mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
custommmanager
This commit is contained in:
parent
4b207d2994
commit
d4385abaa1
51
Assets/Mirror/Examples/Tanks/Prefabs/ConnObj.prefab
Normal file
51
Assets/Mirror/Examples/Tanks/Prefabs/ConnObj.prefab
Normal file
@ -0,0 +1,51 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &2667776152869222729
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1426508401357769970}
|
||||
- component: {fileID: 5712371775279386125}
|
||||
m_Layer: 0
|
||||
m_Name: ConnObj
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1426508401357769970
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2667776152869222729}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.3176136, y: -2.2647743, z: -0.84013176}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &5712371775279386125
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2667776152869222729}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
sceneId: 0
|
||||
serverOnly: 0
|
||||
visible: 0
|
||||
m_AssetId:
|
||||
hasSpawned: 0
|
7
Assets/Mirror/Examples/Tanks/Prefabs/ConnObj.prefab.meta
Normal file
7
Assets/Mirror/Examples/Tanks/Prefabs/ConnObj.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 811333c275062476bb918e5208d98d29
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -33,6 +33,7 @@ Transform:
|
||||
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: 7831918942946891954}
|
||||
- {fileID: 4116800716706440423}
|
||||
@ -151,7 +152,7 @@ MonoBehaviour:
|
||||
health: 4
|
||||
--- !u!95 &2240606817507776182
|
||||
Animator:
|
||||
serializedVersion: 3
|
||||
serializedVersion: 4
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
@ -164,6 +165,7 @@ Animator:
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_LinearVelocityBlending: 0
|
||||
m_StabilizeFeet: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
m_AllowConstantClipSamplingOptimization: 1
|
||||
@ -231,6 +233,7 @@ Transform:
|
||||
w: 0.9997397}
|
||||
m_LocalPosition: {x: 0.00070000027, y: 0.002070647, z: 0.0012600002}
|
||||
m_LocalScale: {x: 0.01, y: 0.010000003, z: 0.010000002}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7831918942946891958}
|
||||
m_RootOrder: 2
|
||||
@ -294,6 +297,7 @@ Light:
|
||||
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!1 &4730779867780281009
|
||||
@ -322,6 +326,7 @@ Transform:
|
||||
m_LocalRotation: {x: -0, y: 0.000000119209275, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.0015906466, z: 0.009359999}
|
||||
m_LocalScale: {x: 0.01, y: 0.010000003, z: 0.010000002}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 7831918942946891958}
|
||||
m_RootOrder: 1
|
||||
@ -355,6 +360,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.8, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 4492442352427800}
|
||||
m_RootOrder: 1
|
||||
@ -370,10 +376,12 @@ MeshRenderer:
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@ -398,6 +406,7 @@ MeshRenderer:
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!102 &1985504562751981867
|
||||
TextMesh:
|
||||
serializedVersion: 3
|
||||
|
@ -43,7 +43,7 @@ RenderSettings:
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
@ -54,7 +54,7 @@ LightmapSettings:
|
||||
m_EnableBakedLightmaps: 0
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 10
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
@ -62,6 +62,7 @@ LightmapSettings:
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
@ -76,10 +77,16 @@ LightmapSettings:
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
@ -87,9 +94,12 @@ LightmapSettings:
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ShowResolutionOverlay: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
m_LightingSettings: {fileID: 4890085278179872738, guid: f96fd246e06b64d8184c9345b58d38dd,
|
||||
type: 2}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
@ -109,6 +119,8 @@ NavMeshSettings:
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 23800000, guid: 0bc607fa2e315482ebe98797e844e11f, type: 2}
|
||||
@ -142,9 +154,10 @@ Camera:
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_GateFitMode: 2
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
@ -229,6 +242,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 3, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
@ -272,6 +286,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 3, y: 0, z: -3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
@ -318,9 +333,12 @@ MeshRenderer:
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 4294967295
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
@ -332,6 +350,7 @@ MeshRenderer:
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 1
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
@ -344,6 +363,7 @@ MeshRenderer:
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!64 &1107091654
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -354,9 +374,9 @@ MeshCollider:
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
serializedVersion: 4
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 14
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!33 &1107091655
|
||||
MeshFilter:
|
||||
@ -376,6 +396,7 @@ Transform:
|
||||
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: 0}
|
||||
m_RootOrder: 1
|
||||
@ -409,6 +430,7 @@ Transform:
|
||||
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: 0}
|
||||
m_RootOrder: 3
|
||||
@ -425,7 +447,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 6442dc8070ceb41f094e44de0bf87274, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
showGUI: 1
|
||||
offsetX: 0
|
||||
offsetY: 0
|
||||
--- !u!114 &1282001520
|
||||
@ -437,30 +458,31 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1282001517}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8aab4c8111b7c411b9b92cf3dbc5bd4e, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: c288194815d1470d920e84b5c6d6d013, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
dontDestroyOnLoad: 1
|
||||
runInBackground: 1
|
||||
autoStartServerBuild: 1
|
||||
showDebugMessages: 0
|
||||
serverTickRate: 30
|
||||
serverBatching: 0
|
||||
serverBatchInterval: 0
|
||||
offlineScene:
|
||||
onlineScene:
|
||||
transport: {fileID: 1282001521}
|
||||
networkAddress: localhost
|
||||
maxConnections: 100
|
||||
disconnectInactiveConnections: 0
|
||||
disconnectInactiveTimeout: 60
|
||||
authenticator: {fileID: 0}
|
||||
playerPrefab: {fileID: 1916082411674582, guid: 6f43bf5488a7443d19ab2a83c6b91f35,
|
||||
type: 3}
|
||||
autoCreatePlayer: 1
|
||||
autoCreatePlayer: 0
|
||||
playerSpawnMethod: 1
|
||||
spawnPrefabs:
|
||||
- {fileID: 5890560936853567077, guid: b7dd46dbf38c643f09e206f9fa4be008, type: 3}
|
||||
- {fileID: 2667776152869222729, guid: 811333c275062476bb918e5208d98d29, type: 3}
|
||||
Localplayername: LocalPlayerName
|
||||
playerTankPrefab: {fileID: 1916082411674582, guid: 6f43bf5488a7443d19ab2a83c6b91f35,
|
||||
type: 3}
|
||||
playerConnPrefab: {fileID: 2667776152869222729, guid: 811333c275062476bb918e5208d98d29,
|
||||
type: 3}
|
||||
--- !u!114 &1282001521
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -474,12 +496,19 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Port: 7777
|
||||
DualMode: 1
|
||||
NoDelay: 1
|
||||
Interval: 10
|
||||
Timeout: 10000
|
||||
FastResend: 2
|
||||
CongestionWindow: 0
|
||||
SendWindowSize: 4096
|
||||
ReceiveWindowSize: 4096
|
||||
MaxRetransmit: 40
|
||||
NonAlloc: 1
|
||||
MaximizeSendReceiveBuffersToOSLimit: 1
|
||||
ReliableMaxMessageSize: 298449
|
||||
UnreliableMaxMessageSize: 1199
|
||||
debugLog: 0
|
||||
statisticsGUI: 0
|
||||
statisticsLog: 0
|
||||
@ -510,6 +539,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -3, y: 0, z: 3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 7
|
||||
@ -553,6 +583,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -3, y: 0, z: -3}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
@ -594,12 +625,14 @@ Light:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2054208274}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 8
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.802082
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
@ -609,6 +642,24 @@ Light:
|
||||
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}
|
||||
@ -616,12 +667,16 @@ Light:
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
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 &2054208276
|
||||
@ -634,6 +689,7 @@ Transform:
|
||||
m_LocalRotation: {x: 0.10938167, y: 0.8754261, z: -0.40821788, w: 0.23456976}
|
||||
m_LocalPosition: {x: 0, y: 10, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
|
89
Assets/Mirror/Examples/Tanks/Scripts/CustomManager.cs
Normal file
89
Assets/Mirror/Examples/Tanks/Scripts/CustomManager.cs
Normal file
@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Mirror;
|
||||
|
||||
public class CustomManager : NetworkManager
|
||||
{
|
||||
public List<MatchData> matches = new List<MatchData>();
|
||||
public string Localplayername;
|
||||
public GameObject playerTankPrefab, playerConnPrefab;
|
||||
|
||||
public override void OnStartServer()
|
||||
{
|
||||
base.OnStartServer();
|
||||
NetworkServer.RegisterHandler<CreateMessage>(Createplayer);
|
||||
}
|
||||
|
||||
public override void OnClientConnect()
|
||||
{
|
||||
base.OnClientConnect();
|
||||
CreateMessage ms = new CreateMessage
|
||||
{
|
||||
playername = Localplayername
|
||||
};
|
||||
NetworkClient.Send(ms);
|
||||
}
|
||||
|
||||
[ServerCallback]
|
||||
void Createplayer(NetworkConnectionToClient conn, CreateMessage message)
|
||||
{
|
||||
//first Create dumy player Obj
|
||||
Debug.Log("Receive Create Player MSG");
|
||||
GameObject playerConn = GameObject.Instantiate(playerConnPrefab);
|
||||
NetworkServer.Spawn(playerConn);
|
||||
playerConn.name = "conn" + message.playername;
|
||||
NetworkServer.AddPlayerForConnection(conn, playerConn);
|
||||
|
||||
|
||||
//then replace it with tank obj
|
||||
//also check it if this player name already on match
|
||||
foreach (MatchData item in matches)
|
||||
{
|
||||
//if yes dont make new tank,and REplace dumy player Obj with already
|
||||
//spawned tank Obj in server based on player name
|
||||
if (item.playerName == message.playername.Replace(" ", ""))
|
||||
{
|
||||
item.connObj=playerConn;
|
||||
NetworkServer.ReplacePlayerForConnection(conn, item.playerObj, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//if no add this new player to matchdata and spawn tank for it and also
|
||||
//REplace dumy player Obj with already spawned tank Obj in server
|
||||
GameObject playerTank = GameObject.Instantiate(playerTankPrefab);
|
||||
playerTankPrefab.name = "tank" + message.playername;
|
||||
NetworkServer.Spawn(playerTank);
|
||||
MatchData md = new MatchData();
|
||||
md.playerName = message.playername;
|
||||
md.playerObj = playerTank;
|
||||
md.connObj = playerConn;
|
||||
matches.Add(md);
|
||||
NetworkServer.ReplacePlayerForConnection(conn, playerTank, false);
|
||||
}
|
||||
|
||||
public override void OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
{
|
||||
foreach (MatchData item in matches)
|
||||
{
|
||||
if (item.playerObj == conn.identity.gameObject)
|
||||
{
|
||||
Debug.Log(conn.identity.gameObject.name);
|
||||
NetworkServer.ReplacePlayerForConnection(conn, item.connObj, false);
|
||||
item.connObj=null;
|
||||
}
|
||||
}
|
||||
base.OnServerDisconnect(conn);
|
||||
}
|
||||
|
||||
}
|
||||
public class MatchData
|
||||
{
|
||||
public string playerName;
|
||||
public GameObject connObj;
|
||||
public GameObject playerObj;
|
||||
}
|
||||
public struct CreateMessage : NetworkMessage
|
||||
{
|
||||
public string playername;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c288194815d1470d920e84b5c6d6d013
|
||||
timeCreated: 1647881849
|
Loading…
Reference in New Issue
Block a user