Files
DougDiggem/Assets/Scripts/RoomDoor.cs
T
2026-02-27 23:55:04 -06:00

54 lines
1.2 KiB
C#

using UnityEngine;
public class RoomDoor : Interactable
{
public RoomDoor linkedDoor;
public bool requiresInteraction; // Do we need to press a button to enter?
TeleportHandler teleportHandler;
// not required and only plays if interaction is required
public Animation doorAnimator;
public AnimationClip openDoor;
public AnimationClip closeDoor;
private void Start()
{
teleportHandler = GameObject.FindWithTag("Player").GetComponent<TeleportHandler>();
}
public override void Interact()
{
if (requiresInteraction)
{
if (doorAnimator && openDoor)
{
doorAnimator.clip = openDoor;
doorAnimator.Play();
}
teleportHandler.EnterRoom(this);
}
}
public void CloseDoor()
{
if (doorAnimator && closeDoor)
{
doorAnimator.clip = closeDoor;
doorAnimator.Play();
}
}
public override void MoveInsideRange()
{
if (!requiresInteraction)
{
teleportHandler.EnterRoom(this);
}
}
public override void MoveOutsideRange()
{
// Do nothing
}
}