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

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using NaughtyAttributes;
  5. using Variables;
  6. public class JoinManager : MonoBehaviour
  7. {
  8. [SerializeField]
  9. private float m_JoinTime = 10;
  10. [SerializeField]
  11. private Reference<float> m_CountDown;
  12. [SerializeField]
  13. private PlayerManager m_playerManager;
  14. [SerializeField,Scene]
  15. private string m_nextScene;
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. m_playerManager.AllowJoin(true);
  20. StartCoroutine(DoCountDown(m_JoinTime));
  21. }
  22. private IEnumerator DoCountDown(float totalTime)
  23. {
  24. m_CountDown.Value = totalTime;
  25. while (m_CountDown > 0)
  26. {
  27. m_CountDown.Value -= Time.deltaTime;
  28. yield return new WaitForEndOfFrame();
  29. }
  30. CountDownFinished();
  31. }
  32. private void CountDownFinished()
  33. {
  34. m_playerManager.AllowJoin(false);
  35. UnityEngine.SceneManagement.SceneManager.LoadScene(m_nextScene);
  36. }
  37. }