//creates a new tween with given arguments that moves along the path private void CreateTween() { //prepare DOTween's parameters, you can look them up here //http://dotween.demigiant.com/documentation.php TweenParams parms = new TweenParams(); //differ between speed or time based tweening if (timeValue == TimeValue.speed) { parms.SetSpeedBased(); } if (loopType == LoopType.yoyo) { parms.SetLoops(-1, DG.Tweening.LoopType.Yoyo); } //apply ease type or animation curve if (easeType == DG.Tweening.Ease.INTERNAL_Custom) { parms.SetEase(animEaseType); } else { parms.SetEase(easeType); } if (moveToPath) { parms.OnWaypointChange(OnWaypointReached); } else { if (loopType == LoopType.yoyo) { parms.OnStepComplete(ReachedEnd); } transform.position = wpPos[0]; parms.OnWaypointChange(OnWaypointChange); parms.OnComplete(ReachedEnd); } tween = transform.DOPath(wpPos, originSpeed, pathType, pathMode, 1) .SetAs(parms) .SetOptions(false, lockPosition, lockRotation) .SetLookAt(lookAhead); if (!moveToPath && startPoint > 0) { GoToWaypoint(startPoint); startPoint = 0; } //continue new tween with adjusted speed if it was changed before if (originSpeed != speed) { ChangeSpeed(speed); } }
private static int OnStepComplete(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 2); TweenParams tweenParams = (TweenParams)ToLua.CheckObject(L, 1, typeof(TweenParams)); LuaTypes luaTypes = LuaDLL.lua_type(L, 2); TweenCallback action; if (luaTypes != LuaTypes.LUA_TFUNCTION) { action = (TweenCallback)ToLua.CheckObject(L, 2, typeof(TweenCallback)); } else { LuaFunction func = ToLua.ToLuaFunction(L, 2); action = (DelegateFactory.CreateDelegate(typeof(TweenCallback), func) as TweenCallback); } TweenParams o = tweenParams.OnStepComplete(action); ToLua.PushObject(L, o); result = 1; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
//creates a new tween with given arguments that moves along the path private void CreateTween() { //prepare DOTween's parameters, you can look them up here //http://dotween.demigiant.com/documentation.php TweenParams parms = new TweenParams(); //differ between speed or time based tweening if (timeValue == TimeValue.speed) { parms.SetSpeedBased(); } if (loopType == LoopType.yoyo) { parms.SetLoops(-1, DG.Tweening.LoopType.Yoyo); } //apply ease type or animation curve if (easeType == DG.Tweening.Ease.Unset) { parms.SetEase(animEaseType); } else { parms.SetEase(easeType); } if (moveToPath) { parms.OnWaypointChange(OnWaypointReached); } else { //on looptype random initialize random order of waypoints if (loopType == LoopType.random) { RandomizeWaypoints(); } else if (loopType == LoopType.yoyo) { parms.OnStepComplete(ReachedEnd); } Vector3 startPos = wpPos[0]; if (local) { startPos = pathContainer.transform.TransformPoint(startPos); } transform.position = startPos; parms.OnWaypointChange(OnWaypointChange); parms.OnComplete(ReachedEnd); } if (pathMode == DG.Tweening.PathMode.Ignore && waypointRotation != RotationType.none) { if (rotationTarget == null) { rotationTarget = transform; } parms.OnUpdate(OnWaypointRotation); } if (local) { tween = transform.DOLocalPath(wpPos, originSpeed, pathType, pathMode) .SetAs(parms) .SetOptions(closeLoop, lockPosition, lockRotation) .SetLookAt(lookAhead); } else { tween = transform.DOPath(wpPos, originSpeed, pathType, pathMode) .SetAs(parms) .SetOptions(closeLoop, lockPosition, lockRotation) .SetLookAt(lookAhead); } if (!moveToPath && startPoint > 0) { GoToWaypoint(startPoint); startPoint = 0; } //continue new tween with adjusted speed if it was changed before if (originSpeed != speed) { ChangeSpeed(speed); } }
public void BeginMoveByPos( Vector3 fromPosition, bool isUIPos, Vector3 targetPos, int easeType, float speed, Action onEnd ) { this.mEnd = onEnd; var parent = this.transform.parent as RectTransform; Vector3 fromScreenPosition; if (isUIPos) { fromScreenPosition = RectTransformUtility.WorldToScreenPoint(null, fromPosition); } else { fromScreenPosition = Camera.main.WorldToScreenPoint(fromPosition); } // var cameraViewPostion = Camera.main.WorldToViewportPoint(fromPosition); mFromLocalPosition = Vector2.zero; RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, fromScreenPosition, null, out mFromLocalPosition); // Debug.LogError("cameraViewPostion" + cameraViewPostion+ "cameraFromPostion" + cameraFromPostion + "fromPosition" + fromPosition + "fromScreenPostion " + fromScreenPostion + " fromLocalPosition: "+ fromLocalPosition); var toScreenPostion = RectTransformUtility.WorldToScreenPoint(null, targetPos); var cameraToPosition = Camera.main.WorldToScreenPoint(targetPos); mToLocalPosition = Vector2.zero; RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, toScreenPostion, null, out mToLocalPosition); //Debug.LogError("cameraToPosition"+ cameraToPosition+" toScreenPostion " + toScreenPostion + " toLocalPosition: " + toLocalPosition); List <Vector3> listBoPint = new List <Vector3>(); // Vector2 range = UnityEngine.Random.insideUnitCircle; int factor = -1;// UnityEngine.Random.Range(0, 1) > 0.5f?1:-1; var length = (mFromLocalPosition + mToLocalPosition).magnitude; listBoPint.Add(mFromLocalPosition); // listBoPint.Add(fromLocalPosition+ new Vector2(factor* length * 0.05f, factor* length * 0.05f)); var temp = (mFromLocalPosition - mToLocalPosition).normalized; var normal = new Vector2(temp.y, -temp.x) * factor; listBoPint.Add(mFromLocalPosition + (mToLocalPosition - mFromLocalPosition) * 0.25f + normal * length * 0.05f); listBoPint.Add((mFromLocalPosition + mToLocalPosition) * 0.5f + normal * length * 0.075f); listBoPint.Add(mFromLocalPosition + (mToLocalPosition - mFromLocalPosition) * 0.75f + normal * length * 0.05f); // listBoPint.Add((fromPosition + ToPosition) / 3f + new Vector3(range.x * 50, range.y * 50, 0)); // listBoPint.Add((fromPosition + ToPosition) * 2 / 3f + new Vector3(range.x * 50, range.y * 50, 0)); listBoPint.Add(mToLocalPosition); Vector3[] path = GeneralPath(listBoPint); TweenParams parms = new TweenParams(); parms.SetSpeedBased(); parms.SetEase((Ease)easeType); parms.OnStepComplete(OnReachEnd); parms.OnUpdate(onMoveUpdate); transform.localPosition = mFromLocalPosition; mTween = transform.DOLocalPath(path, speed, DG.Tweening.PathType.CatmullRom, DG.Tweening.PathMode.Ignore) .SetAs(parms); // .SetOptions(false, DG.Tweening.AxisConstraint.None, DG.Tweening.AxisConstraint.None) // .SetLookAt(0, Vector3.forward, Vector3.up); transform.localScale = Vector3.one; mTotalLength = (mFromLocalPosition - mToLocalPosition).magnitude; mTween.Play(); }
// Token: 0x06000749 RID: 1865 RVA: 0x00030738 File Offset: 0x0002EB38 private void CreateTween() { TweenParams tweenParams = new TweenParams(); if (this.timeValue == splineMove.TimeValue.speed) { tweenParams.SetSpeedBased(true); } if (this.loopType == splineMove.LoopType.yoyo) { tweenParams.SetLoops(-1, new DG.Tweening.LoopType?(DG.Tweening.LoopType.Yoyo)); } if (this.easeType == Ease.INTERNAL_Custom) { tweenParams.SetEase(this.animEaseType); } else { tweenParams.SetEase(this.easeType, null, null); } if (this.moveToPath) { tweenParams.OnWaypointChange(new TweenCallback <int>(this.OnWaypointReached)); } else { if (this.loopType == splineMove.LoopType.random) { this.RandomizeWaypoints(); } else if (this.loopType == splineMove.LoopType.yoyo) { tweenParams.OnStepComplete(new TweenCallback(this.ReachedEnd)); } Vector3 position = this.wpPos[0]; if (this.local) { position = this.pathContainer.transform.TransformPoint(position); } base.transform.position = position; tweenParams.OnWaypointChange(new TweenCallback <int>(this.OnWaypointChange)); tweenParams.OnComplete(new TweenCallback(this.ReachedEnd)); } if (this.local) { this.tween = base.transform.DOLocalPath(this.wpPos, this.originSpeed, this.pathType, this.pathMode, 10, null).SetAs(tweenParams).SetOptions(this.closeLoop, this.lockPosition, this.lockRotation).SetLookAt(this.lookAhead, null, null); } else { this.tween = base.transform.DOPath(this.wpPos, this.originSpeed, this.pathType, this.pathMode, 10, null).SetAs(tweenParams).SetOptions(this.closeLoop, this.lockPosition, this.lockRotation).SetLookAt(this.lookAhead, null, null); } if (!this.moveToPath && this.startPoint > 0) { this.GoToWaypoint(this.startPoint); this.startPoint = 0; } if (this.originSpeed != this.speed) { this.ChangeSpeed(this.speed); } }