using UnityEngine;
using UnityEngine.Events;

public class InputController : MonoBehaviour, ISubscriberInput
{
    public UnityEvent butLeftPress;
    public UnityEvent butLeftRelease;
    public UnityEvent butRightPress;
    public UnityEvent butRightRelease;
    public UnityEvent butUpPress;
    public UnityEvent butUpRelease;
    public UnityEvent butDownPress;
    public UnityEvent butDownRelease;
    public UnityEvent butZoomInPress;
    public UnityEvent butZoomInRelease;
    public UnityEvent butZoomOutPress;
    public UnityEvent butZoomOutRelease;

    private void Start()
    {
        subscribe();
    }

    public void notifyInput(EnumActionCommand command)
    {
        switch (command)
        {
            case EnumActionCommand.LEFT_PRESS:
                butLeftPress.Invoke();
                break;
            case EnumActionCommand.LEFT_RELEASE:
                butLeftRelease.Invoke();
                break;
            case EnumActionCommand.RIGHT_PRESS:
                butRightPress.Invoke();
                break;
            case EnumActionCommand.RIGHT_RELEASE:
                butRightRelease.Invoke();
                break;
            case EnumActionCommand.UP_PRESS:
                butUpPress.Invoke();
                break;
            case EnumActionCommand.UP_RELEASE:
                butUpRelease.Invoke();
                break;
            case EnumActionCommand.DOWN_PRESS:
                butDownPress.Invoke();
                break;
            case EnumActionCommand.DOWN_RELEASE:
                butDownRelease.Invoke();
                break;
            case EnumActionCommand.ZOOM_IN_PRESS:
                butZoomInPress.Invoke();
                break;
            case EnumActionCommand.ZOOM_IN_RELEASE:
                butZoomInRelease.Invoke();
                break;
            case EnumActionCommand.ZOOM_OUT_PRESS:
                butZoomOutPress.Invoke();
                break;
            case EnumActionCommand.ZOOM_OUT_RELEASE:
                butZoomOutRelease.Invoke();
                break;
            default:
                break;
        }
    }

    public void subscribe()
    {
        GameObject.FindGameObjectsWithTag("MasterManager")[0].GetComponent<GameInput_Manager>().subscribe(gameObject);
    }
}
