GitHub
3 年前
当前提交
16ed3868
共有 32 个文件被更改,包括 1120 次插入 和 1136 次删除
-
988Assets/Art/Font/CheckboxFLF SDF.asset
-
60Assets/Prefabs/UI/GameCanvas.prefab
-
13Assets/Prefabs/UI/JoinContent.prefab
-
15Assets/Prefabs/UI/JoinCreateCanvas.prefab
-
13Assets/Prefabs/UI/PlayerInteractionPanel.prefab
-
98Assets/Prefabs/UI/RenamePopup.prefab
-
27Assets/Scenes/mainScene.unity
-
102Assets/Scripts/Game/GameManager.cs
-
32Assets/Scripts/Game/LobbyUser.cs
-
31Assets/Scripts/Game/LocalLobby.cs
-
25Assets/Scripts/Infrastructure/Messenger.cs
-
2Assets/Scripts/Infrastructure/Observed.cs
-
12Assets/Scripts/Lobby/LobbyAsyncRequests.cs
-
53Assets/Scripts/Lobby/LobbyContentHeartbeat.cs
-
4Assets/Scripts/Lobby/ToLocalLobby.cs
-
29Assets/Scripts/Relay/RelayUtpClient.cs
-
39Assets/Scripts/Relay/RelayUtpHost.cs
-
2Assets/Scripts/Relay/RelayUtpSetup.cs
-
1Assets/Scripts/Tests/PlayMode/UtpTests.cs
-
10Assets/Scripts/UI/CountdownUI.cs
-
3Assets/Scripts/UI/JoinCreateLobbyUI.cs
-
6Assets/Scripts/UI/JoinMenuUI.cs
-
35Assets/Scripts/Vivox/VivoxSetup.cs
-
472Assets/TextMesh Pro/Resources/Fonts & Materials/Roboto-Bold SDF.asset
-
8Packages/manifest.json
-
21Packages/packages-lock.json
-
6ProjectSettings/ProjectSettings.asset
-
4ProjectSettings/ProjectVersion.txt
-
66Assets/Scripts/Game/Countdown.cs
-
11Assets/Scripts/Game/Countdown.cs.meta
-
57Assets/Scripts/Relay/RelayPendingApproval.cs
-
11Assets/Scripts/Relay/RelayPendingApproval.cs.meta
988
Assets/Art/Font/CheckboxFLF SDF.asset
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
472
Assets/TextMesh Pro/Resources/Fonts & Materials/Roboto-Bold SDF.asset
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
m_EditorVersion: 2020.3.15f2 |
|||
m_EditorVersionWithRevision: 2020.3.15f2 (6cf78cb77498) |
|||
m_EditorVersion: 2020.3.20f1 |
|||
m_EditorVersionWithRevision: 2020.3.20f1 (41c4e627c95f) |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample |
|||
{ |
|||
/// <summary>
|
|||
/// Runs the countdown to the in-game state. While the start of the countdown is synced via Relay, the countdown itself is handled locally,
|
|||
/// since precise timing isn't necessary.
|
|||
/// </summary>
|
|||
[RequireComponent(typeof(UI.CountdownUI))] |
|||
public class Countdown : MonoBehaviour, IReceiveMessages |
|||
{ |
|||
public class Data : Observed<Countdown.Data> |
|||
{ |
|||
private float m_timeLeft; |
|||
public float TimeLeft |
|||
{ |
|||
get => m_timeLeft; |
|||
set |
|||
{ m_timeLeft = value; |
|||
OnChanged(this); |
|||
} |
|||
} |
|||
public override void CopyObserved(Data oldObserved) { /*No-op, since this is unnecessary.*/ } |
|||
} |
|||
|
|||
private Data m_data = new Data(); |
|||
private UI.CountdownUI m_ui; |
|||
private const int k_countdownTime = 4; |
|||
|
|||
public void OnEnable() |
|||
{ |
|||
if (m_ui == null) |
|||
m_ui = GetComponent<UI.CountdownUI>(); |
|||
m_data.TimeLeft = -1; |
|||
Locator.Get.Messenger.Subscribe(this); |
|||
m_ui.BeginObserving(m_data); |
|||
} |
|||
public void OnDisable() |
|||
{ |
|||
Locator.Get.Messenger.Unsubscribe(this); |
|||
m_ui.EndObserving(); |
|||
} |
|||
|
|||
public void OnReceiveMessage(MessageType type, object msg) |
|||
{ |
|||
if (type == MessageType.StartCountdown) |
|||
{ |
|||
m_data.TimeLeft = k_countdownTime; |
|||
} |
|||
else if (type == MessageType.CancelCountdown) |
|||
{ |
|||
m_data.TimeLeft = -1; |
|||
} |
|||
} |
|||
|
|||
public void Update() |
|||
{ |
|||
if (m_data.TimeLeft < 0) |
|||
return; |
|||
m_data.TimeLeft -= Time.deltaTime; |
|||
if (m_data.TimeLeft < 0) |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.CompleteCountdown, null); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d125c6cac111c6442ac5b07a1f313fa4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.Networking.Transport; |
|||
|
|||
namespace LobbyRelaySample.relay |
|||
{ |
|||
/// <summary>
|
|||
/// The Relay host doesn't need to know what might approve or disapprove of a pending connection, so this will
|
|||
/// broadcast a message that approval is being sought, and if nothing disapproves, the connection will be permitted.
|
|||
/// </summary>
|
|||
public class RelayPendingApproval : IDisposable |
|||
{ |
|||
private NetworkConnection m_pendingConnection; |
|||
private bool m_hasDisposed = false; |
|||
private const float k_waitTime = 0.1f; |
|||
private Action<NetworkConnection, Approval> m_onResult; |
|||
public string ID { get; private set; } |
|||
|
|||
public RelayPendingApproval(NetworkConnection conn, Action<NetworkConnection, Approval> onResult, string id) |
|||
{ |
|||
m_pendingConnection = conn; |
|||
m_onResult = onResult; |
|||
ID = id; |
|||
Locator.Get.UpdateSlow.Subscribe(Approve, k_waitTime); |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.ClientUserSeekingDisapproval, (Action<Approval>)Disapprove); |
|||
} |
|||
~RelayPendingApproval() { Dispose(); } |
|||
|
|||
private void Approve(float unused) |
|||
{ |
|||
try |
|||
{ m_onResult?.Invoke(m_pendingConnection, Approval.OK); |
|||
} |
|||
finally |
|||
{ Dispose(); |
|||
} |
|||
} |
|||
|
|||
public void Disapprove(Approval reason) |
|||
{ |
|||
try |
|||
{ m_onResult?.Invoke(m_pendingConnection, reason); |
|||
} |
|||
finally |
|||
{ Dispose(); |
|||
} |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
if (!m_hasDisposed) |
|||
{ |
|||
Locator.Get.UpdateSlow.Unsubscribe(Approve); |
|||
m_hasDisposed = true; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dbd38eacd3a3f464d8a9a1b69efe37db |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue