yo
This commit is contained in:
parent
f707008ffb
commit
92e08382a8
10 changed files with 95 additions and 4 deletions
|
|
@ -2,6 +2,9 @@ package ei.game.player;
|
|||
|
||||
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;
|
||||
|
||||
public class AiPlayer extends Player{
|
||||
private CommandCenter cc;
|
||||
|
|
@ -16,5 +19,30 @@ public class AiPlayer extends Player{
|
|||
public Building getCC() {
|
||||
return cc;
|
||||
}
|
||||
public void update() {
|
||||
super.update();
|
||||
if(getKredits() >= 800 && cc.getBuildQueueSize()==0) {
|
||||
int unitToBuild = (int)(Math.random()*2);
|
||||
if(unitToBuild==0) {
|
||||
cc.buildUnit(new APU(this));
|
||||
}
|
||||
else if(unitToBuild==1) {
|
||||
cc.buildUnit(new Tank(this));
|
||||
}
|
||||
else if(unitToBuild==2) {
|
||||
cc.buildUnit(new Bomber(this));
|
||||
}
|
||||
}
|
||||
if(unitCount()>=10) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue