From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XRenameDocument.cs | 195 +++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XRenameDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XRenameDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XRenameDocument.cs b/Client/Assets/Scripts/XMainClient/XRenameDocument.cs new file mode 100644 index 00000000..fe68cfba --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XRenameDocument.cs @@ -0,0 +1,195 @@ +using System; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XRenameDocument : XDocComponent + { + public override uint ID + { + get + { + return XRenameDocument.uuID; + } + } + + public uint renameTimes + { + get + { + return this.m_renamesTime; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("RenameDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static RenameList RenameListTable = new RenameList(); + + private uint m_renamesTime = 0u; + + public enum RenameType + { + GUILD_NAME_VOLUME, + PLAYER_NAME_VOLUME, + PLAYER_NAME_COST, + DRAGON_GUILD_NAME_VOLUME + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + } + + public static void Execute(OnLoadedCallback callback = null) + { + XRenameDocument.AsyncLoader.AddTask("Table/RenameList", XRenameDocument.RenameListTable, false); + XRenameDocument.AsyncLoader.Execute(callback); + } + + public int GetRenameCost(uint renameTimes) + { + int num = XRenameDocument.RenameListTable.Table.Length; + bool flag = (ulong)renameTimes < (ulong)((long)num); + int cost; + if (flag) + { + cost = XRenameDocument.RenameListTable.GetByid((int)renameTimes).cost; + } + else + { + cost = XRenameDocument.RenameListTable.Table[num - 1].cost; + } + return cost; + } + + public void SetPlayerRenameTimes(uint value) + { + this.m_renamesTime = value; + XSingleton.singleton.AddGreenLog("SetPlayerRenameTimes" + value, null, null, null, null, null); + } + + public void SendPlayerConstRename(string value, bool isUseItem = false) + { + bool flag = string.IsNullOrEmpty(value); + if (!flag) + { + RpcC2M_ChangeNameNew rpcC2M_ChangeNameNew = new RpcC2M_ChangeNameNew(); + rpcC2M_ChangeNameNew.oArg.name = value; + rpcC2M_ChangeNameNew.oArg.iscostitem = isUseItem; + XSingleton.singleton.Send(rpcC2M_ChangeNameNew); + } + } + + public void ReceivePlayerCostRename(ChangeNameArg arg, ChangeNameRes res) + { + bool flag = res.errorcode == ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("RenameSuccess"), "fece00"); + XSingleton.singleton.XPlayerData.Name = arg.name; + XPlayer player = XSingleton.singleton.Player; + bool flag2 = !arg.iscostitem; + if (flag2) + { + this.m_renamesTime += 1u; + } + bool flag3 = player != null && player.BillBoard != null; + if (flag3) + { + player.BillBoard.Attached(); + } + bool flag4 = DlgBase.singleton.IsVisible(); + if (flag4) + { + DlgBase.singleton.SetVisibleWithAnimation(false, null); + } + bool flag5 = DlgBase.singleton.IsVisible() && DlgBase.singleton.CurrentTab == OptionsTab.InfoTab; + if (flag5) + { + DlgBase.singleton.OnTabChanged(OptionsTab.InfoTab); + } + } + else + { + XSingleton.singleton.ShowErrorCode(res.errorcode); + } + } + + public void SendDragonGuildRenameVolume(string targetValue) + { + bool flag = string.IsNullOrEmpty(targetValue); + if (!flag) + { + RpcC2M_ModifyDragonGuildName rpcC2M_ModifyDragonGuildName = new RpcC2M_ModifyDragonGuildName(); + rpcC2M_ModifyDragonGuildName.oArg.name = targetValue; + XSingleton.singleton.Send(rpcC2M_ModifyDragonGuildName); + } + } + + public void ReceiveDragonGuildRenameVolume(ModifyDragonGuildNameArg oArg, ModifyDragonGuildNameRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.result); + } + else + { + XDragonGuildDocument.Doc.OnNameChange(oArg.name); + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("RenameSuccess"), "fece00"); + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.SetVisibleWithAnimation(false, null); + } + } + } + + public void SendGuildRenameVolume(string targetValue) + { + bool flag = string.IsNullOrEmpty(targetValue); + if (!flag) + { + RpcC2M_ModifyMsGuildName rpcC2M_ModifyMsGuildName = new RpcC2M_ModifyMsGuildName(); + rpcC2M_ModifyMsGuildName.oArg.name = targetValue; + XSingleton.singleton.Send(rpcC2M_ModifyMsGuildName); + } + } + + public void ReceiveGuildRenameVolume(ModifyArg oArg, ModifyRes oRes) + { + bool flag = oRes.error > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.error); + } + else + { + this.NotifyGuildNewName(oArg.name); + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("RenameSuccess"), "fece00"); + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.SetVisibleWithAnimation(false, null); + } + } + } + + public void NotifyGuildNewName(string targetName) + { + XGuildDocument specificDocument = XDocuments.GetSpecificDocument(XGuildDocument.uuID); + bool bInGuild = specificDocument.bInGuild; + if (bInGuild) + { + specificDocument.BasicData.guildName = targetName; + XGuildInfoChange @event = XEventPool.GetEvent(); + @event.Firer = XSingleton.singleton.Player; + XSingleton.singleton.FireEvent(@event); + } + } + } +} -- cgit v1.1-26-g67d0