guodong 2 years ago
parent
commit
9cd1d52291

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

@@ -155,5 +155,7 @@ namespace GFGGame
         public const string GUIDE_VIEW_HIDE = "GUIDE_VIEW_HIDE";
         //每日重置
         public const string RESET_DAILY_DATA = "RESET_DAILY_DATA";
+
+        public const string LUCKY_BOX_FREE_TIME_CHANGED = "LUCKY_BOX_FREE_TIME_CHANGED";
     }
 }

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

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

+ 28 - 0
GameClient/Assets/Game/HotUpdate/Data/LuckyBoxDataManager.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using ET;
 
 namespace GFGGame
 {
@@ -22,6 +23,9 @@ namespace GFGGame
         public long startTime = 1668873600000;
         public long endTime = 1672156799000;
 
+        //存储奖池免费时间,大于存储时间免费
+        public Dictionary<int, long> luckyBoxFreeTimeMillDic = new Dictionary<int, long>();
+
 
         public int times = 0;
         public int luckyBoxIndex;
@@ -65,6 +69,30 @@ namespace GFGGame
                 }
             }
         }
+
+        public void InitServerData(S2C_GetLuckyBoxInfo response)
+        {
+            luckyBoxFreeTimeMillDic.Clear();
+            int count = response.KsLuckyBoxId.Count;
+            for(var i = 0; i < count; i++)
+            {
+                luckyBoxFreeTimeMillDic[response.KsLuckyBoxId[i]] = response.VsFreeTime[i];
+            }
+        }
+
+        public void UpdateFreeTime(int luckyBoxId, long freeTimeMill)
+        {
+            luckyBoxFreeTimeMillDic[luckyBoxId] = freeTimeMill;
+            EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_FREE_TIME_CHANGED);
+        }
+
+        //返回奖池免费时间,如果是0,则不免费,大约0并且当前时间大于存储时间则免费
+        public long GetFreeTime(int luckyBoxId)
+        {
+            luckyBoxFreeTimeMillDic.TryGetValue(luckyBoxId, out var freeTime);
+            return freeTime;
+        }
+
         public void InitData(int boxId)
         {
             LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);

+ 3 - 0
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/LuckyBox/UI_ComBox1.cs

@@ -22,6 +22,7 @@ namespace UI.LuckyBox
         public GImage m_imgSpecial;
         public GGraph m_holder;
         public GGroup m_grpSpecial;
+        public GTextField m_txtFreeTime;
         public const string URL = "ui://drx9d1usduuftcr";
         public const string PACKAGE_NAME = "LuckyBox";
         public const string RES_NAME = "ComBox1";
@@ -84,6 +85,7 @@ namespace UI.LuckyBox
             m_imgSpecial = (GImage)comp.GetChild("imgSpecial");
             m_holder = (GGraph)comp.GetChild("holder");
             m_grpSpecial = (GGroup)comp.GetChild("grpSpecial");
+            m_txtFreeTime = (GTextField)comp.GetChild("txtFreeTime");
         }
         public void Dispose(bool disposeTarget = false)
         {
@@ -105,6 +107,7 @@ namespace UI.LuckyBox
             m_imgSpecial = null;
             m_holder = null;
             m_grpSpecial = null;
+            m_txtFreeTime = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 6 - 0
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/LuckyBox/UI_ComCost.cs

@@ -7,8 +7,10 @@ namespace UI.LuckyBox
     public partial class UI_ComCost
     {
         public GComponent target;
+        public Controller m_c1;
         public GLoader m_loaCost;
         public GTextField m_txtCost;
+        public GTextField m_txtFree;
         public const string URL = "ui://drx9d1usvek812";
         public const string PACKAGE_NAME = "LuckyBox";
         public const string RES_NAME = "ComCost";
@@ -56,13 +58,17 @@ namespace UI.LuckyBox
 
         private void Init(GComponent comp)
         {
+            m_c1 = comp.GetController("c1");
             m_loaCost = (GLoader)comp.GetChild("loaCost");
             m_txtCost = (GTextField)comp.GetChild("txtCost");
+            m_txtFree = (GTextField)comp.GetChild("txtFree");
         }
         public void Dispose(bool disposeTarget = false)
         {
+            m_c1 = null;
             m_loaCost = null;
             m_txtCost = null;
+            m_txtFree = null;
             if(disposeTarget && target != null)
             {
                 target.RemoveFromParent();

+ 30 - 2
GameClient/Assets/Game/HotUpdate/ServerProxy/LuckyBoxSProxy.cs

@@ -1,15 +1,29 @@
 using ET;
+using GFGGame;
+
+namespace ET
+{
+    public class S2C_NoticeLuckyBoxFreeTimeHandler : AMHandler<S2C_NoticeLuckyBoxFreeTime>
+    {
+        protected override async ETTask Run(Session session, S2C_NoticeLuckyBoxFreeTime message)
+        {
+            LuckyBoxDataManager.Instance.UpdateFreeTime(message.LuckyBoxId, message.FreeTime);
+            await ETTask.CompletedTask;
+        }
+    }
+}
 
 namespace GFGGame
 {
+
     public class LuckyBoxSProxy
     {
 
         //抽奖
-        public static async ETTask<bool> ReqGetBonus(int luckyBoxId, int times)
+        public static async ETTask<bool> ReqGetBonus(int luckyBoxId, int times, bool free = false)
         {
             M2C_DrawLuckyBox response = null;
-            response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox() { LuckyBoxId = luckyBoxId, Times = times });
+            response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox() { LuckyBoxId = luckyBoxId, Times = times, Free = free });
             if (response != null)
             {
                 if (response.Error == ErrorCode.ERR_Success)
@@ -42,5 +56,19 @@ namespace GFGGame
             }
             return 0;
         }
+
+        //请求抽奖初始信息
+        public static async ETTask ReqGetLuckyBoxInfo()
+        {
+            S2C_GetLuckyBoxInfo response = null;
+            response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
+            if(response != null)
+            {
+                if(response.Error == ErrorCode.ERR_Success)
+                {
+                    LuckyBoxDataManager.Instance.InitServerData(response);
+                }
+            }
+        }
     }
 }

+ 8 - 0
GameClient/Assets/Game/HotUpdate/Views/LuckyBox/LuckyBoxView.cs

@@ -90,6 +90,7 @@ namespace GFGGame
 
             EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData);
             EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData);
+            EventAgent.AddEventListener(ConstMessage.LUCKY_BOX_FREE_TIME_CHANGED, UpdateFreeInfo);
         }
         protected override void OnShown()
         {
@@ -130,6 +131,7 @@ namespace GFGGame
 
             OnListBgScroll();
             updateBoxEffect();
+            UpdateFreeInfo();
 
             Timers.inst.AddUpdate(CheckGuide);
         }
@@ -365,6 +367,7 @@ namespace GFGGame
             base.RemoveEventListener();
             EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateListItemData);
             EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateListItemData);
+            EventAgent.RemoveEventListener(ConstMessage.LUCKY_BOX_FREE_TIME_CHANGED, UpdateFreeInfo);
         }
 
         private void OnClickBtnBack()
@@ -412,5 +415,10 @@ namespace GFGGame
             GuideCfg cfg = GuideCfgArray.Instance.GetCfg(ConstGuideId.LUCKY_BOX);
             GuideController.TryCompleteGuideIndex(ConstGuideId.LUCKY_BOX, 2);
         }
+
+        private void UpdateFreeInfo()
+        {
+
+        }
     }
 }

BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_fui.bytes