Merge branch 'develop' of https://gitee.com/xlljc/DungeonShooting into develop
# Conflicts: # DungeonShooting_Godot/scene/Hall.tscn
|
@ -0,0 +1,31 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bb7xvumnivsho"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/game/buffComp/active/Prop5003Area.cs" id="1_nxrjx"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_41obf"]
|
||||
colors = PackedColorArray(1, 0, 0, 0.392157, 1, 0, 0, 0)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_ih8qw"]
|
||||
gradient = SubResource("Gradient_41obf")
|
||||
width = 128
|
||||
height = 128
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.5)
|
||||
fill_to = Vector2(1, 0.5)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_1llif"]
|
||||
radius = 15.0333
|
||||
|
||||
[node name="Prop5003Area" type="Area2D" node_paths=PackedStringArray("CircleSprite", "Collision")]
|
||||
collision_layer = 0
|
||||
collision_mask = 4
|
||||
monitorable = false
|
||||
script = ExtResource("1_nxrjx")
|
||||
CircleSprite = NodePath("Circle")
|
||||
Collision = NodePath("CollisionShape2D")
|
||||
|
||||
[node name="Circle" type="Sprite2D" parent="."]
|
||||
texture = SubResource("GradientTexture2D_ih8qw")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_1llif")
|
|
@ -14,7 +14,9 @@
|
|||
2
|
||||
]
|
||||
},
|
||||
"CooldownTime": 0,
|
||||
"Charge": null,
|
||||
"Duration": 0,
|
||||
"CooldownTime": 2,
|
||||
"IsConsumables": true,
|
||||
"MaxCount": 10
|
||||
},
|
||||
|
@ -31,8 +33,48 @@
|
|||
"Effect": {
|
||||
"TotalAmmo": []
|
||||
},
|
||||
"CooldownTime": 0,
|
||||
"Charge": null,
|
||||
"Duration": 0,
|
||||
"CooldownTime": 2,
|
||||
"IsConsumables": true,
|
||||
"MaxCount": 10
|
||||
},
|
||||
{
|
||||
"Id": "0003",
|
||||
"Remark": "\u732A\u732A\u5B58\u94B1\u7F50",
|
||||
"__Activity": "prop5002",
|
||||
"Buff": null,
|
||||
"Condition": null,
|
||||
"Effect": {
|
||||
"PiggyBank": [
|
||||
2
|
||||
]
|
||||
},
|
||||
"Charge": null,
|
||||
"Duration": 0,
|
||||
"CooldownTime": 0,
|
||||
"IsConsumables": true,
|
||||
"MaxCount": 1
|
||||
},
|
||||
{
|
||||
"Id": "0004",
|
||||
"Remark": "\u7EA2\u5916\u9065\u63A7\u5668",
|
||||
"__Activity": "prop5003",
|
||||
"Buff": null,
|
||||
"Condition": null,
|
||||
"Effect": {
|
||||
"AreaTrigger": [
|
||||
200
|
||||
]
|
||||
},
|
||||
"Charge": {
|
||||
"Hurt": [
|
||||
250
|
||||
]
|
||||
},
|
||||
"Duration": 6,
|
||||
"CooldownTime": 0,
|
||||
"IsConsumables": false,
|
||||
"MaxCount": 1
|
||||
}
|
||||
]
|
|
@ -671,6 +671,34 @@
|
|||
"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": "\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",
|
||||
"Details": "",
|
||||
"IsStatic": false,
|
||||
"__Material": "",
|
||||
"Prefab": "res://prefab/prop/ActiveProp.tscn",
|
||||
"Icon": "res://resource/sprite/prop/active/ActiveProp5002.png",
|
||||
"ShowInMapEditor": true
|
||||
},
|
||||
{
|
||||
"Id": "prop5003",
|
||||
"Name": "\u7EA2\u5916\u9065\u63A7\u5668",
|
||||
"Type": 9,
|
||||
"Quality": 1,
|
||||
"Price": 0,
|
||||
"Intro": "\u4F7F\u7528\u540E\u4F1A\u89E6\u53D1\u9644\u8FD1\u5730\u4E0A\u7684\u6B66\u5668\u5F00\u706B",
|
||||
"Details": "",
|
||||
"IsStatic": false,
|
||||
"__Material": "",
|
||||
"Prefab": "res://prefab/prop/ActiveProp.tscn",
|
||||
"Icon": "res://resource/sprite/prop/active/ActiveProp5003.png",
|
||||
"ShowInMapEditor": true
|
||||
},
|
||||
{
|
||||
"Id": "treasure_box0001",
|
||||
"Name": "\u6728\u8D28\u5B9D\u7BB1",
|
||||
|
|
|
@ -1714,7 +1714,7 @@
|
|||
"CameraShake": 2,
|
||||
"BacklashRange": [
|
||||
1,
|
||||
1
|
||||
2
|
||||
],
|
||||
"BacklashRegressionSpeed": 35,
|
||||
"UpliftAngle": 3,
|
||||
|
@ -1790,7 +1790,7 @@
|
|||
"CameraShake": 2,
|
||||
"BacklashRange": [
|
||||
1,
|
||||
1
|
||||
2
|
||||
],
|
||||
"BacklashRegressionSpeed": 35,
|
||||
"UpliftAngle": 3,
|
||||
|
|
Before Width: | Height: | Size: 105 B After Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 83 B After Width: | Height: | Size: 83 B |
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
After Width: | Height: | Size: 314 B |
|
@ -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
|
After Width: | Height: | Size: 424 B |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cjf00ob376y3e"
|
||||
path="res://.godot/imported/ActiveProp5003.png-26abcb759a746b5ad719977590650d45.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://resource/sprite/prop/active/ActiveProp5003.png"
|
||||
dest_files=["res://.godot/imported/ActiveProp5003.png-26abcb759a746b5ad719977590650d45.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
|
|
@ -49,6 +49,22 @@ public static partial class ExcelConfig
|
|||
[JsonInclude]
|
||||
public Dictionary<string, float[]> Effect;
|
||||
|
||||
/// <summary>
|
||||
/// 道具充能效果 <br/>
|
||||
/// 参数配置方式与buff字段相同 <br/>
|
||||
/// 性名称请参阅charge属性表 <br/>
|
||||
/// 注意: 仅当'IsConsumables'为false是生效
|
||||
/// </summary>
|
||||
[JsonInclude]
|
||||
public Dictionary<string, float[]> Charge;
|
||||
|
||||
/// <summary>
|
||||
/// 使用道具的效果持续时间 <br/>
|
||||
/// 单位: 秒
|
||||
/// </summary>
|
||||
[JsonInclude]
|
||||
public float Duration;
|
||||
|
||||
/// <summary>
|
||||
/// 使用一次后的冷却时间 <br/>
|
||||
/// 单位: 秒
|
||||
|
@ -63,7 +79,7 @@ public static partial class ExcelConfig
|
|||
public bool IsConsumables;
|
||||
|
||||
/// <summary>
|
||||
/// 最大叠加次数, 仅当IsConsumables为true时有效
|
||||
/// 最大叠加次数, 仅当'IsConsumables'为true时有效
|
||||
/// </summary>
|
||||
[JsonInclude]
|
||||
public uint MaxCount;
|
||||
|
@ -80,6 +96,8 @@ public static partial class ExcelConfig
|
|||
inst.Buff = Buff;
|
||||
inst.Condition = Condition;
|
||||
inst.Effect = Effect;
|
||||
inst.Charge = Charge;
|
||||
inst.Duration = Duration;
|
||||
inst.CooldownTime = CooldownTime;
|
||||
inst.IsConsumables = IsConsumables;
|
||||
inst.MaxCount = MaxCount;
|
||||
|
|
|
@ -1043,42 +1043,11 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
}
|
||||
#endif
|
||||
var newDelta = (float)delta;
|
||||
if (EnableCustomBehavior)
|
||||
{
|
||||
Process(newDelta);
|
||||
}
|
||||
UpdateProcess(newDelta);
|
||||
|
||||
//更新组件
|
||||
if (_components.Count > 0)
|
||||
{
|
||||
_updatingComp = true;
|
||||
if (EnableCustomBehavior) //启用所有组件
|
||||
{
|
||||
for (int i = 0; i < _components.Count; i++)
|
||||
{
|
||||
if (IsDestroyed) return;
|
||||
var temp = _components[i].Value;
|
||||
if (temp != null && temp.Enable)
|
||||
{
|
||||
temp.Process(newDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //只更新 MoveController 组件
|
||||
{
|
||||
if (MoveController.Enable)
|
||||
{
|
||||
MoveController.Process(newDelta);
|
||||
}
|
||||
}
|
||||
_updatingComp = false;
|
||||
|
||||
if (_changeComponents.Count > 0)
|
||||
{
|
||||
RefreshComponent();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateComponentProcess(newDelta);
|
||||
|
||||
// 更新下坠处理逻辑
|
||||
UpdateFall(newDelta);
|
||||
|
||||
|
@ -1109,7 +1078,7 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
}
|
||||
|
||||
//协程更新
|
||||
ProxyCoroutineHandler.ProxyUpdateCoroutine(ref _coroutineList, newDelta);
|
||||
UpdateCoroutine(newDelta);
|
||||
|
||||
//调试绘制
|
||||
if (IsDebug)
|
||||
|
@ -1118,6 +1087,110 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发调用 Process() 函数
|
||||
/// </summary>
|
||||
public void UpdateProcess(float delta)
|
||||
{
|
||||
if (EnableCustomBehavior)
|
||||
{
|
||||
Process(delta);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发调用 PhysicsProcess() 函数
|
||||
/// </summary>
|
||||
public void UpdatePhysicsProcess(float delta)
|
||||
{
|
||||
if (EnableCustomBehavior)
|
||||
{
|
||||
PhysicsProcess(delta);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新组件
|
||||
/// </summary>
|
||||
public void UpdateComponentProcess(float delta)
|
||||
{
|
||||
//更新组件
|
||||
if (_components.Count > 0)
|
||||
{
|
||||
_updatingComp = true;
|
||||
if (EnableCustomBehavior) //启用所有组件
|
||||
{
|
||||
for (int i = 0; i < _components.Count; i++)
|
||||
{
|
||||
if (IsDestroyed) return;
|
||||
var temp = _components[i].Value;
|
||||
if (temp != null && temp.Enable)
|
||||
{
|
||||
temp.Process(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //只更新 MoveController 组件
|
||||
{
|
||||
if (MoveController.Enable)
|
||||
{
|
||||
MoveController.Process(delta);
|
||||
}
|
||||
}
|
||||
_updatingComp = false;
|
||||
|
||||
if (_changeComponents.Count > 0)
|
||||
{
|
||||
RefreshComponent();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 物理帧更新组件
|
||||
/// </summary>
|
||||
public void UpdateComponentPhysicsProcess(float delta)
|
||||
{
|
||||
if (_components.Count > 0)
|
||||
{
|
||||
_updatingComp = true;
|
||||
if (EnableCustomBehavior) //启用所有组件
|
||||
{
|
||||
for (int i = 0; i < _components.Count; i++)
|
||||
{
|
||||
if (IsDestroyed) return;
|
||||
var temp = _components[i].Value;
|
||||
if (temp != null && temp.Enable)
|
||||
{
|
||||
temp.PhysicsProcess(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //只更新 MoveController 组件
|
||||
{
|
||||
if (MoveController.Enable)
|
||||
{
|
||||
MoveController.PhysicsProcess(delta);
|
||||
}
|
||||
}
|
||||
_updatingComp = false;
|
||||
|
||||
if (_changeComponents.Count > 0)
|
||||
{
|
||||
RefreshComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新协程
|
||||
/// </summary>
|
||||
public void UpdateCoroutine(float delta)
|
||||
{
|
||||
ProxyCoroutineHandler.ProxyUpdateCoroutine(ref _coroutineList, delta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新下坠处理逻辑
|
||||
/// </summary>
|
||||
|
@ -1275,41 +1348,10 @@ public partial class ActivityObject : CharacterBody2D, IDestroy, ICoroutine
|
|||
}
|
||||
#endif
|
||||
var newDelta = (float)delta;
|
||||
if (EnableCustomBehavior)
|
||||
{
|
||||
PhysicsProcess(newDelta);
|
||||
}
|
||||
UpdatePhysicsProcess(newDelta);
|
||||
|
||||
//更新组件
|
||||
if (_components.Count > 0)
|
||||
{
|
||||
_updatingComp = true;
|
||||
if (EnableCustomBehavior) //启用所有组件
|
||||
{
|
||||
for (int i = 0; i < _components.Count; i++)
|
||||
{
|
||||
if (IsDestroyed) return;
|
||||
var temp = _components[i].Value;
|
||||
if (temp != null && temp.Enable)
|
||||
{
|
||||
temp.PhysicsProcess(newDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
else //只更新 MoveController 组件
|
||||
{
|
||||
if (MoveController.Enable)
|
||||
{
|
||||
MoveController.PhysicsProcess(newDelta);
|
||||
}
|
||||
}
|
||||
_updatingComp = false;
|
||||
|
||||
if (_changeComponents.Count > 0)
|
||||
{
|
||||
RefreshComponent();
|
||||
}
|
||||
}
|
||||
UpdateComponentPhysicsProcess(newDelta);
|
||||
}
|
||||
|
||||
//更新新增/移除的组件
|
||||
|
|
|
@ -249,6 +249,16 @@ public partial class ActivityObject
|
|||
/// </summary>
|
||||
public const string Id_prop5001 = "prop5001";
|
||||
/// <summary>
|
||||
/// 名称: 猪猪存钱罐 <br/>
|
||||
/// 简介: 拾起该道具后玩家捡到的所有金币将会被存入到存钱罐中, 使用该道具, 会摧毁存钱罐, 并返回双倍的金币
|
||||
/// </summary>
|
||||
public const string Id_prop5002 = "prop5002";
|
||||
/// <summary>
|
||||
/// 名称: 红外遥控器 <br/>
|
||||
/// 简介: 使用后会触发附近地上的武器开火
|
||||
/// </summary>
|
||||
public const string Id_prop5003 = "prop5003";
|
||||
/// <summary>
|
||||
/// 名称: 木质宝箱 <br/>
|
||||
/// 简介: 木质宝箱
|
||||
/// </summary>
|
||||
|
|
|
@ -84,8 +84,20 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
/// </summary>
|
||||
public float AutoChargeSpeed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否正使用中
|
||||
/// </summary>
|
||||
public bool IsUsing => _durationTimer > 0;
|
||||
|
||||
/// <summary>
|
||||
/// 道具使用时间进度 (0 - 1)
|
||||
/// </summary>
|
||||
public float UsingProgress => 1 - _durationTimer / Attribute.Duration;
|
||||
|
||||
//冷却计时器
|
||||
private float _cooldownTimer = 0;
|
||||
//持续时间计时器
|
||||
private float _durationTimer = 0;
|
||||
|
||||
//被动属性
|
||||
private readonly List<BuffFragment> _buffFragment = new List<BuffFragment>();
|
||||
|
@ -93,6 +105,8 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
private readonly List<ConditionFragment> _conditionFragment = new List<ConditionFragment>();
|
||||
//效果
|
||||
private readonly List<EffectFragment> _effectFragment = new List<EffectFragment>();
|
||||
//充能
|
||||
private readonly List<ChargeFragment> _chargeFragment = new List<ChargeFragment>();
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
|
@ -241,6 +255,53 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
}
|
||||
}
|
||||
|
||||
//初始化道具冷却属性数据
|
||||
if (!buffAttribute.IsConsumables && buffAttribute.Charge != null)
|
||||
{
|
||||
foreach (var keyValuePair in buffAttribute.Charge)
|
||||
{
|
||||
var buffInfo = PropFragmentRegister.ChargeFragmentInfos[keyValuePair.Key];
|
||||
var item = keyValuePair.Value;
|
||||
switch (item.Length)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
|
||||
_chargeFragment.Add(buff);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
|
||||
buff.InitParam(item[0]);
|
||||
_chargeFragment.Add(buff);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
|
||||
buff.InitParam(item[0], item[1]);
|
||||
_chargeFragment.Add(buff);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
|
||||
buff.InitParam(item[0], item[1], item[2]);
|
||||
_chargeFragment.Add(buff);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
var buff = (ChargeFragment)AddComponent(buffInfo.Type);
|
||||
buff.InitParam(item[0], item[1], item[2], item[3]);
|
||||
_chargeFragment.Add(buff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//显示纹理
|
||||
if (!string.IsNullOrEmpty(ActivityBase.Icon))
|
||||
{
|
||||
|
@ -259,6 +320,11 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
{
|
||||
if (!fragment.OnCheckUse()) return false;
|
||||
}
|
||||
|
||||
foreach (var fragment in _effectFragment)
|
||||
{
|
||||
if (!fragment.OnCheckUse()) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -272,6 +338,19 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
{
|
||||
fragment.OnUse();
|
||||
}
|
||||
|
||||
foreach (var fragment in _chargeFragment)
|
||||
{
|
||||
fragment.OnUse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 道具使用持续时间完成时调用
|
||||
/// </summary>
|
||||
protected virtual void OnUsingFinish()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -303,23 +382,28 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
}
|
||||
|
||||
protected override void Process(float delta)
|
||||
{
|
||||
RunUpdate(delta);
|
||||
}
|
||||
|
||||
public override void PackProcess(float delta)
|
||||
{
|
||||
RunUpdate(delta);
|
||||
}
|
||||
|
||||
private void RunUpdate(float delta)
|
||||
{
|
||||
if (CheckAutoDestroy())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//持续时间
|
||||
if (_durationTimer > 0)
|
||||
{
|
||||
_durationTimer -= delta;
|
||||
|
||||
//持续时间完成
|
||||
if (_durationTimer <= 0)
|
||||
{
|
||||
_durationTimer = 0;
|
||||
//冷却计时器
|
||||
_cooldownTimer = Attribute.CooldownTime;
|
||||
UsingFinish();
|
||||
}
|
||||
}
|
||||
//冷却
|
||||
if (_cooldownTimer > 0)
|
||||
else if (_cooldownTimer > 0)
|
||||
{
|
||||
_cooldownTimer -= delta;
|
||||
|
||||
|
@ -337,7 +421,7 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
ChargeProgress += AutoChargeSpeed * delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//检测是否达到自动销毁的条件
|
||||
private bool CheckAutoDestroy()
|
||||
{
|
||||
|
@ -367,7 +451,7 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
/// </summary>
|
||||
public void Use()
|
||||
{
|
||||
if (Master == null)
|
||||
if (Master == null || IsUsing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -379,8 +463,16 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
Count -= 1;
|
||||
}
|
||||
|
||||
//冷却计时器
|
||||
_cooldownTimer = Attribute.CooldownTime;
|
||||
if (Attribute.Duration > 0) //持续时间
|
||||
{
|
||||
_durationTimer = Attribute.Duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
//冷却计时器
|
||||
_cooldownTimer = Attribute.CooldownTime;
|
||||
UsingFinish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,6 +573,21 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
{
|
||||
buffFragment.OnPickUpItem();
|
||||
}
|
||||
|
||||
foreach (var conditionFragment in _conditionFragment)
|
||||
{
|
||||
conditionFragment.OnPickUpItem();
|
||||
}
|
||||
|
||||
foreach (var effectFragment in _effectFragment)
|
||||
{
|
||||
effectFragment.OnPickUpItem();
|
||||
}
|
||||
|
||||
foreach (var chargeFragment in _chargeFragment)
|
||||
{
|
||||
chargeFragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
|
@ -489,6 +596,21 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
{
|
||||
buffFragment.OnRemoveItem();
|
||||
}
|
||||
|
||||
foreach (var conditionFragment in _conditionFragment)
|
||||
{
|
||||
conditionFragment.OnRemoveItem();
|
||||
}
|
||||
|
||||
foreach (var effectFragment in _effectFragment)
|
||||
{
|
||||
effectFragment.OnRemoveItem();
|
||||
}
|
||||
|
||||
foreach (var chargeFragment in _chargeFragment)
|
||||
{
|
||||
chargeFragment.OnRemoveItem();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnActiveItem()
|
||||
|
@ -573,6 +695,22 @@ public partial class ActiveProp : PropActivity, IPackageItem<Role>
|
|||
fragment.OnPickUpItem();
|
||||
}
|
||||
}
|
||||
|
||||
//持续时间完成
|
||||
private void UsingFinish()
|
||||
{
|
||||
OnUsingFinish();
|
||||
|
||||
foreach (var effectFragment in _effectFragment)
|
||||
{
|
||||
effectFragment.OnUsingFinish();
|
||||
}
|
||||
|
||||
foreach (var chargeFragment in _chargeFragment)
|
||||
{
|
||||
chargeFragment.OnUsingFinish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static bool _init = false;
|
||||
|
|
|
@ -26,13 +26,6 @@ public abstract partial class PropActivity : ActivityObject
|
|||
ThrowCollisionMask = PhysicsLayer.Wall;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果道具放入了角色背包中, 则每帧调用
|
||||
/// </summary>
|
||||
public virtual void PackProcess(float delta)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发扔掉道具效果, 并不会管道具是否在道具背包中
|
||||
/// </summary>
|
||||
|
|
|
@ -611,12 +611,15 @@ public abstract partial class Role : ActivityObject
|
|||
//被动道具更新
|
||||
if (BuffPropPack.Count > 0)
|
||||
{
|
||||
var buffProps = BuffPropPack.ToArray();
|
||||
foreach (var prop in buffProps)
|
||||
var buffProps = BuffPropPack;
|
||||
for (var i = 0; i < buffProps.Count; i++)
|
||||
{
|
||||
if (!prop.IsDestroyed)
|
||||
var prop = buffProps[i];
|
||||
if (!prop.IsDestroyed && prop.Master != null)
|
||||
{
|
||||
prop.PackProcess(delta);
|
||||
prop.UpdateProcess(delta);
|
||||
prop.UpdateComponentProcess(delta);
|
||||
prop.UpdateCoroutine(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -625,12 +628,14 @@ public abstract partial class Role : ActivityObject
|
|||
var props = ActivePropsPack.ItemSlot;
|
||||
if (props.Length > 0)
|
||||
{
|
||||
props = (ActiveProp[])props.Clone();
|
||||
foreach (var prop in props)
|
||||
for (var i = 0; i < props.Length; i++)
|
||||
{
|
||||
if (prop != null && !prop.IsDestroyed)
|
||||
var prop = props[i];
|
||||
if (prop != null && !prop.IsDestroyed && prop.Master != null)
|
||||
{
|
||||
prop.PackProcess(delta);
|
||||
prop.UpdateProcess(delta);
|
||||
prop.UpdateComponentProcess(delta);
|
||||
prop.UpdateCoroutine(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,7 +649,40 @@ public abstract partial class Role : ActivityObject
|
|||
TipRoot.Scale = new Vector2(-1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void PhysicsProcess(float delta)
|
||||
{
|
||||
//被动道具更新
|
||||
if (BuffPropPack.Count > 0)
|
||||
{
|
||||
var buffProps = BuffPropPack;
|
||||
for (var i = 0; i < buffProps.Count; i++)
|
||||
{
|
||||
var prop = buffProps[i];
|
||||
if (!prop.IsDestroyed && prop.Master != null)
|
||||
{
|
||||
prop.UpdatePhysicsProcess(delta);
|
||||
prop.UpdateComponentPhysicsProcess(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//主动道具调用更新
|
||||
var props = ActivePropsPack.ItemSlot;
|
||||
if (props.Length > 0)
|
||||
{
|
||||
for (var i = 0; i < props.Length; i++)
|
||||
{
|
||||
var prop = props[i];
|
||||
if (prop != null && !prop.IsDestroyed && prop.Master != null)
|
||||
{
|
||||
prop.UpdatePhysicsProcess(delta);
|
||||
prop.UpdateComponentPhysicsProcess(delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化瞄准辅助线
|
||||
/// </summary>
|
||||
|
@ -687,6 +725,7 @@ public abstract partial class Role : ActivityObject
|
|||
{
|
||||
if (ActivePropsPack.PickupItem(activeProp, exchange) != -1)
|
||||
{
|
||||
activeProp.MoveController.Enable = false;
|
||||
//从可互动队列中移除
|
||||
InteractiveItemList.Remove(activeProp);
|
||||
OnPickUpActiveProp(activeProp);
|
||||
|
@ -715,6 +754,7 @@ public abstract partial class Role : ActivityObject
|
|||
return;
|
||||
}
|
||||
|
||||
activeProp.MoveController.Enable = true;
|
||||
ActivePropsPack.RemoveItem(index);
|
||||
OnRemoveActiveProp(activeProp);
|
||||
//播放抛出效果
|
||||
|
@ -1296,7 +1336,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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -161,6 +161,9 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
//触发板机是是否计算弹药消耗
|
||||
private bool _triggerCalcAmmon = true;
|
||||
|
||||
//用于记录是否有角色操作过这把武器
|
||||
private bool _triggerRoleFlag = false;
|
||||
|
||||
|
@ -254,6 +257,9 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
|
||||
//抖动计时器
|
||||
private float _shakeTimer = 0;
|
||||
|
||||
//换弹完成后播放的动画
|
||||
private string _reloadNextAnimation;
|
||||
|
||||
// ----------------------------------------------
|
||||
private uint _tempLayer;
|
||||
|
@ -801,11 +807,31 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
return Master == null && GetParent() == World.Current.NormalLayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除触发角色开火标记数据
|
||||
/// </summary>
|
||||
public void ClearTriggerRole()
|
||||
{
|
||||
_triggerRoleFlag = false;
|
||||
if (Master == null)
|
||||
{
|
||||
if (Reloading)
|
||||
{
|
||||
_reloadNextAnimation = AnimatorNames.Floodlight;
|
||||
}
|
||||
else
|
||||
{
|
||||
AnimationPlayer.Play(AnimatorNames.Floodlight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扳机函数, 调用即视为按下扳机
|
||||
/// </summary>
|
||||
/// <param name="triggerRole">按下扳机的角色, 如果传 null, 则视为走火</param>
|
||||
public void Trigger(Role triggerRole)
|
||||
/// <param name="calcAmmo">是否计算弹药消耗</param>
|
||||
public void Trigger(Role triggerRole, bool calcAmmo = true)
|
||||
{
|
||||
//不能触发扳机
|
||||
if (!NoMasterCanTrigger && Master == null) return;
|
||||
|
@ -815,7 +841,12 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
|
||||
//更新武器属性信息
|
||||
_triggerFlag = true;
|
||||
if (!_triggerRoleFlag && AnimationPlayer.CurrentAnimation == AnimatorNames.Floodlight)
|
||||
{
|
||||
AnimationPlayer.Play(AnimatorNames.Reset);
|
||||
}
|
||||
_triggerRoleFlag = true;
|
||||
_triggerCalcAmmon = calcAmmo;
|
||||
if (triggerRole != null)
|
||||
{
|
||||
TriggerRole = triggerRole;
|
||||
|
@ -1098,18 +1129,27 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
_reloadShellFlag = false;
|
||||
|
||||
//减子弹数量
|
||||
if (_playerWeaponAttribute != _weaponAttribute) //Ai使用该武器, 有一定概率不消耗弹药
|
||||
if (_triggerCalcAmmon)
|
||||
{
|
||||
if (_playerWeaponAttribute != _weaponAttribute) //Ai使用该武器, 有一定概率不消耗弹药
|
||||
{
|
||||
var count = UseAmmoCount();
|
||||
CurrAmmo -= count;
|
||||
if (Utils.Random.RandomRangeFloat(0, 1) >= _weaponAttribute.AiAttackAttr.AmmoConsumptionProbability) //不消耗弹药
|
||||
{
|
||||
ResidueAmmo += count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrAmmo -= UseAmmoCount();
|
||||
}
|
||||
}
|
||||
else //不消耗弹药
|
||||
{
|
||||
var count = UseAmmoCount();
|
||||
CurrAmmo -= count;
|
||||
if (Utils.Random.RandomRangeFloat(0, 1) >= _weaponAttribute.AiAttackAttr.AmmoConsumptionProbability) //不消耗弹药
|
||||
{
|
||||
ResidueAmmo += count;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrAmmo -= UseAmmoCount();
|
||||
ResidueAmmo += count;
|
||||
}
|
||||
|
||||
if (CurrAmmo == 0)
|
||||
|
@ -1195,9 +1235,9 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
}
|
||||
else //在地上
|
||||
{
|
||||
var v = Utils.Random.RandomConfigRange(Attribute.BacklashRange) * 5;
|
||||
var v = Utils.Random.RandomConfigRange(Attribute.BacklashRange) * 15;
|
||||
var externalForce = MoveController.AddForce(new Vector2(-v, 0).Rotated(Rotation));
|
||||
externalForce.RotationSpeed = -Mathf.DegToRad(40);
|
||||
externalForce.RotationSpeed = -Mathf.DegToRad(50);
|
||||
externalForce.RotationResistance = Mathf.DegToRad(80);
|
||||
}
|
||||
|
||||
|
@ -1584,6 +1624,11 @@ public abstract partial class Weapon : ActivityObject, IPackageItem<Role>
|
|||
private void ReloadFinishHandler()
|
||||
{
|
||||
// Debug.Log("装弹完成.");
|
||||
if (_reloadNextAnimation != null)
|
||||
{
|
||||
AnimationPlayer.Play(_reloadNextAnimation);
|
||||
_reloadNextAnimation = null;
|
||||
}
|
||||
OnReloadFinish();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public partial class Bow : Weapon
|
|||
|
||||
protected override void OnFire()
|
||||
{
|
||||
if (Master.IsPlayer())
|
||||
if (TriggerRole != null && TriggerRole.IsPlayer())
|
||||
{
|
||||
//创建抖动
|
||||
GameCamera.Main.DirectionalShake(Vector2.Right.Rotated(GlobalRotation) * Attribute.CameraShake);
|
||||
|
|
|
@ -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();
|
||||
}
|
31
DungeonShooting_Godot/src/game/buff/ChargeFragment.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
/// <summary>
|
||||
/// 主动道具充能基类
|
||||
/// </summary>
|
||||
public abstract class ChargeFragment : PropFragment
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前组件所挂载的游戏对象
|
||||
/// </summary>
|
||||
public new ActiveProp Master => (ActiveProp)base.Master;
|
||||
|
||||
/// <summary>
|
||||
/// 当道具被使用是调用
|
||||
/// </summary>
|
||||
public abstract void OnUse();
|
||||
|
||||
/// <summary>
|
||||
/// 道具持续时间完成时调用
|
||||
/// </summary>
|
||||
public virtual void OnUsingFinish()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class)]
|
||||
public class ChargeFragmentAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 充能属性名称
|
||||
/// </summary>
|
||||
public string ChargeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
public ChargeFragmentAttribute(string chargeName, string description)
|
||||
{
|
||||
ChargeName = chargeName;
|
||||
Description = description;
|
||||
}
|
||||
}
|
|
@ -4,8 +4,21 @@
|
|||
/// </summary>
|
||||
public abstract class ConditionFragment : PropFragment
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前组件所挂载的游戏对象
|
||||
/// </summary>
|
||||
public new ActiveProp Master => (ActiveProp)base.Master;
|
||||
|
||||
/// <summary>
|
||||
/// 当检测是否可以使用时调用
|
||||
/// </summary>
|
||||
public abstract bool OnCheckUse();
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -4,8 +4,44 @@
|
|||
/// </summary>
|
||||
public abstract class EffectFragment : PropFragment
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前组件所挂载的游戏对象
|
||||
/// </summary>
|
||||
public new ActiveProp Master => (ActiveProp)base.Master;
|
||||
|
||||
/// <summary>
|
||||
/// 当检测是否可以使用时调用
|
||||
/// </summary>
|
||||
public virtual bool OnCheckUse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用道具的回调
|
||||
/// </summary>
|
||||
public abstract void OnUse();
|
||||
|
||||
/// <summary>
|
||||
/// 道具持续时间完成时调用
|
||||
/// </summary>
|
||||
public virtual void OnUsingFinish()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回是否正在使用当前道具
|
||||
/// </summary>
|
||||
public bool IsActive()
|
||||
{
|
||||
return Role != null && Role.ActivePropsPack.ActiveItem == Master;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,24 @@ public abstract class PropFragment : Component<PropActivity>
|
|||
/// </summary>
|
||||
public Role Role => Master?.Master;
|
||||
|
||||
/// <summary>
|
||||
/// 当道具被拾起时调用 (在 Role 赋值之后调用)
|
||||
/// </summary>
|
||||
public abstract void OnPickUpItem();
|
||||
|
||||
/// <summary>
|
||||
/// 当道具被移除时调用 (在 Role 置为 null 之前调用)
|
||||
/// </summary>
|
||||
public abstract void OnRemoveItem();
|
||||
|
||||
/// <summary>
|
||||
/// 返回道具是否在背包中
|
||||
/// </summary>
|
||||
public bool IsInPackage()
|
||||
{
|
||||
return Master != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化被动属性参数
|
||||
/// </summary>
|
||||
|
|
52
DungeonShooting_Godot/src/game/buff/buff/Buff_GetGold.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
49
DungeonShooting_Godot/src/game/buff/charge/Cha_Hurt.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
[ChargeFragment("Hurt",
|
||||
"造成伤害充能, 参数1为充满能量需要造成的伤害值")]
|
||||
public class Cha_Hurt : ChargeFragment
|
||||
{
|
||||
private int _value = 100;
|
||||
|
||||
public override void InitParam(float arg1)
|
||||
{
|
||||
_value = (int)arg1;
|
||||
}
|
||||
|
||||
public override void OnUse()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Process(float delta)
|
||||
{
|
||||
if (Master.IsUsing)
|
||||
{
|
||||
Master.ChargeProgress = 1 - Master.UsingProgress;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnUsingFinish()
|
||||
{
|
||||
Master.ChargeProgress = 0;
|
||||
}
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
Role.OnDamageEvent += OnDamageEvent;
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
Role.OnDamageEvent -= OnDamageEvent;
|
||||
}
|
||||
|
||||
private void OnDamageEvent(Role role, int value)
|
||||
{
|
||||
if (Master.IsUsing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Master.ChargeProgress += 1f / _value * value;
|
||||
}
|
||||
}
|
124
DungeonShooting_Godot/src/game/buff/effect/Eff_AreaTrigger.cs
Normal file
|
@ -0,0 +1,124 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
[EffectFragment("AreaTrigger",
|
||||
"触发附近地上的武器开火, " +
|
||||
"参数1为最大作用半径, ")]
|
||||
public class Eff_AreaTrigger : EffectFragment
|
||||
{
|
||||
private Prop5003Area _areaNode;
|
||||
private List<Weapon> _weaponList = new List<Weapon>();
|
||||
private float _time = 0;
|
||||
|
||||
private int _radius = 250;
|
||||
|
||||
public override void InitParam(float arg1)
|
||||
{
|
||||
_radius = (int)arg1;
|
||||
}
|
||||
|
||||
public override void Ready()
|
||||
{
|
||||
_areaNode = ResourceManager.LoadAndInstantiate<Prop5003Area>(ResourcePath.prefab_prop_activeComp_Prop5003_Area_tscn);
|
||||
_areaNode.BodyEntered += OnBodyEntered;
|
||||
_areaNode.BodyExited += OnBodyExited;
|
||||
AddChild(_areaNode);
|
||||
}
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
_areaNode.QueueFree();
|
||||
}
|
||||
|
||||
public override void OnUse()
|
||||
{
|
||||
_areaNode.PlayEffect(0, _radius, Master.Attribute.Duration);
|
||||
}
|
||||
|
||||
public override void OnUsingFinish()
|
||||
{
|
||||
foreach (var weapon in _weaponList)
|
||||
{
|
||||
weapon.ClearTriggerRole();
|
||||
}
|
||||
_weaponList.Clear();
|
||||
}
|
||||
|
||||
public override void Process(float delta)
|
||||
{
|
||||
if (!Master.IsUsing)
|
||||
{
|
||||
_time = 0;
|
||||
return;
|
||||
}
|
||||
_time += delta;
|
||||
var flag = false;
|
||||
if (_time >= 0.5f)
|
||||
{
|
||||
flag = true;
|
||||
_time %= 0.5f;
|
||||
}
|
||||
for (var i = 0; i < _weaponList.Count; i++)
|
||||
{
|
||||
var weapon = _weaponList[i];
|
||||
if (weapon.Master != null)
|
||||
{
|
||||
_weaponList.RemoveAt(i--);
|
||||
weapon.ClearTriggerRole();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
var weaponBase = weapon.GetUseAttribute(Role);
|
||||
if (!weaponBase.ContinuousShoot)
|
||||
{
|
||||
if (!weaponBase.LooseShoot)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!weapon.IsCharging || weapon.IsChargeFinish())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
weapon.Trigger(Role, false);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPickUpItem()
|
||||
{
|
||||
RemoveChild(_areaNode);
|
||||
Role.AnimatedSprite.AddChild(_areaNode);
|
||||
}
|
||||
|
||||
public override void OnRemoveItem()
|
||||
{
|
||||
Role.AnimatedSprite.RemoveChild(_areaNode);
|
||||
AddChild(_areaNode);
|
||||
}
|
||||
|
||||
private void OnBodyEntered(Node2D node)
|
||||
{
|
||||
if (node is Weapon weapon && weapon.Master == null)
|
||||
{
|
||||
if (!_weaponList.Contains(weapon))
|
||||
{
|
||||
_weaponList.Add(weapon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBodyExited(Node2D node)
|
||||
{
|
||||
if (node is Weapon weapon && weapon.Master == null)
|
||||
{
|
||||
if (_weaponList.Remove(weapon))
|
||||
{
|
||||
weapon.ClearTriggerRole();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
|
||||
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 bool OnCheckUse()
|
||||
{
|
||||
return _currValue > 0;
|
||||
}
|
||||
|
||||
public override void OnUse()
|
||||
{
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
_currValue = 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
using System;
|
||||
using Godot;
|
||||
|
||||
public partial class Prop5003Area : Area2D
|
||||
{
|
||||
[Export]
|
||||
public Sprite2D CircleSprite;
|
||||
|
||||
[Export]
|
||||
public CollisionShape2D Collision;
|
||||
|
||||
public CircleShape2D CircleShape;
|
||||
public GradientTexture2D Gradient;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CircleShape = (CircleShape2D)Collision.Shape;
|
||||
Gradient = (GradientTexture2D)CircleSprite.Texture;
|
||||
SetEnable(false);
|
||||
}
|
||||
|
||||
public void PlayEffect(int startRadius, int endRadius, float time)
|
||||
{
|
||||
var tween = CreateTween();
|
||||
tween.SetParallel();
|
||||
tween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
SetEnable(true);
|
||||
Modulate = Colors.White;
|
||||
}));
|
||||
tween.Chain();
|
||||
|
||||
tween.TweenMethod(Callable.From<int>(SetRadius), startRadius, endRadius * 0.75f, time * 0.2f);
|
||||
tween.Chain();
|
||||
|
||||
tween.TweenInterval(time * 0.55f);
|
||||
tween.Chain();
|
||||
|
||||
tween.TweenMethod(Callable.From<int>(SetRadius), endRadius * 0.75f, endRadius, time * 0.25f);
|
||||
tween.TweenProperty(this, "modulate", new Color(1, 1, 1, 0), time * 0.25f);
|
||||
tween.Chain();
|
||||
|
||||
tween.TweenCallback(Callable.From(() =>
|
||||
{
|
||||
SetEnable(false);
|
||||
}));
|
||||
tween.Play();
|
||||
}
|
||||
|
||||
private void SetRadius(int radius)
|
||||
{
|
||||
Gradient.Width = radius * 2;
|
||||
Gradient.Height = radius * 2;
|
||||
CircleShape.Radius = radius;
|
||||
}
|
||||
|
||||
private void SetEnable(bool value)
|
||||
{
|
||||
Monitoring = value;
|
||||
CircleSprite.Visible = value;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class PropFragmentRegister
|
|||
public static Dictionary<string, PropFragmentInfo> BuffFragmentInfos { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所有主动道具条件数据
|
||||
/// 所有主动道具使用条件数据
|
||||
/// </summary>
|
||||
public static Dictionary<string, PropFragmentInfo> ConditionFragmentInfos { get; private set; }
|
||||
|
||||
|
@ -22,6 +22,11 @@ public class PropFragmentRegister
|
|||
/// 所有主动道具效果数据
|
||||
/// </summary>
|
||||
public static Dictionary<string, PropFragmentInfo> EffectFragmentInfos { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所有主动道具充能条件数据
|
||||
/// </summary>
|
||||
public static Dictionary<string, PropFragmentInfo> ChargeFragmentInfos { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始化 buff
|
||||
|
@ -31,6 +36,7 @@ public class PropFragmentRegister
|
|||
BuffFragmentInfos = new Dictionary<string, PropFragmentInfo>();
|
||||
ConditionFragmentInfos = new Dictionary<string, PropFragmentInfo>();
|
||||
EffectFragmentInfos = new Dictionary<string, PropFragmentInfo>();
|
||||
ChargeFragmentInfos = new Dictionary<string, PropFragmentInfo>();
|
||||
|
||||
var types = typeof(PropFragmentRegister).Assembly.GetTypes();
|
||||
//包含[BuffAttribute]特性
|
||||
|
@ -87,5 +93,23 @@ public class PropFragmentRegister
|
|||
EffectFragmentInfos.Add(attribute.EffectName, effectInfo);
|
||||
}
|
||||
}
|
||||
//包含[ChargeAttribute]特性
|
||||
var charges = types.Where(type =>
|
||||
type.IsClass && !type.IsAbstract && type.IsAssignableTo(typeof(ChargeFragment)));
|
||||
foreach (var type in charges)
|
||||
{
|
||||
var attribute = (ChargeFragmentAttribute)type.GetCustomAttribute(typeof(ChargeFragmentAttribute), false);
|
||||
if (attribute != null)
|
||||
{
|
||||
if (ChargeFragmentInfos.ContainsKey(attribute.ChargeName))
|
||||
{
|
||||
GD.PrintErr($"Charge '{attribute.ChargeName}' 重名!");
|
||||
continue;
|
||||
}
|
||||
|
||||
var chargeInfo = new PropFragmentInfo(attribute.ChargeName, attribute.Description, type);
|
||||
ChargeFragmentInfos.Add(attribute.ChargeName, chargeInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,22 +45,9 @@ public class ResourcePath
|
|||
public const string prefab_ui_EditorColorPicker_tscn = "res://prefab/ui/EditorColorPicker.tscn";
|
||||
public const string prefab_ui_RoomUI_tscn = "res://prefab/ui/RoomUI.tscn";
|
||||
public const string prefab_prop_PropTemplate_tscn = "res://prefab/prop/PropTemplate.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0003_tscn = "res://prefab/prop/buff/BuffProp0003.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0014_tscn = "res://prefab/prop/buff/BuffProp0014.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0002_tscn = "res://prefab/prop/buff/BuffProp0002.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0009_tscn = "res://prefab/prop/buff/BuffProp0009.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0005_tscn = "res://prefab/prop/buff/BuffProp0005.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0013_tscn = "res://prefab/prop/buff/BuffProp0013.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0012_tscn = "res://prefab/prop/buff/BuffProp0012.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0004_tscn = "res://prefab/prop/buff/BuffProp0004.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0008_tscn = "res://prefab/prop/buff/BuffProp0008.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0011_tscn = "res://prefab/prop/buff/BuffProp0011.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0007_tscn = "res://prefab/prop/buff/BuffProp0007.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0006_tscn = "res://prefab/prop/buff/BuffProp0006.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0010_tscn = "res://prefab/prop/buff/BuffProp0010.tscn";
|
||||
public const string prefab_prop_buff_BuffProp0001_tscn = "res://prefab/prop/buff/BuffProp0001.tscn";
|
||||
public const string prefab_prop_active_ActiveProp5001_tscn = "res://prefab/prop/active/ActiveProp5001.tscn";
|
||||
public const string prefab_prop_active_ActiveProp5000_tscn = "res://prefab/prop/active/ActiveProp5000.tscn";
|
||||
public const string prefab_prop_ActiveProp_tscn = "res://prefab/prop/ActiveProp.tscn";
|
||||
public const string prefab_prop_BuffProp_tscn = "res://prefab/prop/BuffProp.tscn";
|
||||
public const string prefab_prop_activeComp_Prop5003_Area_tscn = "res://prefab/prop/activeComp/Prop5003_Area.tscn";
|
||||
public const string prefab_weapon_Weapon0008_tscn = "res://prefab/weapon/Weapon0008.tscn";
|
||||
public const string prefab_weapon_Weapon0004_tscn = "res://prefab/weapon/Weapon0004.tscn";
|
||||
public const string prefab_weapon_Weapon0005_tscn = "res://prefab/weapon/Weapon0005.tscn";
|
||||
|
@ -175,22 +162,6 @@ public class ResourcePath
|
|||
public const string scene_test_TestNavigation2_tscn = "res://scene/test/TestNavigation2.tscn";
|
||||
public const string scene_test_TestLoadTileSetConfig_tscn = "res://scene/test/TestLoadTileSetConfig.tscn";
|
||||
public const string scene_test_TestDrawSprite_tscn = "res://scene/test/TestDrawSprite.tscn";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0009_tres = "res://resource/spriteFrames/prop/buff/BuffProp0009.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0013_tres = "res://resource/spriteFrames/prop/buff/BuffProp0013.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0005_tres = "res://resource/spriteFrames/prop/buff/BuffProp0005.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0004_tres = "res://resource/spriteFrames/prop/buff/BuffProp0004.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0012_tres = "res://resource/spriteFrames/prop/buff/BuffProp0012.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0008_tres = "res://resource/spriteFrames/prop/buff/BuffProp0008.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0003_tres = "res://resource/spriteFrames/prop/buff/BuffProp0003.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0002_tres = "res://resource/spriteFrames/prop/buff/BuffProp0002.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0014_tres = "res://resource/spriteFrames/prop/buff/BuffProp0014.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0001_tres = "res://resource/spriteFrames/prop/buff/BuffProp0001.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0007_tres = "res://resource/spriteFrames/prop/buff/BuffProp0007.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0011_tres = "res://resource/spriteFrames/prop/buff/BuffProp0011.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0010_tres = "res://resource/spriteFrames/prop/buff/BuffProp0010.tres";
|
||||
public const string resource_spriteFrames_prop_buff_BuffProp0006_tres = "res://resource/spriteFrames/prop/buff/BuffProp0006.tres";
|
||||
public const string resource_spriteFrames_prop_active_ActiveProp5001_tres = "res://resource/spriteFrames/prop/active/ActiveProp5001.tres";
|
||||
public const string resource_spriteFrames_prop_active_ActiveProp5000_tres = "res://resource/spriteFrames/prop/active/ActiveProp5000.tres";
|
||||
public const string resource_spriteFrames_weapon_Weapon0002_tres = "res://resource/spriteFrames/weapon/Weapon0002.tres";
|
||||
public const string resource_spriteFrames_weapon_Weapon0014_tres = "res://resource/spriteFrames/weapon/Weapon0014.tres";
|
||||
public const string resource_spriteFrames_weapon_Weapon0004_hit_tres = "res://resource/spriteFrames/weapon/Weapon0004_hit.tres";
|
||||
|
@ -231,11 +202,13 @@ public class ResourcePath
|
|||
public const string resource_config_LiquidMaterial_json = "res://resource/config/LiquidMaterial.json";
|
||||
public const string resource_config_ActivityBase_json = "res://resource/config/ActivityBase.json";
|
||||
public const string resource_config_EnemyBase_json = "res://resource/config/EnemyBase.json";
|
||||
public const string resource_config_ActivePropBase_json = "res://resource/config/ActivePropBase.json";
|
||||
public const string resource_config_BulletBase_json = "res://resource/config/BulletBase.json";
|
||||
public const string resource_config_AiAttackAttr_json = "res://resource/config/AiAttackAttr.json";
|
||||
public const string resource_config_ActivityMaterial_json = "res://resource/config/ActivityMaterial.json";
|
||||
public const string resource_config_WeaponBase_json = "res://resource/config/WeaponBase.json";
|
||||
public const string resource_config_Sound_json = "res://resource/config/Sound.json";
|
||||
public const string resource_config_BuffPropBase_json = "res://resource/config/BuffPropBase.json";
|
||||
public const string resource_navigation_NavigationPolygon_tres = "res://resource/navigation/NavigationPolygon.tres";
|
||||
public const string resource_curve_Curve1_tres = "res://resource/curve/Curve1.tres";
|
||||
public const string resource_theme_theme1_tres = "res://resource/theme/theme1.tres";
|
||||
|
@ -306,7 +279,9 @@ public class ResourcePath
|
|||
public const string resource_sprite_ui_encyclopedia_Item_png = "res://resource/sprite/ui/encyclopedia/Item.png";
|
||||
public const string resource_sprite_ui_encyclopedia_TabSelect_png = "res://resource/sprite/ui/encyclopedia/TabSelect.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Select_png = "res://resource/sprite/ui/encyclopedia/Select.png";
|
||||
public const string resource_sprite_ui_encyclopedia_CloseSelect_png = "res://resource/sprite/ui/encyclopedia/CloseSelect.png";
|
||||
public const string resource_sprite_ui_encyclopedia_TabIcon1_png = "res://resource/sprite/ui/encyclopedia/TabIcon1.png";
|
||||
public const string resource_sprite_ui_encyclopedia_Close_png = "res://resource/sprite/ui/encyclopedia/Close.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_hover_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_hover.png";
|
||||
public const string resource_sprite_ui_mapEditorTools_DoorDragButton_down_png = "res://resource/sprite/ui/mapEditorTools/DoorDragButton_down.png";
|
||||
|
@ -330,6 +305,8 @@ public class ResourcePath
|
|||
public const string resource_sprite_prop_buff_BuffProp0001export_png = "res://resource/sprite/prop/buff/BuffProp0001-export.png";
|
||||
public const string resource_sprite_prop_active_ActiveProp5001_png = "res://resource/sprite/prop/active/ActiveProp5001.png";
|
||||
public const string resource_sprite_prop_active_ActiveProp5000_png = "res://resource/sprite/prop/active/ActiveProp5000.png";
|
||||
public const string resource_sprite_prop_active_ActiveProp5002_png = "res://resource/sprite/prop/active/ActiveProp5002.png";
|
||||
public const string resource_sprite_prop_active_ActiveProp5003_png = "res://resource/sprite/prop/active/ActiveProp5003.png";
|
||||
public const string resource_sprite_weapon_weapon0014_Weapon0014_png = "res://resource/sprite/weapon/weapon0014/Weapon0014.png";
|
||||
public const string resource_sprite_weapon_weapon0013_weapon0014export_png = "res://resource/sprite/weapon/weapon0013/weapon0014-export.png";
|
||||
public const string resource_sprite_weapon_weapon0013_weapon0014_png = "res://resource/sprite/weapon/weapon0013/weapon0014.png";
|
||||
|
|