完成猪猪存钱罐道具

This commit is contained in:
小李xl 2024-03-18 01:32:27 +08:00
parent 059753b9ab
commit 6649e3220e
18 changed files with 247 additions and 27 deletions

View File

@ -34,5 +34,20 @@
"CooldownTime": 0,
"IsConsumables": true,
"MaxCount": 10
},
{
"Id": "0003",
"Remark": "\u732A\u732A\u5B58\u94B1\u7F50",
"__Activity": "prop5002",
"Buff": null,
"Condition": null,
"Effect": {
"PiggyBank": [
2
]
},
"CooldownTime": 0,
"IsConsumables": true,
"MaxCount": 1
}
]

View File

@ -671,6 +671,20 @@
"Icon": "res://resource/sprite/prop/active/ActiveProp5001.png",
"ShowInMapEditor": true
},
{
"Id": "prop5002",
"Name": "\u732A\u732A\u5B58\u94B1\u7F50",
"Type": 9,
"Quality": 1,
"Price": 0,
"Intro": "",
"Details": "\u62FE\u8D77\u8BE5\u9053\u5177\u540E\u73A9\u5BB6\u6361\u5230\u7684\u6240\u6709\u91D1\u5E01\u5C06\u4F1A\u88AB\u5B58\u5165\u5230\u5B58\u94B1\u7F50\u4E2D, \u4F7F\u7528\u8BE5\u9053\u5177, \u4F1A\u6467\u6BC1\u5B58\u94B1\u7F50, \u5E76\u8FD4\u56DE\u53CC\u500D\u7684\u91D1\u5E01,",
"IsStatic": false,
"__Material": "",
"Prefab": "res://prefab/prop/ActiveProp.tscn",
"Icon": "res://resource/sprite/prop/active/ActiveProp5002.png",
"ShowInMapEditor": true
},
{
"Id": "treasure_box0001",
"Name": "\u6728\u8D28\u5B9D\u7BB1",

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dxffht13og4ag"
path="res://.godot/imported/ActiveProp5002.png-add857fab665afd62103e2bff145b98c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resource/sprite/prop/active/ActiveProp5002.png"
dest_files=["res://.godot/imported/ActiveProp5002.png-add857fab665afd62103e2bff145b98c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -123,7 +123,7 @@ DefaultLayer = 1
ShowOffset = Vector2(2.08165e-12, 2)
CollisionVisible = false
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0006" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0006" index="1"]
position = Vector2(-10, -3)
texture = ExtResource("7_30qwa")
@ -135,7 +135,7 @@ DefaultLayer = 1
ShowOffset = Vector2(2.08165e-12, 2)
CollisionVisible = false
[node name="ActivityInstance" type="Node2D" parent="ItemRoot/Item0008" index="0"]
[node name="ActivityInstance" type="Node2D" parent="ItemRoot/Item0008" index="1"]
position = Vector2(2.5, -12)
script = ExtResource("5_lowqi")
Id = "item_0031"
@ -151,7 +151,7 @@ DefaultLayer = 1
ShowOffset = Vector2(2.08165e-12, 2)
CollisionVisible = false
[node name="Item26" type="Sprite2D" parent="ItemRoot/Item0013" index="0"]
[node name="Item26" type="Sprite2D" parent="ItemRoot/Item0013" index="1"]
position = Vector2(18, -2)
texture = ExtResource("8_61dkg")
@ -163,19 +163,19 @@ DefaultLayer = 1
ShowOffset = Vector2(2.08165e-12, 2)
CollisionVisible = false
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0017" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0017" index="1"]
position = Vector2(-2, -13)
texture = ExtResource("8_u3vry")
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0017" index="1"]
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0017" index="2"]
position = Vector2(18, -11)
texture = ExtResource("9_lhdr8")
[node name="Sprite2D3" type="Sprite2D" parent="ItemRoot/Item0017" index="2"]
[node name="Sprite2D3" type="Sprite2D" parent="ItemRoot/Item0017" index="3"]
position = Vector2(-16, -2)
texture = ExtResource("10_4eqn0")
[node name="Sprite2D4" type="Sprite2D" parent="ItemRoot/Item0017" index="3"]
[node name="Sprite2D4" type="Sprite2D" parent="ItemRoot/Item0017" index="4"]
position = Vector2(10, -1)
texture = ExtResource("11_tg3jo")
@ -201,11 +201,11 @@ Id = "item_0002"
DefaultLayer = 1
CollisionVisible = false
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0002" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0002" index="1"]
position = Vector2(32, -2)
texture = ExtResource("12_agfji")
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0002" index="1"]
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0002" index="2"]
material = SubResource("ShaderMaterial_i7git")
position = Vector2(0, -15)
scale = Vector2(1, -1)
@ -223,7 +223,7 @@ script = ExtResource("5_lowqi")
Id = "item_0004"
DefaultLayer = 1
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0004" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0004" index="1"]
position = Vector2(0, -17)
texture = ExtResource("13_unnpl")
@ -258,15 +258,15 @@ script = ExtResource("5_lowqi")
Id = "item_0009"
DefaultLayer = 1
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0009" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0009" index="1"]
position = Vector2(-24, -10)
texture = ExtResource("15_h7524")
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0009" index="1"]
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0009" index="2"]
position = Vector2(1, -10)
texture = ExtResource("15_h7524")
[node name="Sprite2D3" type="Sprite2D" parent="ItemRoot/Item0009" index="2"]
[node name="Sprite2D3" type="Sprite2D" parent="ItemRoot/Item0009" index="3"]
position = Vector2(37, -10)
texture = ExtResource("15_h7524")
@ -300,7 +300,7 @@ script = ExtResource("5_lowqi")
Id = "item_0015"
DefaultLayer = 1
[node name="Slice04" type="Sprite2D" parent="ItemRoot/Item0015" index="0"]
[node name="Slice04" type="Sprite2D" parent="ItemRoot/Item0015" index="1"]
position = Vector2(16, -9)
texture = ExtResource("15_h7524")
@ -322,11 +322,11 @@ script = ExtResource("5_lowqi")
Id = "item_0019"
DefaultLayer = 1
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0019" index="0"]
[node name="Sprite2D" type="Sprite2D" parent="ItemRoot/Item0019" index="1"]
position = Vector2(-23, -7)
texture = ExtResource("16_xj0e1")
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0019" index="1"]
[node name="Sprite2D2" type="Sprite2D" parent="ItemRoot/Item0019" index="2"]
position = Vector2(24, -8)
texture = ExtResource("17_gwwce")

