1. 마우스 클릭 이동 2. 스테이터스 동작 연동 3. 행동 동작 연동 ToDo 1. 공격 모션 추가 하기 2. 점프 모션 추가 하기 3. JSON으로 들어오는 데이터 파싱해서 스테이터스에 담아보기 4. 실제로 AI (적) 구상해서 작성하기.
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class InputManager: IManager
|
|
{
|
|
public Action KeyAction = null;
|
|
public Action<Define.MouseEvent> MouseAction = null;
|
|
|
|
bool _pressed = false;
|
|
float _pressedTime = 0.0f;
|
|
|
|
public void OnUpdate()
|
|
{
|
|
// UI 위에 마우스 있으면 리턴
|
|
if(EventSystem.current.IsPointerOverGameObject()) return;
|
|
|
|
if (Keyboard.current.anyKey.isPressed && KeyAction != null) KeyAction.Invoke();
|
|
|
|
if (MouseAction != null)
|
|
{
|
|
if (Mouse.current.leftButton.isPressed)
|
|
{
|
|
if (!_pressed)
|
|
{
|
|
MouseAction.Invoke(Define.MouseEvent.Down);
|
|
_pressedTime = Time.time;
|
|
}
|
|
MouseAction.Invoke(Define.MouseEvent.Press);
|
|
_pressed = true;
|
|
}
|
|
else
|
|
{
|
|
if (_pressed)
|
|
{
|
|
if (Time.time - _pressedTime < 0.2f)
|
|
MouseAction.Invoke(Define.MouseEvent.Click);
|
|
else
|
|
{
|
|
MouseAction.Invoke(Define.MouseEvent.Up);
|
|
}
|
|
}
|
|
_pressed = false;
|
|
_pressedTime = 0.0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
KeyAction = null;
|
|
MouseAction = null;
|
|
}
|
|
} |