Esempio n. 1
0
    void AddRecipeBtnTask()
    {
        InsertEntityToOccupyList(recipeDropdown.value);
        recipeData possibleRecipe = CLD.FindRecipeResultData(catOccupied.ToArray(), itemOccupied.ToArray());

        recipeText.text = "Cat:";
        foreach (int i in catOccupied)
        {
            recipeText.text += i + " ";
        }
        recipeText.text += " Item:";
        foreach (int i in itemOccupied)
        {
            recipeText.text += i + " ";
        }
        if (possibleRecipe != null)
        {
            recipeCostText.text = "Cost: " + possibleRecipe.cost;
            recipeETCText.text  = possibleRecipe.time + " Sec";
        }
        else
        {
            recipeCostText.text = "Not Found";
            recipeETCText.text  = "Not Found";
        }
        submitRecipeBtn.interactable = possibleRecipe != null && possibleRecipe.cost < overallStats.money;
        GetRecipeDropdownList();
    }
Esempio n. 2
0
    public void SubmitRecipe()
    {
        recipeData s_recipe = CLD.FindRecipeResultData(catOccupied.ToArray(), itemOccupied.ToArray());

        ResetOccupyList();
        ResetReadyList();
        overallStats.SendMessage("SubmitRecipe", s_recipe.id);
    }
    public void SubmitRecipe(int recipe_id)
    {
        if (overallData.gameData.isCrafting)
        {
            Debug.LogError("ALREADY CRAFTING!");
            return;
        }
        Debug.Log("Recipe Received");
        recipeData rD = CLD.GetRecipeByID(recipe_id);
        int        catToRemove = 0, itemToRemove = 0;

        changeMoney(rD.cost * -1);
        for (int i = 0; i < rD.cats.Count; i++)
        {
            if (i == 0 || rD.cats[i - 1] == rD.cats[i])
            {
                catToRemove++;
            }
            else
            {
                CatControl(rD.cats[i - 1], -catToRemove, CatControlType.count);
                catToRemove = 1;
            }

            if (i == rD.cats.Count - 1)
            {
                CatControl(rD.cats[i], -catToRemove, CatControlType.count);
            }
        }
        Debug.Log("Cat Removed");
        for (int i = 0; i < rD.items.Count; i++)
        {
            if (i == 0 || rD.items[i - 1] == rD.items[i])
            {
                itemToRemove++;
            }
            else
            {
                ItemControl(rD.items[i - 1], -itemToRemove);
                itemToRemove = 1;
            }
            if (i == rD.items.Count - 1)
            {
                ItemControl(rD.items[i], -itemToRemove);
            }
        }
        Debug.Log("Item Removed");
        overallData.gameData.isCrafting = true;
        overallData.gameData.craftID    = recipe_id;
        overallData.gameData.craftETC   = ConvertToUnixTimestamp(System.DateTime.Now) + CLD.GetRecipeTime(recipe_id);
        EventNotifier.Invoke("Crafting Start!");
        StartCoroutine(StartCraftingClock());
        OnCatDataChaged.Invoke();
        OnItemDataChanged.Invoke();
    }
Esempio n. 4
0
    public Ientity GetEntityByRecipeID(int id)
    {
        recipeData rD = recipeCollection.recipes[id];

        if (rD.type == "cat")
        {
            return(GetCatData(rD.r_id));
        }
        else if (rD.type == "item")
        {
            return(GetItemData(rD.r_id));
        }
        return(null);
    }