bool ControlUsersStatus()
    {
        int inGameCount = 0;

        for (int i = 0; i < Client.Users.Count; i++)
        {
            string data = SteamMatchmaking.GetLobbyMemberData(Client.Lobby.LobbyID, Client.Users[i].SteamID, "InGame");
            if (data == "")
            {
                continue;
            }
            int index;
            if (int.TryParse(data, out index))
            {
                if (index == 1)
                {
                    inGameCount++;
                }
            }
        }

        if (inGameCount == Client.Users.Count)
        {
            return(true);
        }

        return(false);
    }
Example #2
0
    void ControlAvatarDisponibility(byte[] data, uint dataLenght, CSteamID sender)
    {
        int avatarIndex = data[0];

        for (int i = 0; i < Client.Users.Count; i++)
        {
            string userIndex = SteamMatchmaking.GetLobbyMemberData(Client.Lobby.LobbyID, Client.Users[i].SteamID, "AvatarID");
            if (userIndex == "")
            {
                continue;
            }
            int index;
            if (int.TryParse(userIndex, out index))
            {
                if (index == avatarIndex)
                {
                    return;
                }
            }
        }

        byte[] d = ArrayPool <byte> .Get(1);

        d[0] = (byte)avatarIndex;

        Client.SendPacket(d, 0, d.Length, PacketType.AnswerAvatarSelection, Client.MyID, sender, EP2PSend.k_EP2PSendReliable);

        ArrayPool <byte> .Recycle(d);
    }
Example #3
0
    void UpdateStartState(LobbyDataUpdate_t cb)
    {
        readyUsers.Clear();
        if (Client.Users == null || Client.Users.Count == 0)
        {
            return;
        }

        for (int i = 0; i < Client.Users.Count; i++)
        {
            string data = SteamMatchmaking.GetLobbyMemberData(Client.Lobby.LobbyID, Client.Users[i].SteamID, "Ready");
            if (data == "")
            {
                continue;
            }
            int index;
            if (int.TryParse(data, out index))
            {
                if (index == 1)
                {
                    readyUsers.Add(Client.Users[i].SteamID);
                }
            }
        }
        SetStartButtonState();
        ControlStart();
    }
Example #4
0
    //void Update()
    //{
    //    timer += Time.deltaTime;
    //    if (timer >= 1)
    //    {
    //        timer = 0;
    //        if (!imageLoaded && OwnerID != new CSteamID(0))
    //        {
    //            Texture2D tex = GetUserAvatar(OwnerID);
    //            SetTex(tex);
    //        }
    //    }
    //}

    public void SelectAvatar()
    {
        if (Client.Users == null)
        {
            return;
        }

        for (int i = 0; i < Client.Users.Count; i++)
        {
            string data = SteamMatchmaking.GetLobbyMemberData(Client.Lobby.LobbyID, Client.Users[i].SteamID, "AvatarID");
            if (data == "")
            {
                continue;
            }
            int index;
            if (int.TryParse(data, out index))
            {
                if (index == avatarID)
                {
                    return;
                }
            }
        }

        Client.SendPacketToHost(new byte[] { (byte)avatarID }, PacketType.RequestAvatarSelection, EP2PSend.k_EP2PSendReliable);
    }
Example #5
0
    void UpdateUsers()
    {
        for (int j = 0; j < Avatars.Length; j++)
        {
            Avatars[j].Reset();
        }

        if (Client.Users == null)
        {
            return;
        }

        for (int i = 0; i < Client.Users.Count; i++)
        {
            string data = SteamMatchmaking.GetLobbyMemberData(Client.Lobby.LobbyID, Client.Users[i].SteamID, "AvatarID");
            if (data == "")
            {
                continue;
            }
            int index;
            if (int.TryParse(data, out index))
            {
                Client.Users[i].AvatarID = index;

                for (int j = 0; j < Avatars.Length; j++)
                {
                    if (Avatars[j].avatarID == index)
                    {
                        Avatars[j].UpdateOwner(Client.Users[i]);
                        Avatars[j].Button.interactable = false;
                    }
                }
            }
        }
    }
Example #6
0
 public void HomeWork(CSteamID tu)
 {
     theUser = tu;
     GetUserAvatar();
     Uname.text  = SteamFriends.GetFriendPersonaName(tu);
     Uready.text = SteamMatchmaking.GetLobbyMemberData(Sender.roomid, tu, "key_ready");
 }
Example #7
0
 public IEnumerable <string> GetMembersData(string key)
 {
     for (int i = 0; i < this.MemberCount; i++)
     {
         CSteamID j = SteamMatchmaking.GetLobbyMemberByIndex(this.Info.LobbyId, i);
         yield return(SteamMatchmaking.GetLobbyMemberData(this.Info.LobbyId, j, key));
     }
     yield break;
 }
 /// <summary>
 /// Read and write metadata values to the lobby
 /// </summary>
 /// <param name="metadataKey">The key of the value to be read or writen</param>
 /// <returns>The value of the key if any otherwise returns and empty string.</returns>
 public string this[string metadataKey]
 {
     get
     {
         return(SteamMatchmaking.GetLobbyMemberData(lobbyId, userData.id, metadataKey));
     }
     set
     {
         SteamMatchmaking.SetLobbyMemberData(lobbyId, metadataKey, value);
     }
 }
Example #9
0
    private void HandleWaiting()
    {
        if (lobbyCursor.back())
        {
            SetText("lefthost");
            myMesh.gameObject.SetActive(true);
            SteamMatchmaking.LeaveLobby((CSteamID)current_lobbyID);
            initializedStatus = -2;
            current_lobbyID   = 0;
            return;
        }
        int numusers = SteamMatchmaking.GetNumLobbyMembers((CSteamID)current_lobbyID);

        if (numusers == 1)
        {
            return;
        }
        SteamMatchmaking.SetLobbyData((CSteamID)current_lobbyID, "status", "full");
        SetUpReadyButtons();
        otherUsr = SteamMatchmaking.GetLobbyMemberByIndex((CSteamID)current_lobbyID, 1);
        lastTimeMessageReceived = Time.time;

        int score = 0;

        SteamUserStats.GetUserStat(otherUsr, "GAMESCORE", out score);

        if (player2Rank == null)
        {
            FontData f = PD.mostCommonFont.Clone(); f.color = Color.white;
            player2Rank = GetMeshText(new Vector3(0.745f, 1.8f), SteamFriends.GetFriendPersonaName(otherUsr), f);
            SteamUserStats.RequestUserStats(otherUsr);
        }

        string p2 = SteamMatchmaking.GetLobbyMemberData((CSteamID)current_lobbyID, otherUsr, "player");

        if (string.IsNullOrEmpty(p2))
        {
            return;
        }
        parent.ForcePlayer2(int.Parse(p2));
        initializedStatus = 6;
        myMesh.gameObject.SetActive(false);
    }
    private void UpdateLobbyMembers()
    {
        if (this.m_LobbyId == CSteamID.Nil)
        {
            this.m_LobbyMembers.Clear();
            return;
        }
        int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(this.m_LobbyId);

        this.m_LobbyMembers.Resize(numLobbyMembers);
        for (int i = 0; i < numLobbyMembers; i++)
        {
            CSteamID           lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(this.m_LobbyId, i);
            P2PLobbyMemberInfo p2PLobbyMemberInfo = this.m_LobbyMembers[i];
            p2PLobbyMemberInfo.m_Address = new P2PAddressSteam
            {
                m_SteamID = lobbyMemberByIndex
            };
            p2PLobbyMemberInfo.m_Name = SteamMatchmaking.GetLobbyMemberData(this.m_LobbyId, lobbyMemberByIndex, "member_name");
        }
    }
