From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Guild/XGuildWeeklyBountyDocument.cs | 577 +++++++++++++++++++++ 1 file changed, 577 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Guild/XGuildWeeklyBountyDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/Guild/XGuildWeeklyBountyDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/Guild/XGuildWeeklyBountyDocument.cs b/Client/Assets/Scripts/XMainClient/Guild/XGuildWeeklyBountyDocument.cs new file mode 100644 index 00000000..28994f9f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Guild/XGuildWeeklyBountyDocument.cs @@ -0,0 +1,577 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XGuildWeeklyBountyDocument : XDocComponent + { + public override uint ID + { + get + { + return XGuildWeeklyBountyDocument.uuID; + } + } + + public static XGuildWeeklyBountyDocument Doc + { + get + { + return XSingleton.singleton.Doc.GetXComponent(XGuildWeeklyBountyDocument.uuID) as XGuildWeeklyBountyDocument; + } + } + + public List CurGuildWeeklyTaskList + { + get + { + return this._curGuildWeeklyTaskList; + } + } + + public List RewardedBoxList + { + get + { + return this._rewardedBoxList; + } + } + + public uint WeeklyScore + { + get + { + return this._weeklyScore; + } + } + + public uint WeeklyAskedHelpNum + { + get + { + return this._weeklyAskedHelpNum; + } + } + + public List ChestValueList + { + get + { + return this._chestValueList; + } + } + + public List TaskHelpInfoList + { + get + { + return this._taskHelpInfoList; + } + } + + public double ActivityLeftTime + { + get + { + return this._activityLeftTime; + } + set + { + this._activityLeftTime = value; + } + } + + public uint RemainedFreshTimes + { + get + { + return this._remainedFreshTimes; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XGuildWeeklyBountyDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private uint _weeklyScore; + + private uint _weeklyAskedHelpNum; + + private uint _taskRoleLevel = 0u; + + private List _rewardedBoxList = new List(); + + private List _curGuildWeeklyTaskList = new List(); + + private Dictionary> _guildTaskRewardWithMap = new Dictionary>(); + + private List _chestValueList = new List(); + + private List _taskHelpInfoList = new List(); + + private double _activityLeftTime = 0.0; + + private uint _remainedFreshTimes = 0u; + + public static void Execute(OnLoadedCallback callback = null) + { + XGuildWeeklyBountyDocument.AsyncLoader.Execute(callback); + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + } + + public override void OnDetachFromHost() + { + base.OnDetachFromHost(); + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + } + + public override void OnEnterSceneFinally() + { + base.OnEnterSceneFinally(); + } + + public void SendGetWeeklyTaskInfo() + { + RpcC2G_GetWeeklyTaskInfo rpc = new RpcC2G_GetWeeklyTaskInfo(); + XSingleton.singleton.Send(rpc); + } + + public void OnGetWeeklyTaskInfo(GetWeeklyTaskInfoRes oRes) + { + this._weeklyScore = oRes.score; + this._weeklyAskedHelpNum = oRes.askhelp_num; + this._rewardedBoxList = oRes.rewarded_box; + this._taskHelpInfoList = oRes.helpinfo; + this._taskRoleLevel = oRes.accept_level; + this._activityLeftTime = oRes.lefttime; + this._remainedFreshTimes = oRes.remain_free_refresh_count; + this.UpdateTaskContent(oRes.task); + this.ResetRewardsMap(); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.RefreshUI(); + } + } + + public bool HasFinishWeeklyTasks() + { + return this.IsAllBoxsReward() && this.IsAllTaskFinished(); + } + + public void SendToGetWeeklyTaskReward(uint type, uint value) + { + RpcC2G_GetWeeklyTaskReward rpcC2G_GetWeeklyTaskReward = new RpcC2G_GetWeeklyTaskReward(); + rpcC2G_GetWeeklyTaskReward.oArg.type = type; + rpcC2G_GetWeeklyTaskReward.oArg.value = value; + XSingleton.singleton.Send(rpcC2G_GetWeeklyTaskReward); + } + + public void OnGetWeeklyTaskReward(GetWeeklyTaskRewardArg oArg, GetWeeklyTaskRewardRes oRes) + { + bool flag = oArg.type == 1u && (ulong)oArg.value < (ulong)((long)this._curGuildWeeklyTaskList.Count); + if (flag) + { + this._weeklyScore = oRes.score; + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + GuildWeeklyTaskInfo guildWeeklyTaskInfo = this._curGuildWeeklyTaskList[i]; + bool flag2 = guildWeeklyTaskInfo.originIndex == oArg.value; + if (flag2) + { + guildWeeklyTaskInfo.isRewarded = true; + break; + } + } + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.RefreshTaskList(false); + DlgBase.singleton.RefreshChestList(); + DlgBase.singleton.PlayCompleteEffect(); + } + } + else + { + bool flag4 = oArg.type == 2u; + if (flag4) + { + bool flag5 = !this._rewardedBoxList.Contains(oArg.value); + if (flag5) + { + this._rewardedBoxList.Add(oArg.value); + } + bool flag6 = DlgBase.singleton.IsVisible(); + if (flag6) + { + DlgBase.singleton.RefreshChestList(); + } + } + } + } + + private bool IsAllBoxsReward() + { + List chestValueList = XGuildWeeklyBountyDocument.Doc.ChestValueList; + for (int i = 0; i < chestValueList.Count; i++) + { + bool flag = !this.RewardedBoxList.Contains(chestValueList[i]); + if (flag) + { + return false; + } + } + return true; + } + + private bool IsAllTaskFinished() + { + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag = !this._curGuildWeeklyTaskList[i].isRewarded; + if (flag) + { + return false; + } + } + return true; + } + + private void UpdateTaskContent(List task) + { + this.CurGuildWeeklyTaskList.Clear(); + for (int i = 0; i < task.Count; i++) + { + WeeklyTaskInfo weeklyTaskInfo = task[i]; + this.CurGuildWeeklyTaskList.Add(new GuildWeeklyTaskInfo + { + taskID = weeklyTaskInfo.id, + step = weeklyTaskInfo.step, + isRewarded = weeklyTaskInfo.is_rewarded, + hasAsked = weeklyTaskInfo.ask_help, + refreshedCount = weeklyTaskInfo.refresh_count, + originIndex = weeklyTaskInfo.index, + category = WeeklyTaskCategory.None + }); + } + this._curGuildWeeklyTaskList.Sort(new Comparison(this.SortWeeklyTaskList)); + } + + private int SortWeeklyTaskList(GuildWeeklyTaskInfo x, GuildWeeklyTaskInfo y) + { + DailyTask.RowData dailyTaskTableInfoByID = XGuildDailyTaskDocument.Doc.GetDailyTaskTableInfoByID(x.taskID); + DailyTask.RowData dailyTaskTableInfoByID2 = XGuildDailyTaskDocument.Doc.GetDailyTaskTableInfoByID(y.taskID); + bool flag = dailyTaskTableInfoByID != null && dailyTaskTableInfoByID2 != null; + if (flag) + { + bool flag2 = x.isRewarded ^ y.isRewarded; + if (flag2) + { + bool isRewarded = x.isRewarded; + if (isRewarded) + { + return 1; + } + bool isRewarded2 = y.isRewarded; + if (isRewarded2) + { + return -1; + } + } + else + { + bool flag3 = !x.isRewarded && x.step >= dailyTaskTableInfoByID.conditionNum; + bool flag4 = !y.isRewarded && y.step >= dailyTaskTableInfoByID2.conditionNum; + bool flag5 = flag3 ^ flag4; + if (flag5) + { + bool flag6 = flag3; + if (flag6) + { + return -1; + } + bool flag7 = flag4; + if (flag7) + { + return 1; + } + } + else + { + bool flag8 = dailyTaskTableInfoByID.taskquality != dailyTaskTableInfoByID2.taskquality; + if (flag8) + { + return (int)(dailyTaskTableInfoByID2.taskquality - dailyTaskTableInfoByID.taskquality); + } + } + } + } + return (int)(x.taskID - y.taskID); + } + + private void ResetRewardsMap() + { + this._guildTaskRewardWithMap.Clear(); + this._chestValueList.Clear(); + for (int i = 0; i < XGuildDailyTaskDocument.DailyTaskRewardTable.Table.Length; i++) + { + DailyTaskReward.RowData rowData = XGuildDailyTaskDocument.DailyTaskRewardTable.Table[i]; + uint num = rowData.level[0]; + uint num2 = rowData.level[1]; + bool flag = this._taskRoleLevel >= num && this._taskRoleLevel <= num2; + if (flag) + { + uint mappingValueWithQualityAndType = XGuildDailyTaskDocument.GetMappingValueWithQualityAndType((GuildTaskType)rowData.category, rowData.tasktype, rowData.taskquality); + bool flag2 = rowData.category == 2u && !this._guildTaskRewardWithMap.ContainsKey(mappingValueWithQualityAndType); + if (flag2) + { + this._guildTaskRewardWithMap.Add(mappingValueWithQualityAndType, new List()); + for (int j = 0; j < rowData.taskreward.Count; j++) + { + this._guildTaskRewardWithMap[mappingValueWithQualityAndType].Add(new GuildTaskReward + { + itemID = rowData.taskreward[j, 0], + count = rowData.taskreward[j, 1] + }); + } + } + bool flag3 = rowData.category == 2u && rowData.tasktype == 2u; + if (flag3) + { + bool flag4 = !this._chestValueList.Contains(rowData.taskquality); + if (flag4) + { + this._chestValueList.Add(rowData.taskquality); + } + } + } + } + this._chestValueList.Sort(); + } + + public List GetSingleTaskRewardInfoByID(GuildTaskType type, uint taskID) + { + DailyTask.RowData dailyTaskTableInfoByID = XGuildDailyTaskDocument.Doc.GetDailyTaskTableInfoByID(taskID); + bool flag = dailyTaskTableInfoByID != null; + if (flag) + { + uint mappingValueWithQualityAndType = XGuildDailyTaskDocument.GetMappingValueWithQualityAndType(type, 1u, dailyTaskTableInfoByID.taskquality); + List result = new List(); + bool flag2 = this._guildTaskRewardWithMap.TryGetValue(mappingValueWithQualityAndType, out result); + if (flag2) + { + return result; + } + } + return new List(); + } + + public List GetTotalTaskRewardInfo(GuildTaskType type, uint count) + { + uint mappingValueWithQualityAndType = XGuildDailyTaskDocument.GetMappingValueWithQualityAndType(type, 2u, count); + List list = new List(); + bool flag = this._guildTaskRewardWithMap.TryGetValue(mappingValueWithQualityAndType, out list); + List result; + if (flag) + { + result = list; + } + else + { + result = new List(); + } + return result; + } + + public void SendCommitWeeklyItem(uint index, List items) + { + RpcC2G_TurnOverWeeklyTaskItem rpcC2G_TurnOverWeeklyTaskItem = new RpcC2G_TurnOverWeeklyTaskItem(); + rpcC2G_TurnOverWeeklyTaskItem.oArg.index = index; + rpcC2G_TurnOverWeeklyTaskItem.oArg.itemuid.Clear(); + rpcC2G_TurnOverWeeklyTaskItem.oArg.itemuid.AddRange(items); + XSingleton.singleton.Send(rpcC2G_TurnOverWeeklyTaskItem); + } + + public void OnTurnOverWeeklyTaskReply(TurnOverWeeklyTaskItemArg oArg, TurnOverWeeklyTaskItemRes oRes) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("weeklyCommitSuccess"), "fece00"); + bool flag = (ulong)oArg.index < (ulong)((long)this._curGuildWeeklyTaskList.Count); + if (flag) + { + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag2 = oArg.index == this._curGuildWeeklyTaskList[i].originIndex; + if (flag2) + { + GuildWeeklyTaskInfo guildWeeklyTaskInfo = this._curGuildWeeklyTaskList[i]; + guildWeeklyTaskInfo.step += (uint)oArg.itemuid.Count; + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.RefreshTaskList(false); + } + break; + } + } + } + } + + public void SendToRefreshTaskList(uint taskIndex) + { + RpcC2G_RefreshWeeklyTask rpcC2G_RefreshWeeklyTask = new RpcC2G_RefreshWeeklyTask(); + rpcC2G_RefreshWeeklyTask.oArg.index = taskIndex; + XSingleton.singleton.Send(rpcC2G_RefreshWeeklyTask); + } + + internal void OnRefreshTaskList(RefreshWeeklyTaskArg oArg, RefreshWeeklyTaskRes oRes) + { + bool flag = this._remainedFreshTimes > 0u; + if (flag) + { + this._remainedFreshTimes -= 1u; + } + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag2 = this._curGuildWeeklyTaskList[i].originIndex == oArg.index; + if (flag2) + { + WeeklyTaskInfo task = oRes.task; + this.CurGuildWeeklyTaskList[i] = new GuildWeeklyTaskInfo + { + taskID = task.id, + step = task.step, + isRewarded = task.is_rewarded, + hasAsked = task.ask_help, + refreshedCount = task.refresh_count, + originIndex = task.index + }; + break; + } + } + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.RefreshTaskList(false); + DlgBase.singleton.PlayRefreshEffect(); + } + } + + public int GetTaskOriginalIndexByID(uint curSelectTaskID) + { + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag = this._curGuildWeeklyTaskList[i].taskID == curSelectTaskID; + if (flag) + { + return (int)this._curGuildWeeklyTaskList[i].originIndex; + } + } + return -1; + } + + public GuildWeeklyTaskInfo GetTaskInfoByTaskID(uint curSelectTaskID) + { + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag = this._curGuildWeeklyTaskList[i].taskID == curSelectTaskID; + if (flag) + { + return this._curGuildWeeklyTaskList[i]; + } + } + return null; + } + + public GuildWeeklyTaskInfo GetTaskInfoByIndex(uint curSelectIndex) + { + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool flag = this._curGuildWeeklyTaskList[i].originIndex == curSelectIndex; + if (flag) + { + return this._curGuildWeeklyTaskList[i]; + } + } + return null; + } + + public int GetRewardedTaskCount() + { + int num = 0; + for (int i = 0; i < this._curGuildWeeklyTaskList.Count; i++) + { + bool isRewarded = this._curGuildWeeklyTaskList[i].isRewarded; + if (isRewarded) + { + num++; + } + } + return num; + } + + public void OnGetWeeklyHelpReply(DailyTaskAskHelpArg oArg, DailyTaskAskHelpRes oRes) + { + bool flag = oRes.code == ErrorCode.ERR_SUCCESS; + if (flag) + { + DailyTask.RowData dailyTaskTableInfoByID = XGuildDailyTaskDocument.Doc.GetDailyTaskTableInfoByID(oArg.task_id); + GuildWeeklyTaskInfo taskInfoByTaskID = this.GetTaskInfoByTaskID(oArg.task_id); + bool flag2 = taskInfoByTaskID != null && dailyTaskTableInfoByID != null; + if (flag2) + { + bool flag3 = dailyTaskTableInfoByID.tasktype == 4u; + if (flag3) + { + XGuildDailyTaskDocument.Doc.SendGuildDonateReq(dailyTaskTableInfoByID.conditionNum - taskInfoByTaskID.step, dailyTaskTableInfoByID.BQ[0, 0], oRes.ask_uid, NoticeType.NT_GUILD_Weekly_DONATE_REQ); + } + else + { + XGuildDailyTaskDocument.Doc.SendGuildDonateReq(dailyTaskTableInfoByID.conditionNum - taskInfoByTaskID.step, dailyTaskTableInfoByID.conditionId[0], oRes.ask_uid, NoticeType.NT_GUILD_Weekly_DONATE_REQ); + } + taskInfoByTaskID.hasAsked = true; + this._weeklyAskedHelpNum += 1u; + bool flag4 = DlgBase.singleton.IsVisible(); + if (flag4) + { + DlgBase.singleton.RefreshTaskItem(); + } + } + } + else + { + XSingleton.singleton.ShowSystemTip(oRes.code, "fece00"); + } + } + + public bool GoToTakeTask() + { + XTaskDocument specificDocument = XDocuments.GetSpecificDocument(XTaskDocument.uuID); + XTaskRecord taskRecord = specificDocument.TaskRecord; + for (int i = 0; i < taskRecord.Tasks.Count; i++) + { + bool flag = taskRecord.Tasks[i].Status == TaskStatus.TaskStatus_CanTake && taskRecord.Tasks[i].TableData.TaskType == 7u; + if (flag) + { + return true; + } + } + return false; + } + } +} -- cgit v1.1-26-g67d0