//Jimmy Vegas Unity Tutorial //This script is for the level timer and lives using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FloorTimer : MonoBehaviour { public int secondCount = 0; public int minuteCount = 0; public bool addingTime = false; public GameObject timeDisplay; void Update() { if (addingTime == false) { StartCoroutine(AddSecond()); } } IEnumerator AddSecond() { addingTime = true; yield return new WaitForSeconds(1); secondCount += 1; if (secondCount == 60) { secondCount = 0; minuteCount += 1; } if (secondCount <= 9) { if (minuteCount <= 9) { timeDisplay.GetComponent().text = "0" + minuteCount + ":0" + secondCount; } else { timeDisplay.GetComponent().text = "" + minuteCount + ":0" + secondCount; } } else { if (minuteCount <= 9) { timeDisplay.GetComponent().text = "0" + minuteCount + ":" + secondCount; } else { timeDisplay.GetComponent().text = "" + minuteCount + ":" + secondCount; } } addingTime = false; } } using System.Collections; using System.Collections.Generic; using UnityEngine; public class ExtraLife : MonoBehaviour { public AudioSource lifeSound; void Update() { transform.Rotate(0, 1, 0, Space.World); } void OnTriggerEnter(Collider other) { lifeSound.Play(); GlobalLife.lifeValue += 1; this.gameObject.SetActive(false); } }