Exemplo n.º 1
0
    public void PerfomAction(StateType action)
    {
        if (action == StateType.endBowl)
        {
            if (!turn)
            {
                score.FillRolls(pointsPerRoll, turn);
                score.FillFrame(TotalPoints(pointsPerRoll), turn);
            }
            else
            {
                score.FillRolls(pointsPerRoll_p2, turn);
                score.FillFrame(TotalPoints(pointsPerRoll_p2), turn);
            }

            foreach (pin pin in GameObject.FindObjectsOfType <pin>())
            {
                pin.standingReset();
            }



            cam1.SetActive(true);
            cam2.SetActive(false);

            tball.res2();
        }
        else if (action == StateType.endRound)
        {
            if (!turn)
            {
                score.FillRolls(pointsPerRoll, turn);
                score.FillFrame(TotalPoints(pointsPerRoll), turn);
                score.green1.SetActive(false);
                score.green2.SetActive(true);
                turn = true;
            }
            else
            {
                score.FillRolls(pointsPerRoll_p2, turn);
                score.FillFrame(TotalPoints(pointsPerRoll_p2), turn);
                score.green1.SetActive(true);
                score.green2.SetActive(false);
                turn = false;
            }

            foreach (pin pin in GameObject.FindObjectsOfType <pin>())
            {
                pin.standingReset();
                pin.reset();
            }

            click = GetComponent <AudioSource> ();
            click.Play();

            cam1.SetActive(true);
            cam2.SetActive(false);

            pinMngr.Reset();
            tball.res2();
        }
        else if (action == StateType.lastRound)
        {
            if (!turn)
            {
                score.FillRolls(pointsPerRoll, turn);
            }
            else
            {
                score.FillRolls(pointsPerRoll_p2, turn);
            }

            foreach (pin pin in GameObject.FindObjectsOfType <pin>())
            {
                pin.standingReset();
                pin.reset();
            }

            cam1.SetActive(true);
            cam2.SetActive(false);
            pinMngr.Reset();
            tball.res2();
        }
        else if (action == StateType.endGame)
        {
            score.FillRolls(pointsPerRoll_p2, turn);
            score.FillFrame(TotalPoints(pointsPerRoll_p2), turn);
            score.green1.SetActive(false);
            score.green2.SetActive(false);


            List <int> totalPlayer2 = new List <int> ();
            List <int> totalPlayer1 = new List <int> ();
            totalPlayer2 = TotalPoints(pointsPerRoll_p2);
            totalPlayer1 = TotalPoints(pointsPerRoll);


            if (totalPlayer1[totalPlayer1.Count - 1] > totalPlayer2 [totalPlayer2.Count - 1])
            {
                Result.text = Name1.text + " is the winner!";
            }
            else if (totalPlayer1[totalPlayer1.Count - 1] < totalPlayer2 [totalPlayer2.Count - 1])
            {
                Result.text = Name2.text + " is the winner!";
            }
            else
            {
                Result.text = "It's a draw!";
            }

            pointsPerRoll.Clear();
            pointsPerRoll_p2.Clear();
            tball.push = false;
            endGamePanel.SetActive(true);
        }
    }