//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, December 05, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class FairyCreateWin : Window
|
{
|
[SerializeField] Text textCreateLimit1;
|
[SerializeField] Text textCreateLimit2;
|
[SerializeField] Button creationClose;
|
[SerializeField] InputField creationInput;
|
[SerializeField] Button creationConfirm;
|
|
private FairyModel m_Model;
|
private FairyModel model {
|
get {
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<FairyModel>());
|
}
|
}
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
creationClose.onClick.AddListener(CloseClick);
|
creationConfirm.onClick.AddListener(OnCreatConfirm);
|
}
|
|
protected override void OnPreOpen()
|
{
|
PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += OnRefreshFariyInfo;
|
|
textCreateLimit1.text = Language.Get("L1132", model.createFairyLv);
|
textCreateLimit2.text = Language.Get("L1133", model.createFairyCost);
|
creationInput.text = string.Empty;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= OnRefreshFariyInfo;
|
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
private void OnCreatConfirm()
|
{
|
if (PlayerDatas.Instance.baseData.LV < model.createFairyLv)
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("L1005"));
|
return;
|
}
|
|
if (string.IsNullOrEmpty(creationInput.text))
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("L1015"));
|
return;
|
}
|
|
if (DirtyWordConfig.IsDirtWord(creationInput.text) || UIHelper.HasSpecialCharac(creationInput.text)
|
|| DirtyNameConfig.IsDirtName(creationInput.text))
|
{
|
SysNotifyMgr.Instance.ShowTip("FamilyNameChangeUnlegal");
|
return;
|
}
|
|
if (PlayerDatas.Instance.baseData.diamond >= model.createFairyCost)
|
{
|
CA404_tagCGPyCreatFamily creatPack = new CA404_tagCGPyCreatFamily();
|
creatPack.Name = creationInput.text;
|
creatPack.FakeID = 0;
|
GameNetSystem.Instance.SendInfo(creatPack);
|
}
|
else
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
SysNotifyMgr.Instance.ShowTip("GoldErr");
|
return;
|
}
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
CloseImmediately();
|
}
|
}
|
|
private void OnRefreshFariyInfo()
|
{
|
if (PlayerDatas.Instance.fairyData.HasFairy)
|
{
|
CloseImmediately();
|
}
|
}
|
}
|
|
}
|
|
|
|
|