View File

@ -249,6 +249,11 @@ public partial class ActivityObject
/// </summary>
public const string Id_prop5001 = "prop5001";
/// <summary>
/// 名称: 猪猪存钱罐 <br/>
/// 简介:
/// </summary>
public const string Id_prop5002 = "prop5002";
/// <summary>
/// 名称: 木质宝箱 <br/>
/// 简介: 木质宝箱
/// </summary>

View File

@ -481,6 +481,16 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
buffFragment.OnPickUpItem();
}
foreach (var conditionFragment in _conditionFragment)
{
conditionFragment.OnPickUpItem();
}
foreach (var effectFragment in _effectFragment)
{
effectFragment.OnPickUpItem();
}
}
public override void OnRemoveItem()
@ -489,6 +499,16 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
{
buffFragment.OnRemoveItem();
}
foreach (var conditionFragment in _conditionFragment)
{
conditionFragment.OnRemoveItem();
}
foreach (var effectFragment in _effectFragment)
{
effectFragment.OnRemoveItem();
}
}
public virtual void OnActiveItem()

View File

@ -1296,7 +1296,7 @@ public abstract partial class Role : ActivityObject
/// </summary>
public virtual void AddGold(int goldCount)
{
RoleState.Gold += goldCount;
RoleState.Gold += RoleState.CalcGetGold(goldCount);
//播放音效
SoundManager.PlaySoundByConfig(ExcelConfig.Sound_Map["gold"], Position, this);
}

View File

@ -226,4 +226,20 @@ public class RoleState
return distance;
}
/// <summary>
/// 计算获取的金币
/// </summary>
public event Action<int, RefValue<int>> CalcGetGoldEvent;
public int CalcGetGold(int gold)
{
if (CalcGetGoldEvent != null)
{
var result = new RefValue<int>(gold);
CalcGetGoldEvent(gold, result);
return result.Value;
}
return gold;
}
}

