/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.maps.units;
import transientlibs.maps.tiles.Tile;
import com.badlogic.gdx.physics.box2d.Body;
import transientlibs.slick2d.util.Log;
import transientlibs.bindedobjects.core.GDXImageCatalog;
import transientlibs.bindedobjects.core.datasets.Action;
import transientlibs.bindedobjects.gamecontent.Creatures;
import transientlibs.maps.entities.MapEntityGDX;
import transientlibs.objects.creatures.ai.AbstractAIBrain;
import transientlibs.objects.creatures.items.Equipment;
import transientlibs.objects.creatures.items.Inventory;
import transientlibs.objects.creatures.items.Item;
import transientlibs.objects.cards.Deck;
import transientlibs.objects.misc.GenericTask;
import transientlibs.processors.misc.Detonator;
import transientlibs.preui.gdx.game.TransientInput;
import transientlibs.maps.implementation.TilelessMap;
import transientlibs.maps.utils.fov.FOVBoard;
import transientlibs.maps.utils.pathfinding.PathFinder;
import transientlibs.objects.general.ModeSelector;
import transientlibs.objects.general.Node;
import transientlibs.objects.primitives.SmallPoints;
import transientlibs.preui.objects.gui.interfaces.IAnimation;
import transientlibs.objects.primitives.Coords;
import transientlibs.objects.primitives.Int;
/**
*
* @author kibertoad
*/
public class GDXUnit extends MapEntityGDX implements GenericUnit {
public Int sightRange = new Int(1);
//public TransientImage picture;
public Int side = new Int(-1);
public Unit collidedUnit;
public int sizeX; //absolute in pixels
public int sizeY;
public float mapSizeX; //relative to tile, where 1 = full tile
public float mapSizeY; //relative to tile, where 1 = full tile
public static int screenOffsetX = 0;
public static int screenOffsetY = 0;
public IAnimation currentAnimation = null;
public Creatures creatures;
public boolean isDead;
public SmallPoints HP = new SmallPoints(0, 0);
public static GDXUnit currentUnit;
public static GDXUnit lastUnit;
public GenericTask assignedTask = null;
public IAnimation actionAnimation = null;
public IAnimation movingAnimation;
public PathFinder pathfinder;
public Action currentAction = null;
public AbstractAIBrain AIBrain = null;
public GDXUnit target = null;
public ModeSelector modeSelector;
public Inventory inventory = new Inventory();
public Equipment equipment = new Equipment();
public Node actionTarget;
public int stepCount = 0;
public int direction = 6; // can be -1 if not moved
public int lastDirection = 6; //positioning
public Int maxActionPoints = new Int(0);
public Int actionPoints = new Int(0);
public Coords targettedCoords = new Coords();
public Coords aimedCoords = new Coords();
public boolean canSeePlayer = false;
public Deck deck = null;
public GDXImageCatalog transientImages = null;
public boolean movedThisTurn = false;
public static float step = 2f;
public GDXUnit(int onX, int onY, int setID, TilelessMap setMap) {
super(Creatures.creatures.get(setID).masterImage, onX, onY, setMap);
creatures = Creatures.creatures.get(setID);
for (Int i : creatures.equippedItems) {
equipment.equipItem(new Item(i.value));
}
ofType = setID;
isDrawn = true;
HP.setup(creatures.maxHP, creatures.maxHP);
HP.min = -10000;
Log.info("now hp: " + HP.now.value);
pathfinder = new PathFinder(mapCoords, setMap);
maxActionPoints.value = creatures.movementSpeed;
actionPoints.value = maxActionPoints.value;
pathfinder.currentMovementReach = actionPoints;
pathfinder.globalMovementReach.value = actionPoints.value;
movingAnimation = creatures.walkAnimation;
noHoverOnTransparent = false;
}
@Override
public Creatures getCreatures() {
return creatures;
}
@Override
public Coords getScreenCoords() {
return screenCoords;
}
@Override
public Coords getMapCoords() {
return mapCoords;
}
@Override
public Int getSightRange() {
return sightRange;
}
@Override
public void processTurn() {
}
@Override
public void processBrain() {
if (AIBrain != null) {
AIBrain.process();
}
}
@Override
public Int getSide() {
return side;
}
@Override
public void getDamage(int ofType, int ofAmount) {
HP.decrease(ofAmount);
}
@Override
public void getDamage(int ofAmount) {
getDamage(-1, ofAmount);
}
@Override
public void calcImagePosition() {
Detonator.INSTANCE.screenCoordsCalculator.calculateScreenCoords(this);
}
@Override
public Deck getDeck() {
return deck;
}
@Override
public AbstractAIBrain getBrain() {
return AIBrain;
}
@Override
public SmallPoints getHP() {
return HP;
}
@Override
public Inventory getInventory() {
return inventory;
}
@Override
public int getDirection() {
return direction;
}
@Override
public void setDirection(int toDirection) {
direction = toDirection;
}
@Override
public void getHealing(int ofType, int ofAmount) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void getHealing(int ofAmount) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Tile currentTile() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Tile deltaTile(float deltaX, float deltaY) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Node getActionTarget() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Coords multiplyVectorByDirection(float vector) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Int getVerticalVelocity() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void performMove(float deltaX, float deltaY) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean move(int inDirection) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public void moveUnit(TransientInput input, float delta) {
//Log.info("check movement");
movedThisTurn = false;
if (input.buttons[TransientInput.UP]) {
this.mapCoords.y -= (1 * delta);
movedThisTurn = true;
}
//else if (input.buttons[TransientInput.DOWN]) {
else if (input.buttons[TransientInput.DOWN]) {
this.mapCoords.y += (1 * delta);
movedThisTurn = true;
}
if (input.buttons[TransientInput.LEFT]) {
this.mapCoords.x -= (1 * delta);
movedThisTurn = true;
} else if (input.buttons[TransientInput.RIGHT]) {
this.mapCoords.x += (1 * delta);
movedThisTurn = true;
}
if (movedThisTurn) {
Log.info("MOVE: "+this.mapCoords.toString());
if ((direction == 4) || (direction == 6)) {
if ((getImage() != creatures.visualInformation.getDirectionImages(direction))) {
setImage(creatures.visualInformation.getDirectionImages(direction));
}
}
calcImagePosition();
}
// make sure the ship is inside the stage
//if( x < 0 ) x = 0;
//else if( x > stage.width() - width ) x = stage.width() - width;
//if( y < 0 ) y = 0;
//else if( y > stage.height() - height ) y = stage.height() - height;
}
@Override
public void processPhysicsMovement(TransientInput input, float delta) {
moveUnit(input, delta);
}
@Override
public void setDeck(Deck setDeck) {
deck = setDeck;
}
@Override
public Body getBody() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setBody(Body setB) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void syncCoordsFromBody() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
public void syncCoordsToBody() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Coords getAimedCoords() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setAimedCoords(Coords setCoords) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void processGenericMovement(TransientInput onInput) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void reCalc() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Int getActionPoints() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Int getMaxActionPoints() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public PathFinder getPathfinder() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public FOVBoard getFOV() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setFOV(FOVBoard setBoard) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}