Example #1
0
 void Awake()
 {
     if (IsMainInstance)
     {
         Instance = this;
     }
 }
Example #2
0
    public void Add(Item it, int amount)
    {
        InventoryEntry entry = InventoryEntries.FirstOrDefault(e => e.Item == it);

        GameEventHandler.Singleton.OnLootObtained(it, amount);

        if (entry == default(InventoryEntry))
        {
            InventoryEntries.Add(new InventoryEntry()
            {
                Item = it, Amount = amount
            });
        }
        else
        {
            entry.Amount += amount;
        }


        // Check if a new recipe is makeable
        if (currentRecipes == null)
        {
            currentRecipes = CraftingTable.GetPossibleRecipes();
        }
        else
        {
            List <CraftingRecipe> recipes = CraftingTable.GetPossibleRecipes();
            foreach (var recipe in recipes)
            {
                if (!currentRecipes.Contains(recipe) && !CraftingRecipesMade.RecipesMade.Contains(recipe.ID))
                {
                    string postText = "";
                    foreach (var component in recipe.Components)
                    {
                        postText +=
                            $"{component.Amount} {component.Item.GetName()}{(component.Amount > 1 ? "s" : "")}\n";
                    }
                    QuickPopUp.Show(QuestionMark, $"<size=150%>New Craftable Recipe!</size>\nA new recipe is now craftable!\nRequires:{postText}");
                }
            }
            currentRecipes = recipes;
        }
    }
Example #3
0
 private void AchievementComplete(Achievement ach)
 {
     QuickPopUp.Show(ach.AchievementIcon, "<size=150%>Achievement!</size>\n" + ach.AchievementCompletedText);
     Debug.Log("Achievement Completed! " + ach);
 }