45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|