/** * @method PathToLocation * @param Vector3 Location The location to path to * @return Vector2[] * Create a set of positions that mark out the points that are to be plotted * between the Movable body's Location and the one provided. * Specifically it * - Gets the cardinal direction from current movable body's location to input location * - Plots x tiles in the given direction * - The number of tiles is dermined by colliders that block movemement, * and distance from Location (it will not surpass it by the magnitude diff between the Movable body and Location) */ private Vector2[] PathToLocation(Vector3 Location) { List <Vector2> positions = new List <Vector2>(); ArrowDirection travelDirection = ArrowDirectionUtil.GetBestFitRelativeCardinalDirection( Movable.GetPosition(), Location ); Vector3 dir = Quaternion.Euler(0, 0, (float)travelDirection + 180) * Vector2.up; //Debug.DrawLine(Movable.GetPosition(), Location, new Color(0f, 1f, 0f)); int distance = (int)Mathf.Round(((Vector2)Location - (Vector2)Movable.GetPosition()).magnitude); positions.AddRange(PlotUntilCollision(Movable.GetPosition(), dir, distance)); return(positions.ToArray()); }
public void AddPlotPoint(Vector2 Point) { ArrowDirection Dir = ArrowDirection.Undefined; if (Points.Count != PlotPointIndex++) { return; } if (Points.Count >= 1) { Dir = ArrowDirectionUtil.GetBestFitRelativeCardinalDirection(Points[Points.Count - 1].Point, Point); } PlottableArrowPoint ArrowPoint = new PlottableArrowPoint(Point, Dir); Points.Add(ArrowPoint); }