halfmagic
7/24/2019 - 1:36 AM

Timer using coroutine(Deprecated, needed to be cleaned)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(AppManager))]
public class UserTimer : MonoBehaviour
{
    #region Timer Coroutines
    public IEnumerator _NoshowTimer(int timeLimit)
    {
        for (int i = 0; i < timeLimit; i++)
        {
            Debug.Log("Noshow Timer : " + (timeLimit - i));
            yield return new WaitForSeconds(timeLimit / timeLimit);
        }
        this.gameObject.GetComponent<AppManager>().ToIdleScene();
        this.gameObject.GetComponent<AppManager>().noshowTimerStarted = false;
    }
    public IEnumerator _InteractionTimer(int timeLimit)
    {

        for (int i = 0; i < timeLimit; i++)
        {
            Debug.Log("Interaction Timer : " + (timeLimit - i));
            yield return new WaitForSeconds(timeLimit / timeLimit);
        }
        this.gameObject.GetComponent<AppManager>().ToIdleScene();
    }
    public IEnumerator _LostTrackingTimer(int timeLimit)
    {
        for (int i = 0; i < timeLimit; i++)
        {
            Debug.Log("Lost Tracking : " + (timeLimit - i));
            yield return new WaitForSeconds(timeLimit / timeLimit);
        }
        this.gameObject.GetComponent<AppManager>().ToIdleScene();
    }
    #endregion
}