Beispiel #1
0
    private void ui_click_joinLobbyButtonPressed(Button b, SteamHubLobby lobby)
    {
        noMessagesHint.SetActive(true);

        b.interactable = false;
        SteamHub.Lobby_Join(lobby);
    }
    public void ui_find_match()
    {
        //print("SetStat(\"NumGames\", " + (4) + ") - " + ret);

        //SteamUserStats.GetStat("NumGames", out m_NumGamesStat);
        //Debug.Log(ret + " " + m_NumGamesStat);

        //bool ret = SteamUserStats.SetStat("NumGames", m_NumGamesStat + 1);
        //print("SetStat(\"NumGames\", " + (m_NumGamesStat + 1) + ") - " + ret);

        //Debug.Log(m_NumGamesStat);
        //float myELO;
        //SteamUserStats.GetStat("AverageSpeed", out myELO);

        //Debug.Log(myELO);
        int  Data;
        bool ret = SteamUserStats.GetStat("NumGames", out Data);

        if (ret)
        {
            //SteamMatchmaking.AddRequestLobbyListNearValueFilter("ELO", Data);
            SteamMatchmaking.AddRequestLobbyListFilterSlotsAvailable(1);
            SteamMatchmaking.AddRequestLobbyListDistanceFilter(ELobbyDistanceFilter.k_ELobbyDistanceFilterDefault);

            SteamMatchmaking.AddRequestLobbyListResultCountFilter(10);

            SteamHub.Lobby_RefreshList();
        }
    }
Beispiel #3
0
 public void ui_do_getLobbies()
 {
     // Refresh the lobby list.
     // This will cause the callbacks.LobbyListUpdated callback to fire when done
     SteamHub.Lobby_RefreshList();
     // Text t = LobbyListText.GetComponent<Text>();
     // t.text = "Refreshing Lobby List";
 }
