public bool IsHaveingEquip(NeedEquip[] needEquip)
    {
        if (needEquip == null)
        {
            return(true);
        }
        List <NeedEquip> list = new List <NeedEquip>(NeedEquip.DivideNeedEquip(needEquip));

        for (LinkedListNode <EquipItemInfo> linkedListNode = equipItemInventory.GetFirstNode(); linkedListNode != null; linkedListNode = linkedListNode.Next)
        {
            NeedEquip needEquip2 = null;
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].equipItemID == linkedListNode.Value.tableID && list[i].num == 1 && list[i].needLv <= linkedListNode.Value.level)
                {
                    needEquip2 = list[i];
                    break;
                }
            }
            if (needEquip2 != null)
            {
                list.Remove(needEquip2);
            }
            if (list.Count == 0)
            {
                return(true);
            }
        }
        if (list.Count != 0)
        {
            return(false);
        }
        return(true);
    }
Esempio n. 2
0
    public static NeedEquip[] DivideNeedEquip(NeedEquip[] old)
    {
        List <NeedEquip> list = new List <NeedEquip>();

        for (int i = 0; i < old.Length; i++)
        {
            for (int j = 0; j < old[i].num; j++)
            {
                NeedEquip needEquip = old[i].Copy();
                needEquip.num = 1;
                list.Add(needEquip);
            }
        }
        return(list.ToArray());
    }
Esempio n. 3
0
 protected void CheckNeedMaterialNumFromInventory()
 {
     if (needMaterial != null)
     {
         haveMaterialNum = new int[needMaterial.Length];
         List <uint> list = new List <uint>();
         for (int i = 0; i < needMaterial.Length; i++)
         {
             list.Add(needMaterial[i].itemID);
         }
         LinkedListNode <ItemInfo> node;
         for (node = MonoBehaviourSingleton <InventoryManager> .I.itemInventory.GetFirstNode(); node != null; node = node.Next)
         {
             uint find_id = 0u;
             list.ForEach(delegate(uint id)
             {
                 if (find_id == 0 && id == node.Value.tableID)
                 {
                     int num = 0;
                     for (int l = 0; l < needMaterial.Length; l++)
                     {
                         if (needMaterial[l].itemID == id)
                         {
                             num = l;
                             break;
                         }
                     }
                     haveMaterialNum[num] = node.Value.num;
                     find_id = id;
                 }
             });
             if (find_id != 0)
             {
                 list.Remove(find_id);
             }
         }
     }
     if (needEquip != null)
     {
         needEquip    = NeedEquip.DivideNeedEquip(needEquip);
         haveEquipNum = new int[needEquip.Length];
         if (selectedUniqueIdList == null)
         {
             selectedUniqueIdList = new ulong[needEquip.Length];
         }
         List <uint> list2 = new List <uint>();
         for (int j = 0; j < needEquip.Length; j++)
         {
             list2.Add(needEquip[j].equipItemID);
         }
         for (LinkedListNode <EquipItemInfo> linkedListNode = MonoBehaviourSingleton <InventoryManager> .I.equipItemInventory.GetFirstNode(); linkedListNode != null; linkedListNode = linkedListNode.Next)
         {
             for (int k = 0; k < needEquip.Length; k++)
             {
                 if (linkedListNode.Value.tableID == needEquip[k].equipItemID)
                 {
                     haveEquipNum[k]++;
                 }
             }
         }
     }
 }