예제 #1
0
파일: World.java 프로젝트: Sindusk/polarity
 public static void createSinglePlayerArea(Node node) {
   node.setLocalTranslation(0, 100, 0);
   CG.createPhyBox(
       node,
       "floor",
       T.v3f(50, 0.1f, 50),
       T.v3f(0, -1, 0),
       T.getMaterialPath("lava_rock"),
       T.v2f(5, 5));
   CG.createPhyBox(
       node,
       "wall",
       T.v3f(30, 20, 0.1f),
       T.v3f(0, 20, -60),
       T.getMaterialPath("BC_Tex"),
       T.v2f(15, 10));
   CG.createPhyBox(node, "savior", T.v3f(10, 0.1f, 10), T.v3f(0, -101, 0), ColorRGBA.Yellow);
 }
예제 #2
0
파일: World.java 프로젝트: Sindusk/polarity
 public static void generateStart() {
   map.add(
       geoFloor(
           new Vector3f(0, -0.5f, 0), 5, 5, T.getMaterialPath("brick"), new Vector2f(5, 5), true));
   int x = -2;
   int z;
   while (x <= 2) {
     z = -2;
     while (z <= 2) {
       world.put(new Vector3f(x, 0, z), "h");
       z++;
     }
     x++;
   }
 }
예제 #3
0
파일: World.java 프로젝트: Sindusk/polarity
 public Wall(Vector3f start, float xi, float zi, int spaces) {
   float x = start.getX();
   float z = start.getZ();
   float xl = 0;
   float zl = 0;
   Vector3f loc = new Vector3f(0, 0, 0);
   int i = 0;
   ends[0] = start.clone();
   while (i < spaces) {
     loc = new Vector3f(x + (i * xi), start.getY(), z + (i * zi));
     if (world.get(loc) != null
         && (world.get(loc).contains("h") || world.get(loc).contains("w"))) {
       break;
     } else {
       world.put(loc, "w");
     }
     xl += xi;
     zl += zi;
     i++;
   }
   i--;
   if (i > 0) {
     spaces -= i;
   } else {
     spaces -= 1;
   }
   if (spaces > 0) {
     walls.add(new Wall(loc.clone().add(xi, 0, zi), xi, zi, spaces));
   }
   if (xl == 0 && zl == 0) {
     return;
   }
   loc = new Vector3f(x + ((i / 2f) * xi), start.getY(), z + ((i / 2f) * zi));
   map.add(
       geoWall(
           loc,
           xl,
           zl,
           T.getMaterialPath("synthetic"),
           new Vector2f(Math.max(FastMath.abs(xl), FastMath.abs(zl)), 2),
           true));
 }
예제 #4
0
파일: World.java 프로젝트: Sindusk/polarity
    public Hallway(Vector3f start, float xi, float zi) {
      float x = start.getX() + xi;
      float z = start.getZ() + zi;
      float rng, dist;
      int len = 0;
      int spread = 0;
      int lenMax = FastMath.nextRandomInt(HALL_LENGTH_MIN, HALL_LENGTH_MAX);
      boolean b = false;
      // Make sure both xi and zi have an absolute value of 1:
      xi = A.sign(xi);
      zi = A.sign(zi);
      // Assign the first 2 corners:
      corners[0] =
          new Vector3f(
              (zi * (HALL_WIDTH - 1)) + x,
              start.getY(),
              (xi * (HALL_WIDTH - 1)) + z); // Bottom Left
      corners[1] =
          new Vector3f(
              (-zi * (HALL_WIDTH - 1)) + x,
              start.getY(),
              (-xi * (HALL_WIDTH - 1)) + z); // Bottom Right
      Vector3f left = corners[0].clone();
      Vector3f right = corners[1].clone();
      ArrayList<HallData> newHalls = new ArrayList(1);
      while (len <= lenMax) {
        if (world.get(left) != null && world.get(left).contains("h")) {
          b = true;
        }
        if (world.get(right) != null && world.get(right).contains("h")) {
          b = true;
        }
        // Check each of the spaces in this step for hallway:
        if (b) {
          right.addLocal(-xi, 0, -zi);
          left.addLocal(-xi, 0, -zi);
          break;
        }
        world.put(left.clone(), "h");
        world.put(right.add(zi, 0, xi), "h");
        world.put(right.clone(), "h");
        // Check distance & random to see if more hallways should be created:
        dist = left.distance(Vector3f.ZERO);
        rng = FastMath.nextRandomFloat();
        if (dist < HALL_MAX_RADIUS && spread > HALL_SPREAD && len < lenMax) {
          if (rng < 0.13f) {
            newHalls.add(new HallData(left.clone(), zi, xi));
            spread = 0;
          } else if (rng < 0.26f) {
            newHalls.add(new HallData(right.clone(), -zi, -xi));
            spread = 0;
          } else if (rng < 0.33f) {
            newHalls.add(new HallData(left.clone(), zi, xi));
            newHalls.add(new HallData(right.clone(), -zi, -xi));
            spread = 0;
          }
        }
        x += xi;
        z += zi;
        spread++;
        len++;
        left.addLocal(xi, 0, zi);
        right.addLocal(xi, 0, zi);
      }
      corners[2] = right.clone(); // Top Right
      corners[3] = left.clone(); // Top Left

      // Generate hallways:
      int j = 0;
      while (j < newHalls.size()) {
        hallways.add(new Hallway(newHalls.get(j).start, newHalls.get(j).xi, newHalls.get(j).zi));
        j++;
      }

      // Return if there's no hallway to generate (0 in size):
      float xs = FastMath.abs(corners[1].getX() - corners[3].getX()) + 1;
      float zs = FastMath.abs(corners[1].getZ() - corners[3].getZ()) + 1;
      if (Math.min(FastMath.abs(xs), FastMath.abs(zs)) < 1) {
        return;
      }

      // Generate the front wall:
      walls.add(new Wall(left.add(xi, 0, zi), -zi, -xi, HALL_WIDTH * 2 - 1));
      walls.add(new Wall(left.add(zi, 0, xi), -xi, -zi, len + 1));
      walls.add(new Wall(right.add(-zi, 0, -xi), -xi, -zi, len + 1));

      // Generate the actual floor:
      float xloc = (corners[3].getX() + corners[1].getX()) * 0.5f;
      float zloc = (corners[3].getZ() + corners[1].getZ()) * 0.5f;
      NPCManager.addNew("grunt", new Vector3f(xloc, start.getY(), zloc).mult(ZS).add(0, 5, 0));
      center = new Vector3f(xloc, start.getY() - 0.5f, zloc);
      floor = geoFloor(center, xs, zs, T.getMaterialPath("BC_Tex"), new Vector2f(zs, xs), true);
      map.add(floor);
    }