浏览代码

WIP Integrating Wire

/main/staging/wire_implementation
当前提交
affdbccc
共有 4 个文件被更改,包括 26 次插入20 次删除
  1. 3
      Assets/Scripts/GameLobby/Game/GameManager.cs
  2. 9
      Assets/Scripts/GameLobby/Game/LocalLobby.cs
  3. 21
      Assets/Scripts/GameLobby/Lobby/LobbyManager.cs
  4. 13
      Assets/Scripts/GameLobby/Relay/RelayUtpSetup.cs

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


/// </summary>
public class GameManager : MonoBehaviour, IReceiveMessages
{
public LocalLobby LocalLobby => m_LocalLobby;
public Action<GameState> onGameStateChanged;
public LocalLobbyList LobbyList { get; private set; } = new LocalLobbyList();

LocalPlayer m_LocalUser;
LocalLobby m_LocalLobby;
LobbySynchronizer m_LobbySynchronizer;
RelayUtpSetup m_RelaySetup;
RelayUtpClient m_RelayClient;

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


/// (The way that the Lobby service handles its data doesn't necessarily match our needs, so we need to map from that to this LocalLobby for use in the sample code.)
/// </summary>
[System.Serializable]
public class LocalLobby : Observed<LocalLobby>
public class LocalLobby
{
public bool CanSetChanged = true;

return sb.ToString();
}
// This ends up being called from the lobby list when we get data about a lobby without having joined it yet.
public override void CopyObserved(LocalLobby oldObserved)
{
// CopyObserved(oldObserved.Data, oldObserved.m_LocalPlayers);
}
}
}

21
Assets/Scripts/GameLobby/Lobby/LobbyManager.cs


public Lobby CurrentLobby => m_CurrentLobby;
Lobby m_CurrentLobby;
LobbyEventCallbacks m_LobbyEventCallbacks = new LobbyEventCallbacks();
const int k_maxLobbiesToShow = 16; // If more are necessary, consider retrieving paginated results or using filters.
Task m_HeartBeatTask;

{
if (m_CreateCooldown.IsInCooldown)
{
UnityEngine.Debug.LogWarning("Create Lobby hit the rate limit.");
Debug.LogWarning("Create Lobby hit the rate limit.");
return null;
}

Player = new Player(id: uasId, data: CreateInitialPlayerData(localUser))
};
m_CurrentLobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayers, createOptions);
StartHeartBeat();
return m_CurrentLobby;

m_CurrentLobby = await LobbyService.Instance.JoinLobbyByCodeAsync(lobbyCode, joinOptions);
}
return m_CurrentLobby;
}

Filters = filters
};
return await LobbyService.Instance.QueryLobbiesAsync(queryOptions);
}
//TODO Finish this
public async Task SubscribeToLobbyChanges(string lobbyID, LocalLobby localLobby)
{
m_LobbyEventCallbacks.LobbyChanged += changes =>
{
if (changes.Name.Changed)
localLobby.LobbyName.Value = changes.Name.Value;
if (changes.IsPrivate.Changed)
localLobby.Private.Value = changes.IsPrivate.Value;
};
await LobbyService.Instance.SubscribeToLobbyEventsAsync(lobbyID, m_LobbyEventCallbacks);
}
List<QueryFilter> LobbyColorToFilters(LobbyColor limitToColor)

13
Assets/Scripts/GameLobby/Relay/RelayUtpSetup.cs


protected override void JoinRelay()
{
m_localLobby.onChanged += OnLobbyChange;
m_localLobby.RelayCode.onChanged += OnLobbyChange;
private void OnLobbyChange(LocalLobby lobby)
private void OnLobbyChange(string relayChanged)
if (m_localLobby.RelayCode != null)
{
RelayAPIInterface.JoinAsync(m_localLobby.RelayCode.Value, OnJoin);
m_localLobby.onChanged -= OnLobbyChange;
}
RelayAPIInterface.JoinAsync(relayChanged, OnJoin);
m_localLobby.RelayCode.onChanged -= OnLobbyChange;
}
private void OnJoin(JoinAllocation joinAllocation)

正在加载...
取消
保存