diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll index e3cc9db..f02895f 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb index 2e70876..174e7a7 100644 Binary files a/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityCompatibilityTests.Unity35/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll index e3cc9db..f02895f 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb index 2e70876..174e7a7 100644 Binary files a/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityTests.Unity4/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll index e3cc9db..f02895f 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll differ diff --git a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb index 2e70876..174e7a7 100644 Binary files a/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb and b/UnityTests.Unity5/Assets/Demigiant/DOTween/DOTween.dll.mdb differ diff --git a/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.cs b/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.cs index cc4acd4..18785a6 100644 --- a/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.cs +++ b/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.cs @@ -5,20 +5,18 @@ using System.Collections; public class Temp : BrainBase { - [SerializeField] - private Vector3 pos; - [SerializeField] - private float duration; - [SerializeField] - private GameObject goToMove; + public Transform target; - private Tweener moveTween; + IEnumerator Start() + { + yield return new WaitForSeconds(0.6f); - // Update is called once per frame - void Update() { - if(moveTween == null) { - moveTween = goToMove.transform.DOLocalMove(pos, duration).SetAutoKill(false); - } - moveTween.ChangeEndValue(pos, duration, true); + Sequence s0 = DOTween.Sequence().Append(target.DOMoveX(3, 2)).OnComplete(()=> Debug.Log("s0 complete")); + Sequence s1 = DOTween.Sequence().Append(target.DOMoveY(3, 2)).OnComplete(()=> Debug.Log("s1 complete")); + Sequence s = DOTween.Sequence().Append(s0).Append(s1).OnComplete(()=> Debug.Log("MAIN COMPLETE")); + + yield return new WaitForSeconds(0.2f); + + s.Complete(); } } \ No newline at end of file diff --git a/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.unity b/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.unity index de4a611..92b2dc1 100644 Binary files a/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.unity and b/UnityTests.Unity5/Assets/_Tests/Bugs/Temp.unity differ diff --git a/UnityTests.Unity5/Assets/_Tests/TempTests.cs b/UnityTests.Unity5/Assets/_Tests/TempTests.cs index 68f3570..ca48b67 100644 --- a/UnityTests.Unity5/Assets/_Tests/TempTests.cs +++ b/UnityTests.Unity5/Assets/_Tests/TempTests.cs @@ -1,32 +1,96 @@ using UnityEngine; using UnityEngine.UI; +using System; using System.Collections; using System.Collections.Generic; using DG.Tweening; -using DG.Tweening.Plugins; -using DG.Tweening.Plugins.Core; -using DG.Tweening.Plugins.Options; -using System; public class TempTests : BrainBase { public Transform target; - public Ease easeType; - public float gotoTime; - public Vector3[] waypoints; + public float delay; + Vector2 originalPosition; + Vector2 targetOriginalPosition; + SpriteRenderer targetOverlay; + Sequence seq; + int prevCompletedLoops; - Tween t; - - IEnumerator Start() + IEnumerator Start() { - yield return new WaitForSeconds(0.6f); + originalPosition = transform.position; + DOTween.Init(); - t = target.DOPath(waypoints, 5, PathType.CatmullRom).SetEase(easeType); - t.GotoWaypoint(2); + yield return new WaitForSeconds(delay); + + StartAnimationWithTarget(target); + + yield return new WaitForSeconds(4); + + StartCoroutine(StopAnimation()); +// Invoke("StopAnimation", 5); + } + + public void StartAnimationWithTarget(Transform target) + { + Debug.Log("StartAnimationWithTarget"); + + // Prepare + targetOriginalPosition = target.position; + targetOverlay = target.Find("Sprite").GetComponent(); + + // Execute + Attack(); + } + + public IEnumerator StopAnimation() + { + Debug.Log("Stopping animation"); + Debug.Log("Completed loops: " + seq.CompletedLoops()); + int loopTo = seq.CompletedLoops() + 1; + // yield return seq.WaitForElapsedLoops(seq.CompletedLoops() + 1); + yield return seq.WaitForElapsedLoops(loopTo); + + Debug.Log("KILLING"); + + seq.Kill(true); + } + + void Attack() + { + Vector2 direction = (targetOriginalPosition - originalPosition).normalized; + + float attackAnticipationTime = 0.05f; + float attackMoveForwardTime = 0.08f; + + // Attacking unit movement + seq = DOTween.Sequence(); + seq.Append(transform.DOBlendableMoveBy(-direction * 0.05f, attackAnticipationTime)); + seq.Append(transform.DOBlendableMoveBy(direction * 0.2f, attackMoveForwardTime)); + seq.Append(transform.DOBlendableMoveBy(-((-direction * 0.05f) + (direction * 0.2f)), 0.3f)); + + // Target unit movement + Sequence def = DOTween.Sequence(); + def.Append(target.DOBlendableMoveBy(direction * 0.2f, 0.05f)); + def.Append(target.DOBlendableMoveBy(-(direction * 0.2f), 0.3f)); + seq.Insert(attackAnticipationTime + attackMoveForwardTime, def); + + // Target unit hit flashing + targetOverlay.color = new Color(1, 1, 1, 0); + Sequence flash = DOTween.Sequence(); + flash.Append(targetOverlay.DOFade(0.7f, 0.05f)); + flash.Append(targetOverlay.DOFade(0, 0.5f)).SetEase(Ease.Linear); + seq.Insert(attackAnticipationTime + attackMoveForwardTime, flash); + + seq.AppendInterval(1.5f); + seq.SetLoops(-1); } void OnGUI() { - if (GUILayout.Button("Goto")) t.Goto(gotoTime); + if (seq != null) { + if (seq.CompletedLoops() != prevCompletedLoops) Debug.Log("LOOP CHANGE FROM " + prevCompletedLoops + " TO " + seq.CompletedLoops()); + GUILayout.Label("completed loops: " + seq.CompletedLoops() + " (duration: " + seq.Duration(false) + ")"); + prevCompletedLoops = seq.CompletedLoops(); + } } } \ No newline at end of file diff --git a/UnityTests.Unity5/Assets/_Tests/TempTests.unity b/UnityTests.Unity5/Assets/_Tests/TempTests.unity index a451720..9a1d13d 100644 Binary files a/UnityTests.Unity5/Assets/_Tests/TempTests.unity and b/UnityTests.Unity5/Assets/_Tests/TempTests.unity differ diff --git a/UnityTests.Unity5/ProjectSettings/TagManager.asset b/UnityTests.Unity5/ProjectSettings/TagManager.asset index f73f240..3a10b46 100644 Binary files a/UnityTests.Unity5/ProjectSettings/TagManager.asset and b/UnityTests.Unity5/ProjectSettings/TagManager.asset differ diff --git a/_DOTween.Assembly/DOTween/DOTween.cs b/_DOTween.Assembly/DOTween/DOTween.cs index 46d73c3..22a498b 100644 --- a/_DOTween.Assembly/DOTween/DOTween.cs +++ b/_DOTween.Assembly/DOTween/DOTween.cs @@ -21,7 +21,7 @@ namespace DG.Tweening public class DOTween { /// DOTween's version - public static readonly string Version = "1.0.350"; + public static readonly string Version = "1.0.351"; /////////////////////////////////////////////// // Options //////////////////////////////////// diff --git a/_DOTween.Assembly/DOTween/TweenExtensions.cs b/_DOTween.Assembly/DOTween/TweenExtensions.cs index 6e1a9c6..802804b 100644 --- a/_DOTween.Assembly/DOTween/TweenExtensions.cs +++ b/_DOTween.Assembly/DOTween/TweenExtensions.cs @@ -97,7 +97,7 @@ namespace DG.Tweening if (complete) { TweenManager.Complete(t); - if (t.autoKill) return; // Already killed by Complete, so no need to go on + if (t.autoKill && t.loops >= 0) return; // Already killed by Complete, so no need to go on } if (TweenManager.isUpdateLoop) { diff --git a/_DOTween.Assembly/bin/DOTween.dll b/_DOTween.Assembly/bin/DOTween.dll index e3cc9db..f02895f 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll and b/_DOTween.Assembly/bin/DOTween.dll differ diff --git a/_DOTween.Assembly/bin/DOTween.dll.mdb b/_DOTween.Assembly/bin/DOTween.dll.mdb index 2e70876..174e7a7 100644 Binary files a/_DOTween.Assembly/bin/DOTween.dll.mdb and b/_DOTween.Assembly/bin/DOTween.dll.mdb differ