예제 #1
0
 // put the information into detail panel
 public void SetUpDetailPanel(int index)
 {
     recipe = Craft._Recipes [index];
     detailIcon.sprite = Resources.Load<Sprite>("Sprite/" + recipe.name);
     detailNameLabel.text = recipe.name;
     detailDescription.text = recipe.description;
     detailPanel.SetActive (true);
     for (int i = 0; i < recipe.materials.Count; i++) {
         GameObject newButton = Instantiate(detailListButtonPf) as GameObject;
         string name = recipe.getName(i);
         int amount = recipe.getAmount(i);
         newButton.GetComponentInChildren<Text>().text = name + " (" + amount.ToString() + ")";
         newButton.GetComponentInChildren<Image>().sprite = Resources.Load<Sprite>("Sprite/" + name);
         newButton.transform.SetParent(detailContentPanel.transform, false);
     }
 }
예제 #2
0
 // put materials into boxes
 public void SetUpCraftPanel(int index)
 {
     recipe = Craft._Recipes [index];
     for (int i = 0; i < materials.Count; i++) {
         if(i < recipe.materials.Count){
             GameObject newItem = Instantiate (inventoryItemPF) as GameObject;
             Item it = new Item(recipe.getName(i), recipe.getAmount(i), recipe.description);
             newItem.GetComponent<Item> ().DisplayItem(it);
             newItem.GetComponent<Item> ().GetComponentInChildren<Text> ().enabled = false;
             newItem.GetComponent<ClickandDrag> ().enabled = false;
             materials[i].GetComponent<MaterialBoxScript>().material = newItem.GetComponent<Item>();
             newItem.transform.SetParent (materials[i].transform, false);
             UpdateText();
         }else{
             materialNums[i].text = "??/??";
         }
     }
     GameObject resultItem = Instantiate (inventoryItemPF) as GameObject;
     resultItem.GetComponent<Item> ().DisplayItem (new Item (recipe.name, 1, recipe.description));
     resultItem.GetComponent<Item> ().GetComponentInChildren<Text> ().enabled = false;
     resultItem.GetComponent<ClickandDrag> ().enabled = false;
     resultItem.transform.SetParent (product.transform, false);
 }