Ejemplo n.º 1
0
    private void Update()
    {
        UpdatePosition();
        UpdateMousePosition();

        if (Input.GetMouseButtonUp(0) && hasBallInHand)
        {
            float chargeBallSpeed = ballSpeed + (maxBallSpeed - ballSpeed) * chargeBall;

            BallThrow = mouseDirection * chargeBallSpeed;
            playerBall.Throw(mouseDirection, chargeBallSpeed);

            hasBallInHand = false;
            hasBallExited = false;

            mouseIndicator.localScale = Vector2.one * normalIndicatorScale;

            chargeBall = 0;
        }
        else
        {
            if (Input.GetMouseButton(0) && hasBallInHand)
            {
                chargeBall = Math.Min(1f, chargeBall + chargeTime * Time.deltaTime);

                float indicatorChargeScale = normalIndicatorScale + (maxIndicatorScale - normalIndicatorScale) * chargeBall;
                mouseIndicator.localScale = new Vector2(indicatorChargeScale, normalIndicatorScale);
            }

            BallThrow = Vector2.zero;
        }
    }