Sfoglia il codice sorgente

Added everything :

Unity Client
Unity Server
Standalone Server (no physics engine)
master
Figg 4 anni fa
parent
commit
fb4fbe034d
100 ha cambiato i file con 8542 aggiunte e 0 eliminazioni
  1. 8
    0
      Client/Assets/Materials.meta
  2. 78
    0
      Client/Assets/Materials/LocalPlayer.mat
  3. 8
    0
      Client/Assets/Materials/LocalPlayer.mat.meta
  4. 78
    0
      Client/Assets/Materials/Player.mat
  5. 8
    0
      Client/Assets/Materials/Player.mat.meta
  6. 8
    0
      Client/Assets/Prefabs.meta
  7. 261
    0
      Client/Assets/Prefabs/LocalPlayer.prefab
  8. 7
    0
      Client/Assets/Prefabs/LocalPlayer.prefab.meta
  9. 147
    0
      Client/Assets/Prefabs/Player.prefab
  10. 7
    0
      Client/Assets/Prefabs/Player.prefab.meta
  11. 8
    0
      Client/Assets/Scenes.meta
  12. 1548
    0
      Client/Assets/Scenes/Main.unity
  13. 7
    0
      Client/Assets/Scenes/Main.unity.meta
  14. 63
    0
      Client/Assets/Scenes/MainSettings.lighting
  15. 8
    0
      Client/Assets/Scenes/MainSettings.lighting.meta
  16. 8
    0
      Client/Assets/Scripts.meta
  17. 62
    0
      Client/Assets/Scripts/CameraController.cs
  18. 11
    0
      Client/Assets/Scripts/CameraController.cs.meta
  19. 298
    0
      Client/Assets/Scripts/Client.cs
  20. 11
    0
      Client/Assets/Scripts/Client.cs.meta
  21. 69
    0
      Client/Assets/Scripts/ClientHandle.cs
  22. 11
    0
      Client/Assets/Scripts/ClientHandle.cs.meta
  23. 54
    0
      Client/Assets/Scripts/ClientSend.cs
  24. 11
    0
      Client/Assets/Scripts/ClientSend.cs.meta
  25. 45
    0
      Client/Assets/Scripts/GameManager.cs
  26. 11
    0
      Client/Assets/Scripts/GameManager.cs.meta
  27. 387
    0
      Client/Assets/Scripts/Packet.cs
  28. 11
    0
      Client/Assets/Scripts/Packet.cs.meta
  29. 34
    0
      Client/Assets/Scripts/PlayerController.cs
  30. 11
    0
      Client/Assets/Scripts/PlayerController.cs.meta
  31. 40
    0
      Client/Assets/Scripts/PlayerManager.cs
  32. 11
    0
      Client/Assets/Scripts/PlayerManager.cs.meta
  33. 52
    0
      Client/Assets/Scripts/ThreadManager.cs
  34. 11
    0
      Client/Assets/Scripts/ThreadManager.cs.meta
  35. 37
    0
      Client/Assets/Scripts/UIManager.cs
  36. 11
    0
      Client/Assets/Scripts/UIManager.cs.meta
  37. 46
    0
      Client/Logs/Packages-Update.log
  38. 43
    0
      Client/Packages/manifest.json
  39. 330
    0
      Client/Packages/packages-lock.json
  40. 19
    0
      Client/ProjectSettings/AudioManager.asset
  41. 6
    0
      Client/ProjectSettings/ClusterInputManager.asset
  42. 34
    0
      Client/ProjectSettings/DynamicsManager.asset
  43. 11
    0
      Client/ProjectSettings/EditorBuildSettings.asset
  44. 30
    0
      Client/ProjectSettings/EditorSettings.asset
  45. 63
    0
      Client/ProjectSettings/GraphicsSettings.asset
  46. 295
    0
      Client/ProjectSettings/InputManager.asset
  47. 91
    0
      Client/ProjectSettings/NavMeshAreas.asset
  48. 56
    0
      Client/ProjectSettings/Physics2DSettings.asset
  49. 7
    0
      Client/ProjectSettings/PresetManager.asset
  50. 673
    0
      Client/ProjectSettings/ProjectSettings.asset
  51. 2
    0
      Client/ProjectSettings/ProjectVersion.txt
  52. 232
    0
      Client/ProjectSettings/QualitySettings.asset
  53. 43
    0
      Client/ProjectSettings/TagManager.asset
  54. 9
    0
      Client/ProjectSettings/TimeManager.asset
  55. 34
    0
      Client/ProjectSettings/UnityConnectSettings.asset
  56. 12
    0
      Client/ProjectSettings/VFXManager.asset
  57. 8
    0
      Client/ProjectSettings/VersionControlSettings.asset
  58. 10
    0
      Client/ProjectSettings/XRSettings.asset
  59. 19
    0
      Client/UserSettings/EditorUserSettings.asset
  60. 227
    0
      Server Standalone/GameServer/GameServer/Client.cs
  61. 12
    0
      Server Standalone/GameServer/GameServer/Constants.cs
  62. 21
    0
      Server Standalone/GameServer/GameServer/GameLogic.cs
  63. 386
    0
      Server Standalone/GameServer/GameServer/Packet.cs
  64. 71
    0
      Server Standalone/GameServer/GameServer/Player.cs
  65. 42
    0
      Server Standalone/GameServer/GameServer/Program.cs
  66. 126
    0
      Server Standalone/GameServer/GameServer/Server.cs
  67. 35
    0
      Server Standalone/GameServer/GameServer/ServerHandle.cs
  68. 110
    0
      Server Standalone/GameServer/GameServer/ServerSend.cs
  69. 47
    0
      Server Standalone/GameServer/GameServer/ThreadManager.cs
  70. 34
    0
      Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.deps.json
  71. BIN
      Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.dll
  72. BIN
      Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.exe
  73. 8
    0
      Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.runtimeconfig.dev.json
  74. 9
    0
      Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.runtimeconfig.json
  75. 8
    0
      Server/Assets/Prefabs.meta
  76. 186
    0
      Server/Assets/Prefabs/Player.prefab
  77. 7
    0
      Server/Assets/Prefabs/Player.prefab.meta
  78. 8
    0
      Server/Assets/Scenes.meta
  79. 411
    0
      Server/Assets/Scenes/Game.unity
  80. 7
    0
      Server/Assets/Scenes/Game.unity.meta
  81. 63
    0
      Server/Assets/Scenes/SampleSceneSettings.lighting
  82. 8
    0
      Server/Assets/Scenes/SampleSceneSettings.lighting.meta
  83. 8
    0
      Server/Assets/Scripts.meta
  84. 231
    0
      Server/Assets/Scripts/Client.cs
  85. 11
    0
      Server/Assets/Scripts/Client.cs.meta
  86. 9
    0
      Server/Assets/Scripts/Constants.cs
  87. 11
    0
      Server/Assets/Scripts/Constants.cs.meta
  88. 41
    0
      Server/Assets/Scripts/NetworkManager.cs
  89. 11
    0
      Server/Assets/Scripts/NetworkManager.cs.meta
  90. 387
    0
      Server/Assets/Scripts/Packet.cs
  91. 11
    0
      Server/Assets/Scripts/Packet.cs.meta
  92. 131
    0
      Server/Assets/Scripts/Player.cs
  93. 11
    0
      Server/Assets/Scripts/Player.cs.meta
  94. 131
    0
      Server/Assets/Scripts/Server.cs
  95. 11
    0
      Server/Assets/Scripts/Server.cs.meta
  96. 38
    0
      Server/Assets/Scripts/ServerHandle.cs
  97. 11
    0
      Server/Assets/Scripts/ServerHandle.cs.meta
  98. 139
    0
      Server/Assets/Scripts/ServerSend.cs
  99. 11
    0
      Server/Assets/Scripts/ServerSend.cs.meta
  100. 0
    0
      Server/Assets/Scripts/ThreadManager.cs

+ 8
- 0
Client/Assets/Materials.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: 953df05de29f8f24fb115146faaf9e58
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 78
- 0
Client/Assets/Materials/LocalPlayer.mat Vedi File

@@ -0,0 +1,78 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!21 &2100000
4
+Material:
5
+  serializedVersion: 6
6
+  m_ObjectHideFlags: 0
7
+  m_CorrespondingSourceObject: {fileID: 0}
8
+  m_PrefabInstance: {fileID: 0}
9
+  m_PrefabAsset: {fileID: 0}
10
+  m_Name: LocalPlayer
11
+  m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12
+  m_ShaderKeywords: 
13
+  m_LightmapFlags: 4
14
+  m_EnableInstancingVariants: 0
15
+  m_DoubleSidedGI: 0
16
+  m_CustomRenderQueue: -1
17
+  stringTagMap: {}
18
+  disabledShaderPasses: []
19
+  m_SavedProperties:
20
+    serializedVersion: 3
21
+    m_TexEnvs:
22
+    - _BumpMap:
23
+        m_Texture: {fileID: 0}
24
+        m_Scale: {x: 1, y: 1}
25
+        m_Offset: {x: 0, y: 0}
26
+    - _DetailAlbedoMap:
27
+        m_Texture: {fileID: 0}
28
+        m_Scale: {x: 1, y: 1}
29
+        m_Offset: {x: 0, y: 0}
30
+    - _DetailMask:
31
+        m_Texture: {fileID: 0}
32
+        m_Scale: {x: 1, y: 1}
33
+        m_Offset: {x: 0, y: 0}
34
+    - _DetailNormalMap:
35
+        m_Texture: {fileID: 0}
36
+        m_Scale: {x: 1, y: 1}
37
+        m_Offset: {x: 0, y: 0}
38
+    - _EmissionMap:
39
+        m_Texture: {fileID: 0}
40
+        m_Scale: {x: 1, y: 1}
41
+        m_Offset: {x: 0, y: 0}
42
+    - _MainTex:
43
+        m_Texture: {fileID: 0}
44
+        m_Scale: {x: 1, y: 1}
45
+        m_Offset: {x: 0, y: 0}
46
+    - _MetallicGlossMap:
47
+        m_Texture: {fileID: 0}
48
+        m_Scale: {x: 1, y: 1}
49
+        m_Offset: {x: 0, y: 0}
50
+    - _OcclusionMap:
51
+        m_Texture: {fileID: 0}
52
+        m_Scale: {x: 1, y: 1}
53
+        m_Offset: {x: 0, y: 0}
54
+    - _ParallaxMap:
55
+        m_Texture: {fileID: 0}
56
+        m_Scale: {x: 1, y: 1}
57
+        m_Offset: {x: 0, y: 0}
58
+    m_Floats:
59
+    - _BumpScale: 1
60
+    - _Cutoff: 0.5
61
+    - _DetailNormalMapScale: 1
62
+    - _DstBlend: 0
63
+    - _GlossMapScale: 1
64
+    - _Glossiness: 0.5
65
+    - _GlossyReflections: 1
66
+    - _Metallic: 0
67
+    - _Mode: 0
68
+    - _OcclusionStrength: 1
69
+    - _Parallax: 0.02
70
+    - _SmoothnessTextureChannel: 0
71
+    - _SpecularHighlights: 1
72
+    - _SrcBlend: 1
73
+    - _UVSec: 0
74
+    - _ZWrite: 1
75
+    m_Colors:
76
+    - _Color: {r: 1, g: 0.4481132, b: 0.50367475, a: 1}
77
+    - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78
+  m_BuildTextureStacks: []

+ 8
- 0
Client/Assets/Materials/LocalPlayer.mat.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: 8db1878c25ae486409d6031112f7adb5
3
+NativeFormatImporter:
4
+  externalObjects: {}
5
+  mainObjectFileID: 0
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 78
- 0
Client/Assets/Materials/Player.mat Vedi File

@@ -0,0 +1,78 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!21 &2100000
4
+Material:
5
+  serializedVersion: 6
6
+  m_ObjectHideFlags: 0
7
+  m_CorrespondingSourceObject: {fileID: 0}
8
+  m_PrefabInstance: {fileID: 0}
9
+  m_PrefabAsset: {fileID: 0}
10
+  m_Name: Player
11
+  m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12
+  m_ShaderKeywords: 
13
+  m_LightmapFlags: 4
14
+  m_EnableInstancingVariants: 0
15
+  m_DoubleSidedGI: 0
16
+  m_CustomRenderQueue: -1
17
+  stringTagMap: {}
18
+  disabledShaderPasses: []
19
+  m_SavedProperties:
20
+    serializedVersion: 3
21
+    m_TexEnvs:
22
+    - _BumpMap:
23
+        m_Texture: {fileID: 0}
24
+        m_Scale: {x: 1, y: 1}
25
+        m_Offset: {x: 0, y: 0}
26
+    - _DetailAlbedoMap:
27
+        m_Texture: {fileID: 0}
28
+        m_Scale: {x: 1, y: 1}
29
+        m_Offset: {x: 0, y: 0}
30
+    - _DetailMask:
31
+        m_Texture: {fileID: 0}
32
+        m_Scale: {x: 1, y: 1}
33
+        m_Offset: {x: 0, y: 0}
34
+    - _DetailNormalMap:
35
+        m_Texture: {fileID: 0}
36
+        m_Scale: {x: 1, y: 1}
37
+        m_Offset: {x: 0, y: 0}
38
+    - _EmissionMap:
39
+        m_Texture: {fileID: 0}
40
+        m_Scale: {x: 1, y: 1}
41
+        m_Offset: {x: 0, y: 0}
42
+    - _MainTex:
43
+        m_Texture: {fileID: 0}
44
+        m_Scale: {x: 1, y: 1}
45
+        m_Offset: {x: 0, y: 0}
46
+    - _MetallicGlossMap:
47
+        m_Texture: {fileID: 0}
48
+        m_Scale: {x: 1, y: 1}
49
+        m_Offset: {x: 0, y: 0}
50
+    - _OcclusionMap:
51
+        m_Texture: {fileID: 0}
52
+        m_Scale: {x: 1, y: 1}
53
+        m_Offset: {x: 0, y: 0}
54
+    - _ParallaxMap:
55
+        m_Texture: {fileID: 0}
56
+        m_Scale: {x: 1, y: 1}
57
+        m_Offset: {x: 0, y: 0}
58
+    m_Floats:
59
+    - _BumpScale: 1
60
+    - _Cutoff: 0.5
61
+    - _DetailNormalMapScale: 1
62
+    - _DstBlend: 0
63
+    - _GlossMapScale: 1
64
+    - _Glossiness: 0.5
65
+    - _GlossyReflections: 1
66
+    - _Metallic: 0
67
+    - _Mode: 0
68
+    - _OcclusionStrength: 1
69
+    - _Parallax: 0.02
70
+    - _SmoothnessTextureChannel: 0
71
+    - _SpecularHighlights: 1
72
+    - _SrcBlend: 1
73
+    - _UVSec: 0
74
+    - _ZWrite: 1
75
+    m_Colors:
76
+    - _Color: {r: 0.19900322, g: 0.5310952, b: 0.9811321, a: 1}
77
+    - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78
+  m_BuildTextureStacks: []

+ 8
- 0
Client/Assets/Materials/Player.mat.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: e89c0b8167b23004b8a3ab565f7cd683
3
+NativeFormatImporter:
4
+  externalObjects: {}
5
+  mainObjectFileID: 0
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 8
- 0
Client/Assets/Prefabs.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: f11a499a99e50b5409d7d025ff81f39c
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 261
- 0
Client/Assets/Prefabs/LocalPlayer.prefab Vedi File

@@ -0,0 +1,261 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!1 &1812357814943969944
4
+GameObject:
5
+  m_ObjectHideFlags: 0
6
+  m_CorrespondingSourceObject: {fileID: 0}
7
+  m_PrefabInstance: {fileID: 0}
8
+  m_PrefabAsset: {fileID: 0}
9
+  serializedVersion: 6
10
+  m_Component:
11
+  - component: {fileID: 1041431511750686907}
12
+  - component: {fileID: 2056807471970957764}
13
+  - component: {fileID: 257826213841081018}
14
+  - component: {fileID: 3695191566423652038}
15
+  m_Layer: 0
16
+  m_Name: Camera
17
+  m_TagString: Untagged
18
+  m_Icon: {fileID: 0}
19
+  m_NavMeshLayer: 0
20
+  m_StaticEditorFlags: 0
21
+  m_IsActive: 1
22
+--- !u!4 &1041431511750686907
23
+Transform:
24
+  m_ObjectHideFlags: 0
25
+  m_CorrespondingSourceObject: {fileID: 0}
26
+  m_PrefabInstance: {fileID: 0}
27
+  m_PrefabAsset: {fileID: 0}
28
+  m_GameObject: {fileID: 1812357814943969944}
29
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
30
+  m_LocalPosition: {x: 0, y: 0.5, z: 0}
31
+  m_LocalScale: {x: 1, y: 1, z: 1}
32
+  m_Children: []
33
+  m_Father: {fileID: 45418054428285366}
34
+  m_RootOrder: 1
35
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
36
+--- !u!20 &2056807471970957764
37
+Camera:
38
+  m_ObjectHideFlags: 0
39
+  m_CorrespondingSourceObject: {fileID: 0}
40
+  m_PrefabInstance: {fileID: 0}
41
+  m_PrefabAsset: {fileID: 0}
42
+  m_GameObject: {fileID: 1812357814943969944}
43
+  m_Enabled: 1
44
+  serializedVersion: 2
45
+  m_ClearFlags: 1
46
+  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
47
+  m_projectionMatrixMode: 1
48
+  m_GateFitMode: 2
49
+  m_FOVAxisMode: 0
50
+  m_SensorSize: {x: 36, y: 24}
51
+  m_LensShift: {x: 0, y: 0}
52
+  m_FocalLength: 50
53
+  m_NormalizedViewPortRect:
54
+    serializedVersion: 2
55
+    x: 0
56
+    y: 0
57
+    width: 1
58
+    height: 1
59
+  near clip plane: 0.3
60
+  far clip plane: 1000
61
+  field of view: 60
62
+  orthographic: 0
63
+  orthographic size: 5
64
+  m_Depth: 0
65
+  m_CullingMask:
66
+    serializedVersion: 2
67
+    m_Bits: 4294967295
68
+  m_RenderingPath: -1
69
+  m_TargetTexture: {fileID: 0}
70
+  m_TargetDisplay: 0
71
+  m_TargetEye: 3
72
+  m_HDR: 1
73
+  m_AllowMSAA: 1
74
+  m_AllowDynamicResolution: 0
75
+  m_ForceIntoRT: 0
76
+  m_OcclusionCulling: 1
77
+  m_StereoConvergence: 10
78
+  m_StereoSeparation: 0.022
79
+--- !u!81 &257826213841081018
80
+AudioListener:
81
+  m_ObjectHideFlags: 0
82
+  m_CorrespondingSourceObject: {fileID: 0}
83
+  m_PrefabInstance: {fileID: 0}
84
+  m_PrefabAsset: {fileID: 0}
85
+  m_GameObject: {fileID: 1812357814943969944}
86
+  m_Enabled: 1
87
+--- !u!114 &3695191566423652038
88
+MonoBehaviour:
89
+  m_ObjectHideFlags: 0
90
+  m_CorrespondingSourceObject: {fileID: 0}
91
+  m_PrefabInstance: {fileID: 0}
92
+  m_PrefabAsset: {fileID: 0}
93
+  m_GameObject: {fileID: 1812357814943969944}
94
+  m_Enabled: 1
95
+  m_EditorHideFlags: 0
96
+  m_Script: {fileID: 11500000, guid: 890f95e314ccd1b4a8ebc2967e40c329, type: 3}
97
+  m_Name: 
98
+  m_EditorClassIdentifier: 
99
+  player: {fileID: 1803770970494520731}
100
+  sensitivity: 100
101
+  clampAngle: 85
102
+--- !u!1 &7653160948494156789
103
+GameObject:
104
+  m_ObjectHideFlags: 0
105
+  m_CorrespondingSourceObject: {fileID: 0}
106
+  m_PrefabInstance: {fileID: 0}
107
+  m_PrefabAsset: {fileID: 0}
108
+  serializedVersion: 6
109
+  m_Component:
110
+  - component: {fileID: 45418054428285366}
111
+  - component: {fileID: 1803770970494520731}
112
+  - component: {fileID: 4550656003621098184}
113
+  m_Layer: 0
114
+  m_Name: LocalPlayer
115
+  m_TagString: Untagged
116
+  m_Icon: {fileID: 0}
117
+  m_NavMeshLayer: 0
118
+  m_StaticEditorFlags: 0
119
+  m_IsActive: 1
120
+--- !u!4 &45418054428285366
121
+Transform:
122
+  m_ObjectHideFlags: 0
123
+  m_CorrespondingSourceObject: {fileID: 0}
124
+  m_PrefabInstance: {fileID: 0}
125
+  m_PrefabAsset: {fileID: 0}
126
+  m_GameObject: {fileID: 7653160948494156789}
127
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
128
+  m_LocalPosition: {x: 400, y: 222.16667, z: 0}
129
+  m_LocalScale: {x: 1, y: 1, z: 1}
130
+  m_Children:
131
+  - {fileID: 7988090100498975415}
132
+  - {fileID: 1041431511750686907}
133
+  m_Father: {fileID: 0}
134
+  m_RootOrder: 0
135
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
136
+--- !u!114 &1803770970494520731
137
+MonoBehaviour:
138
+  m_ObjectHideFlags: 0
139
+  m_CorrespondingSourceObject: {fileID: 0}
140
+  m_PrefabInstance: {fileID: 0}
141
+  m_PrefabAsset: {fileID: 0}
142
+  m_GameObject: {fileID: 7653160948494156789}
143
+  m_Enabled: 1
144
+  m_EditorHideFlags: 0
145
+  m_Script: {fileID: 11500000, guid: 1b6d6c3f4ee598345923a54e9d03c528, type: 3}
146
+  m_Name: 
147
+  m_EditorClassIdentifier: 
148
+  id: 0
149
+  username: 
150
+  health: 0
151
+  maxHealth: 100
152
+  model: {fileID: 6429579079514183289}
153
+--- !u!114 &4550656003621098184
154
+MonoBehaviour:
155
+  m_ObjectHideFlags: 0
156
+  m_CorrespondingSourceObject: {fileID: 0}
157
+  m_PrefabInstance: {fileID: 0}
158
+  m_PrefabAsset: {fileID: 0}
159
+  m_GameObject: {fileID: 7653160948494156789}
160
+  m_Enabled: 1
161
+  m_EditorHideFlags: 0
162
+  m_Script: {fileID: 11500000, guid: f4f0d5dfe444a704899ef45cef86fb5c, type: 3}
163
+  m_Name: 
164
+  m_EditorClassIdentifier: 
165
+  camTransform: {fileID: 1041431511750686907}
166
+--- !u!1 &7827230631166118890
167
+GameObject:
168
+  m_ObjectHideFlags: 0
169
+  m_CorrespondingSourceObject: {fileID: 0}
170
+  m_PrefabInstance: {fileID: 0}
171
+  m_PrefabAsset: {fileID: 0}
172
+  serializedVersion: 6
173
+  m_Component:
174
+  - component: {fileID: 7988090100498975415}
175
+  - component: {fileID: 4162494423906124694}
176
+  - component: {fileID: 6429579079514183289}
177
+  - component: {fileID: 1860523273102113808}
178
+  m_Layer: 0
179
+  m_Name: Model
180
+  m_TagString: Untagged
181
+  m_Icon: {fileID: 0}
182
+  m_NavMeshLayer: 0
183
+  m_StaticEditorFlags: 0
184
+  m_IsActive: 1
185
+--- !u!4 &7988090100498975415
186
+Transform:
187
+  m_ObjectHideFlags: 0
188
+  m_CorrespondingSourceObject: {fileID: 0}
189
+  m_PrefabInstance: {fileID: 0}
190
+  m_PrefabAsset: {fileID: 0}
191
+  m_GameObject: {fileID: 7827230631166118890}
192
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
193
+  m_LocalPosition: {x: 0, y: 0, z: 0}
194
+  m_LocalScale: {x: 1, y: 1, z: 1}
195
+  m_Children: []
196
+  m_Father: {fileID: 45418054428285366}
197
+  m_RootOrder: 0
198
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
199
+--- !u!33 &4162494423906124694
200
+MeshFilter:
201
+  m_ObjectHideFlags: 0
202
+  m_CorrespondingSourceObject: {fileID: 0}
203
+  m_PrefabInstance: {fileID: 0}
204
+  m_PrefabAsset: {fileID: 0}
205
+  m_GameObject: {fileID: 7827230631166118890}
206
+  m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
207
+--- !u!23 &6429579079514183289
208
+MeshRenderer:
209
+  m_ObjectHideFlags: 0
210
+  m_CorrespondingSourceObject: {fileID: 0}
211
+  m_PrefabInstance: {fileID: 0}
212
+  m_PrefabAsset: {fileID: 0}
213
+  m_GameObject: {fileID: 7827230631166118890}
214
+  m_Enabled: 1
215
+  m_CastShadows: 1
216
+  m_ReceiveShadows: 1
217
+  m_DynamicOccludee: 1
218
+  m_MotionVectors: 1
219
+  m_LightProbeUsage: 1
220
+  m_ReflectionProbeUsage: 1
221
+  m_RayTracingMode: 2
222
+  m_RayTraceProcedural: 0
223
+  m_RenderingLayerMask: 1
224
+  m_RendererPriority: 0
225
+  m_Materials:
226
+  - {fileID: 2100000, guid: 8db1878c25ae486409d6031112f7adb5, type: 2}
227
+  m_StaticBatchInfo:
228
+    firstSubMesh: 0
229
+    subMeshCount: 0
230
+  m_StaticBatchRoot: {fileID: 0}
231
+  m_ProbeAnchor: {fileID: 0}
232
+  m_LightProbeVolumeOverride: {fileID: 0}
233
+  m_ScaleInLightmap: 1
234
+  m_ReceiveGI: 1
235
+  m_PreserveUVs: 0
236
+  m_IgnoreNormalsForChartDetection: 0
237
+  m_ImportantGI: 0
238
+  m_StitchLightmapSeams: 1
239
+  m_SelectedEditorRenderState: 3
240
+  m_MinimumChartSize: 4
241
+  m_AutoUVMaxDistance: 0.5
242
+  m_AutoUVMaxAngle: 89
243
+  m_LightmapParameters: {fileID: 0}
244
+  m_SortingLayerID: 0
245
+  m_SortingLayer: 0
246
+  m_SortingOrder: 0
247
+  m_AdditionalVertexStreams: {fileID: 0}
248
+--- !u!136 &1860523273102113808
249
+CapsuleCollider:
250
+  m_ObjectHideFlags: 0
251
+  m_CorrespondingSourceObject: {fileID: 0}
252
+  m_PrefabInstance: {fileID: 0}
253
+  m_PrefabAsset: {fileID: 0}
254
+  m_GameObject: {fileID: 7827230631166118890}
255
+  m_Material: {fileID: 0}
256
+  m_IsTrigger: 0
257
+  m_Enabled: 1
258
+  m_Radius: 0.5
259
+  m_Height: 2
260
+  m_Direction: 1
261
+  m_Center: {x: 0, y: 0, z: 0}

+ 7
- 0
Client/Assets/Prefabs/LocalPlayer.prefab.meta Vedi File

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: fed14461b4167eb4d897b53e57f95e22
3
+PrefabImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: 

+ 147
- 0
Client/Assets/Prefabs/Player.prefab Vedi File

@@ -0,0 +1,147 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!1 &7653160948494156789
4
+GameObject:
5
+  m_ObjectHideFlags: 0
6
+  m_CorrespondingSourceObject: {fileID: 0}
7
+  m_PrefabInstance: {fileID: 0}
8
+  m_PrefabAsset: {fileID: 0}
9
+  serializedVersion: 6
10
+  m_Component:
11
+  - component: {fileID: 45418054428285366}
12
+  - component: {fileID: 1803770970494520731}
13
+  m_Layer: 0
14
+  m_Name: Player
15
+  m_TagString: Untagged
16
+  m_Icon: {fileID: 0}
17
+  m_NavMeshLayer: 0
18
+  m_StaticEditorFlags: 0
19
+  m_IsActive: 1
20
+--- !u!4 &45418054428285366
21
+Transform:
22
+  m_ObjectHideFlags: 0
23
+  m_CorrespondingSourceObject: {fileID: 0}
24
+  m_PrefabInstance: {fileID: 0}
25
+  m_PrefabAsset: {fileID: 0}
26
+  m_GameObject: {fileID: 7653160948494156789}
27
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
28
+  m_LocalPosition: {x: 400, y: 222.16667, z: 0}
29
+  m_LocalScale: {x: 1, y: 1, z: 1}
30
+  m_Children:
31
+  - {fileID: 7988090100498975415}
32
+  m_Father: {fileID: 0}
33
+  m_RootOrder: 0
34
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35
+--- !u!114 &1803770970494520731
36
+MonoBehaviour:
37
+  m_ObjectHideFlags: 0
38
+  m_CorrespondingSourceObject: {fileID: 0}
39
+  m_PrefabInstance: {fileID: 0}
40
+  m_PrefabAsset: {fileID: 0}
41
+  m_GameObject: {fileID: 7653160948494156789}
42
+  m_Enabled: 1
43
+  m_EditorHideFlags: 0
44
+  m_Script: {fileID: 11500000, guid: 1b6d6c3f4ee598345923a54e9d03c528, type: 3}
45
+  m_Name: 
46
+  m_EditorClassIdentifier: 
47
+  id: 0
48
+  username: 
49
+  health: 0
50
+  maxHealth: 100
51
+  model: {fileID: 6429579079514183289}
52
+--- !u!1 &7827230631166118890
53
+GameObject:
54
+  m_ObjectHideFlags: 0
55
+  m_CorrespondingSourceObject: {fileID: 0}
56
+  m_PrefabInstance: {fileID: 0}
57
+  m_PrefabAsset: {fileID: 0}
58
+  serializedVersion: 6
59
+  m_Component:
60
+  - component: {fileID: 7988090100498975415}
61
+  - component: {fileID: 4162494423906124694}
62
+  - component: {fileID: 6429579079514183289}
63
+  - component: {fileID: 1860523273102113808}
64
+  m_Layer: 0
65
+  m_Name: Model
66
+  m_TagString: Untagged
67
+  m_Icon: {fileID: 0}
68
+  m_NavMeshLayer: 0
69
+  m_StaticEditorFlags: 0
70
+  m_IsActive: 1
71
+--- !u!4 &7988090100498975415
72
+Transform:
73
+  m_ObjectHideFlags: 0
74
+  m_CorrespondingSourceObject: {fileID: 0}
75
+  m_PrefabInstance: {fileID: 0}
76
+  m_PrefabAsset: {fileID: 0}
77
+  m_GameObject: {fileID: 7827230631166118890}
78
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
79
+  m_LocalPosition: {x: 0, y: 0, z: 0}
80
+  m_LocalScale: {x: 1, y: 1, z: 1}
81
+  m_Children: []
82
+  m_Father: {fileID: 45418054428285366}
83
+  m_RootOrder: 0
84
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
85
+--- !u!33 &4162494423906124694
86
+MeshFilter:
87
+  m_ObjectHideFlags: 0
88
+  m_CorrespondingSourceObject: {fileID: 0}
89
+  m_PrefabInstance: {fileID: 0}
90
+  m_PrefabAsset: {fileID: 0}
91
+  m_GameObject: {fileID: 7827230631166118890}
92
+  m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
93
+--- !u!23 &6429579079514183289
94
+MeshRenderer:
95
+  m_ObjectHideFlags: 0
96
+  m_CorrespondingSourceObject: {fileID: 0}
97
+  m_PrefabInstance: {fileID: 0}
98
+  m_PrefabAsset: {fileID: 0}
99
+  m_GameObject: {fileID: 7827230631166118890}
100
+  m_Enabled: 1
101
+  m_CastShadows: 1
102
+  m_ReceiveShadows: 1
103
+  m_DynamicOccludee: 1
104
+  m_MotionVectors: 1
105
+  m_LightProbeUsage: 1
106
+  m_ReflectionProbeUsage: 1
107
+  m_RayTracingMode: 2
108
+  m_RayTraceProcedural: 0
109
+  m_RenderingLayerMask: 1
110
+  m_RendererPriority: 0
111
+  m_Materials:
112
+  - {fileID: 2100000, guid: e89c0b8167b23004b8a3ab565f7cd683, type: 2}
113
+  m_StaticBatchInfo:
114
+    firstSubMesh: 0
115
+    subMeshCount: 0
116
+  m_StaticBatchRoot: {fileID: 0}
117
+  m_ProbeAnchor: {fileID: 0}
118
+  m_LightProbeVolumeOverride: {fileID: 0}
119
+  m_ScaleInLightmap: 1
120
+  m_ReceiveGI: 1
121
+  m_PreserveUVs: 0
122
+  m_IgnoreNormalsForChartDetection: 0
123
+  m_ImportantGI: 0
124
+  m_StitchLightmapSeams: 1
125
+  m_SelectedEditorRenderState: 3
126
+  m_MinimumChartSize: 4
127
+  m_AutoUVMaxDistance: 0.5
128
+  m_AutoUVMaxAngle: 89
129
+  m_LightmapParameters: {fileID: 0}
130
+  m_SortingLayerID: 0
131
+  m_SortingLayer: 0
132
+  m_SortingOrder: 0
133
+  m_AdditionalVertexStreams: {fileID: 0}
134
+--- !u!136 &1860523273102113808
135
+CapsuleCollider:
136
+  m_ObjectHideFlags: 0
137
+  m_CorrespondingSourceObject: {fileID: 0}
138
+  m_PrefabInstance: {fileID: 0}
139
+  m_PrefabAsset: {fileID: 0}
140
+  m_GameObject: {fileID: 7827230631166118890}
141
+  m_Material: {fileID: 0}
142
+  m_IsTrigger: 0
143
+  m_Enabled: 1
144
+  m_Radius: 0.5
145
+  m_Height: 2
146
+  m_Direction: 1
147
+  m_Center: {x: 0, y: 0, z: 0}

+ 7
- 0
Client/Assets/Prefabs/Player.prefab.meta Vedi File

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: 77249b16d4a36884fa0d0c1e730900aa
3
+PrefabImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: 

+ 8
- 0
Client/Assets/Scenes.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: dfba665f3b6b48d4b97409f7b7ed5d7d
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 1548
- 0
Client/Assets/Scenes/Main.unity
File diff soppresso perché troppo grande
Vedi File


+ 7
- 0
Client/Assets/Scenes/Main.unity.meta Vedi File

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: 9fc0d4010bbf28b4594072e72b8655ab
3
+DefaultImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: 

+ 63
- 0
Client/Assets/Scenes/MainSettings.lighting Vedi File

@@ -0,0 +1,63 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!850595691 &4890085278179872738
4
+LightingSettings:
5
+  m_ObjectHideFlags: 0
6
+  m_CorrespondingSourceObject: {fileID: 0}
7
+  m_PrefabInstance: {fileID: 0}
8
+  m_PrefabAsset: {fileID: 0}
9
+  m_Name: MainSettings
10
+  serializedVersion: 2
11
+  m_GIWorkflowMode: 1
12
+  m_EnableBakedLightmaps: 1
13
+  m_EnableRealtimeLightmaps: 0
14
+  m_RealtimeEnvironmentLighting: 1
15
+  m_BounceScale: 1
16
+  m_AlbedoBoost: 1
17
+  m_IndirectOutputScale: 1
18
+  m_UsingShadowmask: 1
19
+  m_BakeBackend: 1
20
+  m_LightmapMaxSize: 1024
21
+  m_BakeResolution: 40
22
+  m_Padding: 2
23
+  m_TextureCompression: 1
24
+  m_AO: 0
25
+  m_AOMaxDistance: 1
26
+  m_CompAOExponent: 1
27
+  m_CompAOExponentDirect: 0
28
+  m_ExtractAO: 0
29
+  m_MixedBakeMode: 2
30
+  m_LightmapsBakeMode: 1
31
+  m_FilterMode: 1
32
+  m_LightmapParameters: {fileID: 0}
33
+  m_ExportTrainingData: 0
34
+  m_TrainingDataDestination: TrainingData
35
+  m_RealtimeResolution: 2
36
+  m_ForceWhiteAlbedo: 0
37
+  m_ForceUpdates: 0
38
+  m_FinalGather: 0
39
+  m_FinalGatherRayCount: 256
40
+  m_FinalGatherFiltering: 1
41
+  m_PVRCulling: 1
42
+  m_PVRSampling: 1
43
+  m_PVRDirectSampleCount: 32
44
+  m_PVRSampleCount: 500
45
+  m_PVREnvironmentSampleCount: 500
46
+  m_PVREnvironmentReferencePointCount: 2048
47
+  m_LightProbeSampleCountMultiplier: 4
48
+  m_PVRBounces: 2
49
+  m_PVRRussianRouletteStartBounce: 2
50
+  m_PVREnvironmentMIS: 0
51
+  m_PVRFilteringMode: 2
52
+  m_PVRDenoiserTypeDirect: 0
53
+  m_PVRDenoiserTypeIndirect: 0
54
+  m_PVRDenoiserTypeAO: 0
55
+  m_PVRFilterTypeDirect: 0
56
+  m_PVRFilterTypeIndirect: 0
57
+  m_PVRFilterTypeAO: 0
58
+  m_PVRFilteringGaussRadiusDirect: 1
59
+  m_PVRFilteringGaussRadiusIndirect: 5
60
+  m_PVRFilteringGaussRadiusAO: 2
61
+  m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62
+  m_PVRFilteringAtrousPositionSigmaIndirect: 2
63
+  m_PVRFilteringAtrousPositionSigmaAO: 1

+ 8
- 0
Client/Assets/Scenes/MainSettings.lighting.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: 1716d9329ee3a094d8560d5a79d46e88
3
+NativeFormatImporter:
4
+  externalObjects: {}
5
+  mainObjectFileID: 0
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 8
- 0
Client/Assets/Scripts.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: fc8d382e776b86b499e211021d41e296
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 62
- 0
Client/Assets/Scripts/CameraController.cs Vedi File

@@ -0,0 +1,62 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class CameraController : MonoBehaviour
6
+{
7
+    public PlayerManager player;
8
+    public float sensitivity = 100f;
9
+    public float clampAngle = 85f;
10
+
11
+    private float verticalRotation;
12
+    private float horizontalRotation;
13
+
14
+    private void Start()
15
+    {
16
+        verticalRotation = transform.eulerAngles.x;
17
+        horizontalRotation = transform.eulerAngles.y;
18
+    }
19
+
20
+    private void Update()
21
+    {
22
+        if (Input.GetKeyDown(KeyCode.Escape))
23
+        {
24
+            ToggleCursorMode();
25
+        }
26
+
27
+        if (Cursor.lockState == CursorLockMode.Locked)
28
+        {
29
+            Look();
30
+        }
31
+        
32
+        Debug.DrawRay(transform.position, transform.forward * 2, Color.red);
33
+    }
34
+
35
+    private void Look()
36
+    {
37
+        float _mouseVertical = -Input.GetAxis("Mouse Y");
38
+        float _mouseHorizontal = Input.GetAxis("Mouse X");
39
+
40
+        verticalRotation += _mouseVertical * sensitivity * Time.deltaTime;
41
+        horizontalRotation += _mouseHorizontal * sensitivity * Time.deltaTime;
42
+
43
+        verticalRotation = Mathf.Clamp(verticalRotation, -clampAngle, clampAngle);
44
+
45
+        transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
46
+        player.transform.rotation = Quaternion.Euler(0 , horizontalRotation, 0);
47
+    }
48
+
49
+    private void ToggleCursorMode()
50
+    {
51
+        Cursor.visible = !Cursor.visible;
52
+
53
+        if (Cursor.lockState == CursorLockMode.None)
54
+        {
55
+            Cursor.lockState = CursorLockMode.Locked;
56
+        }
57
+        else
58
+        {
59
+            Cursor.lockState = CursorLockMode.None;
60
+        }
61
+    }
62
+}

+ 11
- 0
Client/Assets/Scripts/CameraController.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 890f95e314ccd1b4a8ebc2967e40c329
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 298
- 0
Client/Assets/Scripts/Client.cs Vedi File

@@ -0,0 +1,298 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+using System.Net;
5
+using System.Net.Sockets;
6
+using System;
7
+
8
+public class Client : MonoBehaviour
9
+{
10
+    public static Client instance;
11
+    public static int dataBufferSize = 4096;
12
+
13
+    public string ip = "127.0.0.1";
14
+    public int port = 26950;
15
+    public int myId = 0;
16
+    public TCP tcp;
17
+    public UDP udp;
18
+
19
+    private bool isConnected = false;
20
+    private delegate void PacketHandler(Packet _packet);
21
+    private static Dictionary<int, PacketHandler> packetHandlers;
22
+
23
+    private void Awake()
24
+    {
25
+        if (instance == null)
26
+        {
27
+            instance = this;
28
+        }
29
+        else if (instance != this)
30
+        {
31
+            Debug.Log("Instance already exists. Destroying object !");
32
+            Destroy(this);
33
+        }
34
+    }
35
+
36
+    private void Start()
37
+    {
38
+        tcp = new TCP();
39
+        udp = new UDP();
40
+    }
41
+
42
+    private void OnApplicationQuit()
43
+    {
44
+        Disconnect();
45
+    }
46
+
47
+    public void ConnectToServer()
48
+    {
49
+        InitializeClientData();
50
+
51
+        isConnected = true;
52
+        tcp.Connect();
53
+    }
54
+
55
+    public class TCP
56
+    {
57
+        public TcpClient socket;
58
+
59
+        private NetworkStream stream;
60
+        private Packet receivedData;
61
+        private byte[] receiveBuffer;
62
+
63
+        public void Connect()
64
+        {
65
+            socket = new TcpClient
66
+            {
67
+                ReceiveBufferSize = dataBufferSize,
68
+                SendBufferSize = dataBufferSize
69
+            };
70
+
71
+            receiveBuffer = new byte[dataBufferSize];
72
+            socket.BeginConnect(instance.ip, instance.port, ConnectCallback, socket);
73
+        }
74
+        
75
+        private void ConnectCallback(IAsyncResult _result)
76
+        {
77
+            socket.EndConnect(_result);
78
+            Debug.Log("test");
79
+            if (!socket.Connected)
80
+            {
81
+                Debug.Log("Couldn't connect"); 
82
+                return;
83
+            }
84
+
85
+            stream = socket.GetStream();
86
+
87
+            receivedData = new Packet();
88
+
89
+            stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
90
+        }
91
+
92
+        public void SendData(Packet _packet)
93
+        {
94
+            try
95
+            {
96
+                if (socket != null)
97
+                {
98
+                    stream.BeginWrite(_packet.ToArray(), 0, _packet.Length(), null, null);
99
+                }
100
+            }
101
+            catch (Exception _ex)
102
+            {
103
+                Debug.Log($"Error sending data to server via TCP : {_ex}");
104
+            }
105
+        }
106
+
107
+        private void ReceiveCallback(IAsyncResult _result)
108
+        {
109
+            try
110
+            {
111
+                int _byteLength = stream.EndRead(_result);
112
+                if (_byteLength <= 0)
113
+                {
114
+                    instance.Disconnect();
115
+                    return;
116
+                }
117
+
118
+                byte[] _data = new byte[_byteLength];
119
+                Array.Copy(receiveBuffer, _data, _byteLength);
120
+
121
+                receivedData.Reset(HandleData(_data));
122
+                stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
123
+
124
+            }
125
+            catch (Exception)
126
+            {
127
+                Disconnect();
128
+            }
129
+        }
130
+
131
+        private bool HandleData(byte[] _data)
132
+        {
133
+            int _packetLength = 0;
134
+
135
+            receivedData.SetBytes(_data);
136
+
137
+            if (receivedData.UnreadLength() >= 4)
138
+            {
139
+                _packetLength = receivedData.ReadInt();
140
+                if (_packetLength <= 0)
141
+                {
142
+                    return true;
143
+                }
144
+            }
145
+
146
+            while (_packetLength > 0 && _packetLength <= receivedData.UnreadLength())
147
+            {
148
+                byte[] _packetBytes = receivedData.ReadBytes(_packetLength);
149
+                ThreadManager.ExecuteOnMainThread(() =>
150
+                {
151
+                    using (Packet _packet = new Packet(_packetBytes))
152
+                    {
153
+                        int _packetId = _packet.ReadInt();
154
+                        packetHandlers[_packetId](_packet);
155
+                    }
156
+                });
157
+
158
+                _packetLength = 0;
159
+                if (receivedData.UnreadLength() >= 4)
160
+                {
161
+                    _packetLength = receivedData.ReadInt();
162
+                    if (_packetLength <= 0)
163
+                    {
164
+                        return true;
165
+                    }
166
+                }
167
+            }
168
+
169
+            if (_packetLength <= 1)
170
+            {
171
+                return true;
172
+            }
173
+
174
+            return false;
175
+        }
176
+
177
+        private void Disconnect()
178
+        {
179
+            instance.Disconnect();
180
+
181
+            stream = null;
182
+            receivedData = null;
183
+            receiveBuffer = null;
184
+            socket = null;
185
+        }
186
+    }
187
+
188
+    public class UDP
189
+    {
190
+        public UdpClient socket;
191
+        public IPEndPoint endPoint;
192
+
193
+        public void Connect(int _localPort)
194
+        {
195
+            socket = new UdpClient(_localPort);
196
+
197
+            endPoint = new IPEndPoint(IPAddress.Parse(instance.ip), instance.port);
198
+            socket.Connect(endPoint);
199
+            socket.BeginReceive(ReceiveCallback, null);
200
+
201
+            using (Packet _packet = new Packet())
202
+            {
203
+                SendData(_packet);
204
+            }
205
+        }
206
+
207
+        public void SendData(Packet _packet)
208
+        {
209
+            try
210
+            {
211
+                _packet.InsertInt(instance.myId);
212
+                if (socket != null)
213
+                {
214
+                    socket.BeginSend(_packet.ToArray(), _packet.Length(), null, null);
215
+                }
216
+            }
217
+            catch (Exception _ex)
218
+            {
219
+                Debug.Log($"Error sending data to server via UDP : {_ex}");
220
+            }
221
+        }
222
+
223
+        private void ReceiveCallback(IAsyncResult _result)
224
+        {
225
+            try
226
+            {
227
+                byte[] _data = socket.EndReceive(_result, ref endPoint);
228
+                socket.BeginReceive(ReceiveCallback, null);
229
+
230
+                if (_data.Length < 4)
231
+                {
232
+                    instance.Disconnect();
233
+                    return;
234
+                }
235
+
236
+                HandleData(_data);
237
+            }
238
+            catch (Exception)
239
+            {
240
+                Disconnect();
241
+            }
242
+        }
243
+
244
+        private void HandleData(byte[] _data)
245
+        {
246
+            using (Packet _packet = new Packet(_data))
247
+            {
248
+                int _packetLength = _packet.ReadInt();
249
+                _data = _packet.ReadBytes(_packetLength);
250
+            }
251
+
252
+            ThreadManager.ExecuteOnMainThread(() =>
253
+            {
254
+                using (Packet _packet = new Packet(_data))
255
+                {
256
+                    int _packetId = _packet.ReadInt();
257
+                    packetHandlers[_packetId](_packet);
258
+                }
259
+            });
260
+        }
261
+
262
+        private void Disconnect()
263
+        {
264
+            instance.Disconnect();
265
+
266
+            endPoint = null;
267
+            socket = null;
268
+        }
269
+    }
270
+
271
+    private void InitializeClientData()
272
+    {
273
+        packetHandlers = new Dictionary<int, PacketHandler>()
274
+        {
275
+            { (int)ServerPackets.welcome, ClientHandle.Welcome },
276
+            { (int)ServerPackets.spawnPlayer, ClientHandle.SpawnPlayer },
277
+            { (int)ServerPackets.playerPosition, ClientHandle.PlayerPosition },
278
+            { (int)ServerPackets.playerRotation, ClientHandle.PlayerRotation },
279
+            { (int)ServerPackets.playerDisconnected, ClientHandle.PlayerDisconnected },
280
+            { (int)ServerPackets.playerHealth, ClientHandle.PlayerHealth },
281
+            { (int)ServerPackets.playerRespawned, ClientHandle.PlayerRespawned }
282
+
283
+        };
284
+        Debug.Log("Initialized packets.");
285
+    }
286
+
287
+    private void Disconnect()
288
+    {
289
+        if (isConnected)
290
+        {
291
+            isConnected = false;
292
+            tcp.socket.Close();
293
+            udp.socket.Close();
294
+
295
+            Debug.Log("Disconnected from server");
296
+        }
297
+    }
298
+}

+ 11
- 0
Client/Assets/Scripts/Client.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 131588d54708a534897302729994d77f
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 69
- 0
Client/Assets/Scripts/ClientHandle.cs Vedi File

@@ -0,0 +1,69 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using System.IO.Pipes;
4
+using System.Net;
5
+using UnityEngine;
6
+
7
+public class ClientHandle : MonoBehaviour
8
+{
9
+    public static void Welcome(Packet _packet)
10
+    {
11
+        string _msg = _packet.ReadString();
12
+        int _myId = _packet.ReadInt();
13
+
14
+        Debug.Log($"Message from the server: {_msg}");
15
+        Client.instance.myId = _myId;
16
+        ClientSend.WelcomeReceived();
17
+
18
+        Client.instance.udp.Connect(((IPEndPoint) Client.instance.tcp.socket.Client.LocalEndPoint).Port);
19
+    }
20
+
21
+    public static void SpawnPlayer(Packet _packet)
22
+    {
23
+        int _id = _packet.ReadInt();
24
+        string _username = _packet.ReadString();
25
+        Vector3 _position = _packet.ReadVector3();
26
+        Quaternion _rotation = _packet.ReadQuaternion();
27
+
28
+        GameManager.instance.SpawnPlayer(_id, _username, _position, _rotation);
29
+    }
30
+
31
+    public static void PlayerPosition(Packet _packet)
32
+    {
33
+        int _id = _packet.ReadInt();
34
+        Vector3 _position = _packet.ReadVector3();
35
+
36
+        GameManager.players[_id].transform.position = _position;
37
+    }
38
+
39
+    public static void PlayerRotation(Packet _packet)
40
+    {
41
+        int _id = _packet.ReadInt();
42
+        Quaternion _rotation = _packet.ReadQuaternion();
43
+
44
+        GameManager.players[_id].transform.rotation = _rotation;
45
+    }
46
+
47
+    public static void PlayerDisconnected(Packet _packet)
48
+    {
49
+        int _id = _packet.ReadInt();
50
+
51
+        Destroy(GameManager.players[_id].gameObject);
52
+        GameManager.players.Remove(_id);
53
+    }
54
+
55
+    public static void PlayerHealth(Packet _packet)
56
+    {
57
+        int _id = _packet.ReadInt();
58
+        float _health = _packet.ReadFloat();
59
+
60
+        GameManager.players[_id].SetHealth(_health);
61
+    }
62
+
63
+    public static void PlayerRespawned(Packet _packet)
64
+    {
65
+        int _id = _packet.ReadInt();
66
+
67
+        GameManager.players[_id].Respawn();
68
+    }
69
+}

+ 11
- 0
Client/Assets/Scripts/ClientHandle.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: fd0e1bf0142ed844698a09b38e5a861f
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 54
- 0
Client/Assets/Scripts/ClientSend.cs Vedi File

@@ -0,0 +1,54 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class ClientSend : MonoBehaviour
6
+{
7
+    private static void SendTCPData(Packet _packet)
8
+    {
9
+        _packet.WriteLength();
10
+        Client.instance.tcp.SendData(_packet);
11
+    }
12
+
13
+    private static void SendUDPData(Packet _packet)
14
+    {
15
+        _packet.WriteLength();
16
+        Client.instance.udp.SendData(_packet);
17
+    }
18
+
19
+    #region packets
20
+    public static void WelcomeReceived()
21
+    {
22
+        using (Packet _packet = new Packet((int)ClientPackets.welcomeReceived))
23
+        {
24
+            _packet.Write(Client.instance.myId);
25
+            _packet.Write(UIManager.instance.usernameField.text);
26
+
27
+            SendTCPData(_packet);
28
+        }
29
+    }
30
+
31
+    public static void PlayerMovement(bool[] _inputs)
32
+    {
33
+        using (Packet _packet = new Packet((int)ClientPackets.playerMovement))
34
+        {
35
+            _packet.Write(_inputs.Length);
36
+            foreach (bool _input in _inputs)
37
+            {
38
+                _packet.Write(_input);
39
+            }
40
+            _packet.Write(GameManager.players[Client.instance.myId].transform.rotation);
41
+            SendUDPData(_packet);
42
+        }
43
+    }
44
+
45
+    public static void PlayerShoot(Vector3 _facing)
46
+    {
47
+        using (Packet _packet = new Packet((int)ClientPackets.playerShoot))
48
+        {
49
+            _packet.Write(_facing);
50
+            SendTCPData(_packet);
51
+        }
52
+    }
53
+    #endregion
54
+}

+ 11
- 0
Client/Assets/Scripts/ClientSend.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 744c270a1eecf9244b858106ed9c6797
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 45
- 0
Client/Assets/Scripts/GameManager.cs Vedi File

@@ -0,0 +1,45 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using System.Runtime.InteropServices.ComTypes;
4
+using UnityEngine;
5
+
6
+public class GameManager : MonoBehaviour
7
+{
8
+    public static GameManager instance;
9
+
10
+    public static Dictionary<int, PlayerManager> players = new Dictionary<int, PlayerManager>();
11
+
12
+    public GameObject localPlayerPrefab;
13
+    public GameObject playerPrefab;
14
+
15
+
16
+    private void Awake()
17
+    {
18
+        if (instance == null)
19
+        {
20
+            instance = this;
21
+        }
22
+        else if (instance != this)
23
+        {
24
+            Debug.Log("Instance already exists. Destroying object !");
25
+            Destroy(this);
26
+        }
27
+    }
28
+
29
+    public void SpawnPlayer(int _id, string _username, Vector3 _position, Quaternion _rotation)
30
+    {
31
+        GameObject _player;
32
+
33
+        if(_id == Client.instance.myId)
34
+        {
35
+            _player = Instantiate(localPlayerPrefab, _position, _rotation);
36
+        } else
37
+        {
38
+            _player = Instantiate(playerPrefab, _position, _rotation);
39
+        }
40
+
41
+        _player.GetComponent<PlayerManager>().Initialize(_id, _username);
42
+
43
+        players.Add(_id, _player.GetComponent<PlayerManager>());
44
+    }
45
+}

+ 11
- 0
Client/Assets/Scripts/GameManager.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: ca3bb586695c6e94fb28f94fc9b3da31
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 387
- 0
Client/Assets/Scripts/Packet.cs Vedi File

@@ -0,0 +1,387 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using UnityEngine;
5
+
6
+/// <summary>Sent from server to client.</summary>
7
+public enum ServerPackets
8
+{
9
+    welcome = 1,
10
+    spawnPlayer,
11
+    playerPosition,
12
+    playerRotation,
13
+    playerDisconnected,
14
+    playerHealth,
15
+    playerRespawned
16
+}
17
+
18
+/// <summary>Sent from client to server.</summary>
19
+public enum ClientPackets
20
+{
21
+    welcomeReceived = 1,
22
+    playerMovement,
23
+    playerShoot
24
+}
25
+
26
+public class Packet : IDisposable
27
+{
28
+    private List<byte> buffer;
29
+    private byte[] readableBuffer;
30
+    private int readPos;
31
+
32
+    /// <summary>Creates a new empty packet (without an ID).</summary>
33
+    public Packet()
34
+    {
35
+        buffer = new List<byte>(); // Intitialize buffer
36
+        readPos = 0; // Set readPos to 0
37
+    }
38
+
39
+    /// <summary>Creates a new packet with a given ID. Used for sending.</summary>
40
+    /// <param name="_id">The packet ID.</param>
41
+    public Packet(int _id)
42
+    {
43
+        buffer = new List<byte>(); // Intitialize buffer
44
+        readPos = 0; // Set readPos to 0
45
+
46
+        Write(_id); // Write packet id to the buffer
47
+    }
48
+
49
+    /// <summary>Creates a packet from which data can be read. Used for receiving.</summary>
50
+    /// <param name="_data">The bytes to add to the packet.</param>
51
+    public Packet(byte[] _data)
52
+    {
53
+        buffer = new List<byte>(); // Intitialize buffer
54
+        readPos = 0; // Set readPos to 0
55
+
56
+        SetBytes(_data);
57
+    }
58
+
59
+    #region Functions
60
+    /// <summary>Sets the packet's content and prepares it to be read.</summary>
61
+    /// <param name="_data">The bytes to add to the packet.</param>
62
+    public void SetBytes(byte[] _data)
63
+    {
64
+        Write(_data);
65
+        readableBuffer = buffer.ToArray();
66
+    }
67
+
68
+    /// <summary>Inserts the length of the packet's content at the start of the buffer.</summary>
69
+    public void WriteLength()
70
+    {
71
+        buffer.InsertRange(0, BitConverter.GetBytes(buffer.Count)); // Insert the byte length of the packet at the very beginning
72
+    }
73
+
74
+    /// <summary>Inserts the given int at the start of the buffer.</summary>
75
+    /// <param name="_value">The int to insert.</param>
76
+    public void InsertInt(int _value)
77
+    {
78
+        buffer.InsertRange(0, BitConverter.GetBytes(_value)); // Insert the int at the start of the buffer
79
+    }
80
+
81
+    /// <summary>Gets the packet's content in array form.</summary>
82
+    public byte[] ToArray()
83
+    {
84
+        readableBuffer = buffer.ToArray();
85
+        return readableBuffer;
86
+    }
87
+
88
+    /// <summary>Gets the length of the packet's content.</summary>
89
+    public int Length()
90
+    {
91
+        return buffer.Count; // Return the length of buffer
92
+    }
93
+
94
+    /// <summary>Gets the length of the unread data contained in the packet.</summary>
95
+    public int UnreadLength()
96
+    {
97
+        return Length() - readPos; // Return the remaining length (unread)
98
+    }
99
+
100
+    /// <summary>Resets the packet instance to allow it to be reused.</summary>
101
+    /// <param name="_shouldReset">Whether or not to reset the packet.</param>
102
+    public void Reset(bool _shouldReset = true)
103
+    {
104
+        if (_shouldReset)
105
+        {
106
+            buffer.Clear(); // Clear buffer
107
+            readableBuffer = null;
108
+            readPos = 0; // Reset readPos
109
+        }
110
+        else
111
+        {
112
+            readPos -= 4; // "Unread" the last read int
113
+        }
114
+    }
115
+    #endregion
116
+
117
+    #region Write Data
118
+    /// <summary>Adds a byte to the packet.</summary>
119
+    /// <param name="_value">The byte to add.</param>
120
+    public void Write(byte _value)
121
+    {
122
+        buffer.Add(_value);
123
+    }
124
+    /// <summary>Adds an array of bytes to the packet.</summary>
125
+    /// <param name="_value">The byte array to add.</param>
126
+    public void Write(byte[] _value)
127
+    {
128
+        buffer.AddRange(_value);
129
+    }
130
+    /// <summary>Adds a short to the packet.</summary>
131
+    /// <param name="_value">The short to add.</param>
132
+    public void Write(short _value)
133
+    {
134
+        buffer.AddRange(BitConverter.GetBytes(_value));
135
+    }
136
+    /// <summary>Adds an int to the packet.</summary>
137
+    /// <param name="_value">The int to add.</param>
138
+    public void Write(int _value)
139
+    {
140
+        buffer.AddRange(BitConverter.GetBytes(_value));
141
+    }
142
+    /// <summary>Adds a long to the packet.</summary>
143
+    /// <param name="_value">The long to add.</param>
144
+    public void Write(long _value)
145
+    {
146
+        buffer.AddRange(BitConverter.GetBytes(_value));
147
+    }
148
+    /// <summary>Adds a float to the packet.</summary>
149
+    /// <param name="_value">The float to add.</param>
150
+    public void Write(float _value)
151
+    {
152
+        buffer.AddRange(BitConverter.GetBytes(_value));
153
+    }
154
+    /// <summary>Adds a bool to the packet.</summary>
155
+    /// <param name="_value">The bool to add.</param>
156
+    public void Write(bool _value)
157
+    {
158
+        buffer.AddRange(BitConverter.GetBytes(_value));
159
+    }
160
+    /// <summary>Adds a string to the packet.</summary>
161
+    /// <param name="_value">The string to add.</param>
162
+    public void Write(string _value)
163
+    {
164
+        Write(_value.Length); // Add the length of the string to the packet
165
+        buffer.AddRange(Encoding.ASCII.GetBytes(_value)); // Add the string itself
166
+    }
167
+
168
+    public void Write(Vector3 _value)
169
+    {
170
+        Write(_value.x);
171
+        Write(_value.y);
172
+        Write(_value.z);
173
+    }
174
+
175
+    public void Write(Quaternion _value)
176
+    {
177
+        Write(_value.x);
178
+        Write(_value.y);
179
+        Write(_value.z);
180
+        Write(_value.w);
181
+    }
182
+    #endregion
183
+
184
+    #region Read Data
185
+    /// <summary>Reads a byte from the packet.</summary>
186
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
187
+    public byte ReadByte(bool _moveReadPos = true)
188
+    {
189
+        if (buffer.Count > readPos)
190
+        {
191
+            // If there are unread bytes
192
+            byte _value = readableBuffer[readPos]; // Get the byte at readPos' position
193
+            if (_moveReadPos)
194
+            {
195
+                // If _moveReadPos is true
196
+                readPos += 1; // Increase readPos by 1
197
+            }
198
+            return _value; // Return the byte
199
+        }
200
+        else
201
+        {
202
+            throw new Exception("Could not read value of type 'byte'!");
203
+        }
204
+    }
205
+
206
+    /// <summary>Reads an array of bytes from the packet.</summary>
207
+    /// <param name="_length">The length of the byte array.</param>
208
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
209
+    public byte[] ReadBytes(int _length, bool _moveReadPos = true)
210
+    {
211
+        if (buffer.Count > readPos)
212
+        {
213
+            // If there are unread bytes
214
+            byte[] _value = buffer.GetRange(readPos, _length).ToArray(); // Get the bytes at readPos' position with a range of _length
215
+            if (_moveReadPos)
216
+            {
217
+                // If _moveReadPos is true
218
+                readPos += _length; // Increase readPos by _length
219
+            }
220
+            return _value; // Return the bytes
221
+        }
222
+        else
223
+        {
224
+            throw new Exception("Could not read value of type 'byte[]'!");
225
+        }
226
+    }
227
+
228
+    /// <summary>Reads a short from the packet.</summary>
229
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
230
+    public short ReadShort(bool _moveReadPos = true)
231
+    {
232
+        if (buffer.Count > readPos)
233
+        {
234
+            // If there are unread bytes
235
+            short _value = BitConverter.ToInt16(readableBuffer, readPos); // Convert the bytes to a short
236
+            if (_moveReadPos)
237
+            {
238
+                // If _moveReadPos is true and there are unread bytes
239
+                readPos += 2; // Increase readPos by 2
240
+            }
241
+            return _value; // Return the short
242
+        }
243
+        else
244
+        {
245
+            throw new Exception("Could not read value of type 'short'!");
246
+        }
247
+    }
248
+
249
+    /// <summary>Reads an int from the packet.</summary>
250
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
251
+    public int ReadInt(bool _moveReadPos = true)
252
+    {
253
+        if (buffer.Count > readPos)
254
+        {
255
+            // If there are unread bytes
256
+            int _value = BitConverter.ToInt32(readableBuffer, readPos); // Convert the bytes to an int
257
+            if (_moveReadPos)
258
+            {
259
+                // If _moveReadPos is true
260
+                readPos += 4; // Increase readPos by 4
261
+            }
262
+            return _value; // Return the int
263
+        }
264
+        else
265
+        {
266
+            throw new Exception("Could not read value of type 'int'!");
267
+        }
268
+    }
269
+
270
+    /// <summary>Reads a long from the packet.</summary>
271
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
272
+    public long ReadLong(bool _moveReadPos = true)
273
+    {
274
+        if (buffer.Count > readPos)
275
+        {
276
+            // If there are unread bytes
277
+            long _value = BitConverter.ToInt64(readableBuffer, readPos); // Convert the bytes to a long
278
+            if (_moveReadPos)
279
+            {
280
+                // If _moveReadPos is true
281
+                readPos += 8; // Increase readPos by 8
282
+            }
283
+            return _value; // Return the long
284
+        }
285
+        else
286
+        {
287
+            throw new Exception("Could not read value of type 'long'!");
288
+        }
289
+    }
290
+
291
+    /// <summary>Reads a float from the packet.</summary>
292
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
293
+    public float ReadFloat(bool _moveReadPos = true)
294
+    {
295
+        if (buffer.Count > readPos)
296
+        {
297
+            // If there are unread bytes
298
+            float _value = BitConverter.ToSingle(readableBuffer, readPos); // Convert the bytes to a float
299
+            if (_moveReadPos)
300
+            {
301
+                // If _moveReadPos is true
302
+                readPos += 4; // Increase readPos by 4
303
+            }
304
+            return _value; // Return the float
305
+        }
306
+        else
307
+        {
308
+            throw new Exception("Could not read value of type 'float'!");
309
+        }
310
+    }
311
+
312
+    /// <summary>Reads a bool from the packet.</summary>
313
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
314
+    public bool ReadBool(bool _moveReadPos = true)
315
+    {
316
+        if (buffer.Count > readPos)
317
+        {
318
+            // If there are unread bytes
319
+            bool _value = BitConverter.ToBoolean(readableBuffer, readPos); // Convert the bytes to a bool
320
+            if (_moveReadPos)
321
+            {
322
+                // If _moveReadPos is true
323
+                readPos += 1; // Increase readPos by 1
324
+            }
325
+            return _value; // Return the bool
326
+        }
327
+        else
328
+        {
329
+            throw new Exception("Could not read value of type 'bool'!");
330
+        }
331
+    }
332
+
333
+    /// <summary>Reads a string from the packet.</summary>
334
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
335
+    public string ReadString(bool _moveReadPos = true)
336
+    {
337
+        try
338
+        {
339
+            int _length = ReadInt(); // Get the length of the string
340
+            string _value = Encoding.ASCII.GetString(readableBuffer, readPos, _length); // Convert the bytes to a string
341
+            if (_moveReadPos && _value.Length > 0)
342
+            {
343
+                // If _moveReadPos is true string is not empty
344
+                readPos += _length; // Increase readPos by the length of the string
345
+            }
346
+            return _value; // Return the string
347
+        }
348
+        catch
349
+        {
350
+            throw new Exception("Could not read value of type 'string'!");
351
+        }
352
+    }
353
+
354
+    public Vector3 ReadVector3(bool _moveReadPos = true)
355
+    {
356
+        return new Vector3(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
357
+    }
358
+
359
+    public Quaternion ReadQuaternion(bool _moveReadPos = true)
360
+    {
361
+        return new Quaternion(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
362
+    }
363
+    #endregion
364
+
365
+    private bool disposed = false;
366
+
367
+    protected virtual void Dispose(bool _disposing)
368
+    {
369
+        if (!disposed)
370
+        {
371
+            if (_disposing)
372
+            {
373
+                buffer = null;
374
+                readableBuffer = null;
375
+                readPos = 0;
376
+            }
377
+
378
+            disposed = true;
379
+        }
380
+    }
381
+
382
+    public void Dispose()
383
+    {
384
+        Dispose(true);
385
+        GC.SuppressFinalize(this);
386
+    }
387
+}

+ 11
- 0
Client/Assets/Scripts/Packet.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: ea6fb0c0f6b720343ba0c4c015118e2f
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 34
- 0
Client/Assets/Scripts/PlayerController.cs Vedi File

@@ -0,0 +1,34 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class PlayerController : MonoBehaviour
6
+{
7
+    public Transform camTransform;
8
+    private void Update()
9
+    {
10
+        if (Input.GetKeyDown(KeyCode.Mouse0))
11
+        {
12
+            ClientSend.PlayerShoot(camTransform.forward);
13
+        }
14
+    }
15
+
16
+    private void FixedUpdate()
17
+    {
18
+        SendInputToServer();
19
+    }
20
+
21
+    private void SendInputToServer()
22
+    {
23
+        bool[] _inputs = new bool[]
24
+        {
25
+            Input.GetKey(KeyCode.Z),
26
+            Input.GetKey(KeyCode.S),
27
+            Input.GetKey(KeyCode.Q),
28
+            Input.GetKey(KeyCode.D),
29
+            Input.GetKey(KeyCode.Space)
30
+        };
31
+
32
+        ClientSend.PlayerMovement(_inputs);
33
+    }
34
+}

+ 11
- 0
Client/Assets/Scripts/PlayerController.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: f4f0d5dfe444a704899ef45cef86fb5c
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 40
- 0
Client/Assets/Scripts/PlayerManager.cs Vedi File

@@ -0,0 +1,40 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class PlayerManager : MonoBehaviour
6
+{
7
+    public int id;
8
+    public string username;
9
+    public float health;
10
+    public float maxHealth;
11
+    public MeshRenderer model;
12
+
13
+    public void Initialize(int _id, string _username)
14
+    {
15
+        id = _id;
16
+        username = _username;
17
+        health = maxHealth;
18
+    }
19
+
20
+    public void SetHealth(float _health)
21
+    {
22
+        health = _health;
23
+
24
+        if (health <= 0f)
25
+        {
26
+            Die();
27
+        }
28
+    }
29
+
30
+    public void Die()
31
+    {
32
+        model.enabled = false;
33
+    }
34
+
35
+    public void Respawn()
36
+    {
37
+        model.enabled = true;
38
+        SetHealth(maxHealth);
39
+    }
40
+}

+ 11
- 0
Client/Assets/Scripts/PlayerManager.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 1b6d6c3f4ee598345923a54e9d03c528
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 52
- 0
Client/Assets/Scripts/ThreadManager.cs Vedi File

@@ -0,0 +1,52 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class ThreadManager : MonoBehaviour
6
+{
7
+    private static readonly List<Action> executeOnMainThread = new List<Action>();
8
+    private static readonly List<Action> executeCopiedOnMainThread = new List<Action>();
9
+    private static bool actionToExecuteOnMainThread = false;
10
+
11
+    private void Update()
12
+    {
13
+        UpdateMain();
14
+    }
15
+
16
+    /// <summary>Sets an action to be executed on the main thread.</summary>
17
+    /// <param name="_action">The action to be executed on the main thread.</param>
18
+    public static void ExecuteOnMainThread(Action _action)
19
+    {
20
+        if (_action == null)
21
+        {
22
+            Debug.Log("No action to execute on main thread!");
23
+            return;
24
+        }
25
+
26
+        lock (executeOnMainThread)
27
+        {
28
+            executeOnMainThread.Add(_action);
29
+            actionToExecuteOnMainThread = true;
30
+        }
31
+    }
32
+
33
+    /// <summary>Executes all code meant to run on the main thread. NOTE: Call this ONLY from the main thread.</summary>
34
+    public static void UpdateMain()
35
+    {
36
+        if (actionToExecuteOnMainThread)
37
+        {
38
+            executeCopiedOnMainThread.Clear();
39
+            lock (executeOnMainThread)
40
+            {
41
+                executeCopiedOnMainThread.AddRange(executeOnMainThread);
42
+                executeOnMainThread.Clear();
43
+                actionToExecuteOnMainThread = false;
44
+            }
45
+
46
+            for (int i = 0; i < executeCopiedOnMainThread.Count; i++)
47
+            {
48
+                executeCopiedOnMainThread[i]();
49
+            }
50
+        }
51
+    }
52
+}

+ 11
- 0
Client/Assets/Scripts/ThreadManager.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: ab462d1621fbecd4a909e19f76004e72
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 37
- 0
Client/Assets/Scripts/UIManager.cs Vedi File

@@ -0,0 +1,37 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using System.Net;
4
+using UnityEngine;
5
+using UnityEngine.UI;
6
+
7
+public class UIManager : MonoBehaviour
8
+{
9
+    public static UIManager instance;
10
+
11
+    public GameObject startMenu;
12
+    public InputField usernameField;
13
+    public InputField ipField;
14
+
15
+    private void Awake()
16
+    {
17
+        if (instance == null)
18
+        {
19
+            instance = this;
20
+        }
21
+        else if (instance != this)
22
+        {
23
+            Debug.Log("Instance already exists. Destroying object !");
24
+            Destroy(this);
25
+        }
26
+    }
27
+
28
+    public void ConnectToServer()
29
+    {
30
+        startMenu.SetActive(false);
31
+        usernameField.interactable = false;
32
+        ipField.interactable = false;
33
+
34
+        Client.instance.ip = ipField.text;
35
+        Client.instance.ConnectToServer();
36
+    }
37
+}

+ 11
- 0
Client/Assets/Scripts/UIManager.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: c40ee04f18d79964b9327918d2619776
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 46
- 0
Client/Logs/Packages-Update.log Vedi File

@@ -0,0 +1,46 @@
1
+
2
+=== Mon Oct  5 17:12:13 2020
3
+
4
+Packages were changed.
5
+Update Mode: mergeDefaultDependencies
6
+
7
+The following packages were added:
8
+  com.unity.collab-proxy@1.3.8
9
+  com.unity.ide.rider@1.2.1
10
+  com.unity.ide.visualstudio@2.0.2
11
+  com.unity.ide.vscode@1.2.1
12
+  com.unity.modules.ai@1.0.0
13
+  com.unity.modules.androidjni@1.0.0
14
+  com.unity.modules.animation@1.0.0
15
+  com.unity.modules.assetbundle@1.0.0
16
+  com.unity.modules.audio@1.0.0
17
+  com.unity.modules.cloth@1.0.0
18
+  com.unity.modules.director@1.0.0
19
+  com.unity.modules.imageconversion@1.0.0
20
+  com.unity.modules.imgui@1.0.0
21
+  com.unity.modules.jsonserialize@1.0.0
22
+  com.unity.modules.particlesystem@1.0.0
23
+  com.unity.modules.physics@1.0.0
24
+  com.unity.modules.physics2d@1.0.0
25
+  com.unity.modules.screencapture@1.0.0
26
+  com.unity.modules.terrain@1.0.0
27
+  com.unity.modules.terrainphysics@1.0.0
28
+  com.unity.modules.tilemap@1.0.0
29
+  com.unity.modules.ui@1.0.0
30
+  com.unity.modules.uielements@1.0.0
31
+  com.unity.modules.umbra@1.0.0
32
+  com.unity.modules.unityanalytics@1.0.0
33
+  com.unity.modules.unitywebrequest@1.0.0
34
+  com.unity.modules.unitywebrequestassetbundle@1.0.0
35
+  com.unity.modules.unitywebrequestaudio@1.0.0
36
+  com.unity.modules.unitywebrequesttexture@1.0.0
37
+  com.unity.modules.unitywebrequestwww@1.0.0
38
+  com.unity.modules.vehicles@1.0.0
39
+  com.unity.modules.video@1.0.0
40
+  com.unity.modules.vr@1.0.0
41
+  com.unity.modules.wind@1.0.0
42
+  com.unity.modules.xr@1.0.0
43
+  com.unity.test-framework@1.1.14
44
+  com.unity.textmeshpro@3.0.1
45
+  com.unity.timeline@1.3.4
46
+  com.unity.ugui@1.0.0

+ 43
- 0
Client/Packages/manifest.json Vedi File

@@ -0,0 +1,43 @@
1
+{
2
+  "dependencies": {
3
+    "com.unity.collab-proxy": "1.3.9",
4
+    "com.unity.ide.rider": "1.2.1",
5
+    "com.unity.ide.visualstudio": "2.0.3",
6
+    "com.unity.ide.vscode": "1.2.2",
7
+    "com.unity.test-framework": "1.1.14",
8
+    "com.unity.textmeshpro": "3.0.1",
9
+    "com.unity.timeline": "1.3.4",
10
+    "com.unity.ugui": "1.0.0",
11
+    "com.unity.modules.ai": "1.0.0",
12
+    "com.unity.modules.androidjni": "1.0.0",
13
+    "com.unity.modules.animation": "1.0.0",
14
+    "com.unity.modules.assetbundle": "1.0.0",
15
+    "com.unity.modules.audio": "1.0.0",
16
+    "com.unity.modules.cloth": "1.0.0",
17
+    "com.unity.modules.director": "1.0.0",
18
+    "com.unity.modules.imageconversion": "1.0.0",
19
+    "com.unity.modules.imgui": "1.0.0",
20
+    "com.unity.modules.jsonserialize": "1.0.0",
21
+    "com.unity.modules.particlesystem": "1.0.0",
22
+    "com.unity.modules.physics": "1.0.0",
23
+    "com.unity.modules.physics2d": "1.0.0",
24
+    "com.unity.modules.screencapture": "1.0.0",
25
+    "com.unity.modules.terrain": "1.0.0",
26
+    "com.unity.modules.terrainphysics": "1.0.0",
27
+    "com.unity.modules.tilemap": "1.0.0",
28
+    "com.unity.modules.ui": "1.0.0",
29
+    "com.unity.modules.uielements": "1.0.0",
30
+    "com.unity.modules.umbra": "1.0.0",
31
+    "com.unity.modules.unityanalytics": "1.0.0",
32
+    "com.unity.modules.unitywebrequest": "1.0.0",
33
+    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
34
+    "com.unity.modules.unitywebrequestaudio": "1.0.0",
35
+    "com.unity.modules.unitywebrequesttexture": "1.0.0",
36
+    "com.unity.modules.unitywebrequestwww": "1.0.0",
37
+    "com.unity.modules.vehicles": "1.0.0",
38
+    "com.unity.modules.video": "1.0.0",
39
+    "com.unity.modules.vr": "1.0.0",
40
+    "com.unity.modules.wind": "1.0.0",
41
+    "com.unity.modules.xr": "1.0.0"
42
+  }
43
+}

+ 330
- 0
Client/Packages/packages-lock.json Vedi File

@@ -0,0 +1,330 @@
1
+{
2
+  "dependencies": {
3
+    "com.unity.collab-proxy": {
4
+      "version": "1.3.9",
5
+      "depth": 0,
6
+      "source": "registry",
7
+      "dependencies": {},
8
+      "url": "https://packages.unity.com"
9
+    },
10
+    "com.unity.ext.nunit": {
11
+      "version": "1.0.0",
12
+      "depth": 1,
13
+      "source": "registry",
14
+      "dependencies": {},
15
+      "url": "https://packages.unity.com"
16
+    },
17
+    "com.unity.ide.rider": {
18
+      "version": "1.2.1",
19
+      "depth": 0,
20
+      "source": "registry",
21
+      "dependencies": {
22
+        "com.unity.test-framework": "1.1.1"
23
+      },
24
+      "url": "https://packages.unity.com"
25
+    },
26
+    "com.unity.ide.visualstudio": {
27
+      "version": "2.0.3",
28
+      "depth": 0,
29
+      "source": "registry",
30
+      "dependencies": {},
31
+      "url": "https://packages.unity.com"
32
+    },
33
+    "com.unity.ide.vscode": {
34
+      "version": "1.2.2",
35
+      "depth": 0,
36
+      "source": "registry",
37
+      "dependencies": {},
38
+      "url": "https://packages.unity.com"
39
+    },
40
+    "com.unity.test-framework": {
41
+      "version": "1.1.14",
42
+      "depth": 0,
43
+      "source": "registry",
44
+      "dependencies": {
45
+        "com.unity.ext.nunit": "1.0.0",
46
+        "com.unity.modules.imgui": "1.0.0",
47
+        "com.unity.modules.jsonserialize": "1.0.0"
48
+      },
49
+      "url": "https://packages.unity.com"
50
+    },
51
+    "com.unity.textmeshpro": {
52
+      "version": "3.0.1",
53
+      "depth": 0,
54
+      "source": "registry",
55
+      "dependencies": {
56
+        "com.unity.ugui": "1.0.0"
57
+      },
58
+      "url": "https://packages.unity.com"
59
+    },
60
+    "com.unity.timeline": {
61
+      "version": "1.3.4",
62
+      "depth": 0,
63
+      "source": "registry",
64
+      "dependencies": {},
65
+      "url": "https://packages.unity.com"
66
+    },
67
+    "com.unity.ugui": {
68
+      "version": "1.0.0",
69
+      "depth": 0,
70
+      "source": "builtin",
71
+      "dependencies": {
72
+        "com.unity.modules.ui": "1.0.0"
73
+      }
74
+    },
75
+    "com.unity.modules.ai": {
76
+      "version": "1.0.0",
77
+      "depth": 0,
78
+      "source": "builtin",
79
+      "dependencies": {}
80
+    },
81
+    "com.unity.modules.androidjni": {
82
+      "version": "1.0.0",
83
+      "depth": 0,
84
+      "source": "builtin",
85
+      "dependencies": {}
86
+    },
87
+    "com.unity.modules.animation": {
88
+      "version": "1.0.0",
89
+      "depth": 0,
90
+      "source": "builtin",
91
+      "dependencies": {}
92
+    },
93
+    "com.unity.modules.assetbundle": {
94
+      "version": "1.0.0",
95
+      "depth": 0,
96
+      "source": "builtin",
97
+      "dependencies": {}
98
+    },
99
+    "com.unity.modules.audio": {
100
+      "version": "1.0.0",
101
+      "depth": 0,
102
+      "source": "builtin",
103
+      "dependencies": {}
104
+    },
105
+    "com.unity.modules.cloth": {
106
+      "version": "1.0.0",
107
+      "depth": 0,
108
+      "source": "builtin",
109
+      "dependencies": {
110
+        "com.unity.modules.physics": "1.0.0"
111
+      }
112
+    },
113
+    "com.unity.modules.director": {
114
+      "version": "1.0.0",
115
+      "depth": 0,
116
+      "source": "builtin",
117
+      "dependencies": {
118
+        "com.unity.modules.audio": "1.0.0",
119
+        "com.unity.modules.animation": "1.0.0"
120
+      }
121
+    },
122
+    "com.unity.modules.imageconversion": {
123
+      "version": "1.0.0",
124
+      "depth": 0,
125
+      "source": "builtin",
126
+      "dependencies": {}
127
+    },
128
+    "com.unity.modules.imgui": {
129
+      "version": "1.0.0",
130
+      "depth": 0,
131
+      "source": "builtin",
132
+      "dependencies": {}
133
+    },
134
+    "com.unity.modules.jsonserialize": {
135
+      "version": "1.0.0",
136
+      "depth": 0,
137
+      "source": "builtin",
138
+      "dependencies": {}
139
+    },
140
+    "com.unity.modules.particlesystem": {
141
+      "version": "1.0.0",
142
+      "depth": 0,
143
+      "source": "builtin",
144
+      "dependencies": {}
145
+    },
146
+    "com.unity.modules.physics": {
147
+      "version": "1.0.0",
148
+      "depth": 0,
149
+      "source": "builtin",
150
+      "dependencies": {}
151
+    },
152
+    "com.unity.modules.physics2d": {
153
+      "version": "1.0.0",
154
+      "depth": 0,
155
+      "source": "builtin",
156
+      "dependencies": {}
157
+    },
158
+    "com.unity.modules.screencapture": {
159
+      "version": "1.0.0",
160
+      "depth": 0,
161
+      "source": "builtin",
162
+      "dependencies": {
163
+        "com.unity.modules.imageconversion": "1.0.0"
164
+      }
165
+    },
166
+    "com.unity.modules.subsystems": {
167
+      "version": "1.0.0",
168
+      "depth": 1,
169
+      "source": "builtin",
170
+      "dependencies": {
171
+        "com.unity.modules.jsonserialize": "1.0.0"
172
+      }
173
+    },
174
+    "com.unity.modules.terrain": {
175
+      "version": "1.0.0",
176
+      "depth": 0,
177
+      "source": "builtin",
178
+      "dependencies": {}
179
+    },
180
+    "com.unity.modules.terrainphysics": {
181
+      "version": "1.0.0",
182
+      "depth": 0,
183
+      "source": "builtin",
184
+      "dependencies": {
185
+        "com.unity.modules.physics": "1.0.0",
186
+        "com.unity.modules.terrain": "1.0.0"
187
+      }
188
+    },
189
+    "com.unity.modules.tilemap": {
190
+      "version": "1.0.0",
191
+      "depth": 0,
192
+      "source": "builtin",
193
+      "dependencies": {
194
+        "com.unity.modules.physics2d": "1.0.0"
195
+      }
196
+    },
197
+    "com.unity.modules.ui": {
198
+      "version": "1.0.0",
199
+      "depth": 0,
200
+      "source": "builtin",
201
+      "dependencies": {}
202
+    },
203
+    "com.unity.modules.uielements": {
204
+      "version": "1.0.0",
205
+      "depth": 0,
206
+      "source": "builtin",
207
+      "dependencies": {
208
+        "com.unity.modules.ui": "1.0.0",
209
+        "com.unity.modules.imgui": "1.0.0",
210
+        "com.unity.modules.jsonserialize": "1.0.0",
211
+        "com.unity.modules.uielementsnative": "1.0.0"
212
+      }
213
+    },
214
+    "com.unity.modules.uielementsnative": {
215
+      "version": "1.0.0",
216
+      "depth": 1,
217
+      "source": "builtin",
218
+      "dependencies": {
219
+        "com.unity.modules.ui": "1.0.0",
220
+        "com.unity.modules.imgui": "1.0.0",
221
+        "com.unity.modules.jsonserialize": "1.0.0"
222
+      }
223
+    },
224
+    "com.unity.modules.umbra": {
225
+      "version": "1.0.0",
226
+      "depth": 0,
227
+      "source": "builtin",
228
+      "dependencies": {}
229
+    },
230
+    "com.unity.modules.unityanalytics": {
231
+      "version": "1.0.0",
232
+      "depth": 0,
233
+      "source": "builtin",
234
+      "dependencies": {
235
+        "com.unity.modules.unitywebrequest": "1.0.0",
236
+        "com.unity.modules.jsonserialize": "1.0.0"
237
+      }
238
+    },
239
+    "com.unity.modules.unitywebrequest": {
240
+      "version": "1.0.0",
241
+      "depth": 0,
242
+      "source": "builtin",
243
+      "dependencies": {}
244
+    },
245
+    "com.unity.modules.unitywebrequestassetbundle": {
246
+      "version": "1.0.0",
247
+      "depth": 0,
248
+      "source": "builtin",
249
+      "dependencies": {
250
+        "com.unity.modules.assetbundle": "1.0.0",
251
+        "com.unity.modules.unitywebrequest": "1.0.0"
252
+      }
253
+    },
254
+    "com.unity.modules.unitywebrequestaudio": {
255
+      "version": "1.0.0",
256
+      "depth": 0,
257
+      "source": "builtin",
258
+      "dependencies": {
259
+        "com.unity.modules.unitywebrequest": "1.0.0",
260
+        "com.unity.modules.audio": "1.0.0"
261
+      }
262
+    },
263
+    "com.unity.modules.unitywebrequesttexture": {
264
+      "version": "1.0.0",
265
+      "depth": 0,
266
+      "source": "builtin",
267
+      "dependencies": {
268
+        "com.unity.modules.unitywebrequest": "1.0.0",
269
+        "com.unity.modules.imageconversion": "1.0.0"
270
+      }
271
+    },
272
+    "com.unity.modules.unitywebrequestwww": {
273
+      "version": "1.0.0",
274
+      "depth": 0,
275
+      "source": "builtin",
276
+      "dependencies": {
277
+        "com.unity.modules.unitywebrequest": "1.0.0",
278
+        "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
279
+        "com.unity.modules.unitywebrequestaudio": "1.0.0",
280
+        "com.unity.modules.audio": "1.0.0",
281
+        "com.unity.modules.assetbundle": "1.0.0",
282
+        "com.unity.modules.imageconversion": "1.0.0"
283
+      }
284
+    },
285
+    "com.unity.modules.vehicles": {
286
+      "version": "1.0.0",
287
+      "depth": 0,
288
+      "source": "builtin",
289
+      "dependencies": {
290
+        "com.unity.modules.physics": "1.0.0"
291
+      }
292
+    },
293
+    "com.unity.modules.video": {
294
+      "version": "1.0.0",
295
+      "depth": 0,
296
+      "source": "builtin",
297
+      "dependencies": {
298
+        "com.unity.modules.audio": "1.0.0",
299
+        "com.unity.modules.ui": "1.0.0",
300
+        "com.unity.modules.unitywebrequest": "1.0.0"
301
+      }
302
+    },
303
+    "com.unity.modules.vr": {
304
+      "version": "1.0.0",
305
+      "depth": 0,
306
+      "source": "builtin",
307
+      "dependencies": {
308
+        "com.unity.modules.jsonserialize": "1.0.0",
309
+        "com.unity.modules.physics": "1.0.0",
310
+        "com.unity.modules.xr": "1.0.0"
311
+      }
312
+    },
313
+    "com.unity.modules.wind": {
314
+      "version": "1.0.0",
315
+      "depth": 0,
316
+      "source": "builtin",
317
+      "dependencies": {}
318
+    },
319
+    "com.unity.modules.xr": {
320
+      "version": "1.0.0",
321
+      "depth": 0,
322
+      "source": "builtin",
323
+      "dependencies": {
324
+        "com.unity.modules.physics": "1.0.0",
325
+        "com.unity.modules.jsonserialize": "1.0.0",
326
+        "com.unity.modules.subsystems": "1.0.0"
327
+      }
328
+    }
329
+  }
330
+}

+ 19
- 0
Client/ProjectSettings/AudioManager.asset Vedi File

@@ -0,0 +1,19 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!11 &1
4
+AudioManager:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  m_Volume: 1
8
+  Rolloff Scale: 1
9
+  Doppler Factor: 1
10
+  Default Speaker Mode: 2
11
+  m_SampleRate: 0
12
+  m_DSPBufferSize: 1024
13
+  m_VirtualVoiceCount: 512
14
+  m_RealVoiceCount: 32
15
+  m_SpatializerPlugin: 
16
+  m_AmbisonicDecoderPlugin: 
17
+  m_DisableAudio: 0
18
+  m_VirtualizeEffects: 1
19
+  m_RequestedDSPBufferSize: 1024

+ 6
- 0
Client/ProjectSettings/ClusterInputManager.asset Vedi File

@@ -0,0 +1,6 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!236 &1
4
+ClusterInputManager:
5
+  m_ObjectHideFlags: 0
6
+  m_Inputs: []

+ 34
- 0
Client/ProjectSettings/DynamicsManager.asset Vedi File

@@ -0,0 +1,34 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!55 &1
4
+PhysicsManager:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 11
7
+  m_Gravity: {x: 0, y: -9.81, z: 0}
8
+  m_DefaultMaterial: {fileID: 0}
9
+  m_BounceThreshold: 2
10
+  m_SleepThreshold: 0.005
11
+  m_DefaultContactOffset: 0.01
12
+  m_DefaultSolverIterations: 6
13
+  m_DefaultSolverVelocityIterations: 1
14
+  m_QueriesHitBackfaces: 0
15
+  m_QueriesHitTriggers: 1
16
+  m_EnableAdaptiveForce: 0
17
+  m_ClothInterCollisionDistance: 0
18
+  m_ClothInterCollisionStiffness: 0
19
+  m_ContactsGeneration: 1
20
+  m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
21
+  m_AutoSimulation: 1
22
+  m_AutoSyncTransforms: 0
23
+  m_ReuseCollisionCallbacks: 1
24
+  m_ClothInterCollisionSettingsToggle: 0
25
+  m_ContactPairsMode: 0
26
+  m_BroadphaseType: 0
27
+  m_WorldBounds:
28
+    m_Center: {x: 0, y: 0, z: 0}
29
+    m_Extent: {x: 250, y: 250, z: 250}
30
+  m_WorldSubdivisions: 8
31
+  m_FrictionType: 0
32
+  m_EnableEnhancedDeterminism: 0
33
+  m_EnableUnifiedHeightmaps: 1
34
+  m_DefaultMaxAngluarSpeed: 7

+ 11
- 0
Client/ProjectSettings/EditorBuildSettings.asset Vedi File

@@ -0,0 +1,11 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!1045 &1
4
+EditorBuildSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  m_Scenes:
8
+  - enabled: 1
9
+    path: Assets/Scenes/Main.unity
10
+    guid: 9fc0d4010bbf28b4594072e72b8655ab
11
+  m_configObjects: {}

+ 30
- 0
Client/ProjectSettings/EditorSettings.asset Vedi File

@@ -0,0 +1,30 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!159 &1
4
+EditorSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 11
7
+  m_ExternalVersionControlSupport: Visible Meta Files
8
+  m_SerializationMode: 2
9
+  m_LineEndingsForNewScripts: 0
10
+  m_DefaultBehaviorMode: 0
11
+  m_PrefabRegularEnvironment: {fileID: 0}
12
+  m_PrefabUIEnvironment: {fileID: 0}
13
+  m_SpritePackerMode: 0
14
+  m_SpritePackerPaddingPower: 1
15
+  m_EtcTextureCompressorBehavior: 1
16
+  m_EtcTextureFastCompressor: 1
17
+  m_EtcTextureNormalCompressor: 2
18
+  m_EtcTextureBestCompressor: 4
19
+  m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref
20
+  m_ProjectGenerationRootNamespace: 
21
+  m_CollabEditorSettings:
22
+    inProgressEnabled: 1
23
+  m_EnableTextureStreamingInEditMode: 1
24
+  m_EnableTextureStreamingInPlayMode: 1
25
+  m_AsyncShaderCompilation: 1
26
+  m_EnterPlayModeOptionsEnabled: 0
27
+  m_EnterPlayModeOptions: 3
28
+  m_ShowLightmapResolutionOverlay: 1
29
+  m_UseLegacyProbeSampleCount: 0
30
+  m_SerializeInlineMappingsOnOneLine: 1

+ 63
- 0
Client/ProjectSettings/GraphicsSettings.asset Vedi File

@@ -0,0 +1,63 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!30 &1
4
+GraphicsSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 13
7
+  m_Deferred:
8
+    m_Mode: 1
9
+    m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
10
+  m_DeferredReflections:
11
+    m_Mode: 1
12
+    m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
13
+  m_ScreenSpaceShadows:
14
+    m_Mode: 1
15
+    m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
16
+  m_LegacyDeferred:
17
+    m_Mode: 1
18
+    m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
19
+  m_DepthNormals:
20
+    m_Mode: 1
21
+    m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
22
+  m_MotionVectors:
23
+    m_Mode: 1
24
+    m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
25
+  m_LightHalo:
26
+    m_Mode: 1
27
+    m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
28
+  m_LensFlare:
29
+    m_Mode: 1
30
+    m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
31
+  m_AlwaysIncludedShaders:
32
+  - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
33
+  - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
34
+  - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
35
+  - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
36
+  - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
37
+  - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
38
+  m_PreloadedShaders: []
39
+  m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
40
+    type: 0}
41
+  m_CustomRenderPipeline: {fileID: 0}
42
+  m_TransparencySortMode: 0
43
+  m_TransparencySortAxis: {x: 0, y: 0, z: 1}
44
+  m_DefaultRenderingPath: 1
45
+  m_DefaultMobileRenderingPath: 1
46
+  m_TierSettings: []
47
+  m_LightmapStripping: 0
48
+  m_FogStripping: 0
49
+  m_InstancingStripping: 0
50
+  m_LightmapKeepPlain: 1
51
+  m_LightmapKeepDirCombined: 1
52
+  m_LightmapKeepDynamicPlain: 1
53
+  m_LightmapKeepDynamicDirCombined: 1
54
+  m_LightmapKeepShadowMask: 1
55
+  m_LightmapKeepSubtractive: 1
56
+  m_FogKeepLinear: 1
57
+  m_FogKeepExp: 1
58
+  m_FogKeepExp2: 1
59
+  m_AlbedoSwatchInfos: []
60
+  m_LightsUseLinearIntensity: 0
61
+  m_LightsUseColorTemperature: 0
62
+  m_LogWhenShaderIsCompiled: 0
63
+  m_AllowEnlightenSupportForUpgradedProject: 0

+ 295
- 0
Client/ProjectSettings/InputManager.asset Vedi File

@@ -0,0 +1,295 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!13 &1
4
+InputManager:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  m_Axes:
8
+  - serializedVersion: 3
9
+    m_Name: Horizontal
10
+    descriptiveName: 
11
+    descriptiveNegativeName: 
12
+    negativeButton: left
13
+    positiveButton: right
14
+    altNegativeButton: a
15
+    altPositiveButton: d
16
+    gravity: 3
17
+    dead: 0.001
18
+    sensitivity: 3
19
+    snap: 1
20
+    invert: 0
21
+    type: 0
22
+    axis: 0
23
+    joyNum: 0
24
+  - serializedVersion: 3
25
+    m_Name: Vertical
26
+    descriptiveName: 
27
+    descriptiveNegativeName: 
28
+    negativeButton: down
29
+    positiveButton: up
30
+    altNegativeButton: s
31
+    altPositiveButton: w
32
+    gravity: 3
33
+    dead: 0.001
34
+    sensitivity: 3
35
+    snap: 1
36
+    invert: 0
37
+    type: 0
38
+    axis: 0
39
+    joyNum: 0
40
+  - serializedVersion: 3
41
+    m_Name: Fire1
42
+    descriptiveName: 
43
+    descriptiveNegativeName: 
44
+    negativeButton: 
45
+    positiveButton: left ctrl
46
+    altNegativeButton: 
47
+    altPositiveButton: mouse 0
48
+    gravity: 1000
49
+    dead: 0.001
50
+    sensitivity: 1000
51
+    snap: 0
52
+    invert: 0
53
+    type: 0
54
+    axis: 0
55
+    joyNum: 0
56
+  - serializedVersion: 3
57
+    m_Name: Fire2
58
+    descriptiveName: 
59
+    descriptiveNegativeName: 
60
+    negativeButton: 
61
+    positiveButton: left alt
62
+    altNegativeButton: 
63
+    altPositiveButton: mouse 1
64
+    gravity: 1000
65
+    dead: 0.001
66
+    sensitivity: 1000
67
+    snap: 0
68
+    invert: 0
69
+    type: 0
70
+    axis: 0
71
+    joyNum: 0
72
+  - serializedVersion: 3
73
+    m_Name: Fire3
74
+    descriptiveName: 
75
+    descriptiveNegativeName: 
76
+    negativeButton: 
77
+    positiveButton: left shift
78
+    altNegativeButton: 
79
+    altPositiveButton: mouse 2
80
+    gravity: 1000
81
+    dead: 0.001
82
+    sensitivity: 1000
83
+    snap: 0
84
+    invert: 0
85
+    type: 0
86
+    axis: 0
87
+    joyNum: 0
88
+  - serializedVersion: 3
89
+    m_Name: Jump
90
+    descriptiveName: 
91
+    descriptiveNegativeName: 
92
+    negativeButton: 
93
+    positiveButton: space
94
+    altNegativeButton: 
95
+    altPositiveButton: 
96
+    gravity: 1000
97
+    dead: 0.001
98
+    sensitivity: 1000
99
+    snap: 0
100
+    invert: 0
101
+    type: 0
102
+    axis: 0
103
+    joyNum: 0
104
+  - serializedVersion: 3
105
+    m_Name: Mouse X
106
+    descriptiveName: 
107
+    descriptiveNegativeName: 
108
+    negativeButton: 
109
+    positiveButton: 
110
+    altNegativeButton: 
111
+    altPositiveButton: 
112
+    gravity: 0
113
+    dead: 0
114
+    sensitivity: 0.1
115
+    snap: 0
116
+    invert: 0
117
+    type: 1
118
+    axis: 0
119
+    joyNum: 0
120
+  - serializedVersion: 3
121
+    m_Name: Mouse Y
122
+    descriptiveName: 
123
+    descriptiveNegativeName: 
124
+    negativeButton: 
125
+    positiveButton: 
126
+    altNegativeButton: 
127
+    altPositiveButton: 
128
+    gravity: 0
129
+    dead: 0
130
+    sensitivity: 0.1
131
+    snap: 0
132
+    invert: 0
133
+    type: 1
134
+    axis: 1
135
+    joyNum: 0
136
+  - serializedVersion: 3
137
+    m_Name: Mouse ScrollWheel
138
+    descriptiveName: 
139
+    descriptiveNegativeName: 
140
+    negativeButton: 
141
+    positiveButton: 
142
+    altNegativeButton: 
143
+    altPositiveButton: 
144
+    gravity: 0
145
+    dead: 0
146
+    sensitivity: 0.1
147
+    snap: 0
148
+    invert: 0
149
+    type: 1
150
+    axis: 2
151
+    joyNum: 0
152
+  - serializedVersion: 3
153
+    m_Name: Horizontal
154
+    descriptiveName: 
155
+    descriptiveNegativeName: 
156
+    negativeButton: 
157
+    positiveButton: 
158
+    altNegativeButton: 
159
+    altPositiveButton: 
160
+    gravity: 0
161
+    dead: 0.19
162
+    sensitivity: 1
163
+    snap: 0
164
+    invert: 0
165
+    type: 2
166
+    axis: 0
167
+    joyNum: 0
168
+  - serializedVersion: 3
169
+    m_Name: Vertical
170
+    descriptiveName: 
171
+    descriptiveNegativeName: 
172
+    negativeButton: 
173
+    positiveButton: 
174
+    altNegativeButton: 
175
+    altPositiveButton: 
176
+    gravity: 0
177
+    dead: 0.19
178
+    sensitivity: 1
179
+    snap: 0
180
+    invert: 1
181
+    type: 2
182
+    axis: 1
183
+    joyNum: 0
184
+  - serializedVersion: 3
185
+    m_Name: Fire1
186
+    descriptiveName: 
187
+    descriptiveNegativeName: 
188
+    negativeButton: 
189
+    positiveButton: joystick button 0
190
+    altNegativeButton: 
191
+    altPositiveButton: 
192
+    gravity: 1000
193
+    dead: 0.001
194
+    sensitivity: 1000
195
+    snap: 0
196
+    invert: 0
197
+    type: 0
198
+    axis: 0
199
+    joyNum: 0
200
+  - serializedVersion: 3
201
+    m_Name: Fire2
202
+    descriptiveName: 
203
+    descriptiveNegativeName: 
204
+    negativeButton: 
205
+    positiveButton: joystick button 1
206
+    altNegativeButton: 
207
+    altPositiveButton: 
208
+    gravity: 1000
209
+    dead: 0.001
210
+    sensitivity: 1000
211
+    snap: 0
212
+    invert: 0
213
+    type: 0
214
+    axis: 0
215
+    joyNum: 0
216
+  - serializedVersion: 3
217
+    m_Name: Fire3
218
+    descriptiveName: 
219
+    descriptiveNegativeName: 
220
+    negativeButton: 
221
+    positiveButton: joystick button 2
222
+    altNegativeButton: 
223
+    altPositiveButton: 
224
+    gravity: 1000
225
+    dead: 0.001
226
+    sensitivity: 1000
227
+    snap: 0
228
+    invert: 0
229
+    type: 0
230
+    axis: 0
231
+    joyNum: 0
232
+  - serializedVersion: 3
233
+    m_Name: Jump
234
+    descriptiveName: 
235
+    descriptiveNegativeName: 
236
+    negativeButton: 
237
+    positiveButton: joystick button 3
238
+    altNegativeButton: 
239
+    altPositiveButton: 
240
+    gravity: 1000
241
+    dead: 0.001
242
+    sensitivity: 1000
243
+    snap: 0
244
+    invert: 0
245
+    type: 0
246
+    axis: 0
247
+    joyNum: 0
248
+  - serializedVersion: 3
249
+    m_Name: Submit
250
+    descriptiveName: 
251
+    descriptiveNegativeName: 
252
+    negativeButton: 
253
+    positiveButton: return
254
+    altNegativeButton: 
255
+    altPositiveButton: joystick button 0
256
+    gravity: 1000
257
+    dead: 0.001
258
+    sensitivity: 1000
259
+    snap: 0
260
+    invert: 0
261
+    type: 0
262
+    axis: 0
263
+    joyNum: 0
264
+  - serializedVersion: 3
265
+    m_Name: Submit
266
+    descriptiveName: 
267
+    descriptiveNegativeName: 
268
+    negativeButton: 
269
+    positiveButton: enter
270
+    altNegativeButton: 
271
+    altPositiveButton: space
272
+    gravity: 1000
273
+    dead: 0.001
274
+    sensitivity: 1000
275
+    snap: 0
276
+    invert: 0
277
+    type: 0
278
+    axis: 0
279
+    joyNum: 0
280
+  - serializedVersion: 3
281
+    m_Name: Cancel
282
+    descriptiveName: 
283
+    descriptiveNegativeName: 
284
+    negativeButton: 
285
+    positiveButton: escape
286
+    altNegativeButton: 
287
+    altPositiveButton: joystick button 1
288
+    gravity: 1000
289
+    dead: 0.001
290
+    sensitivity: 1000
291
+    snap: 0
292
+    invert: 0
293
+    type: 0
294
+    axis: 0
295
+    joyNum: 0

+ 91
- 0
Client/ProjectSettings/NavMeshAreas.asset Vedi File

@@ -0,0 +1,91 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!126 &1
4
+NavMeshProjectSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  areas:
8
+  - name: Walkable
9
+    cost: 1
10
+  - name: Not Walkable
11
+    cost: 1
12
+  - name: Jump
13
+    cost: 2
14
+  - name: 
15
+    cost: 1
16
+  - name: 
17
+    cost: 1
18
+  - name: 
19
+    cost: 1
20
+  - name: 
21
+    cost: 1
22
+  - name: 
23
+    cost: 1
24
+  - name: 
25
+    cost: 1
26
+  - name: 
27
+    cost: 1
28
+  - name: 
29
+    cost: 1
30
+  - name: 
31
+    cost: 1
32
+  - name: 
33
+    cost: 1
34
+  - name: 
35
+    cost: 1
36
+  - name: 
37
+    cost: 1
38
+  - name: 
39
+    cost: 1
40
+  - name: 
41
+    cost: 1
42
+  - name: 
43
+    cost: 1
44
+  - name: 
45
+    cost: 1
46
+  - name: 
47
+    cost: 1
48
+  - name: 
49
+    cost: 1
50
+  - name: 
51
+    cost: 1
52
+  - name: 
53
+    cost: 1
54
+  - name: 
55
+    cost: 1
56
+  - name: 
57
+    cost: 1
58
+  - name: 
59
+    cost: 1
60
+  - name: 
61
+    cost: 1
62
+  - name: 
63
+    cost: 1
64
+  - name: 
65
+    cost: 1
66
+  - name: 
67
+    cost: 1
68
+  - name: 
69
+    cost: 1
70
+  - name: 
71
+    cost: 1
72
+  m_LastAgentTypeID: -887442657
73
+  m_Settings:
74
+  - serializedVersion: 2
75
+    agentTypeID: 0
76
+    agentRadius: 0.5
77
+    agentHeight: 2
78
+    agentSlope: 45
79
+    agentClimb: 0.75
80
+    ledgeDropHeight: 0
81
+    maxJumpAcrossDistance: 0
82
+    minRegionArea: 2
83
+    manualCellSize: 0
84
+    cellSize: 0.16666667
85
+    manualTileSize: 0
86
+    tileSize: 256
87
+    accuratePlacement: 0
88
+    debug:
89
+      m_Flags: 0
90
+  m_SettingNames:
91
+  - Humanoid

+ 56
- 0
Client/ProjectSettings/Physics2DSettings.asset Vedi File

@@ -0,0 +1,56 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!19 &1
4
+Physics2DSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 4
7
+  m_Gravity: {x: 0, y: -9.81}
8
+  m_DefaultMaterial: {fileID: 0}
9
+  m_VelocityIterations: 8
10
+  m_PositionIterations: 3
11
+  m_VelocityThreshold: 1
12
+  m_MaxLinearCorrection: 0.2
13
+  m_MaxAngularCorrection: 8
14
+  m_MaxTranslationSpeed: 100
15
+  m_MaxRotationSpeed: 360
16
+  m_BaumgarteScale: 0.2
17
+  m_BaumgarteTimeOfImpactScale: 0.75
18
+  m_TimeToSleep: 0.5
19
+  m_LinearSleepTolerance: 0.01
20
+  m_AngularSleepTolerance: 2
21
+  m_DefaultContactOffset: 0.01
22
+  m_JobOptions:
23
+    serializedVersion: 2
24
+    useMultithreading: 0
25
+    useConsistencySorting: 0
26
+    m_InterpolationPosesPerJob: 100
27
+    m_NewContactsPerJob: 30
28
+    m_CollideContactsPerJob: 100
29
+    m_ClearFlagsPerJob: 200
30
+    m_ClearBodyForcesPerJob: 200
31
+    m_SyncDiscreteFixturesPerJob: 50
32
+    m_SyncContinuousFixturesPerJob: 50
33
+    m_FindNearestContactsPerJob: 100
34
+    m_UpdateTriggerContactsPerJob: 100
35
+    m_IslandSolverCostThreshold: 100
36
+    m_IslandSolverBodyCostScale: 1
37
+    m_IslandSolverContactCostScale: 10
38
+    m_IslandSolverJointCostScale: 10
39
+    m_IslandSolverBodiesPerJob: 50
40
+    m_IslandSolverContactsPerJob: 50
41
+  m_AutoSimulation: 1
42
+  m_QueriesHitTriggers: 1
43
+  m_QueriesStartInColliders: 1
44
+  m_CallbacksOnDisable: 1
45
+  m_ReuseCollisionCallbacks: 1
46
+  m_AutoSyncTransforms: 0
47
+  m_AlwaysShowColliders: 0
48
+  m_ShowColliderSleep: 1
49
+  m_ShowColliderContacts: 0
50
+  m_ShowColliderAABB: 0
51
+  m_ContactArrowScale: 0.2
52
+  m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
53
+  m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
54
+  m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
55
+  m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
56
+  m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

+ 7
- 0
Client/ProjectSettings/PresetManager.asset Vedi File

@@ -0,0 +1,7 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!1386491679 &1
4
+PresetManager:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  m_DefaultPresets: {}

+ 673
- 0
Client/ProjectSettings/ProjectSettings.asset Vedi File

@@ -0,0 +1,673 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!129 &1
4
+PlayerSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 20
7
+  productGUID: 16ce8d11816bee04990a9dc280d3ee13
8
+  AndroidProfiler: 0
9
+  AndroidFilterTouchesWhenObscured: 0
10
+  AndroidEnableSustainedPerformanceMode: 0
11
+  defaultScreenOrientation: 4
12
+  targetDevice: 2
13
+  useOnDemandResources: 0
14
+  accelerometerFrequency: 60
15
+  companyName: DefaultCompany
16
+  productName: ClientServTestv2
17
+  defaultCursor: {fileID: 0}
18
+  cursorHotspot: {x: 0, y: 0}
19
+  m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
20
+  m_ShowUnitySplashScreen: 1
21
+  m_ShowUnitySplashLogo: 1
22
+  m_SplashScreenOverlayOpacity: 1
23
+  m_SplashScreenAnimation: 1
24
+  m_SplashScreenLogoStyle: 1
25
+  m_SplashScreenDrawMode: 0
26
+  m_SplashScreenBackgroundAnimationZoom: 1
27
+  m_SplashScreenLogoAnimationZoom: 1
28
+  m_SplashScreenBackgroundLandscapeAspect: 1
29
+  m_SplashScreenBackgroundPortraitAspect: 1
30
+  m_SplashScreenBackgroundLandscapeUvs:
31
+    serializedVersion: 2
32
+    x: 0
33
+    y: 0
34
+    width: 1
35
+    height: 1
36
+  m_SplashScreenBackgroundPortraitUvs:
37
+    serializedVersion: 2
38
+    x: 0
39
+    y: 0
40
+    width: 1
41
+    height: 1
42
+  m_SplashScreenLogos: []
43
+  m_VirtualRealitySplashScreen: {fileID: 0}
44
+  m_HolographicTrackingLossScreen: {fileID: 0}
45
+  defaultScreenWidth: 1024
46
+  defaultScreenHeight: 768
47
+  defaultScreenWidthWeb: 960
48
+  defaultScreenHeightWeb: 600
49
+  m_StereoRenderingPath: 0
50
+  m_ActiveColorSpace: 0
51
+  m_MTRendering: 1
52
+  mipStripping: 0
53
+  numberOfMipsStripped: 0
54
+  m_StackTraceTypes: 010000000100000001000000010000000100000001000000
55
+  iosShowActivityIndicatorOnLoading: -1
56
+  androidShowActivityIndicatorOnLoading: -1
57
+  iosUseCustomAppBackgroundBehavior: 0
58
+  iosAllowHTTPDownload: 1
59
+  allowedAutorotateToPortrait: 1
60
+  allowedAutorotateToPortraitUpsideDown: 1
61
+  allowedAutorotateToLandscapeRight: 1
62
+  allowedAutorotateToLandscapeLeft: 1
63
+  useOSAutorotation: 1
64
+  use32BitDisplayBuffer: 1
65
+  preserveFramebufferAlpha: 0
66
+  disableDepthAndStencilBuffers: 0
67
+  androidStartInFullscreen: 1
68
+  androidRenderOutsideSafeArea: 1
69
+  androidUseSwappy: 1
70
+  androidBlitType: 0
71
+  defaultIsNativeResolution: 1
72
+  macRetinaSupport: 1
73
+  runInBackground: 1
74
+  captureSingleScreen: 0
75
+  muteOtherAudioSources: 0
76
+  Prepare IOS For Recording: 0
77
+  Force IOS Speakers When Recording: 0
78
+  deferSystemGesturesMode: 0
79
+  hideHomeButton: 0
80
+  submitAnalytics: 1
81
+  usePlayerLog: 1
82
+  bakeCollisionMeshes: 0
83
+  forceSingleInstance: 0
84
+  useFlipModelSwapchain: 1
85
+  resizableWindow: 0
86
+  useMacAppStoreValidation: 0
87
+  macAppStoreCategory: public.app-category.games
88
+  gpuSkinning: 1
89
+  xboxPIXTextureCapture: 0
90
+  xboxEnableAvatar: 0
91
+  xboxEnableKinect: 0
92
+  xboxEnableKinectAutoTracking: 0
93
+  xboxEnableFitness: 0
94
+  visibleInBackground: 1
95
+  allowFullscreenSwitch: 1
96
+  fullscreenMode: 3
97
+  xboxSpeechDB: 0
98
+  xboxEnableHeadOrientation: 0
99
+  xboxEnableGuest: 0
100
+  xboxEnablePIXSampling: 0
101
+  metalFramebufferOnly: 0
102
+  xboxOneResolution: 0
103
+  xboxOneSResolution: 0
104
+  xboxOneXResolution: 3
105
+  xboxOneMonoLoggingLevel: 0
106
+  xboxOneLoggingLevel: 1
107
+  xboxOneDisableEsram: 0
108
+  xboxOneEnableTypeOptimization: 0
109
+  xboxOnePresentImmediateThreshold: 0
110
+  switchQueueCommandMemory: 0
111
+  switchQueueControlMemory: 16384
112
+  switchQueueComputeMemory: 262144
113
+  switchNVNShaderPoolsGranularity: 33554432
114
+  switchNVNDefaultPoolsGranularity: 16777216
115
+  switchNVNOtherPoolsGranularity: 16777216
116
+  switchNVNMaxPublicTextureIDCount: 0
117
+  switchNVNMaxPublicSamplerIDCount: 0
118
+  stadiaPresentMode: 0
119
+  stadiaTargetFramerate: 0
120
+  vulkanNumSwapchainBuffers: 3
121
+  vulkanEnableSetSRGBWrite: 0
122
+  m_SupportedAspectRatios:
123
+    4:3: 1
124
+    5:4: 1
125
+    16:10: 1
126
+    16:9: 1
127
+    Others: 1
128
+  bundleVersion: 0.1
129
+  preloadedAssets: []
130
+  metroInputSource: 0
131
+  wsaTransparentSwapchain: 0
132
+  m_HolographicPauseOnTrackingLoss: 1
133
+  xboxOneDisableKinectGpuReservation: 1
134
+  xboxOneEnable7thCore: 1
135
+  vrSettings:
136
+    cardboard:
137
+      depthFormat: 0
138
+      enableTransitionView: 0
139
+    daydream:
140
+      depthFormat: 0
141
+      useSustainedPerformanceMode: 0
142
+      enableVideoLayer: 0
143
+      useProtectedVideoMemory: 0
144
+      minimumSupportedHeadTracking: 0
145
+      maximumSupportedHeadTracking: 1
146
+    hololens:
147
+      depthFormat: 1
148
+      depthBufferSharingEnabled: 1
149
+    lumin:
150
+      depthFormat: 0
151
+      frameTiming: 2
152
+      enableGLCache: 0
153
+      glCacheMaxBlobSize: 524288
154
+      glCacheMaxFileSize: 8388608
155
+    oculus:
156
+      sharedDepthBuffer: 1
157
+      dashSupport: 1
158
+      lowOverheadMode: 0
159
+      protectedContext: 0
160
+      v2Signing: 1
161
+    enable360StereoCapture: 0
162
+  isWsaHolographicRemotingEnabled: 0
163
+  enableFrameTimingStats: 0
164
+  useHDRDisplay: 0
165
+  D3DHDRBitDepth: 0
166
+  m_ColorGamuts: 00000000
167
+  targetPixelDensity: 30
168
+  resolutionScalingMode: 0
169
+  androidSupportedAspectRatio: 1
170
+  androidMaxAspectRatio: 2.1
171
+  applicationIdentifier: {}
172
+  buildNumber: {}
173
+  AndroidBundleVersionCode: 1
174
+  AndroidMinSdkVersion: 19
175
+  AndroidTargetSdkVersion: 0
176
+  AndroidPreferredInstallLocation: 1
177
+  aotOptions: 
178
+  stripEngineCode: 1
179
+  iPhoneStrippingLevel: 0
180
+  iPhoneScriptCallOptimization: 0
181
+  ForceInternetPermission: 0
182
+  ForceSDCardPermission: 0
183
+  CreateWallpaper: 0
184
+  APKExpansionFiles: 0
185
+  keepLoadedShadersAlive: 0
186
+  StripUnusedMeshComponents: 1
187
+  VertexChannelCompressionMask: 4054
188
+  iPhoneSdkVersion: 988
189
+  iOSTargetOSVersionString: 11.0
190
+  tvOSSdkVersion: 0
191
+  tvOSRequireExtendedGameController: 0
192
+  tvOSTargetOSVersionString: 11.0
193
+  uIPrerenderedIcon: 0
194
+  uIRequiresPersistentWiFi: 0
195
+  uIRequiresFullScreen: 1
196
+  uIStatusBarHidden: 1
197
+  uIExitOnSuspend: 0
198
+  uIStatusBarStyle: 0
199
+  appleTVSplashScreen: {fileID: 0}
200
+  appleTVSplashScreen2x: {fileID: 0}
201
+  tvOSSmallIconLayers: []
202
+  tvOSSmallIconLayers2x: []
203
+  tvOSLargeIconLayers: []
204
+  tvOSLargeIconLayers2x: []
205
+  tvOSTopShelfImageLayers: []
206
+  tvOSTopShelfImageLayers2x: []
207
+  tvOSTopShelfImageWideLayers: []
208
+  tvOSTopShelfImageWideLayers2x: []
209
+  iOSLaunchScreenType: 0
210
+  iOSLaunchScreenPortrait: {fileID: 0}
211
+  iOSLaunchScreenLandscape: {fileID: 0}
212
+  iOSLaunchScreenBackgroundColor:
213
+    serializedVersion: 2
214
+    rgba: 0
215
+  iOSLaunchScreenFillPct: 100
216
+  iOSLaunchScreenSize: 100
217
+  iOSLaunchScreenCustomXibPath: 
218
+  iOSLaunchScreeniPadType: 0
219
+  iOSLaunchScreeniPadImage: {fileID: 0}
220
+  iOSLaunchScreeniPadBackgroundColor:
221
+    serializedVersion: 2
222
+    rgba: 0
223
+  iOSLaunchScreeniPadFillPct: 100
224
+  iOSLaunchScreeniPadSize: 100
225
+  iOSLaunchScreeniPadCustomXibPath: 
226
+  iOSUseLaunchScreenStoryboard: 0
227
+  iOSLaunchScreenCustomStoryboardPath: 
228
+  iOSDeviceRequirements: []
229
+  iOSURLSchemes: []
230
+  iOSBackgroundModes: 0
231
+  iOSMetalForceHardShadows: 0
232
+  metalEditorSupport: 1
233
+  metalAPIValidation: 1
234
+  iOSRenderExtraFrameOnPause: 0
235
+  appleDeveloperTeamID: 
236
+  iOSManualSigningProvisioningProfileID: 
237
+  tvOSManualSigningProvisioningProfileID: 
238
+  iOSManualSigningProvisioningProfileType: 0
239
+  tvOSManualSigningProvisioningProfileType: 0
240
+  appleEnableAutomaticSigning: 0
241
+  iOSRequireARKit: 0
242
+  iOSAutomaticallyDetectAndAddCapabilities: 1
243
+  appleEnableProMotion: 0
244
+  clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea
245
+  templatePackageId: com.unity.template.3d@5.0.3
246
+  templateDefaultScene: Assets/Scenes/SampleScene.unity
247
+  AndroidTargetArchitectures: 1
248
+  AndroidSplashScreenScale: 0
249
+  androidSplashScreen: {fileID: 0}
250
+  AndroidKeystoreName: 
251
+  AndroidKeyaliasName: 
252
+  AndroidBuildApkPerCpuArchitecture: 0
253
+  AndroidTVCompatibility: 0
254
+  AndroidIsGame: 1
255
+  AndroidEnableTango: 0
256
+  androidEnableBanner: 1
257
+  androidUseLowAccuracyLocation: 0
258
+  androidUseCustomKeystore: 0
259
+  m_AndroidBanners:
260
+  - width: 320
261
+    height: 180
262
+    banner: {fileID: 0}
263
+  androidGamepadSupportLevel: 0
264
+  AndroidMinifyWithR8: 0
265
+  AndroidMinifyRelease: 0
266
+  AndroidMinifyDebug: 0
267
+  AndroidValidateAppBundleSize: 1
268
+  AndroidAppBundleSizeToValidate: 150
269
+  m_BuildTargetIcons: []
270
+  m_BuildTargetPlatformIcons: []
271
+  m_BuildTargetBatching:
272
+  - m_BuildTarget: Standalone
273
+    m_StaticBatching: 1
274
+    m_DynamicBatching: 0
275
+  - m_BuildTarget: tvOS
276
+    m_StaticBatching: 1
277
+    m_DynamicBatching: 0
278
+  - m_BuildTarget: Android
279
+    m_StaticBatching: 1
280
+    m_DynamicBatching: 0
281
+  - m_BuildTarget: iPhone
282
+    m_StaticBatching: 1
283
+    m_DynamicBatching: 0
284
+  - m_BuildTarget: WebGL
285
+    m_StaticBatching: 0
286
+    m_DynamicBatching: 0
287
+  m_BuildTargetGraphicsJobs:
288
+  - m_BuildTarget: MacStandaloneSupport
289
+    m_GraphicsJobs: 0
290
+  - m_BuildTarget: Switch
291
+    m_GraphicsJobs: 1
292
+  - m_BuildTarget: MetroSupport
293
+    m_GraphicsJobs: 1
294
+  - m_BuildTarget: AppleTVSupport
295
+    m_GraphicsJobs: 0
296
+  - m_BuildTarget: BJMSupport
297
+    m_GraphicsJobs: 1
298
+  - m_BuildTarget: LinuxStandaloneSupport
299
+    m_GraphicsJobs: 1
300
+  - m_BuildTarget: PS4Player
301
+    m_GraphicsJobs: 1
302
+  - m_BuildTarget: iOSSupport
303
+    m_GraphicsJobs: 0
304
+  - m_BuildTarget: WindowsStandaloneSupport
305
+    m_GraphicsJobs: 1
306
+  - m_BuildTarget: XboxOnePlayer
307
+    m_GraphicsJobs: 1
308
+  - m_BuildTarget: LuminSupport
309
+    m_GraphicsJobs: 0
310
+  - m_BuildTarget: AndroidPlayer
311
+    m_GraphicsJobs: 0
312
+  - m_BuildTarget: WebGLSupport
313
+    m_GraphicsJobs: 0
314
+  m_BuildTargetGraphicsJobMode:
315
+  - m_BuildTarget: PS4Player
316
+    m_GraphicsJobMode: 0
317
+  - m_BuildTarget: XboxOnePlayer
318
+    m_GraphicsJobMode: 0
319
+  m_BuildTargetGraphicsAPIs:
320
+  - m_BuildTarget: AndroidPlayer
321
+    m_APIs: 150000000b000000
322
+    m_Automatic: 0
323
+  - m_BuildTarget: iOSSupport
324
+    m_APIs: 10000000
325
+    m_Automatic: 1
326
+  - m_BuildTarget: AppleTVSupport
327
+    m_APIs: 10000000
328
+    m_Automatic: 0
329
+  - m_BuildTarget: WebGLSupport
330
+    m_APIs: 0b000000
331
+    m_Automatic: 1
332
+  m_BuildTargetVRSettings:
333
+  - m_BuildTarget: Standalone
334
+    m_Enabled: 0
335
+    m_Devices:
336
+    - Oculus
337
+    - OpenVR
338
+  openGLRequireES31: 0
339
+  openGLRequireES31AEP: 0
340
+  openGLRequireES32: 0
341
+  m_TemplateCustomTags: {}
342
+  mobileMTRendering:
343
+    Android: 1
344
+    iPhone: 1
345
+    tvOS: 1
346
+  m_BuildTargetGroupLightmapEncodingQuality: []
347
+  m_BuildTargetGroupLightmapSettings: []
348
+  playModeTestRunnerEnabled: 0
349
+  runPlayModeTestAsEditModeTest: 0
350
+  actionOnDotNetUnhandledException: 1
351
+  enableInternalProfiler: 0
352
+  logObjCUncaughtExceptions: 1
353
+  enableCrashReportAPI: 0
354
+  cameraUsageDescription: 
355
+  locationUsageDescription: 
356
+  microphoneUsageDescription: 
357
+  switchNMETAOverride: 
358
+  switchNetLibKey: 
359
+  switchSocketMemoryPoolSize: 6144
360
+  switchSocketAllocatorPoolSize: 128
361
+  switchSocketConcurrencyLimit: 14
362
+  switchScreenResolutionBehavior: 2
363
+  switchUseCPUProfiler: 0
364
+  switchUseGOLDLinker: 0
365
+  switchApplicationID: 0x01004b9000490000
366
+  switchNSODependencies: 
367
+  switchTitleNames_0: 
368
+  switchTitleNames_1: 
369
+  switchTitleNames_2: 
370
+  switchTitleNames_3: 
371
+  switchTitleNames_4: 
372
+  switchTitleNames_5: 
373
+  switchTitleNames_6: 
374
+  switchTitleNames_7: 
375
+  switchTitleNames_8: 
376
+  switchTitleNames_9: 
377
+  switchTitleNames_10: 
378
+  switchTitleNames_11: 
379
+  switchTitleNames_12: 
380
+  switchTitleNames_13: 
381
+  switchTitleNames_14: 
382
+  switchPublisherNames_0: 
383
+  switchPublisherNames_1: 
384
+  switchPublisherNames_2: 
385
+  switchPublisherNames_3: 
386
+  switchPublisherNames_4: 
387
+  switchPublisherNames_5: 
388
+  switchPublisherNames_6: 
389
+  switchPublisherNames_7: 
390
+  switchPublisherNames_8: 
391
+  switchPublisherNames_9: 
392
+  switchPublisherNames_10: 
393
+  switchPublisherNames_11: 
394
+  switchPublisherNames_12: 
395
+  switchPublisherNames_13: 
396
+  switchPublisherNames_14: 
397
+  switchIcons_0: {fileID: 0}
398
+  switchIcons_1: {fileID: 0}
399
+  switchIcons_2: {fileID: 0}
400
+  switchIcons_3: {fileID: 0}
401
+  switchIcons_4: {fileID: 0}
402
+  switchIcons_5: {fileID: 0}
403
+  switchIcons_6: {fileID: 0}
404
+  switchIcons_7: {fileID: 0}
405
+  switchIcons_8: {fileID: 0}
406
+  switchIcons_9: {fileID: 0}
407
+  switchIcons_10: {fileID: 0}
408
+  switchIcons_11: {fileID: 0}
409
+  switchIcons_12: {fileID: 0}
410
+  switchIcons_13: {fileID: 0}
411
+  switchIcons_14: {fileID: 0}
412
+  switchSmallIcons_0: {fileID: 0}
413
+  switchSmallIcons_1: {fileID: 0}
414
+  switchSmallIcons_2: {fileID: 0}
415
+  switchSmallIcons_3: {fileID: 0}
416
+  switchSmallIcons_4: {fileID: 0}
417
+  switchSmallIcons_5: {fileID: 0}
418
+  switchSmallIcons_6: {fileID: 0}
419
+  switchSmallIcons_7: {fileID: 0}
420
+  switchSmallIcons_8: {fileID: 0}
421
+  switchSmallIcons_9: {fileID: 0}
422
+  switchSmallIcons_10: {fileID: 0}
423
+  switchSmallIcons_11: {fileID: 0}
424
+  switchSmallIcons_12: {fileID: 0}
425
+  switchSmallIcons_13: {fileID: 0}
426
+  switchSmallIcons_14: {fileID: 0}
427
+  switchManualHTML: 
428
+  switchAccessibleURLs: 
429
+  switchLegalInformation: 
430
+  switchMainThreadStackSize: 1048576
431
+  switchPresenceGroupId: 
432
+  switchLogoHandling: 0
433
+  switchReleaseVersion: 0
434
+  switchDisplayVersion: 1.0.0
435
+  switchStartupUserAccount: 0
436
+  switchTouchScreenUsage: 0
437
+  switchSupportedLanguagesMask: 0
438
+  switchLogoType: 0
439
+  switchApplicationErrorCodeCategory: 
440
+  switchUserAccountSaveDataSize: 0
441
+  switchUserAccountSaveDataJournalSize: 0
442
+  switchApplicationAttribute: 0
443
+  switchCardSpecSize: -1
444
+  switchCardSpecClock: -1
445
+  switchRatingsMask: 0
446
+  switchRatingsInt_0: 0
447
+  switchRatingsInt_1: 0
448
+  switchRatingsInt_2: 0
449
+  switchRatingsInt_3: 0
450
+  switchRatingsInt_4: 0
451
+  switchRatingsInt_5: 0
452
+  switchRatingsInt_6: 0
453
+  switchRatingsInt_7: 0
454
+  switchRatingsInt_8: 0
455
+  switchRatingsInt_9: 0
456
+  switchRatingsInt_10: 0
457
+  switchRatingsInt_11: 0
458
+  switchRatingsInt_12: 0
459
+  switchLocalCommunicationIds_0: 
460
+  switchLocalCommunicationIds_1: 
461
+  switchLocalCommunicationIds_2: 
462
+  switchLocalCommunicationIds_3: 
463
+  switchLocalCommunicationIds_4: 
464
+  switchLocalCommunicationIds_5: 
465
+  switchLocalCommunicationIds_6: 
466
+  switchLocalCommunicationIds_7: 
467
+  switchParentalControl: 0
468
+  switchAllowsScreenshot: 1
469
+  switchAllowsVideoCapturing: 1
470
+  switchAllowsRuntimeAddOnContentInstall: 0
471
+  switchDataLossConfirmation: 0
472
+  switchUserAccountLockEnabled: 0
473
+  switchSystemResourceMemory: 16777216
474
+  switchSupportedNpadStyles: 22
475
+  switchNativeFsCacheSize: 32
476
+  switchIsHoldTypeHorizontal: 0
477
+  switchSupportedNpadCount: 8
478
+  switchSocketConfigEnabled: 0
479
+  switchTcpInitialSendBufferSize: 32
480
+  switchTcpInitialReceiveBufferSize: 64
481
+  switchTcpAutoSendBufferSizeMax: 256
482
+  switchTcpAutoReceiveBufferSizeMax: 256
483
+  switchUdpSendBufferSize: 9
484
+  switchUdpReceiveBufferSize: 42
485
+  switchSocketBufferEfficiency: 4
486
+  switchSocketInitializeEnabled: 1
487
+  switchNetworkInterfaceManagerInitializeEnabled: 1
488
+  switchPlayerConnectionEnabled: 1
489
+  ps4NPAgeRating: 12
490
+  ps4NPTitleSecret: 
491
+  ps4NPTrophyPackPath: 
492
+  ps4ParentalLevel: 11
493
+  ps4ContentID: ED1633-NPXX51362_00-0000000000000000
494
+  ps4Category: 0
495
+  ps4MasterVersion: 01.00
496
+  ps4AppVersion: 01.00
497
+  ps4AppType: 0
498
+  ps4ParamSfxPath: 
499
+  ps4VideoOutPixelFormat: 0
500
+  ps4VideoOutInitialWidth: 1920
501
+  ps4VideoOutBaseModeInitialWidth: 1920
502
+  ps4VideoOutReprojectionRate: 60
503
+  ps4PronunciationXMLPath: 
504
+  ps4PronunciationSIGPath: 
505
+  ps4BackgroundImagePath: 
506
+  ps4StartupImagePath: 
507
+  ps4StartupImagesFolder: 
508
+  ps4IconImagesFolder: 
509
+  ps4SaveDataImagePath: 
510
+  ps4SdkOverride: 
511
+  ps4BGMPath: 
512
+  ps4ShareFilePath: 
513
+  ps4ShareOverlayImagePath: 
514
+  ps4PrivacyGuardImagePath: 
515
+  ps4NPtitleDatPath: 
516
+  ps4RemotePlayKeyAssignment: -1
517
+  ps4RemotePlayKeyMappingDir: 
518
+  ps4PlayTogetherPlayerCount: 0
519
+  ps4EnterButtonAssignment: 1
520
+  ps4ApplicationParam1: 0
521
+  ps4ApplicationParam2: 0
522
+  ps4ApplicationParam3: 0
523
+  ps4ApplicationParam4: 0
524
+  ps4DownloadDataSize: 0
525
+  ps4GarlicHeapSize: 2048
526
+  ps4ProGarlicHeapSize: 2560
527
+  playerPrefsMaxSize: 32768
528
+  ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ
529
+  ps4pnSessions: 1
530
+  ps4pnPresence: 1
531
+  ps4pnFriends: 1
532
+  ps4pnGameCustomData: 1
533
+  playerPrefsSupport: 0
534
+  enableApplicationExit: 0
535
+  resetTempFolder: 1
536
+  restrictedAudioUsageRights: 0
537
+  ps4UseResolutionFallback: 0
538
+  ps4ReprojectionSupport: 0
539
+  ps4UseAudio3dBackend: 0
540
+  ps4UseLowGarlicFragmentationMode: 1
541
+  ps4SocialScreenEnabled: 0
542
+  ps4ScriptOptimizationLevel: 0
543
+  ps4Audio3dVirtualSpeakerCount: 14
544
+  ps4attribCpuUsage: 0
545
+  ps4PatchPkgPath: 
546
+  ps4PatchLatestPkgPath: 
547
+  ps4PatchChangeinfoPath: 
548
+  ps4PatchDayOne: 0
549
+  ps4attribUserManagement: 0
550
+  ps4attribMoveSupport: 0
551
+  ps4attrib3DSupport: 0
552
+  ps4attribShareSupport: 0
553
+  ps4attribExclusiveVR: 0
554
+  ps4disableAutoHideSplash: 0
555
+  ps4videoRecordingFeaturesUsed: 0
556
+  ps4contentSearchFeaturesUsed: 0
557
+  ps4attribEyeToEyeDistanceSettingVR: 0
558
+  ps4IncludedModules: []
559
+  ps4attribVROutputEnabled: 0
560
+  monoEnv: 
561
+  splashScreenBackgroundSourceLandscape: {fileID: 0}
562
+  splashScreenBackgroundSourcePortrait: {fileID: 0}
563
+  blurSplashScreenBackground: 1
564
+  spritePackerPolicy: 
565
+  webGLMemorySize: 16
566
+  webGLExceptionSupport: 1
567
+  webGLNameFilesAsHashes: 0
568
+  webGLDataCaching: 1
569
+  webGLDebugSymbols: 0
570
+  webGLEmscriptenArgs: 
571
+  webGLModulesDirectory: 
572
+  webGLTemplate: APPLICATION:Default
573
+  webGLAnalyzeBuildSize: 0
574
+  webGLUseEmbeddedResources: 0
575
+  webGLCompressionFormat: 1
576
+  webGLWasmArithmeticExceptions: 0
577
+  webGLLinkerTarget: 1
578
+  webGLThreadsSupport: 0
579
+  webGLDecompressionFallback: 0
580
+  scriptingDefineSymbols: {}
581
+  platformArchitecture: {}
582
+  scriptingBackend: {}
583
+  il2cppCompilerConfiguration: {}
584
+  managedStrippingLevel: {}
585
+  incrementalIl2cppBuild: {}
586
+  allowUnsafeCode: 0
587
+  useDeterministicCompilation: 1
588
+  additionalIl2CppArgs: 
589
+  scriptingRuntimeVersion: 1
590
+  gcIncremental: 1
591
+  gcWBarrierValidation: 0
592
+  apiCompatibilityLevelPerPlatform: {}
593
+  m_RenderingPath: 1
594
+  m_MobileRenderingPath: 1
595
+  metroPackageName: Template_3D
596
+  metroPackageVersion: 
597
+  metroCertificatePath: 
598
+  metroCertificatePassword: 
599
+  metroCertificateSubject: 
600
+  metroCertificateIssuer: 
601
+  metroCertificateNotAfter: 0000000000000000
602
+  metroApplicationDescription: Template_3D
603
+  wsaImages: {}
604
+  metroTileShortName: 
605
+  metroTileShowName: 0
606
+  metroMediumTileShowName: 0
607
+  metroLargeTileShowName: 0
608
+  metroWideTileShowName: 0
609
+  metroSupportStreamingInstall: 0
610
+  metroLastRequiredScene: 0
611
+  metroDefaultTileSize: 1
612
+  metroTileForegroundText: 2
613
+  metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0}
614
+  metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1}
615
+  metroSplashScreenUseBackgroundColor: 0
616
+  platformCapabilities: {}
617
+  metroTargetDeviceFamilies: {}
618
+  metroFTAName: 
619
+  metroFTAFileTypes: []
620
+  metroProtocolName: 
621
+  XboxOneProductId: 
622
+  XboxOneUpdateKey: 
623
+  XboxOneSandboxId: 
624
+  XboxOneContentId: 
625
+  XboxOneTitleId: 
626
+  XboxOneSCId: 
627
+  XboxOneGameOsOverridePath: 
628
+  XboxOnePackagingOverridePath: 
629
+  XboxOneAppManifestOverridePath: 
630
+  XboxOneVersion: 1.0.0.0
631
+  XboxOnePackageEncryption: 0
632
+  XboxOnePackageUpdateGranularity: 2
633
+  XboxOneDescription: 
634
+  XboxOneLanguage:
635
+  - enus
636
+  XboxOneCapability: []
637
+  XboxOneGameRating: {}
638
+  XboxOneIsContentPackage: 0
639
+  XboxOneEnableGPUVariability: 1
640
+  XboxOneSockets: {}
641
+  XboxOneSplashScreen: {fileID: 0}
642
+  XboxOneAllowedProductIds: []
643
+  XboxOnePersistentLocalStorageSize: 0
644
+  XboxOneXTitleMemory: 8
645
+  XboxOneOverrideIdentityName: 
646
+  XboxOneOverrideIdentityPublisher: 
647
+  vrEditorSettings:
648
+    daydream:
649
+      daydreamIconForeground: {fileID: 0}
650
+      daydreamIconBackground: {fileID: 0}
651
+  cloudServicesEnabled:
652
+    UNet: 1
653
+  luminIcon:
654
+    m_Name: 
655
+    m_ModelFolderPath: 
656
+    m_PortalFolderPath: 
657
+  luminCert:
658
+    m_CertPath: 
659
+    m_SignPackage: 1
660
+  luminIsChannelApp: 0
661
+  luminVersion:
662
+    m_VersionCode: 1
663
+    m_VersionName: 
664
+  apiCompatibilityLevel: 6
665
+  cloudProjectId: 
666
+  framebufferDepthMemorylessMode: 0
667
+  projectName: 
668
+  organizationId: 
669
+  cloudEnabled: 0
670
+  enableNativePlatformBackendsForNewInputSystem: 0
671
+  disableOldInputManagerSupport: 0
672
+  legacyClampBlendShapeWeights: 0
673
+  virtualTexturingSupportEnabled: 0

+ 2
- 0
Client/ProjectSettings/ProjectVersion.txt Vedi File

@@ -0,0 +1,2 @@
1
+m_EditorVersion: 2020.1.1f1
2
+m_EditorVersionWithRevision: 2020.1.1f1 (2285c3239188)

+ 232
- 0
Client/ProjectSettings/QualitySettings.asset Vedi File

@@ -0,0 +1,232 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!47 &1
4
+QualitySettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 5
7
+  m_CurrentQuality: 5
8
+  m_QualitySettings:
9
+  - serializedVersion: 2
10
+    name: Very Low
11
+    pixelLightCount: 0
12
+    shadows: 0
13
+    shadowResolution: 0
14
+    shadowProjection: 1
15
+    shadowCascades: 1
16
+    shadowDistance: 15
17
+    shadowNearPlaneOffset: 3
18
+    shadowCascade2Split: 0.33333334
19
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
20
+    shadowmaskMode: 0
21
+    blendWeights: 1
22
+    textureQuality: 1
23
+    anisotropicTextures: 0
24
+    antiAliasing: 0
25
+    softParticles: 0
26
+    softVegetation: 0
27
+    realtimeReflectionProbes: 0
28
+    billboardsFaceCameraPosition: 0
29
+    vSyncCount: 0
30
+    lodBias: 0.3
31
+    maximumLODLevel: 0
32
+    streamingMipmapsActive: 0
33
+    streamingMipmapsAddAllCameras: 1
34
+    streamingMipmapsMemoryBudget: 512
35
+    streamingMipmapsRenderersPerFrame: 512
36
+    streamingMipmapsMaxLevelReduction: 2
37
+    streamingMipmapsMaxFileIORequests: 1024
38
+    particleRaycastBudget: 4
39
+    asyncUploadTimeSlice: 2
40
+    asyncUploadBufferSize: 16
41
+    asyncUploadPersistentBuffer: 1
42
+    resolutionScalingFixedDPIFactor: 1
43
+    excludedTargetPlatforms: []
44
+  - serializedVersion: 2
45
+    name: Low
46
+    pixelLightCount: 0
47
+    shadows: 0
48
+    shadowResolution: 0
49
+    shadowProjection: 1
50
+    shadowCascades: 1
51
+    shadowDistance: 20
52
+    shadowNearPlaneOffset: 3
53
+    shadowCascade2Split: 0.33333334
54
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
55
+    shadowmaskMode: 0
56
+    blendWeights: 2
57
+    textureQuality: 0
58
+    anisotropicTextures: 0
59
+    antiAliasing: 0
60
+    softParticles: 0
61
+    softVegetation: 0
62
+    realtimeReflectionProbes: 0
63
+    billboardsFaceCameraPosition: 0
64
+    vSyncCount: 0
65
+    lodBias: 0.4
66
+    maximumLODLevel: 0
67
+    streamingMipmapsActive: 0
68
+    streamingMipmapsAddAllCameras: 1
69
+    streamingMipmapsMemoryBudget: 512
70
+    streamingMipmapsRenderersPerFrame: 512
71
+    streamingMipmapsMaxLevelReduction: 2
72
+    streamingMipmapsMaxFileIORequests: 1024
73
+    particleRaycastBudget: 16
74
+    asyncUploadTimeSlice: 2
75
+    asyncUploadBufferSize: 16
76
+    asyncUploadPersistentBuffer: 1
77
+    resolutionScalingFixedDPIFactor: 1
78
+    excludedTargetPlatforms: []
79
+  - serializedVersion: 2
80
+    name: Medium
81
+    pixelLightCount: 1
82
+    shadows: 1
83
+    shadowResolution: 0
84
+    shadowProjection: 1
85
+    shadowCascades: 1
86
+    shadowDistance: 20
87
+    shadowNearPlaneOffset: 3
88
+    shadowCascade2Split: 0.33333334
89
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
90
+    shadowmaskMode: 0
91
+    blendWeights: 2
92
+    textureQuality: 0
93
+    anisotropicTextures: 1
94
+    antiAliasing: 0
95
+    softParticles: 0
96
+    softVegetation: 0
97
+    realtimeReflectionProbes: 0
98
+    billboardsFaceCameraPosition: 0
99
+    vSyncCount: 1
100
+    lodBias: 0.7
101
+    maximumLODLevel: 0
102
+    streamingMipmapsActive: 0
103
+    streamingMipmapsAddAllCameras: 1
104
+    streamingMipmapsMemoryBudget: 512
105
+    streamingMipmapsRenderersPerFrame: 512
106
+    streamingMipmapsMaxLevelReduction: 2
107
+    streamingMipmapsMaxFileIORequests: 1024
108
+    particleRaycastBudget: 64
109
+    asyncUploadTimeSlice: 2
110
+    asyncUploadBufferSize: 16
111
+    asyncUploadPersistentBuffer: 1
112
+    resolutionScalingFixedDPIFactor: 1
113
+    excludedTargetPlatforms: []
114
+  - serializedVersion: 2
115
+    name: High
116
+    pixelLightCount: 2
117
+    shadows: 2
118
+    shadowResolution: 1
119
+    shadowProjection: 1
120
+    shadowCascades: 2
121
+    shadowDistance: 40
122
+    shadowNearPlaneOffset: 3
123
+    shadowCascade2Split: 0.33333334
124
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
125
+    shadowmaskMode: 1
126
+    blendWeights: 2
127
+    textureQuality: 0
128
+    anisotropicTextures: 1
129
+    antiAliasing: 0
130
+    softParticles: 0
131
+    softVegetation: 1
132
+    realtimeReflectionProbes: 1
133
+    billboardsFaceCameraPosition: 1
134
+    vSyncCount: 1
135
+    lodBias: 1
136
+    maximumLODLevel: 0
137
+    streamingMipmapsActive: 0
138
+    streamingMipmapsAddAllCameras: 1
139
+    streamingMipmapsMemoryBudget: 512
140
+    streamingMipmapsRenderersPerFrame: 512
141
+    streamingMipmapsMaxLevelReduction: 2
142
+    streamingMipmapsMaxFileIORequests: 1024
143
+    particleRaycastBudget: 256
144
+    asyncUploadTimeSlice: 2
145
+    asyncUploadBufferSize: 16
146
+    asyncUploadPersistentBuffer: 1
147
+    resolutionScalingFixedDPIFactor: 1
148
+    excludedTargetPlatforms: []
149
+  - serializedVersion: 2
150
+    name: Very High
151
+    pixelLightCount: 3
152
+    shadows: 2
153
+    shadowResolution: 2
154
+    shadowProjection: 1
155
+    shadowCascades: 2
156
+    shadowDistance: 70
157
+    shadowNearPlaneOffset: 3
158
+    shadowCascade2Split: 0.33333334
159
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
160
+    shadowmaskMode: 1
161
+    blendWeights: 4
162
+    textureQuality: 0
163
+    anisotropicTextures: 2
164
+    antiAliasing: 2
165
+    softParticles: 1
166
+    softVegetation: 1
167
+    realtimeReflectionProbes: 1
168
+    billboardsFaceCameraPosition: 1
169
+    vSyncCount: 1
170
+    lodBias: 1.5
171
+    maximumLODLevel: 0
172
+    streamingMipmapsActive: 0
173
+    streamingMipmapsAddAllCameras: 1
174
+    streamingMipmapsMemoryBudget: 512
175
+    streamingMipmapsRenderersPerFrame: 512
176
+    streamingMipmapsMaxLevelReduction: 2
177
+    streamingMipmapsMaxFileIORequests: 1024
178
+    particleRaycastBudget: 1024
179
+    asyncUploadTimeSlice: 2
180
+    asyncUploadBufferSize: 16
181
+    asyncUploadPersistentBuffer: 1
182
+    resolutionScalingFixedDPIFactor: 1
183
+    excludedTargetPlatforms: []
184
+  - serializedVersion: 2
185
+    name: Ultra
186
+    pixelLightCount: 4
187
+    shadows: 2
188
+    shadowResolution: 2
189
+    shadowProjection: 1
190
+    shadowCascades: 4
191
+    shadowDistance: 150
192
+    shadowNearPlaneOffset: 3
193
+    shadowCascade2Split: 0.33333334
194
+    shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
195
+    shadowmaskMode: 1
196
+    blendWeights: 4
197
+    textureQuality: 0
198
+    anisotropicTextures: 2
199
+    antiAliasing: 2
200
+    softParticles: 1
201
+    softVegetation: 1
202
+    realtimeReflectionProbes: 1
203
+    billboardsFaceCameraPosition: 1
204
+    vSyncCount: 1
205
+    lodBias: 2
206
+    maximumLODLevel: 0
207
+    streamingMipmapsActive: 0
208
+    streamingMipmapsAddAllCameras: 1
209
+    streamingMipmapsMemoryBudget: 512
210
+    streamingMipmapsRenderersPerFrame: 512
211
+    streamingMipmapsMaxLevelReduction: 2
212
+    streamingMipmapsMaxFileIORequests: 1024
213
+    particleRaycastBudget: 4096
214
+    asyncUploadTimeSlice: 2
215
+    asyncUploadBufferSize: 16
216
+    asyncUploadPersistentBuffer: 1
217
+    resolutionScalingFixedDPIFactor: 1
218
+    excludedTargetPlatforms: []
219
+  m_PerPlatformDefaultQuality:
220
+    Android: 2
221
+    Lumin: 5
222
+    Nintendo 3DS: 5
223
+    Nintendo Switch: 5
224
+    PS4: 5
225
+    PSP2: 2
226
+    Stadia: 5
227
+    Standalone: 5
228
+    WebGL: 3
229
+    Windows Store Apps: 5
230
+    XboxOne: 5
231
+    iPhone: 2
232
+    tvOS: 2

+ 43
- 0
Client/ProjectSettings/TagManager.asset Vedi File

@@ -0,0 +1,43 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!78 &1
4
+TagManager:
5
+  serializedVersion: 2
6
+  tags: []
7
+  layers:
8
+  - Default
9
+  - TransparentFX
10
+  - Ignore Raycast
11
+  - 
12
+  - Water
13
+  - UI
14
+  - 
15
+  - 
16
+  - 
17
+  - 
18
+  - 
19
+  - 
20
+  - 
21
+  - 
22
+  - 
23
+  - 
24
+  - 
25
+  - 
26
+  - 
27
+  - 
28
+  - 
29
+  - 
30
+  - 
31
+  - 
32
+  - 
33
+  - 
34
+  - 
35
+  - 
36
+  - 
37
+  - 
38
+  - 
39
+  - 
40
+  m_SortingLayers:
41
+  - name: Default
42
+    uniqueID: 0
43
+    locked: 0

+ 9
- 0
Client/ProjectSettings/TimeManager.asset Vedi File

@@ -0,0 +1,9 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!5 &1
4
+TimeManager:
5
+  m_ObjectHideFlags: 0
6
+  Fixed Timestep: 0.033333
7
+  Maximum Allowed Timestep: 0.1
8
+  m_TimeScale: 1
9
+  Maximum Particle Timestep: 0.033333

+ 34
- 0
Client/ProjectSettings/UnityConnectSettings.asset Vedi File

@@ -0,0 +1,34 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!310 &1
4
+UnityConnectSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 1
7
+  m_Enabled: 0
8
+  m_TestMode: 0
9
+  m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
10
+  m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
11
+  m_ConfigUrl: https://config.uca.cloud.unity3d.com
12
+  m_TestInitMode: 0
13
+  CrashReportingSettings:
14
+    m_EventUrl: https://perf-events.cloud.unity3d.com
15
+    m_Enabled: 0
16
+    m_LogBufferSize: 10
17
+    m_CaptureEditorExceptions: 1
18
+  UnityPurchasingSettings:
19
+    m_Enabled: 0
20
+    m_TestMode: 0
21
+  UnityAnalyticsSettings:
22
+    m_Enabled: 0
23
+    m_TestMode: 0
24
+    m_InitializeOnStartup: 1
25
+  UnityAdsSettings:
26
+    m_Enabled: 0
27
+    m_InitializeOnStartup: 1
28
+    m_TestMode: 0
29
+    m_IosGameId: 
30
+    m_AndroidGameId: 
31
+    m_GameIds: {}
32
+    m_GameId: 
33
+  PerformanceReportingSettings:
34
+    m_Enabled: 0

+ 12
- 0
Client/ProjectSettings/VFXManager.asset Vedi File

@@ -0,0 +1,12 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!937362698 &1
4
+VFXManager:
5
+  m_ObjectHideFlags: 0
6
+  m_IndirectShader: {fileID: 0}
7
+  m_CopyBufferShader: {fileID: 0}
8
+  m_SortShader: {fileID: 0}
9
+  m_StripUpdateShader: {fileID: 0}
10
+  m_RenderPipeSettingsPath: 
11
+  m_FixedTimeStep: 0.016666668
12
+  m_MaxDeltaTime: 0.05

+ 8
- 0
Client/ProjectSettings/VersionControlSettings.asset Vedi File

@@ -0,0 +1,8 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!890905787 &1
4
+VersionControlSettings:
5
+  m_ObjectHideFlags: 0
6
+  m_Mode: Visible Meta Files
7
+  m_CollabEditorSettings:
8
+    inProgressEnabled: 1

+ 10
- 0
Client/ProjectSettings/XRSettings.asset Vedi File

@@ -0,0 +1,10 @@
1
+{
2
+    "m_SettingKeys": [
3
+        "VR Device Disabled",
4
+        "VR Device User Alert"
5
+    ],
6
+    "m_SettingValues": [
7
+        "False",
8
+        "False"
9
+    ]
10
+}

+ 19
- 0
Client/UserSettings/EditorUserSettings.asset Vedi File

@@ -0,0 +1,19 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!162 &1
4
+EditorUserSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 4
7
+  m_ConfigSettings:
8
+    vcSharedLogLevel:
9
+      value: 0d5e400f0650
10
+      flags: 0
11
+  m_VCAutomaticAdd: 1
12
+  m_VCDebugCom: 0
13
+  m_VCDebugCmd: 0
14
+  m_VCDebugOut: 0
15
+  m_SemanticMergeMode: 2
16
+  m_VCShowFailedCheckout: 1
17
+  m_VCOverwriteFailedCheckoutAssets: 1
18
+  m_VCOverlayIcons: 1
19
+  m_VCAllowAsyncUpdate: 0

+ 227
- 0
Server Standalone/GameServer/GameServer/Client.cs Vedi File

@@ -0,0 +1,227 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using System.Net;
5
+using System.Net.Sockets;
6
+using System.Numerics;
7
+
8
+namespace GameServer
9
+{
10
+    class Client
11
+    {
12
+        public static int dataBufferSize = 4096;
13
+        
14
+        public int id;
15
+        public Player player;
16
+        public TCP tcp;
17
+        public UDP udp;
18
+
19
+        public Client(int _clientId)
20
+        {
21
+            id = _clientId;
22
+            tcp = new TCP(id);
23
+            udp = new UDP(id);
24
+        }
25
+
26
+        public class TCP
27
+        {
28
+            public TcpClient socket;
29
+
30
+            private readonly int id;
31
+            private NetworkStream stream;
32
+            private Packet receivedData;
33
+            private byte[] receiveBuffer;
34
+
35
+            public TCP(int _id)
36
+            {
37
+                id = _id;
38
+            }
39
+
40
+            public void Connect(TcpClient _socket)
41
+            {
42
+                socket = _socket;
43
+                socket.ReceiveBufferSize = dataBufferSize;
44
+                socket.SendBufferSize = dataBufferSize;
45
+
46
+                stream = socket.GetStream();
47
+
48
+                receivedData = new Packet();
49
+                receiveBuffer = new byte[dataBufferSize];
50
+
51
+                stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
52
+
53
+                ServerSend.Welcome(id, "Welcome to the server");
54
+            }
55
+
56
+            public void SendData(Packet _packet)
57
+            {
58
+                try
59
+                {
60
+                    if (socket != null)
61
+                    {
62
+                        stream.BeginWrite(_packet.ToArray(), 0, _packet.Length(), null, null);
63
+                    }
64
+                }
65
+                catch (Exception _ex)
66
+                {
67
+                    Console.WriteLine($"Error sending data to the player {id} via TCP: {_ex}");
68
+                }
69
+            }
70
+
71
+            private void ReceiveCallback(IAsyncResult _result)
72
+            {
73
+                try
74
+                {
75
+                    int _byteLength = stream.EndRead(_result);
76
+                    if (_byteLength <= 0)
77
+                    {
78
+                        Server.clients[id].Disconnect();
79
+                        return;
80
+                    }
81
+
82
+                    byte[] _data = new byte[_byteLength];
83
+                    Array.Copy(receiveBuffer, _data, _byteLength);
84
+
85
+                    receivedData.Reset(HandleData(_data));
86
+                    stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
87
+                }
88
+                catch (Exception _ex)
89
+                {
90
+                    Console.WriteLine($"Error receiving TCP data : {_ex}");
91
+                    // TODO diconnect
92
+                }
93
+            }
94
+
95
+            private bool HandleData(byte[] _data)
96
+            {
97
+                int _packetLength = 0;
98
+
99
+                receivedData.SetBytes(_data);
100
+
101
+                if (receivedData.UnreadLength() >= 4)
102
+                {
103
+                    _packetLength = receivedData.ReadInt();
104
+                    if (_packetLength <= 0)
105
+                    {
106
+                        return true;
107
+                    }
108
+                }
109
+
110
+                while (_packetLength > 0 && _packetLength <= receivedData.UnreadLength())
111
+                {
112
+                    byte[] _packetBytes = receivedData.ReadBytes(_packetLength);
113
+                    ThreadManager.ExecuteOnMainThread(() =>
114
+                    {
115
+                        using (Packet _packet = new Packet(_packetBytes))
116
+                        {
117
+                            int _packetId = _packet.ReadInt();
118
+                            Server.packetHandlers[_packetId](id, _packet);
119
+                        }
120
+                    });
121
+
122
+                    _packetLength = 0;
123
+                    if (receivedData.UnreadLength() >= 4)
124
+                    {
125
+                        _packetLength = receivedData.ReadInt();
126
+                        if (_packetLength <= 0)
127
+                        {
128
+                            return true;
129
+                        }
130
+                    }
131
+                }
132
+
133
+                if (_packetLength <= 1)
134
+                {
135
+                    return true;
136
+                }
137
+
138
+                return false;
139
+            }
140
+
141
+            public void Disconnect()
142
+            {
143
+                socket.Close();
144
+                stream = null;
145
+                receivedData = null;
146
+                receiveBuffer = null;
147
+                socket = null;
148
+            }
149
+        }
150
+    
151
+        public class UDP
152
+        {
153
+            public IPEndPoint endPoint;
154
+
155
+            private int id;
156
+
157
+            public UDP(int _id)
158
+            {
159
+                id = _id;
160
+            }
161
+
162
+            public void Connect(IPEndPoint _endPoint)
163
+            {
164
+                endPoint = _endPoint;
165
+            }
166
+
167
+            public void SendData(Packet _packet)
168
+            {
169
+                Server.SendUDPData(endPoint, _packet);
170
+            }
171
+
172
+            public void HandleData(Packet _packetData)
173
+            {
174
+                int _packetLength = _packetData.ReadInt();
175
+                byte[] _packetBytes = _packetData.ReadBytes(_packetLength);
176
+
177
+                ThreadManager.ExecuteOnMainThread(() =>
178
+                {
179
+                    using (Packet _packet = new Packet(_packetBytes))
180
+                    {
181
+                        int _packetId = _packet.ReadInt();
182
+                        Server.packetHandlers[_packetId](id, _packet);
183
+                    }
184
+                });
185
+            }
186
+
187
+            public void Disconnect()
188
+            {
189
+                endPoint = null;
190
+            }
191
+        }
192
+
193
+        public void SendIntoGame(string _playerName)
194
+        {
195
+            player = new Player(id, _playerName, new Vector3(0, 0, 0));
196
+
197
+            foreach (Client _client in Server.clients.Values)
198
+            {
199
+                if (_client.player != null)
200
+                {
201
+                    if (_client.id != id)
202
+                    {
203
+                        ServerSend.SpawnPlayer(id, _client.player);
204
+                    }
205
+                }
206
+            }
207
+
208
+            foreach (Client _client in Server.clients.Values)
209
+            {
210
+                if (_client.player != null)
211
+                {
212
+                    ServerSend.SpawnPlayer(_client.id, player);
213
+                }
214
+            }
215
+        }
216
+
217
+        public void Disconnect()
218
+        {
219
+            Console.WriteLine($"{tcp.socket.Client.RemoteEndPoint} has disconnected.");
220
+
221
+            player = null;
222
+
223
+            tcp.Disconnect();
224
+            udp.Disconnect();
225
+        }
226
+    }
227
+}

+ 12
- 0
Server Standalone/GameServer/GameServer/Constants.cs Vedi File

@@ -0,0 +1,12 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace GameServer
6
+{
7
+    class Constants
8
+    {
9
+        public const int TICKS_PER_SEC = 30;
10
+        public const int MS_PER_TICKS = 1000 / TICKS_PER_SEC;
11
+    }
12
+}

+ 21
- 0
Server Standalone/GameServer/GameServer/GameLogic.cs Vedi File

@@ -0,0 +1,21 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace GameServer
6
+{
7
+    class GameLogic
8
+    {
9
+        public static void Update()
10
+        {
11
+            foreach (Client _client in Server.clients.Values)
12
+            {
13
+                if (_client.player != null)
14
+                {
15
+                    _client.player.Update();
16
+                }   
17
+            }
18
+            ThreadManager.UpdateMain();
19
+        }
20
+    }
21
+}

+ 386
- 0
Server Standalone/GameServer/GameServer/Packet.cs Vedi File

@@ -0,0 +1,386 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Numerics;
4
+using System.Text;
5
+
6
+namespace GameServer
7
+{
8
+    /// <summary>Sent from server to client.</summary>
9
+    public enum ServerPackets
10
+    {
11
+        welcome = 1,
12
+        spawnPlayer,
13
+        playerPosition,
14
+        playerRotation
15
+    }
16
+
17
+    /// <summary>Sent from client to server.</summary>
18
+    public enum ClientPackets
19
+    {
20
+        welcomeReceived = 1,
21
+        playerMovement
22
+    }
23
+
24
+    public class Packet : IDisposable
25
+    {
26
+        private List<byte> buffer;
27
+        private byte[] readableBuffer;
28
+        private int readPos;
29
+
30
+        /// <summary>Creates a new empty packet (without an ID).</summary>
31
+        public Packet()
32
+        {
33
+            buffer = new List<byte>(); // Intitialize buffer
34
+            readPos = 0; // Set readPos to 0
35
+        }
36
+
37
+        /// <summary>Creates a new packet with a given ID. Used for sending.</summary>
38
+        /// <param name="_id">The packet ID.</param>
39
+        public Packet(int _id)
40
+        {
41
+            buffer = new List<byte>(); // Intitialize buffer
42
+            readPos = 0; // Set readPos to 0
43
+
44
+            Write(_id); // Write packet id to the buffer
45
+        }
46
+
47
+        /// <summary>Creates a packet from which data can be read. Used for receiving.</summary>
48
+        /// <param name="_data">The bytes to add to the packet.</param>
49
+        public Packet(byte[] _data)
50
+        {
51
+            buffer = new List<byte>(); // Intitialize buffer
52
+            readPos = 0; // Set readPos to 0
53
+
54
+            SetBytes(_data);
55
+        }
56
+
57
+        #region Functions
58
+        /// <summary>Sets the packet's content and prepares it to be read.</summary>
59
+        /// <param name="_data">The bytes to add to the packet.</param>
60
+        public void SetBytes(byte[] _data)
61
+        {
62
+            Write(_data);
63
+            readableBuffer = buffer.ToArray();
64
+        }
65
+
66
+        /// <summary>Inserts the length of the packet's content at the start of the buffer.</summary>
67
+        public void WriteLength()
68
+        {
69
+            buffer.InsertRange(0, BitConverter.GetBytes(buffer.Count)); // Insert the byte length of the packet at the very beginning
70
+        }
71
+
72
+        /// <summary>Inserts the given int at the start of the buffer.</summary>
73
+        /// <param name="_value">The int to insert.</param>
74
+        public void InsertInt(int _value)
75
+        {
76
+            buffer.InsertRange(0, BitConverter.GetBytes(_value)); // Insert the int at the start of the buffer
77
+        }
78
+
79
+        /// <summary>Gets the packet's content in array form.</summary>
80
+        public byte[] ToArray()
81
+        {
82
+            readableBuffer = buffer.ToArray();
83
+            return readableBuffer;
84
+        }
85
+
86
+        /// <summary>Gets the length of the packet's content.</summary>
87
+        public int Length()
88
+        {
89
+            return buffer.Count; // Return the length of buffer
90
+        }
91
+
92
+        /// <summary>Gets the length of the unread data contained in the packet.</summary>
93
+        public int UnreadLength()
94
+        {
95
+            return Length() - readPos; // Return the remaining length (unread)
96
+        }
97
+
98
+        /// <summary>Resets the packet instance to allow it to be reused.</summary>
99
+        /// <param name="_shouldReset">Whether or not to reset the packet.</param>
100
+        public void Reset(bool _shouldReset = true)
101
+        {
102
+            if (_shouldReset)
103
+            {
104
+                buffer.Clear(); // Clear buffer
105
+                readableBuffer = null;
106
+                readPos = 0; // Reset readPos
107
+            }
108
+            else
109
+            {
110
+                readPos -= 4; // "Unread" the last read int
111
+            }
112
+        }
113
+        #endregion
114
+
115
+        #region Write Data
116
+        /// <summary>Adds a byte to the packet.</summary>
117
+        /// <param name="_value">The byte to add.</param>
118
+        public void Write(byte _value)
119
+        {
120
+            buffer.Add(_value);
121
+        }
122
+        /// <summary>Adds an array of bytes to the packet.</summary>
123
+        /// <param name="_value">The byte array to add.</param>
124
+        public void Write(byte[] _value)
125
+        {
126
+            buffer.AddRange(_value);
127
+        }
128
+        /// <summary>Adds a short to the packet.</summary>
129
+        /// <param name="_value">The short to add.</param>
130
+        public void Write(short _value)
131
+        {
132
+            buffer.AddRange(BitConverter.GetBytes(_value));
133
+        }
134
+        /// <summary>Adds an int to the packet.</summary>
135
+        /// <param name="_value">The int to add.</param>
136
+        public void Write(int _value)
137
+        {
138
+            buffer.AddRange(BitConverter.GetBytes(_value));
139
+        }
140
+        /// <summary>Adds a long to the packet.</summary>
141
+        /// <param name="_value">The long to add.</param>
142
+        public void Write(long _value)
143
+        {
144
+            buffer.AddRange(BitConverter.GetBytes(_value));
145
+        }
146
+        /// <summary>Adds a float to the packet.</summary>
147
+        /// <param name="_value">The float to add.</param>
148
+        public void Write(float _value)
149
+        {
150
+            buffer.AddRange(BitConverter.GetBytes(_value));
151
+        }
152
+        /// <summary>Adds a bool to the packet.</summary>
153
+        /// <param name="_value">The bool to add.</param>
154
+        public void Write(bool _value)
155
+        {
156
+            buffer.AddRange(BitConverter.GetBytes(_value));
157
+        }
158
+        /// <summary>Adds a string to the packet.</summary>
159
+        /// <param name="_value">The string to add.</param>
160
+        public void Write(string _value)
161
+        {
162
+            Write(_value.Length); // Add the length of the string to the packet
163
+            buffer.AddRange(Encoding.ASCII.GetBytes(_value)); // Add the string itself
164
+        }
165
+
166
+        public void Write(Vector3 _value)
167
+        {
168
+            Write(_value.X);
169
+            Write(_value.Y);
170
+            Write(_value.Z);
171
+        }
172
+
173
+        public void Write(Quaternion _value)
174
+        {
175
+            Write(_value.X);
176
+            Write(_value.Y);
177
+            Write(_value.Z);
178
+            Write(_value.W);
179
+        }
180
+        #endregion
181
+
182
+        #region Read Data
183
+        /// <summary>Reads a byte from the packet.</summary>
184
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
185
+        public byte ReadByte(bool _moveReadPos = true)
186
+        {
187
+            if (buffer.Count > readPos)
188
+            {
189
+                // If there are unread bytes
190
+                byte _value = readableBuffer[readPos]; // Get the byte at readPos' position
191
+                if (_moveReadPos)
192
+                {
193
+                    // If _moveReadPos is true
194
+                    readPos += 1; // Increase readPos by 1
195
+                }
196
+                return _value; // Return the byte
197
+            }
198
+            else
199
+            {
200
+                throw new Exception("Could not read value of type 'byte'!");
201
+            }
202
+        }
203
+
204
+        /// <summary>Reads an array of bytes from the packet.</summary>
205
+        /// <param name="_length">The length of the byte array.</param>
206
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
207
+        public byte[] ReadBytes(int _length, bool _moveReadPos = true)
208
+        {
209
+            if (buffer.Count > readPos)
210
+            {
211
+                // If there are unread bytes
212
+                byte[] _value = buffer.GetRange(readPos, _length).ToArray(); // Get the bytes at readPos' position with a range of _length
213
+                if (_moveReadPos)
214
+                {
215
+                    // If _moveReadPos is true
216
+                    readPos += _length; // Increase readPos by _length
217
+                }
218
+                return _value; // Return the bytes
219
+            }
220
+            else
221
+            {
222
+                throw new Exception("Could not read value of type 'byte[]'!");
223
+            }
224
+        }
225
+
226
+        /// <summary>Reads a short from the packet.</summary>
227
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
228
+        public short ReadShort(bool _moveReadPos = true)
229
+        {
230
+            if (buffer.Count > readPos)
231
+            {
232
+                // If there are unread bytes
233
+                short _value = BitConverter.ToInt16(readableBuffer, readPos); // Convert the bytes to a short
234
+                if (_moveReadPos)
235
+                {
236
+                    // If _moveReadPos is true and there are unread bytes
237
+                    readPos += 2; // Increase readPos by 2
238
+                }
239
+                return _value; // Return the short
240
+            }
241
+            else
242
+            {
243
+                throw new Exception("Could not read value of type 'short'!");
244
+            }
245
+        }
246
+
247
+        /// <summary>Reads an int from the packet.</summary>
248
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
249
+        public int ReadInt(bool _moveReadPos = true)
250
+        {
251
+            if (buffer.Count > readPos)
252
+            {
253
+                // If there are unread bytes
254
+                int _value = BitConverter.ToInt32(readableBuffer, readPos); // Convert the bytes to an int
255
+                if (_moveReadPos)
256
+                {
257
+                    // If _moveReadPos is true
258
+                    readPos += 4; // Increase readPos by 4
259
+                }
260
+                return _value; // Return the int
261
+            }
262
+            else
263
+            {
264
+                throw new Exception("Could not read value of type 'int'!");
265
+            }
266
+        }
267
+
268
+        /// <summary>Reads a long from the packet.</summary>
269
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
270
+        public long ReadLong(bool _moveReadPos = true)
271
+        {
272
+            if (buffer.Count > readPos)
273
+            {
274
+                // If there are unread bytes
275
+                long _value = BitConverter.ToInt64(readableBuffer, readPos); // Convert the bytes to a long
276
+                if (_moveReadPos)
277
+                {
278
+                    // If _moveReadPos is true
279
+                    readPos += 8; // Increase readPos by 8
280
+                }
281
+                return _value; // Return the long
282
+            }
283
+            else
284
+            {
285
+                throw new Exception("Could not read value of type 'long'!");
286
+            }
287
+        }
288
+
289
+        /// <summary>Reads a float from the packet.</summary>
290
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
291
+        public float ReadFloat(bool _moveReadPos = true)
292
+        {
293
+            if (buffer.Count > readPos)
294
+            {
295
+                // If there are unread bytes
296
+                float _value = BitConverter.ToSingle(readableBuffer, readPos); // Convert the bytes to a float
297
+                if (_moveReadPos)
298
+                {
299
+                    // If _moveReadPos is true
300
+                    readPos += 4; // Increase readPos by 4
301
+                }
302
+                return _value; // Return the float
303
+            }
304
+            else
305
+            {
306
+                throw new Exception("Could not read value of type 'float'!");
307
+            }
308
+        }
309
+
310
+        /// <summary>Reads a bool from the packet.</summary>
311
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
312
+        public bool ReadBool(bool _moveReadPos = true)
313
+        {
314
+            if (buffer.Count > readPos)
315
+            {
316
+                // If there are unread bytes
317
+                bool _value = BitConverter.ToBoolean(readableBuffer, readPos); // Convert the bytes to a bool
318
+                if (_moveReadPos)
319
+                {
320
+                    // If _moveReadPos is true
321
+                    readPos += 1; // Increase readPos by 1
322
+                }
323
+                return _value; // Return the bool
324
+            }
325
+            else
326
+            {
327
+                throw new Exception("Could not read value of type 'bool'!");
328
+            }
329
+        }
330
+
331
+        /// <summary>Reads a string from the packet.</summary>
332
+        /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
333
+        public string ReadString(bool _moveReadPos = true)
334
+        {
335
+            try
336
+            {
337
+                int _length = ReadInt(); // Get the length of the string
338
+                string _value = Encoding.ASCII.GetString(readableBuffer, readPos, _length); // Convert the bytes to a string
339
+                if (_moveReadPos && _value.Length > 0)
340
+                {
341
+                    // If _moveReadPos is true string is not empty
342
+                    readPos += _length; // Increase readPos by the length of the string
343
+                }
344
+                return _value; // Return the string
345
+            }
346
+            catch
347
+            {
348
+                throw new Exception("Could not read value of type 'string'!");
349
+            }
350
+        }
351
+
352
+        public Vector3 ReadVector3(bool _moveReadPos = true)
353
+        {
354
+            return new Vector3(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
355
+        }
356
+
357
+        public Quaternion ReadQuaternion(bool _moveReadPos = true)
358
+        {
359
+            return new Quaternion(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
360
+        }
361
+        #endregion
362
+
363
+        private bool disposed = false;
364
+
365
+        protected virtual void Dispose(bool _disposing)
366
+        {
367
+            if (!disposed)
368
+            {
369
+                if (_disposing)
370
+                {
371
+                    buffer = null;
372
+                    readableBuffer = null;
373
+                    readPos = 0;
374
+                }
375
+
376
+                disposed = true;
377
+            }
378
+        }
379
+
380
+        public void Dispose()
381
+        {
382
+            Dispose(true);
383
+            GC.SuppressFinalize(this);
384
+        }
385
+    }
386
+}

+ 71
- 0
Server Standalone/GameServer/GameServer/Player.cs Vedi File

@@ -0,0 +1,71 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Dynamic;
4
+using System.Numerics;
5
+using System.Text;
6
+
7
+namespace GameServer
8
+{
9
+    class Player
10
+    {
11
+        public int id;
12
+        public string username;
13
+
14
+        public Vector3 position;
15
+        public Quaternion rotation;
16
+
17
+        private float moveSpeed = 5f / Constants.TICKS_PER_SEC;
18
+        private bool[] inputs;
19
+
20
+        public Player(int _id, string _username, Vector3 _pos)
21
+        {
22
+            id = _id;
23
+            username = _username;
24
+            position = _pos;
25
+            rotation = Quaternion.Identity;
26
+
27
+            inputs = new bool[4];
28
+        }
29
+
30
+        public void Update()
31
+        {
32
+            Vector2 _inputDirection = Vector2.Zero;
33
+            if (inputs[0])
34
+            {
35
+                _inputDirection.Y += 1;
36
+            }
37
+            if (inputs[1])
38
+            {
39
+                _inputDirection.Y -= 1;
40
+            }
41
+            if (inputs[2])
42
+            {
43
+                _inputDirection.X += 1;
44
+            }
45
+            if (inputs[3])
46
+            {
47
+                _inputDirection.X -= 1;
48
+            }
49
+
50
+            Move(_inputDirection);
51
+        }
52
+
53
+        private void Move(Vector2 _inputDirection)
54
+        {
55
+            Vector3 _forward = Vector3.Transform(new Vector3(0, 0, 1), rotation);
56
+            Vector3 _right = Vector3.Normalize(Vector3.Cross(_forward, new Vector3(0, 1, 0)));
57
+
58
+            Vector3 _moveDirection = _right * _inputDirection.X + _forward * _inputDirection.Y;
59
+            position += _moveDirection * moveSpeed;
60
+
61
+            ServerSend.PlayerPosition(this);
62
+            ServerSend.PlayerRotation(this);
63
+        }
64
+
65
+        public void SetInput(bool[] _inputs, Quaternion _rotation)
66
+        {
67
+            inputs = _inputs;
68
+            rotation = _rotation;
69
+        }
70
+    }
71
+}

+ 42
- 0
Server Standalone/GameServer/GameServer/Program.cs Vedi File

@@ -0,0 +1,42 @@
1
+using System;
2
+using System.Threading;
3
+
4
+namespace GameServer
5
+{
6
+    class Program
7
+    {
8
+        private static bool isRunning = false;
9
+
10
+        static void Main(string[] args)
11
+        {
12
+            Console.Title = "Game Server";
13
+            isRunning = true;
14
+
15
+            Thread mainThread = new Thread(new ThreadStart(MainThread));
16
+            mainThread.Start();
17
+
18
+            Server.Start(8, 26950);
19
+        }
20
+
21
+        private static void MainThread()
22
+        {
23
+            Console.WriteLine($"Main thread started. Running at {Constants.TICKS_PER_SEC} ticks per second.");
24
+            DateTime _nextLoop = DateTime.Now;
25
+
26
+            while (isRunning)
27
+            {
28
+                while (_nextLoop < DateTime.Now)
29
+                {
30
+                    GameLogic.Update();
31
+
32
+                    _nextLoop = _nextLoop.AddMilliseconds(Constants.MS_PER_TICKS);
33
+
34
+                    if (_nextLoop > DateTime.Now)
35
+                    {
36
+                        Thread.Sleep(_nextLoop - DateTime.Now);
37
+                    }
38
+                }
39
+            }
40
+        }
41
+    }
42
+}

+ 126
- 0
Server Standalone/GameServer/GameServer/Server.cs Vedi File

@@ -0,0 +1,126 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+using System.Net;
5
+using System.Net.Sockets;
6
+
7
+namespace GameServer
8
+{
9
+    class Server
10
+    {
11
+        public static int MaxPlayers { get; private set; }
12
+        public static int Port { get; private set; }
13
+        public static Dictionary<int, Client> clients = new Dictionary<int, Client>();
14
+        public delegate void PacketHandler(int _fromClient, Packet _packet);
15
+        public static Dictionary<int, PacketHandler> packetHandlers;
16
+        
17
+        public static TcpListener tcpListener;
18
+        public static UdpClient udpListener;
19
+
20
+        public static void Start(int _maxPlayers, int _port)
21
+        {
22
+            MaxPlayers = _maxPlayers;
23
+            Port = _port;
24
+
25
+            Console.WriteLine("Starting Server...");
26
+            InitializeServerData();
27
+
28
+            tcpListener = new TcpListener(IPAddress.Any, Port);
29
+            tcpListener.Start();
30
+            tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
31
+
32
+            udpListener = new UdpClient(Port);
33
+            udpListener.BeginReceive(UDPReceiveCallback, null);
34
+
35
+            Console.WriteLine($"Server started on port : {Port}.");
36
+        }
37
+
38
+        private static void TCPConnectCallback(IAsyncResult _result)
39
+        {
40
+            TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
41
+            tcpListener.BeginAcceptTcpClient(new AsyncCallback(TCPConnectCallback), null);
42
+            Console.WriteLine($"Incoming connection from {_client.Client.RemoteEndPoint}...");
43
+
44
+            for (int i = 1; i <= MaxPlayers; i++)
45
+            {
46
+                if (clients[i].tcp.socket == null)
47
+                {
48
+                    clients[i].tcp.Connect(_client);
49
+                    return;
50
+                }
51
+            }
52
+
53
+            Console.WriteLine($"{_client.Client.RemoteEndPoint} failed to connect. server full !");
54
+        }
55
+
56
+        private static void UDPReceiveCallback(IAsyncResult _result)
57
+        {
58
+            try
59
+            {
60
+                IPEndPoint _clientEndPoint = new IPEndPoint(IPAddress.Any, 0);
61
+                byte[] _data = udpListener.EndReceive(_result, ref _clientEndPoint);
62
+                udpListener.BeginReceive(UDPReceiveCallback, null);
63
+
64
+                if (_data.Length < 4)
65
+                {
66
+                    return;
67
+                }
68
+
69
+                using (Packet _packet = new Packet(_data))
70
+                {
71
+                    int _clientId = _packet.ReadInt();
72
+
73
+                    if (_clientId == 0)
74
+                    {
75
+                        return;
76
+                    }
77
+
78
+                    if (clients[_clientId].udp.endPoint == null)
79
+                    {
80
+                        clients[_clientId].udp.Connect(_clientEndPoint);
81
+                        return;
82
+                    }
83
+
84
+                    if (clients[_clientId].udp.endPoint.ToString() == _clientEndPoint.ToString())
85
+                    {
86
+                        clients[_clientId].udp.HandleData(_packet);
87
+                    }
88
+                }
89
+            }
90
+            catch (Exception _ex)
91
+            {
92
+                Console.WriteLine($"Error receiving UDP data: {_ex}");
93
+            }
94
+        }
95
+
96
+        public static void SendUDPData(IPEndPoint _clientEndPoint, Packet _packet)
97
+        {
98
+            try
99
+            {
100
+                if (_clientEndPoint != null)
101
+                {
102
+                    udpListener.BeginSend(_packet.ToArray(), _packet.Length(), _clientEndPoint, null, null);
103
+                }
104
+            }
105
+            catch (Exception _ex)
106
+            {
107
+                Console.WriteLine($"Error sending data to {_clientEndPoint} via UDP: {_ex}");
108
+            }
109
+        }
110
+
111
+        private static void InitializeServerData()
112
+        {
113
+            for (int i = 1; i <= MaxPlayers; i++)
114
+            {
115
+                clients.Add(i, new Client(i));
116
+            }
117
+
118
+            packetHandlers = new Dictionary<int, PacketHandler>()
119
+            {
120
+                { (int)ClientPackets.welcomeReceived, ServerHandle.WelcomeReceived },
121
+                { (int)ClientPackets.playerMovement, ServerHandle.PlayerMovement }
122
+            };
123
+            Console.WriteLine("Initialized packets.");
124
+        }
125
+    }
126
+}

+ 35
- 0
Server Standalone/GameServer/GameServer/ServerHandle.cs Vedi File

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Numerics;
4
+using System.Text;
5
+
6
+namespace GameServer
7
+{
8
+    class ServerHandle
9
+    {
10
+        public static void WelcomeReceived(int _fromClient, Packet _packet)
11
+        {
12
+            int _clientIdCheck = _packet.ReadInt();
13
+            string _username = _packet.ReadString();
14
+
15
+            Console.WriteLine($"{Server.clients[_fromClient].tcp.socket.Client.RemoteEndPoint} connected successfully and is now player {_fromClient}.");
16
+            if (_clientIdCheck != _fromClient)
17
+            {
18
+                Console.WriteLine($"Player \"{_username}\" (ID: {_fromClient}) has assumed the wrong client ID ({_clientIdCheck})!");
19
+            }
20
+            Server.clients[_fromClient].SendIntoGame(_username);
21
+        }
22
+
23
+        public static void PlayerMovement(int _fromClient, Packet _packet)
24
+        {
25
+            bool[] _inputs = new bool[_packet.ReadInt()];
26
+            for (int i = 0; i < _inputs.Length; i++)
27
+            {
28
+                _inputs[i] = _packet.ReadBool();
29
+            }
30
+            Quaternion _rotation = _packet.ReadQuaternion();
31
+
32
+            Server.clients[_fromClient].player.SetInput(_inputs, _rotation); 
33
+        }
34
+    }
35
+}

+ 110
- 0
Server Standalone/GameServer/GameServer/ServerSend.cs Vedi File

@@ -0,0 +1,110 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Text;
4
+
5
+namespace GameServer
6
+{
7
+    class ServerSend
8
+    {
9
+        private static void SendTCPData(int _toClient, Packet _packet)
10
+        {
11
+            _packet.WriteLength();
12
+            Server.clients[_toClient].tcp.SendData(_packet);
13
+        }
14
+
15
+        private static void SendUDPData(int _toClient, Packet _packet)
16
+        {
17
+            _packet.WriteLength();
18
+            Server.clients[_toClient].udp.SendData(_packet);
19
+        }
20
+
21
+        private static void SendTCPDataToAll(Packet _packet)
22
+        {
23
+            _packet.WriteLength();
24
+            for (int i = 1; i <= Server.MaxPlayers; i++)
25
+            {
26
+                Server.clients[i].tcp.SendData(_packet);
27
+            }
28
+        }
29
+
30
+        private static void SendTCPDataToAll(int _exceptClient, Packet _packet)
31
+        {
32
+            _packet.WriteLength();
33
+            for (int i = 1; i <= Server.MaxPlayers; i++)
34
+            {
35
+                if (i != _exceptClient)
36
+                {
37
+                    Server.clients[i].tcp.SendData(_packet);
38
+                }
39
+            }
40
+        }
41
+
42
+        private static void SendUDPDataToAll(Packet _packet)
43
+        {
44
+            _packet.WriteLength();
45
+            for (int i = 1; i <= Server.MaxPlayers; i++)
46
+            {
47
+                Server.clients[i].udp.SendData(_packet);
48
+            }
49
+        }
50
+
51
+        private static void SendUDPDataToAll(int _exceptClient, Packet _packet)
52
+        {
53
+            _packet.WriteLength();
54
+            for (int i = 1; i <= Server.MaxPlayers; i++)
55
+            {
56
+                if (i != _exceptClient)
57
+                {
58
+                    Server.clients[i].udp.SendData(_packet);
59
+                }
60
+            }
61
+        }
62
+
63
+        #region packets
64
+        public static void Welcome(int _toClient, string _msg)
65
+        {
66
+            using Packet _packet = new Packet((int)ServerPackets.welcome);
67
+
68
+            _packet.Write(_msg);
69
+            _packet.Write(_toClient);
70
+
71
+            SendTCPData(_toClient, _packet);
72
+        }
73
+        
74
+        public static void SpawnPlayer(int _toClient, Player _player)
75
+        {
76
+            using (Packet _packet = new Packet((int)ServerPackets.spawnPlayer))
77
+            {
78
+                _packet.Write(_player.id);
79
+                _packet.Write(_player.username);
80
+                _packet.Write(_player.position);
81
+                _packet.Write(_player.rotation);
82
+
83
+                SendTCPData(_toClient, _packet);
84
+            }
85
+        }
86
+
87
+        public static void PlayerPosition(Player _player)
88
+        {
89
+            using (Packet _packet = new Packet((int)ServerPackets.playerPosition))
90
+            {
91
+                _packet.Write(_player.id);
92
+                _packet.Write(_player.position);
93
+
94
+                SendUDPDataToAll(_packet);
95
+            }
96
+        }
97
+
98
+        public static void PlayerRotation(Player _player)
99
+        {
100
+            using (Packet _packet = new Packet((int)ServerPackets.playerRotation))
101
+            {
102
+                _packet.Write(_player.id);
103
+                _packet.Write(_player.rotation);
104
+
105
+                SendUDPDataToAll(_player.id, _packet);
106
+            }
107
+        }
108
+        #endregion
109
+    }
110
+}

+ 47
- 0
Server Standalone/GameServer/GameServer/ThreadManager.cs Vedi File

@@ -0,0 +1,47 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+public class ThreadManager
5
+{
6
+    private static readonly List<Action> executeOnMainThread = new List<Action>();
7
+    private static readonly List<Action> executeCopiedOnMainThread = new List<Action>();
8
+    private static bool actionToExecuteOnMainThread = false;
9
+
10
+
11
+    /// <summary>Sets an action to be executed on the main thread.</summary>
12
+    /// <param name="_action">The action to be executed on the main thread.</param>
13
+    public static void ExecuteOnMainThread(Action _action)
14
+    {
15
+        if (_action == null)
16
+        {
17
+            Console.WriteLine("No action to execute on main thread!");
18
+            return;
19
+        }
20
+
21
+        lock (executeOnMainThread)
22
+        {
23
+            executeOnMainThread.Add(_action);
24
+            actionToExecuteOnMainThread = true;
25
+        }
26
+    }
27
+
28
+    /// <summary>Executes all code meant to run on the main thread. NOTE: Call this ONLY from the main thread.</summary>
29
+    public static void UpdateMain()
30
+    {
31
+        if (actionToExecuteOnMainThread)
32
+        {
33
+            executeCopiedOnMainThread.Clear();
34
+            lock (executeOnMainThread)
35
+            {
36
+                executeCopiedOnMainThread.AddRange(executeOnMainThread);
37
+                executeOnMainThread.Clear();
38
+                actionToExecuteOnMainThread = false;
39
+            }
40
+
41
+            for (int i = 0; i < executeCopiedOnMainThread.Count; i++)
42
+            {
43
+                executeCopiedOnMainThread[i]();
44
+            }
45
+        }
46
+    }
47
+}

+ 34
- 0
Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.deps.json Vedi File

@@ -0,0 +1,34 @@
1
+{
2
+  "runtimeTarget": {
3
+    "name": ".NETCoreApp,Version=v3.1",
4
+    "signature": ""
5
+  },
6
+  "compilationOptions": {},
7
+  "targets": {
8
+    ".NETCoreApp,Version=v3.1": {
9
+      "GameServer/1.0.0": {
10
+        "dependencies": {
11
+          "System.Numerics.Vectors": "4.5.0"
12
+        },
13
+        "runtime": {
14
+          "GameServer.dll": {}
15
+        }
16
+      },
17
+      "System.Numerics.Vectors/4.5.0": {}
18
+    }
19
+  },
20
+  "libraries": {
21
+    "GameServer/1.0.0": {
22
+      "type": "project",
23
+      "serviceable": false,
24
+      "sha512": ""
25
+    },
26
+    "System.Numerics.Vectors/4.5.0": {
27
+      "type": "package",
28
+      "serviceable": true,
29
+      "sha512": "sha512-QQTlPTl06J/iiDbJCiepZ4H//BVraReU4O4EoRw1U02H5TLUIT7xn3GnDp9AXPSlJUDyFs4uWjWafNX6WrAojQ==",
30
+      "path": "system.numerics.vectors/4.5.0",
31
+      "hashPath": "system.numerics.vectors.4.5.0.nupkg.sha512"
32
+    }
33
+  }
34
+}

BIN
Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.dll Vedi File


BIN
Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.exe Vedi File


+ 8
- 0
Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.runtimeconfig.dev.json Vedi File

@@ -0,0 +1,8 @@
1
+{
2
+  "runtimeOptions": {
3
+    "additionalProbingPaths": [
4
+      "C:\\Users\\Figg\\.dotnet\\store\\|arch|\\|tfm|",
5
+      "C:\\Users\\Figg\\.nuget\\packages"
6
+    ]
7
+  }
8
+}

+ 9
- 0
Server Standalone/GameServer/GameServer/bin/Debug/netcoreapp3.1/GameServer.runtimeconfig.json Vedi File

@@ -0,0 +1,9 @@
1
+{
2
+  "runtimeOptions": {
3
+    "tfm": "netcoreapp3.1",
4
+    "framework": {
5
+      "name": "Microsoft.NETCore.App",
6
+      "version": "3.1.0"
7
+    }
8
+  }
9
+}

+ 8
- 0
Server/Assets/Prefabs.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: a221ef2b4efe22b478768f90b4782c0a
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 186
- 0
Server/Assets/Prefabs/Player.prefab Vedi File

@@ -0,0 +1,186 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!1 &186954010188405824
4
+GameObject:
5
+  m_ObjectHideFlags: 0
6
+  m_CorrespondingSourceObject: {fileID: 0}
7
+  m_PrefabInstance: {fileID: 0}
8
+  m_PrefabAsset: {fileID: 0}
9
+  serializedVersion: 6
10
+  m_Component:
11
+  - component: {fileID: 5425218917365801267}
12
+  - component: {fileID: 4397547428674543274}
13
+  - component: {fileID: 5809629626955138879}
14
+  m_Layer: 0
15
+  m_Name: Player
16
+  m_TagString: Player
17
+  m_Icon: {fileID: 0}
18
+  m_NavMeshLayer: 0
19
+  m_StaticEditorFlags: 0
20
+  m_IsActive: 1
21
+--- !u!4 &5425218917365801267
22
+Transform:
23
+  m_ObjectHideFlags: 0
24
+  m_CorrespondingSourceObject: {fileID: 0}
25
+  m_PrefabInstance: {fileID: 0}
26
+  m_PrefabAsset: {fileID: 0}
27
+  m_GameObject: {fileID: 186954010188405824}
28
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29
+  m_LocalPosition: {x: 0, y: 0, z: 0}
30
+  m_LocalScale: {x: 1, y: 1, z: 1}
31
+  m_Children:
32
+  - {fileID: 3409202299637031209}
33
+  - {fileID: 2088743231698579764}
34
+  m_Father: {fileID: 0}
35
+  m_RootOrder: 0
36
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
37
+--- !u!114 &4397547428674543274
38
+MonoBehaviour:
39
+  m_ObjectHideFlags: 0
40
+  m_CorrespondingSourceObject: {fileID: 0}
41
+  m_PrefabInstance: {fileID: 0}
42
+  m_PrefabAsset: {fileID: 0}
43
+  m_GameObject: {fileID: 186954010188405824}
44
+  m_Enabled: 1
45
+  m_EditorHideFlags: 0
46
+  m_Script: {fileID: 11500000, guid: fef6c5c8db7a0f34f9cd6abcb254124f, type: 3}
47
+  m_Name: 
48
+  m_EditorClassIdentifier: 
49
+  id: 0
50
+  username: 
51
+  controller: {fileID: 5809629626955138879}
52
+  shootOrigin: {fileID: 2088743231698579764}
53
+  gravity: -9.81
54
+  moveSpeed: 5
55
+  jumpSpeed: 5
56
+  health: 0
57
+  maxHealth: 100
58
+--- !u!143 &5809629626955138879
59
+CharacterController:
60
+  m_ObjectHideFlags: 0
61
+  m_CorrespondingSourceObject: {fileID: 0}
62
+  m_PrefabInstance: {fileID: 0}
63
+  m_PrefabAsset: {fileID: 0}
64
+  m_GameObject: {fileID: 186954010188405824}
65
+  m_Material: {fileID: 0}
66
+  m_IsTrigger: 0
67
+  m_Enabled: 1
68
+  serializedVersion: 2
69
+  m_Height: 2
70
+  m_Radius: 0.5
71
+  m_SlopeLimit: 45
72
+  m_StepOffset: 0.3
73
+  m_SkinWidth: 0.08
74
+  m_MinMoveDistance: 0.001
75
+  m_Center: {x: 0, y: 0, z: 0}
76
+--- !u!1 &671975962558417643
77
+GameObject:
78
+  m_ObjectHideFlags: 0
79
+  m_CorrespondingSourceObject: {fileID: 0}
80
+  m_PrefabInstance: {fileID: 0}
81
+  m_PrefabAsset: {fileID: 0}
82
+  serializedVersion: 6
83
+  m_Component:
84
+  - component: {fileID: 2088743231698579764}
85
+  m_Layer: 0
86
+  m_Name: ShootOrigin
87
+  m_TagString: Untagged
88
+  m_Icon: {fileID: 0}
89
+  m_NavMeshLayer: 0
90
+  m_StaticEditorFlags: 0
91
+  m_IsActive: 1
92
+--- !u!4 &2088743231698579764
93
+Transform:
94
+  m_ObjectHideFlags: 0
95
+  m_CorrespondingSourceObject: {fileID: 0}
96
+  m_PrefabInstance: {fileID: 0}
97
+  m_PrefabAsset: {fileID: 0}
98
+  m_GameObject: {fileID: 671975962558417643}
99
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
100
+  m_LocalPosition: {x: 0, y: 0.5, z: 0}
101
+  m_LocalScale: {x: 1, y: 1, z: 1}
102
+  m_Children: []
103
+  m_Father: {fileID: 5425218917365801267}
104
+  m_RootOrder: 1
105
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
106
+--- !u!1 &2919497842785777827
107
+GameObject:
108
+  m_ObjectHideFlags: 0
109
+  m_CorrespondingSourceObject: {fileID: 0}
110
+  m_PrefabInstance: {fileID: 0}
111
+  m_PrefabAsset: {fileID: 0}
112
+  serializedVersion: 6
113
+  m_Component:
114
+  - component: {fileID: 3409202299637031209}
115
+  - component: {fileID: 5538381881179158306}
116
+  - component: {fileID: 7088708182739535300}
117
+  m_Layer: 0
118
+  m_Name: Model
119
+  m_TagString: Untagged
120
+  m_Icon: {fileID: 0}
121
+  m_NavMeshLayer: 0
122
+  m_StaticEditorFlags: 0
123
+  m_IsActive: 1
124
+--- !u!4 &3409202299637031209
125
+Transform:
126
+  m_ObjectHideFlags: 0
127
+  m_CorrespondingSourceObject: {fileID: 0}
128
+  m_PrefabInstance: {fileID: 0}
129
+  m_PrefabAsset: {fileID: 0}
130
+  m_GameObject: {fileID: 2919497842785777827}
131
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
132
+  m_LocalPosition: {x: 0, y: 0, z: 0}
133
+  m_LocalScale: {x: 1, y: 1, z: 1}
134
+  m_Children: []
135
+  m_Father: {fileID: 5425218917365801267}
136
+  m_RootOrder: 0
137
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
138
+--- !u!33 &5538381881179158306
139
+MeshFilter:
140
+  m_ObjectHideFlags: 0
141
+  m_CorrespondingSourceObject: {fileID: 0}
142
+  m_PrefabInstance: {fileID: 0}
143
+  m_PrefabAsset: {fileID: 0}
144
+  m_GameObject: {fileID: 2919497842785777827}
145
+  m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
146
+--- !u!23 &7088708182739535300
147
+MeshRenderer:
148
+  m_ObjectHideFlags: 0
149
+  m_CorrespondingSourceObject: {fileID: 0}
150
+  m_PrefabInstance: {fileID: 0}
151
+  m_PrefabAsset: {fileID: 0}
152
+  m_GameObject: {fileID: 2919497842785777827}
153
+  m_Enabled: 1
154
+  m_CastShadows: 1
155
+  m_ReceiveShadows: 1
156
+  m_DynamicOccludee: 1
157
+  m_MotionVectors: 1
158
+  m_LightProbeUsage: 1
159
+  m_ReflectionProbeUsage: 1
160
+  m_RayTracingMode: 2
161
+  m_RayTraceProcedural: 0
162
+  m_RenderingLayerMask: 1
163
+  m_RendererPriority: 0
164
+  m_Materials:
165
+  - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
166
+  m_StaticBatchInfo:
167
+    firstSubMesh: 0
168
+    subMeshCount: 0
169
+  m_StaticBatchRoot: {fileID: 0}
170
+  m_ProbeAnchor: {fileID: 0}
171
+  m_LightProbeVolumeOverride: {fileID: 0}
172
+  m_ScaleInLightmap: 1
173
+  m_ReceiveGI: 1
174
+  m_PreserveUVs: 0
175
+  m_IgnoreNormalsForChartDetection: 0
176
+  m_ImportantGI: 0
177
+  m_StitchLightmapSeams: 1
178
+  m_SelectedEditorRenderState: 3
179
+  m_MinimumChartSize: 4
180
+  m_AutoUVMaxDistance: 0.5
181
+  m_AutoUVMaxAngle: 89
182
+  m_LightmapParameters: {fileID: 0}
183
+  m_SortingLayerID: 0
184
+  m_SortingLayer: 0
185
+  m_SortingOrder: 0
186
+  m_AdditionalVertexStreams: {fileID: 0}

+ 7
- 0
Server/Assets/Prefabs/Player.prefab.meta Vedi File

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: ebfcd44656309fd4f8912d3de248011a
3
+PrefabImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: 

+ 8
- 0
Server/Assets/Scenes.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: facd3790e3ef3a448b50f9f5b27f0af1
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 411
- 0
Server/Assets/Scenes/Game.unity Vedi File

@@ -0,0 +1,411 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!29 &1
4
+OcclusionCullingSettings:
5
+  m_ObjectHideFlags: 0
6
+  serializedVersion: 2
7
+  m_OcclusionBakeSettings:
8
+    smallestOccluder: 5
9
+    smallestHole: 0.25
10
+    backfaceThreshold: 100
11
+  m_SceneGUID: 00000000000000000000000000000000
12
+  m_OcclusionCullingData: {fileID: 0}
13
+--- !u!104 &2
14
+RenderSettings:
15
+  m_ObjectHideFlags: 0
16
+  serializedVersion: 9
17
+  m_Fog: 0
18
+  m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19
+  m_FogMode: 3
20
+  m_FogDensity: 0.01
21
+  m_LinearFogStart: 0
22
+  m_LinearFogEnd: 300
23
+  m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24
+  m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25
+  m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26
+  m_AmbientIntensity: 1
27
+  m_AmbientMode: 0
28
+  m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29
+  m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30
+  m_HaloStrength: 0.5
31
+  m_FlareStrength: 1
32
+  m_FlareFadeSpeed: 3
33
+  m_HaloTexture: {fileID: 0}
34
+  m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35
+  m_DefaultReflectionMode: 0
36
+  m_DefaultReflectionResolution: 128
37
+  m_ReflectionBounces: 1
38
+  m_ReflectionIntensity: 1
39
+  m_CustomReflection: {fileID: 0}
40
+  m_Sun: {fileID: 705507994}
41
+  m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
42
+  m_UseRadianceAmbientProbe: 0
43
+--- !u!157 &3
44
+LightmapSettings:
45
+  m_ObjectHideFlags: 0
46
+  serializedVersion: 12
47
+  m_GIWorkflowMode: 1
48
+  m_GISettings:
49
+    serializedVersion: 2
50
+    m_BounceScale: 1
51
+    m_IndirectOutputScale: 1
52
+    m_AlbedoBoost: 1
53
+    m_EnvironmentLightingMode: 0
54
+    m_EnableBakedLightmaps: 1
55
+    m_EnableRealtimeLightmaps: 0
56
+  m_LightmapEditorSettings:
57
+    serializedVersion: 12
58
+    m_Resolution: 2
59
+    m_BakeResolution: 40
60
+    m_AtlasSize: 1024
61
+    m_AO: 0
62
+    m_AOMaxDistance: 1
63
+    m_CompAOExponent: 1
64
+    m_CompAOExponentDirect: 0
65
+    m_ExtractAmbientOcclusion: 0
66
+    m_Padding: 2
67
+    m_LightmapParameters: {fileID: 0}
68
+    m_LightmapsBakeMode: 1
69
+    m_TextureCompression: 1
70
+    m_FinalGather: 0
71
+    m_FinalGatherFiltering: 1
72
+    m_FinalGatherRayCount: 256
73
+    m_ReflectionCompression: 2
74
+    m_MixedBakeMode: 2
75
+    m_BakeBackend: 1
76
+    m_PVRSampling: 1
77
+    m_PVRDirectSampleCount: 32
78
+    m_PVRSampleCount: 500
79
+    m_PVRBounces: 2
80
+    m_PVREnvironmentSampleCount: 500
81
+    m_PVREnvironmentReferencePointCount: 2048
82
+    m_PVRFilteringMode: 2
83
+    m_PVRDenoiserTypeDirect: 0
84
+    m_PVRDenoiserTypeIndirect: 0
85
+    m_PVRDenoiserTypeAO: 0
86
+    m_PVRFilterTypeDirect: 0
87
+    m_PVRFilterTypeIndirect: 0
88
+    m_PVRFilterTypeAO: 0
89
+    m_PVREnvironmentMIS: 0
90
+    m_PVRCulling: 1
91
+    m_PVRFilteringGaussRadiusDirect: 1
92
+    m_PVRFilteringGaussRadiusIndirect: 5
93
+    m_PVRFilteringGaussRadiusAO: 2
94
+    m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95
+    m_PVRFilteringAtrousPositionSigmaIndirect: 2
96
+    m_PVRFilteringAtrousPositionSigmaAO: 1
97
+    m_ExportTrainingData: 0
98
+    m_TrainingDataDestination: TrainingData
99
+    m_LightProbeSampleCountMultiplier: 4
100
+  m_LightingDataAsset: {fileID: 0}
101
+  m_LightingSettings: {fileID: 4890085278179872738, guid: e9c62cb55cac1f245bcf3a779d9e9dc6, type: 2}
102
+--- !u!196 &4
103
+NavMeshSettings:
104
+  serializedVersion: 2
105
+  m_ObjectHideFlags: 0
106
+  m_BuildSettings:
107
+    serializedVersion: 2
108
+    agentTypeID: 0
109
+    agentRadius: 0.5
110
+    agentHeight: 2
111
+    agentSlope: 45
112
+    agentClimb: 0.4
113
+    ledgeDropHeight: 0
114
+    maxJumpAcrossDistance: 0
115
+    minRegionArea: 2
116
+    manualCellSize: 0
117
+    cellSize: 0.16666667
118
+    manualTileSize: 0
119
+    tileSize: 256
120
+    accuratePlacement: 0
121
+    maxJobWorkers: 0
122
+    preserveTilesOutsideBounds: 0
123
+    debug:
124
+      m_Flags: 0
125
+  m_NavMeshData: {fileID: 0}
126
+--- !u!1 &660589823
127
+GameObject:
128
+  m_ObjectHideFlags: 0
129
+  m_CorrespondingSourceObject: {fileID: 0}
130
+  m_PrefabInstance: {fileID: 0}
131
+  m_PrefabAsset: {fileID: 0}
132
+  serializedVersion: 6
133
+  m_Component:
134
+  - component: {fileID: 660589826}
135
+  - component: {fileID: 660589825}
136
+  - component: {fileID: 660589824}
137
+  m_Layer: 0
138
+  m_Name: NetworkManager
139
+  m_TagString: Untagged
140
+  m_Icon: {fileID: 0}
141
+  m_NavMeshLayer: 0
142
+  m_StaticEditorFlags: 0
143
+  m_IsActive: 1
144
+--- !u!114 &660589824
145
+MonoBehaviour:
146
+  m_ObjectHideFlags: 0
147
+  m_CorrespondingSourceObject: {fileID: 0}
148
+  m_PrefabInstance: {fileID: 0}
149
+  m_PrefabAsset: {fileID: 0}
150
+  m_GameObject: {fileID: 660589823}
151
+  m_Enabled: 1
152
+  m_EditorHideFlags: 0
153
+  m_Script: {fileID: 11500000, guid: 9a3b7330cd08b6b4cbbfae595059d655, type: 3}
154
+  m_Name: 
155
+  m_EditorClassIdentifier: 
156
+--- !u!114 &660589825
157
+MonoBehaviour:
158
+  m_ObjectHideFlags: 0
159
+  m_CorrespondingSourceObject: {fileID: 0}
160
+  m_PrefabInstance: {fileID: 0}
161
+  m_PrefabAsset: {fileID: 0}
162
+  m_GameObject: {fileID: 660589823}
163
+  m_Enabled: 1
164
+  m_EditorHideFlags: 0
165
+  m_Script: {fileID: 11500000, guid: 5c82b540c9d84e3478d571870afd8252, type: 3}
166
+  m_Name: 
167
+  m_EditorClassIdentifier: 
168
+  playerPrefab: {fileID: 186954010188405824, guid: ebfcd44656309fd4f8912d3de248011a, type: 3}
169
+--- !u!4 &660589826
170
+Transform:
171
+  m_ObjectHideFlags: 0
172
+  m_CorrespondingSourceObject: {fileID: 0}
173
+  m_PrefabInstance: {fileID: 0}
174
+  m_PrefabAsset: {fileID: 0}
175
+  m_GameObject: {fileID: 660589823}
176
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
177
+  m_LocalPosition: {x: 0, y: 0, z: 0}
178
+  m_LocalScale: {x: 1, y: 1, z: 1}
179
+  m_Children: []
180
+  m_Father: {fileID: 0}
181
+  m_RootOrder: 2
182
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
183
+--- !u!1 &705507993
184
+GameObject:
185
+  m_ObjectHideFlags: 0
186
+  m_CorrespondingSourceObject: {fileID: 0}
187
+  m_PrefabInstance: {fileID: 0}
188
+  m_PrefabAsset: {fileID: 0}
189
+  serializedVersion: 6
190
+  m_Component:
191
+  - component: {fileID: 705507995}
192
+  - component: {fileID: 705507994}
193
+  m_Layer: 0
194
+  m_Name: Directional Light
195
+  m_TagString: Untagged
196
+  m_Icon: {fileID: 0}
197
+  m_NavMeshLayer: 0
198
+  m_StaticEditorFlags: 0
199
+  m_IsActive: 1
200
+--- !u!108 &705507994
201
+Light:
202
+  m_ObjectHideFlags: 0
203
+  m_CorrespondingSourceObject: {fileID: 0}
204
+  m_PrefabInstance: {fileID: 0}
205
+  m_PrefabAsset: {fileID: 0}
206
+  m_GameObject: {fileID: 705507993}
207
+  m_Enabled: 1
208
+  serializedVersion: 10
209
+  m_Type: 1
210
+  m_Shape: 0
211
+  m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
212
+  m_Intensity: 1
213
+  m_Range: 10
214
+  m_SpotAngle: 30
215
+  m_InnerSpotAngle: 21.80208
216
+  m_CookieSize: 10
217
+  m_Shadows:
218
+    m_Type: 2
219
+    m_Resolution: -1
220
+    m_CustomResolution: -1
221
+    m_Strength: 1
222
+    m_Bias: 0.05
223
+    m_NormalBias: 0.4
224
+    m_NearPlane: 0.2
225
+    m_CullingMatrixOverride:
226
+      e00: 1
227
+      e01: 0
228
+      e02: 0
229
+      e03: 0
230
+      e10: 0
231
+      e11: 1
232
+      e12: 0
233
+      e13: 0
234
+      e20: 0
235
+      e21: 0
236
+      e22: 1
237
+      e23: 0
238
+      e30: 0
239
+      e31: 0
240
+      e32: 0
241
+      e33: 1
242
+    m_UseCullingMatrixOverride: 0
243
+  m_Cookie: {fileID: 0}
244
+  m_DrawHalo: 0
245
+  m_Flare: {fileID: 0}
246
+  m_RenderMode: 0
247
+  m_CullingMask:
248
+    serializedVersion: 2
249
+    m_Bits: 4294967295
250
+  m_RenderingLayerMask: 1
251
+  m_Lightmapping: 1
252
+  m_LightShadowCasterMode: 0
253
+  m_AreaSize: {x: 1, y: 1}
254
+  m_BounceIntensity: 1
255
+  m_ColorTemperature: 6570
256
+  m_UseColorTemperature: 0
257
+  m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
258
+  m_UseBoundingSphereOverride: 0
259
+  m_ShadowRadius: 0
260
+  m_ShadowAngle: 0
261
+--- !u!4 &705507995
262
+Transform:
263
+  m_ObjectHideFlags: 0
264
+  m_CorrespondingSourceObject: {fileID: 0}
265
+  m_PrefabInstance: {fileID: 0}
266
+  m_PrefabAsset: {fileID: 0}
267
+  m_GameObject: {fileID: 705507993}
268
+  m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
269
+  m_LocalPosition: {x: 0, y: 3, z: 0}
270
+  m_LocalScale: {x: 1, y: 1, z: 1}
271
+  m_Children: []
272
+  m_Father: {fileID: 0}
273
+  m_RootOrder: 1
274
+  m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
275
+--- !u!1 &864062481
276
+GameObject:
277
+  m_ObjectHideFlags: 0
278
+  m_CorrespondingSourceObject: {fileID: 0}
279
+  m_PrefabInstance: {fileID: 0}
280
+  m_PrefabAsset: {fileID: 0}
281
+  serializedVersion: 6
282
+  m_Component:
283
+  - component: {fileID: 864062484}
284
+  - component: {fileID: 864062483}
285
+  - component: {fileID: 864062482}
286
+  m_Layer: 0
287
+  m_Name: Ground
288
+  m_TagString: Untagged
289
+  m_Icon: {fileID: 0}
290
+  m_NavMeshLayer: 0
291
+  m_StaticEditorFlags: 0
292
+  m_IsActive: 1
293
+--- !u!64 &864062482
294
+MeshCollider:
295
+  m_ObjectHideFlags: 0
296
+  m_CorrespondingSourceObject: {fileID: 0}
297
+  m_PrefabInstance: {fileID: 0}
298
+  m_PrefabAsset: {fileID: 0}
299
+  m_GameObject: {fileID: 864062481}
300
+  m_Material: {fileID: 0}
301
+  m_IsTrigger: 0
302
+  m_Enabled: 1
303
+  serializedVersion: 4
304
+  m_Convex: 0
305
+  m_CookingOptions: 30
306
+  m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
307
+--- !u!33 &864062483
308
+MeshFilter:
309
+  m_ObjectHideFlags: 0
310
+  m_CorrespondingSourceObject: {fileID: 0}
311
+  m_PrefabInstance: {fileID: 0}
312
+  m_PrefabAsset: {fileID: 0}
313
+  m_GameObject: {fileID: 864062481}
314
+  m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
315
+--- !u!4 &864062484
316
+Transform:
317
+  m_ObjectHideFlags: 0
318
+  m_CorrespondingSourceObject: {fileID: 0}
319
+  m_PrefabInstance: {fileID: 0}
320
+  m_PrefabAsset: {fileID: 0}
321
+  m_GameObject: {fileID: 864062481}
322
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
323
+  m_LocalPosition: {x: 0, y: 0, z: 0}
324
+  m_LocalScale: {x: 10, y: 1, z: 10}
325
+  m_Children: []
326
+  m_Father: {fileID: 0}
327
+  m_RootOrder: 3
328
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
329
+--- !u!1 &963194225
330
+GameObject:
331
+  m_ObjectHideFlags: 0
332
+  m_CorrespondingSourceObject: {fileID: 0}
333
+  m_PrefabInstance: {fileID: 0}
334
+  m_PrefabAsset: {fileID: 0}
335
+  serializedVersion: 6
336
+  m_Component:
337
+  - component: {fileID: 963194228}
338
+  - component: {fileID: 963194227}
339
+  - component: {fileID: 963194226}
340
+  m_Layer: 0
341
+  m_Name: Main Camera
342
+  m_TagString: MainCamera
343
+  m_Icon: {fileID: 0}
344
+  m_NavMeshLayer: 0
345
+  m_StaticEditorFlags: 0
346
+  m_IsActive: 1
347
+--- !u!81 &963194226
348
+AudioListener:
349
+  m_ObjectHideFlags: 0
350
+  m_CorrespondingSourceObject: {fileID: 0}
351
+  m_PrefabInstance: {fileID: 0}
352
+  m_PrefabAsset: {fileID: 0}
353
+  m_GameObject: {fileID: 963194225}
354
+  m_Enabled: 1
355
+--- !u!20 &963194227
356
+Camera:
357
+  m_ObjectHideFlags: 0
358
+  m_CorrespondingSourceObject: {fileID: 0}
359
+  m_PrefabInstance: {fileID: 0}
360
+  m_PrefabAsset: {fileID: 0}
361
+  m_GameObject: {fileID: 963194225}
362
+  m_Enabled: 1
363
+  serializedVersion: 2
364
+  m_ClearFlags: 1
365
+  m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
366
+  m_projectionMatrixMode: 1
367
+  m_GateFitMode: 2
368
+  m_FOVAxisMode: 0
369
+  m_SensorSize: {x: 36, y: 24}
370
+  m_LensShift: {x: 0, y: 0}
371
+  m_FocalLength: 50
372
+  m_NormalizedViewPortRect:
373
+    serializedVersion: 2
374
+    x: 0
375
+    y: 0
376
+    width: 1
377
+    height: 1
378
+  near clip plane: 0.3
379
+  far clip plane: 1000
380
+  field of view: 60
381
+  orthographic: 0
382
+  orthographic size: 5
383
+  m_Depth: -1
384
+  m_CullingMask:
385
+    serializedVersion: 2
386
+    m_Bits: 4294967295
387
+  m_RenderingPath: -1
388
+  m_TargetTexture: {fileID: 0}
389
+  m_TargetDisplay: 0
390
+  m_TargetEye: 3
391
+  m_HDR: 1
392
+  m_AllowMSAA: 1
393
+  m_AllowDynamicResolution: 0
394
+  m_ForceIntoRT: 0
395
+  m_OcclusionCulling: 1
396
+  m_StereoConvergence: 10
397
+  m_StereoSeparation: 0.022
398
+--- !u!4 &963194228
399
+Transform:
400
+  m_ObjectHideFlags: 0
401
+  m_CorrespondingSourceObject: {fileID: 0}
402
+  m_PrefabInstance: {fileID: 0}
403
+  m_PrefabAsset: {fileID: 0}
404
+  m_GameObject: {fileID: 963194225}
405
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
406
+  m_LocalPosition: {x: 0, y: 1, z: -10}
407
+  m_LocalScale: {x: 1, y: 1, z: 1}
408
+  m_Children: []
409
+  m_Father: {fileID: 0}
410
+  m_RootOrder: 0
411
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

+ 7
- 0
Server/Assets/Scenes/Game.unity.meta Vedi File

@@ -0,0 +1,7 @@
1
+fileFormatVersion: 2
2
+guid: 9fc0d4010bbf28b4594072e72b8655ab
3
+DefaultImporter:
4
+  externalObjects: {}
5
+  userData: 
6
+  assetBundleName: 
7
+  assetBundleVariant: 

+ 63
- 0
Server/Assets/Scenes/SampleSceneSettings.lighting Vedi File

@@ -0,0 +1,63 @@
1
+%YAML 1.1
2
+%TAG !u! tag:unity3d.com,2011:
3
+--- !u!850595691 &4890085278179872738
4
+LightingSettings:
5
+  m_ObjectHideFlags: 0
6
+  m_CorrespondingSourceObject: {fileID: 0}
7
+  m_PrefabInstance: {fileID: 0}
8
+  m_PrefabAsset: {fileID: 0}
9
+  m_Name: SampleSceneSettings
10
+  serializedVersion: 2
11
+  m_GIWorkflowMode: 1
12
+  m_EnableBakedLightmaps: 1
13
+  m_EnableRealtimeLightmaps: 0
14
+  m_RealtimeEnvironmentLighting: 1
15
+  m_BounceScale: 1
16
+  m_AlbedoBoost: 1
17
+  m_IndirectOutputScale: 1
18
+  m_UsingShadowmask: 1
19
+  m_BakeBackend: 1
20
+  m_LightmapMaxSize: 1024
21
+  m_BakeResolution: 40
22
+  m_Padding: 2
23
+  m_TextureCompression: 1
24
+  m_AO: 0
25
+  m_AOMaxDistance: 1
26
+  m_CompAOExponent: 1
27
+  m_CompAOExponentDirect: 0
28
+  m_ExtractAO: 0
29
+  m_MixedBakeMode: 2
30
+  m_LightmapsBakeMode: 1
31
+  m_FilterMode: 1
32
+  m_LightmapParameters: {fileID: 0}
33
+  m_ExportTrainingData: 0
34
+  m_TrainingDataDestination: TrainingData
35
+  m_RealtimeResolution: 2
36
+  m_ForceWhiteAlbedo: 0
37
+  m_ForceUpdates: 0
38
+  m_FinalGather: 0
39
+  m_FinalGatherRayCount: 256
40
+  m_FinalGatherFiltering: 1
41
+  m_PVRCulling: 1
42
+  m_PVRSampling: 1
43
+  m_PVRDirectSampleCount: 32
44
+  m_PVRSampleCount: 500
45
+  m_PVREnvironmentSampleCount: 500
46
+  m_PVREnvironmentReferencePointCount: 2048
47
+  m_LightProbeSampleCountMultiplier: 4
48
+  m_PVRBounces: 2
49
+  m_PVRRussianRouletteStartBounce: 2
50
+  m_PVREnvironmentMIS: 0
51
+  m_PVRFilteringMode: 2
52
+  m_PVRDenoiserTypeDirect: 0
53
+  m_PVRDenoiserTypeIndirect: 0
54
+  m_PVRDenoiserTypeAO: 0
55
+  m_PVRFilterTypeDirect: 0
56
+  m_PVRFilterTypeIndirect: 0
57
+  m_PVRFilterTypeAO: 0
58
+  m_PVRFilteringGaussRadiusDirect: 1
59
+  m_PVRFilteringGaussRadiusIndirect: 5
60
+  m_PVRFilteringGaussRadiusAO: 2
61
+  m_PVRFilteringAtrousPositionSigmaDirect: 0.5
62
+  m_PVRFilteringAtrousPositionSigmaIndirect: 2
63
+  m_PVRFilteringAtrousPositionSigmaAO: 1

+ 8
- 0
Server/Assets/Scenes/SampleSceneSettings.lighting.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: e9c62cb55cac1f245bcf3a779d9e9dc6
3
+NativeFormatImporter:
4
+  externalObjects: {}
5
+  mainObjectFileID: 0
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 8
- 0
Server/Assets/Scripts.meta Vedi File

@@ -0,0 +1,8 @@
1
+fileFormatVersion: 2
2
+guid: 7b75315629e077c43bd5d2d6db1c54e6
3
+folderAsset: yes
4
+DefaultImporter:
5
+  externalObjects: {}
6
+  userData: 
7
+  assetBundleName: 
8
+  assetBundleVariant: 

+ 231
- 0
Server/Assets/Scripts/Client.cs Vedi File

@@ -0,0 +1,231 @@
1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.Net;
5
+using System.Net.Sockets;
6
+using UnityEngine;
7
+
8
+public class Client
9
+{
10
+    public static int dataBufferSize = 4096;
11
+
12
+    public int id;
13
+    public Player player;
14
+    public TCP tcp;
15
+    public UDP udp;
16
+
17
+    public Client(int _clientId)
18
+    {
19
+        id = _clientId;
20
+        tcp = new TCP(id);
21
+        udp = new UDP(id);
22
+    }
23
+
24
+    public class TCP
25
+    {
26
+        public TcpClient socket;
27
+
28
+        private readonly int id;
29
+        private NetworkStream stream;
30
+        private Packet receivedData;
31
+        private byte[] receiveBuffer;
32
+
33
+        public TCP(int _id)
34
+        {
35
+            id = _id;
36
+        }
37
+
38
+        public void Connect(TcpClient _socket)
39
+        {
40
+            socket = _socket;
41
+            socket.ReceiveBufferSize = dataBufferSize;
42
+            socket.SendBufferSize = dataBufferSize;
43
+
44
+            stream = socket.GetStream();
45
+
46
+            receivedData = new Packet();
47
+            receiveBuffer = new byte[dataBufferSize];
48
+
49
+            stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
50
+
51
+            ServerSend.Welcome(id, "Welcome to the server");
52
+        }
53
+
54
+        public void SendData(Packet _packet)
55
+        {
56
+            try
57
+            {
58
+                if (socket != null)
59
+                {
60
+                    stream.BeginWrite(_packet.ToArray(), 0, _packet.Length(), null, null);
61
+                }
62
+            }
63
+            catch (Exception _ex)
64
+            {
65
+                Debug.Log($"Error sending data to the player {id} via TCP: {_ex}");
66
+            }
67
+        }
68
+
69
+        private void ReceiveCallback(IAsyncResult _result)
70
+        {
71
+            try
72
+            {
73
+                int _byteLength = stream.EndRead(_result);
74
+                if (_byteLength <= 0)
75
+                {
76
+                    Server.clients[id].Disconnect();
77
+                    return;
78
+                }
79
+
80
+                byte[] _data = new byte[_byteLength];
81
+                Array.Copy(receiveBuffer, _data, _byteLength);
82
+
83
+                receivedData.Reset(HandleData(_data));
84
+                stream.BeginRead(receiveBuffer, 0, dataBufferSize, ReceiveCallback, null);
85
+            }
86
+            catch (Exception _ex)
87
+            {
88
+                Debug.Log($"Error receiving TCP data : {_ex}");
89
+                // TODO diconnect
90
+            }
91
+        }
92
+
93
+        private bool HandleData(byte[] _data)
94
+        {
95
+            int _packetLength = 0;
96
+
97
+            receivedData.SetBytes(_data);
98
+
99
+            if (receivedData.UnreadLength() >= 4)
100
+            {
101
+                _packetLength = receivedData.ReadInt();
102
+                if (_packetLength <= 0)
103
+                {
104
+                    return true;
105
+                }
106
+            }
107
+
108
+            while (_packetLength > 0 && _packetLength <= receivedData.UnreadLength())
109
+            {
110
+                byte[] _packetBytes = receivedData.ReadBytes(_packetLength);
111
+                ThreadManager.ExecuteOnMainThread(() =>
112
+                {
113
+                    using (Packet _packet = new Packet(_packetBytes))
114
+                    {
115
+                        int _packetId = _packet.ReadInt();
116
+                        Server.packetHandlers[_packetId](id, _packet);
117
+                    }
118
+                });
119
+
120
+                _packetLength = 0;
121
+                if (receivedData.UnreadLength() >= 4)
122
+                {
123
+                    _packetLength = receivedData.ReadInt();
124
+                    if (_packetLength <= 0)
125
+                    {
126
+                        return true;
127
+                    }
128
+                }
129
+            }
130
+
131
+            if (_packetLength <= 1)
132
+            {
133
+                return true;
134
+            }
135
+
136
+            return false;
137
+        }
138
+
139
+        public void Disconnect()
140
+        {
141
+            socket.Close();
142
+            stream = null;
143
+            receivedData = null;
144
+            receiveBuffer = null;
145
+            socket = null;
146
+        }
147
+    }
148
+
149
+    public class UDP
150
+    {
151
+        public IPEndPoint endPoint;
152
+
153
+        private int id;
154
+
155
+        public UDP(int _id)
156
+        {
157
+            id = _id;
158
+        }
159
+
160
+        public void Connect(IPEndPoint _endPoint)
161
+        {
162
+            endPoint = _endPoint;
163
+        }
164
+
165
+        public void SendData(Packet _packet)
166
+        {
167
+            Server.SendUDPData(endPoint, _packet);
168
+        }
169
+
170
+        public void HandleData(Packet _packetData)
171
+        {
172
+            int _packetLength = _packetData.ReadInt();
173
+            byte[] _packetBytes = _packetData.ReadBytes(_packetLength);
174
+
175
+            ThreadManager.ExecuteOnMainThread(() =>
176
+            {
177
+                using (Packet _packet = new Packet(_packetBytes))
178
+                {
179
+                    int _packetId = _packet.ReadInt();
180
+                    Server.packetHandlers[_packetId](id, _packet);
181
+                }
182
+            });
183
+        }
184
+
185
+        public void Disconnect()
186
+        {
187
+            endPoint = null;
188
+        }
189
+    }
190
+
191
+    public void SendIntoGame(string _playerName)
192
+    {
193
+        player = NetworkManager.instance.InstantiatePlayer();
194
+        player.Initialize(id, _playerName);
195
+
196
+        foreach (Client _client in Server.clients.Values)
197
+        {
198
+            if (_client.player != null)
199
+            {
200
+                if (_client.id != id)
201
+                {
202
+                    ServerSend.SpawnPlayer(id, _client.player);
203
+                }
204
+            }
205
+        }
206
+
207
+        foreach (Client _client in Server.clients.Values)
208
+        {
209
+            if (_client.player != null)
210
+            {
211
+                ServerSend.SpawnPlayer(_client.id, player);
212
+            }
213
+        }
214
+    }
215
+
216
+    public void Disconnect()
217
+    {
218
+        Debug.Log($"{tcp.socket.Client.RemoteEndPoint} has disconnected.");
219
+
220
+        ThreadManager.ExecuteOnMainThread(() =>
221
+        {
222
+            UnityEngine.Object.Destroy(player.gameObject);
223
+            player = null;
224
+        });
225
+
226
+        tcp.Disconnect();
227
+        udp.Disconnect();
228
+
229
+        ServerSend.PlayerDisconnected(id);
230
+    }
231
+}

+ 11
- 0
Server/Assets/Scripts/Client.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 75117f3be01657b46ab2852084d46ec2
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 9
- 0
Server/Assets/Scripts/Constants.cs Vedi File

@@ -0,0 +1,9 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class Constants
6
+{
7
+    public const int TICKS_PER_SEC = 30;
8
+    public const int MS_PER_TICKS = 1000 / TICKS_PER_SEC;
9
+}

+ 11
- 0
Server/Assets/Scripts/Constants.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 2928664bb9c8ca54982bc6f4bf60cd85
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 41
- 0
Server/Assets/Scripts/NetworkManager.cs Vedi File

@@ -0,0 +1,41 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class NetworkManager : MonoBehaviour
6
+{
7
+    public static NetworkManager instance;
8
+
9
+    public GameObject playerPrefab;
10
+
11
+    private void Awake()
12
+    {
13
+        if (instance == null)
14
+        {
15
+            instance = this;
16
+        }
17
+        else if (instance != this)
18
+        {
19
+            Debug.Log("Instance already exists, destroying object !");
20
+            Destroy(this);
21
+        }
22
+    }
23
+
24
+    private void Start()
25
+    {
26
+        QualitySettings.vSyncCount = 0;
27
+        Application.targetFrameRate = 30;
28
+
29
+        Server.Start(10, 26950);
30
+    }
31
+
32
+    private void OnApplicationQuit()
33
+    {
34
+        Server.Stop();
35
+    }
36
+
37
+    public Player InstantiatePlayer()
38
+    {
39
+        return Instantiate(playerPrefab, new Vector3(0f, 0.5f, 0f), Quaternion.identity).GetComponent<Player>();
40
+    }
41
+}

+ 11
- 0
Server/Assets/Scripts/NetworkManager.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 5c82b540c9d84e3478d571870afd8252
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 387
- 0
Server/Assets/Scripts/Packet.cs Vedi File

@@ -0,0 +1,387 @@
1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.Text;
5
+using UnityEngine;
6
+
7
+public enum ServerPackets
8
+{
9
+    welcome = 1,
10
+    spawnPlayer,
11
+    playerPosition,
12
+    playerRotation,
13
+    playerDisconnected,
14
+    playerHealth,
15
+    playerRespawned
16
+}
17
+
18
+/// <summary>Sent from client to server.</summary>
19
+public enum ClientPackets
20
+{
21
+    welcomeReceived = 1,
22
+    playerMovement,
23
+    playerShoot
24
+}
25
+
26
+public class Packet : IDisposable
27
+{
28
+    private List<byte> buffer;
29
+    private byte[] readableBuffer;
30
+    private int readPos;
31
+
32
+    /// <summary>Creates a new empty packet (without an ID).</summary>
33
+    public Packet()
34
+    {
35
+        buffer = new List<byte>(); // Intitialize buffer
36
+        readPos = 0; // Set readPos to 0
37
+    }
38
+
39
+    /// <summary>Creates a new packet with a given ID. Used for sending.</summary>
40
+    /// <param name="_id">The packet ID.</param>
41
+    public Packet(int _id)
42
+    {
43
+        buffer = new List<byte>(); // Intitialize buffer
44
+        readPos = 0; // Set readPos to 0
45
+
46
+        Write(_id); // Write packet id to the buffer
47
+    }
48
+
49
+    /// <summary>Creates a packet from which data can be read. Used for receiving.</summary>
50
+    /// <param name="_data">The bytes to add to the packet.</param>
51
+    public Packet(byte[] _data)
52
+    {
53
+        buffer = new List<byte>(); // Intitialize buffer
54
+        readPos = 0; // Set readPos to 0
55
+
56
+        SetBytes(_data);
57
+    }
58
+
59
+    #region Functions
60
+    /// <summary>Sets the packet's content and prepares it to be read.</summary>
61
+    /// <param name="_data">The bytes to add to the packet.</param>
62
+    public void SetBytes(byte[] _data)
63
+    {
64
+        Write(_data);
65
+        readableBuffer = buffer.ToArray();
66
+    }
67
+
68
+    /// <summary>Inserts the length of the packet's content at the start of the buffer.</summary>
69
+    public void WriteLength()
70
+    {
71
+        buffer.InsertRange(0, BitConverter.GetBytes(buffer.Count)); // Insert the byte length of the packet at the very beginning
72
+    }
73
+
74
+    /// <summary>Inserts the given int at the start of the buffer.</summary>
75
+    /// <param name="_value">The int to insert.</param>
76
+    public void InsertInt(int _value)
77
+    {
78
+        buffer.InsertRange(0, BitConverter.GetBytes(_value)); // Insert the int at the start of the buffer
79
+    }
80
+
81
+    /// <summary>Gets the packet's content in array form.</summary>
82
+    public byte[] ToArray()
83
+    {
84
+        readableBuffer = buffer.ToArray();
85
+        return readableBuffer;
86
+    }
87
+
88
+    /// <summary>Gets the length of the packet's content.</summary>
89
+    public int Length()
90
+    {
91
+        return buffer.Count; // Return the length of buffer
92
+    }
93
+
94
+    /// <summary>Gets the length of the unread data contained in the packet.</summary>
95
+    public int UnreadLength()
96
+    {
97
+        return Length() - readPos; // Return the remaining length (unread)
98
+    }
99
+
100
+    /// <summary>Resets the packet instance to allow it to be reused.</summary>
101
+    /// <param name="_shouldReset">Whether or not to reset the packet.</param>
102
+    public void Reset(bool _shouldReset = true)
103
+    {
104
+        if (_shouldReset)
105
+        {
106
+            buffer.Clear(); // Clear buffer
107
+            readableBuffer = null;
108
+            readPos = 0; // Reset readPos
109
+        }
110
+        else
111
+        {
112
+            readPos -= 4; // "Unread" the last read int
113
+        }
114
+    }
115
+    #endregion
116
+
117
+    #region Write Data
118
+    /// <summary>Adds a byte to the packet.</summary>
119
+    /// <param name="_value">The byte to add.</param>
120
+    public void Write(byte _value)
121
+    {
122
+        buffer.Add(_value);
123
+    }
124
+    /// <summary>Adds an array of bytes to the packet.</summary>
125
+    /// <param name="_value">The byte array to add.</param>
126
+    public void Write(byte[] _value)
127
+    {
128
+        buffer.AddRange(_value);
129
+    }
130
+    /// <summary>Adds a short to the packet.</summary>
131
+    /// <param name="_value">The short to add.</param>
132
+    public void Write(short _value)
133
+    {
134
+        buffer.AddRange(BitConverter.GetBytes(_value));
135
+    }
136
+    /// <summary>Adds an int to the packet.</summary>
137
+    /// <param name="_value">The int to add.</param>
138
+    public void Write(int _value)
139
+    {
140
+        buffer.AddRange(BitConverter.GetBytes(_value));
141
+    }
142
+    /// <summary>Adds a long to the packet.</summary>
143
+    /// <param name="_value">The long to add.</param>
144
+    public void Write(long _value)
145
+    {
146
+        buffer.AddRange(BitConverter.GetBytes(_value));
147
+    }
148
+    /// <summary>Adds a float to the packet.</summary>
149
+    /// <param name="_value">The float to add.</param>
150
+    public void Write(float _value)
151
+    {
152
+        buffer.AddRange(BitConverter.GetBytes(_value));
153
+    }
154
+    /// <summary>Adds a bool to the packet.</summary>
155
+    /// <param name="_value">The bool to add.</param>
156
+    public void Write(bool _value)
157
+    {
158
+        buffer.AddRange(BitConverter.GetBytes(_value));
159
+    }
160
+    /// <summary>Adds a string to the packet.</summary>
161
+    /// <param name="_value">The string to add.</param>
162
+    public void Write(string _value)
163
+    {
164
+        Write(_value.Length); // Add the length of the string to the packet
165
+        buffer.AddRange(Encoding.ASCII.GetBytes(_value)); // Add the string itself
166
+    }
167
+
168
+    public void Write(Vector3 _value)
169
+    {
170
+        Write(_value.x);
171
+        Write(_value.y);
172
+        Write(_value.z);
173
+    }
174
+
175
+    public void Write(Quaternion _value)
176
+    {
177
+        Write(_value.x);
178
+        Write(_value.y);
179
+        Write(_value.z);
180
+        Write(_value.w);
181
+    }
182
+    #endregion
183
+
184
+    #region Read Data
185
+    /// <summary>Reads a byte from the packet.</summary>
186
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
187
+    public byte ReadByte(bool _moveReadPos = true)
188
+    {
189
+        if (buffer.Count > readPos)
190
+        {
191
+            // If there are unread bytes
192
+            byte _value = readableBuffer[readPos]; // Get the byte at readPos' position
193
+            if (_moveReadPos)
194
+            {
195
+                // If _moveReadPos is true
196
+                readPos += 1; // Increase readPos by 1
197
+            }
198
+            return _value; // Return the byte
199
+        }
200
+        else
201
+        {
202
+            throw new Exception("Could not read value of type 'byte'!");
203
+        }
204
+    }
205
+
206
+    /// <summary>Reads an array of bytes from the packet.</summary>
207
+    /// <param name="_length">The length of the byte array.</param>
208
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
209
+    public byte[] ReadBytes(int _length, bool _moveReadPos = true)
210
+    {
211
+        if (buffer.Count > readPos)
212
+        {
213
+            // If there are unread bytes
214
+            byte[] _value = buffer.GetRange(readPos, _length).ToArray(); // Get the bytes at readPos' position with a range of _length
215
+            if (_moveReadPos)
216
+            {
217
+                // If _moveReadPos is true
218
+                readPos += _length; // Increase readPos by _length
219
+            }
220
+            return _value; // Return the bytes
221
+        }
222
+        else
223
+        {
224
+            throw new Exception("Could not read value of type 'byte[]'!");
225
+        }
226
+    }
227
+
228
+    /// <summary>Reads a short from the packet.</summary>
229
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
230
+    public short ReadShort(bool _moveReadPos = true)
231
+    {
232
+        if (buffer.Count > readPos)
233
+        {
234
+            // If there are unread bytes
235
+            short _value = BitConverter.ToInt16(readableBuffer, readPos); // Convert the bytes to a short
236
+            if (_moveReadPos)
237
+            {
238
+                // If _moveReadPos is true and there are unread bytes
239
+                readPos += 2; // Increase readPos by 2
240
+            }
241
+            return _value; // Return the short
242
+        }
243
+        else
244
+        {
245
+            throw new Exception("Could not read value of type 'short'!");
246
+        }
247
+    }
248
+
249
+    /// <summary>Reads an int from the packet.</summary>
250
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
251
+    public int ReadInt(bool _moveReadPos = true)
252
+    {
253
+        if (buffer.Count > readPos)
254
+        {
255
+            // If there are unread bytes
256
+            int _value = BitConverter.ToInt32(readableBuffer, readPos); // Convert the bytes to an int
257
+            if (_moveReadPos)
258
+            {
259
+                // If _moveReadPos is true
260
+                readPos += 4; // Increase readPos by 4
261
+            }
262
+            return _value; // Return the int
263
+        }
264
+        else
265
+        {
266
+            throw new Exception("Could not read value of type 'int'!");
267
+        }
268
+    }
269
+
270
+    /// <summary>Reads a long from the packet.</summary>
271
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
272
+    public long ReadLong(bool _moveReadPos = true)
273
+    {
274
+        if (buffer.Count > readPos)
275
+        {
276
+            // If there are unread bytes
277
+            long _value = BitConverter.ToInt64(readableBuffer, readPos); // Convert the bytes to a long
278
+            if (_moveReadPos)
279
+            {
280
+                // If _moveReadPos is true
281
+                readPos += 8; // Increase readPos by 8
282
+            }
283
+            return _value; // Return the long
284
+        }
285
+        else
286
+        {
287
+            throw new Exception("Could not read value of type 'long'!");
288
+        }
289
+    }
290
+
291
+    /// <summary>Reads a float from the packet.</summary>
292
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
293
+    public float ReadFloat(bool _moveReadPos = true)
294
+    {
295
+        if (buffer.Count > readPos)
296
+        {
297
+            // If there are unread bytes
298
+            float _value = BitConverter.ToSingle(readableBuffer, readPos); // Convert the bytes to a float
299
+            if (_moveReadPos)
300
+            {
301
+                // If _moveReadPos is true
302
+                readPos += 4; // Increase readPos by 4
303
+            }
304
+            return _value; // Return the float
305
+        }
306
+        else
307
+        {
308
+            throw new Exception("Could not read value of type 'float'!");
309
+        }
310
+    }
311
+
312
+    /// <summary>Reads a bool from the packet.</summary>
313
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
314
+    public bool ReadBool(bool _moveReadPos = true)
315
+    {
316
+        if (buffer.Count > readPos)
317
+        {
318
+            // If there are unread bytes
319
+            bool _value = BitConverter.ToBoolean(readableBuffer, readPos); // Convert the bytes to a bool
320
+            if (_moveReadPos)
321
+            {
322
+                // If _moveReadPos is true
323
+                readPos += 1; // Increase readPos by 1
324
+            }
325
+            return _value; // Return the bool
326
+        }
327
+        else
328
+        {
329
+            throw new Exception("Could not read value of type 'bool'!");
330
+        }
331
+    }
332
+
333
+    /// <summary>Reads a string from the packet.</summary>
334
+    /// <param name="_moveReadPos">Whether or not to move the buffer's read position.</param>
335
+    public string ReadString(bool _moveReadPos = true)
336
+    {
337
+        try
338
+        {
339
+            int _length = ReadInt(); // Get the length of the string
340
+            string _value = Encoding.ASCII.GetString(readableBuffer, readPos, _length); // Convert the bytes to a string
341
+            if (_moveReadPos && _value.Length > 0)
342
+            {
343
+                // If _moveReadPos is true string is not empty
344
+                readPos += _length; // Increase readPos by the length of the string
345
+            }
346
+            return _value; // Return the string
347
+        }
348
+        catch
349
+        {
350
+            throw new Exception("Could not read value of type 'string'!");
351
+        }
352
+    }
353
+
354
+    public Vector3 ReadVector3(bool _moveReadPos = true)
355
+    {
356
+        return new Vector3(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
357
+    }
358
+
359
+    public Quaternion ReadQuaternion(bool _moveReadPos = true)
360
+    {
361
+        return new Quaternion(ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos), ReadFloat(_moveReadPos));
362
+    }
363
+    #endregion
364
+
365
+    private bool disposed = false;
366
+
367
+    protected virtual void Dispose(bool _disposing)
368
+    {
369
+        if (!disposed)
370
+        {
371
+            if (_disposing)
372
+            {
373
+                buffer = null;
374
+                readableBuffer = null;
375
+                readPos = 0;
376
+            }
377
+
378
+            disposed = true;
379
+        }
380
+    }
381
+
382
+    public void Dispose()
383
+    {
384
+        Dispose(true);
385
+        GC.SuppressFinalize(this);
386
+    }
387
+}

+ 11
- 0
Server/Assets/Scripts/Packet.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 70df187e7a7a15240957ab4b29411a38
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 131
- 0
Server/Assets/Scripts/Player.cs Vedi File

@@ -0,0 +1,131 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class Player : MonoBehaviour
6
+{
7
+    public int id;
8
+    public string username;
9
+    public CharacterController controller;
10
+    public Transform shootOrigin;
11
+    public float gravity = -9.81f;
12
+    public float moveSpeed = 5f;
13
+    public float jumpSpeed = 5f;
14
+    public float health;
15
+    public float maxHealth = 100f;
16
+
17
+    private float yVelocity = 0;
18
+    private bool[] inputs;
19
+
20
+    private void Start()
21
+    {
22
+        gravity *= Time.fixedDeltaTime * Time.fixedDeltaTime;
23
+        moveSpeed *= Time.fixedDeltaTime;
24
+        jumpSpeed *= Time.fixedDeltaTime;
25
+    }
26
+
27
+    public void Initialize(int _id, string _username)
28
+    {
29
+        id = _id;
30
+        username = _username;
31
+        health = maxHealth;
32
+
33
+        inputs = new bool[5];
34
+    }
35
+
36
+    public void FixedUpdate()
37
+    {
38
+        if (health <= 0f)
39
+        {
40
+            return;
41
+        }
42
+
43
+        Vector2 _inputDirection = Vector2.zero;
44
+        if (inputs[0])
45
+        {
46
+            _inputDirection.y += 1;
47
+        }
48
+        if (inputs[1])
49
+        {
50
+            _inputDirection.y -= 1;
51
+        }
52
+        if (inputs[2])
53
+        {
54
+            _inputDirection.x -= 1;
55
+        }
56
+        if (inputs[3])
57
+        {
58
+            _inputDirection.x += 1;
59
+        }
60
+
61
+        Move(_inputDirection);
62
+    }
63
+
64
+    private void Move(Vector2 _inputDirection)
65
+    {
66
+        Vector3 _moveDirection = transform.right * _inputDirection.x + transform.forward * _inputDirection.y;
67
+        _moveDirection *= moveSpeed;
68
+
69
+        if (controller.isGrounded)
70
+        {
71
+            yVelocity = 0f;
72
+            if (inputs[4])
73
+            {
74
+                yVelocity = jumpSpeed;
75
+            }
76
+        }
77
+        yVelocity += gravity;
78
+
79
+        _moveDirection.y = yVelocity;
80
+        controller.Move(_moveDirection);
81
+
82
+        ServerSend.PlayerPosition(this);
83
+        ServerSend.PlayerRotation(this);
84
+    }
85
+
86
+    public void SetInput(bool[] _inputs, Quaternion _rotation)
87
+    {
88
+        inputs = _inputs;
89
+        transform.rotation = _rotation;
90
+    }
91
+
92
+    public void Shoot(Vector3 _viewDirection)
93
+    {
94
+        if (Physics.Raycast(shootOrigin.position, _viewDirection, out RaycastHit _hit, 25f))
95
+        {
96
+            if (_hit.collider.CompareTag("Player"))
97
+            {
98
+                _hit.collider.GetComponent<Player>().TakeDamage(50f);
99
+            }
100
+        }
101
+    }
102
+
103
+    public void TakeDamage(float _damage)
104
+    {
105
+        if (health <= 0f)
106
+        {
107
+            return;
108
+        }
109
+
110
+        health -= _damage;
111
+        if (health <= 0f)
112
+        {
113
+            health = 0f;
114
+            controller.enabled = false;
115
+            transform.position = new Vector3(0f, 25f, 0f);
116
+            ServerSend.PlayerPosition(this);
117
+            StartCoroutine(Respawn());
118
+        }
119
+
120
+        ServerSend.PlayerHealth(this);
121
+    }
122
+
123
+    private IEnumerator Respawn()
124
+    {
125
+        yield return new WaitForSeconds(5f);
126
+
127
+        health = maxHealth;
128
+        controller.enabled = true;
129
+        ServerSend.PlayerRespawned(this);
130
+    }
131
+}

+ 11
- 0
Server/Assets/Scripts/Player.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: fef6c5c8db7a0f34f9cd6abcb254124f
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 131
- 0
Server/Assets/Scripts/Server.cs Vedi File

@@ -0,0 +1,131 @@
1
+using System;
2
+using System.Collections;
3
+using System.Collections.Generic;
4
+using System.Net;
5
+using System.Net.Sockets;
6
+using UnityEngine;
7
+
8
+public class Server
9
+{
10
+    public static int MaxPlayers { get; private set; }
11
+    public static int Port { get; private set; }
12
+    public static Dictionary<int, Client> clients = new Dictionary<int, Client>();
13
+    public delegate void PacketHandler(int _fromClient, Packet _packet);
14
+    public static Dictionary<int, PacketHandler> packetHandlers;
15
+
16
+    public static TcpListener tcpListener;
17
+    public static UdpClient udpListener;
18
+
19
+    public static void Start(int _maxPlayers, int _port)
20
+    {
21
+        MaxPlayers = _maxPlayers;
22
+        Port = _port;
23
+
24
+        Debug.Log("Starting Server...");
25
+        InitializeServerData();
26
+
27
+        tcpListener = new TcpListener(IPAddress.Any, Port);
28
+        tcpListener.Start();
29
+        tcpListener.BeginAcceptTcpClient(TCPConnectCallback, null);
30
+
31
+        udpListener = new UdpClient(Port);
32
+        udpListener.BeginReceive(UDPReceiveCallback, null);
33
+
34
+        Debug.Log($"Server started on port : {Port}.");
35
+    }
36
+
37
+    private static void TCPConnectCallback(IAsyncResult _result)
38
+    {
39
+        TcpClient _client = tcpListener.EndAcceptTcpClient(_result);
40
+        tcpListener.BeginAcceptTcpClient(new AsyncCallback(TCPConnectCallback), null);
41
+        Debug.Log($"Incoming connection from {_client.Client.RemoteEndPoint}...");
42
+
43
+        for (int i = 1; i <= MaxPlayers; i++)
44
+        {
45
+            if (clients[i].tcp.socket == null)
46
+            {
47
+                clients[i].tcp.Connect(_client);
48
+                return;
49
+            }
50
+        }
51
+
52
+        Debug.Log($"{_client.Client.RemoteEndPoint} failed to connect. server full !");
53
+    }
54
+
55
+    private static void UDPReceiveCallback(IAsyncResult _result)
56
+    {
57
+        try
58
+        {
59
+            IPEndPoint _clientEndPoint = new IPEndPoint(IPAddress.Any, 0);
60
+            byte[] _data = udpListener.EndReceive(_result, ref _clientEndPoint);
61
+            udpListener.BeginReceive(UDPReceiveCallback, null);
62
+
63
+            if (_data.Length < 4)
64
+            {
65
+                return;
66
+            }
67
+
68
+            using (Packet _packet = new Packet(_data))
69
+            {
70
+                int _clientId = _packet.ReadInt();
71
+
72
+                if (_clientId == 0)
73
+                {
74
+                    return;
75
+                }
76
+
77
+                if (clients[_clientId].udp.endPoint == null)
78
+                {
79
+                    clients[_clientId].udp.Connect(_clientEndPoint);
80
+                    return;
81
+                }
82
+
83
+                if (clients[_clientId].udp.endPoint.ToString() == _clientEndPoint.ToString())
84
+                {
85
+                    clients[_clientId].udp.HandleData(_packet);
86
+                }
87
+            }
88
+        }
89
+        catch (Exception _ex)
90
+        {
91
+            Debug.Log($"Error receiving UDP data: {_ex}");
92
+        }
93
+    }
94
+
95
+    public static void SendUDPData(IPEndPoint _clientEndPoint, Packet _packet)
96
+    {
97
+        try
98
+        {
99
+            if (_clientEndPoint != null)
100
+            {
101
+                udpListener.BeginSend(_packet.ToArray(), _packet.Length(), _clientEndPoint, null, null);
102
+            }
103
+        }
104
+        catch (Exception _ex)
105
+        {
106
+            Debug.Log($"Error sending data to {_clientEndPoint} via UDP: {_ex}");
107
+        }
108
+    }
109
+
110
+    private static void InitializeServerData()
111
+    {
112
+        for (int i = 1; i <= MaxPlayers; i++)
113
+        {
114
+            clients.Add(i, new Client(i));
115
+        }
116
+
117
+        packetHandlers = new Dictionary<int, PacketHandler>()
118
+            {
119
+                { (int)ClientPackets.welcomeReceived, ServerHandle.WelcomeReceived },
120
+                { (int)ClientPackets.playerMovement, ServerHandle.PlayerMovement },
121
+                { (int)ClientPackets.playerShoot, ServerHandle.PlayerShoot }
122
+            };
123
+        Debug.Log("Initialized packets.");
124
+    }
125
+
126
+    public static void Stop()
127
+    {
128
+        tcpListener.Stop();
129
+        udpListener.Close();
130
+    }
131
+}

+ 11
- 0
Server/Assets/Scripts/Server.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 02b9637f413a2414a9176a1f711a649f
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 38
- 0
Server/Assets/Scripts/ServerHandle.cs Vedi File

@@ -0,0 +1,38 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class ServerHandle
6
+{
7
+    public static void WelcomeReceived(int _fromClient, Packet _packet)
8
+    {
9
+        int _clientIdCheck = _packet.ReadInt();
10
+        string _username = _packet.ReadString();
11
+
12
+        Debug.Log($"{Server.clients[_fromClient].tcp.socket.Client.RemoteEndPoint} connected successfully and is now player {_fromClient}.");
13
+        if (_clientIdCheck != _fromClient)
14
+        {
15
+            Debug.Log($"Player \"{_username}\" (ID: {_fromClient}) has assumed the wrong client ID ({_clientIdCheck})!");
16
+        }
17
+        Server.clients[_fromClient].SendIntoGame(_username);
18
+    }
19
+
20
+    public static void PlayerMovement(int _fromClient, Packet _packet)
21
+    {
22
+        bool[] _inputs = new bool[_packet.ReadInt()];
23
+        for (int i = 0; i < _inputs.Length; i++)
24
+        {
25
+            _inputs[i] = _packet.ReadBool();
26
+        }
27
+        Quaternion _rotation = _packet.ReadQuaternion();
28
+
29
+        Server.clients[_fromClient].player.SetInput(_inputs, _rotation);
30
+    }
31
+
32
+    public static void PlayerShoot(int _fromClient, Packet _packet)
33
+    {
34
+        Vector3 shootDirection = _packet.ReadVector3();
35
+
36
+        Server.clients[_fromClient].player.Shoot(shootDirection);
37
+    }
38
+}

+ 11
- 0
Server/Assets/Scripts/ServerHandle.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 98cdaf458f3d06c4585517a12282d1be
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 139
- 0
Server/Assets/Scripts/ServerSend.cs Vedi File

@@ -0,0 +1,139 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+public class ServerSend
6
+{
7
+    private static void SendTCPData(int _toClient, Packet _packet)
8
+    {
9
+        _packet.WriteLength();
10
+        Server.clients[_toClient].tcp.SendData(_packet);
11
+    }
12
+
13
+    private static void SendUDPData(int _toClient, Packet _packet)
14
+    {
15
+        _packet.WriteLength();
16
+        Server.clients[_toClient].udp.SendData(_packet);
17
+    }
18
+
19
+    private static void SendTCPDataToAll(Packet _packet)
20
+    {
21
+        _packet.WriteLength();
22
+        for (int i = 1; i <= Server.MaxPlayers; i++)
23
+        {
24
+            Server.clients[i].tcp.SendData(_packet);
25
+        }
26
+    }
27
+
28
+    private static void SendTCPDataToAll(int _exceptClient, Packet _packet)
29
+    {
30
+        _packet.WriteLength();
31
+        for (int i = 1; i <= Server.MaxPlayers; i++)
32
+        {
33
+            if (i != _exceptClient)
34
+            {
35
+                Server.clients[i].tcp.SendData(_packet);
36
+            }
37
+        }
38
+    }
39
+
40
+    private static void SendUDPDataToAll(Packet _packet)
41
+    {
42
+        _packet.WriteLength();
43
+        for (int i = 1; i <= Server.MaxPlayers; i++)
44
+        {
45
+            Server.clients[i].udp.SendData(_packet);
46
+        }
47
+    }
48
+
49
+    private static void SendUDPDataToAll(int _exceptClient, Packet _packet)
50
+    {
51
+        _packet.WriteLength();
52
+        for (int i = 1; i <= Server.MaxPlayers; i++)
53
+        {
54
+            if (i != _exceptClient)
55
+            {
56
+                Server.clients[i].udp.SendData(_packet);
57
+            }
58
+        }
59
+    }
60
+
61
+    #region packets
62
+    public static void Welcome(int _toClient, string _msg)
63
+    {
64
+        using (Packet _packet = new Packet((int)ServerPackets.welcome))
65
+        {
66
+            _packet.Write(_msg);
67
+            _packet.Write(_toClient);
68
+
69
+            SendTCPData(_toClient, _packet);
70
+        }
71
+    }
72
+
73
+    public static void SpawnPlayer(int _toClient, Player _player)
74
+    {
75
+        using (Packet _packet = new Packet((int)ServerPackets.spawnPlayer))
76
+        {
77
+            _packet.Write(_player.id);
78
+            _packet.Write(_player.username);
79
+            _packet.Write(_player.transform.position);
80
+            _packet.Write(_player.transform.rotation);
81
+
82
+            SendTCPData(_toClient, _packet);
83
+        }
84
+    }
85
+
86
+    public static void PlayerPosition(Player _player)
87
+    {
88
+        using (Packet _packet = new Packet((int)ServerPackets.playerPosition))
89
+        {
90
+            _packet.Write(_player.id);
91
+            _packet.Write(_player.transform.position);
92
+
93
+            SendUDPDataToAll(_packet);
94
+        }
95
+    }
96
+
97
+    public static void PlayerRotation(Player _player)
98
+    {
99
+        using (Packet _packet = new Packet((int)ServerPackets.playerRotation))
100
+        {
101
+            _packet.Write(_player.id);
102
+            _packet.Write(_player.transform.rotation);
103
+
104
+            SendUDPDataToAll(_player.id, _packet);
105
+        }
106
+    }
107
+
108
+    public static void PlayerDisconnected(int _playerId)
109
+    {
110
+        using (Packet _packet = new Packet((int)ServerPackets.playerDisconnected))
111
+        {
112
+            _packet.Write(_playerId);
113
+
114
+            SendTCPDataToAll(_packet);
115
+        }
116
+    }
117
+
118
+    public static void PlayerHealth(Player _player)
119
+    {
120
+        using (Packet _packet = new Packet((int)ServerPackets.playerHealth))
121
+        {
122
+            _packet.Write(_player.id);
123
+            _packet.Write(_player.health);
124
+
125
+            SendTCPDataToAll(_packet);
126
+        }
127
+    }
128
+
129
+    public static void PlayerRespawned(Player _player)
130
+    {
131
+        using (Packet _packet = new Packet((int)ServerPackets.playerRespawned))
132
+        {
133
+            _packet.Write(_player.id);
134
+
135
+            SendTCPDataToAll(_packet);
136
+        }
137
+    }
138
+    #endregion
139
+}

+ 11
- 0
Server/Assets/Scripts/ServerSend.cs.meta Vedi File

@@ -0,0 +1,11 @@
1
+fileFormatVersion: 2
2
+guid: 1939d30e8457d43499c2f054f786586e
3
+MonoImporter:
4
+  externalObjects: {}
5
+  serializedVersion: 2
6
+  defaultReferences: []
7
+  executionOrder: 0
8
+  icon: {instanceID: 0}
9
+  userData: 
10
+  assetBundleName: 
11
+  assetBundleVariant: 

+ 0
- 0
Server/Assets/Scripts/ThreadManager.cs Vedi File


Dato che sono stati cambiati molti file in questo diff, alcuni di essi non verranno mostrati

Loading…
Annulla
Salva