Android Open Source - Ready-Set-Rogue Asset Depot






From Project

Back to project page Ready-Set-Rogue.

License

The source code is released under:

GNU General Public License

If you think the Android project Ready-Set-Rogue listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.warsheep.scamp;
/*ww  w. j ava  2s  .co  m*/
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;

import java.util.HashMap;
import java.util.Map;

public class AssetDepot {
    public static final String MAP_PATH = "prefabs/maps/test_level.json";

    private static final String[] LOAD_ON_START = {"creatures_24x24", "world_24x24"};
    private Map<String, TextureAtlas> textures;
    private Map<String, JsonValue> prefabs;
    private AssetManager assetManager;
    private JsonReader jsonReader;

    private static final AssetDepot instance = new AssetDepot();

    public static synchronized AssetDepot getInstance() {
        return instance;
    }

    private AssetDepot() {
        assetManager = new AssetManager();
        jsonReader = new JsonReader();
        textures = new HashMap<>();
        prefabs = new HashMap<>();
        for (int i = 0; i < LOAD_ON_START.length; i++) {
            this.prefetch(LOAD_ON_START[i]);
        }
    }

    public JsonValue fetchJson(String handle) {
        if(!this.prefabs.containsKey(handle)) {
            this.prefabs.put(handle, jsonReader.parse(new FileHandle("prefabs/" + handle + ".json")));
        }
        return this.prefabs.get(handle);
    }

    public AtlasRegion fetchImage(String path, String handle) {
        if (!this.textures.containsKey(path)) {
            this.prefetch(path);
        }
        return textures.get(path).findRegion(handle);
    }

    public AtlasRegion fetchImage(String path, String handle, int index) {
        if (!this.textures.containsKey(path)) {
            this.prefetch(path);
        }
        return textures.get(path).findRegion(handle, index);
    }

    public void prefetch(String path) {
        assetManager.load(atlasPath(path), TextureAtlas.class);
        assetManager.finishLoading();
        textures.put(path, assetManager.get(atlasPath(path), TextureAtlas.class));
    }

    private String atlasPath(String path) {
        String fileName = path.substring(0, path.indexOf('_')) + ".atlas";
        return path + "/" + fileName;
    }

}




Java Source Code List

com.warsheep.scamp.AssetDepot.java
com.warsheep.scamp.IOSLauncher.java
com.warsheep.scamp.MapImporter.java
com.warsheep.scamp.PrefabFactory.java
com.warsheep.scamp.Scamp.java
com.warsheep.scamp.adt.BSPRectangle.java
com.warsheep.scamp.adt.Container.java
com.warsheep.scamp.adt.Pair.java
com.warsheep.scamp.adt.Room.java
com.warsheep.scamp.algorithms.BSPMapGenerator.java
com.warsheep.scamp.algorithms.Compositor.java
com.warsheep.scamp.android.AndroidLauncher.java
com.warsheep.scamp.client.HtmlLauncher.java
com.warsheep.scamp.components.AIControllableComponent.java
com.warsheep.scamp.components.AttackerComponent.java
com.warsheep.scamp.components.CameraComponent.java
com.warsheep.scamp.components.CollidableComponent.java
com.warsheep.scamp.components.ControllableComponent.java
com.warsheep.scamp.components.DamageableComponent.java
com.warsheep.scamp.components.DropComponent.java
com.warsheep.scamp.components.ECSMapper.java
com.warsheep.scamp.components.FactionComponent.java
com.warsheep.scamp.components.InventoryComponent.java
com.warsheep.scamp.components.LevelComponent.java
com.warsheep.scamp.components.MovementComponent.java
com.warsheep.scamp.components.StateComponent.java
com.warsheep.scamp.components.TileComponent.java
com.warsheep.scamp.components.TransformComponent.java
com.warsheep.scamp.components.VisibleComponent.java
com.warsheep.scamp.desktop.AssetPacker.java
com.warsheep.scamp.desktop.DesktopLauncher.java
com.warsheep.scamp.processors.AIProcessor.java
com.warsheep.scamp.processors.CameraProcessor.java
com.warsheep.scamp.processors.CollisionProcessor.java
com.warsheep.scamp.processors.CombatProcessor.java
com.warsheep.scamp.processors.ControlProcessor.java
com.warsheep.scamp.processors.DeathProcessor.java
com.warsheep.scamp.processors.LevelingProcessor.java
com.warsheep.scamp.processors.MovementProcessor.java
com.warsheep.scamp.processors.StateProcessor.java
com.warsheep.scamp.processors.TileProcessor.java
com.warsheep.scamp.processors.VisibilityProcessor.java
com.warsheep.scamp.screens.MainGameScreen.java
com.warsheep.scamp.screens.MainMenuScreen.java