Esempio n. 1
0
 private void renderGround(GL2 g) {
   if ((Globals.upCamera && Globals.floor >= 0 && Globals.floor < 3) || !Globals.upCamera) {
     if (Globals.upCamera && Globals.floor >= 0 && Globals.floor < 3) {
       switch (Globals.floor) {
         case 0:
           g.glColor3f(1, 1, 1);
           break;
         case 1:
           g.glColor3f(0.6f, 0.6f, 0.6f);
           break;
         case 2:
           g.glColor3f(0.25f, 0.25f, 0.25f);
           break;
       }
     }
     ground.render(g, this);
   }
 }
Esempio n. 2
0
  public void serialize(Document doc, Element root) {
    Element tile = doc.createElement("tile");
    tile.setAttribute("x", Integer.toString(x));
    tile.setAttribute("y", Integer.toString(y));
    tile.setAttribute("height", Float.toString(height));
    tile.setAttribute("caveHeight", Float.toString(caveHeight));
    tile.setAttribute("caveSize", Float.toString(caveSize));
    root.appendChild(tile);

    ground.serialize(doc, tile);
    cave.serialize(doc, tile);
    if (label != null) {
      label.serialize(doc, tile, false);
    }
    if (caveLabel != null) {
      caveLabel.serialize(doc, tile, true);
    }

    final HashMap<Integer, Element> levels = new HashMap<>();

    for (Entry<EntityData, TileEntity> e : entities.entrySet()) {
      final EntityData key = e.getKey();
      final TileEntity entity = e.getValue();
      final int floor = key.getFloor();

      Element level = levels.get(floor);
      if (level == null) {
        level = doc.createElement("level");
        level.setAttribute("value", Integer.toString(key.getFloor()));
        levels.put(key.getFloor(), level);
        tile.appendChild(level);
      }

      switch (key.getType()) {
        case FLOORROOF:
          entity.serialize(doc, level);
          break;
        case HWALL:
        case HFENCE:
          Element hWall = doc.createElement("hWall");
          entity.serialize(doc, hWall);
          level.appendChild(hWall);
          break;
        case VWALL:
        case VFENCE:
          Element vWall = doc.createElement("vWall");
          entity.serialize(doc, vWall);
          level.appendChild(vWall);
          break;
        case HBORDER:
          Element hDeco = doc.createElement("hBorder");
          entity.serialize(doc, hDeco);
          level.appendChild(hDeco);
          break;
        case VBORDER:
          Element vDeco = doc.createElement("vBorder");
          entity.serialize(doc, vDeco);
          level.appendChild(vDeco);
          break;
        case OBJECT:
          ObjectEntityData objectData = (ObjectEntityData) key;
          Element objectElement = doc.createElement("object");
          objectElement.setAttribute("position", objectData.getLocation().toString());
          entity.serialize(doc, objectElement);
          level.appendChild(objectElement);
          break;
      }
    }
  }