using UnityEngine;
using UnityEngine.EventSystems;

public class TouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public enum ButtonType
    {
        Left,
        Right,
        Fire
    }

    public ButtonType buttonType;

    public void OnPointerDown(PointerEventData eventData)
    {
        switch (buttonType)
        {
            case ButtonType.Left:
                PlayerController.Instance?.SetMoveLeft(true);
                break;
            case ButtonType.Right:
                PlayerController.Instance?.SetMoveRight(true);
                break;
            case ButtonType.Fire:
                PlayerController.Instance?.Fire();
                break;
        }
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        switch (buttonType)
        {
            case ButtonType.Left:
                PlayerController.Instance?.SetMoveLeft(false);
                break;
            case ButtonType.Right:
                PlayerController.Instance?.SetMoveRight(false);
                break;
        }
    }
}
