|
@@ -0,0 +1,403 @@
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
+using System.Linq;
|
|
|
|
+using ET;
|
|
|
|
+using FairyGUI;
|
|
|
|
+using UI.Store;
|
|
|
|
+using UnityEngine;
|
|
|
|
+
|
|
|
|
+namespace GFGGame
|
|
|
|
+{
|
|
|
|
+ public class StoreBrocadeWeavView : BaseWindow
|
|
|
|
+ {
|
|
|
|
+ private UI_StoreBrocadeWeavUI _ui;
|
|
|
|
+
|
|
|
|
+ private List<BattlePassCfg> _rewardCfgs;
|
|
|
|
+
|
|
|
|
+ public override void Dispose()
|
|
|
|
+ {
|
|
|
|
+ if (_ui != null)
|
|
|
|
+ {
|
|
|
|
+ _ui.Dispose();
|
|
|
|
+ _ui = null;
|
|
|
|
+ }
|
|
|
|
+ base.Dispose();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected override void OnInit()
|
|
|
|
+ {
|
|
|
|
+ base.OnInit();
|
|
|
|
+ packageName = UI_StoreBrocadeWeavUI.PACKAGE_NAME;
|
|
|
|
+ _ui = UI_StoreBrocadeWeavUI.Create();
|
|
|
|
+ viewCom = _ui.target;
|
|
|
|
+ isfullScreen = true;
|
|
|
|
+ clickBlankToClose = false;
|
|
|
|
+ _ui.m_btnOpen.onClick.Add(OnBtnOpenClick);
|
|
|
|
+ _ui.m_btnBuyLevel.onClick.Add(OnBtnBuyLevel);
|
|
|
|
+ _ui.m_btnGetAll.onClick.Add(OnBtnGetAllClick);
|
|
|
|
+ _ui.m_btnBrocadeWeavTask.onClick.Add(OnBtnBrocadeWeavTaskClick);
|
|
|
|
+ _ui.m_RewardList.itemRenderer = ListBoxRewardItemRender;
|
|
|
|
+ _ui.m_RewardList.SetVirtual();
|
|
|
|
+ _ui.m_SpecialReward.m_RewardList.itemRenderer = SpecialRewardRender;
|
|
|
|
+ _ui.m_tip.onClick.Add(RuleController.ShowRuleView);
|
|
|
|
+ _ui.m_tip.data = 300012;
|
|
|
|
+ _ui.m_LevelProcess.m_loaIcon.url =
|
|
|
|
+ ResPathUtil.GetCommonGameResPath(ItemCfgArray.Instance.GetCfg(ConstItemID.BATTLE_PASS_CURRENCY).res);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected override void OnHide()
|
|
|
|
+ {
|
|
|
|
+ base.OnHide();
|
|
|
|
+ Timers.inst.Remove(UpdateTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ protected override void OnShown()
|
|
|
|
+ {
|
|
|
|
+ base.OnShown();
|
|
|
|
+ oldLevel = 0;
|
|
|
|
+ SetSeasonLeftTime();
|
|
|
|
+ SetBattlePassLevel();
|
|
|
|
+ SetOpenBattlePassBtnStatus();
|
|
|
|
+ FreshSpecialReward(oldLevel);
|
|
|
|
+ var battlePassCfgs =
|
|
|
|
+ BattlePassCfgArray.Instance.GetCfgsByid(BattlePassTaskDataManager.Instance.GetSeasonId());
|
|
|
|
+ var minLevel =
|
|
|
|
+ (from battlePassCfg in battlePassCfgs
|
|
|
|
+ let state = BattlePassTaskDataManager.Instance.GetRewardState(battlePassCfg.level)
|
|
|
|
+ where battlePassCfg.level != 0 && state != 2
|
|
|
|
+ select battlePassCfg.level).FirstOrDefault();
|
|
|
|
+ minLevel = Mathf.Max(1, minLevel);
|
|
|
|
+ _ui.m_RewardList.ScrollToView(minLevel - 1);
|
|
|
|
+ UpdateBtnBrocadeWeavTaskRed();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected override void AddEventListener()
|
|
|
|
+ {
|
|
|
|
+ base.AddEventListener();
|
|
|
|
+ //监听通行证等级变化
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.BATTLEPASS_LEVEL_CHANGE, SetBattlePassLevel);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NOTICE_PASSPORT_OPEN, OnBattlePassOpen);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, OnItemChange);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NOTICE_BATCH_TASK_STATE_CHANGE, UpdateBtnBrocadeWeavTaskRed);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected override void RemoveEventListener()
|
|
|
|
+ {
|
|
|
|
+ base.RemoveEventListener();
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.BATTLEPASS_LEVEL_CHANGE, SetBattlePassLevel);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NOTICE_PASSPORT_OPEN, OnBattlePassOpen);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, OnItemChange);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NOTICE_BATCH_TASK_STATE_CHANGE, UpdateBtnBrocadeWeavTaskRed);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnBattlePassOpen()
|
|
|
|
+ {
|
|
|
|
+ SetOpenBattlePassBtnStatus();
|
|
|
|
+ FreshReward();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnItemChange(EventContext eventContext)
|
|
|
|
+ {
|
|
|
|
+ var itemId = (int)eventContext.data;
|
|
|
|
+ if (itemId != ConstItemID.BATTLE_PASS_CURRENCY) return;
|
|
|
|
+
|
|
|
|
+ //刷新积分列表
|
|
|
|
+ SetExpProcess();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //开启通行证
|
|
|
|
+ private void OnBtnOpenClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ ViewManager.Show<OpenBattlePassView>(null, new object[] { typeof(StoreBrocadeWeavView).FullName, null });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnBtnBuyLevel(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ var dataManager = BattlePassTaskDataManager.Instance;
|
|
|
|
+ var seasonId = dataManager.GetSeasonId();
|
|
|
|
+ var battlePassCfg =
|
|
|
|
+ BattlePassCfgArray.Instance.GetCfgByidAndlevel(seasonId, dataManager.GetBattlePassLevel() + 1);
|
|
|
|
+ if (battlePassCfg == null)
|
|
|
|
+ {
|
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已经满级");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ ViewManager.Show<BuyBattlePassLevelView>(null, new object[] { typeof(StoreBrocadeWeavView).FullName, null });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //领取奖励
|
|
|
|
+ private async void OnBtnGetClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ if (!(context.sender is GObject obj)) return;
|
|
|
|
+ var id = (int)obj.data;
|
|
|
|
+ var get = await BattlePassTaskSProxy.GetBattlePassReward(id);
|
|
|
|
+ if (!get) return;
|
|
|
|
+ SetBattlePassLevel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //继续领取
|
|
|
|
+ private void OnBtnContinueClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ // if (!(context.sender is GObject obj)) return;
|
|
|
|
+ // var id = (int)obj.data;
|
|
|
|
+ // var isBuy = BattlePassTaskDataManager.Instance.GetIsBuy();
|
|
|
|
+ // if (!isBuy)
|
|
|
|
+ // {
|
|
|
|
+ ViewManager.Show<OpenBattlePassView>(null, new object[] { typeof(StoreBrocadeWeavView).FullName, null });
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+ // var get = await BattlePassTaskSProxy.GetBattlePassReward(id);
|
|
|
|
+ // if (!get) return;
|
|
|
|
+ // SetBattlePassLevel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //领取全部奖励
|
|
|
|
+ private async void OnBtnGetAllClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ var get = await BattlePassTaskSProxy.GetAllBattlePassReward(onSuccess: () =>
|
|
|
|
+ {
|
|
|
|
+ var isBuy = BattlePassTaskDataManager.Instance.GetIsBuy();
|
|
|
|
+ if (isBuy) return;
|
|
|
|
+ ViewManager.Show<OpenBattlePassView>(null,
|
|
|
|
+ new object[] { typeof(StoreBrocadeWeavView).FullName, null });
|
|
|
|
+ });
|
|
|
|
+ if (!get) return;
|
|
|
|
+ SetBattlePassLevel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //点击织造任务
|
|
|
|
+ private void OnBtnBrocadeWeavTaskClick(EventContext context)
|
|
|
|
+ {
|
|
|
|
+ ViewManager.Show<BrocadeWeavTaskView>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //前往
|
|
|
|
+ // private void OnBtnGoClick(EventContext context)
|
|
|
|
+ // {
|
|
|
|
+ // Hide();
|
|
|
|
+ // var btnGo = context.sender as GObject;
|
|
|
|
+ // if (btnGo == null) return;
|
|
|
|
+ // ViewManager.Show($"GFGGame.{btnGo.data}", null, new[] { typeof(TaskView).FullName, viewData }, true);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void ListBoxRewardItemRender(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ var item = UI_BrocadeWeavRewardItem.Proxy(obj);
|
|
|
|
+ var level = index + 1;
|
|
|
|
+
|
|
|
|
+ //设置进度
|
|
|
|
+ item.m_imageProgress.visible = BattlePassTaskDataManager.Instance.GetBattlePassLevel() >= level;
|
|
|
|
+ //这里跳过为0的第一个配置
|
|
|
|
+ var battlePassCfg = _rewardCfgs[level];
|
|
|
|
+ //设置等级
|
|
|
|
+ item.m_Level.text = battlePassCfg.level.ToString();
|
|
|
|
+ //获取玩家当前的通行证等级
|
|
|
|
+ var state = BattlePassTaskDataManager.Instance.GetRewardState(level);
|
|
|
|
+ //设置奖励
|
|
|
|
+ var bonusNormalArr = battlePassCfg.bonusNormalArr;
|
|
|
|
+ if (bonusNormalArr != null && bonusNormalArr.Length > 0)
|
|
|
|
+ {
|
|
|
|
+ item.m_NormalReward.visible = true;
|
|
|
|
+ var itemData = ItemUtil.createItemData(bonusNormalArr[0]);
|
|
|
|
+ var itemView = new ItemView(item.m_NormalReward);
|
|
|
|
+ item.m_NormalReward.data ??= itemView;
|
|
|
|
+ itemView.SetData(itemData);
|
|
|
|
+ itemView.ChangeTxtCountStyle();
|
|
|
|
+ itemView.GrpGotVisible = BattlePassTaskDataManager.Instance.CheckLevelRewardGet(level);
|
|
|
|
+ bool redDot = (!BattlePassTaskDataManager.Instance.CheckLevelRewardGet(level) && state == 1);
|
|
|
|
+ RedDotController.Instance.SetComRedDot(item.m_NormalReward, redDot);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ item.m_NormalReward.data = null;
|
|
|
|
+ item.m_NormalReward.visible = false;
|
|
|
|
+ }
|
|
|
|
+ if (item.m_RewardList.data == null)
|
|
|
|
+ {
|
|
|
|
+ item.m_RewardList.itemRenderer = SpecialRewardRender;
|
|
|
|
+ }
|
|
|
|
+ var superLevelRewardGet = BattlePassTaskDataManager.Instance.CheckSuperLevelRewardGet(level);
|
|
|
|
+ item.m_RewardList.data = (battlePassCfg.bonusSpecialArr, true , state, superLevelRewardGet);
|
|
|
|
+ item.m_RewardList.numItems = battlePassCfg.bonusSpecialArr.Length;
|
|
|
|
+ if (state == 1)
|
|
|
|
+ {
|
|
|
|
+ item.m_touch.onClick.Set(OnBtnGetClick);
|
|
|
|
+ item.m_touch.data = battlePassCfg.level;
|
|
|
|
+ item.m_touch.touchable = true;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ item.m_touch.onClick.Clear();
|
|
|
|
+ item.m_touch.touchable = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置按钮状态
|
|
|
|
+ //SetBtnState(item, battlePassCfg.level, state);
|
|
|
|
+ //item.target.data = battlePassCfg;
|
|
|
|
+
|
|
|
|
+ UI_BrocadeWeavRewardItem.ProxyEnd();
|
|
|
|
+ FreshSpecialReward(level);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //SpecialRewardRender
|
|
|
|
+ private static void SpecialRewardRender(int index, GObject obj)
|
|
|
|
+ {
|
|
|
|
+ var keyValuePair = ((int[][], bool, int, bool))obj.parent.data;
|
|
|
|
+ var itemInfo = keyValuePair.Item1[index];
|
|
|
|
+ var itemData = ItemUtil.createItemData(itemInfo);
|
|
|
|
+ var itemView = new ItemView(obj as GComponent);
|
|
|
|
+ obj.data ??= itemView;
|
|
|
|
+ itemView.SetData(itemData);
|
|
|
|
+ itemView.ChangeTxtCountStyle();
|
|
|
|
+ var isBuy = BattlePassTaskDataManager.Instance.GetIsBuy();
|
|
|
|
+ if (keyValuePair.Item2 && isBuy) {
|
|
|
|
+ RedDotController.Instance.SetComRedDot(itemView.GetGComponentObj, keyValuePair.Item3 == 1);
|
|
|
|
+ itemView.GrpGotVisible = keyValuePair.Item4;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //根据状态设置按钮
|
|
|
|
+ private void SetBtnState(UI_BrocadeWeavRewardItem item, int id, int state)
|
|
|
|
+ {
|
|
|
|
+ item.m_c1.selectedIndex = state;
|
|
|
|
+ RedDotController.Instance.SetComRedDot(item.m_GetRewardBt, state == 1);
|
|
|
|
+ if (item.m_GetRewardBt.data == null)
|
|
|
|
+ {
|
|
|
|
+ item.m_GetRewardBt.onClick.Add(OnBtnGetClick);
|
|
|
|
+ }
|
|
|
|
+ item.m_GetRewardBt.data = id;
|
|
|
|
+ //继续领取
|
|
|
|
+ if (item.m_ContinueBt.data == null)
|
|
|
|
+ {
|
|
|
|
+ item.m_ContinueBt.onClick.Add(OnBtnContinueClick);
|
|
|
|
+ }
|
|
|
|
+ item.m_ContinueBt.data = id;
|
|
|
|
+ //前往
|
|
|
|
+ if (item.m_ComeBt.data == null)
|
|
|
|
+ {
|
|
|
|
+ item.m_ComeBt.enabled = false;
|
|
|
|
+ }
|
|
|
|
+ item.m_ComeBt.data = id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置赛季剩余时间
|
|
|
|
+ private void SetSeasonLeftTime()
|
|
|
|
+ {
|
|
|
|
+ //获取赛季结束时间
|
|
|
|
+ Timers.inst.Add(1, 0, UpdateTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //UpdateTime
|
|
|
|
+ private void UpdateTime(object param)
|
|
|
|
+ {
|
|
|
|
+ var seasonEndTime = BattlePassTaskDataManager.Instance.GetSeasonEndTime();
|
|
|
|
+ var leftTime = seasonEndTime - TimeHelper.ServerNow();
|
|
|
|
+ if (leftTime <= 0)
|
|
|
|
+ {
|
|
|
|
+ Timers.inst.Remove(UpdateTime);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ _ui.m_LeftTime.text = TimeUtil.FormattingTimeTo_DDHHmm(leftTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void SetBattlePassLevel()
|
|
|
|
+ {
|
|
|
|
+ //获取玩家当前的通行证等级
|
|
|
|
+ var dataManager = BattlePassTaskDataManager.Instance;
|
|
|
|
+ var battlePassLevel = dataManager.GetBattlePassLevel();
|
|
|
|
+ var uiExpProcess = _ui.m_LevelProcess;
|
|
|
|
+ uiExpProcess.m_Level.text = battlePassLevel.ToString();
|
|
|
|
+ SetExpProcess();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void SetExpProcess()
|
|
|
|
+ {
|
|
|
|
+ var dataManager = BattlePassTaskDataManager.Instance;
|
|
|
|
+ var seasonId = dataManager.GetSeasonId();
|
|
|
|
+ var uiExpProcess = _ui.m_LevelProcess;
|
|
|
|
+ //获取当前等级的经验
|
|
|
|
+ var battlePassCfg =
|
|
|
|
+ BattlePassCfgArray.Instance.GetCfgByidAndlevel(seasonId, dataManager.GetBattlePassLevel());
|
|
|
|
+ if (battlePassCfg == null)
|
|
|
|
+ {
|
|
|
|
+ //已经超过了最大等级
|
|
|
|
+ uiExpProcess.target.max = 100;
|
|
|
|
+ uiExpProcess.target.value = 0;
|
|
|
|
+ uiExpProcess.m_c1.selectedIndex = 1;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ uiExpProcess.target.max = battlePassCfg.value;
|
|
|
|
+ uiExpProcess.target.value = dataManager.GetBattlePassExp();
|
|
|
|
+ uiExpProcess.m_NumProcess.SetVar("value", dataManager.GetBattlePassExp().ToString())
|
|
|
|
+ .SetVar("maxValue", battlePassCfg.value.ToString()).FlushVars();
|
|
|
|
+ FreshReward();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void FreshReward()
|
|
|
|
+ {
|
|
|
|
+ //刷新奖励列表
|
|
|
|
+ _rewardCfgs =
|
|
|
|
+ new List<BattlePassCfg>(
|
|
|
|
+ BattlePassCfgArray.Instance.GetCfgsByid(BattlePassTaskDataManager.Instance.GetSeasonId()));
|
|
|
|
+ //去掉第一个为0的配置
|
|
|
|
+ _ui.m_RewardList.numItems = _rewardCfgs.Count - 1;
|
|
|
|
+ RedDotController.Instance.SetComRedDot(_ui.m_btnGetAll,
|
|
|
|
+ BattlePassTaskDataManager.Instance.CheckStoreBrocadeWeavRed());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void SetOpenBattlePassBtnStatus()
|
|
|
|
+ {
|
|
|
|
+ //通行证是否购买
|
|
|
|
+ var isBuy = BattlePassTaskDataManager.Instance.GetIsBuy();
|
|
|
|
+ _ui.m_c1.selectedIndex = isBuy ? 1 : 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private int oldLevel;
|
|
|
|
+
|
|
|
|
+ //刷新特别大奖展示
|
|
|
|
+ private void FreshSpecialReward(int level)
|
|
|
|
+ {
|
|
|
|
+ var battlePassCfg = BattlePassTaskDataManager.Instance.GetSpecialCfg(level);
|
|
|
|
+ var uiBattlePassReward = _ui.m_SpecialReward;
|
|
|
|
+ if (battlePassCfg == null)
|
|
|
|
+ {
|
|
|
|
+ uiBattlePassReward.target.visible = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var newLeve = battlePassCfg.level;
|
|
|
|
+ if (newLeve == oldLevel) return;
|
|
|
|
+ oldLevel = newLeve;
|
|
|
|
+ uiBattlePassReward.target.visible = true;
|
|
|
|
+ uiBattlePassReward.m_Level.text = newLeve.ToString();
|
|
|
|
+ //设置奖励
|
|
|
|
+ var bonusNormalArr = battlePassCfg.bonusNormalArr;
|
|
|
|
+ if (bonusNormalArr != null && bonusNormalArr.Length > 0)
|
|
|
|
+ {
|
|
|
|
+ uiBattlePassReward.m_NormalReward.visible = true;
|
|
|
|
+ var itemData = ItemUtil.createItemData(bonusNormalArr[0]);
|
|
|
|
+ var item = new ItemView(uiBattlePassReward.m_NormalReward);
|
|
|
|
+ item.SetData(itemData);
|
|
|
|
+ item.ChangeTxtCountStyle();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ uiBattlePassReward.m_NormalReward.visible = false;
|
|
|
|
+ }
|
|
|
|
+ var superLevelRewardGet = BattlePassTaskDataManager.Instance.CheckSuperLevelRewardGet(level);
|
|
|
|
+ var state = BattlePassTaskDataManager.Instance.GetRewardState(level);
|
|
|
|
+ uiBattlePassReward.m_RewardList.data = (battlePassCfg.bonusSpecialArr,false ,state, superLevelRewardGet);
|
|
|
|
+ uiBattlePassReward.m_RewardList.numItems = battlePassCfg.bonusSpecialArr.Length;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //更新织造任务按钮红点
|
|
|
|
+ private void UpdateBtnBrocadeWeavTaskRed()
|
|
|
|
+ {
|
|
|
|
+ RedDotController.Instance.SetComRedDot(_ui.m_btnBrocadeWeavTask,
|
|
|
|
+ TaskDataManager.Instance.CheckTaskRewardCanGet(TaskFuncType.BattlePass));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|