浏览代码
Completing the game state shift from lobby to relay. This adjusts the countdown to be interruptible and to properly handle exiting the game and restarting it. I'm also starting to trim a bit from the GameStateManager and the main scene, though most of that is pending.
/main/staging
Completing the game state shift from lobby to relay. This adjusts the countdown to be interruptible and to properly handle exiting the game and restarting it. I'm also starting to trim a bit from the GameStateManager and the main scene, though most of that is pending.
/main/staging
nathaniel.buck@unity3d.com
3 年前
当前提交
90d3890c
共有 21 个文件被更改,包括 342 次插入 和 679 次删除
-
47Assets/Prefabs/UI/GameCanvas.prefab
-
32Assets/Prefabs/UI/LobbyGameCanvas.prefab
-
194Assets/Prefabs/UI/PlayerInteractionPanel.prefab
-
109Assets/Scenes/mainScene.unity
-
126Assets/Scripts/Entities/GameStateManager.cs
-
14Assets/Scripts/Entities/LocalLobby.cs
-
8Assets/Scripts/Infrastructure/Messenger.cs
-
6Assets/Scripts/Infrastructure/ObserverBehaviour.cs
-
19Assets/Scripts/Lobby/LobbyContentHeartbeat.cs
-
2Assets/Scripts/Lobby/ToLocalLobby.cs
-
22Assets/Scripts/Relay/RelayUtpClient.cs
-
68Assets/Scripts/Relay/RelayUtpHost.cs
-
2Assets/Scripts/Relay/RelayUtpSetup.cs
-
12Assets/Scripts/UI/CountdownUI.cs
-
2Assets/Scripts/UI/EndGameButtonUI.cs
-
2Assets/Scripts/UI/InLobbyUserUI.cs
-
2Assets/Scripts/UI/ReadyCheckUI.cs
-
273Assets/Prefabs/UI/CountDownUI.prefab
-
7Assets/Prefabs/UI/CountDownUI.prefab.meta
-
63Assets/Scripts/Lobby/ReadyCheck.cs
-
11Assets/Scripts/Lobby/ReadyCheck.cs.meta
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &5694388898566309151 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 2473738857440996537} |
|||
- component: {fileID: 9125082141416656856} |
|||
- component: {fileID: 288221731430065532} |
|||
- component: {fileID: 1604604243888226905} |
|||
- component: {fileID: 1102405501498744344} |
|||
- component: {fileID: 3702758058023689559} |
|||
m_Layer: 5 |
|||
m_Name: CountDownUI |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &2473738857440996537 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_ConstrainProportionsScale: 0 |
|||
m_Children: |
|||
- {fileID: 2508362878409625140} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0} |
|||
m_AnchorMax: {x: 1, y: 1} |
|||
m_AnchoredPosition: {x: 0, y: -77.436} |
|||
m_SizeDelta: {x: -50, y: -404.7342} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!222 &9125082141416656856 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &288221731430065532 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 5b3b588e7ae40ec4ca35fdb9404513ab, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_onVisibilityChange: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
showing: 0 |
|||
m_CountDownText: {fileID: 6871324529924300226} |
|||
--- !u!114 &1604604243888226905 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: f38cf340acfcd4c64a6968b7386ad570, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_onVisibilityChange: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
showing: 0 |
|||
m_ShowThisWhen: 2 |
|||
--- !u!114 &1102405501498744344 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 70dfc2fde0a9ef04eaff29a138f0bf45, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
OnObservedUpdated: |
|||
m_PersistentCalls: |
|||
m_Calls: |
|||
- m_Target: {fileID: 288221731430065532} |
|||
m_TargetAssemblyTypeName: CountdownUI, LobbyRooms |
|||
m_MethodName: ObservedUpdated |
|||
m_Mode: 0 |
|||
m_Arguments: |
|||
m_ObjectArgument: {fileID: 0} |
|||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine |
|||
m_IntArgument: 0 |
|||
m_FloatArgument: 0 |
|||
m_StringArgument: |
|||
m_BoolArgument: 0 |
|||
m_CallState: 2 |
|||
- m_Target: {fileID: 1604604243888226905} |
|||
m_TargetAssemblyTypeName: LobbyRooms.UI.LobbyStateVisibilityUI, LobbyRooms |
|||
m_MethodName: ObservedUpdated |
|||
m_Mode: 0 |
|||
m_Arguments: |
|||
m_ObjectArgument: {fileID: 0} |
|||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine |
|||
m_IntArgument: 0 |
|||
m_FloatArgument: 0 |
|||
m_StringArgument: |
|||
m_BoolArgument: 0 |
|||
m_CallState: 2 |
|||
observeOnStart: 0 |
|||
--- !u!225 &3702758058023689559 |
|||
CanvasGroup: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5694388898566309151} |
|||
m_Enabled: 1 |
|||
m_Alpha: 1 |
|||
m_Interactable: 1 |
|||
m_BlocksRaycasts: 1 |
|||
m_IgnoreParentGroups: 0 |
|||
--- !u!1 &6120000553027287259 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 2508362878409625140} |
|||
- component: {fileID: 3642688559417843241} |
|||
- component: {fileID: 6871324529924300226} |
|||
m_Layer: 5 |
|||
m_Name: CountdownText |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!224 &2508362878409625140 |
|||
RectTransform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6120000553027287259} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_ConstrainProportionsScale: 0 |
|||
m_Children: [] |
|||
m_Father: {fileID: 2473738857440996537} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
m_AnchorMin: {x: 0, y: 0} |
|||
m_AnchorMax: {x: 1, y: 1} |
|||
m_AnchoredPosition: {x: 0, y: 0} |
|||
m_SizeDelta: {x: 0, y: 0} |
|||
m_Pivot: {x: 0.5, y: 0.5} |
|||
--- !u!222 &3642688559417843241 |
|||
CanvasRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6120000553027287259} |
|||
m_CullTransparentMesh: 1 |
|||
--- !u!114 &6871324529924300226 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6120000553027287259} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_Material: {fileID: 0} |
|||
m_Color: {r: 1, g: 1, b: 1, a: 1} |
|||
m_RaycastTarget: 1 |
|||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} |
|||
m_Maskable: 1 |
|||
m_OnCullStateChanged: |
|||
m_PersistentCalls: |
|||
m_Calls: [] |
|||
m_text: 'Starting in:' |
|||
m_isRightToLeft: 0 |
|||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} |
|||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} |
|||
m_fontSharedMaterials: [] |
|||
m_fontMaterial: {fileID: 0} |
|||
m_fontMaterials: [] |
|||
m_fontColor32: |
|||
serializedVersion: 2 |
|||
rgba: 4294967295 |
|||
m_fontColor: {r: 1, g: 1, b: 1, a: 1} |
|||
m_enableVertexGradient: 0 |
|||
m_colorMode: 3 |
|||
m_fontColorGradient: |
|||
topLeft: {r: 1, g: 1, b: 1, a: 1} |
|||
topRight: {r: 1, g: 1, b: 1, a: 1} |
|||
bottomLeft: {r: 1, g: 1, b: 1, a: 1} |
|||
bottomRight: {r: 1, g: 1, b: 1, a: 1} |
|||
m_fontColorGradientPreset: {fileID: 0} |
|||
m_spriteAsset: {fileID: 0} |
|||
m_tintAllSprites: 0 |
|||
m_StyleSheet: {fileID: 0} |
|||
m_TextStyleHashCode: -1183493901 |
|||
m_overrideHtmlColors: 0 |
|||
m_faceColor: |
|||
serializedVersion: 2 |
|||
rgba: 4294967295 |
|||
m_fontSize: 21 |
|||
m_fontSizeBase: 36 |
|||
m_fontWeight: 400 |
|||
m_enableAutoSizing: 1 |
|||
m_fontSizeMin: 18 |
|||
m_fontSizeMax: 21 |
|||
m_fontStyle: 0 |
|||
m_HorizontalAlignment: 1 |
|||
m_VerticalAlignment: 512 |
|||
m_textAlignment: 65535 |
|||
m_characterSpacing: 0 |
|||
m_wordSpacing: 0 |
|||
m_lineSpacing: 0 |
|||
m_lineSpacingMax: 0 |
|||
m_paragraphSpacing: 0 |
|||
m_charWidthMaxAdj: 0 |
|||
m_enableWordWrapping: 1 |
|||
m_wordWrappingRatios: 0.4 |
|||
m_overflowMode: 0 |
|||
m_linkedTextComponent: {fileID: 0} |
|||
parentLinkedComponent: {fileID: 0} |
|||
m_enableKerning: 1 |
|||
m_enableExtraPadding: 0 |
|||
checkPaddingRequired: 0 |
|||
m_isRichText: 1 |
|||
m_parseCtrlCharacters: 1 |
|||
m_isOrthographic: 1 |
|||
m_isCullingEnabled: 0 |
|||
m_horizontalMapping: 0 |
|||
m_verticalMapping: 0 |
|||
m_uvLineOffset: 0 |
|||
m_geometrySortingOrder: 0 |
|||
m_IsTextObjectScaleStatic: 0 |
|||
m_VertexBufferAutoSizeReduction: 0 |
|||
m_useMaxVisibleDescender: 1 |
|||
m_pageToDisplay: 1 |
|||
m_margin: {x: 5, y: 5, z: 5, w: 5} |
|||
m_isUsingLegacyAnimationComponent: 0 |
|||
m_isVolumetricText: 0 |
|||
m_hasFontAssetChanged: 0 |
|||
m_baseMaterial: {fileID: 0} |
|||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: f90e4035352c7ce40b68e50109a9bb4f |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
namespace LobbyRelaySample |
|||
{ |
|||
/// <summary>
|
|||
/// On the host, this will watch for all players to ready, and once they have, it will prepare for a synchronized countdown.
|
|||
/// </summary>
|
|||
public class ReadyCheck : IDisposable |
|||
{ |
|||
float m_ReadyTime = 5; |
|||
|
|||
public ReadyCheck(float readyTime = 5) |
|||
{ |
|||
m_ReadyTime = readyTime; |
|||
} |
|||
|
|||
public void BeginCheckingForReady() |
|||
{ |
|||
Locator.Get.UpdateSlow.Subscribe(OnUpdate); |
|||
} |
|||
|
|||
public void EndCheckingForReady() |
|||
{ |
|||
Locator.Get.UpdateSlow.Unsubscribe(OnUpdate); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Checks the lobby to see if we have all Readied up. If so, send out a message with the target time at which to end a countdown.
|
|||
/// </summary>
|
|||
void OnUpdate(float dt) |
|||
{ |
|||
var lobby = LobbyAsyncRequests.Instance.CurrentLobby; |
|||
if (lobby == null || lobby.Players.Count == 0) |
|||
return; |
|||
|
|||
int readyCount = lobby.Players.Count((p) => |
|||
{ |
|||
if (p.Data?.ContainsKey("UserStatus") != true) // Needs to be "!= true" to handle null properly.
|
|||
return false; |
|||
UserStatus status; |
|||
if (Enum.TryParse(p.Data["UserStatus"].Value, out status)) |
|||
return status == UserStatus.Ready; |
|||
return false; |
|||
}); |
|||
|
|||
if (readyCount == lobby.Players.Count) |
|||
{ |
|||
Dictionary<string, string> data = new Dictionary<string, string>(); |
|||
DateTime targetTime = DateTime.Now.AddSeconds(m_ReadyTime); |
|||
data.Add("AllPlayersReady", targetTime.Ticks.ToString()); |
|||
LobbyAsyncRequests.Instance.UpdateLobbyDataAsync(data, null); |
|||
EndCheckingForReady(); |
|||
} |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
EndCheckingForReady(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c16ed59d99a3d22468478da00327e666 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue