diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index e294583..2b8c676 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -1951,7 +1951,7 @@ } /// - /// 设置是否启用碰撞层, 该函数是设置下载状态下原碰撞层 + /// 设置是否启用碰撞层, 该函数是设置下坠状态下原碰撞层 /// public void SetOriginCollisionLayerValue(uint layer, bool vale) { diff --git a/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs new file mode 100644 index 0000000..9b5dbfe --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/prop/BuffActivity.cs @@ -0,0 +1,116 @@ + +using System.Collections.Generic; +using Godot; + +/// +/// 通用被动道具实体类 +/// +[Tool] +public partial class BuffActivity : PropActivity +{ + //被动属性 + private readonly List _buffFragment = new List(); + + public override void OnPickUpItem() + { + foreach (var buffFragment in _buffFragment) + { + buffFragment.OnPickUpItem(); + } + } + + public override void OnRemoveItem() + { + foreach (var buffFragment in _buffFragment) + { + buffFragment.OnRemoveItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment() where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2, float arg3) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2, arg3); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + /// + /// 添加被动属性 + /// + public void AddBuffFragment(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new() + { + var fragment = AddComponent(); + _buffFragment.Add(fragment); + fragment.InitParam(arg1, arg2, arg3, arg4); + if (Master != null) + { + fragment.OnPickUpItem(); + } + } + + public override void Interactive(ActivityObject master) + { + if (master is Player role) + { + Pickup(); + role.PickUpBuffProp(this); + } + } + + public override CheckInteractiveResult CheckInteractive(ActivityObject master) + { + if (master is Player) + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); + } + return base.CheckInteractive(master); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs b/DungeonShooting_Godot/src/game/activity/prop/Prop.cs deleted file mode 100644 index 90fb6e7..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs +++ /dev/null @@ -1,61 +0,0 @@ - -using Godot; - -/// -/// 道具基类 -/// -public abstract partial class Prop : ActivityObject -{ - /// - /// 道具所属角色 - /// - public Role Master { get; set; } - - /// - /// 当道具被拾起时调用 (在 Master 赋值之后调用) - /// - public abstract void OnPickUpItem(); - - /// - /// 当道具被移除时调用 (在 Master 置为 null 之前调用) - /// - public abstract void OnRemoveItem(); - - public override void OnInit() - { - ThrowCollisionMask = PhysicsLayer.Wall; - } - - /// - /// 如果道具放入了角色背包中, 则每帧调用 - /// - public virtual void PackProcess(float delta) - { - } - - /// - /// 触发扔掉道具效果, 并不会管道具是否在道具背包中 - /// - /// 触发扔掉该道具的的角色 - public void ThrowProp(Role master) - { - ThrowProp(master, master.GlobalPosition); - } - - /// - /// 触发扔掉道具效果, 并不会管道具是否在道具背包中 - /// - /// 触发扔掉该道具的的角色 - /// 投抛起始位置 - public void ThrowProp(Role master, Vector2 startPosition) - { - //阴影偏移 - ShadowOffset = new Vector2(0, 2); - GlobalRotation = 0; - var startHeight = 8; - Throw(startPosition, startHeight, 0, Vector2.Zero, 0); - - //继承role的移动速度 - InheritVelocity(master); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs new file mode 100644 index 0000000..d9ff654 --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs @@ -0,0 +1,61 @@ + +using Godot; + +/// +/// 道具基类 +/// +public abstract partial class PropActivity : ActivityObject +{ + /// + /// 道具所属角色 + /// + public Role Master { get; set; } + + /// + /// 当道具被拾起时调用 (在 Master 赋值之后调用) + /// + public abstract void OnPickUpItem(); + + /// + /// 当道具被移除时调用 (在 Master 置为 null 之前调用) + /// + public abstract void OnRemoveItem(); + + public override void OnInit() + { + ThrowCollisionMask = PhysicsLayer.Wall; + } + + /// + /// 如果道具放入了角色背包中, 则每帧调用 + /// + public virtual void PackProcess(float delta) + { + } + + /// + /// 触发扔掉道具效果, 并不会管道具是否在道具背包中 + /// + /// 触发扔掉该道具的的角色 + public void ThrowProp(Role master) + { + ThrowProp(master, master.GlobalPosition); + } + + /// + /// 触发扔掉道具效果, 并不会管道具是否在道具背包中 + /// + /// 触发扔掉该道具的的角色 + /// 投抛起始位置 + public void ThrowProp(Role master, Vector2 startPosition) + { + //阴影偏移 + ShadowOffset = new Vector2(0, 2); + GlobalRotation = 0; + var startHeight = 8; + Throw(startPosition, startHeight, 0, Vector2.Zero, 0); + + //继承role的移动速度 + InheritVelocity(master); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs deleted file mode 100644 index 93d7df6..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp.cs +++ /dev/null @@ -1,327 +0,0 @@ - -using Godot; - -/// -/// 主动使用道具 -/// -public abstract partial class ActiveProp : Prop, IPackageItem -{ - public int PackageIndex { get; set; } - - /// - /// 道具是否可以叠加 - /// - public bool Superposition { get; set; } = false; - - /// - /// 道具可使用次数 - /// - public int Count - { - get => _count; - set - { - var temp = _count; - _count = Mathf.Clamp(value, 0, _maxCount); - if (temp != _count) - { - OnChangeCount(); - } - } - } - - private int _count = 1; - - /// - /// 道具最大叠加用次数 - /// - public int MaxCount - { - get => _maxCount; - set - { - var temp = _maxCount; - _maxCount = Mathf.Max(1, value); - if (temp != _maxCount) - { - OnChangeMaxCount(); - } - - if (Count > _maxCount) - { - Count = _maxCount; - } - } - } - - private int _maxCount = 1; - - /// - /// 使用一次后的冷却时间, 单位: 秒 - /// - public float CooldownTime { get; set; } = 2f; - - /// - /// 当道具使用完后是否自动销毁 - /// - public bool AutoDestroy { get; set; } = false; - - /// - /// 道具充能进度, 必须要充能完成才能使用, 值范围: 0 - 1 - /// - public float ChargeProgress - { - get => _chargeProgress; - set - { - var temp = _chargeProgress; - _chargeProgress = Mathf.Clamp(value, 0, 1); - if (temp != _chargeProgress) - { - OnChangeChargeProgress(); - } - } - } - - private float _chargeProgress = 1; - - /// - /// 自动充能速度, 也就是每秒充能进度, 如果为0则表示不就行自动充能 - /// - public float AutoChargeSpeed { get; set; } - - //冷却计时器 - private float _cooldownTimer = 0; - - /// - /// 当检测是否可以使用时调用 - /// - public abstract bool OnCheckUse(); - - /// - /// 当道具被使用时调用, 函数返回值为消耗数量 - /// - protected abstract int OnUse(); - - /// - /// 道具数量改变时调用 - /// - protected virtual void OnChangeCount() - { - } - - /// - /// 道具最大数量改变时调用 - /// - protected virtual void OnChangeMaxCount() - { - } - - /// - /// 道具充能进度改变时调用 - /// - protected virtual void OnChangeChargeProgress() - { - } - - /// - /// 冷却完成时调用 - /// - protected virtual void OnCooldownFinish() - { - } - - 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 (_cooldownTimer > 0) - { - _cooldownTimer -= delta; - - //冷却完成 - if (_cooldownTimer <= 0) - { - _cooldownTimer = 0; - OnCooldownFinish(); - } - } - - //自动充能 - if (AutoChargeSpeed > 0 && ChargeProgress < 1) - { - ChargeProgress += AutoChargeSpeed * delta; - } - } - - //检测是否达到自动销毁的条件 - private bool CheckAutoDestroy() - { - if (Count == 0 && AutoDestroy) //用光了, 自动销毁 - { - if (Master != null) - { - Master.ActivePropsPack.RemoveItem(this); - } - Destroy(); - return true; - } - - return false; - } - - /// - /// 检测是否可以使用当前道具 - /// - public bool CheckUse() - { - return ChargeProgress >= 1 && _cooldownTimer <= 0 && Count > 0 && OnCheckUse(); - } - - /// - /// 触发使用道具 - /// - public void Use() - { - if (Master == null) - { - return; - } - if (CheckUse()) //可以使用道具 - { - var num = OnUse(); - if (num != 0) - { - Count -= num; - } - - //冷却计时器 - _cooldownTimer = CooldownTime; - } - } - - /// - /// 获取冷却进度 0 - 1 - /// - public float GetCooldownProgress() - { - if (_cooldownTimer <= 0) - { - return 1; - } - - return (CooldownTime - _cooldownTimer) / CooldownTime; - } - - public override void Interactive(ActivityObject master) - { - if (master is Player player) - { - if (player.ActivePropsPack.Capacity == 0) - { - //容量为0 - return; - } - var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); - if (item == null) //没有同类型物体 - { - if (!player.ActivePropsPack.HasVacancy()) //没有空位置, 扔掉当前道具 - { - player.ThrowActiveProp(player.ActivePropsPack.ActiveIndex); - } - //替换手中的道具 - if (player.PickUpActiveProp(this)) - { - Pickup(); - } - } - else - { - //处理同类型道具 - if (Superposition && item.Count < item.MaxCount) //允许叠加 - { - if (item.Count + Count > item.MaxCount) - { - Count -= item.MaxCount - item.Count; - item.Count = item.MaxCount; - } - else - { - item.Count += Count; - Count = 0; - } - Destroy(); - } - } - } - } - - public override CheckInteractiveResult CheckInteractive(ActivityObject master) - { - if (master is Player player) - { - if (player.ActivePropsPack.Capacity == 0) - { - //容量为0 - return new CheckInteractiveResult(this); - } - //查找相同类型的道具 - var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); - if (item == null) //没有同类型物体 - { - if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具 - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); - } - - //替换手中的道具 - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace); - } - - //处理同类型道具 - if (Superposition && item.Count < item.MaxCount) //允许叠加 - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet); - } - - //该道具不能拾起 - return new CheckInteractiveResult(this); - } - - return new CheckInteractiveResult(this); - } - - public override void OnPickUpItem() - { - } - - public override void OnRemoveItem() - { - } - - public virtual void OnActiveItem() - { - } - - public virtual void OnConcealItem() - { - } - - public virtual void OnOverflowItem() - { - Master.ThrowActiveProp(PackageIndex); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs index bdc2ce4..29d77b4 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs @@ -5,7 +5,7 @@ /// 医药箱, 使用后恢复一颗红心 /// [Tool] -public partial class ActiveProp5000 : ActiveProp +public partial class ActiveProp5000 : ActivePropActivity { public override void OnInit() { diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs index 43770cb..6940fdf 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs @@ -5,7 +5,7 @@ /// 弹药箱, 使用后补全当前武器备用弹药 /// [Tool] -public partial class ActiveProp5001 : ActiveProp +public partial class ActiveProp5001 : ActivePropActivity { public override void OnInit() { diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs new file mode 100644 index 0000000..cd1600c --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActivePropActivity.cs @@ -0,0 +1,327 @@ + +using Godot; + +/// +/// 主动使用道具 +/// +public abstract partial class ActivePropActivity : PropActivity, IPackageItem +{ + public int PackageIndex { get; set; } + + /// + /// 道具是否可以叠加 + /// + public bool Superposition { get; set; } = false; + + /// + /// 道具可使用次数 + /// + public int Count + { + get => _count; + set + { + var temp = _count; + _count = Mathf.Clamp(value, 0, _maxCount); + if (temp != _count) + { + OnChangeCount(); + } + } + } + + private int _count = 1; + + /// + /// 道具最大叠加用次数 + /// + public int MaxCount + { + get => _maxCount; + set + { + var temp = _maxCount; + _maxCount = Mathf.Max(1, value); + if (temp != _maxCount) + { + OnChangeMaxCount(); + } + + if (Count > _maxCount) + { + Count = _maxCount; + } + } + } + + private int _maxCount = 1; + + /// + /// 使用一次后的冷却时间, 单位: 秒 + /// + public float CooldownTime { get; set; } = 2f; + + /// + /// 当道具使用完后是否自动销毁 + /// + public bool AutoDestroy { get; set; } = false; + + /// + /// 道具充能进度, 必须要充能完成才能使用, 值范围: 0 - 1 + /// + public float ChargeProgress + { + get => _chargeProgress; + set + { + var temp = _chargeProgress; + _chargeProgress = Mathf.Clamp(value, 0, 1); + if (temp != _chargeProgress) + { + OnChangeChargeProgress(); + } + } + } + + private float _chargeProgress = 1; + + /// + /// 自动充能速度, 也就是每秒充能进度, 如果为0则表示不就行自动充能 + /// + public float AutoChargeSpeed { get; set; } + + //冷却计时器 + private float _cooldownTimer = 0; + + /// + /// 当检测是否可以使用时调用 + /// + public abstract bool OnCheckUse(); + + /// + /// 当道具被使用时调用, 函数返回值为消耗数量 + /// + protected abstract int OnUse(); + + /// + /// 道具数量改变时调用 + /// + protected virtual void OnChangeCount() + { + } + + /// + /// 道具最大数量改变时调用 + /// + protected virtual void OnChangeMaxCount() + { + } + + /// + /// 道具充能进度改变时调用 + /// + protected virtual void OnChangeChargeProgress() + { + } + + /// + /// 冷却完成时调用 + /// + protected virtual void OnCooldownFinish() + { + } + + 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 (_cooldownTimer > 0) + { + _cooldownTimer -= delta; + + //冷却完成 + if (_cooldownTimer <= 0) + { + _cooldownTimer = 0; + OnCooldownFinish(); + } + } + + //自动充能 + if (AutoChargeSpeed > 0 && ChargeProgress < 1) + { + ChargeProgress += AutoChargeSpeed * delta; + } + } + + //检测是否达到自动销毁的条件 + private bool CheckAutoDestroy() + { + if (Count == 0 && AutoDestroy) //用光了, 自动销毁 + { + if (Master != null) + { + Master.ActivePropsPack.RemoveItem(this); + } + Destroy(); + return true; + } + + return false; + } + + /// + /// 检测是否可以使用当前道具 + /// + public bool CheckUse() + { + return ChargeProgress >= 1 && _cooldownTimer <= 0 && Count > 0 && OnCheckUse(); + } + + /// + /// 触发使用道具 + /// + public void Use() + { + if (Master == null) + { + return; + } + if (CheckUse()) //可以使用道具 + { + var num = OnUse(); + if (num != 0) + { + Count -= num; + } + + //冷却计时器 + _cooldownTimer = CooldownTime; + } + } + + /// + /// 获取冷却进度 0 - 1 + /// + public float GetCooldownProgress() + { + if (_cooldownTimer <= 0) + { + return 1; + } + + return (CooldownTime - _cooldownTimer) / CooldownTime; + } + + public override void Interactive(ActivityObject master) + { + if (master is Player player) + { + if (player.ActivePropsPack.Capacity == 0) + { + //容量为0 + return; + } + var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); + if (item == null) //没有同类型物体 + { + if (!player.ActivePropsPack.HasVacancy()) //没有空位置, 扔掉当前道具 + { + player.ThrowActiveProp(player.ActivePropsPack.ActiveIndex); + } + //替换手中的道具 + if (player.PickUpActiveProp(this)) + { + Pickup(); + } + } + else + { + //处理同类型道具 + if (Superposition && item.Count < item.MaxCount) //允许叠加 + { + if (item.Count + Count > item.MaxCount) + { + Count -= item.MaxCount - item.Count; + item.Count = item.MaxCount; + } + else + { + item.Count += Count; + Count = 0; + } + Destroy(); + } + } + } + } + + public override CheckInteractiveResult CheckInteractive(ActivityObject master) + { + if (master is Player player) + { + if (player.ActivePropsPack.Capacity == 0) + { + //容量为0 + return new CheckInteractiveResult(this); + } + //查找相同类型的道具 + var item = player.ActivePropsPack.GetItemById(ActivityBase.Id); + if (item == null) //没有同类型物体 + { + if (player.ActivePropsPack.HasVacancy()) //还有空位, 拾起道具 + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); + } + + //替换手中的道具 + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Replace); + } + + //处理同类型道具 + if (Superposition && item.Count < item.MaxCount) //允许叠加 + { + return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.Bullet); + } + + //该道具不能拾起 + return new CheckInteractiveResult(this); + } + + return new CheckInteractiveResult(this); + } + + public override void OnPickUpItem() + { + } + + public override void OnRemoveItem() + { + } + + public virtual void OnActiveItem() + { + } + + public virtual void OnConcealItem() + { + } + + public virtual void OnOverflowItem() + { + Master.ThrowActiveProp(PackageIndex); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffActivity.cs deleted file mode 100644 index 1dfc591..0000000 --- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffActivity.cs +++ /dev/null @@ -1,101 +0,0 @@ - -using System.Collections.Generic; -using Godot; - -/// -/// 通用被动道具实体类 -/// -[Tool] -public partial class BuffActivity : Prop -{ - private readonly List _buffFragment = new List(); - - public override void OnPickUpItem() - { - foreach (var buffFragment in _buffFragment) - { - buffFragment.OnPickUpItem(); - } - } - - public override void OnRemoveItem() - { - foreach (var buffFragment in _buffFragment) - { - buffFragment.OnRemoveItem(); - } - } - - public void AddBuffFragment() where T : BuffFragment, new() - { - var fragment = AddComponent(); - _buffFragment.Add(fragment); - fragment.Init(); - if (Master != null) - { - fragment.OnPickUpItem(); - } - } - - public void AddBuffFragment(float arg1) where T : BuffFragment, new() - { - var fragment = AddComponent(); - _buffFragment.Add(fragment); - fragment.Init(arg1); - if (Master != null) - { - fragment.OnPickUpItem(); - } - } - - public void AddBuffFragment(float arg1, float arg2) where T : BuffFragment, new() - { - var fragment = AddComponent(); - _buffFragment.Add(fragment); - fragment.Init(arg1, arg2); - if (Master != null) - { - fragment.OnPickUpItem(); - } - } - - public void AddBuffFragment(float arg1, float arg2, float arg3) where T : BuffFragment, new() - { - var fragment = AddComponent(); - _buffFragment.Add(fragment); - fragment.Init(arg1, arg2, arg3); - if (Master != null) - { - fragment.OnPickUpItem(); - } - } - - public void AddBuffFragment(float arg1, float arg2, float arg3, float arg4) where T : BuffFragment, new() - { - var fragment = AddComponent(); - _buffFragment.Add(fragment); - fragment.Init(arg1, arg2, arg3, arg4); - if (Master != null) - { - fragment.OnPickUpItem(); - } - } - - public override void Interactive(ActivityObject master) - { - if (master is Player role) - { - Pickup(); - role.PickUpBuffProp(this); - } - } - - public override CheckInteractiveResult CheckInteractive(ActivityObject master) - { - if (master is Player) - { - return new CheckInteractiveResult(this, true, CheckInteractiveResult.InteractiveType.PickUp); - } - return base.CheckInteractive(master); - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index e0e6477..d5d5905 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -59,7 +59,7 @@ /// /// 携带的主动道具包裹 /// - public Package ActivePropsPack { get; private set; } + public Package ActivePropsPack { get; private set; } /// /// 互动碰撞区域 @@ -431,21 +431,21 @@ /// /// 当拾起某个主动道具时调用 /// - protected virtual void OnPickUpActiveProp(ActiveProp activeProp) + protected virtual void OnPickUpActiveProp(ActivePropActivity activePropActivity) { } /// /// 当移除某个主动道具时调用 /// - protected virtual void OnRemoveActiveProp(ActiveProp activeProp) + protected virtual void OnRemoveActiveProp(ActivePropActivity activePropActivity) { } /// /// 当切换到某个主动道具时调用 /// - protected virtual void OnExchangeActiveProp(ActiveProp activeProp) + protected virtual void OnExchangeActiveProp(ActivePropActivity activePropActivity) { } @@ -466,7 +466,7 @@ public override void OnInit() { RoleState = OnCreateRoleState(); - ActivePropsPack = AddComponent>(); + ActivePropsPack = AddComponent>(); ActivePropsPack.SetCapacity(RoleState.CanPickUpWeapon ? 1 : 0); _startScale = Scale; @@ -617,7 +617,7 @@ var props = ActivePropsPack.ItemSlot; if (props.Length > 0) { - props = (ActiveProp[])props.Clone(); + props = (ActivePropActivity[])props.Clone(); foreach (var prop in props) { if (prop != null && !prop.IsDestroyed) @@ -673,15 +673,15 @@ /// /// 拾起主动道具, 返回是否成功拾起, 如果不想立刻切换到该道具, exchange 请传 false /// - /// 主动道具对象 + /// 主动道具对象 /// 是否立即切换到该道具, 默认 true - public bool PickUpActiveProp(ActiveProp activeProp, bool exchange = true) + public bool PickUpActiveProp(ActivePropActivity activePropActivity, bool exchange = true) { - if (ActivePropsPack.PickupItem(activeProp, exchange) != -1) + if (ActivePropsPack.PickupItem(activePropActivity, exchange) != -1) { //从可互动队列中移除 - InteractiveItemList.Remove(activeProp); - OnPickUpActiveProp(activeProp); + InteractiveItemList.Remove(activePropActivity); + OnPickUpActiveProp(activePropActivity); return true; } diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 733491f..f9669ae 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -354,14 +354,14 @@ UiManager.Open_Settlement(); } - protected override void OnPickUpActiveProp(ActiveProp activeProp) + protected override void OnPickUpActiveProp(ActivePropActivity activePropActivity) { - EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activeProp); + EventManager.EmitEvent(EventEnum.OnPlayerPickUpProp, activePropActivity); } - protected override void OnRemoveActiveProp(ActiveProp activeProp) + protected override void OnRemoveActiveProp(ActivePropActivity activePropActivity) { - EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activeProp); + EventManager.EmitEvent(EventEnum.OnPlayerRemoveProp, activePropActivity); } protected override void OnPickUpBuffProp(BuffActivity buffActivity) diff --git a/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs b/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs new file mode 100644 index 0000000..2d44e2f --- /dev/null +++ b/DungeonShooting_Godot/src/game/buff/BuffAttribute.cs @@ -0,0 +1,21 @@ +using System; + +[AttributeUsage(AttributeTargets.Class)] +public class BuffAttribute : Attribute +{ + /// + /// Buff属性名称 + /// + public string BuffName { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + public BuffAttribute(string buffName, string description) + { + BuffName = buffName; + Description = description; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs index a470a8d..50c0727 100644 --- a/DungeonShooting_Godot/src/game/buff/BuffFragment.cs +++ b/DungeonShooting_Godot/src/game/buff/BuffFragment.cs @@ -2,7 +2,7 @@ using System; /// -/// 被动道具逻辑基类 +/// 被动属性逻辑基类 /// public abstract partial class BuffFragment : Component { @@ -20,28 +20,35 @@ /// 当道具被移除时调用 (在 Master 置为 null 之前调用) /// public abstract void OnRemoveItem(); - - public virtual void Init() - { - Debug.LogError($"'{GetType().FullName}'为实现0参数初始化函数!"); - } - - public virtual void Init(float arg1) + + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1) { Debug.LogError($"'{GetType().FullName}'为实现1参数初始化函数!"); } - public virtual void Init(float arg1, float arg2) + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2) { Debug.LogError($"'{GetType().FullName}'为实现2参数初始化函数!"); } - public virtual void Init(float arg1, float arg2, float arg3) + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2, float arg3) { Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); } - public virtual void Init(float arg1, float arg2, float arg3, float arg4) + /// + /// 初始化被动属性参数 + /// + public virtual void InitParam(float arg1, float arg2, float arg3, float arg4) { Debug.LogError($"'{GetType().FullName}'为实现4参数初始化函数!"); } diff --git a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs index 1fef352..8003172 100644 --- a/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs +++ b/DungeonShooting_Godot/src/game/buff/fragment/Buff_MoveSpeed.cs @@ -1,18 +1,28 @@ +/// +/// 移速 buff +/// +[Buff("MoveSpeed", "移速 buff, 参数 1 为移动速度值")] public class Buff_MoveSpeed : BuffFragment { - public override void Init(float arg1) + private float _moveSpeed; + + public override void InitParam(float arg1) { - + _moveSpeed = arg1; } public override void OnPickUpItem() { - + Role.RoleState.MoveSpeed += _moveSpeed; + Role.RoleState.Acceleration += _moveSpeed * 1.4f; + Role.RoleState.Friction += _moveSpeed; } public override void OnRemoveItem() { - + Role.RoleState.MoveSpeed -= _moveSpeed; + Role.RoleState.Acceleration -= _moveSpeed * 1.4f; + Role.RoleState.Friction -= _moveSpeed; } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/event/EventEnum.cs b/DungeonShooting_Godot/src/game/event/EventEnum.cs index afe09d8..dd3a2b6 100644 --- a/DungeonShooting_Godot/src/game/event/EventEnum.cs +++ b/DungeonShooting_Godot/src/game/event/EventEnum.cs @@ -59,11 +59,11 @@ /// OnPlayerRemoveWeapon, /// - /// 玩家拾起道具, 参数为 + /// 玩家拾起道具, 参数为 /// OnPlayerPickUpProp, /// - /// 玩家丢弃道具, 参数为 + /// 玩家丢弃道具, 参数为 /// OnPlayerRemoveProp, diff --git a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs index 466618c..893e742 100644 --- a/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomUI/RoomUIPanel.cs @@ -73,7 +73,7 @@ //玩家拾起道具, 弹出提示 private void OnPlayerPickUpProp(object propObj) { - var prop = (Prop)propObj; + var prop = (PropActivity)propObj; var message = $"{prop.ActivityBase.Name}\n{prop.ActivityBase.Intro}"; BottomTipsPanel.ShowTips(prop.GetDefaultTexture(), message); }