using System;
using UnityEngine;

public class InputManager : Singleton<InputManager>
{

    #region Events
    private event Action _primaryAction = null;
    public event Action PrimaryAction
    {
        add
        {
            _primaryAction -= value;
            _primaryAction += value;
        }
        remove
        {
            _primaryAction -= value;
        }
    }

    private event Action _secondaryAction = null;
    public event Action SecondaryAction
    {
        add
        {
            _secondaryAction -= value;
            _secondaryAction += value;
        }
        remove
        {
            _secondaryAction -= value;
        }
    }

    private event Action _tertiaryAction = null;
    public event Action TertiaryAction
    {
        add
        {
            _tertiaryAction -= value;
            _tertiaryAction += value;
        }
        remove
        {
            _tertiaryAction -= value;
        }
    }
    #endregion Events


    // Update is called once per frame
    private void Update()
    {
        // Get current mode from game manager
        GameState state = GameManager.Instance.CurrentState;
        switch (state)
        {
            case GameState.StartMenu:
                HandleMenuInputs();
                break;
            case GameState.TrajectoryMix:
                HandleTrajectoryMixInputs();
                break;
            case GameState.AngleSelection:
                HandleAngleSelectionInput();
                break;
            case GameState.PowerSelection:
                HandlePowerSelectionInput();
                break;
            case GameState.RocketLaunch:
                HandleRocketLaunchInput();
                break;
            case GameState.EndMenu:
                HandleMenuInputs();
                break;
            default:
                break;
        }



    }

    private void HandleMenuInputs()
    {

    }

    private void HandleTrajectoryMixInputs()
    {

    }

    private void HandleAngleSelectionInput()
    {
        if (Input.GetKeyDown(KeyCode.C))
        {
            _tertiaryAction();
        }

        if (Input.GetMouseButton(0))
        {
            _secondaryAction();
        }

        if (Input.GetMouseButtonDown(1))
        {
            _primaryAction();
        }
    }

    private void HandlePowerSelectionInput()
    {

    }

    private void HandleRocketLaunchInput()
    {

    }
}
