예제 #1
0
        public override void Enter(params object[] args)
        {
            _screen      = new RenderTarget2D(StateMachine.Game.GraphicsDevice, VirtualScreenSize.Width * VirtualScreenSize.ScreenSizeMultiplier, VirtualScreenSize.Height * VirtualScreenSize.ScreenSizeMultiplier);
            _spriteBatch = new SpriteBatch(StateMachine.Game.GraphicsDevice);

            bool resetForNewGame = true;

            if (args.Length > 0 && args[0] is bool)
            {
                resetForNewGame = (bool)args[0];
            }
            // Generate map
            TerrainFactory.GenerateGrid();
            TerrainFactory.GenerateResourceGrid();

            // Generate available buildings
            var buildings = BuildingFactory.GenerateAvailableBuildings();

            // Create models
            _playerModel          = new PlayerModel();
            _playerResourcesModel = new PlayerResourcesModel();
            _terrainTileListModel = new TerrainTileListModel(TerrainFactory.Tiles, TerrainFactory.Resources);
            _buildingListModel    = new BuildingListModel(buildings);


            // Create and add controllers
            var playerController     = new PlayerController(_playerModel, _terrainTileListModel);
            var backgroundController = new BackgroundController(_playerModel, _terrainTileListModel, _playerResourcesModel);
            var buildController      = new BuildController(_buildingListModel, _playerModel, _playerResourcesModel);

            _controllers.Add(playerController);
            _controllers.Add(backgroundController);
            _controllers.Add(buildController);

            // Create and add views
            _views.Add(new BackgroundView(StateMachine.Game.Content, _spriteBatch, _terrainTileListModel, _playerModel));
            _views.Add(new PlayerResourcesView(StateMachine.Game.Content, _spriteBatch, _playerResourcesModel, _playerModel));
            _views.Add(new PlayerView(StateMachine.Game.Content, _spriteBatch, _playerModel));
            _views.Add(new BuildView(StateMachine.Game.Content, _spriteBatch, _buildingListModel, _playerModel, _playerResourcesModel));
        }