init: version 1

This commit is contained in:
Job
2025-07-17 17:16:02 +02:00
commit a76c0f6445
519 changed files with 202925 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using UnityEngine;
using System.Collections;
/// <summary>
/// ExitController handles the logic of the exit door.
/// </summary>
[RequireComponent(typeof(Animator))]
public class ExitController : Activateable
{
[Header("Configuration")]
public float playerExitDelay = 1f;
private Animator _animator;
private Coroutine _transitionCoroutine;
private void Awake()
{
_animator = GetComponent<Animator>();
}
private void OnTriggerEnter2D(Collider2D other)
{
if (isActive && other.CompareTag("Player"))
{
_transitionCoroutine ??= StartCoroutine(WaitAndTransition());
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (other.CompareTag("Player") && _transitionCoroutine != null)
{
StopCoroutine(_transitionCoroutine);
_transitionCoroutine = null;
}
}
private IEnumerator WaitAndTransition()
{
yield return new WaitForSeconds(playerExitDelay);
TransitionManager.Instance.NextLevel();
_transitionCoroutine = null;
}
protected override void OnActivation()
{
_animator.SetBool("IsActive", true);
}
protected override void OnDeactivation()
{
_animator.SetBool("IsActive", false);
}
}