Explorar o código

增加根据vip等级显示不同颜色的名字功能

大爷 hai 1 ano
pai
achega
d43a0bc3ae

+ 18 - 4
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/GameServer/TiktokPushHandler.cs

@@ -20,12 +20,26 @@ namespace ET.Client
         {
             EventSystem.Instance.Publish(TiktokGiftEvent.Clone(a.GiftType, a.GiftNum, a.NickName, a.Url));
 
-            if(a.TotalMoney > ConstValue.MoneyShowVipName)
+            var unit = UnitMgr.Instance.GetUnit((uint)a.UnitId);
+            if (unit != null && unit is BattleUnit bu)
             {
-                //花了钱,就可以显示大名
-                EventSystem.Instance.Publish(ShowVipName.Clone((uint)a.UnitId));
-            }
+                for (int i = GameSetting.VipMoney.Length - 1; i >= 0; i--)
+                {
+                    if (GameSetting.VipMoney[i] <= a.TotalMoney)
+                    {
+                        //花了钱,就可以显示大名
+                        bu.Vip = i + 1;
+                        EventSystem.Instance.Publish(ShowVipName.Clone((uint)a.UnitId, i + 1));
 
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                Log.Warning("gift unit is null");
+                return;
+            }
             await ETTask.CompletedTask;
         }
     }

+ 1 - 0
Unity/Assets/Scripts/Codes/Hotfix/Client/battle/unit/BattleUnit.cs

@@ -15,6 +15,7 @@ public class BattleUnit : BattleObject
     public bool IsDead { get { return ZUnit.CurrentState == UnitActionStatus.Dead; } }
 
     private EventDispatcher<UnitActionStatus, object> actionChangeHandler;
+    public int Vip = 0;
 
     public override void OnAwake(ZoneObject zo)
     {

+ 6 - 4
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/OnNewZoneObject.cs

@@ -55,6 +55,7 @@ namespace ET.Client
             go.transform.rotation = RenderUtils.UnityRotationFromBattle(zu.Direction);
 
             var render = ModelViewComponent.Instance.AddChildWithId<UnitRenderComponet, GameObject>(unit.Id, go, true);
+            render.Vip = unit.Vip;
             if (zu.Info.Properties is XmdsUnitProperties prop && prop.ShowHPBanner)
             {
                 CreateHeadbar(render, zu).Coroutine();
@@ -125,14 +126,13 @@ namespace ET.Client
             var view = await GameObjectPool.Instance.AcquireHeadBar();
             view.visible = true;
             render.HeadBar = view;
-            var name = view.GetChild("text_name");
+            var name = view.GetChild("text_name").asTextField;
             var progresshp = view.GetChild("bar_hp") as GProgressBar;
             progresshp.max = 100;
             progresshp.min = 0;
             render.NameBar = name;
             render.HPBar = progresshp;
 
-            
             if (zu.Force == 3)
             {
                 name.text = "";
@@ -151,12 +151,14 @@ namespace ET.Client
 
         private async void TryShowName(UnitRenderComponet render)
         {
-            if (render.IsVipName)
+            if (render.Vip > 0)
             {
                 render.NameBar.visible = true;
+                render.NameBar.color = GameSetting.VipColor[render.Vip];
             }
             else
             {
+                render.NameBar.color = GameSetting.VipColor[0];
                 var unitCnt = UnitMgr.Instance.PlayerList.Count - 7;
                 if (unitCnt <= GameSetting.Name_level_1)
                 {
@@ -171,7 +173,7 @@ namespace ET.Client
                         {
                             if (id == render.Id) continue;
                             var r = ModelViewComponent.Instance.GetChild<UnitRenderComponet>(id);
-                            if (r != null && r.NameBar != null && !r.IsVipName)
+                            if (r != null && r.NameBar != null && r.Vip == 0)
                             {
                                 r.NameBar.visible = false;
                             }

+ 2 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Unit/UnitRenderSystem.cs

@@ -80,7 +80,8 @@ namespace ET.Client
             if (unitRender != null)
             {
                 unitRender.NameBar.visible = true;
-                unitRender.IsVipName = true;
+                unitRender.Vip = args.Vip;
+                unitRender.NameBar.color = GameSetting.VipColor[args.Vip];
             }
         }
     }

+ 3 - 1
Unity/Assets/Scripts/Codes/Model/Client/EventTypeClient.cs

@@ -333,10 +333,12 @@ namespace ET
         public class ShowVipName
         {
             public uint ObjId;
+            public int Vip;
             public static ShowVipName Static = new();
-            public static ShowVipName Clone(uint objId)
+            public static ShowVipName Clone(uint objId, int vip)
             {
                 Static.ObjId = objId;
+                Static .Vip = vip;
                 return Static;
             }
         }

+ 4 - 1
Unity/Assets/Scripts/Codes/Model/Client/GameSetting.cs

@@ -1,5 +1,5 @@
 using UnityEngine;
-
+using Color = UnityEngine.Color;
 namespace ET
 {
     public class GameSetting : Singleton<GameSetting>
@@ -10,6 +10,9 @@ namespace ET
         public const int Name_level_3 = 100;      //少于多少人时,名字显示3秒
         public const int Name_level_4 = 200;      //少于多少人时,名字显示1秒
 
+        public static int MoneyShowVipName = 1040;  //10.4元享受vip待遇
+        public static int[] VipMoney = { 1040, 1990, 5200, 10400 };
+        public static Color[] VipColor = { Color.white, new Color(0xcc / 255f, 1, 1, 1), new Color(0x66 / 255f,0xcc / 255f, 1, 1), new Color(1, 1, 0x33 / 255f, 1), Color.red };
         public enum Sets
         {
             Mute_int,

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

@@ -7,8 +7,6 @@
     {
         //session过期时间(毫秒),设置小于等于0时,session永不过期
         public const int SessionTimeoutTime = 5 * 1000;
-
-        public static int MoneyShowVipName = 1040;  //10.4元享受vip待遇
     }
 
     public enum BattlePushCnst

+ 3 - 3
Unity/Assets/Scripts/Codes/ModelView/Client/Unit/UnitRenderComponet.cs

@@ -26,12 +26,12 @@ namespace ET.Client
         public AnimatorCommand DoingCmd;
         public GComponent HeadBar;
         public GProgressBar HPBar;
-        public GObject NameBar;
+        public GTextField NameBar;
         public Transform TransHeadInfo;
         public Transform TransChest;
         public Transform TransFoot;
 
-        public bool IsVipName;
+        public int Vip = 0;
 
         //TODO: 获得模型绑定部件,如不存在返回Root
         public Transform GetBindPart(string partName)
@@ -101,7 +101,7 @@ namespace ET.Client
             TransFoot = null;
             Commands.Clear();
             BuffEffects.Clear();
-            IsVipName = false;
+            Vip = 0;
         }
     }