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

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