public override void OnLobbyClientSceneChanged(NetworkConnection conn) { // Disables UI if players are in-game if (SceneManager.GetActiveScene().name == playScene) { Instantiate(UIManager.Instance.PauseMenuPrefab); lobbyUI.SetActive(false); } else if (SceneManager.GetActiveScene().name == lobbyScene) { lobbyUI.SetActive(true); UIManager.Instance.HideCursor(false); InGamePlayerList.Clear(); } }
public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId) { foreach (Transform startPos in startPositions) // Make Carnivore & Herbivore Start Position Lists { if (startPos.transform.tag == "CarnivoreStartPos") { carnivoreStartPoints.Add(startPos); } else { herbivoreStartPoints.Add(startPos); } } LobbyPlayer player = null; // Finds the lobby player foreach (LobbyPlayer p in lobbySlots) { if (p.netId == conn.playerControllers[playerControllerId].unetView.netId) { player = p; break; } } if (player == null) { Debug.Log("NetworkGameManager, OnLobbyServerCreateGamePlayer: Player not found!"); return(null); } Debug.Log("Client " + conn.playerControllers[playerControllerId].unetView.netId + " selected " + player.CharacterSelected.name); GameObject spawnedPlayer; // Spawns corresponding player prefab if (!spawnPrefabs.Contains(player.CharacterSelected)) { spawnedPlayer = Instantiate(gamePlayerPrefab); } else { if (player.CharacterSelected.GetComponent <Character>().GetType() == typeof(Carnivore)) { // Debugging Carnivores in game >> Debug.Log("cList count: " + carnivoreStartPoints.Count); spawnedPlayer = Instantiate(player.CharacterSelected, carnivoreStartPoints[Random.Range(0, carnivoreStartPoints.Count)].position, player.CharacterSelected.transform.rotation); // Starting position is randomly selected from carnivore list InGamePlayerList.Add(spawnedPlayer.GetComponent <Character>()); } else { // Debugging Herbivores in game >> Debug.Log("hList count: " + herbivoreStartPoints.Count); notBlockedSpawnPoints.Clear(); foreach (Transform startPos in herbivoreStartPoints) // Add starting positions that are empty into new starting position list { if (startPos.transform.GetComponent <StartPositionCheck>().isEmpty == true) { notBlockedSpawnPoints.Add(startPos.transform); } } // Debugging count of available starting positions >> Debug.Log("notblockedSpawnPoints Count: " + notBlockedSpawnPoints.Count); Vector3 spawnPoint = Vector3.zero; if (notBlockedSpawnPoints != null && notBlockedSpawnPoints.Count > 0) // Starting position is randomly selected from new list { spawnPoint = notBlockedSpawnPoints[Random.Range(0, notBlockedSpawnPoints.Count)].transform.position; } spawnedPlayer = Instantiate(player.CharacterSelected, spawnPoint, player.CharacterSelected.transform.rotation); InGamePlayerList.Add(spawnedPlayer.GetComponent <Character>()); } } return(spawnedPlayer); }