コード例 #1
0
		public List<LocationOfInterest> GetInterestingLocations(Avatar observer)
		{
			List<LocationOfInterest> locationsOfInterest = new List<LocationOfInterest>();

			MapTile observerTile = _quest.GetAvatarMapTile(observer);
			Point observerLocation = _quest.Map.GetMapTileLocation(observerTile);
			PointList visibleLocations = _quest.Map.GetPointsWithinLineOfSightOf(observerLocation);

			//// Get a list of all actionable map tiles
			PointList interestingLocations = _quest.Map.GetActionableMapPoints(observer.Faction);
			
			// Filter out interesting locations that are not in the visible set
			PointList visibleInterestingLocations = interestingLocations.Intersects(visibleLocations);

			// Create paths to each of these points
			PathfindingNode observerNode = _quest.Map.GetPathfindingNodeForTile(observerTile);
			foreach (Point point in visibleInterestingLocations)
			{
				PathfindingNode pointNode = _quest.Map.GetPathfindingNodeForLocation(point.X, point.Y);
				List<PathfindingNode> path = _quest.Map.PathfindingGraph.FindRoute(observerNode, pointNode);
				if (path != null)
				{
					PointList pathSteps = new PointList();
					for (int i = 1; i < path.Count; i++)
					{ pathSteps.Add(_quest.Map.GetPointForPathfindingNode(path[i])); }

					LocationOfInterest interest = new LocationOfInterest(pathSteps);
					locationsOfInterest.Add(interest);
				}
			}

			return locationsOfInterest;
		}
コード例 #2
0
		public List<LocationOfInterest> GetInterestingLocationsCheating(Avatar observer)
		{
			List<LocationOfInterest> locationsOfInterest = new List<LocationOfInterest>();

			MapTile observerTile = _quest.GetAvatarMapTile(observer);
			Point observerLocation = _quest.Map.GetMapTileLocation(observerTile);
			PointList visibleLocations = _quest.Map.GetPointsWithinLineOfSightOf(observerLocation);

			//// Get a list of all actionable map tiles
			PointList interestingLocations = _quest.Map.GetActionableMapPoints(observer.Faction);

			// Find the closest location by straight-line distance.  It was too expensive to calculate Pathfinding distance.
			PathfindingNode observerNode = _quest.Map.GetPathfindingNodeForTile(observerTile);
			Point closestDistanceInterestingLocation = null;
			double closestDistance = float.MaxValue;
			foreach (Point point in interestingLocations)
			{
				double distance = Math.Sqrt(Math.Pow(observerLocation.X - point.X, 2) + Math.Pow(observerLocation.Y - point.Y, 2));
				if (distance < closestDistance)
				{
					closestDistanceInterestingLocation = point;
					closestDistance = distance;
				}
			}

			if (closestDistanceInterestingLocation != null)
			{
				PathfindingNode pointNode = _quest.Map.GetPathfindingNodeForLocation(closestDistanceInterestingLocation.X, closestDistanceInterestingLocation.Y);
				List<PathfindingNode> path = _quest.Map.PathfindingGraph.FindRoute(observerNode, pointNode);
				if (path != null)
				{
					PointList pathSteps = new PointList();
					for (int i = 1; i < path.Count; i++)
					{ pathSteps.Add(_quest.Map.GetPointForPathfindingNode(path[i])); }

					LocationOfInterest interest = new LocationOfInterest(pathSteps);
					locationsOfInterest.Add(interest);
					return locationsOfInterest;
				}
			}

			return locationsOfInterest;
		}