Exemplo n.º 1
0
        public GridBuilder WithSquareStatus(GridCoordinate coordinate, GridSquareStatus status)
        {
            var squareBuilder = _squareBuilders[coordinate.Row, coordinate.Column];

            squareBuilder.WithStatus(status);

            return(this);
        }
Exemplo n.º 2
0
 public GridSquareArrayBuilder WithStatus(GridSquareStatus status)
 {
     for (int i = 0; i < _gridSquareMocks.Length; i++)
     {
         _gridSquareMocks[i] = new GridSquareBuilder().WithStatus(status).BuildMock();
     }
     return this;
 }
Exemplo n.º 3
0
 public GridSquareBuilder WithStatus(GridSquareStatus status)
 {
     _gridSquareMock.SetupGet(s => s.Status).Returns(status);
     if (status != GridSquareStatus.Untouched)
     {
         _gridSquareMock.SetupGet(s => s.NumberOfBombs).Returns(1);
     }
     return(this);
 }
Exemplo n.º 4
0
 public GridBuilder WithAllSquaresWithStatus(GridSquareStatus status)
 {
     for (int i = 0; i < _size; i++)
     {
         for (int j = 0; j < _size; j++)
         {
             var squareBuilder = _squareBuilders[i, j];
             squareBuilder.WithStatus(status);
         }
     }
     return(this);
 }
 public CADGridSquare()
 {
     image  = Resources.Load <Sprite>("square");
     status = GridSquareStatus.Available;
 }
Exemplo n.º 6
0
        private List <GridCoordinate> GetNeighbours(GridCoordinate coordinate, Direction[] possibleDirections, GridSquareStatus withStatus)
        {
            List <GridCoordinate> result = new List <GridCoordinate>();

            foreach (Direction direction in possibleDirections)
            {
                GridCoordinate otherCoordinate = coordinate.GetNeighbor(direction);
                if (!otherCoordinate.IsOutOfBounds(this.opponentGrid.Size))
                {
                    IGridSquare otherSquare = this.opponentGrid.GetSquareAt(otherCoordinate);

                    if (otherSquare.Status == withStatus)
                    {
                        result.Add(otherCoordinate);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 7
0
 protected virtual void Miss()
 {
     Status = GridSquareStatus.MISS;
 }
Exemplo n.º 8
0
 protected virtual void Hit()
 {
     Status = GridSquareStatus.HIT;
     OnChanged(EventArgs.Empty);
 }
Exemplo n.º 9
0
 public ShipBuilder WithSquares(GridSquareStatus status = GridSquareStatus.Untouched)
 {
     _shipMock.SetupGet(s => s.Squares).Returns(new GridSquareArrayBuilder(_kind).WithStatus(status).BuildArray());
     return(this);
 }