Beispiel #1
0
    void FixedUpdate()
    {
        if (gameState.GetState() != 2)
        {
            // Calculate how fast player should be moving
            Vector3 targetVelocity = new Vector3(Input.GetAxis("Horizontal"),
                                                 0, Input.GetAxis("Vertical"));

            targetVelocity  = transform.TransformDirection(targetVelocity);
            targetVelocity *= moveSpeed;

            // Apply a force that attempts to reach our target velocity
            Vector3 velocity       = GetComponent <Rigidbody>().velocity;
            Vector3 velocityChange = (targetVelocity - velocity);
            velocityChange.x = Mathf.Clamp(velocityChange.x,
                                           -maxVelocityChange, maxVelocityChange);
            velocityChange.z = Mathf.Clamp(velocityChange.z,
                                           -maxVelocityChange, maxVelocityChange);
            GetComponent <Rigidbody>().AddForce(velocityChange,
                                                ForceMode.VelocityChange);

            // Rotate camera with Mouse
            if (Input.GetAxis("Mouse X") > 0)
            {
                transform.Rotate(Vector3.up * rotateSpeed * Time.deltaTime);
            }
            else if (Input.GetAxis("Mouse X") < 0)
            {
                transform.Rotate(Vector3.up * -rotateSpeed * Time.deltaTime);
            }
        }
    }
Beispiel #2
0
 void Update()
 {
     if (gameState.GetState() == 2)
     {
         Debug.Log("WON. Beer: " + (uint)quantity);
         gameState.SetFinalBeer((uint)quantity);
         Destroy(gameObject);
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     displayTime.text = "" + gameState.GetTime();
     if (gameState.GetState() == 0)
     {
         displayObjective.text = "Find the bar and get some drinks!";
     }
     else if (gameState.GetState() == 1)
     {
         displayObjective.text = "Find your friends without spilling the drinks!\nCurrent drinks level: " + gameState.GetBeer();
     }
     else if (gameState.GetState() == 2)
     {
         displayObjective.text   = "Congratulations! Enjoy the show!";
         displauyBeerResult.text = "" + gameState.GetFinalbeer();
         displayTimeResult.text  = "" + gameState.GetFinalTime();
         DisplayResults();
     }
 }