예제 #1
0
    private IEnumerator Timer()
    {
        int i = (int)_gameTime;

        AddEnergy(0);

        while (i >= 0)
        {
            if (!_gamePaused)
            {
                GameTimerChanged?.Invoke(i);
                i--;
            }
            yield return(new WaitForSecondsRealtime(1f));
        }
        _gameEnded = true;

        CheckGameEndedCondition(_gameParemeters.gameEndCondition);
        yield return(null);
    }
예제 #2
0
    private void GameSettingsLoaded(GameParemeters gameParemeters)
    {
        Debug.Log("Настройки игры загружены!");

        _gameParemeters            = gameParemeters;
        _gameTime                  = (int)gameParemeters.gameTime;
        _needEnergyToCompleteLevel = (int)gameParemeters.neededEnergy;

        if (GameEconomy.curentItem)
        {
            _gameTime = (int)GameEconomy.curentItem.TryModifyParameter(GameParameter.GameTime, _gameTime);
        }

        Application.targetFrameRate = 60;

        if (_startFromPause)
        {
            SetPauseEnabled();
        }
        else
        {
            SetPauseDisabled();
        }
        FindAndStartListeningSouls();

        StopCoroutine("Timer");

        if (_gameTime != -1)
        {
            StartCoroutine("Timer");
        }
        else
        {
            AddEnergy(0);
            GameTimerChanged?.Invoke(-1);
        }
    }