浏览代码

LogHandling seperation start

/main/staging/error_UI_UX
当前提交
de763b1a
共有 6 个文件被更改,包括 1103 次插入19 次删除
  1. 62
      Assets/Scripts/Game/GameManager.cs
  2. 40
      Assets/Scripts/Infrastructure/LogHandlerSettings.cs
  3. 11
      Assets/Scripts/Infrastructure/LogHandlerSettings.cs.meta
  4. 8
      Assets/StreamingAssets.meta
  5. 1001
      lobby-relay-sample.zip

62
Assets/Scripts/Game/GameManager.cs


/// </summary>
public class GameManager : MonoBehaviour, IReceiveMessages
{
[SerializeField]
[Tooltip("Only logs of this level or higher will appear in the console.")]
private LogMode m_logMode = LogMode.Critical;
[SerializeField]
private List<LocalGameStateObserver> m_GameStateObservers = new List<LocalGameStateObserver>();
[SerializeField]

[SerializeField]
private List<LobbyServiceDataObserver> m_LobbyServiceObservers = new List<LobbyServiceDataObserver>();
#endregion
private LocalGameState m_localGameState = new LocalGameState();

private bool m_coolingDown;
/// <summary>Rather than a setter, this is usable in-editor. It won't accept an enum, however.</summary>
public void SetLobbyColorFilter(int color) { m_lobbyColorFilter = (LobbyColor)color; }
public void SetLobbyColorFilter(int color)
{
m_lobbyColorFilter = (LobbyColor)color;
}
private void Awake()
{
// Do some arbitrary operations to instantiate singletons.

LogHandler.Get().mode = m_logMode;
Locator.Get.Provide(new Auth.Identity(OnAuthSignIn));
Application.wantsToQuit += OnWantToQuit;
}

foreach (var userObs in m_LocalUserObservers)
userObs.BeginObserving(m_localUser);
}
#endregion
/// <summary>

{
if (type == MessageType.RenameRequest)
{ m_localUser.DisplayName = (string)msg;
{
m_localUser.DisplayName = (string)msg;
}
else if (type == MessageType.CreateLobbyRequest)
{

var createLobbyData = (LocalLobby)msg;
LobbyAsyncRequests.Instance.CreateLobbyAsync(createLobbyData.LobbyName, createLobbyData.MaxPlayerCount, createLobbyData.Private, m_localUser, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
{
lobby.ToLocalLobby.Convert(r, m_localLobby);
OnCreatedLobby();
},
OnFailedJoin);

LocalLobby.LobbyData lobbyInfo = (LocalLobby.LobbyData)msg;
LobbyAsyncRequests.Instance.JoinLobbyAsync(lobbyInfo.LobbyID, lobbyInfo.LobbyCode, m_localUser, (r) =>
{ lobby.ToLocalLobby.Convert(r, m_localLobby);
{
lobby.ToLocalLobby.Convert(r, m_localLobby);
OnJoinedLobby();
},
OnFailedJoin);

return;
m_lobbyServiceData.State = LobbyQueryState.Fetching;
LobbyAsyncRequests.Instance.RetrieveLobbyListAsync(
qr => {
qr =>
{
er => {
er =>
{
long errorLong = 0;
if (er != null)
errorLong = er.Status;

}
else if (type == MessageType.ChangeGameState)
{ SetGameState((GameState)msg);
{
SetGameState((GameState)msg);
{ EmoteType emote = (EmoteType)msg;
{
EmoteType emote = (EmoteType)msg;
{ m_localUser.UserStatus = (UserStatus)msg;
{
m_localUser.UserStatus = (UserStatus)msg;
{ BeginCountDown();
{
BeginCountDown();
{ m_localLobby.State = LobbyState.Lobby;
{
m_localLobby.State = LobbyState.Lobby;
{ m_localUser.UserStatus = UserStatus.InGame;
{
m_localUser.UserStatus = UserStatus.InGame;
{ m_localLobby.State = LobbyState.Lobby;
{
m_localLobby.State = LobbyState.Lobby;
m_localLobby.CountDownTime = 0;
SetUserLobbyState();
}

LobbyAsyncRequests.Instance.EndTracking();
if (m_relaySetup != null)
{ Component.Destroy(m_relaySetup);
{
Component.Destroy(m_relaySetup);
{ Component.Destroy(m_relayClient);
{
Component.Destroy(m_relayClient);
m_relayClient = null;
}
}

StartCoroutine(RetryRelayConnection());
return;
}
m_relayClient = client;
OnReceiveMessage(MessageType.LobbyUserStatus, UserStatus.Lobby);
}

yield break;
m_localLobby.CountDownTime -= Time.deltaTime;
}
if (m_relayClient is RelayUtpHost)
(m_relayClient as RelayUtpHost).SendInGameState();
}

}
#region Teardown
/// <summary>
/// In builds, if we are in a lobby and try to send a Leave request on application quit, it won't go through if we're quitting on the same frame.
/// So, we need to delay just briefly to let the request happen (though we don't need to wait for the result).

m_localLobby = null;
}
}
#endregion
}
}

40
Assets/Scripts/Infrastructure/LogHandlerSettings.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Serialization;
namespace LobbyRelaySample
{
public class LogHandlerSettings : MonoBehaviour
{
[SerializeField]
[Tooltip("Only logs of this level or higher will appear in the console.")]
private LogMode m_Mode = LogMode.Critical;
void Awake()
{
LogHandler.Get().mode = m_Mode;
}
}
[System.Serializable]
public class LogFilter
{
[SerializeField]
private LogType m_ifThisType;
public LogType IfThisType => m_ifThisType;
public UnityEvent<string> m_logMessageCallback;
public void Filter(LogType logType, string logString)
{
if (logType != IfThisType)
return;
m_logMessageCallback?.Invoke(logString);
}
}
}

11
Assets/Scripts/Infrastructure/LogHandlerSettings.cs.meta


fileFormatVersion: 2
guid: 089231d71bcfb8d479b4f8b778b1026f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/StreamingAssets.meta


fileFormatVersion: 2
guid: 856fc4d990badc74a96656143dedb8e9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
lobby-relay-sample.zip
文件差异内容过多而无法显示
查看文件

正在加载...
取消
保存