/// <summary> /// Used when show Route Path toggle is checked /// </summary> void UpdateRoutePathLine(float x, float y) { if (pathLine != null) // remove existing line { DestroyImmediate(pathLine.gameObject); } // Find a route for this tank to destination Vector2 destination = new Vector2(x, y); List <Vector2> route = tank.FindRoute(destination); if (route == null) { // Draw a straight red line if no route is available pathLine = map.AddLine(tank.currentMap2DLocation, destination, Color.red, pathArcElevation, pathLineWidth); } else { pathLine = map.AddLine(route.ToArray(), Color.yellow, pathArcElevation, pathLineWidth); } pathLine.drawingDuration = pathDrawingDuration; pathLine.dashInterval = pathDashInterval; pathLine.dashAnimationDuration = pathDashAnimationDuration; UpdateCircle(destination); }
public static List <Vector2> WMSK_FindRoute(this GameObject o, Vector2 destination) { GameObjectAnimator anim = o.GetComponent <GameObjectAnimator>() ?? o.AddComponent <GameObjectAnimator>(); return(anim.FindRoute(destination)); }