using DG.Tweening;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairySiegeSpringGridAwardWin : Window
|
{
|
[SerializeField] ImageEx imgBg;
|
[SerializeField] ImageEx imgItem;
|
[SerializeField] TextEx txtCnt;
|
FairySiegeActModel model { get { return ModelCenter.Instance.GetModel<FairySiegeActModel>(); } }
|
|
#region Build-in
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.UpdateGridAwardAction += OnUpdateGridAward;
|
Reset();
|
UpdateData();
|
PlayAnim();
|
}
|
|
protected override void OnPreClose()
|
{
|
model.UpdateGridAwardAction -= OnUpdateGridAward;
|
StopAnim();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
#endregion
|
|
private void OnUpdateGridAward()
|
{
|
Reset();
|
UpdateData();
|
PlayAnim();
|
}
|
|
private Sequence sequence;
|
|
private void Reset()
|
{
|
StopAnim();
|
|
//Color color = imgBg.color;
|
//color.a = 1f;
|
//imgBg.color = color;
|
}
|
|
private void PlayAnim()
|
{
|
UpdateData();
|
sequence.AppendCallback(CloseClick).SetDelay(0.5f);
|
}
|
|
private void StopAnim()
|
{
|
sequence?.Kill();
|
sequence = DOTween.Sequence();
|
}
|
|
private void UpdateData()
|
{
|
var gridAwardList = model.gridAwardList;
|
if (gridAwardList.IsNullOrEmpty())
|
return;
|
int itemID = gridAwardList[0].id;
|
int cnt = gridAwardList[0].count;
|
if (!ItemConfig.Has(itemID))
|
return;
|
ItemConfig itemConfig = ItemConfig.Get(itemID);
|
imgItem.SetSprite(itemConfig.IconKey);
|
txtCnt.text = Language.Get("CelestialPalace13", cnt);
|
}
|
}
|
}
|