From e47f04fb79718c9b0f464a05d91136cc76ed7d53 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Tue, 23 Feb 2021 13:05:42 +0000 Subject: [PATCH] trigger dialogue on artefact pickup --- game/Assets/Data/Artefacts.meta | 8 + .../Data/Artefacts/Artefact System.asset | 16 ++ .../Data/Artefacts/Artefact System.asset.meta | 8 + .../Artefacts/ArtefactObjects.meta | 0 .../Artefacts/ArtefactObjects/Artefact1.asset | 2 +- .../ArtefactObjects/Artefact1.asset.meta | 0 .../Artefacts/ArtefactObjects/Artefact2.asset | 2 +- .../ArtefactObjects/Artefact2.asset.meta | 0 game/Assets/Data/Artefacts/Inventory.asset | 14 ++ .../Data/Artefacts/Inventory.asset.meta | 8 + .../Artefacts/nearbyArtefactID.asset | 0 .../Artefacts/nearbyArtefactID.asset.meta | 0 game/Assets/Prefabs/Artefacts/Artefact.prefab | 91 ++++++++++- game/Assets/Scenes/Dialogue.unity | 146 ++++++++++++++++++ game/Assets/Scripts/Artefacts/Artefact.cs | 7 +- .../Scripts/Artefacts/ArtefactControl.cs | 15 +- .../Scripts/Artefacts/ArtefactInventory.cs | 20 +-- .../Scripts/Artefacts/ArtefactSystem.cs | 17 ++ .../Scripts/Artefacts/ArtefactSystem.cs.meta | 11 ++ .../Scripts/Dialogue/DialogueDatabase.cs | 6 + .../Assets/Scripts/Dialogue/DialogueSystem.cs | 22 ++- 21 files changed, 354 insertions(+), 39 deletions(-) create mode 100644 game/Assets/Data/Artefacts.meta create mode 100644 game/Assets/Data/Artefacts/Artefact System.asset create mode 100644 game/Assets/Data/Artefacts/Artefact System.asset.meta rename game/Assets/{Scripts => Data}/Artefacts/ArtefactObjects.meta (100%) rename game/Assets/{Scripts => Data}/Artefacts/ArtefactObjects/Artefact1.asset (93%) rename game/Assets/{Scripts => Data}/Artefacts/ArtefactObjects/Artefact1.asset.meta (100%) rename game/Assets/{Scripts => Data}/Artefacts/ArtefactObjects/Artefact2.asset (93%) rename game/Assets/{Scripts => Data}/Artefacts/ArtefactObjects/Artefact2.asset.meta (100%) create mode 100644 game/Assets/Data/Artefacts/Inventory.asset create mode 100644 game/Assets/Data/Artefacts/Inventory.asset.meta rename game/Assets/{Scripts => Data}/Artefacts/nearbyArtefactID.asset (100%) rename game/Assets/{Scripts => Data}/Artefacts/nearbyArtefactID.asset.meta (100%) create mode 100644 game/Assets/Scripts/Artefacts/ArtefactSystem.cs create mode 100644 game/Assets/Scripts/Artefacts/ArtefactSystem.cs.meta diff --git a/game/Assets/Data/Artefacts.meta b/game/Assets/Data/Artefacts.meta new file mode 100644 index 0000000..966a35e --- /dev/null +++ b/game/Assets/Data/Artefacts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d2764ab4e4dca7a45b1067df7aab2588 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Data/Artefacts/Artefact System.asset b/game/Assets/Data/Artefacts/Artefact System.asset new file mode 100644 index 0000000..2db9f80 --- /dev/null +++ b/game/Assets/Data/Artefacts/Artefact System.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: d089d711384390948a578301b55b65f9, type: 3} + m_Name: Artefact System + m_EditorClassIdentifier: + _dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2} + _inventory: {fileID: 11400000, guid: 1a9441435aa1fc649a84169f689c7f53, type: 2} diff --git a/game/Assets/Data/Artefacts/Artefact System.asset.meta b/game/Assets/Data/Artefacts/Artefact System.asset.meta new file mode 100644 index 0000000..324fe58 --- /dev/null +++ b/game/Assets/Data/Artefacts/Artefact System.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f523ac0d77530064b8b41c627b13fae0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Artefacts/ArtefactObjects.meta b/game/Assets/Data/Artefacts/ArtefactObjects.meta similarity index 100% rename from game/Assets/Scripts/Artefacts/ArtefactObjects.meta rename to game/Assets/Data/Artefacts/ArtefactObjects.meta diff --git a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact1.asset b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact1.asset similarity index 93% rename from game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact1.asset rename to game/Assets/Data/Artefacts/ArtefactObjects/Artefact1.asset index 4f059fd..dcf9f39 100644 --- a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact1.asset +++ b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact1.asset @@ -13,4 +13,4 @@ MonoBehaviour: m_Name: Artefact1 m_EditorClassIdentifier: _artefactID: 1 - _artefactDialogue: + _dialogueKey: ARTEFACT_0_0 diff --git a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact1.asset.meta b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact1.asset.meta similarity index 100% rename from game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact1.asset.meta rename to game/Assets/Data/Artefacts/ArtefactObjects/Artefact1.asset.meta diff --git a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact2.asset b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact2.asset similarity index 93% rename from game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact2.asset rename to game/Assets/Data/Artefacts/ArtefactObjects/Artefact2.asset index b7b438e..15d302c 100644 --- a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact2.asset +++ b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact2.asset @@ -13,4 +13,4 @@ MonoBehaviour: m_Name: Artefact2 m_EditorClassIdentifier: _artefactID: 2 - _artefactDialogue: + _dialogueKey: ARTEFACT_1_0 diff --git a/game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact2.asset.meta b/game/Assets/Data/Artefacts/ArtefactObjects/Artefact2.asset.meta similarity index 100% rename from game/Assets/Scripts/Artefacts/ArtefactObjects/Artefact2.asset.meta rename to game/Assets/Data/Artefacts/ArtefactObjects/Artefact2.asset.meta diff --git a/game/Assets/Data/Artefacts/Inventory.asset b/game/Assets/Data/Artefacts/Inventory.asset new file mode 100644 index 0000000..c07d731 --- /dev/null +++ b/game/Assets/Data/Artefacts/Inventory.asset @@ -0,0 +1,14 @@ +%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: 6be0ffc922ae4ac4cb7568e04674a61c, type: 3} + m_Name: Inventory + m_EditorClassIdentifier: diff --git a/game/Assets/Data/Artefacts/Inventory.asset.meta b/game/Assets/Data/Artefacts/Inventory.asset.meta new file mode 100644 index 0000000..28b1c20 --- /dev/null +++ b/game/Assets/Data/Artefacts/Inventory.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1a9441435aa1fc649a84169f689c7f53 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Artefacts/nearbyArtefactID.asset b/game/Assets/Data/Artefacts/nearbyArtefactID.asset similarity index 100% rename from game/Assets/Scripts/Artefacts/nearbyArtefactID.asset rename to game/Assets/Data/Artefacts/nearbyArtefactID.asset diff --git a/game/Assets/Scripts/Artefacts/nearbyArtefactID.asset.meta b/game/Assets/Data/Artefacts/nearbyArtefactID.asset.meta similarity index 100% rename from game/Assets/Scripts/Artefacts/nearbyArtefactID.asset.meta rename to game/Assets/Data/Artefacts/nearbyArtefactID.asset.meta diff --git a/game/Assets/Prefabs/Artefacts/Artefact.prefab b/game/Assets/Prefabs/Artefacts/Artefact.prefab index 87ae9cd..9930110 100644 --- a/game/Assets/Prefabs/Artefacts/Artefact.prefab +++ b/game/Assets/Prefabs/Artefacts/Artefact.prefab @@ -1,5 +1,86 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &1085328826835407779 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2663749718261374877} + - component: {fileID: 2205831332405259923} + - component: {fileID: 8272008737841710381} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2663749718261374877 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085328826835407779} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.05, z: 0} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} + m_Children: [] + m_Father: {fileID: 8781564213167799764} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &2205831332405259923 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085328826835407779} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &8272008737841710381 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085328826835407779} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} --- !u!1 &8781564213167799763 GameObject: m_ObjectHideFlags: 0 @@ -28,10 +109,11 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8781564213167799763} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.38, y: 0.5, z: 38.53155} + m_LocalPosition: {x: 0, y: 0.5, z: 0} m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} m_Children: - {fileID: 8781564214893312960} + - {fileID: 2663749718261374877} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -50,7 +132,7 @@ MeshRenderer: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8781564213167799763} - m_Enabled: 1 + m_Enabled: 0 m_CastShadows: 1 m_ReceiveShadows: 1 m_DynamicOccludee: 1 @@ -93,7 +175,7 @@ CapsuleCollider: m_GameObject: {fileID: 8781564213167799763} m_Material: {fileID: 0} m_IsTrigger: 0 - m_Enabled: 1 + m_Enabled: 0 m_Radius: 0.5000001 m_Height: 2 m_Direction: 1 @@ -112,6 +194,7 @@ MonoBehaviour: m_EditorClassIdentifier: data: {fileID: 0} _nearbyArtefactID: {fileID: 11400000, guid: caba70196fbb1c549a934f7566f7a247, type: 2} + _artefacts: {fileID: 11400000, guid: f523ac0d77530064b8b41c627b13fae0, type: 2} --- !u!1 &8781564214893312975 GameObject: m_ObjectHideFlags: 0 @@ -141,7 +224,7 @@ Transform: m_GameObject: {fileID: 8781564214893312975} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 2, y: 2, z: 2} + m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 8781564213167799764} m_RootOrder: 0 diff --git a/game/Assets/Scenes/Dialogue.unity b/game/Assets/Scenes/Dialogue.unity index 9ab0ec6..d88c1af 100644 --- a/game/Assets/Scenes/Dialogue.unity +++ b/game/Assets/Scenes/Dialogue.unity @@ -957,6 +957,79 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1549487653} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1001 &1580220236 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 8781564213167799763, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_Name + value: Artefact 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_RootOrder + value: 5 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.x + value: -5.31 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.z + value: 6.65 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564214016862072, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: data + value: + objectReference: {fileID: 11400000, guid: 38f76e60d5df1d445a455c63a88da8e1, type: 2} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 2dae894ec500e524a88f985657f9682d, type: 3} --- !u!1 &1708945667 GameObject: m_ObjectHideFlags: 0 @@ -1052,6 +1125,79 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1708945667} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1001 &1751696412 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 8781564213167799763, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_Name + value: Artefact 2 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_RootOrder + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalScale.z + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.x + value: -5.23 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalPosition.z + value: 2.22 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564213167799764, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8781564214016862072, guid: 2dae894ec500e524a88f985657f9682d, type: 3} + propertyPath: data + value: + objectReference: {fileID: 11400000, guid: 4c18fa3513891124282e56285b09c211, type: 2} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 2dae894ec500e524a88f985657f9682d, type: 3} --- !u!224 &1894783044 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 5119468870989674483, guid: fde30a46065b3b144ac612ec0b3e484a, type: 3} diff --git a/game/Assets/Scripts/Artefacts/Artefact.cs b/game/Assets/Scripts/Artefacts/Artefact.cs index 0dd12c1..7a9e2da 100644 --- a/game/Assets/Scripts/Artefacts/Artefact.cs +++ b/game/Assets/Scripts/Artefacts/Artefact.cs @@ -2,14 +2,13 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -[CreateAssetMenu(fileName = "New Artefact", menuName = "Artefact", order = 51)] +[CreateAssetMenu(fileName = "New Artefact", menuName = "KernelPanic/Artefacts/Artefact")] public class Artefact : ScriptableObject { - public int artefactID => _artefactID; [SerializeField] private int _artefactID; - public string artefactDialogue => _artefactDialogue; - [SerializeField] private string _artefactDialogue; + public string dialogueKey => _dialogueKey; + [SerializeField] private string _dialogueKey; public bool show => _show; private bool _show = false; diff --git a/game/Assets/Scripts/Artefacts/ArtefactControl.cs b/game/Assets/Scripts/Artefacts/ArtefactControl.cs index f1601aa..f0a6afa 100644 --- a/game/Assets/Scripts/Artefacts/ArtefactControl.cs +++ b/game/Assets/Scripts/Artefacts/ArtefactControl.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using Ktyl.Util; +using UnityEngine.Events; public class ArtefactControl : MonoBehaviour { @@ -14,13 +15,13 @@ public class ArtefactControl : MonoBehaviour private Artefact data; public int artefactID => _artefactID; private int _artefactID; - private string _artefactDialogue; [SerializeField] private SerialInt _nearbyArtefactID; + [SerializeField] private ArtefactSystem _artefacts; + private void Start() { _artefactID = data.artefactID; - _artefactDialogue = data.artefactDialogue; _show = data.show; _canInteract = data.canInteract; @@ -55,14 +56,10 @@ public class ArtefactControl : MonoBehaviour { if (_canInteract == true) { - ArtefactInventory.addA(data); - foreach (var x in ArtefactInventory.artefactList) - { - Debug.Log(x.ToString()); - } - + // artefact system informs other systems about found artefact + _artefacts.FindArtefact(data); } - //here put 'show artifact dialogue' + if (this.gameObject != null) Destroy(this.gameObject); _nearbyArtefactID.Value = -1; diff --git a/game/Assets/Scripts/Artefacts/ArtefactInventory.cs b/game/Assets/Scripts/Artefacts/ArtefactInventory.cs index 6c64d57..7c479c3 100644 --- a/game/Assets/Scripts/Artefacts/ArtefactInventory.cs +++ b/game/Assets/Scripts/Artefacts/ArtefactInventory.cs @@ -3,27 +3,23 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +[CreateAssetMenu(menuName = "KernelPanic/Artefacts/Inventory")] public class ArtefactInventory : ScriptableObject { - public static List artefactList = new List(); - private static bool exists = false; + private readonly List artefactList = new List(); - public static void addA(Artefact a) + public void addA(Artefact a) { //check if duplicate in the list - exists = false; foreach (Artefact x in artefactList) { if (x.artefactID == a.artefactID) - exists = true; + { + Debug.LogError($"{a} already exists in inventory", this); + return; + } } - if ( exists == false) - { - artefactList.Add(a); - } - + artefactList.Add(a); } - - } diff --git a/game/Assets/Scripts/Artefacts/ArtefactSystem.cs b/game/Assets/Scripts/Artefacts/ArtefactSystem.cs new file mode 100644 index 0000000..d9c2cc6 --- /dev/null +++ b/game/Assets/Scripts/Artefacts/ArtefactSystem.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(menuName = "KernelPanic/Artefacts/Artefact System")] +public class ArtefactSystem : ScriptableObject +{ + [SerializeField] private DialogueSystem _dialogue; + [SerializeField] private ArtefactInventory _inventory; + + public void FindArtefact(Artefact artefact) + { + _inventory.addA(artefact); + + _dialogue.PlayLine(artefact.dialogueKey); + } +} diff --git a/game/Assets/Scripts/Artefacts/ArtefactSystem.cs.meta b/game/Assets/Scripts/Artefacts/ArtefactSystem.cs.meta new file mode 100644 index 0000000..96a1050 --- /dev/null +++ b/game/Assets/Scripts/Artefacts/ArtefactSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d089d711384390948a578301b55b65f9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scripts/Dialogue/DialogueDatabase.cs b/game/Assets/Scripts/Dialogue/DialogueDatabase.cs index b127959..9b5447d 100644 --- a/game/Assets/Scripts/Dialogue/DialogueDatabase.cs +++ b/game/Assets/Scripts/Dialogue/DialogueDatabase.cs @@ -68,6 +68,12 @@ public static partial class DialogueDatabase var lines = 0; foreach (var row in values) { + if (row.Count != 2) + { + Debug.Log($":: skipping non-matching line: {lines}: {(row.Count == 0 ? "empty" : string.Join(",", row))}"); + continue; + } + sb.AppendLine($"{row[0]}{SPLIT_CHAR}{row[1]}"); lines++; } diff --git a/game/Assets/Scripts/Dialogue/DialogueSystem.cs b/game/Assets/Scripts/Dialogue/DialogueSystem.cs index c1ea9b2..57105ea 100644 --- a/game/Assets/Scripts/Dialogue/DialogueSystem.cs +++ b/game/Assets/Scripts/Dialogue/DialogueSystem.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using FMOD.Studio; using UnityEngine; #if UNITY_EDITOR using UnityEditor; @@ -29,7 +30,17 @@ public partial class DialogueSystem : ScriptableObject { // retrieve cached key var fmodKey = _fmodKeyCache[key]; - var eventDescription = FMODUnity.RuntimeManager.GetEventDescription(fmodKey); + + EventDescription? eventDescription = null; + + try + { + eventDescription = FMODUnity.RuntimeManager.GetEventDescription(fmodKey); + } + catch (FMODUnity.EventNotFoundException e) + { + Debug.LogWarning($"no FMOD event {fmodKey}"); + } DialogueLine dl; dl.text = DialogueDatabase.ReadDialogue(key); @@ -37,12 +48,12 @@ public partial class DialogueSystem : ScriptableObject dl.duration = _settings.HideAfter; // read audio data out of FMOD, check if event exists - if (eventDescription.isValid()) + if (eventDescription.HasValue) { // assign values and play audio // get dialogue line duration from FMOD - eventDescription.getLength(out int ms); + eventDescription.Value.getLength(out int ms); // get length gives us a value in milliseconds so it needs to be converted to seconds // before assignment @@ -51,11 +62,6 @@ public partial class DialogueSystem : ScriptableObject // event is valid FMODUnity.RuntimeManager.PlayOneShot(fmodKey); } - else - { - // no event available boooooooo - Debug.LogError($"FMOD event desc for key {fmodKey} is not valid", this); - } onDialogueLine?.Invoke(this, dl); }