public void SetShip(ShipControl ship, Sprite image, bool disregardValidity) { ShipUpgrades u = null; if ((ship) || (disregardValidity)) { if (ship) { u = ship.gameObject.GetComponent <ShipUpgrades> (); } this.gameObject.SetActive(true); affectedShip = ship; display.sprite = image; } else { this.gameObject.SetActive(false); } if (u) { if (upgrade) { upgrade.gameObject.SetActive(u.AmountOfUpgrades() == u.GetMaxUpgrades()); } if (upgradeText) { upgradeText.text = u.AmountOfUpgrades().ToString(); upgradeText.gameObject.SetActive(true); } } else { if (upgrade) { upgrade.gameObject.SetActive(false); } if (upgradeText) { upgradeText.gameObject.SetActive(false); } } }
public void SetButtonText() { if (selectedShip != 0) { GameObject ship = ships [selectedShip - 1]; GetComponent <AudioManager> ().selectedShip = ship; if (ship != null) { buyUpgradePanel.SetActive(true); buyShipsPanel.SetActive(false); buyUpgradePanel.gameObject.transform.GetChild(0).GetComponent <Button> ().enabled = true; ShipUpgrades u = ship.GetComponent <ShipUpgrades> (); SetButtonActive(buyUpgradePanel.transform.GetChild(0).gameObject, u.UpgradeText()); if (u.AmountOfUpgrades() != u.GetMaxUpgrades()) { priceText1.text = "" + 5; // u.GetUpgradeCost priceText2.text = ""; } else { priceText1.text = ""; priceText2.text = ""; } /*if (ship.GetComponent<ShipUpgrades> ().GetMaxUpgrades () - ship.GetComponent<ShipUpgrades> ().AmountOfUpgrades () > 0) { * SetButtonActive (buyUpgradePanel.transform.GetChild (0).gameObject, "Buy Upgrade"); * priceText1.text = "" + 5; * priceText2.text = ""; * } else if (ship.GetComponent<ShipUpgrades> ().GetMaxUpgrades () == ship.GetComponent<ShipUpgrades> ().AmountOfUpgrades ()) { * buyUpgradePanel.gameObject.transform.GetChild (0).GetComponent<Button> ().enabled = false; * SetButtonActive (buyUpgradePanel.transform.GetChild (0).gameObject, "Ship Fully Upgraded"); * priceText1.text = ""; * priceText2.text = ""; * }*/ } else { selectedShip = ShipContainer.GetSpaceshipCount() + 1; buyShipsPanel.SetActive(true); buyUpgradePanel.SetActive(false); SetButtonActive(buyShipsPanel.transform.GetChild(0).gameObject, "Buy Pidgeon"); priceText1.text = "" + 5; priceText2.text = "" + 5; SetButtonActive(buyShipsPanel.transform.GetChild(1).gameObject, "Buy UFO"); } } else { buyUpgradePanel.SetActive(false); buyShipsPanel.SetActive(false); } }
public bool UpgradeAvailable() { if (affectedShip) { ShipUpgrades u = affectedShip.gameObject.GetComponent <ShipUpgrades> (); if (u) { return(u.AmountOfUpgrades() != u.GetMaxUpgrades()); } else { return(false); } } else { return(true); } }