コード例 #1
0
ファイル: Doors.java プロジェクト: Onurrr/377_Remake
 public static int getNextFace(Doors d) {
   int f = d.originalFace;
   if (d.type == 0) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         f = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         f = 2;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         f = 3;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         f = 0;
       } else if (d.originalFace != d.currentFace) {
         f = d.originalFace;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         f = 3;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         f = 0;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         f = 1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         f = 2;
       } else if (d.originalFace != d.currentFace) {
         f = d.originalFace;
       }
     }
   } else if (d.type == 9) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         f = 3;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         f = 2;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         f = 1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         f = 0;
       } else if (d.originalFace != d.currentFace) {
         f = d.originalFace;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         f = 3;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         f = 0;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         f = 1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         f = 2;
       } else if (d.originalFace != d.currentFace) {
         f = d.originalFace;
       }
     }
   }
   d.currentFace = f;
   return f;
 }
コード例 #2
0
ファイル: Doors.java プロジェクト: Onurrr/377_Remake
 public static boolean handleDoor(int id, int x, int y, int z) {
   final String objectName =
       GameObjectData.forId(id) != null ? GameObjectData.forId(id).getName().toLowerCase() : "";
   if (!objectName.contains("fence")
           && !objectName.contains("gate")
           && !objectName.contains("door")
       || objectName.contains("trapdoor")
       || objectName.contains("tree")) {
     return false;
   }
   /* Special Doors */
   if (id == 883
       || id == 1805
       || id == 2882
       || id == 2883
       || id == 2623
       || id == 2112
       || id == 1804
       || id == 2266
       || id == 2406
       || id == 2407
       || id == 2631
       || id == 2623
       || id == 8958
       || id == 8959
       || id == 8960
       || id == 1589
       || id == 1590) {
     return false;
   }
   Doors d = getDoor(id, x, y, z);
   if (d == null) {
     return false;
   }
   GameObject g = ObjectHandler.getInstance().getObject(id, x, y, z);
   if (g != null) {
     if (d.type == 9) {
       ObjectHandler.getInstance().removeClip(x, y, z, 9, g.getDef().getFace());
     } else {
       ObjectHandler.getInstance().removeDoorClip(x, y, z, g.getDef().getFace());
     }
   }
   CacheObject c = ObjectLoader.object(id, x, y, z);
   if (c != null) {
     if (d.type == 9) {
       ObjectHandler.getInstance().removeClip(x, y, z, 9, c.getRotation());
     } else {
       ObjectHandler.getInstance().removeDoorClip(x, y, z, c.getRotation());
     }
   }
   int xAdjustment = 0, yAdjustment = 0;
   if (d.type == 0) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = -1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         yAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = 1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         yAdjustment = -1;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         yAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         yAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     }
   } else if (d.type == 9) {
     if (!d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     } else if (d.open) {
       if (d.originalFace == 0 && d.currentFace == 0) {
         xAdjustment = 1;
       } else if (d.originalFace == 1 && d.currentFace == 1) {
         xAdjustment = 1;
       } else if (d.originalFace == 2 && d.currentFace == 2) {
         xAdjustment = -1;
       } else if (d.originalFace == 3 && d.currentFace == 3) {
         xAdjustment = -1;
       }
     }
   }
   if (xAdjustment != 0 || yAdjustment != 0) {
     ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
     new GameObject(
         Constants.EMPTY_OBJECT,
         d.doorX,
         d.doorY,
         d.doorZ,
         0,
         d.type,
         Constants.EMPTY_OBJECT,
         999999999);
   }
   if (d.doorX == d.originalX && d.doorY == d.originalY) {
     d.doorX += xAdjustment;
     d.doorY += yAdjustment;
   } else {
     ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
     new GameObject(
         Constants.EMPTY_OBJECT,
         d.doorX,
         d.doorY,
         d.doorZ,
         0,
         d.type,
         Constants.EMPTY_OBJECT,
         999999999);
     d.doorX = d.originalX;
     d.doorY = d.originalY;
   }
   if (id == 1513) {
     d.doorId = 1534;
   } else if (id == 22
       || id == 2550
       || id == 2551
       || id == 2556
       || id == 2558
       || id == 2557
       || id == 3014) {
     d.doorId = id;
   } else if (d.doorId == d.originalId) {
     if (!d.open) {
       d.doorId += 1;
     } else if (d.open) {
       d.doorId -= 1;
     }
   } else if (d.doorId != d.originalId) {
     if (!d.open) {
       d.doorId -= 1;
     } else if (d.open) {
       d.doorId += 1;
     }
   }
   int newFace = getNextFace(d);
   ObjectHandler.getInstance().removeObject(d.doorX, d.doorY, d.doorZ, 0);
   new GameObject(
       d.doorId, d.doorX, d.doorY, d.doorZ, newFace, d.type, Constants.EMPTY_OBJECT, 999999);
   return true;
 }