using System;
using UnityEngine;

public class PlayManager : SingletonMonoBehaviour<PlayManager>
{
    protected override void OnAwake()
    {
        if (GameManager.Instance == null)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
            return;
        }
        //if( GameManager.Instance.isSpeedRun)
        //{
        //    Debug.Log("SpeedRun 모드 활성화");
        //}
        //else
        //{
        //    Debug.Log("일반 모드 활성화");
        //}
    }

    Event keyEvent;


    public Action keyWdown = null;
    public Action keyAdown = null;
    public Action keySdown = null;
    public Action keyDdown = null;
    public Action keyWup = null;
    public Action keySup = null;
    public Action keyAup = null;
    public Action keyDup = null;
    public Action kewEsc = null;
    public Action keySpace = null;
    private void OnGUI()
    {
        keyEvent = Event.current;
        if (keyEvent.type == EventType.KeyDown)  // 키가 눌린 경우
        {
            switch (Event.current.keyCode)
            {
                case KeyCode.Escape:
                    kewEsc?.Invoke();

                    break;
                case KeyCode.A:
                    keyAdown?.Invoke();
                    break;
                case KeyCode.D:
                    keyDdown?.Invoke();
                    break;
                case KeyCode.S:
                    keySdown?.Invoke();
                    break;
                case KeyCode.W:
                    keyWdown?.Invoke();
                    break;
                case KeyCode.Space:
                    Debug.Log(keySpace);
                    keySpace?.Invoke();
                    break;
            }
        }
        else if (keyEvent.type == EventType.KeyUp)
        {
            switch (Event.current.keyCode)
            {
                case KeyCode.A:
                    keyAup?.Invoke();
                    break;
                case KeyCode.D:
                    keyDup?.Invoke();
                    break;
                case KeyCode.S:
                    keySup?.Invoke();
                    break;
                case KeyCode.W:
                    keyWup?.Invoke();
                    break;
            }
        }
    }

}
