public void SetCraftText(CraftRecipe craft) { needTitle.text = craft.Type != CraftRecipe.CraftType.拆解 ? string.Format("合成{0}需要:", craft.Name) : string.Format("{0}需要:", craft.Name); tempCraft = craft; string needText = ""; bool canCraft = true; for (int i = 0; i < craft.NeedItemIDs.Length; i++) { needText += string.Format("{0} ({1}/{2})\n", InventoryManager.Instance.GetItemByID(craft.NeedItemIDs[i]).Name, BackPack.Instance.GetCountByID(craft.NeedItemIDs[i]), craft.NeedItemCount[i]); if (BackPack.Instance.GetCountByID(craft.NeedItemIDs[i]) < craft.NeedItemCount[i]) { canCraft = false; } } if (craft.Type == CraftRecipe.CraftType.拆解) { needText += string.Format("\n获得以下物品:\n"); for (int i = 0; i < craft.GetItemIDs.Length; i++) { needText += string.Format("{0}:{1}\n", InventoryManager.Instance.GetItemByID(craft.GetItemIDs[i]).Name, craft.GetItemCount[i]); } } craftButton.interactable = canCraft; needItems.text = needText; }
public void StartCraft(CraftRecipe recipe, int createCount) { currentRecipe = recipe; currentCreateCount = createCount; storingItems = recipe.srcItemUnitList; craftEndTime = IngameTime.Time + recipe.needTime * createCount; UpdatePopupText(); craftingSound = SoundManager.Instance.Play("SE_CookMeat00", true); }
private void EndCraft() { if (currentRecipe != null && IngameTime.Time < craftEndTime) { UIInstantMessage.Instance.RequestMessage("製作を中断しました"); } currentRecipe = null; uiFieldPopup.DispSlider(false); UpdatePopupText(); craftingSound?.Stop(); }
public bool CanCraftCondition(CraftRecipe recipe) { if (currentFacility == null) { return(recipe.craftConditionType <= CraftConditionType.None); } if (currentFacility.ConditionType < recipe.craftConditionType) { return(false); } return(true); }
private void UpdatePopupText() { if (storingItems == null) { uiFieldPopup.SetText(CraftRecipe.GetConditionName(conditionType)); } else if (currentRecipe != null) { uiFieldPopup.SetText("製作中..."); } else { uiFieldPopup.SetText("完了"); } }
public void InitializeRecipe(CraftRecipe craft, CraftManager manager) { _recipe = craft; _manager = manager; var x = -60; foreach (var recipeItem in craft.Recipe) { AddItem(recipeItem, x); x += 40; } AddItem(craft.Result, 60); SetAvailability(manager.Available(craft)); }
public void RemoveFromRecept(CraftRecipe craftRecipe) { var input = new List <Item>(); craftRecipe.Input.ForEach(n => input.Add(n)); for (int i = 0; i < input.Count; i++) { if (_items.Contains(input[i])) { _items.Remove(input[i]); input.RemoveAt(i); i--; } } OnChangeInventery.Invoke(); }
public void AssignRecipe(CraftRecipe newRecipe) { assignedRecipe=newRecipe; //Add required ingredient icons foreach (CraftRecipe.CraftableItems ingredientKey in newRecipe.requiredIngredients.Keys) { RecipeIngredient newIngredientImage=Instantiate(ingredientPrefab); newIngredientImage.AssignIngredientItem(ingredientKey,newRecipe.requiredIngredients[ingredientKey]); newIngredientImage.transform.SetParent(ingredientsGroup,false); } descriptionText.text=newRecipe.description; //fatigueCostText.text=(newRecipe.requiredFatigue+InventoryScreenHandler.mainISHandler.selectedMember.currentFatigueCraftPenalty)+" fatigue"; //Refresh make button makeButton.AssignMadeItem(assignedRecipe); //if (canMakeItem) makeButton.GetComponent<Button>().interactable=true; //else makeButton.GetComponent<Button>().interactable=false; }
void ParseCraftJson() { craftList = new List <CraftRecipe>(); TextAsset craftText = Resources.Load <TextAsset>("Crafts"); string craftJson = craftText.text; JSONObject craftObjects = new JSONObject(craftJson); foreach (JSONObject temp in craftObjects.list) { int id = (int)temp["id"].n; string name = temp["name"].str; bool isNeedLearn = temp["isNeedLearn"].n == 0 ? false : true; CraftRecipe.CraftType type = (CraftRecipe.CraftType)System.Enum.Parse(typeof(CraftRecipe.CraftType), temp["type"].str); int[] needItemIDs = new int[temp["needItemIDs"].list.Count]; for (int i = 0; i < temp["needItemIDs"].list.Count; i++) { needItemIDs[i] = int.Parse(temp["needItemIDs"].list[i].str); } int[] needItemCount = new int[temp["needItemCount"].list.Count]; for (int i = 0; i < temp["needItemCount"].list.Count; i++) { needItemCount[i] = int.Parse(temp["needItemCount"].list[i].str); } int[] getItemIDs = new int[temp["getItemIDs"].list.Count]; for (int i = 0; i < temp["getItemIDs"].list.Count; i++) { getItemIDs[i] = int.Parse(temp["getItemIDs"].list[i].str); } int[] getItemCount = new int[temp["getItemCount"].list.Count]; for (int i = 0; i < temp["getItemCount"].list.Count; i++) { getItemCount[i] = int.Parse(temp["getItemCount"].list[i].str); } CraftRecipe craft = new CraftRecipe(id, name, isNeedLearn, type, needItemIDs, needItemCount, getItemIDs, getItemCount); craftList.Add(craft); } craftRecipos = SetCraftList(true); craftLearned = SetCraftList(false); }
public bool IsContainsToRecept(CraftRecipe craftRecipe) { if (craftRecipe) { var input = new List <Item>(); var TempItems = new List <Item>(); craftRecipe.Input.ForEach(n => input.Add(n)); _items.ForEach(n => TempItems.Add(n)); for (int i = 0; i < input.Count; i++) { if (TempItems.Contains(input[i])) { TempItems.Remove(input[i]); input.RemoveAt(i); i--; } } return(input.Count == 0); } else { return(false); } }
public void AssignIngredientItem(CraftRecipe.CraftableItems itemType, int requiredNumber) { ingredientItem = CraftRecipe.GetItemInstance(itemType); ingredientIcon.sprite=ingredientItem.GetItemSprite(); requiredNumberText.text="x"+requiredNumber; }
public void RegisterCraftRecipe(int sourceId1, int sourceId2, int sourceId3, int targetId) { CraftRecipe <int, int, int> Recipe = new CraftRecipe <int, int, int>(sourceId1, sourceId2, sourceId3); CraftRecipes.Add(Recipe, targetId); }
public int CraftRecipe(int sourceId1, int sourceId2, int sourceId3) { CraftRecipe <int, int, int> Recipe = new CraftRecipe <int, int, int>(sourceId1, sourceId2, sourceId3); return(CraftRecipes[Recipe]); }
//Craft public bool IsCraftRRecipeExists(int sourceId1, int sourceId2, int sourceId3) { CraftRecipe <int, int, int> Recipe = new CraftRecipe <int, int, int>(sourceId1, sourceId2, sourceId3); return(CraftRecipes.ContainsKey(Recipe)); }