This commit is contained in:
parent
5c5084f211
commit
a92a0c021e
20 changed files with 281 additions and 12 deletions
|
|
@ -1,19 +1,107 @@
|
|||
package ei.game.scene.buildings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import ei.engine.math.Vector2f;
|
||||
import ei.engine.math.Vector2i;
|
||||
import ei.engine.math.Vector3f;
|
||||
import ei.engine.scene.Node;
|
||||
import ei.game.algo.AStar;
|
||||
import ei.game.algo.AStarNode;
|
||||
import ei.game.gamestate.InGameState;
|
||||
import ei.game.player.Player;
|
||||
import ei.game.scene.GameEntity;
|
||||
import ei.game.scene.Map;
|
||||
import ei.game.scene.units.Unit;
|
||||
import ei.game.scene.weapons.Weapon;
|
||||
import ei.game.scene.weapons.WeaponHandler;
|
||||
|
||||
public abstract class Building extends GameEntity{
|
||||
private ArrayList<Unit> availableUnits;
|
||||
private Queue<Unit> buildQueue;
|
||||
private Node unitNode;
|
||||
private Vector2i oldPos;
|
||||
private int size;
|
||||
|
||||
|
||||
public Building(int l, Vector2i pos, Player p, int size) {
|
||||
super(l, p);
|
||||
this.size = size;
|
||||
unitNode = new Node("UnitNode");
|
||||
unitNode.setLocation(Map.getPixelByPos(pos.getX(), pos.getY(), this.size));
|
||||
System.out.println("location: "+unitNode.getLocation());
|
||||
setPos(pos.getX(), pos.getY(), this.size);
|
||||
}
|
||||
|
||||
public Building(int l, Player p) {
|
||||
super(l,p);
|
||||
// TODO Auto-generated constructor stub
|
||||
public void setSelected(boolean b) {
|
||||
if(b) {
|
||||
unitNode.add(getSelection().getSelectNode());
|
||||
}
|
||||
else{
|
||||
unitNode.remove(getSelection().getSelectNode());
|
||||
}
|
||||
}
|
||||
|
||||
public void setMouseOver(boolean b) {
|
||||
if(b) {
|
||||
unitNode.add(getSelection().getMouseOverNode());
|
||||
}
|
||||
else{
|
||||
unitNode.remove(getSelection().getMouseOverNode());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sets the size of the building.
|
||||
* @param size
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
/**
|
||||
* Returns the sprite for the unit
|
||||
*
|
||||
* @return The sprite for the unit
|
||||
*/
|
||||
public Node getNode(){
|
||||
return unitNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the pos of the unit in the map
|
||||
*
|
||||
* @param x The x pos to move to
|
||||
* @param y The y pos to move to
|
||||
*/
|
||||
public void setPos(int x, int y, int size) {
|
||||
if(oldPos!=null) {
|
||||
InGameState.getMap().removeBuildPos(oldPos.getX(), oldPos.getY(), size);
|
||||
}
|
||||
oldPos = new Vector2i(x, y);
|
||||
InGameState.getMap().setBuildPos(this, x, y, size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes this unit from the game.
|
||||
*
|
||||
*/
|
||||
public void removeUnit(){
|
||||
unitNode.remove(getSprite());
|
||||
getPlayer().removeUnit(this);
|
||||
InGameState.getMap().removePos(oldPos.getX(), oldPos.getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Updating the unit
|
||||
*/
|
||||
public void update() {
|
||||
|
||||
if(getLife()<=0) {
|
||||
removeUnit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue