示例#1
0
    /// <summary>
    /// Will retruen the amt of Category in all inventories.
    ///
    /// Used for GUI
    /// </summary>
    /// <param name="pCat"></param>
    /// <returns></returns>
    public float ReturnAmountOnCategory(PCat pCat)
    {
        if (Program.GameFullyLoaded() && GameInventory.InventItems.Count == 0)
        {
            SetInitialGameInventory();
        }

        return(GameInventory.ReturnAmountOnCategory(pCat));
    }
示例#2
0
文件: Inventory.cs 项目: Cdrix/SM
    /// <summary>
    /// Will return a list with all the products in the inventory of tht category.
    /// For ex if is food will put all the food items
    /// </summary>
    /// <param name="pCat"></param>
    /// <returns></returns>
    List <P> ReturnListOfCatOfProd(PCat pCat)
    {
        List <P> res = new List <P>();

        if (pCat == PCat.Food)
        {
            return(FoodCatItems);
        }

        return(res);
    }
示例#3
0
    /// <summary>
    /// Will remove from the 'building' and will tell u how much is left to be removed
    /// </summary>
    private float LeftToRemovePCat(PCat cat, float amt, Structure building)
    {
        if (building.Inventory.DoWeHaveOfThisCat(cat))
        {
            var removed = building.Inventory.RemoveByCategory(cat, amt);
            var left    = amt - removed;

            return(left);
        }
        return(amt);
    }
示例#4
0
文件: Inventory.cs 项目: Cdrix/SM
    /// <summary>
    /// Use for see how much food is it in all Storages
    /// </summary>
    /// <param name="pCat"></param>
    /// <returns></returns>
    public float ReturnAmountOnCategory(PCat pCat)
    {
        List <P> foodItems = ReturnListOfCatOfProd(pCat);
        float    res       = 0;

        for (int i = 0; i < foodItems.Count; i++)
        {
            res += ReturnAmtOfItemOnInv(foodItems[i]);
        }

        return(res);
    }
示例#5
0
    /// <summary>
    /// Will remove the item and the amount from the inventories.
    ///
    /// This method is use for an building was built and 40 wood for ex needs to be removed
    ///
    /// Will loop thru the storages until remove the full amt
    /// </summary>
    /// <param name="item"></param>
    /// <param name="amt"></param>
    public void RemoveOnCategory(PCat cat, float amt)
    {
        var storages = BuildingController.FindAllStructOfThisTypeContain(H.Storage);

        for (int i = 0; i < storages.Count; i++)
        {
            var left = LeftToRemovePCat(cat, amt, storages[i]);

            if (left == 0)
            {
                return;
            }
        }
    }
示例#6
0
文件: Inventory.cs 项目: Cdrix/SM
    /// <summary>
    /// Will return items of type
    ///
    /// Used to get all the food out of a person
    /// </summary>
    /// <returns></returns>
    public List <InvItem> ReturnAllItemsCat(PCat pCat)
    {
        List <InvItem> res = new List <InvItem>();

        for (int i = 0; i < _inventItems.Count; i++)
        {
            var cateOfCurr = CategorizeProd(_inventItems[i].Key);
            if (cateOfCurr == pCat)
            {
                res.Add(_inventItems[i]);
            }
        }
        return(res);
    }
示例#7
0
文件: Inventory.cs 项目: Cdrix/SM
    /// <summary>
    ///
    /// </summary>
    /// <param name="pCat"></param>
    /// <param name="amtNeeded"></param>
    /// <returns>Returns wht is left from amt needed. if is 0 is was fully covered</returns>
    internal float RemoveByCategory(PCat pCat, float amtNeeded)
    {
        var items = ReturnAllItemsCat(pCat);

        for (int i = 0; i < items.Count; i++)
        {
            //if the items is not able to cover it all needed
            if (items[i].Amount < amtNeeded)
            {
                //amt Needed being covered
                amtNeeded -= items[i].Amount;
                //will delete tht item from inventory
                RemoveByWeight(items[i].Key, items[i].Amount);
            }
            //if can cover the rest needed
            else
            {
                RemoveByWeight(items[i].Key, amtNeeded);
                amtNeeded = 0;
            }
        }
        return(amtNeeded);
    }
示例#8
0
文件: Inventory.cs 项目: Cdrix/SM
 public bool DoWeHaveOfThisCat(PCat cat)
 {
     return(ReturnAmountOnCategory(cat) > 0);
 }