From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/DragonGuildLiveness.cs | 248 +++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/DragonGuildLiveness.cs (limited to 'Client/Assets/Scripts/XMainClient/DragonGuildLiveness.cs') diff --git a/Client/Assets/Scripts/XMainClient/DragonGuildLiveness.cs b/Client/Assets/Scripts/XMainClient/DragonGuildLiveness.cs new file mode 100644 index 00000000..5c52251c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/DragonGuildLiveness.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using KKSG; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class DragonGuildLiveness + { + public List RecordList + { + get + { + return this.m_recordList; + } + } + + public uint CurExp + { + get + { + return this.m_curExp; + } + set + { + this.m_curExp = value; + } + } + + public uint MaxExp + { + get + { + List list = new List(); + this.GetDragonGuildLivenessRowsByLevel(XPartnerDocument.Doc.CurPartnerLevel, out list); + bool flag = list.Count != 0; + uint result; + if (flag) + { + result = list[list.Count - 1].liveness; + } + else + { + result = 0u; + } + return result; + } + } + + private DragonGuildLivenessTable m_table; + + private uint m_curExp = 0u; + + private uint m_takeChest = 0u; + + private List m_recordList = new List(); + + public DragonGuildLivenessDlg View; + + public DragonGuildLiveness(DragonGuildLivenessTable table) + { + this.m_table = table; + } + + public DragonGuildLivenessTable.RowData GetPartnerLivenessRow(uint livenessId, int partnerLevel) + { + for (int i = 0; i < this.m_table.Table.Length; i++) + { + DragonGuildLivenessTable.RowData rowData = this.m_table.Table[i]; + bool flag = rowData.liveness == livenessId && (long)partnerLevel >= (long)((ulong)rowData.level[0]) && (long)partnerLevel <= (long)((ulong)rowData.level[1]); + if (flag) + { + return this.m_table.Table[i]; + } + } + return null; + } + + public void GetDragonGuildLivenessRowsByLevel(uint partnerLevel, out List lst) + { + lst = new List(); + for (int i = 0; i < this.m_table.Table.Length; i++) + { + DragonGuildLivenessTable.RowData rowData = this.m_table.Table[i]; + bool flag = partnerLevel >= rowData.level[0] && partnerLevel <= rowData.level[1]; + if (flag) + { + lst.Add(rowData); + } + } + lst.Sort(new Comparison(this.Compare)); + } + + private int Compare(DragonGuildLivenessTable.RowData left, DragonGuildLivenessTable.RowData right) + { + bool flag = left.liveness < right.liveness; + int result; + if (flag) + { + result = -1; + } + else + { + result = 1; + } + return result; + } + + public bool IsChestOpened(int index) + { + uint num = 1u << index; + return (this.m_takeChest & num) > 0u; + } + + public int FindNeedShowReward() + { + bool flag = this.CurExp >= this.MaxExp; + int result; + if (flag) + { + result = 0; + } + else + { + List list; + this.GetDragonGuildLivenessRowsByLevel(XPartnerDocument.Doc.CurPartnerLevel, out list); + for (int i = 0; i < list.Count; i++) + { + bool flag2 = !this.IsChestOpened(i + 1); + if (flag2) + { + return i; + } + } + result = 0; + } + return result; + } + + public bool IsHadRedPoint() + { + List list; + this.GetDragonGuildLivenessRowsByLevel(XPartnerDocument.Doc.CurPartnerLevel, out list); + for (int i = 0; i < list.Count; i++) + { + bool flag = !this.IsChestOpened(i + 1) && this.m_curExp >= list[i].liveness; + if (flag) + { + return true; + } + } + return false; + } + + public void ReqDragonGuildLivenessInfo() + { + RpcC2M_GetDragonGuildLiveness rpc = new RpcC2M_GetDragonGuildLiveness(); + XSingleton.singleton.Send(rpc); + } + + public void ReqTakeDragonGuildChest(uint index) + { + RpcC2G_TakeDragonGuildChest rpcC2G_TakeDragonGuildChest = new RpcC2G_TakeDragonGuildChest(); + rpcC2G_TakeDragonGuildChest.oArg.index = index; + XSingleton.singleton.Send(rpcC2G_TakeDragonGuildChest); + } + + public void OnGetDragonGuildLivenessInfoBack(GetPartnerLivenessRes oRes) + { + bool flag = oRes == null; + if (flag) + { + XSingleton.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00"); + } + else + { + bool flag2 = oRes.result == ErrorCode.ERR_INVALID_REQUEST; + if (flag2) + { + string fullName = MethodBase.GetCurrentMethod().ReflectedType.FullName; + XSingleton.singleton.OnGetInvalidRequest(fullName); + } + else + { + bool flag3 = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag3) + { + XSingleton.singleton.ShowSystemTip(oRes.result, "fece00"); + } + else + { + this.m_curExp = oRes.liveness; + this.m_takeChest = oRes.takedchest; + this.m_recordList.Clear(); + for (int i = 0; i < oRes.record.Count; i++) + { + this.m_recordList.Add(new DragonGuildLivenessRecord(oRes.record[i])); + } + XDragonGuildDocument.Doc.IsHadLivenessRedPoint = this.IsHadRedPoint(); + bool flag4 = this.View != null && this.View.IsVisible(); + if (flag4) + { + this.View.FillContent(); + } + } + } + } + } + + public void OnTakeDragonGuildChestBack(TakePartnerChestArg oArg, TakePartnerChestRes oRes) + { + bool flag = oRes == null; + if (flag) + { + XSingleton.singleton.ShowSystemTip(ErrorCode.ERR_FAILED, "fece00"); + } + else + { + bool flag2 = oRes.result == ErrorCode.ERR_INVALID_REQUEST; + if (flag2) + { + string fullName = MethodBase.GetCurrentMethod().ReflectedType.FullName; + XSingleton.singleton.OnGetInvalidRequest(fullName); + } + else + { + bool flag3 = oRes.result > ErrorCode.ERR_SUCCESS; + if (flag3) + { + XSingleton.singleton.ShowSystemTip(oRes.result, "fece00"); + } + else + { + this.m_takeChest = oRes.takedchest; + XDragonGuildDocument.Doc.IsHadLivenessRedPoint = this.IsHadRedPoint(); + bool flag4 = this.View != null && this.View.IsVisible(); + if (flag4) + { + this.View.ResetBoxRedDot((int)(oArg.index - 1u)); + } + } + } + } + } + } +} -- cgit v1.1-26-g67d0