Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.28 KB | None | 0 0
  1.         for (int i = 0; i < recipes.Length; i++) {
  2.  
  3.             Debug.Log ("Refreshing recipe " + recipes [i].recipeName);
  4.  
  5.             Debug.Log (" [i] is " + i.ToString () + ", Recipe length is" + recipes.Length.ToString ());
  6.  
  7.        
  8.             //If its at least 1 size recipe,
  9.             if (recipes [i].ingredients.Length >= 1) {
  10.                
  11.             //  Debug.Log ("Recipe length is 1, finding " + "Craft" + items [recipes [i].outputID].globalName);
  12.  
  13.                 //If it is a size 1 recipe and there is an info1,
  14.                 if (recipes [i].i1 != null) {
  15.                     Debug.Log ("Recipe reporting i1 exists for recipe" + recipes [i].recipeName);
  16.                     if (recipes [i].ingredients [0].y <= recipes [i].i1.amount) {
  17.  
  18.                         Debug.Log ("You have enough of first ingredient for" + recipes [i].recipeName);
  19.                         //  if (GameObject.Find ("Craft" + items [recipes [i].outputID].globalName)) {
  20.                         //rather
  21.                         if (recipes [i].recipeButton) {
  22.  
  23.                             //We know there is already a button for it. Do nothing.
  24.  
  25.                             Debug.Log ("Found button for. No need to make one!" + recipes [i].recipeButton.recipe.recipeName);
  26.  
  27.                         } else {
  28.                             Debug.Log ("No craft button, can craft " + recipes [i].recipeName + "... Trying to make button");
  29.  
  30.  
  31.                             GameObject newbutton = Instantiate (craftbutton, craftscreen.position, craftscreen.rotation, craftscreen);
  32.                             recipes [i].recipeButton = newbutton.GetComponent<CraftButton> ();
  33.                             newbutton.GetComponent<CraftButton> ().name = ("Craft" + items [recipes [i].outputID].globalName);
  34.                             newbutton.GetComponent<CraftButton> ().recipe = recipes [i];
  35.  
  36.  
  37.  
  38.                         }
  39.                         break;
  40.                     } else {
  41.                         Debug.Log ("i1 must exist, but must have not enough of first ingredient for:" + recipes [i].recipeName);
  42.                         if (recipes [i].recipeButton != null) {
  43.                             Destroy (recipes [i].recipeButton.gameObject, 0f);
  44.                             recipes [i].i1 = null;
  45.                             recipes [i].recipeButton = null;
  46.                         }
  47.                         break;
  48.                     }
  49.                     break;
  50.                 }
  51.                 //Otherwise, if its size 1 and i1 is null,
  52.                 else {
  53.                    
  54.                 //  if (recipes [i].ingredients [0].x == recipes [i].outputID)
  55.                     Debug.Log ("Recipe reporting i1 null for recipe!" + recipes [i].recipeName);
  56.                     Debug.Log ("Trying to set i1 on recipe " + recipes [i].recipeName + " as " + items [(int)recipes [i].ingredients [0].x].globalName);
  57.                     //If there is an info
  58.                     if (GameObject.Find (items [(int)recipes [i].ingredients [0].x].globalName)) {
  59.                         //Set this reference recipe i1 to the info we supposedly found
  60.                         recipes [i].i1 = GameObject.Find (items [(int)recipes [i].ingredients [0].x].globalName).GetComponentInChildren<ItemInfo> ();
  61.                         Debug.Log ("Looked for " + items [(int)recipes [i].ingredients [0].x].globalName + " found and set" + recipes [i].i1.iteminfo.itemName);
  62.                         return;
  63.                     } else {
  64.                         //otherwise, if we did not in fact find an info,
  65.                         Debug.Log ("Size 1 recipe has i1, returned null!");
  66.                         //i += 1;
  67.                         break;
  68.                         //break;
  69.                     }
  70.                     Debug.Log ("Recipe set!" + recipes [i].i1.iteminfo.itemName + " info, i think!");
  71.                     break;
  72.                     Debug.Log ("Recipe set!" + recipes [i].i1.iteminfo.itemName + " info, i think!");
  73.                 }
  74.                 break;
  75.                 //count += 1;
  76.             }else{break;}
  77.  
  78. /////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.
  79.  
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement