Пример #1
0
    //assigning player on trigger enter
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player1")
        {
            player1 = other.GetComponent <PlayerController>();
            if (player1.destination == transform)
            {
                canpickup = true;
                player1.CloseVegButtons();
                player1.Player1ActionButton.SetActive(true);
                player1.Player1Buttons[0].transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Esc";
                player1.Player1Buttons[0].transform.GetChild(1).GetComponent <Text>().text             = "Discard";
                player1.Player1Buttons[0].SetActive(true);
                Debug.Log("player entered zone " + gameObject.name);
            }
        }

        else if (other.tag == "Player2")
        {
            player2 = other.GetComponent <Player2Controller>();
            if (player2.destination == transform)
            {
                player2pickup = true;
                player2.CloseVegButtons();
                player2.Player1ActionButton.SetActive(true);
                player2.Player1Buttons[0].transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "BackSpace";
                player2.Player1Buttons[0].transform.GetChild(1).GetComponent <Text>().text             = "Discard";
                player2.Player1Buttons[0].SetActive(true);
                Debug.Log("player2 entered zone " + gameObject.name);
            }
        }
    }
Пример #2
0
    //assigning player on trigger enter
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player1")
        {
            Debug.Log("player entered bonus area");
            player1 = other.GetComponent <PlayerController>();

            switch (bonusID)
            {
            case 1:
                player1.player1Points = player1.player1Points + 10;
                break;

            case 2:
                manager.player1CurrCountdownValue = manager.player1CurrCountdownValue + 10;
                break;

            case 3:
                StartCoroutine(IncreaseSpeedTemporarily());
                break;
            }
            player1.CloseVegButtons();
            player1.Player1ActionButton.SetActive(false);
            player1.ResetVegetableButtons();
            Destroy(gameObject);
        }
        else if (other.tag == "Player2")
        {
            Debug.Log("player2 entered bonus area");
            player2 = other.GetComponent <Player2Controller>();

            switch (bonusID)
            {
            case 1:
                player2.player1Points = player2.player1Points + 10;                                                                      //points bonus
                break;

            case 2:
                manager.player2CurrCountdownValue = manager.player2CurrCountdownValue + 10;                        //time left bonus
                break;

            case 3:
                StartCoroutine(IncreaseSpeedTemporarilyForPlayer2());                               //speed increase bonus
                break;
            }
            player2.CloseVegButtons();
            player2.Player1ActionButton.SetActive(false);
            player2.ResetVegetableButtons();
            Destroy(gameObject);
        }
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        //if game is not on, then start it
        if (Input.GetKeyDown(KeyCode.Space) && !isGameOn)
        {
            isGameOn = true;
            player1.ResetVegetableButtons();
            player2.ResetVegetableButtons();
            player2.Player1ActionButton.SetActive(false);
            player1.Player1ActionButton.SetActive(false);
            StartCoroutine(Player1Countdown(Player1TimeLeft));
            StartCoroutine(Player2Countdown(Player2TimeLeft));

            for (int i = 0; i < customers.Length; i++)
            {
                customers[i].WaitForFood();
            }
        }

        //else if game is over, restart it
        else if (Input.GetKeyDown(KeyCode.Escape) && !isGameOn)
        {
            Scene scene = SceneManager.GetActiveScene();
            SceneManager.LoadScene(scene.name);
        }

        //check to see how many customers left
        if (customers[0].istimeLeft == false && customers[1].istimeLeft == false && customers[2].istimeLeft == false && customers[3].istimeLeft == false && customers[4].istimeLeft == false)
        {
            player1.CloseVegButtons();
            player1.Player1ActionButton.SetActive(false);
            player2.CloseVegButtons();
            player2.Player1ActionButton.SetActive(false);
            player1.Player1ActionButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Esc";
            player1.Player1ActionButton.transform.GetChild(1).GetComponent <Text>().text             = "Restart";
            player1.Player1ActionButton.SetActive(true);
            isGameOn = false;
            DisplayHighScore();
            highscorePanel.SetActive(true);
        }
    }
