|
@@ -2,7 +2,6 @@ using System.Collections.Generic;
|
|
|
using ET;
|
|
|
using FairyGUI;
|
|
|
using UI.Task;
|
|
|
-using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -12,17 +11,13 @@ namespace GFGGame
|
|
|
|
|
|
private List<BattlePassCfg> _rewardCfgs;
|
|
|
|
|
|
- private int maxShowIndex;
|
|
|
-
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
- maxShowIndex = 0;
|
|
|
if (_ui != null)
|
|
|
{
|
|
|
_ui.Dispose();
|
|
|
_ui = null;
|
|
|
}
|
|
|
-
|
|
|
base.Dispose();
|
|
|
}
|
|
|
|
|
@@ -34,27 +29,42 @@ namespace GFGGame
|
|
|
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_RewardList.itemRenderer = ListBoxRewardItemRender;
|
|
|
+ _ui.m_RewardList.SetVirtual();
|
|
|
_ui.m_SpecialReward.m_RewardList.itemRenderer = SpecialRewardRender;
|
|
|
}
|
|
|
|
|
|
+ protected override void OnHide()
|
|
|
+ {
|
|
|
+ base.OnHide();
|
|
|
+ Timers.inst.Remove(UpdateTime);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
protected override void OnShown()
|
|
|
{
|
|
|
base.OnShown();
|
|
|
- //获取通行证奖励配置
|
|
|
- var seasonId = BattlePassTaskDataManager.Instance.GetSeasonId();
|
|
|
- _rewardCfgs = new List<BattlePassCfg>(BattlePassCfgArray.Instance.GetCfgsByid(seasonId));
|
|
|
- //去掉第一个为0的配置
|
|
|
- _ui.m_RewardList.numItems = _rewardCfgs.Count - 1;
|
|
|
+ oldLevel = 0;
|
|
|
SetSeasonLeftTime();
|
|
|
SetBattlePassLevel();
|
|
|
SetOpenBattlePassBtnStatus();
|
|
|
- FreshSpecialReward();
|
|
|
+ FreshSpecialReward(oldLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void AddEventListener()
|
|
|
+ {
|
|
|
+ base.AddEventListener();
|
|
|
+ //监听通行证等级变化
|
|
|
+ EventAgent.AddEventListener(ConstMessage.BATTLEPASS_LEVEL_CHANGE, SetBattlePassLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.BATTLEPASS_LEVEL_CHANGE, SetBattlePassLevel);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -70,24 +80,31 @@ namespace GFGGame
|
|
|
}
|
|
|
|
|
|
//领取奖励
|
|
|
- private void OnBtnGetClick(EventContext context)
|
|
|
+ private async void OnBtnGetClick(EventContext context)
|
|
|
{
|
|
|
- //TODO
|
|
|
- Log.Debug("领取奖励");
|
|
|
+ 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)
|
|
|
+ private async void OnBtnContinueClick(EventContext context)
|
|
|
{
|
|
|
- //TODO
|
|
|
- Log.Debug("继续领取");
|
|
|
+ if (!(context.sender is GObject obj)) return;
|
|
|
+ var id = (int)obj.data;
|
|
|
+ var get = await BattlePassTaskSProxy.GetBattlePassReward(id);
|
|
|
+ if (!get) return;
|
|
|
+ SetBattlePassLevel();
|
|
|
}
|
|
|
|
|
|
//领取全部奖励
|
|
|
- private void OnBtnGetAllClick(EventContext context)
|
|
|
+ private async void OnBtnGetAllClick(EventContext context)
|
|
|
{
|
|
|
- //TODO
|
|
|
- Log.Debug("领取全部奖励");
|
|
|
+ var get = await BattlePassTaskSProxy.GetAllBattlePassReward();
|
|
|
+ if (!get) return;
|
|
|
+ SetBattlePassLevel();
|
|
|
}
|
|
|
|
|
|
//前往
|
|
@@ -99,6 +116,7 @@ namespace GFGGame
|
|
|
ViewManager.Show($"GFGGame.{btnGo.data}", null, new[] { typeof(TaskView).FullName, viewData }, true);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void ListBoxRewardItemRender(int index, GObject obj)
|
|
|
{
|
|
|
var item = UI_BattlePassRewardItem.Proxy(obj);
|
|
@@ -118,12 +136,10 @@ namespace GFGGame
|
|
|
item.m_NormalReward.m_num.text = bonusNormalArr[0][1].ToString();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (item.m_RewardList.data == null)
|
|
|
{
|
|
|
item.m_RewardList.itemRenderer = SpecialRewardRender;
|
|
|
}
|
|
|
-
|
|
|
item.m_RewardList.data = battlePassCfg.bonusSpecialArr;
|
|
|
item.m_RewardList.numItems = battlePassCfg.bonusSpecialArr.Length;
|
|
|
//获取玩家当前的通行证等级
|
|
@@ -131,8 +147,8 @@ namespace GFGGame
|
|
|
//设置按钮状态
|
|
|
SetBtnState(item, battlePassCfg.id, state);
|
|
|
item.target.data = battlePassCfg;
|
|
|
- maxShowIndex = Mathf.Max(maxShowIndex, level);
|
|
|
UI_BattlePassRewardItem.ProxyEnd();
|
|
|
+ FreshSpecialReward(level);
|
|
|
}
|
|
|
|
|
|
//SpecialRewardRender
|
|
@@ -140,11 +156,6 @@ namespace GFGGame
|
|
|
{
|
|
|
var item = UI_RewardIconYellow.Proxy(obj);
|
|
|
var parentData = (int[][])obj.parent.data;
|
|
|
- // if (!(obj.parent.data is int[][] parentData))
|
|
|
- // {
|
|
|
- // UI_RewardIconYellow.ClearProxy();
|
|
|
- // return;
|
|
|
- // }
|
|
|
var itemInfo = parentData[index];
|
|
|
var itemId = itemInfo[0];
|
|
|
var num = itemInfo[1];
|
|
@@ -165,24 +176,19 @@ namespace GFGGame
|
|
|
{
|
|
|
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.onClick.Add(OnBtnGoClick);
|
|
|
}
|
|
|
-
|
|
|
- item.m_GetRewardBt.data = id;
|
|
|
-
|
|
|
- item.m_GetRewardBt.data = id;
|
|
|
+ item.m_ComeBt.data = id;
|
|
|
}
|
|
|
|
|
|
//设置赛季剩余时间
|
|
@@ -210,37 +216,46 @@ namespace GFGGame
|
|
|
//获取玩家当前的通行证等级
|
|
|
var dataManager = BattlePassTaskDataManager.Instance;
|
|
|
var battlePassLevel = dataManager.GetBattlePassLevel();
|
|
|
+ var seasonId = dataManager.GetSeasonId();
|
|
|
var uiExpProcess = _ui.m_LevelProcess;
|
|
|
uiExpProcess.m_Level.text = battlePassLevel.ToString();
|
|
|
//获取当前等级的经验
|
|
|
var battlePassCfg =
|
|
|
- BattlePassCfgArray.Instance.GetCfgByidAndlevel(dataManager.GetSeasonId(),
|
|
|
- dataManager.GetBattlePassLevel());
|
|
|
+ BattlePassCfgArray.Instance.GetCfgByidAndlevel(seasonId, dataManager.GetBattlePassLevel());
|
|
|
uiExpProcess.target.max = battlePassCfg.value;
|
|
|
uiExpProcess.target.value = dataManager.GetBattlePassExp();
|
|
|
uiExpProcess.m_NumProcess.SetVar("value", dataManager.GetBattlePassExp().ToString())
|
|
|
.SetVar("maxValue", battlePassCfg.value.ToString()).FlushVars();
|
|
|
+ //刷新奖励列表
|
|
|
+ _rewardCfgs = new List<BattlePassCfg>(BattlePassCfgArray.Instance.GetCfgsByid(seasonId));
|
|
|
+ //去掉第一个为0的配置
|
|
|
+ _ui.m_RewardList.numItems = _rewardCfgs.Count - 1;
|
|
|
}
|
|
|
|
|
|
private void SetOpenBattlePassBtnStatus()
|
|
|
{
|
|
|
//通行证是否购买
|
|
|
var isBuy = BattlePassTaskDataManager.Instance.GetIsBuy();
|
|
|
- _ui.m_c1.selectedIndex = isBuy ? 0 : 1;
|
|
|
+ _ui.m_c1.selectedIndex = isBuy ? 1 : 0;
|
|
|
}
|
|
|
|
|
|
+ private int oldLevel;
|
|
|
+
|
|
|
//刷新特别大奖展示
|
|
|
- private void FreshSpecialReward()
|
|
|
+ private void FreshSpecialReward(int level)
|
|
|
{
|
|
|
- var battlePassCfg = BattlePassTaskDataManager.Instance.GetSpecialCfg(maxShowIndex);
|
|
|
+ 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 = battlePassCfg.level.ToString();
|
|
|
+ uiBattlePassReward.m_Level.text = newLeve.ToString();
|
|
|
//设置奖励
|
|
|
var bonusNormalArr = battlePassCfg.bonusNormalArr;
|
|
|
if (bonusNormalArr != null && bonusNormalArr.Length > 0)
|