void OnClick() { //increase the powerup level if (currentPowerupLevel < powerupUpgradeLevelMAX && //check if the max level has not been achieved hInGameScriptCS.getCurrencyCount() >= upgradeCost) //check if user has enough currency { currentPowerupLevel++; //increase the power-up level hInGameScriptCS.alterCurrencyCount(-upgradeCost); //deduct the cost of power-up upgrade hNGUIMenuScript.updateCurrencyOnHeader(hNGUIMenuScript.getCurrentMenu()); //update the currency on the header bar //tell the power-up script to increase the duration of the power-up hPowerupsMainControllerCS.upgradePowerup(powerup); //Update the text on the power-up item in shop uilLevelText.text = "Level " + currentPowerupLevel; } } //end of On Click
} //end of listener clicks function /* * FUNCTION: Perform function according to the clicked button. * CALLED BY: listenerClicks() */ private void handlerPowerupItem(Transform buttonTransform) { if (buttonTransform == tBuyButton) { //increase the powerup level if (currentPowerupLevel < powerupUpgradeLevelMAX && //check if the max level has not been achieved hInGameScriptCS.getCurrencyCount() >= upgradeCost) //check if user has enough currency { currentPowerupLevel++; //increase the power-up level hInGameScriptCS.alterCurrencyCount(-upgradeCost); //deduct the cost of power-up upgrade hShopScriptCS.updateCurrencyOnHeader(); //update the currency on the header bar //tell the power-up script to increase the duration of the power-up hPowerupsMainControllerCS.upgradePowerup(powerup); //Update the text on the power-up item in shop (this.transform.Find("Text_ItemLevel").GetComponent("TextMesh") as TextMesh).text = "Level " + currentPowerupLevel; } } //end of if }