浏览代码
Initial network behavior - When entering the InGame state, players will disable menu components and the host will spawn networked objects for the symbols. They can move with Rigidbody physics for all players. Returning to the menu cleans up. Note that this currently only works with a local network connection.
/main/staging/ngo_minigame_structure
Initial network behavior - When entering the InGame state, players will disable menu components and the host will spawn networked objects for the symbols. They can move with Rigidbody physics for all players. Returning to the menu cleans up. Note that this currently only works with a local network connection.
/main/staging/ngo_minigame_structure
nathaniel.buck@unity3d.com
3 年前
当前提交
5f41201b
共有 27 个文件被更改,包括 1335 次插入 和 52 次删除
-
115Assets/Prefabs/GameManager.prefab
-
73Assets/Scenes/mainScene.unity
-
3Assets/Scripts/Game/ServerAddress.cs
-
1Assets/Scripts/Infrastructure/Messenger.cs
-
4Assets/Scripts/LobbyRelaySample.asmdef
-
31Packages/packages-lock.json
-
73ProjectSettings/DynamicsManager.asset
-
8Assets/Prefabs/InGame.meta
-
8Assets/Scripts/Game/InGame.meta
-
273Assets/Prefabs/InGame/InGameLogic.prefab
-
7Assets/Prefabs/InGame/InGameLogic.prefab.meta
-
216Assets/Prefabs/InGame/SymbolContainer.prefab
-
7Assets/Prefabs/InGame/SymbolContainer.prefab.meta
-
19Assets/Prefabs/InGame/SymbolData.asset
-
8Assets/Prefabs/InGame/SymbolData.asset.meta
-
187Assets/Prefabs/InGame/SymbolObject.prefab
-
7Assets/Prefabs/InGame/SymbolObject.prefab.meta
-
126Assets/Scripts/Game/InGame/InGameRunner.cs
-
11Assets/Scripts/Game/InGame/InGameRunner.cs.meta
-
134Assets/Scripts/Game/InGame/SetupInGame.cs
-
11Assets/Scripts/Game/InGame/SetupInGame.cs.meta
-
25Assets/Scripts/Game/InGame/SymbolContainer.cs
-
11Assets/Scripts/Game/InGame/SymbolContainer.cs.meta
-
18Assets/Scripts/Game/InGame/SymbolData.cs
-
11Assets/Scripts/Game/InGame/SymbolData.cs.meta
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!55 &1 |
|||
PhysicsManager: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 13 |
|||
m_Gravity: {x: 0, y: -9.81, z: 0} |
|||
m_DefaultMaterial: {fileID: 0} |
|||
m_BounceThreshold: 2 |
|||
m_SleepThreshold: 0.005 |
|||
m_DefaultContactOffset: 0.01 |
|||
m_DefaultSolverIterations: 6 |
|||
m_DefaultSolverVelocityIterations: 1 |
|||
m_QueriesHitBackfaces: 0 |
|||
m_QueriesHitTriggers: 1 |
|||
m_EnableAdaptiveForce: 0 |
|||
m_ClothInterCollisionDistance: 0.1 |
|||
m_ClothInterCollisionStiffness: 0.2 |
|||
m_ContactsGeneration: 1 |
|||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
|||
m_AutoSimulation: 1 |
|||
m_AutoSyncTransforms: 0 |
|||
m_ReuseCollisionCallbacks: 1 |
|||
m_ClothInterCollisionSettingsToggle: 0 |
|||
m_ClothGravity: {x: 0, y: -9.81, z: 0} |
|||
m_ContactPairsMode: 0 |
|||
m_BroadphaseType: 0 |
|||
m_WorldBounds: |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
m_Extent: {x: 250, y: 250, z: 250} |
|||
m_WorldSubdivisions: 8 |
|||
m_FrictionType: 0 |
|||
m_EnableEnhancedDeterminism: 0 |
|||
m_EnableUnifiedHeightmaps: 1 |
|||
m_SolverType: 0 |
|||
m_DefaultMaxAngularSpeed: 50 |
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!55 &1 |
|||
PhysicsManager: |
|||
m_ObjectHideFlags: 0 |
|||
serializedVersion: 13 |
|||
m_Gravity: {x: 0, y: 0, z: 0} |
|||
m_DefaultMaterial: {fileID: 0} |
|||
m_BounceThreshold: 2 |
|||
m_DefaultMaxDepenetrationVelocity: 10 |
|||
m_SleepThreshold: 0.005 |
|||
m_DefaultContactOffset: 0.01 |
|||
m_DefaultSolverIterations: 6 |
|||
m_DefaultSolverVelocityIterations: 1 |
|||
m_QueriesHitBackfaces: 0 |
|||
m_QueriesHitTriggers: 1 |
|||
m_EnableAdaptiveForce: 0 |
|||
m_ClothInterCollisionDistance: 0.1 |
|||
m_ClothInterCollisionStiffness: 0.2 |
|||
m_ContactsGeneration: 1 |
|||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
|||
m_AutoSimulation: 1 |
|||
m_AutoSyncTransforms: 0 |
|||
m_ReuseCollisionCallbacks: 1 |
|||
m_ClothInterCollisionSettingsToggle: 0 |
|||
m_ClothGravity: {x: 0, y: -9.81, z: 0} |
|||
m_ContactPairsMode: 0 |
|||
m_BroadphaseType: 0 |
|||
m_WorldBounds: |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
m_Extent: {x: 250, y: 250, z: 250} |
|||
m_WorldSubdivisions: 8 |
|||
m_FrictionType: 0 |
|||
m_EnableEnhancedDeterminism: 0 |
|||
m_EnableUnifiedHeightmaps: 1 |
|||
m_SolverType: 0 |
|||
m_DefaultMaxAngularSpeed: 50 |
|
|||
fileFormatVersion: 2 |
|||
guid: 3a0d1ac78c0fde0439b99a6a5bb4e4b4 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: f43593fb271f15b408f35b25f4fb10ee |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &238192747445020667 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 485451675458297819} |
|||
m_Layer: 0 |
|||
m_Name: InGameLogic |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &485451675458297819 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 238192747445020667} |
|||
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_Children: |
|||
- {fileID: 7668134686248305871} |
|||
- {fileID: 6532331214593598572} |
|||
- {fileID: 5289034077109495657} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!1 &421060454917747513 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 6532331214593598572} |
|||
- component: {fileID: 8873025738981341763} |
|||
m_Layer: 0 |
|||
m_Name: InGameCamera |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &6532331214593598572 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 421060454917747513} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: -10} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 485451675458297819} |
|||
m_RootOrder: 1 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!20 &8873025738981341763 |
|||
Camera: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 421060454917747513} |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_ClearFlags: 2 |
|||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} |
|||
m_projectionMatrixMode: 1 |
|||
m_GateFitMode: 2 |
|||
m_FOVAxisMode: 0 |
|||
m_SensorSize: {x: 36, y: 24} |
|||
m_LensShift: {x: 0, y: 0} |
|||
m_FocalLength: 50 |
|||
m_NormalizedViewPortRect: |
|||
serializedVersion: 2 |
|||
x: 0 |
|||
y: 0 |
|||
width: 1 |
|||
height: 1 |
|||
near clip plane: 0.3 |
|||
far clip plane: 1000 |
|||
field of view: 60 |
|||
orthographic: 0 |
|||
orthographic size: 5 |
|||
m_Depth: 0 |
|||
m_CullingMask: |
|||
serializedVersion: 2 |
|||
m_Bits: 4294967295 |
|||
m_RenderingPath: -1 |
|||
m_TargetTexture: {fileID: 0} |
|||
m_TargetDisplay: 0 |
|||
m_TargetEye: 3 |
|||
m_HDR: 1 |
|||
m_AllowMSAA: 1 |
|||
m_AllowDynamicResolution: 0 |
|||
m_ForceIntoRT: 0 |
|||
m_OcclusionCulling: 1 |
|||
m_StereoConvergence: 10 |
|||
m_StereoSeparation: 0.022 |
|||
--- !u!1 &1306704497370578788 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 5289034077109495657} |
|||
- component: {fileID: 8928417086886337167} |
|||
- component: {fileID: 6673480979101889538} |
|||
m_Layer: 0 |
|||
m_Name: InGameRunner |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &5289034077109495657 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1306704497370578788} |
|||
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_Children: [] |
|||
m_Father: {fileID: 485451675458297819} |
|||
m_RootOrder: 2 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &8928417086886337167 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1306704497370578788} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
GlobalObjectIdHash: 951099334 |
|||
AlwaysReplicateAsRoot: 0 |
|||
DontDestroyWithOwner: 0 |
|||
AutoObjectParentSync: 1 |
|||
--- !u!114 &6673480979101889538 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 1306704497370578788} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: e30fcbc5a3738e94a87d7a028a2a6fba, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_playerCursorPrefab: {fileID: -1321688216342888635, guid: 905594b4ee5bb864a84af916cc445d1b, type: 3} |
|||
m_symbolContainerPrefab: {fileID: 3984715711634906321, guid: f42ed38d10b57ec48870f76a7a63389e, type: 3} |
|||
m_symbolObjectPrefab: {fileID: 1734492152380024498, guid: e371ca3112f9e244ab574b472387b64b, type: 3} |
|||
--- !u!1 &9019482255774987314 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 7668134686248305871} |
|||
- component: {fileID: 4557534325444114211} |
|||
- component: {fileID: 5194253823978692452} |
|||
m_Layer: 0 |
|||
m_Name: NGONetworkManager |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &7668134686248305871 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 9019482255774987314} |
|||
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_Children: [] |
|||
m_Father: {fileID: 485451675458297819} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &4557534325444114211 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 9019482255774987314} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
DontDestroy: 0 |
|||
RunInBackground: 0 |
|||
LogLevel: 1 |
|||
NetworkConfig: |
|||
ProtocolVersion: 0 |
|||
NetworkTransport: {fileID: 5194253823978692452} |
|||
PlayerPrefab: {fileID: 0} |
|||
NetworkPrefabs: |
|||
- Override: 0 |
|||
Prefab: {fileID: 3227847727972158006, guid: 905594b4ee5bb864a84af916cc445d1b, type: 3} |
|||
SourcePrefabToOverride: {fileID: 0} |
|||
SourceHashToOverride: 0 |
|||
OverridingTargetPrefab: {fileID: 0} |
|||
- Override: 0 |
|||
Prefab: {fileID: 5240148789413552765, guid: f42ed38d10b57ec48870f76a7a63389e, type: 3} |
|||
SourcePrefabToOverride: {fileID: 0} |
|||
SourceHashToOverride: 0 |
|||
OverridingTargetPrefab: {fileID: 0} |
|||
- Override: 0 |
|||
Prefab: {fileID: 8828823320646980938, guid: e371ca3112f9e244ab574b472387b64b, type: 3} |
|||
SourcePrefabToOverride: {fileID: 0} |
|||
SourceHashToOverride: 0 |
|||
OverridingTargetPrefab: {fileID: 0} |
|||
TickRate: 30 |
|||
ClientConnectionBufferTimeout: 10 |
|||
ConnectionApproval: 0 |
|||
ConnectionData: |
|||
EnableTimeResync: 0 |
|||
TimeResyncInterval: 30 |
|||
EnsureNetworkVariableLengthSafety: 0 |
|||
EnableSceneManagement: 1 |
|||
ForceSamePrefabs: 1 |
|||
RecycleNetworkIds: 1 |
|||
NetworkIdRecycleDelay: 120 |
|||
RpcHashSize: 0 |
|||
LoadSceneTimeOut: 120 |
|||
MessageBufferTimeout: 20 |
|||
EnableNetworkLogs: 1 |
|||
--- !u!114 &5194253823978692452 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 9019482255774987314} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 6960e84d07fb87f47956e7a81d71c4e6, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
m_ProtocolType: 0 |
|||
m_MaximumPacketSize: 1400 |
|||
m_MaxPacketQueueSize: 128 |
|||
m_SendQueueBatchSize: 6144 |
|||
ConnectionData: |
|||
Address: 127.0.0.1 |
|||
Port: 7777 |
|
|||
fileFormatVersion: 2 |
|||
guid: 73173c97c128d614aa2a1167a2eaea68 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &5240148789413552765 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 3305037517699072277} |
|||
- component: {fileID: 3984715711634906321} |
|||
- component: {fileID: 6367926983050135602} |
|||
- component: {fileID: 2974066117406568032} |
|||
- component: {fileID: 2302923454152093614} |
|||
- component: {fileID: 210836793418873202} |
|||
- component: {fileID: -8143583295587582139} |
|||
m_Layer: 0 |
|||
m_Name: SymbolContainer |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &3305037517699072277 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
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_Children: |
|||
- {fileID: 4682315930965214729} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &3984715711634906321 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
GlobalObjectIdHash: 951099334 |
|||
AlwaysReplicateAsRoot: 0 |
|||
DontDestroyWithOwner: 0 |
|||
AutoObjectParentSync: 1 |
|||
--- !u!54 &6367926983050135602 |
|||
Rigidbody: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
serializedVersion: 2 |
|||
m_Mass: 1 |
|||
m_Drag: 0 |
|||
m_AngularDrag: 0.05 |
|||
m_UseGravity: 1 |
|||
m_IsKinematic: 0 |
|||
m_Interpolate: 0 |
|||
m_Constraints: 120 |
|||
m_CollisionDetection: 0 |
|||
--- !u!114 &2974066117406568032 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
SyncPositionX: 1 |
|||
SyncPositionY: 1 |
|||
SyncPositionZ: 1 |
|||
SyncRotAngleX: 1 |
|||
SyncRotAngleY: 1 |
|||
SyncRotAngleZ: 1 |
|||
SyncScaleX: 1 |
|||
SyncScaleY: 1 |
|||
SyncScaleZ: 1 |
|||
PositionThreshold: 0.001 |
|||
RotAngleThreshold: 0.01 |
|||
ScaleThreshold: 0.01 |
|||
InLocalSpace: 0 |
|||
Interpolate: 1 |
|||
CanCommitToTransform: 0 |
|||
--- !u!114 &2302923454152093614 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: f6c0be61502bb534f922ebb746851216, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
--- !u!114 &210836793418873202 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 73a6c5df5c3139e448d76f8918fece73, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
--- !u!65 &-8143583295587582139 |
|||
BoxCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 5240148789413552765} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 1 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Size: {x: 1, y: 1, z: 1} |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
--- !u!1 &6633045103840132799 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 4682315930965214729} |
|||
- component: {fileID: 1714068474508632102} |
|||
- component: {fileID: 7391847843263227954} |
|||
m_Layer: 0 |
|||
m_Name: TempVisual |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &4682315930965214729 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6633045103840132799} |
|||
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_Children: [] |
|||
m_Father: {fileID: 3305037517699072277} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!33 &1714068474508632102 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6633045103840132799} |
|||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &7391847843263227954 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 6633045103840132799} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RayTraceProcedural: 0 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 0} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
m_AdditionalVertexStreams: {fileID: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: f42ed38d10b57ec48870f76a7a63389e |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 26062727ed87bcc439ec8f0f86354a51, type: 3} |
|||
m_Name: SymbolData |
|||
m_EditorClassIdentifier: |
|||
m_availableSymbols: |
|||
- {fileID: 21300000, guid: f18a89c12a346a8488ed507a0bd79d2e, type: 3} |
|||
- {fileID: 21300000, guid: 7236d49fc9649dc44a67849a94ab3969, type: 3} |
|||
- {fileID: 21300000, guid: bc8c0e2bc04ce93488efe4ea898047a9, type: 3} |
|||
- {fileID: 21300000, guid: 0fca28892f34375439c32b1ee1c8d655, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: 84a81a2f14d442a49b46eccefb73933f |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &3226722501078289267 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 2207893811600523791} |
|||
- component: {fileID: 6202594079177850961} |
|||
- component: {fileID: 8777844193165894662} |
|||
- component: {fileID: 1572105415912633256} |
|||
m_Layer: 0 |
|||
m_Name: Visual |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &2207893811600523791 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3226722501078289267} |
|||
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_Children: [] |
|||
m_Father: {fileID: 4221838266206954178} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!33 &6202594079177850961 |
|||
MeshFilter: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3226722501078289267} |
|||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} |
|||
--- !u!23 &8777844193165894662 |
|||
MeshRenderer: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3226722501078289267} |
|||
m_Enabled: 1 |
|||
m_CastShadows: 1 |
|||
m_ReceiveShadows: 1 |
|||
m_DynamicOccludee: 1 |
|||
m_MotionVectors: 1 |
|||
m_LightProbeUsage: 1 |
|||
m_ReflectionProbeUsage: 1 |
|||
m_RayTracingMode: 2 |
|||
m_RayTraceProcedural: 0 |
|||
m_RenderingLayerMask: 1 |
|||
m_RendererPriority: 0 |
|||
m_Materials: |
|||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} |
|||
m_StaticBatchInfo: |
|||
firstSubMesh: 0 |
|||
subMeshCount: 0 |
|||
m_StaticBatchRoot: {fileID: 0} |
|||
m_ProbeAnchor: {fileID: 0} |
|||
m_LightProbeVolumeOverride: {fileID: 0} |
|||
m_ScaleInLightmap: 1 |
|||
m_ReceiveGI: 1 |
|||
m_PreserveUVs: 0 |
|||
m_IgnoreNormalsForChartDetection: 0 |
|||
m_ImportantGI: 0 |
|||
m_StitchLightmapSeams: 1 |
|||
m_SelectedEditorRenderState: 3 |
|||
m_MinimumChartSize: 4 |
|||
m_AutoUVMaxDistance: 0.5 |
|||
m_AutoUVMaxAngle: 89 |
|||
m_LightmapParameters: {fileID: 0} |
|||
m_SortingLayerID: 0 |
|||
m_SortingLayer: 0 |
|||
m_SortingOrder: 0 |
|||
m_AdditionalVertexStreams: {fileID: 0} |
|||
--- !u!135 &1572105415912633256 |
|||
SphereCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3226722501078289267} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 0 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Radius: 0.5 |
|||
m_Center: {x: 0, y: 0, z: 0} |
|||
--- !u!1 &8828823320646980938 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 4221838266206954178} |
|||
- component: {fileID: 1734492152380024498} |
|||
- component: {fileID: 2622345469831693260} |
|||
- component: {fileID: 1363360377255918887} |
|||
m_Layer: 0 |
|||
m_Name: SymbolObject |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &4221838266206954178 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8828823320646980938} |
|||
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_Children: |
|||
- {fileID: 2207893811600523791} |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!114 &1734492152380024498 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8828823320646980938} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
GlobalObjectIdHash: 951099334 |
|||
AlwaysReplicateAsRoot: 0 |
|||
DontDestroyWithOwner: 0 |
|||
AutoObjectParentSync: 1 |
|||
--- !u!114 &2622345469831693260 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8828823320646980938} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: e96cb6065543e43c4a752faaa1468eb1, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|||
SyncPositionX: 1 |
|||
SyncPositionY: 1 |
|||
SyncPositionZ: 1 |
|||
SyncRotAngleX: 1 |
|||
SyncRotAngleY: 1 |
|||
SyncRotAngleZ: 1 |
|||
SyncScaleX: 1 |
|||
SyncScaleY: 1 |
|||
SyncScaleZ: 1 |
|||
PositionThreshold: 0.001 |
|||
RotAngleThreshold: 0.01 |
|||
ScaleThreshold: 0.01 |
|||
InLocalSpace: 0 |
|||
Interpolate: 1 |
|||
CanCommitToTransform: 0 |
|||
--- !u!65 &1363360377255918887 |
|||
BoxCollider: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 8828823320646980938} |
|||
m_Material: {fileID: 0} |
|||
m_IsTrigger: 1 |
|||
m_Enabled: 1 |
|||
serializedVersion: 2 |
|||
m_Size: {x: 1, y: 1, z: 1} |
|||
m_Center: {x: 0, y: 0, z: 0} |
|
|||
fileFormatVersion: 2 |
|||
guid: e371ca3112f9e244ab574b472387b64b |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.Netcode; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample.inGame |
|||
{ |
|||
/// <summary>
|
|||
/// Once the NetworkManager has been spawned, we need something to manage the game state and setup other in-game objects
|
|||
/// that is itself a networked object, to track things like network connect events.
|
|||
/// </summary>
|
|||
public class InGameRunner : NetworkBehaviour |
|||
{ |
|||
private Action m_onConnectionVerified; |
|||
private int m_expectedPlayerCount; // Used by the host, but we can't call the RPC until the network connection completes.
|
|||
private bool m_canSpawnInGameObjects; |
|||
private const int k_symbolCount = 100; |
|||
private Queue<Vector2> m_pendingSymbolPositions = new Queue<Vector2>(); |
|||
|
|||
[SerializeField] private NetworkObject m_playerCursorPrefab; |
|||
[SerializeField] private NetworkObject m_symbolContainerPrefab; |
|||
private Transform m_symbolContainerInstance; |
|||
[SerializeField] private NetworkObject m_symbolObjectPrefab; |
|||
|
|||
private NetworkList<ulong> m_connectedPlayerIds; |
|||
|
|||
public void Initialize(Action onConnectionVerified, int expectedPlayerCount) |
|||
{ |
|||
m_onConnectionVerified = onConnectionVerified; |
|||
m_expectedPlayerCount = expectedPlayerCount; |
|||
m_canSpawnInGameObjects = false; |
|||
} |
|||
|
|||
public override void OnNetworkSpawn() |
|||
{ |
|||
if (IsHost) |
|||
FinishInitialize(); |
|||
VerifyConnection_ServerRpc(OwnerClientId); |
|||
} |
|||
|
|||
public override void OnNetworkDespawn() |
|||
{ |
|||
// This will be where to do full clean up?
|
|||
UnityEngine.Debug.LogError("InGameRunner despawn"); |
|||
} |
|||
|
|||
private void FinishInitialize() |
|||
{ |
|||
if (m_connectedPlayerIds != null) |
|||
m_connectedPlayerIds.Clear(); |
|||
else |
|||
m_connectedPlayerIds = new NetworkList<ulong>(); |
|||
m_symbolContainerInstance = NetworkObject.Instantiate(m_symbolContainerPrefab).transform; |
|||
ResetPendingSymbolPositions(); |
|||
} |
|||
|
|||
private void ResetPendingSymbolPositions() |
|||
{ |
|||
m_pendingSymbolPositions.Clear(); |
|||
for (int n = 0; n < k_symbolCount; n++) |
|||
{ |
|||
// TEMP we need to do a BSP or some such to mix up the positions.
|
|||
m_pendingSymbolPositions.Enqueue(new Vector2(-9 + (n % 10) * 2, n / 10 * 3)); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// To verify the connection, invoke a server RPC call that then invokes a client RPC call.
|
|||
/// </summary>
|
|||
[ServerRpc(RequireOwnership = false)] |
|||
private void VerifyConnection_ServerRpc(ulong clientId) |
|||
{ |
|||
VerifyConnection_ClientRpc(clientId); |
|||
|
|||
// If not spawning things in the background, start that.
|
|||
m_canSpawnInGameObjects = true; |
|||
} |
|||
[ClientRpc] |
|||
private void VerifyConnection_ClientRpc(ulong clientId) |
|||
{ |
|||
if (clientId == OwnerClientId) |
|||
VerifyConnectionConfirm_ServerRpc(OwnerClientId); |
|||
} |
|||
/// <summary>
|
|||
/// Once the connection is confirmed, check if all players have connected.
|
|||
/// </summary>
|
|||
[ServerRpc(RequireOwnership = false)] |
|||
private void VerifyConnectionConfirm_ServerRpc(ulong clientId) |
|||
{ |
|||
if (!m_connectedPlayerIds.Contains(clientId)) |
|||
m_connectedPlayerIds.Add(clientId); |
|||
bool areAllPlayersConnected = m_connectedPlayerIds.Count >= m_expectedPlayerCount; // The game will begin at this point, or else there's a timeout for booting any unconnected players.
|
|||
VerifyConnectionConfirm_ClientRpc(clientId, areAllPlayersConnected); |
|||
} |
|||
[ClientRpc] |
|||
private void VerifyConnectionConfirm_ClientRpc(ulong clientId, bool shouldStartImmediately) |
|||
{ |
|||
if (clientId == OwnerClientId) |
|||
m_onConnectionVerified?.Invoke(); |
|||
if (shouldStartImmediately) |
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.GameBeginning, null); |
|||
} |
|||
|
|||
// TODO: BSP for choosing symbol spawn positions?
|
|||
// TODO: Remove the timer to test for packet loss.
|
|||
private float m_timer = 0.04f; // We'll want to space out the object spawning a little to reduce the risk of packet loss. It will happen in the background, so we have time.
|
|||
public void Update() |
|||
{ |
|||
if (!m_canSpawnInGameObjects || m_symbolContainerInstance?.childCount >= k_symbolCount || !IsHost) |
|||
return; |
|||
if (m_pendingSymbolPositions.Count > 0) |
|||
{ |
|||
m_timer -= Time.deltaTime; |
|||
if (m_timer < 0) |
|||
{ |
|||
m_timer = 0.04f; |
|||
Vector3 pendingPos = m_pendingSymbolPositions.Dequeue(); |
|||
NetworkObject symbolObj = NetworkObject.Instantiate(m_symbolObjectPrefab); |
|||
symbolObj.Spawn(); |
|||
symbolObj.TrySetParent(m_symbolContainerInstance, false); |
|||
symbolObj.transform.localPosition = pendingPos; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e30fcbc5a3738e94a87d7a028a2a6fba |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.Netcode; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample.inGame |
|||
{ |
|||
/// <summary>
|
|||
/// Once the local player is in a lobby and that lobby has entered the In-Game state, this will load in whatever is necessary to actually run the game part.
|
|||
/// This will exist in the game scene so that it can hold references to scene objects that spawned prefab instances will need.
|
|||
/// </summary>
|
|||
public class SetupInGame : MonoBehaviour, IReceiveMessages |
|||
{ |
|||
[SerializeField] private GameObject m_prefabNetworkManager = default; |
|||
[SerializeField] private LocalLobbyObserver m_lobbyObserver = default; |
|||
[SerializeField] private GameObject[] m_disableWhileInGame = default; |
|||
|
|||
private GameObject m_inGameManagerObj; |
|||
private NetworkManager m_networkManager; |
|||
private InGameObjectSpawner m_objectSpawner; |
|||
private InGameRunner m_inGameRunner; |
|||
private int m_playerCount; // The server will need to know this.
|
|||
|
|||
private bool m_isHost; |
|||
private bool m_doesNeedCleanup = false; |
|||
|
|||
// TEMP? Relay stuff
|
|||
private ServerAddress m_serverAddress; |
|||
private Action<UnityTransport> m_initializeTransport; |
|||
|
|||
|
|||
/* |
|||
* Things to do: |
|||
* |
|||
* x Disable whatever menu behaviors. Maintain a back button with additional RPC calls? |
|||
* --- Need to make RelayUtpClient not an MB so I can freely disable the menus? It is on the GameManager, as it happens, but... |
|||
* x Spawn the object with the NetworkManager and allow that to connect. |
|||
* - Wait for all players to connect, or boot a player after a few seconds (via Relay) if they did not connect. |
|||
* - While waiting, server selects the target sequence, spawns the symbol container, and starts pooling/spawning the symbol objects. |
|||
* - Once all players are in, show the target sequence and instructions, and then the server starts moving the symbol container and listening to click events. |
|||
* - After the symbols are all passed (I guess tracking the symbol container position or a timeout), finish the game (set the winner flag). |
|||
* x Clients clean up and return to the lobby screen. Host sets the lobby back to the regular state. |
|||
* |
|||
*/ |
|||
|
|||
public void Start() |
|||
{ |
|||
Locator.Get.Messenger.Subscribe(this); |
|||
m_lobbyObserver.OnObservedUpdated.AddListener(UpdatePlayerCount); |
|||
} |
|||
public void OnDestroy() |
|||
{ |
|||
Locator.Get.Messenger.Unsubscribe(this); |
|||
m_lobbyObserver.OnObservedUpdated.RemoveListener(UpdatePlayerCount); |
|||
} |
|||
|
|||
private void SetMenuVisibility(bool areVisible) |
|||
{ |
|||
foreach (GameObject go in m_disableWhileInGame) |
|||
go.SetActive(areVisible); |
|||
} |
|||
|
|||
private void CreateNetworkManager() |
|||
{ |
|||
m_inGameManagerObj = GameObject.Instantiate(m_prefabNetworkManager); |
|||
m_networkManager = m_inGameManagerObj.GetComponentInChildren<NetworkManager>(); |
|||
m_objectSpawner = m_inGameManagerObj.GetComponentInChildren<InGameObjectSpawner>(); |
|||
m_inGameRunner = m_inGameManagerObj.GetComponentInChildren<InGameRunner>(); |
|||
m_inGameRunner.Initialize(OnConnectionVerified, m_playerCount); |
|||
|
|||
// TODO: I'll need this when we switch to the Relay Unity Transport option.
|
|||
//UnityTransport transport = m_inGameManagerObj.GetComponentInChildren<UnityTransport>();
|
|||
//transport.SetConnectionData(m_serverAddress.IP, (ushort)m_serverAddress.Port);
|
|||
//m_initializeTransport(transport);
|
|||
|
|||
if (m_isHost) |
|||
m_networkManager.StartHost(); |
|||
else |
|||
m_networkManager.StartClient(); |
|||
} |
|||
|
|||
private void UpdatePlayerCount(LocalLobby lobby) |
|||
{ m_playerCount = lobby.PlayerCount; |
|||
} |
|||
|
|||
private void OnConnectionVerified() |
|||
{ |
|||
// TODO: Anything here?
|
|||
} |
|||
|
|||
public void SetRelayAddress(LocalLobby changed) |
|||
{ |
|||
m_serverAddress = changed.RelayServer; // Note that this could be null.
|
|||
} |
|||
|
|||
public void OnLocalUserChange(LobbyUser user) |
|||
{ |
|||
m_isHost = user.IsHost; |
|||
} |
|||
|
|||
public void SetRelayServerData(string address, int port, byte[] allocationBytes, byte[] key, byte[] connectionData, byte[] hostConnectionData, bool isSecure) |
|||
{ |
|||
m_initializeTransport = (transport) => { transport.SetRelayServerData(address, (ushort)port, allocationBytes, key, connectionData, hostConnectionData, isSecure); }; |
|||
} |
|||
|
|||
public void OnReceiveMessage(MessageType type, object msg) |
|||
{ |
|||
if (type == MessageType.ConfirmInGameState) |
|||
{ |
|||
m_doesNeedCleanup = true; |
|||
SetMenuVisibility(false); |
|||
CreateNetworkManager(); |
|||
} |
|||
|
|||
else if (type == MessageType.GameBeginning) |
|||
{ |
|||
// If this player hasn't successfully connected via NGO, get booted.
|
|||
Locator.Get.Messenger.OnReceiveMessage(MessageType.DisplayErrorPopup, "Failed to join the game."); |
|||
// TODO: Need to handle both failing to connect and connecting but failing to initialize.
|
|||
// I.e. cleaning up networked objects *might* be necessary.
|
|||
} |
|||
|
|||
else if (type == MessageType.ChangeGameState) |
|||
{ |
|||
// Once we're in-game, any state change reflects the player leaving the game, so we should clean up.
|
|||
if (m_doesNeedCleanup) |
|||
{ |
|||
GameObject.Destroy(m_inGameManagerObj); // Since this destroys the NetworkManager, that will kick off cleaning up networked objects.
|
|||
SetMenuVisibility(true); |
|||
m_doesNeedCleanup = false; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3f7533ddeca587549a9798a65a8670ba |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.Netcode; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample.inGame |
|||
{ |
|||
[RequireComponent(typeof(Rigidbody))] |
|||
public class SymbolContainer : NetworkBehaviour |
|||
{ |
|||
public void Start() |
|||
{ |
|||
if (IsHost) |
|||
GetComponent<NetworkObject>().Spawn(); |
|||
} |
|||
|
|||
public override void OnNetworkSpawn() |
|||
{ |
|||
if (IsHost) |
|||
{ |
|||
Rigidbody m_rb = this.GetComponent<Rigidbody>(); |
|||
m_rb.MovePosition(Vector3.up * 10); |
|||
m_rb.velocity = Vector3.down; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 73a6c5df5c3139e448d76f8918fece73 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace LobbyRelaySample.inGame |
|||
{ |
|||
public class SymbolData : ScriptableObject |
|||
{ |
|||
[SerializeField] public List<Sprite> m_availableSymbols; |
|||
public int SymbolCount => m_availableSymbols.Count; |
|||
|
|||
public Sprite GetSymbolForIndex(int index) |
|||
{ |
|||
if (index < 0 || index >= m_availableSymbols.Count) |
|||
index = 0; |
|||
return m_availableSymbols[index]; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 26062727ed87bcc439ec8f0f86354a51 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue