// Update is called once per frame void Update() { if (this.transform.parent == null) { // Tages Stunden und Minutenzähler minute += Time.deltaTime * speed; if (minute > 59) { hour++; minute = 0; } if (hour > 23) { day++; hour = 0; } if (hour > 0) { GameObject New = Instantiate(Prefabliste.Instance().GetGameObject(vein), new Vector3(0, 0, 0), Quaternion.identity); New.transform.position = this.transform.position; New.name = vein; Destroy(this.gameObject); } } }
public void InstantItem(string name, int amount) { for (int i = 0; i < amount; i++) { float placeX = Random.Range(-0.2f, 0.2f); float placeY = Random.Range(-0.2f, 0.2f); GameObject Spawn = Instantiate(Prefabliste.Instance().GetGameObject(name), new Vector3(0, 0, 0), Quaternion.identity); Spawn.transform.position = this.transform.position; Spawn.transform.position += new Vector3(placeX, placeY, 0); Spawn.name = name; } }
private void DropItem() { for (int i = 0; i < 3; i++) { string Name = this.name.Substring(0, this.name.Length - 4); float placeX = Random.Range(-0.5f, 0.5f); float placeY = Random.Range(-0.5f, 0.5f); if (!this.name.Contains("Stone")) { // Erzadern GameObject Spawn = Instantiate(Prefabliste.Instance().GetGameObject(Name + "ore"), new Vector3(0, 0, 0), Quaternion.identity); Spawn.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn.name = Name + "ore"; var spritetake = Spawn.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 1; } else { // Stein GameObject Spawn = Instantiate(Prefabliste.Instance().GetGameObject(Name), new Vector3(0, 0, 0), Quaternion.identity); Spawn.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn.name = Name; var spritetake = Spawn.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 1; } } float placeVX = Random.Range(-1f, 1f); float placeVY = Random.Range(-1f, 1f); // Vein GameObject Vein = Instantiate(Prefabliste.Instance().GetGameObject("Vein"), new Vector3(0, 0, 0), Quaternion.identity); Vein.transform.position = this.transform.position + new Vector3(placeVX, placeVY, 0); Vein.name = "Vein"; Vein myVein = Vein.GetComponent <Vein>(); myVein.vein = this.name; var spritetakeV = Vein.GetComponent <SpriteRenderer>(); spritetakeV.sortingOrder = 1; SoundManager.SendMessage("PlaySound", "stonebreak"); Destroy(this.gameObject); Charakter.SendMessage("EXP", 10); }
public void GetFish() { string name = Fishsorts[fishIndex]; print(name); GameObject Crafted = Instantiate(Prefabliste.Instance().GetGameObject(name), new Vector3(0, 0, 0), Quaternion.identity); Crafted.name = name; Crafted.transform.SetParent(Haken.transform); Crafted.transform.localPosition = Haken.transform.localPosition; Crafted.transform.eulerAngles = new Vector3(0, 0, 225); var spritetake = Crafted.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 11; reactiontimer = 2f; myItems = this.GetComponent <Items>(); myItems.Childlist.Add(Crafted); }
private void DropItem() { for (int i = 0; i < 3; i++) { float placeX = Random.Range(-0.5f, 0.5f); float placeY = Random.Range(-0.5f, 0.5f); // Log droppen GameObject Spawn = Instantiate(Prefabliste.Instance().GetGameObject("Log"), new Vector3(0, 0, 0), Quaternion.identity); Spawn.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn.name = "Log"; var spritetake = Spawn.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 1; // Ast droppen placeX = Random.Range(-0.5f, 0.5f); placeY = Random.Range(-0.5f, 0.5f); GameObject Spawn2 = Instantiate(Prefabliste.Instance().GetGameObject("Twig"), new Vector3(0, 0, 0), Quaternion.identity); Spawn2.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn2.name = "Twig"; var spritetake2 = Spawn2.GetComponent <SpriteRenderer>(); spritetake2.sortingOrder = 1; // Resin droppen placeX = Random.Range(-0.5f, 0.5f); placeY = Random.Range(-0.5f, 0.5f); GameObject Spawn3 = Instantiate(Prefabliste.Instance().GetGameObject("Resin"), new Vector3(0, 0, 0), Quaternion.identity); Spawn3.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn3.name = "Resin"; var spritetake3 = Spawn3.GetComponent <SpriteRenderer>(); spritetake3.sortingOrder = 1; // Sapling droppen placeX = Random.Range(-0.5f, 0.5f); placeY = Random.Range(-0.5f, 0.5f); GameObject Spawn4 = Instantiate(Prefabliste.Instance().GetGameObject("Sapling"), new Vector3(0, 0, 0), Quaternion.identity); Spawn4.transform.position = this.transform.position + new Vector3(placeX, placeY, 0); Spawn4.name = "Sapling"; var spritetake4 = Spawn4.GetComponent <SpriteRenderer>(); spritetake4.sortingOrder = 1; } Destroy(this.gameObject); Charakter.SendMessage("EXP", 10); }
public void Drinking() { if (childcounterR > 0) { ChildR = Rightarm.gameObject.transform.GetChild(0); Items myItems = ChildR.GetComponent <Items>(); if (Input.GetKey(KeyCode.E) && myItems.Drinkinglist.Contains(ChildR.name)) { Dtiming = true; animator.SetBool("drinking", true); } if (Dtiming == true) { Dtimer -= Time.deltaTime; if (Dtimer < 0.5) { SoundManager.SendMessage("PlaySound", "drinking"); } if (Dtimer < 0) { string ChildRnamenew = ChildR.name.Replace("_water", ""); Destroy((ChildR as Transform).gameObject); GameObject NewObj = Instantiate(Prefabliste.Instance().GetGameObject(ChildRnamenew), new Vector3(0, 0, 0), Quaternion.identity); NewObj.name = NewObj.name.Replace("(Clone)", ""); NewObj.transform.SetParent(Rightarm.transform); NewObj.transform.localPosition = new Vector3(0, -0.1f, 1); NewObj.transform.localEulerAngles = new Vector3(0, 0, 0); var spritetake = NewObj.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 10; Dtiming = false; animator.SetBool("drinking", false); int value = myItems.drinkingwerte[ChildR.name]; Charakter.SendMessage("Thirsttimer", value); } } else { Dtimer = 1.5f; } } }
void OnTriggerStay2D(Collider2D col) { if (col.CompareTag("waterfillable") && myCtrl.Wftiming == true && myCtrl.Wftimer < 0.5f) { string name = Child.name; Destroy((Child as Transform).gameObject); GameObject NewObj = Instantiate(Prefabliste.Instance().GetGameObject(name + "_water"), new Vector3(0, 0, 0), Quaternion.identity); NewObj.name = NewObj.name.Replace("(Clone)", ""); NewObj.transform.position = col.transform.position; NewObj.transform.eulerAngles = new Vector3(0, 0, +30); NewObj.transform.SetParent(Rightarm.transform); var spritetake = NewObj.GetComponent <SpriteRenderer>(); spritetake.sortingOrder = 10; if (myCtrl.Wftimer < 0.5) { SoundManager.SendMessage("PlaySound", "waterfill"); } } }
// Update is called once per frame void Update() { if (this.transform.parent == null) { // Tages Stunden und Minutenzähler minute += Time.deltaTime * speed; if (minute > 59) { hour++; minute = 0; } if (hour > 23) { day++; hour = 0; } if (hour > 0) { int random = Random.Range(1, 2); if (random == 1) { tree = "Beech"; } if (random == 2) { tree = "Firtree"; } GameObject New = Instantiate(Prefabliste.Instance().GetGameObject(tree), new Vector3(0, 0, 0), Quaternion.identity); New.transform.position = this.transform.position; New.name = tree; Destroy(this.gameObject); } } }
public void Craft() { int childcounterI = 0; int slotcounter = 0; // Prüfen ob Inventar voll foreach (Transform InventarSlot in SlotPanel.transform) { Transform ChildofInventarSlot = InventarSlot.gameObject.transform.GetChild(0); childcounterI = ChildofInventarSlot.childCount; if (childcounterI > 1) { slotcounter++; } } // Gegenstand herstellen---------------------------------------------------------- if (proof == true && slotcounter < 20) { CrafttimerbarCurrent.transform.localScale = new Vector3(0, 1, 1); for (int i = 0; i < readamount; i++) { Crafted = Instantiate(Prefabliste.Instance().GetGameObject(TextofButton), new Vector3(0, 0, 0), Quaternion.identity); Crafted.name = Crafted.name.Substring(0, Crafted.name.Length - 7); foreach (Transform InventarSlots in SlotPanel.transform) { Transform ChildofInventarSlot = InventarSlots.gameObject.transform.GetChild(0); int InventarSlotcounter = ChildofInventarSlot.transform.childCount; if (InventarSlotcounter == 1) { Crafted.gameObject.GetComponent <SpriteRenderer>().enabled = false; Crafted.transform.SetParent(ChildofInventarSlot.transform); } if (InventarSlotcounter > 1) { Child = ChildofInventarSlot.gameObject.transform.GetChild(1); } if (InventarSlotcounter > 1 && InventarSlotcounter < 21 && Crafted.name == Child.name) { Crafted.gameObject.GetComponent <SpriteRenderer>().enabled = false; Crafted.transform.SetParent(ChildofInventarSlot.transform); } } Crafted = null; } // Resourcen löschen for (int j = 0; j < rescount1; j++) { Transform Child = CraftItem1UI.gameObject.transform.GetChild(j + 1); Destroy((Child as Transform).gameObject); } for (int j = 0; j < rescount2; j++) { Transform Child = CraftItem2UI.gameObject.transform.GetChild(j + 1); Destroy((Child as Transform).gameObject); } for (int j = 0; j < rescount3; j++) { Transform Child = CraftItem3UI.gameObject.transform.GetChild(j + 1); Destroy((Child as Transform).gameObject); } for (int j = 0; j < rescount4; j++) { Transform Child = CraftItem4UI.gameObject.transform.GetChild(j + 1); Destroy((Child as Transform).gameObject); } proof = false; ProcessRecipeResources(); } }