public void Travers_level(ITreeTraversCallback iCallback)
 {
     if (this.queue == null)
     {
         this.queue = new Queue <BEquip_node>();
     }
     if (this.root != null)
     {
         this.queue.Enqueue(this.root);
     }
     while (this.queue.Count > 0)
     {
         BEquip_node bEquip_node = this.queue.Dequeue();
         if (iCallback == null || iCallback.TraversCallback(bEquip_node, bEquip_node.Level))
         {
             int childrenNum = bEquip_node.GetChildrenNum();
             for (int i = 0; i < childrenNum; i++)
             {
                 BEquip_node childByIndex = bEquip_node.GetChildByIndex(i);
                 if (childByIndex != null)
                 {
                     this.queue.Enqueue(childByIndex);
                 }
             }
         }
     }
 }
        private bool OnCallback(BEquip_node node, int level)
        {
            bool result = false;

            if (node != null && node.Data != null)
            {
                RItemData data = node.Data;
                int       num  = this._hasItems.IndexOf(data.ID);
                if (data.Possessed && num != -1)
                {
                    this._hasItems.RemoveAt(num);
                }
                else if (!data.Afford)
                {
                    result = true;
                }
                else if (this.num == 6 && data.Price <= data.RealPrice)
                {
                    result = true;
                }
                else
                {
                    this.InsertItem(data);
                }
            }
            return(result);
        }
 public void GenerateTree(RItemData data)
 {
     if (data != null)
     {
         this.root = new BEquip_node(data, 0);
         this.root.GenerateChilren(0);
     }
 }
Beispiel #4
0
        public BEquip_node GetChildByIndex(int n)
        {
            BEquip_node result = null;

            if (this.children != null && n >= 0 && n < this.children.Count)
            {
                result = this.children[n];
            }
            return(result);
        }
Beispiel #5
0
        private bool OnCallback(BEquip_node node, int level)
        {
            RItemData data = node.Data;

            if (data != null)
            {
                data.Afford = (this._money >= data.RealPrice);
            }
            return(true);
        }
Beispiel #6
0
 public void AddChild(BEquip_node newChild)
 {
     if (newChild != null)
     {
         if (this.children == null)
         {
             this.children = new List <BEquip_node>();
         }
         this.children.Add(newChild);
     }
 }
Beispiel #7
0
        private bool OnCallback(BEquip_node node, int level)
        {
            bool      result = false;
            RItemData data   = node.Data;

            if (data != null)
            {
                this.curTarget    = data.ID;
                data.PossessedNum = this._hasItems.Count(new Func <string, bool>(this.Selector));
                result            = !data.Possessed;
            }
            return(result);
        }
 public void DestroyTree()
 {
     if (this.root != null)
     {
         this.root.DestroyChildren();
         this.root = null;
     }
     if (this.queue != null)
     {
         this.queue.Clear();
         this.queue = null;
     }
 }
        private bool OnCallback(BEquip_node node, int level)
        {
            bool result = true;

            if (node.Data.Possessed && !node.Data.ID.Equals(this._targetItem.ID))
            {
                int num = this._hasItems.IndexOf(node.Data.ID);
                if (num != -1)
                {
                    this._hasItems.RemoveAt(num);
                    this.realPrice -= node.Data.Config.sell;
                    result          = false;
                }
            }
            return(result);
        }
        private bool OnCallback(BEquip_node node, int level)
        {
            bool result = false;

            if (node != null)
            {
                if (this.func_price == null)
                {
                    this.func_price = new RecommendItem_price(node.Data, this._hasItems);
                }
                else
                {
                    this.func_price.Reset(node.Data, this._hasItems);
                }
                node.Travers_first(this.func_price);
                node.Data.RealPrice = (int)this.func_price.Result;
                result = true;
            }
            return(result);
        }
Beispiel #11
0
        public void GenerateChilren(int depth)
        {
            if (depth > 3)
            {
                return;
            }
            List <RItemData> list = this.data.GenerateChilren(this._level + 1);

            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != null)
                    {
                        BEquip_node bEquip_node = new BEquip_node(list[i], this._level + 1);
                        this.AddChild(bEquip_node);
                        bEquip_node.GenerateChilren(depth + 1);
                    }
                }
            }
        }
 private void UpdateRItemsSub_Tree(string rootItem)
 {
     if (string.IsNullOrEmpty(rootItem))
     {
         if (this.tree != null)
         {
             this.tree.DestroyTree();
         }
     }
     else
     {
         if (this.tree == null)
         {
             this.tree = new BattleEquipTools_Tree();
         }
         BEquip_node root = this.tree.GetRoot();
         if (root == null || !root.Data.ID.Equals(rootItem))
         {
             this.tree.DestroyTree();
             RItemData rItemData = new RItemData(rootItem, this.data.DicShops);
             this.tree.GenerateTree(rItemData);
         }
     }
 }