示例#1
0
    void Update()
    {
        if (GameManager.GameHasStarted && !GameManager.GameFinished && !GameManager.InEscapeMenu)
        {
            // Direction arrow
            DrawTargetDirection();

            if (Input.GetMouseButton(0) && PlayBall.Instance.movement == Vector3.zero && GameManager.GameHasStarted)
            {
                // Set and fill power bar
                powerBar.SetActive(true);
                if (launchPower < 1f)
                {
                    launchPower += Time.deltaTime / 2;
                }
            }

            if (Input.GetMouseButtonUp(0) && ball.GetComponent <PlayBall>().movement == Vector3.zero && GameManager.GameHasStarted && powerBar.activeSelf == true)
            {
                // Launch Ball
                LaunchBall(launchPower);
                powerBar.SetActive(false);
            }

            // Update power bar image
            powerBarImage.fillAmount = launchPower;
        }
    }
示例#2
0
    private void FixedUpdate()
    {
        CheckForCollisions();

        // Ball rolling physics
        HandlingBallRollGravity();

        // Gravity
        if (!ball.isColliding)
        {
            ball.GetComponent <PlayBall>().AddGravity();
        }

        // Move ball
        ball.GetComponent <PlayBall>().Move();
    }