// Update is called once per frame void Update() { //If we are in range then create bombs at postions that don't already have them. if (PlayerInRange(interactionRange, playerObject)) { //Show Help Text bombExplainText.SetActive(true); if (Input.GetKeyDown(respawnBombsKey)) { //See if a bomb exists GameObject bombInstance = GameObject.Find("BombPickup(Clone)"); if (bombInstance != null) { //Destroy all bomb pick ups that are "owned" by this parent instance DestroyMyBombs(gameObject); } //Spawn New Bombs CreateAllBombs(); //Apply Time Penalty GameTimerScript.ApplyTimePenalty(10.0f); } } else { //Hide Help Text bombExplainText.SetActive(false); } }
//When the player leaves the trigger, apply the accumulated penalty time and reset it void OnTriggerExit(Collider other) { if (enableTimePenalty) { //Call Event to Apply Time Penalty GameTimerScript.ApplyTimePenalty(totalPenaltyTime); totalPenaltyTime = 0.0f; } }