//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, September 12, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
namespace vnxbqy.UI
|
{
|
|
public class FairyChangeTipWin : Window
|
{
|
private Button notifyCancelBtn;
|
private Button notifyChangeBtn;
|
private InputField notifyInput;
|
private Text notifyFreeCnt;
|
|
FairyModel model { get { return ModelCenter.Instance.GetModel<FairyModel>(); } }
|
|
private void OnNotifyChangeBtn()
|
{
|
if (notifyInput.text != string.Empty)
|
{
|
if (DirtyWordConfig.IsDirtWord(notifyInput.text))
|
{
|
ServerTipDetails.DisplayNormalTip(Language.Get("L1007"));
|
return;
|
}
|
}
|
int freeCnt = Mathf.Max(0, model.freeNotifyCount - (int)PlayerDatas.Instance.fairyData.fairy.Extra3);
|
if (freeCnt < 1)
|
{
|
if (PlayerDatas.Instance.baseData.diamond < model.changeNotifyCost)
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
SysNotifyMgr.Instance.ShowTip("GoldErr");
|
return;
|
}
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
return;
|
}
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ChangeTipConfirm", model.changeNotifyCost), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
SendChangeNotify();
|
}
|
});
|
return;
|
}
|
SendChangeNotify();
|
}
|
|
private void SendChangeNotify()
|
{
|
LanguageVerify.Instance.VerifyFairy(notifyInput.text, 1, PlayerDatas.Instance.fairyData.fairy.FamilyName,
|
PlayerDatas.Instance.fairyData.mine.FamilyLV, (bool ok, string result) =>
|
{
|
if (ok)
|
{
|
C0F04_tagCFamilyChangeBroadcast notifyPack = new C0F04_tagCFamilyChangeBroadcast();
|
notifyPack.Msg = result;
|
GameNetSystem.Instance.SendInfo(notifyPack);
|
CloseImmediately();
|
|
try
|
{
|
OperationLogCollect.Instance.ChatReport(result, Language.Get("GameNotice1"), string.Empty, ChatInfoType.Fairy);
|
}
|
catch (Exception e)
|
{
|
DebugEx.Log(e.Message);
|
}
|
}
|
});
|
}
|
|
private void OnNotifyCancelBtn()
|
{
|
CloseImmediately();
|
}
|
#region Built-in
|
protected override void BindController()
|
{
|
notifyCancelBtn = transform.Find("CancelBtn").GetComponent<Button>();
|
notifyCancelBtn.onClick.AddListener(OnNotifyCancelBtn);
|
notifyChangeBtn = transform.Find("CountBtn").GetComponent<Button>();
|
notifyChangeBtn.onClick.AddListener(OnNotifyChangeBtn);
|
notifyInput = transform.Find("InputField").GetComponent<InputField>();
|
notifyInput.characterLimit = 45;
|
notifyFreeCnt = notifyChangeBtn.transform.Find("BtnText").GetComponent<Text>();
|
}
|
|
protected override void AddListeners()
|
{
|
notifyInput.onValueChanged.AddListener(OnValueChanged);
|
}
|
|
private void OnValueChanged(string msg)
|
{
|
PlayerFairyData.FairyData fairy = PlayerDatas.Instance.fairyData.fairy;
|
var _changed = !fairy.Broadcast.Equals(msg);
|
notifyChangeBtn.interactable = _changed;
|
}
|
|
protected override void OnPreOpen()
|
{
|
notifyInput.text = PlayerDatas.Instance.fairyData.fairy.Broadcast;
|
PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += OnRefreshFairyInfo;
|
notifyChangeBtn.interactable = false;
|
OnRefreshFairyInfo();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= OnRefreshFairyInfo;
|
|
}
|
#endregion
|
private void OnRefreshFairyInfo()
|
{
|
PlayerFairyData.FairyData fairy = PlayerDatas.Instance.fairyData.fairy;
|
if (fairy == null)
|
{
|
return;
|
}
|
notifyInput.text = fairy.Broadcast;
|
int freeCnt = Mathf.Max(0, model.freeNotifyCount - (int)PlayerDatas.Instance.fairyData.fairy.Extra3);
|
notifyFreeCnt.text = UIHelper.ReplaceNewLine(Language.Get("L1098", freeCnt, model.freeNotifyCount));
|
|
if (PlayerDatas.Instance.fairyData.mine.FamilyLV < 2)
|
{
|
CloseImmediately();
|
}
|
}
|
}
|
|
}
|
|
|
|
|