Пример #4
0
    private void OnTriggerExit(Collider other)
    {
        //removing player reference on its exit
        if (other.tag == "Player1")
        {
            canDrop = false;

            player1.CloseVegButtons();
            Player1ChopButton.SetActive(false);
            player1 = null;
            Debug.Log("player left zone " + gameObject.name);
        }

        //Player2 Zone
        else if (other.tag == "Player2")
        {
            canDrop = false;

            player2.CloseVegButtons();
            Player2ChopButton.SetActive(false);
            player2 = null;
            Debug.Log("player2 left zone " + gameObject.name);
        }
    }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        //serve customer and see the reation
        if (Input.GetKeyDown(KeyCode.Tab) && canPlaceBowl)
        {
            player1.ServeCustomer(CustomerID);
            player1.canServe = false;
            canPlaceBowl     = false;
            float n = (timePast / WaitingTime) * 100;

            if (customerOrderID == player1.saladCombinationID && n >= 30.0f)
            {
                remarkText.text = "Excellent!";
                player1.player1Points++;
                manager.Player1ScoreText.text = "Player1 Score: " + player1.player1Points.ToString();
                bonusEarned = true;
                SpawnRandomBonus();
                serveButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "`";
                serveButton.transform.GetChild(1).GetComponent <Text>().text             = "Take Bonus";
                serveButton.SetActive(true);
            }
            else if (customerOrderID == player1.saladCombinationID)
            {
                remarkText.text = "Good";
                player1.player1Points++;
                manager.Player1ScoreText.text = "Player1 Score: " + player1.player1Points.ToString();
                gameObject.SetActive(false);
                player1.CloseVegButtons();
                player1.ResetVegetableButtons();
                player1.Player1ActionButton.SetActive(false);
            }

            else
            {
                remarkText.text = "I am angry!!";
                player1.player1Points--;
                manager.Player1ScoreText.text = "Player1 Score: " + player1.player1Points.ToString();
                StopCoroutine(co);
                timeBar.color = Color.red;
                StartCoroutine(WaitingCountdown(timePast, 0.5f));
                player1.CloseVegButtons();
                player1.ResetVegetableButtons();
                player1.Player1ActionButton.SetActive(false);
                //reduce time
            }
        }

        //on bonus earned
        else if (Input.GetKeyDown(KeyCode.BackQuote) && bonusEarned)
        {
            Vector3 target = new Vector3(bonusSpawnPos[randomArea].position.x, bonusSpawnPos[randomArea].position.y, bonusSpawnPos[randomArea].position.z);
            player1.GetComponent <NavMeshAgent>().SetDestination(target);
            bonusEarned = false;
        }

        //Player2 Actions
        else if (Input.GetKeyDown(KeyCode.Backslash) && canPlaceBowl)
        {
            player2.ServeCustomer(CustomerID);
            player2.canServe = false;
            canPlaceBowl     = false;
            float n = (timePast / WaitingTime) * 100;

            if (customerOrderID == player2.saladCombinationID && n >= 30.0f)
            {
                remarkText.text = "Excellent!";
                player2.player1Points++;
                manager.Player2ScoreText.text = player2.player1Points.ToString() + " :Player2 Score";
                bonusEarned = true;
                SpawnRandomBonus();
                serveButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "=";
                serveButton.transform.GetChild(1).GetComponent <Text>().text             = "Take Bonus";
                serveButton.SetActive(true);
            }
            else if (customerOrderID == player2.saladCombinationID)
            {
                remarkText.text = "Good";
                player2.player1Points++;
                manager.Player2ScoreText.text = player2.player1Points.ToString() + " :Player2 Score";
                gameObject.SetActive(false);
                player2.CloseVegButtons();
                player2.ResetVegetableButtons();
                player2.Player1ActionButton.SetActive(false);
            }

            else
            {
                remarkText.text = "I am angry!!";
                player2.player1Points--;
                manager.Player2ScoreText.text = player2.player1Points.ToString() + " :Player2 Score";
                StopCoroutine(co);
                timeBar.color = Color.red;
                StartCoroutine(WaitingCountdown(timePast, 0.5f));
                player2.CloseVegButtons();
                player2.ResetVegetableButtons();
                player2.Player1ActionButton.SetActive(false);
                //reduce time
            }
        }

        else if (Input.GetKeyDown(KeyCode.Equals) && bonusEarned)
        {
            Vector3 target = new Vector3(bonusSpawnPos[randomArea].position.x, bonusSpawnPos[randomArea].position.y, bonusSpawnPos[randomArea].position.z);
            player2.GetComponent <NavMeshAgent>().SetDestination(target);
            bonusEarned = false;
        }
    }
