diff --git a/Assets/Data/Objectives/Level 1.asset b/Assets/Data/Objectives/Level 1.asset index efd04c8..4bf77d0 100644 --- a/Assets/Data/Objectives/Level 1.asset +++ b/Assets/Data/Objectives/Level 1.asset @@ -18,5 +18,9 @@ MonoBehaviour: Quantity: 20 TimeLimit: 180 MaxDefectivePercentage: 80 + LevelMessage: 'Welcome, employee! + + Please ensure the quality of our HexaTorus + product.' SuccessMessage: Great job! FailureMessage: Try again! diff --git a/Assets/Prefabs/Trash Bin.prefab b/Assets/Prefabs/Trash Bin.prefab index d1a49f7..d285714 100644 --- a/Assets/Prefabs/Trash Bin.prefab +++ b/Assets/Prefabs/Trash Bin.prefab @@ -169,7 +169,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: -876546973899608171, guid: 2ec19dda799c8744292de0274474475b, type: 3} + - {fileID: 2100000, guid: 241446fb42920fe46b66d2b7e6127c28, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -300,6 +300,7 @@ MonoBehaviour: DoorTransform: {fileID: 6652562342234367164} OpenAnchor: {fileID: 2524347250120916255} ClosedAnchor: {fileID: 6441365300226329974} + destroyClip: {fileID: 8300000, guid: cea05c4bfdbcb8944908f2b214364021, type: 3} --- !u!114 &4182849772416151034 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 796e65f..80c650f 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -3407,6 +3407,112 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 539769830} m_Mesh: {fileID: -5163259039384273826, guid: bdea37ec281a49c45ae34b3c72e5c08d, type: 3} +--- !u!1 &553410429 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 553410430} + - component: {fileID: 553410433} + - component: {fileID: 553410432} + - component: {fileID: 553410431} + m_Layer: 0 + m_Name: Screen + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &553410430 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 553410429} + serializedVersion: 2 + m_LocalRotation: {x: -0.70710576, y: -2.2737368e-13, z: -0, w: 0.70710784} + m_LocalPosition: {x: -0.034988996, y: 6.61, z: 18.79} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 721670239} + m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} +--- !u!64 &553410431 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 553410429} + 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: 5 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &553410432 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 553410429} + 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: 54361f89cfee8b94d810c14a6beb11b5, 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!33 &553410433 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 553410429} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &559891127 GameObject: m_ObjectHideFlags: 0 @@ -4327,6 +4433,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 553410430} - {fileID: 1482407713} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -8021,16 +8128,16 @@ RectTransform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1482407712} - m_LocalRotation: {x: -0, y: -1, z: -0, w: 0.00000058114523} - m_LocalPosition: {x: 0, y: 0, z: -4} + m_LocalRotation: {x: -0, y: -0.0000022947786, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 18.75} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 721670239} - m_LocalEulerAnglesHint: {x: 0, y: -180, z: 0} + 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.000004649162, y: 5.11} + m_AnchoredPosition: {x: -0.034988813, y: 6.61} m_SizeDelta: {x: 10, y: 5} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1482407714 @@ -8621,6 +8728,14 @@ PrefabInstance: propertyPath: m_Name value: Trash Bin objectReference: {fileID: 0} + - target: {fileID: 6154826662665204373, guid: 9a8b6d48785ecc64aa27f072abb69239, type: 3} + propertyPath: destroyClip + value: + objectReference: {fileID: 8300000, guid: cea05c4bfdbcb8944908f2b214364021, type: 3} + - target: {fileID: 6154826662665204373, guid: 9a8b6d48785ecc64aa27f072abb69239, type: 3} + propertyPath: CooldownDuration + value: 2 + objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] diff --git a/Assets/Scripts/Game Schedule/LevelObjective.cs b/Assets/Scripts/Game Schedule/LevelObjective.cs index d91dcd5..6f19df9 100644 --- a/Assets/Scripts/Game Schedule/LevelObjective.cs +++ b/Assets/Scripts/Game Schedule/LevelObjective.cs @@ -22,6 +22,9 @@ public class LevelObjective : ScriptableObject [Range(0, 100)] public int MaxDefectivePercentage; + [TextArea] + public string LevelMessage; + [TextArea] public string SuccessMessage; diff --git a/Assets/Scripts/Game Schedule/Scoreboard.cs b/Assets/Scripts/Game Schedule/Scoreboard.cs index 97e09b8..377636e 100644 --- a/Assets/Scripts/Game Schedule/Scoreboard.cs +++ b/Assets/Scripts/Game Schedule/Scoreboard.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text; using TMPro; using UnityEditor; using UnityEngine; @@ -118,21 +119,32 @@ public class Scoreboard: MonoBehaviour public void UpdateText() { - string text = $"Time left: {Mathf.Floor(_timeLeft)}\n"; + StringBuilder sb = new(); + + int minutes = (int) _timeLeft / 60; + int seconds = (int) _timeLeft % 60; + sb.Append($"Time left: {minutes}:{seconds}\n"); + sb.Append("\n"); + + sb.Append(CurrentObjective.LevelMessage); + + sb.Append("\n"); + sb.Append("\n"); + foreach (var quota in CurrentObjective.Quotas) { if (ProductCounts.ContainsKey(quota.Type)) { - text += $"{quota.Type.name}: {TotalCount(quota.Type)}/{quota.Quantity}\n"; + sb.Append($"{quota.Type.name}: {TotalCount(quota.Type)}/{quota.Quantity}\n"); } else { - text += $"{quota.Type.name}: 0/{quota.Quantity}\n"; + sb.Append($"{quota.Type.name}: 0/{quota.Quantity}\n"); } } - textMesh.text = text; + textMesh.text = sb.ToString(); } public void CountScores() diff --git a/Assets/Scripts/Machines/TrashBin.cs b/Assets/Scripts/Machines/TrashBin.cs index ce09038..e1a0621 100644 --- a/Assets/Scripts/Machines/TrashBin.cs +++ b/Assets/Scripts/Machines/TrashBin.cs @@ -6,7 +6,7 @@ public class TrashBin : MonoBehaviour public float CooldownDuration; private float _cooldownTimer; - private float _incinerationTimer = 1f; + private float _incinerationTimer; public float IncinerationDuration = 1f; public float doorVelocity = 5f; @@ -14,35 +14,33 @@ public class TrashBin : MonoBehaviour public Transform OpenAnchor; public Transform ClosedAnchor; private Vector3 _targetPosition; + + public AudioClip destroyClip; List enteredProducts = new List(); public void Start() { _targetPosition = OpenAnchor.position; + _incinerationTimer = IncinerationDuration; } public void OnTriggerEnter(Collider otherCollider) { - var rb = otherCollider.GetComponentInParent(); + var product = otherCollider.GetComponentInParent(); - if (!rb) + if (product == null) { return; } - - var product = otherCollider.GetComponentInParent(); - if (product) + if (!enteredProducts.Contains(product)) { - if (!enteredProducts.Contains(product)) - { - enteredProducts.Add(product); - } - - _cooldownTimer = CooldownDuration; - _targetPosition = ClosedAnchor.position; + enteredProducts.Add(product); } + + _incinerationTimer = IncinerationDuration; + _targetPosition = ClosedAnchor.position; } public void OnTriggerExit(Collider collider) @@ -65,12 +63,23 @@ public class TrashBin : MonoBehaviour _targetPosition, Time.deltaTime * doorVelocity); - if (_cooldownTimer <= 0) + if (_cooldownTimer > 0) + { + _cooldownTimer -= Time.deltaTime; + + if (_cooldownTimer <= 0) + { + _targetPosition = OpenAnchor.position; + } + + return; + } + + if (enteredProducts.Count == 0) { return; } - _cooldownTimer -= Time.deltaTime; _incinerationTimer -= Time.deltaTime; if (_incinerationTimer <= 0) @@ -81,12 +90,10 @@ public class TrashBin : MonoBehaviour } enteredProducts.Clear(); - _incinerationTimer = IncinerationDuration; - } - - if (_cooldownTimer <= 0) - { - _targetPosition = OpenAnchor.position; + + NAudio.Play(destroyClip, transform.position, 0.33f); + enteredProducts.Clear(); + _cooldownTimer = CooldownDuration; } } } \ No newline at end of file