|
|
|
|
|
|
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() |
|
|
|