using LitJson;
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//玩法前瞻
|
class FuncPreNoticeWin : ILWindow
|
{
|
public int[][] itemArray;
|
|
ButtonEx btnReward;
|
List<ItemCell> items = new List<ItemCell>();
|
Text stateTxt;
|
Button close;
|
protected override void BindController()
|
{
|
base.BindController();
|
btnReward = proxy.GetWidgtEx<ButtonEx>("CommonButton");
|
items.Add(proxy.GetWidgtEx<ItemCell>("itemcell0"));
|
items.Add(proxy.GetWidgtEx<ItemCell>("itemcell1"));
|
items.Add(proxy.GetWidgtEx<ItemCell>("itemcell2"));
|
items.Add(proxy.GetWidgtEx<ItemCell>("itemcell3"));
|
stateTxt = proxy.GetWidgtEx<Text>("TextEx");
|
close = proxy.GetWidgtEx<Button>("Img_Close");
|
|
|
|
|
}
|
|
protected override void AddListeners()
|
{
|
base.AddListeners();
|
btnReward.AddListener(() =>
|
{//领取奖励
|
var pack = new IL_CA504_tagCMPlayerGetReward();
|
pack.RewardType = 48;
|
GameNetSystem.Instance.SendInfo(pack);
|
});
|
|
close.AddListener(()=> {
|
CloseWin<FuncPreNoticeWin>();
|
});
|
}
|
|
|
protected override void OnPreOpen()
|
{
|
FuncAwardModel.Instance.onReceived += RefreshBtn;
|
int state = FuncAwardModel.Instance.TryGetAwardState(48);
|
if (state == -1)
|
state = 0;
|
RefreshBtn(state);
|
|
if (itemArray == null || itemArray.Length < 1)
|
{
|
var config = FuncConfigConfig.Get("GameNoticeReward");
|
itemArray = JsonMapper.ToObject<int[][]>(config.Numerical1);
|
}
|
|
for (int i = 0; i < items.Count; i++)
|
{
|
items[i].SetActiveIL(false);
|
}
|
|
for (int i = 0; i < itemArray.Length; i++)
|
{
|
if (i >= items.Count)
|
{
|
continue;
|
}
|
items[i].SetActiveIL(true);
|
var itemID = itemArray[i][0];
|
var materialModel = new ItemCellModel(itemID, false, (ulong)itemArray[i][1]);
|
items[i].Init(materialModel);
|
items[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
base.OnAfterClose();
|
FuncAwardModel.Instance.onReceived -= RefreshBtn;
|
}
|
|
|
|
//刷新按钮的状态
|
void RefreshBtn(int state)
|
{
|
btnReward.SetColorful(null, state == 0);
|
// RealmPractice109 领取
|
//RealmPractice110 已领取
|
stateTxt.text = Language.Get(state == 0 ? "RealmPractice109" : "RealmPractice110");
|
}
|
|
}
|