コード例 #1
0
        public void OnFindLobbies(bool result)
        {
            if (result)
            {
                Console.WriteLine("Failure during lobby search.");
                return;
            }

            var obj = new Dict();

            int num_lobbies = SteamMatches.NumLobbies();

            Console.WriteLine("Found {0} lobbies", num_lobbies);
            obj["NumLobbies"] = num_lobbies;

            var lobby_list  = new List <Dict>(num_lobbies);
            var lobby_names = new List <String>(num_lobbies);

            for (int i = 0; i < num_lobbies; i++)
            {
                string lobby_name        = SteamMatches.GetLobbyData(i, "name");
                string game_started      = SteamMatches.GetLobbyData(i, "GameStarted");
                string countdown_started = SteamMatches.GetLobbyData(i, "CountDownStarted");
                if (!lobby_names.Contains(lobby_name) && !(countdown_started == "true" && game_started != "true"))
                {
                    int member_count = SteamMatches.GetLobbyMemberCount(i);
                    int capacity     = SteamMatches.GetLobbyCapacity(i);

                    // Console.WriteLine("lobby {0} name: {1} members: {2}/{3}", i, lobby_name, member_count, capacity);

                    if (capacity <= 0)
                    {
                        continue;
                    }

                    var lobby = new Dict();
                    lobby["Name"]        = lobby_name;
                    lobby["Index"]       = i;
                    lobby["MemberCount"] = member_count;
                    lobby["Capacity"]    = capacity;
                    lobby["GameStarted"] = game_started;

                    lobby["NumPlayers"]    = SteamMatches.GetLobbyData(i, "NumPlayers").MaybeInt();
                    lobby["NumSpectators"] = SteamMatches.GetLobbyData(i, "NumSpectators").MaybeInt();
                    lobby["MaxPlayers"]    = SteamMatches.GetLobbyData(i, "MaxPlayers").MaybeInt();

                    lobby_names.Add(lobby_name);
                    lobby_list.Add(lobby);
                }
            }

            obj["Lobbies"] = lobby_list;
            obj["Online"]  = true;

            Send("lobbies", obj);
        }
コード例 #2
0
        void Test_OnFindLobbies(bool result)
        {
            Console.WriteLine(result);

            if (result)
            {
                Console.WriteLine("Failure during lobby search.");
                return;
            }

            int n = SteamMatches.NumLobbies();

            Console.WriteLine("Found {0} lobbies", n);

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(SteamMatches.GetLobbyData(i, "name"));
            }

            SteamMatches.JoinCreatedLobby(Test_OnJoinLobby, Test_OnLobbyChatUpdate, Test_OnLobbyChatMsg, Test_OnLobbyDataUpdate);
        }