Browse Source

增加玩家单位血条动态展示:当受到的伤害或加血超过20%血量时,显示血量变化动画
增加vip玩家头顶名字显示规则:打赏104个抖币

大爷 1 year ago
parent
commit
41cd4895f2

+ 31 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/TiktokPushHandler.cs

@@ -0,0 +1,31 @@
+
+using ET.EventType;
+
+namespace ET.Client
+{
+    [MessageHandler(SceneType.Client)]
+    public class TiktokLikePushHandler : AMHandler<G2C_LikeInfoPush>
+    {
+        protected override async ETTask Run(Session session, G2C_LikeInfoPush a)
+        {
+            EventSystem.Instance.Publish(ShowUIAnimation.Clone(ShowUIAnimation.AniType.LikeEnergy, (int)(a.ConfigNum * 100 / a.TotalNum)));
+            await ETTask.CompletedTask;
+        }
+    }
+
+    [MessageHandler(SceneType.Client)]
+    public class TiktokGiftPushHandler : AMHandler<G2C_GiftInfoPush>
+    {
+        protected override async ETTask Run(Session session, G2C_GiftInfoPush a)
+        {
+            EventSystem.Instance.Publish(TiktokGiftEvent.Clone(a.GiftType, a.GiftNum, a.NickName, a.Url));
+
+            if(a.TotalMoney > ConstValue.MoneyShowVipName)
+            {
+                //花了钱,就可以显示大名
+                EventSystem.Instance.Publish(ShowVipName.Clone((uint)a.UnitId));
+            }
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 11 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/TiktokPushHandler.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8d939a34ed4c0c54c86309741222854d
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Global/GlobalViewMgr.cs

@@ -30,7 +30,7 @@ namespace ET.Client
             //加入所有headbar的parent view
             var root = await UIHelper.Create("HeadBar", "HeadBarRoot", 0);
             HeadbarView = root;
-            root.visible = false;
+            //root.visible = false;
         }
     }
 }

+ 10 - 3
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/OnNewZoneObject.cs

@@ -3,6 +3,7 @@ using ET.EventType;
 using FairyGUI;
 using Sirenix.Utilities;
 using UnityEngine;
+using XmdsCommon.Plugin;
 
 namespace ET.Client
 {
@@ -53,7 +54,10 @@ namespace ET.Client
             go.transform.rotation = RenderUtils.UnityRotationFromBattle(zu.Direction);
 
             var render = ModelViewComponent.Instance.AddChildWithId<UnitRenderComponet, GameObject>(unit.Id, go, true);
-            await CreateHeadbar(render, zu);
+            if (zu.Info.Properties is XmdsUnitProperties prop && prop.ShowHPBanner)
+            {
+                await CreateHeadbar(render, zu);
+            }
             if (unit is BattleActor)
             {
                 CameraMgr.FollowMe(go.transform.position);
@@ -118,16 +122,19 @@ namespace ET.Client
         private async ETTask CreateHeadbar(UnitRenderComponet render, ZoneUnit zu)
         {
             var view = await GameObjectPool.Instance.AcquireHeadBar();
-            view.visible = false;
 
             render.HeadBar = view;
             var name = view.GetChild("text_name");
             var progresshp = view.GetChild("bar_hp") as GProgressBar;
             progresshp.max = 100;
             progresshp.min = 0;
+            render.NameBar = name;
             render.HPBar = progresshp;
 
-            name.text = render.GameObject.name;
+            name.text = "";
+            name.visible = false;
+
+            progresshp.visible = false;
             progresshp.value = zu.HP * 100 / zu.MaxHP;
             render.SyncHeadBarPos();
         }

+ 28 - 8
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/UnitRenderSystem.cs

@@ -69,7 +69,24 @@ namespace ET.Client
             }
         }
     }
-
+    [Event]
+    [FriendOfAttribute(typeof(ET.Client.UnitRenderComponet))]
+    public class ShowVipNameEventHandler : BEvent<ShowVipName>
+    {
+        protected override async ETTask OnEvent(ShowVipName args)
+        {
+            await ETTask.CompletedTask;
+            var unitRender = ModelViewComponent.Instance.GetChild<UnitRenderComponet>(args.ObjId);
+            if (unitRender != null)
+            {
+                unitRender.NameBar.visible = true;
+            }
+            else
+            {
+                Log.Error($"Not Found unitRender: {args.ObjId}");
+            }
+        }
+    }
     [Event]
     public class SyncUnitPosEventHandler : BEvent<EventType.SyncUnitPosEvent>
     {
@@ -108,7 +125,7 @@ namespace ET.Client
                 var unitRender = ModelViewComponent.Instance.GetChild<UnitRenderComponet>(args.Id);
                 if (unitRender != null)
                 {
-                    unitRender.SyncHeadBarHP(args.Value);
+                    unitRender.SyncHeadBarHP(args.Value).Coroutine();
                 }
             }
             await ETTask.CompletedTask;
@@ -181,28 +198,31 @@ namespace ET.Client
                 if(pos.z < 0 || pos.x < 0 || pos.x > Screen.width || pos.y < 0 || pos.y > Screen.height)
                 {
                     //不在视野中
-                    self.HeadBar.visible = false;
+                    self.HeadBar.SetXY(999999, 999999);
                 }
                 else
                 {
                     pos.y = Screen.height - pos.y;
                     pos = GRoot.inst.GlobalToLocal(pos);
                     self.HeadBar.SetXY(pos.x, pos.y);
-                    self.HeadBar.visible = true;
                 }
             }
         }
-        public static void SyncHeadBarHP(this UnitRenderComponet self, float value, bool bTween = false)
+        public static async ETTask SyncHeadBarHP(this UnitRenderComponet self, float newValue)
         {
             if (self.HPBar != null)
             {
-                if (bTween)
+                var old = self.HPBar.value;
+                if ((old - newValue) > 20 || (newValue - old > 20 && old > 0))
                 {
-                    self.HPBar.TweenValue(value, 0.6f);
+                    self.HPBar.visible = true;
+                    self.HPBar.TweenValue(newValue, 0.6f);
+                    await TimerComponent.Instance.WaitAsync(700);
+                    self.HPBar.visible = false;
                 }
                 else
                 {
-                    self.HPBar.value = value;
+                    self.HPBar.value = newValue;
                 }
             }
         }

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

@@ -314,6 +314,32 @@ namespace ET
                 return Static;
             }
         }
+        public class TiktokGiftEvent
+        {
+            public int index;
+            public int num;
+            public string nickname;
+            public string avatar;
+            public static TiktokGiftEvent Static = new();
+            public static TiktokGiftEvent Clone(int index, int num, string name, string url)
+            {
+                Static.index = index;
+                Static.num = num;
+                Static.nickname = name;
+                Static.avatar = url;
+                return Static;
+            }
+        }
+        public class ShowVipName
+        {
+            public uint ObjId;
+            public static ShowVipName Static = new();
+            public static ShowVipName Clone(uint objId)
+            {
+                Static.ObjId = objId;
+                return Static;
+            }
+        }
         public class ShowOrHideHeadBar
         {
             public bool Flag;

+ 2 - 0
Unity/Assets/Scripts/Codes/Model/Share/Const/ConstValue.cs

@@ -15,6 +15,8 @@
 #else
         public static int IsDebug = 0;
 #endif
+
+        public static int MoneyShowVipName = 1040;  //10.4元享受vip待遇
     }
 
     public enum BattlePushCnst