Пример #1
0
    private void CheckGameEnding()
    {
        if (GameState != GameState.Playing)
        {
            return;
        }

        var numberOfDeadPersons     = GameObject.FindGameObjectsWithTag(Person.GetTag(PersonTags.Dead)).Length;
        var numberOfInfectedPersons = GameObject.FindGameObjectsWithTag(Person.GetTag(PersonTags.Infected)).Length;

        if (numberOfDeadPersons == PersonSpawner.GetPersonCount())
        {
            GameWon();
            return;
        }

        if (numberOfDeadPersons + numberOfInfectedPersons == PersonSpawner.GetPersonCount() && !_notifiedAllMonstersEffected)
        {
            NotificationManager.Notify(NotificationType.AllMonstersInfected);
            _notifiedAllMonstersEffected = true;
        }

        if (Cannon.CannonBallsRemaining() != 0)
        {
            return;
        }

        var cannonBallsInAir = GameObject.FindGameObjectsWithTag("CannonBall");

        if (cannonBallsInAir.Length != 0)
        {
            return;
        }

        // counting all the infected and contagious persons
        var remainingInfectedPersonsCount =
            GameObject.FindGameObjectsWithTag(Person.GetTag(PersonTags.Infected)).Length;

        if (remainingInfectedPersonsCount != 0)
        {
            return;
        }


        if (GameProgressManager.GetCurrentProgressState() == GameProgressState.Complete)
        {
            GameWon();
        }
        else
        {
            GameOver();
        }
    }