protected void Setup (Vector3 start, FloodPath flood, OnPathDelegate callback) { this.flood = flood; if (flood == null || flood.GetState () < PathState.Returned) { throw new System.ArgumentException ("You must supply a calculated FloodPath to the 'flood' argument"); } base.Setup (start, flood.originalStartPoint, callback); nnConstraint = new FloodPathConstraint (flood); }
/** Starts a path specified by PathTypesDemo.activeDemo */ void DemoPath () { Path p = null; if (activeDemo == DemoMode.ABPath) { p = ABPath.Construct (start.position,end.position, OnPathComplete); if (agents != null && agents.Length > 0) { List<Vector3> pts = ListPool<Vector3>.Claim(agents.Length); Vector3 avg = Vector3.zero; for (int i=0;i<agents.Length;i++) { pts.Add (agents[i].transform.position); avg += pts[i]; } avg /= pts.Count; for (int i=0;i<agents.Length;i++) pts[i] -= avg; PathUtilities.GetPointsAroundPoint (end.position, AstarPath.active.graphs[0] as IRaycastableGraph, pts, 0, 0.2f); for (int i=0;i<agents.Length;i++) { if (agents[i] == null) continue; agents[i].target.position = pts[i]; agents[i].UpdatePath(); } } } else if (activeDemo == DemoMode.MultiTargetPath) { MultiTargetPath mp = MultiTargetPath.Construct (multipoints.ToArray (), end.position, null, OnPathComplete); p = mp; } else if (activeDemo == DemoMode.RandomPath) { RandomPath rp = RandomPath.Construct (start.position,searchLength, OnPathComplete); rp.spread = spread; rp.aimStrength = aimStrength; rp.aim = end.position; p = rp; } else if (activeDemo == DemoMode.FleePath) { FleePath fp = FleePath.Construct (start.position, end.position, searchLength, OnPathComplete); fp.aimStrength = aimStrength; fp.spread = spread; p = fp; } else if (activeDemo == DemoMode.ConstantPath) { StartCoroutine(CalculateConstantPath()); p = null; } else if (activeDemo == DemoMode.FloodPath) { FloodPath fp = FloodPath.Construct (end.position, null); lastFlood = fp; p = fp; } else if (activeDemo == DemoMode.FloodPathTracer && lastFlood != null) { FloodPathTracer fp = FloodPathTracer.Construct (end.position, lastFlood, OnPathComplete); p = fp; } if (p != null) { AstarPath.StartPath (p); lastPath = p; } }
public override void Reset () { base.Reset (); flood = null; }
public static FloodPathTracer Construct (Vector3 start, FloodPath flood, OnPathDelegate callback = null) { FloodPathTracer p = PathPool<FloodPathTracer>.GetPath (); p.Setup (start, flood, callback); return p; }
public FloodPathConstraint (FloodPath path) { if (path == null) { Debug.LogWarning ("FloodPathConstraint should not be used with a NULL path"); } this.path = path; }