diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index 9b341a7..2169f4a 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -1043,42 +1043,11 @@
}
#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 @@
}
//协程更新
- ProxyCoroutineHandler.ProxyUpdateCoroutine(ref _coroutineList, newDelta);
+ UpdateCoroutine(newDelta);
//调试绘制
if (IsDebug)
@@ -1119,6 +1088,110 @@
}
///
+ /// 触发调用 Process() 函数
+ ///
+ public void UpdateProcess(float delta)
+ {
+ if (EnableCustomBehavior)
+ {
+ Process(delta);
+ }
+ }
+
+ ///
+ /// 触发调用 PhysicsProcess() 函数
+ ///
+ public void UpdatePhysicsProcess(float delta)
+ {
+ if (EnableCustomBehavior)
+ {
+ PhysicsProcess(delta);
+ }
+ }
+
+ ///
+ /// 更新组件
+ ///
+ 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();
+ }
+ }
+
+ }
+
+ ///
+ /// 物理帧更新组件
+ ///
+ 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();
+ }
+ }
+ }
+
+ ///
+ /// 更新协程
+ ///
+ public void UpdateCoroutine(float delta)
+ {
+ ProxyCoroutineHandler.ProxyUpdateCoroutine(ref _coroutineList, delta);
+ }
+
+ ///
/// 更新下坠处理逻辑
///
public void UpdateFall(float delta)
@@ -1275,41 +1348,10 @@
}
#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);
}
//更新新增/移除的组件
diff --git a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs
index a82a0bb..85a6ccd 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/ActiveProp.cs
@@ -259,6 +259,11 @@
{
if (!fragment.OnCheckUse()) return false;
}
+
+ foreach (var fragment in _effectFragment)
+ {
+ if (!fragment.OnCheckUse()) return false;
+ }
return true;
}
@@ -304,16 +309,6 @@
protected override void Process(float delta)
{
- RunUpdate(delta);
- }
-
- public override void PackProcess(float delta)
- {
- RunUpdate(delta);
- }
-
- private void RunUpdate(float delta)
- {
if (CheckAutoDestroy())
{
return;
@@ -337,7 +332,7 @@
ChargeProgress += AutoChargeSpeed * delta;
}
}
-
+
//检测是否达到自动销毁的条件
private bool CheckAutoDestroy()
{
diff --git a/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs b/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs
index d9ff654..dc05bae 100644
--- a/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs
+++ b/DungeonShooting_Godot/src/game/activity/prop/PropActivity.cs
@@ -27,13 +27,6 @@
}
///
- /// 如果道具放入了角色背包中, 则每帧调用
- ///
- public virtual void PackProcess(float delta)
- {
- }
-
- ///
/// 触发扔掉道具效果, 并不会管道具是否在道具背包中
///
/// 触发扔掉该道具的的角色
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index 1dfe706..ecb1011 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -611,12 +611,15 @@
//被动道具更新
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 @@
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 @@
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);
+ }
+ }
+ }
+ }
+
///
/// 初始化瞄准辅助线
///
@@ -687,6 +725,7 @@
{
if (ActivePropsPack.PickupItem(activeProp, exchange) != -1)
{
+ activeProp.MoveController.Enable = false;
//从可互动队列中移除
InteractiveItemList.Remove(activeProp);
OnPickUpActiveProp(activeProp);
@@ -715,6 +754,7 @@
return;
}
+ activeProp.MoveController.Enable = true;
ActivePropsPack.RemoveItem(index);
OnRemoveActiveProp(activeProp);
//播放抛出效果
diff --git a/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs b/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs
index 2fbd2ac..2e5ce51 100644
--- a/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs
+++ b/DungeonShooting_Godot/src/game/buff/ConditionFragment.cs
@@ -5,6 +5,11 @@
public abstract class ConditionFragment : PropFragment
{
///
+ /// 当前组件所挂载的游戏对象
+ ///
+ public new ActiveProp Master => (ActiveProp)base.Master;
+
+ ///
/// 当检测是否可以使用时调用
///
public abstract bool OnCheckUse();
diff --git a/DungeonShooting_Godot/src/game/buff/EffectFragment.cs b/DungeonShooting_Godot/src/game/buff/EffectFragment.cs
index 6837887..de0ea3c 100644
--- a/DungeonShooting_Godot/src/game/buff/EffectFragment.cs
+++ b/DungeonShooting_Godot/src/game/buff/EffectFragment.cs
@@ -5,6 +5,19 @@
public abstract class EffectFragment : PropFragment
{
///
+ /// 当前组件所挂载的游戏对象
+ ///
+ public new ActiveProp Master => (ActiveProp)base.Master;
+
+ ///
+ /// 当检测是否可以使用时调用
+ ///
+ public virtual bool OnCheckUse()
+ {
+ return true;
+ }
+
+ ///
/// 使用道具的回调
///
public abstract void OnUse();
@@ -16,4 +29,12 @@
public override void OnRemoveItem()
{
}
+
+ ///
+ /// 返回是否正在使用当前道具
+ ///
+ public bool IsActive()
+ {
+ return Role != null && Role.ActivePropsPack.ActiveItem == Master;
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/buff/PropFragment.cs b/DungeonShooting_Godot/src/game/buff/PropFragment.cs
index ef9c638..927ee2e 100644
--- a/DungeonShooting_Godot/src/game/buff/PropFragment.cs
+++ b/DungeonShooting_Godot/src/game/buff/PropFragment.cs
@@ -10,14 +10,22 @@
public Role Role => Master?.Master;
///
- /// 当道具被拾起时调用 (在 Master 赋值之后调用)
+ /// 当道具被拾起时调用 (在 Role 赋值之后调用)
///
public abstract void OnPickUpItem();
///
- /// 当道具被移除时调用 (在 Master 置为 null 之前调用)
+ /// 当道具被移除时调用 (在 Role 置为 null 之前调用)
///
public abstract void OnRemoveItem();
+
+ ///
+ /// 返回道具是否在背包中
+ ///
+ public bool IsInPackage()
+ {
+ return Master != null;
+ }
///
/// 初始化被动属性参数
diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_AreaTrigger.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_AreaTrigger.cs
new file mode 100644
index 0000000..cce7b8c
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_AreaTrigger.cs
@@ -0,0 +1,44 @@
+
+using Godot;
+
+[EffectFragment("AreaTrigger", "")]
+public class Eff_AreaTrigger : EffectFragment
+{
+ private Area2D _areaNode;
+ private CollisionShape2D _shapeNode;
+ private CircleShape2D _shape;
+
+ public override void Ready()
+ {
+ _areaNode = new Area2D();
+ _shapeNode = new CollisionShape2D();
+ _shape = new CircleShape2D();
+ _shapeNode.Shape = _shape;
+
+ _areaNode.AddChild(_shapeNode);
+ AddChild(_areaNode);
+ }
+
+ public override void OnDestroy()
+ {
+ _areaNode.QueueFree();
+ _shapeNode.QueueFree();
+ }
+
+ public override void OnUse()
+ {
+
+ }
+
+ public override void OnPickUpItem()
+ {
+ RemoveChild(_areaNode);
+ Role.AddChild(_areaNode);
+ }
+
+ public override void OnRemoveItem()
+ {
+ Role.RemoveChild(_areaNode);
+ AddChild(_areaNode);
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs
index 3712386..1e80544 100644
--- a/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs
+++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_PiggyBank.cs
@@ -13,9 +13,13 @@
_value = arg1;
}
+ public override bool OnCheckUse()
+ {
+ return _currValue > 0;
+ }
+
public override void OnUse()
{
- Debug.Log("存入了: " + _currValue);
var goldList = Utils.GetGoldList(Mathf.FloorToInt(_currValue * _value));
foreach (var id in goldList)
{
@@ -27,6 +31,8 @@
0
);
}
+
+ _currValue = 0;
}
public override void OnPickUpItem()