View File

@ -6,13 +6,4 @@ using System;
/// </summary>
public abstract class BuffFragment : PropFragment
{
/// <summary>
/// 当道具被拾起时调用 (在 Master 赋值之后调用)
/// </summary>
public abstract void OnPickUpItem();
/// <summary>
/// 当道具被移除时调用 (在 Master 置为 null 之前调用)
/// </summary>
public abstract void OnRemoveItem();
}

View File

@ -8,4 +8,12 @@ public abstract class ConditionFragment : PropFragment
/// 当检测是否可以使用时调用
/// </summary>
public abstract bool OnCheckUse();
public override void OnPickUpItem()
{
}
public override void OnRemoveItem()
{
}
}

View File

@ -8,4 +8,12 @@ public abstract class EffectFragment : PropFragment
/// 使用道具的回调
/// </summary>
public abstract void OnUse();
public override void OnPickUpItem()
{
}
public override void OnRemoveItem()
{
}
}

View File

@ -9,6 +9,16 @@ public abstract class PropFragment : Component<PropActivity>
/// </summary>
public Role Role => Master?.Master;
/// <summary>
/// 当道具被拾起时调用 (在 Master 赋值之后调用)
/// </summary>
public abstract void OnPickUpItem();
/// <summary>
/// 当道具被移除时调用 (在 Master 置为 null 之前调用)
/// </summary>
public abstract void OnRemoveItem();
/// <summary>
/// 初始化被动属性参数
/// </summary>

View File

@ -0,0 +1,52 @@
using Godot;
[BuffFragment("GetGold", "计算获取的金币buff, " +
"参数1为金币数量添加类型, 1: 具体数量, 2:百分比(小数), " +
"参数2为增加金币的数量值")]
public class Buff_GetGold : BuffFragment
{
private int _type;
private float _value;
public override void InitParam(float arg1, float arg2)
{
_type = (int)arg1;
_value = arg2;
}
public override void OnPickUpItem()
{
if (_type == 1)
{
Role.RoleState.CalcGetGoldEvent += OnCalcGetGoldEvent1;
}
else
{
Role.RoleState.CalcGetGoldEvent += OnCalcGetGoldEvent2;
}
}
public override void OnRemoveItem()
{
if (_type == 1)
{
Role.RoleState.CalcGetGoldEvent -= OnCalcGetGoldEvent1;
}
else
{
Role.RoleState.CalcGetGoldEvent -= OnCalcGetGoldEvent2;
}
}
private void OnCalcGetGoldEvent1(int origin, RefValue<int> refValue)
{
refValue.Value += Mathf.CeilToInt(_value);
}
private void OnCalcGetGoldEvent2(int origin, RefValue<int> refValue)
{
refValue.Value += Mathf.CeilToInt(origin * _value);
}
}

View File

@ -0,0 +1,47 @@
using Godot;
[EffectFragment("PiggyBank", "存钱罐, 使用后返还存入的金币, 参数1为返还金币的倍率(小数)")]
public class Eff_PiggyBank : EffectFragment
{
private float _value;
//当前存入的金币数量
private float _currValue;
public override void InitParam(float arg1)
{
_value = arg1;
}
public override void OnUse()
{
Debug.Log("存入了: " + _currValue);
var goldList = Utils.GetGoldList(Mathf.FloorToInt(_currValue * _value));
foreach (var id in goldList)
{
var o = ObjectManager.GetActivityObject<Gold>(id);
o.Position = Role.Position;
o.Throw(0,
Utils.Random.RandomRangeInt(50, 110),
new Vector2(Utils.Random.RandomRangeInt(-20, 20), Utils.Random.RandomRangeInt(-20, 20)),
0
);
}
}
public override void OnPickUpItem()
{
Role.RoleState.CalcGetGoldEvent += OnCalcGetGoldEvent;
}
public override void OnRemoveItem()
{
Role.RoleState.CalcGetGoldEvent -= OnCalcGetGoldEvent;
}
private void OnCalcGetGoldEvent(int origin, RefValue<int> refValue)
{
_currValue += refValue.Value;
refValue.Value = 0;
}
}