CapersProject/Assets/02.Scripts/Tycoon/LiquidInteractionRegion.cs
2024-09-24 19:35:49 +09:00

42 lines
966 B
C#

using System;
using BlueWater.Players.Tycoons;
using UnityEngine;
namespace BlueWater
{
public class LiquidInteractionRegion : MonoBehaviour
{
private TycoonPlayer _tycoonPlayer;
private bool _isEntered;
private void Start()
{
_tycoonPlayer = GameManager.Instance.CurrentTycoonPlayer;
}
private void Update()
{
if (!_isEntered) return;
if (_tycoonPlayer.TycoonPickupHandler.IsPickedUpItem()) return;
EventManager.OnLiquidRegionEntered?.Invoke();
}
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player")) return;
_isEntered = true;
}
private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("Player")) return;
_isEntered = false;
EventManager.OnLiquidRegionExited?.Invoke();
}
}
}