Эх сурвалжийг харах

修复厨师死亡后减免效果不消失bug

SZAND\msx_2 1 жил өмнө
parent
commit
347b87a262

+ 2 - 0
ActionTowerDefense/Assets/Scripts/MoveCharacter.cs

@@ -375,6 +375,7 @@ public class MoveCharacter : Character
         reductionEffect.SetActive(true);
         isDamageReduction = true;
         reductionDegree = degree;
+        canNotChangeHurt = true;
     }
 
     public void DamageReductionStateToOff(float onTime)
@@ -386,6 +387,7 @@ public class MoveCharacter : Character
     {
         isDamageReduction = false;
         reductionEffect.SetActive(false);
+        canNotChangeHurt = false;
     }
 
     public override void BeHit(int damage, Vector3 force, bool changeHurt, float repelValue)

+ 13 - 0
ActionTowerDefense/Assets/Scripts/Spirits/Spirits_Cook.cs

@@ -8,6 +8,7 @@ public class Spirits_Cook : MonoBehaviour
     public GameObject attributeUpEffect;
     public float reductionDegree;
     public float reductionTime;
+    private List<MoveCharacter> mcs = new List<MoveCharacter>();
 
     private void OnTriggerEnter(Collider other)
     {
@@ -17,6 +18,7 @@ public class Spirits_Cook : MonoBehaviour
             if (!mc.isDamageReduction)
             {
                 mc.DamageReductionStateOn(reductionDegree, attributeUpEffect);
+                mcs.Add(mc);
             }
         }
     }
@@ -32,4 +34,15 @@ public class Spirits_Cook : MonoBehaviour
             }
         }
     }
+
+    private void OnDisable()
+    {
+        foreach(MoveCharacter mc in mcs)
+        {
+            if (!mc.isDamageReduction)
+            {
+                mc.DamageReductionStateToOff(reductionTime);
+            }
+        }
+    }
 }