123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- using System;
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.MiniGame;
- using UnityEngine;
- using System.Text.RegularExpressions;
- namespace GFGGame
- {
- public class GameStartView : BaseWindow
- {
- private UI_GameStartUI _ui;
- //后续这里改成读表内容,1:CardGame,2:Merge2048Game,3:HuarongRoadGame
- private List<string> viewJumpName = new List<string>() {"","FlipGameView", "TZFEGameCheckView" ,"ActivityHuaRongDaoView"};
- private List<ActivityOpenCfg> activityGameDate;
- private List<int> GameType = new List<int>();
- private List<int> ChallengeList = new List<int>();
- //由于每个游戏都有一个表
- private List<CardGame> CardGameDate;
- private List<Merge2048Game> Merge2048GameDate;
- private int NumTicketOne = 3;
- private int NumTicketTwo = 3;
- private EffectUI _effectUI1;
- private EffectUI _effectUI2;
- private EffectUI _effectUI3;
- private EffectUI _effectUI4;
- public override void Dispose()
- {
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- EffectUIPool.Recycle(_effectUI2);
- _effectUI2 = null;
- EffectUIPool.Recycle(_effectUI3);
- _effectUI3 = null;
- EffectUIPool.Recycle(_effectUI4);
- _effectUI4 = null;
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_GameStartUI.PACKAGE_NAME;
- _ui = UI_GameStartUI.Create();
- this.viewCom = _ui.target;
- isfullScreen = true;
- isReturnView = true;
- _ui.m_game1.onClick.Add(OnClickBtnGameOne);
- _ui.m_game2.onClick.Add(OnClickBtnGameTwo);
- _ui.m_btnBack.onClick.Add(OnClickBtnBack);
- _ui.m_shopBtn.onClick.Add(OnClickBtnShop);
- _ui.m_addIcon.onClick.Add(OnClickBtnAdd);
- _ui.m_rewardBtn.target.onClick.Add(OnClickBtnReward);
- _ui.m_tipsOne.onClick.Add(RuleController.ShowRuleView);
- _ui.m_tipsTwo.onClick.Add(RuleController.ShowRuleView);
- _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_effectIcon1, "ui_Activity", "YXJY_Icon");
- _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_effectText1, "ui_Activity", "YXJY_Game_Text");
- _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_effectIcon2, "ui_Activity", "SGLL_Icon");
- _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_effectText2, "ui_Activity", "SGLL_Game_Text");
- }
- protected override void OnShown()
- {
- base.OnShown();
- activityGameDate = ActivityOpenCfgArray.Instance.GetCfgsBytype(ConstLimitTimeActivityType.ActLimitStlyc);
- GetGameIdByActivityDate();
- UpdateChallengeBtn();
- ReqChallageReward();
- UpdateView();
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- EventAgent.AddEventListener(ConstMessage.MINI_GAME_UPDATE, UpdateRed);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- EventAgent.AddEventListener(ConstMessage.MINI_GAME_UPDATE, UpdateRed);
- }
- protected override void OnHide()
- {
- GameType.Clear();
- ChallengeList.Clear();
- base.OnHide();
- }
- private void UpdateRed()
- {
- RedDotController.Instance.SetComRedDot(_ui.m_rewardBtn.target, MiniGameDateManager.Instance.GetRewardRot());
- }
- private void UpdateView()
- {
- if(ChallengeList.Count == 0)
- {
- _ui.m_rewardBtn.target.visible = false;
- }
- else
- {
- _ui.m_rewardBtn.target.visible = true;
- }
- _ui.m_ticket.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(3000017).res);
- _ui.m_needNum1.text = NumTicketOne.ToString();
- _ui.m_needNum2.text = NumTicketTwo.ToString();
- _ui.m_needIcon1.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(3000017).res);
- _ui.m_needIcon2.url = ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(3000017).res);
- _ui.m_needNum2.visible = false;
- _ui.m_needIcon2.visible = false;
- _ui.m_game1.url = "";
- _ui.m_game2.url = "";
- _ui.m_tipsOne.data = 300026;
- _ui.m_tipsTwo.data = 300027;
- ItemData item;
- if (BagDataManager.Instance.GetBagData().TryGetValue(3000017,out item))
- {
- _ui.m_ticketNum.text = item.num.ToString();
- }
- else
- {
- _ui.m_ticketNum.text = "0";
- }
- }
- private void OnClickBtnBack()
- {
- this.Hide();
- }
- private void OnClickBtnShop()
- {
- ViewManager.Show<StoreView>(new object[] { ConstStoreTabId.STORE_EXCHANGE, ConstStoreSubId.STORE_ACTIVITY_EXCHANGE });
- }
- private void OnClickBtnReward()
- {
- ViewManager.Show<ChallengeRewardView>(new object[] { ChallengeList });
- }
- private async void ReqChallageReward()
- {
- var result = await MiniGameProxy.ReqGetChallengeReward(activityGameDate[0].id);
- if (!result) return;
- RedDotController.Instance.SetComRedDot(_ui.m_rewardBtn.target, MiniGameDateManager.Instance.GetRewardRot());
- }
- private void OnClickBtnAdd()
- {
- object[] sourceDatas = new object[] { 3000017, null };
- GoodsItemTipsController.ShowItemTips(3000017, sourceDatas);
- }
- private async void OnClickBtnGameOne()
- {
- var result = await MiniGameProxy.ReqMiniGameStart(CardGameArray.Instance.GetCfgsBytypeAndsubType(GameType[0], GameType[1])[0].id, GameType[0], activityGameDate[0].id);
- if (!result) return;
- ViewManager.Show($"GFGGame.{viewJumpName[GameType[0]]}", new object[] { CardGameArray.Instance.GetCfgsBytypeAndsubType(GameType[0], GameType[1])[0].id });
- }
- private void OnClickBtnGameTwo()
- {
- ViewManager.Show($"GFGGame.{viewJumpName[GameType[2]]}",new object[] { GameType[2],GameType[3]});
- }
- private void GetGameIdByActivityDate()
- {
- string pattern = @"\d+";
- for(int i = 0; i < activityGameDate[0].params5Arr.Length; i++)
- {
- MatchCollection matches = Regex.Matches(activityGameDate[0].params5Arr[i], pattern);
- foreach (Match match in matches)
- {
- GameType.Add(int.Parse(match.Value));
- }
- }
- }
- private void OnNumericChange()
- {
- ItemData item;
- if (BagDataManager.Instance.GetBagData().TryGetValue(3000017, out item))
- {
- _ui.m_ticketNum.text = item.num.ToString();
- }
- else
- {
- _ui.m_ticketNum.text = "0";
- }
- }
- private void UpdateChallengeBtn()
- {
- int index = 0;
- //当两个游戏都只有一关时,奖励按钮隐藏
- for(int i = 0;i<GameType.Count;i+=2)
- {
- switch (GameType[i])
- {
- case 1:
- List<CardGame> CardGameDate = CardGameArray.Instance.GetCfgsBytypeAndsubType(GameType[i], GameType[i +1]);
- if( CardGameDate.Count <= 1)
- {
- ChallengeList.Add(GameType[i]);
- ChallengeList.Add(GameType[i+1]);
- }
- if(i < 1)
- {
- //NumTicketOne = CardGameDate[0].comsumeStartArr[0][1];
- }
- else
- {
- //NumTicketTwo = CardGameDate[0].comsumeStartArr[0][1];
- }
- break;
- case 2:
- List<Merge2048Game> Merge2048GameDate = Merge2048GameArray.Instance.GetCfgsBytypeAndsubType(GameType[i], GameType[i + 1]);
- if (Merge2048GameDate.Count <= 1 || Merge2048GameDate[0].bonusWinFirstArr.Length > 0)
- {
- ChallengeList.Add(GameType[i]);
- ChallengeList.Add(GameType[i + 1]);
- }
- if (i < 1)
- {
- //NumTicketOne = CardGameDate[0].comsumeStartArr[0][1];
- }
- else
- {
- //NumTicketTwo = CardGameDate[0].comsumeStartArr[0][1];
- }
- break;
- case 3:
- List <HuarongRoadGame> HuarongRoadGameDate = HuarongRoadGameArray.Instance.GetCfgsBytypeAndsubType(GameType[i], GameType[i + 1]);
- if (HuarongRoadGameDate.Count <= 1)
- {
- ChallengeList.Add(GameType[i]);
- ChallengeList.Add(GameType[i + 1]);
- }
- if (i < 1)
- {
- //NumTicketOne = CardGameDate[0].comsumeStartArr[0][1];
- }
- else
- {
- //NumTicketTwo = CardGameDate[0].comsumeStartArr[0][1];
- }
- break;
- }
- }
- }
- }
- }
|