Пример #6
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape) && player1 != null && player1.destination == transform)
        {
            player1.ResetVegetableButtons();
            Debug.Log("reset");
        }

        //what to do when player has picked up a vegetable
        if (Input.GetKeyDown(KeyCode.A) && canpickup)
        {
            player1.CloseVegButtons();

            Player1GoToChopButton1.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "S";
            Player1GoToChopButton1.transform.GetChild(1).GetComponent <Text>().text             = "Go to Chopping Board";
            Player1GoToChopButton1.SetActive(true);

            //Player1GoToChopButton2.transform.GetChild(0).GetChild(0).GetComponent<Text>().text = "D";
            //Player1GoToChopButton2.transform.GetChild(1).GetComponent<Text>().text = "Go to Chopping Board2";
            //Player1GoToChopButton2.SetActive(true);

            Player1PickAnotherVegButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Esc";
            Player1PickAnotherVegButton.transform.GetChild(1).GetComponent <Text>().text             = "Pick other Vegetable";
            Player1PickAnotherVegButton.SetActive(true);

            if (player1.vegetablesCarryingArray[0] == null || player1.vegetablesCarryingArray[1] == null)
            {
                Player1PickupAgainButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "A";
                Player1PickupAgainButton.transform.GetChild(1).GetComponent <Text>().text             = "Pickup Again";
                Player1PickupAgainButton.SetActive(true);
            }
            else
            {
                Player1PickupAgainButton.SetActive(false);
            }

            player1.SelectVegetable(vegId, orderCalculationID);
        }

        //Player2 Zone
        if (Input.GetKeyDown(KeyCode.Backspace) && player2 != null && player2.destination == transform)
        {
            player2.ResetVegetableButtons();
            Debug.Log("reset");
        }

        if (Input.GetKeyDown(KeyCode.L) && player2pickup)
        {
            player2.SelectVegetable(vegId, orderCalculationID);

            player2.CloseVegButtons();

            //Player2GoToChopButton1.transform.GetChild(0).GetChild(0).GetComponent<Text>().text = ";";
            //Player2GoToChopButton1.transform.GetChild(1).GetComponent<Text>().text = "Go to Chopping Board1";
            //Player2GoToChopButton1.SetActive(true);

            Player2GoToChopButton2.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "'";
            Player2GoToChopButton2.transform.GetChild(1).GetComponent <Text>().text             = "Go to Chopping Board";
            Player2GoToChopButton2.SetActive(true);

            Player2PickAnotherVegButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Backspace";
            Player2PickAnotherVegButton.transform.GetChild(1).GetComponent <Text>().text             = "Pick other Vegetable";
            Player2PickAnotherVegButton.SetActive(true);

            if (player2.vegetablesCarryingArray[0] == null || player2.vegetablesCarryingArray[1] == null)
            {
                Player2PickupAgainButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "L";
                Player2PickupAgainButton.transform.GetChild(1).GetComponent <Text>().text             = "Pickup Again";
                Player2PickupAgainButton.SetActive(true);
            }
            else
            {
                Player2PickupAgainButton.SetActive(false);
            }
        }

        else
        {
            return;
        }
    }
Пример #7
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player1")
        {
            canDrop = true;
            Debug.Log("player entered zone " + gameObject.name);
            player1 = other.GetComponent <PlayerController>();

            if (player1.vegetablesCarryingArray != null && player1.destination == transform)
            {
                player1.CloseVegButtons();                                                                   //close buttons to show all vegetables
                player1.Player1ActionButton.SetActive(false);


                //assigning texts and activating all buttons to display all options a player has.

                Player1ChopButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Space";
                Player1ChopButton.transform.GetChild(1).GetComponent <Text>().text             = "Chop";
                Player1ChopButton.SetActive(true);

                if (other.GetComponent <PlayerController>().vegetablesCarryingArray[1] != null)
                {
                    PlayerVeg2 = other.GetComponent <PlayerController>().vegetablesCarryingArray[1];

                    Player1SidePlateButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "LCtrl";
                    Player1SidePlateButton.transform.GetChild(1).GetComponent <Text>().text             = "Keep at Side Plate";
                    Player1SidePlateButton.SetActive(true);
                    Debug.Log(PlayerVeg2.name);
                }
                else if (other.GetComponent <PlayerController>().vegetablesCarryingArray[0] != null)
                {
                    PlayerVeg1 = other.GetComponent <PlayerController>().vegetablesCarryingArray[0];
                    Player1SidePlateButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "LCtrl";
                    Player1SidePlateButton.transform.GetChild(1).GetComponent <Text>().text             = "Keep at Side Plate";
                    Player1SidePlateButton.SetActive(true);
                    Debug.Log(PlayerVeg1.name);
                }
            }
        }


        //Player2 Actions
        if (other.tag == "Player2")
        {
            canDrop = true;
            Debug.Log("player2 entered zone " + gameObject.name);
            player2 = other.GetComponent <Player2Controller>();

            if (player2.vegetablesCarryingArray != null && player2.destination == transform)
            {
                player2.CloseVegButtons();
                player2.Player1ActionButton.SetActive(false);

                Player2ChopButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "Enter";
                Player2ChopButton.transform.GetChild(1).GetComponent <Text>().text             = "Chop";
                Player2ChopButton.SetActive(true);

                if (other.GetComponent <Player2Controller>().vegetablesCarryingArray[1] != null)
                {
                    Player2Veg2 = other.GetComponent <Player2Controller>().vegetablesCarryingArray[1];

                    Player2SidePlateButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "RCtrl";
                    Player2SidePlateButton.transform.GetChild(1).GetComponent <Text>().text             = "Keep at Side Plate";
                    Player2SidePlateButton.SetActive(true);
                    Debug.Log(Player2Veg2.name);
                }
                else if (other.GetComponent <Player2Controller>().vegetablesCarryingArray[0] != null)
                {
                    Player2Veg1 = other.GetComponent <Player2Controller>().vegetablesCarryingArray[0];
                    Player2SidePlateButton.transform.GetChild(0).GetChild(0).GetComponent <Text>().text = "RCtrl";
                    Player2SidePlateButton.transform.GetChild(1).GetComponent <Text>().text             = "Keep at Side Plate";
                    Player2SidePlateButton.SetActive(true);
                    Debug.Log(Player2Veg1.name);
                }
            }
        }
    }