Exemple #1
0
    /// <summary>
    /// Add a steam Lobby to the list of visible lobbies
    /// </summary>
    /// <param name="lobby">The Steamworks Lobby to add to the list</param>
    private void AddServer(Steamworks.Data.Lobby lobby)
    {
        var hostName = lobby.Id.Value.ToString();

        for (int i = 0; i < serverList.Count; ++i)
        {
            var server = serverList[i];
            if (server.Hostname == hostName)
            {
                // Already have that server listed nothing else to do
                return;
            }
        }

        var serverListItemData = new FacepunchServerListItemData {
            ListItem = GameObject.Instantiate <FacepunchServerListEntry>(serverListEntryTemplate, servers.content),
            Hostname = hostName,
        };

        serverListItemData.ListItem.gameObject.SetActive(true);

        serverListItemData.lobby = lobby;

        UpdateItem(serverListItemData);
        serverListItemData.NextUpdate = Time.time + 5.0f + UnityEngine.Random.Range(0.0f, 1.0f);

        serverList.Add(serverListItemData);
        SetListItemSelected(serverListItemData, false);

        RepositionItems();
    }
Exemple #2
0
 /// <summary>
 /// Set the border around the selected server entry
 /// </summary>
 /// <param name="data"></param>
 /// <param name="selected"></param>
 private void SetListItemSelected(FacepunchServerListItemData data, bool selected)
 {
     data.ListItem.GetComponent <Image>().enabled = selected;
 }
Exemple #3
0
    /// <summary>
    /// Update a specific server's details on the server list.
    /// </summary>
    /// <param name="option">The server display information to update</param>
    private void UpdateItem(FacepunchServerListItemData option)
    {
        // TODO:  Extract lobby info for display on the menu

        option.ListItem.hostName.text = option.Hostname;
    }
Exemple #4
0
 /// <summary>
 /// Remove a lobby from the list
 /// </summary>
 /// <param name="item">Lobby listItemData to remove</param>
 private void RemoveServer(FacepunchServerListItemData item)
 {
     Destroy(item.ListItem.gameObject);
     serverList.Remove(item);
     RepositionItems();
 }