コード例 #1
0
ファイル: MinigameAreas.java プロジェクト: Onurrr/377_Remake
 public static boolean isInArea(Position position, Area area) {
   return position.getZ() == area.getSouthWestCorner().getZ()
       && position.getX() > area.getSouthWestCorner().getX()
       && position.getY() > area.getSouthWestCorner().getY()
       && position.getX() < area.getNorthEastCorner().getX()
       && position.getY() < area.getNorthEastCorner().getY();
 }
コード例 #2
0
ファイル: MinigameAreas.java プロジェクト: Onurrr/377_Remake
 public Area enlarge(int distance) {
   this.southWestCorner =
       new Position(
           southWestCorner.getX() - distance,
           southWestCorner.getY() - distance,
           southWestCorner.getZ());
   this.northEastCorner =
       new Position(
           northEastCorner.getX() + distance,
           northEastCorner.getY() + distance,
           northEastCorner.getZ());
   return this;
 }
コード例 #3
0
ファイル: Npc.java プロジェクト: Austyn/RuneSourceDevelopment
 /** Makes walkable npcs walk, then updates it's position. */
 public void sendNpcWalk() {
   if (walkType == WalkType.WALK && Misc.randomNumber(10) == 0) {
     int yModifier = 0, xModifier = 0, direction = 0;
     int[][] coordinateModifiers = {
       {-1, 1}, {0, 1}, {1, 1}, {-1, 0}, {1, 0}, {-1, -1}, {0, -1}, {1, -1}
     };
     direction = Misc.randomNumber(8);
     xModifier = coordinateModifiers[direction][0];
     yModifier = coordinateModifiers[direction][1];
     if (minWalk.getX() <= (currentX + xModifier)
         && minWalk.getY() <= (currentY + yModifier)
         && maxWalk.getX() >= (currentX + xModifier)
         && maxWalk.getY() >= (currentY + yModifier)) {
       primaryDirection = direction;
       appendNpcPosition(xModifier, yModifier);
       getUpdateFlags().faceEntity(65535);
     }
   }
 }
コード例 #4
0
ファイル: MinigameAreas.java プロジェクト: Onurrr/377_Remake
 public static Position randomPosition(Area area) {
   Position finalPosition =
       new Position(
           area.getSouthWestCorner().getX()
               + Misc.random(area.getNorthEastCorner().getX() - area.getSouthWestCorner().getX()),
           area.getSouthWestCorner().getY()
               + Misc.random(area.getNorthEastCorner().getY() - area.getSouthWestCorner().getY()),
           area.getSouthWestCorner().getZ());
   while (Region.getClipping(finalPosition.getX(), finalPosition.getY(), finalPosition.getZ())
       != 0)
     finalPosition =
         new Position(
             area.getSouthWestCorner().getX()
                 + Misc.random(
                     area.getNorthEastCorner().getX() - area.getSouthWestCorner().getX()),
             area.getSouthWestCorner().getY()
                 + Misc.random(
                     area.getNorthEastCorner().getY() - area.getSouthWestCorner().getY()),
             area.getSouthWestCorner().getZ());
   return finalPosition;
 }