コード例 #1
0
        private void drawPixel(int x, int y, MapElementStatus status)
        {
            if (_trackingMap[x, y] != status)
            {
                _trackingMap[x, y] = status;

                switch (status)
                {
                    case MapElementStatus.Waypoint:
                        _bm.SetPixel(x, y, System.Drawing.Color.DarkRed);
                        break;
                    case MapElementStatus.Visited:
                        _bm.SetPixel(x, y, System.Drawing.Color.DeepPink);
                        break;
                    case MapElementStatus.Blocked:
                        _bm.SetPixel(x, y, System.Drawing.Color.Black);
                        break;
                    case MapElementStatus.Collided:
                        _bm.SetPixel(x, y, System.Drawing.Color.Red);
                        break;
                    case MapElementStatus.WaypointVisited:
                        _bm.SetPixel(x, y, System.Drawing.Color.Blue);
                        break;
                    case MapElementStatus.Discovered:
                        _bm.SetPixel(x, y, System.Drawing.Color.SkyBlue);
                        break;
                }
            }
        }
コード例 #2
0
        public void UpdateSensordata(MapElementStatus[,] arrMap, Point posRobot)
        {
            int widthSensorMap = arrMap.GetLength(0);
            int heightSensorMap = arrMap.GetLength(1);

            int offsetLeft = (widthSensorMap - 800) / 2;
            int offsetTop = (heightSensorMap - 600) / 2;

            for (int i = offsetLeft; i < 800 + offsetLeft; i++)
            {
                for (int j = offsetTop; j < 600 + offsetTop; j++)
                {
                    // nur überschreiben wenn Undiscovered
                    if (_map[i - offsetLeft, j - offsetTop] == MapElementStatus.Undiscovered)
                    {
                        MapElementStatus status = offsetLeft < 0 || offsetTop < 0 ? MapElementStatus.Undiscovered : arrMap[i, j];

                        if (status == MapElementStatus.TargetShadowed)
                        {

                        }


						if (_conversationDictionary.Keys.Any(k => k == status))
						{

							_map[i - offsetLeft, j - offsetTop] = _conversationDictionary[status];
						}
                    }
                }
            }
        }
コード例 #3
0
        protected Point GetRandomPoint(MapElementStatus status)
        {
            _point.X = _random.Next(0, 800);
            _point.Y = _random.Next(0, 600);
            _point.Status = status;

            return _point;
        }
コード例 #4
0
		private bool IsEdgeField(int x, int y, MapElementStatus[,] map)
		{
			const MapElementStatus status = MapElementStatus.Undiscovered;

			return IsFieldBorderSafe(x - 1, y, map, status)
					|| IsFieldBorderSafe(x, y - 1, map, status)
					|| IsFieldBorderSafe(x + 1, y, map, status)
					|| IsFieldBorderSafe(x, y + 1, map, status);
		}
コード例 #5
0
		private bool IsFieldBorderSafe(int x, int y, MapElementStatus[,] map, MapElementStatus status)
		{
			if (x < 0 || y < 0 || x > map.GetUpperBound(Constants.XDimension) || y > map.GetUpperBound(Constants.YDimension))
			{
				return false;
			}

			return map[x, y] == status;
		}
コード例 #6
0
		public static void StoreAsBitmap(string path, MapElementStatus[,] data)
		{
			var bitmap = new Bitmap(data.GetUpperBound(0), data.GetUpperBound(1));

			for (int x = 0; x < data.GetUpperBound(0); x++)
			{
				for (int y = 0; y < data.GetUpperBound(1); y++)
				{
					bitmap.SetPixel(x, y, ColorCode[data[x, y]]);
				}
			}

			// bitmap.Save(path);
		}
