Guest User

Untitled

a guest
Dec 10th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. package nz.artedungeon.strategies;
  2.  
  3. import com.rsbuddy.script.methods.Objects;
  4. import com.rsbuddy.script.wrappers.GameObject;
  5. import nz.artedungeon.DungeonMain;
  6. import nz.artedungeon.common.Strategy;
  7. import nz.artedungeon.dungeon.Explore;
  8. import nz.artedungeon.dungeon.MyPlayer;
  9. import nz.artedungeon.dungeon.doors.Door;
  10. import nz.artedungeon.dungeon.doors.Normal;
  11. import nz.artedungeon.dungeon.rooms.Room;
  12. import nz.artedungeon.misc.GameConstants;
  13.  
  14.  
  15. public class ChangeRoom extends Strategy
  16. {
  17.  
  18. public ChangeRoom(DungeonMain parent) {
  19. super(parent);
  20. }
  21.  
  22.  
  23. public int execute() {
  24. for (Room room : Explore.getRooms()) {
  25. if (room.contains(MyPlayer.location())) {
  26. MyPlayer.setLastRoom(MyPlayer.currentRoom());
  27. MyPlayer.setCurrentRoom(room);
  28. MyPlayer.setCurArea(MyPlayer.currentRoom().getArea());
  29. //TODO Might need this
  30. // if (!MyPlayer.lastDoorOpened().isOpen() &&
  31. // Calculations.distanceTo(MyPlayer.lastDoorOpened().getLocation()) < 5) {
  32. // MyPlayer.lastDoorOpened().setOpen(true);
  33. // MyPlayer.lastRoom()
  34. // .updateDoor(MyPlayer.lastDoorOpened());
  35. // MyPlayer.lastDoorOpened().setConnector(MyPlayer.currentRoom());
  36. // Explore.getDoors().remove(MyPlayer.lastDoorOpened());
  37. // Explore.getDoors().add(MyPlayer.lastDoorOpened());
  38. // }
  39. return random(400, 600);
  40. }
  41. }
  42. MyPlayer.setLastRoom(MyPlayer.currentRoom());
  43. MyPlayer.setCurrentRoom(Explore.newRoom());
  44. updateDoors();
  45. if (Objects.getNearest(GameConstants.BOSS_DOORS) != null && Explore.getBossRoom() == null) {
  46. Explore.setBossRoom(MyPlayer.currentRoom());
  47. parent.foundBoss = true;
  48. GameObject bossDoor = Objects.getNearest(GameConstants.BOSS_DOORS);
  49. Door tempDoor = new Normal(bossDoor, parent);
  50. tempDoor.setConnector(MyPlayer.lastRoom());
  51. tempDoor.setOpen(true);
  52. Explore.getDoors().add(tempDoor);
  53. }
  54. return random(400, 600);
  55. }
  56.  
  57. public void updateDoors() {
  58. MyPlayer.setLastDoorOpended(MyPlayer.lastRoom().getClosestDoorAll());
  59. Door closestDoor = MyPlayer.currentRoom().getClosestDoorTo(MyPlayer.lastDoorOpened());
  60. if (closestDoor != null) {
  61. closestDoor.setOpen(true);
  62. closestDoor.setConnector(MyPlayer.lastRoom());
  63. }
  64. MyPlayer.lastDoorOpened().setOpen(true);
  65. MyPlayer.lastRoom().updateDoor(MyPlayer.lastDoorOpened());
  66. MyPlayer.currentRoom().updateDoor(closestDoor);
  67. MyPlayer.lastDoorOpened().setConnector(MyPlayer.currentRoom());
  68. Explore.getDoors().remove(MyPlayer.lastDoorOpened());
  69. Explore.getDoors().add(MyPlayer.lastDoorOpened());
  70. Explore.getDoors().remove(closestDoor);
  71. Explore.getDoors().add(closestDoor);
  72. }
  73.  
  74. public boolean isValid() {
  75. return MyPlayer.currentRoom() != null && !MyPlayer.currentRoom().contains(MyPlayer.location());
  76. }
  77.  
  78.  
  79. public void reset() {
  80.  
  81. }
  82.  
  83. public String getStatus() {
  84. return "Switching rooms";
  85. }
  86.  
  87. }
Add Comment
Please, Sign In to add comment