Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < recipes.Length; i++) {
- Debug.Log ("Refreshing recipe " + recipes [i].recipeName);
- Debug.Log (" [i] is " + i.ToString () + ", Recipe length is" + recipes.Length.ToString ());
- //If its at least 1 size recipe,
- if (recipes [i].ingredients.Length >= 1) {
- // Debug.Log ("Recipe length is 1, finding " + "Craft" + items [recipes [i].outputID].globalName);
- //If it is a size 1 recipe and there is an info1,
- if (recipes [i].i1 != null) {
- Debug.Log ("Recipe reporting i1 exists for recipe" + recipes [i].recipeName);
- if (recipes [i].ingredients [0].y <= recipes [i].i1.amount) {
- Debug.Log ("You have enough of first ingredient for" + recipes [i].recipeName);
- // if (GameObject.Find ("Craft" + items [recipes [i].outputID].globalName)) {
- //rather
- if (recipes [i].recipeButton) {
- //We know there is already a button for it. Do nothing.
- Debug.Log ("Found button for. No need to make one!" + recipes [i].recipeButton.recipe.recipeName);
- } else {
- Debug.Log ("No craft button, can craft " + recipes [i].recipeName + "... Trying to make button");
- GameObject newbutton = Instantiate (craftbutton, craftscreen.position, craftscreen.rotation, craftscreen);
- recipes [i].recipeButton = newbutton.GetComponent<CraftButton> ();
- newbutton.GetComponent<CraftButton> ().name = ("Craft" + items [recipes [i].outputID].globalName);
- newbutton.GetComponent<CraftButton> ().recipe = recipes [i];
- }
- break;
- } else {
- Debug.Log ("i1 must exist, but must have not enough of first ingredient for:" + recipes [i].recipeName);
- if (recipes [i].recipeButton != null) {
- Destroy (recipes [i].recipeButton.gameObject, 0f);
- recipes [i].i1 = null;
- recipes [i].recipeButton = null;
- }
- break;
- }
- break;
- }
- //Otherwise, if its size 1 and i1 is null,
- else {
- // if (recipes [i].ingredients [0].x == recipes [i].outputID)
- Debug.Log ("Recipe reporting i1 null for recipe!" + recipes [i].recipeName);
- Debug.Log ("Trying to set i1 on recipe " + recipes [i].recipeName + " as " + items [(int)recipes [i].ingredients [0].x].globalName);
- //If there is an info
- if (GameObject.Find (items [(int)recipes [i].ingredients [0].x].globalName)) {
- //Set this reference recipe i1 to the info we supposedly found
- recipes [i].i1 = GameObject.Find (items [(int)recipes [i].ingredients [0].x].globalName).GetComponentInChildren<ItemInfo> ();
- Debug.Log ("Looked for " + items [(int)recipes [i].ingredients [0].x].globalName + " found and set" + recipes [i].i1.iteminfo.itemName);
- return;
- } else {
- //otherwise, if we did not in fact find an info,
- Debug.Log ("Size 1 recipe has i1, returned null!");
- //i += 1;
- break;
- //break;
- }
- Debug.Log ("Recipe set!" + recipes [i].i1.iteminfo.itemName + " info, i think!");
- break;
- Debug.Log ("Recipe set!" + recipes [i].i1.iteminfo.itemName + " info, i think!");
- }
- break;
- //count += 1;
- }else{break;}
- /////Here is where I put the same as above inside the loop, only asking if the recipe's ingredients length is other numbers, and using i2 i3 i4 i5 etc.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement