From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/Guild/XGuildSignInDocument.cs | 333 +++++++++++++++++++++ 1 file changed, 333 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Guild/XGuildSignInDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/Guild/XGuildSignInDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/Guild/XGuildSignInDocument.cs b/Client/Assets/Scripts/XMainClient/Guild/XGuildSignInDocument.cs new file mode 100644 index 00000000..506d73b9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Guild/XGuildSignInDocument.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XGuildSignInDocument : XDocComponent, ILogSource + { + public override uint ID + { + get + { + return XGuildSignInDocument.uuID; + } + } + + public XGuildSignInView GuildSignInView { get; set; } + + public uint TotalCount { get; set; } + + public uint CurrentCount { get; set; } + + public uint SignInSelection + { + get + { + return this._SignInSelection; + } + set + { + this._SignInSelection = value; + this._CheckCanSignIn(); + } + } + + public uint Progress + { + get + { + return this._Progress; + } + } + + public int CanSignInSelection + { + get + { + return this._CanSignInSelection; + } + } + + public bool bHasAvailableChest + { + get + { + return this._bHasAvailableChest; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("GuildSignInDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static GuildCheckinTable m_SignInTable = new GuildCheckinTable(); + + private static GuildCheckinBoxTable m_BoxTable = new GuildCheckinBoxTable(); + + private List m_LogList = new List(); + + private uint _SignInSelection; + + private uint _Progress; + + private int _CanSignInSelection; + + private bool _bHasAvailableChest; + + private uint _BoxState; + + public List GetLogList() + { + return this.m_LogList; + } + + public void SetChestStateAndProgress(uint progress, uint chest) + { + this._BoxState = chest; + this._Progress = progress; + bool flag = this.CheckAvailableChest(); + if (flag) + { + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + } + bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag2) + { + this.GuildSignInView.RefreshProgress(); + } + } + + public int _CheckCanSignIn() + { + this._CanSignInSelection = 0; + bool flag = this.SignInSelection == 0u; + if (flag) + { + for (int i = XGuildSignInDocument.m_SignInTable.Table.Length - 1; i >= 0; i--) + { + GuildCheckinTable.RowData rowData = XGuildSignInDocument.m_SignInTable.Table[i]; + ulong virtualItemCount = XSingleton.singleton.Doc.XBagDoc.GetVirtualItemCount((ItemEnum)rowData.consume[0]); + bool flag2 = virtualItemCount >= (ulong)rowData.consume[1]; + if (flag2) + { + this._CanSignInSelection = i + 1; + break; + } + } + } + return this._CanSignInSelection; + } + + private bool CheckAvailableChest() + { + this._bHasAvailableChest = false; + for (int i = 0; i < XGuildSignInDocument.m_BoxTable.Table.Length; i++) + { + bool flag = XGuildSignInDocument.m_BoxTable.Table[i].process <= this._Progress && !this.IsBoxOpen(i); + if (flag) + { + this._bHasAvailableChest = true; + break; + } + } + return this._bHasAvailableChest; + } + + public bool IsBoxOpen(int index) + { + return ((ulong)this._BoxState & (ulong)(1L << (index & 31))) > 0UL; + } + + public void SetBoxOpen(int index) + { + this._BoxState |= 1u << index; + } + + public static void Execute(OnLoadedCallback callback = null) + { + XGuildSignInDocument.AsyncLoader.AddTask("Table/GuildCheckin", XGuildSignInDocument.m_SignInTable, false); + XGuildSignInDocument.AsyncLoader.AddTask("Table/GuildCheckinBox", XGuildSignInDocument.m_BoxTable, false); + XGuildSignInDocument.AsyncLoader.Execute(callback); + } + + public static GuildCheckinTable.RowData[] GetSignInTableData() + { + return XGuildSignInDocument.m_SignInTable.Table; + } + + public static GuildCheckinBoxTable.RowData[] GetBoxTableData() + { + return XGuildSignInDocument.m_BoxTable.Table; + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this._Progress = 0u; + this._BoxState = 0u; + this._bHasAvailableChest = false; + this.SignInSelection = 100u; + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + base.RegisterEvent(XEventDefine.XEvent_InGuildStateChanged, new XComponent.XEventHandler(this.OnInGuildStateChanged)); + base.RegisterEvent(XEventDefine.XEvent_VirtualItemChanged, new XComponent.XEventHandler(this.OnVirtualItemChanged)); + } + + protected bool OnVirtualItemChanged(XEventArgs args) + { + bool flag = this.SignInSelection > 0u; + bool result; + if (flag) + { + result = true; + } + else + { + this._CheckCanSignIn(); + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + result = true; + } + return result; + } + + protected bool OnInGuildStateChanged(XEventArgs args) + { + XInGuildStateChangedEventArgs xinGuildStateChangedEventArgs = args as XInGuildStateChangedEventArgs; + bool flag = !xinGuildStateChangedEventArgs.bIsEnter; + if (flag) + { + this.SignInSelection = 100u; + this._bHasAvailableChest = false; + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + } + return true; + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + bool flag = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag) + { + this.ReqAllInfo(); + } + } + + public void ReqAllInfo() + { + RpcC2M_QueryGuildCheckinNew rpc = new RpcC2M_QueryGuildCheckinNew(); + XSingleton.singleton.Send(rpc); + } + + public void OnGetAllInfo(QueryGuildCheckinRes oRes) + { + this.SignInSelection = oRes.checkin; + this.CurrentCount = oRes.checkincount; + this.TotalCount = oRes.allcount; + this._BoxState = oRes.boxmask; + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + bool flag = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag) + { + this.GuildSignInView.Refresh(); + } + } + + public void ReqFetchBox(uint index) + { + RpcC2G_GetGuildCheckinBox rpcC2G_GetGuildCheckinBox = new RpcC2G_GetGuildCheckinBox(); + rpcC2G_GetGuildCheckinBox.oArg.index = index; + XSingleton.singleton.Send(rpcC2G_GetGuildCheckinBox); + } + + public void OnFetchBox(GetGuildCheckinBoxArg oArg, GetGuildCheckinBoxRes oRes) + { + bool flag = oRes.errorcode > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowSystemTip(oRes.errorcode, "fece00"); + } + else + { + this.SetBoxOpen((int)oArg.index); + bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag2) + { + this.GuildSignInView.OpenBox((int)oArg.index); + } + bool flag3 = !this.CheckAvailableChest(); + if (flag3) + { + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + } + } + } + + public void ReqSignIn(uint index) + { + RpcC2M_GuildCheckinNew rpcC2M_GuildCheckinNew = new RpcC2M_GuildCheckinNew(); + rpcC2M_GuildCheckinNew.oArg.type = index; + XSingleton.singleton.Send(rpcC2M_GuildCheckinNew); + } + + public void OnSignIn(GuildCheckinArg oArg, GuildCheckinRes oRes) + { + bool flag = oRes.errorcode > ErrorCode.ERR_SUCCESS; + if (flag) + { + XSingleton.singleton.ShowSystemTip(oRes.errorcode, "fece00"); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_SIGNIN_SUCCESS"), "fece00"); + this.SignInSelection = oArg.type; + uint currentCount = this.CurrentCount + 1u; + this.CurrentCount = currentCount; + bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag2) + { + this.GuildSignInView.Refresh(); + } + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildHall_SignIn, true); + } + } + + public void ReqLogList() + { + RpcC2M_GetGuildCheckinRecordsNew rpc = new RpcC2M_GetGuildCheckinRecordsNew(); + XSingleton.singleton.Send(rpc); + } + + public void onGetLogList(GetGuildCheckinRecordsRes oRes) + { + int num = oRes.name.Count - this.m_LogList.Count; + for (int i = 0; i < num; i++) + { + this.m_LogList.Add(new XGuildSignInLog()); + } + bool flag = num < 0; + if (flag) + { + this.m_LogList.RemoveRange(this.m_LogList.Count + num, -num); + } + for (int j = 0; j < this.m_LogList.Count; j++) + { + XGuildSignInLog xguildSignInLog = this.m_LogList[this.m_LogList.Count - j - 1] as XGuildSignInLog; + xguildSignInLog.name = oRes.name[j]; + xguildSignInLog.uid = oRes.roleid[j]; + xguildSignInLog.type = oRes.type[j]; + xguildSignInLog.time = (int)oRes.timestamp[j]; + } + bool flag2 = this.GuildSignInView != null && this.GuildSignInView.IsVisible(); + if (flag2) + { + this.GuildSignInView.LogView.Refresh(); + } + } + } +} -- cgit v1.1-26-g67d0