From 01e9dc3a74e0bf3190f75b766d486428efb47b1c Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Tue, 22 Oct 2024 12:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=8A=A5=E9=94=99=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E3=80=91=E5=A2=9E=E5=8A=A0cellindex=E4=B8=BA-1=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E5=89=8D=E8=BF=94=E5=9B=9E,=E4=B8=8D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=94=99=E8=AF=AF=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Code/Scripts/Gameplay/Area/AreaChecker.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Area/AreaChecker.cs b/ProjectNLD/Assets/Code/Scripts/Gameplay/Area/AreaChecker.cs index d240582a948..d4d9be0662d 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Area/AreaChecker.cs +++ b/ProjectNLD/Assets/Code/Scripts/Gameplay/Area/AreaChecker.cs @@ -89,6 +89,10 @@ namespace Gameplay.Area private bool _CheckCenterIsSelfVehicle(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } var units = AreaManager.instance.GetUnitsByCellIndex(centerCellIndex); var senderTroopId = troopId; var isSelf = false; @@ -107,6 +111,10 @@ namespace Gameplay.Area private bool _CheckAreaContainsSelfSide(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } var influenceAreaId = influenceId; var areaIndexs = AreaManager.instance.GetCellIndexs(centerCellIndex, influenceAreaId); // 查找所有友军 @@ -121,6 +129,10 @@ namespace Gameplay.Area private bool _CheckAreaContainsEnemy(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } if (troopId == ETroopsId.Self) { // 需要额外判断是否在光亮区域 @@ -141,6 +153,10 @@ namespace Gameplay.Area private bool _CheckCenterIsEmpty(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } if (troopId == ETroopsId.Self) { // 需要额外判断是否在光亮区域 @@ -166,6 +182,10 @@ namespace Gameplay.Area private bool _CheckCenterIsSelfSide(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } var units = AreaManager.instance.GetUnitsByCellIndex(centerCellIndex); var senderTroopId = troopId; var isSelf = false; @@ -187,6 +207,10 @@ namespace Gameplay.Area private bool _CheckCenterIsEnemy(int centerCellIndex) { + if (centerCellIndex == -1) + { + return false; + } if (troopId == ETroopsId.Self) { // 需要额外判断是否在光亮区域