public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Add(player); player.SetDisplayName($"Player {Players.Count}"); player.SetTeamColor(new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f))); player.SetPartyOwner(Players.Count == 1); }
public override void OnServerAddPlayer(NetworkConnection conn) { //When Server adds player to scene e.g. Lobby now. Add player to player lobby list. Set team color & set party owner to the first person in lobby. //Calls normal spawn player logic. Then spawns the unit spawner in at spawnPoint for Server & over Network for clients. base.OnServerAddPlayer(conn); //Get player and create new random color RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Add(player); //Sets the teams color when a player is added. player.SetTeamColor(new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f))); //Sets the party owner as whoever is in lobby first. player.SetPartyOwner(Players.Count == 1); }
public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); //set player random color RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); player.SetTeamColor(new Color( Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f) )); GameObject unitSpawnerInstance = Instantiate(unitSpawnerPrefab, conn.identity.transform.position, conn.identity.transform.rotation); NetworkServer.Spawn(unitSpawnerInstance, conn); }
public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); player.SetTeamColor(new Color( UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f), UnityEngine.Random.Range(0, 1f) )); GameObject unitSpawner = Instantiate(unitSpawnerPf, conn.identity.transform.position, conn.identity.transform.rotation); NetworkServer.Spawn(unitSpawner, conn); }
public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Add(player); player.SetDisplayName($"Player {Players.Count}"); player.SetTeamColor(new Color( UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value)); // sets party owner to player connected first (host) player.SetPartyOwner(Players.Count == 1); }