Browse Source

新年红包

huangxiaoyue 1 year ago
parent
commit
6a6ebe2269
25 changed files with 179 additions and 18 deletions
  1. 3 0
      GameClient/Assets/Game/HotUpdate/Constant/ConstMessage.cs
  2. 18 0
      GameClient/Assets/Game/HotUpdate/Data/NewYearRedEnvelopeDataManager.cs
  3. 11 0
      GameClient/Assets/Game/HotUpdate/Data/NewYearRedEnvelopeDataManager.cs.meta
  4. 0 3
      GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/NewYearRedEnvelope/UI_Button1.cs
  5. 3 4
      GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/NewYearRedEnvelope/UI_NewYearRedEnvelopeUI.cs
  6. 63 0
      GameClient/Assets/Game/HotUpdate/ServerProxy/NewYearRedEnvelopeSproxy.cs
  7. 11 0
      GameClient/Assets/Game/HotUpdate/ServerProxy/NewYearRedEnvelopeSproxy.cs.meta
  8. 8 6
      GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs
  9. 62 5
      GameClient/Assets/Game/HotUpdate/Views/NewYearRedEnvelope/NewYearRedEnvelopeView.cs
  10. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0!a.png
  11. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0.png
  12. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_1!a.png
  13. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_1.png
  14. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_2!a.png
  15. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_2.png
  16. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_4!a.png
  17. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_4.png
  18. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_7!a.png
  19. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_7.png
  20. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_8!a.png
  21. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_8.png
  22. BIN
      GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_fui.bytes
  23. BIN
      GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_atlas0!a.png
  24. BIN
      GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_atlas0.png
  25. BIN
      GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_fui.bytes

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

@@ -232,5 +232,8 @@ namespace GFGGame
 
         //显示系统公告界面
         public const string SHOW_SYSTEM_NOTICE = "SHOW_SYSTEM_NOTICE";
+
+        //新年红包领取加倍按钮
+        public const string NEW_YEAR_RED_ENVELOPE_INFO = "NEW_YEAR_RED_ENVELOPE_INFO";
     }
 }

+ 18 - 0
GameClient/Assets/Game/HotUpdate/Data/NewYearRedEnvelopeDataManager.cs

