From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XLevelDocument.cs | 493 +++++++++++++++++++++ 1 file changed, 493 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XLevelDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XLevelDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XLevelDocument.cs b/Client/Assets/Scripts/XMainClient/XLevelDocument.cs new file mode 100644 index 00000000..b8b94c9c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XLevelDocument.cs @@ -0,0 +1,493 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.Battle; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XLevelDocument : XDocComponent + { + public override uint ID + { + get + { + return XLevelDocument.uuID; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XLevelDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static RandomTaskTable _randomtask = new RandomTaskTable(); + + public Dictionary SceneDayEnter = new Dictionary(); + + public Dictionary SceneBuyCount = new Dictionary(); + + public Dictionary> DropData = new Dictionary>(); + + public List SceneBox = new List(); + + private int _rtask = 0; + + private XTimerMgr.ElapsedEventHandler _showRandomTaskCb = null; + + private bool m_bIsResetSceneMesBack = true; + + private int m_reqSceneId = 0; + + public XLevelDocument() + { + this._showRandomTaskCb = new XTimerMgr.ElapsedEventHandler(this.ShowRandomTask); + } + + public static void Execute(OnLoadedCallback callback = null) + { + XLevelDocument.AsyncLoader.AddTask("Table/randomtask", XLevelDocument._randomtask, false); + XLevelDocument.AsyncLoader.Execute(callback); + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this.SceneDayEnter.Clear(); + for (int i = 0; i < XBagDocument.DropTable.Table.Length; i++) + { + int dropID = XBagDocument.DropTable.Table[i].DropID; + int itemID = XBagDocument.DropTable.Table[i].ItemID; + int itemCount = XBagDocument.DropTable.Table[i].ItemCount; + XDropData item = default(XDropData); + item.itemID = itemID; + item.count = itemCount; + bool flag = this.DropData.ContainsKey(dropID); + if (flag) + { + this.DropData[dropID].Add(item); + } + else + { + List value = new List(); + this.DropData.Add(dropID, value); + this.DropData[dropID].Add(item); + } + } + } + + public override void OnDetachFromHost() + { + base.OnDetachFromHost(); + } + + public void UpdateSceneDayTime(QuerySceneDayCountRes data) + { + for (int i = 0; i < data.sceneid.Count; i++) + { + bool flag = this.SceneDayEnter.ContainsKey(data.sceneid[i]); + if (flag) + { + this.SceneDayEnter[data.sceneid[i]] = data.scenecout[i]; + } + else + { + this.SceneDayEnter.Add(data.sceneid[i], data.scenecout[i]); + } + bool flag2 = this.SceneBuyCount.ContainsKey(data.sceneid[i]); + if (flag2) + { + this.SceneBuyCount[data.sceneid[i]] = data.scenebuycount[i]; + } + else + { + this.SceneBuyCount.Add(data.sceneid[i], data.scenebuycount[i]); + } + } + this.SceneBox.Clear(); + this.SceneBox.AddRange(data.chestOpenedScene); + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.UpdateSceneEnterTime(); + DlgBase.singleton.UpdateSceneBox(); + } + this.RefreshRedPoint(); + } + + public override void OnEnterSceneFinally() + { + base.OnEnterSceneFinally(); + bool flag = SceneType.SCENE_HALL == XSingleton.singleton.GetSceneType(XSingleton.singleton.SceneID); + if (flag) + { + RpcC2G_QuerySceneDayCount rpcC2G_QuerySceneDayCount = new RpcC2G_QuerySceneDayCount(); + List list = ListPool.Get(); + XSingleton.singleton.GetChapterList(XChapterType.SCENE_BATTLE, list); + for (int i = 0; i < list.Count; i++) + { + XChapter.RowData chapter = XSingleton.singleton.GetChapter(list[i]); + List list2 = ListPool.Get(); + XSingleton.singleton.GetSceneListByChapter(list[i], list2); + rpcC2G_QuerySceneDayCount.oArg.type = 1u; + for (int j = 0; j < list2.Count; j++) + { + rpcC2G_QuerySceneDayCount.oArg.groupid.Add(list2[j]); + } + ListPool.Release(list2); + } + ListPool.Release(list); + XSingleton.singleton.Send(rpcC2G_QuerySceneDayCount); + } + } + + public static string GetDifficulty(int _PlayerPPT, int _RecommendPower) + { + string[] array = XSingleton.singleton.GetValue("SceneDifficult").Split(XGlobalConfig.ListSeparator); + float num = (float)_PlayerPPT / (float)_RecommendPower; + float[] array2 = new float[] + { + float.Parse(array[0]), + float.Parse(array[1]), + float.Parse(array[2]) + }; + bool flag = num >= array2[0]; + string @string; + if (flag) + { + @string = XStringDefineProxy.GetString("EASY"); + } + else + { + bool flag2 = num >= array2[1] && num < array2[0]; + if (flag2) + { + @string = XStringDefineProxy.GetString("NORMAL"); + } + else + { + bool flag3 = num >= array2[2] && num < array2[1]; + if (flag3) + { + @string = XStringDefineProxy.GetString("HARD"); + } + else + { + @string = XStringDefineProxy.GetString("VERYHARD"); + } + } + } + return @string; + } + + public double GetExpAddition(int level) + { + PlayerLevelTable.RowData byLevel = XSingleton.singleton.LevelTable.GetByLevel(level); + bool flag = byLevel != null; + double result; + if (flag) + { + result = byLevel.ExpAddition; + } + else + { + result = 1.0; + } + return result; + } + + public void RefreshRedPoint() + { + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Level_Normal, false); + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Level_Elite, true); + } + + public void OnFetchSceneChestSucc(uint sceneID) + { + this.SceneBox.Add(sceneID); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.OnFetchSceneChestSucc(); + } + this.RefreshRedPoint(); + } + + public List GetDropData(int dropID) + { + bool flag = this.DropData.ContainsKey(dropID); + List result; + if (flag) + { + result = this.DropData[dropID]; + } + else + { + result = null; + } + return result; + } + + public void AutoGoBattle(int sceneid, int chapterid, uint diff) + { + DlgBase.singleton.SetVisible(false, true); + DlgBase.singleton.SetAutoSelectScene(sceneid, chapterid, diff); + DlgBase.singleton.FadeShow(); + } + + public void ResetScene(int sceneid) + { + this.m_reqSceneId = sceneid; + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData((uint)sceneid); + RpcC2G_StageCountReset rpcC2G_StageCountReset = new RpcC2G_StageCountReset(); + rpcC2G_StageCountReset.oArg.groupid = ((sceneData.DayLimitGroupID > 0u) ? sceneData.DayLimitGroupID : ((uint)sceneid)); + XSingleton.singleton.Send(rpcC2G_StageCountReset); + this.m_bIsResetSceneMesBack = false; + } + + public void OnResetSceneSucc(uint sceneid, StageCountResetRes oRes) + { + this.m_bIsResetSceneMesBack = true; + bool flag = oRes.errorcode == ErrorCode.ERR_INVALID_REQUEST; + if (flag) + { + string fullName = MethodBase.GetCurrentMethod().ReflectedType.FullName; + XSingleton.singleton.OnGetInvalidRequest(fullName); + } + else + { + bool flag2 = oRes.errorcode > ErrorCode.ERR_SUCCESS; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(oRes.errorcode, "fece00"); + } + else + { + bool flag3 = this.SceneDayEnter.ContainsKey(sceneid); + if (flag3) + { + this.SceneDayEnter[sceneid] = 0u; + } + bool flag4 = this.SceneBuyCount.ContainsKey(sceneid); + if (flag4) + { + Dictionary sceneBuyCount = this.SceneBuyCount; + sceneBuyCount[sceneid] += 1u; + } + bool flag5 = DlgBase.singleton.IsVisible(); + if (flag5) + { + DlgBase.singleton.OnResetSucc(); + } + } + } + } + + public bool HasChapterRedpoint(int chapterid) + { + XChapter.RowData chapter = XSingleton.singleton.GetChapter(chapterid); + List list = ListPool.Get(); + XSingleton.singleton.GetSceneListByChapter(chapterid, list); + int num = 0; + for (int i = 0; i < list.Count; i++) + { + uint num2 = list[i]; + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(list[i]); + int num3 = XSingleton.singleton.GetRank((int)num2); + bool flag = num3 == -1; + if (flag) + { + num3 = 0; + } + num += num3; + bool flag2 = sceneData.SceneChest != 0; + if (flag2) + { + bool flag3 = num3 > 0 && !this.SceneBox.Contains(num2); + if (flag3) + { + ListPool.Release(list); + return true; + } + } + } + ListPool.Release(list); + for (int j = 0; j < chapter.Drop.Count; j++) + { + int num4 = chapter.Drop[j, 0]; + bool flag4 = num >= num4; + if (flag4) + { + bool flag5 = !XSingleton.singleton.HasChapterBoxFetched(chapterid, j); + if (flag5) + { + return true; + } + } + } + return false; + } + + public bool HasDifficultAllChapterRedpoint(int difficult) + { + List list = ListPool.Get(); + XSingleton.singleton.GetChapterList(XChapterType.SCENE_BATTLE, list); + for (int i = 0; i < list.Count; i++) + { + XChapter.RowData chapter = XSingleton.singleton.GetChapter(list[i]); + bool flag = chapter.Difficult[1] == difficult; + if (flag) + { + bool flag2 = this.HasChapterRedpoint(list[i]); + bool flag3 = flag2; + if (flag3) + { + ListPool.Release(list); + return true; + } + } + } + ListPool.Release(list); + return false; + } + + public int GetUnFinishedPreSceneID(SceneTable.RowData data) + { + bool flag = data != null && data.PreScene != null; + if (flag) + { + for (int i = 0; i < data.PreScene.Length; i++) + { + bool flag2 = data.PreScene[i] != 0; + if (flag2) + { + int rank = XSingleton.singleton.GetRank(data.PreScene[i]); + bool flag3 = rank <= 0; + if (flag3) + { + return data.PreScene[i]; + } + } + } + } + return 0; + } + + public SceneRefuseReason CanLevelOpen(uint sceneID) + { + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(sceneID); + bool flag = sceneData == null; + SceneRefuseReason result; + if (flag) + { + result = SceneRefuseReason.Admit; + } + else + { + int preTask = (int)sceneData.PreTask; + bool flag2 = preTask != 0; + if (flag2) + { + XTaskDocument specificDocument = XDocuments.GetSpecificDocument(XTaskDocument.uuID); + bool flag3 = !specificDocument.TaskRecord.IsTaskFinished((uint)preTask); + if (flag3) + { + return SceneRefuseReason.PreTask_Notfinish; + } + } + int[] preScene = sceneData.PreScene; + bool flag4 = preScene != null && preScene.Length != 0; + if (flag4) + { + bool flag5 = this.GetUnFinishedPreSceneID(sceneData) > 0; + if (flag5) + { + return SceneRefuseReason.PreScene_Notfinish; + } + } + bool flag6 = (uint)sceneData.RequiredLevel > XSingleton.singleton.XPlayerData.Level; + if (flag6) + { + result = SceneRefuseReason.Level_NotEnough; + } + else + { + bool flag7 = 1 == XSingleton.singleton.GetSceneDifficult((int)sceneID); + if (flag7) + { + uint num = sceneData.DayLimitGroupID; + bool flag8 = num == 0u; + if (flag8) + { + num = sceneID; + } + uint num2 = 0u; + bool flag9 = this.SceneDayEnter.TryGetValue(num, out num2); + if (flag9) + { + bool flag10 = num2 == 0u; + if (flag10) + { + return SceneRefuseReason.ReachLimitTimes; + } + } + } + result = SceneRefuseReason.Admit; + } + } + return result; + } + + public void OnTaskRandomTask(int rtask) + { + XSingleton.singleton.SetTimer(1f, this._showRandomTaskCb, rtask); + } + + public override void PostUpdate(float fDeltaT) + { + base.PostUpdate(fDeltaT); + bool isPlaying = XSingleton.singleton.IsPlaying; + if (!isPlaying) + { + bool flag = this._rtask > 0; + if (flag) + { + DlgBase.singleton.ShowRandomTask(this._rtask); + this._rtask = 0; + } + } + } + + protected void ShowRandomTask(object o) + { + int rtask = (int)o; + this._rtask = rtask; + } + + public RandomTaskTable.RowData GetRandomTaskData(int rtask) + { + return XLevelDocument._randomtask.GetByTaskID(rtask); + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + bool flag = !this.m_bIsResetSceneMesBack; + if (flag) + { + this.ResetScene(this.m_reqSceneId); + } + } + + public BossRushTable.RowData GetBossRushConfig(uint sceneID, uint index) + { + return null; + } + + public uint GetBossRushReward(uint sceneID, int killcount) + { + return 0u; + } + } +} -- cgit v1.1-26-g67d0