From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/XNPCFavorDrama.cs | 190 +++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XNPCFavorDrama.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XNPCFavorDrama.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/XNPCFavorDrama.cs b/Client/Assets/Scripts/XMainClient/UI/XNPCFavorDrama.cs new file mode 100644 index 00000000..6f11088f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/XNPCFavorDrama.cs @@ -0,0 +1,190 @@ +using System; +using KKSG; +using UILib; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class XNPCFavorDrama + { + private XFavorParam _param; + + private XNPCFavorDocument doc; + + private uint npcId = 0u; + + public bool BDeprecated = true; + + public void ShowNpc(XNpc npc) + { + DlgBase.singleton.SetVisible(true, true); + this.doc = XDocuments.GetSpecificDocument(XNPCFavorDocument.uuID); + this._param = XDataPool.GetData(); + this._param.Npc = npc; + this.npcId = npc.TypeID; + XNPCFavorDocument.ShowNPCDrama(npc.TypeID); + } + + public uint GetXNpcId() + { + return this.npcId; + } + + public void RefreshOperateStatus(bool isfirst = false, string text = null) + { + bool flag = this._param == null; + if (!flag) + { + EFavorState state = this.doc.GetState(this.GetXNpcId()); + bool bRecycled = this._param.bRecycled; + if (bRecycled) + { + this._param = XDataPool.GetData(); + } + switch (state) + { + case EFavorState.CanSend: + this._param.Text = ((text == null) ? this.GetRandomGiveWords() : text); + this._param.isShowSend = !this.IsSendDialogOpen(); + this._param.isShowExchange = false; + this._param.sendCallback = new ButtonClickEventHandler(this.ToSend); + break; + case EFavorState.SendWithExchange: + case EFavorState.Exchange: + this._param.Text = ((text == null) ? this.GetRandomGiveWords() : text); + this._param.isShowSend = (!this.IsSendDialogOpen() && !this.IsChangeDialogOpen()); + this._param.isShowExchange = !this.IsChangeDialogOpen(); + this._param.isShowExchangeRedpoint = true; + this._param.sendCallback = new ButtonClickEventHandler(this.ToSend); + this._param.exchangeCallback = new ButtonClickEventHandler(this.ToExchange); + break; + } + this._FireEvent(this._param); + } + } + + private bool IsSendDialogOpen() + { + return DlgBase.singleton.IsVisible() && DlgBase.singleton.IsSendDilogVisible(); + } + + private bool IsChangeDialogOpen() + { + return DlgBase.singleton.IsVisible() && DlgBase.singleton.IsChangeDialogVisible(); + } + + private void _FireEvent(XFavorParam param) + { + DlgBase.singleton.SetUpFavorParam(param); + param.Recycle(); + } + + private bool ToSend(IXUIButton button) + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + NpcFeelingOneNpc oneNpcByXId = this.doc.GetOneNpcByXId(this.GetXNpcId()); + bool flag2 = oneNpcByXId != null && this.doc.IsCanSend(); + if (flag2) + { + bool flag3 = this.doc.IsCanLevelUp(oneNpcByXId); + if (flag3) + { + NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId()); + XSingleton.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("NPCFavorisFull"), npcTableInfoByXId.name), "fece00"); + } + else + { + DlgBase.singleton.ShowNPCFavorSend(); + this.RefreshOperateStatus(false, this.GetRandomGiveWords()); + this._FireEvent(this._param); + } + } + } + return true; + } + + private bool ToExchange(IXUIButton button) + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.ShowNPCFavorExchnage(); + this.RefreshOperateStatus(false, this.GetRandomExchangeWords()); + this._FireEvent(this._param); + } + return true; + } + + private bool ToConfirmSend() + { + XSingleton.singleton.CloseModalDlg(); + return true; + } + + private string GetRandomGiveWords() + { + NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId()); + return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveWords); + } + + private string GetSendSuccessWords() + { + NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId()); + return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveSuccessWords); + } + + private string GetRandomExchangeWords() + { + NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId()); + return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.exchangeWords); + } + + private string GetExchangeSuccessWords() + { + NpcFeeling.RowData npcTableInfoByXId = XNPCFavorDocument.GetNpcTableInfoByXId(this.GetXNpcId()); + return (npcTableInfoByXId == null) ? string.Empty : this.GetRandomStr(npcTableInfoByXId.giveSuccessWords); + } + + private string GetRandomStr(string[] content) + { + bool flag = content != null && content.Length != 0; + string result; + if (flag) + { + result = content[XSingleton.singleton.RandomInt(content.Length)]; + } + else + { + result = string.Empty; + } + return result; + } + + public void SendSuccess() + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.NtfSendDramaRefresh(); + this.RefreshOperateStatus(false, this.GetSendSuccessWords()); + this._FireEvent(this._param); + } + this.doc.PlaySendSuccessFx(this.GetXNpcId()); + } + + public void ExchangeSuccess() + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.NtfExchangeDlgClose(); + this.RefreshOperateStatus(false, this.GetExchangeSuccessWords()); + this._FireEvent(this._param); + } + this.doc.PlayExchangeSuccessFx(this.GetXNpcId()); + } + } +} -- cgit v1.1-26-g67d0