@@ -0,0 +1,18 @@
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using ET;
+using UnityEngine;
+
+namespace GFGGame
+{
+    public class NewYearRedEnvelopeDataManager
+    {
+        public static int Status = RedPacketStatus.None;  //红包领取状态
+        public static int ItemId = 0;  //红包奖励物品
+        public static int ItemNum = 0;  //奖励数量(单倍)
+
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/Data/NewYearRedEnvelopeDataManager.cs.meta

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

+ 0 - 3
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/NewYearRedEnvelope/UI_Button1.cs

@@ -7,7 +7,6 @@ namespace UI.NewYearRedEnvelope
     public partial class UI_Button1
     {
         public GButton target;
-        public Controller m_ButtonType;
         public GRichTextField m_txtTime;
         public const string URL = "ui://pt3t9f1ujsko7";
         public const string PACKAGE_NAME = "NewYearRedEnvelope";
@@ -56,12 +55,10 @@ namespace UI.NewYearRedEnvelope
 
         private void Init(GComponent comp)
         {
-            m_ButtonType = comp.GetController("ButtonType");
             m_txtTime = (GRichTextField)comp.GetChild("txtTime");
         }
         public void Dispose(bool disposeTarget = false)
         {
-            m_ButtonType = null;
             m_txtTime = null;
             if(disposeTarget && target != null)
             {

+ 3 - 4
GameClient/Assets/Game/HotUpdate/FairyGUI/GenCode/NewYearRedEnvelope/UI_NewYearRedEnvelopeUI.cs

@@ -11,8 +11,8 @@ namespace UI.NewYearRedEnvelope
         public Controller m_openType;
         public GButton m_btnOpen;
         public GRichTextField m_txtTime;
-        public UI_Button1 m_btnGet;
         public UI_Button1 m_btnDoubleGet;
+        public GComponent m_itemReward;
         public GRichTextField m_textGetNum;
         public const string URL = "ui://pt3t9f1ujsko0";
         public const string PACKAGE_NAME = "NewYearRedEnvelope";
@@ -65,8 +65,8 @@ namespace UI.NewYearRedEnvelope
             m_openType = comp.GetController("openType");
             m_btnOpen = (GButton)comp.GetChild("btnOpen");
             m_txtTime = (GRichTextField)comp.GetChild("txtTime");
-            m_btnGet = (UI_Button1)UI_Button1.Create(comp.GetChild("btnGet"));
             m_btnDoubleGet = (UI_Button1)UI_Button1.Create(comp.GetChild("btnDoubleGet"));
+            m_itemReward = (GComponent)comp.GetChild("itemReward");
             m_textGetNum = (GRichTextField)comp.GetChild("textGetNum");
         }
         public void Dispose(bool disposeTarget = false)
@@ -75,10 +75,9 @@ namespace UI.NewYearRedEnvelope
             m_openType = null;
             m_btnOpen = null;
             m_txtTime = null;
-            m_btnGet.Dispose();
-            m_btnGet = null;
             m_btnDoubleGet.Dispose();
             m_btnDoubleGet = null;
+            m_itemReward = null;
             m_textGetNum = null;
             if(disposeTarget && target != null)
             {

+ 63 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/NewYearRedEnvelopeSproxy.cs

@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+using ET;
+using GFGGame;
+using UnityEngine;
+
+namespace ET
+{
+    public class NoticeRedPacketDouble : AMHandler<S2C_NoticeRedPacketDouble>
+    {
+        protected override async ETTask Run(Session session, S2C_NoticeRedPacketDouble message)
+        {
+            NewYearRedEnvelopeDataManager.Status = RedPacketStatus.Double;
+            ET.Log.Debug("打印测试======双倍推送==========");
+            int[][] itemData = new int[][] { new int[] { message.ItemId, message.ItemNum } };
+            BonusController.TryShowBonusList(itemData);
+            await ETTask.CompletedTask;
+        }
+    }
+}
+
+namespace GFGGame
+{
+    public class NewYearRedEnvelopeSProxy
+    {
+        //获取红包信息
+        public static async ETTask<bool> ReqGetRedPacketInfo(int activityId)
+        {
+            S2C_GetRedPacketInfo response = null;
+            response = (S2C_GetRedPacketInfo)await MessageHelper.SendToServer(new C2S_GetRedPacketInfo() { ActivityId = activityId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    NewYearRedEnvelopeDataManager.Status = response.Status;
+                    NewYearRedEnvelopeDataManager.ItemId = response.ItemId;
+                    NewYearRedEnvelopeDataManager.ItemNum = response.ItemNum;
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        //开红包
+        public static async ETTask<bool> ReqOpenRedPacket(int activityId)
+        {
+            S2C_ReqOpenRedPacket response = null;
+            response = (S2C_ReqOpenRedPacket)await MessageHelper.SendToServer(new C2S_ReqOpenRedPacket() { ActivityId = activityId });
+            if (response != null)
+            {
+                if (response.Error == ErrorCode.ERR_Success)
+                {
+                    NewYearRedEnvelopeDataManager.Status = RedPacketStatus.Open;
+                    int[][] itemData = new int[][] { new int[] { response.ItemId, response.ItemNum } };
+                    BonusController.TryShowBonusList(itemData);
+                    var ramdomInt = Random.Range(1, 4).ToString();
+                    PlayerPrefs.SetString("NewYearRedEnvelopeRamdomInt", ramdomInt);   
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+}

+ 11 - 0
GameClient/Assets/Game/HotUpdate/ServerProxy/NewYearRedEnvelopeSproxy.cs.meta

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

+ 8 - 6
GameClient/Assets/Game/HotUpdate/Views/MainUI/MainUIView.cs

@@ -335,12 +335,14 @@ namespace GFGGame
 
         private void OnClickBtnXiuFang()
         {
-            if (isOpen) return;
-            isOpen = true;
-            _ui.m_btnXiuFang.m_holder1.visible = true;
-            _ui.m_btnXiuFang.m_holder1.visible = false;
-            ViewManager.Show<XiuFangView>();
-            isOpen = false;
+            ViewManager.Show<NewYearRedEnvelopeView>();
+
+            //if (isOpen) return;
+            //isOpen = true;
+            //_ui.m_btnXiuFang.m_holder1.visible = true;
+            //_ui.m_btnXiuFang.m_holder1.visible = false;
+            //ViewManager.Show<XiuFangView>();
+            //isOpen = false;
         }
 
         private void OnClickBtnDailyLogin()

+ 62 - 5
GameClient/Assets/Game/HotUpdate/Views/NewYearRedEnvelope/NewYearRedEnvelopeView.cs

@@ -1,6 +1,9 @@
 using FairyGUI;
 using ET;
 using UI.NewYearRedEnvelope;
+using UI.CommonGame;
+using UnityEngine;
+using System;
 
 namespace GFGGame
 {
@@ -29,41 +32,95 @@ namespace GFGGame
             //viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
 
             _ui.m_btnOpen.onClick.Add(OnClickBtnOpen);
+            _ui.m_btnDoubleGet.target.onClick.Add(OnClickBtnDoubleGet);
         }
+
         protected override void AddEventListener()
         {
             base.AddEventListener();
-            //EventAgent.AddEventListener(ConstMessage.MAIL_REFRESH, RefreshList);
+            EventAgent.AddEventListener(ConstMessage.NEW_YEAR_RED_ENVELOPE_INFO, RefreshViewInfo);
         }
 
         protected override void RemoveEventListener()
         {
             base.RemoveEventListener();
-            //EventAgent.RemoveEventListener(ConstMessage.MAIL_REFRESH, RefreshList);
+            EventAgent.RemoveEventListener(ConstMessage.NEW_YEAR_RED_ENVELOPE_INFO, RefreshViewInfo);
+        }
+
+        private void RefreshViewInfo()
+        {
+            _ui.m_btnDoubleGet.target.visible = NewYearRedEnvelopeDataManager.Status != RedPacketStatus.Double;
         }
 
         protected override void OnShown()
         {
             base.OnShown();
+
+            int actRedPacketId = ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.NewYearRedPacket);
+            if (NewYearRedEnvelopeDataManager.Status == RedPacketStatus.None) { 
+                _ui.m_openType.selectedIndex = 0;
+                _ui.m_titleImgType.selectedIndex = 0; 
+            }
+            else if (NewYearRedEnvelopeDataManager.Status == RedPacketStatus.Open) { 
+                RefreshOpenView();
+            }
+
+            _ui.m_textGetNum.text = NewYearRedEnvelopeDataManager.ItemNum.ToString();
             Timers.inst.Add(1, 0, UpdateTime);
         }
 
+        private void RefreshOpenView()
+        {
+            _ui.m_openType.selectedIndex = 1;
+            var titleIndex = PlayerPrefs.GetString("NewYearRedEnvelopeRamdomInt");
+            ET.Log.Debug("打印测试=====取出随机数===========" + Convert.ToInt32(titleIndex));
+            _ui.m_titleImgType.selectedIndex = Convert.ToInt32(titleIndex) - 1;
+            UI_ComItem item = UI_ComItem.Proxy(_ui.m_itemReward);
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(NewYearRedEnvelopeDataManager.ItemId);
+            RarityIconController.UpdateRarityIcon(item.m_loaRarity, itemCfg.id, false);
+            item.target.data = itemCfg;
+            item.m_QualityType.selectedIndex = itemCfg.rarity - 1;
+            item.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
+            item.m_txtCount.text = NewYearRedEnvelopeDataManager.ItemNum.ToString();
+            UI_ComItem.ProxyEnd();
+        }
+
         private void UpdateTime(object param)
         {
             int actLimitId = ActivityDataManager.Instance.GetCurOpenActiveByType(ConstLimitTimeActivityType.ActLimitStlyc);
             ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(actLimitId);
             long time = TimeUtil.DateTimeToTimestamp(activityOpenCfg.endTime) - TimeHelper.ServerNow();
-            string strTime = TimeUtil.FormattingTimeTo_DD_HH_mm(time);
-            _ui.m_txtTime.text = strTime;
+            string strTime = TimeUtil.FormattingTimeTo_DDHHmm(time);
+            _ui.m_txtTime.text = "第一天:" + strTime;
             UI_Button1 btn = UI_Button1.Proxy(_ui.m_btnDoubleGet.target);
             btn.m_txtTime.text = strTime;
             UI_Button1.ProxyEnd();
         }
 
+        private void OnClickBtnDoubleGet(EventContext context)
+        {
+            ET.Log.Debug("打印测试=====点击双倍按钮===========");
+            ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(NewYearRedEnvelopeDataManager.ItemId);
+            if (!AntiAddictionController.CheckAntiAddictionRecharge(1))
+            {
+                ShopSProxy.ReqShopBuy(itemCfg.id, 1).Coroutine();
+                LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
+            }
+        }
+
         private void OnClickBtnOpen(EventContext context)
         {
+            ReqLeagueList();
+        }
 
-            _ui.m_openType.selectedIndex = 1;
+        private async void ReqLeagueList()
+        {
+            int actRedPacketId = ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityType.NewYearRedPacket);
+            bool result = await NewYearRedEnvelopeSProxy.ReqOpenRedPacket(actRedPacketId);
+            if (result)
+            {
+                RefreshOpenView();
+            }
         }
 
         protected override void OnHide()

BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_1!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_1.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_2!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_2.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_4!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_4.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_7!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_7.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_8!a.png


BIN
GameClient/Assets/ResIn/UI/LuckyBox/LuckyBox_atlas0_8.png


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


BIN
GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_atlas0!a.png


BIN
GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_atlas0.png


BIN
GameClient/Assets/ResIn/UI/NewYearRedEnvelope/NewYearRedEnvelope_fui.bytes