public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); players.Add(player); player.SetDisplayName($"Player {players.Count}"); player.SetTeamColour(UnityEngine.Random.ColorHSV(0f, 1f, 0.8f, 1f, 0.8f, 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); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Add(player); player.SetDisplayName($"Player {Players.Count}"); player.SetTeamColour(new Color( UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f) )); player.SetPartyOwner(Players.Count == 1); // only set to party owner, if there is only one player }
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); }
public override void OnServerAddPlayer(NetworkConnection conn) { //Performs all base logic of the overrided class base.OnServerAddPlayer(conn); RTSPlayer player = conn.identity.GetComponent <RTSPlayer>(); Players.Add(player); player.SetDisplayName($"Player{Players.Count}"); player = conn.identity.GetComponent <RTSPlayer>(); player.SetTeamColor(new Color( UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f) )); player.SetPartyOwner(Players.Count == 1); }