/** * Called when the user presses the buy button. */ public void Buy() { if (activeUpgrade.price.value > status.Tickets) { // ########################################################### // add error message for trying to buy with not enough tickets // ########################################################### return; } if (activeUpgrade.currentLevel < activeUpgrade.maxLevel) { status.Tickets -= activeUpgrade.price.value; activeUpgrade.LevelUp(); } else { // this upgrade is already at max level } // update ui activeUpgradeUI.populate(); UpdateTicketText(); ClosePopUp(); }