示例#1
0
文件: World.java 项目: munro/lzr
 public void render() {
   ListIterator<Wall> it;
   Wall w;
   for (it = walls.listIterator(); it.hasNext(); ) {
     w = it.next();
     w.render();
   }
 }
示例#2
0
文件: World.java 项目: munro/lzr
 boolean intersectsWall(Vector2f a, Vector2f b) {
   ListIterator<Wall> it;
   Wall w;
   // int x = 0;
   for (it = walls.listIterator(); it.hasNext(); ) {
     w = it.next();
     // System.out.println("HEY " + (x++));
     if (w.intersectsLine(a, b)) return true;
   }
   return false;
 }
示例#3
0
 public Materials getMaterials(boolean withRight, boolean withTop) {
   Materials materials = new Materials();
   entities
       .values()
       .stream()
       .forEach(
           (entity) -> {
             materials.put(entity.getMaterials());
           });
   if (withRight) {
     for (int i = 0; i < Constants.FLOORS_LIMIT; i++) {
       Wall wall = map.getTile(this, 1, 0).getVerticalWall(i);
       Wall fence = map.getTile(this, 1, 0).getVerticalFence(i);
       if (wall != null) {
         materials.put(wall.getMaterials());
       }
       if (fence != null) {
         materials.put(fence.getMaterials());
       }
     }
   }
   if (withTop) {
     for (int i = 0; i < Constants.FLOORS_LIMIT; i++) {
       Wall wall = map.getTile(this, 0, 1).getHorizontalWall(i);
       Wall fence = map.getTile(this, 0, 1).getHorizontalFence(i);
       if (wall != null) {
         materials.put(wall.getMaterials());
       }
       if (fence != null) {
         materials.put(fence.getMaterials());
       }
     }
   }
   return materials;
 }
示例#4
0
 public void produce(double x, double y) {
   Wall tmp = new Wall(x, y);
   tmp.init(units, tower, grid, weapons, effects);
   tower.add(tmp);
 }
示例#5
0
  private void renderEntities(GL2 g) {
    for (Entry<EntityData, TileEntity> e : entities.entrySet()) {
      EntityData key = e.getKey();
      final int floor = key.getFloor();
      float colorMod = 1;
      if (Globals.upCamera) {
        switch (Globals.floor - floor) {
          case 0:
            colorMod = 1;
            break;
          case 1:
            colorMod = 0.6f;
            break;
          case 2:
            colorMod = 0.25f;
            break;
          default:
            continue;
        }
      }
      TileEntity entity = e.getValue();
      g.glPushMatrix();
      switch (key.getType()) {
        case FLOORROOF:
          g.glTranslatef(4, 0, 3 * floor + getFloorHeight() / Constants.HEIGHT_MOD);
          g.glColor3f(colorMod, colorMod, colorMod);
          entity.render(g, this);
          break;
        case VWALL:
        case VFENCE:
          g.glTranslatef(0, 0, 3 * floor + getVerticalWallHeight() / Constants.HEIGHT_MOD);
          g.glRotatef(90, 0, 0, 1);
          float vdiff = getVerticalWallHeightDiff() / 47f;
          if (vdiff < 0) {
            g.glTranslatef(0, 0, -vdiff * 4f);
          }
          deform(g, vdiff);

          Wall vwall = (Wall) entity;
          if (Globals.upCamera) {
            vwall.data.color.use(g, colorMod);
          } else {
            g.glColor3f(1, 1, 1);
          }
          vwall.render(g, this);
          g.glColor3f(1, 1, 1);
          break;
        case HWALL:
        case HFENCE:
          g.glTranslatef(0, 0, 3 * floor + getHorizontalWallHeight() / Constants.HEIGHT_MOD);
          float hdiff = getHorizontalWallHeightDiff() / 47f;
          if (hdiff < 0) {
            g.glTranslatef(0, 0, -hdiff * 4f);
          }
          deform(g, hdiff);
          Wall hwall = (Wall) entity;
          if (Globals.upCamera) {
            hwall.data.color.use(g, colorMod);
          } else {
            g.glColor3f(1, 1, 1);
          }
          hwall.render(g, this);
          g.glColor3f(1, 1, 1);
          break;
        case OBJECT:
          ObjectEntityData objData = (ObjectEntityData) key;
          ObjectLocation loc = objData.getLocation();
          GameObject obj = (GameObject) entity;
          g.glColor3f(colorMod, colorMod, colorMod);
          g.glTranslatef(
              loc.getHorizontalAlign(),
              loc.getVerticalAlign(),
              3 * floor
                  + getHeight(loc.getHorizontalAlign() / 4f, loc.getVerticalAlign() / 4f)
                      / Constants.HEIGHT_MOD);
          obj.render(g, this);
          break;
      }
      g.glPopMatrix();
      g.glColor3f(1, 1, 1);
    }
  }
示例#6
0
 /** add a control point */
 public void addPoint(Point p) {
   if (pts2d.size() < 4) {
     super.addPoint(p);
   }
 }