Пример #1
0
 public static void Resume()
 {
     resume = true;
     pause  = false;
     BallCamController.Disabled(false);
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (resume || pause)
        {
            resume = false;
            return;
        }

//        if (rb.velocity.sqrMagnitude <= 0.025)
//            stopBall();

        if (calcWind && timer == 0)
        {
            windDir    = new Vector3(UnityEngine.Random.Range(-1f, 1.1f), 0, UnityEngine.Random.Range(-1f, 1.1f));
            windSpd[2] = UnityEngine.Random.Range(windSpd[0], windSpd[1] + 1);
            //((Text)windTxt).text = "Wind Speed: " + windSpd[2] +"\nWind Direction:" + windDir;
            WindText.SetText("Wind Speed: " + windSpd[2] + "km/h\nWind Direction: " + windDir +
                             "\nPower: " + power + "\nMax Power: " + maxPower + "\nCoins: " + CoinBehaviour.Collected +
                             "Cooldown: " + timer);
            calcWind = false;
            updatePos();
        }
        color.r = power / maxPower;
        arrowRend.material.color = color;
        if (!shoot && timer == 0 && Input.GetKeyUp("mouse 0"))
        {
            force = cam.transform.forward;
            shoot = true;
            BallCamController.Disabled(false);
        }
        else if (shoot && Input.GetKeyUp("mouse 0"))
        {
            timer = 5 * (int)power;
            shoot = false;
            BallCamController.Disabled(false);
            shot++;
            calcWind = true;
            /*Possibly account for ball being on slope */
            //Vector3 planeNorm = rb.getPlane();
            Vector3 planeNorm = new Vector3(0, 1, 0);                    //Use the norm of the x,z plane
            force = Vector3.ProjectOnPlane(force, planeNorm).normalized; //Project onto a flat surface as we dont care about camera height
            Debug.Log(force);
            rb.AddForce(force * power * power + windDir * windSpd[2] * windSpd[2]);
            power = 1f;
        }
        else if (shoot && Input.GetKeyUp("mouse 1"))
        {
            shoot = false;
            BallCamController.Disabled(false);
            power = 1f;
        }

        if (timer != 0)
        {
            timer -= 1;
        }

        if (!incognitoMode)
        {
            if (Input.GetKeyDown("s"))
            {
                stopBall();
            }
            else if (Input.GetKeyDown("r"))
            {
                resetBall();
            }
            else if (Input.GetKeyDown("j"))
            {
                jump(jumpPower * jumpPower);
            }
            else if (Input.GetKeyDown("d"))
            {
                if (curr.prev != null)
                {
                    stopBall();
                    rb.transform.position = curr.prev.pos;
                    curr = curr.prev;
                    shot--;
                    calcWind = true;
                    cheated  = true;
                }
            }
            else if (Input.GetKeyDown("f"))
            {
                if (curr.next != null)
                {
                    stopBall();
                    rb.transform.position = curr.next.pos;
                    curr = curr.next;
                    shot++;
                    calcWind = true;
                    cheated  = true;
                }
            }
        }

        // Hide arrow when ball is in motion
        if (timer == 0)
        {
            arrowRend.enabled = true;
        }
        else
        {
            arrowRend.enabled = false;
        }
    }
Пример #3
0
 public static void Pause()
 {
     pause = true;
     BallCamController.Disabled(true);
 }