Пример #1
0
 public String getSpawnType() {
   return switchExpression.evaluate();
 }
Пример #2
0
  @Override
  public void parse(Element p_elem) {
    if (kind == null) {
      throw new RuntimeException("Action kind is unknown !");
    }

    // Store XML element in order to read easier from ZEditor, and use all
    // convenience read methods
    super.parse(p_elem);

    // Read common attributes
    who = readAttribute("who");
    what = readAttribute("what");
    effect = readAttribute("effect");
    unblock = isTrue("unblock");
    speed = Float.valueOf("0" + p_elem.getAttribute("speed"));
    unstoppable = isTrue("unstoppable");
    foreground = readBoolean("foreground");
    // Read less common ones
    String strPos = p_elem.getAttribute("pos");
    String strAngle = p_elem.getAttribute("angle");
    switch (kind) {
      case _throw:
        target = IPoint.fromString(readAttribute("to"));
        way = readAttribute("way");
      case spawn:
        delta = isTrue("delta");
        reverse = readInt("reverse");
        rotation = readInt("rotation");
        String temp = readAttribute("z");
        if (temp != null) {
          z = new FloatExpression(temp);
        }
        shadow = readAttribute("shadow");
      case animation:
      case impact:
        location = IPoint.fromString(strPos);
        if (!"".equals(strAngle)) {
          val = Integer.valueOf(strAngle);
        }
      case perso:
        text = readAttribute("type");
        String strInfo = readAttribute("info");
        if (strInfo != null) {
          info = PersoInfo.valueOf(strInfo);
        }
        attente = readInt("attente", -1);
        action = readAttribute("action"); // Empty string means "no action"
        weapon = readAttribute("weapon");
        alpha = readInt("alpha", -1);
        alphaA = getFloatExpr("alphaA");
        break;
      case speak:
        text = readAttribute("text");
        break;
      case sound:
      case map:
      case music:
        // String
        text = readNonEmptyAttribute("name");
        break;
      case moveTo:
        backward = isTrue("backward");
        open = isTrue("open");
        text = readAttribute("way");
      case pos:
        // Position
        if (!strPos.isEmpty()) {
          location = IPoint.fromString(strPos);
        }
        delta = isTrue("delta");
        z = new FloatExpression(readInt("z", -1));
        break;
      case script:
        text = readAttribute("text");
      case angle:
      case wait:
      case zoom:
      case herospecial:
        val = readInt("value");
        break;
      case fadeIn:
      case fadeOut:
      case filter:
      case end:
        // Integer
        val = readInt("type");
        break;
      case focus:
        delta = isTrue("delta");
        if (readAttribute("unblock") == null) {
          unblock = true;
        }
        break;
      case take:
        val = readInt("value");
      case putDown:
      case attack:
        text = readAttribute("item");
        break;
      case exec:
        text = p_elem.getAttribute("script");
        break;
      case mapReplace:
      case zikReplace:
      case nameReplace:
        text = p_elem.getAttribute("name");
        break;
      case markQuest:
        text = readAttribute("name");
        val = isTrue("value") ? 1 : 0;
        break;
      case visible:
      case activate:
        activate = isTrue("value");
        break;
      case tile:
        location = IPoint.fromString(strPos);
        back = (int) evaluateFloat("back", -2);
        back2 = (int) evaluateFloat("back2", -2);
        fore = (int) evaluateFloat("fore", -2);
        break;
      case remove:
        text = readAttribute("chaining");
        break;
    }

    // As several variables are used for different usage (which is bad),
    // make specific here
    if (kind == ActionKind.spawn || kind == ActionKind._throw) {
      switchExpression = ZSSwitch.parseForDialog(text);
      // Read V,A and F coordinates
      v = read3Coordinates("v");
      a = read3Coordinates("a");
      f = read3Coordinates("f");
      alphaA = getFloatExpr("alphaA");
      alpha = readInt("alpha", -1);
    }

    // Not needed anymore : free some memory
    if (!EngineZildo.game.editing) {
      xmlElement = null;
    }
  }