Beispiel #4
0
    private void MyCallbacks_LobbyEntered(SteamHubLobby lobby)
    {
        SteamHub.Lobby_RefreshList();
        SteamHub.LobbyActive.SetData <string>(SteamUser.GetSteamID().ToString(), "false");

        lobbyEnteredCounter++;

        Debug.Log("LobbyEntered called " + lobbyEnteredCounter.ToString() + " times. Last entered lobby # " + ((lobby == null) ? "NULL" : lobby.LobbyId.ToString()));

        foreach (Transform child in chatBox.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
    }
Beispiel #5
0
    //join match based on ELO, game mode, etc
    //host new game if none found
    public void ui_join_match()
    {
        foreach (var lobby in SteamHub.LobbyList)
        {
            int lobbyMaxMembers = SteamMatchmaking.GetLobbyMemberLimit(lobby.LobbyId);

            if (lobby.MembersCount < lobbyMaxMembers)
            {
                SteamHub.Lobby_Join(lobby);
            }

            break;
        }
    }
Beispiel #6
0
 public void ui_do_createLobby()
 {
     if (lobbyName.GetComponent <Text>().text != "" && lobbySlots.GetComponent <Text>().text != "")
     {
         int desiredLobbySlots = int.Parse(lobbySlots.GetComponent <Text>().text);
         // Create a lobby
         SteamHub.Lobby_Create(false, desiredLobbySlots);
         Text t = createLobbyText.GetComponent <Text>();
         t.text = "Created Lobby with " + desiredLobbySlots.ToString() + " slots";
     }
     else
     {
         // TODO: Tell user to enter a name
     }
 }
Beispiel #7
0
 private void ui_click_leaveLobbyButtonPressed(Button b, SteamHubLobby lobby)
 {
     b.interactable = false;
     SteamHub.Lobby_LeaveActive();
 }
Beispiel #8
0
 public void ui_do_leaveLobby()
 {
     SteamHub.Lobby_LeaveActive();
     SteamHub.Lobby_RefreshList();
 }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        DontDestroyOnLoad(lobbyCanvas);

        // fill out all callbacks on SteamHub.Lobby_Callbacks
        var callbacks = new SteamHub.Lobby_Callbacks();

        callbacks.LobbyCreated     = MyCallbacks_LobbyCreated;
        callbacks.LobbyEntered     = MyCallbacks_LobbyEntered;
        callbacks.LobbyListUpdated = MyCallbacks_LobbyListUpdated;
        callbacks.LobbyDataUpdated = MyCallbacks_LobbyDataUpdated;
        callbacks.LobbyChatUpdate  = MyCallbacks_LobbyChatUpdate;
        callbacks.LobbyChatMessage = MyCallbacks_LobbyChatMessage;



        // call LobbyManager_Start
        SteamHub.LobbyManager_Start(callbacks);

        Text t = createLobbyText.GetComponent <Text>();

        t.text = "Create or join a lobby please";

        SteamHub.Lobby_RefreshList();

        if (SteamManager.Initialized && profilePic != null)
        {
            profileName.text = SteamFriends.GetPersonaName();
            SteamFriends.SetRichPresence("status", "Main Menu");

            //display profile pic in top right
            CSteamID m_Friend = SteamUser.GetSteamID();

            int FriendAvatar = SteamFriends.GetLargeFriendAvatar(m_Friend);
            print("SteamFriends.GetLargeFriendAvatar(" + m_Friend + ") - " + FriendAvatar);

            uint ImageWidth;
            uint ImageHeight;
            bool ret = Steamworks.SteamUtils.GetImageSize(FriendAvatar, out ImageWidth, out ImageHeight);

            if (ret && ImageWidth > 0 && ImageHeight > 0)
            {
                byte[] Image = new byte[ImageWidth * ImageHeight * 4];

                ret = Steamworks.SteamUtils.GetImageRGBA(FriendAvatar, Image, (int)(ImageWidth * ImageHeight * 4));
                if (ret)
                {
                    m_LargeAvatar = new Texture2D((int)ImageWidth, (int)ImageHeight, TextureFormat.RGBA32, false, true);
                    m_LargeAvatar.LoadRawTextureData(Image);
                    m_LargeAvatar.Apply();

                    profilePic.GetComponent <Image>().sprite = Sprite.Create(m_LargeAvatar, new Rect(0, 0, 184, 184), new Vector2(184, 184));
                }
            }
        }

        if (SteamManager.Initialized)
        {
            Debug.Log("Steam Online");

            steamNotification.GetComponent <Text>().color = Color.green;
            steamNotification.GetComponent <Text>().text  = "STEAM ONLINE";
            // steamNotification.SetActive(false);

            //bool ret0 =
            SteamUserStats.RequestCurrentStats();

            //we're going to use Spacewar's "NumWins" to track kills and "AverageSpeed" as ELO for matchmaking
            //NumLosses as deaths?
            //float myELO;
            //SteamUserStats.GetStat("AverageSpeed", out myELO);
            //bool ret4 = SteamUserStats.ResetAllStats(true);
            int Data;
            //bool ret =
            SteamUserStats.GetStat("NumGames", out Data);
            // Debug.Log(Data + " " + ret);

            currentEloText.GetComponent <Text>().text = "CURRENT ELO: " + Data;

            currentEloVisualFeedback.fillAmount = Data / 100.0f;

            // int m_nTotalNumWins;
            //SteamUserStats.GetStat("NumWins", out m_nTotalNumWins);
            //Debug.Log(m_nTotalNumWins);

            //SteamUserStats.SetStat("NumWins", 10);

            //bool bSuccess = SteamUserStats.StoreStats();
            //Debug.Log(bSuccess);
        }
        else
        {
            Debug.Log("Steam Offline");

            steamNotification.GetComponent <Text>().color = Color.red;
            steamNotification.GetComponent <Text>().text  = "STEAM OFFLINE";
        }
    }