Przeglądaj źródła

修复玩家扣血会报错的问题

WGL 1 miesiąc temu
rodzic
commit
aa92ea410a

+ 4 - 3
ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

@@ -1771,10 +1771,11 @@ public class PlayerController : MoveCharacter
 
     public override void BeHit(AttackController.AttackMethod attackMethod, Character attackFrom, int damage = -1)
     {
-        Photosphere photosphere = conductController.photospheres[conductController.photospheres.Count - 1];
-        if (photosphere)
+        List<Photosphere> photospheres = conductController.photospheres;
+        if (photospheres.Count > 0)
         {
-            if(damage == -1)
+            Photosphere photosphere = photospheres[photospheres.Count - 1];
+            if (damage == -1)
             {
                 photosphere.hp -= attackMethod.attackInfo.damage;
             }