public MovementPlanRequester(Player player, PlayerMover playerMover) { _player = player; _movementPlanner = new MovementPlanner(_player, 5f); playerMover.MovementPlanRequested += RequestNextPlan; }
public MapManager() { terrainMap_ = new TerrainMap(new Vector3D(0, 0, 0), new Vector3D(0, 0, 0)); movementPlanner_ = new MovementPlanner(new Vector2D(0, 0), new Vector2D(0, 0)); numPoints_ = 0; CurrentLocation = new Vector3D(0, 0, 0); UpDirection = new Vector3D(0, 1, 0); X_Axis = new Vector3D(1, 0, 0); Y_Axis = new Vector3D(0, 0, 1); }
/// <summary> /// Generates a movement planner from a terrain map with a valid up direction. /// </summary> /// <remarks>Does not copy points. Must be done before adding any points.</remarks> public void GenerateMovementPlanner() { var groundPlane = new PlaneD(CurrentLocation, UpDirection); var referenceCenter = new Vector3D(terrainMap_.Center); var projectedCenter = groundPlane.ProjectPoint(ref referenceCenter); var projectedCenterX = (projectedCenter - CurrentLocation).Dot(X_Axis); var projectedCenterY = (projectedCenter - CurrentLocation).Dot(Y_Axis); var flatCenter = new Vector2D(projectedCenterX, projectedCenterY); var referenceExtents = new Vector3D(terrainMap_.Extents); var projectedExtents = groundPlane.ProjectPoint(ref referenceExtents); var maxExtent = Math.Abs((projectedExtents - CurrentLocation).Dot(X_Axis)); maxExtent = Math.Max(maxExtent, Math.Abs((projectedExtents - CurrentLocation).Dot(Y_Axis))); var flatExtents = new Vector2D(maxExtent, maxExtent); movementPlanner_ = new MovementPlanner(flatCenter, flatExtents); }