Ejemplo n.º 1
0
    void Update()
    {
        if (running)
        {
            timeText.text = ((int)(timeLimit)).ToString();
            timeLimit    -= Time.deltaTime;

            if (timeLimit <= 0 && running == true)
            {
                running = false;
                //show panel with scores
                //slide menu back in
                if (p1Detection._score > p2Detection._score)
                {
                    //p1wins
                    p1Detection.PlayWinCheer();
                    p2Detection.PlayLoose();
                    camController.CameraMoveToP1Win();

                    gameMusic.Stop();
                    endGameSound.Play();

                    TheresaWinsUi.SetActive(true);
                    EUWinsUi.SetActive(false);
                    DrawUi.SetActive(false);


                    zoneP1.SetActive(false);
                    zoneP2.SetActive(false);
                }
                else if (p1Detection._score < p2Detection._score)
                {
                    p2Detection.PlayWinCheer();
                    p1Detection.PlayLoose();

                    camController.CameraMoveToP2Win();
                    gameMusic.Stop();
                    endGameSound.Play();


                    TheresaWinsUi.SetActive(false);
                    EUWinsUi.SetActive(true);
                    DrawUi.SetActive(false);

                    zoneP1.SetActive(false);
                    zoneP2.SetActive(false);
                }
                else
                {
                    TheresaWinsUi.SetActive(false);
                    EUWinsUi.SetActive(false);
                    DrawUi.SetActive(true);
                    gameMusic.Stop();
                    endGameSound.Play();
                    p1Detection.PlayLoose();
                    p2Detection.PlayLoose();


                    zoneP1.SetActive(false);
                    zoneP2.SetActive(false);
                }
            }

            if (Input.GetKey(KeyCode.Escape) && running == true)
            {
                //show the pause panel
                Time.timeScale = 0;
                PauseUi.SetActive(true);
            }
        }
    }