Example #1
0
 public void Execute(int column, int row)
 {
     if (_gameBoard.GetMovableAt(column, row) is Train train)
     {
         _gameState.SetCurrentTrain(train);
     }
 }
Example #2
0
 public void Execute(int column, int row)
 {
     if (_gameBoard.GetMovableAt(column, row) is Train train)
     {
         _gameState.SetCurrentTrain(train);
     }
     else
     {
         _trackLayout.ToggleTrack(column, row);
     }
 }
Example #3
0
 public void Execute(int column, int row)
 {
     if (_gameBoard.GetMovableAt(column, row) is Train train)
     {
         _gameState.SetCurrentTrain(train);
     }
     else
     {
         if (_trackLayout.TryGet(column, row, out Track? track))
         {
             track.TryToggle();
         }
     }
 }
Example #4
0
        public void Execute(int column, int row, bool isPartOfDrag)
        {
            if (isPartOfDrag)
            {
                return;
            }

            if (_gameBoard.GetMovableAt(column, row) is Train train)
            {
                _trainManager.CurrentTrain = train;
            }
            else
            {
                if (_trackLayout.TryGet(column, row, out Track? track))
                {
                    track.NextState();
                }
            }
        }
Example #5
0
 public void Execute(int column, int row, bool isPartOfDrag)
 {
     _collection.Remove(column, row);
     if (_gameBoard.GetMovableAt(column, row) is { } moveable)
     {
         _gameBoard.RemoveMovable(moveable);
         if (_trainManager.CurrentTrain == moveable)
         {
             _trainManager.CurrentTrain = null;
         }
     }
 }
Example #6
0
 public bool IsValid(int column, int row) => _trackLayout.TryGet(column, row, out _) &&
 _gameBoard.GetMovableAt(column, row) == null;
Example #7
0
 public bool IsValid(int column, int row) => _gameBoard.GetTrackAt(column, row) != null &&
 _gameBoard.GetMovableAt(column, row) == null;