예제 #1
0
        public GridBuilder WithSquareStatus(GridCoordinate coordinate, GridSquareStatus status)
        {
            var squareBuilder = _squareBuilders[coordinate.Row, coordinate.Column];

            squareBuilder.WithStatus(status);

            return(this);
        }
예제 #2
0
 public GridSquareArrayBuilder WithStatus(GridSquareStatus status)
 {
     for (int i = 0; i < _gridSquareMocks.Length; i++)
     {
         _gridSquareMocks[i] = new GridSquareBuilder().WithStatus(status).BuildMock();
     }
     return this;
 }
예제 #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);
 }
예제 #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;
 }
예제 #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);
        }
예제 #7
0
 protected virtual void Miss()
 {
     Status = GridSquareStatus.MISS;
 }
예제 #8
0
 protected virtual void Hit()
 {
     Status = GridSquareStatus.HIT;
     OnChanged(EventArgs.Empty);
 }
예제 #9
0
 public ShipBuilder WithSquares(GridSquareStatus status = GridSquareStatus.Untouched)
 {
     _shipMock.SetupGet(s => s.Squares).Returns(new GridSquareArrayBuilder(_kind).WithStatus(status).BuildArray());
     return(this);
 }