Browse Source

增加HUD显示塔 & BOSS的血量条

大爷 1 year ago
parent
commit
9541cabba6

+ 9 - 1
FGUIProject/assets/HUD/HUD.xml

@@ -19,7 +19,15 @@
       <Button title="Mute"/>
     </component>
     <group id="n14_o3v3" name="TestBtns" xy="1268,160" size="307,754"/>
-    <image id="n13_uy5h" name="n13" src="uy5h8h" fileName="png_kpzlxbg.png" xy="1220,330" size="34,2000"/>
+    <image id="n13_uy5h" name="n13" src="uy5h8h" fileName="png_kpzlxbg.png" xy="1220,330" size="34,715"/>
+    <component id="n21_tjcv" name="progressbar_1" src="tjcv8p" fileName="ProgressBar1.xml" xy="97,392">
+      <ProgressBar max="100"/>
+    </component>
+    <component id="n22_tjcv" name="progressbar_2" src="tjcv8r" fileName="ProgressBar2.xml" xy="795,391">
+      <ProgressBar max="100"/>
+    </component>
+    <text id="n25_tjcv" name="txt_hp1" xy="103,435" size="400,42" fontSize="30" color="#0ceed8" align="center" vAlign="middle" autoSize="none" bold="true" text="30%"/>
+    <text id="n26_tjcv" name="txt_hp2" xy="796,435" size="400,42" fontSize="30" color="#f85800" align="center" vAlign="middle" autoSize="none" bold="true" text="30%"/>
   </displayList>
   <Button downEffect="dark" downEffectValue=".71"/>
 </component>

+ 11 - 0
FGUIProject/assets/HUD/ProgressBar1.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component size="400,40" extention="ProgressBar">
+  <displayList>
+    <image id="n0_tjcv" name="n0" src="tjcvk" fileName="hpBar_bg_player.png" xy="0,0" size="400,40">
+      <relation target="" sidePair="width-width,height-height"/>
+    </image>
+    <image id="n1_tjcv" name="bar" src="tjcv8o" fileName="hpbar_lightgreen.png" xy="1,0" size="398,40"/>
+    <image id="n2_tjcv" name="n2" src="tjcv8s" fileName="hpBar_cover.png" xy="0,0" size="400,40"/>
+  </displayList>
+  <ProgressBar/>
+</component>

+ 11 - 0
FGUIProject/assets/HUD/ProgressBar2.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<component size="400,40" extention="ProgressBar">
+  <displayList>
+    <image id="n0_tjcv" name="n0" src="tjcvk" fileName="hpBar_bg_player.png" xy="0,0" size="400,40">
+      <relation target="" sidePair="width-width,height-height"/>
+    </image>
+    <image id="n1_tjcv" name="bar" src="tjcv8q" fileName="hpbar_red.png" xy="1,0" size="398,40"/>
+    <image id="n2_tjcv" name="n2" src="tjcv8s" fileName="hpBar_cover.png" xy="0,0" size="400,40"/>
+  </displayList>
+  <ProgressBar/>
+</component>

BIN
FGUIProject/assets/HUD/hpBar_bg_player.png


BIN
FGUIProject/assets/HUD/hpBar_cover.png


BIN
FGUIProject/assets/HUD/hpbar_lightgreen.png


BIN
FGUIProject/assets/HUD/hpbar_red.png


+ 6 - 0
FGUIProject/assets/HUD/package.xml

@@ -16,6 +16,12 @@
     <image id="icx38l" name="I_btn_zdyy.png" path="/"/>
     <image id="icx38m" name="I_icon_zdyy.png" path="/"/>
     <component id="icx38n" name="Button4.xml" path="/"/>
+    <image id="tjcvk" name="hpBar_bg_player.png" path="/"/>
+    <image id="tjcv8o" name="hpbar_lightgreen.png" path="/"/>
+    <component id="tjcv8p" name="ProgressBar1.xml" path="/"/>
+    <image id="tjcv8q" name="hpbar_red.png" path="/"/>
+    <component id="tjcv8r" name="ProgressBar2.xml" path="/"/>
+    <image id="tjcv8s" name="hpBar_cover.png" path="/"/>
   </resources>
   <publish name=""/>
 </packageDescription>

BIN
Unity/Assets/Res/FGUI/HUD_atlas0.png


BIN
Unity/Assets/Res/FGUI/HUD_fui.bytes


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

@@ -5,6 +5,7 @@ using ET;
 using ET.EventType;
 using Sirenix.Utilities;
 using System;
