public static SimpleTween addTween(Transform transform, Vector3 targetPos, float time, ITweenableObject targetObject = null, float delay = 0.0f, System.Delegate callback = null, params object[] args) { SimpleTween tw = new SimpleTween(transform, targetPos, time, targetObject, delay, callback, args); _tweenList.Add(tw); return(tw); }
public static bool removeTween(SimpleTween tw) { bool isRemove = _tweenList.Remove(tw); tw = null; return(isRemove); }
public void Trigger(SimpleTween tween, Vector3 point, Action onComplete) { this.tween = tween; this.onComplete = onComplete; sourcePos = transform.position; targetPos = point; timeScale = 1.0f / tween.Duration; timer = 0.0f; }
private void OnDestroy() { BubblesPlayer.Instance.ChangeScoreEvent -= SetScore; BubblesPlayer.Instance.ChangeStarsEvent -= SetStars; ts.Break(); SimpleTween.Cancel(gameObject, false); SimpleTween.Cancel(starRightFull.gameObject, false); SimpleTween.Cancel(starLeftFull.gameObject, false); SimpleTween.Cancel(starMiddleFull.gameObject, false); }
private void Update() { if (tween != null) { if (timer > 1.0f) { tween = null; transform.position = targetPos; onComplete(); } else { transform.position = tween.Evaluate(sourcePos, targetPos, timer); } timer += timeScale * Time.deltaTime; } }
public void update() { if (GameManager.me.isPaused) { return; } for (int i = _tweenList.Count - 1; i >= 0; --i) { tw = _tweenList[i]; if (tw.pause) { continue; } if (tw.delay > 0.0f) { tw.delay -= GameManager.globalDeltaTime; continue; } if (tw.time > 0.0f) { tw.update(GameManager.globalDeltaTime); } if (tw.time <= 0.0f) { _tweenList.RemoveAt(i); tw.complete(); if (tw.method != null) { tw.method.DynamicInvoke(tw.parameters); if (_tweenList.Count == 0) { break; } } tw = null; } } }
private void OnDestroy() { if (MPlayer) { MPlayer.ChangeScoreEvent -= SetScore; } if (MPlayer) { MPlayer.ChangeStarsEvent -= SetStars; } if (ts != null) { ts.Break(); } SimpleTween.Cancel(gameObject, false); SimpleTween.Cancel(starRightFull, false); SimpleTween.Cancel(starLeftFull, false); SimpleTween.Cancel(starMiddleFull, false); }
private IEnumerator SetMapPositionToAciveButton() { yield return(new WaitForSeconds(0.1f)); if (sRect) { int bCount = biomesCount; float contentSizeY = content.sizeDelta.y / (bCount) * (bCount - 1.0f); float relPos = content.InverseTransformPoint(ActiveButton.transform.position).y; // Debug.Log("contentY : " + contentSizeY + " ;relpos : " + relPos + " : " + relPos / contentSizeY); float vpos = (-contentSizeY / (bCount * 2.0f) + relPos) / contentSizeY; // SimpleTween.Cancel(gameObject, false); float start = sRect.verticalNormalizedPosition; SimpleTween.Value(gameObject, start, vpos, 0.25f).SetOnUpdate((float f) => { sRect.verticalNormalizedPosition = Mathf.Clamp01(f); }); //sRect.verticalNormalizedPosition = Mathf.Clamp01(vpos); // Debug.Log("vpos : " + Mathf.Clamp01(vpos)); } else { Debug.Log("no scrolling rect"); } }
private void SetStars() { if (!starLeftSet) { starLeftFull.SetActive(BubblesPlayer.Instance.StarCount >= 1); } if (!starMiddleSet) { starMiddleFull.SetActive(BubblesPlayer.Instance.StarCount >= 2); } if (!starRightSet) { starRightFull.SetActive(BubblesPlayer.Instance.StarCount >= 3); } ts = new TweenSeq(); if (BubblesPlayer.Instance.StarCount >= 1 && !starLeftSet) { starLeftSet = true; ts.Add((callBack) => { if (curveLeft) { float time = curveLeft.Length / speed; curveLeft.MoveAlongPath(starLeftFull.gameObject, starLeftEmpty.transform, time, 0f, EaseAnim.EaseInOutSine, callBack); } else { SimpleTween.Move(starLeftFull.gameObject, starLeftFull.transform.position, starLeftEmpty.transform.position, 0.5f).AddCompleteCallBack(() => { callBack(); }); } }); } if (BubblesPlayer.Instance.StarCount >= 2 && !starMiddleSet) { starMiddleSet = true; ts.Add((callBack) => { if (curveMiddle) { float time = curveMiddle.Length / speed; curveMiddle.MoveAlongPath(starMiddleFull.gameObject, starMiddleEmpty.transform, time, 0f, EaseAnim.EaseInOutSine, callBack); } else { SimpleTween.Move(starMiddleFull.gameObject, starMiddleFull.transform.position, starMiddleEmpty.transform.position, 0.5f).AddCompleteCallBack(() => { callBack(); }); } }); } if (BubblesPlayer.Instance.StarCount >= 3 && !starRightSet) { starRightSet = true; ts.Add((callBack) => { if (curveRight) { float time = curveRight.Length / speed; curveRight.MoveAlongPath(starRightFull.gameObject, starRightEmpty.transform, time, 0f, EaseAnim.EaseInOutSine, callBack); } else { SimpleTween.Move(starRightFull.gameObject, starRightFull.transform.position, starRightEmpty.transform.position, 0.5f).AddCompleteCallBack(() => { callBack(); }); } }); } ts.Start(); }
public void Trigger(SimpleTween tween, Vector3 point) { Trigger(tween, point, () => {}); }
public override void OnStart() { // 0 Actions.Add("Reset", () => { SimpleTween .Tween(this.Actor) .Sequence .Cancel(); SimpleTween .Tween(this.Actor) .MoveTo(new Vector3(0, 0, 0), 0); }); // 1 Actions.Add("Simple Move and repeat", () => { this.Actor.Tween() .MoveTo(new Vector3(0, -100, 0), 2) .SetRepetitions(2); }); // 2 Actions.Add("Simple Move and repeat (API)", () => { SimpleTween .Tween(this.Actor) .MoveTo(new Vector3(0, -100, 0), 2) .SetRepetitions(2); }); // 3 Actions.Add("Simple Move (API)", () => { SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2); }); // 4 Actions.Add("Chain Move and reverse", () => { SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2) .SetFrom(new Vector3(0, 0, 0)) .SetReversed() //.Chain() .MoveTo(new Vector3(0, -100, 0), 2); }); // 5 Actions.Add("Simple Move and cancel", () => { var x = SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2); // This has to create a new sequence. Discussion's over. // Otherwise, this would happen AFTER the MoveTo. Which is weird. SimpleTween .Tween(this.Actor) .Wait(1, (_) => x.Cancel()); }); // 6 Actions.Add("Start time with startDelay", () => { var y = SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), duration: 2) // Move for 2 seconds .ScaleTo(new Vector3(2, 2, 1), duration: 1, startDelay: 0) // While scaling the object up .ScaleTo(new Vector3(1, 1, 1), duration: 1); // Now scale the object down. This happens after **the previous tween** }); // 7 Actions.Add("Chain Move and instant cancel", () => { var y = SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2) .SetFrom(new Vector3(0, 0, 0)) .SetReversed() //.Chain() .MoveTo(new Vector3(-100, -100, 0), 2); y.Sequence.Cancel(); }); // 8 Actions.Add("Tween and instant finish", () => { SimpleTween .Tween(this.Actor) .Finish(); }); // 9 Actions.Add("NOT IMPLEMENTED Set Percentage", () => { var x1 = SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2); //x1.Percentage = 0.5f; }); // 10 Actions.Add("Move, wait and move", () => { SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2) .Wait(2) // Acts like .Sequence()? (At least the return value does?) .MoveTo(new Vector3(-100, -50, 0), 2); // Uh... }); // 11 Actions.Add("NOT IMPLEMENTED 2", () => { //SimpleTween // .MoveTo(this.Actor, new Vector3(0, -100, 0), 2) // .OnFinished((x2) => x2.Repeat()); }); // 12 Actions.Add("Multiple Moves and repeat", () => { SimpleTween .MoveTo(this.Actor, new Vector3(0, -100, 0), 2) .MoveTo(new Vector3(100, -100, 0), 2) .MoveTo(new Vector3(100, 0, 0), 2) .Sequence .SetRepetitions(3); }); // 13 Actions.Add("Create sequence and add to actor", () => { var seq = SimpleTween .CreateSequence() .MoveTo(new Vector3(0, -100, 0), 1) .MoveTo(new Vector3(0, -100, 30), 1) .MoveTo(new Vector3(30, -100, 0), 1) .Sequence .SetRepetitions(2); SimpleTween .Add(seq, this.Actor); }); // TODO: We've reached this point vvv // 14 Actions.Add("Single Animation Additive Mode", () => { SimpleTween .Tween(Actor) .MoveTo(new Vector3(0, -100, 0), 2) .SetAdditive(true); }); // 15 Actions.Add("Multiple Animations including Additive Mode", () => { SimpleTween .Tween(Actor) .MoveTo(new Vector3(0, -100, 0), 2, 0) .MoveTo(new Vector3(0, -100, 50), 2, 0) .SetAdditive(true); }); // 16 Actions.Add("Multiple Animations with Additive Mode", () => { SimpleTween .Tween(Actor) .MoveTo(new Vector3(0, -100, 0), 2, 0) .SetAdditive(true) .MoveTo(new Vector3(0, -100, 50), 2, 0) .SetAdditive(true); }); /*Actor * .Tween()*/ /*SimpleTween * .RotateTo(Actor, Quaternion.RotationY(Mathf.Pi), 3.6f); * SimpleTween * .In(5, () => * { * SimpleTween * .RotateTo(Actor, Quaternion.RotationY(Mathf.PiOverTwo), 3f); * * SimpleTween * .MoveTo(Actor, new Vector3(0, -100, 0), 2); * SimpleTween * .ScaleTo(Actor, new Vector3(2), 2); * }); */ }
void Start() { //InvokeRepeating("Clockwise", 0, 2f / speed); //testing path = new SimpleTween(transform.position, points[0], Time.time, 1); transform.Rotate(transform.forward, 90); }