/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.maps.implementation;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.graphics.OrthographicCamera;
import transientlibs.maps.entities.Landmark;
import transientlibs.maps.tiles.Tile;
import transientlibs.maps.units.Unit;
import transientlibs.maps.entities.Bullet;
import transientlibs.maps.utils.pathfinding.PathFinder;
import com.badlogic.gdx.physics.box2d.World;
import java.util.ArrayList;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.Binding;
import transientlibs.bindedobjects.gamecontent.Terrain;
import transientlibs.maps.units.GenericUnit;
import transientlibs.maps.misc.MapEye;
import transientlibs.objects.general.Node;
import transientlibs.objects.primitives.Coords;
import transientlibs.preui.objects.gui.elements.Marker;
import transientlibs.preui.objects.gui.interfaces.IColour;
import transientlibs.preui.objects.states.IState;
import transientlibs.processors.misc.Detonator;
/**
*
* @author kibertoad
*/
public class TilelessMap extends Node {
public Camera camera = null;
public String code = null;
public Unit player;
public int pathfindingGoalX;
public int pathfindingGoalY;
public int sizeX = -1;
public int sizeY = -1;
public Coords drawOffset = new Coords(0, 0); //used for tileless maps
public MapEye eye = new MapEye();
public ArrayList<GenericUnit> units = new ArrayList<GenericUnit>();
public ArrayList<Bullet> missiles = new ArrayList<Bullet>();
public ArrayList<Landmark> landmarks = new ArrayList<Landmark>();
public TilelessMap() {
camera = new OrthographicCamera(Detonator.INSTANCE.currentGenericGame.getScreenWidth(), Detonator.INSTANCE.currentGenericGame.getScreenHeight());
camera.position.set(0, 0, 0);
//super(null, null, 0, 0);
}
public World getWorld() {
return null;
}
public float getCameraX() {
return camera.position.x;
}
public float getCameraY() {
return camera.position.y;
}
public int getCameraSizeX() {
return (int) camera.viewportWidth;
}
public int getCameraSizeY() {
return (int) camera.viewportHeight;
}
public GenericUnit returnUnit(int x, int y) {
for (GenericUnit u : units) {
if (u.getMapCoords().isSame(x, y)) {
return u;
}
}
return null;
}
public Coords getTileScreenCoords(int x, int y) {
return null;
}
public Coords getTileMapCoords(int screenX, int screenY) {
return null;
}
public Tile getTile(int x, int y) {
return null;
}
public Terrain getTerrain(int x, int y) {
return null;
}
public void processUnitEncounterWithLandmark(GenericUnit u) {
}
public boolean tileIsObstacle(int x, int y) {
return false;
}
public Tile getTile(Coords fromCoords) {
return null;
}
public void removeUnitFromTile(int x, int y, GenericUnit theUnit) {
}
public void removeLandmark(Landmark l) {
if (landmarks.contains(l)) {
landmarks.remove(l);
}
getTile(l.mapCoords.getIntX(), l.mapCoords.getIntY()).landmarks.remove(l);
}
public void addUnitToTile(int x, int y, GenericUnit theUnit) {
}
public void reduceCompositionPriority(IState state) {
}
public GenericUnit returnTileUnit(int setX, int setY, int notSide) {
return null;
}
public boolean hasTiles() {
return false;
}
//public void fill
public void recenterEye(int setX, int setY) {
//eye.eyePosition.x = setX;
//eye.eyePosition.y = setY;
Log.notImplemented();
}
public void moveEye(float x, float y) {
//eye.eyePosition.move(x, y);
//Coords.checkIfValidScrolling(this);
Log.notImplemented();
}
public void placeLandmark(Landmark landmark) {
placeLandmark(landmark.mapCoords.getIntX(), landmark.mapCoords.getIntY(), landmark);
}
public void placeLandmark(int x, int y, Landmark landmark) {
}
public void recountOnScreenTiles() {
}
public void placeUnit(int x, int y, GenericUnit unit) {
}
public void placeLandmark(int x, int y, int landmarkID) {
placeLandmark(x, y, new Landmark(x, y, landmarkID, this));
}
public void placeLandmark(int x, int y, String landmarkCode) {
placeLandmark(x, y, new Landmark(x, y, Binding.getBinding(Binding.landmarkBinding, landmarkCode), this));
}
public int getActualSizeX() {
return sizeX + 1;
}
public int getActualSizeY() {
return sizeY + 1;
}
public Landmark returnClosestLandmark(Coords fromCoords, int landmarkType, Landmark fromLandmark) {
boolean skipFlag = false;
PathFinder pathfinder = new PathFinder(fromCoords, this);
Landmark bestLandmark = null;
int bestResult = 999999999;
if (fromLandmark != null) {
skipFlag = true;
}
for (Landmark l : landmarks) {
Log.info("Found: " + l.ofType + "; Looking for: " + landmarkType);
if ((skipFlag == false) && (l.ofType == landmarkType)) {
pathfindingGoalX = l.mapCoords.getIntX();
pathfindingGoalY = l.mapCoords.getIntY();
pathfinder.goalX = l.mapCoords.getIntX();
pathfinder.goalY = l.mapCoords.getIntY();
pathfinder.updatePath();
if (pathfinder.path != null) {
//Log.info("Path exists");
if (pathfinder.path.getLength() < bestResult) {
//Log.info("Path is optimal");
bestResult = pathfinder.path.getLength();
bestLandmark = l;
}
}
}
if (fromLandmark == l) {
skipFlag = false;
}
}
return bestLandmark;
}
public GenericUnit getPlayer() {
return null;
}
public IColour getTileAutomapColour(int x, int y) {
return null;
}
public boolean hasTiledProperty(GenericUnit pc, String onlyaer, String harvester, String string) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public void removeUnit(GenericUnit currentOpponent) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public int getTileHeight() {
return Terrain.tileHeight;
}
public int getTileWidth() {
return Terrain.tileWidth;
}
public boolean withinBorders(int tryX, int tryY) {
return (tryX > 0) && (tryY > 0) && (tryX < getActualSizeX()) && (tryY < getActualSizeY());
}
public int getHeight() {
return sizeY;
}
public int getWidth() {
return sizeX;
}
}