public int GetItemTotalPrice(InventoryItemObject item) { if (!IsShopActive()) { //Debug.Log ("shop is not active"); return(item.info.costInfo.timePrice); } Transform slot = item.GetSlot(); if (slot == null) { return(0); } WagonInventoryUI inventory = slot.parent.parent.GetComponent <WagonInventoryUI>(); if (inventory == shopInventory) { return(item.GetBuyPrice()); } else { if (vendorShopInfo.FindInfoByIndex(item.info.databaseIndex) != null) { return(item.GetSellPrice()); } else { //Debug.Log ("vendor is not interested"); return(0); } } }
public bool CanPutInSlot(Transform slotToPut, InventoryItemObject item) { SlotInfo slotInfo = GetSlotInfo(slotToPut); if (slotInfo.type == SlotType.Equipment) { if (item.info.type == equipmentUI.GetSlotType(slotToPut)) { return(true); } return(false); } else if (slotInfo.type == SlotType.Wagon) { WagonInventoryUI wagon = wagonUIs [slotInfo.wagonIndex]; return(wagon.CanPutInSlot(slotToPut, item.info.uiInfo.size)); } else if (slotInfo.type == SlotType.Shop) { WagonInventoryUI wagon = shopInventory; return(wagon.CanPutInSlot(slotToPut, item.info.uiInfo.size)); } return(false); }
public Transform FindEmptySlot(InventoryItemObject item, SlotType type, int wagonIndex = -1, int slotIndex = -1) { WagonInventoryUI wagon = null; if (type == SlotType.Wagon) { if (wagonIndex > -1 && wagonIndex < wagonUIs.Count) { wagon = wagonUIs [wagonIndex]; } else { wagon = wagonUIs [0]; } } else if (type == SlotType.Shop) { wagon = shopInventory; } if (wagonIndex > -1 && wagonIndex < wagonUIs.Count) { if (slotIndex > -1 && slotIndex < wagonUIs[wagonIndex].slots.Count) { // if slot and wagon indexes is correct then return specific slot if (wagon.IsEmptySlotForItem(slotIndex, item)) { // all right //SetupUIItem(item, wagonIndex, slotIndex); return(GetSlot(type, slotIndex, wagonIndex)); } } // if only wagon index is correct then return first empty slot in that wagon int emptySlotIndex = wagon.FindEmptySlotForItem(item); if (emptySlotIndex != -1) { // all right //SetupUIItem(item, wagonIndex, emptySlotIndex); return(GetSlot(type, emptySlotIndex, wagonIndex)); } } // else return completely first empty slot // should work only with player wagons, not shop for (int checkingWagonIndex = 0; checkingWagonIndex < wagonUIs.Count; checkingWagonIndex++) { if (type == SlotType.Wagon) { wagon = wagonUIs [checkingWagonIndex]; } int emptySlotIndex = wagon.FindEmptySlotForItem(item); if (emptySlotIndex != -1) { //SetupUIItem(item, checkingWagonIndex, emptySlotIndex); return(GetSlot(type, emptySlotIndex, checkingWagonIndex)); } } Debug.Log("no inventory space for item"); return(null); }