internal void SetRecipe(int index)
        {
            selectedIndex = -1;
            recipeInfo.RemoveAllChildren();

            foreach (var item in recipeSlots)
            {
                item.selected = false;
            }

            var recipeslot = recipeSlots[index];

            recipeslot.selected = false;
            recipeslot.selected = true;
            selectedIndex       = index;

            Recipe recipe = Main.recipe[index];

            for (int i = 0; i < Recipe.maxRequirements; i++)
            {
                if (recipe.requiredItem[i].type > 0)
                {
                    UIIngredientSlot ingredient = new UIIngredientSlot(recipe.requiredItem[i].Clone());
                    ingredient.Left.Pixels = 200 + (i % 5 * 40);
                    ingredient.Top.Pixels  = (i / 5 * 40);

                    OverrideForGroups(recipe, ingredient.item);
                    // TODO, stack?

                    recipeInfo.Append(ingredient);
                }
            }
        }
        internal void SetRecipe(int index)
        {
            selectedIndex = -1;
            recipeInfo.craftingTilesGrid.Clear();

            foreach (var item in recipeSlots)
            {
                item.selected = false;
            }

            var recipeslot = recipeSlots[index];

            recipeslot.selected = false;
            recipeslot.selected = true;
            selectedIndex       = index;

            List <UIIngredientSlot> ingredients = new List <UIIngredientSlot>();
            Recipe recipe = Main.recipe[index];

            for (int i = 0; i < Recipe.maxRequirements; i++)
            {
                if (recipe.requiredItem[i].type > 0)
                {
                    UIIngredientSlot ingredient = new UIIngredientSlot(recipe.requiredItem[i].Clone(), i);
                    //ingredient.Left.Pixels = 200 + (i % 5 * 40);
                    //ingredient.Top.Pixels = (i / 5 * 40);

                    ingredients.Add(ingredient);

                    OverrideForGroups(recipe, ingredient.item);
                    // TODO, stack?

                    //recipeInfo.Append(ingredient);
                }
            }
            recipeInfo.craftingTilesGrid.AddRange(ingredients);             // order...
            CraftUI.instance.SetRecipe(index);

            //for (int i = 0; i < Recipe.maxRequirements; i++)
            //{
            //	if (recipe.requiredTile[i] > 0)
            //	{
            //		var tileSlot = new UITileNoSlot(recipe.requiredTile[i], i, 0.75f);
            //		tileSlot.Left.Pixels = 10 + (i * 40);
            //		tileSlot.Top.Pixels = 0;
            //		recipeInfo.Append(tileSlot);
            //		recipeInfo.tileList.Add(tileSlot);
            //	}
            //}
        }
Beispiel #3
0
    UIIngredientSlot CreateIngredientSlot()
    {
        UIIngredientSlot slot = null;

        for (int i = 0; i < ingredientSlotList.Count; i++)
        {
            if (!ingredientSlotList[i].gameObject.activeSelf)
            {
                slot = ingredientSlotList[i];
                break;
            }
        }
        if (slot == null)
        {
            GameObject go = Instantiate(needMaterialSlotPrefab, needMaterialParent, false);
            slot = go.GetComponent <UIIngredientSlot>();
            ingredientSlotList.Add(slot);
        }
        return(slot);
    }
