public void itemUpgrade(int i) { PlayerShip shipScript = playerShip.GetComponent <PlayerShip>(); Invent invScript = playerShip.GetComponent <Invent>(); if (invScript.checkSlot(i)) { Item item = invScript.getSlot(i); switch (item.type) { case "shooter": if (shipScript.getMetal() >= ((Shooter)item).upgradeCost()) { shipScript.spendMetal(((Shooter)item).upgradeCost()); ((Shooter)item).upgrade(); } break; case "default": default: Debug.Log("Default item upgrade not valid"); break; } } }
public void itemSell(int i) { PlayerShip shipScript = playerShip.GetComponent <PlayerShip>(); Invent invScript = playerShip.GetComponent <Invent>(); if (invScript.checkSlot(i)) { Item item = invScript.getSlot(i); shipScript.metal += item.getSellValue(); invScript.emptySlot(i); } }
void loadUIElements(GameObject ship) { Invent invent = ship.GetComponent <Invent>(); for (int i = 0; i < 5; i++) { if (invent.checkSlot(i)) { bottomBarOverlays[i].gameObject.SetActive(true); shopOverlays[i].gameObject.SetActive(true); bottomBarOverlays[i].sprite = invent.getSlot(i).image; shopOverlays[i].sprite = invent.getSlot(i).image; shopItemNames[i].text = invent.getSlot(i).getName() + "\nLvl " + invent.getSlot(i).getLevel(); Item item = invent.getSlot(i); switch (item.type) { case "shooter": shopItemStats[i].text = ((Shooter)item).getStats(); shopItemUpgrades[i].text = ((Shooter)item).getUpgradeStats(); break; case "default": default: shopItemStats[i].text = "child class stats not defined."; shopItemUpgrades[i].text = "child class upgrade stats not defined"; break; } } else { bottomBarOverlays[i].gameObject.SetActive(false); shopOverlays[i].gameObject.SetActive(false); shopItemNames[i].text = ""; shopItemStats[i].text = ""; shopItemUpgrades[i].text = ""; } } }
public void itemPressed(int i) { PlayerShip shipScript = playerShip.GetComponent <PlayerShip>(); Invent invScript = playerShip.GetComponent <Invent>(); if (invScript.checkSlot(i)) { Item item = invScript.getSlot(i); switch (item.type) { case "shooter": item.setShip(playerShip); // Inefficient ((Shooter)item).activate(); break; case "default": default: item.setShip(playerShip); // Inefficient ((Shooter)item).activate(); break; } } }