Browse Source

Merge remote-tracking branch 'remotes/origin/master' into xiaojie

何晓捷 2 years ago
parent
commit
94f92c9f20

+ 5 - 0
GameClient/Assets/Game/HotUpdate/Constant/ConstMessage.cs

@@ -124,5 +124,10 @@ namespace GFGGame
         public const string CONTINUOUS_REBATE_GIFT = "CONTINUOUS_REBATE_GIFT";//领取连续返利礼包
         public const string CONTINUOUS_REBATE_GIFT_SHOP_BUY = "CONTINUOUS_REBATE_GIFT_SHOP_BUY";
         public const string ACTIVITY_LUCKY_BOX = "ACTIVITY_LUCKY_BOX";//通知限时抽奖活动剩余次数
+        
+        //通知活动移除
+        public const string ACTIVITY_REMOVE = "ACTIVITY_REMOVE";
+        //通知活动添加
+        public const string ACTIVITY_ADD = "ACTIVITY_ADD";
     }
 }

+ 6 - 6
GameClient/Assets/Game/HotUpdate/Constant/ConstSortingOrder.cs

@@ -2,11 +2,11 @@ namespace GFGGame
 {
     public class ConstSortingOrder
     {
-        public const int TOP = 99;
-        public const int Guide = 100;
-        public const int Modal = 101;
-        public const int Alert = 102;
-        public const int Debug = 103;
-        public const int Float = 104;
+        public const int TOP = 1099;
+        public const int Guide = 1100;
+        public const int Modal = 1101;
+        public const int Alert = 1102;
+        public const int Debug = 1103;
+        public const int Float = 1104;
     }
 }

+ 1 - 0
GameClient/Assets/Game/HotUpdate/Controller/GameController.cs

@@ -256,6 +256,7 @@ namespace GFGGame
             EnduringGiftBoxSProxy.ReqGetAllGiftBagRebateStatus().Coroutine();
             ChatSProxy.ReqQueryChatMsg(ChatType.League).Coroutine();
             ChatSProxy.ReqQueryChatMsg(ChatType.LeagueQuestion).Coroutine();
+            ActivityGlobalSProxy.GetActivityInfo().Coroutine();
 
             int storageAutoPlay = StorageDataManager.Instance.GetStorageValue(ConstStorageId.STORAGE_AUTO_PLAY);
             FightDataManager.Instance.autoPlay = storageAutoPlay <= 0 ? false : true;

+ 78 - 0
GameClient/Assets/Game/HotUpdate/Data/ActivityGlobalDataManager.cs

@@ -0,0 +1,78 @@
+using System.Collections.Generic;
+using System.Linq;
+using ET;
+using FairyGUI;
+
+namespace GFGGame
+{
+    public class ActivityInfo
+    {
+        public int activityId;
+
+        public long startTime;
+
+        public long endTime;
+    }
+
+    public class ActivityGlobalDataManager : SingletonBase<ActivityGlobalDataManager>
+    {
+        private Dictionary<int, ActivityInfo> activityInfos = new Dictionary<int, ActivityInfo>();
+
+        private Dictionary<int, List<int>> activityInfosByType = new Dictionary<int, List<int>>();
+
+        //添加活动数据
+        public void AddActivityInfo(ActivityInfo activityInfo)
+        {
+            if (activityInfo == null) return;
+            if (activityInfos.ContainsKey(activityInfo.activityId)) return;
+            activityInfos.Add(activityInfo.activityId, activityInfo);
+            if (!activityInfosByType.ContainsKey(activityInfo.activityId))
+            {
+                activityInfosByType.Add(activityInfo.activityId, new List<int>());
+            }
+            activityInfosByType[activityInfo.activityId].Add(activityInfo.activityId);
+            //ACTIVITY_ADD
+            EventAgent.DispatchEvent(ConstMessage.ACTIVITY_ADD, activityInfo.activityId);
+            //TODO 判断下时间非法情况
+            Timers.inst.Add(activityInfo.endTime - TimeHelper.ServerNow(), 0, ClientRemoveActivityInfo,
+                activityInfo.activityId);
+        }
+
+        private static void ClientRemoveActivityInfo(object param)
+        {
+            var activityId = (int)param;
+            ActivityGlobalSProxy.ReqCloseActivity(activityId).Coroutine();
+        }
+
+        //RemoveActivityInfo
+        public void RemoveActivityInfo(int activityId)
+        {
+            if (!activityInfos.ContainsKey(activityId)) return;
+            activityInfos.Remove(activityId);
+            if (!activityInfosByType.ContainsKey(activityId)) return;
+            activityInfosByType.Remove(activityId);
+            //ACTIVITY_REMOVE
+            EventAgent.DispatchEvent(ConstMessage.ACTIVITY_REMOVE, activityId);
+        }
+
+        //获取活动数据
+        public ActivityInfo GetActivityInfo(int activityId)
+        {
+            if (!activityInfos.ContainsKey(activityId)) return null;
+            return activityInfos[activityId];
+        }
+
+        //获取活动数据根据类型
+        public List<int> GetActivityInfoIdsByType(int activityType)
+        {
+            return !activityInfosByType.ContainsKey(activityType) ? new List<int>() : activityInfosByType[activityType];
+        }
+
+        //获取活动数据根据类型
+        public List<ActivityInfo> GetActivityInfoByType(int activityType)
+        {
+            var activityInfoIds = GetActivityInfoIdsByType(activityType);
+            return activityInfoIds.Select(GetActivityInfo).Where(activityInfo => activityInfo != null).ToList();
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/Game/HotUpdate/Data/ActivityGlobalDataManager.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 6ffaecd67741449e8034482090b52e39
+timeCreated: 1685762521

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Data/PhotographUtil.cs

@@ -210,7 +210,7 @@ namespace GFGGame
                 string[] strs = tf.name.Split('_');
                 if (strs.Length > 1 && strs[1] == "eff")//子物体是特效
                 {
-                    DressUpUtil.SetParticleSortingOrder(tf.gameObject, changeLayer, true);
+                    DressUpUtil.SetRenderersOrder(tf.gameObject, changeLayer, true);
                 }
             }
             CubismRenderController[] cubismRenders = parentObj.GetComponentsInChildren<CubismRenderController>();

+ 27 - 11
GameClient/Assets/Game/HotUpdate/DressUp/DressUpUtil.cs

@@ -186,7 +186,7 @@ namespace GFGGame
             //特效
             if (!string.IsNullOrEmpty(effRes))
             {
-                TryAddEffectObj(effRes, BODY_EFFECT_OBJ_NAME, parentObj, 0);
+                TryAddEffectObj(effRes, BODY_EFFECT_OBJ_NAME, parentObj, 0, false);
             }
         }
 
@@ -237,9 +237,10 @@ namespace GFGGame
             //这里需要先添加静态图,防止加载动画有延迟,出现光头
             GameObject spriteObj = AddSpriteObj(res, ext, spritObjName, parentObj, sortingOrder, needSetMask);
 
+            GameObject aniObj = null;
             if (showAni)
             {
-                var aniObj = AddAnimationObj(res, aniObjName, parentObj, sortingOrder);
+                aniObj = AddAnimationObj(res, aniObjName, parentObj, sortingOrder);
                 if (aniObj != null && spriteObj != null)
                 {
                     Timers.inst.Add(0.03f, 1, (obj) =>
@@ -269,7 +270,7 @@ namespace GFGGame
 
             aniObjName = string.Format(FORMAT_EFFECT_OBJ_NAME, itemCfg.subType, layerId);
             TryRemoveObj(parentObj, aniObjName);
-            TryAddEffectObj(res, aniObjName, parentObj, sortingOrder);
+            TryAddEffectObj(res, aniObjName, parentObj, sortingOrder, aniObj != null);
         }
 
         private static GameObject AddSpriteObj(string res, string ext, string objName, GameObject parentObj, int sortingOrder, bool needSetMask)
@@ -387,7 +388,7 @@ namespace GFGGame
             {
                 render.SortingOrder = sortingOrder;
             }
-            SetParticleSortingOrder(gameObj, sortingOrder);
+            SetRenderersOrder(gameObj, sortingOrder);
             return gameObj;
         }
 
@@ -423,9 +424,9 @@ namespace GFGGame
             return gameObj;
         }
 
-        private static void TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder)
+        private static void TryAddEffectObj(string res, string objName, GameObject parentObj, int sortingOrder, bool inAni)
         {
-            var resPath = ResPathUtil.GetDressUpEffectPath(res);
+            var resPath = ResPathUtil.GetDressUpEffectPath(res, inAni);
             if (!VEngine.Versions.Contains(resPath))
             {
                 return;
@@ -436,12 +437,11 @@ namespace GFGGame
             gameObj.transform.SetParent(parentObj.transform, false);
             gameObj.name = objName;
             var sortingGroup = gameObj.transform.GetComponent<SortingGroup>();
-            if (sortingGroup == null)
+            if (sortingGroup != null)
             {
-                sortingGroup = gameObj.AddComponent<SortingGroup>();
+                GameObject.Destroy(sortingGroup);
             }
-            sortingGroup.sortingOrder = sortingOrder + 1;//特效层默认高一个层级
-            //SetParticleSortingOrder(gameObj, sortingOrder + 1);//特效层默认高一个层级
+            SetRenderersOrder(gameObj, sortingOrder + 1);//特效层默认高一个层级
         }
 
         public static void LoadSpritePos(string res, out float tx, out float ty)
@@ -464,9 +464,25 @@ namespace GFGGame
             ty = 0;
         }
 
