Save state across scenes & finished Quest interactions

This commit is contained in:
AgentSchmisch 2025-06-19 01:07:40 +02:00
parent 2fc7d5061b
commit 3f66591822
23 changed files with 819 additions and 310 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8c34cc63b3722f245be837e67f74992f
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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}

View File

@ -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);

View File

@ -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;
}

View File

@ -10,12 +10,12 @@ public class PlayerInteraction : MonoBehaviour
[SerializeField] private InputActionReference InteractAction;
[SerializeField] private InputActionReference DialogAction;
[SerializeField] private GameObject dialogManagerObject;
private readonly List<GameObject> interactableObjects = new();
private List<GameObject> interactableObjects = new();
private int blueberryCount;
private int dialogIndex;
private DialogManager dialogManager;
private List<InventoryItem> inventory = new();
[SerializeField] private List<InventoryItem> inventory = new();
private GameObject speaker;
@ -54,15 +54,14 @@ public class PlayerInteraction : MonoBehaviour
speaker = interactableObjects.Count > 0 ? ColliderInteractable() : PhysicsRaycastInteractable();
dialog = speaker.GetComponent<QuestGiver>().Talk();
if (dialog == null) return;
if (dialog == null || dialog.Length == 0) return;
// immedeately start the dialog
dialogManager.ShowDialog("<b>" + dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text,
dialogManager.ShowDialog("<b>" + dialog[dialogIndex].speaker + ": ", dialog[dialogIndex].text,
gameObject.GetComponentInChildren<Animator>(), speaker.GetComponentInChildren<Animator>());
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("<b>" + dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text,
gameObject?.GetComponentInChildren<Animator>(), speaker?.GetComponentInChildren<Animator>());
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("<b>" + dialog[dialogIndex].speaker + "</b>: ",
dialog[dialogIndex].text, gameObject?.GetComponentInChildren<Animator>(),
speaker?.GetComponentInChildren<Animator>());
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
{

View File

@ -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<PlayerInteraction>()?.AddToInventory(twigReward);
other.gameObject.GetComponent<PlayerInteraction>().AddToInventory(twigReward);
Destroy(gameObject);
Destroy(gameObject);
pickupItem.Post(gameObject);
pickupItem.Post(gameObject);
collected = true;
collected = true;
}
}
}

View File

@ -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<ItemReward>();
rewardCopy.itemName = this.itemName;
rewardCopy.quantity = this.quantity;
player.GetComponent<PlayerInteraction>().AddToInventory(rewardCopy);
Debug.Log($"You have received {quantity} {itemName}(s)!");
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e7bd6bc0eede93c4ea682518fef398dd

View File

@ -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<InventoryItem> 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<PlayerInteraction>().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<PlayerInteraction>()
.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<PlayerInteraction>();
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<PlayerInteraction>().RemoveFromInventory(requiredItem);
reward.giveReward(GameObject.Find("Player")); // Give the reward to the player
rewardFunction.RewardPlayer();
if (rewardFunction != null) rewardFunction.RewardPlayer();
return quest.success;
}
}

View File

@ -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<ItemReward>();
reward.itemName = itemName;
reward.quantity = quantity;
player.GetComponent<PlayerInteraction>().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<PlayerInteraction>().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)!");
}

View File

@ -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

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6c18e61a86e4bd8498c238462ae9657e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: dc78e90d3a39cf54fbaf1cf84bf17059
guid: 2ac23e8781840054c8a835df7fffe208
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

View File

@ -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<InventoryItem> inventory = new List<InventoryItem>();
public int blueberryCount;
public Dialog[] dialog;
public SaveablePlayer(string uid, Vector3 position, Quaternion rotation, List<InventoryItem> inventory, int blueberrycount, Dialog[] dialog)
{
this.uid = uid;
this.position = position;
this.rotation = rotation;
this.inventory = inventory;
this.blueberryCount = blueberrycount;
this.dialog = dialog;
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f19caeb072954d54fbc00f2ea514825b

View File

@ -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<StateManager>();
// 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<BushInteraction>().GetBlueberryCount(), gameObject.GetComponent<BushInteraction>().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<TwigInteraction>().IsCollected()));
}
else if (type == ObjectType.Player)
{
stateManager.PlayerData = new SaveablePlayer(uid, transform.position, transform.rotation, gameObject.GetComponent<PlayerInteraction>().GetInventoryItems(), gameObject.GetComponent<PlayerInteraction>().GetBlueberryCount(), gameObject.GetComponent<PlayerInteraction>().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<QuestGiver>().isActive, gameObject.GetComponent<QuestGiver>().isCompleted, gameObject.GetComponent<QuestGiver>().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<BushInteraction>();
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<TwigInteraction>();
if (shtick == null || interaction == null)
return;
interaction.SetCollected(shtick.collected);
}
else if (type == ObjectType.Player)
{
SaveablePlayer player = stateManager.PlayerData;
PlayerInteraction interaction = gameObject.GetComponent<PlayerInteraction>();
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<QuestGiver>();
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<BushInteraction>();
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<TwigInteraction>();
shtick.collected = interaction.IsCollected();
}
else if (type == ObjectType.Player)
{
SaveablePlayer player = stateManager.PlayerData;
PlayerInteraction interaction = gameObject.GetComponent<PlayerInteraction>();
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<QuestGiver>();
if (npc == null || questGiver == null)
return;
npc.isActive = questGiver.isActive;
npc.isCompleted = questGiver.isCompleted;
npc.dialog = questGiver.GetCurrentQuest();
}
}
private void OnDestroy()
{
SaveMyself();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f1c09e61be8049e4089c30fd8ea36a7f

View File

@ -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<SaveableBerryBush> BerryBushData = new List<SaveableBerryBush>();
[SerializeField] public List<SaveableTwig> TwigData = new List<SaveableTwig>();
[SerializeField] public List<SaveableNPC> NPCData = new List<SaveableNPC>();
[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");
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1583dcf9011d5a142af4d8b1610298df