Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Dropdownmenu myDropdownmenu;
- public GameObject Dropdown;
- public Rezepte myRezepte;
- public GameObject Handwerk;
- public GameObject CrafttimerbarCurrent;
- public GameObject CrafttimerBackground;
- public GameObject Dropdown1;
- public static string TextofButton;
- public GameObject CraftItem1UI, CraftItem2UI, CraftItem3UI, CraftItem4UI, Description, CraftedItem;
- public int amount;
- public int LvL;
- public string Res1 = null;
- public string Res2 = null;
- public string Res3 = null;
- public string Res4 = null;
- public int rescount1 = 0;
- public int rescount2 = 0;
- public int rescount3 = 0;
- public int rescount4 = 0;
- public string description = null;
- public int readamount = 1;
- public Sprite Slotitem;
- public int _Dropdownvalue;
- public int Dropdownvalue
- {
- get
- {
- return _Dropdownvalue;
- }
- set
- {
- if (value != _Dropdownvalue)
- {
- print("oben : "+Dropdownvalue);
- Invoke("myDropdownmenu.ChangeDropmenu()",0.5f);
- DropdownValueChange();
- }
- _Dropdownvalue = value;
- }
- }
- void Start()
- {
- myDropdownmenu = Dropdown1.GetComponent<Dropdownmenu>();
- Handwerk = GameObject.Find("Handwerk");
- // Rightarm = GameObject.Find("Rightarm");
- // SlotPanel = GameObject.Find("SlotPanel");
- // Mouse = GameObject.Find("Mouse");
- CrafttimerbarCurrent.SetActive(false);
- CrafttimerBackground.SetActive(false);
- // readamount = 1;
- }
- // Update is called once per frame
- void Update()
- {
- Dropdownvalue = Dropdown1.GetComponent<Dropdown>().value;
- print(Dropdownvalue);
- }
- // Schritt 1--------------------------------------------------------------------------------
- // Auszuführen im Dropdownmenü unter DropdownonValueChange
- public void DropdownValueChange()
- {
- // Rezeptliste anhand des Dropdownmenüs ausgewählt
- switch (Dropdownvalue)
- {
- case 0: Rezepte.ListofLists = Rezepte.Handwerksrezepteliste; break;
- case 1: Rezepte.ListofLists = Rezepte.Werkzeugliste; break;
- case 2: Rezepte.ListofLists = Rezepte.Essensliste; break;
- case 3: Rezepte.ListofLists = Rezepte.Kleidungsliste; break;
- case 4: Rezepte.ListofLists = Rezepte.Buildinglist; break;
- case 5: Rezepte.ListofLists = Rezepte.Weaponlist; break;
- case 6: Rezepte.ListofLists = Rezepte.Otherlist; break;
- }
- // Buttons mit Rezepten versehen
- foreach (Rezepte List in Rezepte.ListofLists)
- {
- string LvL = List.LvL.ToString();
- string buttonstr = List.buttonnumber;
- string name = List.name;
- int buttonint = int.Parse(buttonstr);
- buttonint--;
- Button Buttonsearch = Dropdownmenu.Buttonliste[buttonint];
- Buttonsearch.GetComponentsInChildren<Text>()[0].text = name+" LvL "+LvL;
- }
- }
- // Schritt 2--------------------------------------------------------------------------------
- // Button mit Rezept gedrückt
- public void SelectRecipe()
- {
- Res1 = null;
- Res2 = null;
- Res3 = null;
- rescount1 = 0;
- rescount2 = 0;
- rescount3 = 0;
- rescount4 = 0;
- description = null;
- foreach (Rezepte rez in Rezepte.ListofLists)
- {
- if (rez.name == TextofButton)
- {
- switch (rez.rescount)
- {
- case 1:
- LvL = rez.LvL;
- Res1 = rez.Resource1;
- rescount1 = rez.Resource1count;
- description = rez.description;
- break;
- case 2:
- LvL = rez.LvL;
- Res1 = rez.Resource1;
- rescount1 = rez.Resource1count;
- Res2 = rez.Resource2;
- rescount2 = rez.Resource2count;
- description = rez.description;
- break;
- case 3:
- LvL = rez.LvL;
- Res1 = rez.Resource1;
- rescount1 = rez.Resource1count;
- Res2 = rez.Resource2;
- rescount2 = rez.Resource2count;
- Res3 = rez.Resource3;
- rescount3 = rez.Resource3count;
- description = rez.description;
- break;
- case 4:
- LvL = rez.LvL;
- Res1 = rez.Resource1;
- rescount1 = rez.Resource1count;
- Res2 = rez.Resource2;
- rescount2 = rez.Resource2count;
- Res3 = rez.Resource3;
- rescount3 = rez.Resource3count;
- Res4 = rez.Resource4;
- rescount4 = rez.Resource4count;
- description = rez.description;
- break;
- }
- }
- }
- }
- // Schritt 3--------------------------------------------------------------------------------
- public void ProcessResources()
- {
- CraftItem1UI.GetComponent<Image>().sprite = Slotitem;
- CraftItem2UI.GetComponent<Image>().sprite = Slotitem;
- CraftItem3UI.GetComponent<Image>().sprite = Slotitem;
- CraftItem4UI.GetComponent<Image>().sprite = Slotitem;
- CraftItem1UI.GetComponentsInChildren<Text>()[0].text = null;
- CraftItem2UI.GetComponentsInChildren<Text>()[0].text = null;
- CraftItem3UI.GetComponentsInChildren<Text>()[0].text = null;
- CraftItem4UI.GetComponentsInChildren<Text>()[0].text = null;
- if (Res1 != null)
- {
- Sprite Sprite1 = Resources.Load("Grau/" + Res1 + "_grey", typeof(Sprite)) as Sprite;
- CraftItem1UI.GetComponent<Image>().sprite = Sprite1;
- }
- if (Res2 != null)
- {
- Sprite Sprite2 = Resources.Load("Grau/" + Res2 + "_grey", typeof(Sprite)) as Sprite;
- CraftItem2UI.GetComponent<Image>().sprite = Sprite2;
- }
- if (Res3 != null)
- {
- Sprite Sprite3 = Resources.Load("Grau/" + Res3 + "_grey", typeof(Sprite)) as Sprite;
- CraftItem3UI.GetComponent<Image>().sprite = Sprite3;
- }
- if (Res4 != null)
- {
- Sprite Sprite4 = Resources.Load("Grau/" + Res4 + "_grey", typeof(Sprite)) as Sprite;
- CraftItem4UI.GetComponent<Image>().sprite = Sprite4;
- }
- if(rescount1 != 0)
- {
- rescount1 *= readamount;
- CraftItem1UI.GetComponentsInChildren<Text>()[0].text = rescount1.ToString();
- }
- if (rescount2 != 0)
- {
- rescount2 *= readamount;
- CraftItem2UI.GetComponentsInChildren<Text>()[0].text = rescount2.ToString();
- }
- if (rescount3 != 0)
- {
- rescount3 *= readamount;
- CraftItem3UI.GetComponentsInChildren<Text>()[0].text = rescount3.ToString();
- }
- if (rescount4 != 0)
- {
- rescount4 *= readamount;
- CraftItem4UI.GetComponentsInChildren<Text>()[0].text = rescount4.ToString();
- }
- if (description != null)
- {
- Description.GetComponent<Text>().text = description;
- }
- // Rezept dem Crafted Item zuweisen
- Sprite CraftedSprite = Resources.Load("Crafted/" + TextofButton, typeof(Sprite)) as Sprite;
- CraftedItem.gameObject.GetComponent<Image>().sprite = CraftedSprite;
- CraftedItem.GetComponentsInChildren<Text>()[0].text = readamount.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement