From 3f66591822b979b0bcda38d2411e9bb3a7bc6328 Mon Sep 17 00:00:00 2001 From: AgentSchmisch Date: Thu, 19 Jun 2025 01:07:40 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Save=20state=20across=20scenes=20&?= =?UTF-8?q?=20finished=20Quest=20interactions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bush_With_Blueberriess.prefab | 18 + blueberryPeak/Assets/Prefabs/Stick.prefab | 2 +- .../Assets/Prefabs/game/StateManager.prefab | 47 ++ .../Prefabs/game/StateManager.prefab.meta | 7 + blueberryPeak/Assets/Scenes/flo_s_scene.unity | 539 ++++++++++-------- blueberryPeak/Assets/Scripts/Audio/Wind.cs | 2 +- .../Assets/Scripts/Player/DialogManager.cs | 10 +- .../Scripts/Player/PlayerInteraction.cs | 45 +- .../Assets/Scripts/Player/TwigInteraction.cs | 12 +- .../Assets/Scripts/Quests/ItemReward.cs | 20 + .../Assets/Scripts/Quests/ItemReward.cs.meta | 2 + .../Assets/Scripts/Quests/QuestGiver.cs | 59 +- blueberryPeak/Assets/Scripts/Quests/Reward.cs | 22 +- .../Quests/Rewards/RequiredTwigs.asset | 16 + .../Quests/Rewards/RequiredTwigs.asset.meta | 8 + .../Scripts/Quests/Rewards/TwigReward.asset | 4 +- .../Quests/Rewards/TwigReward.asset.meta | 2 +- blueberryPeak/Assets/Scripts/SaveData.cs | 78 +++ blueberryPeak/Assets/Scripts/SaveData.cs.meta | 2 + blueberryPeak/Assets/Scripts/Saveable.cs | 185 ++++++ blueberryPeak/Assets/Scripts/Saveable.cs.meta | 2 + blueberryPeak/Assets/Scripts/StateManager.cs | 45 ++ .../Assets/Scripts/StateManager.cs.meta | 2 + 23 files changed, 819 insertions(+), 310 deletions(-) create mode 100644 blueberryPeak/Assets/Prefabs/game/StateManager.prefab create mode 100644 blueberryPeak/Assets/Prefabs/game/StateManager.prefab.meta create mode 100644 blueberryPeak/Assets/Scripts/Quests/ItemReward.cs create mode 100644 blueberryPeak/Assets/Scripts/Quests/ItemReward.cs.meta create mode 100644 blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset create mode 100644 blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset.meta create mode 100644 blueberryPeak/Assets/Scripts/SaveData.cs create mode 100644 blueberryPeak/Assets/Scripts/SaveData.cs.meta create mode 100644 blueberryPeak/Assets/Scripts/Saveable.cs create mode 100644 blueberryPeak/Assets/Scripts/Saveable.cs.meta create mode 100644 blueberryPeak/Assets/Scripts/StateManager.cs create mode 100644 blueberryPeak/Assets/Scripts/StateManager.cs.meta diff --git a/blueberryPeak/Assets/Prefabs/BlueberryBushes/Bush_With_Blueberriess.prefab b/blueberryPeak/Assets/Prefabs/BlueberryBushes/Bush_With_Blueberriess.prefab index 0ac8007..8658774 100644 --- a/blueberryPeak/Assets/Prefabs/BlueberryBushes/Bush_With_Blueberriess.prefab +++ b/blueberryPeak/Assets/Prefabs/BlueberryBushes/Bush_With_Blueberriess.prefab @@ -86,6 +86,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: d17453879435f2149b8e7c5efef8fb4e, type: 3} insertIndex: -1 addedObject: {fileID: 551273734587190997} + - targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: d17453879435f2149b8e7c5efef8fb4e, type: 3} + insertIndex: -1 + addedObject: {fileID: -7050144180352489672} m_SourcePrefab: {fileID: 100100000, guid: d17453879435f2149b8e7c5efef8fb4e, type: 3} --- !u!1 &2630037540465012823 stripped GameObject: @@ -104,6 +107,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9a881c5714daa538f8fa52539a6fc646, type: 3} m_Name: m_EditorClassIdentifier: + blueberryCount: 3 emptyBush: {fileID: 8661470530288400513, guid: fcc8beee856f5484ba1e4466f8aedb46, type: 3} PlayBushesEvent: idInternal: 0 @@ -134,3 +138,17 @@ SphereCollider: serializedVersion: 3 m_Radius: 0.64 m_Center: {x: 0, y: 0.57, z: 0} +--- !u!114 &-7050144180352489672 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2630037540465012823} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1c09e61be8049e4089c30fd8ea36a7f, type: 3} + m_Name: + m_EditorClassIdentifier: + uid: 00ba2dc2-f346-4c3d-bc1f-636adf56082a + type: 1 diff --git a/blueberryPeak/Assets/Prefabs/Stick.prefab b/blueberryPeak/Assets/Prefabs/Stick.prefab index 92b43e1..71b30c9 100644 --- a/blueberryPeak/Assets/Prefabs/Stick.prefab +++ b/blueberryPeak/Assets/Prefabs/Stick.prefab @@ -85,7 +85,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f1c09e61be8049e4089c30fd8ea36a7f, type: 3} m_Name: m_EditorClassIdentifier: - uid: 744b16d2-d1bf-4074-a967-a3c2caf16ecc + uid: 229f30d1-7342-4a11-8746-0139dcbefcab type: 2 --- !u!1001 &2343360094618611992 PrefabInstance: diff --git a/blueberryPeak/Assets/Prefabs/game/StateManager.prefab b/blueberryPeak/Assets/Prefabs/game/StateManager.prefab new file mode 100644 index 0000000..d06439a --- /dev/null +++ b/blueberryPeak/Assets/Prefabs/game/StateManager.prefab @@ -0,0 +1,47 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1469131783969527291 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7089947114587616522} + - component: {fileID: 2746166930782798835} + m_Layer: 0 + m_Name: StateManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7089947114587616522 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1469131783969527291} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 314, y: 45.990005, 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!114 &2746166930782798835 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1469131783969527291} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1583dcf9011d5a142af4d8b1610298df, type: 3} + m_Name: + m_EditorClassIdentifier: + currentSceneIndex: 0 diff --git a/blueberryPeak/Assets/Prefabs/game/StateManager.prefab.meta b/blueberryPeak/Assets/Prefabs/game/StateManager.prefab.meta new file mode 100644 index 0000000..23c673d --- /dev/null +++ b/blueberryPeak/Assets/Prefabs/game/StateManager.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8c34cc63b3722f245be837e67f74992f +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/blueberryPeak/Assets/Scenes/flo_s_scene.unity b/blueberryPeak/Assets/Scenes/flo_s_scene.unity index ff26c1d..574cd15 100644 --- a/blueberryPeak/Assets/Scenes/flo_s_scene.unity +++ b/blueberryPeak/Assets/Scenes/flo_s_scene.unity @@ -1020,63 +1020,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 124528176} m_PrefabAsset: {fileID: 0} ---- !u!1001 &134862462 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalPosition.x - value: 1.432251 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalPosition.y - value: 4.0769615 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalPosition.z - value: -3.753543 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: -8679921383154817045, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 919132149155446097, guid: 67614fa75482f9344bb5c3428398638d, type: 3} - propertyPath: m_Name - value: Fox_House - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 67614fa75482f9344bb5c3428398638d, type: 3} --- !u!1001 &151361210 PrefabInstance: m_ObjectHideFlags: 0 @@ -1935,22 +1878,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 268051631} m_PrefabAsset: {fileID: 0} ---- !u!1 &288744875 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 2030155835593061689, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - m_PrefabInstance: {fileID: 1531267697844782104} - m_PrefabAsset: {fileID: 0} ---- !u!114 &288744880 stripped -MonoBehaviour: - m_CorrespondingSourceObject: {fileID: 6385820191761614647, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - m_PrefabInstance: {fileID: 1531267697844782104} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 288744875} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 82c6be17482ec2847b23775deb9b5ca7, type: 3} - m_Name: - m_EditorClassIdentifier: --- !u!1001 &292597895 PrefabInstance: m_ObjectHideFlags: 0 @@ -2470,15 +2397,15 @@ PrefabInstance: - target: {fileID: 3123357398500628543, guid: 5704dc66b89074156933e2ba70d2d2d7, type: 3} propertyPath: dialogManager value: - objectReference: {fileID: 288744880} + objectReference: {fileID: 0} - target: {fileID: 3123357398500628543, guid: 5704dc66b89074156933e2ba70d2d2d7, type: 3} propertyPath: dialogManagerObject value: - objectReference: {fileID: 288744875} + objectReference: {fileID: 1671044935} - target: {fileID: 3740866600301396226, guid: 5704dc66b89074156933e2ba70d2d2d7, type: 3} propertyPath: cameraTransform value: - objectReference: {fileID: 934616501} + objectReference: {fileID: 1296656953} - target: {fileID: 7563270112099016041, guid: 5704dc66b89074156933e2ba70d2d2d7, type: 3} propertyPath: m_Name value: Luna @@ -3019,6 +2946,11 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 442645533} m_PrefabAsset: {fileID: 0} +--- !u!1 &448660793 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2630037540465012823, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} + m_PrefabInstance: {fileID: 2699808308164711631} + m_PrefabAsset: {fileID: 0} --- !u!1001 &464447489 PrefabInstance: m_ObjectHideFlags: 0 @@ -3749,63 +3681,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 638687327} m_PrefabAsset: {fileID: 0} ---- !u!1001 &644764757 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalPosition.x - value: 12.93 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalPosition.y - value: 5.69 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalPosition.z - value: 4.62 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8080420989084569541, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - propertyPath: m_Name - value: Camera - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} --- !u!1001 &645237588 PrefabInstance: m_ObjectHideFlags: 0 @@ -4209,6 +4084,11 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 689541243} m_PrefabAsset: {fileID: 0} +--- !u!1 &703421485 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2630037540465012823, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} + m_PrefabInstance: {fileID: 4462347664803557153} + m_PrefabAsset: {fileID: 0} --- !u!1 &713901128 GameObject: m_ObjectHideFlags: 0 @@ -4218,6 +4098,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 713901129} + - component: {fileID: 713901130} m_Layer: 0 m_Name: StateManager m_TagString: Untagged @@ -4240,6 +4121,28 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &713901130 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 713901128} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1583dcf9011d5a142af4d8b1610298df, type: 3} + m_Name: + m_EditorClassIdentifier: + currentSceneIndex: 0 + BerryBushData: [] + TwigData: [] + NPCData: [] + PlayerData: + uid: + position: {x: 0, y: 0, z: 0} + rotation: {x: 0, y: 0, z: 0, w: 0} + inventory: [] + blueberryCount: 0 --- !u!1001 &717145944 PrefabInstance: m_ObjectHideFlags: 0 @@ -5360,6 +5263,25 @@ Transform: m_Children: [] m_Father: {fileID: 1771154901} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &902268970 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 8358918113582884329, guid: 752d00c28e3278343b00df87a0486005, type: 3} + m_PrefabInstance: {fileID: 2143013923956880322} + m_PrefabAsset: {fileID: 0} +--- !u!114 &902268975 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902268970} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1c09e61be8049e4089c30fd8ea36a7f, type: 3} + m_Name: + m_EditorClassIdentifier: + uid: a0b0c25f-6f2b-4c61-b398-7a9ddeef04c3 + type: 3 --- !u!1001 &916341880 PrefabInstance: m_ObjectHideFlags: 0 @@ -5503,11 +5425,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 931947759} m_PrefabAsset: {fileID: 0} ---- !u!4 &934616501 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 8538518650932330681, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} - m_PrefabInstance: {fileID: 644764757} - m_PrefabAsset: {fileID: 0} --- !u!1001 &941618660 PrefabInstance: m_ObjectHideFlags: 0 @@ -6215,6 +6132,63 @@ Transform: m_CorrespondingSourceObject: {fileID: 8044303137933371746, guid: d35cab8b21f7e447c94954e58c9c3528, type: 3} m_PrefabInstance: {fileID: 916341880} m_PrefabAsset: {fileID: 0} +--- !u!1001 &1077262244 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 1735147224235397921, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_Name + value: Stick + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalPosition.x + value: -1.62 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalPosition.y + value: 0.5786003 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalPosition.z + value: -2.1611595 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2194414921720918247, guid: a18767e7dba904ad48463d5962ebab56, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: a18767e7dba904ad48463d5962ebab56, type: 3} --- !u!1001 &1082384625 PrefabInstance: m_ObjectHideFlags: 0 @@ -6800,6 +6774,20 @@ Transform: m_CorrespondingSourceObject: {fileID: 3401367369672272621, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} m_PrefabInstance: {fileID: 4462347664803557153} m_PrefabAsset: {fileID: 0} +--- !u!114 &1241509684 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 703421485} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1c09e61be8049e4089c30fd8ea36a7f, type: 3} + m_Name: + m_EditorClassIdentifier: + uid: 640f1b45-4c1e-4f60-9c10-8dc222c6122e + type: 1 --- !u!1 &1272620832 GameObject: m_ObjectHideFlags: 0 @@ -7066,6 +7054,11 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 1287831706} m_PrefabAsset: {fileID: 0} +--- !u!4 &1296656953 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 8538518650932330681, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + m_PrefabInstance: {fileID: 1671129617} + m_PrefabAsset: {fileID: 0} --- !u!1001 &1316996589 PrefabInstance: m_ObjectHideFlags: 0 @@ -7908,6 +7901,20 @@ Transform: m_CorrespondingSourceObject: {fileID: 3401367369672272621, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} m_PrefabInstance: {fileID: 2699808308164711631} m_PrefabAsset: {fileID: 0} +--- !u!114 &1524098920 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 448660793} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f1c09e61be8049e4089c30fd8ea36a7f, type: 3} + m_Name: + m_EditorClassIdentifier: + uid: 84ec2b86-600f-4eff-92c5-c2dfdc8d4b13 + type: 1 --- !u!1001 &1524962397 PrefabInstance: m_ObjectHideFlags: 0 @@ -8641,6 +8648,67 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 1592681507} m_PrefabAsset: {fileID: 0} +--- !u!1001 &1603372945 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalPosition.x + value: -8.87068 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalPosition.y + value: 0.98 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalPosition.z + value: -1.8824902 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1745689670249651042, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2264011724657500812, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: m_Name + value: SceneSwitcher + objectReference: {fileID: 0} + - target: {fileID: 7419702660099155392, guid: 157ff23549611354485c3446833dc2bf, type: 3} + propertyPath: switchToScene + value: Forest + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 157ff23549611354485c3446833dc2bf, type: 3} --- !u!1001 &1608505542 PrefabInstance: m_ObjectHideFlags: 0 @@ -9154,6 +9222,83 @@ MonoBehaviour: scalingFactor: 1 m_posOffsetData: {fileID: 0} listenerMask: 1 +--- !u!114 &1656399206 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 3740866600301396226, guid: 5704dc66b89074156933e2ba70d2d2d7, type: 3} + m_PrefabInstance: {fileID: 355138358} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1656399201} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 23256d9e6183ca49ab546e357a0a1717, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &1671044935 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 8080420989084569541, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + m_PrefabInstance: {fileID: 1671129617} + m_PrefabAsset: {fileID: 0} +--- !u!1001 &1671129617 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalPosition.x + value: 12.93 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalPosition.y + value: 5.69 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalPosition.z + value: 4.62 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2666620144834527649, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3506049021219160777, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: playerMovement + value: + objectReference: {fileID: 1656399206} + - target: {fileID: 8080420989084569541, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} + propertyPath: m_Name + value: CameraHolder + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 606b0b0fab65b431d8563c3d78c7a99c, type: 3} --- !u!1001 &1685684246 PrefabInstance: m_ObjectHideFlags: 0 @@ -12675,103 +12820,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 1158718667690615635, guid: 3e6739342356e4396b5214b3aa5a0864, type: 3} m_PrefabInstance: {fileID: 2146104686} m_PrefabAsset: {fileID: 0} ---- !u!1001 &1531267697844782104 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 2030155835593061689, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_Name - value: DialogManager - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_Pivot.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_Pivot.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchorMax.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 9178170545849500620, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 50a67b6c620910a40a87f9a72c8abb1b, type: 3} --- !u!1001 &2143013923956880322 PrefabInstance: m_ObjectHideFlags: 0 @@ -12827,7 +12875,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 8358918113582884329, guid: 752d00c28e3278343b00df87a0486005, type: 3} + insertIndex: -1 + addedObject: {fileID: 902268975} m_SourcePrefab: {fileID: 100100000, guid: 752d00c28e3278343b00df87a0486005, type: 3} --- !u!1001 &2699808308164711631 PrefabInstance: @@ -12884,7 +12935,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 2630037540465012823, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} + insertIndex: -1 + addedObject: {fileID: 1524098920} m_SourcePrefab: {fileID: 100100000, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} --- !u!1001 &4462347664803557153 PrefabInstance: @@ -12954,15 +13008,18 @@ PrefabInstance: - {fileID: 5925787052338864152, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 2630037540465012823, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} + insertIndex: -1 + addedObject: {fileID: 1241509684} m_SourcePrefab: {fileID: 100100000, guid: 8ad6cc069840cbb4fab063174a981f78, type: 3} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 m_Roots: + - {fileID: 1671129617} - {fileID: 1272620836} - {fileID: 1745342965} - - {fileID: 644764757} - {fileID: 355138358} - {fileID: 1591857820} - {fileID: 2076945219} @@ -12971,6 +13028,6 @@ SceneRoots: - {fileID: 536486187} - {fileID: 97279694} - {fileID: 2143013923956880322} - - {fileID: 1531267697844782104} - {fileID: 713901129} - - {fileID: 134862462} + - {fileID: 1603372945} + - {fileID: 1077262244} diff --git a/blueberryPeak/Assets/Scripts/Audio/Wind.cs b/blueberryPeak/Assets/Scripts/Audio/Wind.cs index 8f652ce..a8c0275 100644 --- a/blueberryPeak/Assets/Scripts/Audio/Wind.cs +++ b/blueberryPeak/Assets/Scripts/Audio/Wind.cs @@ -51,7 +51,7 @@ public class Wind : MonoBehaviour while (!Mathf.Approximately(currentWindSpeed, val)) { - print(val+ " " +currentWindSpeed); + // print(val+ " " +currentWindSpeed); // Move currentWindSpeed towards val by windSpeedStep * Time.deltaTime currentWindSpeed = Mathf.MoveTowards(currentWindSpeed, val, windSpeedStep * Time.deltaTime); AkSoundEngine.SetRTPCValue("WindSpeed", currentWindSpeed); diff --git a/blueberryPeak/Assets/Scripts/Player/DialogManager.cs b/blueberryPeak/Assets/Scripts/Player/DialogManager.cs index 17844ea..ee986d0 100644 --- a/blueberryPeak/Assets/Scripts/Player/DialogManager.cs +++ b/blueberryPeak/Assets/Scripts/Player/DialogManager.cs @@ -34,7 +34,7 @@ public class DialogManager : MonoBehaviour dialogPanel.SetActive(false); // Hide on start } - public void ShowDialog(string message, Animator player, Animator quester) + public void ShowDialog(string speaker, string message, Animator player, Animator quester) { if (player != null) { @@ -50,16 +50,16 @@ public class DialogManager : MonoBehaviour print("should be showing dialog"); if (dialogCoroutine != null) StopCoroutine(dialogCoroutine); - dialogCoroutine = StartCoroutine(ShowDialogCoroutine(message)); + dialogCoroutine = StartCoroutine(ShowDialogCoroutine(speaker, message)); dialogPanel.SetActive(true); playerMovement.moveAllowed = false; } // Coroutine to show dialog. Each letter is displayed one by one // Coroutine to show dialog. Each letter is displayed one by one - private IEnumerator ShowDialogCoroutine(string message) + private IEnumerator ShowDialogCoroutine(string speaker, string message) { - dialogText.text = ""; // Clear previous text + dialogText.text = speaker; // Clear previous text dialogPanel.SetActive(true); playerMovement.moveAllowed = false; @@ -95,7 +95,7 @@ public class DialogManager : MonoBehaviour if (quester != null) { - player.SetBool("Talking", false); + quester.SetBool("Talking", false); quester = null; } diff --git a/blueberryPeak/Assets/Scripts/Player/PlayerInteraction.cs b/blueberryPeak/Assets/Scripts/Player/PlayerInteraction.cs index 237150b..8656443 100644 --- a/blueberryPeak/Assets/Scripts/Player/PlayerInteraction.cs +++ b/blueberryPeak/Assets/Scripts/Player/PlayerInteraction.cs @@ -10,12 +10,12 @@ public class PlayerInteraction : MonoBehaviour [SerializeField] private InputActionReference InteractAction; [SerializeField] private InputActionReference DialogAction; [SerializeField] private GameObject dialogManagerObject; - private readonly List interactableObjects = new(); + private List interactableObjects = new(); private int blueberryCount; private int dialogIndex; private DialogManager dialogManager; - private List inventory = new(); + [SerializeField] private List inventory = new(); private GameObject speaker; @@ -54,15 +54,14 @@ public class PlayerInteraction : MonoBehaviour speaker = interactableObjects.Count > 0 ? ColliderInteractable() : PhysicsRaycastInteractable(); dialog = speaker.GetComponent().Talk(); - if (dialog == null) return; + if (dialog == null || dialog.Length == 0) return; // immedeately start the dialog - dialogManager.ShowDialog("" + dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text, + dialogManager.ShowDialog("" + dialog[dialogIndex].speaker + ": ", dialog[dialogIndex].text, gameObject.GetComponentInChildren(), speaker.GetComponentInChildren()); talking = true; // skip the 0th dialog entry since it has already been shown - dialogIndex++; if (dialogIndex >= dialog.Length) { // reset the dialog index if we reach the end of the dialog @@ -73,6 +72,7 @@ public class PlayerInteraction : MonoBehaviour speaker = null; dialogManager.HideDialog(); } + dialogIndex++; } } @@ -106,16 +106,11 @@ public class PlayerInteraction : MonoBehaviour private void onDialogContinue(InputAction.CallbackContext context) { - if (context.performed && dialog != null) + if (context.performed && dialog != null && dialog.Length > 0) { print("Dialog continue"); // scroll the dialog only if there is text to be shown - print(dialog[dialogIndex].text); - dialogManager.ShowDialog("" + dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text, - gameObject?.GetComponentInChildren(), speaker?.GetComponentInChildren()); - - dialogIndex++; if (dialogIndex >= dialog.Length) { // reset the dialog index if we reach the end of the dialog @@ -129,9 +124,24 @@ public class PlayerInteraction : MonoBehaviour speaker = null; dialogManager.HideDialog(); } + else + { + dialogManager.ShowDialog("" + dialog[dialogIndex].speaker + ": ", + dialog[dialogIndex].text, gameObject?.GetComponentInChildren(), + speaker?.GetComponentInChildren()); + dialogIndex++; + } } } + public Dialog[] GetDialog() + { + return dialog; + } + public void SetDialog(Dialog[] savedDialog) + { + dialog = savedDialog; + } public int GetBlueberryCount() { return blueberryCount; @@ -150,17 +160,22 @@ public class PlayerInteraction : MonoBehaviour public void AddToInventory(InventoryItem reward) { - inventory.Add(reward); + InventoryItem item = inventory.Find(e => e.itemName == reward.itemName); + if (item == null) + inventory.Add(Instantiate(reward)); + else + item.quantity += reward.quantity; Debug.Log("Added " + reward.name + " to inventory. Total items: " + inventory.Count); } public void RemoveFromInventory(InventoryItem reward) { Debug.Log("Attempting to remove " + reward.name + " from inventory."); - if (inventory.Contains(reward)) + InventoryItem item = inventory.Find(e => e.itemName == reward.itemName); + if (item != null) { - inventory.Remove(reward); - Debug.Log("Removed " + reward.name + " from inventory. Total items: " + inventory.Count); + inventory.Remove(item); + Debug.Log("Removed " + item.itemName + " from inventory. Total items: " + inventory.Count); } else { diff --git a/blueberryPeak/Assets/Scripts/Player/TwigInteraction.cs b/blueberryPeak/Assets/Scripts/Player/TwigInteraction.cs index e11043e..347d9df 100644 --- a/blueberryPeak/Assets/Scripts/Player/TwigInteraction.cs +++ b/blueberryPeak/Assets/Scripts/Player/TwigInteraction.cs @@ -28,14 +28,16 @@ public class TwigInteraction : MonoBehaviour { // Play the "Play_BerryWithBush" event if bush has berries // PlayBerryWithBushEvent.Post(gameObject); + if (other.CompareTag("Player")) + { + other.gameObject.GetComponent()?.AddToInventory(twigReward); - other.gameObject.GetComponent().AddToInventory(twigReward); + Destroy(gameObject); - Destroy(gameObject); - - pickupItem.Post(gameObject); + pickupItem.Post(gameObject); - collected = true; + collected = true; + } } } diff --git a/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs b/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs new file mode 100644 index 0000000..69197c9 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs @@ -0,0 +1,20 @@ +using System; +using UnityEngine; + + +[CreateAssetMenu(menuName = "GameItems/ItemReward")] +[Serializable] +public class ItemReward : InventoryItem +{ + + + public override void giveReward(GameObject player) + { + var rewardCopy = ScriptableObject.CreateInstance(); + rewardCopy.itemName = this.itemName; + rewardCopy.quantity = this.quantity; + + player.GetComponent().AddToInventory(rewardCopy); + Debug.Log($"You have received {quantity} {itemName}(s)!"); + } +} \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs.meta b/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs.meta new file mode 100644 index 0000000..06e5be7 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Quests/ItemReward.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: e7bd6bc0eede93c4ea682518fef398dd \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/Quests/QuestGiver.cs b/blueberryPeak/Assets/Scripts/Quests/QuestGiver.cs index 5b99088..1ae4eba 100644 --- a/blueberryPeak/Assets/Scripts/Quests/QuestGiver.cs +++ b/blueberryPeak/Assets/Scripts/Quests/QuestGiver.cs @@ -6,8 +6,8 @@ public class QuestGiver : MonoBehaviour { [SerializeField] private TextAsset questFile; [SerializeField] private InventoryItem reward; - [SerializeField] private InventoryItem requiredItem; - [SerializeField] private DeleteTreeReward rewardFunction; + [SerializeField] private ItemReward requiredItem; + [SerializeField] public DeleteTreeReward rewardFunction; public bool isActive; public bool isCompleted; @@ -32,6 +32,7 @@ public class QuestGiver : MonoBehaviour { Debug.LogError("Failed to parse quest data: " + e.Message); } + } private void Start() @@ -41,21 +42,29 @@ public class QuestGiver : MonoBehaviour // Update is called once per frame private void Update() { + } public QuestData GetCurrentQuest() { return quest; } + public void SetCurrentQuest(QuestData questSave) + { + quest = questSave; + } public void CheckInventory(List inventory) { + InventoryItem item = inventory.Find(e => e.itemName == requiredItem.itemName); + print(item.itemName + item.quantity); // Check if the required item is in the player's inventory - if (inventory.Contains(requiredItem)) + if (item != null && item.quantity >= requiredItem.quantity) { isCompleted = true; // Mark the quest as completed FinishQuest(); } + else { isCompleted = false; // Mark the quest as not completed @@ -65,43 +74,53 @@ public class QuestGiver : MonoBehaviour public Dialog[] Talk() { Debug.Log("Talking to quest giver: " + quest.id); + if (!isActive && isCompleted) - // If the quest is completed, return the repetition dialog + { return quest.repetition; + } if (!isActive) { - // Initialize the quest isActive = true; return quest.initial; } - if (isActive && isCompleted) + if (isActive) { - isActive = false; // reset the quest - isCompleted = true; - // take the Requireditem from the player inventory + if (!isCompleted) + { + CheckInventory(GameObject.FindGameObjectsWithTag("Player")[0].GetComponent().GetInventoryItems()); + } - // If the quest is active and completed, return the success dialog - return quest.success; + // Re-check after CheckInventory potentially updates the quest + if (isCompleted) + { + isActive = false; + return quest.success; + } + else + { + return quest.reminder; + } } - // If the quest is active but not completed, return the reminder dialog - CheckInventory(GameObject.FindGameObjectsWithTag("Player")[0].GetComponent() - .GetInventoryItems()); - return quest.reminder; + return null; // fallback } public Dialog[] FinishQuest() { // If the quest is active and completed, return the success dialog + PlayerInteraction player = GameObject.Find("Fox").GetComponent(); + player.RemoveFromInventory(requiredItem); + if (reward) + { + reward.giveReward(GameObject.Find("Fox")); // Give the reward to the player + } + if (rewardFunction != null) + rewardFunction.RewardPlayer(); isActive = false; isCompleted = true; - GameObject.Find("Player").GetComponent().RemoveFromInventory(requiredItem); - - reward.giveReward(GameObject.Find("Player")); // Give the reward to the player - rewardFunction.RewardPlayer(); - if (rewardFunction != null) rewardFunction.RewardPlayer(); return quest.success; } } \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/Quests/Reward.cs b/blueberryPeak/Assets/Scripts/Quests/Reward.cs index 1839167..7710f82 100644 --- a/blueberryPeak/Assets/Scripts/Quests/Reward.cs +++ b/blueberryPeak/Assets/Scripts/Quests/Reward.cs @@ -1,7 +1,9 @@ +using System; using UnityEngine; // base class for all rewards +[Serializable] public abstract class InventoryItem : ScriptableObject { [SerializeField] public string itemName; @@ -11,25 +13,7 @@ public abstract class InventoryItem : ScriptableObject public abstract void giveReward(GameObject player); } -[CreateAssetMenu(menuName = "GameItems/ItemReward")] -public class ItemReward : InventoryItem -{ - public ItemReward(string itemName, int quantity) - { - this.itemName = itemName; - this.quantity = quantity; - } - public override void giveReward(GameObject player) - { - var reward = CreateInstance(); - reward.itemName = itemName; - reward.quantity = quantity; - player.GetComponent().AddToInventory(reward); - // Add logic to give an item to the player - Debug.Log($"You have received {quantity} {itemName}(s)!"); - } -} [CreateAssetMenu(menuName = "GameItems/ItemRewardWithScript")] public class ItemRewardWithScript : InventoryItem @@ -54,7 +38,7 @@ public class ItemRewardWithScript : InventoryItem player.GetComponent().AddToInventory(reward); -// Add logic to give an item to the player + // Add logic to give an item to the player Debug.Log($"You have received {quantity} {itemName}(s)!"); } diff --git a/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset b/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset new file mode 100644 index 0000000..bb28d91 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset @@ -0,0 +1,16 @@ +%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: e7bd6bc0eede93c4ea682518fef398dd, type: 3} + m_Name: RequiredTwigs + m_EditorClassIdentifier: + itemName: Twig + quantity: 9 diff --git a/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset.meta b/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset.meta new file mode 100644 index 0000000..3e4d49e --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Quests/Rewards/RequiredTwigs.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6c18e61a86e4bd8498c238462ae9657e +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset b/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset index 9218e2c..65e1e55 100644 --- a/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset +++ b/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset @@ -9,8 +9,8 @@ MonoBehaviour: m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 0} + m_Script: {fileID: 11500000, guid: e7bd6bc0eede93c4ea682518fef398dd, type: 3} m_Name: TwigReward - m_EditorClassIdentifier: Assembly-CSharp::ItemReward + m_EditorClassIdentifier: itemName: Twig quantity: 1 diff --git a/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset.meta b/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset.meta index 8f98ee7..4406715 100644 --- a/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset.meta +++ b/blueberryPeak/Assets/Scripts/Quests/Rewards/TwigReward.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dc78e90d3a39cf54fbaf1cf84bf17059 +guid: 2ac23e8781840054c8a835df7fffe208 NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/blueberryPeak/Assets/Scripts/SaveData.cs b/blueberryPeak/Assets/Scripts/SaveData.cs new file mode 100644 index 0000000..cd04924 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/SaveData.cs @@ -0,0 +1,78 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Unity.VisualScripting; + +[Serializable] +public partial class SaveData +{ + public string uid; + public Vector3 position; + public Quaternion rotation; +} + +[Serializable] +public class SaveableBerryBush : SaveData +{ + public int blueberryCount; + public bool BlueBerriesPicked; + public SaveableBerryBush(string uid, Vector3 position, Quaternion rotation, int blueberryCount, bool blueBerriesPicked) + { + this.uid = uid; + this.position = position; + this.rotation = rotation; + this.blueberryCount = blueberryCount; + this.BlueBerriesPicked = blueBerriesPicked; + } +} + + +[Serializable] +public class SaveableTwig : SaveData +{ + public bool collected; + public SaveableTwig(string uid, Vector3 position, Quaternion rotation, bool collected) + { + this.uid = uid; + this.position = position; + this.rotation = rotation; + this.collected = collected; + } +} + +[Serializable] +public class SaveableNPC : SaveData +{ + public bool isActive; + public bool isCompleted; + public QuestData dialog; + + public SaveableNPC(string uid, Vector3 position, Quaternion rotation, bool isActive, bool isCompleted, QuestData dialog) + { + this.uid = uid; + this.position = position; + this.rotation = rotation; + this.isActive = isActive; + this.isCompleted = isCompleted; + this.dialog = dialog; + } +} + +[Serializable] +public class SaveablePlayer : SaveData +{ + public List inventory = new List(); + public int blueberryCount; + public Dialog[] dialog; + + public SaveablePlayer(string uid, Vector3 position, Quaternion rotation, List inventory, int blueberrycount, Dialog[] dialog) + { + this.uid = uid; + this.position = position; + this.rotation = rotation; + this.inventory = inventory; + this.blueberryCount = blueberrycount; + this.dialog = dialog; + } +} diff --git a/blueberryPeak/Assets/Scripts/SaveData.cs.meta b/blueberryPeak/Assets/Scripts/SaveData.cs.meta new file mode 100644 index 0000000..05fd210 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/SaveData.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f19caeb072954d54fbc00f2ea514825b \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/Saveable.cs b/blueberryPeak/Assets/Scripts/Saveable.cs new file mode 100644 index 0000000..9273e1a --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Saveable.cs @@ -0,0 +1,185 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using UnityEngine.UIElements; + + +public class Saveable : MonoBehaviour +{ + public enum ObjectType + { + Player, + BerryBush, + Twig, + NPC, + } + + [SerializeField] private string uid = ""; + [SerializeField] private ObjectType type = ObjectType.BerryBush; + +#if UNITY_EDITOR + void OnValidate() + { + if (uid != "") + { + // If the UID is already set, we don't need to do anything + return; + } + // Generate a new UID based on the position of the object + uid = Guid.NewGuid().ToString(); + } +#endif + private StateManager stateManager = null; + private void Awake() + { + stateManager = GameObject.FindObjectOfType(); + // check if there is a saveState for the current object + RestoreMyself(); + EnqueueSave(); + } + + void EnqueueSave() + { + if (stateManager == null) + return; + + // add yourself to the stateManager depending on the type + if (type == ObjectType.BerryBush) + { + // check if the bush is already registered in the berrybushdata array + if (stateManager.BerryBushData.Find(e => e.uid == uid) == null) + stateManager.BerryBushData.Add(new SaveableBerryBush(uid, transform.position, transform.rotation, gameObject.GetComponent().GetBlueberryCount(), gameObject.GetComponent().AreBlueberriesPicked())); + } + else if (type == ObjectType.Twig) + { + if (stateManager.TwigData.Find(e => e.uid == uid) == null) + stateManager.TwigData.Add(new SaveableTwig(uid, transform.position, transform.rotation, gameObject.GetComponent().IsCollected())); + } + + else if (type == ObjectType.Player) + { + stateManager.PlayerData = new SaveablePlayer(uid, transform.position, transform.rotation, gameObject.GetComponent().GetInventoryItems(), gameObject.GetComponent().GetBlueberryCount(), gameObject.GetComponent().GetDialog()); + } + + else if (type == ObjectType.NPC) + { + if (stateManager.NPCData.Find(e => e.uid == uid) == null) + stateManager.NPCData.Add(new SaveableNPC(uid, transform.position, transform.rotation, gameObject.GetComponent().isActive, gameObject.GetComponent().isCompleted, gameObject.GetComponent().GetCurrentQuest())); + } + + } + + private void RestoreMyself() + { + if (stateManager == null) + return; + + + if (type == ObjectType.BerryBush) + { + //save itself to the statemanager + SaveableBerryBush bush = stateManager.BerryBushData.Find(e => e.uid == uid); + BushInteraction interaction = gameObject.GetComponent(); + if (bush == null || interaction == null) + return; + interaction.SetBlueberriesPicked(bush.BlueBerriesPicked); + interaction.SetBlueberryCount(bush.blueberryCount); + } + else if (type == ObjectType.Twig) + { + SaveableTwig shtick = stateManager.TwigData.Find(e => e.uid == uid); + TwigInteraction interaction = gameObject.GetComponent(); + if (shtick == null || interaction == null) + return; + interaction.SetCollected(shtick.collected); + } + + else if (type == ObjectType.Player) + { + SaveablePlayer player = stateManager.PlayerData; + PlayerInteraction interaction = gameObject.GetComponent(); + if (player == null) + return; + interaction.SetInventoryItems(player.inventory); + interaction.SetBlueberryCount(player.blueberryCount); + interaction.SetDialog(player.dialog); + // transform.position = player.position; + // transform.rotation = player.rotation; + } + + else if (type == ObjectType.NPC) + { + SaveableNPC npc = stateManager.NPCData.Find(e => e.uid == uid); + QuestGiver questGiver = gameObject.GetComponent(); + if (npc == null || questGiver == null) + return; + questGiver.isActive = npc.isActive; + questGiver.isCompleted = npc.isCompleted; + questGiver.SetCurrentQuest(npc.dialog); + // delete the tree for the beaver quest if it is completed + if (questGiver.isCompleted && questGiver.rewardFunction != null) + { + questGiver.rewardFunction.RewardPlayer(); + } + + } + } + + public string GetUID() + { + return uid; + } + public void SaveMyself() + { + if (stateManager == null) + return; + + + if (type == ObjectType.BerryBush) + { + //save itself to the statemanager + SaveableBerryBush bush = stateManager.BerryBushData.Find(e => e.uid == uid); + BushInteraction interaction = gameObject.GetComponent(); + if (bush == null || interaction == null) + return; + bush.blueberryCount = interaction.GetBlueberryCount(); + bush.BlueBerriesPicked = interaction.AreBlueberriesPicked(); + } + else if (type == ObjectType.Twig) + { + SaveableTwig shtick = stateManager.TwigData.Find(e => e.uid == uid); + if (shtick == null) + return; + TwigInteraction interaction = gameObject.GetComponent(); + shtick.collected = interaction.IsCollected(); + } + + else if (type == ObjectType.Player) + { + SaveablePlayer player = stateManager.PlayerData; + PlayerInteraction interaction = gameObject.GetComponent(); + player.blueberryCount = interaction.GetBlueberryCount(); + player.inventory = interaction.GetInventoryItems(); + player.dialog = interaction.GetDialog(); + // player.position = transform.position; + // player.rotation = transform.rotation; + } + + else if (type == ObjectType.NPC) + { + SaveableNPC npc = stateManager.NPCData.Find(e => e.uid == uid); + QuestGiver questGiver = gameObject.GetComponent(); + if (npc == null || questGiver == null) + return; + npc.isActive = questGiver.isActive; + npc.isCompleted = questGiver.isCompleted; + npc.dialog = questGiver.GetCurrentQuest(); + } + } + + private void OnDestroy() + { + SaveMyself(); + } + +} \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/Saveable.cs.meta b/blueberryPeak/Assets/Scripts/Saveable.cs.meta new file mode 100644 index 0000000..b545dc1 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/Saveable.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: f1c09e61be8049e4089c30fd8ea36a7f \ No newline at end of file diff --git a/blueberryPeak/Assets/Scripts/StateManager.cs b/blueberryPeak/Assets/Scripts/StateManager.cs new file mode 100644 index 0000000..ffee861 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/StateManager.cs @@ -0,0 +1,45 @@ +using UnityEngine; +using System; +using System.Collections.Generic; +using Unity.VisualScripting; + + + + +public class StateManager : MonoBehaviour +{ + public static StateManager Instance { get; private set; } + + public int currentSceneIndex = 0; + + + [SerializeField] public List BerryBushData = new List(); + [SerializeField] public List TwigData = new List(); + + [SerializeField] public List NPCData = new List(); + + [SerializeField] public SaveablePlayer PlayerData; + private void Awake() + { + if (Instance != null && Instance != this) + { + Destroy(gameObject); // Only one instance allowed + return; + } + + Instance = this; + DontDestroyOnLoad(gameObject); // Persist through scenes + + } + + public void SaveGameState() + { + Debug.Log("Saving game state..."); + } + + public void LoadGameState() + { + Debug.Log("Restoring game state"); + } + +} diff --git a/blueberryPeak/Assets/Scripts/StateManager.cs.meta b/blueberryPeak/Assets/Scripts/StateManager.cs.meta new file mode 100644 index 0000000..9895ec0 --- /dev/null +++ b/blueberryPeak/Assets/Scripts/StateManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 1583dcf9011d5a142af4d8b1610298df \ No newline at end of file