Ejemplo n.º 1
0
    private void ClimbLadder()
    {
        if (!IsClimbing)
        {
            return;
        }

        velocity.x = 0f;
        velocity.y = moveInput.y * speed;

        if (moveInput.x != 0f)
        {
            float?yDropOff = climbedLadder.GetDropOffLevel(transform.position);

            Debug.Log(yDropOff);

            if (yDropOff != null)
            {
                climbedLadder = null;
                velocity.y    = 0f;

                Vector2 newPos = transform.position;
                newPos.y = (float)yDropOff;
                rb.MovePosition(newPos);
                return;
            }
        }

        if (moveInput.y > 0f)
        {
            StartCoroutine(soundSystem.PlaySfxAsync("climb"));
            if (transform.position.y >= climbedLadder.HighestLevel)
            {
                velocity.y = 0f;
            }
        }

        if (moveInput.y < 0f)
        {
            StartCoroutine(soundSystem.PlaySfxAsync("climb"));
            if (transform.position.y <= climbedLadder.LowestLevel)
            {
                velocity.y = 0f;
            }
        }

        else
        {
            StartCoroutine(soundSystem.PlaySfxAsync(state: false));
        }
    }