public void OnRefill() { inventory.Clear(); int resCount = 0; foreach (UCE_HarvestingHarvestItems harvestItem in harvestItems) { if (UnityEngine.Random.value <= harvestItem.probability) { int amount = (UnityEngine.Random.Range(harvestItem.minAmount, harvestItem.maxAmount)); for (int i = 1; i <= amount; i++) { inventory.Add(new ItemSlot(new Item(harvestItem.template))); } resCount += amount; if (resCount >= currentResources) { break; } } } currentResources -= resCount; }
public void AddOne(ItemSlot slot) { if (!CanAdd(slot)) { Debug.Log($"{gameObject.name} Container: Weight limit reached"); return; } var index = GetItemIndexByNameAndCond(slot.name, slot._condition); if (index != -1) { ItemSlot slotForChange = Items[index]; bool hasIncreased = slotForChange.TryIncrease(); if (hasIncreased) { Items[index] = slotForChange; _currentWeight += slot.GetWeightOf(1); return; } } Items.Add(slot); _currentWeight += slot.GetWeightOf(1); Debug.Log($"Add slot {slot.name} {slot.GetCondition()} in {GetType().Name}"); }
private void OnRefill() { inventory.Clear(); gold = Random.Range(lootGoldMin, lootGoldMax); coins = Random.Range(lootCoinsMin, lootCoinsMax); foreach (ItemDropChance itemChance in dropChances) { if (Random.value <= itemChance.probability) { inventory.Add(new ItemSlot(new Item(itemChance.item))); } } }
public void UCE_UpgradeGuildWarehouse() { if (UCE_CanUpgradeGuildWarehouse()) { guildWarehouse.warehouseUpgradeCost[guildWarehouseLevel].payCost(this); int oldSize = guildWarehouseStorageItems; guildWarehouseLevel++; int sizeDifference = guildWarehouseStorageItems - oldSize; for (int i = 0; i < sizeDifference; ++i) { UCE_guildWarehouse.Add(new ItemSlot()); } guildWarehouseActionDone = true; UCE_ShowPopup(guildWarehouse.warehouseUpgradeLabel); } }