This commit is contained in:
parent
01639fd378
commit
bdd9d6c746
8 changed files with 115 additions and 68 deletions
|
|
@ -1,40 +1,40 @@
|
|||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0001111111111111000000011111111111110000
|
||||
0000000000000010000000000000000000100000
|
||||
0000000000000100000000000000000001000000
|
||||
0000000000001000000000000000000010000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000001000000000000000000010000000000
|
||||
0000000010000000000000000000100000000000
|
||||
0000000100000000000000000001000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000010000000000000000000100000000000000
|
||||
0000100000000000000000001000000000000000
|
||||
0001000000000000000000010000000000000000
|
||||
0011111111111111100000111111111111111000
|
||||
0000000000000000000000000000000000000000
|
||||
0222222222222222222002222222222222222220
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0001111111111111000000011111111111110000
|
||||
0000000000000010000000000000000000100000
|
||||
0000000000000100000000000000000001000000
|
||||
0000000000001000000000000000000010000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000001000000000000000000010000000000
|
||||
0000000010000000000000000000100000000000
|
||||
0000000100000000000000000001000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000010000000000000000000100000000000000
|
||||
0000100000000000000000001000000000000000
|
||||
0001000000000000000000010000000000000000
|
||||
0011111111111111100000111111111111111000
|
||||
0000000000000000000000000000000000000000
|
||||
0222222222222222222002222222222222222220
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000003000000000000000000000000000
|
||||
0000000000003000000000000000000000000000
|
||||
0000000000003000000000000000000000000000
|
||||
0000000000003000000000000000000000000000
|
||||
0000000000003000000000000000000000000000
|
||||
0000000000003333333333333333333333333330
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
|
|
@ -1,37 +1,37 @@
|
|||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000111100000000000000001111000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000000110000000000000000001100000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000111100000000000000001111000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000100000000000000000001000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000001000000000000000000010000000000000
|
||||
0000000110000000000000000001100000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
0000000000000000000000000000000000000000
|
||||
|
|
|
|||
|
|
@ -49,9 +49,6 @@ public class InGameState extends GameState{
|
|||
player.addUnit(new Tank(0, 0, player));
|
||||
player.addUnit(new Tank(1,0, player));
|
||||
player.addUnit(new Tank(2,0, player));
|
||||
player.addUnit(new Bomber(3, 0, player));
|
||||
player.addUnit(new Bomber(6, 0, player));
|
||||
player.addUnit(new Bomber(7, 0, player));
|
||||
player.addUnit(new APU(4, 0, player));
|
||||
player.addUnit(new APU(5, 0, player));
|
||||
PlayerHandler.getInstance().addPlayer(player);
|
||||
|
|
@ -59,9 +56,6 @@ public class InGameState extends GameState{
|
|||
AiPlayer ai = new AiPlayer();
|
||||
ai.addUnit(new Tank(1,39, ai));
|
||||
ai.addUnit(new Tank(2,39, ai));
|
||||
ai.addUnit(new Bomber(3, 39, ai));
|
||||
ai.addUnit(new Bomber(6, 39, ai));
|
||||
ai.addUnit(new Bomber(7, 39, ai));
|
||||
ai.addUnit(new APU(4, 39, ai));
|
||||
ai.addUnit(new APU(5, 39, ai));
|
||||
PlayerHandler.getInstance().addPlayer(ai);
|
||||
|
|
|
|||
|
|
@ -1,24 +1,42 @@
|
|||
package ei.game.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ei.game.scene.GameEntity;
|
||||
import ei.game.scene.buildings.Building;
|
||||
import ei.game.scene.buildings.CommandCenter;
|
||||
import ei.game.scene.units.APU;
|
||||
import ei.game.scene.units.Bomber;
|
||||
import ei.game.scene.units.Tank;
|
||||
/**
|
||||
* The AiPlayer class.
|
||||
* @author Jesper Lundin
|
||||
*
|
||||
*/
|
||||
|
||||
public class AiPlayer extends Player{
|
||||
private CommandCenter cc;
|
||||
private int timer;
|
||||
private ArrayList<GameEntity> attackingUnits;
|
||||
|
||||
/**
|
||||
* Constructor for the AiPlayer class. Creates a temporary
|
||||
*
|
||||
*/
|
||||
public AiPlayer(){
|
||||
super();
|
||||
cc = new CommandCenter(30,30,this);
|
||||
addUnit(cc);
|
||||
attackingUnits = new ArrayList<GameEntity>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Building getCC() {
|
||||
return cc;
|
||||
}
|
||||
/**
|
||||
* Handles the actions for the computer controlled player.
|
||||
*/
|
||||
public void update() {
|
||||
super.update();
|
||||
if(getKredits() >= 800 && cc.getBuildQueueSize()==0) {
|
||||
|
|
@ -33,25 +51,49 @@ public class AiPlayer extends Player{
|
|||
cc.buildUnit(new Bomber(this));
|
||||
}
|
||||
}
|
||||
if(unitCount()>=10) {
|
||||
if((unitCount()>=10 || attackingUnits.size()>=2) && timer%100==0) {
|
||||
for(int i=0; i < unitCount(); i++) {
|
||||
if(!getUnit(i).isAttacking()){
|
||||
|
||||
getUnit(i).move(false, getUnit(i).getPos().getX()-2, getUnit(i).getPos().getY()-2);
|
||||
if(!attackingUnits.contains(getUnit(i))) {
|
||||
attackingUnits.add(getUnit(i));
|
||||
if(!getUnit(i).isAttacking() && !getUnit(i).isMoving()){
|
||||
attackingUnits.get(i).move(false, attackingUnits.get(i).getPos().getX()-2, attackingUnits.get(i).getPos().getY()-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
attackingUnits.clear();
|
||||
}
|
||||
timer++;
|
||||
removeDead();
|
||||
|
||||
}
|
||||
/**
|
||||
* Removes the dead units from the temporary army.
|
||||
*
|
||||
*/
|
||||
public void removeDead(){
|
||||
for(int i=0; i<attackingUnits.size() ;i++){
|
||||
if(attackingUnits.get(i).getLife() <= 0){
|
||||
attackingUnits.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Defeated if the command center is dead.
|
||||
*/
|
||||
public boolean defeated() {
|
||||
if(cc.getLife() <= 0){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Game over man! Game over!
|
||||
*/
|
||||
public void endGame(int s) {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public abstract class GameEntity{
|
|||
|
||||
public abstract boolean isAttacking();
|
||||
|
||||
public abstract boolean isMoving();
|
||||
|
||||
|
||||
/**
|
||||
* Set the life
|
||||
|
|
|
|||
|
|
@ -215,5 +215,8 @@ public abstract class Building extends GameEntity{
|
|||
public boolean isAttacking() {
|
||||
return false;
|
||||
}
|
||||
public boolean isMoving(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,12 @@ public abstract class Unit extends GameEntity{
|
|||
}
|
||||
return true;
|
||||
}
|
||||
public boolean isMoving() {
|
||||
if(path==null || path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Moving a unit to the given pos
|
||||
*
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public abstract class Weapon {
|
|||
if(vect.getY() < part.getLocation().getY()) {
|
||||
part.getLocation().add(0f, -yVelocity, 0f);
|
||||
}
|
||||
if(Math.abs(part.getLocation().getX()-vect.getX()) < 10 && Math.abs(part.getLocation().getY()-vect.getY()) < 10) {
|
||||
if(Math.abs(part.getLocation().getX()-vect.getX()) < 15 && Math.abs(part.getLocation().getY()-vect.getY()) < 15) {
|
||||
part.regenerate = false;
|
||||
if(!hit && !InGameState.getMap().isPosEmpty(target.getX(), target.getY())) {
|
||||
InGameState.getMap().getPos(target.getX(), target.getY()).damaged(damage);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue