diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs b/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs new file mode 100644 index 0000000..2d561fc --- /dev/null +++ b/DungeonShooting_Godot/src/framework/activity/ActivityMaterial.cs @@ -0,0 +1,8 @@ + +/// +/// 物体材质 +/// +public class ActivityMaterial +{ + +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 764238a..a3481de 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -115,7 +115,7 @@ public bool IsThrowing => _throwForce != null && !_isFallOver; /// - /// 当前物体的海拔高度, 如果大于0, 则会做自由落体运动, 也就是执行投抛代码 + /// 当前物体的海拔高度, 如果大于0, 则会做自由落体运动, 也就是执行投抛逻辑 /// public float Altitude { @@ -143,11 +143,6 @@ } private float _verticalSpeed; - - /// - /// 物体投抛时旋转速度, 角度制 - /// - public float ThrowRotationDegreesSpeed { get; set; } /// /// 落地之后是否回弹 @@ -163,6 +158,11 @@ /// 物体下坠回弹后的运动速度衰减量 /// public float BounceSpeed { get; set; } = 0.75f; + + /// + /// 物体下坠回弹后的旋转速度衰减量 + /// + public float BounceRotationSpeed { get; set; } = 0.5f; /// /// 投抛状态下物体碰撞器大小, 如果 (x, y) 都小于 0, 则默认使用 AnimatedSprite 的默认动画第一帧的大小 @@ -207,6 +207,11 @@ public bool EnableCustomBehavior { get; set; } = true; /// + /// 物体材质数据 + /// + public ActivityMaterial ActivityMaterial { get; private set; } + + /// /// 所在的 World 对象 /// public World World { get; private set; } @@ -703,7 +708,7 @@ Altitude = altitude; //Position = Position + new Vector2(0, altitude); VerticalSpeed = verticalSpeed; - ThrowRotationDegreesSpeed = rotateSpeed; + //ThrowRotationDegreesSpeed = rotateSpeed; if (_throwForce != null) { MoveController.RemoveForce(_throwForce); @@ -711,6 +716,7 @@ _throwForce = new ExternalForce(ForceNames.Throw); _throwForce.Velocity = velocity; + _throwForce.RotationSpeed = Mathf.DegToRad(rotateSpeed); MoveController.AddForce(_throwForce); InitThrowData(); @@ -909,7 +915,7 @@ { if (EnableVerticalMotion) //如果启用了纵向运动, 则更新运动 { - GlobalRotationDegrees = GlobalRotationDegrees + ThrowRotationDegreesSpeed * newDelta; + //GlobalRotationDegrees = GlobalRotationDegrees + ThrowRotationDegreesSpeed * newDelta; var ysp = VerticalSpeed; @@ -944,7 +950,15 @@ OnFirstFallToGround(); } - MoveController.ScaleAllForce(BounceSpeed); + if (_throwForce != null) + { + //缩放移动速度 + //MoveController.ScaleAllForce(BounceSpeed); + _throwForce.Velocity *= BounceSpeed; + //缩放旋转速度 + //MoveController.ScaleAllRotationSpeed(BounceStrength); + _throwForce.RotationSpeed *= BounceRotationSpeed; + } //如果落地高度不够低, 再抛一次 if (Bounce && (!_hasResilienceVerticalSpeed || _resilienceVerticalSpeed > 5)) { @@ -965,7 +979,6 @@ } } _verticalSpeed = _resilienceVerticalSpeed; - ThrowRotationDegreesSpeed = ThrowRotationDegreesSpeed * BounceStrength; _isFallOver = false; OnFallToGround(); diff --git a/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs b/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs index 5f45e1b..02ee215 100644 --- a/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs +++ b/DungeonShooting_Godot/src/framework/activity/ExternalForce.cs @@ -22,7 +22,7 @@ public bool EnableResistanceInTheAir { get; set; } = true; /// - /// 当速度(Velocity和RotationSpeed)到达 0 后是否自动销毁, 默认 true + /// 当速度( Velocity 和 RotationSpeed )到达 0 后是否自动销毁, 默认 true /// public bool AutoDestroy { get; set; } = true; diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs index cff7286..e577646 100644 --- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs +++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs @@ -32,9 +32,9 @@ private Vector2 _basisVelocity = Vector2.Zero; /// - /// 缩放所有力对象, 包括基础速率 + /// 缩放所有外力对象的速率, 包括基础速率 /// - public void ScaleAllForce(float scale) + public void ScaleAllVelocity(float scale) { foreach (var externalForce in _forceList) { @@ -43,9 +43,20 @@ BasisVelocity *= scale; } + + /// + /// 缩放所有外力对象的旋转速率 + /// + public void ScaleAllRotationSpeed(float scale) + { + foreach (var externalForce in _forceList) + { + externalForce.RotationSpeed *= scale; + } + } /// - /// 给当前控制器添加指定外力速率, 并且平均分配给所有外力速率 + /// 添加外力速率, 并且平均分配给所有外力速率 /// public void AddVelocity(Vector2 velocity) { @@ -68,9 +79,28 @@ } /// - /// 设置所有力对象, 包括基础速率 + /// 添加外力旋转速率, 并且平均分配给所有外力旋转速率 /// - public void SetAllForce(Vector2 value) + public void AddRotationSpeed(float speed) + { + if (speed != 0) + { + var forceCount = GetForceCount(); + if (forceCount > 0) + { + var tempS = speed / forceCount; + for (var i = 0; i < _forceList.Count; i++) + { + _forceList[i].RotationSpeed += tempS; + } + } + } + } + + /// + /// 设置所有外力对象的速率 + /// + public void SetAllVelocity(Vector2 value) { foreach (var externalForce in _forceList) { @@ -81,6 +111,17 @@ } /// + /// 设置所有外力对象的旋转速率 + /// + public void SetAllRotationSpeed(float speed) + { + foreach (var externalForce in _forceList) + { + externalForce.RotationSpeed = speed; + } + } + + /// /// 获取所有外力对象 /// public ExternalForce[] GetAllForce() @@ -97,7 +138,7 @@ } /// - /// 快速创建一个外力, 该外力为匿名外力, 当速率变为 0 时自动销毁 + /// 快速创建一个速率外力, 该外力为匿名外力, 当速率变为 0 时自动销毁 /// /// 外力速率 /// 阻力大小 @@ -111,6 +152,20 @@ } /// + /// 快速创建一个旋转外力, 该外力为匿名外力, 当速率变为 0 时自动销毁 + /// + /// 外力旋转速率, 弧度制 + /// 阻力大小 + public ExternalForce AddForce(float rotationSpeed, float resistance) + { + var force = AddForce("_anonymity_" + _index++); + force.AutoDestroy = true; + force.RotationSpeed = rotationSpeed; + force.RotationResistance = resistance; + return force; + } + + /// /// 快速创建一个外力, 该外力为匿名外力, 当速率变为 0 时自动销毁 /// /// 外力速率 diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index 6010427..027db19 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -981,11 +981,10 @@ else { damage = RoleState.CallCalcHurtDamageEvent(damage); - if (damage < 0) + if (damage > 0) { - return; + Hp -= damage; } - Hp -= damage; //播放血液效果 // var packedScene = ResourceManager.Load(ResourcePath.prefab_effect_Blood_tscn); // var blood = packedScene.Instance();