示例#1
0
  private static void createGraphicData(List<String> lines) {
    Model m = null;
    ModelAnim a = null;
    Particle p = null;
    Texture t = null;
    TextureCliped c = null;
    Animation A = null;
    for (String l : lines) {
      if (l.charAt(0) == '+') continue;
      String[] data = l.split(" ");
      String action = data[0];
      if ("new".equals(action)) { // create new thing
        String object = data[1];
        String name = data[2];
        if ("Model".equals(object)) {
          a = null;
          m = new Model();
          models.put(name, m);
          System.out.println("new model " + name);
        } else if ("ModelRepeat".equals(object)) {
          a = null;
          m = new ModelRepeat();
          models.put(name, m);
          System.out.println("new modelRepeat " + name);
        } else if ("ModelAnim".equals(object)) {
          a = new ModelAnim();
          m = null;
          models.put(name, a);
          System.out.println("new modelAnim " + name);
        } else if ("Particle".equals(object)) {
          p = new Particle();
          a = null;
          m = null;
          models.put(name, p);
          System.out.println("new particle " + name);
        } else if ("Texture".equals(object)) {
          t = Texture.loadTexture(name);
          c = null;
          textures.put(name, t);
          System.out.println("new texture " + name);
        } else if ("TextureCliped".equals(object)) {
          c = TextureCliped.loadTextureCliped(name);
          textures.put(name, c);
          System.out.println("new textureCliped " + name);
        } else if ("Animation".equals(object)) {
          A = new Animation();
          if (a != null) a.setAnimation(name, A);
          System.out.println("new animation " + name);
        }
      } else if ("set".equals(action)) { // set stuff
        String attribute = data[1];

        if (m != null) {
          if ("Texture".equals(attribute)) {
            String path = data[2];
            m.setTexture(getTexture(path));
          }
        } else if (A != null) {
          if ("Texture".equals(attribute)) {
            String path = data[2];
            A.setTexture(getTexture(path));
          } else if ("Duration".equals(attribute)) {
            String duration = data[2];
            A.setDuration(Float.valueOf(duration));
          } else if ("FrameCount".equals(attribute)) {
            String count = data[2];
            A.setFrameCount(Integer.valueOf(count));
          } else if ("Frame".equals(attribute)) {
            String frame = data[2];
            String clipID = data[3];
            A.setFrame(Integer.valueOf(frame), Integer.valueOf(clipID));
          }
        } else if (c != null) {
          if ("FrameCount".equals(attribute)) {
            String x = data[2];
            String y = data[3];
            c.setFrameCount(Integer.valueOf(x), Integer.valueOf(y));
          }
        }
      }
    }
  }