diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AIAdvancedStateEnum.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AIAdvancedStateEnum.cs index a04b743..a9c963d 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AIAdvancedStateEnum.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AIAdvancedStateEnum.cs @@ -5,15 +5,15 @@ /// Ai 状态, 正常, 未发现目标 /// AiNormal, - // /// - // /// 发现目标, 但不知道在哪 - // /// - // AiProbe, /// /// 找到玩家,准备通知其他敌人 /// AiFind, /// + /// 惊讶状态 + /// + AiAstonished, + /// /// 收到其他敌人通知, 前往发现目标的位置 /// AiLeaveFor, diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiProbeState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiProbeState.cs deleted file mode 100644 index 3f8a865..0000000 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/advancedState/AiProbeState.cs +++ /dev/null @@ -1,20 +0,0 @@ -// -// /// -// /// Ai 不确定玩家位置 -// /// -// public class AiProbeState : StateBase -// { -// public AiProbeState() : base(AiStateEnum.AiProbe) -// { -// } -// -// public override void Process(float delta) -// { -// //其他敌人发现玩家 -// if (Master.CanChangeLeaveFor()) -// { -// ChangeState(AiStateEnum.AiLeaveFor); -// return; -// } -// } -// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index f77474a..74d2215 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -184,8 +184,6 @@ OnCheckEnemy(); } - //更新敌人视野 - UpdateEnemiesView(); if (ActivityObject.IsDebug) { QueueRedraw(); @@ -635,52 +633,6 @@ } } - /// - /// 更新敌人视野 - /// - private void UpdateEnemiesView() - { - World.Enemy_IsFindTarget = false; - World.Enemy_FindTargetAffiliationSet.Clear(); - for (var i = 0; i < World.Enemy_InstanceList.Count; i++) - { - var enemy = World.Enemy_InstanceList[i]; - if (enemy is Enemy e) - { - var state = e.StateController.CurrState; - if (state == AINormalStateEnum.AiFollowUp || state == AINormalStateEnum.AiSurround) //目标在视野内 - { - if (!World.Enemy_IsFindTarget) - { - World.Enemy_IsFindTarget = true; - World.Enemy_FindTargetPosition = Player.Current.GetCenterPosition(); - World.Enemy_FindTargetAffiliationSet.Add(Player.Current.AffiliationArea); - } - World.Enemy_FindTargetAffiliationSet.Add(enemy.AffiliationArea); - } - } - else if (enemy is AdvancedEnemy ae) - { - var state = ae.StateController.CurrState; - if (state == AIAdvancedStateEnum.AiFollowUp || state == AIAdvancedStateEnum.AiSurround || state == AIAdvancedStateEnum.AiFindAmmo) //目标在视野内 - { - if (!World.Enemy_IsFindTarget) - { - World.Enemy_IsFindTarget = true; - World.Enemy_FindTargetPosition = Player.Current.GetCenterPosition(); - World.Enemy_FindTargetAffiliationSet.Add(Player.Current.AffiliationArea); - } - World.Enemy_FindTargetAffiliationSet.Add(enemy.AffiliationArea); - } - } - else - { - throw new Exception("World.Enemy_InstanceList 混入了非 Enemy 和 AdvancedEnemy 类型的对象!"); - } - - } - } - private void DisposeRoomInfo(RoomInfo roomInfo) { roomInfo.Destroy(); diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index 30a6676..27d4805 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using Godot; +using NnormalState; /// /// 游戏世界 @@ -64,20 +65,20 @@ /// public List Enemy_InstanceList { get; } = new List(); - /// - /// 公共属性, 敌人是否找到目标, 如果找到目标, 则与目标同房间的所有敌人都会知道目标的位置 - /// - public bool Enemy_IsFindTarget { get; set; } - - /// - /// 公共属性, 敌人在哪个区域找到的目标, 所有该区域下的敌人都会知道目标的位置 - /// - public HashSet Enemy_FindTargetAffiliationSet { get; } = new HashSet(); - - /// - /// 公共属性, 敌人找到的目标的位置, 如果目标在视野内, 则一直更新 - /// - public Vector2 Enemy_FindTargetPosition { get; set; } + // /// + // /// 公共属性, 敌人是否找到目标, 如果找到目标, 则与目标同房间的所有敌人都会知道目标的位置 + // /// + // public bool Enemy_IsFindTarget { get; set; } + // + // /// + // /// 公共属性, 敌人在哪个区域找到的目标, 所有该区域下的敌人都会知道目标的位置 + // /// + // public HashSet Enemy_FindTargetAffiliationSet { get; } = new HashSet(); + // + // /// + // /// 公共属性, 敌人找到的目标的位置, 如果目标在视野内, 则一直更新 + // /// + // public Vector2 Enemy_FindTargetPosition { get; set; } private bool _pause = false; private List _coroutineList; @@ -115,6 +116,29 @@ return null; } + + /// + /// 通知其他敌人发现目标了 + /// + /// 发送通知的角色 + /// 目标 + public void NotifyEnemyTarget(Role self, ActivityObject target) + { + foreach (var role in Enemy_InstanceList) + { + if (role != self && role.AffiliationArea == self.AffiliationArea) + { + if (role is AdvancedEnemy advancedEnemy) + { + //将未发现目标的敌人状态置为惊讶状态 + if (advancedEnemy.StateController.CurrState == AIAdvancedStateEnum.AiNormal) + { + advancedEnemy.StateController.ChangeState(AIAdvancedStateEnum.AiAstonished); + } + } + } + } + } public long StartCoroutine(IEnumerator able) {