generate simple room
This commit is contained in:
44
Assets/Escape Room Engine/Engine/Scripts/Room.cs
Normal file
44
Assets/Escape Room Engine/Engine/Scripts/Room.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user