コード例 #1
0
    private void CreateSlots()
    {
        for (int i = 0; i < recipes.list.Count; i++)
        {
            CraftableItem item = Instantiate(craftableItemPrefab, uiContent.transform).GetComponent <CraftableItem>();

            RecipeObject recipe = recipes.list[i];

            item.Set(recipe);
            item.GetButton().onClick.AddListener(delegate { playerCrafting.Craft(recipe); });
        }
    }
コード例 #2
0
    public void Set(RecipeObject _recipe)
    {
        recipe = _recipe;

        productIcon.sprite = _recipe.product.item.displaySprite;
        productCount.text  = _recipe.product.quantity.ToString();

        for (int i = 0; i < _recipe.ingredients.Length; i++)
        {
            ingredientBackgrounds[i].sprite = ingredientSlotBackground;
            ingredientIcons[i].sprite       = _recipe.ingredients[i].item.displaySprite;
            ingredientsCount[i].text        = _recipe.ingredients[i].quantity.ToString();
        }
    }
コード例 #3
0
        public void SetData(RecipeObject recipe)
        {
            var index = transform.GetSiblingIndex();

            if (index < recipe.Specifications.Count)
            {
                var specification = recipe.Specifications[index];
                var specIcon      = _iconUtil.GetSpecificationIcon(specification.type);

                gameObject.SetActive(true);
                SetIcon(specIcon);
                SetCount(specification.value);
            }
            else
            {
                gameObject.SetActive(false);
            }
        }
コード例 #4
0
    public void Craft(RecipeObject recipe)
    {
        //Debug.Log("Trying to craft");
        for (int i = 0; i < recipe.ingredients.Length; i++)
        {
            if (playerInventory.GetTotalItemCount(recipe.ingredients[i].item) < recipe.ingredients[i].quantity)
            {
                return;
            }
        }

        for (int i = 0; i < recipe.ingredients.Length; i++)
        {
            playerInventory.RemoveItem(recipe.ingredients[i].item, recipe.ingredients[i].quantity);
        }

        playerInventory.AddItem(recipe.product.item, recipe.product.quantity);
        Debug.Log("Crafted " + recipe.product.item.name);
    }
コード例 #5
0
        public async void SetPartInfo(RecipeObject recipe)
        {
            var index = transform.GetSiblingIndex();

            if (index < recipe.Parts.Count)
            {
                var part      = recipe.Parts[index];
                var data      = part.data;
                var store     = _controllersResolver.GetStoreByType(data.ItemType);
                var itemCount = store.GetItem(data.Slug).GetCount(part.quality);
                var sprite    = await AssetsController.LoadAsset <Sprite>(data.Icon);

                SetPartIcon(sprite);
                SetPartText($"{itemCount}/{part.count}");
                SetPartQuality(part.quality);
            }
            else
            {
                ResetPartInfo();
            }
        }
コード例 #6
0
        public JsonResult GetRecipeData(string productName, string EquipID, string ID)
        {
            var result = RecipeClass.getData(productName, EquipID, ID);

            Dictionary <string, object> response = new Dictionary <string, object>();
            List <RecipeObject>         obj      = new List <RecipeObject>();

            int counter = 0;

            string type = EquipmentModels.GetEquipmentTypeByID(Convert.ToInt32(ID));

            if (type == "")
            {
                var child = EquipmentModels.getChildEquipments(EquipID);
                if (child == null)
                {
                    counter = 0;
                }
                else
                {
                    if (child.Count > 0)
                    {
                        counter = child.Count;
                    }
                    else
                    {
                        counter = 0;
                    }
                }
            }
            else
            {
                counter = 1;
            }

            try
            {
                if (result.Rows.Count > 0)
                {
                    foreach (DataRow dr in result.Rows)
                    {
                        var temp_obj = new RecipeObject();
                        temp_obj.RecipeID    = dr["RecipeID"].ToString();
                        temp_obj.RecipeName  = dr["RecipeName"].ToString();
                        temp_obj.RecipeBody  = dr["RecipeBody"].ToString();
                        temp_obj.ProductName = dr["ProductName"].ToString();
                        temp_obj.EquipID     = dr["EquipID"].ToString();
                        temp_obj.Counter     = counter;
                        DataTable dt = new DataTable();
                        dt = RecipeClass.getParams(dr["RecipeID"].ToString());
                        List <string> lstGroupName     = new List <string>();
                        List <string> lstParameterName = new List <string>();
                        List <string> lstMin           = new List <string>();
                        List <string> lstMax           = new List <string>();
                        List <string> lstValue         = new List <string>();
                        if (dt != null)
                        {
                            if (dt.Rows.Count > 0)
                            {
                                foreach (DataRow dr2 in dt.Rows)
                                {
                                    lstGroupName.Add(dr2["GroupName"].ToString());
                                    lstParameterName.Add(dr2["ParameterName"].ToString());
                                    lstMin.Add(dr2["Min"].ToString());
                                    lstMax.Add(dr2["Max"].ToString());
                                    lstValue.Add(dr2["Value"].ToString());
                                }
                            }
                        }
                        temp_obj.GroupName     = lstGroupName;
                        temp_obj.ParameterName = lstParameterName;
                        temp_obj.Min           = lstMin;
                        temp_obj.Max           = lstMax;
                        temp_obj.Value         = lstValue;
                        obj.Add(temp_obj);
                    }
                }
                else
                {
                    obj = null;
                }
            }
            catch
            {
                obj = null;
            }

            return(Json(obj, JsonRequestBehavior.AllowGet));
        }