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();
        }
    }
Example #2
0
    public static void UpdateProgress()
    {
        _gameProgressManager.animator.Play("ProgressBarAnimation", -1, 0f);

        _gameProgressManager.gameProgress += 6f / (PersonSpawner.GetPersonCount() * 5f);

        if (_gameProgressManager.gameProgress > _gameProgressManager.progressSlider.maxValue)
        {
            if (!_notifiedProgressMax)
            {
                NotificationManager.Notify(NotificationType.LevelUp);
                _notifiedProgressMax = true;
            }
            _progressState = GameProgressState.Complete;
        }
        else
        {
            _progressState = GameProgressState.NotComplete;
        }

        _gameProgressManager.UpdateUi();
    }