Ejemplo n.º 1
0
 public void setLevel(LevelDefinition level) {
   this.nRows = level.getHeight();
   this.nCols = level.getWidth();
   this.cellHeight = this.canvasHeight / this.nRows;
   this.cellWidth = this.canvasWidth / this.nCols;
   this.currentLayout = new GameObject[this.nRows * this.nCols];
   this.addLevelObjects(level);
 }
Ejemplo n.º 2
0
 private void addLevelObjects(LevelDefinition level) {
   for (GameObjectDefinition objDef : level.getObjects()) {
     GameObject obj =
         this.gameObjectFactory.getObject(objDef.getSprite(), this.cellWidth, this.cellHeight);
     obj.rotate(objDef.getRotations());
     this.addToLayout(obj, objDef.getInsertionRow(), objDef.getInsertionCol());
   }
 }
Ejemplo n.º 3
0
  public static void writeExample() {
    Levels levels = new Levels();
    levels.levels = new ArrayList<LevelDefinition>();

    {
      LevelDefinition ld = new LevelDefinition();
      ld.start_time = 7;
      ld.groups = new ArrayList<ProbabilityGroup>();

      ProbabilityGroup pg1 = new ProbabilityGroup();
      pg1.chance = 0.3f;
      pg1.sequences = new ArrayList<String>();
      pg1.sequences.add("a");
      pg1.sequences.add("b");

      ProbabilityGroup pg2 = new ProbabilityGroup();
      pg2.chance = 0.7f;
      pg2.sequences = new ArrayList<String>();
      pg2.sequences.add("c");
      pg2.sequences.add("d");
      pg2.sequences.add("e");

      ld.groups.add(pg1);
      ld.groups.add(pg2);

      levels.levels.add(ld);
    }
    {
      LevelDefinition ld = new LevelDefinition();
      ld.start_time = 21;
      ld.groups = new ArrayList<ProbabilityGroup>();

      ProbabilityGroup pg1 = new ProbabilityGroup();
      pg1.chance = 0.4f;
      pg1.sequences = new ArrayList<String>();
      pg1.sequences.add("f");
      pg1.sequences.add("g");
      pg1.sequences.add("h");

      ProbabilityGroup pg2 = new ProbabilityGroup();
      pg2.chance = 0.6f;
      pg2.sequences = new ArrayList<String>();
      pg2.sequences.add("i");
      pg2.sequences.add("j");

      ld.groups.add(pg1);
      ld.groups.add(pg2);

      levels.levels.add(ld);
    }

    String s = json.prettyPrint(levels);
    Gdx.files.local(PATH).writeString(s, false);
  }
Ejemplo n.º 4
0
 private void index() {
   for (LevelDefinition ld : levels) {
     ld.index();
   }
 }