using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices.ComTypes; using UnityEngine; public class GameManager : MonoBehaviour { public static GameManager instance; public static Dictionary players = new Dictionary(); public GameObject localPlayerPrefab; public GameObject playerPrefab; private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("Instance already exists. Destroying object !"); Destroy(this); } } public void SpawnPlayer(int _id, string _username, Vector3 _position, Quaternion _rotation) { GameObject _player; if(_id == Client.instance.myId) { _player = Instantiate(localPlayerPrefab, _position, _rotation); } else { _player = Instantiate(playerPrefab, _position, _rotation); } _player.GetComponent().Initialize(_id, _username); players.Add(_id, _player.GetComponent()); } }