瀏覽代碼

增加不同等级玩家单位,HUD美化

大爷 1 年之前
父節點
當前提交
41d330a4f6

+ 3 - 3
FGUIProject/assets/HUD/Button3.xml

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
-<component size="300,100" pivot="0.5,0.5" extention="Button">
+<component size="220,70" pivot="0.5,0.5" extention="Button">
   <controller name="button" pages="0,up,1,down,2,over,3,selectedOver" selected="0"/>
   <displayList>
-    <image id="n2_o3v3" name="n2" src="o3v38j" fileName="shcj_sxxlbtn01_sel.png" xy="0,0" size="300,100"/>
-    <text id="n1_o3v3" name="title" xy="0,0" size="300,100" fontSize="54" align="center" vAlign="middle" autoSize="none" singleLine="true" text="测试按扭">
+    <image id="n2_o3v3" name="n2" src="o3v38j" fileName="shcj_sxxlbtn01_sel.png" xy="0,0" size="220,70"/>
+    <text id="n1_o3v3" name="title" xy="0,0" size="220,70" fontSize="40" align="center" vAlign="middle" autoSize="none" singleLine="true" text=" 测试按钮">
       <relation target="" sidePair="width-width,height-height"/>
     </text>
   </displayList>

+ 4 - 4
FGUIProject/assets/HUD/Button4.xml

@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
-<component size="300,100" extention="Button">
+<component size="220,70" extention="Button">
   <controller name="button" pages="0,up,1,down,2,over,3,selectedOver" selected="0"/>
   <displayList>
-    <text id="n1_icx3" name="title" xy="3,0" size="205,100" fontSize="54" align="center" vAlign="middle" autoSize="none" singleLine="true" text="Mute">
+    <text id="n1_icx3" name="title" xy="3,0" size="125,70" fontSize="42" align="center" vAlign="middle" autoSize="none" singleLine="true" text="Mute">
       <relation target="" sidePair="width-width,height-height"/>
     </text>
-    <image id="n3_icx3" name="n3" src="icx38l" fileName="I_btn_zdyy.png" xy="210,4" size="94,100" aspect="true">
+    <image id="n3_icx3" name="n3" src="icx38l" fileName="I_btn_zdyy.png" xy="143,2" size="69,70">
       <relation target="" sidePair="width-width,height-height"/>
     </image>
-    <image id="n2_icx3" name="checked" src="icx38m" fileName="I_icon_zdyy.png" xy="228,32"/>
+    <image id="n2_icx3" name="checked" src="icx38m" fileName="I_icon_zdyy.png" xy="147,13"/>
   </displayList>
   <Button/>
 </component>

+ 19 - 12
FGUIProject/assets/HUD/HUD.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<component size="1600,2560" opaque="false" extention="Button">
+<component size="1125,2000" opaque="false" extention="Button">
   <displayList>
     <image id="n0_vcrv" name="bg_direction" src="vcrv8b" fileName="bg_direction.png" xy="4,1376" group="n5_vcrv" visible="false"/>
     <image id="n1_vcrv" name="img_direction" src="vcrv8c" fileName="img_direction.png" xy="73,1445" group="n5_vcrv" visible="false"/>
@@ -7,27 +7,34 @@
     <component id="n8_pzlz" name="btn_skill2" src="pzlz8d" fileName="Button1.xml" xy="693,1354" group="n10_pzlz" visible="false"/>
     <component id="n9_pzlz" name="btn_skill1" src="pzlz8e" fileName="Button2.xml" xy="572,1410" group="n10_pzlz" visible="false"/>
     <group id="n10_pzlz" name="skillbtns" xy="572,1354" size="321,156"/>
-    <component id="n16_o3v3" name="btn_func1" src="o3v38i" fileName="Button3.xml" xy="1275,364" group="n14_o3v3">
+    <component id="n16_o3v3" name="btn_func1" src="o3v38i" fileName="Button3.xml" xy="895,1340" group="n14_o3v3">
       <Button title="显/隐血条" titleColor="#000000"/>
     </component>
