public static AbstractNavPath Create(NavPathType pathType, NavPathData pathData, Vector3 offset, bool pathFlipOn, IPathTrigger triggerHandler) { AbstractNavPath navPath = null; if (pathData.WayPoints.Count == 2 && pathType != NavPathType.LinePosLineDir) { pathType = NavPathType.LinePosLineDir; DebugUtils.Warning("AbstractNavPath", "Create LineType, Not ", EnumUtils.EnumToString(pathType)); } switch (pathType) { case NavPathType.CurvePosCurveDir: navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler); break; case NavPathType.LinePosLineDir: navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler); break; case NavPathType.LinePosLineAngle: navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler); break; case NavPathType.LinePosCurveDir: navPath = new NavCurvePosCurveDir(pathData, offset, pathFlipOn, triggerHandler); break; default: DebugUtils.Error("AbstractNavPath", "Create Not Supported ", EnumUtils.EnumToString(pathType)); break; } return(navPath); }
public static AbstractNavPath Create(NavPathType pathType, Vector3 offset, bool pathFlipOn, IPathTrigger triggerHandler, List <Vector3> waypoints, int subdivisions = 5) { NavPathData pathData = CreatePathData(waypoints, subdivisions); return(Create(pathType, pathData, offset, pathFlipOn, triggerHandler)); }
public static BehaviourTimeCallback PathTo(this Transform trans, float duration, List <Vector3> waypoints, NavPathType pathType = NavPathType.LinePosLineDir, int subdivisions = 5) { FixedPathController pathCtrl = new FixedPathController(); AbstractNavPath navPath = NavPathUtils.Create(pathType, Vector3.zero, false, null, waypoints, subdivisions); pathCtrl.StartMove(navPath, navPath.PathLength / duration, Vector3.zero, false); pathCtrl.mCtlPosition = trans; pathCtrl.mCtlRotate = trans; Callback <FixedPathController, BehaviourTimeCallback> callback = new Callback <FixedPathController, BehaviourTimeCallback>(); callback.Arg1 = pathCtrl; callback.Handler = (Action <FixedPathController, BehaviourTimeCallback>)PathTo; BehaviourTimeCallback beh = new BehaviourTimeCallback(callback); callback.Arg2 = beh; return(beh); }