Example #11
0
    private void OnLobbyChatUpdate(LobbyDataUpdate_t lobbyDataUpdate)
    {
        ulong steamid = lobbyDataUpdate.m_ulSteamIDMember;

        print("Player joining... " + steamid);

        string joinedCID = SteamMatchmaking.GetLobbyMemberData(
            m_lobbyID,
            new CSteamID(steamid),
            "cid");

        if (joinedCID == null)
        {
            return;
        }
        if (lobbyDataUpdate.m_bSuccess == 1)
        {
            Match.AddPlayer(steamid, int.Parse(joinedCID));

            int neededPlayers = int.Parse(SteamMatchmaking.GetLobbyData(m_lobbyID, "NeededPlayers"));
            int playerCount   = SteamMatchmaking.GetNumLobbyMembers(m_lobbyID);

            if (new CSteamID(steamid) == Match.HostID)
            {
                Match.HostServer = true;
                Match.AddPlayer(steamid, ClientPlayer.Singleton.Cid);
            }
            Debug.Log($"{playerCount} / {neededPlayers}");
            if (playerCount >= neededPlayers)
            {
                Debug.Log($"Required players met. Starting...");
                m_matchSetup.Setup(Match.HostID);
            }
        }
        else
        {
            Match.RemovePlayer(steamid);
        }
    }
 /// <summary>
 ///     Called when either the lobby or a lobby member has their data updated.
 /// </summary>
 /// <param name="pCallback"></param>
 private void OnLobbyDataUpdate(LobbyDataUpdate_t pCallback)
 {
     if (pCallback.m_ulSteamIDLobby != pCallback.m_ulSteamIDMember)
     {
         if (NetLogFilter.logInfo)
         {
             Debug.Log($"Lobby Member Data Updated | ({Time.time})");
         }
         CSteamID lobby  = new CSteamID(pCallback.m_ulSteamIDLobby);
         CSteamID member = new CSteamID(pCallback.m_ulSteamIDMember);
         string   info   = SteamMatchmaking.GetLobbyMemberData(lobby, member, LobbyMemberData);
         LobbyMemberDataUpdated?.Invoke(member, info);
     }
     else
     {
         if (NetLogFilter.logInfo)
         {
             Debug.Log($"Lobby Data Updated | ({Time.time})");
         }
         CSteamID lobby = new CSteamID(pCallback.m_ulSteamIDLobby);
         string   data  = SteamMatchmaking.GetLobbyData(lobby, LobbyData);
         LobbyDataUpdated?.Invoke(data);
     }
 }
