From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/XDailyActivitiesDocument.cs | 340 +++++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XDailyActivitiesDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XDailyActivitiesDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XDailyActivitiesDocument.cs b/Client/Assets/Scripts/XMainClient/XDailyActivitiesDocument.cs new file mode 100644 index 00000000..9b546292 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XDailyActivitiesDocument.cs @@ -0,0 +1,340 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XDailyActivitiesDocument : XDocComponent + { + public override uint ID + { + get + { + return XDailyActivitiesDocument.uuID; + } + } + + public XDailyActivitiesView View + { + get + { + return this._view; + } + set + { + this._view = value; + } + } + + public List ActivityList + { + get + { + return this._ActivityList; + } + } + + public uint CurrentExp + { + get + { + return this._CurrentExp; + } + } + + public uint WeekExp + { + get + { + return this._WeekExp; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("DailyActivitiesDocument"); + + private XDailyActivitiesView _view = null; + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static ActivityChestTable _ChestReader = new ActivityChestTable(); + + private static ActivityTable _ActivityReader = new ActivityTable(); + + private List _ActivityList = new List(); + + public uint _CurrentExp = 0u; + + public uint _WeekExp = 0u; + + private uint _ChestsInfo = 0u; + + public List ChestExps = new List(); + + public List WeekExps = new List(); + + public List SpriteName = new List(); + + public SeqListRef Reward = default(SeqListRef); + + public int ChestCount; + + public uint MaxExp; + + public int SeverRedPointNotify = 0; + + public static void Execute(OnLoadedCallback callback = null) + { + XDailyActivitiesDocument.AsyncLoader.AddTask("Table/ActivityChest", XDailyActivitiesDocument._ChestReader, false); + XDailyActivitiesDocument.AsyncLoader.AddTask("Table/Activity", XDailyActivitiesDocument._ActivityReader, false); + XDailyActivitiesDocument.AsyncLoader.Execute(callback); + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this._ActivityList.Clear(); + this.ChestExps = XSingleton.singleton.GetUIntList("ActivityChestExp"); + this.SpriteName = XSingleton.singleton.GetStringList("ActivityChestSpriteName"); + this.ChestCount = this.ChestExps.Count; + this.MaxExp = this.ChestExps[this.ChestExps.Count - 1]; + this.WeekExps = XSingleton.singleton.GetUIntList("ActivityChestExpWeekly"); + } + + public void QueryDailyActivityData() + { + RpcC2G_GetActivityInfo rpc = new RpcC2G_GetActivityInfo(); + XSingleton.singleton.Send(rpc); + } + + public void GetDailyActivityData(ActivityRecord data) + { + this._ChestsInfo = data.ChestGetInfo; + this._CurrentExp = data.ActivityAllValue; + this._WeekExp = data.activityWeekValue; + this._ActivityList.Clear(); + for (int i = 0; i < data.ActivityId.Count; i++) + { + ActivityTable.RowData activityBasicInfo = this.GetActivityBasicInfo(data.ActivityId[i]); + XDailyActivity xdailyActivity = new XDailyActivity(); + xdailyActivity.id = data.ActivityId[i]; + xdailyActivity.currentCount = data.FinishCount[i]; + xdailyActivity.requiredCount = data.NeedFinishCount[i]; + xdailyActivity.finish = (xdailyActivity.currentCount == xdailyActivity.requiredCount); + xdailyActivity.random = (activityBasicInfo.random > 0u); + xdailyActivity.sysID = activityBasicInfo.id; + this._ActivityList.Add(xdailyActivity); + } + this._ActivityList.Sort(new Comparison(XDailyActivitiesDocument.CompareActivityList)); + bool flag = this.View != null && this.View.active; + if (flag) + { + this.View.RefreshPage(); + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.FillContent(); + } + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Reward_Activity, true); + } + + private static int CompareActivityList(XDailyActivity act1, XDailyActivity act2) + { + bool flag = act1.finish != act2.finish; + int result; + if (flag) + { + result = (act1.finish ? 1 : -1); + } + else + { + bool flag2 = act1.random != act2.random; + if (flag2) + { + result = (act1.random ? -1 : 1); + } + else + { + result = 0; + } + } + return result; + } + + public bool IsFinishedAllActivity() + { + for (int i = 0; i < this._ActivityList.Count; i++) + { + bool flag = !this._ActivityList[i].finish; + if (flag) + { + return false; + } + } + return true; + } + + public int GetTotalActivityNum() + { + return this._ActivityList.Count; + } + + public int GetFinishedActivityNum() + { + int num = 0; + for (int i = 0; i < this._ActivityList.Count; i++) + { + bool flag = !this._ActivityList[i].finish; + if (flag) + { + num++; + } + } + return num; + } + + public ActivityTable.RowData GetActivityBasicInfo(uint sortid) + { + for (int i = 0; i < XDailyActivitiesDocument._ActivityReader.Table.Length; i++) + { + bool flag = sortid == XDailyActivitiesDocument._ActivityReader.Table[i].sortid; + if (flag) + { + return XDailyActivitiesDocument._ActivityReader.Table[i]; + } + } + return null; + } + + public void DealWithBuyReply() + { + bool flag = DlgBase.singleton._livenessActivityHandler != null && DlgBase.singleton._livenessActivityHandler.IsVisible(); + if (flag) + { + DlgBase.singleton._livenessActivityHandler.InitView(false); + } + } + + public void GetChestReward(uint chestid) + { + uint num = chestid + 1u; + uint level = XSingleton.singleton.XPlayerData.Level; + for (int i = 0; i < XDailyActivitiesDocument._ChestReader.Table.Length; i++) + { + ActivityChestTable.RowData rowData = XDailyActivitiesDocument._ChestReader.Table[i]; + bool flag = rowData.chest != num; + if (!flag) + { + bool flag2 = rowData.level[0] <= level && rowData.level[1] >= level; + if (flag2) + { + this.Reward = rowData.viewabledrop; + return; + } + } + } + XSingleton.singleton.AddErrorLog("Can't Find This Player's ActivityChest,chest id = ", num.ToString(), " level = ", level.ToString(), null, null); + } + + public bool IsChestOpend(uint index) + { + uint num = 1u << (int)index; + return (this._ChestsInfo & num) > 0u; + } + + public void ReqFetchChest(uint id) + { + RpcC2G_GetActivityChest rpcC2G_GetActivityChest = new RpcC2G_GetActivityChest(); + rpcC2G_GetActivityChest.oArg.ChestIndex = id; + XSingleton.singleton.Send(rpcC2G_GetActivityChest); + } + + public void OnFetchChest(uint chestID, uint chestInfo, List itemID, List itemCount) + { + this._ChestsInfo = chestInfo; + bool flag = this.View != null && this.View.active; + if (flag) + { + this.View.OnChestFetched(chestID); + } + this.SeverRedPointNotify = 0; + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Reward_Activity, true); + } + + public bool HasCanFetchReward() + { + bool flag = this.SeverRedPointNotify != 0; + bool result; + if (flag) + { + bool flag2 = this.SeverRedPointNotify > 0; + if (flag2) + { + this.SeverRedPointNotify = 0; + result = true; + } + else + { + this.SeverRedPointNotify = 0; + result = false; + } + } + else + { + for (int i = 0; i < this.ChestCount; i++) + { + bool flag3 = !this.IsChestOpend((uint)i) && this.CurrentExp >= this.ChestExps[i]; + if (flag3) + { + return true; + } + } + for (int j = 0; j < this.WeekExps.Count; j++) + { + bool flag4 = !this.IsChestOpend((uint)(this.ChestCount + j)) && this.WeekExp >= this.WeekExps[j]; + if (flag4) + { + return true; + } + } + result = false; + } + return result; + } + + public uint FindNeed2ShowReward() + { + bool flag = this.CurrentExp >= this.MaxExp; + uint result; + if (flag) + { + result = 0u; + } + else + { + for (int i = 0; i < this.ChestCount; i++) + { + bool flag2 = !this.IsChestOpend((uint)i); + if (flag2) + { + return (uint)i; + } + } + result = 0u; + } + return result; + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + bool flag = DlgBase.singleton._livenessActivityHandler != null && DlgBase.singleton._livenessActivityHandler.IsVisible(); + if (flag) + { + this.QueryDailyActivityData(); + } + } + } +} -- cgit v1.1-26-g67d0