refactor radial menu, every click work as cancel - problem with invoke in radial button add listener
This commit is contained in:
@@ -7,20 +7,25 @@ public class BaseInteractableObject : MonoBehaviour
|
||||
[SerializeField]
|
||||
public Transform _interactionPoint;
|
||||
[SerializeField]
|
||||
public List<ItemsMenuActionSO> _menuActions;
|
||||
public List<RadialMenuActionSO> _menuActions;
|
||||
|
||||
protected Player _player;
|
||||
private InteractionStatus _currentStatus=InteractionStatus.Complete;
|
||||
|
||||
private InteractionStatus _currentStatus = InteractionStatus.None;
|
||||
|
||||
public InteractionStatus Interact(Player player)
|
||||
{
|
||||
_player=player;
|
||||
if (_currentStatus == InteractionStatus.Complete && _menuActions.Any())
|
||||
_player = player;
|
||||
if (_currentStatus == InteractionStatus.None && _menuActions.Any())
|
||||
{
|
||||
UIManager.Instance.ShowItemsMenu(_menuActions,PopupMenuCallback);
|
||||
UIManager.Instance.ShowItemsMenu(_menuActions, PopupMenuCallback);
|
||||
_currentStatus = InteractionStatus.WaitForChoose;
|
||||
}
|
||||
else if(_currentStatus!=InteractionStatus.WaitForChoose)
|
||||
else if (_currentStatus == InteractionStatus.Complete)
|
||||
{
|
||||
_currentStatus = InteractionStatus.None;
|
||||
return InteractionStatus.Complete;
|
||||
}
|
||||
else if (_currentStatus != InteractionStatus.WaitForChoose && _currentStatus != InteractionStatus.Complete)
|
||||
{
|
||||
if (_player.IsPathComplete(_interactionPoint.position))
|
||||
{
|
||||
@@ -35,13 +40,20 @@ public class BaseInteractableObject : MonoBehaviour
|
||||
return _currentStatus;
|
||||
}
|
||||
|
||||
private void PopupMenuCallback()
|
||||
private void PopupMenuCallback(RadialMenuActionSO action)
|
||||
{
|
||||
_currentStatus = InteractionStatus.InProgress;
|
||||
if (action.Action == RadialMenuActions.Cancel)
|
||||
{
|
||||
_currentStatus = InteractionStatus.Complete;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentStatus = InteractionStatus.InProgress;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InteractAction()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user