// Author: Daniele Giardini - http://www.demigiant.com // Created: 2017/10/28 20:13 // License Copyright (c) Daniele Giardini using System.Collections.Generic; namespace DG.Tweening { /// /// Extra DOTween methods not included in public engine (for consistency reasons) /// public static class DOTweenExtras { static readonly List _RecyclableList = new List(); #region Public Methods #region Info Getters /// /// Returns TRUE if there are tweens with the given id, and they're all currently playing forward /// public static bool IsPlayForwardById(object id) { List tweens = DOTween.TweensById(id, false, _RecyclableList); return AreAllPlayingForward(tweens); } /// /// Returns TRUE if there are tweens with the given target, and they're all currently playing forward /// public static bool IsPlayForwardByTarget(object target) { List tweens = DOTween.TweensByTarget(target, false, _RecyclableList); return AreAllPlayingForward(tweens); } /// /// Returns TRUE if there are tweens with the given id, and they're all currently playing backwards /// public static bool IsPlayBackwardsById(object id) { List tweens = DOTween.TweensById(id, false, _RecyclableList); return AreAllPlayingBackwards(tweens); } /// /// Returns TRUE if there are tweens with the given target, and they're all currently playing backwards /// public static bool IsPlayBackwardsByTarget(object target) { List tweens = DOTween.TweensByTarget(target, false, _RecyclableList); return AreAllPlayingBackwards(tweens); } /// /// Returns TRUE if there are tweens with the given id, and they're all currently paused /// public static bool IsPausedById(object id) { List tweens = DOTween.TweensById(id, false, _RecyclableList); return AreAllPaused(tweens); } /// /// Returns TRUE if there are tweens with the given target, and they're all currently paused /// public static bool IsPausedByTarget(object target) { List tweens = DOTween.TweensByTarget(target, false, _RecyclableList); return AreAllPaused(tweens); } #endregion #endregion #region Methods static bool AreAllPlayingForward(List tweens) { if (tweens == null) return false; foreach (Tween t in tweens) { if (!t.IsPlaying() || t.isBackwards) return false; } return true; } static bool AreAllPlayingBackwards(List tweens) { if (tweens == null) return false; foreach (Tween t in tweens) { if (!t.IsPlaying() || !t.isBackwards) return false; } return true; } static bool AreAllPaused(List tweens) { if (tweens == null) return false; foreach (Tween t in tweens) { if (t.IsPlaying()) return false; } return true; } #endregion } }