Ejemplo n.º 1
0
    public void AddInventoryToGlobalItems()
    {
        Debug.Log("inventory > global");
        Debug.Log("Local inventory:");

        if (QuestManager.instance != null && QuestManager.instance.enabled)
        {
            QuestManager.instance.TryToCompleteAdventurerQuest(itemQuantity);
        }

        int diseasedGoldLoss = 0;

        if (DiseasedManager.instance != null && DiseasedManager.instance.enabled && DiseasedManager.instance.DiseasedItem != null)
        {
            diseasedGoldLoss = HandleDiseasedItem(DiseasedManager.instance.DiseasedItem);
        }

        AddToNewItemsLog(diseasedGoldLoss);

        List <string> itemsToRemove = new List <string>();

        foreach (var itemName in itemQuantity.Keys)
        {
            int quantity = itemQuantity[itemName];
            Debug.Log($"{itemName}: {quantity}");

            if (quantity <= 0)
            {
                itemsToRemove.Add(itemName);
            }
        }

        foreach (var ItemName in itemsToRemove)
        {
            itemQuantity.Remove(ItemName);
        }

        // TODO: remove this hardcode
        if (itemQuantity.ContainsKey("Gem"))
        {
            int gemAmount = itemQuantity["Gem"];
            GoldManager.GetGemsAndSendWithModifier(gemAmount);
            itemQuantity.Remove("Gem");
        }

        ItemManager.instance.AddItemsAfterGetting(itemQuantity);
        ItemsAddedToGlobalInventory.Invoke();
    }