using System; using System.Collections.Generic; using KKSG; using UILib; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class XGuildInheritDocument : XDocComponent { public override uint ID { get { return XGuildInheritDocument.uuID; } } public uint TeacherCount { get { return this.m_teacherCount; } } public uint StudentCount { get { return this.m_studentCount; } } private static int InheritLimitRange { get { XLevelSealDocument specificDocument = XDocuments.GetSpecificDocument(XLevelSealDocument.uuID); uint sealType = specificDocument.SealType; SeqList sequenceList = XSingleton.singleton.GetSequenceList("GuildInheritRoleLvlGap", true); int i = 0; int count = (int)sequenceList.Count; while (i < count) { bool flag = (long)sequenceList[i, 0] == (long)((ulong)sealType); if (flag) { return sequenceList[i, 1]; } i++; } return sequenceList[(int)(sequenceList.Count - 1), 1]; } } public List InheritList { get { return this.m_inheritList; } } public uint bHasAvailableIconShow { get { return this.m_avilableReqCount; } set { this.m_avilableReqCount = value; DlgBase.singleton.RefreshH5ButtonState(XSysDefine.XSys_GuildInherit, true); } } public new static readonly uint uuID = XSingleton.singleton.XHash("XGuildInheritDocument"); private uint m_avilableReqCount = 0u; private uint m_teacherCount = 0u; private uint m_studentCount = 0u; private List m_inheritList = new List(); private ulong m_SelectFriend = 0UL; private float m_teacherTime = 0f; private XFx m_selectEffect = null; private bool m_Inheriting = false; private float m_bubbleTime = 11f; private ulong InheritTeacherID = 0UL; protected override void OnReconnected(XReconnectedEventArgs arg) { bool flag = DlgBase.singleton.IsVisible(); if (flag) { this.SendInheritList(); } } public string GetTeacherLeftTimeString() { bool flag = this.m_teacherTime > 0f; string result; if (flag) { result = XStringDefineProxy.GetString("GUILD_INHERIT_TEACHER_TIME", new object[] { XSingleton.singleton.TimeDuarationFormatString((int)this.m_teacherTime, 5) }); } else { result = string.Empty; } return result; } public bool TryGetInheritCountString(out string message) { message = string.Empty; bool flag = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)XSingleton.singleton.StudentMinLevel); bool result; if (flag) { result = false; } else { bool flag2 = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)XSingleton.singleton.TeacherMinLevel); if (flag2) { message = XStringDefineProxy.GetString("GUILD_INHERIT_MESSAGE2", new object[] { XSingleton.singleton.TeacherMinLevel, this.m_studentCount }); } else { message = XStringDefineProxy.GetString("GUILD_INHERIT_MESSAGE1", new object[] { this.m_teacherCount, this.m_studentCount, XGuildInheritDocument.InheritLimitRange }); } result = true; } return result; } public static void TryOutInherit(XEntity entity) { bool isPlayer = entity.IsPlayer; if (isPlayer) { XSingleton.singleton.AddGreenLog("Player Out Inherit", null, null, null, null, null); XSingleton.singleton.Freezed = false; bool flag = entity.Nav != null; if (flag) { entity.Nav.Interrupt(); entity.Nav.Enabled = true; } XGuildInheritDocument specificDocument = XDocuments.GetSpecificDocument(XGuildInheritDocument.uuID); specificDocument.StopInherit(); } XInheritComponent xinheritComponent = entity.GetXComponent(XInheritComponent.uuID) as XInheritComponent; bool flag2 = xinheritComponent != null; if (flag2) { entity.DetachComponent(XInheritComponent.uuID); } XBubbleComponent xbubbleComponent = entity.GetXComponent(XBubbleComponent.uuID) as XBubbleComponent; bool flag3 = xbubbleComponent != null; if (flag3) { entity.DetachComponent(XBubbleComponent.uuID); } } public void StopInherit() { this.m_Inheriting = false; bool flag = this.m_selectEffect != null; if (flag) { XSingleton.singleton.DestroyFx(this.m_selectEffect, true); this.m_selectEffect = null; } bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.HideProcess(); } } public static void TryInInherit(XEntity entity) { bool isPlayer = entity.IsPlayer; if (isPlayer) { XSingleton.singleton.AddGreenLog("Player in Inherit", null, null, null, null, null); XSingleton.singleton.Freezed = false; XSingleton.singleton.Freezed = true; bool flag = entity.Nav != null; if (flag) { entity.Nav.Interrupt(); entity.Nav.Enabled = false; } } XInheritComponent xinheritComponent = entity.GetXComponent(XInheritComponent.uuID) as XInheritComponent; bool flag2 = xinheritComponent == null; if (flag2) { XSingleton.singleton.CreateComponent(entity, XInheritComponent.uuID); } } public static bool IsInherit(uint level) { return XGuildInheritDocument.IsInheritInitiator(level) || XGuildInheritDocument.IsInheritReceiver(level); } public static bool IsInheritReceiver(uint level) { bool flag = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)XSingleton.singleton.StudentMinLevel) || (ulong)level < (ulong)((long)XSingleton.singleton.TeacherMinLevel); return !flag && level - XSingleton.singleton.XPlayerData.Level >= (uint)XGuildInheritDocument.InheritLimitRange; } public static bool IsInheritInitiator(uint level) { bool flag = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)XSingleton.singleton.TeacherMinLevel) || (ulong)level < (ulong)((long)XSingleton.singleton.StudentMinLevel); return !flag && XSingleton.singleton.XPlayerData.Level - level >= (uint)XGuildInheritDocument.InheritLimitRange; } public override void Update(float fDeltaT) { base.Update(fDeltaT); bool flag = this.m_teacherTime > 0f; if (flag) { this.m_teacherTime -= fDeltaT; } else { this.m_teacherTime = 0f; } bool inheriting = this.m_Inheriting; if (inheriting) { bool flag2 = this.m_bubbleTime > 0f; if (flag2) { this.m_bubbleTime -= fDeltaT; } else { this.m_bubbleTime = 11f; this.ShowBubble(); } } } public void SynInheritExp(synGuildInheritExp res) { XSingleton.singleton.AddGreenLog("SynInheritExp:", res.teacherId.ToString(), null, null, null, null); bool flag = res.turn == 0u; if (flag) { bool flag2 = XSingleton.singleton.GetSceneType(XSingleton.singleton.SceneID) == SceneType.SCENE_HALL; if (flag2) { XSingleton.singleton.CloseAllUI(); } this.InheritTeacherID = res.teacherId; XSingleton.singleton.AddGreenLog("Start Inherit", null, null, null, null, null); this.m_Inheriting = true; this.m_bubbleTime = 11f; float countdownTime = (float)(XSingleton.singleton.GetInt("GuildInheritTime") * XSingleton.singleton.GetInt("GuildInheritTimes")); string @string = XStringDefineProxy.GetString("GUILD_INHERIT_PROCESSMESS"); string string2 = XStringDefineProxy.GetString("GUILD_INHERIT_HELP"); DlgBase.singleton.ShowProcess(countdownTime, @string, string2, null); bool flag3 = XSingleton.singleton.GetSceneType(XSingleton.singleton.SceneID) == SceneType.SCENE_GUILD_HALL && XSingleton.singleton.XPlayerData != null; if (flag3) { bool flag4 = XSingleton.singleton.XPlayerData.RoleID == res.teacherId; if (flag4) { this.m_teacherCount -= 1u; } else { this.m_studentCount -= 1u; } } } else { bool islast = res.islast; if (islast) { this.m_Inheriting = false; this.InheritTeacherID = 0UL; DlgBase.singleton.HideProcess(); XSingleton.singleton.AddGreenLog("Stop Inherit", null, null, null, null, null); ulong num = 0UL; bool flag5 = XSingleton.singleton.XPlayerData.RoleID != res.roleOne; if (flag5) { num = res.roleOne; } else { bool flag6 = XSingleton.singleton.XPlayerData.RoleID != res.roleTwo; if (flag6) { num = res.roleTwo; } } bool flag7 = (ulong)res.turn == (ulong)((long)XSingleton.singleton.GetInt("GuildInheritTimes")); if (flag7) { bool flag8 = XSingleton.singleton.XPlayerData.RoleID != this.InheritTeacherID; if (flag8) { DlgBase.singleton.AddChat(XStringDefineProxy.GetString("GUILD_INHERIT_CHAT2"), ChatChannelType.Guild, null, false); } bool flag9 = num != 0UL && !DlgBase.singleton.IsMyFriend(num); if (flag9) { this.m_SelectFriend = num; XSingleton.singleton.ShowModalDialog(XStringDefineProxy.GetString("GUILD_INHERIT_ADDFRIEND"), XStringDefineProxy.GetString(XStringDefine.COMMON_OK), XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL), new ButtonClickEventHandler(this.OnAddFriend)); } } } } bool flag10 = res.islast || this.m_selectEffect != null; if (!flag10) { XEntity entity = XSingleton.singleton.GetEntity(res.roleOne); XEntity entity2 = XSingleton.singleton.GetEntity(res.roleTwo); bool flag11 = entity == null || entity2 == null; if (!flag11) { Vector3 position = entity.EngineObject.Position; Vector3 position2 = entity2.EngineObject.Position; Vector3 position3 = (position + position2) / 2f; this.m_selectEffect = XSingleton.singleton.CreateFx("Effects/FX_Particle/UIfx/UI_cg_lx", null, true); Quaternion rotation = Quaternion.FromToRotation(position - position2, Vector3.zero); this.m_selectEffect.Play(position3, rotation, Vector3.one, 1f); } } } private void ShowBubble() { bool flag = this.InheritTeacherID == 0UL; if (!flag) { XEntity entity = XSingleton.singleton.GetEntity(this.InheritTeacherID); bool flag2 = entity == null; if (!flag2) { XBubbleEventArgs @event = XEventPool.GetEvent(); @event.bubbletext = XStringDefineProxy.GetString("GUILD_INHERIT_CHAT1"); @event.existtime = 3f; @event.Firer = entity; @event.speaker = entity.Name; XBubbleComponent xbubbleComponent = entity.GetXComponent(XBubbleComponent.uuID) as XBubbleComponent; bool flag3 = xbubbleComponent == null; if (flag3) { XSingleton.singleton.CreateComponent(entity, XBubbleComponent.uuID); } XSingleton.singleton.FireEvent(@event); } } } private bool OnAddFriend(IXUIButton btn) { DlgBase.singleton.AddFriendById(this.m_SelectFriend); XSingleton.singleton.CloseModalDlg(); return true; } public void SynInheritBaseInfo(SynGuildInheritNumInfo res) { XSingleton.singleton.AddGreenLog("XGuildInheritDocument.SynInheritBaseInfo teacherNumber:", res.teacherNum.ToString(), " teacher:", res.lastTime.ToString(), null, null); this.bHasAvailableIconShow = res.reqNum; this.m_studentCount = res.studentNum; this.m_teacherCount = res.teacherNum; bool flag = this.m_teacherCount > 0u; if (flag) { this.m_teacherTime = res.lastTime; } else { this.m_teacherTime = 0f; } } public void SendInheritList() { RpcC2M_ReqGuildInheritInfo rpc = new RpcC2M_ReqGuildInheritInfo(); XSingleton.singleton.Send(rpc); } public void ReceiveInheritList(ReqGuildInheritInfoArg oArg, ReqGuildInheritInfoRes oRes) { this.m_inheritList.Clear(); int num = oRes.data.Count - this.m_inheritList.Count; bool flag = num < 0; if (flag) { this.m_inheritList.RemoveRange(this.m_inheritList.Count + num, -num); } else { for (int i = 0; i < num; i++) { GuildInheritInfo item = new GuildInheritInfo(); this.m_inheritList.Add(item); } } int j = 0; int count = this.m_inheritList.Count; while (j < count) { this.m_inheritList[j].Set(oRes.data[j]); j++; } this.bHasAvailableIconShow = (uint)this.m_inheritList.Count; bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.RefreshData(); } } public void SendDelInherit() { RpcC2M_DelGuildInherit rpc = new RpcC2M_DelGuildInherit(); XSingleton.singleton.Send(rpc); } public void ReceiveDelInherit(DelGuildInheritRes res) { bool flag = res.errorCode > ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.ShowSystemTip(res.errorCode, "fece00"); } else { this.m_inheritList.Clear(); this.bHasAvailableIconShow = (uint)this.m_inheritList.Count; } } public void SendReqInherit(ulong uid) { RpcC2M_AddGuildInherit rpcC2M_AddGuildInherit = new RpcC2M_AddGuildInherit(); rpcC2M_AddGuildInherit.oArg.reqRoleId = uid; XSingleton.singleton.Send(rpcC2M_AddGuildInherit); } public void ReceiveReqInherit(AddGuildInheritArg arg, AddGuildInheritRes res) { XSingleton.singleton.AddGreenLog("XGuildInheritDocument.ReceiveReqInherit", null, null, null, null, null); bool flag = res.errorcode > ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.ShowSystemTip(res.errorcode, "fece00"); } else { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_INHERIT_REQSUCCESS"), "fece00"); } } public void SendAccpetInherit(int index) { bool flag = this.m_inheritList == null || index < 0 || index >= this.m_inheritList.Count; if (!flag) { GuildInheritInfo guildInheritInfo = this.m_inheritList[index]; bool flag2 = !XGuildInheritDocument.IsInherit(guildInheritInfo.level); if (flag2) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_GUILD_INHERIT_LVL"), "fece00"); } else { bool flag3 = XSingleton.singleton.XPlayerData.Outlook.state.type == OutLookStateType.OutLook_Inherit; if (flag3) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_INHERIT_ING"), "fece00"); } else { RpcC2M_AceptGuildInherit rpcC2M_AceptGuildInherit = new RpcC2M_AceptGuildInherit(); rpcC2M_AceptGuildInherit.oArg.roleId = guildInheritInfo.uid; XSingleton.singleton.Send(rpcC2M_AceptGuildInherit); } } } } public void ReceiveAccpetInherit(AceptGuildInheritArg arg, AceptGuildInheritRes res) { bool flag = false; int i = 0; int count = this.m_inheritList.Count; while (i < count) { bool flag2 = this.m_inheritList[i].uid == arg.roleId; if (flag2) { this.m_inheritList.RemoveAt(i); flag = true; break; } i++; } bool flag3 = flag; if (flag3) { this.bHasAvailableIconShow = (uint)this.m_inheritList.Count; } bool flag4 = res.errorcode > ErrorCode.ERR_SUCCESS; if (flag4) { XSingleton.singleton.ShowSystemTip(res.errorcode, "fece00"); bool flag5 = DlgBase.singleton.IsVisible(); if (flag5) { DlgBase.singleton.RefreshData(); } } else { bool flag6 = DlgBase.singleton.IsVisible(); if (flag6) { DlgBase.singleton.SetVisibleWithAnimation(false, null); } } } } }