private void SetInitialGameInventory() { var storages = BuildingController.FindAllStructOfThisTypeContain(H.Storage); for (int i = 0; i < storages.Count; i++) { GameInventory.AddItems(storages[i].Inventory.InventItems); } }
/// <summary> /// Will tell u if the item is on one of the inventorires /// </summary> /// <param name="item"></param> /// <returns></returns> public bool IsItemOnInv(P item) { var storages = BuildingController.FindAllStructOfThisTypeContain(H.Storage); for (int i = 0; i < storages.Count; i++) { if (storages[i].Inventory.IsItemOnInv(item)) { return(true); } } return(false); }
/// <summary> /// Will tell u if all inventories are empty on the storages /// </summary> /// <returns></returns> internal bool IsEmpty() { var storages = BuildingController.FindAllStructOfThisTypeContain(H.Storage); for (int i = 0; i < storages.Count; i++) { if (!storages[i].Inventory.IsEmpty()) { return(false); } } return(true); }
/// <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; } } }
/// <summary> /// Will tell u if item on inventories and amount on inventories bigger than the asked for 'amt' /// </summary> /// <param name="item"></param> /// <param name="amt"></param> /// <returns></returns> public bool HasThisItemAndAmt(P item, float amt) { float accum = 0; var storages = BuildingController.FindAllStructOfThisTypeContain(H.Storage); for (int i = 0; i < storages.Count; i++) { if (storages[i].Inventory.IsItemOnInv(item)) { accum += storages[i].Inventory.ReturnAmtOfItemOnInv(item); } } return(accum > amt); }