using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
public class WytjRulesWin : Window,SecondWindowInterface
|
{
|
[SerializeField]
|
List<GameObject> rewardlist = new List<GameObject>();
|
|
TaiChiModel _taiChiModel;
|
TaiChiModel taiChiModel
|
{
|
get { return _taiChiModel ?? (_taiChiModel = ModelCenter.Instance.GetModel<TaiChiModel>()); }
|
}
|
|
public Button close { get; set; }
|
|
protected override void BindController()
|
{
|
if (this is SecondWindowInterface)
|
{
|
var frame = this.GetComponentInChildren<SecondFrameLoader>();
|
frame.Create();
|
close = frame.GetComponentInChildren<Button>();
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
close.AddListener(CloseWin);
|
}
|
|
protected override void OnPreOpen()
|
{
|
InitUI();
|
}
|
protected override void OnAfterOpen()
|
{
|
|
}
|
protected override void OnPreClose()
|
{
|
|
}
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
private void InitUI()
|
{
|
int i = 0;
|
for(i = 0; i < rewardlist.Count; i++)
|
{
|
DiceReward diceReward = taiChiModel.GetDiceReward(i);
|
if (diceReward == null)
|
return;
|
|
int j = 0;
|
for(j = 0; j < rewardlist[i].transform.childCount; j++)
|
{
|
Text numText = rewardlist[i].transform.GetChild(j).Find("num").GetComponent<Text>();
|
Button iconBtn = rewardlist[i].transform.GetChild(j).GetComponent<Button>();
|
Image itemIcon = rewardlist[i].transform.GetChild(j).GetComponent<Image>();
|
iconBtn.RemoveAllListeners();
|
ItemConfig itemConfig = null;
|
switch (j)
|
{
|
case 0:
|
itemConfig = ItemConfig.Get(diceReward.itemID);
|
numText.text = ItemLogicUtility.Instance.OnChangeCoinsUnit((ulong)diceReward.itemCount);
|
break;
|
case 1:
|
itemConfig = ItemConfig.Get(diceReward.goldId);
|
numText.text = ItemLogicUtility.Instance.OnChangeCoinsUnit((ulong)diceReward.gold);
|
break;
|
case 2:
|
itemConfig = ItemConfig.Get(diceReward.expId);
|
numText.text = ItemLogicUtility.Instance.OnChangeCoinsUnit((ulong)taiChiModel.GetDiceRewardExp(diceReward.exp));
|
break;
|
}
|
|
if(itemConfig != null)
|
{
|
itemIcon.SetSprite(itemConfig.IconKey);
|
iconBtn.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemConfig.ID);
|
});
|
}
|
}
|
}
|
}
|
|
private void CloseWin()
|
{
|
CloseImmediately();
|
}
|
}
|
}
|