Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / manager / InputManager.cs
@小李xl 小李xl on 9 Jul 2023 3 KB 修复拾起道具的bug
  1.  
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 输入管理器
  6. /// </summary>
  7. public static class InputManager
  8. {
  9. /// <summary>
  10. /// 移动方向, 键鼠: 键盘WASD
  11. /// </summary>
  12. public static Vector2 MoveAxis { get; private set; }
  13. /// <summary>
  14. /// 鼠标在SubViewport节点下的坐标, 键鼠: 鼠标移动
  15. /// </summary>
  16. public static Vector2 CursorPosition { get; private set; }
  17. /// <summary>
  18. /// 是否按下打开轮盘按钮, 键鼠: 键盘Tab
  19. /// </summary>
  20. public static bool Roulette { get; set; }
  21. /// <summary>
  22. /// 是否按下切换上一把武器, 键鼠: 键盘Q
  23. /// </summary>
  24. public static bool ExchangeWeapon { get; private set; }
  25.  
  26. /// <summary>
  27. /// 是否按下投抛武器按钮, 键鼠: 键盘G
  28. /// </summary>
  29. public static bool ThrowWeapon { get; private set; }
  30. /// <summary>
  31. /// 是否按下使用道具按钮, 键鼠: 键盘F
  32. /// </summary>
  33. public static bool UseActiveProp { get; private set; }
  34. /// <summary>
  35. /// 是否按下切换道具按钮, 键鼠: 键盘Z
  36. /// </summary>
  37. public static bool ExchangeProp { get; private set; }
  38. /// <summary>
  39. /// 是否按下丢弃道具按钮, 键鼠: 键盘X
  40. /// </summary>
  41. public static bool RemoveProp { get; private set; }
  42. /// <summary>
  43. /// 是否按钮互动按钮, 键鼠: 键盘E
  44. /// </summary>
  45. public static bool Interactive { get; private set; }
  46. /// <summary>
  47. /// 是否按钮换弹按钮, 键鼠: 键盘R
  48. /// </summary>
  49. public static bool Reload { get; private set; }
  50. /// <summary>
  51. /// 是否按钮开火按钮, 键鼠: 鼠标左键
  52. /// </summary>
  53. public static bool Fire { get; private set; }
  54. /// <summary>
  55. /// 是否按钮近战攻击按钮 (使用远程武器发起的近战攻击), 键鼠: 鼠标右键
  56. /// </summary>
  57. public static bool MeleeAttack { get; private set; }
  58. /// <summary>
  59. /// 是否按下翻滚按钮, 键鼠: 键盘Space
  60. /// </summary>
  61. public static bool Roll { get; private set; }
  62. /// <summary>
  63. /// 是否按下打开地图按钮, 键鼠: 键盘Ctrl
  64. /// </summary>
  65. public static bool Map { get; private set; }
  66.  
  67. /// <summary>
  68. /// 更新输入管理器
  69. /// </summary>
  70. public static void Update(float delta)
  71. {
  72. var application = GameApplication.Instance;
  73. MoveAxis = Input.GetVector("move_left", "move_right", "move_up", "move_down");
  74. CursorPosition = application.GlobalToViewPosition(application.GetGlobalMousePosition());
  75. ExchangeWeapon = Input.IsActionJustPressed("exchangeWeapon");
  76. ThrowWeapon = Input.IsActionJustPressed("throwWeapon");
  77. Interactive = Input.IsActionJustPressed("interactive");
  78. Reload = Input.IsActionJustPressed("reload");
  79. Fire = Input.IsActionPressed("fire");
  80. MeleeAttack = Input.IsActionJustPressed("meleeAttack");
  81. Roll = Input.IsActionJustPressed("roll");
  82. UseActiveProp = Input.IsActionJustPressed("useActiveProp");
  83. RemoveProp = Input.IsActionJustPressed("removeProp");
  84. }
  85. }