public void AddPlayer(DeltaSkyIXPlayerNet _player) { if (!players.ContainsKey(_player.playerId)) { players.Add(_player.playerId, _player); } }
private IEnumerator AssignPlayerToLobbySlotDelayed(DeltaSkyIXPlayerNet _player, bool _left, int _slotId) { // Keep trying to get the lobby until it's not null Lobby lobby = FindObjectOfType <Lobby>(); Debug.Log("Looking for lobby"); while (lobby == null) { yield return(null); lobby = FindObjectOfType <Lobby>(); } Debug.Log("Found lobby"); // Lobby successfully got, so assign the player lobby.AssignPlayerToSlot(_player, _left, _slotId); }
protected void AssignPlayerId(GameObject _playerObj) { byte id = 0; //List<string> playerUsernames = players.Values.Select(x => x.username).ToList(); // Generate a list that is sorted by the keys value List <byte> playerIds = players.Keys.OrderBy(x => x).ToList(); // Loop through all keys (playerID's) in the player dictionary foreach (byte key in playerIds) { // If the temp id matches this key, increment the id value if (id == key) { id++; } } // Get the playernet component from the gameobject and assign it's playerid DeltaSkyIXPlayerNet player = _playerObj.GetComponent <DeltaSkyIXPlayerNet>(); player.playerId = id; players.Add(id, player); }
public void RpcStartMatch() { //Activates all players in the match foreach (DeltaSkyIXPlayerNet p in DeltaSkyIxNetworkManager.Instance.Players) { foreach (GameObject matchObject in p.matchObjects) { matchObject.SetActive(true); } } LevelManager.LoadLevel("Gameplay"); DeltaSkyIXPlayerNet player = DeltaSkyIxNetworkManager.Instance.LocalPlayer; FindObjectOfType <Lobby>().OnMatchStarted(); player.movement.Enable(); player.GetComponentInChildren <Camera>().enabled = true; player.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; player.GetComponent <NetworkRigidbody>().enabled = true; player.mouseRotation.enabled = true; player.shooting.enabled = true; }