using System; using System.Collections.Generic; using KKSG; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUpdater; using XUtliPoolLib; namespace XMainClient { internal class XLevelFinishMgr : XSingleton { public bool NeedUpdate { get; set; } public uint LastFinishScene { get; set; } public string LevelRewardToken { get; set; } public bool HaveBattleResultData { get; set; } public bool IsCurrentLevelFinished { get; set; } public bool IsCurrentLevelWin { get; set; } public bool NeedCheckLevelfinishScript { get; set; } public bool WaitingLevelContinueSelect { get; set; } public bool IsFastLevelFinish { get; set; } public bool IsReturnClicked { get; set; } public int KeyNpcID { get; set; } private uint _current_scene_id; private List _WinCondition = new List(); private List _LoseCondition = new List(); public override bool Init() { return true; } public override void Uninit() { } public void OnSceneLoaded(uint sceneID) { this._current_scene_id = sceneID; this.NeedUpdate = false; this.HaveBattleResultData = false; this.IsCurrentLevelFinished = false; this.IsCurrentLevelWin = false; this.NeedCheckLevelfinishScript = false; this.WaitingLevelContinueSelect = false; this.IsFastLevelFinish = (sceneID == 100u || sceneID == 25u); this.IsReturnClicked = false; this.KeyNpcID = 0; XLevelRewardDocument specificDocument = XDocuments.GetSpecificDocument(XLevelRewardDocument.uuID); specificDocument.RequestServer = false; this._WinCondition.Clear(); this._LoseCondition.Clear(); SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(sceneID); bool flag = sceneData != null; if (flag) { for (int i = 0; i < sceneData.WinCondition.Count; i++) { XLevelWin item = default(XLevelWin); item.cond = (XLevelWinCondition)sceneData.WinCondition[i, 0]; item.param = sceneData.WinCondition[i, 1]; this._WinCondition.Add(item); } for (int j = 0; j < sceneData.LoseCondition.Count; j++) { XLevelLose xlevelLose = default(XLevelLose); xlevelLose.cond = (XLevelLoseCondtion)sceneData.LoseCondition[j, 0]; xlevelLose.param = sceneData.LoseCondition[j, 1]; this._LoseCondition.Add(xlevelLose); bool flag2 = xlevelLose.cond == XLevelLoseCondtion.LevelLose_NpcDie; if (flag2) { this.KeyNpcID = sceneData.LoseCondition[j, 1]; } } } } public void OnLeaveScene() { this.NeedUpdate = false; this.NeedCheckLevelfinishScript = false; this.IsFastLevelFinish = false; } public void CanLevelFinished(XLevelState ls) { bool isCurrentLevelFinished = this.IsCurrentLevelFinished; if (!isCurrentLevelFinished) { bool needCheckLevelfinishScript = this.NeedCheckLevelfinishScript; if (!needCheckLevelfinishScript) { bool waitingLevelContinueSelect = this.WaitingLevelContinueSelect; if (!waitingLevelContinueSelect) { bool flag = false; bool flag2 = false; bool bKillOpponent = true; bool flag3 = false; for (int i = 0; i < this._WinCondition.Count; i++) { switch (this._WinCondition[i].cond) { case XLevelWinCondition.LevelWin_Boss: { bool flag4 = ls._boss_total > 0 && ls._boss_total == ls._boss_kill; if (flag4) { flag = true; flag2 = XSingleton.singleton.ExecuteWaveExtraScript(ls._BossWave); } break; } case XLevelWinCondition.LevelWin_Killall: { bool flag5 = ls._total_monster > 0 && ls._total_monster == ls._total_kill; if (flag5) { flag = true; bool flag6 = ls._BossWave > 0; if (flag6) { flag2 = XSingleton.singleton.ExecuteWaveExtraScript(ls._BossWave); } } break; } case XLevelWinCondition.LevelWin_Kill_N: { bool flag7 = ls._total_kill >= this._WinCondition[i].param; if (flag7) { flag = true; } break; } case XLevelWinCondition.LevelWin_Time: { float time = Time.time; bool flag8 = time - ls._start_time > (float)this._WinCondition[i].param; if (flag8) { flag = true; } break; } case XLevelWinCondition.LevelWin_PVP: { bool flag9 = ls._total_kill == this._WinCondition[i].param; if (flag9) { flag = true; } break; } case XLevelWinCondition.LevelWin_BossRush: { float time2 = Time.time; uint num = uint.Parse(XSingleton.singleton.GetValue("BossRushTime")); bool flag10 = this.IsReturnClicked || ls._refuseRevive || time2 - ls._start_time > num || (ls._boss_kill > 0 && DlgBase.singleton.isWin); if (flag10) { XBossBushDocument specificDocument = XDocuments.GetSpecificDocument(XBossBushDocument.uuID); bool flag11 = ls._boss_kill > 0 || specificDocument.respData.currank > 1; if (flag11) { flag = true; bKillOpponent = false; } else { flag3 = true; bKillOpponent = false; } bool flag12 = XSingleton.singleton.Boss != null; if (flag12) { XSingleton.singleton.Puppets(XSingleton.singleton.Boss, true, false); } } break; } } bool flag13 = flag || flag3; if (flag13) { break; } } bool flag14 = flag; if (flag14) { this.StopPlayerAllysAI(); bool flag15 = !flag2; if (flag15) { this.OnLevelFinish(ls._lastDieEntityPos + new Vector3(0f, ls._lastDieEntityHeight, 0f) / 2f, ls._lastDieEntityPos, 500u, 0u, bKillOpponent); this.IsCurrentLevelFinished = true; this.IsCurrentLevelWin = true; return; } this.KillAllOpponent(); this.NeedCheckLevelfinishScript = true; } bool flag16 = flag3; if (flag16) { this.OnLevelFailed(); this.IsCurrentLevelFinished = true; this.IsCurrentLevelWin = false; } else { for (int j = 0; j < this._LoseCondition.Count; j++) { switch (this._LoseCondition[j].cond) { case XLevelLoseCondtion.LevelLose_PlayerDie: { bool flag17 = ls._my_team_alive == 0u && ls._refuseRevive; if (flag17) { flag3 = true; } break; } case XLevelLoseCondtion.LevelTime_Out: { float time3 = Time.time; bool flag18 = time3 - ls._start_time > (float)this._LoseCondition[j].param; if (flag18) { flag3 = true; } break; } case XLevelLoseCondtion.LevelLose_NpcDie: { bool key_npc_die = ls._key_npc_die; if (key_npc_die) { flag3 = true; } break; } } bool flag19 = flag3; if (flag19) { break; } } bool flag20 = flag3; if (flag20) { this.OnLevelFailed(); this.IsCurrentLevelFinished = true; this.IsCurrentLevelWin = false; } } } } } } public void ForceLevelFinish(bool win) { this.IsCurrentLevelFinished = true; if (win) { XLevelState ls = XSingleton.singleton.ls; this.IsCurrentLevelWin = true; this.OnLevelFinish(ls._lastDieEntityPos + new Vector3(0f, ls._lastDieEntityHeight, 0f) / 2f, ls._lastDieEntityPos, 500u, 0u, true); } else { this.OnLevelFailed(); } } public void OnLevelFailed() { XSingleton.singleton.SetLastFailSceneID(this._current_scene_id); this.LastFinishScene = 0u; this.IsCurrentLevelWin = false; bool flag = DlgBase.singleton.IsLoaded(); if (flag) { DlgBase.singleton.SkillHandler.ResetPressState(); DlgBase.singleton.SetVisiblePure(false); } bool flag2 = DlgBase.singleton.IsLoaded(); if (flag2) { DlgBase.singleton.SetVisiblePure(false); } bool flag3 = DlgBase.singleton.IsLoaded(); if (flag3) { DlgBase.singleton.SetVisiblePure(false); } XSingleton.singleton.MakeEffectEnable(XPostEffect.BlackWhite, true); XLevelRewardDocument specificDocument = XDocuments.GetSpecificDocument(XLevelRewardDocument.uuID); specificDocument.ShowStageFailUI(null); XFPStrengthenDocument specificDocument2 = XDocuments.GetSpecificDocument(XFPStrengthenDocument.uuID); specificDocument2.TryShowBrief(); XSingleton.singleton.bStopBlockRedPoint = true; } public void OnLevelFinish(Vector3 dropInitPos, Vector3 dropGounrdPos, uint money, uint itemCount, bool bKillOpponent) { bool flag = DlgBase.singleton.IsLoaded(); if (flag) { DlgBase.singleton.SetVisiblePure(false); } if (bKillOpponent) { this.KillAllOpponent(); } SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this._current_scene_id); List ally = XSingleton.singleton.GetAlly(XSingleton.singleton.Player); for (int i = 0; i < ally.Count; i++) { XAIEnableAI @event = XEventPool.GetEvent(); @event.Firer = ally[i]; @event.Enable = false; XSingleton.singleton.FireEvent(@event); } bool flag2 = string.IsNullOrEmpty(sceneData.EndCutScene); if (flag2) { XSingleton.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.SendBattleReport), null); } else { XSingleton.singleton.SetTimer(sceneData.EndCutSceneTime, new XTimerMgr.ElapsedEventHandler(this.PlayCutScene), sceneData.EndCutScene); } } private void PlayCutScene(object o) { string str = (string)o; this.NeedUpdate = true; XSingleton.singleton.Start("CutScene/" + str, true, true); } public void KillAllOpponent() { XSingleton.singleton.OnBeforeKillMonster(); List opponent = XSingleton.singleton.GetOpponent(XSingleton.singleton.Player); for (int i = 0; i < opponent.Count; i++) { bool flag = !XEntity.ValideEntity(opponent[i]) || opponent[i].IsPuppet; if (!flag) { XSingleton.singleton.ls._after_force_kill++; opponent[i].Attributes.ForceDeath(); } } } public void StopPlayerAllysAI() { XAIStopEventArgs @event = XEventPool.GetEvent(); @event.Firer = XSingleton.singleton.Player; XSingleton.singleton.FireEvent(@event); List ally = XSingleton.singleton.GetAlly(XSingleton.singleton.Player); for (int i = 0; i < ally.Count; i++) { XAIStopEventArgs event2 = XEventPool.GetEvent(); event2.Firer = ally[i]; XSingleton.singleton.FireEvent(event2); } } protected void ForceReturnHall(object o) { XSingleton.singleton.ReqLeaveScene(); } public void Update(float deltaT) { bool needCheckLevelfinishScript = this.NeedCheckLevelfinishScript; if (needCheckLevelfinishScript) { bool flag = !XSingleton.singleton.BossExtarScriptExecuting; if (flag) { this.NeedCheckLevelfinishScript = false; this.ForceLevelFinish(true); } } bool flag2 = !this.NeedUpdate; if (!flag2) { bool isPlaying = XSingleton.singleton.IsPlaying; if (!isPlaying) { this.NeedUpdate = false; bool syncMode = XSingleton.singleton.SyncMode; if (syncMode) { this.ShowLevelFinishUI(); } else { this.SendBattleReport(null); } } } } public void SendBattleReport(object o) { this.LastFinishScene = this._current_scene_id; XLevelState ls = XSingleton.singleton.ls; XAttributes attributes = XSingleton.singleton.Player.Attributes; RpcC2G_ReportBattle rpcC2G_ReportBattle = new RpcC2G_ReportBattle(); rpcC2G_ReportBattle.oArg.battledata = new BattleData(); rpcC2G_ReportBattle.oArg.battledata.timespan = (int)(ls._end_time - ls._start_time); double attr = XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic); double attr2 = XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total); rpcC2G_ReportBattle.oArg.battledata.hppercent = (uint)(attr * 100.0 / attr2); rpcC2G_ReportBattle.oArg.battledata.Combo = (int)XSingleton.singleton.ls._max_combo; rpcC2G_ReportBattle.oArg.battledata.BeHit = (int)XSingleton.singleton.ls._player_behit; rpcC2G_ReportBattle.oArg.battledata.found = XSingleton.singleton.ls._enemy_in_fight; for (int i = 0; i < XLevelRewardDocument.Table.Table.Length; i++) { StageRankTable.RowData rowData = XLevelRewardDocument.Table.Table[i]; bool flag = rowData.scendid != this._current_scene_id; if (!flag) { bool flag2 = false; uint num = 0u; bool flag3 = rowData.star2[0] == 5u; if (flag3) { flag2 = true; num = rowData.star2[1]; } bool flag4 = rowData.star3[0] == 5u; if (flag4) { flag2 = true; num = rowData.star3[1]; } bool flag5 = !flag2; if (!flag5) { List all = XSingleton.singleton.GetAll(); for (int j = 0; j < all.Count; j++) { XEntity xentity = all[j]; bool flag6 = !xentity.IsRole && xentity.TypeID == num; if (flag6) { rpcC2G_ReportBattle.oArg.battledata.npchp = (uint)(xentity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic) * 100.0 / xentity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total)); break; } } break; } } } XTaskDocument specificDocument = XDocuments.GetSpecificDocument(XTaskDocument.uuID); foreach (KeyValuePair keyValuePair in specificDocument.TaskMonstersKilled) { bool flag7 = keyValuePair.Value == 0u; if (!flag7) { rpcC2G_ReportBattle.oArg.battledata.monster_id.Add(keyValuePair.Key); rpcC2G_ReportBattle.oArg.battledata.monster_num.Add(keyValuePair.Value); } } List list = new List(ls._entity_die.Keys); for (int k = 0; k < list.Count; k++) { rpcC2G_ReportBattle.oArg.battledata.smallmonster.Add((uint)list[k]); rpcC2G_ReportBattle.oArg.battledata.smallmonster.Add((uint)ls._entity_die[list[k]]); } bool flag8 = XSingleton.singleton.SceneType == SceneType.SCENE_BOSSRUSH; if (flag8) { rpcC2G_ReportBattle.oArg.battledata.bossrush.Add(DlgBase.singleton.killAllMonster); } rpcC2G_ReportBattle.oArg.battledata.OpenChest = ls._box_enemy_kill; XSingleton.singleton.PickAllDoodad(); XSingleton.singleton.ReportServerList(rpcC2G_ReportBattle.oArg.battledata.pickDoodadWaveID); XLevelRewardDocument specificDocument2 = XDocuments.GetSpecificDocument(XLevelRewardDocument.uuID); specificDocument2.LevelFinishTime = rpcC2G_ReportBattle.oArg.battledata.timespan; specificDocument2.LevelFinishHp = rpcC2G_ReportBattle.oArg.battledata.hppercent; specificDocument2.RequestServer = true; rpcC2G_ReportBattle.oArg.battledata.anticheatInfo = new CliAntiCheatInfo(); rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.battleStamp = this.LevelRewardToken; rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.totalDamage = (uint)XSingleton.singleton.ls._total_damage; rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.totalHurt = (uint)XSingleton.singleton.ls._total_hurt; rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.totalRecovery = (uint)XSingleton.singleton.ls._total_heal; rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.currentHp = (uint)XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic); for (int l = 0; l < XSingleton.singleton.ls._monster_refresh_time.Count; l++) { rpcC2G_ReportBattle.oArg.battledata.anticheatInfo.monsterRfsTimes.Add(XSingleton.singleton.ls._monster_refresh_time[l]); } XSingleton.singleton.Send(rpcC2G_ReportBattle); } public void SendLevelFailData() { bool syncMode = XSingleton.singleton.SyncMode; if (!syncMode) { RpcC2G_ReportBattle rpcC2G_ReportBattle = new RpcC2G_ReportBattle(); rpcC2G_ReportBattle.oArg.battledata = new BattleData(); rpcC2G_ReportBattle.oArg.battledata.isfailed = true; rpcC2G_ReportBattle.oArg.battledata.failedinfo = new BattleFailedData(); rpcC2G_ReportBattle.oArg.battledata.failedinfo.timespan = (uint)(Time.time - XSingleton.singleton.ls._start_time); rpcC2G_ReportBattle.oArg.battledata.failedinfo.deathcount = XSingleton.singleton.ls._death_count; double attr = XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic); double attr2 = XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total); rpcC2G_ReportBattle.oArg.battledata.failedinfo.hppercent = (uint)(attr * 100.0 / attr2); XSingleton.singleton.Send(rpcC2G_ReportBattle); } } public static void PlayVictory() { XPlayer player = XSingleton.singleton.Player; bool isMounted = player.IsMounted; if (!isMounted) { player.Net.ReportSkillAction(null, player.SkillMgr.GetDisappearIdentity(), -1); XSingleton.singleton.GameCamera.TargetOffset = 7f; XComponent xcomponent = XSingleton.singleton.GameCamera.GetXComponent(XCameraVAdjustComponent.uuID); bool flag = xcomponent != null; if (flag) { xcomponent.Enabled = false; } } } public void StartLevelFinish() { XAIEnableAI @event = XEventPool.GetEvent(); @event.Firer = XSingleton.singleton.Player; @event.Enable = false; XSingleton.singleton.FireEvent(@event); bool isFastLevelFinish = this.IsFastLevelFinish; if (isFastLevelFinish) { this.ForceReturnHall(null); } else { SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this._current_scene_id); bool flag = !string.IsNullOrEmpty(sceneData.EndCutScene) && XSingleton.singleton.SyncMode; if (flag) { XSingleton.singleton.SetTimer(sceneData.EndCutSceneTime, new XTimerMgr.ElapsedEventHandler(this.PlayCutScene), sceneData.EndCutScene); } else { this.ShowLevelFinishUI(); } } } private void ShowLevelFinishUI() { this.IsCurrentLevelFinished = true; XSingleton.singleton.Pause = false; bool flag = DlgBase.singleton.IsLoaded(); if (flag) { DlgBase.singleton.SkillHandler.ResetPressState(); DlgBase.singleton.SetVisiblePure(false); DlgBase.singleton.Show(false); DlgBase.singleton.SetFakeHide(true); } bool flag2 = DlgBase.singleton.IsLoaded(); if (flag2) { DlgBase.singleton.SetVisiblePure(false); DlgBase.singleton.Show(false); DlgBase.singleton.SetFakeHide(false); } bool flag3 = DlgBase.singleton.IsLoaded(); if (flag3) { DlgBase.singleton.SetVisiblePure(false); } bool flag4 = DlgBase.singleton.IsLoaded(); if (flag4) { DlgBase.singleton.SetVisible(false, true); } XLevelRewardDocument specificDocument = XDocuments.GetSpecificDocument(XLevelRewardDocument.uuID); specificDocument.ShowBattleResultFrame(); } } }