private void UpdateGame() { if (serverController.game.started) { if (!hasStarted) { gameStartText.text = ""; serverController.uiManager.ShowPopup("The game has started", serverController.uiManager.popupDuration); hasStarted = true; foreach (GameObject targetPositionInstance in targetPositionInstances) { Destroy(targetPositionInstance); } } } else { if (serverController.isAtStart) { gameStartText.text = "Wait for other players to get to their start position."; } else { gameStartText.text = "Please move to your start position."; } } if (playerInstances.Count == 0) { CreatePlayerList(); } else { List <Player> playerList = serverController.game.players; for (int i = 0; i < playerList.Count; i++) { Player player = playerList[i]; GameObject otherPlayerInstance = playerInstances[i]; OtherPlayerScript otherPlayerInstanceScript = otherPlayerInstance.GetComponent <OtherPlayerScript>(); otherPlayerInstanceScript.UpdateInformation(player.position); } if (targetPositionInstances.Count > 0) { foreach (GameObject targetPositionInstance in targetPositionInstances) { TargetPosition targetPosition = targetPositionInstance.GetComponent <TargetPosition>(); targetPosition.UpdateInformation(targetPosition.targetCoordinate); } } } }
private void CreatePlayerList() { foreach (Player player in serverController.game.players) { GameObject newPlayer = Instantiate(playerPrefab, game.transform); OtherPlayerScript otherPlayerScript = newPlayer.GetComponent <OtherPlayerScript>(); otherPlayerScript.playerName = player.name; otherPlayerScript.ip = player.ip; otherPlayerScript.isHost = player.isHost; otherPlayerScript.playertype = player.playertype; Debug.Log(player.playertype); if (serverController.playerName == player.name && serverController.playerIp == player.ip) { otherPlayerScript.isPlayer = true; } playerInstances.Add(newPlayer); } }