room Gen, doors

This commit is contained in:
2025-06-30 16:28:30 +02:00
parent b4d49703d2
commit ba83e64b8d
4 changed files with 188 additions and 162 deletions

View File

@@ -8,6 +8,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -600122568662034771, guid: 1a5d554c0c76caf4195cae47e098b79d, type: 3}
propertyPath: prefabSize.x
value: 10
objectReference: {fileID: 0}
- target: {fileID: 3479177569595356638, guid: 1a5d554c0c76caf4195cae47e098b79d, type: 3}
propertyPath: m_LocalPosition.x
value: 20

View File

@@ -5,6 +5,11 @@ public class DoorController : MonoBehaviour
[SerializeField] private Animator doorLAnimator;
[SerializeField] private Animator doorRAnimator;
public void Start()
{
//OpenDoor();
}
public void OpenDoor()
{
doorLAnimator.SetTrigger("Open");

View File

@@ -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"));
}
}
}