GameManagerScript.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class GameManagerScript : MonoBehaviour {
  6. private int playerCount;
  7. private string gameMode;
  8. public Database db;
  9. public string GameMode { get => gameMode; set => gameMode = value; }
  10. public int GameId { get; internal set; }
  11. List<KeyValuePair<string, int>> players;
  12. // Start is called before the first frame update
  13. void Start() {
  14. db = GameObject.Find("GameManager").GetComponent<Database>();
  15. GameId = PlayerPrefs.GetInt("GameId");
  16. db.SetLocalOrOnline("Local");
  17. db.SetLastPlayedDate(GameId);
  18. StatsScript statsScript = GameObject.Find("StatsPanel").GetComponent<StatsScript>();
  19. }
  20. private List<KeyValuePair<string,int>> GetPlayersForGame() {
  21. players = db.GetPlayersForGame(GameId);
  22. return players;
  23. }
  24. public List<KeyValuePair<string, int>> GetPlayers() {
  25. if (players == null) {
  26. players = GetPlayersForGame();
  27. }
  28. return players;
  29. }
  30. public Database GetDatabase() {
  31. if (db == null) {
  32. db = GameObject.Find("GameManager").GetComponent<Database>();
  33. }
  34. return db;
  35. }
  36. }