Exemple #1
0
 private DivinedSectorResult GetTopRightEdgeResult(Location locationToExamine,
                                                   DivinedSectorResult result,
                                                   ICoordinate regionCoordinateToGet)
 {
     if (this.OffTopRightEdge(locationToExamine))
     {
         result = result.Get("topRight",
                             regionCoordinateToGet.X,
                             regionCoordinateToGet.Y -= 1,
                             Sector.SDecrement(locationToExamine.Sector.X),
                             Sector.SIncrement(locationToExamine.Sector.Y),
                             0,
                             7);
     }
     return(result);
 }
Exemple #2
0
 private DivinedSectorResult GetBottomLeftEdgeResult(Location locationToExamine,
                                                     DivinedSectorResult result,
                                                     ICoordinate regionCoordinateToGet)
 {
     if (this.OffBottomLeftEdge(locationToExamine))
     {
         result = result.Get("bottomLeft",
                             regionCoordinateToGet.X -= 1,
                             regionCoordinateToGet.Y, // -= 1
                             Sector.SIncrement(locationToExamine.Sector.X),
                             Sector.SDecrement(locationToExamine.Sector.Y),
                             7,
                             0);
     }
     return(result);
 }
Exemple #3
0
 private DivinedSectorResult GetLeftEdgeResult(Location locationToExamine,
                                               DivinedSectorResult result,
                                               ICoordinate regionCoordinateToGet,
                                               ICoordinate sectorCoordinateToGet)
 {
     if (this.OffLeftEdge(locationToExamine))
     {
         result = result.Get("left",
                             regionCoordinateToGet.X -= 1,
                             regionCoordinateToGet.Y,
                             sectorCoordinateToGet.X,
                             Sector.SDecrement(locationToExamine.Sector.Y),
                             7,
                             locationToExamine.Sector.X);
     }
     return(result);
 }
Exemple #4
0
 private DivinedSectorResult GetRightEdgeResult(Location locationToExamine,
                                                DivinedSectorResult result,
                                                ICoordinate regionCoordinateToGet,
                                                ICoordinate sectorCoordinateToGet)
 {
     if (this.OffRightEdge(locationToExamine))
     {
         result = result.Get("right",
                             regionCoordinateToGet.X += 1,
                             regionCoordinateToGet.Y,
                             sectorCoordinateToGet.X,
                             Sector.SIncrement(locationToExamine.Sector.Y),
                             0,
                             locationToExamine.Sector.X);
     }
     return(result);
 }
Exemple #5
0
 private DivinedSectorResult GetBottomEdgeResult(Location locationToExamine,
                                                 DivinedSectorResult result,
                                                 ICoordinate regionCoordinateToGet,
                                                 ICoordinate sectorCoordinateToGet)
 {
     if (this.OffBottomEdge(locationToExamine))
     {
         result = result.Get("bottom",
                             regionCoordinateToGet.X,
                             regionCoordinateToGet.Y += 1,
                             Sector.SIncrement(locationToExamine.Sector.X),
                             sectorCoordinateToGet.Y,
                             locationToExamine.Sector.Y,
                             0);
     }
     return(result);
 }
Exemple #6
0
 private DivinedSectorResult GetBottomRightEdgeResult(Location locationToExamine,
                                                      DivinedSectorResult result,
                                                      ICoordinate regionCoordinateToGet,
                                                      ICoordinate sectorCoordinateToGet)
 {
     if (this.OffBottomRightEdge(locationToExamine))
     {
         result = result.Get("bottomRight",
                             regionCoordinateToGet.X += 1,
                             regionCoordinateToGet.Y += 1,
                             Sector.SIncrement(locationToExamine.Sector.X),
                             sectorCoordinateToGet.Y, //todo:  This shows as 8, but current position needs to be fixed.  don't fix here.
                             0,
                             0);
     }
     return(result);
 }
Exemple #7
0
        /// <summary>
        /// Returns map Location info on the location Requested.
        /// If passed an area not in region passed, example: {ThisRegion}.[-1, 0], then the proper location will be divined & returned.
        /// </summary>
        /// <param name="locationToExamine"></param>
        /// <param name="map"></param>
        /// <returns></returns>
        public Location DivineSectorOnMap(Location locationToExamine, IMap map)
        {
            var result = new DivinedSectorResult();

            //todo: perhaps this code needs to be in the constructor -------------
            result.RegionCoordinateToGet = locationToExamine.Region;
            result.SectorCoordinateToGet = (Coordinate)locationToExamine.Sector;
            result.CurrentLocationX      = locationToExamine.Sector.X;
            result.CurrentLocationY      = locationToExamine.Sector.Y;
            result.Direction             = "Here";
            //todo: perhaps this code needs to be in the constructor -------------

            var locationToGet         = new Location();
            var regionCoordinateToGet = new Coordinate(locationToExamine.Region.X, locationToExamine.Region.Y, false);
            var sectorCoordinateToGet = new Coordinate(locationToExamine.Sector.X, locationToExamine.Sector.Y, false);

            result = this.GetLeftEdgeResult(locationToExamine, result, regionCoordinateToGet, sectorCoordinateToGet);
            result = this.GetRightEdgeResult(locationToExamine, result, regionCoordinateToGet, sectorCoordinateToGet);
            result = this.GetTopEdgeResult(locationToExamine, result, regionCoordinateToGet, sectorCoordinateToGet);
            result = this.GetBottomEdgeResult(locationToExamine, result, regionCoordinateToGet, sectorCoordinateToGet);

            result = this.GetBottomRightEdgeResult(locationToExamine, result, regionCoordinateToGet, sectorCoordinateToGet);
            result = this.GetTopRightEdgeResult(locationToExamine, result, regionCoordinateToGet);
            result = this.GetTopLeftEdgeResult(locationToExamine, result, regionCoordinateToGet);
            result = this.GetBottomLeftEdgeResult(locationToExamine, result, regionCoordinateToGet);

            if (result.RegionCoordinateToGet == null)
            {
                string error;
                throw new ArgumentException();
            }

            locationToGet.Region = Regions.Get(map, new Coordinate(result.RegionCoordinateToGet.X, result.RegionCoordinateToGet.Y, false));

            if (locationToGet.Region.Type != RegionType.GalacticBarrier)
            {
                //todo: moving to the 7th column in sector breaks things?
                locationToGet.Sector = locationToGet.Region.Sectors.Single(s => s.X == result.CurrentLocationX && s.Y == result.CurrentLocationY);
            }

            return(locationToGet);
        }