示例#1
0
        public void SetLayer(int layer)
        {
            if (layer == 0)
            {
                return;
            }
            this.layer = layer;

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

            if (this.gameObject != null)
            {
                SetLayerRecursively(this.gameObject);
            }
        }
示例#2
0
    public void Update()
    {
        if (startTime <= 0)
        {
            return;
        }

        if (!GameTimer.Within(startTime, this.LifeTime))
        {
            Dispose();
            return;
        }

        for (PListNode pos = this.actionEvents.next, next; pos != this.actionEvents; pos = next)
        {
            next = pos.next; //先保存下一个节点
            ZWActionEvent ae = ( ZWActionEvent )pos;
            if (ae.Disposed)
            {
                this.actionEvents.Remove(ae);
                return;
            }
            if (ae.Active)
            {
                ae.DoEvent();
            }
            ae.Update();
        }
    }
示例#3
0
 public void Remove(PListNode node)
 {
     node.prev.next = node.next;
     node.next.prev = node.prev;
     node.prev      = null;
     node.next      = null;
     Count--;
 }
示例#4
0
 public void Add(PListNode node)
 {
     this.next.prev = node;
     node.next      = this.next;
     node.prev      = this;
     this.next      = node;
     this.Count++;
 }
示例#5
0
 public void RemoveZWAction(ZWAction action)
 {
     if (this.start_ == action)
     {
         this.start_ = action.prev;
     }
     this.actionList_.Remove(action);
 }
示例#6
0
    public void AddTail(PListNode node)
    {
        PListNode p = prev;

        this.prev = node;
        node.next = this;
        node.prev = p;
        p.next    = node;
        Count++;
    }
示例#7
0
    /// <summary>
    /// 删除所有节点
    /// </summary>
    public void RemoveAllItem()
    {
        PListNode node = this.item_list.prev;

        while (node != this.item_list)
        {
            PListNode prev = node.prev;
            RemoveItem(node as LRUItem);
            node = prev;
        }
    }
示例#8
0
        public void Destroy()
        {
            if (destroy)
            {
                return;
            }

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

                if (ctrls != null)
                {
                    foreach (IController c in ctrls.Values)
                    {
                        if (c != null)
                        {
                            c.Destroy();
                        }
                    }
                    ctrls.Clear();
                    ctrls = null;
                }

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

                this.SetParent(null);
                this.OnDestroy();

                if (this.owner != null)
                {
                    this.owner.RemoveInstance(this);
                    this.owner = null;
                }
            } catch (Exception e) {
                LOG.LogError(e.ToString(), this.gameObject);
            }
            destroy = true;
        }
示例#9
0
    //结束Action
    void EndAction()
    {
        for (PListNode pos = this.actionEvents.next; pos != this.actionEvents; pos = pos.next)
        {
            ZWActionEvent ae = (ZWActionEvent)pos;
            ae.Dispose();
        }

        if (ActionPerformer_)
        {
            ActionPerformer_.RemoveZWAction(this);
        }
    }
示例#10
0
        public void Create()
        {
            if (destroy)
            {
                return;
            }
            this.OnCreate();
            complete = true;
            if (this.parent != null)
            {
                if (this.gameObject != null && this.parent.gameObject != null)
                {
                    this.gameObject.transform.parent = this.parent.gameObject.transform;
                }

                // Inherit the parent's layer, when child doesn't assign a layer.
                if (this.layer == 0 && this.parent.layer != 0)
                {
                    this.layer = this.parent.layer;
                }
            }

            ApplyInitPosition();

            if (children != null)
            {
                for (PListNode n = children.next; n != children; n = n.next)
                {
                    IRenderObject child = (IRenderObject)n;
                    if (this.gameObject != null && child.gameObject != null)
                    {
                        child.gameObject.transform.parent = this.gameObject.transform;
                        child.ApplyInitPosition();
                    }
                }
            }

            SetLayer(this.layer);

            if (!this.visible)
            {
                SetVisible(this.visible);
            }

            if (!this.skinvisible)
            {
                SetSkinVisible(this.skinvisible);
            }
        }
