using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class GameManager : MonoBehaviour { public Transform player; public static Transform Player { get { if (instance == null) { return null; } return instance.player; } } public static GameManager instance { get; private set; } public Text timerTxt; public float game_start_timer = 5; public float game_end_timer = 15; public GameObject gameOverPanel; public GameObject[] bees; void Awake() { instance = this; } float t; bool gameStarted = false; bool beesReleased = false; public static void StartGame() { instance.gameStarted= true; } private void Update() { if(!gameStarted) { return; } t += Time.deltaTime; if(t < game_start_timer) { timerTxt.text = (game_start_timer - t).ToString("n0"); }else if(t < game_end_timer) { if (!beesReleased) { beesReleased = true; ReleaseTheBees(); } timerTxt.text = (game_end_timer - t).ToString("n0"); } } void ReleaseTheBees() { foreach(GameObject enemy in bees) { enemy.SetActive(true); } } public static void GameOver() { instance.gameOverPanel.SetActive(true); } public void Restart() { SceneManager.LoadScene(0); } }