| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GameManagerScript : MonoBehaviour {
- private int playerCount;
- private string gameMode;
- private int gameId;
- public Database db;
-
- public string GameMode { get => gameMode; set => gameMode = value; }
- public int GameId { get; internal set; }
- List<KeyValuePair<string, int>> players;
- // Start is called before the first frame update
- void Start() {
- db = GameObject.Find("GameManager").GetComponent<Database>();
- GameId = PlayerPrefs.GetInt("GameId");
- db.SetLocalOrOnline("Local");
- db.SetLastPlayedDate(gameId);
- StatsScript statsScript = GameObject.Find("StatsPanel").GetComponent<StatsScript>();
- statsScript.AddPlayersToStats(GetPlayersForGame());
- }
- private List<KeyValuePair<string,int>> GetPlayersForGame() {
- players = db.GetPlayersForGame(GameId);
- return players;
- }
- public List<KeyValuePair<string, int>> GetPlayers() {
- if (players == null) {
- players = GetPlayersForGame();
- }
- return players;
- }
- public Database GetDatabase() {
- if (db == null) {
- db = GameObject.Find("GameManager").GetComponent<Database>();
- }
- return db;
- }
- }
|