diff --git a/Assets/_Scenes/Level-1.unity b/Assets/_Scenes/Level-1.unity index dc2124504d5164d02fb32c3d9f964a93c800bd4c..452d730947ed09f35d95fa26e8e0d38495c61b7c 100644 --- a/Assets/_Scenes/Level-1.unity +++ b/Assets/_Scenes/Level-1.unity @@ -1435,7 +1435,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48070 + surfaceParameter: 50828 meshQueryIndex: 2 subMeshQueryIndex: 0 geometryHashValue: 7492658120593371510 @@ -2239,7 +2239,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48800 + surfaceParameter: 51768 meshQueryIndex: 7 subMeshQueryIndex: 0 geometryHashValue: -3903635759205392269 @@ -2356,7 +2356,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48352 + surfaceParameter: 49572 meshQueryIndex: 10 subMeshQueryIndex: 0 geometryHashValue: 4964005172828069971 @@ -6147,102 +6147,6 @@ MonoBehaviour: - EdgeIndices: 14000000150000001600000017000000 TexGenIndex: 5 Generation: 102 ---- !u!1 &350155936 -GameObject: - m_ObjectHideFlags: 17 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 350155939} - - component: {fileID: 350155938} - - component: {fileID: 350155937} - m_Layer: 0 - m_Name: '[default-CSGModel]' - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 124 - m_IsActive: 1 ---- !u!54 &350155937 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 350155936} - serializedVersion: 4 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_CenterOfMass: {x: 0, y: 0, z: 0} - m_InertiaTensor: {x: 1, y: 1, z: 1} - m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} - m_IncludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ExcludeLayers: - serializedVersion: 2 - m_Bits: 0 - m_ImplicitCom: 1 - m_ImplicitTensor: 1 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 126 - m_CollisionDetection: 0 ---- !u!114 &350155938 -MonoBehaviour: - m_ObjectHideFlags: 17 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 350155936} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8672dcc90e16b0a489a41edf56e016f8, type: 3} - m_Name: - m_EditorClassIdentifier: - PrefabBehaviour: 0 - PrefabSourceAlignment: 4 - PrefabDestinationAlignment: 0 - Version: 1.1 - infiniteBrush: {fileID: 0} - Settings: 1025 - VertexChannels: 14 - ReceiveGI: 2 - MeshColliderCookingOptions: 14 - ShowGeneratedMeshes: 0 - DefaultPhysicsMaterial: {fileID: 13400000, guid: 0c5fdfb44d6f19646a41a0720fbf751a, type: 2} - exportType: 0 - originType: 0 - exportColliders: 0 - exportPath: - angleError: 1 - areaError: 1 - hardAngle: 60 - packMargin: 20 - scaleInLightmap: 1 - autoUVMaxDistance: 0.5 - autoUVMaxAngle: 89 - minimumChartSize: 4 ---- !u!4 &350155939 -Transform: - m_ObjectHideFlags: 17 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 350155936} - 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: 1055458805} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &354420147 GameObject: m_ObjectHideFlags: 0 @@ -6283,8 +6187,6 @@ MonoBehaviour: storyData: events: [] progress: - statisticsData: - enemiesKilled: 0 --- !u!4 &354420149 Transform: m_ObjectHideFlags: 0 @@ -6822,113 +6724,6 @@ MonoBehaviour: - EdgeIndices: 07000000060000000500000004000000 TexGenIndex: 5 Generation: 2 ---- !u!1 &440287449 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 440287453} - - component: {fileID: 440287452} - - component: {fileID: 440287451} - - component: {fileID: 440287450} - m_Layer: 0 - m_Name: Cube - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!65 &440287450 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 440287449} - 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, z: 0} ---- !u!23 &440287451 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 440287449} - 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_RayTracingAccelStructBuildFlagsOverride: 0 - m_RayTracingAccelStructBuildFlags: 1 - 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!33 &440287452 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 440287449} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &440287453 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 440287449} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.38413328, y: 0.731027, z: -0.5519944} - m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &447968708 GameObject: m_ObjectHideFlags: 0 @@ -10464,7 +10259,7 @@ MonoBehaviour: meshQuery: layers: 33554440 maskAndChannels: 8 - surfaceParameter: 48638 + surfaceParameter: 51096 meshQueryIndex: 3 subMeshQueryIndex: 0 geometryHashValue: -4918844872027614375 @@ -17145,53 +16940,6 @@ MonoBehaviour: - EdgeIndices: 14000000150000001600000017000000 TexGenIndex: 5 Generation: 103 ---- !u!1 &1055458804 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1055458805} - - component: {fileID: 1055458806} - m_Layer: 0 - m_Name: '[generated-meshes]' - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1055458805 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1055458804} - 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: 350155939} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1055458806 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1055458804} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5c3643d4978096d4880d7edbf4f65a50, type: 3} - m_Name: - m_EditorClassIdentifier: - Version: 1 - owner: {fileID: 350155938} - helperSurfaces: [] --- !u!1 &1058284600 GameObject: m_ObjectHideFlags: 0 @@ -24562,7 +24310,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48702 + surfaceParameter: 50448 meshQueryIndex: 0 subMeshQueryIndex: 0 geometryHashValue: -6651895931905097050 @@ -28055,6 +27803,53 @@ MonoBehaviour: - EdgeIndices: 14000000150000001600000017000000 TexGenIndex: 5 Generation: 33 +--- !u!1 &1335415072 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1335415073} + - component: {fileID: 1335415074} + m_Layer: 0 + m_Name: '[generated-meshes]' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1335415073 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1335415072} + 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: 2032356636} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1335415074 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1335415072} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5c3643d4978096d4880d7edbf4f65a50, type: 3} + m_Name: + m_EditorClassIdentifier: + Version: 1 + owner: {fileID: 2032356635} + helperSurfaces: [] --- !u!1 &1419645566 GameObject: m_ObjectHideFlags: 0 @@ -29206,7 +29001,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48216 + surfaceParameter: 49944 meshQueryIndex: 11 subMeshQueryIndex: 0 geometryHashValue: 764308404911602976 @@ -29323,7 +29118,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48224 + surfaceParameter: 51458 meshQueryIndex: 13 subMeshQueryIndex: 0 geometryHashValue: 2108131890784662871 @@ -29440,7 +29235,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48744 + surfaceParameter: 49494 meshQueryIndex: 8 subMeshQueryIndex: 0 geometryHashValue: 6305151497879606268 @@ -29952,7 +29747,7 @@ MonoBehaviour: meshQuery: layers: 33554440 maskAndChannels: 8 - surfaceParameter: 48638 + surfaceParameter: 51096 meshQueryIndex: 3 subMeshQueryIndex: 0 geometryHashValue: -4918844872027614375 @@ -30905,7 +30700,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48582 + surfaceParameter: 50152 meshQueryIndex: 1 subMeshQueryIndex: 0 geometryHashValue: -2686321270799861702 @@ -33965,6 +33760,54 @@ MonoBehaviour: - EdgeIndices: 14000000150000001600000017000000 TexGenIndex: 5 Generation: 4 +--- !u!1 &1815034046 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1815034048} + - component: {fileID: 1815034047} + m_Layer: 0 + m_Name: GameStatistics + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1815034047 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1815034046} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 699af7536f1e4c5584c4d74309a3eea3, type: 3} + m_Name: + m_EditorClassIdentifier: + enemiesKilled: 0 + shotsFired: 0 + shotsHit: 0 + playtime: 0 +--- !u!4 &1815034048 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1815034046} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -2.2181702, y: -0.7429848, z: 6.3747277} + 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 &1819086314 GameObject: m_ObjectHideFlags: 0 @@ -34753,7 +34596,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48668 + surfaceParameter: 50142 meshQueryIndex: 9 subMeshQueryIndex: 0 geometryHashValue: 1105880644623963868 @@ -34914,7 +34757,7 @@ MonoBehaviour: meshQuery: layers: 16777223 maskAndChannels: 234881031 - surfaceParameter: 48962 + surfaceParameter: 51320 meshQueryIndex: 12 subMeshQueryIndex: 0 geometryHashValue: -7033192528700183668 @@ -36874,6 +36717,102 @@ MonoBehaviour: - EdgeIndices: 07000000060000000500000004000000 TexGenIndex: 5 Generation: 65 +--- !u!1 &2032356633 +GameObject: + m_ObjectHideFlags: 17 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2032356636} + - component: {fileID: 2032356635} + - component: {fileID: 2032356634} + m_Layer: 0 + m_Name: '[default-CSGModel]' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 124 + m_IsActive: 1 +--- !u!54 &2032356634 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2032356633} + serializedVersion: 4 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_CenterOfMass: {x: 0, y: 0, z: 0} + m_InertiaTensor: {x: 1, y: 1, z: 1} + m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ImplicitCom: 1 + m_ImplicitTensor: 1 + m_UseGravity: 0 + m_IsKinematic: 1 + m_Interpolate: 0 + m_Constraints: 126 + m_CollisionDetection: 0 +--- !u!114 &2032356635 +MonoBehaviour: + m_ObjectHideFlags: 17 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2032356633} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8672dcc90e16b0a489a41edf56e016f8, type: 3} + m_Name: + m_EditorClassIdentifier: + PrefabBehaviour: 0 + PrefabSourceAlignment: 4 + PrefabDestinationAlignment: 0 + Version: 1.1 + infiniteBrush: {fileID: 0} + Settings: 1025 + VertexChannels: 14 + ReceiveGI: 2 + MeshColliderCookingOptions: 14 + ShowGeneratedMeshes: 0 + DefaultPhysicsMaterial: {fileID: 13400000, guid: 0c5fdfb44d6f19646a41a0720fbf751a, type: 2} + exportType: 0 + originType: 0 + exportColliders: 0 + exportPath: + angleError: 1 + areaError: 1 + hardAngle: 60 + packMargin: 20 + scaleInLightmap: 1 + autoUVMaxDistance: 0.5 + autoUVMaxAngle: 89 + minimumChartSize: 4 +--- !u!4 &2032356636 +Transform: + m_ObjectHideFlags: 17 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2032356633} + 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: 1335415073} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2032377795 GameObject: m_ObjectHideFlags: 0 @@ -38188,5 +38127,5 @@ SceneRoots: - {fileID: 1899092101} - {fileID: 1298502551} - {fileID: 1607743606} - - {fileID: 440287453} - - {fileID: 350155939} + - {fileID: 1815034048} + - {fileID: 2032356636} diff --git a/Assets/_Scripts/Core/Game/Data/Currency/CurrencyData.cs b/Assets/_Scripts/Core/Game/Data/Currency/CurrencyData.cs index 09b5ee4db6eaed98474b982e87af989b3895eb0c..c1e1674f0ab39a0ef1fee0513f13478760274e77 100644 --- a/Assets/_Scripts/Core/Game/Data/Currency/CurrencyData.cs +++ b/Assets/_Scripts/Core/Game/Data/Currency/CurrencyData.cs @@ -14,7 +14,7 @@ namespace _Scripts.Core.Game.Data.Currency public String description; } - public int balance; + public int balance = 100; public List<Transaction> transactions = new(); public void AddTransaction(int amount, string description) diff --git a/Assets/_Scripts/Core/Game/Data/GameSaveData.cs b/Assets/_Scripts/Core/Game/Data/GameSaveData.cs index 28ec75396bde44b5313b14f31a712aadcbb5577b..840aba8f67b6f3c676edc5aa1224a890539621e7 100644 --- a/Assets/_Scripts/Core/Game/Data/GameSaveData.cs +++ b/Assets/_Scripts/Core/Game/Data/GameSaveData.cs @@ -3,84 +3,81 @@ using System.Collections.Generic; using System.IO; using _Scripts.Core.Game.Data.Currency; using _Scripts.Core.Game.Data.Position; -using _Scripts.Core.Game.Data.Statistics; using _Scripts.Core.Game.Data.Story; -using Unity.VisualScripting; using UnityEngine; -using UnityEngine.Serialization; -public class GameSaveData : MonoBehaviour +namespace _Scripts.Core.Game.Data { - // Static Instance - public static GameSaveData Instance; - - // Attributes - public DifficultyType difficulty = DifficultyType.NORMAL; - public List<string> events = new(); - // Save the currency of the player - public CurrencyData currencyData = new(); - // Save the position and the level of the player - public PositionData positionData = new(); - // Save the story state of the player - public StoryData storyData; - public StatisticsData statisticsData = new(); - - // Constructor - private void Awake() + public class GameSaveData : MonoBehaviour { - Instance = this; - storyData = new StoryData(events); - DontDestroyOnLoad(gameObject); - } + // Static Instance + public static GameSaveData Instance; - public void SaveGame() - { - GameDataWrapper wrapper = new GameDataWrapper + // Attributes + public DifficultyType difficulty = DifficultyType.NORMAL; + public List<string> events = new(); + // Save the currency of the player + public CurrencyData currencyData = new(); + // Save the position and the level of the player + public PositionData positionData = new(); + // Save the story state of the player + public StoryData storyData; + + // Constructor + private void Awake() { - difficulty = this.difficulty, - events = this.events, - currencyData = this.currencyData, - positionData = this.positionData, - storyData = this.storyData, - statisticsData = this.statisticsData - }; - - string json = JsonUtility.ToJson(wrapper, true); - File.WriteAllText(Application.persistentDataPath + "/savegame.json", json); - Debug.Log("Game saved to " + Application.persistentDataPath + "/savegame.json"); - } + Instance = this; + storyData = new StoryData(events); + DontDestroyOnLoad(gameObject); + } - public void LoadGame() - { - string path = Application.persistentDataPath + "/savegame.json"; - if (File.Exists(path)) + public void SaveGame() { - string json = File.ReadAllText(path); - GameDataWrapper wrapper = JsonUtility.FromJson<GameDataWrapper>(json); + GameDataWrapper wrapper = new GameDataWrapper + { + difficulty = this.difficulty, + events = this.events, + currencyData = this.currencyData, + positionData = this.positionData, + storyData = this.storyData, + }; - this.difficulty = wrapper.difficulty; - this.events = wrapper.events; - this.currencyData = wrapper.currencyData; - this.positionData = wrapper.positionData; - this.storyData = wrapper.storyData; - this.statisticsData = wrapper.statisticsData; - Debug.Log("Game loaded from " + path); + string json = JsonUtility.ToJson(wrapper, true); + File.WriteAllText(Application.persistentDataPath + "/savegame.json", json); + Debug.Log("Game saved to " + Application.persistentDataPath + "/savegame.json"); } - else + + public void LoadGame() { - Debug.LogError("Save file not found in " + path); + string path = Application.persistentDataPath + "/savegame.json"; + if (File.Exists(path)) + { + string json = File.ReadAllText(path); + GameDataWrapper wrapper = JsonUtility.FromJson<GameDataWrapper>(json); + + this.difficulty = wrapper.difficulty; + this.events = wrapper.events; + this.currencyData = wrapper.currencyData; + this.positionData = wrapper.positionData; + this.storyData = wrapper.storyData; + Debug.Log("Game loaded from " + path); + } + else + { + Debug.LogError("Save file not found in " + path); + } } - } -} -[Serializable] -public class GameDataWrapper -{ - public DifficultyType difficulty; - public List<String> events; - public CurrencyData currencyData; - public PositionData positionData; - public StoryData storyData; - public StatisticsData statisticsData; -} + } + + [Serializable] + public class GameDataWrapper + { + public DifficultyType difficulty; + public List<String> events; + public CurrencyData currencyData; + public PositionData positionData; + public StoryData storyData; + } +} \ No newline at end of file diff --git a/Assets/_Scripts/Core/Game/Data/GameStatistics.cs b/Assets/_Scripts/Core/Game/Data/GameStatistics.cs new file mode 100644 index 0000000000000000000000000000000000000000..f084c0eb54dcd87298252bb612a0f21de4e8117b --- /dev/null +++ b/Assets/_Scripts/Core/Game/Data/GameStatistics.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.Serialization; + +namespace _Scripts.Core.Game.Data +{ + [Serializable] + public class GameStatistics : MonoBehaviour + { + // Static Instance + public static GameStatistics Instance; + + // Saved + public int enemiesKilled = 0; + // Helper for Accuracy + public int shotsFired = 0; + + public int shotsHit = 0; + // Saved + public float Accuracy => shotsFired > 0 ? (float)shotsHit / shotsFired * 100 : 0; + + public int DistanceTraveled { get; set; } + // Helper for PlaytimeFormatted + public int playtime = 0; + private int _playTimeHour; + private int _playTimeMinute; + private int _playTimeSecond; + // Saved + public string PlaytimeFormatted + { + get => $"{_playTimeHour:D2}:{_playTimeMinute:D2}:{_playTimeSecond:D2}"; + set + { + if (TimeSpan.TryParse(value, out TimeSpan result)) + { + playtime = (int)result.TotalSeconds; + _playTimeHour = result.Hours + result.Days * 24; + _playTimeMinute = result.Minutes; + _playTimeSecond = result.Seconds; + } + } + } + + public int SkillsUsed { get; set; } + public int ObjectsInteracted { get; set; } + public int PetsOwned { get; set; } + + // Constructor + private void Awake() + { + if (Instance == null) + { + Instance = this; + DontDestroyOnLoad(gameObject); + } + else + { + Destroy(gameObject); + } + } + + private void Start() + { + StartCoroutine(RecordTimeRoutine()); + } + + public void AddEnemiesKilled() + { + enemiesKilled++; + } + + public void AddShotsFired() + { + shotsFired++; + } + + public void AddDistanceTraveled() + { + DistanceTraveled++; + } + + public void AddSkillsUsed() + { + SkillsUsed++; + } + + public void AddObjectsInteracted() + { + ObjectsInteracted++; + } + + public void AddPetsOwned() + { + PetsOwned++; + } + + public void Load(string json) + { + GameStatistics data = JsonUtility.FromJson<GameStatistics>(json); + if (data != null) + { + enemiesKilled = data.enemiesKilled; + shotsFired = data.shotsFired; + shotsHit = data.shotsHit; + DistanceTraveled = data.DistanceTraveled; + PlaytimeFormatted = data.PlaytimeFormatted; + SkillsUsed = data.SkillsUsed; + } + } + + public string SaveToJson() + { + return JsonUtility.ToJson(this); + } + + public IEnumerator RecordTimeRoutine() + { + TimeSpan ts; + while (true) + { + yield return new WaitForSeconds(1); + playtime += 1; + ts = TimeSpan.FromSeconds(playtime); + _playTimeHour = (int)ts.TotalHours; + _playTimeMinute = ts.Minutes; + _playTimeSecond = ts.Seconds; + } + } + } +} \ No newline at end of file diff --git a/Assets/_Scripts/Core/Game/Data/Statistics/StatisticsData.cs.meta b/Assets/_Scripts/Core/Game/Data/GameStatistics.cs.meta similarity index 100% rename from Assets/_Scripts/Core/Game/Data/Statistics/StatisticsData.cs.meta rename to Assets/_Scripts/Core/Game/Data/GameStatistics.cs.meta diff --git a/Assets/_Scripts/Core/Game/Data/Statistics.meta b/Assets/_Scripts/Core/Game/Data/Statistics.meta deleted file mode 100644 index 71f65bd01f223f83ba89129d0cc05a636d219641..0000000000000000000000000000000000000000 --- a/Assets/_Scripts/Core/Game/Data/Statistics.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4479f1739fe8476aa8170ea9ad5a7feb -timeCreated: 1713929215 \ No newline at end of file diff --git a/Assets/_Scripts/Core/Game/Data/Statistics/StatisticsData.cs b/Assets/_Scripts/Core/Game/Data/Statistics/StatisticsData.cs deleted file mode 100644 index 5fb9cbe1e08da675aaba4e3dc623d21a814fcdc2..0000000000000000000000000000000000000000 --- a/Assets/_Scripts/Core/Game/Data/Statistics/StatisticsData.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using UnityEngine; - -namespace _Scripts.Core.Game.Data.Statistics -{ - [Serializable] - public class StatisticsData - { - public int enemiesKilled = 0; - public void Load(string json) - { - StatisticsData data = JsonUtility.FromJson<StatisticsData>(json); - if (data != null) - { - enemiesKilled = data.enemiesKilled; - } - } - - public string SaveToJson() - { - return JsonUtility.ToJson(this); - } - } -} \ No newline at end of file diff --git a/Assets/_Scripts/Core/Game/GameController.cs b/Assets/_Scripts/Core/Game/GameController.cs index 07e72f810a91db94303d687eddb33e99ff7c80fb..ef1b44b491f284b33494a220d15bd89ae65674b9 100644 --- a/Assets/_Scripts/Core/Game/GameController.cs +++ b/Assets/_Scripts/Core/Game/GameController.cs @@ -1,4 +1,6 @@ using System; +using System.Collections; +using _Scripts.Core.Game.Data; using UnityEngine; public class GameController : MonoBehaviour