コード例 #1
0
ファイル: Level.java プロジェクト: sofian86/autickax
  public void setTextures() {
    for (GameObject gameObject : this.gameObjects) {
      if (gameObject.getTexture() == null) gameObject.setTexture();
    }

    for (GameObject universalObject : this.universalObjects) {
      universalObject.setTexture();
    }
    if (this.car.getTexture() == null) this.car.setTexture();
    if (this.start.getTexture() == null) this.start.setTexture();
    if (this.finish.getTexture() == null) this.finish.setTexture();
  }
コード例 #2
0
ファイル: Level.java プロジェクト: sofian86/autickax
  public void parseLevel(FileHandle file) throws Exception {

    Element root = new XmlReader().parse(file);

    this.pathway = Pathway.parsePathway(root);

    // Loading game objects
    Element entities = root.getChildByName("entities");
    this.gameObjects = new ArrayList<GameObject>();
    if (entities != null) {
      for (int i = 0; i < entities.getChildCount(); i++) {
        Element gameObject = entities.getChild(i);
        this.gameObjects.add(GameObject.parseGameObject(gameObject));
      }
    }

    // Loading universal objects
    Element universalObjects = root.getChildByName("drawings");
    this.universalObjects = new ArrayList<GameObject>();
    if (universalObjects != null) {
      for (int i = 0; i < universalObjects.getChildCount(); i++) {
        Element universalObject = universalObjects.getChild(i);
        this.universalObjects.add(GameObject.parseGameObject(universalObject));
      }
    }

    // Loading car
    Element car = root.getChildByName(Car.name);
    this.car = Car.parseCar(car);

    // Loading start
    Element start = root.getChildByName(Start.name);
    this.start = (Start) GameObject.parseGameObject(start);

    // Loading finish
    Element finish = root.getChildByName(Finish.name);
    this.finish = (Finish) GameObject.parseGameObject(finish);

    // Background
    Element background = root.getChildByName("background");
    this.background = LevelBackground.parseLevelBackground(background);

    // Time limit
    this.timeLimit = root.getFloat("timeLimit");

    Element difficulty = root.getChildByName("difficulty");
    this.setDifficulty(Difficulty.valueOf(difficulty.getText()));

    System.out.println("Loading level \"" + file.name() + "\" done.");
  }