From 0e27831cf707158d76bb12ee13675596304adc63 Mon Sep 17 00:00:00 2001 From: Stedd Date: Sun, 3 Sep 2023 19:09:38 +0200 Subject: [PATCH] Unit spawner Players are assigned a unit spawner at connect Unit spawner can spawn units. Units has simple path finding Copied a few scripts from Section 1 --- Assets/Materials/UnitSpawner_Mat.mat | 133 +++++++ Assets/Materials/UnitSpawner_Mat.mat.meta | 8 + Assets/Prefabs/Player.prefab | 374 ++++++++++++------ Assets/Prefabs/Player.prefab.meta | 2 +- Assets/Prefabs/Unit.prefab | 202 ++++++++++ Assets/Prefabs/Unit.prefab.meta | 7 + Assets/Prefabs/UnitSpawner.prefab | 208 ++++++++++ Assets/Prefabs/UnitSpawner.prefab.meta | 7 + Assets/Scenes/MainScene.unity | 203 +++++++++- Assets/Scripts/Buildings.meta | 8 + Assets/Scripts/Buildings/UnitSpawner.cs | 35 ++ Assets/Scripts/Buildings/UnitSpawner.cs.meta | 11 + Assets/Scripts/Networking/NetworkPlayer.cs | 99 +++++ .../Scripts/Networking/NetworkPlayer.cs.meta | 11 + .../Scripts/Networking/RTSNetworkManager.cs | 22 +- Assets/Scripts/Util.meta | 8 + Assets/Scripts/Util/ColorManipulation.cs | 6 + Assets/Scripts/Util/ColorManipulation.cs.meta | 11 + 18 files changed, 1214 insertions(+), 141 deletions(-) create mode 100644 Assets/Materials/UnitSpawner_Mat.mat create mode 100644 Assets/Materials/UnitSpawner_Mat.mat.meta create mode 100644 Assets/Prefabs/Unit.prefab create mode 100644 Assets/Prefabs/Unit.prefab.meta create mode 100644 Assets/Prefabs/UnitSpawner.prefab create mode 100644 Assets/Prefabs/UnitSpawner.prefab.meta create mode 100644 Assets/Scripts/Buildings.meta create mode 100644 Assets/Scripts/Buildings/UnitSpawner.cs create mode 100644 Assets/Scripts/Buildings/UnitSpawner.cs.meta create mode 100644 Assets/Scripts/Networking/NetworkPlayer.cs create mode 100644 Assets/Scripts/Networking/NetworkPlayer.cs.meta create mode 100644 Assets/Scripts/Util.meta create mode 100644 Assets/Scripts/Util/ColorManipulation.cs create mode 100644 Assets/Scripts/Util/ColorManipulation.cs.meta diff --git a/Assets/Materials/UnitSpawner_Mat.mat b/Assets/Materials/UnitSpawner_Mat.mat new file mode 100644 index 0000000..9b4289a --- /dev/null +++ b/Assets/Materials/UnitSpawner_Mat.mat @@ -0,0 +1,133 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-4427551773171829186 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 7 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: UnitSpawner_Mat + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _AlphaToMask: 0 + - _Blend: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _DstBlendAlpha: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 0.8584906, g: 0.82405555, b: 0.1579299, a: 1} + - _Color: {r: 0.8584906, g: 0.82405555, b: 0.15792987, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/UnitSpawner_Mat.mat.meta b/Assets/Materials/UnitSpawner_Mat.mat.meta new file mode 100644 index 0000000..e90d6ad --- /dev/null +++ b/Assets/Materials/UnitSpawner_Mat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 463a725e26aba9040a6ee9ce470b31f0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 08ad757..839d470 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1,5 +1,88 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &3749893881854938843 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7212763053583310241} + - component: {fileID: 3453635016999828623} + - component: {fileID: 6316955320539365924} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &7212763053583310241 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2385999535964237451} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3453635016999828623 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &6316955320539365924 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &5181188659209802552 GameObject: m_ObjectHideFlags: 0 @@ -10,9 +93,7 @@ GameObject: m_Component: - component: {fileID: 2385999535964237451} - component: {fileID: 5351038950168726961} - - component: {fileID: 2439696136893951540} - - component: {fileID: 6123744421715133446} - - component: {fileID: 8681090027785358193} + - component: {fileID: 3733238636321905986} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -33,7 +114,8 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 4352769845730777867} + - {fileID: 7212763053583310241} + - {fileID: 1731608187634053948} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &5351038950168726961 @@ -49,11 +131,11 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: sceneId: 0 - _assetId: 3649603090 + _assetId: 3019086376 serverOnly: 0 visible: 0 hasSpawned: 0 ---- !u!114 &2439696136893951540 +--- !u!114 &3733238636321905986 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -62,141 +144,183 @@ MonoBehaviour: m_GameObject: {fileID: 5181188659209802552} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3} + m_Script: {fileID: 11500000, guid: 91a604620298dff4fb1301fafef543f7, type: 3} m_Name: m_EditorClassIdentifier: syncDirection: 0 syncMode: 0 syncInterval: 0 - target: {fileID: 2385999535964237451} - clientAuthority: 0 - syncPosition: 1 - syncRotation: 1 - syncScale: 0 - interpolatePosition: 1 - interpolateRotation: 1 - interpolateScale: 1 - coordinateSpace: 0 - sendIntervalMultiplier: 1 - timelineOffset: 0 - showGizmos: 0 - showOverlay: 0 - overlayColor: {r: 0, g: 0, b: 0, a: 0.5} - onlySyncOnChange: 1 - onlySyncOnChangeCorrectionMultiplier: 2 - rotationSensitivity: 0.01 - compressRotation: 0 - positionPrecision: 0.01 - scalePrecision: 0.01 ---- !u!195 &6123744421715133446 -NavMeshAgent: + _playerNameObject: {fileID: 9103673863276277696} + _displayName: Missing Name + _playerColor: {r: 0, g: 0, b: 0, a: 1} +--- !u!1 &7370235515971428967 +GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5181188659209802552} + serializedVersion: 6 + m_Component: + - component: {fileID: 1731608187634053948} + - component: {fileID: 5064429962249226307} + - component: {fileID: 9103673863276277696} + m_Layer: 0 + m_Name: PlayerName + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1731608187634053948 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7370235515971428967} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2385999535964237451} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 2.08} + m_SizeDelta: {x: 5.24, y: 1.3} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!23 &5064429962249226307 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7370235515971428967} m_Enabled: 1 - m_AgentTypeID: 1479372276 - m_Radius: 2.13 - m_Speed: 2.2 - m_Acceleration: 2 - avoidancePriority: 50 - m_AngularSpeed: 90 - m_StoppingDistance: 1 - m_AutoTraverseOffMeshLink: 1 - m_AutoBraking: 1 - m_AutoRepath: 1 - m_Height: 2.28 - m_BaseOffset: 0 - m_WalkableMask: 4294967295 - m_ObstacleAvoidanceType: 4 ---- !u!114 &8681090027785358193 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!114 &9103673863276277696 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5181188659209802552} + m_GameObject: {fileID: 7370235515971428967} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc5d69536d0782647a3de12f2d524c45, type: 3} + m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3} m_Name: m_EditorClassIdentifier: - syncDirection: 0 - syncMode: 0 - syncInterval: 0 - _navMeshAgent: {fileID: 6123744421715133446} ---- !u!1001 &4315183336175566048 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 2385999535964237451} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalRotation.w - value: 0.7071068 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalRotation.x - value: -0.7071068 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: -90 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - propertyPath: m_Name - value: tank with lazer cannon - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, type: 3} ---- !u!4 &4352769845730777867 stripped -Transform: - m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, - type: 3} - m_PrefabInstance: {fileID: 4315183336175566048} - m_PrefabAsset: {fileID: 0} + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Sample text + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 9 + m_fontSizeBase: 9 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 0 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + _SortingLayer: 0 + _SortingLayerID: 0 + _SortingOrder: 0 + m_hasFontAssetChanged: 0 + m_renderer: {fileID: 5064429962249226307} + m_maskType: 0 diff --git a/Assets/Prefabs/Player.prefab.meta b/Assets/Prefabs/Player.prefab.meta index 955bbde..93b5510 100644 --- a/Assets/Prefabs/Player.prefab.meta +++ b/Assets/Prefabs/Player.prefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 137622a055406ed4f823d72e0ad2fd8a +guid: 1931872f3adf2dc4cb0318c713241e40 PrefabImporter: externalObjects: {} userData: diff --git a/Assets/Prefabs/Unit.prefab b/Assets/Prefabs/Unit.prefab new file mode 100644 index 0000000..49c0f8a --- /dev/null +++ b/Assets/Prefabs/Unit.prefab @@ -0,0 +1,202 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5181188659209802552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2385999535964237451} + - component: {fileID: 5351038950168726961} + - component: {fileID: 2439696136893951540} + - component: {fileID: 6123744421715133446} + - component: {fileID: 8681090027785358193} + m_Layer: 0 + m_Name: Unit + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2385999535964237451 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 4352769845730777867} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5351038950168726961 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneId: 0 + _assetId: 3649603090 + serverOnly: 0 + visible: 0 + hasSpawned: 0 +--- !u!114 &2439696136893951540 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8ff3ba0becae47b8b9381191598957c8, type: 3} + m_Name: + m_EditorClassIdentifier: + syncDirection: 0 + syncMode: 0 + syncInterval: 0 + target: {fileID: 2385999535964237451} + clientAuthority: 0 + syncPosition: 1 + syncRotation: 1 + syncScale: 0 + interpolatePosition: 1 + interpolateRotation: 1 + interpolateScale: 1 + coordinateSpace: 0 + sendIntervalMultiplier: 1 + timelineOffset: 0 + showGizmos: 0 + showOverlay: 0 + overlayColor: {r: 0, g: 0, b: 0, a: 0.5} + onlySyncOnChange: 1 + onlySyncOnChangeCorrectionMultiplier: 2 + rotationSensitivity: 0.01 + compressRotation: 0 + positionPrecision: 0.01 + scalePrecision: 0.01 +--- !u!195 &6123744421715133446 +NavMeshAgent: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_AgentTypeID: 1479372276 + m_Radius: 2.13 + m_Speed: 2.2 + m_Acceleration: 2 + avoidancePriority: 50 + m_AngularSpeed: 90 + m_StoppingDistance: 1 + m_AutoTraverseOffMeshLink: 1 + m_AutoBraking: 1 + m_AutoRepath: 1 + m_Height: 2.28 + m_BaseOffset: 0 + m_WalkableMask: 4294967295 + m_ObstacleAvoidanceType: 4 +--- !u!114 &8681090027785358193 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc5d69536d0782647a3de12f2d524c45, type: 3} + m_Name: + m_EditorClassIdentifier: + syncDirection: 0 + syncMode: 0 + syncInterval: 0 + _navMeshAgent: {fileID: 6123744421715133446} +--- !u!1001 &4315183336175566048 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 2385999535964237451} + m_Modifications: + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalRotation.w + value: 0.7071068 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalRotation.x + value: -0.7071068 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: -90 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 919132149155446097, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + propertyPath: m_Name + value: tank with lazer cannon + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, type: 3} +--- !u!4 &4352769845730777867 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 199344dcb2a104c4f96cfe9d1d7f27cf, + type: 3} + m_PrefabInstance: {fileID: 4315183336175566048} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Prefabs/Unit.prefab.meta b/Assets/Prefabs/Unit.prefab.meta new file mode 100644 index 0000000..955bbde --- /dev/null +++ b/Assets/Prefabs/Unit.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 137622a055406ed4f823d72e0ad2fd8a +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/UnitSpawner.prefab b/Assets/Prefabs/UnitSpawner.prefab new file mode 100644 index 0000000..edcff30 --- /dev/null +++ b/Assets/Prefabs/UnitSpawner.prefab @@ -0,0 +1,208 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3749893881854938843 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7212763053583310241} + - component: {fileID: 3453635016999828623} + - component: {fileID: 6316955320539365924} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7212763053583310241 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2385999535964237451} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3453635016999828623 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &6316955320539365924 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3749893881854938843} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 463a725e26aba9040a6ee9ce470b31f0, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &5060469411889776094 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8539516553049106391} + m_Layer: 0 + m_Name: SpawnPoint + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8539516553049106391 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5060469411889776094} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 1.5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 2385999535964237451} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &5181188659209802552 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2385999535964237451} + - component: {fileID: 5351038950168726961} + - component: {fileID: 6857147680838656630} + - component: {fileID: 4523658194776954158} + m_Layer: 0 + m_Name: UnitSpawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2385999535964237451 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 7212763053583310241} + - {fileID: 8539516553049106391} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5351038950168726961 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3} + m_Name: + m_EditorClassIdentifier: + sceneId: 0 + _assetId: 1651298871 + serverOnly: 0 + visible: 0 + hasSpawned: 0 +--- !u!114 &6857147680838656630 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dffb2386490fea94fb1107c6d89bdc7d, type: 3} + m_Name: + m_EditorClassIdentifier: + syncDirection: 0 + syncMode: 0 + syncInterval: 0 + _unitPrefab: {fileID: 5181188659209802552, guid: 137622a055406ed4f823d72e0ad2fd8a, + type: 3} + _unitSpawnPoint: {fileID: 8539516553049106391} +--- !u!65 &4523658194776954158 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5181188659209802552} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0.5, z: 0} diff --git a/Assets/Prefabs/UnitSpawner.prefab.meta b/Assets/Prefabs/UnitSpawner.prefab.meta new file mode 100644 index 0000000..76fe95a --- /dev/null +++ b/Assets/Prefabs/UnitSpawner.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6b3f92c8871964b49bddf21c7d1a1571 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 6b14a2d..9362b03 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -123,6 +123,39 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &9051834 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9051835} + m_Layer: 0 + m_Name: GFX + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &9051835 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9051834} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 14.7938595, y: 9.42663, z: -8.76183} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 410087041} + - {fileID: 832575519} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &168675452 GameObject: m_ObjectHideFlags: 0 @@ -220,11 +253,13 @@ MonoBehaviour: disconnectInactiveConnections: 0 disconnectInactiveTimeout: 60 authenticator: {fileID: 0} - playerPrefab: {fileID: 5181188659209802552, guid: 137622a055406ed4f823d72e0ad2fd8a, + playerPrefab: {fileID: 5181188659209802552, guid: 1931872f3adf2dc4cb0318c713241e40, type: 3} autoCreatePlayer: 1 playerSpawnMethod: 1 - spawnPrefabs: [] + spawnPrefabs: + - {fileID: 5181188659209802552, guid: 137622a055406ed4f823d72e0ad2fd8a, type: 3} + - {fileID: 5181188659209802552, guid: 6b3f92c8871964b49bddf21c7d1a1571, type: 3} snapshotSettings: bufferTimeMultiplier: 2 bufferLimit: 32 @@ -238,6 +273,8 @@ MonoBehaviour: deliveryTimeEmaDuration: 2 connectionQualityInterval: 3 timeInterpolationGui: 0 + _unitSpawnerPrefab: {fileID: 5181188659209802552, guid: 6b3f92c8871964b49bddf21c7d1a1571, + type: 3} --- !u!1 &330585543 GameObject: m_ObjectHideFlags: 0 @@ -250,6 +287,7 @@ GameObject: - component: {fileID: 330585545} - component: {fileID: 330585544} - component: {fileID: 330585547} + - component: {fileID: 330585548} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -324,13 +362,13 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} serializedVersion: 2 - m_LocalRotation: {x: -0, y: 0.9635629, z: -0.2674819, w: 0} - m_LocalPosition: {x: 0, y: 14.5, z: 22.8} + m_LocalRotation: {x: 0.2674822, y: -0, z: -0, w: 0.9635628} + m_LocalPosition: {x: 0, y: 7.8, z: -18.61} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 31.029, y: 180, z: 0} + m_Father: {fileID: 1954283568} + m_LocalEulerAnglesHint: {x: 31.029, y: 0, z: 0} --- !u!114 &330585547 MonoBehaviour: m_ObjectHideFlags: 0 @@ -375,6 +413,22 @@ MonoBehaviour: mipBias: 0 varianceClampScale: 0.9 contrastAdaptiveSharpening: 0 +--- !u!114 &330585548 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 330585543} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c49b4cc203aa6414fae5c798d1d0e7d6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_EventMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_MaxRayIntersections: 0 --- !u!1 &410087039 GameObject: m_ObjectHideFlags: 0 @@ -464,11 +518,11 @@ Transform: m_GameObject: {fileID: 410087039} serializedVersion: 2 m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalPosition: {x: -14.7938595, y: -6.42663, z: 8.76183} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 9051835} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!114 &410087042 MonoBehaviour: @@ -644,12 +698,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 832575517} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -14.7938595, y: -9.42663, z: 8.76183} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 0} + m_Father: {fileID: 9051835} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &839937477 GameObject: @@ -844,6 +898,127 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &1904145804 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1904145807} + - component: {fileID: 1904145806} + - component: {fileID: 1904145805} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1904145805 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1904145804} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_MoveRepeatDelay: 0.5 + m_MoveRepeatRate: 0.1 + m_XRTrackingOrigin: {fileID: 0} + m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, + type: 3} + m_DeselectOnBackgroundClick: 1 + m_PointerBehavior: 0 + m_CursorLockBehavior: 0 +--- !u!114 &1904145806 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1904145804} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1904145807 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1904145804} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1954283567 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1954283568} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1954283568 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1954283567} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 330585546} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2140843247 GameObject: m_ObjectHideFlags: 0 @@ -927,8 +1102,8 @@ Transform: SceneRoots: m_ObjectHideFlags: 0 m_Roots: - - {fileID: 330585546} - - {fileID: 410087041} - - {fileID: 832575519} + - {fileID: 1954283568} + - {fileID: 9051835} + - {fileID: 1904145807} - {fileID: 168675456} - {fileID: 578241694} diff --git a/Assets/Scripts/Buildings.meta b/Assets/Scripts/Buildings.meta new file mode 100644 index 0000000..73c1f71 --- /dev/null +++ b/Assets/Scripts/Buildings.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5374834305b2e384b9fe0f24b44ed7ac +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Buildings/UnitSpawner.cs b/Assets/Scripts/Buildings/UnitSpawner.cs new file mode 100644 index 0000000..036fa23 --- /dev/null +++ b/Assets/Scripts/Buildings/UnitSpawner.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using Mirror; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.InputSystem; + +public class UnitSpawner : NetworkBehaviour, IPointerClickHandler +{ + [SerializeField] private GameObject _unitPrefab; + [SerializeField] private Transform _unitSpawnPoint; + + #region Server + + [Command] + private void CmdSpawnUnit() + { + GameObject unitInstance = Instantiate(_unitPrefab, _unitSpawnPoint.position, _unitSpawnPoint.rotation); + + NetworkServer.Spawn(unitInstance, connectionToClient); + } + + #endregion + + #region Client + + public void OnPointerClick(PointerEventData eventData) + { + if (eventData.button != PointerEventData.InputButton.Left) return; + if (!isOwned) return; + CmdSpawnUnit(); + } +} + +#endregion \ No newline at end of file diff --git a/Assets/Scripts/Buildings/UnitSpawner.cs.meta b/Assets/Scripts/Buildings/UnitSpawner.cs.meta new file mode 100644 index 0000000..cf68bb6 --- /dev/null +++ b/Assets/Scripts/Buildings/UnitSpawner.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dffb2386490fea94fb1107c6d89bdc7d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Networking/NetworkPlayer.cs b/Assets/Scripts/Networking/NetworkPlayer.cs new file mode 100644 index 0000000..caa5739 --- /dev/null +++ b/Assets/Scripts/Networking/NetworkPlayer.cs @@ -0,0 +1,99 @@ +using Mirror; +using TMPro; +using UnityEngine; + +public class NetworkPlayer : NetworkBehaviour +{ + [Header("Connections")] + [SerializeField] private TMP_Text _playerNameObject; + + [Header("Variables")] + [SyncVar(hook = nameof(SetPlayerNameTagText))] + [SerializeField] + private string _displayName = "Missing Name"; + + [SyncVar(hook = nameof(SetPlayerNameTagColor))] + [SerializeField] + private Color _playerColor = Color.black; + + #region Server + + [Server] + public void SetDisplayName(string newDisplayName) + { + _displayName = newDisplayName; + } + + [Server] + public void SetPlayerColor(Color newPlayerColor) + { + _playerColor = newPlayerColor; + } + + [Command] + private void CmdSetDisplayName(string newDisplayName) + { + if (NameLengthIsCorrect(newDisplayName)) + { + RpcDebugLog($"Setting player names{newDisplayName}"); + SetDisplayName(newDisplayName); + } + else + { + RpcDebugLog($"new name: {newDisplayName} : is too long"); + } + } + + [Command] + private void CmdSetNewColor() + { + Color newColor = ColorManipulation.GetRandomColor(); + RpcDebugLog($"Setting player color{newColor.ToString()}"); + SetPlayerColor(newColor); + } + + private bool NameLengthIsCorrect(string newDisplayName) + { + return newDisplayName.Length < 10; + } + + [ClientRpc] + private void RpcDebugLog(string message) + { + Debug.Log(message); + } + + #endregion + + #region Client + + private void SetPlayerNameTagText(string oldText, string newText) + { + if (_playerNameObject != null) + { + _playerNameObject.text = newText; + } + } + + private void SetPlayerNameTagColor(Color oldColor, Color newColor) + { + if (_playerNameObject != null) + { + _playerNameObject.color = newColor; + } + } + + [ContextMenu("SetName")] + private void SetMyName() + { + CmdSetDisplayName("New Name"); + } + + [ContextMenu("NewColor")] + private void SetNewColor() + { + CmdSetNewColor(); + } + + #endregion +} \ No newline at end of file diff --git a/Assets/Scripts/Networking/NetworkPlayer.cs.meta b/Assets/Scripts/Networking/NetworkPlayer.cs.meta new file mode 100644 index 0000000..d099c85 --- /dev/null +++ b/Assets/Scripts/Networking/NetworkPlayer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 91a604620298dff4fb1301fafef543f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Networking/RTSNetworkManager.cs b/Assets/Scripts/Networking/RTSNetworkManager.cs index c2ccda3..bd5d25e 100644 --- a/Assets/Scripts/Networking/RTSNetworkManager.cs +++ b/Assets/Scripts/Networking/RTSNetworkManager.cs @@ -1,6 +1,26 @@ using Mirror; +using UnityEngine; +using UnityEngine.InputSystem; public class RtsNetworkManager : NetworkManager { - + [SerializeField] private GameObject _unitSpawnerPrefab; + + public override void OnServerAddPlayer(NetworkConnectionToClient conn) + { + base.OnServerAddPlayer(conn); + + NetworkPlayer player = conn.identity.GetComponent(); + player.SetDisplayName($"Player {numPlayers.ToString()}"); + player.SetPlayerColor(ColorManipulation.GetRandomColor()); + + Transform playerStartPosition = conn.identity.transform; + + GameObject unitSpawner = Instantiate( + _unitSpawnerPrefab, + playerStartPosition.position, + playerStartPosition.rotation); + + NetworkServer.Spawn(unitSpawner, conn); + } } \ No newline at end of file diff --git a/Assets/Scripts/Util.meta b/Assets/Scripts/Util.meta new file mode 100644 index 0000000..0a8ed51 --- /dev/null +++ b/Assets/Scripts/Util.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f6a1bf87e03927f49bd5326b691031cc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Util/ColorManipulation.cs b/Assets/Scripts/Util/ColorManipulation.cs new file mode 100644 index 0000000..1e30749 --- /dev/null +++ b/Assets/Scripts/Util/ColorManipulation.cs @@ -0,0 +1,6 @@ +using UnityEngine; + +public static class ColorManipulation +{ + public static Color GetRandomColor() => new(Random.value, Random.value, Random.value); +} \ No newline at end of file diff --git a/Assets/Scripts/Util/ColorManipulation.cs.meta b/Assets/Scripts/Util/ColorManipulation.cs.meta new file mode 100644 index 0000000..7b3d59a --- /dev/null +++ b/Assets/Scripts/Util/ColorManipulation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5c5b7d3af1f171c46b09250081a08927 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: