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/XLevelStatistics.cs | 338 +++++++++++++++++++++ 1 file changed, 338 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XLevelStatistics.cs (limited to 'Client/Assets/Scripts/XMainClient/XLevelStatistics.cs') diff --git a/Client/Assets/Scripts/XMainClient/XLevelStatistics.cs b/Client/Assets/Scripts/XMainClient/XLevelStatistics.cs new file mode 100644 index 00000000..2a9434d1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XLevelStatistics.cs @@ -0,0 +1,338 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XLevelStatistics : XSingleton + { + public uint ComboCount + { + get + { + return this._comboCount; + } + set + { + this._comboCount = value; + } + } + + public XLevelState ls = new XLevelState(); + + public static readonly int BOX_ENEMY_ID = 5011; + + private uint _comboCount; + + private float _lastHitTime; + + private float _combo_interval = 2f; + + public void Clear() + { + this._comboCount = 0u; + this._lastHitTime = 0f; + } + + public void OnEnterScene(uint sceneID) + { + this.ls.Reset(); + this.ls._current_scene_id = sceneID; + this.ls._start_time = Time.time; + XSingleton.singleton.GetMonsterCount(XSingleton.singleton.CurrentSpawner, ref this.ls._total_monster, ref this.ls._boss_total); + this._combo_interval = float.Parse(XSingleton.singleton.GetValue("ComboInterval")); + } + + public void OnLeaveScene() + { + } + + public void OnMonsterDie(XEntity entity) + { + Vector3 lastDieEntityPos = entity.EngineObject.Position + new Vector3(0f, entity.Height / 2f, 0f); + bool flag = entity.IsOpposer || entity.IsBoss || entity.IsRole; + if (flag) + { + bool flag2 = XSingleton.singleton.IsOpponent(entity, XSingleton.singleton.Player); + if (flag2) + { + bool flag3 = entity.Wave >= 0 && this.ls.CheckEntityInLevelSpawn(entity.ID); + if (flag3) + { + this.ls._total_kill++; + bool flag4 = entity.CreateTime > 0f; + if (flag4) + { + this.ls._monster_exist_time += (int)(Time.realtimeSinceStartup - entity.CreateTime); + } + bool isBoss = entity.IsBoss; + if (isBoss) + { + this.ls._boss_kill++; + this.ls._BossWave = entity.Wave; + bool flag5 = entity.CreateTime > 0f; + if (flag5) + { + this.ls._boss_exist_time += (int)(Time.realtimeSinceStartup - entity.CreateTime); + } + } + Dictionary entity_in_level_spawn = this.ls._entity_in_level_spawn; + ulong id = entity.ID; + entity_in_level_spawn[id]--; + bool flag6 = (XSingleton.singleton.Player.EngineObject.Position - entity.EngineObject.Position).sqrMagnitude > 2500f; + if (flag6) + { + this.ls._abnormal_monster++; + } + } + this.ls.AddEntityDieCount((ulong)entity.TypeID); + bool flag7 = this.ls._boss_kill <= this.ls._boss_total; + if (flag7) + { + this.ls._lastDieEntityPos = lastDieEntityPos; + this.ls._lastDieEntityHeight = entity.Height; + } + } + } + bool isBoss2 = entity.IsBoss; + if (isBoss2) + { + this.ls._boss_rush_kill++; + } + bool flag8 = DlgBase.singleton.IsLoaded(); + if (flag8) + { + DlgBase.singleton.IndicateHandler.OnMonsterDie(entity); + } + bool flag9 = DlgBase.singleton.IsLoaded(); + if (flag9) + { + DlgBase.singleton.IndicateHandler.OnMonsterDie(entity); + } + bool isPlayer = entity.IsPlayer; + if (isPlayer) + { + this.ls._my_team_alive -= 1u; + this.OnPlayerDie(); + } + bool flag10 = (ulong)entity.TypeID == (ulong)((long)XLevelStatistics.BOX_ENEMY_ID); + if (flag10) + { + this.ls._box_enemy_kill++; + } + bool flag11 = (ulong)entity.TypeID == (ulong)((long)XSingleton.singleton.KeyNpcID); + if (flag11) + { + this.ls._key_npc_die = true; + } + XSingleton.singleton.OnMonsterDie(entity); + } + + public void OnPlayerDie() + { + this.ls._death_count += 1u; + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this.ls._current_scene_id); + XSingleton.singleton.MakeEffectEnable(XPostEffect.BlackWhite, true); + bool flag = sceneData.type == 7 || sceneData.type == 11; + if (!flag) + { + XReviveDocument specificDocument = XDocuments.GetSpecificDocument(XReviveDocument.uuID); + bool flag2 = !sceneData.CanRevive || (specificDocument.ReviveUsedTime >= specificDocument.ReviveMaxTime && !XSingleton.singleton.SyncMode); + if (flag2) + { + this.ls._refuseRevive = true; + } + else + { + bool flag3 = DlgBase.singleton.IsLoaded(); + if (flag3) + { + DlgBase.singleton.SkillHandler.SetVisible(false); + } + specificDocument.StartRevive(); + } + } + } + + public void OnPlayerRevive() + { + this.ls._revive_count += 1u; + this.ls._my_team_alive += 1u; + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this.ls._current_scene_id); + XSingleton.singleton.MakeEffectEnable(XPostEffect.BlackWhite, false); + bool flag = sceneData.type == 7 || sceneData.type == 11; + if (flag) + { + bool flag2 = DlgBase.singleton.IsLoaded(); + if (flag2) + { + DlgBase.singleton.OnPlayerRevive(); + } + } + else + { + bool flag3 = DlgBase.singleton.IsLoaded(); + if (flag3) + { + DlgBase.singleton.SetVisible(false, true); + } + bool flag4 = DlgBase.singleton.IsLoaded(); + if (flag4) + { + DlgBase.singleton.SkillHandler.SetVisible(true); + } + XPlayerAttributes xplayerAttributes = XSingleton.singleton.Player.Attributes as XPlayerAttributes; + xplayerAttributes.HPMPReset(); + XSingleton.singleton.CreateAndPlay(XSingleton.singleton.GetValue("ReviveFx"), XSingleton.singleton.Player.EngineObject, Vector3.zero, Vector3.one, 1f, true, 5f, true); + } + } + + public void OnPlayerRefuseRevive() + { + this.ls._refuseRevive = true; + } + + public void OnHitEnemy(int comboCount = -1) + { + float realtimeSinceStartup = Time.realtimeSinceStartup; + this._lastHitTime = realtimeSinceStartup; + bool flag = comboCount < 0; + if (flag) + { + this._comboCount += 1u; + } + else + { + this._comboCount = (uint)comboCount; + } + bool flag2 = this._comboCount > this.ls._max_combo; + if (flag2) + { + this.ls._max_combo = this._comboCount; + } + bool flag3 = DlgBase.singleton.IsLoaded(); + if (flag3) + { + DlgBase.singleton.OnComboChange(this._comboCount); + } + this._SendComboCountEvent(); + } + + public void OnEnemyHitEnemy(XEntity entity) + { + bool flag = entity == null || entity.Attributes == null || entity.Attributes.HostID != XSingleton.singleton.XPlayerData.RoleID; + if (!flag) + { + XOthersAttributes xothersAttributes = entity.Attributes as XOthersAttributes; + bool flag2 = xothersAttributes != null && xothersAttributes.LinkCombo == 1; + if (flag2) + { + this.OnHitEnemy(-1); + } + } + } + + public void OnPlayerBeHit() + { + this.ls._player_behit += 1u; + } + + public void OnAIinFight(XEntity entity) + { + bool isEnemy = entity.IsEnemy; + if (isEnemy) + { + this.ls._enemy_in_fight += 1u; + } + } + + public void SetPlayerContineIndex(int index) + { + this.ls._player_continue_index = index; + this.ls._start_time = Time.time; + XSingleton.singleton.SetExternalString("playercontinue" + this.ls._player_continue_index.ToString(), false); + } + + public void AddPlayerContinueIndex() + { + this.ls._player_continue_index++; + this.ls._start_time = Time.time; + XSingleton.singleton.SetExternalString("playercontinue" + this.ls._player_continue_index.ToString(), false); + } + + public void Update() + { + float realtimeSinceStartup = Time.realtimeSinceStartup; + bool flag = realtimeSinceStartup - this._lastHitTime > this._combo_interval; + if (flag) + { + bool flag2 = this._comboCount > 0u; + if (flag2) + { + this._comboCount = 0u; + this._SendComboCountEvent(); + } + bool flag3 = DlgBase.singleton.IsLoaded(); + if (flag3) + { + DlgBase.singleton.OnComboChange(this._comboCount); + } + } + bool flag4 = !XSingleton.singleton.SyncMode; + if (flag4) + { + XSingleton.singleton.CanLevelFinished(this.ls); + bool isCurrentLevelFinished = XSingleton.singleton.IsCurrentLevelFinished; + if (isCurrentLevelFinished) + { + bool flag5 = this.ls._end_time <= 0f; + if (flag5) + { + this.ls._end_time = Time.time; + } + } + } + } + + public void OnSetBattleResult() + { + this.ls._remain_monster = XSingleton.singleton.GetOpponent(XSingleton.singleton.Player).Count; + } + + public void OnBeforeKillMonster() + { + this.ls._before_force_kill = this.ls._total_kill; + } + + private void _SendComboCountEvent() + { + bool flag = XSingleton.singleton.SyncMode || XSingleton.singleton.Player == null; + if (!flag) + { + XOnComboChangeEventArgs @event = XEventPool.GetEvent(); + @event.ComboCount = this._comboCount; + @event.Firer = XSingleton.singleton.Player; + XSingleton.singleton.FireEvent(@event); + } + } + + public void SendData() + { + XStaticSecurityStatistics.Append("PlayerDeadCount", this.ls._death_count); + XStaticSecurityStatistics.Append("PlayerReliveCount", this.ls._revive_count); + XStaticSecurityStatistics.Append("MonsterCount", (float)(this.ls._total_monster + XStaticSecurityStatistics._MonsterAIInfo._BossCallMonsterTotal)); + XStaticSecurityStatistics.Append("MonsterEndCount", (float)this.ls._remain_monster); + XStaticSecurityStatistics.Append("MonsterCount1", (float)this.ls._before_force_kill); + XStaticSecurityStatistics.Append("MonsterCount2", (float)this.ls._after_force_kill); + XStaticSecurityStatistics.Append("MonsterCount3", (float)this.ls._abnormal_monster); + XStaticSecurityStatistics.Append("BossCount", (float)this.ls._boss_total); + XStaticSecurityStatistics.Append("BossKillCount", (float)this.ls._boss_kill); + XStaticSecurityStatistics.Append("BossTimeTotal", (float)this.ls._boss_exist_time); + XStaticSecurityStatistics.Append("MonsterTimeTotal", (float)this.ls._monster_exist_time); + XStaticSecurityStatistics.Append("RoundTimeUse", (this.ls._end_time > this.ls._start_time) ? ((this.ls._end_time - this.ls._start_time) * 1000f) : 0f); + } + } +} -- cgit v1.1-26-g67d0