initial room transitioning
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user