Example #1
0
        public bool RemoveAllTweensFromTarget(GameObject target)
        {
            if (target == null)
            {
                Debug.LogError("error, target is null");
                return(false);
            }
            if (!dicOfObjTweens.ContainsKey(target))
            {
                Debug.LogError("error, dicOfTweens not contains target");
                return(false);
            }

            var       tweenComps = dicOfObjTweens[target];
            TweenComp tweenComp  = null;

            for (int i = tweenComps.Count - 1; i >= 0; i--)
            {
                tweenComp = tweenComps[i];
                GameObject.Destroy(tweenComp);
                this.curCount--;
            }
            dicOfObjTweens.Remove(target);
            return(true);
        }
Example #2
0
        public Tween GetTweenById(GameObject target, int id)
        {
            if (target == null)
            {
                Debug.LogError("error, target is null");
                return(null);
            }

            if (!dicOfObjTweens.ContainsKey(target))
            {
                Debug.LogWarning("error, dicOfTweens not contain target");
                return(null);
            }
            var       tweenComps = dicOfObjTweens[target];
            TweenComp tweenComp  = null;

            for (int i = tweenComps.Count - 1; i >= 0; i--)
            {
                tweenComp = tweenComps[i];
                if (tweenComp.GetTween().GetId() == id)
                {
                    return(tweenComp.GetTween());
                }
            }

            Debug.LogWarning("target does not have the tween of id:" + id);
            return(null);
        }
Example #3
0
        /// <summary>
        /// remove tween by id from target
        /// </summary>
        /// <param name="target"></param>
        /// <param name="id"></param>
        public bool RemoveTweenById(GameObject target, int id)
        {
            if (target == null)
            {
                Debug.LogError("error, target is null");
                return(false);
            }

            if (!dicOfObjTweens.ContainsKey(target))
            {
                Debug.LogWarning("error, dicOfTweens not contain target");
                return(false);
            }
            var       tweenComps = dicOfObjTweens[target];
            TweenComp tweenComp  = null;

            for (int i = tweenComps.Count - 1; i >= 0; i--)
            {
                tweenComp = tweenComps[i];
                if (tweenComp.GetTween().GetId() == id)
                {
                    tweenComps.Remove(tweenComp);
                    GameObject.Destroy(tweenComp);
                    this.curCount--;
                    if (tweenComps.Count == 0)
                    {
                        dicOfObjTweens.Remove(target);
                    }

                    return(true);
                }
            }
            Debug.LogWarning("target does not have the tween of id:" + id);
            return(false);
        }
Example #4
0
        bool addTweenComp(GameObject target, TweenComp tweenComp)
        {
            if (!dicOfObjTweens.ContainsKey(target))
            {
                dicOfObjTweens[target] = new List <TweenComp>();
            }
            var tweenComps = dicOfObjTweens[target];

            for (int i = 0; i < tweenComps.Count; i++)
            {
                if (tweenComps[i].GetTween() == tweenComp.GetTween())
                {
                    Debug.LogError("dicOfTweens have the same tween, can not add");
                    return(false);
                }
            }
            tweenComps.Add(tweenComp);
            return(true);
        }