48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
public class BaseInteractableObject : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
public Transform _interactionPoint;
|
|
[SerializeField]
|
|
public List<ItemsMenuActionSO> _menuActions;
|
|
|
|
protected Player _player;
|
|
private InteractionStatus _currentStatus=InteractionStatus.Complete;
|
|
|
|
public InteractionStatus Interact(Player player)
|
|
{
|
|
_player=player;
|
|
if (_currentStatus == InteractionStatus.Complete && _menuActions.Any())
|
|
{
|
|
UIManager.Instance.ShowItemsMenu(_menuActions,PopupMenuCallback);
|
|
_currentStatus = InteractionStatus.WaitForChoose;
|
|
}
|
|
else if(_currentStatus!=InteractionStatus.WaitForChoose)
|
|
{
|
|
if (_player.IsPathComplete(_interactionPoint.position))
|
|
{
|
|
InteractAction();
|
|
_currentStatus = InteractionStatus.Complete;
|
|
}
|
|
else
|
|
{
|
|
_currentStatus = InteractionStatus.FarFromPlayer;
|
|
}
|
|
}
|
|
return _currentStatus;
|
|
}
|
|
|
|
private void PopupMenuCallback()
|
|
{
|
|
_currentStatus = InteractionStatus.InProgress;
|
|
}
|
|
|
|
protected virtual void InteractAction()
|
|
{
|
|
|
|
}
|
|
}
|