예제 #1
0
    public bool makeInventorySpaceFor(GameTypes.ItemType itype)
    {
        //dumps everything in the inventory except items of a certain type
        //return true if unit needs to return to stockpile, false other wise
        Dictionary <GameTypes.ItemType, int> dict = getInventoryDictionary();
        Building sp         = getStockpile();
        bool     new_action = false;

        foreach (KeyValuePair <GameTypes.ItemType, int> pair in dict)
        {
            //skip- if the item is equipped
            Item      it = getItemOfType(pair.Key);
            EquipItem ei = it as EquipItem;
            if (ei)
            {
                if (ei.isEquipped())
                {
                    continue;
                }
            }
            //skip if its the item we want
            if (pair.Key != itype)
            {
                //make an exchange with the stockpile
                exchangeWith(sp, pair.Key, pair.Value);
                new_action = true;
            }
        }
        return(new_action);
    }
예제 #2
0
 public override void wipe()
 {
     //deletes the Items, then resets the Item list to be empty
     //doesnt remove the equipped items
     foreach (Item item in mItems)
     {
         EquipItem ei = item as EquipItem;
         if (ei)
         {
             if (ei.isEquipped())
             {
                 continue;
             }
         }
         Destroy(item.gameObject);
     }
     mItems = new List <Item>();
 }
예제 #3
0
    public List <EquipItem> getEquippedItems()
    {
        List <EquipItem> elist = new List <EquipItem>();

        foreach (Item it in mItems)
        {
            EquipItem ei = it as EquipItem;
            if (!ei)
            {
                continue;
            }
            if (ei.isEquipped() == true)
            {
                elist.Add(ei);
            }
        }
        return(elist);
    }
예제 #4
0
 public override void Update()
 {
     //remove an item if it has 0 or less
     foreach (Item item in mItems)
     {
         if (item.getAmount() <= 0)
         {
             EquipItem ei = item as EquipItem;
             if (ei)
             {
                 if (ei.isEquipped())
                 {
                     unequipItem(ei);
                 }
             }
         }
     }
     base.Update();
 }
예제 #5
0
    public List <EquipItem> getAvailableEquipItems()
    {
        //Items that can be equipped but are not equipped.
        List <EquipItem> alist = new List <EquipItem>();

        foreach (Item it in mItems)
        {
            EquipItem ei = it as EquipItem;
            if (!ei)
            {
                continue;
            }
            if (ei.isEquipped() == false)
            {
                alist.Add(ei);
            }
        }
        return(alist);
    }
예제 #6
0
    public virtual void Update()
    {
        //remove an item if it has 0 or less
        List <Item> ritems = new List <Item>();

        foreach (Item item in mItems)
        {
            if (item.getAmount() <= 0)
            {
                ritems.Add(item);
                //_removeItemOfType(item.getType());
            }
        }
        foreach (Item ri in ritems)
        {
            _removeItemOfType(ri.getType());
        }

        //check that the inventory cap hasnt suddenly gotten much smaller than the size
        while (mCapacity < getSize())
        {
            //the inventory cap has suddenly gotten too small
            foreach (Item item in mItems)
            {
                //dont remove equipped items
                EquipItem ei = item as EquipItem;
                if (ei)
                {
                    if (ei.isEquipped() == true)
                    {
                        continue;
                    }
                }
                _removeItemOfType(item.getType());
                break;
            }
        }
    }
예제 #7
0
    public void dumpInventory()
    {
        //drop everything in the inventory into the stockpile

        /*Exchange ex = ObjectManager.initExchange(transform);
         * ex.setTarget(getStockpile());
         * ex.setExchangeList(getInventoryDictionary());
         * mActions.prependAction(ex);*/
        foreach (KeyValuePair <GameTypes.ItemType, int> it in getInventoryDictionary())
        {
            Item      item = getItemOfType(it.Key);
            EquipItem ei   = item as EquipItem;
            if (ei)
            {
                //if its equipped, dont drop it
                if (ei.isEquipped() == true)
                {
                    continue;
                }
            }
            exchangeWith(getStockpile(), it.Key, it.Value);
        }
    }