Example #1
0
        public void Update()
        {
            if (destroy)
            {
                return;
            }

            if (ctrls != null)
            {
                foreach (var v in ctrls.Values)
                {
                    IController c = v as IController;
                    if (c != null && c.enabled)
                    {
                        c.Update();
                    }
                }
            }
            OnUpdate();

            if (children != null)
            {
                for (PListNode n = children.next, next; n != children; n = next)
                {
                    next = n.next;
                    IRenderObject child = (IRenderObject)n;
                    if (child != null)
                    {
                        child.Update();
                    }
                }
            }

            if (timer != null)
            {
                timer.Process();
            }
        }
        internal void Update()
        {
            if (!active)
            {
                return;
            }

            if (components != null)
            {
                if (dict == null)
                {
                    dict = new Dictionary <IRenderComponent, bool>();
                }
                dict.Clear();

                for (int i = 0; i < tempComponents.Count; i++)
                {
                    var c = tempComponents[i];
                    if (c == null)
                    {
                        continue;
                    }

                    if (dict.ContainsKey(c))
                    {
                        continue;
                    }
                    dict[c] = true;

                    if (c.enabled)
                    {
                        c.Update();
                    }
                }
            }
            OnUpdate();

            if (children != null)
            {
                for (var n = children.next; n != children;)
                {
                    if (n == null)
                    {
                        // children maybe all destroyed in child.Update()
                        // for fix NullReference exception.
                        break;
                    }
                    var next = n.next;

                    IRenderObject child = (IRenderObject)n;
                    if (child != null)
                    {
                        child.Update();
                    }

                    n = next;
                }
            }

            if (timer != null)
            {
                timer.Process();
            }
        }