private IEnumerator StunnedState() { groundMovement.enabled = false; airborneMovement.enabled = false; onAttackCooldown = false; invincible = true; actionState = ActionState.Stunned; m_animator.SetBool("Stunned", true); m_rigidbody.velocity = Vector2.zero; damageFX.enabled = true; Time.timeScale = 0; damageSFX.Play(); yield return(new WaitForSecondsRealtime(.2f)); Time.timeScale = 1; damageFX.enabled = false; for (int i = 0; i < 3; i++) { yield return(new WaitForFixedUpdate()); } if (controller.GetHealth() > 0) { actionState = ActionState.Idle; StartCoroutine(InvencibilityTime()); if (onGround) { SetGroundState(); } else { SetAirborneState(); } m_animator.SetBool("Stunned", false); m_animator.SetTrigger("Reset"); } else { controller.Die(); } }
private IEnumerator StunnedState() { PlayerState = State.Stunned; invincible = true; m_animator.SetBool("Stunned", true); m_rigidbody.velocity = Vector2.zero; damageFX.enabled = true; Time.timeScale = 0; damageFX.GetComponent <AudioSource>().Play(); yield return(new WaitForSecondsRealtime(.2f)); Time.timeScale = 1; damageFX.enabled = false; if (shootCicle != null) { StopCoroutine(shootCicle); } shooting = false; for (int i = 0; i < 3; i++) { yield return(new WaitForFixedUpdate()); } if (controller.GetHealth() < 1) { controller.Die(); } PlayerState = State.Idle; if (gameObject.activeSelf) { StartCoroutine(InvencibilityTime()); } m_animator.SetBool("Stunned", false); }