浏览代码

fix : clarified some naming

/lobby-1.1.0-pre.3-update
UnityJacob 2 年前
当前提交
ab92c9fe
共有 2 个文件被更改,包括 40 次插入26 次删除
  1. 43
      Assets/Scripts/GameLobby/Game/GameManager.cs
  2. 23
      Assets/Scripts/GameLobby/Lobby/LobbyManager.cs

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


await LobbyManager.UpdatePlayerDataAsync(LobbyConverters.LocalToRemoteUserData(m_LocalUser));
}
public void UIChangeMenuState(GameState state)
public void UIChangeMenuState(GameState newState)
{
var isQuittingGame = LocalGameState == GameState.Lobby &&
m_LocalLobby.LocalLobbyState.Value == LobbyState.InGame;

//If we were in-game, make sure we stop by the lobby first
state = GameState.Lobby;
newState = GameState.Lobby;
SetGameState(state);
SetGameState(newState);
}
public void HostSetRelayCode(string code)

public void FinishedCountDown()
{
SetLocalUserStatus(PlayerStatus.InGame);
m_LocalLobby.LocalLobbyState.Value = LobbyState.CountDown;
SendLocalLobbyData();
m_setupInGame.StartNetworkedGame(m_LocalLobby, m_LocalUser);
}

#endregion
void SetGameState(GameState state)
void SetGameState(GameState newState)
var isLeavingLobby = (state == GameState.Menu || state == GameState.JoinMenu) &&
DisconnectFromLobby(newState);
LocalGameState = newState;
onGameStateChanged.Invoke(LocalGameState);
}
void DisconnectFromLobby(GameState newState)
{
var isLeavingLobby = newState is GameState.Menu or GameState.JoinMenu &&
LocalGameState = state;
if (isLeavingLobby)
{

}
onGameStateChanged.Invoke(LocalGameState);
}
void SetCurrentLobbies(IEnumerable<LocalLobby> lobbies)

async Task JoinLobby()
{
m_LocalLobby.LocalLobbyState.onChanged += OnLobbyStateChanged;
LobbyManager.OnKicked += LeaveLobby;
SetLobbyView();
StartVivoxJoin();
SetLocalLobby();
}
catch (Exception exception)
{

void LeaveLobby()
void SetLocalLobby()
{
m_LocalLobby.LocalLobbyState.onChanged += OnLobbyStateChanged;
LobbyManager.OnKicked += LeaveLocalLobby;
SetLobbyView();
StartVivoxJoin();
}
void LeaveLocalLobby()
m_LocalLobby.LocalLobbyState.onChanged -= OnLobbyStateChanged;
LobbyManager.OnKicked -= LeaveLocalLobby;
m_LocalLobby.LocalLobbyState.onChanged -= OnLobbyStateChanged;
LobbyManager.OnKicked -= LeaveLobby;
}
void StartVivoxLogin()

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


public event Action OnKicked;
Lobby m_CurrentLobby;
LocalLobby m_CurrentLocalLobby;
LobbyEventCallbacks m_LobbyEventCallbacks = new LobbyEventCallbacks();
LobbyEventCallbacks m_LobbyEventCallbacks;
public LobbyManager()
{
m_LobbyEventCallbacks = new LobbyEventCallbacks();
}
#region Rate Limiting
public enum RequestType

ServiceRateLimiter m_HeartBeatCooldown = new ServiceRateLimiter(5, 30);
#endregion
#region LobbyWrappers
Dictionary<string, PlayerDataObject> CreateInitialPlayerData(LocalPlayer user)
{

if (!InLobby())
return;
await LobbyService.Instance.RemovePlayerAsync(m_CurrentLobby.Id, AuthenticationService.Instance.PlayerId);
Debug.Log("Left Lobby!");
}
public async Task UpdatePlayerDataAsync(Dictionary<string, string> data)

await LobbyService.Instance.DeleteLobbyAsync(m_CurrentLobby.Id);
}
#endregion
#region LobbyBindings

m_LobbyEventCallbacks = new LobbyEventCallbacks();
m_LobbyEventCallbacks.KickedFromLobby += OnKickedFromLobby;
m_LobbyEventCallbacks.KickedFromLobby += OnRemovedFromLobby;
await LobbyService.Instance.SubscribeToLobbyEventsAsync(lobbyID, m_LobbyEventCallbacks);
}

Debug.Log($"State Changed! {newState}");
}
void OnKickedFromLobby()
void OnRemovedFromLobby()
{
m_CurrentLobby = null;
m_CurrentLocalLobby = null;

m_LobbyEventCallbacks.KickedFromLobby -= OnKickedFromLobby;
m_LobbyEventCallbacks.KickedFromLobby -= OnRemovedFromLobby;
m_LobbyEventCallbacks.LobbyEventConnectionStateChanged -= OnStateChanged;
}

{
#pragma warning disable CS4014
LeaveLobbyAsync();
#pragma warning restore CS4014
OnRemovedFromLobby();
return;
}

正在加载...
取消
保存