Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.0 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyAttributes;
using Variables;
public class JoinManager : MonoBehaviour
{
[SerializeField]
private float m_JoinTime = 10;
[SerializeField]
private Reference<float> m_CountDown;
[SerializeField]
private PlayerManager m_playerManager;
[SerializeField,Scene]
private string m_nextScene;
// Start is called before the first frame update
void Start()
{
m_playerManager.AllowJoin(true);
StartCoroutine(DoCountDown(m_JoinTime));
}
private IEnumerator DoCountDown(float totalTime)
{
m_CountDown.Value = totalTime;
while (m_CountDown > 0)
{
m_CountDown.Value -= Time.deltaTime;
yield return new WaitForEndOfFrame();
}
CountDownFinished();
}
private void CountDownFinished()
{
m_playerManager.AllowJoin(false);
UnityEngine.SceneManagement.SceneManager.LoadScene(m_nextScene);
}
}