コード例 #1
0
ファイル: Weapon.java プロジェクト: cloud-oak/angonya
 public static Weapon load(String id) {
   Weapon w;
   Json j = new Json(OutputType.json);
   w = j.fromJson(Weapon.class, Gdx.files.internal("core/assets/json/weapons/" + id + ".json"));
   w.weaponID = id;
   return w;
 }
コード例 #2
0
 // Json read
 @Override
 public void read(Json json, JsonValue jsonData) {
   logger.debug("Deserializing");
   PhysicsConfig config = json.fromJson(PhysicsConfig.class, jsonData.toString());
   collisionEffect = config.collisionEffect;
   this.buildFromModel(config.sceneModel);
 }
コード例 #3
0
ファイル: ResourceManager.java プロジェクト: kulgan/overlap2d
 @Override
 public SceneVO getSceneVO(String name) {
   SceneDataManager sceneDataManager = facade.retrieveProxy(SceneDataManager.NAME);
   // TODO: this should be cached
   FileHandle file = Gdx.files.internal(sceneDataManager.getCurrProjectScenePathByName(name));
   Json json = new Json();
   json.setIgnoreUnknownFields(true);
   return json.fromJson(SceneVO.class, file.readString());
 }
コード例 #4
0
  @Override
  public void undoAction() {
    Json json = new Json();
    CompositeVO compositeVO = json.fromJson(CompositeVO.class, backup);
    Set<Entity> newEntitiesList = PasteItemsCommand.createEntitiesFromVO(compositeVO);

    for (Entity entity : newEntitiesList) {
      Overlap2DFacade.getInstance().sendNotification(ItemFactory.NEW_ITEM_ADDED, entity);
    }

    sandbox.getSelector().setSelections(newEntitiesList, true);
  }
コード例 #5
0
 private void loadWeapons() {
   logger.debug("Loading Weapons");
   Json json = new Json();
   for (String s : manifest.weapons) {
     try {
       WeaponConfig config = json.fromJson(WeaponConfig.class, Gdx.files.internal(s));
       weaponConfigs.put(config.name, config);
     } catch (SerializationException ex) {
       logger.error("Failed to load weapons file: " + s);
       logger.error(ex.getMessage());
     }
   }
 }
コード例 #6
0
  /**
   * This method accumulates objects defined in a scene, allowing several separate RUBE .json files
   * to be combined. Objects are added to the scene's data, as well as within the Box2D world that
   * is ultimately returned.
   *
   * @param _file The JSON file to parse
   * @return The cumulative scene
   */
  public RubeScene addScene(FileHandle _file) {
    RubeScene scene = null;

    if ((mRubeWorldSerializer != null) && (mWorld != null)) {
      mRubeWorldSerializer.usePreexistingWorld(mWorld);
    }
    try {
      scene = json.fromJson(RubeScene.class, _file);
    } catch (SerializationException ex) {
      throw new SerializationException("Error reading file: " + _file, ex);
    }
    return scene;
  }
コード例 #7
0
  private void loadEntities() {
    logger.debug("Loading Entities");

    Json json = new Json();
    for (String s : manifest.entities) {
      try {
        EntityConfig config = json.fromJson(EntityConfig.class, Gdx.files.internal(s));
        entityConfigs.put(config.name, config);
      } catch (SerializationException ex) {
        logger.error("Failed to load entity file: " + s);
        logger.error(ex.getMessage());
      }
    }
  }
コード例 #8
0
  @Override
  public es.danirod.rectball.model.Statistics loadStatistics() {
    try {
      // Read stats from file and decode them.
      FileHandle handle = getStatistics();
      String encodedJson = handle.readString();
      String decodedJson = Base64Coder.decodeString(encodedJson);

      // Convert JSON to statistics
      Json json = new Json();
      return json.fromJson(es.danirod.rectball.model.Statistics.class, decodedJson);
    } catch (Exception ex) {
      return new es.danirod.rectball.model.Statistics();
    }
  }
コード例 #9
0
  public static <T> T read(FileHandle path, Class<T> clazz, Consumer<Json> setupJson)
      throws IOException {

    Json json = new Json();

    json.setSerializer(clazz, new AnnotatedJsonSerializer<>(json, clazz));

    if (setupJson != null) {
      setupJson.accept(json);
    }

    try {
      return json.fromJson(clazz, path);
    } catch (RuntimeException e) {
      throw new IOException(e);
    }
  }
コード例 #10
0
  public static void Initialize() {

    FileHandle file = Gdx.files.local("saves/savedata.json");
    if (!file.exists()) {

      String savestring =
          json.prettyPrint(
              new SaveData(
                  new PlayerData(
                      PlayerData.AbilityType.NONE, 0, 0, 0, 0, PlayerData.SkinType.HUMAN),
                  new LevelSaveData[] {
                    new LevelSaveData(0, 0, true), new LevelSaveData(0, 0, false)
                  },
                  0));
      file.writeString(savestring, true);
    }
    saveData = json.fromJson(SaveData.class, file);
  }
コード例 #11
0
ファイル: Levels.java プロジェクト: Brusi/VolcanoDrop
 public static void readExample() {
   Levels levels = json.fromJson(Levels.class, Gdx.files.internal(PATH));
   System.out.println("read:");
   System.out.println(json.prettyPrint(levels));
 }
コード例 #12
0
ファイル: Levels.java プロジェクト: Brusi/VolcanoDrop
 public static Levels loadFromFile(FileHandle file) {
   Levels levels = json.fromJson(Levels.class, file);
   levels.index();
   return levels;
 }
コード例 #13
0
 private TutorialHelper() {
   FileHandle handle = Gdx.files.internal(getAssetDirPath() + "tutorial/tutorials.json");
   Json json = new Json();
   tutorials = json.fromJson(ArrayList.class, handle.readString());
 }
コード例 #14
0
ファイル: FavoritesIO.java プロジェクト: 4630599/VisEditor
 public Array<FileHandle> loadFavorites() {
   String data = prefs.getString(keyName, null);
   if (data == null) return new Array<FileHandle>();
   else return json.fromJson(FavouriteData.class, data).toFileHandleArray();
 }
コード例 #15
0
 private void loadManifest() {
   Json json = new Json();
   FileHandle file = Gdx.files.internal("data/assetManifest");
   manifest = json.fromJson(AssetManifest.class, file);
 }
コード例 #16
0
 public static AreaDetails fromJson(final FileHandle file) {
   final AreaDetails res = json.fromJson(AreaDetails.class, file);
   return res;
 }