Quellcode durchsuchen

修复水晶被攻破时,血量条未置0的问题

大爷 vor 1 Jahr
Ursprung
Commit
ff2cd4f311

+ 6 - 5
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/unit/BattleUnit.cs

@@ -133,17 +133,16 @@ public class BattleUnit : BattleObject
 
     private void OnHPChanged()
     {
-        var prop = ZUnit.Info.Properties as XmdsUnitProperties;
-        if (prop != null)
+        if (ZUnit.Info.Properties is XmdsUnitProperties prop)
         {
-            if(prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialElite)
+            if (prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialElite)
             {
                 var hp = ZUnit.HP;
                 var pg = (float)ZUnit.HP * 100 / ZUnit.MaxHP;
                 EventSystem.Instance.Publish<HPRefresh>(HPRefresh.Static.Clone(HPRefresh.Index.Tower, pg, hp));
                 //Log.Debug($"tower({ZUnit.ObjectID}@{ZUnit.Info.Name}) hp: {ZUnit.HP}/{ZUnit.MaxHP}");
             }
-            else if(prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialBoss)
+            else if (prop.GameStatusType == XmdsUnitProperties.StatusType.SpecialBoss)
             {
                 var hp = ZUnit.HP;
                 var pg = (float)ZUnit.HP * 100 / ZUnit.MaxHP;
@@ -181,7 +180,9 @@ public class BattleUnit : BattleObject
 
         var stun = actionChangeHandler.AddListener(UnitActionStatus.Stun, (o) => { });
         actionChangeHandler.AddListener(UnitActionStatus.HitMove, stun);
-        actionChangeHandler.AddListener(UnitActionStatus.Dead, (o) => { });
+        actionChangeHandler.AddListener(UnitActionStatus.Dead, (o) => {
+            OnHPChanged();
+        });
         actionChangeHandler.AddListener(UnitActionStatus.Damage, (o) => { });
         actionChangeHandler.AddListener(UnitActionStatus.Pick, (o) => { });
         actionChangeHandler.AddListener(UnitActionStatus.Spawn, (o) => { });