浏览代码

Reordered the MessageTypes and added space for clarity (and ensured none are serialized). Broke up the GameManager OnReceiveMessage a bit for readability.

/main/staging/host_handshake
nathaniel.buck@unity3d.com 3 年前
当前提交
10dadd0f
共有 2 个文件被更改,包括 32 次插入31 次删除
  1. 35
      Assets/Scripts/Game/GameManager.cs
  2. 28
      Assets/Scripts/Infrastructure/Messenger.cs

35
Assets/Scripts/Game/GameManager.cs


/// </summary>
public void OnReceiveMessage(MessageType type, object msg)
{
if (type == MessageType.RenameRequest)
{ m_localUser.DisplayName = (string)msg;
}
else if (type == MessageType.CreateLobbyRequest)
if (type == MessageType.CreateLobbyRequest)
{
var createLobbyData = (LocalLobby)msg;
LobbyAsyncRequests.Instance.CreateLobbyAsync(createLobbyData.LobbyName, createLobbyData.MaxPlayerCount, createLobbyData.Private, m_localUser, (r) =>

},
m_lobbyColorFilter);
}
else if (type == MessageType.ChangeGameState)
{ SetGameState((GameState)msg);
else if (type == MessageType.QuickJoin)
{
LobbyAsyncRequests.Instance.QuickJoinLobbyAsync(m_localUser, m_lobbyColorFilter, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);
}
else if (type == MessageType.RenameRequest)
{ m_localUser.DisplayName = (string)msg;
}
else if (type == MessageType.ClientUserApproved)
{ ConfirmApproval();

else if (type == MessageType.LobbyUserStatus)
{ m_localUser.UserStatus = (UserStatus)msg;
}
else if (type == MessageType.StartCountdown)
{ m_localLobby.State = LobbyState.CountDown;
}

else if (type == MessageType.CompleteCountdown)
{ if (m_relayClient is RelayUtpHost)
(m_relayClient as RelayUtpHost).SendInGameState();
}
else if (type == MessageType.ChangeGameState)
{ SetGameState((GameState)msg);
}
else if (type == MessageType.ConfirmInGameState)
{ m_localUser.UserStatus = UserStatus.InGame;

{ m_localLobby.State = LobbyState.Lobby;
SetUserLobbyState();
}
else if (type == MessageType.QuickJoin)
{
LobbyAsyncRequests.Instance.QuickJoinLobbyAsync(m_localUser, m_lobbyColorFilter, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);
}
else if (type == MessageType.SetPlayerSound)
{
var playerSound = (LobbyUserAudio)msg;
}
}

28
Assets/Scripts/Infrastructure/Messenger.cs


JoinLobbyRequest = 2,
CreateLobbyRequest = 3,
QueryLobbies = 4,
ChangeGameState = 5,
LobbyUserStatus = 6,
UserSetEmote = 7,
EndGame = 8,
StartCountdown = 9,
CancelCountdown = 10,
ConfirmInGameState = 11,
DisplayErrorPopup = 12,
SetPlayerSound = 13,
QuickJoin = 14,
ClientUserApproved = 15,
ClientUserSeekingDisapproval = 16,
CompleteCountdown = 17,
QuickJoin = 5,
ChangeGameState = 100,
ConfirmInGameState = 101,
LobbyUserStatus = 102,
UserSetEmote = 103,
ClientUserApproved = 104,
ClientUserSeekingDisapproval = 105,
EndGame = 106,
StartCountdown = 200,
CancelCountdown = 201,
CompleteCountdown = 202,
DisplayErrorPopup = 300,
}
/// <summary>

正在加载...
取消
保存