generic puzzle module

This commit is contained in:
2022-11-07 11:12:00 +01:00
parent 511002833c
commit 7e9331f612
24 changed files with 292 additions and 25 deletions

View File

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

View File

@@ -1,8 +1,8 @@
fileFormatVersion: 2
guid: d28f4ecf66835b74894687865fe95018
guid: 46455800cc2ce524c92336599f5ec772
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a70cb93176094309a847f1928d6b950d
timeCreated: 1667873700

View File

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

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29e2ae36585f4e65966bc9ea2f95ac4a
timeCreated: 1667873700

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cba85a4318ad4750860b84245d9685c4
timeCreated: 1667873700

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: f928b97941e3469a9015316bb5ac1309, type: 3}
m_Name: Generic Puzzle
m_EditorClassIdentifier:
modulePrefab: {fileID: 1780958886295268827, guid: e419cb35bd744b24ea973860d8b1405d,
type: 3}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 7400e74756d4cc049b9af0469bba3e00
guid: 2a6dd6683bdc4db9b200ccfab1dd4bed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6e937b2e9f774999b5962c4b40947165
timeCreated: 1667873701

View File

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

View File

@@ -1,8 +1,7 @@
fileFormatVersion: 2
guid: 0e4c15f85acfd754997a7a9d04c19c3e
NativeFormatImporter:
guid: e419cb35bd744b24ea973860d8b1405d
PrefabImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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<DoorModuleDescription> exitDoorTypes;
public List<PuzzleModuleDescription> 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);
}

View File

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

View File

@@ -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<ModuleType> types = new();

View File

@@ -3,5 +3,6 @@
public enum ModuleType
{
DoorEntrance, DoorExit, // door types
Puzzle,
}
}

View File

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

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed86ddbc20ae479895ab3c538ea9226f
timeCreated: 1667873701

View File

@@ -0,0 +1,9 @@
using UnityEngine;
namespace Escape_Room_Engine.Engine.Scripts.Modules
{
[CreateAssetMenu(menuName = "Modules/Puzzle")]
public class PuzzleModuleDescription : ModuleDescription
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f928b97941e3469a9015316bb5ac1309
timeCreated: 1667873701

View File

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