Example #1
0
 public bool ReferenceIsEmpty(GridReference reference)
 {
     if (ContentAtLocation(reference) == GridContents.empty)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
 public void AddPointOfInterest(GridReference reference)
 {
     if (!ReferenceIsInRange(reference))
     {
         throw new ArgumentOutOfRangeException("Outside of grid Reference");
     }
     PointsOfInterest.Add(reference);
 }
Example #3
0
        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);
        }
Example #4
0
        public GridReference PointAtLocation(GridReference reference)
        {
            var point = PointsOfInterest.Find(item => item.Same(reference));

            if (point == null)
            {
                AddPointOfInterest(reference);
                return(reference);
            }
            else
            {
                return(point);
            }
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
 public GridContents ContentAtLocation(GridReference reference)
 {
     return(PointAtLocation(reference).Contents);
 }
Example #8
0
 public void UpdatePointOfInterest(GridReference reference, GridContents newContent)
 {
     PointAtLocation(reference).Contents = newContent;
 }
Example #9
0
 public bool Same(GridReference other)
 {
     return(ThisX == other.ThisX && ThisY == other.ThisY);
 }