Beispiel #4
0
    public void InitSlot(Item data)
    {
        product = data;
        product.onChangedProductionAmount += OnChangedProductionAmount;

        textProductName.text  = product.name;
        textProductLevel.text = "Lv " + product.level.ToString();
        TerritoryManager.Instance.ChangeMaterialImage(imageProduct, product.image);
        textDescription.text = product.description;
        // ================

        Storage.RegisterOnChangedStoredAmountCallback(product.id, OnChangedAmount);


        textStorgaeAmount.text = Storage.GetItemStoredAmount(product).ToStringABC();// itemData == null ? "0" : itemData.amount.ToStringABC();
        float productionTime = product.productionTime;

        textProductionTime.text = productionTime.ToStringTime();

        OnChangedProductionAmount();
        //string buffText = "";
        //double productionAmount = 0;
        //double buffValue = 0;
        //if (productionData != null)
        //{
        //    buffValue = productionData.placeBuffValue;
        //    productionAmount = productionData.finalProductionAmount;
        //}
        //else if (placeData != null)
        //{
        //    buffValue = placeData.placeBuffValue;
        //    productionAmount = placeData.finalProductionAmount;
        //}
        //else
        //{
        //    buffValue = product.productionAmount * (product.placeBuffValue /100);
        //    productionAmount = product.productionAmount;
        //}

        //// ===============
        //if (buffValue > 1)
        //    buffText = "<color=#00ff00ff>(+ " + buffValue.ToStringABC() + ")</color>";
        //textProductionAmount.text = productionAmount.ToStringABC() + buffText;
        //buttonLevelUp.interactable = product.canUpgrade;
        //textLevelUpCost.text = product.upgradeCost.ToStringABC();

        // ================

        for (int i = 0; i < ingredientSlotList.Count; i++)
        {
            ingredientSlotList[i].gameObject.SetActive(false);
        }

        needMaterialPanel.SetActive(product.ingredientList.Count > 0);

        if (product.ingredientList.Count > 0)
        {
            for (int i = 0; i < product.ingredientList.Count; i++)
            {
                UIIngredientSlot slot = CreateIngredientSlot();
                slot.gameObject.SetActive(true);
                if (productionData == null)
                {
                    slot.Init(product, product.ingredientList[i].item, product.ingredientList[i].count);
                }
                else
                {
                    slot.Init(productionData, product.ingredientList[i].item, product.ingredientList[i].count);
                }
            }
        }

        // ================
        buttonApply.gameObject.SetActive(!product.isProduction);
        buttonRelease.gameObject.SetActive(product.isProduction);
    }
        internal void SetRecipe(int index)
        {
            selectedIndex = -1;
            recipeInfo.RemoveAllChildren();

            foreach (var item in recipeSlots)
            {
                item.selected = false;
            }

            var recipeslot = recipeSlots[index];

            recipeslot.selected = false;
            recipeslot.selected = true;
            selectedIndex       = index;

            Recipe recipe = Main.recipe[index];

            for (int i = 0; i < Recipe.maxRequirements; i++)
            {
                if (recipe.requiredItem[i].type > 0)
                {
                    UIIngredientSlot ingredient = new UIIngredientSlot(recipe.requiredItem[i].Clone());
                    ingredient.Left.Pixels = 200 + (i % 5 * 40);
                    ingredient.Top.Pixels  = (i / 5 * 40);

                    string nameOverride;
                    if (recipe.ProcessGroupsForText(recipe.requiredItem[i].type, out nameOverride))
                    {
                        //Main.toolTip.name = name;
                    }
                    if (recipe.anyIronBar && recipe.requiredItem[i].type == 22)
                    {
                        nameOverride = Lang.misc[37].Value + " " + Lang.GetItemNameValue(22);
                    }
                    else if (recipe.anyWood && recipe.requiredItem[i].type == 9)
                    {
                        nameOverride = Lang.misc[37].Value + " " + Lang.GetItemNameValue(9);
                    }
                    else if (recipe.anySand && recipe.requiredItem[i].type == 169)
                    {
                        nameOverride = Lang.misc[37].Value + " " + Lang.GetItemNameValue(169);
                    }
                    else if (recipe.anyFragment && recipe.requiredItem[i].type == 3458)
                    {
                        nameOverride = Lang.misc[37].Value + " " + Lang.misc[51].Value;
                    }
                    else if (recipe.anyPressurePlate && recipe.requiredItem[i].type == 542)
                    {
                        nameOverride = Lang.misc[37].Value + " " + Lang.misc[38].Value;
                    }
                    if (nameOverride != "")
                    {
                        ingredient.item.SetNameOverride(nameOverride);
                    }
                    // TODO, stack?

                    recipeInfo.Append(ingredient);
                }
            }
        }