/// <summary>
        /// Initialize GameView Model
        /// </summary>
        private void InitializeGameViewModel(int columns, int rows)
        {
            // create game configuration for export
            GameConfiguration = new GameConfiguration(columns, rows);
            GameConfiguration.Columns = columns;
            GameConfiguration.Rows = rows;
            CurrentGameArea = new GameArea();
            GameConfiguration.GameAreas.Add(CurrentGameArea);

            // create all areas only for gui yet
            GameArea guiGameArea = new GameArea();
            for (int column = 0; column < columns; column++)
            {
                for (int row = 0; row < rows; row++)
                {
                    Area field = new Area();
                    field.Column = column;
                    field.Row = row;
                    field.Status = Area.AreaStatus.None;
                    guiGameArea.AreaList.Add(field);
                }
            }

            // create gui
            GUIGameInstance = new GuiGameArea(guiGameArea)
            {
                AreaWidth = 800,
                AreaHeight = 600
            };
        }
Exemple #2
0
        public Game(GameConfiguration configuration)
        {
            _configuration = configuration;

            Reset();
        }
Exemple #3
0
        private void StartComponents(GameConfiguration configuration)
        {
            // Instantiate components
            _server = new GameTcpServer();
            _game = new GameController(_server, configuration);

            // Add listeners
            _server.Subscribe(_game);

            // Start the TCP Service
            _server.StartService();

            // Create and start the DiscoveryService
            var discovery = new DiscoveryService();
            discovery.Start();

            // Start the game
            var worker = new BackgroundWorker();
            worker.DoWork += (sender, args) => _game.Loop();
            worker.RunWorkerAsync();
        }