package de.frajul.endlessroll.levels.worlds;

import android.support.annotation.DrawableRes;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.entities.textures.TexturePack;

/**
 * Created by Julian on 14.11.2016.
 */

public enum World {

    GRASSLANDS(R.drawable.world_previews_grasslands, R.drawable.backgrounds_game_grass, R.drawable.terrain_t_grass, R.drawable.terrain_c_grass, R.drawable.obstacles_grass),
    ICY_MOUNTAINS(R.drawable.world_previews_icymountains, R.drawable.backgrounds_game_snow, R.drawable.terrain_t_ice, R.drawable.terrain_c_ice, R.drawable.obstacles_snow);

    private String name;
    @DrawableRes
    private int previewId;
    @DrawableRes
    private int backgroundId;
    @DrawableRes
    private int terrainId;
    @DrawableRes
    private int ceilingId;
    @DrawableRes
    private int obstacleId;

    private Texture background;
    private Texture terrain;
    private Texture ceiling;
    private Texture obstacle;

    World(@DrawableRes int previewId, @DrawableRes int backgroundId, @DrawableRes int terrainId, @DrawableRes int ceilingId, @DrawableRes int obstacleId) {
        this.previewId = previewId;
        this.backgroundId = backgroundId;
        this.terrainId = terrainId;
        this.ceilingId = ceilingId;
        this.obstacleId = obstacleId;
    }

    public static void loadAllSpecificTextures(TexturePack texturePack) {
        for (World world : values())
            world.loadSpecificTextures(texturePack);
    }

    private void loadSpecificTextures(TexturePack texturePack) {
        background = texturePack.loadTexture(backgroundId);
        terrain = texturePack.loadTexture(terrainId);
        ceiling = texturePack.loadTexture(ceilingId);
        obstacle = texturePack.loadAtlas(obstacleId, 8, 8);
    }

    public int getPreviewId() {
        return previewId;
    }

    public Texture getBackgroundTexture() {
        return background;
    }

    public Texture getTerrainTexture() {
        return terrain;
    }

    public Texture getCeilingTexture() {
        return ceiling;
    }

    public Texture getObstacleTexture() {
        return obstacle;
    }
}