-    <component id="n17_o3v3" name="btn_func2" src="o3v38i" fileName="Button3.xml" xy="1275,514" size="300,100" group="n14_o3v3">
+    <component id="n17_o3v3" name="btn_func2" src="o3v38i" fileName="Button3.xml" xy="895,1420" size="220,70" group="n14_o3v3">
       <Button title="摇人"/>
     </component>
-    <component id="n18_o3v3" name="btn_func3" src="o3v38i" fileName="Button3.xml" xy="1275,664" size="300,100" group="n14_o3v3"/>
-    <component id="n19_o3v3" name="btn_func4" src="o3v38i" fileName="Button3.xml" xy="1275,814" size="300,100" group="n14_o3v3"/>
-    <component id="n20_icx3" name="btn_mute" src="icx38n" fileName="Button4.xml" xy="1268,160" group="n14_o3v3">
+    <component id="n18_o3v3" name="btn_func3" src="o3v38i" fileName="Button3.xml" xy="895,1649" size="220,70" group="n14_o3v3">
+      <Button title="范围加血"/>
+    </component>
+    <component id="n19_o3v3" name="btn_func4" src="o3v38i" fileName="Button3.xml" xy="895,1492" size="220,70" group="n14_o3v3">
+      <Button title="摇人2"/>
+    </component>
+    <component id="n20_icx3" name="btn_mute" src="icx38n" fileName="Button4.xml" xy="898,1256" group="n14_o3v3">
       <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,715"/>
-    <component id="n21_tjcv" name="progressbar_1" src="tjcv8p" fileName="ProgressBar1.xml" xy="97,392">
+    <component id="n27_hth0" name="btn_func5" src="o3v38i" fileName="Button3.xml" xy="895,1564" group="n14_o3v3">
+      <Button title="遥人3"/>
+    </component>
+    <image id="n13_uy5h" name="n13" src="uy5h8h" fileName="png_kpzlxbg.png" xy="876,1265" size="34,715" group="n14_o3v3"/>
+    <group id="n14_o3v3" name="TestBtns" xy="876,1256" size="242,724"/>
+    <component id="n21_tjcv" name="progressbar_1" src="tjcv8p" fileName="ProgressBar1.xml" xy="10,392">
       <ProgressBar max="100"/>
     </component>
-    <component id="n22_tjcv" name="progressbar_2" src="tjcv8r" fileName="ProgressBar2.xml" xy="795,391">
+    <component id="n22_tjcv" name="progressbar_2" src="tjcv8r" fileName="ProgressBar2.xml" xy="710,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%"/>
+    <text id="n25_tjcv" name="txt_hp1" xy="16,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="711,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>

二進制
Unity/Assets/Res/FGUI/HUD_fui.bytes


+ 62 - 26
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/BattleMgr_Cmd.cs

@@ -13,33 +13,12 @@ namespace ET
         public override void OnEvent(BattleFunc a)
         {
             Log.Debug($"Battle Func:{a.FuncIndex}");
-            asyncHandler(a.FuncIndex);
-        }
-
-        //获得当前战场focus中心(当前塔位置)
-        private Vector2 vecTemp = new Vector2();
-        private Vector2 GetCurBattleCenter()
-        {
-            foreach(var tid in ConstGame.TowerTemplateIDs)
-            {
-                var tower = BattleMgr.Instance.GetUnitByTemplateID(tid);
-                if(tower != null && !tower.IsDead)
-                {
-                    vecTemp.X = tower.ZUnit.X;
-                    vecTemp.Y = tower.ZUnit.Y;
-                    return vecTemp;
-                }
-            }
-            return new Vector2(0, 0);
-        }
 