+using XmdsCommon.Plugin;
 
 public class BattleUnit : BattleObject
 {
@@ -148,25 +149,45 @@ public class BattleUnit : BattleObject
         throw new NotImplementedException();
     }
 
-    protected virtual void OnMaxHPChanged(ZoneUnit unit, int oldMaxHP, int newMaxHP)
+    protected virtual void OnMPChanged(ZoneUnit unit, int oldMP, int newMP)
     {
         throw new NotImplementedException();
     }
 
-    protected virtual void OnMPChanged(ZoneUnit unit, int oldMP, int newMP)
+    protected virtual void OnMaxHPChanged(ZoneUnit unit, int oldMaxHP, int newMaxHP)
     {
-        throw new NotImplementedException();
+        OnHPChanged();
     }
-
     protected virtual void OnHPChanged(ZoneUnit unit, int oldHP, int newHP)
     {
-        Log.Debug($"hp({unit.ObjectID}) change, {oldHP}-->{newHP}");
+        OnHPChanged();
+    }
+    private void OnHPChanged()
+    {
+        var prop = ZUnit.Info.Properties as XmdsUnitProperties;
+        if (prop != null)
+        {
+            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)
+            {
+                var hp = ZUnit.HP;
+                var pg = (float)ZUnit.HP * 100 / ZUnit.MaxHP;
+                EventSystem.Instance.Publish<HPRefresh>(HPRefresh.Static.Clone(HPRefresh.Index.Boss, pg, hp));
+                Log.Debug($"Boss({ZUnit.ObjectID}) hp: {ZUnit.HP}/{ZUnit.MaxHP}");
+            }
+        }
+        //Log.Debug($"hp({ZUnit.ObjectID}) change: {ZUnit.HP}");
     }
 
     protected virtual void OnSkillActionChanged(ZoneUnit unit, ZoneUnit.SkillState skill, byte index)
     {
         //技能状态
-
     }
 
     protected virtual void OnActionChanged(ZoneUnit unit, UnitActionStatus status, object evt)

+ 30 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/UI/HUD/SceneChangeFinishEvent_CreateHUD.cs

@@ -23,11 +23,32 @@ namespace ET.Client
     {
         public override void OnEvent(SkillChangeEvent a)
         {
-            var view = UIHelper.GetUI("HUD") as GComponent;
+            Log.Debug("actor's skill changed.");
+            /*var view = UIHelper.GetUI("HUD") as GComponent;
             if(view != null)
             {
                 HUDMgr.InitView(view);
+            }*/
+        }
+    }
+
+    [Event(SceneType.None)]
+    public class HPRefreshEventHandler : BEvent<HPRefresh>
+    {
+        public override void OnEvent(HPRefresh a)
+        {
+            var view = UIHelper.GetUI("HUD") as GComponent;
+            if(view == null)
+            {
+                return;
             }
+
+            int index = (int)a.HPIndex;
+            var progress = view.GetChild($"progressbar_{index}") as GProgressBar;
+            progress.visible = true;
+            var txt = view.GetChild($"txt_hp{index}");
+            progress.value = a.Progress;
+            txt.text = a.Progress.ToString("F2") + "%";
         }
     }
 
@@ -85,6 +106,14 @@ namespace ET.Client
                 SoundManager.Instance.UnityAudioSource.mute = isMute;
                 GameSetting.Instance.SetBool(GameSetting.Sets.Mute_int, isMute);
             });
+
+            var progress1 = view.GetChild("progressbar_1") as GProgressBar;
+            var progress2 = view.GetChild("progressbar_2") as GProgressBar;
+            progress1.visible = progress2.visible = false;
+            var txthp1 = view.GetChild("txt_hp1");
+            txthp1.text = "";
+            var txthp2 = view.GetChild("txt_hp2");
+            txthp2.text = "";
         }
     }
 }

+ 18 - 0
Unity/Assets/Scripts/Codes/Model/Client/EventTypeClient.cs

@@ -110,6 +110,24 @@ namespace ET
                 return this;
             }
         }
+        public class HPRefresh
+        {
+            public enum Index
+            {
+                Tower = 1, Boss
+            }
+            public Index HPIndex;
+            public float Progress;
+            public int HP;
+            public static HPRefresh Static = new();
+            public HPRefresh Clone(Index i, float pg, int hp)
+            {
+                HPIndex = i;
+                Progress = pg;
+                HP = hp;
+                return this;
+            }
+        }
     }
 
     //状态指令