From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/Guild/XGuildDocument.cs | 686 +++++++++++++++++++++ 1 file changed, 686 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Guild/XGuildDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/Guild/XGuildDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/Guild/XGuildDocument.cs b/Client/Assets/Scripts/XMainClient/Guild/XGuildDocument.cs new file mode 100644 index 00000000..ccd688c4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Guild/XGuildDocument.cs @@ -0,0 +1,686 @@ +using System; +using System.Collections.Generic; +using KKSG; +using MiniJSON; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XGuildDocument : XDocComponent + { + public override uint ID + { + get + { + return XGuildDocument.uuID; + } + } + + public static XGuildConfig GuildConfig + { + get + { + return XGuildDocument._GuildConfig; + } + } + + public static XGuildPP GuildPP + { + get + { + return XGuildDocument._GuildPP; + } + } + + public static bool InGuild + { + get + { + XGuildDocument specificDocument = XDocuments.GetSpecificDocument(XGuildDocument.uuID); + return specificDocument.bInGuild; + } + } + + public XGuildBasicData BasicData + { + get + { + return this.m_BasicData; + } + } + + public ulong UID + { + get + { + return this.m_BasicData.uid; + } + } + + public GuildPosition Position + { + get + { + return this.m_Position; + } + } + + public uint Level + { + get + { + return this.m_BasicData.level; + } + } + + public uint CurSkillUpCount + { + get + { + return 0u; + } + } + + public uint MaxSkillUpCount + { + get + { + bool flag = !this.bInGuild; + uint result; + if (flag) + { + result = 0u; + } + else + { + result = XGuildDocument.GuildConfig.GetDataByLevel(this.Level).StudySkillTimes; + } + return result; + } + } + + public string PortraitSprite + { + get + { + return XGuildDocument.GetPortraitName(this.m_BasicData.portraitIndex); + } + } + + public uint CurrentCanUseExp + { + get + { + return 0u; + } + } + + public uint CurrentTotalExp + { + get + { + bool flag = !this.bInGuild; + uint result; + if (flag) + { + result = 0u; + } + else + { + result = XGuildDocument.GuildConfig.GetBaseExp(this.Level) + this.m_BasicData.exp; + } + return result; + } + } + + public uint CurrentLevelTotalExp + { + get + { + bool flag = !this.bInGuild; + uint result; + if (flag) + { + result = 0u; + } + else + { + result = XGuildDocument.GuildConfig.GetBaseExp(this.Level) + this.m_BasicData.exp; + } + return result; + } + } + + public bool bInGuild + { + get + { + return this.UID > 0UL; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("GuildDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static GuildPermissionTable m_PermissionTable = new GuildPermissionTable(); + + private static GuildConfigTable m_ConfigTable = new GuildConfigTable(); + + private static Guildintroduce m_IntroduceTable = new Guildintroduce(); + + private static XGuildConfig _GuildConfig = new XGuildConfig(); + + private static XGuildPP _GuildPP = new XGuildPP(); + + private XGuildBasicData m_BasicData = new XGuildBasicData(); + + private bool _bInited = false; + + private GuildPosition m_Position; + + private float m_fEnterTime = 0f; + + public GuildBindStatus qqGroupBindStatus; + + public string qqGroupName; + + public static string GetPortraitName(int index) + { + return "ghicon_" + index.ToString(); + } + + public bool SetID(ulong id) + { + bool flag = !this._bInited || this.m_BasicData.uid != id; + this.m_BasicData.uid = id; + bool flag2 = flag; + if (flag2) + { + bool bInGuild = this.bInGuild; + if (bInGuild) + { + try + { + } + catch + { + } + } + } + return flag; + } + + public bool SetLevel(uint newLevel) + { + bool result = this.m_BasicData.level != 0u && this.m_BasicData.level != newLevel && this.m_BasicData.uid > 0UL; + this.m_BasicData.level = newLevel; + return result; + } + + public bool SetPosition(GuildPosition newPos) + { + bool result = this.m_Position != GuildPosition.GPOS_COUNT && this.m_Position != newPos && this.m_BasicData.uid > 0UL; + this.m_Position = newPos; + return result; + } + + public Guildintroduce.RowData GetIntroduce(string helpName) + { + return XGuildDocument.m_IntroduceTable.GetByHelpName(helpName); + } + + public static void Execute(OnLoadedCallback callback = null) + { + XGuildDocument.AsyncLoader.AddTask("Table/GuildPermission", XGuildDocument.m_PermissionTable, false); + XGuildDocument.AsyncLoader.AddTask("Table/GuildConfig", XGuildDocument.m_ConfigTable, false); + XGuildDocument.AsyncLoader.AddTask("Table/GuildIntroduce", XGuildDocument.m_IntroduceTable, false); + XGuildDocument.AsyncLoader.Execute(callback); + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this._bInited = false; + this.m_Position = GuildPosition.GPOS_COUNT; + this.m_BasicData.uid = 0UL; + this.m_BasicData.level = 0u; + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + base.RegisterEvent(XEventDefine.XEvent_InGuildStateChanged, new XComponent.XEventHandler(this.OnInGuildStateChanged)); + base.RegisterEvent(XEventDefine.XEvent_GuildPositionChanged, new XComponent.XEventHandler(this.OnGuildPositionChanged)); + } + + protected bool OnInGuildStateChanged(XEventArgs args) + { + XInGuildStateChangedEventArgs xinGuildStateChangedEventArgs = args as XInGuildStateChangedEventArgs; + bool bRoleInit = xinGuildStateChangedEventArgs.bRoleInit; + bool result; + if (bRoleInit) + { + result = true; + } + else + { + bool flag = !xinGuildStateChangedEventArgs.bIsEnter; + if (flag) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_EXIT_GUILD"), "fece00"); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_JOIN_GUILD"), "fece00"); + } + result = true; + } + return result; + } + + protected bool OnGuildPositionChanged(XEventArgs args) + { + XSingleton.singleton.ShowModalDialog(XStringDefineProxy.GetString("GUILD_POSITION_CHANGED", new object[] + { + XGuildDocument.GuildPP.GetPositionName(this.m_Position, false) + }), XStringDefineProxy.GetString(XStringDefine.COMMON_OK)); + return true; + } + + public void InitData(PtcM2C_LoginGuildInfo data) + { + bool flag = this.SetID(data.Data.gid); + bool flag2 = this.SetPosition((GuildPosition)data.Data.position); + this.m_BasicData.portraitIndex = (int)data.Data.icon; + bool flag3 = this.SetLevel((uint)data.Data.level); + this.m_BasicData.guildName = data.Data.name; + this.QueryWXGroup(); + this.QueryQQGroup(); + bool flag4 = flag; + if (flag4) + { + XInGuildStateChangedEventArgs @event = XEventPool.GetEvent(); + @event.bIsEnter = this.bInGuild; + @event.bRoleInit = !this._bInited; + @event.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(@event); + } + bool flag5 = flag2; + if (flag5) + { + XGuildPositionChangedEventArgs event2 = XEventPool.GetEvent(); + event2.position = this.m_Position; + event2.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event2); + } + bool flag6 = flag3; + if (flag6) + { + XGuildLevelChangedEventArgs event3 = XEventPool.GetEvent(); + event3.level = this.m_BasicData.level; + event3.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event3); + } + XGuildInfoChange event4 = XEventPool.GetEvent(); + event4.Firer = XSingleton.singleton.Player; + XSingleton.singleton.FireEvent(event4); + XGuildInfoChange event5 = XEventPool.GetEvent(); + event5.Firer = XSingleton.singleton.Doc; + XSingleton.singleton.FireEvent(event5); + this._bInited = true; + } + + public static void OnTableLoaded() + { + XGuildDocument.GuildPP.InitTable(XGuildDocument.m_PermissionTable); + XGuildDocument.GuildConfig.Init(XGuildDocument.m_ConfigTable); + } + + private bool _CanEnter() + { + float time = Time.time; + bool flag = time - this.m_fEnterTime > 3f; + bool result; + if (flag) + { + this.m_fEnterTime = time; + result = true; + } + else + { + result = false; + } + return result; + } + + public GuildSceneState TryEnterGuildScene() + { + bool bInGuild = this.bInGuild; + GuildSceneState result; + if (bInGuild) + { + SceneType sceneType = XSingleton.singleton.SceneType; + bool flag = sceneType == SceneType.SCENE_GUILD_HALL; + if (flag) + { + result = GuildSceneState.GSS_InGuildScene; + } + else + { + bool flag2 = !this._CanEnter(); + if (flag2) + { + result = GuildSceneState.GSS_NotGuildScene; + } + else + { + HomePlantDocument.Doc.GardenId = this.UID; + PtcC2G_EnterSceneReq ptcC2G_EnterSceneReq = new PtcC2G_EnterSceneReq(); + ptcC2G_EnterSceneReq.Data.sceneID = (uint)XSingleton.singleton.GetInt("GuildHallSceneID"); + ptcC2G_EnterSceneReq.Data.roleID = this.UID; + XSingleton.singleton.Send(ptcC2G_EnterSceneReq); + result = GuildSceneState.GSS_NotGuildScene; + } + } + } + else + { + bool flag3 = !DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.SetVisibleWithAnimation(true, null); + } + result = GuildSceneState.GSS_NoPermission; + } + return result; + } + + public void TryShowGuildHallUI() + { + bool bInGuild = this.bInGuild; + if (bInGuild) + { + DlgBase.singleton.SetVisibleWithAnimation(true, null); + } + else + { + bool flag = !DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.SetVisibleWithAnimation(true, null); + } + } + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + } + + public override void OnEnterSceneFinally() + { + bool flag = XSingleton.singleton.SceneType == SceneType.SCENE_GUILD_HALL; + if (flag) + { + HomePlantDocument doc = HomePlantDocument.Doc; + doc.ClearFarmInfo(); + doc.HomeSprite.ClearInfo(); + HomePlantDocument.Doc.GardenId = this.UID; + doc.FetchPlantInfo(0u); + } + base.OnEnterSceneFinally(); + } + + public bool IHavePermission(GuildPermission pem) + { + return XGuildDocument.GuildPP.HasPermission(this.m_Position, pem); + } + + public bool CheckPermission(GuildPermission pem) + { + bool flag = !this.CheckInGuild(); + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = this.IHavePermission(pem); + if (flag2) + { + result = true; + } + else + { + XSingleton.singleton.ShowSystemTip(ErrorCode.ERR_GUILD_NO_PERMISSION, "fece00"); + result = false; + } + } + return result; + } + + public bool CheckUnlockLevel(XSysDefine sys) + { + bool flag = !this.CheckInGuild(); + bool result; + if (flag) + { + result = false; + } + else + { + uint unlockLevel = XGuildDocument.GuildConfig.GetUnlockLevel(sys); + bool flag2 = this.Level >= unlockLevel; + if (flag2) + { + result = true; + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("OPEN_AT_GUILD_LEVEL", new object[] + { + unlockLevel + }), "fece00"); + result = false; + } + } + return result; + } + + public bool IsSysUnlocked(XSysDefine sys) + { + bool flag = !this.bInGuild; + bool result; + if (flag) + { + result = false; + } + else + { + uint unlockLevel = XGuildDocument.GuildConfig.GetUnlockLevel(sys); + bool flag2 = this.Level >= unlockLevel; + result = flag2; + } + return result; + } + + public bool CheckInGuild() + { + bool bInGuild = this.bInGuild; + bool result; + if (bInGuild) + { + result = true; + } + else + { + XSingleton.singleton.ShowSystemTip(ErrorCode.ERR_GUILD_NOT_IN_GUILD, "fece00"); + result = false; + } + return result; + } + + public static void OnGuildHyperLinkClick(string param) + { + bool flag = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (!flag) + { + ulong id = 0UL; + bool flag2 = XLabelSymbolHelper.ParseGuildParam(param, ref id); + if (flag2) + { + bool flag3 = XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild); + if (flag3) + { + XGuildViewDocument specificDocument = XDocuments.GetSpecificDocument(XGuildViewDocument.uuID); + specificDocument.View(id); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_LOG_CANNOT_JOIN"), "fece00"); + } + } + } + } + + public void QueryWXGroup() + { + bool flag = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_WeChat || !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group); + if (!flag) + { + XSingleton.singleton.wxGroupCallbackType = WXGroupCallBackType.Guild; + Dictionary dictionary = new Dictionary(); + dictionary["unionID"] = this.UID.ToString(); + dictionary["openIdList"] = XSingleton.singleton.OpenID; + string param = Json.Serialize(dictionary); + XSingleton.singleton.XPlatform.QueryWXGroup(param); + } + } + + public void QueryQQGroup() + { + bool flag = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group); + if (!flag) + { + RpcC2M_GetGuildBindInfo rpcC2M_GetGuildBindInfo = new RpcC2M_GetGuildBindInfo(); + rpcC2M_GetGuildBindInfo.oArg.token = XSingleton.singleton.TokenCache; + XSingleton.singleton.Send(rpcC2M_GetGuildBindInfo); + XSingleton.singleton.AddLog("[QQGroup QueryQQGroup]token:" + XSingleton.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + public void OnGetQQGroupBindInfo(GetGuildBindInfoReq oArg, GetGuildBindInfoRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (!flag) + { + this.qqGroupBindStatus = oRes.bind_status; + this.qqGroupName = oRes.group_name; + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.RefreshQQGroupBtn(); + } + } + } + + public void BindQQGroup() + { + bool flag = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group); + if (!flag) + { + RpcC2M_GuildBindGroup rpcC2M_GuildBindGroup = new RpcC2M_GuildBindGroup(); + rpcC2M_GuildBindGroup.oArg.token = XSingleton.singleton.TokenCache; + XSingleton.singleton.Send(rpcC2M_GuildBindGroup); + XSingleton.singleton.AddLog("[QQGroup BindQQGroup]token:" + XSingleton.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + public void OnBindQQGroup(GuildBindGroupReq oArg, GuildBindGroupRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.result); + } + else + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("GUILD_BIN_QQ_GROUP_SUC"), "fece00"); + this.qqGroupName = oRes.group_name; + this.qqGroupBindStatus = GuildBindStatus.GBS_Owner; + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.RefreshQQGroupBtn(); + } + } + } + + public void JoinQQGroup() + { + bool flag = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group); + if (!flag) + { + RpcC2M_GuildJoinBindGroup rpcC2M_GuildJoinBindGroup = new RpcC2M_GuildJoinBindGroup(); + rpcC2M_GuildJoinBindGroup.oArg.token = XSingleton.singleton.TokenCache; + XSingleton.singleton.Send(rpcC2M_GuildJoinBindGroup); + XSingleton.singleton.AddLog("[QQGroup JoinQQGroup]token:" + XSingleton.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + public void OnJoinBindQQGroup(GuildJoinBindGroupReq oArg, GuildJoinBindGroupRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.result); + } + else + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("GUILD_JOIN_QQ_GROUP_SUC"), "fece00"); + this.qqGroupBindStatus = GuildBindStatus.GBS_Member; + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.RefreshQQGroupBtn(); + } + } + } + + public void UnbindQQGroup() + { + bool flag = XSingleton.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group); + if (!flag) + { + RpcC2M_GuildUnBindGroup rpcC2M_GuildUnBindGroup = new RpcC2M_GuildUnBindGroup(); + rpcC2M_GuildUnBindGroup.oArg.token = XSingleton.singleton.TokenCache; + XSingleton.singleton.Send(rpcC2M_GuildUnBindGroup); + XSingleton.singleton.AddLog("[QQGroup UnbindQQGroup]token:" + XSingleton.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + public void OnUnbindQQGroup(GuildUnBindGroupReq oArg, GuildUnBindGroupRes oRes) + { + bool flag = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowErrorCode(oRes.result); + } + else + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("GUILD_UNBIND_QQ_GROUP_SUC"), "fece00"); + this.qqGroupBindStatus = GuildBindStatus.GBS_NotBind; + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.RefreshQQGroupBtn(); + } + } + } + } +} -- cgit v1.1-26-g67d0