/// <summary> /// Would be called when the player cooks their food, probably in the inventory /// manager script. /// This will take in a stack (inventory skewer) and compare the flavors on it to the /// recipe book. If it finds a match, it returns that RecipeData. /// /// </summary> public RecipeData CompareToRecipes(Stack <IngredientData> currentSkewer) { //create a backup copy of the array to be restored, as elements are removed to prevent //double-checking. IngredientData[] ingredientArray = currentSkewer.ToArray(); IngredientData[] ingredientArrayCopy = new IngredientData[ingredientArray.Length]; Array.Copy(ingredientArray, ingredientArrayCopy, ingredientArray.Length); bool recipeLookupFailed = false; //iterate over all recipes for (int i = 0; i < recipes.Length; i++) { RecipeData currentRecipe = recipes[i]; recipeLookupFailed = false; Array.Copy(ingredientArrayCopy, ingredientArray, ingredientArray.Length); //Debug.Log("Checking recipe: " + currentRecipe.displayName); //iterate over each flavor of the current recipe for (int currentFlavor = 0; currentFlavor < currentRecipe.flavors.Length; currentFlavor++) { //If we failed to find the last ingredient, abandon this recipe and try the next if (recipeLookupFailed) { //Debug.Log("Ingredient missing, recipe failed. Try next."); break; } //Debug.Log("Checking for presence of flavor " + currentRecipe.flavors[currentFlavor]); //iterate over each ingredient on the active skewer for (int currentIngredient = 0; currentIngredient < ingredientArray.Length; currentIngredient++) { //Debug.Log("Scanning ingredient " + currentIngredient + " of active skewer"); //if the flavor of the current ingredient matches the recipe flavor currently being tested... if ((ingredientArray[currentIngredient] == null ? 0 : ingredientArray[currentIngredient].flavors & currentRecipe.flavors[currentFlavor]) > 0) { //this flavor is on the skewer, so continue but remove it from the skewer so it isn't counted twice ingredientArray[currentIngredient] = null; recipeLookupFailed = false; //break the loop to check the next flavor on the recipe break; } recipeLookupFailed = true; } } //if you got here without failing, the recipe is a match, so return it if (!recipeLookupFailed) { Debug.Log("found recipe match: " + currentRecipe.displayName); return(currentRecipe); } } //if you get through all the recipes without a match, return null Debug.Log("No matches found"); return(null); }
public void CreateRecipes() { //Init sequencer seq = new Sequencer(); //Recipe 1 TaskData t1 = new TaskData(1, 15, false); TaskData t2 = new TaskData(2, 5, true); TaskData t3 = new TaskData(3, 2, true); TaskData t4 = new TaskData(4, 13, true); TaskData t5 = new TaskData(5, 20, false); TaskData t6 = new TaskData(6, 4, true); TaskData t7 = new TaskData(7, 3, true); TaskData t8 = new TaskData(8, 10, false); TaskData t9 = new TaskData(9, 1, true); TaskData t10 = new TaskData(10, 3, true); t10.addPrereq(t9); t10.addPrereq(t8); t8.addPrereq(t7); t7.addPrereq(t6); t9.addPrereq(t5); t5.addPrereq(t4); t4.addPrereq(t3); t3.addPrereq(t2); t2.addPrereq(t1); r1 = new RecipeData(); r1.finalStep = t10; //Recipe 2 TaskData t11 = new TaskData(11, 10, false); TaskData t12 = new TaskData(12, 6, true); TaskData t13 = new TaskData(13, 4, true); TaskData t14 = new TaskData(14, 15, true); t14.addPrereq(t13); t13.addPrereq(t12); t12.addPrereq(t11); r2 = new RecipeData(); r2.finalStep = t14; //Recipe 3 TaskData t15 = new TaskData(15, 9, false); TaskData t16 = new TaskData(16, 3, true); TaskData t17 = new TaskData(17, 5, true); TaskData t18 = new TaskData(18, 4, true); TaskData t19 = new TaskData(19, 1, true); TaskData t20 = new TaskData(20, 15, false); t20.addPrereq(t19); t19.addPrereq(t18); t19.addPrereq(t17); t19.addPrereq(t16); t19.addPrereq(t15); r3 = new RecipeData(); r3.finalStep = t20; }
public void Initialise(ProductType product, int delayModifier) { Product = product; recipe = IngredientDataLookupManager.Instance.GetRecipeForProductType(Product); int counter = 0; foreach (var rd in recipe.RequiredIngredients) { IngredientType ingredient = rd.Item1; ProcessType process = rd.Item2; ingredientImages[counter].sprite = IngredientDataLookupManager.Instance.GetSpriteForIngredient(ingredient); if (process != ProcessType.NONE && process != ProcessType.GARBAGE) { processImages[counter].enabled = true; processImages[counter].sprite = IngredientDataLookupManager.Instance.GetSpriteForProcess(process); } else { processImages[counter].enabled = false; } counter++; } GameObject prefab = IngredientDataLookupManager.Instance.GetPrefabForProductType(Product); GameObject spawned = Instantiate(prefab, finalProductPreviewParent); spawned.transform.localScale = Vector3.one * finalProductScale; spawned.transform.rotation = Quaternion.Euler(finalProductRotation); SetLayerRecursively(spawned, LayerMask.NameToLayer("UI")); }
public void TestSortFirstSteps() { TaskData t1 = new TaskData(1, 10, false); TaskData t2 = new TaskData(2, 8, true); TaskData t3 = new TaskData(3, 2, false); TaskData t4 = new TaskData(4, 5, true); RecipeData rec1 = new RecipeData(); rec1.finalStep = t1; RecipeData rec2 = new RecipeData(); rec2.finalStep = t2; RecipeData rec3 = new RecipeData(); rec3.finalStep = t3; RecipeData rec4 = new RecipeData(); rec4.finalStep = t4; List <RecipeData> recs = new List <RecipeData>(); recs.Add(rec1); recs.Add(rec2); recs.Add(rec3); recs.Add(rec4); Assert.AreEqual("4,2,3,1", createTestIdString(seq.sortFinalSteps(recs))); }
public override bool Load() { Recipe targetData = target as Recipe; var client = new DatabaseClient("", ""); string error = string.Empty; var db = client.GetDatabase(targetData.SheetName, ref error); var table = db.GetTable <RecipeData>(targetData.WorksheetName) ?? db.CreateTable <RecipeData>(targetData.WorksheetName); List <RecipeData> myDataList = new List <RecipeData>(); var all = table.FindAll(targetData.FilePath); foreach (var elem in all) { RecipeData data = new RecipeData(); data = Cloner.DeepCopy <RecipeData>(elem.Element); myDataList.Add(data); } targetData.dataArray = myDataList.ToArray(); EditorUtility.SetDirty(targetData); AssetDatabase.SaveAssets(); return(true); }
public string StringBuilder(RecipeData data) { string x = ""; for (int i = 0; i < data.recipe.Items.Count; i++) { Item item = data.GetItemByID(data.recipe.Items[i].ItemID); if (item != null) { int item_count = Inventory.Instance.CheckItemCount(data.recipe.Items[i].ItemID); if (item_count >= data.recipe.Items[i].Count * data.AmountSellMuiltplyer) { string value = item.Name + " " + "x" + data.recipe.Items[i].Count * data.AmountSellMuiltplyer + " \n"; x += data.ColorString("FFA500", value); } else { string value = item.Name + " " + "x" + data.recipe.Items[i].Count * data.AmountSellMuiltplyer + " \n"; x += data.ColorString("FFFFFF", value); } } } return(x); }
public WeaveEssencePlayerState(PlayerInput input, PlayerBuildData buildData, PlayerStateData stateData, RecipeData recipes) { this.input = input; this.buildData = buildData; this.stateData = stateData; this.recipes = recipes; }
/// <summary> /// <para>Allows you to add or edit RecipeData for TechTypes.</para> /// <para>Can be used for existing TechTypes too.</para> /// </summary> /// <param name="techType">The TechType whose TechData you want to edit.</param> /// <param name="recipeData">The TechData for that TechType.</param> /// <seealso cref="RecipeData"/> void ICraftDataHandler.SetTechData(TechType techType, RecipeData recipeData) { if (CraftDataPatcher.CustomTechData.TryGetValue(techType, out JsonValue jsonValue)) { jsonValue[TechData.PropertyToID("techType")] = new JsonValue((int)techType); jsonValue[TechData.PropertyToID("craftAmount")] = new JsonValue(recipeData.craftAmount); } else { jsonValue = new JsonValue { { TechData.PropertyToID("techType"), new JsonValue((int)techType) }, { TechData.PropertyToID("craftAmount"), new JsonValue(recipeData.craftAmount) } }; CraftDataPatcher.CustomTechData.Add(techType, jsonValue); } if (recipeData.ingredientCount > 0) { Main.SetIngredients(techType, recipeData.Ingredients); } if (recipeData.linkedItemCount > 0) { Main.SetLinkedItems(techType, recipeData.LinkedItems); } }
/// <summary> /// Metoda CompleteData completeaza un model de date incomplet cu informatii suplimentare /// </summary> /// <param name="dataToBeCompleted">Un model de data pentru retete, cu informatii minime.</param> /// <returns>Un model de data pentru retete, cu informatii complete.</returns> public RecipeData CompleteData(RecipeData dataToBeCompleted) { if (_objectJSON.ContainsKey("instructions")) { dataToBeCompleted.Instructions = _objectJSON.GetValue("instructions").ToString(); } if (_objectJSON.ContainsKey("sourceUrl")) { dataToBeCompleted.URL = _objectJSON.GetValue("sourceUrl").ToString(); } JObject nutrition = (JObject)_objectJSON.GetValue("nutrition"); JArray nutrients = (JArray)nutrition.GetValue("nutrients"); JArray ingredients = (JArray)nutrition.GetValue("ingredients"); string nutrientsString = "Nutrients: \n", ingredientsString = "Ingredients: \n"; foreach (JObject nutrient in nutrients) { nutrientsString += nutrient.GetValue("title").ToString() + ": " + nutrient.GetValue("amount").ToString() + nutrient.GetValue("unit").ToString() + " | "; } foreach (JObject ingredient in ingredients) { ingredientsString += ingredient.GetValue("name").ToString() + ": " + ingredient.GetValue("amount").ToString() + " " + ingredient.GetValue("unit").ToString() + Environment.NewLine; } ingredientsString = ingredientsString.Substring(0, ingredientsString.Length - 2); nutrientsString = nutrientsString.Substring(0, nutrientsString.Length - 2); dataToBeCompleted.Nutrients = nutrientsString; dataToBeCompleted.Ingredients = ingredientsString; return(dataToBeCompleted); }
/// <summary> /// Metoda FilterMultipleData extrage date dintr-un array JSON. Pentru afisarea completa se vor completa datele ulterior. /// </summary> /// <returns>O lista de retete sub forma modelului utilizat, ce contine informatii minime.</returns> public List <RecipeData> FilterMultipleData() { List <RecipeData> dataList = new List <RecipeData>(); foreach (JObject JSONobj in _arrayJSON) { RecipeData dataCreated = new RecipeData(); dataCreated.Title = JSONobj.GetValue("title").ToString(); dataCreated.ID = Int32.Parse(JSONobj.GetValue("id").ToString()); dataCreated.ImageLocation = JSONobj.GetValue("image").ToString(); if (JSONobj.ContainsKey("likes")) { dataCreated.Description = "Likes: " + JSONobj.GetValue("likes").ToString(); } else if (JSONobj.ContainsKey("calories") && JSONobj.ContainsKey("carbs")) { dataCreated.Description = "Calories: " + JSONobj.GetValue("calories").ToString() + " Proteins: " + JSONobj.GetValue("protein").ToString() + " Carbs: " + JSONobj.GetValue("carbs").ToString() + " Fat: " + JSONobj.GetValue("fat").ToString(); } dataList.Add(dataCreated); } return(dataList); }
public CookingEventArgs(Creature creature, RecipeData recipe, bool success, Item item) { this.Creature = creature; this.Recipe = recipe; this.Success = success; this.Item = item; }
public ActionResult Details(int id) { RecipeData newRecipe = new RecipeData(); newRecipe.FindRecipe(id); return(View(newRecipe)); }
public IActionResult Edit(int recipeId) { MXRecipe recipeById = RecipeData.GetById(recipeId); ViewBag.editRecipe = recipeById; ViewBag.title = $"Edit Event {recipeById.Name} (id={recipeById.Id})"; return(View()); }
public IActionResult Edit(int recipeId, string name, string dyeColor) { MXRecipe recipeById = RecipeData.GetById(recipeId); recipeById.Name = name; recipeById.DyeColor = dyeColor; return(Redirect("/Recipe")); }
public ActionResult MethodForm(int id) { RecipeData newData = new RecipeData(); newData.FindRecipe(id); return(View(newData)); }
/// <summary> /// /// </summary> private void JsonDataDatabase(List <RecipeData> purchasable, List <GameObject> item, string location, JsonData data, Transform Parent, SlotType slotType) { try { string app_Path = Application.dataPath + "/StreamingAssets/" + location + FileType; data = JsonMapper.ToObject(File.ReadAllText(app_Path)); for (int i = 0; i < data.Count; i++) { string name = (string)data[i]["Name"]; string key = (string)data[i]["Key"]; string image_preview = (string)data[i]["Image_Preview"]; int image_id = Function.FindImageID(Item_Images, image_preview); List <RecipeItem> ri = new List <RecipeItem>(); for (int x = 0; x < data[i]["Recipe"].Count; x++) { int id = (int)data[i]["Recipe"][x]["ItemID"]; int count = (int)data[i]["Recipe"][x]["Count"]; RecipeItem RecipeItem = new RecipeItem(id, count); ri.Add(RecipeItem); } int sellvalue = (int)data[i]["SellValue"]; Recipe recipe = new Recipe( name, key, Item_Images[image_id], ri, sellvalue); GameObject recipePrefab = CreateRecipePrefab(Parent); RecipeData recipe_data = recipePrefab.GetComponent <RecipeData>(); recipe_data.recipe.Name = recipe.Name; recipe_data.recipe.Key = recipe.Key; recipe_data.recipe.Items = recipe.Items; recipe_data.recipe.SellValue = recipe.SellValue; recipe_data.recipe.Preview_Image = recipe.Preview_Image; purchasable.Add(recipe_data); item.Add(recipePrefab); } } catch (Exception ex) { Debug.Log(ex.Message + location); } }
public IActionResult updateRecipe(List <Recipe> recipeList) { if (recipeList.Count == 0 || recipeList == null) { return(NotFound("Error List")); } RecipeData.writeData(recipeList); return(Ok(recipeList)); }
private EquipamentPLC() { recipe = new Recipe(); recipeData = new RecipeData(); address = ConfigurationManager.AppSettings["connectionString"]; errorLog = new ErrorLog(); logAction = new LogAction(); //logAction.writeLog("connectionString: " + address); }
public Recipe(RecipeData data, Item item, List <RecipeIngredient> ingredients) { this.data = data; Item = item; Item.SetStack(data.ItemCount); Ingredients = ingredients; }
public IActionResult Delete(int[] recipeIds) { foreach (int recipeId in recipeIds) { RecipeData.Remove(recipeId); } return(Redirect("/Events")); }
public IActionResult Get(string name) { var recipe = RecipeData.getRecipeData(name); if (recipe == null) { return(NotFound("No recipe found.")); } return(Ok(recipe)); }
public FCSKit(string classId, string friendlyName, FcCraftingTab parentTab, RecipeData ingredients) : base(classId, friendlyName, $"A kit that allows you to build one {friendlyName} Unit", parentTab) { _ingredients = ingredients; OnFinishedPatching += () => { GetKitPrefab(); CraftDataHandler.SetEquipmentType(TechType, EquipmentType.Hand); }; }
/// <summary> /// Build all settings from import data /// </summary> public static void BuildFromImport() { foreach (RecipeDataImporter settings in ImportCache) { RecipeData recipe = new RecipeData(settings); mRecipes.Add(recipe); } Debug.Log("Discovered " + mRecipes.Count + " recipes"); }
private GameData() { itemData = new ItemData(); worldData = new WorldData(); statusData = new StatusData(); skillData = new SkillData(); recipeData = new RecipeData(); monsterData = new MonsterData(); jobData = new JobData(); npcData = new NPCData(); }
/// <summary> /// /// </summary> private void RecipeSaveState(List <Recipe_Save_State> save, List <GameObject> purchasable) { for (int i = 0; i < purchasable.Count(); i++) { RecipeData item = purchasable[i].GetComponent <RecipeData>(); Recipe_Save_State save_sate = new Recipe_Save_State(); save_sate.Unlocked = item.recipe.Unlocked; save.Add(save_sate); } }
private static bool CheckRequirements(Trashcan __instance, Pickupable item, RecipeData techData) #endif { bool check = true; int craftCountNeeded = techData.craftAmount; IList <InventoryItem> inventoryItems = __instance.storageContainer.container.GetItems(item.GetTechType()); if (inventoryItems != null && inventoryItems.Count >= craftCountNeeded) { while (craftCountNeeded > 0) { Trashcan_Update.inventoryItems.Add(inventoryItems[craftCountNeeded - 1]); craftCountNeeded--; } foreach (TechType techType in techData.LinkedItems) { int linkedCountNeeded = techData.LinkedItems.FindAll((TechType tt) => tt == techType).Count; IList <InventoryItem> inventoryItems2 = __instance.storageContainer.container.GetItems(techType); IList <InventoryItem> inventoryItems3 = Inventory.main.container.GetItems(techType); int count = (inventoryItems2?.Count ?? 0) + (inventoryItems3?.Count ?? 0); if (count < linkedCountNeeded) { ErrorMessage.AddMessage($"Missing {linkedCountNeeded - (inventoryItems2?.Count + inventoryItems3?.Count)} {techType.ToString()}"); Inventory.main.ForcePickup(item); Trashcan_Update.inventoryItems.Clear(); return(false); } int count1 = inventoryItems2?.Count ?? 0; int count2 = inventoryItems3?.Count ?? 0; while (linkedCountNeeded > 0) { if (count1 > 0) { Trashcan_Update.inventoryItems.Add(inventoryItems2[count1 - 1]); count1--; } else if (count2 > 0) { Trashcan_Update.inventoryItems.Add(inventoryItems3[count2 - 1]); count2--; } linkedCountNeeded--; } } } else { check = false; } return(check); }
public IActionResult Calculator(CalculateMXRecipeViewModel calculateMXRecipeViewModel) { MXRecipe newMXRecipe = new MXRecipe { Name = calculateMXRecipeViewModel.Name, DyeColor = calculateMXRecipeViewModel.DyeColor }; RecipeData.Add(newMXRecipe); return(Redirect("/Recipe")); }
public void OnPointerClick(PointerEventData eventData) { if (RecipeData_Master.Count == 1) { RecipeData recipeData = RecipeData_Master[0]; recipeData.Purchase(); CreatePopUpText(recipeData.ToString()); } }
void LoadRecipeListFromJson() { TextAsset itemText = Resources.Load <TextAsset>("Data/RecipeData"); //read file string jsonData = itemText.text; //convert to json string Debug.Log("Got this: " + jsonData); recipeData = JsonUtility.FromJson <RecipeData>(jsonData);//convert to json array Debug.Log("Imported Recipe Number: " + recipeData.RecipeList.Count); }
private void Start() { recipe = RecipeDB.Instance.FindItem(150); SetItemList(); CreatePuzzleSlot(); SetRecipePuzzle(); SetRandomEmptyPuzzle(); uIRestaurant.combinationView.CreateCombination(recipe.Icon, materialIDList); }
/// <summary> /// Calculates quality based on recipe and ingredients. /// </summary> /// <remarks> /// The formula used in this method is unofficial. While it does feel /// very similar in some test cases, it could potentially create /// very different results. Officials also RNG the results, /// which this method currently does not. /// /// The Help fields in the return value specify a tip on what went /// wrong with the cooking attempt, if certain requirements are /// fulfilled. In that case it will set the item to the item in /// question, and the amount to the amount the ingredient differed /// from the recipe. If the value is lower than 0, it was less, /// if it's greater, it was more. If no helpful tip could be found, /// item is null. /// </remarks> /// <param name="recipe"></param> /// <param name="ingredients"></param> /// <returns></returns> private Judgement JudgeQuality(RecipeData recipe, List<Ingredient> ingredients) { Judgement result; result.Quality = 0; result.HelpItem = null; result.HelpAmount = 0; var total = (float)recipe.MainIngredients.Sum(a => a.Amount); foreach (var ingredient in ingredients) { // Every item *should* only appear once in main or other. var ingredientData = recipe.MainIngredients.FirstOrDefault(a => a.ItemId == ingredient.Item.Info.Id); if (ingredientData == null) { ingredientData = recipe.OtherIngredients.FirstOrDefault(a => a.ItemId == ingredient.Item.Info.Id); if (ingredientData == null) { Log.Error("Cooking.JudgeQuality: Failed to get ingredient data for item '{0}' in recipe '{1},{2}'.", ingredient.Item.Info.Id, recipe.Method, recipe.ItemId); break; } } // Calculate the amount difference between the provided // ingredient and the recipe. var amount = ingredient.Amount; var ideal = (1f / total * ingredientData.Amount); var difference = ideal - amount; var differenceAbs = Math.Abs(difference); // Calculate quality var rate = 1f - (1f / ideal * (differenceAbs * 2f)); var qualityAdd = ingredientData.QualityMin + rate * (ingredientData.QualityMax - ingredientData.QualityMin); result.Quality = Math2.Clamp(-100, 100, result.Quality + qualityAdd); // Save the ingredient with the biggest difference, // for the help message. if (differenceAbs > 0.05f && Math.Abs(result.HelpAmount) < differenceAbs) { result.HelpAmount = -difference; result.HelpItem = ingredient.Item; } } return result; }