diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start2/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start2/Preinstall.json index 763ac16c..553b233b 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start2/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start2/Preinstall.json @@ -1 +1 @@ -[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":53,"Y":31},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file +[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":53,"Y":31},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"},"Altitude":0,"VerticalSpeed":5.551115E-14}]},{"Position":{"X":84,"Y":8},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":"weapon0002","CurrAmmon":"7","ResidueAmmo":"7"},"Altitude":0,"VerticalSpeed":5.551115E-14}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs index a459fe4d..de6b899f 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs @@ -122,6 +122,7 @@ public abstract partial class AiRole : Role { if (AttackTarget == null || AttackTarget.IsDestroyed || !IsEnemy(AttackTarget)) { + AttackTarget = null; foreach (var role in World.Role_InstanceList) { if (role.AffiliationArea == AffiliationArea && IsEnemy(role)) diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiAttackState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiAttackState.cs index 12acf2e5..8fcb08d3 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiAttackState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiAttackState.cs @@ -83,6 +83,12 @@ public class AiAttackState : StateBase public override void Process(float delta) { + if (Master.LookTarget == null || Master.LookTarget.IsDestroyed || (Master.LookTarget is Role role && !Master.IsEnemy(role))) //更改攻击状态 + { + ChangeState(AIStateEnum.AiNormal); + return; + } + //更新标记位置 Master.UpdateMarkTargetPosition(); diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiSurroundState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiSurroundState.cs index 94afce73..46497e13 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiSurroundState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiSurroundState.cs @@ -43,6 +43,12 @@ public class AiSurroundState : StateBase public override void Process(float delta) { + if (Master.LookTarget == null) + { + ChangeState(AIStateEnum.AiNormal); + return; + } + //先检查弹药是否打光 if (Master.IsAllWeaponTotalAmmoEmpty()) { diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index 9db906b9..1f8dd9f9 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -128,20 +128,27 @@ public partial class Enemy : AiRole //看向目标 if (LookTarget != null && MountLookTarget) { - var pos = LookTarget.Position; - LookPosition = pos; - //脸的朝向 - var gPos = Position; - if (pos.X > gPos.X && Face == FaceDirection.Left) + if (LookTarget.IsDestroyed) { - Face = FaceDirection.Right; + LookTarget = null; } - else if (pos.X < gPos.X && Face == FaceDirection.Right) + else { - Face = FaceDirection.Left; + var pos = LookTarget.Position; + LookPosition = pos; + //脸的朝向 + var gPos = Position; + if (pos.X > gPos.X && Face == FaceDirection.Left) + { + Face = FaceDirection.Right; + } + else if (pos.X < gPos.X && Face == FaceDirection.Right) + { + Face = FaceDirection.Left; + } + //枪口跟随目标 + MountPoint.SetLookAt(pos); } - //枪口跟随目标 - MountPoint.SetLookAt(pos); } if (RoleState.CanPickUpWeapon) diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 0bc007ce..ca2e85fc 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -203,6 +203,15 @@ public partial class Player : Role else if (InputManager.UseActiveProp) //使用道具 { UseActiveProp(); + + foreach (var role in World.Role_InstanceList) + { + if (IsEnemy(role)) + { + role.Camp = Camp; + break; + } + } } else if (InputManager.ExchangeProp) //切换道具 {