From 7e9331f6125ec98f9355b4a6b5334dd894d67cb3 Mon Sep 17 00:00:00 2001 From: milan Date: Mon, 7 Nov 2022 11:12:00 +0100 Subject: [PATCH] generic puzzle module --- .../Engine/Materials/Generic Material C.mat | 126 ++++++++++++++++++ .../Generic Material C.mat.meta} | 4 +- ...tion.asset => Generic Door Entrance.asset} | 4 +- .../Generic Door Entrance.asset.meta | 3 + .../Generic Door Exit Description.asset.meta | 8 -- ...cription.asset => Generic Door Exit.asset} | 4 +- .../Generic Door Exit.asset.meta | 3 + ...Description.asset => Generic Module.asset} | 2 +- .../Generic Module.asset.meta | 3 + .../Module Descriptions/Generic Puzzle.asset | 16 +++ ...n.asset.meta => Generic Puzzle.asset.meta} | 2 +- .../{Spawn Description.asset => Spawn.asset} | 2 +- .../Module Descriptions/Spawn.asset.meta | 3 + .../Engine/Prefabs/Generic Puzzle.prefab | 76 +++++++++++ .../Generic Puzzle.prefab.meta} | 5 +- .../Engine/Scripts/Engine.cs | 13 ++ .../Scripts/Modules/DoorModuleDescription.cs | 2 +- .../Scripts/Modules/ModuleDescription.cs | 2 +- .../Engine/Scripts/Modules/ModuleType.cs | 1 + .../Engine/Scripts/Modules/PuzzleModule.cs | 13 ++ .../Scripts/Modules/PuzzleModule.cs.meta | 3 + .../Modules/PuzzleModuleDescription.cs | 9 ++ .../Modules/PuzzleModuleDescription.cs.meta | 3 + Assets/Scenes/TestScene.unity | 10 +- 24 files changed, 292 insertions(+), 25 deletions(-) create mode 100644 Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat rename Assets/Escape Room Engine/Engine/{Module Descriptions/Generic Door Entrance Description.asset.meta => Materials/Generic Material C.mat.meta} (64%) rename Assets/Escape Room Engine/Engine/Module Descriptions/{Generic Door Entrance Description.asset => Generic Door Entrance.asset} (79%) create mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset.meta delete mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset.meta rename Assets/Escape Room Engine/Engine/Module Descriptions/{Generic Door Exit Description.asset => Generic Door Exit.asset} (79%) create mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset.meta rename Assets/Escape Room Engine/Engine/Module Descriptions/{Generic Module Description.asset => Generic Module.asset} (92%) create mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset.meta create mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset rename Assets/Escape Room Engine/Engine/Module Descriptions/{Generic Module Description.asset.meta => Generic Puzzle.asset.meta} (79%) rename Assets/Escape Room Engine/Engine/Module Descriptions/{Spawn Description.asset => Spawn.asset} (95%) create mode 100644 Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset.meta create mode 100644 Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab rename Assets/Escape Room Engine/Engine/{Module Descriptions/Spawn Description.asset.meta => Prefabs/Generic Puzzle.prefab.meta} (52%) create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs.meta create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs create mode 100644 Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs.meta diff --git a/Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat b/Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat new file mode 100644 index 0000000..35612ed --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat @@ -0,0 +1,126 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-7117340174757956021 +MonoBehaviour: + m_ObjectHideFlags: 11 + 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: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 5 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Generic Material C + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AlphaClip: 0 + - _Blend: 0 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _Cull: 2 + - _Cutoff: 0.5 + - _DetailAlbedoMapScale: 1 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _Metallic: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.005 + - _QueueOffset: 0 + - _ReceiveShadows: 1 + - _Smoothness: 0.5 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _Surface: 0 + - _WorkflowMode: 1 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 0, a: 1} + - _Color: {r: 1, g: 1, b: 0, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset.meta b/Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat.meta similarity index 64% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset.meta rename to Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat.meta index bb32b05..98a434e 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset.meta +++ b/Assets/Escape Room Engine/Engine/Materials/Generic Material C.mat.meta @@ -1,8 +1,8 @@ fileFormatVersion: 2 -guid: d28f4ecf66835b74894687865fe95018 +guid: 46455800cc2ce524c92336599f5ec772 NativeFormatImporter: externalObjects: {} - mainObjectFileID: 11400000 + mainObjectFileID: 2100000 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset similarity index 79% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset rename to Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset index 42ff1c1..2f727bc 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance Description.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset @@ -10,10 +10,10 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} - m_Name: Generic Door Entrance Description + m_Name: Generic Door Entrance m_EditorClassIdentifier: modulePrefab: {fileID: 5399176795272327488, guid: da9b7a57e7c37d149827fe17188bdeea, type: 3} doorType: 0 - connectedDoorDescription: {fileID: 11400000, guid: 9f41a4c77b171754884cdf194aa156ea, + connectedDoorDescription: {fileID: 11400000, guid: 29e2ae36585f4e65966bc9ea2f95ac4a, type: 2} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset.meta new file mode 100644 index 0000000..376170b --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Entrance.asset.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a70cb93176094309a847f1928d6b950d +timeCreated: 1667873700 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset.meta deleted file mode 100644 index 437489d..0000000 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9f41a4c77b171754884cdf194aa156ea -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 11400000 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset similarity index 79% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset rename to Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset index a8b9dee..b6ca173 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit Description.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset @@ -10,10 +10,10 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} - m_Name: Generic Door Exit Description + m_Name: Generic Door Exit m_EditorClassIdentifier: modulePrefab: {fileID: 5399176795272327488, guid: d877ee36ba6ace440aebce2c20cf70d6, type: 3} doorType: 1 - connectedDoorDescription: {fileID: 11400000, guid: d28f4ecf66835b74894687865fe95018, + connectedDoorDescription: {fileID: 11400000, guid: a70cb93176094309a847f1928d6b950d, type: 2} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset.meta new file mode 100644 index 0000000..3232529 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Door Exit.asset.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 29e2ae36585f4e65966bc9ea2f95ac4a +timeCreated: 1667873700 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset similarity index 92% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset rename to Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset index cb6a4cc..ae10c70 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: abf4a405f6c64073995bded39977563e, type: 3} - m_Name: Generic Module Description + m_Name: Generic Module m_EditorClassIdentifier: modulePrefab: {fileID: 3864228228344123331, guid: ad2655de8289afa40aa520f9fc474681, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset.meta new file mode 100644 index 0000000..437571a --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module.asset.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cba85a4318ad4750860b84245d9685c4 +timeCreated: 1667873700 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset new file mode 100644 index 0000000..e194a6d --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.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: f928b97941e3469a9015316bb5ac1309, type: 3} + m_Name: Generic Puzzle + m_EditorClassIdentifier: + modulePrefab: {fileID: 1780958886295268827, guid: e419cb35bd744b24ea973860d8b1405d, + type: 3} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset.meta similarity index 79% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset.meta rename to Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset.meta index d5e28ed..865db33 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Module Description.asset.meta +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Generic Puzzle.asset.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7400e74756d4cc049b9af0469bba3e00 +guid: 2a6dd6683bdc4db9b200ccfab1dd4bed NativeFormatImporter: externalObjects: {} mainObjectFileID: 11400000 diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset similarity index 95% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset rename to Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset index 5493829..66a957b 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: f5c1202346c34ebc9c3f701a98b50877, type: 3} - m_Name: Spawn Description + m_Name: Spawn m_EditorClassIdentifier: modulePrefab: {fileID: 278361332033420131, guid: db5350cd22f3a0f4f818a5f985342136, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset.meta b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset.meta new file mode 100644 index 0000000..9f05ac8 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn.asset.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6e937b2e9f774999b5962c4b40947165 +timeCreated: 1667873701 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab new file mode 100644 index 0000000..9b6d0d5 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &3249140089838199320 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3864228228344123331, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_Name + value: Generic Puzzle + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_RootOrder + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7860513085978939562, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8884008595548699417, guid: ad2655de8289afa40aa520f9fc474681, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: 46455800cc2ce524c92336599f5ec772, type: 2} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: ad2655de8289afa40aa520f9fc474681, type: 3} diff --git a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset.meta b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab.meta similarity index 52% rename from Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset.meta rename to Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab.meta index 86e17b8..4995ff1 100644 --- a/Assets/Escape Room Engine/Engine/Module Descriptions/Spawn Description.asset.meta +++ b/Assets/Escape Room Engine/Engine/Prefabs/Generic Puzzle.prefab.meta @@ -1,8 +1,7 @@ fileFormatVersion: 2 -guid: 0e4c15f85acfd754997a7a9d04c19c3e -NativeFormatImporter: +guid: e419cb35bd744b24ea973860d8b1405d +PrefabImporter: externalObjects: {} - mainObjectFileID: 11400000 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/Escape Room Engine/Engine/Scripts/Engine.cs b/Assets/Escape Room Engine/Engine/Scripts/Engine.cs index 9c89848..ab1cacf 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Engine.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Engine.cs @@ -27,11 +27,13 @@ namespace Escape_Room_Engine.Engine.Scripts public Material roomMaterial; + [Range(0, 10)] public int minPuzzleCount, maxPuzzleCount; [Tooltip("The minimum size that should be allowed for rooms.")] public Vector2Int minRoomSize; [Tooltip("The size of the physical play space available to the engine.")] public Vector2Int playSpace; public ModuleDescription genericModule; public DoorModuleDescription spawnDoor; public List exitDoorTypes; + public List puzzleTypes; private int NumberOfRooms => _rooms.Count; @@ -77,6 +79,17 @@ namespace Escape_Room_Engine.Engine.Scripts var exit = new Passage(exitDoor); space.AddModule(exitDoor); + // add puzzles + for (var i = 0; i < Utilities.Utilities.RandomInclusive(minPuzzleCount, maxPuzzleCount); i++) + { + var puzzle = new PuzzleModule(space, puzzleTypes.RandomElement()); + puzzle.Place(new Vector2Int( + Random.Range(0, rrDimensions.width), + Random.Range(0, rrDimensions.length) + )); + space.AddModule(puzzle); + } + room.AddSpace(space, exit); } diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs index a89450a..e93f887 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/DoorModuleDescription.cs @@ -2,7 +2,7 @@ namespace Escape_Room_Engine.Engine.Scripts.Modules { - [CreateAssetMenu(menuName = "Door Module")] + [CreateAssetMenu(menuName = "Modules/Door")] public class DoorModuleDescription : ModuleDescription { public DoorType doorType; diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs index ed6e876..0762504 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleDescription.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace Escape_Room_Engine.Engine.Scripts.Modules { - [CreateAssetMenu(menuName = "Generic Module")] + [CreateAssetMenu(menuName = "Modules/Generic Module")] public class ModuleDescription : ScriptableObject { public readonly HashSet types = new(); diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleType.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleType.cs index 0577219..eea3582 100644 --- a/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleType.cs +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/ModuleType.cs @@ -3,5 +3,6 @@ public enum ModuleType { DoorEntrance, DoorExit, // door types + Puzzle, } } \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs new file mode 100644 index 0000000..5c4b1d2 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Modules +{ + public class PuzzleModule : Module + { + internal PuzzleModule(Space space, PuzzleModuleDescription description) : base(space, description) + { + _description.types.Add(ModuleType.Puzzle); + srDimensions.Size = Vector2Int.one; // TODO: larger modules + } + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs.meta new file mode 100644 index 0000000..11aef2d --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModule.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ed86ddbc20ae479895ab3c538ea9226f +timeCreated: 1667873701 \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs new file mode 100644 index 0000000..310a643 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace Escape_Room_Engine.Engine.Scripts.Modules +{ + [CreateAssetMenu(menuName = "Modules/Puzzle")] + public class PuzzleModuleDescription : ModuleDescription + { + } +} \ No newline at end of file diff --git a/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs.meta b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs.meta new file mode 100644 index 0000000..69584f0 --- /dev/null +++ b/Assets/Escape Room Engine/Engine/Scripts/Modules/PuzzleModuleDescription.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f928b97941e3469a9015316bb5ac1309 +timeCreated: 1667873701 \ No newline at end of file diff --git a/Assets/Scenes/TestScene.unity b/Assets/Scenes/TestScene.unity index fc7b2e6..0451cc3 100644 --- a/Assets/Scenes/TestScene.unity +++ b/Assets/Scenes/TestScene.unity @@ -1233,12 +1233,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: roomMaterial: {fileID: 2100000, guid: 39e2ed014eda5d6408c16fbf0fa80781, type: 2} + minPuzzleCount: 2 + maxPuzzleCount: 5 minRoomSize: {x: 3, y: 3} playSpace: {x: 4, y: 6} - genericModule: {fileID: 11400000, guid: 7400e74756d4cc049b9af0469bba3e00, type: 2} - spawnDoor: {fileID: 11400000, guid: 0e4c15f85acfd754997a7a9d04c19c3e, type: 2} + genericModule: {fileID: 11400000, guid: cba85a4318ad4750860b84245d9685c4, type: 2} + spawnDoor: {fileID: 11400000, guid: 6e937b2e9f774999b5962c4b40947165, type: 2} exitDoorTypes: - - {fileID: 11400000, guid: 9f41a4c77b171754884cdf194aa156ea, type: 2} + - {fileID: 11400000, guid: 29e2ae36585f4e65966bc9ea2f95ac4a, type: 2} + puzzleTypes: + - {fileID: 11400000, guid: 2a6dd6683bdc4db9b200ccfab1dd4bed, type: 2} --- !u!4 &1568048335 Transform: m_ObjectHideFlags: 0