/src/isa/gui/GameInput.java

https://gitlab.com/rsgm123/ISA · Java · 154 lines · 129 code · 19 blank · 6 comment · 38 complexity · 93a11c418140f5f4607fa6e27d8b8e84 MD5 · raw file

  1. package isa.gui;
  2. import com.badlogic.gdx.InputProcessor;
  3. import com.badlogic.gdx.graphics.Color;
  4. import isa.Gameplay;
  5. import isa.Person;
  6. import isa.gui.GameScreen.Tab;
  7. public class GameInput implements InputProcessor {
  8. public static int scroll;
  9. public GameScreen screen;
  10. public GameInput(GameScreen screen) {
  11. this.screen = screen;
  12. }
  13. @Override
  14. public boolean keyDown(int keycode) {
  15. return false;
  16. }
  17. @Override
  18. public boolean keyUp(int keycode) {
  19. return false;
  20. }
  21. @Override
  22. public boolean keyTyped(char character) {
  23. return false;
  24. }
  25. @Override
  26. public boolean touchDown(int screenX, int screenY, int pointer, int button) {
  27. if (screen.peopleTab.getBoundingRectangle().contains(screenX, screen.height - screenY)) {
  28. screen.tab = Tab.PEOPLE;
  29. screen.peopleTab.setColor(.7f, .7f, .7f, 1f);
  30. screen.logTab.setColor(Color.WHITE);
  31. screen.storageTab.setColor(Color.WHITE);
  32. scroll = 0;
  33. return true;
  34. } else if (screen.logTab.getBoundingRectangle().contains(screenX, screen.height - screenY)) {
  35. screen.tab = Tab.LOG;
  36. screen.peopleTab.setColor(Color.WHITE);
  37. screen.logTab.setColor(.7f, .7f, .7f, 1f);
  38. screen.storageTab.setColor(Color.WHITE);
  39. scroll = 0;
  40. return true;
  41. } else if (screen.storageTab.getBoundingRectangle().contains(screenX, screen.height - screenY)) {
  42. screen.tab = Tab.STORAGE;
  43. screen.peopleTab.setColor(Color.WHITE);
  44. screen.logTab.setColor(Color.WHITE);
  45. screen.storageTab.setColor(.7f, .7f, .7f, 1f);
  46. scroll = 0;
  47. return true;
  48. }
  49. switch (screen.tab) {
  50. default:
  51. for (Person p : Gameplay.people) {
  52. if (p.suspect.getBoundingRectangle().contains(screenX, screen.height - screenY)) {
  53. p.suspect();
  54. return true;
  55. }
  56. }
  57. break;
  58. case LOG:
  59. // for (Log l : Gameplay.logs) {
  60. // if (l.close.getBoundingRectangle().contains(screenX, screen.height - screenY)) {
  61. // Gameplay.logs.remove(l);
  62. // return true;
  63. // }
  64. // }
  65. break;
  66. case STORAGE:
  67. if (screen.storageBuy10.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money >= 10) {
  68. Gameplay.storage += 10;
  69. Gameplay.money -= 10;
  70. return true;
  71. } else if (screen.storageBuy10.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money < 10) {
  72. screen.errorText = "You do not have enough money for this.";
  73. screen.errorTextCountdownTimerFloatingPointVariable = 3;
  74. return true;
  75. }
  76. if (screen.storageBuy100.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money >= 100) {
  77. Gameplay.storage += 100;
  78. Gameplay.money -= 100;
  79. return true;
  80. } else if (screen.storageBuy100.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money < 100) {
  81. screen.errorText = "You do not have enough money for this.";
  82. screen.errorTextCountdownTimerFloatingPointVariable = 3;
  83. return true;
  84. }
  85. if (screen.storageBuy1000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money >= 1000) {
  86. Gameplay.storage += 1000;
  87. Gameplay.money -= 1000;
  88. return true;
  89. } else if (screen.storageBuy1000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money < 1000) {
  90. screen.errorText = "You do not have enough money for this.";
  91. screen.errorTextCountdownTimerFloatingPointVariable = 3;
  92. return true;
  93. }
  94. if (screen.storageBuy10000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money >= 10000) {
  95. Gameplay.storage += 10000;
  96. Gameplay.money -= 10000;
  97. return true;
  98. } else if (screen.storageBuy10000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money < 10000) {
  99. screen.errorText = "You do not have enough money for this.";
  100. screen.errorTextCountdownTimerFloatingPointVariable = 3;
  101. return true;
  102. }
  103. if (screen.storageBuy100000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money >= 100000) {
  104. Gameplay.storage += 100000;
  105. Gameplay.money -= 100000;
  106. return true;
  107. } else if (screen.storageBuy100000.getBoundingRectangle().contains(screenX, screen.height - screenY) && Gameplay.money < 100000) {
  108. screen.errorText = "You do not have enough money for this.";
  109. screen.errorTextCountdownTimerFloatingPointVariable = 3;
  110. return true;
  111. }
  112. break;
  113. }
  114. return true;
  115. }
  116. @Override
  117. public boolean touchUp(int screenX, int screenY, int pointer, int button) {
  118. return false;
  119. }
  120. @Override
  121. public boolean touchDragged(int screenX, int screenY, int pointer) {
  122. return false;
  123. }
  124. @Override
  125. public boolean mouseMoved(int screenX, int screenY) {
  126. return false;
  127. }
  128. @Override
  129. public boolean scrolled(int amount) {
  130. if ((amount == -1) || (amount == 1 && scroll < 100)) {
  131. scroll += amount * 25;
  132. }
  133. return true;
  134. }
  135. }