meteorgame/Assets/Scripts/JimmyVegas/GlobalTimer.cs

34 lines
737 B
C#
Raw Normal View History

2021-03-18 15:56:10 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalTimer : MonoBehaviour
{
public GameObject timeDisplay01;
public GameObject timeDisplay02;
public bool isTakingTime = false;
public int theSeconds = 150;
public static int extendScore;
void Update()
{
extendScore = theSeconds;
if (isTakingTime == false)
{
StartCoroutine(SubtractSecond());
}
}
IEnumerator SubtractSecond()
{
isTakingTime = true;
theSeconds -= 1;
timeDisplay01.GetComponent<Text>().text = "" + theSeconds;
timeDisplay02.GetComponent<Text>().text = "" + theSeconds;
yield return new WaitForSeconds(1);
isTakingTime = false;
}
}