void Start() { if (gameObject.GetComponent <CreateNewArmor>()) { CreateNewArmor a = gameObject.GetComponent <CreateNewArmor>(); dropArmor = a.NewArmor; Destroy(a); } }
private void Start() { if (gameObject.GetComponent <CreateNewArmor>()) { CreateNewArmor a = gameObject.GetComponent <CreateNewArmor>(); itemArmor = a.NewArmor; Destroy(a); } Transform _weight = gameObject.transform.Find("Weight"); Transform _name = gameObject.transform.Find("Type"); _weight.GetComponent <Text>().text = itemArmor.Weight.ToString() + " lbs"; _name.GetComponent <Text>().text = itemArmor.ItemName; }
void Awake() { scrollBar = GameObject.Find("Canvas/Inventory/Scrollbar").GetComponent <Scrollbar>(); // Inventory.weightText.text = "Weight: " +PlayerStats.curWeight.ToString() + "/" + PlayerStats.maxWeight.ToString() + "(" + ((PlayerStats.curWeight / PlayerStats.maxWeight)*100).ToString() + "%" + ")"; // Inventory.healthText.text = "Health: " + PlayerStats.health.ToString() + "/" + PlayerStats.maxHealth.ToString() + "(" + ((PlayerStats.health / PlayerStats.maxHealth)*100).ToString() + "%" + ")"; foreach (Transform r in UI.inventoryContent.transform) { itemList.Add(r.gameObject); if (r.GetComponent <InventoryWeapon>()) { r.gameObject.AddComponent <CreateNewWeapon>(); CreateNewWeapon cw = r.GetComponent <CreateNewWeapon>(); cw.CreateWeapon(); r.gameObject.SetActive(true); //adding the gameobject to the sell list GameObject clone; clone = Instantiate(shopWeaponPrefab, UI.sellContent.transform.position, transform.rotation) as GameObject; clone.transform.SetParent(UI.sellContent.transform, true); clone.transform.localScale = new Vector3(1, 1, 1); //transfering the data clone.gameObject.GetComponent <DybbukWeapon>().TransferData(cw.NewWeapon); clone.transform.FindChild("Value").GetComponent <Text>().text = "$" + clone.gameObject.GetComponent <DybbukWeapon>().ShopWeapon.SellValue.ToString("n0"); clone.transform.FindChild("Name").GetComponent <Text>().text = clone.gameObject.GetComponent <DybbukWeapon>().ShopWeapon.ItemName.ToString(); clone.transform.FindChild("Level").GetComponent <Text>().text = "Level: " + clone.gameObject.GetComponent <DybbukWeapon>().ShopWeapon.LevelRestriction.ToString(); clone.SetActive(true); sellList.Add(clone); } else if (r.GetComponent <InventoryArmor>()) { r.gameObject.AddComponent <CreateNewArmor>(); CreateNewArmor ca = r.GetComponent <CreateNewArmor>(); ca.CreateArmor(); r.gameObject.SetActive(true); ////adding the gameobject to the sell list GameObject clone; clone = Instantiate(shopArmorPrefab, UI.sellContent.transform.position, transform.rotation) as GameObject; clone.transform.SetParent(UI.sellContent.transform, true); clone.transform.localScale = new Vector3(1, 1, 1); //transfering the data clone.gameObject.GetComponent <DybbukArmor>().TransferData(ca.NewArmor); clone.transform.FindChild("Value").GetComponent <Text>().text = "$" + clone.gameObject.GetComponent <DybbukArmor>().ShopArmor.SellValue.ToString("n0"); clone.transform.FindChild("Name").GetComponent <Text>().text = clone.gameObject.GetComponent <DybbukArmor>().ShopArmor.ItemName.ToString(); clone.transform.FindChild("Level").GetComponent <Text>().text = "Level: " + clone.gameObject.GetComponent <DybbukArmor>().ShopArmor.LevelRestriction.ToString(); clone.SetActive(true); sellList.Add(clone); } else if (r.GetComponent <InventoryMisc>()) { r.gameObject.AddComponent <CreateNewMisc>(); CreateNewMisc cm = r.GetComponent <CreateNewMisc>(); cm.CreateMisc(); r.gameObject.SetActive(true); ////adding the gameobject to the sell list GameObject clone; clone = Instantiate(shopMiscPrefab, UI.sellContent.transform.position, transform.rotation) as GameObject; clone.transform.SetParent(UI.sellContent.transform, true); clone.transform.localScale = new Vector3(1, 1, 1); //transfering the data clone.gameObject.GetComponent <DybbukMisc>().TransferData(cm.NewMisc); clone.transform.FindChild("Value").GetComponent <Text>().text = "$" + clone.gameObject.GetComponent <DybbukMisc>().ShopMisc.SellValue.ToString("n0"); clone.transform.FindChild("Name").GetComponent <Text>().text = clone.gameObject.GetComponent <DybbukMisc>().ShopMisc.ItemName.ToString(); clone.transform.FindChild("Level").GetComponent <Text>().text = " "; clone.SetActive(true); sellList.Add(clone); } else if (r.GetComponent <InventoryAmmo>()) { r.gameObject.AddComponent <CreateNewAmmo>(); CreateNewAmmo a = r.GetComponent <CreateNewAmmo>(); a.CreateAmmo(); r.gameObject.SetActive(true); ////adding the gameobject to the sell list GameObject clone; clone = Instantiate(shopAmmoPrefab, UI.sellContent.transform.position, transform.rotation) as GameObject; clone.transform.SetParent(UI.sellContent.transform, true); clone.transform.localScale = new Vector3(1, 1, 1); //transfering the data clone.gameObject.GetComponent <DybbukAmmo>().TransferData(a.NewAmmo); clone.transform.FindChild("Value").GetComponent <Text>().text = "$" + clone.gameObject.GetComponent <DybbukAmmo>().ShopAmmo.SellValue.ToString("n0"); clone.transform.FindChild("Name").GetComponent <Text>().text = clone.gameObject.GetComponent <DybbukAmmo>().ShopAmmo.ItemName.ToString(); clone.transform.FindChild("Level").GetComponent <Text>().text = "Quantity: " + clone.gameObject.GetComponent <DybbukAmmo>().ShopAmmo.Quantity.ToString(); clone.SetActive(true); sellList.Add(clone); } } }