コード例 #1
0
    public void ShowWelcomeMessage(MessageConnection messageConnection)
    {
        var     message      = (messageConnection.messageHeader as WelcomeMessage);
        uint    playerColour = message.PlayerColour;
        Color32 color32      = new Color32();

        color32 = ColorExtensions.ColorFromUInt(color32, playerColour);
        SetMessagesText(color32, $"Welcome! Your player ID is {message.PlayerID}.");
        bool host = false;

        if (message.PlayerID == 0)
        {
            host = true;
        }

        // Have this clients info ready for the gamemanager.
        ThisClient = new Client(message.PlayerID, "", messageConnection.connection, host);
        ThisClient.PlayerColour = message.PlayerColour;
        AllClientsList.Add(ThisClient);

        // Remove this later
        gameObject.GetComponent <LobbyManager>().thisClient = ThisClient;

        SendSetNameMessage();
    }
コード例 #2
0
    public void ShowNewPlayerMessage(MessageConnection messageConnection)
    {
        var message = (messageConnection.messageHeader as NewPlayerMessage);

        // Get colour and convert
        uint    playerColour = message.PlayerColour;
        Color32 color32      = new Color32();

        color32 = ColorExtensions.ColorFromUInt(color32, playerColour);

        // Display the message
        SetMessagesText(color32, $"Player {message.PlayerID}, {message.PlayerName} has joined the game!");

        // Add to the clientList
        Client otherClient = new Client(message.PlayerID, message.PlayerName, default, false);