浏览代码

WIP: simplifying Lobby SDK calls.

/main/staging/2021_Upgrade/Async_Refactor
当前提交
e9517ac6
共有 6 个文件被更改,包括 14 次插入20 次删除
  1. 4
      Assets/Scripts/GameLobby/Game/GameManager.cs
  2. 8
      Assets/Scripts/GameLobby/Game/LocalLobby.cs
  3. 2
      Assets/Scripts/GameLobby/UI/EmoteButtonUI.cs
  4. 12
      Assets/Scripts/GameLobby/UI/JoinMenuUI.cs
  5. 8
      Assets/StreamingAssets.meta

4
Assets/Scripts/GameLobby/Game/GameManager.cs


}
public async void JoinLobby(LocalLobby lobbyInfo)
public async void JoinLobby(string lobbyID, string lobbyCode)
var lobby = await LobbyManager.JoinLobbyAsync(lobbyInfo.LobbyID.Value, lobbyInfo.LobbyCode.Value,
var lobby = await LobbyManager.JoinLobbyAsync(lobbyID, lobbyCode,
m_LocalUser);
if (lobby != null)
{

8
Assets/Scripts/GameLobby/Game/LocalLobby.cs


using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Serialization;
namespace LobbyRelaySample
{

{
if (m_LocalPlayers.ContainsKey(user.ID.Value))
{
Debug.LogError($"Cant add player {user.DisplayName}({user.ID}) to lobby: {LobbyID} twice");
Debug.LogError($"Cant add player {user.DisplayName.Value}({user.ID.Value}) to lobby: {LobbyID.Value} twice");
Debug.Log($"Adding User: {user.DisplayName} - {user.ID}");
Debug.Log($"Adding User: {user.DisplayName.Value} - {user.ID.Value}");
m_LocalPlayers.Add(user.ID.Value, user);
user.Emote.onChanged += EmoteChangedCallback;
user.DisplayName.onChanged += StringChangedCallback;

onUserListChanged?.Invoke(m_LocalPlayers);
}
Debug.LogWarning($"Player {user.DisplayName}({user.ID}) does not exist in lobby: {LobbyID}");
Debug.LogWarning($"Player {user.DisplayName.Value}({user.ID.Value}) does not exist in lobby: {LobbyID.Value}");
return;
}
m_LocalPlayers.Remove(user.ID.Value);

2
Assets/Scripts/GameLobby/UI/EmoteButtonUI.cs


using TMPro;
using UnityEditor.Scripting;
using UnityEngine;
namespace LobbyRelaySample.UI

12
Assets/Scripts/GameLobby/UI/JoinMenuUI.cs


/// <summary>Contains some amount of information used to join an existing lobby.</summary>
LocalLobby m_LocalLobbySelected;
string m_InputLobbyCode;
public override void Start()
{
base.Start();

public void OnLobbyCodeInputFieldChanged(string newCode)
{
if (!string.IsNullOrEmpty(newCode))
m_LocalLobbySelected.LobbyCode.Value = newCode.ToUpper();
m_InputLobbyCode = newCode.ToUpper();
Manager.JoinLobby(m_LocalLobbySelected);
m_LocalLobbySelected = new LocalLobby();
if (m_LocalLobbySelected == null)
return;
var selectedLobbyID = m_LocalLobbySelected.LobbyID.Value;
Manager.JoinLobby(selectedLobbyID, m_InputLobbyCode);
m_LocalLobbySelected = null;
}
public void OnRefresh()

8
Assets/StreamingAssets.meta


fileFormatVersion: 2
guid: 9d011d4adccc3c842a6972b8feb956d5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存