Exemplo n.º 1
0
 // Control game starting
 private void controlGameStarting()
 {
     // If the game is starting
     if (GameStateCheckers.isGameStarting(gameManagerRef.getCurrentGameState()))
     {
         // If the user presses the escape key
         // Start the game
         if (Input.GetKeyDown(KeyCode.Space))
         {
             gameManagerRef.startGame();
         }
     }
 }
Exemplo n.º 2
0
    // Control look
    private void controlLook()
    {
        // If the current game state is active or starting
        if (GameStateCheckers.isGameActive(gameManagerRef.getCurrentGameState()) || GameStateCheckers.isGameStarting(gameManagerRef.getCurrentGameState()))
        {
            // Add to the rotation x and y values
            rotationX += Input.GetAxis("Mouse X") * lookSensitivity;
            rotationY += -Input.GetAxis("Mouse Y") * lookSensitivity;

            // Clamp the rotation values
            rotationX = Mathf.Clamp(rotationX, -90, 90);
            rotationY = Mathf.Clamp(rotationY, -90, 90);

            // Set the rotation of the player
            transform.eulerAngles = new Vector3(rotationY, rotationX, 0.0f);
        }
    }
Exemplo n.º 3
0
    // Control object interaction
    private void controlObjectInteraction()
    {
        // If the current game state is active
        if (GameStateCheckers.isGameActive(gameManagerRef.getCurrentGameState()))
        {
            // The hit result of the ray cast
            RaycastHit rayCastHitResult;

            // Fire a ray cast
            bool wasRayCastHit = Physics.Raycast(transform.position, transform.forward, out rayCastHitResult, Mathf.Infinity);

            // If the left mouse button is pressed
            if (Input.GetKeyDown(KeyCode.Mouse0))
            {
                // If the raycast hit something
                if (wasRayCastHit)
                {
                    // If the object hit was a dispenser
                    if (rayCastHitResult.collider.CompareTag("Dispenser"))
                    {
                        Dispenser hitDispenser = rayCastHitResult.collider.GetComponent <Dispenser>();

                        // Tell the hit dispenser to dispenser their ingredient
                        hitDispenser.dispenseIngredient();
                    }

                    // If the object hit was the order check button
                    else if (rayCastHitResult.collider.CompareTag("OrderCheckButton"))
                    {
                        OrderCheckButton hitOrderCheckButton = rayCastHitResult.collider.GetComponent <OrderCheckButton>();

                        // Complete the current order
                        orderManagerRef.completeCurrentOrder();
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    // Control pausing
    private void controlPausing()
    {
        // If the game is active
        if (GameStateCheckers.isGameActive(gameManagerRef.getCurrentGameState()))
        {
            // If the user presses the escape key
            // Pause the game
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                gameManagerRef.pauseGame();
            }
        }

        // If the game is paused
        else if (GameStateCheckers.isGamePaused(gameManagerRef.getCurrentGameState()))
        {
            // If the user presses the escape key
            // Resume the game
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                gameManagerRef.resumeGame();
            }
        }
    }