浏览代码

integration changes needed to make my work work with Luke's. GameNetHub now follows a listener pattern like other networked components, so avoid any reverse dependencies of shared logic on client/server code.

/main
David Woodruff 4 年前
当前提交
941f2760
共有 7 个文件被更改,包括 372 次插入374 次删除
  1. 30
      Assets/BossRoom/Scenes/MainMenu.unity
  2. 585
      Assets/BossRoom/Scenes/SampleScene.unity
  3. 20
      Assets/BossRoom/Scripts/Client/Net/ClientGNHLogic.cs
  4. 9
      Assets/BossRoom/Scripts/Client/UI/MainMenuUI.cs
  5. 38
      Assets/BossRoom/Scripts/Server/Net/ServerGNHLogic.cs
  6. 58
      Assets/BossRoom/Scripts/Shared/Net/GameNetHub.cs
  7. 6
      ProjectSettings/EditorBuildSettings.asset

30
Assets/BossRoom/Scenes/MainMenu.unity


m_Component:
- component: {fileID: 308991160}
- component: {fileID: 308991158}
- component: {fileID: 308991161}
- component: {fileID: 308991159}
m_Layer: 0
m_Name: GameHub
m_TagString: Untagged

m_Name:
m_EditorClassIdentifier:
NetworkingManagerGO: {fileID: 1359040525}
--- !u!114 &308991159
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 308991157}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 54b0859a1da930541adf0b2d1bb8d977, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &308991160
Transform:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &308991161
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 308991157}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5bd31edc1b1fd1342b3bf8193a5a03b2, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &342895129
GameObject:
m_ObjectHideFlags: 0

- SampleScene
AllowRuntimeSceneChanges: 1
NetworkedPrefabs:
- Prefab: {fileID: 922472105905938403, guid: e57f88b20c296674cb0c1517a43f99da, type: 3}
- Prefab: {fileID: 4600110157238723781, guid: bb87f9bac2595f8499c048016c4b2e1d, type: 3}
PlayerPrefab: 1
- Prefab: {fileID: 3565665953789623672, guid: 1a58a2c4657fe6d4890d9ad39f43894e, type: 3}
PlayerPrefab: 0

00000000:
type: {class: NullableBoolSerializable, ns: MLAPI.Configuration, asm: Unity.Multiplayer.MLAPI.Runtime}
data:
Value: 6075374942793011955
Value: 1897319656204293034
--- !u!4 &1359040531
Transform:
m_ObjectHideFlags: 0

585
Assets/BossRoom/Scenes/SampleScene.unity


preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 23800000, guid: c7720ceef5c5df34c98168df9d4f695e, type: 2}
--- !u!1 &532797402
m_NavMeshData: {fileID: 23800000, guid: bba3bb41c6cbe4947a4e19778cbc40bc, type: 2}
--- !u!1 &74788320
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 532797406}
- component: {fileID: 532797405}
- component: {fileID: 532797404}
- component: {fileID: 532797403}
- component: {fileID: 74788321}
- component: {fileID: 74788324}
- component: {fileID: 74788323}
- component: {fileID: 74788322}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged

m_IsActive: 1
--- !u!64 &532797403
--- !u!4 &74788321
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 74788320}
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: 216673149}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!64 &74788322
m_GameObject: {fileID: 532797402}
m_GameObject: {fileID: 74788320}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1

m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &532797404
--- !u!23 &74788323
m_GameObject: {fileID: 532797402}
m_GameObject: {fileID: 74788320}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1

