| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- #if ENABLE_INPUT_SYSTEM && DNP_NewInputSystem
- using UnityEngine.InputSystem;
- namespace DamageNumbersPro.Demo
- {
- public static class DNP_InputHandler
- {
- // Directions
- public static bool GetRight()
- {
- if(Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.D].isPressed || Keyboard.current[Key.RightArrow].isPressed;
- }
- }
- public static bool GetLeft()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.A].isPressed || Keyboard.current[Key.LeftArrow].isPressed;
- }
- }
- public static bool GetBack()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.S].isPressed || Keyboard.current[Key.DownArrow].isPressed;
- }
- }
- public static bool GetForward()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.W].isPressed || Keyboard.current[Key.UpArrow].isPressed;
- }
- }
- // Vertical
- public static bool GetJump()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.Space].isPressed;
- }
- }
- public static bool GetUp()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.E].isPressed || Keyboard.current[Key.Space].isPressed;
- }
- }
- public static bool GetDown()
- {
- if (Keyboard.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.Q].isPressed || Keyboard.current[Key.LeftShift].isPressed;
- }
- }
- // Mouse
- public static bool GetLeftClick()
- {
- if (Mouse.current == null)
- {
- return false;
- }
- else
- {
- return Mouse.current.leftButton.wasPressedThisFrame;
- }
- }
- public static bool GetLeftHeld()
- {
- if (Mouse.current == null)
- {
- return false;
- }
- else
- {
- return Mouse.current.leftButton.isPressed;
- }
- }
- public static bool GetRightClick()
- {
- if (Mouse.current == null)
- {
- return false;
- }
- else
- {
- return Mouse.current.rightButton.wasPressedThisFrame;
- }
- }
- public static bool GetRightHeld()
- {
- if (Mouse.current == null)
- {
- return false;
- }
- else
- {
- return Mouse.current.rightButton.isPressed;
- }
- }
- public static Vector2 GetMouseDelta()
- {
- if (Mouse.current == null)
- {
- return Vector2.zero;
- }
- else
- {
- return 100f * Mouse.current.delta.ReadValue() / (float) Screen.height;
- }
- }
- public static float GetMouseScroll()
- {
- if (Mouse.current == null)
- {
- return 0;
- }
- else
- {
- return Mouse.current.scroll.ReadValue().y;
- }
- }
- // Escape
- public static bool GetEscape()
- {
- if (Mouse.current == null)
- {
- return false;
- }
- else
- {
- return Keyboard.current[Key.Escape].wasPressedThisFrame;
- }
- }
- }
- }
- #else
- namespace DamageNumbersPro.Demo
- {
- public static class DNP_InputHandler
- {
- // Directions
- public static bool GetRight()
- {
- return Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow);
- }
- public static bool GetLeft()
- {
- return Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow);
- }
- public static bool GetBack()
- {
- return Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow);
- }
- public static bool GetForward()
- {
- return Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow);
- }
- // Vertical
- public static bool GetJump()
- {
- return Input.GetKey(KeyCode.Space);
- }
- public static bool GetUp()
- {
- return Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Space);
- }
- public static bool GetDown()
- {
- return Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.LeftShift);
- }
- // Other
- public static bool GetLeftClick()
- {
- return Input.GetMouseButtonDown(0);
- }
- public static bool GetLeftHeld()
- {
- return Input.GetMouseButton(0);
- }
- public static bool GetRightClick()
- {
- return Input.GetMouseButtonDown(1);
- }
- public static bool GetRightHeld()
- {
- return Input.GetMouseButton(1);
- }
- public static Vector2 GetMouseDelta()
- {
- return new Vector2(Input.GetAxisRaw("Mouse X") * 2f, Input.GetAxisRaw("Mouse Y") * 2f);
- }
- public static float GetMouseScroll()
- {
- return Input.mouseScrollDelta.y;
- }
- // Escape
- public static bool GetEscape()
- {
- return Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Tab) || Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.P) || Input.GetKeyDown(KeyCode.I);
- }
- }
- }
- #endif
|