Exemplo n.º 1
0
 public GameField(IGameScoreManager gameScoreManager, int rows, int cols)
 {
     scores    = gameScoreManager;
     this.rows = rows;
     this.cols = cols;
     field     = new List <int>(rows * cols);
     rand      = new Random(DateTime.Now.Millisecond);
 }
Exemplo n.º 2
0
 public MainViewModel(IGameField gameField, IGameScoreManager gameScore, INewViewFactory newViewFactory)
 {
     this.gameField              = gameField;
     this.gameScore              = gameScore;
     this.newViewFactory         = newViewFactory;
     moveBarRight                = new DelegateCommand(MoveRight, () => !gameField.IsNotMove && !gameField.IsWinGame);
     moveBarLeft                 = new DelegateCommand(MoveLeft, () => !gameField.IsNotMove && !gameField.IsWinGame);
     moveBarUp                   = new DelegateCommand(MoveUp, () => !gameField.IsNotMove && !gameField.IsWinGame);
     moveBarDown                 = new DelegateCommand(MoveDown, () => !gameField.IsNotMove && !gameField.IsWinGame);
     startGame                   = new DelegateCommand(InitialGame);
     gameScore.ScoreChanged     += GameScore_ScoreChanged;
     gameScore.HighScoreChanged += GameScore_HighScoreChanged;
     gameField.FieldChanged     += GameField_FieldChanged;
     gameField.NotMove          += GameField_NotMove;
     gameField.WinGame          += GameField_WinGame;
 }
Exemplo n.º 3
0
        public GameEngine(IPointResultEngine pointResultEngine,
                          IGameScoreManager gameScoreManager,
                          IUserInterface userInterface,
                          Player playerA,
                          Player playerB)
        {
            _playerA           = playerA ?? throw new ArgumentNullException("playerA");
            _playerB           = playerB ?? throw new ArgumentNullException("playerB");
            _pointResultEngine = pointResultEngine ?? throw new ArgumentNullException("pointResultEngine");
            _gameScoreManager  = gameScoreManager ?? throw new ArgumentNullException("gameScoreManager");
            _userInterface     = userInterface ?? throw new ArgumentNullException("userInterface");

            if (_playerA.Name == _playerB.Name)
            {
                throw new ArgumentException("Players can't have the same name");
            }
        }
Exemplo n.º 4
0
 public virtual IViewModel BuildMainViewModel(IGameField gameField, IGameScoreManager gameScoreManager, INewViewFactory newViewFactory) =>
 new MainViewModel(gameField, gameScoreManager, newViewFactory);
Exemplo n.º 5
0
 public virtual IGameField BuildGameField(IGameScoreManager gameScoreManager, int rows, int cols) =>
 new GameField(gameScoreManager, rows, cols);