Guest User

Untitled

a guest
Jun 14th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. for (int i = 0; i < monster.length; i++) {
  2. int xwertmonster = monster[i].getPosition().getX();
  3. int ywertmonster = monster[i].getPosition().getY();
  4.  
  5. if (nahrung == nahrungmax) {
  6. return EventType.LEVEL_FINISHED;
  7. }
  8.  
  9. if (ywertmonster != ywertplayer && xwertmonster != xwertplayer) {
  10. return EventType.NONE;
  11. }
  12. if ((monster[i].getDirection().equals(Direction.EAST)
  13. && (player.getDirection().equals(Direction.WEST)))
  14. && (xwertmonster - xwertplayer) == 1) {
  15. xwertplayer += 1;
  16. Position zwischenmonsterundplayer =
  17. new Position(xwertplayer, ywertplayer);
  18. if (!getWorld().isValid(zwischenmonsterundplayer)) {
  19. return EventType.NONE;
  20. }
  21. return EventType.COLLISION_EVEN;
  22. }
  23. if ((monster[i].getDirection().equals(Direction.NORTH)
  24. && (player.getDirection().equals(Direction.SOUTH)))
  25. && (xwertmonster - xwertplayer) == 1) {
  26. ywertplayer += 1;
  27. Position zwischenmonsterundplayer =
  28. new Position(xwertplayer, ywertplayer);
  29. if (!getWorld().isValid(zwischenmonsterundplayer)) {
  30. return EventType.NONE;
  31. }
  32. return EventType.COLLISION_EVEN;
  33. }
  34. if ((monster[i].getDirection().equals(Direction.WEST)
  35. && (player.getDirection().equals(Direction.EAST)))
  36. && (xwertmonster - xwertplayer) == 1) {
  37. xwertplayer += 1;
  38. Position zwischenmonsterundplayer =
  39. new Position(xwertplayer, ywertplayer);
  40. if (!getWorld().isValid(zwischenmonsterundplayer)) {
  41. return EventType.NONE;
  42. }
  43. return EventType.COLLISION_EVEN;
  44. }
  45. if ((monster[i].getDirection().equals(Direction.SOUTH)
  46. && (player.getDirection().equals(Direction.NORTH)))
  47. && (xwertmonster - xwertplayer) == 1) {
  48. Position zwischenmonsterundplayer =
  49. new Position(xwertplayer, ywertplayer);
  50. if (!getWorld().isValid(zwischenmonsterundplayer)) {
  51. return EventType.NONE;
  52. }
  53. return EventType.COLLISION_EVEN;
  54. }
  55. if ((monster[i].getDirection().equals(Direction.EAST)
  56. && (player.getDirection().equals(Direction.WEST)))
  57. && (xwertmonster - xwertplayer) == 0) {
  58. return EventType.COLLISION_ODD;
  59. }
  60. if ((monster[i].getDirection().equals(Direction.NORTH)
  61. && (player.getDirection().equals(Direction.SOUTH)))
  62. && (xwertmonster - xwertplayer) == 0) {
  63. return EventType.COLLISION_ODD;
  64. }
  65. if ((monster[i].getDirection().equals(Direction.WEST)
  66. && (player.getDirection().equals(Direction.EAST)))
  67. && (xwertmonster - xwertplayer) == 0) {
  68. return EventType.COLLISION_ODD;
  69. }
  70. if ((monster[i].getDirection().equals(Direction.SOUTH)
  71. && (player.getDirection().equals(Direction.NORTH)))
  72. && (xwertmonster - xwertplayer) == 0) {
  73. return EventType.COLLISION_ODD;
  74. }
  75. }
  76. return EventType.NONE;
Add Comment
Please, Sign In to add comment