diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx index 62c2d8a..3dd1c83 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx index ad56ce8..4c523b5 100644 --- a/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/ActivityMaterial.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx index 4531299..78b30fd 100644 --- a/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/AiAttackAttr.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx index 8e3e0b4..809d271 100644 --- a/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/BulletBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx index 5a36ef9..543b8cd 100644 --- a/DungeonShooting_Godot/excel/excelFile/Sound.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/Sound.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx index c5a29ed..8738ff1 100644 --- a/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx +++ b/DungeonShooting_Godot/excel/excelFile/WeaponBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/resource/config/BulletBase.json b/DungeonShooting_Godot/resource/config/BulletBase.json index babab79..06fc6ed 100644 --- a/DungeonShooting_Godot/resource/config/BulletBase.json +++ b/DungeonShooting_Godot/resource/config/BulletBase.json @@ -7,7 +7,7 @@ "HarmRange": [ 4 ], - "RepelRnage": [ + "RepelRange": [ 20 ], "DeviationAngleRange": [ @@ -41,7 +41,7 @@ "HarmRange": [ 4 ], - "RepelRnage": [ + "RepelRange": [ 30 ], "DeviationAngleRange": [ @@ -76,7 +76,7 @@ "HarmRange": [ 3 ], - "RepelRnage": [ + "RepelRange": [ 10 ], "DeviationAngleRange": [ @@ -110,7 +110,7 @@ "HarmRange": [ 20 ], - "RepelRnage": [ + "RepelRange": [ 200 ], "DeviationAngleRange": [ @@ -144,7 +144,7 @@ "HarmRange": [ 30 ], - "RepelRnage": [ + "RepelRange": [ 0 ], "DeviationAngleRange": [ @@ -178,7 +178,7 @@ "HarmRange": [ 5 ], - "RepelRnage": [ + "RepelRange": [ 0 ], "DeviationAngleRange": [ @@ -210,7 +210,7 @@ "HarmRange": [ 25 ], - "RepelRnage": [ + "RepelRange": [ 150 ], "DeviationAngleRange": [ diff --git a/DungeonShooting_Godot/resource/config/WeaponBase.json b/DungeonShooting_Godot/resource/config/WeaponBase.json index 4e75043..8f0b579 100644 --- a/DungeonShooting_Godot/resource/config/WeaponBase.json +++ b/DungeonShooting_Godot/resource/config/WeaponBase.json @@ -5,6 +5,7 @@ "Remark": "\u6B65\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": true, "AmmoCapacity": 30, "MaxAmmoCapacity": 420, @@ -59,7 +60,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0005", @@ -81,6 +82,7 @@ "Remark": "\u6B65\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 30, "MaxAmmoCapacity": 420, @@ -135,7 +137,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0005", @@ -157,6 +159,7 @@ "Remark": "\u9730\u5F39\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 7, "MaxAmmoCapacity": 140, @@ -211,7 +214,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0003", @@ -233,6 +236,7 @@ "Remark": "\u9730\u5F39\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 7, "MaxAmmoCapacity": 140, @@ -287,7 +291,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0003", @@ -309,6 +313,7 @@ "Remark": "\u624B\u67AA", "Weight": 20, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 12, "MaxAmmoCapacity": 180, @@ -363,7 +368,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0004", @@ -385,6 +390,7 @@ "Remark": "\u624B\u67AA", "Weight": 20, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 12, "MaxAmmoCapacity": 180, @@ -439,7 +445,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0004", @@ -461,6 +467,7 @@ "Remark": "\u5200", "Weight": 40, "WeightType": 2, + "IsMelee": true, "ContinuousShoot": false, "AmmoCapacity": 180, "MaxAmmoCapacity": 180, @@ -514,7 +521,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "", @@ -536,6 +543,7 @@ "Remark": "\u5200", "Weight": 40, "WeightType": 2, + "IsMelee": true, "ContinuousShoot": false, "AmmoCapacity": 180, "MaxAmmoCapacity": 180, @@ -589,7 +597,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "", @@ -611,6 +619,7 @@ "Remark": "\u72D9\u51FB\u67AA", "Weight": 50, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 10, "MaxAmmoCapacity": 80, @@ -665,7 +674,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0008", @@ -687,6 +696,7 @@ "Remark": "\u72D9\u51FB\u67AA", "Weight": 50, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 10, "MaxAmmoCapacity": 80, @@ -741,7 +751,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0008", @@ -763,6 +773,7 @@ "Remark": "\u51B2\u950B\u67AA", "Weight": 30, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": true, "AmmoCapacity": 20, "MaxAmmoCapacity": 600, @@ -817,7 +828,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0002", @@ -839,6 +850,7 @@ "Remark": "\u51B2\u950B\u67AA", "Weight": 30, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 20, "MaxAmmoCapacity": 600, @@ -893,7 +905,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0002", @@ -915,6 +927,7 @@ "Remark": "\u6C64\u59C6\u900A\u51B2\u950B\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": true, "AmmoCapacity": 60, "MaxAmmoCapacity": 600, @@ -969,7 +982,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0007", @@ -991,6 +1004,7 @@ "Remark": "\u6C64\u59C6\u900A\u51B2\u950B\u67AA", "Weight": 40, "WeightType": 2, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 60, "MaxAmmoCapacity": 600, @@ -1045,7 +1059,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0007", @@ -1067,6 +1081,7 @@ "Remark": "\u6FC0\u5149\u624B\u67AA", "Weight": 40, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 10, "MaxAmmoCapacity": 240, @@ -1121,7 +1136,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0010", @@ -1143,6 +1158,7 @@ "Remark": "\u6FC0\u5149\u624B\u67AA", "Weight": 40, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 10, "MaxAmmoCapacity": 240, @@ -1197,7 +1213,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0010", @@ -1219,6 +1235,7 @@ "Remark": "\u69B4\u5F39\u53D1\u5C04\u5668", "Weight": 40, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 1, "MaxAmmoCapacity": 50, @@ -1273,7 +1290,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0011", @@ -1295,6 +1312,7 @@ "Remark": "\u69B4\u5F39\u53D1\u5C04\u5668", "Weight": 40, "WeightType": 1, + "IsMelee": false, "ContinuousShoot": false, "AmmoCapacity": 1, "MaxAmmoCapacity": 50, @@ -1349,7 +1367,7 @@ "MeleeAttackHarmRange": [ 10 ], - "MeleeAttackRepelRnage": [ + "MeleeAttackRepelRange": [ 100 ], "__ShootSound": "shooting0011", diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs index 0f0dcb0..4faf653 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_BulletBase.cs @@ -50,7 +50,7 @@ /// 格式为[value]或者[min,max] /// [JsonInclude] - public float[] RepelRnage; + public float[] RepelRange; /// /// 子弹偏移角度区间
@@ -123,7 +123,7 @@ inst.Type = Type; inst.Prefab = Prefab; inst.HarmRange = HarmRange; - inst.RepelRnage = RepelRnage; + inst.RepelRange = RepelRange; inst.DeviationAngleRange = DeviationAngleRange; inst.SpeedRange = SpeedRange; inst.LifeTimeRange = LifeTimeRange; diff --git a/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs index e45f05e..8a535fd 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs @@ -40,6 +40,12 @@ public byte WeightType; /// + /// 标记是否是近战武器 + /// + [JsonInclude] + public bool IsMelee; + + /// /// 是否连续发射, 如果为false, 则每次发射都需要扣动扳机 /// [JsonInclude] @@ -298,7 +304,7 @@ /// 格式为[value]或者[min,max] ///
[JsonInclude] - public float[] MeleeAttackRepelRnage; + public float[] MeleeAttackRepelRange; /// /// 射击音效 @@ -379,6 +385,7 @@ inst.Remark = Remark; inst.Weight = Weight; inst.WeightType = WeightType; + inst.IsMelee = IsMelee; inst.ContinuousShoot = ContinuousShoot; inst.AmmoCapacity = AmmoCapacity; inst.MaxAmmoCapacity = MaxAmmoCapacity; @@ -421,7 +428,7 @@ inst.ThrowCollisionSize = ThrowCollisionSize; inst.CanMeleeAttack = CanMeleeAttack; inst.MeleeAttackHarmRange = MeleeAttackHarmRange; - inst.MeleeAttackRepelRnage = MeleeAttackRepelRnage; + inst.MeleeAttackRepelRange = MeleeAttackRepelRange; inst.ShootSound = ShootSound; inst.BeginReloadSound = BeginReloadSound; inst.BeginReloadSoundDelayTime = BeginReloadSoundDelayTime; diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 976ffb4..86b0d3d 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -33,21 +33,15 @@ [Export] public Node2D GlobalNodeRoot; /// - /// 是否开启调试 - /// - [ExportGroup("Debug")] - [Export] public bool IsDebug; - - /// /// 游戏目标帧率 /// - public int TargetFps { get; private set; } = 60; + public int TargetFps { get; private set; } /// /// 鼠标指针 /// public Cursor Cursor { get; private set; } - + /// /// 游戏世界 /// @@ -113,7 +107,7 @@ //Engine.MaxFps = TargetFps; //调试绘制开关 //IsDebug = true; - ActivityObject.IsDebug = IsDebug; + ActivityObject.IsDebug = false; //Engine.TimeScale = 0.2f; //调整窗口分辨率 OnWindowSizeChanged(); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs index fbd2791..4e1ec39 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs @@ -128,7 +128,7 @@ var damage = Utils.Random.RandomRangeInt(BulletData.MinHarm, BulletData.MaxHarm); if (BulletData.TriggerRole != null) { - damage = BulletData.TriggerRole.RoleState.CallCalcDamageEvent(damage); + damage = BulletData.TriggerRole.RoleState.CalcDamage(damage); } //造成伤害 role.CallDeferred(nameof(Role.Hurt), damage, Rotation); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index 0c24cdc..94208a4 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -118,14 +118,19 @@ var damage = Utils.Random.RandomRangeInt(BulletData.MinHarm, BulletData.MaxHarm); if (BulletData.TriggerRole != null) { - damage = BulletData.TriggerRole.RoleState.CallCalcDamageEvent(damage); + damage = BulletData.TriggerRole.RoleState.CalcDamage(damage); } //击退 if (role is not Player) //目标不是玩家才会触发击退 { var attr = BulletData.Weapon.GetUseAttribute(BulletData.TriggerRole); - var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRnage); + //计算子弹造成的击退 + var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRange); + if (BulletData.TriggerRole != null) + { + repel = BulletData.TriggerRole.RoleState.CalcBulletRepel(BulletData.Weapon, repel); + } if (repel != 0) { //role.MoveController.AddForce(Vector2.FromAngle(BasisVelocity.Angle()) * repel); diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs index 306ae09..e10d418 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0004.cs @@ -2,18 +2,18 @@ using Godot; /// -/// 护盾恢复时间buff, 恢复时间 - 1.5s +/// 护盾恢复时间buff, 恢复时间 - 2.5s /// [Tool] public partial class BuffPropProp0004 : BuffProp { public override void OnPickUpItem() { - Master.RoleState.ShieldRecoveryTime -= 1.5f; + Master.RoleState.ShieldRecoveryTime -= 2.5f; } public override void OnRemoveItem() { - Master.RoleState.ShieldRecoveryTime += 1.5f; + Master.RoleState.ShieldRecoveryTime += 2.5f; } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs index b359f48..9ec8e03 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs @@ -2,7 +2,7 @@ using Godot; /// -/// 分裂子弹 子弹数量翻倍, 但是精准度和伤害降低 +/// 分裂子弹 子弹数量翻倍, 但是精准度, 击退和伤害降低 /// [Tool] public partial class BuffPropProp0010 : BuffProp @@ -13,6 +13,7 @@ Master.RoleState.CalcBulletDeviationAngleEvent += CalcBulletDeviationAngleEvent; Master.RoleState.CalcDamageEvent += CalcDamageEvent; Master.RoleState.CalcBulletSpeedEvent += CalcBulletSpeedEvent; + Master.RoleState.CalcBulletRepelEvent += CalcBulletRepelEvent; } public override void OnRemoveItem() @@ -21,6 +22,7 @@ Master.RoleState.CalcBulletDeviationAngleEvent -= CalcBulletDeviationAngleEvent; Master.RoleState.CalcDamageEvent -= CalcDamageEvent; Master.RoleState.CalcBulletSpeedEvent -= CalcBulletSpeedEvent; + Master.RoleState.CalcBulletRepelEvent -= CalcBulletRepelEvent; } private void CalcBulletCountEvent(Weapon weapon, int originCount, RefValue refValue) @@ -40,11 +42,21 @@ return; } - refValue.Value = Mathf.Max(1, refValue.Value - Mathf.FloorToInt(originDamage * 0.4f)); + refValue.Value = Mathf.Max(1, refValue.Value - Mathf.FloorToInt(refValue.Value * 0.35f)); } private void CalcBulletSpeedEvent(Weapon weapon, float originSpeed, RefValue speed) { speed.Value += originSpeed * Utils.Random.RandomRangeFloat(-0.05f, 0.05f); } + + private void CalcBulletRepelEvent(Weapon weapon, float originRepel, RefValue repel) + { + if (weapon.Attribute.IsMelee || repel.Value < 0) + { + return; + } + + repel.Value = Mathf.Max(1, repel.Value - Mathf.FloorToInt(repel.Value * 0.35f)); + } } \ 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 f9a1f9f..737e95e 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -1009,7 +1009,7 @@ } else { - damage = RoleState.CallCalcHurtDamageEvent(damage); + damage = RoleState.CalcHurtDamage(damage); if (damage > 0) { Hp -= damage; @@ -1165,13 +1165,13 @@ if (activityObject is Role role) //攻击角色 { var damage = Utils.Random.RandomConfigRange(activeWeapon.Attribute.MeleeAttackHarmRange); - damage = RoleState.CallCalcDamageEvent(damage); + damage = RoleState.CalcDamage(damage); //击退 if (role is not Player) //目标不是玩家才会触发击退 { var attr = IsAi ? activeWeapon.AiUseAttribute : activeWeapon.PlayerUseAttribute; - var repel = Utils.Random.RandomConfigRange(attr.MeleeAttackRepelRnage); + var repel = Utils.Random.RandomConfigRange(attr.MeleeAttackRepelRange); var position = role.GlobalPosition - MountPoint.GlobalPosition; var v2 = position.Normalized() * repel; role.MoveController.AddForce(v2); diff --git a/DungeonShooting_Godot/src/game/activity/role/RoleState.cs b/DungeonShooting_Godot/src/game/activity/role/RoleState.cs index c2c629b..09bec56 100644 --- a/DungeonShooting_Godot/src/game/activity/role/RoleState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/RoleState.cs @@ -55,7 +55,7 @@ /// 攻击/发射后计算伤害 /// public event Action> CalcDamageEvent; - public int CallCalcDamageEvent(int damage) + public int CalcDamage(int damage) { if (CalcDamageEvent != null) { @@ -71,7 +71,7 @@ /// 受伤后计算受到的伤害 /// public event Action> CalcHurtDamageEvent; - public int CallCalcHurtDamageEvent(int damage) + public int CalcHurtDamage(int damage) { if (CalcHurtDamageEvent != null) { @@ -87,7 +87,7 @@ /// 武器初始散射值增量 /// public event Action> CalcStartScatteringEvent; - public float CallCalcStartScatteringEvent(Weapon weapon, float value) + public float CalcStartScattering(Weapon weapon, float value) { if (CalcStartScatteringEvent != null) { @@ -103,7 +103,7 @@ /// 武器最终散射值增量 /// public event Action> CalcFinalScatteringEvent; - public float CallCalcFinalScatteringEvent(Weapon weapon, float value) + public float CalcFinalScattering(Weapon weapon, float value) { if (CalcFinalScatteringEvent != null) { @@ -119,7 +119,7 @@ /// 武器开火发射子弹数量 /// public event Action> CalcBulletCountEvent; - public int CallCalcBulletCountEvent(Weapon weapon, int count) + public int CalcBulletCount(Weapon weapon, int count) { if (CalcBulletCountEvent != null) { @@ -135,7 +135,7 @@ /// 子弹偏移角度, 角度制 /// public event Action> CalcBulletDeviationAngleEvent; - public float CallCalcBulletDeviationAngleEvent(Weapon weapon, float angle) + public float CalcBulletDeviationAngle(Weapon weapon, float angle) { if (CalcBulletDeviationAngleEvent != null) { @@ -151,7 +151,7 @@ /// 子弹速度 /// public event Action> CalcBulletSpeedEvent; - public float CallCalcBulletSpeedEvent(Weapon weapon, float speed) + public float CalcBulletSpeed(Weapon weapon, float speed) { if (CalcBulletSpeedEvent != null) { @@ -167,7 +167,7 @@ /// 子弹射程 /// public event Action> CalcBulletDistanceEvent; - public float CallCalcBulletDistanceEvent(Weapon weapon, float distance) + public float CalcBulletDistance(Weapon weapon, float distance) { if (CalcBulletDistanceEvent != null) { @@ -178,4 +178,20 @@ return distance; } + + /// + /// 子弹击退 + /// + public event Action> CalcBulletRepelEvent; + public float CalcBulletRepel(Weapon weapon, float distance) + { + if (CalcBulletRepelEvent != null) + { + var result = new RefValue(distance); + CalcBulletRepelEvent(weapon, distance, result); + return result.Value; + } + + return distance; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index b59ba0e..2c2c309 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -146,7 +146,7 @@ public bool NoMasterCanTrigger { get; set; } = true; /// - /// 上一次触发改武器开火的角色 + /// 上一次触发改武器开火的角色, 可能为 null /// public Role TriggerRole { get; private set; } @@ -1034,7 +1034,7 @@ var bulletCount = Utils.Random.RandomConfigRange(Attribute.FireBulletCountRange); if (Master != null) { - bulletCount = Master.RoleState.CallCalcBulletCountEvent(this, bulletCount); + bulletCount = Master.RoleState.CalcBulletCount(this, bulletCount); fireRotation += Master.MountPoint.RealRotation; } else @@ -1492,8 +1492,8 @@ var finalScatteringRange = Attribute.FinalScatteringRange; if (Master != null) { - startScatteringRange = Master.RoleState.CallCalcStartScatteringEvent(this, startScatteringRange); - finalScatteringRange = Master.RoleState.CallCalcFinalScatteringEvent(this, finalScatteringRange); + startScatteringRange = Master.RoleState.CalcStartScattering(this, startScatteringRange); + finalScatteringRange = Master.RoleState.CalcFinalScattering(this, finalScatteringRange); } if (startScatteringRange <= finalScatteringRange) { @@ -1514,8 +1514,8 @@ var finalScatteringRange = Attribute.FinalScatteringRange; if (Master != null) { - startScatteringRange = Master.RoleState.CallCalcStartScatteringEvent(this, startScatteringRange); - finalScatteringRange = Master.RoleState.CallCalcFinalScatteringEvent(this, finalScatteringRange); + startScatteringRange = Master.RoleState.CalcStartScattering(this, startScatteringRange); + finalScatteringRange = Master.RoleState.CalcFinalScattering(this, finalScatteringRange); } if (startScatteringRange <= finalScatteringRange) { @@ -1982,9 +1982,9 @@ var deviationAngle = Utils.Random.RandomConfigRange(bullet.DeviationAngleRange); if (TriggerRole != null) { - data.FlySpeed = TriggerRole.RoleState.CallCalcBulletSpeedEvent(this, data.FlySpeed); - data.MaxDistance = TriggerRole.RoleState.CallCalcBulletDistanceEvent(this, data.MaxDistance); - deviationAngle = TriggerRole.RoleState.CallCalcBulletDeviationAngleEvent(this, deviationAngle); + data.FlySpeed = TriggerRole.RoleState.CalcBulletSpeed(this, data.FlySpeed); + data.MaxDistance = TriggerRole.RoleState.CalcBulletDistance(this, data.MaxDistance); + deviationAngle = TriggerRole.RoleState.CalcBulletDeviationAngle(this, deviationAngle); } if (TriggerRole != null && TriggerRole.IsAi) //只有玩家使用该武器才能获得正常速度的子弹 @@ -2020,7 +2020,7 @@ var deviationAngle = Utils.Random.RandomConfigRange(bullet.DeviationAngleRange); if (TriggerRole != null) { - deviationAngle = TriggerRole.RoleState.CallCalcBulletDeviationAngleEvent(this, deviationAngle); + deviationAngle = TriggerRole.RoleState.CalcBulletDeviationAngle(this, deviationAngle); } data.Rotation = fireRotation + Mathf.DegToRad(deviationAngle); diff --git a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs index a8c3dff..f54b9d3 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs @@ -130,18 +130,32 @@ if (activityObject is Role role) //碰到角色 { var damage = Utils.Random.RandomConfigRange(Attribute.Bullet.HarmRange); - damage = Master.RoleState.CallCalcDamageEvent(damage); - //击退 - if (role is not Player) //目标不是玩家才会触发击退 + //计算子弹造成的伤害 + if (TriggerRole != null) { - var attr = Master.IsAi ? AiUseAttribute : PlayerUseAttribute; - var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRnage); - if (repel != 0) + damage = TriggerRole.RoleState.CalcDamage(damage); + } + //击退 + var attr = GetUseAttribute(TriggerRole); + var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRange); + //计算击退 + if (TriggerRole != null) + { + repel = TriggerRole.RoleState.CalcBulletRepel(this, repel); + } + if (repel != 0) + { + Vector2 position; + if (TriggerRole != null) { - var position = role.GlobalPosition - Master.MountPoint.GlobalPosition; - var v2 = position.Normalized() * repel; - role.MoveController.AddForce(v2); + position = role.GlobalPosition - TriggerRole.MountPoint.GlobalPosition; } + else + { + position = role.GlobalPosition - GlobalPosition; + } + var v2 = position.Normalized() * repel; + role.MoveController.AddForce(v2); } //造成伤害 @@ -150,12 +164,12 @@ else if (activityObject is Bullet bullet) //攻击子弹 { var attackLayer = bullet.AttackLayer; - if (Master.CollisionWithMask(attackLayer)) //是攻击玩家的子弹 + if (TriggerRole != null && TriggerRole.CollisionWithMask(attackLayer)) //是攻击玩家的子弹 { bullet.PlayDisappearEffect(); bullet.BasisVelocity = bullet.BasisVelocity.Rotated(Mathf.Pi); bullet.Rotation += Mathf.Pi; - bullet.AttackLayer = Master.AttackLayer; + bullet.AttackLayer = TriggerRole.AttackLayer; } } } diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index c83bbf3..fae30b5 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -185,7 +185,7 @@ //更新敌人视野 UpdateEnemiesView(); - if (GameApplication.Instance.IsDebug) + if (ActivityObject.IsDebug) { QueueRedraw(); } @@ -651,7 +651,7 @@ public override void _Draw() { - if (GameApplication.Instance.IsDebug) + if (ActivityObject.IsDebug) { if (_dungeonTileMap != null && _roomStaticNavigationList != null) {