From d5102a4355a33f9a74ed253dea8225ec25d3d6d2 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Fri, 26 May 2023 19:31:37 +0800 Subject: [PATCH] fix: :ambulance: fix the bug about rescue and treat when in the same Position --- docs/版本更新说明.md | 7 +++++-- logic/GameClass/GameObj/Map/Map.cs | 10 ++++------ logic/Preparation/Utility/GameData.cs | 1 - 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/版本更新说明.md b/docs/版本更新说明.md index 3842b21..4e2b209 100644 --- a/docs/版本更新说明.md +++ b/docs/版本更新说明.md @@ -94,6 +94,9 @@ # 5月26日14:00更新 - improve:优化CD逻辑 -# 5月26日更新 +# 5月26日19:00更新 - docs:指令执行失败可能会使你返回idle状态,而非简单的无效 -- docs:删除了“实际上唤醒或勉励不同的人是有效的” \ No newline at end of file +- docs:删除了“实际上唤醒或勉励不同的人是有效的” + +# 5月26日更新 +- fix:修复了坐标相同导致无法唤醒和勉励的问题 \ No newline at end of file diff --git a/logic/GameClass/GameObj/Map/Map.cs b/logic/GameClass/GameObj/Map/Map.cs index 8fbec0c..ad13c9e 100644 --- a/logic/GameClass/GameObj/Map/Map.cs +++ b/logic/GameClass/GameObj/Map/Map.cs @@ -250,18 +250,16 @@ namespace GameClass.GameObj } return GameObjForInteract; } - public Student? StudentForInteract(XY Pos) + public Student? StudentForInteract(XY Pos, Student AStudent) { - Student? GameObjForInteract = null; GameObjLockDict[GameObjType.Character].EnterReadLock(); try { foreach (Character character in GameObjDict[GameObjType.Character]) { - if (!character.IsGhost() && GameData.ApproachToInteract(character.Position, Pos)) + if (!character.IsGhost() && character != AStudent && GameData.ApproachToInteract(character.Position, Pos)) { - GameObjForInteract = (Student)character; - break; + return (Student)character; } } } @@ -269,7 +267,7 @@ namespace GameClass.GameObj { GameObjLockDict[GameObjType.Character].ExitReadLock(); } - return GameObjForInteract; + return null; } public GameObj? OneInTheSameCell(XY Pos, GameObjType gameObjType) { diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs index ea1f2c9..a11ef4b 100644 --- a/logic/Preparation/Utility/GameData.cs +++ b/logic/Preparation/Utility/GameData.cs @@ -78,7 +78,6 @@ namespace Preparation.Utility } public static bool ApproachToInteract(XY pos1, XY pos2) { - if (pos1 == pos2) return false; return Math.Abs(PosGridToCellX(pos1) - PosGridToCellX(pos2)) <= 1 && Math.Abs(PosGridToCellY(pos1) - PosGridToCellY(pos2)) <= 1; } public static bool ApproachToInteractInACross(XY pos1, XY pos2)