generate simple room

This commit is contained in:
2022-10-28 21:19:00 +02:00
parent 347b026ade
commit ddb7ce73c9
27 changed files with 635 additions and 2519 deletions

View File

@@ -0,0 +1,44 @@
using System.Collections.Generic;
using UnityEngine;
namespace Escape_Room_Engine.Engine.Scripts
{
public class Room
{
internal Passage entrance, exit;
private GameObject _roomObject;
private List<Space> _spaces = new();
internal Room(Passage entrance)
{
this.entrance = entrance;
}
internal void AddSpace(Space space, Passage spaceExit)
{
_spaces.Add(space);
exit = spaceExit;
}
internal void InstantiateRoom(Transform parent, string name)
{
_roomObject = new GameObject($"Room {name}");
_roomObject.transform.SetParent(parent);
for (var i = 0; i < _spaces.Count; i++)
{
_spaces[i].InstantiateSpace(_roomObject.transform, i.ToString());
}
}
internal void Destroy()
{
foreach (var space in _spaces)
{
space.Destroy();
}
Object.Destroy(_roomObject);
}
}
}