m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &532797405
--- !u!33 &74788324
m_GameObject: {fileID: 532797402}
m_GameObject: {fileID: 74788320}
--- !u!4 &532797406
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 532797402}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: -1, z: 10}
m_LocalScale: {x: 2, y: 2, z: 2}
m_Children: []
m_Father: {fileID: 1233618361}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &705507993
--- !u!1 &216673148
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 705507995}
- component: {fileID: 705507994}
- component: {fileID: 216673149}
m_Name: Directional Light
m_Name: Environment
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
--- !u!4 &216673149
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 2, z: 10}
m_GameObject: {fileID: 216673148}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 1233618361}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225
m_Children:
- {fileID: 74788321}
- {fileID: 586636177}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &586636173
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
- component: {fileID: 586636177}
- component: {fileID: 586636176}
- component: {fileID: 586636175}
- component: {fileID: 586636174}
m_Name: Main Camera
m_TagString: MainCamera
m_Name: Cube
m_TagString: Untagged
m_StaticEditorFlags: 0
m_StaticEditorFlags: 4294967295
--- !u!81 &963194226
AudioListener:
--- !u!65 &586636174
BoxCollider:
m_GameObject: {fileID: 963194225}
m_GameObject: {fileID: 586636173}
m_Material: {fileID: 0}
m_IsTrigger: 0
--- !u!20 &963194227
Camera:
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &586636175
MeshRenderer:
m_GameObject: {fileID: 963194225}
m_GameObject: {fileID: 586636173}
serializedVersion: 2
m_ClearFlags: 1
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: -1
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!4 &963194228
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!33 &586636176
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 586636173}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &586636177
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 10, z: -5.62}
m_LocalScale: {x: 1, y: 1, z: 1}
m_GameObject: {fileID: 586636173}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1.462, y: 0.2971146, z: -1.431}
m_LocalScale: {x: 2, y: 1, z: 2}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
--- !u!1 &1069853755
m_Father: {fileID: 216673149}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &669501775
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 1069853757}
- component: {fileID: 1069853756}
- component: {fileID: 1069853760}
- component: {fileID: 1069853759}
- component: {fileID: 1069853758}
- component: {fileID: 1069853761}
- component: {fileID: 669501777}
- component: {fileID: 669501776}
- component: {fileID: 669501778}
- component: {fileID: 669501779}
m_Layer: 0
m_Name: NetworkingManager
m_TagString: Untagged

m_IsActive: 1
--- !u!114 &1069853756
--- !u!114 &669501776
m_GameObject: {fileID: 1069853755}
m_GameObject: {fileID: 669501775}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 593a2fe42fa9d37498c96f9a383b6521, type: 3}

LogLevel: 1
NetworkConfig:
ProtocolVersion: 0
NetworkTransport: {fileID: 1069853760}
NetworkTransport: {fileID: 669501778}
- Prefab: {fileID: 922472105905938403, guid: e57f88b20c296674cb0c1517a43f99da, type: 3}
- Prefab: {fileID: 4600110157238723781, guid: bb87f9bac2595f8499c048016c4b2e1d, type: 3}
ReceiveTickrate: 0
MaxReceiveEventsPerTickRate: 1000
EventTickrate: 0
ReceiveTickrate: 64
MaxReceiveEventsPerTickRate: 500
EventTickrate: 64
SecondsHistory: 0
SecondsHistory: 5
EnableNetworkedVar: 0
EnableNetworkedVar: 1
EnableSceneManagement: 0
EnableSceneManagement: 1
ForceSamePrefabs: 1
UsePrefabSync: 0
RecycleNetworkIds: 1

EnableMessageBuffering: 0
EnableMessageBuffering: 1
MessageBufferTimeout: 20
EnableNetworkLogs: 1
EnableEncryption: 0

00000000:
type: {class: NullableBoolSerializable, ns: MLAPI.Configuration, asm: Unity.Multiplayer.MLAPI.Runtime}
data:
Value: 6075374942793011955
--- !u!4 &1069853757
Value: 1897319656204293034
--- !u!4 &669501777
m_GameObject: {fileID: 1069853755}
m_GameObject: {fileID: 669501775}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalPosition: {x: 0, y: 0, z: 0}
--- !u!114 &1069853758
--- !u!114 &669501778
m_GameObject: {fileID: 1069853755}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 52c005b32a68a254cbe502a4e5cb8eb6, type: 3}
m_Name:
m_EditorClassIdentifier:
appId: bc5b8b0d-edf3-4c61-9593-ce38da7f0c79
gameVersion: 0.0.0
region: EU
nickName:
roomName:
maxPlayers: 4
batchedTransportEventCode: 129
channelIdCodesStartRange: 130
attachSupportLogger: 1
sendQueueBatchSize: 4096
--- !u!114 &1069853759
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: db28424c2ae12f64da25c9ecccded6b1, type: 3}
m_Name:
m_EditorClassIdentifier:
Port: 7777
Address: 127.0.0.1
PingInterval: 1
DisconnectTimeout: 5
ReconnectDelay: 0.5
MaxConnectAttempts: 10
channels: []
MessageBufferSize: 5120
SimulatePacketLossChance: 0
SimulateMinLatency: 0
SimulateMaxLatency: 0
--- !u!114 &1069853760
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1069853755}
m_GameObject: {fileID: 669501775}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b84c2d8dfe509a34fb59e2b81f8e1319, type: 3}

MLAPIRelayAddress: 184.72.104.138
MLAPIRelayPort: 8888
MessageSendMode: 0
--- !u!114 &1069853761
--- !u!114 &669501779
m_GameObject: {fileID: 1069853755}
m_GameObject: {fileID: 669501775}
--- !u!1 &1233618360
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 1233618361}
- component: {fileID: 705507995}
- component: {fileID: 705507994}
m_Name: Environment
m_Name: Directional Light
m_StaticEditorFlags: 4294967295
m_StaticEditorFlags: 0
--- !u!4 &1233618361
--- !u!108 &705507994
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 1
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &705507995
m_GameObject: {fileID: 1233618360}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_Children:
- {fileID: 532797406}
- {fileID: 705507995}
m_Children: []
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1522473406
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 297185343939699586, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_Name
value: BossRoomState
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3}
--- !u!1 &1601651753
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &963194225
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}

m_Component:
- component: {fileID: 1601651754}
- component: {fileID: 1601651755}
- component: {fileID: 963194228}
- component: {fileID: 963194227}
- component: {fileID: 963194226}
m_Name: SimulationManager
m_TagString: Untagged
m_Name: Main Camera
m_TagString: MainCamera
--- !u!4 &1601651754
Transform:
--- !u!81 &963194226
AudioListener:
m_GameObject: {fileID: 1601651753}
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: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1601651755
MonoBehaviour:
m_GameObject: {fileID: 963194225}
m_Enabled: 1
--- !u!20 &963194227
Camera:
m_GameObject: {fileID: 1601651753}
m_GameObject: {fileID: 963194225}
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3e6c31da8c35c2743b0311f50e3e1a69, type: 3}
m_Name:
m_EditorClassIdentifier:
tickRate: 20
serializedVersion: 2
m_ClearFlags: 1
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: -1
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!4 &963194228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 10, z: -6}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}

20
Assets/BossRoom/Scripts/Client/Net/ClientGNHLogic.cs


/// <summary>
/// Client logic for the GameNetHub. Contains implementations for all of GameNetHub's S2C RPCs.
/// </summary>
public class ClientGNHLogic
[RequireComponent(typeof(GameNetHub))]
public class ClientGNHLogic : MonoBehaviour
private GameNetHub m_hub;
private GameNetHub m_Hub;
public ClientGNHLogic(GameNetHub hub)
public void Start()
m_hub = hub;
m_Hub = GetComponent<GameNetHub>();
m_Hub.NetworkStartEvent += this.NetworkStart;
m_Hub.ConnectFinishedEvent += this.OnConnectFinished;
public void RecvConnectFinished( ConnectStatus status )
public void NetworkStart()
{
if( !m_Hub.NetManager.IsClient ) { this.enabled = false; }
}
public void OnConnectFinished( ConnectStatus status )
//m_hub.GetComponent<BossRoomStateManager>().ChangeState(targetState, null);
}

9
Assets/BossRoom/Scripts/Client/UI/MainMenuUI.cs


private BossRoom.GameNetHub m_netHub;
/// <summary>
/// This will get more sophisticated as we move to a true relay model.
/// </summary>
private const int k_connectPort = 9998;
// Start is called before the first frame update
void Start()
{

{
GetIPAddress();
m_netHub.StartHost(GetIPAddress(), 9998);
m_netHub.StartHost(GetIPAddress(), k_connectPort);
m_netHub.StartClient(GetIPAddress(), 9998);
BossRoom.Client.ClientGNHLogic.StartClient(m_netHub, GetIPAddress(), k_connectPort);
}
}
}

38
Assets/BossRoom/Scripts/Server/Net/ServerGNHLogic.cs