Example #13
0
    public void RenderOnGUI()
    {
        GUILayout.BeginArea(new Rect(Screen.width - 200, 0, 200, Screen.height));
        GUILayout.Label("Variables:");
        GUILayout.Label("m_Lobby: " + m_Lobby);
        GUILayout.EndArea();

        GUILayout.BeginVertical("box");
        m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width(Screen.width - 215), GUILayout.Height(Screen.height - 33));

        GUILayout.Label("GetFavoriteGameCount() : " + SteamMatchmaking.GetFavoriteGameCount());

        {
            AppId_t AppID;
            uint    IP;
            ushort  ConnPort;
            ushort  QueryPort;
            uint    Flags;
            uint    LastPlayedOnServer;
            bool    ret = SteamMatchmaking.GetFavoriteGame(0, out AppID, out IP, out ConnPort, out QueryPort, out Flags, out LastPlayedOnServer);
            GUILayout.Label("GetFavoriteGame(0, out AppID, out IP, out ConnPort, out QueryPort, out Flags, out LastPlayedOnServer) : " + ret + " -- " + AppID + " -- " + IP + " -- " + ConnPort + " -- " + QueryPort + " -- " + Flags + " -- " + LastPlayedOnServer);
        }

        if (GUILayout.Button("AddFavoriteGame(TestConstants.Instance.k_AppId_TeamFortress2, TestConstants.k_IpAddress208_78_165_233_uint, TestConstants.k_Port27015, TestConstants.k_Port27015, Constants.k_unFavoriteFlagFavorite, CurrentUnixTime)"))
        {
            uint CurrentUnixTime = (uint)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds;
            int  ret             = SteamMatchmaking.AddFavoriteGame(TestConstants.Instance.k_AppId_TeamFortress2, TestConstants.k_IpAddress208_78_165_233_uint, TestConstants.k_Port27015, TestConstants.k_Port27015, Constants.k_unFavoriteFlagFavorite, CurrentUnixTime);
            print("SteamMatchmaking.AddFavoriteGame(" + TestConstants.Instance.k_AppId_TeamFortress2 + ", " + TestConstants.k_IpAddress208_78_165_233_uint + ", " + TestConstants.k_Port27015 + ", " + TestConstants.k_Port27015 + ", " + Constants.k_unFavoriteFlagFavorite + ", " + CurrentUnixTime + ") : " + ret);
        }

        if (GUILayout.Button("RemoveFavoriteGame(TestConstants.Instance.k_AppId_TeamFortress2, TestConstants.k_IpAddress208_78_165_233_uint, TestConstants.k_Port27015, TestConstants.k_Port27015, Constants.k_unFavoriteFlagFavorite)"))
        {
            bool ret = SteamMatchmaking.RemoveFavoriteGame(TestConstants.Instance.k_AppId_TeamFortress2, TestConstants.k_IpAddress208_78_165_233_uint, TestConstants.k_Port27015, TestConstants.k_Port27015, Constants.k_unFavoriteFlagFavorite);
            print("SteamMatchmaking.RemoveFavoriteGame(" + TestConstants.Instance.k_AppId_TeamFortress2 + ", " + TestConstants.k_IpAddress208_78_165_233_uint + ", " + TestConstants.k_Port27015 + ", " + TestConstants.k_Port27015 + ", " + Constants.k_unFavoriteFlagFavorite + ") : " + ret);
        }

        if (GUILayout.Button("RequestLobbyList()"))
        {
            SteamAPICall_t handle = SteamMatchmaking.RequestLobbyList();
            OnLobbyMatchListCallResult.Set(handle);
            print("SteamMatchmaking.RequestLobbyList() : " + handle);
        }

        if (GUILayout.Button("AddRequestLobbyListStringFilter(\"SomeStringKey\", \"SomeValue\", ELobbyComparison.k_ELobbyComparisonNotEqual)"))
        {
            SteamMatchmaking.AddRequestLobbyListStringFilter("SomeStringKey", "SomeValue", ELobbyComparison.k_ELobbyComparisonNotEqual);
            print("SteamMatchmaking.AddRequestLobbyListStringFilter(" + "\"SomeStringKey\"" + ", " + "\"SomeValue\"" + ", " + ELobbyComparison.k_ELobbyComparisonNotEqual + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListNumericalFilter(\"SomeIntKey\", 0, ELobbyComparison.k_ELobbyComparisonNotEqual)"))
        {
            SteamMatchmaking.AddRequestLobbyListNumericalFilter("SomeIntKey", 0, ELobbyComparison.k_ELobbyComparisonNotEqual);
            print("SteamMatchmaking.AddRequestLobbyListNumericalFilter(" + "\"SomeIntKey\"" + ", " + 0 + ", " + ELobbyComparison.k_ELobbyComparisonNotEqual + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListNearValueFilter(\"SomeIntKey\", 0)"))
        {
            SteamMatchmaking.AddRequestLobbyListNearValueFilter("SomeIntKey", 0);
            print("SteamMatchmaking.AddRequestLobbyListNearValueFilter(" + "\"SomeIntKey\"" + ", " + 0 + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListFilterSlotsAvailable(3)"))
        {
            SteamMatchmaking.AddRequestLobbyListFilterSlotsAvailable(3);
            print("SteamMatchmaking.AddRequestLobbyListFilterSlotsAvailable(" + 3 + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide)"))
        {
            SteamMatchmaking.AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide);
            print("SteamMatchmaking.AddRequestLobbyListDistanceFilter(" + ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListResultCountFilter(1)"))
        {
            SteamMatchmaking.AddRequestLobbyListResultCountFilter(1);
            print("SteamMatchmaking.AddRequestLobbyListResultCountFilter(" + 1 + ")");
        }

        if (GUILayout.Button("AddRequestLobbyListCompatibleMembersFilter((CSteamID)0)"))
        {
            SteamMatchmaking.AddRequestLobbyListCompatibleMembersFilter((CSteamID)0);
            print("SteamMatchmaking.AddRequestLobbyListCompatibleMembersFilter(" + (CSteamID)0 + ")");
        }

        if (GUILayout.Button("GetLobbyByIndex(0)"))
        {
            m_Lobby = SteamMatchmaking.GetLobbyByIndex(0);
            print("SteamMatchmaking.GetLobbyByIndex(" + 0 + ") : " + m_Lobby);
        }

        if (GUILayout.Button("CreateLobby(ELobbyType.k_ELobbyTypePublic, 1)"))
        {
            SteamAPICall_t handle = SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, 1);
            OnLobbyCreatedCallResult.Set(handle);
            print("SteamMatchmaking.CreateLobby(" + ELobbyType.k_ELobbyTypePublic + ", " + 1 + ") : " + handle);
        }

        if (GUILayout.Button("JoinLobby(m_Lobby)"))
        {
            SteamAPICall_t handle = SteamMatchmaking.JoinLobby(m_Lobby);
            OnLobbyEnterCallResult.Set(handle);
            print("SteamMatchmaking.JoinLobby(" + m_Lobby + ") : " + handle);
        }

        if (GUILayout.Button("LeaveLobby(m_Lobby)"))
        {
            SteamMatchmaking.LeaveLobby(m_Lobby);
            m_Lobby = CSteamID.Nil;
            print("SteamMatchmaking.LeaveLobby(" + m_Lobby + ")");
        }

        if (GUILayout.Button("InviteUserToLobby(m_Lobby, SteamUser.GetSteamID())"))
        {
            bool ret = SteamMatchmaking.InviteUserToLobby(m_Lobby, SteamUser.GetSteamID());
            print("SteamMatchmaking.InviteUserToLobby(" + m_Lobby + ", " + SteamUser.GetSteamID() + ") : " + ret);
        }

        GUILayout.Label("GetNumLobbyMembers(m_Lobby) : " + SteamMatchmaking.GetNumLobbyMembers(m_Lobby));

        GUILayout.Label("GetLobbyMemberByIndex(m_Lobby, 0) : " + SteamMatchmaking.GetLobbyMemberByIndex(m_Lobby, 0));

        GUILayout.Label("GetLobbyData(m_Lobby, \"name\") : " + SteamMatchmaking.GetLobbyData(m_Lobby, "name"));

        if (GUILayout.Button("SetLobbyData(m_Lobby, \"name\", \"Test Lobby!\")"))
        {
            bool ret = SteamMatchmaking.SetLobbyData(m_Lobby, "name", "Test Lobby!");
            print("SteamMatchmaking.SetLobbyData(" + m_Lobby + ", " + "\"name\"" + ", " + "\"Test Lobby!\"" + ") : " + ret);
        }

        GUILayout.Label("GetLobbyDataCount(m_Lobby) : " + SteamMatchmaking.GetLobbyDataCount(m_Lobby));

        {
            string Key;
            string Value;
            bool   ret = SteamMatchmaking.GetLobbyDataByIndex(m_Lobby, 0, out Key, 255, out Value, 255);
            GUILayout.Label("GetLobbyDataByIndex(m_Lobby, 0, out Key, 255, out Value, 255) : " + ret + " -- " + Key + " -- " + Value);
        }

        if (GUILayout.Button("DeleteLobbyData(m_Lobby, \"name\")"))
        {
            bool ret = SteamMatchmaking.DeleteLobbyData(m_Lobby, "name");
            print("SteamMatchmaking.DeleteLobbyData(" + m_Lobby + ", " + "\"name\"" + ") : " + ret);
        }

        GUILayout.Label("GetLobbyMemberData(m_Lobby, SteamUser.GetSteamID(), \"test\") : " + SteamMatchmaking.GetLobbyMemberData(m_Lobby, SteamUser.GetSteamID(), "test"));

        if (GUILayout.Button("SetLobbyMemberData(m_Lobby, \"test\", \"This is a test Key!\")"))
        {
            SteamMatchmaking.SetLobbyMemberData(m_Lobby, "test", "This is a test Key!");
            print("SteamMatchmaking.SetLobbyMemberData(" + m_Lobby + ", " + "\"test\"" + ", " + "\"This is a test Key!\"" + ")");
        }

        if (GUILayout.Button("SendLobbyChatMsg(m_Lobby, MsgBody, MsgBody.Length)"))
        {
            byte[] MsgBody = System.Text.Encoding.UTF8.GetBytes("Test Message!");
            bool   ret     = SteamMatchmaking.SendLobbyChatMsg(m_Lobby, MsgBody, MsgBody.Length);
            print("SteamMatchmaking.SendLobbyChatMsg(" + m_Lobby + ", " + MsgBody + ", " + MsgBody.Length + ") : " + ret);
        }

        //SteamMatchmaking.GetLobbyChatEntry() // Only called from within OnLobbyChatMsg!

        if (GUILayout.Button("RequestLobbyData(m_Lobby)"))
        {
            bool ret = SteamMatchmaking.RequestLobbyData(m_Lobby);
            print("SteamMatchmaking.RequestLobbyData(" + m_Lobby + ") : " + ret);
        }

        if (GUILayout.Button("SetLobbyGameServer(m_Lobby, TestConstants.k_IpAddress127_0_0_1_uint, TestConstants.k_Port27015, CSteamID.NonSteamGS)"))
        {
            SteamMatchmaking.SetLobbyGameServer(m_Lobby, TestConstants.k_IpAddress127_0_0_1_uint, TestConstants.k_Port27015, CSteamID.NonSteamGS);
            print("SteamMatchmaking.SetLobbyGameServer(" + m_Lobby + ", " + TestConstants.k_IpAddress127_0_0_1_uint + ", " + TestConstants.k_Port27015 + ", " + CSteamID.NonSteamGS + ")");
        }

        {
            uint     GameServerIP;
            ushort   GameServerPort;
            CSteamID SteamIDGameServer;
            bool     ret = SteamMatchmaking.GetLobbyGameServer(m_Lobby, out GameServerIP, out GameServerPort, out SteamIDGameServer);
            GUILayout.Label("GetLobbyGameServer(m_Lobby, out GameServerIP, out GameServerPort, out SteamIDGameServer) : " + ret + " -- " + GameServerIP + " -- " + GameServerPort + " -- " + SteamIDGameServer);
        }

        if (GUILayout.Button("SetLobbyMemberLimit(m_Lobby, 6)"))
        {
            bool ret = SteamMatchmaking.SetLobbyMemberLimit(m_Lobby, 6);
            print("SteamMatchmaking.SetLobbyMemberLimit(" + m_Lobby + ", " + 6 + ") : " + ret);
        }

        GUILayout.Label("GetLobbyMemberLimit(m_Lobby) : " + SteamMatchmaking.GetLobbyMemberLimit(m_Lobby));

        if (GUILayout.Button("SetLobbyType(m_Lobby, ELobbyType.k_ELobbyTypePublic)"))
        {
            bool ret = SteamMatchmaking.SetLobbyType(m_Lobby, ELobbyType.k_ELobbyTypePublic);
            print("SteamMatchmaking.SetLobbyType(" + m_Lobby + ", " + ELobbyType.k_ELobbyTypePublic + ") : " + ret);
        }

        if (GUILayout.Button("SetLobbyJoinable(m_Lobby, true)"))
        {
            bool ret = SteamMatchmaking.SetLobbyJoinable(m_Lobby, true);
            print("SteamMatchmaking.SetLobbyJoinable(" + m_Lobby + ", " + true + ") : " + ret);
        }

        if (GUILayout.Button("GetLobbyOwner(m_Lobby)"))
        {
            CSteamID ret = SteamMatchmaking.GetLobbyOwner(m_Lobby);
            print("SteamMatchmaking.GetLobbyOwner(" + m_Lobby + ") : " + ret);
        }

        if (GUILayout.Button("SetLobbyOwner(m_Lobby, SteamUser.GetSteamID())"))
        {
            bool ret = SteamMatchmaking.SetLobbyOwner(m_Lobby, SteamUser.GetSteamID());
            print("SteamMatchmaking.SetLobbyOwner(" + m_Lobby + ", " + SteamUser.GetSteamID() + ") : " + ret);
        }

        if (GUILayout.Button("SetLinkedLobby(m_Lobby, m_Lobby)"))
        {
            bool ret = SteamMatchmaking.SetLinkedLobby(m_Lobby, m_Lobby);
            print("SteamMatchmaking.SetLinkedLobby(" + m_Lobby + ", " + m_Lobby + ") : " + ret);
        }

        //SteamMatchmaking.CheckForPSNGameBootInvite() // PS3 Only.

        GUILayout.EndScrollView();
        GUILayout.EndVertical();
    }
Example #14
0
        public void OnLobbyDataUpdate(LobbyDataUpdate_t pCallback)
        {
            if (pCallback.m_ulSteamIDLobby == pCallback.m_ulSteamIDMember)
            {
                LobbyInfo info = new LobbyInfo(SteamMatchmaking.GetLobbyData(new CSteamID(pCallback.m_ulSteamIDLobby), "LOBBY_INFO"));

                if (pCallback.m_ulSteamIDLobby == 0)
                {
                    return;
                }
                Logger.Debug($"Received: {info.ToString()}");
                if (pCallback.m_ulSteamIDLobby == SteamAPI.getLobbyID().m_SteamID)
                {
                    SteamAPI.UpdateLobbyInfo(info);
                    if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.WAITING))
                    {
                        currentScreen = info.Screen;
                        Logger.Debug($"Song has been selected, going to the waiting screen");
                        WaitingMenu.Instance.Present();
                    }
                    else if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.MENU))
                    {
                        currentScreen = info.Screen;
                        Logger.Debug($"Song has finished, updating state to menu");
                        GameController.Instance.SongFinished(null, null, null, null);
                    }
                    else if (DidScreenChange(info.Screen, LobbyInfo.SCREEN_TYPE.PLAY_SONG))
                    {
                        currentScreen = info.Screen;
                        Logger.Debug($"Host requested to play the current song {info.CurrentSongId}");

                        LevelSO song = SongListUtils.GetInstalledSong();
                        if (SteamAPI.IsHost())
                        {
                            SteamAPI.setLobbyStatus("Playing " + song.songName + " by " + song.songAuthorName);
                        }

                        SteamAPI.ClearPlayerReady(new CSteamID(SteamAPI.GetUserID()), true);
                        SongListUtils.StartSong(song, SteamAPI.GetSongDifficulty(), info.GameplayModifiers);
                    }
                }
                else
                {
                    SteamAPI.SetOtherLobbyData(pCallback.m_ulSteamIDLobby, info);
                }
            }
            else
            {
                string status = SteamMatchmaking.GetLobbyMemberData(new CSteamID(pCallback.m_ulSteamIDLobby), new CSteamID(pCallback.m_ulSteamIDMember), "STATUS");
                if (status == "DISCONNECTED")
                {
                    SteamAPI.DisconnectPlayer(pCallback.m_ulSteamIDMember);
                }
                else if (status.StartsWith("KICKED"))
                {
                    ulong playerId = Convert.ToUInt64(status.Substring(7));
                    if (playerId != 0 && playerId == SteamAPI.GetUserID())
                    {
                        SteamAPI.Disconnect();
                    }
                }
            }
        }
Example #15
0
    void UpdateLobbyInfo(ref Lobby outLobby)
    {
        outLobby.m_SteamID     = Sender.roomid;
        outLobby.m_Owner       = SteamMatchmaking.GetLobbyOwner(Sender.roomid);
        outLobby.m_Members     = new LobbyMembers[SteamMatchmaking.GetNumLobbyMembers(Sender.roomid)];
        outLobby.m_MemberLimit = SteamMatchmaking.GetLobbyMemberLimit(Sender.roomid);

        int nDataCount = SteamMatchmaking.GetLobbyDataCount(Sender.roomid);

        outLobby.m_Data = new LobbyMetaData[nDataCount];

        int Ucount = SteamMatchmaking.GetNumLobbyMembers(Sender.roomid);

        //ULS.CreateDs(Ucount);
        for (int i = 0; i < nDataCount; ++i)
        {
            bool lobby_data_ret = SteamMatchmaking.GetLobbyDataByIndex(Sender.roomid, i, out outLobby.m_Data[i].m_Key, Constants.k_nMaxLobbyKeyLength, out outLobby.m_Data[i].m_Value, Constants.k_cubChatMetadataMax);
            if (lobby_data_ret)
            {
                continue;
            }
            Debug.LogError("SteamMatchmaking.GetLobbyDataByIndex returned false.");
            continue;
        }
        //Notready.text = SteamMatchmaking.GetLobbyMemberData(Sender.roomid, SteamUser.GetSteamID(), "key_ready");
        int rc = 0;
        int gc = 0;

        for (int i = 0; i < outLobby.m_Members.Length; i++)
        {
            outLobby.m_Members[i].m_SteamID = SteamMatchmaking.GetLobbyMemberByIndex(Sender.roomid, i);
            //ULS.UDs[i].GetComponent<UserDetailScript>().HomeWork(outLobby.m_Members[i].m_SteamID);
            outLobby.m_Members[i].m_Data = new LobbyMetaData[1];
            LobbyMetaData lmd = new LobbyMetaData();
            lmd.m_Key   = "key_ready";
            lmd.m_Value = SteamMatchmaking.GetLobbyMemberData(Sender.roomid, outLobby.m_Members[i].m_SteamID, lmd.m_Key);
            if (lmd.m_Value == "READY")
            {
                rc++;
            }
            if (lmd.m_Value == "GREEN")
            {
                gc++;
            }
            outLobby.m_Members[i].m_Data[0] = lmd;
            //ULS.UDs[i].GetComponent<UserDetailScript>().Uready.text = lmd.m_Value;
            if (outLobby.m_Members[i].m_SteamID == SteamUser.GetSteamID())
            {
                MPControl(lmd.m_Value);
            }
        }
        if (rc == outLobby.m_MemberLimit)
        {
            if (rc == 1)
            {
                TestStart();
            }
            else
            {
                GameStart(rc);
            }
        }
        if (gc == outLobby.m_MemberLimit && SteamMatchmaking.GetLobbyOwner(Sender.roomid) == SteamUser.GetSteamID())
        {
            Debug.Log("All Players Green");
            Startbutton.interactable = true;
        }
    }
Example #16
0
 public void Update()
 {
     SteamAPI.RunCallbacks();
     if (initializedStatus == -3)          // LEAVING LOBBY LIST
     {
         MoveTextDown();
         lobbyCursor.SetVisibility(false);
         lobbyCursor.setY(8);
         SetText("leftlobby");
         initializedStatus = -2;
     }
     else if (initializedStatus == -1)            // CONNECTION FAILED
     {
         SetText("connfail");
         initializedStatus = -2;
     }
     else if (initializedStatus == 1)            // SELECTING OPTION
     {
         if (myMode == 1)
         {
             SetText("roomMake");
             SteamAPICall_t try_toHost = SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypeFriendsOnly, 2);
             initializedStatus = 3;
         }
         else if (myMode == 2)
         {
             SetText("roomFind");
             FindFriendLobbies();
         }
         else if (myMode == 3)
         {
             SetText("matchFind");
             SteamAPICall_t try_getList = SteamMatchmaking.RequestLobbyList();
         }
     }
     else if (initializedStatus == 2)            // VIEWING FRIEND LIST
     {
         LobbyUpdate();
     }
     else if (initializedStatus == 4)            // HOST WAITING FOR FRIEND TO JOIN
     {
         HandleWaiting();
     }
     else if (initializedStatus == 5)                                            // FRIEND WAITING FOR BOTH TO BE READY
     {
         if (SteamMatchmaking.GetNumLobbyMembers((CSteamID)current_lobbyID) < 2) // whoppy machine broke
         {
             BailFromState5(false);
         }
         else if (lobbyCursor.back())                // bailing
         {
             BailFromState5(false);
             return;
         }
         else if (lobbyCursor.launchOrPause())
         {
             p1Ok.GetComponent <SpriteRenderer>().sprite = roundsSheet[1];
             SteamMatchmaking.SetLobbyMemberData((CSteamID)current_lobbyID, "ready", "yes");
             isReady = true;
         }
         if (SteamMatchmaking.GetLobbyData((CSteamID)current_lobbyID, "ready") == "yes")
         {
             p2Ok.GetComponent <SpriteRenderer>().sprite = roundsSheet[1];
             lastTimeMessageReceived = Time.time;
             if (isReady)
             {
                 CleanUpReadyButtons(true);
                 initializedStatus = 7;
             }
         }
         else if (IsTimedOut(20.0f))
         {
             BailFromState5();
             return;
         }
     }
     else if (initializedStatus == 6)                                            // HOST WAITING FOR BOTH TO BE READY
     {
         if (SteamMatchmaking.GetNumLobbyMembers((CSteamID)current_lobbyID) < 2) // whoppy machine broke
         {
             parent.HidePlayer2();
             SetText("hostfriendlefthost");
             Destroy(player2Rank);
             myMesh.gameObject.SetActive(true);
             SteamMatchmaking.SetLobbyData((CSteamID)current_lobbyID, "status", "open");
             initializedStatus = 4;
             CleanUpReadyButtons(false);
         }
         else if (lobbyCursor.back())                // bailing
         {
             parent.HidePlayer2();
             SetText("friendlefthost");
             MoveTextDown();
             myMesh.gameObject.SetActive(true);
             SteamMatchmaking.SetLobbyData((CSteamID)current_lobbyID, "status", "dead");
             SteamMatchmaking.LeaveLobby((CSteamID)current_lobbyID);
             CleanUpReadyButtons(false);
             Destroy(player2Rank);
             initializedStatus = -2;
             return;
         }
         else if (lobbyCursor.launchOrPause())
         {
             p1Ok.GetComponent <SpriteRenderer>().sprite = roundsSheet[1];
             SteamMatchmaking.SetLobbyData((CSteamID)current_lobbyID, "ready", "yes");
             isReady = true;
         }
         if (SteamMatchmaking.GetLobbyMemberData((CSteamID)current_lobbyID, otherUsr, "ready") == "yes")
         {
             p2Ok.GetComponent <SpriteRenderer>().sprite = roundsSheet[1];
             if (isReady)
             {
                 CleanUpReadyButtons(true);
                 initializedStatus = 8;
             }
         }
         else if (IsTimedOut(20.0f))
         {
             BailFromState5();
             return;
         }
     }
     else if (initializedStatus == 7)            // p2 waiting for P2P connection and match starting *
     {
         PD.isOnlineHost     = false;
         PD.onlineOpponentId = (ulong)otherUsr;
         //Debug.Log ("AWAITING P2P CONNECTION");
         if (GetMessages().Count > 0)
         {
             lastTimeMessageReceived = Time.time;
             SteamMatchmaking.SetLobbyMemberData((CSteamID)current_lobbyID, "fullReady", "yes");
             SendMessage();
             GoToMatch();
         }
         else if (IsTimedOut(20.0f))
         {
             BailFromState5();
             return;
         }
         // waiting for OnP2PSessionRequest
     }
     else if (initializedStatus == 8)            // p1 sending P2P connection
     {
         SendMessage();
         Debug.Log("SENDING P2P CONNECTION TO " + otherUsr.ToString());
         initializedStatus = 9;
         if (IsTimedOut(20.0f))
         {
             BailFromState5();
             return;
         }
     }
     else if (initializedStatus == 9)            // p1 waiting for p2 to receive
     //if(SteamMatchmaking.GetLobbyMemberData((CSteamID)current_lobbyID, otherUsr, "fullReady") == "yes") {
     {
         Debug.Log("AWAITING P2P CONNECTION");
         PD.isOnlineHost     = true;
         PD.onlineOpponentId = (ulong)otherUsr;
         if (GetMessages().Count > 0)
         {
             lastTimeMessageReceived = Time.time;
             SteamMatchmaking.SetLobbyMemberData((CSteamID)current_lobbyID, "fullReady", "yes");
             GoToMatch();
         }
         else if (IsTimedOut(20.0f))
         {
             BailFromState5();
             return;
         }
     }
 }
 public static T GetLobbyMemberData <T>(CSteamID lobby, CSteamID user, string key)
 {
     return(JsonUtility.FromJson <T>(SteamMatchmaking.GetLobbyMemberData(lobby, user, key)));
 }
    public void RenderOnGUI()
    {
        //GUILayout.BeginArea(new Rect(Screen.width - 120, 0, 120, Screen.height));
        Console.WriteLine("Variables:");
        Console.WriteLine("m_Lobby: " + m_Lobby);
        //GUILayout.EndArea();

        Console.WriteLine("GetFavoriteGameCount() : " + SteamMatchmaking.GetFavoriteGameCount());

        {
            AppId_t AppID;
            uint    IP;
            ushort  ConnPort;
            ushort  QueryPort;
            uint    Flags;
            uint    LastPlayedOnServer;
            bool    ret = SteamMatchmaking.GetFavoriteGame(0, out AppID, out IP, out ConnPort, out QueryPort, out Flags, out LastPlayedOnServer);
            Console.WriteLine("GetFavoriteGame(0, out AppID, out IP, out ConnPort, out QueryPort, out Flags, out LastPlayedOnServer) : " + ret + " -- " + AppID + " -- " + IP + " -- " + ConnPort + " -- " + QueryPort + " -- " + Flags + " -- " + LastPlayedOnServer);
        }

        // 3494815209 = 208.78.165.233 = Valve Payload Server (Virginia srcds150 #1)
        //if (GUILayout.Button("AddFavoriteGame((AppId_t)480, 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite, CurrentUnixTime"))
        {
            uint CurrentUnixTime = (uint)(System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds;
            Console.WriteLine("SteamMatchmaking.AddFavoriteGame(" + (AppId_t)480 + ", 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite, " + CurrentUnixTime + ") : " + SteamMatchmaking.AddFavoriteGame((AppId_t)480, 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite, CurrentUnixTime));
        }

        //if (GUILayout.Button("RemoveFavoriteGame((AppId_t)480, 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite)"))
        {
            Console.WriteLine("SteamMatchmaking.RemoveFavoriteGame(" + (AppId_t)480 + ", 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite) : " + SteamMatchmaking.RemoveFavoriteGame((AppId_t)480, 3494815209, 27015, 27015, Constants.k_unFavoriteFlagFavorite));
        }

        //if (GUILayout.Button("RequestLobbyList()"))
        {
            SteamAPICall_t handle = SteamMatchmaking.RequestLobbyList();
            OnLobbyMatchListCallResult.Set(handle);
            Console.WriteLine("SteamMatchmaking.RequestLobbyList() : " + handle);
        }

        //if (GUILayout.Button("AddRequestLobbyListStringFilter(\"SomeStringKey\", \"SomeValue\", ELobbyComparison.k_ELobbyComparisonNotEqual)"))
        {
            SteamMatchmaking.AddRequestLobbyListStringFilter("SomeStringKey", "SomeValue", ELobbyComparison.k_ELobbyComparisonNotEqual);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListStringFilter(\"SomeStringKey\", \"SomeValue\", ELobbyComparison.k_ELobbyComparisonNotEqual)");
        }

        //if (GUILayout.Button("AddRequestLobbyListNumericalFilter(\"SomeIntKey\", 0, ELobbyComparison.k_ELobbyComparisonNotEqual)"))
        {
            SteamMatchmaking.AddRequestLobbyListNumericalFilter("SomeIntKey", 0, ELobbyComparison.k_ELobbyComparisonNotEqual);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListNumericalFilter(\"SomeIntKey\", 0, ELobbyComparison.k_ELobbyComparisonNotEqual)");
        }

        //if (GUILayout.Button("AddRequestLobbyListNearValueFilter(\"SomeIntKey\", 0)"))
        {
            SteamMatchmaking.AddRequestLobbyListNearValueFilter("SomeIntKey", 0);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListNearValueFilter(\"SomeIntKey\", 0)");
        }

        //if (GUILayout.Button("AddRequestLobbyListFilterSlotsAvailable(3)"))
        {
            SteamMatchmaking.AddRequestLobbyListFilterSlotsAvailable(3);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListFilterSlotsAvailable(3)");
        }

        //if (GUILayout.Button("AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide)"))
        {
            SteamMatchmaking.AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterWorldwide)");
        }

        //if (GUILayout.Button("AddRequestLobbyListResultCountFilter(1)"))
        {
            SteamMatchmaking.AddRequestLobbyListResultCountFilter(1);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListResultCountFilter(1)");
        }

        //if (GUILayout.Button("AddRequestLobbyListCompatibleMembersFilter((CSteamID)0)"))
        {
            SteamMatchmaking.AddRequestLobbyListCompatibleMembersFilter((CSteamID)0);
            Console.WriteLine("SteamMatchmaking.AddRequestLobbyListCompatibleMembersFilter((CSteamID)0)");
        }

        //if (GUILayout.Button("GetLobbyByIndex(0)"))
        {
            m_Lobby = SteamMatchmaking.GetLobbyByIndex(0);
            Console.WriteLine("SteamMatchmaking.SteamMatchmaking.GetLobbyByIndex(0) : " + m_Lobby);
        }

        //if (GUILayout.Button("CreateLobby(ELobbyType.k_ELobbyTypePublic, 1)"))
        {
            SteamAPICall_t handle = SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, 1);
            OnLobbyCreatedCallResult.Set(handle);
            Console.WriteLine("SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, 1) : " + handle);
        }

        //if (GUILayout.Button("JoinLobby(m_Lobby)"))
        {
            SteamAPICall_t handle = SteamMatchmaking.JoinLobby(m_Lobby);
            OnLobbyEnterCallResult.Set(handle);
            Console.WriteLine("SteamMatchmaking.JoinLobby(" + m_Lobby + ") : " + handle);
        }

        //if (GUILayout.Button("LeaveLobby(m_Lobby)"))
        {
            SteamMatchmaking.LeaveLobby(m_Lobby);
            m_Lobby = CSteamID.Nil;
            Console.WriteLine("SteamMatchmaking.LeaveLobby(" + m_Lobby + ")");
        }

        //if (GUILayout.Button("InviteUserToLobby(m_Lobby, SteamUser.GetSteamID())"))
        {
            Console.WriteLine("SteamMatchmaking.InviteUserToLobby(" + m_Lobby + ", SteamUser.GetSteamID()) : " + SteamMatchmaking.InviteUserToLobby(m_Lobby, SteamUser.GetSteamID()));
        }

        Console.WriteLine("GetNumLobbyMembers(m_Lobby) : " + SteamMatchmaking.GetNumLobbyMembers(m_Lobby));

        Console.WriteLine("GetLobbyMemberByIndex(m_Lobby, 0) : " + SteamMatchmaking.GetLobbyMemberByIndex(m_Lobby, 0));

        Console.WriteLine("SteamMatchmaking.GetLobbyData(m_Lobby, \"name\") : " + SteamMatchmaking.GetLobbyData(m_Lobby, "name"));

        //if (GUILayout.Button("SetLobbyData(m_Lobby, \"name\", \"Test Lobby!\")"))
        {
            Console.WriteLine("SteamMatchmaking.SetLobbyData(" + m_Lobby + ", \"name\", \"Test Lobby!\") : " + SteamMatchmaking.SetLobbyData(m_Lobby, "name", "Test Lobby!"));
        }

        Console.WriteLine("GetLobbyDataCount(m_Lobby) : " + SteamMatchmaking.GetLobbyDataCount(m_Lobby));

        {
            string Key;
            string Value;
            bool   ret = SteamMatchmaking.GetLobbyDataByIndex(m_Lobby, 0, out Key, 255, out Value, 255);
            Console.WriteLine("SteamMatchmaking.GetLobbyDataByIndex(m_Lobby, 0, out Key, 255, out Value, 255) : " + ret + " -- " + Key + " -- " + Value);
        }

        //if (GUILayout.Button("DeleteLobbyData(m_Lobby, \"name\")"))
        {
            Console.WriteLine("SteamMatchmaking.DeleteLobbyData(" + m_Lobby + ", \"name\") : " + SteamMatchmaking.DeleteLobbyData(m_Lobby, "name"));
        }

        {
            Console.WriteLine("SteamMatchmaking.GetLobbyMemberData(m_Lobby, SteamUser.GetSteamID(), \"test\") : " + SteamMatchmaking.GetLobbyMemberData(m_Lobby, SteamUser.GetSteamID(), "test"));
        }

        //if (GUILayout.Button("SetLobbyMemberData(m_Lobby, \"test\", \"This is a test Key!\")"))
        {
            SteamMatchmaking.SetLobbyMemberData(m_Lobby, "test", "This is a test Key!");
            Console.WriteLine("SteamMatchmaking.SetLobbyMemberData(" + m_Lobby + ", \"test\", \"This is a test Key!\")");
        }

        //if (GUILayout.Button("SendLobbyChatMsg(m_Lobby, MsgBody, MsgBody.Length)"))
        {
            byte[] MsgBody = System.Text.Encoding.UTF8.GetBytes("Test Message!");
            Console.WriteLine("SteamMatchmaking.SendLobbyChatMsg(" + m_Lobby + ", MsgBody, MsgBody.Length) : " + SteamMatchmaking.SendLobbyChatMsg(m_Lobby, MsgBody, MsgBody.Length));
        }

        //GetLobbyChatEntry(CSteamID steamIDLobby, int iChatID, out CSteamID pSteamIDUser, byte[] pvData, int cubData, out EChatEntryType peChatEntryType); // Only called from within OnLobbyChatMsg!

        //if (GUILayout.Button("RequestLobbyData(m_Lobby)"))
        {
            Console.WriteLine("SteamMatchmaking.RequestLobbyData(" + m_Lobby + ") : " + SteamMatchmaking.RequestLobbyData(m_Lobby));
        }

        //if (GUILayout.Button("SetLobbyGameServer(m_Lobby, 2130706433, 1337, CSteamID.NonSteamGS)"))
        {
            SteamMatchmaking.SetLobbyGameServer(m_Lobby, 2130706433, 1337, CSteamID.NonSteamGS); //127.0.0.1
            Console.WriteLine("SteamMatchmaking.SetLobbyGameServer(" + m_Lobby + ", 2130706433, 1337, CSteamID.NonSteamGS)");
        }

        {
            uint     GameServerIP;
            ushort   GameServerPort;
            CSteamID SteamIDGameServer;
            bool     ret = SteamMatchmaking.GetLobbyGameServer(m_Lobby, out GameServerIP, out GameServerPort, out SteamIDGameServer);
            Console.WriteLine("GetLobbyGameServer(m_Lobby, out GameServerIP, out GameServerPort, out SteamIDGameServer) : " + ret + " -- " + GameServerIP + " -- " + GameServerPort + " -- " + SteamIDGameServer);
        }

        //if (GUILayout.Button("SetLobbyMemberLimit(m_Lobby, 6)"))
        {
            Console.WriteLine("SteamMatchmaking.SteamMatchmaking.SetLobbyMemberLimit(" + m_Lobby + ", 6) : " + SteamMatchmaking.SetLobbyMemberLimit(m_Lobby, 6));
        }

        Console.WriteLine("GetLobbyMemberLimit(m_Lobby) : " + SteamMatchmaking.GetLobbyMemberLimit(m_Lobby));

        //if (GUILayout.Button("SetLobbyType(m_Lobby, ELobbyType.k_ELobbyTypePublic))"))
        {
            Console.WriteLine("SteamMatchmaking.SetLobbyType(" + m_Lobby + ", ELobbyType.k_ELobbyTypePublic)) : " + SteamMatchmaking.SetLobbyType(m_Lobby, ELobbyType.k_ELobbyTypePublic));
        }

        //if (GUILayout.Button("SetLobbyJoinable(m_Lobby, true)"))
        {
            Console.WriteLine("SteamMatchmaking.SetLobbyJoinable(" + m_Lobby + ", true) : " + SteamMatchmaking.SetLobbyJoinable(m_Lobby, true));
        }

        //if (GUILayout.Button("GetLobbyOwner(m_Lobby)"))
        {
            Console.WriteLine("SteamMatchmaking.GetLobbyOwner(" + m_Lobby + ") : " + SteamMatchmaking.GetLobbyOwner(m_Lobby));
        }

        //if (GUILayout.Button("SetLobbyOwner(m_Lobby, SteamUser.GetSteamID())"))
        {
            Console.WriteLine("SteamMatchmaking.SteamMatchmaking.SetLobbyOwner(" + m_Lobby + ", SteamUser.GetSteamID()) : " + SteamMatchmaking.SetLobbyOwner(m_Lobby, SteamUser.GetSteamID()));
        }

        //if (GUILayout.Button("SetLinkedLobby(m_Lobby, m_Lobby)"))
        {
            Console.WriteLine("SteamMatchmaking.SteamMatchmaking.SetLinkedLobby(" + m_Lobby + ", " + m_Lobby + ") : " + SteamMatchmaking.SetLinkedLobby(m_Lobby, m_Lobby));
        }
    }
Example #19
0
    /// <summary>
    /// Updates players' gameobject avatars on main menu's scene
    /// </summary>
    void UpdateTeammatesPresence()
    {
        if (C.LOG_INVITE)
        {
            Debug.Log("Updating teammates presence");
        }

        /// Cleanup
        FlushTeammatesPresence();

        /// Placing
        var membersNum = SteamMatchmaking.GetNumLobbyMembers(teambuilderLobbyId);
        int index      = 0; /// using 'index' variable to access Teammate* arrays without running out of borders

        for (int i = 0; i < membersNum; i++)
        {
            var member = SteamMatchmaking.GetLobbyMemberByIndex(teambuilderLobbyId, i);
            if (member != SteamUser.GetSteamID())  /// if not our player
            {
                if (C.LOG_INVITE)
                {
                    Debug.Log("Updating team-builder lobby data on player: " + SteamFriends.GetFriendPersonaName(member));
                }

                /// Get name and avatar
                TeammateNames[index].text = SteamFriends.GetFriendPersonaName(member);
                SteamNetworkManager.Instance.GetUserData(member, (data) =>
                {
                    /// Steam avatars uploaded 'inverted', needed to rotate
                    TeammateAvatars[index].rectTransform.rotation = Quaternion.Euler(new Vector3(0f, 180f, 180f));
                    TeammateAvatars[index].sprite = data.Avatar;
                    TeammateAvatars[index].transform.parent.GetChild(1).gameObject.GetComponentInChildren <ImageState>().SetState(true);
                });

                /// Get customization profile
                int[] preset    = new int[4];
                var   strPreset = SteamMatchmaking.GetLobbyMemberData(teambuilderLobbyId, member, "preset");
                if (C.LOG_INVITE)
                {
                    Debug.Log("Got " + SteamFriends.GetFriendPersonaName(member) + "'s customization message: " + strPreset);
                }

                /// Place avatar gameobject
                if (strPreset != "")
                {
                    TeammatePads[index].SetActive(true);
                }

                /// Parse and apply customization
                for (int j = 0; j < preset.Length; j++)
                {
                    if (strPreset != "")
                    {
                        var sp = strPreset.Substring(j * 5 + 1, 4);
                        if (C.LOG_INVITE)
                        {
                            Debug.Log("Preset #" + (j + 1).ToString() + ": " + sp);
                        }
                        preset[j] = int.Parse(sp);
                    }
                    else
                    {
                        TeammatePads[index].SetActive(false);
                    }
                }
                if (C.LOG_INVITE)
                {
                    Debug.Log("Customization profile of " + SteamFriends.GetFriendPersonaName(member) + " is: " + Utility.LogArray(preset));
                }
                TeammateCustomizers[index].ApplyCustomization(preset);

                index++;
            }
        }
    }