GameManager.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using cfg;
  2. using SimpleJSON;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using UnityEngine;
  7. using TMPro;
  8. public class GameManager : MonoBehaviour
  9. {
  10. public static GameManager instance;
  11. public float gameTime;
  12. public Tables allCfgData;
  13. public UIHP p1uiHP;
  14. public UIHP p1uiMP;
  15. public GameObject[] demonicNum;
  16. public TextMeshProUGUI text;
  17. private JSONNode Loader(string fileName)
  18. {
  19. return JSON.Parse(File.ReadAllText("GenerateDatas/json/" + fileName + ".json"));
  20. }
  21. public void GetAllExcel()
  22. {
  23. allCfgData = new Tables(Loader);
  24. }
  25. private void Awake()
  26. {
  27. if (!instance)
  28. {
  29. instance = this;
  30. GetAllExcel();
  31. }
  32. else
  33. {
  34. DestroyImmediate(gameObject);
  35. return;
  36. }
  37. }
  38. private void Start()
  39. {
  40. gameTime = 0;
  41. }
  42. private void FixedUpdate()
  43. {
  44. gameTime += Time.deltaTime;
  45. EnemyCreater.instance.OnGameTimeChange(gameTime);
  46. int timeText = (int)gameTime;
  47. text.text = $"{timeText / 60:D2}:{timeText % 60:D2}({timeText}s)";
  48. }
  49. }