Browse Source

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

WGL 1 month ago
parent
commit
aa92ea410a
1 changed files with 4 additions and 3 deletions
  1. 4 3
      ActionTowerDefense/Assets/Scripts/Characters/PlayerController.cs

+ 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;
             }