浏览代码

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

大爷 1 年之前
父节点
当前提交
ff2cd4f311
共有 1 个文件被更改,包括 6 次插入5 次删除
  1. 6 5
      Unity/Assets/Scripts/Codes/Hotfix/Client/battle/unit/BattleUnit.cs

+ 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) => { });