private Vector3 mNext; // 插值的结束方向 public NavLinePosLineAngle(NavPathData pathData, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler, float frameCount) : base(pathData, offset, flipType, triggerHandler) { // 会先执行 Initialize() mFrameCountInv = 1.0f / frameCount; mCurFrame = 0; CurInfo.isDirChanged = true; UpdatePosAndTangent(); CurInfo.curveDir = mNext; mLast = mNext; }
public static bool Flip(NavPathFlipType type, ref Vector2 value) { int idx = 0; int t = (int)type; while ((t & (1 << idx)) != 0 && idx < 2) { value[idx] = Flip((NavPathFlipType)(1 << idx), value[idx]); idx++; } return(true); }
public static bool Flip(NavPathFlipType type, Vector4 value, out Vector4 outV) { outV = value; int idx = 0; int t = (int)type; while ((t & (1 << idx)) != 0 && idx < 4) { outV[idx] = Flip((NavPathFlipType)(1 << idx), value[idx]); idx++; } return(true); }
private static float Flip(NavPathFlipType type, float v) { switch (type) { case NavPathFlipType.None: return(v); case NavPathFlipType.X: case NavPathFlipType.Y: case NavPathFlipType.Z: case NavPathFlipType.W: return(-v); } return(v); }
public NavPointFixed(NavPathData pathData, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler) : base(pathData, offset, flipType, triggerHandler) { }
public static BehaviourCallback NavPathTo(this Transform trans, float duration, List <Vector3> waypoints, Vector3 offset, IPathTrigger triggerHandler = null, NavPathFlipType flipType = NavPathFlipType.None, NavPathMoveType pathType = NavPathMoveType.LinePosLineDir, int subdivisions = 5, float pathLength = 0.0f) { NavPathController pathCtrl = new NavPathController(); AbstractNavPath navPath = NavPathUtils.Create(pathType, offset, flipType, triggerHandler, waypoints, subdivisions, pathLength); pathCtrl.StartMove(navPath, navPath.PathLength / duration); pathCtrl.mCtlPosition = trans; pathCtrl.mCtlRotate = trans; Callback2 <NavPathController, BehaviourCallback> callback = new Callback2 <NavPathController, BehaviourCallback>(); callback.Arg1 = pathCtrl; callback.Handler = (Action <NavPathController, BehaviourCallback>)PathTo; BehaviourCallback beh = new BehaviourCallback(callback, callback, callback); callback.Arg2 = beh; return(beh); }
public static AbstractNavPath Create(NavPathMoveType pathType, NavPathData pathData, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler) { AbstractNavPath navPath = null; if (pathData.WayPoints.Count == 1) { pathType = NavPathMoveType.Fixed; } else if (pathData.WayPoints.Count == 2) { pathType = NavPathMoveType.LinePosLineDir; // DebugUtils.Log(InfoType.Warning, "AbstractNavPath Create LineType, Not " + EnumUtils.EnumToString(pathType)); } switch (pathType) { case NavPathMoveType.Fixed: navPath = new NavPointFixed(pathData, offset, flipType, triggerHandler); break; case NavPathMoveType.CurvePosCurveDir: navPath = new NavCurvePosCurveDir(pathData, offset, flipType, triggerHandler); break; case NavPathMoveType.LinePosLineDir: navPath = new NavLinePosLineDir(pathData, offset, flipType, triggerHandler); break; case NavPathMoveType.LinePosLineAngle: navPath = new NavLinePosLineAngle(pathData, offset, flipType, triggerHandler, 10); break; case NavPathMoveType.LinePosCurveDir: navPath = new NavLinePosCurveDir(pathData, offset, flipType, triggerHandler); break; default: DebugUtils.Log(InfoType.Error, "AbstractNavPath Create Not Supported " + EnumUtils.EnumToString(pathType)); break; } return(navPath); }
public static AbstractNavPath Create(NavPathMoveType pathType, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler, List <Vector3> waypoints, int subdivisions = 5, float pathLength = 0.0f) { NavPathData pathData = CreatePathData(waypoints, subdivisions, pathLength); return(Create(pathType, pathData, offset, flipType, triggerHandler)); }
public NavCurvePosCurveDir(NavPathData pathData, Vector3 offset, NavPathFlipType flipType, IPathTrigger triggerHandler) : base(pathData, offset, flipType, triggerHandler) { }