protected override void StateChanged() { switch ((EntityState)prevState) { case EntityState.Lock: inputEnabled = true; InputManager input = Main.instance != null ? Main.instance.input : null; if (input) { input.AddButtonCall(0, InputAction.MenuEscape, OnInputPause); } mStats.isInvul = false; mCtrl.moveSideLock = false; LevelController.instance.TimeResume(); break; } switch ((EntityState)state) { case EntityState.Normal: inputEnabled = true; break; case EntityState.Hurt: Blink(hurtInvulDelay); sfxHurt.Play(); if (!stats.noPain) { if (mCurWeaponInd >= 0) { Weapon curWpn = weapons[mCurWeaponInd]; if (curWpn.stopOnHurt) { curWpn.FireStop(); } } //check to see if we can stop sliding, then do hurt SetSlide(false); if (mSliding) { state = (int)EntityState.Normal; } else { inputEnabled = false; mCtrlSpr.PlayOverrideClip(clipHurt); } } else { state = (int)EntityState.Normal; } break; case EntityState.Dead: { UIModalManager.instance.ModalCloseAll(); stats.EnergyShieldSetActive(false); if (mCurWeaponInd >= 0) { weapons[mCurWeaponInd].FireStop(); } SetSlide(false); mCtrl.enabled = false; rigidbody.isKinematic = true; rigidbody.detectCollisions = false; collider.enabled = false; //disable all input inputEnabled = false; InputManager input = Main.instance != null ? Main.instance.input : null; if (input) { input.RemoveButtonCall(0, InputAction.MenuEscape, OnInputPause); } // mCtrlSpr.anim.gameObject.SetActive(false); if (deathGOActivate) { deathGOActivate.SetActive(true); } bool isHardcore = SlotInfo.gameMode == SlotInfo.GameMode.Hardcore; if (isHardcore) { PlayerStats.curLife--; if (PlayerStats.curLife == 0) { SlotInfo.SetDead(true); } } //save when we die if (!UserData.instance.autoSave && !mTimeTrial) { UserData.instance.autoSave = true; UserData.instance.Save(); SlotInfo.SaveCurrentSlotData(); PlayerPrefs.Save(); } StartCoroutine(DoDeathFinishDelay()); } break; case EntityState.Lock: UIModalManager.instance.ModalCloseAll(); if (currentWeapon) { currentWeapon.FireStop(); } LockControls(); break; case EntityState.Victory: UIModalManager.instance.ModalCloseAll(); if (currentWeapon) { currentWeapon.FireStop(); } stats.EnergyShieldSetActive(false); currentWeaponIndex = -1; LockControls(); mCtrlSpr.PlayOverrideClip("victory"); //ok to save now if (!mTimeTrial) { if (saveLevelComplete) { LevelController.Complete(levelCompletePersist); } UserData.instance.autoSave = true; SlotInfo.SaveCurrentSlotData(); PlayerPrefs.Save(); } break; case EntityState.Final: UIModalManager.instance.ModalCloseAll(); if (currentWeapon) { currentWeapon.FireStop(); } stats.EnergyShieldSetActive(false); currentWeaponIndex = -1; LockControls(); if (saveLevelComplete) { LevelController.Complete(levelCompletePersist); } SlotInfo.ComputeClearTime(); SlotInfo.SaveCurrentSlotData(); PlayerPrefs.Save(); break; case EntityState.Exit: UIModalManager.instance.ModalCloseAll(); if (currentWeapon) { currentWeapon.FireStop(); } stats.EnergyShieldSetActive(false); currentWeaponIndex = -1; LockControls(); break; case EntityState.Invalid: inputEnabled = false; break; } }