Esempio n. 1
0
        public IEnumerator GBStartCoroutine(string id, IEnumerator routine)
        {
            GlobalCoroutineBehavior gcb = null;

            if (curCoroutineDict.ContainsKey(id))
            {
                gcb = curCoroutineDict[id];
            }
            else
            {
                if (CoroutinePool.Count == 0)
                {
                    GameObject go = new GameObject("GlobalCoroutineBehavior");
                    go.transform.SetParent(transform);
                    gcb             = go.AddComponent <GlobalCoroutineBehavior>();
                    gcb.onComplete += OnCompleteCoroutineBehavior;
                }
                else
                {
                    gcb = CoroutinePool[0];
                    CoroutinePool.Remove(gcb);
                }
                curCoroutineDict[id] = gcb;
            }
            yield return(gcb.GBStartCoroutine(id, routine));
        }
Esempio n. 2
0
        public void UTStopCoroutine(string id)
        {
            GlobalCoroutineBehavior gcb = null;

            curCoroutineDict.TryGetValue(id, out gcb);
            if (gcb != null)
            {
                gcb.UTStopCoroutine();
            }
        }
Esempio n. 3
0
        private void OnCompleteCoroutineBehavior(string id)
        {
            GlobalCoroutineBehavior gcb = null;

            curCoroutineDict.TryGetValue(id, out gcb);
            if (gcb != null)
            {
                if (!CoroutinePool.Contains(gcb))
                {
                    CoroutinePool.Add(gcb);
                }
            }
            if (curCoroutineDict.ContainsKey(id))
            {
                curCoroutineDict.Remove(id);
            }
        }