private IEnumerator WaitAndDo() { running = true; timepassed = 0; while (timepassed <= delay) { yield return(new WaitForSeconds(0.01f)); timepassed += 0.01f; } timepassed = 0; running = false; interactable = true; if (level < maxLevel) { upgradeable = true; } ResourceHandler.instance.allyResource += returnValue; UpdateInteractables(); if (upgradeObj != null) { upgradeObj.Finish(); } transactionObj.Finish(); }
private IEnumerator UpgradeCoroutine(ButtonBase upgradeObj) { StopCoroutine("UpgradeDelayChange"); StartCoroutine("UpgradeDelayChange"); upgradeCooldown = true; yield return(new WaitForSeconds(upgradeDelay)); upgradeCooldown = false; UpdateInteractables(); upgradeObj.Finish(); }
void Update() { if (Input.GetKeyUp(upgradeKey) && upgradeObj != null) { upgradeCooldown = false; StopCoroutine("UpgradeCoroutine"); UpdateInteractables(); upgradeObj.Finish(); } else { UpdateInteractables(); } if (upgradeObj != null) { upgradeObj.Update(); } transactionObj.Update(); bar.gameObject.SetActive(running); bar.value = timepassed / delay; }