diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs index 0ae1c61..56766a5 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/AiRole.cs @@ -123,7 +123,7 @@ /// public bool CheckUsableWeaponInUnclaimed() { - foreach (var unclaimedWeapon in World.Weapon_UnclaimedWeapons) + foreach (var unclaimedWeapon in World.Weapon_UnclaimedList) { //判断是否能拾起武器, 条件: 相同的房间 if (unclaimedWeapon.AffiliationArea == AffiliationArea) @@ -163,7 +163,7 @@ { Weapon target = null; var position = Position; - foreach (var weapon in World.Weapon_UnclaimedWeapons) + foreach (var weapon in World.Weapon_UnclaimedList) { //判断是否能拾起武器, 条件: 相同的房间, 或者当前房间目前没有战斗, 或者不在战斗房间 if (weapon.AffiliationArea == AffiliationArea) diff --git a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs index c69ba6d..dee42c0 100644 --- a/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/ai/state/AiNormalState.cs @@ -62,7 +62,8 @@ //发现玩家 Master.LookTarget = attackTarget; //判断是否进入通知状态 - if (Master.World.Enemy_InstanceList.FindIndex(enemy => + if (Master.World.Role_InstanceList.FindIndex(role => + role is AiRole enemy && enemy != Master && !enemy.IsDie && enemy.AffiliationArea == Master.AffiliationArea && enemy.StateController.CurrState == AIStateEnum.AiNormal) != -1) { diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index 998ecfd..c17d753 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -94,15 +94,15 @@ public override void EnterTree() { - if (!World.Enemy_InstanceList.Contains(this)) + if (!World.Role_InstanceList.Contains(this)) { - World.Enemy_InstanceList.Add(this); + World.Role_InstanceList.Add(this); } } public override void ExitTree() { - World.Enemy_InstanceList.Remove(this); + World.Role_InstanceList.Remove(this); } protected override void OnDie() @@ -181,7 +181,8 @@ { LookTarget = target; //判断是否进入通知状态 - if (World.Enemy_InstanceList.FindIndex(enemy => + if (World.Role_InstanceList.FindIndex(role => + role is AiRole enemy && enemy != this && !enemy.IsDie && enemy.AffiliationArea == AffiliationArea && enemy.StateController.CurrState == AIStateEnum.AiNormal) != -1) { diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index e3378db..2ec849b 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -484,13 +484,13 @@ //收集落在地上的武器 if (IsInGround()) { - World.Weapon_UnclaimedWeapons.Add(this); + World.Weapon_UnclaimedList.Add(this); } } public override void ExitTree() { - World.Weapon_UnclaimedWeapons.Remove(this); + World.Weapon_UnclaimedList.Remove(this); } protected override void Process(float delta) diff --git a/DungeonShooting_Godot/src/game/buff/effect/Eff_SwapWeapon.cs b/DungeonShooting_Godot/src/game/buff/effect/Eff_SwapWeapon.cs index d2b95ae..e89e6fb 100644 --- a/DungeonShooting_Godot/src/game/buff/effect/Eff_SwapWeapon.cs +++ b/DungeonShooting_Godot/src/game/buff/effect/Eff_SwapWeapon.cs @@ -14,13 +14,12 @@ public override void OnUse() { - var list = new List(); - foreach (var enemy in Master.World.Enemy_InstanceList) + var list = new List(); + foreach (var role in Master.World.Role_InstanceList) { - if (enemy.WeaponPack.ActiveItem != null) + if (role is AiRole enemy && enemy.IsEnemy(Role) && enemy.WeaponPack.ActiveItem != null) { list.Add(enemy); - } } @@ -45,9 +44,9 @@ return false; } - foreach (var enemy in Master.World.Enemy_InstanceList) + foreach (var role in Master.World.Role_InstanceList) { - if (enemy.WeaponPack.ActiveItem != null) + if (role is AiRole enemy && enemy.IsEnemy(Role) && enemy.WeaponPack.ActiveItem != null) { return true; } diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index 7878e52..eb38790 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -858,10 +858,10 @@ if (room.IsSeclusion) { var playerAffiliationArea = CurrWorld.Player.AffiliationArea; - foreach (var enemy in CurrWorld.Enemy_InstanceList) + foreach (var role in CurrWorld.Role_InstanceList) { //不与玩家处于同一个房间 - if (!enemy.IsDestroyed && enemy.AffiliationArea != playerAffiliationArea) + if (role is AiRole enemy && !enemy.IsDestroyed && enemy.AffiliationArea != playerAffiliationArea) { if (enemy.StateController.CurrState != AIStateEnum.AiNormal) { diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 5ba219f..41e04fd 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -75,7 +75,7 @@ //更新敌人位置 { - var enemyList = World.Current.Enemy_InstanceList; + var enemyList = World.Current.Role_InstanceList; if (enemyList.Count == 0) //没有敌人 { foreach (var sprite in _enemySpriteList) @@ -90,8 +90,8 @@ var count = 0; //绘制数量 for (var i = 0; i < enemyList.Count; i++) { - var enemy = enemyList[i]; - if (!enemy.IsDestroyed && !enemy.IsDie && enemy.AffiliationArea != null && enemy.AffiliationArea.RoomInfo.RoomFogMask.IsExplored) + var role = enemyList[i]; + if (role is AiRole enemy && !enemy.IsDestroyed && !enemy.IsDie && enemy.AffiliationArea != null && enemy.AffiliationArea.RoomInfo.RoomFogMask.IsExplored) { count++; Sprite2D sprite; diff --git a/DungeonShooting_Godot/src/game/world/World.cs b/DungeonShooting_Godot/src/game/world/World.cs index 34add95..f6f9fa4 100644 --- a/DungeonShooting_Godot/src/game/world/World.cs +++ b/DungeonShooting_Godot/src/game/world/World.cs @@ -65,12 +65,12 @@ /// /// 所有被扔在地上的武器 /// - public HashSet Weapon_UnclaimedWeapons { get; } = new HashSet(); + public HashSet Weapon_UnclaimedList { get; } = new HashSet(); /// - /// 记录所有存活的敌人 + /// 记录所有存活的角色 /// - public List Enemy_InstanceList { get; } = new List(); + public List Role_InstanceList { get; } = new List(); /// /// 随机数对象 @@ -142,12 +142,12 @@ /// 目标 public void NotifyEnemyTarget(Role self, ActivityObject target) { - foreach (var role in Enemy_InstanceList) + foreach (var role in Role_InstanceList) { - if (role != self && !role.IsDestroyed && role.AffiliationArea == self.AffiliationArea) + if (role != self && !role.IsDestroyed && role.AffiliationArea == self.AffiliationArea && role is AiRole enemy) { //将未发现目标的敌人状态置为惊讶状态 - var controller = role.StateController; + var controller = enemy.StateController; //延时通知效果 role.CallDelay(Utils.Random.RandomRangeFloat(0.2f, 1f), () => {