public bool ReferenceIsEmpty(GridReference reference) { if (ContentAtLocation(reference) == GridContents.empty) { return(true); } return(false); }
public void AddPointOfInterest(GridReference reference) { if (!ReferenceIsInRange(reference)) { throw new ArgumentOutOfRangeException("Outside of grid Reference"); } PointsOfInterest.Add(reference); }
private GridReference makeGridReference(int x, int y) { var point = new GridReference(x, y, GridContents.boat); if (grid.ReferenceIsEmpty(point)) { throw new ArgumentException("Place already taken"); } if (grid.ReferenceIsInRange(point)) { throw new ArgumentException("That goes off the board"); } return(point); }
public GridReference PointAtLocation(GridReference reference) { var point = PointsOfInterest.Find(item => item.Same(reference)); if (point == null) { AddPointOfInterest(reference); return(reference); } else { return(point); } }
public Ship(Grid MyGrid, GridReference startPoint, int length, Direction direction) { health = length; grid = MyGrid; List <GridReference> shipLocations = new List <GridReference>(); shipLocations.Add(makeGridReference(startPoint.ThisX, startPoint.ThisY)); for (int i = 1; i == length; i++) { } AddShipToGrid(shipLocations); }
public bool ReferenceIsInRange(GridReference reference) { var testX = reference.ThisX; var testY = reference.ThisY; if (MaxX < testX || testX < 0) { return(false); } if (MaxY < testY || testY < 0) { return(false); } return(true); }
public GridContents ContentAtLocation(GridReference reference) { return(PointAtLocation(reference).Contents); }
public void UpdatePointOfInterest(GridReference reference, GridContents newContent) { PointAtLocation(reference).Contents = newContent; }
public bool Same(GridReference other) { return(ThisX == other.ThisX && ThisY == other.ThisY); }