Ejemplo n.º 1
0
  ArrayList<Mob> getMobs() {
    ArrayList<Mob> realMobs = new ArrayList<Mob>();

    for (JsonMob jm : mobs) {

      Mob xyz = null;

      Class<?> cl;
      try {
        cl = Class.forName(jm.getName());

        Constructor<?> con = cl.getConstructor(float.class, float.class);
        xyz = (Mob) con.newInstance(jm.getX(), jm.getY());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }

      xyz.setID(jm.getID());

      realMobs.add(xyz);
    }
    return realMobs;
  }
Ejemplo n.º 2
0
  ArrayList<Entity> getEntities() {
    ArrayList<Entity> realEntities = new ArrayList<Entity>();

    for (JsonEntity je : this.entities) {

      Entity xyz = null;

      Class<?> cl;
      try {
        cl = Class.forName(je.getName());

        Constructor<?> con = cl.getConstructor(float.class, float.class, boolean.class);
        xyz = (Entity) con.newInstance(je.getX(), je.getY(), je.getSolid());
      } catch (ClassNotFoundException e) {
        e.printStackTrace();
      } catch (NoSuchMethodException e) {
        e.printStackTrace();
      } catch (SecurityException e) {
        e.printStackTrace();
      } catch (InstantiationException e) {
        e.printStackTrace();
      } catch (IllegalAccessException e) {
        e.printStackTrace();
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        e.printStackTrace();
      }

      if (xyz.isSign()) {
        xyz.setSignText(je.getSignText());
        System.out.println("Sign Text = " + je.getSignText());
      }
      realEntities.add(xyz);
    }
    return realEntities;
  }