/** * <summary>Rotates the camera automatically to a fixed pitch and/or spin angle. Regular rotation will be disabled while this occurs.</summary> * <param name = "_controlPitch">If True, the pitch angle will be affected</param> * <param name = "_newPitchAngle">The new pitch angle, if _controlPitch = True</param> * <param name = "_controlSpin">If True, the spin angle will be affected</param> * <param name = "_newSpinAngle">The new spin angle, if _controlSpin = True</param> * <param name = "_transitionTime">The duration, in seconds, that the rotation will take</param> * <param name = "moveMethod">The movement method, if _transitionTime > 0 (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "timeCurve">The AnimationCurve that controls the change in rotation over time, if moveMethod = MoveMethod.CustomCurve</param> */ public void ForceRotation(bool _controlPitch, float _newPitchAngle, bool _controlSpin, float _newSpinAngle, float _transitionTime = 0f, MoveMethod moveMethod = MoveMethod.Linear, AnimationCurve timeCurve = null) { autoControlPitch = false; autoControlPitch = false; if (_controlPitch || _controlSpin) { if (_transitionTime > 0f) { autoControlPitch = _controlPitch; autoControlSpin = _controlSpin; autoPitchAngle = _newPitchAngle; autoSpinAngle = _newSpinAngle; autoMoveMethod = moveMethod; autoControlTime = _transitionTime; autoControlStartTime = Time.time; autoMoveCurve = timeCurve; } else { if (_controlPitch) { pitch = _newPitchAngle; } if (_controlSpin) { spin = _newSpinAngle; } } } }
public void Move(Vector3 _newVector, MoveMethod _moveMethod, float _transitionTime, TransformType _transformType) { isMoving = true; targetVector = _newVector; moveMethod = _moveMethod; transformType = _transformType; if (_transformType == TransformType.Translate) { startVector = transform.localPosition; } else if (_transformType == TransformType.Rotate) { startVector = transform.localEulerAngles; } else { startVector = transform.localScale; } moveChangeTime = _transitionTime; moveStartTime = Time.time; }
public void SetActive(int _ID, float _value, float _changeTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { if (_changeTime < 0f) { return; } activeKey = null; foreach (ShapeKey shapeKey in shapeKeys) { if (shapeKey.ID == _ID) { activeKey = shapeKey; shapeKey.targetValue = _value; } else { shapeKey.targetValue = 0f; } } moveMethod = _moveMethod; timeCurve = _timeCurve; changeTime = _changeTime; startTime = Time.time; }
public void PrepareForLanding(Vector2 landPosition, Vector2 planetPosition) { var method = new LandingMove (landPosition, planetPosition); method.Landed += MoveOnPlanet; actualMethod = method; type = MoveType.Landing; }
/** * <summary>Sets a blendshape as the "active" one, causing all others to be disabled.</summary> * <param name = "_label">The name of the blendshape to affect</param> * <param name = "_value">The value to set the active blendshape</param> * <param name = "_changeTime">The duration, in seconds, that the group's blendshapes should be affected</param> * <param name = "_moveMethod">The interpolation method by which the blendshapes are affected (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the transition speed will be follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param> */ public void SetActive(string _label, float _value, float _changeTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { if (_changeTime < 0f) { return; } activeKey = null; foreach (ShapeKey shapeKey in shapeKeys) { if (shapeKey.label == _label) { activeKey = shapeKey; shapeKey.targetValue = _value; } else { shapeKey.targetValue = 0f; } shapeKey.ResetInitialValue(); } moveMethod = _moveMethod; timeCurve = _timeCurve; changeTime = _changeTime; startTime = Time.time; }
IEnumerator BlindMoveTo(Vector3 destination, Actions moveType) { MoveMethod mover = GetMoveMethod(moveType); float distanceBefore = PlanarDistance(transform.position, destination); if (distanceBefore < Mathf.Epsilon) { yield break; } yield return(TurnDegrees(PlanarAngle(transform.forward, destination - transform.position))); actor.OnActionBegin(moveType); while (true) { mover(Vector3.forward); yield return(null); if (!IsMoving) { yield return(SmartCoroutine.Exit); } float distanceAfter = PlanarDistance(transform.position, destination); if (distanceAfter >= distanceBefore) { break; } distanceBefore = distanceAfter; } mover(Vector3.back); actor.OnActionEnd(moveType); }
public static float Interpolate(float startT, float deltaT, MoveMethod moveMethod, AnimationCurve timeCurve) { if (moveMethod == MoveMethod.Curved) { moveMethod = MoveMethod.Smooth; } else if (moveMethod == MoveMethod.Smooth) { return(-0.5f * (Mathf.Cos(Mathf.PI * (Time.time - startT) / deltaT) - 1f)); } else if (moveMethod == MoveMethod.EaseIn) { return(1f - Mathf.Cos((Time.time - startT) / deltaT * (Mathf.PI / 2))); } else if (moveMethod == MoveMethod.EaseOut) { return(Mathf.Sin((Time.time - startT) / deltaT * (Mathf.PI / 2))); } else if (moveMethod == MoveMethod.CustomCurve) { if (timeCurve == null || timeCurve.length == 0) { return(1f); } float startTime = timeCurve [0].time; float endTime = timeCurve [timeCurve.length - 1].time; return(timeCurve.Evaluate((endTime - startTime) * (Time.time - startT) / deltaT + startTime)); } return((Time.time - startT) / deltaT); }
public void SmoothChange(float _changeTime, MoveMethod method, AnimationCurve _timeCurve) { LookAtCentre(); moveMethod = method; isSmoothChanging = true; StopCrossfade(); startTime = Time.time; changeTime = _changeTime; startPosition = transform.position; startRotation = transform.rotation; startFOV = _camera.fieldOfView; startOrtho = _camera.orthographicSize; startFocalDistance = focalDistance; startPerspectiveOffset = perspectiveOffset; if (method == MoveMethod.CustomCurve) { timeCurve = _timeCurve; } else { timeCurve = null; } }
public SwitchCameraOptions(float _time, MoveMethod _method, bool _smooth, bool _waitFinish) { time = _time; method = _method; smooth = _smooth; waitFinish = _waitFinish; }
override public void ShowGUI(List <ActionParameter> parameters) { bool showWaitOption = false; returnToLast = EditorGUILayout.Toggle("Return to last gameplay?", returnToLast); if (!returnToLast) { parameterID = Action.ChooseParameterGUI("New camera:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; linkedCamera = null; } else { linkedCamera = (_Camera)EditorGUILayout.ObjectField("New camera:", linkedCamera, typeof(_Camera), true); constantID = FieldToID <_Camera> (linkedCamera, constantID); linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true); } if (linkedCamera && linkedCamera is GameCameraAnimated) { GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera; if (animatedCamera.animatedCameraType == AnimatedCameraType.PlayWhenActive && transitionTime <= 0f) { showWaitOption = true; } } } if (linkedCamera is GameCamera25D && !returnToLast) { transitionTime = 0f; } else { transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime); if (transitionTime > 0f) { moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod); showWaitOption = true; if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve); } } } if (showWaitOption) { willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } AfterRunningOption(); }
public void MoveOnPlanet(Vector2 planetPosition) { if (actualMethod is LandingMove) (actualMethod as LandingMove).Landed -= MoveOnPlanet; actualMethod = new LandMove (planetPosition); type = MoveType.LandMove; }
public ClingyPositionTweener(GameObject gameObject, TweenOptions tweenOptions, MoveMethod moveMethod, GetDestinationPositionDelegate GetDestinationPosition, TweenCompleteDelegate TweenComplete = null, TweenCancelledDelegate TweenCancelled = null) : base(gameObject, tweenOptions, TweenComplete, TweenCancelled) { this.moveMethod = moveMethod; this.GetDestinationPosition = GetDestinationPosition; }
// only server can call this public void MoveTo(Vector3 destination, MoveMethod method, float duration = 0.0f) { if (!isServer) { return; } RpcMoveToPosition(destination, method, duration); }
/// <summary> /// Set the file pointer position for the given file. /// </summary> /// <param name="distance">Offset.</param> /// <param name="moveMethod">Start position.</param> /// <returns>The new pointer position.</returns> public static long SetFilePointer(SafeFileHandle fileHandle, long distance, MoveMethod moveMethod) { if (!Imports.SetFilePointerEx(fileHandle, distance, out long position, moveMethod)) { throw Error.GetExceptionForLastError(); } return(position); }
/** * <summary>Disables all blendshapes within a ShapeGroup.</summary> * <param name = "_groupID">The unique identifier of the ShapeGroup to affect</param> * <param name = "_deltaTime">The duration, in seconds, that the group's blendshapes should be disabled</param> * <param name = "_moveMethod">The interpolation method by which the blendshapes are affected (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the transition speed will be follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param> */ public void DisableAllKeys(string _groupLabel, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { ShapeGroup shapeGroup = GetGroup(_groupLabel); if (shapeGroup != null) { shapeGroup.SetActive(-1, 0f, _deltaTime, _moveMethod, _timeCurve); } }
public void SetActiveKey (int _groupID, int _keyID, float _value, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { foreach (ShapeGroup shapeGroup in shapeGroups) { if (shapeGroup.ID == _groupID) { shapeGroup.SetActive (_keyID, _value, _deltaTime, _moveMethod, _timeCurve); } } }
public static Tweener TweenPosition(GameObject gameObject, TweenOptions tweenOptions, MoveMethod moveMethod, GetDestinationPositionDelegate GetDestinationPosition, TweenCompleteDelegate TweenComplete = null, TweenCancelledDelegate TweenCancelled = null) { Tweener tweener = new ClingyPositionTweener(gameObject, tweenOptions, moveMethod, GetDestinationPosition, TweenComplete, TweenCancelled); tweener.Start(); return(tweener); }
public void DisableAllKeys(int _groupID, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { foreach (ShapeGroup shapeGroup in shapeGroups) { if (shapeGroup.ID == _groupID) { shapeGroup.SetActive (-1, 0f, _deltaTime, _moveMethod, _timeCurve); } } }
public void DisableAllKeys(int _groupID, float _deltaTime, MoveMethod _moveMethod, AnimationCurve _timeCurve) { foreach (ShapeGroup shapeGroup in shapeGroups) { if (shapeGroup.ID == _groupID) { shapeGroup.SetActive(-1, 0f, _deltaTime, _moveMethod, _timeCurve); } } }
/// <summary> /// Set the file pointer position for the given file. /// </summary> /// <param name="distance">Offset.</param> /// <param name="moveMethod">Start position.</param> /// <returns>The new pointer position.</returns> public static long SetFilePointer(SafeFileHandle fileHandle, long distance, MoveMethod moveMethod) { long position; if (!Direct.SetFilePointerEx(fileHandle, distance, out position, moveMethod)) { throw ErrorHelper.GetIoExceptionForLastError(); } return(position); }
public void MoveFilePointer(int cbToMove, MoveMethod fMoveMethod) { if (_hFile != null) { if (SetFilePointer(_hFile, cbToMove, IntPtr.Zero, fMoveMethod) == INVALID_SET_FILE_POINTER) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } } }
/// <summary> /// 移动文件夹中的所有文件夹与文件到另一个文件夹 /// </summary> /// <param name="sourcePath">源文件夹</param> /// <param name="destPath">目标文件夹</param> public static void MoveFolder(this string sourcePath, string destPath, MoveMethod MoveMethod = MoveMethod.EqualDrive) { if (Directory.Exists(sourcePath)) { if (!Directory.Exists(destPath)) { //目标目录不存在则创建 try { Directory.CreateDirectory(destPath); } catch (Exception ex) { throw new Exception("创建目标目录失败:" + ex.Message); } } //获得源文件下所有文件 List <string> files = new List <string>(Directory.GetFiles(sourcePath)); files.ForEach(c => { string destFile = Path.Combine(new string[] { destPath, Path.GetFileName(c) }); //覆盖模式 if (File.Exists(destFile)) { File.Delete(destFile); } File.Move(c, destFile); }); //获得源文件下所有目录文件 List <string> folders = new List <string>(Directory.GetDirectories(sourcePath)); folders.ForEach(c => { string destDir = Path.Combine(new string[] { destPath, Path.GetFileName(c) }); switch (MoveMethod) { case MoveMethod.EqualDrive: //Directory.Move必须要在同一个根目录下移动才有效,不能在不同卷中移动。 Directory.Move(c, destDir); break; case MoveMethod.CrossDrive: //采用递归的方法实现 MoveFolder(c, destDir); break; } }); } else { throw new DirectoryNotFoundException("源目录不存在!"); } }
public void MoveFilePointer(int cbToMove, MoveMethod fMoveMethod) { if (_hFile != null) { if (SetFilePointer(_hFile, cbToMove, IntPtr.Zero, fMoveMethod) == INVALID_SET_FILE_POINTER) { ThrowLastWin32Err(); } } }
override public void ShowGUI(List <ActionParameter> parameters) { parameterID = Action.ChooseParameterGUI("Third-person camera:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; linkedCamera = null; } else { linkedCamera = (GameCameraThirdPerson)EditorGUILayout.ObjectField("Third-person camera:", linkedCamera, typeof(GameCameraThirdPerson), true); constantID = FieldToID <GameCameraThirdPerson> (linkedCamera, constantID); linkedCamera = IDToField <GameCameraThirdPerson> (linkedCamera, constantID, true); } controlPitch = EditorGUILayout.Toggle("Control pitch?", controlPitch); if (controlPitch) { newPitchAngle = EditorGUILayout.FloatField("New pitch angle:", newPitchAngle); } controlSpin = EditorGUILayout.Toggle("Control spin?", controlSpin); if (controlSpin) { newSpinAngle = EditorGUILayout.FloatField("New spin angle:", newSpinAngle); isRelativeToTarget = EditorGUILayout.Toggle("Spin relative to target?", isRelativeToTarget); } if (controlPitch || controlSpin) { transitionTimeParameterID = Action.ChooseParameterGUI("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float); if (transitionTimeParameterID < 0) { transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime); } if (transitionTime > 0f) { moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle("Wait until finish?", willWait); } } AfterRunningOption(); }
public void SmoothChange(float _changeTime, MoveMethod method) { LookAtCentre(); moveMethod = method; isSmoothChanging = true; startTime = Time.time; changeTime = _changeTime; startPosition = transform.position; startRotation = transform.rotation; startFOV = GetComponent <Camera>().fieldOfView; }
public static int SeekFile(IntPtr hFile, long lDistanceToMove, MoveMethod dwMoveMethod) { var li = new LARGE_INTEGER(); li.QuadPart = lDistanceToMove; var ret = m_fileSystemIo.SeekFile(hFile, li.LowPart, ref li.HighPart, (int)dwMoveMethod); if (ret == INVALID_SET_FILE_POINTER) { throw new Exception("Invalid seek"); } return(ret); }
/** * <summary>Moves the GameObject by referencing a Marker component as its target Transform.</summary> * <param name = "_marker">A Marker whose position, rotation and scale will be the target values of the GameObject</param> * <param name = "_moveMethod">The interpolation method by which the GameObject moves (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "_transitionTime">The time, in seconds, that the movement should take place over</param> * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the movement speed will follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param> */ public void Move(Marker _marker, MoveMethod _moveMethod, float _transitionTime, AnimationCurve _timeCurve) { if (GetComponent <Rigidbody>() && !GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().velocity = GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } StopCoroutine("_UpdateMovement"); transformType = TransformType.CopyMarker; if (_transitionTime == 0f) { isMoving = false; transform.localPosition = _marker.transform.localPosition; transform.localEulerAngles = _marker.transform.localEulerAngles; transform.localScale = _marker.transform.localScale; } else { isMoving = true; doEulerRotation = false; moveMethod = _moveMethod; startPosition = transform.localPosition; startRotation = transform.localRotation; startScale = transform.localScale; endPosition = _marker.transform.localPosition; endRotation = _marker.transform.localRotation; endScale = _marker.transform.localScale; moveChangeTime = _transitionTime; moveStartTime = Time.time; if (moveMethod == MoveMethod.CustomCurve) { timeCurve = _timeCurve; } else { timeCurve = null; } StartCoroutine("_UpdateMovement"); } }
//静态方法。移动文件微操作。 public static void Mov(FileInfo srcPath, string desPath, MoveMethod movemethod) { int IndexNum = 0; switch(movemethod) { case MoveMethod.Dirc: //直接移动。不做任何异常处理 srcPath.MoveTo(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + srcPath.Extension); break; case MoveMethod.OverR://覆盖(先删除后移动),如果无权删除,则重命名 try { File.Delete(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + srcPath.Extension); srcPath.MoveTo(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + srcPath.Extension); } catch(UnauthorizedAccessException) { //如果有重名,则加上_n后缀。n从1开始直到不重名为止。n不大于100000,避免死循环 for (int i = 0; i < 100000; i++) { if (!File.Exists(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + @"_" + i.ToString() + srcPath.Extension)) { IndexNum = i; break; } } srcPath.MoveTo(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + @"_" + IndexNum.ToString() + srcPath.Extension); } break; case MoveMethod.Ren://重命名后移动 //如果有重名,则加上_n后缀。n从1开始直到不重名为止。n不大于100000,避免死循环 for (int i = 0; i < 100000; i++) { if (!File.Exists(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + @"_" + i.ToString() + srcPath.Extension)) { IndexNum = i; break; } } srcPath.MoveTo(desPath + "\\" + Path.GetFileNameWithoutExtension(srcPath.FullName) + @"_" + IndexNum.ToString() + srcPath.Extension); break; case MoveMethod.None://跳过 break; } }
/** * <summary>Moves the GameObject by referencing a Marker component as its target Transform.</summary> * <param name = "_marker">A Marker whose position, rotation and scale will be the target values of the GameObject</param> * <param name = "_moveMethod">The interpolation method by which the GameObject moves (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "_transitionTime">The time, in seconds, that the movement should take place over</param> * <param name = "_timeCurve">If _moveMethod = MoveMethod.CustomCurve, then the movement speed will follow the shape of the supplied AnimationCurve. This curve can exceed "1" in the Y-scale, allowing for overshoot effects.</param> */ public void Move(Marker _marker, MoveMethod _moveMethod, float _transitionTime, AnimationCurve _timeCurve) { if (GetComponent <Rigidbody>() && !GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().velocity = GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } if (_transitionTime == 0f) { positionChangeTime = rotateChangeTime = scaleChangeTime = 0f; transform.localPosition = _marker.transform.localPosition; transform.localEulerAngles = _marker.transform.localEulerAngles; transform.localScale = _marker.transform.localScale; } else { doEulerRotation = false; positionMethod = rotateMethod = scaleMethod = _moveMethod; startPosition = transform.localPosition; startRotation = transform.localRotation; startScale = transform.localScale; endPosition = _marker.transform.localPosition; endRotation = _marker.transform.localRotation; endScale = _marker.transform.localScale; positionChangeTime = rotateChangeTime = scaleChangeTime = _transitionTime; positionStartTime = rotateStartTime = scaleStartTime = Time.time; if (_moveMethod == MoveMethod.CustomCurve) { positionTimeCurve = _timeCurve; rotateTimeCurve = _timeCurve; scaleTimeCurve = _timeCurve; } else { positionTimeCurve = rotateTimeCurve = scaleTimeCurve = null; } } }
override public void ShowGUI() { returnToLast = EditorGUILayout.Toggle("Return to last gameplay?", returnToLast); if (!returnToLast) { linkedCamera = (GameCamera)EditorGUILayout.ObjectField("New camera:", linkedCamera, typeof(GameCamera), true); } transitionTime = EditorGUILayout.Slider("Transition time:", transitionTime, 0, 10f); if (transitionTime > 0f) { moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod); willWait = EditorGUILayout.Toggle("Pause until finish?", willWait); } AfterRunningOption(); }
override public void ShowGUI() { linkedProp = (Moveable)EditorGUILayout.ObjectField("Object to transform:", linkedProp, typeof(Moveable), true); EditorGUILayout.BeginHorizontal(); transformType = (TransformType)EditorGUILayout.EnumPopup(transformType); toBy = (ToBy)EditorGUILayout.EnumPopup(toBy); EditorGUILayout.EndHorizontal(); newVector = EditorGUILayout.Vector3Field("Vector:", newVector); transitionTime = EditorGUILayout.Slider("Transition time:", transitionTime, 0, 10f); if (transitionTime > 0f) { moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method", moveMethod); willWait = EditorGUILayout.Toggle("Pause until finish?", willWait); } AfterRunningOption(); }
public void Move(MoveMethod moveMethod, Vector3 toPoint, float time, Action onMoveComplete) { _moveMethod = time > 0 ? moveMethod : MoveMethod.MovePosition; // FIXME a dirty hack _moveCompleteCallback = onMoveComplete; _isMoving = true; _timePassed = 0; _timeOverall = time; _destPoint = toPoint; _startPoint = transform.position; _rigidbody.drag = 0; if (_moveMethod == MoveMethod.SetVelocityThenStop) { _rigidbody.velocity = _timeOverall > 0 ? (_destPoint - _startPoint) / _timeOverall : (_destPoint - _startPoint).normalized * short.MaxValue; } else if (_moveMethod == MoveMethod.ForcesWithDrag) { _rigidbody.AddForce((_destPoint - _startPoint) / _timeOverall, ForceMode.Acceleration); _rigidbody.drag = 1; } }
public override long Seek(long offset, SeekOrigin origin) { MoveMethod moveMethod = MoveMethod.Begin; switch (origin) { case SeekOrigin.Begin: moveMethod = MoveMethod.Begin; break; case SeekOrigin.Current: moveMethod = MoveMethod.Current; break; case SeekOrigin.End: moveMethod = MoveMethod.End; break; } var result = StormLib.SFileSetFilePointer(handle, offset, IntPtr.Zero, moveMethod); if (result == StormLib.SFILE_INVALID_SIZE) { throw new IOException("SFileSetFilePointer failed"); } position = result; return(position); }
public static void MovePosition(Vector3 position, Transform transform, MoveMethod moveMethod, Rigidbody rb = null, Rigidbody2D rb2D = null) { if (moveMethod == MoveMethod.Translate) { transform.position = position; } else if (moveMethod == MoveMethod.SetPhysics) { if (rb) { rb.position = position; } else if (rb2D && rb2D.simulated) { rb2D.position = position; } else { transform.position = position; } } else if (moveMethod == MoveMethod.MovePhysics) { if (rb) { rb.MovePosition(position); } else if (rb2D && rb2D.simulated) { rb2D.MovePosition(position); } else { transform.position = position; } } }
//静态方法。移动目录微操作。重载 public static void Mov(DirectoryInfo srcPath, string desPath, MoveMethod movemethod) { int IndexNum = 0; switch (movemethod) { case MoveMethod.Dirc: //直接移动。不做任何异常处理 srcPath.MoveTo(desPath + "\\" + srcPath.Name); break; case MoveMethod.OverR://覆盖/合并(递归处理)当目标目录为空或者到没有重名时停止 MoveFile(srcPath, desPath + "\\" + srcPath.Name); MoveDirc(srcPath, desPath + "\\" + srcPath.Name); try { srcPath.Delete(); } catch { //MessageBox.Show("无法删除"+srcPath.ToString()+"\n目录不是空的"); } break; case MoveMethod.Ren://重命名后移动 //如果有重名,则加上_n后缀。n从1开始直到不重名为止。n不大于100000,避免死循环 for (int i = 0; i < 100000; i++) { if (!Directory.Exists(desPath + "\\" + srcPath.Name + @"_" + i.ToString())) { IndexNum = i; break; } } srcPath.MoveTo(desPath + "\\" + srcPath.Name + @"_" + IndexNum.ToString()); break; case MoveMethod.None://跳过 break; } }
private void _MoveToPosition(Vector3 destination, MoveMethod method, float duration) { // all because of localPlayerAuthority bool ai = (GetComponent <AICharacter>() != null); if (ai && !isServer) { return; // only server moves Ai } if (!ai && !isLocalPlayer) { return; // do not control other's character } if (duration <= 0.01f || method == MoveMethod.Teleport) { m_rigidbody.MovePosition(destination); m_rigidbody.velocity = new Vector3(0, m_rigidbody.velocity.y, 0); } else if (method == MoveMethod.Tween && duration > 0.01f) { //currentCoroutine = StartCoroutine(MoveTweenCoroutine(destination, duration)); } }
internal static extern int SetFilePointerCE( IntPtr hFile, int lDistanceToMove, int lpDistanceToMoveHigh, MoveMethod dwMoveMethod);
public virtual void ReplaceScreen(Screen screen, MoveMethod m) { if (screen != null && screen != this) { screen.SetOnLoadState(false); SetLock(true); screen.SetLock(true); this.replaceMethod = m; this.replaceDstScreen = screen; screen.SetRepaintMode(SCREEN_CANVAS_REPAINT); switch (m) { case MoveMethod.FROM_LEFT: dstPos.SetLocation(-GetWidth(), 0); isScreenFrom = true; break; case MoveMethod.FROM_RIGHT: dstPos.SetLocation(GetWidth(), 0); isScreenFrom = true; break; case MoveMethod.FROM_UP: dstPos.SetLocation(0, -GetHeight()); isScreenFrom = true; break; case MoveMethod.FROM_DOWN: dstPos.SetLocation(0, GetHeight()); isScreenFrom = true; break; case MoveMethod.FROM_UPPER_LEFT: dstPos.SetLocation(-GetWidth(), -GetHeight()); isScreenFrom = true; break; case MoveMethod.FROM_UPPER_RIGHT: dstPos.SetLocation(GetWidth(), -GetHeight()); isScreenFrom = true; break; case MoveMethod.FROM_LOWER_LEFT: dstPos.SetLocation(-GetWidth(), GetHeight()); isScreenFrom = true; break; case MoveMethod.FROM_LOWER_RIGHT: dstPos.SetLocation(GetWidth(), GetHeight()); isScreenFrom = true; break; default: dstPos.SetLocation(0, 0); isScreenFrom = false; break; } Replace_Thread loading = new Replace_Thread(screen); CallEvent(loading); replaceLoading = true; } }
public override void ShowGUI(List<ActionParameter> parameters) { parameterID = Action.ChooseParameterGUI ("Third-person camera:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; linkedCamera = null; } else { linkedCamera = (GameCameraThirdPerson) EditorGUILayout.ObjectField ("Third-person camera:", linkedCamera, typeof (GameCameraThirdPerson), true); constantID = FieldToID <GameCameraThirdPerson> (linkedCamera, constantID); linkedCamera = IDToField <GameCameraThirdPerson> (linkedCamera, constantID, true); } controlPitch = EditorGUILayout.Toggle ("Control pitch?", controlPitch); if (controlPitch) { newPitchAngle = EditorGUILayout.FloatField ("New pitch angle:", newPitchAngle); } controlSpin = EditorGUILayout.Toggle ("Control spin?", controlSpin); if (controlSpin) { newSpinAngle = EditorGUILayout.FloatField ("New spin angle:", newSpinAngle); isRelativeToTarget = EditorGUILayout.Toggle ("Spin relative to target?", isRelativeToTarget); } if (controlPitch || controlSpin) { transitionTimeParameterID = Action.ChooseParameterGUI ("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float); if (transitionTimeParameterID < 0) { transitionTime = EditorGUILayout.FloatField ("Transition time (s):", transitionTime); } if (transitionTime > 0f) { moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method:", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } } AfterRunningOption (); }
/** * <summary>Sets a _Camera as the new attachedCamera to follow.</summary> * <param name = "newCamera">The new _Camera to follow</param> * <param name = "transitionTime">The time, in seconds, that it will take to move towards the new _Camera</param> * <param name = "_moveMethod">How the Camera should move towards the new _Camera, if transitionTime > 0f (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param> * <param name = "_animationCurve">The AnimationCurve that dictates movement over time, if _moveMethod = MoveMethod.CustomCurve</param> */ public void SetGameCamera(_Camera newCamera, float transitionTime = 0f, MoveMethod _moveMethod = MoveMethod.Linear, AnimationCurve _animationCurve = null) { if (newCamera == null) { return; } if (attachedCamera != null && attachedCamera is GameCamera25D) { if (newCamera is GameCamera25D) { } else { RemoveBackground (); } } AssignOwnCamera (); _camera.ResetProjectionMatrix (); attachedCamera = newCamera; attachedCamera.SetCameraComponent (); if (attachedCamera && attachedCamera._camera) { _camera.farClipPlane = attachedCamera._camera.farClipPlane; _camera.nearClipPlane = attachedCamera._camera.nearClipPlane; _camera.orthographic = attachedCamera._camera.orthographic; } // Set LookAt if (attachedCamera is GameCamera) { GameCamera gameCam = (GameCamera) attachedCamera; cursorAffectsRotation = gameCam.followCursor; lookAtAmount = gameCam.cursorInfluence; } else if (attachedCamera is GameCameraAnimated) { GameCameraAnimated gameCam = (GameCameraAnimated) attachedCamera; if (gameCam.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement) { cursorAffectsRotation = gameCam.followCursor; lookAtAmount = gameCam.cursorInfluence; } else { cursorAffectsRotation = false; } } else { cursorAffectsRotation = false; } // Set background if (attachedCamera is GameCamera25D) { GameCamera25D cam25D = (GameCamera25D) attachedCamera; cam25D.SetActiveBackground (); } // TransparencySortMode if (attachedCamera is GameCamera2D) { _camera.transparencySortMode = TransparencySortMode.Orthographic; } else if (attachedCamera) { if (attachedCamera._camera.orthographic) { _camera.transparencySortMode = TransparencySortMode.Orthographic; } else { _camera.transparencySortMode = TransparencySortMode.Perspective; } } // UFPS if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS) { UltimateFPSIntegration._Update (KickStarter.stateHandler.gameState); } KickStarter.stateHandler.LimitHotspotsToCamera (attachedCamera); if (transitionTime > 0f) { SmoothChange (transitionTime, _moveMethod, _animationCurve); } else if (attachedCamera != null) { attachedCamera.MoveCameraInstant (); SnapToAttached (); } }
/** * <summary>Interpolates a float over time, according to various interpolation methods.</summary> * <param name = "startT">The starting time</param> * <param name = "deltaT">The time difference</param> * <param name = "moveMethod">The method of interpolation (Linear, Smooth, Curved, EaseIn, EaseOut, Curved)</param> * <param name = "timeCurve">The AnimationCurve to interpolate against, if the moveMethod = MoveMethod.Curved</param> * <returns>The interpolated float</returns> */ public static float Interpolate(float startT, float deltaT, MoveMethod moveMethod, AnimationCurve timeCurve = null) { if (moveMethod == MoveMethod.Curved) { moveMethod = MoveMethod.Smooth; } else if (moveMethod == MoveMethod.Smooth) { return -0.5f * (Mathf.Cos (Mathf.PI * (Time.time - startT) / deltaT) - 1f); } else if (moveMethod == MoveMethod.EaseIn) { return 1f - Mathf.Cos ((Time.time - startT) / deltaT * (Mathf.PI / 2)); } else if (moveMethod == MoveMethod.EaseOut) { return Mathf.Sin ((Time.time - startT) / deltaT * (Mathf.PI / 2)); } else if (moveMethod == MoveMethod.CustomCurve) { if (timeCurve == null || timeCurve.length == 0) { return 1f; } float startTime = timeCurve [0].time; float endTime = timeCurve [timeCurve.length - 1].time; return timeCurve.Evaluate ((endTime - startTime) * (Time.time - startT) / deltaT + startTime); } return ((Time.time - startT) / deltaT); }
public void LiftOff() { actualMethod = new BasicMoveMethod (); type = MoveType.Fly; }
private static extern int SetFilePointer(SafeFileHandle hFile, int lDistanceToMove, out int lpDistanceToMoveHigh, MoveMethod dwMoveMethod);
internal static extern UInt32 SetFilePointer( SafeFileHandle hFile, Int32 cbDistanceToMove, IntPtr pDistanceToMoveHigh, MoveMethod fMoveMethod);
public override void ShowGUI(List<ActionParameter> parameters) { parameterID = Action.ChooseParameterGUI ("Moveable object:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; linkedProp = null; } else { linkedProp = (Moveable) EditorGUILayout.ObjectField ("Moveable object:", linkedProp, typeof (Moveable), true); constantID = FieldToID <Moveable> (linkedProp, constantID); linkedProp = IDToField <Moveable> (linkedProp, constantID, false); } EditorGUILayout.BeginHorizontal (); transformType = (TransformType) EditorGUILayout.EnumPopup (transformType); if (transformType != TransformType.CopyMarker) { toBy = (ToBy) EditorGUILayout.EnumPopup (toBy); } EditorGUILayout.EndHorizontal (); if (transformType == TransformType.CopyMarker) { markerParameterID = Action.ChooseParameterGUI ("Marker:", parameters, markerParameterID, ParameterType.GameObject); if (markerParameterID >= 0) { markerID = 0; marker = null; } else { marker = (Marker) EditorGUILayout.ObjectField ("Marker:", marker, typeof (Marker), true); markerID = FieldToID <Marker> (marker, markerID); marker = IDToField <Marker> (marker, markerID, false); } } else { newVector = EditorGUILayout.Vector3Field ("Vector:", newVector); } transitionTime = EditorGUILayout.Slider ("Transition time:", transitionTime, 0, 10f); if (transitionTime > 0f) { if (transformType == TransformType.Rotate) { doEulerRotation = EditorGUILayout.Toggle ("Euler rotation?", doEulerRotation); } moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } AfterRunningOption (); }
public static int SeekFile(IntPtr hFile, long lDistanceToMove, MoveMethod dwMoveMethod) { var li = new LARGE_INTEGER(); li.QuadPart = lDistanceToMove; var ret = m_fileSystemIo.SeekFile(hFile, li.LowPart, ref li.HighPart, (int)dwMoveMethod); if (ret == INVALID_SET_FILE_POINTER) throw new Exception("Invalid seek"); return ret; }
public override void ShowGUI(List<ActionParameter> parameters) { isPlayer = EditorGUILayout.Toggle ("Is player?", isPlayer); if (!isPlayer) { parameterID = ChooseParameterGUI ("Object:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; shapeObject = null; } else { shapeObject = (Shapeable) EditorGUILayout.ObjectField ("Object:", shapeObject, typeof (Shapeable), true); constantID = FieldToID <Shapeable> (shapeObject, constantID); shapeObject = IDToField <Shapeable> (shapeObject, constantID, false); } } else { Player _player = null; if (Application.isPlaying) { _player = KickStarter.player; } else { _player = AdvGame.GetReferences ().settingsManager.GetDefaultPlayer (); } if (_player != null && _player.GetShapeable ()) { shapeObject = _player.GetShapeable (); } else { shapeObject = null; EditorGUILayout.HelpBox ("Cannot find player with Shapeable script attached", MessageType.Warning); } } if (shapeObject != null && shapeObject.shapeGroups != null) { shapeGroupID = ActionBlendShape.ShapeableGroupGUI ("Shape group:", shapeObject.shapeGroups, shapeGroupID); disableAllKeys = EditorGUILayout.Toggle ("Disable all keys?", disableAllKeys); if (!disableAllKeys) { ShapeGroup _shapeGroup = shapeObject.GetGroup (shapeGroupID); if (_shapeGroup != null) { if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0) { shapeKeyID = ShapeableKeyGUI (_shapeGroup.shapeKeys, shapeKeyID); } else { EditorGUILayout.HelpBox ("No shape keys found.", MessageType.Info); } } shapeValue = EditorGUILayout.Slider ("New value:", shapeValue, 0f, 100f); } } else { EditorGUILayout.HelpBox ("An object must be assigned before more options can show.", MessageType.Info); } fadeTime = EditorGUILayout.FloatField ("Transition time:", fadeTime); if (fadeTime > 0f) { moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method:", moveMethod); if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve); } willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } AfterRunningOption (); }
public void Move(Marker _marker, MoveMethod _moveMethod, float _transitionTime, AnimationCurve _timeCurve) { if (GetComponent <Rigidbody>() && !GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().velocity = GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } StopCoroutine ("_UpdateMovement"); transformType = TransformType.CopyMarker; if (_transitionTime == 0f) { isMoving = false; transform.localPosition = _marker.transform.localPosition; transform.localEulerAngles = _marker.transform.localEulerAngles; transform.localScale = _marker.transform.localScale; } else { isMoving = true; doEulerRotation = false; moveMethod = _moveMethod; startPosition = transform.localPosition; startRotation = transform.localRotation; startScale = transform.localScale; endPosition = _marker.transform.localPosition; endRotation = _marker.transform.localRotation; endScale = _marker.transform.localScale; moveChangeTime = _transitionTime; moveStartTime = Time.time; if (moveMethod == MoveMethod.CustomCurve) { timeCurve = _timeCurve; } else { timeCurve = null; } StartCoroutine ("_UpdateMovement"); } }
private void SmoothChange(float _changeTime, MoveMethod method, AnimationCurve _timeCurve = null) { LookAtCentre (); moveMethod = method; isSmoothChanging = true; StopCrossfade (); startTime = Time.time; changeTime = _changeTime; startPosition = transform.position; startRotation = transform.rotation; startFOV = _camera.fieldOfView; startOrtho = _camera.orthographicSize; startFocalDistance = focalDistance; startPerspectiveOffset = perspectiveOffset; if (method == MoveMethod.CustomCurve) { timeCurve = _timeCurve; } else { timeCurve = null; } }
public void Move(Vector3 _newVector, MoveMethod _moveMethod, float _transitionTime, TransformType _transformType, bool _doEulerRotation, AnimationCurve _timeCurve) { StopCoroutine ("_UpdateMovement"); if (GetComponent <Rigidbody>() && !GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().velocity = GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } if (_transitionTime == 0f) { isMoving = false; if (_transformType == TransformType.Translate) { transform.localPosition = _newVector; } else if (_transformType == TransformType.Rotate) { transform.localEulerAngles = _newVector; } else if (_transformType == TransformType.Scale) { transform.localScale = _newVector; } } else { isMoving = true; doEulerRotation = _doEulerRotation; moveMethod = _moveMethod; transformType = _transformType; startPosition = endPosition = transform.localPosition; startEulerRotation = endEulerRotation = transform.localEulerAngles; startRotation = endRotation = transform.localRotation; startScale = endScale = transform.localScale; if (_transformType == TransformType.Translate) { endPosition = _newVector; } else if (_transformType == TransformType.Rotate) { endRotation = Quaternion.Euler (_newVector); endEulerRotation = _newVector; } else if (_transformType == TransformType.Scale) { endScale = _newVector; } moveChangeTime = _transitionTime; moveStartTime = Time.time; if (moveMethod == MoveMethod.CustomCurve) { timeCurve = _timeCurve; } else { timeCurve = null; } StartCoroutine ("_UpdateMovement"); } }
private static void MoveFilePointer(int cbToMove, MoveMethod fMoveMethod) { if (_hFile != null) if (SetFilePointer(_hFile, cbToMove, IntPtr.Zero, fMoveMethod) == INVALID_SET_FILE_POINTER) ThrowLastWin32Err(); }
public override void ShowGUI(List<ActionParameter> parameters) { bool showWaitOption = false; returnToLast = EditorGUILayout.Toggle ("Return to last gameplay?", returnToLast); if (!returnToLast) { parameterID = Action.ChooseParameterGUI ("New camera:", parameters, parameterID, ParameterType.GameObject); if (parameterID >= 0) { constantID = 0; linkedCamera = null; } else { linkedCamera = (_Camera) EditorGUILayout.ObjectField ("New camera:", linkedCamera, typeof (_Camera), true); constantID = FieldToID <_Camera> (linkedCamera, constantID); linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true); } if (linkedCamera && linkedCamera is GameCameraAnimated) { GameCameraAnimated animatedCamera = (GameCameraAnimated) linkedCamera; if (animatedCamera.animatedCameraType == AnimatedCameraType.PlayWhenActive && transitionTime <= 0f) { showWaitOption = true; } } } if (linkedCamera is GameCamera25D && !returnToLast) { transitionTime = 0f; } else { transitionTimeParameterID = Action.ChooseParameterGUI ("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float); if (transitionTimeParameterID < 0) { transitionTime = EditorGUILayout.FloatField ("Transition time (s):", transitionTime); } if (transitionTime > 0f) { moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method:", moveMethod); showWaitOption = true; if (moveMethod == MoveMethod.CustomCurve) { timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve); } } } if (showWaitOption) { willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait); } AfterRunningOption (); }