GameManagerScript.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. StatsScript statsScript;
  10. public string GameMode { get => gameMode; set => gameMode = value; }
  11. public int GameId { get; internal set; }
  12. List<KeyValuePair<string, int>> players;
  13. // Start is called before the first frame update
  14. void Start() {
  15. db = Database.Instance;
  16. GameId = PlayerPrefs.GetInt("GameId");
  17. db.SetLocalOrOnline("Local");
  18. db.SetLastPlayedDate(GameId);
  19. statsScript = GameObject.Find("StatsPanel").GetComponent<StatsScript>();
  20. }
  21. private List<KeyValuePair<string,int>> GetPlayersForGame() {
  22. players = db.GetPlayersForGame(GameId);
  23. return players;
  24. }
  25. public void UpdateQuestiosLost(int questionsLost, string playerName) {
  26. db.SetQuestionsLost(GameId, playerName, questionsLost);
  27. }
  28. public void UpdateQuestionsInAnswerLine(string playerName, int count) {
  29. }
  30. public List<KeyValuePair<string, int>> GetPlayers() {
  31. if (players == null) {
  32. players = GetPlayersForGame();
  33. }
  34. return players;
  35. }
  36. }