public GameController(IEnumerable <IView> availableViews, IWindowFascade windowFascade, IBoardStrategy strategy) : base(availableViews, windowFascade) { Game game = Game.Instance; _strategy = strategy; if (strategy.ProfileName.Equals("Justtest")) { _score = new NullScore(); } else { _score = new RealScore(); } game.Score = _score; if (_spaceShipPosition == null) { _spaceShipPosition = game.Board?.GetPosition(); } var bullets = game.Board?.GetBullets() != null?game.Board?.GetBullets() : new List <Bullet>(); _boardDirector = new BoardDirector(_strategy, game.Level, game.Score, _spaceShipPosition, bullets); _builder = new BoardBuilder(); _boardDirector.Construct(_builder); game.Board = _builder.Build(); }
public BoardDirector(IBoardStrategy strategy, int level, Score.Score score, Position spaceShipPosition, IList <Bullet> bullets) { _strategy = strategy; _level = level; _score = score; _spaceShipPosition = spaceShipPosition; _bullets = bullets; }
/// <summary> /// Handles the Click event of the btnGenerateBoard control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void btnGenerateBoard_Click(object sender, EventArgs e) { int boardSize = int.Parse(txtBoardSize.Text); int numOfMen = int.Parse(txtNumOfMen.Text); int numOfWomen = int.Parse(txtNumOfWomen.Text); m_numOfGenerations = int.Parse(cmbNumOfGenerations.Text); var board = new Board(boardSize); BoardStrategyParameters parameters = GetStrategyParameters(); IBoardStrategy strategy = BoardStrategyFactory.CreateStrategy(parameters); m_boardManager = new BoardManager(board, strategy); m_boardManager.PopulateBoard(numOfMen, numOfWomen); m_boardPanels = new Panel[boardSize, boardSize]; InitializeBoardGraphics(m_boardManager.Board); btnRunAutomata.Enabled = true; }
public BoardManager(Board board, IBoardStrategy strategy) { m_board = board; m_startegy = strategy; m_rand = new Random(DateTime.Now.Millisecond); }
public BoardManager(Board board, IBoardStrategy strategy) { m_board = board; m_startegy = strategy; m_rand = new Random(DateTime.Now.Millisecond); }
public IController ChangeController(string command, IBoardStrategy strategy = null) { return(command.Equals(Contracts.Contracts.GameController) ? new GameController(ViewsFactory.Create(command), WindowFacade, strategy) : this); }