void Jump() { if (m_NumberOfJumps > 0) { m_PlayerAnimator.SetInteger("AnimationState", 1); if (!m_IsSliding) { m_AnimationState = AnimationState.JUMPING; m_IsJumping = true; m_NumberOfJumps--; if (m_LastJump == 1) { if (m_NumberOfJumps == 1) { m_NumberOfJumps = 0; } } m_LastJump = m_NumberOfJumps; if (m_NumberOfJumps == 1) { m_PlayerAudioManager.PlayJumpSound(); } else { m_PlayerAudioManager.PlayDoubleJumpSound(); } m_Rigidbody2D.velocity = new Vector2(m_Rigidbody2D.velocity.x, m_JumpStrength); } } }
void SwitchState(AnimationStates nextState) { m_AnimationState = nextState; switch (m_AnimationState) { case AnimationStates.LANDING: m_PlayerAnimator.SetInteger("AnimationState", 7); // . // . // . landingParticleSystem.Play(); // Sistema de partículas con polvillo... SwitchState(AnimationStates.RUNNING); break; case AnimationStates.RUNNING: m_IsDashing = false; m_IsSliding = false; m_IsTurning = false; //m_PlayerAnimator.SetInteger("AnimationState",0); m_MovementSpeed = m_OriginalMovementSpeed; //m_StartSliderTimer = false; RestartJumpsIfNeeded(); break; case AnimationStates.JUMP: if (m_AvailableJumps == 2) { m_PlayerAudioManager.PlayJumpSound(); } else if (m_AvailableJumps == 1) { m_PlayerAudioManager.PlayDoubleJumpSound(); } m_AvailableJumps--; m_PlayerAnimator.SetInteger("AnimationState", 1); m_Rigidbody2D.velocity = new Vector2(m_Rigidbody2D.velocity.x, m_JumpStrength); break; case AnimationStates.FALLING: if (m_IsGrounded) { SwitchState(AnimationStates.LANDING); } break; case AnimationStates.TURN: m_IsTurning = true; m_TurnTimer = 0; m_PlayerAnimator.SetInteger("AnimationState", 10); m_MovementSpeed = Vector2.zero.x; break; case AnimationStates.DASH: m_IsDashing = true; m_DashTimer = 0; m_MovementSpeed = m_DashSpeed; break; case AnimationStates.SLIDE: m_IsSliding = true; m_PlayerAnimator.SetInteger("AnimationState", 2); m_SlideTimer = 0; m_StartSliderTimer = true; break; } }