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