From 5bcc96a4a01ffc309932c0a8cdc7e58500cb9e8a Mon Sep 17 00:00:00 2001 From: Khauvinkh Date: Sun, 18 Aug 2024 18:42:01 +0200 Subject: [PATCH] Scoring and stuff. --- Assets/Audio/Scanner.meta | 8 + .../Scanner/scanner_not-an-item.wav.meta | 23 ++ Assets/Audio/Scanner/scanner_scan.wav.meta | 23 ++ Assets/Data/Objectives.meta | 8 + Assets/Data/Objectives/Level 1.asset | 22 ++ Assets/Data/Objectives/Level 1.asset.meta | 8 + .../Prefabs/Conveyor/Product Receiver.prefab | 264 +++++++++++++++++- Assets/Scenes/Main.unity | 66 ++++- .../Scripts/Game Schedule/LevelObjective.cs | 31 ++ .../Game Schedule/LevelObjective.cs.meta | 3 + Assets/Scripts/Game Schedule/Scoreboard.cs | 115 ++++++++ .../Scripts/Game Schedule/Scoreboard.cs.meta | 3 + .../Scripts/Game Schedule/StagingManager.cs | 8 +- Assets/Scripts/Grid Units/Grid.cs | 1 - Assets/Scripts/Grid Units/GridUnit.cs | 32 +-- Assets/Scripts/Machines/ProductReceiver.cs | 9 +- ProjectSettings/EditorBuildSettings.asset | 5 +- 17 files changed, 587 insertions(+), 42 deletions(-) create mode 100644 Assets/Audio/Scanner.meta create mode 100644 Assets/Audio/Scanner/scanner_not-an-item.wav.meta create mode 100644 Assets/Audio/Scanner/scanner_scan.wav.meta create mode 100644 Assets/Data/Objectives.meta create mode 100644 Assets/Data/Objectives/Level 1.asset create mode 100644 Assets/Data/Objectives/Level 1.asset.meta create mode 100644 Assets/Scripts/Game Schedule/LevelObjective.cs create mode 100644 Assets/Scripts/Game Schedule/LevelObjective.cs.meta create mode 100644 Assets/Scripts/Game Schedule/Scoreboard.cs create mode 100644 Assets/Scripts/Game Schedule/Scoreboard.cs.meta diff --git a/Assets/Audio/Scanner.meta b/Assets/Audio/Scanner.meta new file mode 100644 index 0000000..078eacb --- /dev/null +++ b/Assets/Audio/Scanner.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e7e8ae76ff1c5b4aab543fbaebcbac6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Scanner/scanner_not-an-item.wav.meta b/Assets/Audio/Scanner/scanner_not-an-item.wav.meta new file mode 100644 index 0000000..166a35e --- /dev/null +++ b/Assets/Audio/Scanner/scanner_not-an-item.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 8c21db8e71083614d9ac3d0a2806ea4e +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Audio/Scanner/scanner_scan.wav.meta b/Assets/Audio/Scanner/scanner_scan.wav.meta new file mode 100644 index 0000000..30a222f --- /dev/null +++ b/Assets/Audio/Scanner/scanner_scan.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: cf1261045ab6d8242adafc4270a58783 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Objectives.meta b/Assets/Data/Objectives.meta new file mode 100644 index 0000000..96de23d --- /dev/null +++ b/Assets/Data/Objectives.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 92b52ec8a69551746943394b818ffeb8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Data/Objectives/Level 1.asset b/Assets/Data/Objectives/Level 1.asset new file mode 100644 index 0000000..ab1b070 --- /dev/null +++ b/Assets/Data/Objectives/Level 1.asset @@ -0,0 +1,22 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + 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: 65221132d7bd4e79856cce65eeb5ce58, type: 3} + m_Name: Level 1 + m_EditorClassIdentifier: + Stage: 1 + Quotas: + - Type: {fileID: 11400000, guid: 42240b227563f074aa0dd8fee3c0cb35, type: 2} + Quantity: 10 + TimeLimit: 60 + MaxDefectivePercentage: 100 + SuccessMessage: Great job! + FailureMessage: Try again! diff --git a/Assets/Data/Objectives/Level 1.asset.meta b/Assets/Data/Objectives/Level 1.asset.meta new file mode 100644 index 0000000..c29c1c4 --- /dev/null +++ b/Assets/Data/Objectives/Level 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b1326e0e514393547971198daa612d49 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Conveyor/Product Receiver.prefab b/Assets/Prefabs/Conveyor/Product Receiver.prefab index 8fe06a0..c554ff5 100644 --- a/Assets/Prefabs/Conveyor/Product Receiver.prefab +++ b/Assets/Prefabs/Conveyor/Product Receiver.prefab @@ -1,5 +1,88 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &2691121107702918304 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6124643934757847502} + - component: {fileID: 1803345453588852622} + - component: {fileID: 2049186239399771702} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6124643934757847502 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2691121107702918304} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.75, y: 0.1875, z: -1.125} + m_LocalScale: {x: 2.75, y: 1.625, z: 0.25} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6238139087991197689} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &1803345453588852622 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2691121107702918304} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2049186239399771702 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2691121107702918304} + 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: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &3300142079730169062 GameObject: m_ObjectHideFlags: 0 @@ -97,6 +180,89 @@ MonoBehaviour: x: 0 y: 0 z: 0 +--- !u!1 &4146203376468199520 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4748086957800454890} + - component: {fileID: 7569872471742462254} + - component: {fileID: 2056203298572318800} + m_Layer: 0 + m_Name: Cube (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4748086957800454890 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4146203376468199520} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.8125, y: 0.1875, z: 0} + m_LocalScale: {x: 0.3751, y: 1.625, z: 2} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6238139087991197689} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &7569872471742462254 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4146203376468199520} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2056203298572318800 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4146203376468199520} + 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: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &5578451197856738425 GameObject: m_ObjectHideFlags: 0 @@ -128,6 +294,9 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 29782541997105855} + - {fileID: 6124643934757847502} + - {fileID: 4748086957800454890} + - {fileID: 7524344916720894899} - {fileID: 1037217556386504287} - {fileID: 8893193092501905694} m_Father: {fileID: 0} @@ -160,6 +329,89 @@ MonoBehaviour: x: 0 y: 0 z: 0 +--- !u!1 &8709015778225462089 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7524344916720894899} + - component: {fileID: 1582601958366311740} + - component: {fileID: 3143886536820141369} + m_Layer: 0 + m_Name: Cube (3) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7524344916720894899 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8709015778225462089} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.5625, y: 1.1110001, z: 0} + m_LocalScale: {x: 3.125108, y: 0.25, z: 2} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6238139087991197689} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &1582601958366311740 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8709015778225462089} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &3143886536820141369 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8709015778225462089} + 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: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &9029570661290360059 GameObject: m_ObjectHideFlags: 0 @@ -187,8 +439,8 @@ Transform: m_GameObject: {fileID: 9029570661290360059} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.75, y: 0, z: 0} - m_LocalScale: {x: 2.75, y: 1.25, z: 1.25} + m_LocalPosition: {x: 0.75, y: 0.1875, z: 1.125} + m_LocalScale: {x: 2.75, y: 1.625, z: 0.25} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 6238139087991197689} @@ -261,19 +513,19 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3} propertyPath: m_LocalScale.y - value: 0.75 + value: 0.6961451 objectReference: {fileID: 0} - target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3} propertyPath: m_LocalPosition.x - value: 2.3000002 + value: 2.078 objectReference: {fileID: 0} - target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3} propertyPath: m_LocalPosition.y - value: 0.318 + value: 0.26 objectReference: {fileID: 0} - target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3} propertyPath: m_LocalPosition.z - value: -0.020006057 + value: -0.02 objectReference: {fileID: 0} - target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3} propertyPath: m_LocalRotation.w diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index cfba4f0..04755f2 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -144,7 +144,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3} propertyPath: m_LocalPosition.x - value: -1.875 + value: -0.875 objectReference: {fileID: 0} - target: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3} propertyPath: m_LocalPosition.y @@ -826,6 +826,52 @@ MonoBehaviour: throwKey: 102 examineKey: 101 placeKey: 116 +--- !u!1 &721670237 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 721670239} + - component: {fileID: 721670238} + m_Layer: 0 + m_Name: Scoreboard + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &721670238 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 721670237} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 49f7d9fae60a4082a271f0a2fa185f79, type: 3} + m_Name: + m_EditorClassIdentifier: + CurrentObjective: {fileID: 11400000, guid: b1326e0e514393547971198daa612d49, type: 2} + _timeLeft: 0 +--- !u!4 &721670239 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 721670237} + 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 &969068469 GameObject: m_ObjectHideFlags: 0 @@ -1412,6 +1458,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 892330fb84d24d79b298b2fa65e8e92f, type: 3} m_Name: m_EditorClassIdentifier: + Objectives: [] CurrentStage: 0 --- !u!4 &1503113266 Transform: @@ -1597,7 +1644,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3} propertyPath: m_LocalPosition.x - value: -1.875 + value: -0.875 objectReference: {fileID: 0} - target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3} propertyPath: m_LocalPosition.y @@ -1670,7 +1717,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3} propertyPath: m_LocalPosition.x - value: -1.875 + value: -0.875 objectReference: {fileID: 0} - target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3} propertyPath: m_LocalPosition.y @@ -1815,10 +1862,6 @@ PrefabInstance: propertyPath: m_Name value: Product Receiver objectReference: {fileID: 0} - - target: {fileID: 5578451197856738425, guid: b5bb2f074e9e2c04baf833ea6393a1f6, type: 3} - propertyPath: m_IsActive - value: 0 - objectReference: {fileID: 0} - target: {fileID: 6238139087991197689, guid: b5bb2f074e9e2c04baf833ea6393a1f6, type: 3} propertyPath: m_LocalPosition.x value: -6.5 @@ -1876,6 +1919,14 @@ PrefabInstance: propertyPath: m_Name value: Product Spawner objectReference: {fileID: 0} + - target: {fileID: 6186656074767359943, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3} + propertyPath: ProductionPhases.Array.data[0].Duration + value: 40 + objectReference: {fileID: 0} + - target: {fileID: 6186656074767359943, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3} + propertyPath: ProductionPhases.Array.data[0].TotalSpawnCount + value: 15 + objectReference: {fileID: 0} - target: {fileID: 9072778288000056937, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3} propertyPath: m_LocalPosition.x value: 3.25 @@ -1938,3 +1989,4 @@ SceneRoots: - {fileID: 24716034} - {fileID: 1736605487} - {fileID: 164936391} + - {fileID: 721670239} diff --git a/Assets/Scripts/Game Schedule/LevelObjective.cs b/Assets/Scripts/Game Schedule/LevelObjective.cs new file mode 100644 index 0000000..d91dcd5 --- /dev/null +++ b/Assets/Scripts/Game Schedule/LevelObjective.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +[CreateAssetMenu(fileName = "New Level Objective", menuName = "Data/Level Objective", order = 0)] +public class LevelObjective : ScriptableObject +{ + public StagingManager.StageEnum Stage; + + [Serializable] + public struct ProductQuota + { + public ProductType Type; + public int Quantity; + } + + public List Quotas; + + public float TimeLimit; + + [Range(0, 100)] + public int MaxDefectivePercentage; + + [TextArea] + public string SuccessMessage; + + [TextArea] + public string FailureMessage; + +} \ No newline at end of file diff --git a/Assets/Scripts/Game Schedule/LevelObjective.cs.meta b/Assets/Scripts/Game Schedule/LevelObjective.cs.meta new file mode 100644 index 0000000..63e1e9d --- /dev/null +++ b/Assets/Scripts/Game Schedule/LevelObjective.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 65221132d7bd4e79856cce65eeb5ce58 +timeCreated: 1723996942 \ No newline at end of file diff --git a/Assets/Scripts/Game Schedule/Scoreboard.cs b/Assets/Scripts/Game Schedule/Scoreboard.cs new file mode 100644 index 0000000..93c3c3e --- /dev/null +++ b/Assets/Scripts/Game Schedule/Scoreboard.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class Scoreboard: MonoBehaviour +{ + public static Scoreboard Instance; + public LevelObjective CurrentObjective; + + public Dictionary ProductCounts = new (); + + public float _timeLeft; + public bool _running; + + public void Start() + { + if (!Instance) + { + Instance = this; + } + + _running = true; + SetObjective(CurrentObjective); + } + + public void SetObjective(LevelObjective objective) + { + CurrentObjective = objective; + + ProductCounts = new(); + + _timeLeft = objective.TimeLimit; + } + + public void ScoreProduct(Product product) + { + if (!ProductCounts.ContainsKey(product.Type)) + { + ProductCounts[product.Type] = new Vector2Int(); + } + + var currentCount = ProductCounts[product.Type]; + + if (product.Defect == DefectType.None) + { + currentCount.x++; + } + else + { + currentCount.y++; + } + + ProductCounts[product.Type] = currentCount; + } + + private int TotalCount(ProductType type) + { + return ProductCounts[type].x + ProductCounts[type].y; + } + + private int DefectPercentage(ProductType type) + { + if (TotalCount(type) == 0) + { + return 0; + } + + return 100 * ProductCounts[type].y / TotalCount(type); + } + + private void Update() + { + if (!_running) + { + return; + } + + _timeLeft -= Time.deltaTime; + Debug.Log(_timeLeft); + + if (_timeLeft <= 0) + { + CountScores(); + _running = false; + } + } + + public void CountScores() + { + bool success = true; + + foreach (var quota in CurrentObjective.Quotas) + { + if (quota.Quantity > TotalCount(quota.Type)) + { + success = false; + Debug.LogError($"Not enough {quota.Type.name}"); + break; + } + + Debug.Log($"{quota.Type.name}: {TotalCount(quota.Type)}/{quota.Quantity}"); + + if (CurrentObjective.MaxDefectivePercentage < DefectPercentage(quota.Type)) + { + success = false; + Debug.LogError($"Too many broken {quota.Type.name}"); + break; + } + + Debug.Log($"{quota.Type.name}: Quality level: {DefectPercentage(quota.Type)}%"); + } + + Debug.Log(success? CurrentObjective.SuccessMessage : CurrentObjective.FailureMessage); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Game Schedule/Scoreboard.cs.meta b/Assets/Scripts/Game Schedule/Scoreboard.cs.meta new file mode 100644 index 0000000..0ea2159 --- /dev/null +++ b/Assets/Scripts/Game Schedule/Scoreboard.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 49f7d9fae60a4082a271f0a2fa185f79 +timeCreated: 1723996883 \ No newline at end of file diff --git a/Assets/Scripts/Game Schedule/StagingManager.cs b/Assets/Scripts/Game Schedule/StagingManager.cs index ab1d107..ddf2c48 100644 --- a/Assets/Scripts/Game Schedule/StagingManager.cs +++ b/Assets/Scripts/Game Schedule/StagingManager.cs @@ -8,6 +8,8 @@ public class StagingManager: MonoBehaviour public static StagingManager Instance; public static List StageProps; + public List Objectives; + public StageEnum CurrentStage; [Flags] @@ -63,13 +65,17 @@ public class StagingManager: MonoBehaviour } } +#if UNITY_EDITOR [MenuItem("Tools/Staging/Level1")] +#endif public static void SetStage1() { SetStage(StageEnum.Level1); } - + +#if UNITY_EDITOR [MenuItem("Tools/Staging/Level2")] +#endif public static void SetStage2() { SetStage(StageEnum.Level2); diff --git a/Assets/Scripts/Grid Units/Grid.cs b/Assets/Scripts/Grid Units/Grid.cs index 92685c6..20c73cb 100644 --- a/Assets/Scripts/Grid Units/Grid.cs +++ b/Assets/Scripts/Grid Units/Grid.cs @@ -6,7 +6,6 @@ using quaternion = Unity.Mathematics.quaternion; public static class Grid { - public static float CellSize = 0.25f; public static float HalfCellSize => CellSize / 2; diff --git a/Assets/Scripts/Grid Units/GridUnit.cs b/Assets/Scripts/Grid Units/GridUnit.cs index 679c41d..c813ac0 100644 --- a/Assets/Scripts/Grid Units/GridUnit.cs +++ b/Assets/Scripts/Grid Units/GridUnit.cs @@ -5,39 +5,36 @@ using static Unity.Mathematics.math; using static Grid; using Color = UnityEngine.Color; -#if UNITY_EDITOR - [ExecuteAlways] [SelectionBase] [DisallowMultipleComponent] public class GridUnit : MonoBehaviour { - - public int3 Size = new (1, 1, 1); - private Vector3 SizeInMeters => new (Size.x * CellSize, Size.y * CellSize, Size.z * CellSize); - + + public int3 Size = new(1, 1, 1); + private Vector3 SizeInMeters => new(Size.x * CellSize, Size.y * CellSize, Size.z * CellSize); + public float3 CenterOffset; - [SerializeField, HideInInspector] - private int3 cachedSize = new (1, 1, 1); - [SerializeField, HideInInspector] - private float3 cachedOffset; - - private bool isDirty => transform.hasChanged || - !all(cachedOffset != CenterOffset) || + [SerializeField, HideInInspector] private int3 cachedSize = new(1, 1, 1); + [SerializeField, HideInInspector] private float3 cachedOffset; + + private bool isDirty => transform.hasChanged || + !all(cachedOffset != CenterOffset) || !all(cachedSize == Size); +#if UNITY_EDITOR public void Update() { if (!isDirty) { return; } - + SnapUnit(transform, Size, CenterOffset); transform.hasChanged = false; - + cachedOffset = CenterOffset; cachedSize = Size; } @@ -48,11 +45,10 @@ public class GridUnit : MonoBehaviour Transform t = unit.transform; quaternion rotation = t.rotation; var position = (float3)t.position + mul(rotation, unit.CenterOffset); - + Gizmos.color = Color.white; Gizmos.matrix = Matrix4x4.TRS(position, rotation, Vector3.one); Gizmos.DrawWireCube(Vector3.zero, unit.SizeInMeters); } -} - #endif +} diff --git a/Assets/Scripts/Machines/ProductReceiver.cs b/Assets/Scripts/Machines/ProductReceiver.cs index 7c71da9..5f15da4 100644 --- a/Assets/Scripts/Machines/ProductReceiver.cs +++ b/Assets/Scripts/Machines/ProductReceiver.cs @@ -15,14 +15,7 @@ public class ProductReceiver : MonoBehaviour if (product != null) { - if (product.Defect != DefectType.None) - { - defectiveProductCount++; - } - else - { - normalProductCount++; - } + Scoreboard.Instance.ScoreProduct(product); Destroy(product.gameObject); } diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 0147887..6eb4c59 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -4,5 +4,8 @@ EditorBuildSettings: m_ObjectHideFlags: 0 serializedVersion: 2 - m_Scenes: [] + m_Scenes: + - enabled: 1 + path: Assets/Scenes/Main.unity + guid: 12264ad5f5014704f852121ae907d689 m_configObjects: {}