示例#1
0
    private void PlayerReadyOnServer(NetworkMessage message)
    {
        NetworkPlayerData playerDataMessage = message.ReadMessage <NetworkPlayerData>();

        PlayerData playerData = playersManager.FindPlayerById(playerDataMessage.id);

        playerData.ready = true;

        LobbyManager lobbyManager = LobbyManager.Instance;

        if (lobbyManager.IsEveryoneReady())
        {
            lobbyManager.ClearState();

            NetworkServer.SendToAll(MessageConstants.MESSAGE, new NetworkConsoleMessage(0, "Servers says: Enough players in lobby, game will start soon.", MessageColor.BLUE));

            StartCoroutine(GameAboutToStartMessage());
        }

        NetworkServer.SendToAll(MessageConstants.MESSAGE, new NetworkConsoleMessage(0, "Servers says: " + playerData.playerName + " is ready.", MessageColor.BLUE));
    }