package de.frajul.endlessroll.entities.tileLists;

import de.frajul.endlessroll.data.Vector;
import de.frajul.endlessroll.entities.Entity;
import de.frajul.endlessroll.entities.textures.Texture;
import de.frajul.endlessroll.levels.TileData;

/**
 * Created by Julian on 18.12.2015.
 */

public class Tile extends Entity {

    private int gridColumnCount;

    public Tile(TileList.Type type, Texture texture, float edge, TileData data) {
        this(type, texture, edge, data.getX(), data.getWidth());
    }

    public Tile(TileList.Type type, Texture texture, float edge, float x, float width) {
        super(texture, new Vector(), width, 0);
        super.height = type.calculateTileHeightFromEdge(edge);
        super.position.x = x;
        switch (type) {
            case TERRAIN:
                super.position.y = edge - super.height / 2;
                break;
            case CEILING:
                super.position.y = edge + super.height / 2;
                break;
        }
        gridColumnCount = (int) (width / height);
        gridColumnCount = Math.max(gridColumnCount, 3);
    }

    public int getGridColumnCount() {
        return gridColumnCount;
    }
}
