Exemplo n.º 1
0
  // read all defense missile from given defense destructor
  protected void readDefenseDestructorFromGivenDestructor(Element destructor) {
    NamedNodeMap attributes = destructor.getAttributes();
    String id = "";
    String type;

    Attr attr = (Attr) attributes.item(0);

    String name = attr.getNodeName();

    // if it's iron dome
    if (name.equals("id")) {
      id = attr.getNodeValue();

      // update id's in the war
      IdGenerator.updateIronDomeId(id);
      // add to war
      war.addIronDome(id);

      NodeList destructdMissiles = destructor.getElementsByTagName("destructdMissile");
      readDefensDestructoreMissiles(destructdMissiles, id);

      // if it's launcher destructor
    } else {
      if (name.equals("type")) {
        type = attr.getNodeValue();

        // add to war
        id = war.addDefenseLauncherDestructor(type);

        NodeList destructedLanuchers = destructor.getElementsByTagName("destructedLanucher");
        readDefensDestructoreMissiles(destructedLanuchers, id);
      }
    }
  }
Exemplo n.º 2
0
  // read enemy launchers and their missiles form XML
  protected void readEnemyLaunchers() {
    NodeList launchers = root.getElementsByTagName("launcher");

    for (int i = 0; i < launchers.getLength(); i++) {
      Element tempLauncher = (Element) launchers.item(i);

      String idLauncher = tempLauncher.getAttribute("id");
      boolean isHidden = Boolean.parseBoolean(tempLauncher.getAttribute("isHidden"));

      // add to the war
      war.addEnemyLauncher(idLauncher, isHidden);
      IdGenerator.updateEnemyLauncherId(idLauncher);

      NodeList missiles = tempLauncher.getElementsByTagName("missile");

      // read all missiles
      readMissilesForGivenLauncher(missiles, idLauncher);
    }

    // update the id's in the war
    IdGenerator.updateFinalEnemyMissileId();
    IdGenerator.updateFinalEnemyLauncherId();
  }
Exemplo n.º 3
0
  // read all defense destructors and their missiles from XML
  protected void readDefenseDestructors() {
    ;
    NodeList destructors = root.getElementsByTagName("destructor");

    int destructorsSize = destructors.getLength();
    for (int i = 0; i < destructorsSize; i++) {
      Element destructor = (Element) destructors.item(i);

      readDefenseDestructorFromGivenDestructor(destructor);
    }

    // update the id's in the war
    IdGenerator.updateFinalIronDomeId();
  }