using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
namespace vnxbqy.UI
|
{
|
|
public class FashiongDecomposeWin : Window,SecondWindowInterface
|
{
|
[SerializeField] Button decomposeBtn;
|
[SerializeField] Text wardrobeLvText;
|
[SerializeField] Text upgradeExpText;
|
[SerializeField] Text getExpText;
|
[SerializeField] ScrollerController lineCtrl;
|
[SerializeField, Header("创建格子数")] int initGrid = 100;
|
|
FashionDressModel model{ get { return ModelCenter.Instance.GetModel<FashionDressModel>(); }}
|
|
public Button close { get; set; }
|
|
#region Built-in
|
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(CloseClick);
|
decomposeBtn.AddListener(ClickDecompose);
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.cabinetRefresh += UpdateCabinetInfo;
|
FashionDecomposeModel.Instance.UpdateDecomposeExpEvent += UpdateGetExp;
|
SetDisplay();
|
}
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
model.cabinetRefresh -= UpdateCabinetInfo;
|
FashionDecomposeModel.Instance.UpdateDecomposeExpEvent -= UpdateGetExp;
|
}
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
private void SetDisplay()
|
{
|
FashionDecomposeModel.Instance.GetDecomposeItem();
|
CreateLineCell();
|
UpdateGetExp();
|
UpdateCabinetLv();
|
}
|
|
private void UpdateCabinetInfo()
|
{
|
FashionDecomposeModel.Instance.GetDecomposeItem();
|
UpdateCabinetLv();
|
lineCtrl.m_Scorller.RefreshActiveCellViews();
|
}
|
|
private void CreateLineCell()
|
{
|
int line = initGrid / 5;
|
lineCtrl.Refresh();
|
for (int i = 0; i < line; i++)
|
{
|
lineCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
lineCtrl.Restart();
|
}
|
|
private void UpdateCabinetLv()
|
{
|
int wardrobeLv = model.cabinetLevel;
|
wardrobeLvText.text = Language.Get("FashionDress106",wardrobeLv);
|
int curWardrobeExp = model.cabinetExp;
|
bool isCabinetMax = wardrobeLv >= model.cabinetMaxLevel ? true : false;
|
int upgradeLv = isCabinetMax ? model.cabinetMaxLevel : wardrobeLv + 1;
|
var cabinetConfig = FashionDressCabinetConfig.Get(upgradeLv);
|
upgradeExpText.SetActive(cabinetConfig != null);
|
if (cabinetConfig != null)
|
{
|
int upgradeWardrobeExp = cabinetConfig.NeedExp;
|
if (isCabinetMax)
|
{
|
upgradeExpText.text = StringUtility.Contact("(", Language.Get("FashionDress105"),")");
|
}
|
else
|
{
|
upgradeExpText.text = StringUtility.Contact("(", curWardrobeExp, "/", upgradeWardrobeExp, ")");
|
}
|
}
|
}
|
|
private void UpdateGetExp()
|
{
|
int getDecomposeExp = FashionDecomposeModel.Instance.GetSumDecomposeExp();
|
getExpText.text = getDecomposeExp.ToString();
|
}
|
|
private void ClickDecompose()
|
{
|
int getDecomposeExp = FashionDecomposeModel.Instance.GetSumDecomposeExp();
|
if(getDecomposeExp <= 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("FashionDecomposeRemind");
|
return;
|
}
|
FashionDecomposeModel.Instance.SendDecomposeFashion();
|
CloseImmediately();
|
}
|
}
|
}
|