diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
index a689872..f427088 100644
--- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
+++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs
@@ -631,7 +631,7 @@
_throwForce = new ExternalForce("throw");
_throwForce.Velocity = velocity;
- MoveController.AddConstantForce(_throwForce);
+ MoveController.AddForce(_throwForce);
InitThrowData();
}
@@ -1122,16 +1122,11 @@
}
///
- /// 继承指定物体的运动速率, 该速率可能会有衰减
+ /// 继承指定物体的运动速率
///
- public void InheritVelocity(ActivityObject other)
+ public void InheritVelocity(ActivityObject other, float scale = 0.5f)
{
- var velocity = other.Velocity;
- if (velocity != Vector2.Zero)
- {
- var force = MoveController.AddConstantForce(velocity * 0.5f, 15);
- force.EnableResistanceInTheAir = false;
- }
+ MoveController.AddVelocity(other.Velocity * scale);
}
///
diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
index b4b8ea4..9e7c149 100644
--- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
+++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs
@@ -43,6 +43,30 @@
BasisVelocity *= scale;
}
+
+ ///
+ /// 给当前控制器添加指定外力速率, 并且平均分配给基础速率和外力速率
+ ///
+ public void AddVelocity(Vector2 velocity)
+ {
+ if (velocity != Vector2.Zero)
+ {
+ var forceCount = GetForceCount();
+ if (forceCount == 0)
+ {
+ _basisVelocity += velocity;
+ }
+ else
+ {
+ var tempV = velocity / (forceCount + 1);
+ _basisVelocity += tempV;
+ for (var i = 0; i < _forceList.Count; i++)
+ {
+ _forceList[i].Velocity += tempV;
+ }
+ }
+ }
+ }
///
/// 设置所有力对象, 包括基础速率
@@ -78,9 +102,9 @@
///
/// 外力速率
/// 阻力大小
- public ExternalForce AddConstantForce(Vector2 velocity, float resistance)
+ public ExternalForce AddForce(Vector2 velocity, float resistance)
{
- var force = AddConstantForce("_anonymity_" + _index++);
+ var force = AddForce("_anonymity_" + _index++);
force.Velocity = velocity;
force.Resistance = resistance;
return force;
@@ -90,9 +114,9 @@
/// 快速创建一个外力, 该外力为匿名外力, 当速率变为 0 时自动销毁
///
/// 外力速率
- public ExternalForce AddConstantForce(Vector2 velocity)
+ public ExternalForce AddForce(Vector2 velocity)
{
- var force = AddConstantForce("_anonymity_" + _index++);
+ var force = AddForce("_anonymity_" + _index++);
force.Velocity = velocity;
return force;
}
@@ -101,18 +125,18 @@
///
/// 根据名称添加一个外力, 并返回创建的外力的对象, 如果存在这个名称的外力, 移除之前的外力, 当速率变为 0 时不会自动销毁
///
- public ExternalForce AddConstantForce(string name)
+ public ExternalForce AddForce(string name)
{
var f = new ExternalForce(name);
f.AutoDestroy = false;
- AddConstantForce(f);
+ AddForce(f);
return f;
}
///
/// 根据对象添加一个外力力, 如果存在这个名称的外力, 移除之前的外力
///
- public T AddConstantForce(T force) where T : ExternalForce
+ public T AddForce(T force) where T : ExternalForce
{
RemoveForce(force.Name);
_forceList.Add(force);
diff --git a/DungeonShooting_Godot/src/framework/activity/components/StateBase.cs b/DungeonShooting_Godot/src/framework/activity/components/StateBase.cs
index c936b6f..ce71a11 100644
--- a/DungeonShooting_Godot/src/framework/activity/components/StateBase.cs
+++ b/DungeonShooting_Godot/src/framework/activity/components/StateBase.cs
@@ -75,7 +75,7 @@
}
///
- /// 立即切换到下一个指定状态, 并且这一帧会被调用 PhysicsProcess
+ /// 立即切换到下一个指定状态, 并且这一帧会被调用 Process
///
public void ChangeStateInstant(S next, params object[] args)
{
@@ -83,7 +83,7 @@
}
///
- /// 切换到下一个指定状态, 下一帧才会调用 PhysicsProcess
+ /// 切换到下一个指定状态, 下一帧才会调用 Process
///
public void ChangeState(S next, params object[] args)
{
diff --git a/DungeonShooting_Godot/src/framework/activity/components/StateController.cs b/DungeonShooting_Godot/src/framework/activity/components/StateController.cs
index ca379b4..ecb69be 100644
--- a/DungeonShooting_Godot/src/framework/activity/components/StateController.cs
+++ b/DungeonShooting_Godot/src/framework/activity/components/StateController.cs
@@ -78,16 +78,16 @@
///
public StateBase GetState(S state)
{
- if (_states.ContainsKey(state))
+ if (_states.TryGetValue(state, out var temp))
{
- return _states[state];
+ return temp;
}
return null;
}
///
- /// 立即切换到下一个指定状态, 并且这一帧会被调用 PhysicsProcess
+ /// 立即切换到下一个指定状态, 并且这一帧会被调用 Process
///
public void ChangeStateInstant(S next, params object[] arg)
{
@@ -95,7 +95,7 @@
}
///
- /// 切换到下一个指定状态, 下一帧才会调用 PhysicsProcess
+ /// 切换到下一个指定状态, 下一帧才会调用 Process
///
public void ChangeState(S next, params object[] arg)
{
diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs
index bc091b0..6e10cc3 100644
--- a/DungeonShooting_Godot/src/game/activity/role/Role.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs
@@ -735,6 +735,10 @@
}
}
+ ///
+ /// 添加被动
+ ///
+ ///
public void PushBuff(Buff buff)
{