InputSetting.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using Core;
  3. using UnityEngine;
  4. public static class InputSetting
  5. {
  6. public static bool IsWorking()
  7. {
  8. return Core.Input.JoystickIsOpen;
  9. }
  10. public static void Stop(bool noRecord = false)
  11. {
  12. Log.Info("stop the input system");
  13. if (noRecord)
  14. {
  15. Core.Input.JoystickIsOpen = false;
  16. SingletonMono<MobileInputPlayer>.Instance.Visible = false;
  17. }
  18. else
  19. {
  20. InputSetting._pauseCount += 1u;
  21. if (InputSetting._pauseCount > 0u)
  22. {
  23. Core.Input.JoystickIsOpen = false;
  24. if (R.Mode.CurrentMode == Mode.AllMode.UI || R.Mode.CurrentMode == Mode.AllMode.Story)
  25. {
  26. return;
  27. }
  28. SingletonMono<MobileInputPlayer>.Instance.Visible = false;
  29. }
  30. }
  31. }
  32. public static void Resume(bool noRecord = false)
  33. {
  34. Log.Info("resume the input system");
  35. if (noRecord)
  36. {
  37. Core.Input.JoystickIsOpen = true;
  38. if (R.Mode.CurrentMode == Mode.AllMode.UI || R.Mode.CurrentMode == Mode.AllMode.Story)
  39. {
  40. return;
  41. }
  42. SingletonMono<MobileInputPlayer>.Instance.Visible = true;
  43. }
  44. else
  45. {
  46. if (InputSetting._pauseCount == 0u)
  47. {
  48. Log.Warning("InputSetting is never pause when resume");
  49. return;
  50. }
  51. InputSetting._pauseCount -= 1u;
  52. if (InputSetting._pauseCount <= 0u)
  53. {
  54. Core.Input.JoystickIsOpen = true;
  55. if (R.Mode.CurrentMode == Mode.AllMode.UI || R.Mode.CurrentMode == Mode.AllMode.Story)
  56. {
  57. return;
  58. }
  59. SingletonMono<MobileInputPlayer>.Instance.Visible = true;
  60. }
  61. }
  62. }
  63. public static int JudgeDir(Vector3 from, Vector3 to)
  64. {
  65. return InputSetting.JudgeDir(from.x, to.x);
  66. }
  67. public static int JudgeDir(float from, float to)
  68. {
  69. return (to - from <= 0f) ? -1 : 1;
  70. }
  71. public const int LEFT = -1;
  72. public const int RIGHT = 1;
  73. public const int STOP = 0;
  74. public const int CURRENT = 3;
  75. public const int UP = 2;
  76. public const int DOWN = -2;
  77. public const int RIGHT_UP = 4;
  78. public const int RIGHT_DOWN = -4;
  79. public const int LEFT_UP = 5;
  80. public const int LEFT_DOWN = -5;
  81. public static bool Assistant = true;
  82. private static uint _pauseCount;
  83. }