private static void EulerTo(Transform trans, Vector3 start, Vector3 end, BehaviourTimeCallback beh) { if (trans != null) { trans.eulerAngles = GeoUtils.Interpolation(start, end, beh.Percent); } }
private static void LocalMoveTo(Transform trans, Vector3 start, Vector3 end, BehaviourTimeCallback beh) { if (trans != null) { trans.localPosition = GeoUtils.Interpolation(start, end, beh.Percent); } }
public void Append(BehaviourTimeCallback callback, float duration) { if (State == ThreeState.Ready) { // 以当前最大结束时间作为开始时间点 Insert(MaxDuration, callback, duration); } }
public void Insert(float time, BehaviourTimeCallback callback, float duration) { if (State == ThreeState.Ready) { callback.SetStartTime(time, duration); Behaviours.Add(callback); float target = time + duration; MaxDuration = Math.Max(MaxDuration, target); } }
public static BehaviourTimeCallback LocalMoveTo(this Transform trans, Vector3 end) { Callback <Transform, Vector3, Vector3, BehaviourTimeCallback> callback = new Callback <Transform, Vector3, Vector3, BehaviourTimeCallback>(); callback.Arg1 = trans; callback.Arg2 = trans.localPosition; callback.Arg3 = end; callback.Handler = (Action <Transform, Vector3, Vector3, BehaviourTimeCallback>)LocalMoveTo; BehaviourTimeCallback beh = new BehaviourTimeCallback(callback); callback.Arg4 = beh; return(beh); }
public static BehaviourTimeCallback RotateTo(this Transform trans, Quaternion end) { Callback <Transform, Quaternion, Quaternion, BehaviourTimeCallback> callback = new Callback <Transform, Quaternion, Quaternion, BehaviourTimeCallback>(); callback.Arg1 = trans; callback.Arg2 = trans.rotation; callback.Arg3 = end; callback.Handler = (Action <Transform, Quaternion, Quaternion, BehaviourTimeCallback>)RotateTo; BehaviourTimeCallback beh = new BehaviourTimeCallback(callback); callback.Arg4 = beh; return(beh); }
public static BehaviourTimeCallback EulerTo(this Transform trans, Vector3 end) { Callback <Transform, Vector3, Vector3, BehaviourTimeCallback> callback = new Callback <Transform, Vector3, Vector3, BehaviourTimeCallback>(); callback.Arg1 = trans; callback.Arg2 = trans.eulerAngles; callback.Arg3 = end; callback.Handler = (Action <Transform, Vector3, Vector3, BehaviourTimeCallback>)EulerTo; BehaviourTimeCallback beh = new BehaviourTimeCallback(callback); callback.Arg4 = beh; return(beh); }
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); }
private static void LocalRotateTo(Transform trans, Quaternion start, Quaternion end, BehaviourTimeCallback beh) { if (trans != null) { // 采用线性插值 trans.localRotation = Quaternion.Lerp(start, end, beh.Percent); } }
private static void PathTo(FixedPathController pathCtl, BehaviourTimeCallback beh) { pathCtl.Update(Time.deltaTime); }