示例#1
0
    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)
    {
        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);
    }