示例#11
0
    public void Update()
    {
        for (PListNode pos = this.start_.next, next; pos != this.actionList_; pos = next, this.start_ = next)
        {
            //先保存下一个节点
            next = pos.next;
            ZWAction action = ( ZWAction )pos;
            action.Update();
        }

        if (this.start_.next == this.actionList_)
        {
            start_ = this.actionList_;
        }
    }
示例#12
0
 public void Clear()
 {
     for (int i = 0; i < socket_size_; i++)
     {
         PList head = list_[i];
         for (PListNode pos = head.next; pos != head; pos = pos.next)
         {
             TimerEventObject obj = (TimerEventObject)pos;
             obj.enable = 0;
             obj.proc   = null;
             obj.obj    = null;
         }
         head.Init();
     }
 }
示例#13
0
    public void Process()
    {
        PList head      = list_[socket_index_];
        int   cur_index = socket_index_;

        socket_index_++;
        if (socket_index_ >= socket_size_)
        {
            socket_index_ = 0;
        }

        PListNode pos = null, n = null;

        for (pos = head.next, n = pos.next;
             pos != head;
             pos = n, n = pos.next)
        {
            TimerEventObject obj = (TimerEventObject)pos;
            if (obj.circle <= 0)
            {
                head.Remove(pos);
                if ((0 != obj.enable) && obj.proc(obj.obj, obj.p1, obj.p2))
                {
                    obj.circle = (short)(obj.interval / socket_size_);
                    int index = obj.interval % socket_size_ + cur_index;
                    if (index == cur_index)
                    {
                        obj.circle--;
                    }
                    if (index >= socket_size_)
                    {
                        index = index - socket_size_;
                    }
                    list_[index].Add(pos);
                }
                else
                {
                    obj.proc = null;
                    obj.obj  = null;
                }
            }
            else
            {
                obj.circle--;
            }
        }
    }
示例#14
0
    public PListNode Pop()
    {
        if (prev == this)
        {
            return(null);
        }

        PListNode node = this.next;

        node.prev.next = node.next;
        node.next.prev = node.prev;
        node.prev      = null;
        node.next      = null;
        Count--;

        return(node);
    }
示例#15
0
    public void AddListTail(PList list)
    {
        if (list.next == list)
        {
            return;
        }

        PListNode first = list.next;
        PListNode last  = list.prev;
        PListNode at    = this.prev;

        at.next    = first;
        first.prev = at;

        this.prev = last;
        last.next = this;

        this.Count += list.Count;
        list.Init();
    }
示例#16
0
    /// <summary>
    /// 遍历节点,提供visitor如果返回true时,停止遍历
    /// </summary>
    /// <param name="visitor"></param>
    public void ForEach(Predicate <T> visitor)
    {
        if (visitor == null)
        {
            return;
        }
        if (Count == 0)
        {
            return;
        }
        PListNode node = this.item_list.next;

        while (node != this.item_list)
        {
            LRUItem item = node as LRUItem;
            if (visitor(item.value))
            {
                break;
            }
            node = node.next;
        }
    }
示例#17
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();
            }
        }
示例#18
0
    /// <summary>
    /// 更新节点
    /// </summary>
    /// <param name="needkeeper">可选,外部决定是否需要删除过期节点</param>
    public void Update(Predicate <T> needkeeper)
    {
        //从尾部开始遍历
        PListNode node = this.item_list.prev;

        while (node != this.item_list)
        {
            LRUItem   item = node as LRUItem;
            PListNode prev = node.prev;
            if (item.time + this.life_time < GameTimer.time)
            {
                if (needkeeper == null || !needkeeper(item.value))
                {
                    RemoveItem(item);
                }
            }
            else
            {
                break;
            }
            node = prev;
        }
    }
示例#19
0
 public void Awake()
 {
     this.actionList_ = new PList();
     this.start_      = this.actionList_;
     this.actionList_.Init();
 }