-        public static void SetParticleSortingOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
+        public static void SetRenderersOrder(GameObject gameObj, int sortingOrder, bool isAdd = false)
         {
+            var meshRenderers = gameObj.transform.GetComponentsInChildren<MeshRenderer>();
+            for (int i = 0; i < meshRenderers.Length; i++)
+            {
+                var renderer = meshRenderers[i].GetComponent<Renderer>();
+                if (renderer != null)
+                {
+                    if (isAdd)
+                    {
+                        renderer.sortingOrder = renderer.sortingOrder + sortingOrder;
+                    }
+                    else
+                    {
 
+                        renderer.sortingOrder = sortingOrder;
+                    }
+                }
+            }
             ParticleSystem[] particles = gameObj.transform.GetComponentsInChildren<ParticleSystem>();
             for (int i = 0; i < particles.Length; i++)
             {

+ 4 - 0
GameClient/Assets/Game/HotUpdate/DressUp/MyDressUpHelper.cs

@@ -64,6 +64,10 @@ namespace GFGGame
                 {
                     isShangYi = true;
                 }
+                if(itemCfg.subType == ConstDressUpItemType.NEI_DA && itemCfg.id != ConstItemID.DEFULT_NEI_DA)
+                {
+                    isShangYi = true;
+                }
                 if (itemCfg.subType == ConstDressUpItemType.XIA_ZHUANG && itemCfg.id != ConstItemID.DEFULT_XIA_ZHUANG)
                 {
                     isXiaZhuang = true;

+ 72 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/ActivityGlobalSProxy.cs

@@ -0,0 +1,72 @@
+using ET;
+using GFGGame;
+
+namespace ET
+{
+    //S2C_NoticeActivityOpen
+    public class S2C_NoticeActivityOpenHandler : AMHandler<S2C_NoticeActivityOpen>
+    {
+        protected override async ETTask Run(Session session, S2C_NoticeActivityOpen message)
+        {
+            ActivityGlobalDataManager.Instance.AddActivityInfo(new ActivityInfo
+            {
+                activityId = message.ActivityId,
+                startTime = message.StartTime,
+                endTime = message.EndTime
+            });
+            await ETTask.CompletedTask;
+        }
+    }
+    
+    //S2C_NoticeActivityClose
+    public class S2C_NoticeActivityCloseHandler : AMHandler<S2C_NoticeActivityClose>
+    {
+        protected override async ETTask Run(Session session, S2C_NoticeActivityClose message)
+        {
+            ActivityGlobalDataManager.Instance.RemoveActivityInfo(message.ActivityId);
+            await ETTask.CompletedTask;
+        }
+    }
+}
+
+namespace GFGGame
+{
+    public class ActivityGlobalSProxy
+    {
+        public static async ETTask GetActivityInfo()
+        {
+            var c2SGetActivityList = new C2S_GetActivityList();
+            //获取活动数据,这里是一次性拉去所有活动数据,如果活动数据量大,可以分类型拉取
+            c2SGetActivityList.Type.Add(0);
+            var response = (S2C_GetActivityList)await MessageHelper.SendToServer(c2SGetActivityList);
+            if (!(response is { Error: ErrorCode.ERR_Success }))
+            {
+                Log.Error("GetActivityInfo error");
+                return;
+            }
+            response.ActivityList.ForEach(activityInfo =>
+            {
+                ActivityGlobalDataManager.Instance.AddActivityInfo(new ActivityInfo
+                {
+                    activityId = activityInfo.ActivityId,
+                    startTime = activityInfo.StartTime,
+                    endTime = activityInfo.EndTime
+                });
+            });
+        }
+
+        //C2S_CloseActivity
+        public static async ETTask<bool> ReqCloseActivity(int activityId)
+        {
+            var response =
+                (S2C_CloseActivity)await MessageHelper.SendToServer(new C2S_CloseActivity()
+                    { ActivityId = activityId });
+            if (!(response is { Error: ErrorCode.ERR_Success }))
+            {
+                Log.Error("ReqCloseActivity error");
+                return false;
+            }
+            return true;
+        }
+    }
+}

+ 3 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/ActivityGlobalSProxy.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: af8ba20371d34f6cb41a29aad5df7459
+timeCreated: 1685762716

+ 5 - 1
GameClient/Assets/Game/HotUpdate/Utils/ResPathUtil.cs

@@ -111,8 +111,12 @@ namespace GFGGame
         {
             return $"{ANIMATION_DIR_PATH}/DressUp/{res}/{res}.{extName}";
         }
-        public static string GetDressUpEffectPath(string res, string extName = "prefab")
+        public static string GetDressUpEffectPath(string res, bool inAni = false, string extName = "prefab")
         {
+            if(inAni)
+            {
+                return $"{EFFECT_DIR_PATH}/DressUpAni/{res}/{res}.{extName}";
+            }
             return $"{EFFECT_DIR_PATH}/DressUp/{res}/{res}.{extName}";
         }
         public static string GetViewEffectPath(string uiName, string resName, string extName = "prefab")

+ 1 - 1
GameClient/Assets/Game/HotUpdate/Views/Common/Controller/LuckyBoxController.cs

@@ -38,7 +38,7 @@ namespace GFGGame
             if (_luckyBoxCfg.resArr.Length > 1 || _luckyBoxCfg.suitShowArr.Length > 1)
             {
                 Timers.inst.Remove(UpdateTime);
-                Timers.inst.Add(1, 0, UpdateTime);
+                //Timers.inst.Add(1, 0, UpdateTime);
             }
         }