Example #1
0
        public MapPoint GetCellInDirection(DirectionsEnum direction, short step)
        {
            MapPoint mapPoint = null;

            switch (direction)
            {
            case DirectionsEnum.DIRECTION_EAST:
                mapPoint = MapPoint.GetPoint(this.m_x + (int)step, this.m_y + (int)step);
                break;

            case DirectionsEnum.DIRECTION_SOUTH_EAST:
                mapPoint = MapPoint.GetPoint(this.m_x + (int)step, this.m_y);
                break;

            case DirectionsEnum.DIRECTION_SOUTH:
                mapPoint = MapPoint.GetPoint(this.m_x + (int)step, this.m_y - (int)step);
                break;

            case DirectionsEnum.DIRECTION_SOUTH_WEST:
                mapPoint = MapPoint.GetPoint(this.m_x, this.m_y - (int)step);
                break;

            case DirectionsEnum.DIRECTION_WEST:
                mapPoint = MapPoint.GetPoint(this.m_x - (int)step, this.m_y - (int)step);
                break;

            case DirectionsEnum.DIRECTION_NORTH_WEST:
                mapPoint = MapPoint.GetPoint(this.m_x - (int)step, this.m_y);
                break;

            case DirectionsEnum.DIRECTION_NORTH:
                mapPoint = MapPoint.GetPoint(this.m_x - (int)step, this.m_y + (int)step);
                break;

            case DirectionsEnum.DIRECTION_NORTH_EAST:
                mapPoint = MapPoint.GetPoint(this.m_x, this.m_y + (int)step);
                break;
            }
            MapPoint result;

            if (mapPoint != null)
            {
                if (MapPoint.IsInMap(mapPoint.X, mapPoint.Y))
                {
                    result = mapPoint;
                }
                else
                {
                    result = null;
                }
            }
            else
            {
                result = null;
            }
            return(result);
        }
Example #2
0
        public static Point CellIdToCoord(uint cellId)
        {
            if (!MapPoint.m_initialized)
            {
                MapPoint.InitializeStaticGrid();
            }
            MapPoint point = MapPoint.GetPoint((short)cellId);

            return(new Point(point.X, point.Y));
        }
Example #3
0
 public static MapPoint GetPoint(Cell cell)
 {
     return(MapPoint.GetPoint(cell.Id));
 }