2024-06-21 22:11:53 +00:00
|
|
|
using System.Collections;
|
|
|
|
using BlueWater.Utility;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace BlueWater.Maps
|
|
|
|
{
|
|
|
|
public class MapPortal : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private Collider _collider;
|
|
|
|
|
|
|
|
[SerializeField, Required]
|
|
|
|
private Transform _targetTransform;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Vector2 _fadeInOutTime = new(1f, 1f);
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private float _delayAfterFadeIn = 0.5f;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Color _fadeColor = new(0f, 0f, 0f, 0f);
|
|
|
|
|
|
|
|
private Coroutine _portalCoroutineInstance;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
InitializeComponents();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
|
|
private void InitializeComponents()
|
|
|
|
{
|
|
|
|
_collider = GetComponent<Collider>();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
|
{
|
|
|
|
if (!other.CompareTag("Player") || !_targetTransform) return;
|
|
|
|
|
|
|
|
Utils.StartUniqueCoroutine(this, ref _portalCoroutineInstance, PortalCoroutine(other));
|
|
|
|
}
|
|
|
|
|
|
|
|
private IEnumerator PortalCoroutine(Collider other)
|
|
|
|
{
|
|
|
|
PlayerInputKeyManager.Instance.DisableCurrentPlayerInput();
|
2024-10-10 09:32:18 +00:00
|
|
|
EventManager.InvokeFadeInOut(_fadeInOutTime.x, _fadeInOutTime.y, _fadeColor, _delayAfterFadeIn);
|
2024-08-29 09:51:32 +00:00
|
|
|
//CombatUiManager.Instance.FadeInOut(_fadeInOutTime.x, _fadeInOutTime.y, _fadeColor, _delayAfterFadeIn);
|
2024-06-21 22:11:53 +00:00
|
|
|
yield return new WaitForSeconds(_fadeInOutTime.x);
|
|
|
|
|
|
|
|
other.transform.position = _targetTransform.position;
|
|
|
|
yield return new WaitForSeconds(_delayAfterFadeIn + _fadeInOutTime.y);
|
|
|
|
|
|
|
|
PlayerInputKeyManager.Instance.EnableCurrentPlayerInput();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|