room Gen, doors
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
///<summary>
|
||||
@@ -6,11 +7,24 @@ using UnityEngine;
|
||||
///
|
||||
public class RoomHandler : MonoBehaviour
|
||||
{
|
||||
[Header("Doors")]
|
||||
[SerializeField] private GameObject wallNorth;
|
||||
[SerializeField] private GameObject wallSouth;
|
||||
[SerializeField] private GameObject wallEast;
|
||||
[SerializeField] private GameObject wallWest;
|
||||
|
||||
public enum Side
|
||||
{
|
||||
North,
|
||||
South,
|
||||
East,
|
||||
West
|
||||
}
|
||||
|
||||
private readonly Dictionary<Side, DoorAnimation> doors = new();
|
||||
|
||||
public void RegisterDoor(Side dir, DoorAnimation doorAnim) => doors[dir] = doorAnim;
|
||||
|
||||
/// <summary>
|
||||
/// Creates entrances to corridors leading to other rooms
|
||||
/// </summary>
|
||||
@@ -25,4 +39,21 @@ public class RoomHandler : MonoBehaviour
|
||||
wallEast.SetActive(!eastOpen);
|
||||
wallWest.SetActive(!westOpen);
|
||||
}
|
||||
|
||||
public void ToggleAllDoors()
|
||||
{
|
||||
foreach (DoorAnimation door in doors.Values)
|
||||
{
|
||||
door.ToggleDoor();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDoorState(Side dir, bool open)
|
||||
{
|
||||
if (doors.TryGetValue(dir, out DoorAnimation da))
|
||||
{
|
||||
da.ToggleDoor();
|
||||
Debug.Log("Door " + dir + " is now " + (open ? "open" : "closed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user