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);
|
|
|
|
}
|
|
}
|