// ====================================================================================== // PRIVATE MEMBERS // ====================================================================================== private void UpdateTransform(float _inputHorizontal, float _inputVertical, bool _doJump, bool _doDash) { // update transform Vector3 initialPos = this.transform.position; bool isWallSnapped = CheckWalls(); bool isWalking = UpdateWalk(_inputHorizontal); bool isDashing = UpdateDash(_inputHorizontal, _inputVertical, _doDash); UpdateJump(_doJump, isWallSnapped); UpdateGravity(isWallSnapped); UpdateCollisions(initialPos, this.transform.position); bool isGrabbed = CheckLedge(initialPos, this.transform.position); Vector3 finalPos = this.transform.position; Vector3 deltaPos = finalPos - initialPos; // update animation state PlayerAnimatorController.eStates nextState = GetNextState(isDashing, isWallSnapped, isWalking, isGrabbed, deltaPos); // sfx //if (nextState == eStates.Dashing && m_state != nextState) //{ // m_jetpackSFX.Stop(); // m_dashSFX.Play(); //} //else if (nextState == eStates.JetpackUp) //{ // m_jetpackSFX.loop = true; // if (!m_jetpackSFX.isPlaying) // { // m_jetpackSFX.Play(); // } //} //else //{ // m_jetpackSFX.loop = false; //} m_state = nextState; m_direction = deltaPos.x > 0 ? PlayerAnimatorController.eDirections.Right : m_direction; m_direction = deltaPos.x < 0 ? PlayerAnimatorController.eDirections.Left : m_direction; }
// ====================================================================================== // PUBLIC MEMBERS // ====================================================================================== public void Start() { m_direction = PlayerAnimatorController.eDirections.Right; m_state = PlayerAnimatorController.eStates.Idle; m_animator = this.GetComponent <PlayerAnimatorController>(); #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif m_dashTimer = m_dashDuration; m_dashDirection = Vector2.right; m_dashCooldownTimer = m_dashCoolDownDuration; m_collisionEpsilon = PhysicsMgr.CollisionDetectionPrecision; }