Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ccaebaf06 | ||
|
|
04e06652f5 | ||
|
|
a36cf65f6d | ||
|
|
fb04675716 | ||
|
|
07861676d6 | ||
|
|
153089a432 | ||
|
|
d196a23816 | ||
|
|
5d729f584a | ||
|
|
1fe20dbb5d | ||
|
|
4e625ea185 | ||
|
|
fee664a936 |
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SwUserDefinedSpecifications">
|
||||||
|
<option name="specTypeByUrl">
|
||||||
|
<map />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Character
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: be5ce586e1f1d9a43aea5965b6e5ea02, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_BuildTextureStacks: []
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bb9f295792e17a541ac256536656b256
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,102 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e91d85c032f28e43ba2e957c347ebd1
|
||||||
|
ModelImporter:
|
||||||
|
serializedVersion: 20200
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
materials:
|
||||||
|
materialImportMode: 2
|
||||||
|
materialName: 0
|
||||||
|
materialSearch: 1
|
||||||
|
materialLocation: 1
|
||||||
|
animations:
|
||||||
|
legacyGenerateAnimations: 4
|
||||||
|
bakeSimulation: 0
|
||||||
|
resampleCurves: 1
|
||||||
|
optimizeGameObjects: 0
|
||||||
|
motionNodeName:
|
||||||
|
rigImportErrors:
|
||||||
|
rigImportWarnings:
|
||||||
|
animationImportErrors:
|
||||||
|
animationImportWarnings:
|
||||||
|
animationRetargetingWarnings:
|
||||||
|
animationDoRetargetingWarnings: 0
|
||||||
|
importAnimatedCustomProperties: 0
|
||||||
|
importConstraints: 0
|
||||||
|
animationCompression: 1
|
||||||
|
animationRotationError: 0.5
|
||||||
|
animationPositionError: 0.5
|
||||||
|
animationScaleError: 0.5
|
||||||
|
animationWrapMode: 0
|
||||||
|
extraExposedTransformPaths: []
|
||||||
|
extraUserProperties: []
|
||||||
|
clipAnimations: []
|
||||||
|
isReadable: 0
|
||||||
|
meshes:
|
||||||
|
lODScreenPercentages: []
|
||||||
|
globalScale: 1
|
||||||
|
meshCompression: 0
|
||||||
|
addColliders: 0
|
||||||
|
useSRGBMaterialColor: 1
|
||||||
|
sortHierarchyByName: 1
|
||||||
|
importVisibility: 1
|
||||||
|
importBlendShapes: 1
|
||||||
|
importCameras: 1
|
||||||
|
importLights: 1
|
||||||
|
fileIdsGeneration: 2
|
||||||
|
swapUVChannels: 0
|
||||||
|
generateSecondaryUV: 0
|
||||||
|
useFileUnits: 1
|
||||||
|
keepQuads: 0
|
||||||
|
weldVertices: 1
|
||||||
|
bakeAxisConversion: 0
|
||||||
|
preserveHierarchy: 0
|
||||||
|
skinWeightsMode: 0
|
||||||
|
maxBonesPerVertex: 4
|
||||||
|
minBoneWeight: 0.001
|
||||||
|
meshOptimizationFlags: -1
|
||||||
|
indexFormat: 0
|
||||||
|
secondaryUVAngleDistortion: 8
|
||||||
|
secondaryUVAreaDistortion: 15.000001
|
||||||
|
secondaryUVHardAngle: 88
|
||||||
|
secondaryUVMarginMethod: 1
|
||||||
|
secondaryUVMinLightmapResolution: 40
|
||||||
|
secondaryUVMinObjectScale: 1
|
||||||
|
secondaryUVPackMargin: 4
|
||||||
|
useFileScale: 1
|
||||||
|
tangentSpace:
|
||||||
|
normalSmoothAngle: 60
|
||||||
|
normalImportMode: 0
|
||||||
|
tangentImportMode: 3
|
||||||
|
normalCalculationMode: 4
|
||||||
|
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||||
|
blendShapeNormalImportMode: 1
|
||||||
|
normalSmoothingSource: 0
|
||||||
|
referencedClips: []
|
||||||
|
importAnimation: 1
|
||||||
|
humanDescription:
|
||||||
|
serializedVersion: 3
|
||||||
|
human: []
|
||||||
|
skeleton: []
|
||||||
|
armTwist: 0.5
|
||||||
|
foreArmTwist: 0.5
|
||||||
|
upperLegTwist: 0.5
|
||||||
|
legTwist: 0.5
|
||||||
|
armStretch: 0.05
|
||||||
|
legStretch: 0.05
|
||||||
|
feetSpacing: 0
|
||||||
|
globalScale: 1
|
||||||
|
rootMotionBoneName:
|
||||||
|
hasTranslationDoF: 0
|
||||||
|
hasExtraRoot: 0
|
||||||
|
skeletonHasParents: 1
|
||||||
|
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||||
|
autoGenerateAvatarMappingIfUnspecified: 1
|
||||||
|
animationType: 2
|
||||||
|
humanoidOversampling: 1
|
||||||
|
avatarSetup: 0
|
||||||
|
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||||
|
additionalBone: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,108 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be5ce586e1f1d9a43aea5965b6e5ea02
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 0
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 0
|
||||||
|
wrapV: 0
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID:
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &4093383343133656139
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 4093383343133656141}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Player
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &4093383343133656141
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4093383343133656139}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 150, y: 50.039, z: 150}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 6997416220352495879}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &6443714940181712877
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6997416220352495879}
|
||||||
|
- component: {fileID: 1794263797225469849}
|
||||||
|
- component: {fileID: 7917482631429352262}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Cube
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &6997416220352495879
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6443714940181712877}
|
||||||
|
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||||
|
m_LocalPosition: {x: 0, y: -0.132, z: 0.024}
|
||||||
|
m_LocalScale: {x: 0.24999988, y: 0.24999988, z: 0.25}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 4093383343133656141}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||||
|
--- !u!33 &1794263797225469849
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6443714940181712877}
|
||||||
|
m_Mesh: {fileID: -5495902117074765545, guid: 9e91d85c032f28e43ba2e957c347ebd1, type: 3}
|
||||||
|
--- !u!23 &7917482631429352262
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 6443714940181712877}
|
||||||
|
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: 2100000, guid: bb9f295792e17a541ac256536656b256, type: 2}
|
||||||
|
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}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f648243c6b14d514d92cde4ec433276b
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -308,6 +308,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
material: {fileID: 2100000, guid: f4343d4c3fcbdb94b9db1c71ca64ba0a, type: 2}
|
material: {fileID: 2100000, guid: f4343d4c3fcbdb94b9db1c71ca64ba0a, type: 2}
|
||||||
|
playerPrefab: {fileID: 4093383343133656139, guid: f648243c6b14d514d92cde4ec433276b, type: 3}
|
||||||
worldSize: 0
|
worldSize: 0
|
||||||
blockData:
|
blockData:
|
||||||
- name: Air
|
- name: Air
|
||||||
@@ -320,89 +321,6 @@ MonoBehaviour:
|
|||||||
textures: 020207010202
|
textures: 020207010202
|
||||||
- name: Stone
|
- name: Stone
|
||||||
textures: 000000000000
|
textures: 000000000000
|
||||||
--- !u!1 &1356629356
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 1356629359}
|
|
||||||
- component: {fileID: 1356629358}
|
|
||||||
- component: {fileID: 1356629357}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Main Camera
|
|
||||||
m_TagString: MainCamera
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!81 &1356629357
|
|
||||||
AudioListener:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1356629356}
|
|
||||||
m_Enabled: 1
|
|
||||||
--- !u!20 &1356629358
|
|
||||||
Camera:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1356629356}
|
|
||||||
m_Enabled: 1
|
|
||||||
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 &1356629359
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 1356629356}
|
|
||||||
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: 1789911867}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1 &1414729002
|
--- !u!1 &1414729002
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -431,7 +349,7 @@ Light:
|
|||||||
serializedVersion: 10
|
serializedVersion: 10
|
||||||
m_Type: 1
|
m_Type: 1
|
||||||
m_Shape: 0
|
m_Shape: 0
|
||||||
m_Color: {r: 0.9339623, g: 0.5683072, b: 0.5683072, a: 1}
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_Intensity: 0.8
|
m_Intensity: 0.8
|
||||||
m_Range: 10
|
m_Range: 10
|
||||||
m_SpotAngle: 30
|
m_SpotAngle: 30
|
||||||
@@ -474,7 +392,7 @@ Light:
|
|||||||
m_Lightmapping: 4
|
m_Lightmapping: 4
|
||||||
m_LightShadowCasterMode: 0
|
m_LightShadowCasterMode: 0
|
||||||
m_AreaSize: {x: 1, y: 1}
|
m_AreaSize: {x: 1, y: 1}
|
||||||
m_BounceIntensity: 0
|
m_BounceIntensity: 0.5
|
||||||
m_ColorTemperature: 6570
|
m_ColorTemperature: 6570
|
||||||
m_UseColorTemperature: 0
|
m_UseColorTemperature: 0
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||||
@@ -680,8 +598,8 @@ GameObject:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 1789911867}
|
|
||||||
- component: {fileID: 1789911868}
|
- component: {fileID: 1789911868}
|
||||||
|
- component: {fileID: 1789911870}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Player
|
m_Name: Player
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -689,7 +607,7 @@ GameObject:
|
|||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
--- !u!4 &1789911867
|
--- !u!4 &1789911868
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
@@ -697,14 +615,15 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1789911866}
|
m_GameObject: {fileID: 1789911866}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 150, y: 50, z: 150}
|
m_LocalPosition: {x: 150, y: 50.039, z: 150}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1356629359}
|
- {fileID: 1934992309}
|
||||||
|
- {fileID: 6473166405133837942}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &1789911868
|
--- !u!114 &1789911870
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
@@ -716,6 +635,171 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 68efa1f8faa15f54b905841d23d36864, type: 3}
|
m_Script: {fileID: 11500000, guid: 68efa1f8faa15f54b905841d23d36864, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
mouseSpeed: 3
|
mouseSpeed: 4
|
||||||
moveSpeed: 10
|
walkSpeed: 5
|
||||||
|
jumpForce: 8
|
||||||
world: {fileID: 948138834}
|
world: {fileID: 948138834}
|
||||||
|
--- !u!1 &1934992308
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1934992309}
|
||||||
|
- component: {fileID: 1934992311}
|
||||||
|
- component: {fileID: 1934992310}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Camera
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &1934992309
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1934992308}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 1.7, z: 0.036}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1789911868}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!81 &1934992310
|
||||||
|
AudioListener:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1934992308}
|
||||||
|
m_Enabled: 1
|
||||||
|
--- !u!20 &1934992311
|
||||||
|
Camera:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1934992308}
|
||||||
|
m_Enabled: 1
|
||||||
|
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.01
|
||||||
|
far clip plane: 1000
|
||||||
|
field of view: 70
|
||||||
|
orthographic: 0
|
||||||
|
orthographic size: 5
|
||||||
|
m_Depth: 0
|
||||||
|
m_CullingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 55
|
||||||
|
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!33 &2317136213949272296
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7035241573763573916}
|
||||||
|
m_Mesh: {fileID: -5495902117074765545, guid: 9e91d85c032f28e43ba2e957c347ebd1, type: 3}
|
||||||
|
--- !u!23 &6137864197909744695
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7035241573763573916}
|
||||||
|
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: 2100000, guid: bb9f295792e17a541ac256536656b256, type: 2}
|
||||||
|
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!4 &6473166405133837942
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7035241573763573916}
|
||||||
|
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||||
|
m_LocalPosition: {x: 0, y: -0.08, z: 0.024}
|
||||||
|
m_LocalScale: {x: 0.24999988, y: 0.24999988, z: 0.25}
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1789911868}
|
||||||
|
m_RootOrder: 1
|
||||||
|
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
|
||||||
|
--- !u!1 &7035241573763573916
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 6473166405133837942}
|
||||||
|
- component: {fileID: 2317136213949272296}
|
||||||
|
- component: {fileID: 6137864197909744695}
|
||||||
|
m_Layer: 6
|
||||||
|
m_Name: Cube
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
|||||||
@@ -130,6 +130,44 @@ public class Client
|
|||||||
Send(new byte[]{6});
|
Send(new byte[]{6});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//1.12 == [1] = 1, [2] = 12
|
||||||
|
public void SendPositionUpdate(Vector3 position)
|
||||||
|
{
|
||||||
|
string x = position.x.ToString("n4");
|
||||||
|
string y = position.y.ToString("n4");
|
||||||
|
string z = position.z.ToString("n4");
|
||||||
|
|
||||||
|
string sendPosition = x + " " + y + " " + z;
|
||||||
|
byte[] sendPositionASCII = Encoding.ASCII.GetBytes(sendPosition);
|
||||||
|
byte[] send = new byte[sendPositionASCII.Length + 1];
|
||||||
|
send[0] = 7;
|
||||||
|
for (int i = 1; i < send.Length; i++)
|
||||||
|
{
|
||||||
|
send[i] = sendPositionASCII[i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
Send(send);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendRotationUpdate(Quaternion rotation)
|
||||||
|
{
|
||||||
|
string x = rotation.x.ToString("n4");
|
||||||
|
string y = rotation.y.ToString("n4");
|
||||||
|
string z = rotation.z.ToString("n4");
|
||||||
|
string w = rotation.w.ToString("n4");
|
||||||
|
|
||||||
|
string sendRotation = x + " " + y + " " + z + " " + w;
|
||||||
|
byte[] sendRotationASCII = Encoding.ASCII.GetBytes(sendRotation);
|
||||||
|
byte[] send = new byte[sendRotationASCII.Length + 1];
|
||||||
|
send[0] = 8;
|
||||||
|
for (int i = 1; i < send.Length; i++)
|
||||||
|
{
|
||||||
|
send[i] = sendRotationASCII[i - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
Send(send);
|
||||||
|
}
|
||||||
|
|
||||||
private void Receive()
|
private void Receive()
|
||||||
{
|
{
|
||||||
while(true)
|
while(true)
|
||||||
@@ -145,9 +183,62 @@ public class Client
|
|||||||
|
|
||||||
world.EditBlock(chunk, positionInChunk, blockID);
|
world.EditBlock(chunk, positionInChunk, blockID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add a new player
|
||||||
|
if (data[0] == 5)
|
||||||
|
{
|
||||||
|
world.AddPlayer(data[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//update a players position
|
||||||
|
if (data[0] == 7)
|
||||||
|
{
|
||||||
|
byte[] positionASCII = new byte[data.Length - 2];
|
||||||
|
for (int i = 0; i < data.Length - 2; i++)
|
||||||
|
{
|
||||||
|
positionASCII[i] = data[i + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte id = data[1];
|
||||||
|
|
||||||
|
string[] positionString = Encoding.ASCII.GetString(positionASCII).Split(' ');
|
||||||
|
float x = float.Parse(positionString[0]);
|
||||||
|
float y = float.Parse(positionString[1]);
|
||||||
|
float z = float.Parse(positionString[2]);
|
||||||
|
|
||||||
|
world.UpdatePlayerPosition(new Vector3(x, y, z), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove a player from local world
|
||||||
|
if (data[0] == 4)
|
||||||
|
{
|
||||||
|
world.RemovePlayer(data[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//update a players rotation
|
||||||
|
if (data[0] == 8)
|
||||||
|
{
|
||||||
|
byte[] rotationASCII = new byte[data.Length - 2];
|
||||||
|
for (int i = 0; i < data.Length - 2; i++)
|
||||||
|
{
|
||||||
|
rotationASCII[i] = data[i + 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte id = data[1];
|
||||||
|
|
||||||
|
string[] rotationString = Encoding.ASCII.GetString(rotationASCII).Split(' ');
|
||||||
|
float x = float.Parse(rotationString[0]);
|
||||||
|
float y = float.Parse(rotationString[1]);
|
||||||
|
float z = float.Parse(rotationString[2]);
|
||||||
|
float w = float.Parse(rotationString[3]);
|
||||||
|
|
||||||
|
world.UpdatePlayerRotation(new Quaternion(x, y, z, w), id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//sends an edit block request to server
|
||||||
public void EditBlock(Vector3 positionInWorld, byte blockID)
|
public void EditBlock(Vector3 positionInWorld, byte blockID)
|
||||||
{
|
{
|
||||||
ChunkCoord chunk = new ChunkCoord((int)(positionInWorld.x / Data.chunkWidth),
|
ChunkCoord chunk = new ChunkCoord((int)(positionInWorld.x / Data.chunkWidth),
|
||||||
@@ -161,6 +252,7 @@ public class Client
|
|||||||
Send(new byte[] { 3, (byte)chunk.x, (byte)chunk.z, xInChunk, yInChunk, zInChunk, blockID });
|
Send(new byte[] { 3, (byte)chunk.x, (byte)chunk.z, xInChunk, yInChunk, zInChunk, blockID });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//default send method
|
||||||
private void Send(byte[] data)
|
private void Send(byte[] data)
|
||||||
{
|
{
|
||||||
client.Send(data, data.Length);
|
client.Send(data, data.Length);
|
||||||
|
|||||||
@@ -7,9 +7,25 @@ public class Player : MonoBehaviour
|
|||||||
{
|
{
|
||||||
//game
|
//game
|
||||||
[SerializeField] private float mouseSpeed;
|
[SerializeField] private float mouseSpeed;
|
||||||
[SerializeField] private float moveSpeed;
|
[SerializeField] private float walkSpeed = 5;
|
||||||
|
[SerializeField] private float jumpForce;
|
||||||
[SerializeField] private World world;
|
[SerializeField] private World world;
|
||||||
|
private float playerWidth = 0.15f;
|
||||||
|
private float playerOffsetWidth = 0.1f;
|
||||||
|
private float horizontal;
|
||||||
|
private float vertical;
|
||||||
|
private float mouseX;
|
||||||
|
private float mouseY;
|
||||||
|
private Vector3 velocity = new Vector3(0, 0, 0);
|
||||||
|
private float rotX = 0;
|
||||||
|
private float verticalMomentum = 0;
|
||||||
|
private bool jumpRequest;
|
||||||
|
private bool isGrounded = true;
|
||||||
|
|
||||||
|
private float gravity = -20f;
|
||||||
private Camera camera = null;
|
private Camera camera = null;
|
||||||
|
private Vector3 lastPosition = new Vector3();
|
||||||
|
private Quaternion lastRotation = new Quaternion();
|
||||||
|
|
||||||
//network
|
//network
|
||||||
private Client client = null;
|
private Client client = null;
|
||||||
@@ -17,47 +33,261 @@ public class Player : MonoBehaviour
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
client = world.GetClient();
|
client = world.GetClient();
|
||||||
|
|
||||||
|
//lock the cursor
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
camera = GetComponentInChildren<Camera>();
|
camera = GetComponentInChildren<Camera>();
|
||||||
|
transform.position = new Vector3((byte)transform.position.x,
|
||||||
|
world.GetHeight((byte)transform.position.x, (byte)transform.position.z) + 2, (byte)transform.position.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Jump()
|
||||||
|
{
|
||||||
|
//add velocity up
|
||||||
|
verticalMomentum = jumpForce;
|
||||||
|
isGrounded = false;
|
||||||
|
jumpRequest = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
//if space was pressed
|
||||||
|
if (jumpRequest)
|
||||||
|
{
|
||||||
|
Jump();
|
||||||
|
}
|
||||||
|
|
||||||
|
CalculateVelocity();
|
||||||
|
transform.Translate(velocity, Space.World);
|
||||||
|
|
||||||
|
//check if position or rotation had changed and send an update
|
||||||
|
Vector3 position = transform.position;
|
||||||
|
Quaternion rotation = transform.rotation;
|
||||||
|
|
||||||
|
if (lastPosition.x != position.x || lastPosition.y != position.y || lastPosition.z != position.z)
|
||||||
|
{
|
||||||
|
client.SendPositionUpdate(transform.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotation.w != lastRotation.w || rotation.x != lastRotation.x || rotation.y != lastRotation.y ||
|
||||||
|
rotation.z != lastRotation.z)
|
||||||
|
{
|
||||||
|
client.SendRotationUpdate(transform.rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastPosition = new Vector3(transform.position.x, transform.position.y, transform.position.z);
|
||||||
|
lastRotation = transform.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
transform.Rotate(0, Input.GetAxis("Mouse X") * mouseSpeed, 0);
|
//get the player input
|
||||||
camera.transform.Rotate(-Input.GetAxis("Mouse Y") * mouseSpeed, 0, 0);
|
horizontal = Input.GetAxisRaw("Horizontal");
|
||||||
|
vertical = Input.GetAxisRaw("Vertical");
|
||||||
|
mouseX = Input.GetAxis("Mouse X");
|
||||||
|
mouseY = Input.GetAxis("Mouse Y");
|
||||||
|
|
||||||
float up = 0;
|
if (isGrounded && Input.GetButton("Jump"))
|
||||||
if (Input.GetKey(KeyCode.Space))
|
|
||||||
{
|
{
|
||||||
up = 1;
|
jumpRequest = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKey(KeyCode.LeftShift))
|
//get the camera up and down movement and clamp it
|
||||||
{
|
rotX -= mouseY * 1.4f;
|
||||||
up = -1;
|
rotX = Mathf.Clamp(rotX, -90, 90);
|
||||||
}
|
|
||||||
|
|
||||||
transform.Translate(Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime, up * moveSpeed * Time.deltaTime,
|
camera.transform.localRotation = Quaternion.Euler(rotX, 0, 0);
|
||||||
Input.GetAxis("Vertical") * moveSpeed * Time.deltaTime);
|
|
||||||
|
|
||||||
|
transform.Rotate(0, mouseX, 0);
|
||||||
|
|
||||||
|
//send destroy block request to server
|
||||||
if (Input.GetMouseButtonDown(0))
|
if (Input.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
RaycastHit hit;
|
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit))
|
||||||
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit))
|
|
||||||
{
|
{
|
||||||
hit.point += camera.transform.forward / 10;
|
hit.point += camera.transform.forward / 10;
|
||||||
client.EditBlock(hit.point, 0);
|
client.EditBlock(hit.point, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//send build block request to server
|
||||||
if (Input.GetMouseButtonDown(1))
|
if (Input.GetMouseButtonDown(1))
|
||||||
{
|
{
|
||||||
RaycastHit hit;
|
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out RaycastHit hit))
|
||||||
if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit))
|
|
||||||
{
|
{
|
||||||
hit.point -= camera.transform.forward / 10;
|
hit.point -= camera.transform.forward / 10;
|
||||||
client.EditBlock(hit.point, 4);
|
client.EditBlock(hit.point, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CalculateVelocity()
|
||||||
|
{
|
||||||
|
//check if player can accelerate any faster (there is a max speed)
|
||||||
|
if (verticalMomentum > gravity)
|
||||||
|
{
|
||||||
|
verticalMomentum += Time.fixedDeltaTime * gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add velocity for moving, falling and jumping
|
||||||
|
velocity = ((transform.forward * vertical) + (transform.right * horizontal)) * Time.fixedDeltaTime * walkSpeed;
|
||||||
|
velocity += Vector3.up * verticalMomentum * Time.fixedDeltaTime;
|
||||||
|
|
||||||
|
//check colliders on z axis
|
||||||
|
if ((velocity.z > 0 && front) || (velocity.z < 0 && back))
|
||||||
|
{
|
||||||
|
velocity.z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders on x axis
|
||||||
|
if ((velocity.x > 0 && right) || (velocity.x < 0 && left))
|
||||||
|
{
|
||||||
|
velocity.x = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders on y axis
|
||||||
|
if (velocity.y < 0)
|
||||||
|
{
|
||||||
|
velocity.y = CheckDownSpeed(velocity.y);
|
||||||
|
}
|
||||||
|
else if (velocity.y > 0)
|
||||||
|
{
|
||||||
|
velocity.y = CheckUpSpeed(velocity.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
velocity.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for -y
|
||||||
|
private float CheckDownSpeed(float downSpeed)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth, transform.position.y + downSpeed, transform.position.z - playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth, transform.position.y + downSpeed, transform.position.z - playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth, transform.position.y + downSpeed, transform.position.z + playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth, transform.position.y + downSpeed, transform.position.z + playerWidth))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
isGrounded = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
isGrounded = false;
|
||||||
|
return downSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for +y
|
||||||
|
private float CheckUpSpeed(float upSpeed)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth, transform.position.y + upSpeed + 2f, transform.position.z - playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth, transform.position.y + upSpeed + 2f, transform.position.z - playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth, transform.position.y + upSpeed + 2f, transform.position.z + playerWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth, transform.position.y + upSpeed + 2f, transform.position.z + playerWidth))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return upSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for +z
|
||||||
|
public bool front
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x, transform.position.y, transform.position.z + playerWidth + playerOffsetWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z + playerWidth + playerOffsetWidth))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for -z
|
||||||
|
public bool back
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x, transform.position.y, transform.position.z - playerWidth - playerOffsetWidth)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z - playerWidth - playerOffsetWidth))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for -x
|
||||||
|
public bool left
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth - playerOffsetWidth, transform.position.y, transform.position.z )) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x - playerWidth - playerOffsetWidth, transform.position.y + 1f, transform.position.z))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//check colliders for +x
|
||||||
|
public bool right
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth + playerOffsetWidth, transform.position.y, transform.position.z)) ||
|
||||||
|
world.CheckBlock(new Vector3(transform.position.x + playerWidth + playerOffsetWidth, transform.position.y + 1f, transform.position.z))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//stores update data for position and if a player should be removed from the world
|
||||||
|
public class PlayerPositionUpdateData
|
||||||
|
{
|
||||||
|
public PlayerPositionUpdateData(byte id, Vector3 position, bool destroy)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.position = position;
|
||||||
|
this.destroy = destroy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public Vector3 position;
|
||||||
|
public bool destroy;
|
||||||
|
}
|
||||||
|
|
||||||
|
//stores update data for rotations
|
||||||
|
public class PlayerRotationsUpdateData
|
||||||
|
{
|
||||||
|
public byte id;
|
||||||
|
public Quaternion rotation;
|
||||||
|
|
||||||
|
public PlayerRotationsUpdateData(byte id, Quaternion rotation)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.rotation = rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,15 @@ public class World : MonoBehaviour
|
|||||||
{
|
{
|
||||||
//basic
|
//basic
|
||||||
[SerializeField] private Material material;
|
[SerializeField] private Material material;
|
||||||
|
[SerializeField] private GameObject playerPrefab;
|
||||||
public int worldSize;
|
public int worldSize;
|
||||||
private string name;
|
private string name;
|
||||||
private string ip;
|
private Dictionary<byte, GameObject> otherPlayers = new Dictionary<byte, GameObject>();
|
||||||
private int port;
|
private Queue<byte> playersToCreate = new Queue<byte>();
|
||||||
|
private Queue<Player.PlayerPositionUpdateData> playersPositionsToUpdate = new Queue<Player.PlayerPositionUpdateData>();
|
||||||
|
|
||||||
|
private Queue<Player.PlayerRotationsUpdateData> playersRotationsToUpdate =
|
||||||
|
new Queue<Player.PlayerRotationsUpdateData>();
|
||||||
|
|
||||||
//chunks
|
//chunks
|
||||||
private Chunk[,] chunks;
|
private Chunk[,] chunks;
|
||||||
@@ -21,35 +26,104 @@ public class World : MonoBehaviour
|
|||||||
|
|
||||||
//network
|
//network
|
||||||
private Client client;
|
private Client client;
|
||||||
|
private string ip;
|
||||||
|
private int port;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
//get default information
|
||||||
name = PlayerPrefs.GetString("userName");
|
name = PlayerPrefs.GetString("userName");
|
||||||
ip = PlayerPrefs.GetString("serverIP");
|
ip = PlayerPrefs.GetString("serverIP");
|
||||||
port = int.Parse(PlayerPrefs.GetString("port"));
|
port = int.Parse(PlayerPrefs.GetString("port"));
|
||||||
client = new Client(ip, port, this, name);
|
client = new Client(ip, port, this, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//removes a player from the game world
|
||||||
|
public void RemovePlayer(byte id)
|
||||||
|
{
|
||||||
|
playersPositionsToUpdate.Enqueue(new Player.PlayerPositionUpdateData(id, Vector3.zero, true));
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
//update 1 chunk in list
|
||||||
if (chunksToUpdate.Count > 0)
|
if (chunksToUpdate.Count > 0)
|
||||||
{
|
{
|
||||||
ChunkCoord chunk = chunksToUpdate.Dequeue();
|
ChunkCoord chunk = chunksToUpdate.Dequeue();
|
||||||
chunks[chunk.x, chunk.z].Update();
|
chunks[chunk.x, chunk.z].Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//create 1 player in list
|
||||||
|
if (playersToCreate.Count > 0)
|
||||||
|
{
|
||||||
|
byte id = playersToCreate.Dequeue();
|
||||||
|
GameObject player = Instantiate(playerPrefab);
|
||||||
|
player.transform.position = new Vector3((byte)player.transform.position.x,
|
||||||
|
GetHeight((byte)player.transform.position.x, (byte)player.transform.position.z) + 2,
|
||||||
|
(byte)player.transform.position.z);
|
||||||
|
player.transform.SetParent(gameObject.transform);
|
||||||
|
otherPlayers.Add(id, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update 1 player position in list
|
||||||
|
if (playersPositionsToUpdate.Count > 0)
|
||||||
|
{
|
||||||
|
Player.PlayerPositionUpdateData data = playersPositionsToUpdate.Dequeue();
|
||||||
|
otherPlayers.TryGetValue(data.id, out GameObject g);
|
||||||
|
if (g != null)
|
||||||
|
{
|
||||||
|
g.transform.position = data.position;
|
||||||
|
if (data.destroy)
|
||||||
|
{
|
||||||
|
Destroy(g);
|
||||||
|
otherPlayers.Remove(data.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//update 1 player rotation in list
|
||||||
|
if (playersRotationsToUpdate.Count > 0)
|
||||||
|
{
|
||||||
|
Player.PlayerRotationsUpdateData data = playersRotationsToUpdate.Dequeue();
|
||||||
|
otherPlayers.TryGetValue(data.id, out GameObject g);
|
||||||
|
if (g != null)
|
||||||
|
{
|
||||||
|
g.transform.rotation = data.rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//enqueue player position update to list
|
||||||
|
public void UpdatePlayerPosition(Vector3 position, byte id)
|
||||||
|
{
|
||||||
|
playersPositionsToUpdate.Enqueue(new Player.PlayerPositionUpdateData(id, position, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
//enqueue player rotation update to list
|
||||||
|
public void UpdatePlayerRotation(Quaternion rotation, byte id)
|
||||||
|
{
|
||||||
|
playersRotationsToUpdate.Enqueue(new Player.PlayerRotationsUpdateData(id, rotation));
|
||||||
|
}
|
||||||
|
|
||||||
|
//enqueue player create data to list
|
||||||
|
public void AddPlayer(byte id)
|
||||||
|
{
|
||||||
|
playersToCreate.Enqueue(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//creates the array for chunk objects
|
||||||
public void CreateChunkArray()
|
public void CreateChunkArray()
|
||||||
{
|
{
|
||||||
chunks = new Chunk[worldSize, worldSize];
|
chunks = new Chunk[worldSize, worldSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//initialized a chunk
|
||||||
public void InitChunk(int x, int z, byte[,,] blocks)
|
public void InitChunk(int x, int z, byte[,,] blocks)
|
||||||
{
|
{
|
||||||
chunks[x, z] = new Chunk(material, new ChunkCoord(x, z), this, blocks);
|
chunks[x, z] = new Chunk(material, new ChunkCoord(x, z), this, blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//creates an array of chunks
|
//initialized the chunk objects
|
||||||
public void CreateChunks()
|
public void CreateChunks()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < worldSize; x++)
|
for (int x = 0; x < worldSize; x++)
|
||||||
@@ -143,7 +217,8 @@ public class World : MonoBehaviour
|
|||||||
return blockData[blockID].textures;
|
return blockData[blockID].textures;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte GetHeight(int x, int z)
|
//get the perlin noise height
|
||||||
|
public byte GetHeight(int x, int z)
|
||||||
{
|
{
|
||||||
float scale = 0.025f;
|
float scale = 0.025f;
|
||||||
byte perlinHeight = 10;
|
byte perlinHeight = 10;
|
||||||
@@ -153,6 +228,7 @@ public class World : MonoBehaviour
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//edit a block in local chunk storage
|
||||||
public void EditBlock(ChunkCoord chunk, Vector3 positionInChunk, byte blockID)
|
public void EditBlock(ChunkCoord chunk, Vector3 positionInChunk, byte blockID)
|
||||||
{
|
{
|
||||||
byte xInChunk = (byte)(positionInChunk.x);
|
byte xInChunk = (byte)(positionInChunk.x);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ PlayerSettings:
|
|||||||
submitAnalytics: 1
|
submitAnalytics: 1
|
||||||
usePlayerLog: 1
|
usePlayerLog: 1
|
||||||
bakeCollisionMeshes: 0
|
bakeCollisionMeshes: 0
|
||||||
forceSingleInstance: 0
|
forceSingleInstance: 1
|
||||||
useFlipModelSwapchain: 1
|
useFlipModelSwapchain: 1
|
||||||
resizableWindow: 1
|
resizableWindow: 1
|
||||||
useMacAppStoreValidation: 0
|
useMacAppStoreValidation: 0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ TagManager:
|
|||||||
-
|
-
|
||||||
- Water
|
- Water
|
||||||
- UI
|
- UI
|
||||||
-
|
- Culling
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
-
|
-
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class Server
|
|||||||
{
|
{
|
||||||
//game
|
//game
|
||||||
private World world;
|
private World world;
|
||||||
|
private List<Vector3> playerPositions = new List<Vector3>();
|
||||||
|
|
||||||
//network
|
//network
|
||||||
private UdpClient client;
|
private UdpClient client;
|
||||||
@@ -41,9 +42,10 @@ public class Server
|
|||||||
//[0] = 2: world size
|
//[0] = 2: world size
|
||||||
//[0] = 3: edit block
|
//[0] = 3: edit block
|
||||||
//[0] = 4: disconnect player
|
//[0] = 4: disconnect player
|
||||||
//[0] = 5:
|
//[0] = 5: create new player in client
|
||||||
//[0] = 6: player ready
|
//[0] = 6: player ready
|
||||||
//[0] = 7:
|
//[0] = 7: player position update
|
||||||
|
//[0] = 8: player rotation update
|
||||||
|
|
||||||
private void Receive()
|
private void Receive()
|
||||||
{
|
{
|
||||||
@@ -72,19 +74,29 @@ public class Server
|
|||||||
|
|
||||||
if (tempEndPoint != null)
|
if (tempEndPoint != null)
|
||||||
{
|
{
|
||||||
|
foreach (IPEndPoint e in players)
|
||||||
|
{
|
||||||
|
if (i != GetPlayerID(e))
|
||||||
|
{
|
||||||
|
Send(new byte[]{4, (byte)i}, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
players.Remove(tempEndPoint);
|
players.Remove(tempEndPoint);
|
||||||
Console.WriteLine(playerNames[i] + " left the game" + "\n");
|
Console.WriteLine(playerNames[i] + " left the game" + "\n");
|
||||||
playerNames.RemoveAt(i);
|
playerNames.RemoveAt(i);
|
||||||
|
playerPositions.RemoveAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//init message / world transfer
|
||||||
if (data[0] == 0)
|
if (data[0] == 0)
|
||||||
{
|
{
|
||||||
Thread t = new Thread(TransferWorld);
|
Thread t = new Thread(TransferWorld);
|
||||||
t.Start(endPoint);
|
t.Start(endPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get the world size (first message from client)
|
||||||
if (data[0] == 2)
|
if (data[0] == 2)
|
||||||
{
|
{
|
||||||
Send(new byte[] { 2, (byte)world.worldSize }, endPoint);
|
Send(new byte[] { 2, (byte)world.worldSize }, endPoint);
|
||||||
@@ -99,12 +111,30 @@ public class Server
|
|||||||
//add player
|
//add player
|
||||||
players.Add(endPoint);
|
players.Add(endPoint);
|
||||||
playerNames.Add(name);
|
playerNames.Add(name);
|
||||||
|
playerPositions.Add(new Vector3(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//edit a block in world
|
||||||
if (data[0] == 3)
|
if (data[0] == 3)
|
||||||
{
|
{
|
||||||
ChunkCoord chunk = new ChunkCoord(data[1], data[2]);
|
ChunkCoord chunk = new ChunkCoord(data[1], data[2]);
|
||||||
Vector3 positionInChunk = new Vector3(data[3], data[4], data[5]);
|
Vector3 positionInChunk = new Vector3(data[3], data[4], data[5]);
|
||||||
|
Vector3 positionInWorld = new Vector3(chunk.x * Data.chunkWidth + positionInChunk.x,
|
||||||
|
positionInChunk.y, chunk.z * Data.chunkWidth + positionInChunk.z);
|
||||||
|
|
||||||
|
//check that there is no player on the block position
|
||||||
|
bool found = false;
|
||||||
|
foreach (Vector3 v in playerPositions)
|
||||||
|
{
|
||||||
|
if (((int)v.x == (int)positionInWorld.x && (int)v.z == (int)positionInWorld.z) &&
|
||||||
|
((int)v.y == (int)positionInWorld.y || (int)v.y + 1 == (int)positionInWorld.y))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
byte blockID = data[6];
|
byte blockID = data[6];
|
||||||
|
|
||||||
world.EditBlock(chunk, positionInChunk, blockID);
|
world.EditBlock(chunk, positionInChunk, blockID);
|
||||||
@@ -118,13 +148,99 @@ public class Server
|
|||||||
}, e);
|
}, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//a player successfully joined the game...
|
||||||
if (data[0] == 6)
|
if (data[0] == 6)
|
||||||
{
|
{
|
||||||
int id = GetPlayerID(endPoint);
|
int id = GetPlayerID(endPoint);
|
||||||
Console.WriteLine(playerNames[id] + " joined" + "\n");
|
Console.WriteLine(playerNames[id] + " joined" + "\n");
|
||||||
|
|
||||||
|
foreach (IPEndPoint e in players)
|
||||||
|
{
|
||||||
|
if (id != GetPlayerID(e))
|
||||||
|
{
|
||||||
|
//create player objects of that player in every connected client
|
||||||
|
Send(new byte[]{5, (byte)GetPlayerID(e)}, endPoint);
|
||||||
|
//create player objects of all connected clients in the currently connected client
|
||||||
|
Send(new byte[]{5, (byte)GetPlayerID(endPoint)}, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//update a players position on the server
|
||||||
|
if (data[0] == 7)
|
||||||
|
{
|
||||||
|
byte[] positionASCII = new byte[data.Length - 1];
|
||||||
|
for (int i = 0; i < data.Length - 1; i++)
|
||||||
|
{
|
||||||
|
positionASCII[i] = data[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] positionString = Encoding.ASCII.GetString(positionASCII).Split(' ');
|
||||||
|
float x = float.Parse(positionString[0]);
|
||||||
|
float y = float.Parse(positionString[1]);
|
||||||
|
float z = float.Parse(positionString[2]);
|
||||||
|
|
||||||
|
int id = GetPlayerID(endPoint);
|
||||||
|
|
||||||
|
playerPositions[id] = new Vector3(x, y, z);
|
||||||
|
|
||||||
|
string sendPosition = x + " " + y + " " + z;
|
||||||
|
byte[] sendPositionASCII = Encoding.ASCII.GetBytes(sendPosition);
|
||||||
|
byte[] send = new byte[sendPositionASCII.Length + 2];
|
||||||
|
send[0] = 7;
|
||||||
|
send[1] = (byte)id;
|
||||||
|
for (int i = 2; i < send.Length; i++)
|
||||||
|
{
|
||||||
|
send[i] = sendPositionASCII[i - 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
//send update to every other client
|
||||||
|
foreach (IPEndPoint e in players)
|
||||||
|
{
|
||||||
|
if (id != GetPlayerID(e))
|
||||||
|
{
|
||||||
|
Send(send, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//update a players rotation on server
|
||||||
|
if (data[0] == 8)
|
||||||
|
{
|
||||||
|
byte[] rotationASCII = new byte[data.Length - 1];
|
||||||
|
for (int i = 0; i < data.Length - 1; i++)
|
||||||
|
{
|
||||||
|
rotationASCII[i] = data[i + 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] rotationString = Encoding.ASCII.GetString(rotationASCII).Split(' ');
|
||||||
|
string x = rotationString[0];
|
||||||
|
string y = rotationString[1];
|
||||||
|
string z = rotationString[2];
|
||||||
|
string w = rotationString[3];
|
||||||
|
|
||||||
|
byte id = (byte)GetPlayerID(endPoint);
|
||||||
|
string sendRotation = x + " " + y + " " + z + " " + w;
|
||||||
|
byte[] sendRotationASCII = Encoding.ASCII.GetBytes(sendRotation);
|
||||||
|
byte[] send = new byte[sendRotationASCII.Length + 2];
|
||||||
|
send[0] = 8;
|
||||||
|
send[1] = id;
|
||||||
|
|
||||||
|
for (int i = 2; i < send.Length; i++)
|
||||||
|
{
|
||||||
|
send[i] = sendRotationASCII[i - 2];
|
||||||
|
}
|
||||||
|
|
||||||
|
//send update to every other client
|
||||||
|
foreach (IPEndPoint e in players)
|
||||||
|
{
|
||||||
|
if (id != GetPlayerID(e))
|
||||||
|
{
|
||||||
|
Send(send, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -134,6 +250,7 @@ public class Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returns the id of an player
|
||||||
private int GetPlayerID(IPEndPoint endPoint)
|
private int GetPlayerID(IPEndPoint endPoint)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -150,6 +267,7 @@ public class Server
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//starts a tcp client for world transfer
|
||||||
private void TransferWorld(object o)
|
private void TransferWorld(object o)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -201,6 +319,7 @@ public class Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//default send function
|
||||||
private void Send(byte[] data, IPEndPoint endPoint)
|
private void Send(byte[] data, IPEndPoint endPoint)
|
||||||
{
|
{
|
||||||
client.Send(data, data.Length, endPoint);
|
client.Send(data, data.Length, endPoint);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user