/// <summary>
/// Server logic plugin for the GameNetHub. Contains implementations for all GameNetHub's C2S RPCs.
/// </summary>
public class ServerGNHLogic
public class ServerGNHLogic : MonoBehaviour
{
private GameNetHub m_Hub;

{
m_Hub = hub;
m_Hub.NetManager.ConnectionApprovalCallback += this.ApprovalCheck;
}
//The "BossRoom" server always advances to CharSelect immediately on start. Different games
//may do this differently.
MLAPI.SceneManagement.NetworkSceneManager.SwitchScene("CharSelect");
public void Start()
{
m_Hub = GetComponent<GameNetHub>();
m_Hub.NetworkStartEvent += this.NetworkStart;
/// <summary>
/// Initializes host mode on this client. Call this and then other clients should connect to us!
/// </summary>
/// <remarks>
/// See notes in GNH_Client.StartClient about why this must be static.
/// </remarks>
/// <param name="hub">The GameNetHub that is invoking us. </param>
/// <param name="ipaddress">The IP address to connect to (currently IPV4 only).</param>
/// <param name="port">The port to connect to. </param>
public static void StartHost(GameNetHub hub, string ipaddress, int port )
public void NetworkStart()
//DMW_NOTE: non-portable. We need to be updated when moving to UTP transport.
var transport = hub.NetworkingManagerGO.GetComponent<MLAPI.Transports.UNET.UnetTransport>();
transport.ConnectAddress = ipaddress;
transport.ServerListenPort = port;
if (!m_Hub.NetManager.IsServer)
{
this.enabled = false;
}
else
{
m_Hub.NetManager.ConnectionApprovalCallback += this.ApprovalCheck;
hub.NetManager.StartHost();
//The "BossRoom" server always advances to CharSelect immediately on start. Different games
//may do this differently.
MLAPI.SceneManagement.NetworkSceneManager.SwitchScene("CharSelect");
}
/// <summary>
/// This logic plugs into the "ConnectionApprovalCallback" exposed by MLAPI.NetworkingManager, and is run every time a client connects to us.

58
Assets/BossRoom/Scripts/Shared/Net/GameNetHub.cs


using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

{
public GameObject NetworkingManagerGO;
private BossRoom.Client.ClientGNHLogic m_ClientLogic;
private BossRoom.Server.ServerGNHLogic m_ServerLogic;
/// <summary>
/// This synthesizes a general NetworkStart event out of other events provided by MLAPI. This can be removed
/// when the NetworkingManager starts publishing this event directly.
/// </summary>
public event Action NetworkStartEvent;
/// <summary>
/// This event contains the game-level results of the ApprovalCheck carried out by the server, and is fired
/// immediately after the socket connection completing. It won't fire in the event of a socket level failure.
/// </summary>
public event Action<ConnectStatus> ConnectFinishedEvent;
public MLAPI.NetworkingManager NetManager { get; private set; }

Object.DontDestroyOnLoad(this.gameObject);
UnityEngine.Object.DontDestroyOnLoad(this.gameObject);
NetManager = NetworkingManagerGO.GetComponent<MLAPI.NetworkingManager>();

using (PooledBitReader reader = PooledBitReader.Get(stream))
{
ConnectStatus status = (ConnectStatus)reader.ReadInt32();
m_ClientLogic.RecvConnectFinished(status );
ConnectFinishedEvent?.Invoke(status);
}
});
}

{
if (NetManager.IsClient)
{
m_ClientLogic = new BossRoom.Client.ClientGNHLogic(this);
if ( NetManager.IsServer )
if (NetManager.IsServer)
m_ServerLogic = new BossRoom.Server.ServerGNHLogic(this);
if( NetManager.IsHost )
if (NetManager.IsHost)
m_ClientLogic.RecvConnectFinished(ConnectStatus.SUCCESS );
ConnectFinishedEvent?.Invoke(ConnectStatus.SUCCESS);
}
/// <summary>
/// Wraps the invocation of NetworkingManager.StartClient, including our GUID as the payload.
/// </summary>
/// <param name="ipaddress">the IP address of the host to connect to. (IPV4 only)</param>
/// <param name="port">The port of the host to connect to. </param>
public void StartClient(string ipaddress, int port)
{
BossRoom.Client.ClientGNHLogic.StartClient(this, ipaddress, port);
NetworkStartEvent?.Invoke();
/// Wraps the invocation of NetworkingManager.StartHost.
/// Initializes host mode on this client. Call this and then other clients should connect to us!
/// <param name="ipaddress">The IP address of the network interface we should listen to connections on. (IPV4 only)</param>
/// <param name="port">The port we should listen on. </param>
public void StartHost(string ipaddress, int port )
/// <remarks>
/// See notes in GNH_Client.StartClient about why this must be static.
/// </remarks>
/// <param name="hub">The GameNetHub that is invoking us. </param>
/// <param name="ipaddress">The IP address to connect to (currently IPV4 only).</param>
/// <param name="port">The port to connect to. </param>
public void StartHost( string ipaddress, int port)
BossRoom.Server.ServerGNHLogic.StartHost(this, ipaddress, port);
//DMW_NOTE: non-portable. We need to be updated when moving to UTP transport.
var transport = NetworkingManagerGO.GetComponent<MLAPI.Transports.UNET.UnetTransport>();
transport.ConnectAddress = ipaddress;
transport.ServerListenPort = port;
NetManager.StartHost();
//Server->Client RPCs

6
ProjectSettings/EditorBuildSettings.asset


serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/MainMenu.unity
path: Assets/BossRoom/Scenes/MainMenu.unity
path: Assets/Scenes/CharSelect.unity
path: Assets/BossRoom/Scenes/CharSelect.unity
path: Assets/Scenes/SampleScene.unity
path: Assets/BossRoom/Scenes/SampleScene.unity
guid: 9fc0d4010bbf28b4594072e72b8655ab
m_configObjects: {}
正在加载...
取消
保存