Exemplo n.º 1
0
    //如果我们没有足够的玩家,我们想禁用按钮JOIN
    //但OnLobbyClientConnect未在主机玩家上调用。 所以我们重写lobbyPlayer的创建
    public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId)
    {
        //print("服务器创建Lobby玩家");
        GameObject obj = Instantiate(lobbyPlayerPrefab.gameObject) as GameObject;

        LHLobbyPlayer newPlayer = obj.GetComponent <LHLobbyPlayer>();

        newPlayer.ToggleJoinButton(numPlayers + 1 >= minPlayers);

        for (int i = 0; i < lobbySlots.Length; ++i)
        {
            LHLobbyPlayer p = lobbySlots[i] as LHLobbyPlayer;

            if (p != null)
            {
                p.RpcUpdateRemoveButton();
                p.ToggleJoinButton(numPlayers + 1 >= minPlayers);
            }
        }

        return(obj);
    }