Пример #1
0
    void StartGame()
    {
        _gameEvents = CreateGameEvents();

        // Init game control / time vars
        _timeController.Init(_entityController, _gameEvents, _gameData.DefaultTimescale);
        _timeController.Start();

        _inputDelay = _gameData.InputDelay;
        _input.Init(_gameData.InputData, _inputDelay);

        _mapController.Init(_gameData.MapData);

        _entityController.Init(_mapController, _gameData.EntityCreationData, _gameEvents);

        _monsterCreator.Init(_entityController, _mapController, _timeController, _gameEvents.Monsters, _gameData.EntityCreationData.MonsterData);

        _eventLogger.Init(_timeController, _gameEvents);

        _hud = CreateGameHUD();

        _input.OnLayoutChanged += _hud.OnInputLayoutChanged;


        // populate the level
        PopulateLevel();

        foreach (var stateContext in _playStatesData.Values)
        {
            stateContext.Init(this);
        }
        ;

        _playStateID     = PlayStates.Action;
        _nextPlayStateID = PlayStates.Action;
        _result          = GameResult.Running;

        _hud.Init(_eventLogger, _entityController.Player, _timeController, _cameraController.UICamera);
        RegisterEntityEvents();
        _gameEvents.Flow.SendStarted();
    }