-        private void asyncHandler(BattleFunc.Index index)
-        {
             var session = PlayerComponent.Instance.ClientScene().GetComponent<SessionComponent>().Session;
-            switch (index)
+            switch (a.FuncIndex)
             {
-                case BattleFunc.Index.Func2:
-                    var units = new int[] {105, 108, 111, 117};
+                case 2:
+                    var units = new int[] { 105, 108, 111, 117 };
                     var centerpos = GetCurBattleCenter();
                     var rand = new Random();
                     foreach (var id in units)
@@ -59,7 +38,7 @@ namespace ET
                         }).Coroutine();
                     }
                     break;
-                case BattleFunc.Index.Func3:
+                case 3:
                     session.Call(new C2G_TriggrBattleFunction()
                     {
                         TriggerID = 10111,
@@ -71,10 +50,67 @@ namespace ET
                         Value6 = 0,
                     }).Coroutine();
                     break;
-                default:
+                case 4:
+                    var units2 = new int[] { 106, 109, 112, 118 };
+                    centerpos = GetCurBattleCenter();
+                    rand = new Random();
+                    foreach (var id in units2)
+                    {
+                        float r = (rand.Next(1000)) / 100.0f + 5;
+                        double ang = rand.Next(180) / 180.0f * Math.PI + Math.PI;
+                        Log.Debug($"rand unit r({r}), ang({ang})");
+                        float x = centerpos.X + (float)(r * Math.Cos(ang));
+                        float y = centerpos.Y - (float)(r * Math.Sin(ang));
+
+                        session.Call(new C2G_AddUnitsToMap()
+                        {
+                            UnitId = id,
+                            Force = 1,
+                            X = (int)x,
+                            Y = (int)y
+                        }).Coroutine();
+                    }
+                    break;
+                case 5:
+                    var units3 = new int[] { 107, 1110, 113, 119 };
+                    centerpos = GetCurBattleCenter();
+                    rand = new Random();
+                    foreach (var id in units3)
+                    {
+                        float r = (rand.Next(1000)) / 100.0f + 5;
+                        double ang = rand.Next(180) / 180.0f * Math.PI + Math.PI;
+                        Log.Debug($"rand unit r({r}), ang({ang})");
+                        float x = centerpos.X + (float)(r * Math.Cos(ang));
+                        float y = centerpos.Y - (float)(r * Math.Sin(ang));
+
+                        session.Call(new C2G_AddUnitsToMap()
+                        {
+                            UnitId = id,
+                            Force = 1,
+                            X = (int)x,
+                            Y = (int)y
+                        }).Coroutine();
+                    }
                     break;
             }
         }
+
+        //获得当前战场focus中心(当前塔位置)
+        private Vector2 vecTemp = new Vector2();
+        private Vector2 GetCurBattleCenter()
+        {
+            foreach(var tid in ConstGame.TowerTemplateIDs)
+            {
+                var tower = BattleMgr.Instance.GetUnitByTemplateID(tid);
+                if(tower != null && !tower.IsDead)
+                {
+                    vecTemp.X = tower.ZUnit.X;
+                    vecTemp.Y = tower.ZUnit.Y;
+                    return vecTemp;
+                }
+            }
+            return new Vector2(0, 0);
+        }
     }
 
     //发送战斗服指令相关

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

@@ -80,9 +80,11 @@ namespace ET.Client
 
             btn1.visible = false;
             btn2.visible = false;
-            for (int i=1; i<=4; i++)
+            for (int i=1; i<= 99; i++)
             {
                 var btn = view.GetChild($"btn_func{i}");
+                if (btn == null) break;
+
                 var index = i;
                 btn.onClick.Set(() =>
                 {

+ 2 - 6
Unity/Assets/Scripts/Codes/Model/Client/EventTypeClient.cs

@@ -98,15 +98,11 @@ namespace ET
         }
         public class BattleFunc
         {
-            public enum Index
-            {
-                Func1 = 1, Func2, Func3, Func4
-            }
-            public Index FuncIndex;
+            public int FuncIndex;
             public static BattleFunc Static = new();
             public BattleFunc Clone(int index)
             {
-                FuncIndex = (Index)index;
+                FuncIndex = index;
                 return this;
             }
         }