コード例 #7
0
        /// <summary>
        /// Will detect all edges with in the area, but ignore the outer most pixels.
        /// </summary>
        /// <param name="map">2D Array of MapElementStatus.</param>
        /// <returns>List of Edge Points.</returns>
		public List<Point> GetEdgePoints(MapElementStatus[,] map)
		{
			List<Point> edgePoints = new List<Point>();

			for (var x = 1; x <= map.GetUpperBound(Constants.XDimension) - 2; x++)
			{
                for (var y = 1; y <= map.GetUpperBound(Constants.YDimension) - 2; y++)
				{
					if (map[x, y] == MapElementStatus.Discovered && IsEdgeField(x, y, map))
					{
						edgePoints.Add(new Point(x, y));
					}
				}
			}

			return edgePoints;
		}
コード例 #8
0
 public void SetStatus(double x, double y, MapElementStatus status)
 {
     SetStatus((int)x, (int)y, status);
 }
コード例 #9
0
 public void SetStatus(int x, int y, MapElementStatus status)
 {
     if(_map[x, y] != status) _map[x, y] = status;
 }
コード例 #10
0
        private MapElementStatus[,] GetBaseFieldMap(Bitmap bitmap)
        {
            MapElementStatus[,] map = new MapElementStatus[bitmap.Width, bitmap.Height];

            for (int x = 0; x < bitmap.Width; x++)
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    if (bitmap.GetPixel(x, y).R < 125)
                    {
                        map[x, y] = MapElementStatus.Blocked;
                    }
                    else if (bitmap.GetPixel(x, y).R <= 255 && bitmap.GetPixel(x, y).B <= 100)
                    {
                        map[x, y] = MapElementStatus.Target;
                    }
                }
            }

            return map;
        }
コード例 #11
0
        private void SpawnShadow(CartesianArray<MapElementStatus> viewport, Point point, Area area, MapElementStatus elementType, double ratio, Modifiers modifier, bool increaseX)
        {
            int xdistance = 0;
            int ydistance = 0;

            bool first = true;

            var curentPoint = new Point(point.X + xdistance, point.Y + ydistance);
            Point lastPoint = null;

            do
            {
                viewport[curentPoint] =
                    first ? elementType : 
                        (viewport[curentPoint] == MapElementStatus.Undiscovered ? MapElementStatus.Shadowed: viewport[curentPoint] );

                first = false;

                if (increaseX)
                {
                    xdistance += modifier.X;
                    ydistance = Convert.ToInt32(Math.Floor(ratio * xdistance * modifier.X * modifier.Y));
                }
                else
                {
                    ydistance += modifier.Y;
                    xdistance = Convert.ToInt32(Math.Floor(ratio * ydistance * modifier.X * modifier.Y));
                }
                lastPoint = curentPoint;
                curentPoint = new Point(point.X + xdistance, point.Y + ydistance);

                if (Math.Abs(lastPoint.X - curentPoint.X) > 1 || Math.Abs(lastPoint.Y -curentPoint.Y) > 1)
                {
                    
                }

            } while (IsInbound(curentPoint, area));
        }
コード例 #12
0
        private void SpawnShadow(CartesianArray<MapElementStatus> viewport, Point point, Area area, MapElementStatus elementType)
        {         
			bool increaseX = Math.Abs(point.X) > Math.Abs(point.Y);
			double ratio = 0.0;

            var modifier = new Modifiers(point.X > 0 ? 1 : -1, point.Y > 0 ? 1 : -1);

			if (point.X != 0 && point.Y != 0)
			{
                double x = Math.Abs(point.X);
                double y = Math.Abs(point.Y);
                ratio = Math.Abs(increaseX ? y / x : x / y);
            }

            SpawnShadow(viewport, point, area, elementType, ratio, modifier, increaseX);
        }
コード例 #13
0
 private MapElementStatus GetStatusToSpawnFor(MapElementStatus status)
 {
     return status == MapElementStatus.Blocked
                ? MapElementStatus.BlockedShadowed
                : MapElementStatus.TargetShadowed;
 }
コード例 #14
0
 public TrackingMapEntry()
 {
     status = MapElementStatus.Undiscovered;
 }