Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < monster.length; i++) {
- int xwertmonster = monster[i].getPosition().getX();
- int ywertmonster = monster[i].getPosition().getY();
- if (nahrung == nahrungmax) {
- return EventType.LEVEL_FINISHED;
- }
- if (ywertmonster != ywertplayer && xwertmonster != xwertplayer) {
- return EventType.NONE;
- }
- if ((monster[i].getDirection().equals(Direction.EAST)
- && (player.getDirection().equals(Direction.WEST)))
- && (xwertmonster - xwertplayer) == 1) {
- xwertplayer += 1;
- Position zwischenmonsterundplayer =
- new Position(xwertplayer, ywertplayer);
- if (!getWorld().isValid(zwischenmonsterundplayer)) {
- return EventType.NONE;
- }
- return EventType.COLLISION_EVEN;
- }
- if ((monster[i].getDirection().equals(Direction.NORTH)
- && (player.getDirection().equals(Direction.SOUTH)))
- && (xwertmonster - xwertplayer) == 1) {
- ywertplayer += 1;
- Position zwischenmonsterundplayer =
- new Position(xwertplayer, ywertplayer);
- if (!getWorld().isValid(zwischenmonsterundplayer)) {
- return EventType.NONE;
- }
- return EventType.COLLISION_EVEN;
- }
- if ((monster[i].getDirection().equals(Direction.WEST)
- && (player.getDirection().equals(Direction.EAST)))
- && (xwertmonster - xwertplayer) == 1) {
- xwertplayer += 1;
- Position zwischenmonsterundplayer =
- new Position(xwertplayer, ywertplayer);
- if (!getWorld().isValid(zwischenmonsterundplayer)) {
- return EventType.NONE;
- }
- return EventType.COLLISION_EVEN;
- }
- if ((monster[i].getDirection().equals(Direction.SOUTH)
- && (player.getDirection().equals(Direction.NORTH)))
- && (xwertmonster - xwertplayer) == 1) {
- Position zwischenmonsterundplayer =
- new Position(xwertplayer, ywertplayer);
- if (!getWorld().isValid(zwischenmonsterundplayer)) {
- return EventType.NONE;
- }
- return EventType.COLLISION_EVEN;
- }
- if ((monster[i].getDirection().equals(Direction.EAST)
- && (player.getDirection().equals(Direction.WEST)))
- && (xwertmonster - xwertplayer) == 0) {
- return EventType.COLLISION_ODD;
- }
- if ((monster[i].getDirection().equals(Direction.NORTH)
- && (player.getDirection().equals(Direction.SOUTH)))
- && (xwertmonster - xwertplayer) == 0) {
- return EventType.COLLISION_ODD;
- }
- if ((monster[i].getDirection().equals(Direction.WEST)
- && (player.getDirection().equals(Direction.EAST)))
- && (xwertmonster - xwertplayer) == 0) {
- return EventType.COLLISION_ODD;
- }
- if ((monster[i].getDirection().equals(Direction.SOUTH)
- && (player.getDirection().equals(Direction.NORTH)))
- && (xwertmonster - xwertplayer) == 0) {
- return EventType.COLLISION_ODD;
- }
- }
- return EventType.NONE;
Add Comment
Please, Sign In to add comment