Added ai player and fixed so player kan create units
This commit is contained in:
parent
e7403858f8
commit
c83605d5c4
22 changed files with 373 additions and 123 deletions
|
|
@ -11,6 +11,7 @@ import ei.engine.scene.Box;
|
|||
import ei.engine.scene.Sprite;
|
||||
import ei.engine.texture.Texture;
|
||||
import ei.game.hud.InGameHud;
|
||||
import ei.game.player.Player;
|
||||
import ei.game.scene.GameEntity;
|
||||
import ei.game.scene.Map;
|
||||
|
||||
|
|
@ -25,10 +26,12 @@ public class InGameMouseInput extends MouseInput{
|
|||
|
||||
private InGameHud hud;
|
||||
private Map map;
|
||||
private Player player;
|
||||
|
||||
public InGameMouseInput(Map map) {
|
||||
public InGameMouseInput(Map map, Player p) {
|
||||
super("InGameMouseInput","data/cursor/cursor.png");
|
||||
this.map = map;
|
||||
this.player = p;
|
||||
this.selected = new ArrayList<GameEntity>();
|
||||
|
||||
//inits the mouse texture
|
||||
|
|
@ -205,12 +208,15 @@ public class InGameMouseInput extends MouseInput{
|
|||
public void selectUnits(Vector2i startPos, Vector2i stopPos){
|
||||
for(int i=Math.min(startPos.getX(), stopPos.getX()); i<=Math.max(startPos.getX(), stopPos.getX()) ;i++){
|
||||
for(int j=Math.min(startPos.getY(), stopPos.getY()); j<=Math.max(startPos.getY(), stopPos.getY()) ;j++){
|
||||
if(!map.isPosEmpty(i, j)){
|
||||
if(!map.isPosEmpty(i, j) && map.getPos(i, j).getPlayer() == player){
|
||||
selected.add(map.getPos(i, j));
|
||||
map.getPos(i, j).setSelected(true);
|
||||
map.getPos(i, j).setSelected(true,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!selected.isEmpty()){
|
||||
selected.get((int)(Math.random()*selected.size())).setSelected(true,true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -219,7 +225,7 @@ public class InGameMouseInput extends MouseInput{
|
|||
*/
|
||||
public void deselectAllUnits(){
|
||||
for(int i=0; i<selected.size(); i++) {
|
||||
selected.get(i).setSelected(false);
|
||||
selected.get(i).setSelected(false,false);
|
||||
}
|
||||
selected.clear();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue