package core.engine.terrain;

import core.engine.Loader;
import core.engine.entity.Camera;
import core.engine.model.HexagonModel;
import core.engine.model.RawModel;
import core.engine.model.TexturedModel;
import core.engine.textures.ModelTexture;
import utils.vectors.Vector3f;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Terrain {

    private List<TerrainTile> terrainTiles = new ArrayList<>();

    public Terrain(Loader loader, ModelTexture modelTexture, int rows, int columns, int numberPlayers) {
        TerrainGenerator terrainGenerator = new TerrainGenerator();

        HexagonModel hexagonModel = new HexagonModel();
        RawModel rawModel = loader.loadHexagon(hexagonModel);
        TexturedModel texturedModel = new TexturedModel(rawModel, modelTexture);
        for(int row = 0; row < rows; row++) {
            for(int column = 0; column < columns; column++) {
                if(row % 2 == 1) {
                    terrainTiles.add(new TerrainTile(texturedModel, new Vector3f(column  *  2* 0.866f, 0, row   * 1.5f),0,0,0,1, row, column, terrainGenerator.generateColor(column, row)));
                } else {
                    terrainTiles.add(new TerrainTile(texturedModel, new Vector3f(column  *2 * 0.866f - 0.866f, 0, row * 1.5f),0,0,0,1, row, column, terrainGenerator.generateColor(column, row)));
                }

            }
        }
    }

    public List<TerrainTile> getTerrainTiles() {
        return terrainTiles;
    }
}
