This commit is contained in:
parent
e1c0fa7a48
commit
7e309db351
9 changed files with 16 additions and 18 deletions
Binary file not shown.
|
|
@ -30,13 +30,13 @@ public class InGameState extends GameState{
|
||||||
|
|
||||||
HumanPlayer player = new HumanPlayer();
|
HumanPlayer player = new HumanPlayer();
|
||||||
Tank t1 = new Tank(player);
|
Tank t1 = new Tank(player);
|
||||||
t1.setLife(10);
|
|
||||||
player.addUnit(t1);
|
player.addUnit(t1);
|
||||||
Tank t2 = new Tank(1,0, player);
|
Tank t2 = new Tank(1,0, player);
|
||||||
t2.setLife(30);
|
|
||||||
player.addUnit(t2);
|
player.addUnit(t2);
|
||||||
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(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));
|
||||||
player.addUnit(new CommandCenter(10, 10, player));
|
player.addUnit(new CommandCenter(10, 10, player));
|
||||||
|
|
|
||||||
|
|
@ -84,13 +84,13 @@ public abstract class Building extends GameEntity{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes this unit from the game.
|
* Removes this building from the game.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeUnit(){
|
public void removeBuilding(){
|
||||||
unitNode.remove(getSprite());
|
unitNode.remove(getSprite());
|
||||||
getPlayer().removeUnit(this);
|
getPlayer().removeUnit(this);
|
||||||
InGameState.getMap().removePos(oldPos.getX(), oldPos.getY());
|
InGameState.getMap().removeBuildPos(oldPos.getX(), oldPos.getY(), this.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -99,7 +99,7 @@ public abstract class Building extends GameEntity{
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|
||||||
if(getLife()<=0) {
|
if(getLife()<=0) {
|
||||||
removeUnit();
|
removeBuilding();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ public abstract class MapEntity extends Unit{
|
||||||
removeUnit();
|
removeUnit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void move(int x, int y){
|
||||||
|
}
|
||||||
|
|
||||||
protected void move(int x, int y, boolean b) {}
|
protected void move(int x, int y, boolean b) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class APU extends Unit{
|
||||||
private Sprite sprite;
|
private Sprite sprite;
|
||||||
|
|
||||||
private Sound gunSound;
|
private Sound gunSound;
|
||||||
private Sound moveSound;
|
private Sound moveSound[] = new Sound[2];
|
||||||
private Sound attackSound;
|
private Sound attackSound;
|
||||||
private Sound selectSound;
|
private Sound selectSound;
|
||||||
|
|
||||||
|
|
@ -28,12 +28,12 @@ public class APU extends Unit{
|
||||||
sprite.setSize(new Vector2f(40,40));
|
sprite.setSize(new Vector2f(40,40));
|
||||||
getNode().add(sprite);
|
getNode().add(sprite);
|
||||||
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
|
||||||
moveSound = new Sound("moveSound", "data/sounds/APUmove1.wav");
|
moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav");
|
||||||
|
moveSound[1] = new Sound("moveSound", "data/sounds/APUmove2.wav");
|
||||||
selectSound = new Sound("selectSound", "data/sounds/APUselect.wav");
|
selectSound = new Sound("selectSound", "data/sounds/APUselect.wav");
|
||||||
attackSound = new Sound("attackSound", "data/sounds/APUattack.wav");
|
attackSound = new Sound("attackSound", "data/sounds/APUattack.wav");
|
||||||
|
|
||||||
selectionBox = new SelectBox(40,40,getMaxLife());
|
selectionBox = new SelectBox(40,40,getMaxLife());
|
||||||
setLife(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectBox getSelection() {
|
protected SelectBox getSelection() {
|
||||||
|
|
@ -56,7 +56,7 @@ public class APU extends Unit{
|
||||||
return gunSound;
|
return gunSound;
|
||||||
}
|
}
|
||||||
public Sound getMoveSound() {
|
public Sound getMoveSound() {
|
||||||
return moveSound;
|
return moveSound[(int)(Math.random()*2)];
|
||||||
}
|
}
|
||||||
public Sound getSelectSound() {
|
public Sound getSelectSound() {
|
||||||
return selectSound;
|
return selectSound;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ public class Bomber extends Unit{
|
||||||
attackSound = new Sound("attackSound", "data/sounds/BOMBERattack.wav");
|
attackSound = new Sound("attackSound", "data/sounds/BOMBERattack.wav");
|
||||||
|
|
||||||
selectionBox = new SelectBox(40,40,getMaxLife());
|
selectionBox = new SelectBox(40,40,getMaxLife());
|
||||||
setLife(180);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectBox getSelection() {
|
protected SelectBox getSelection() {
|
||||||
|
|
@ -70,7 +69,7 @@ public class Bomber extends Unit{
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public float getVelocity() {
|
public float getVelocity() {
|
||||||
return 3;
|
return 2;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Manages the sprite connected to this unit.
|
* Manages the sprite connected to this unit.
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ public class Tank extends Unit{
|
||||||
attackSound = new Sound("attackSound", "data/sounds/TANKattack.wav");
|
attackSound = new Sound("attackSound", "data/sounds/TANKattack.wav");
|
||||||
|
|
||||||
selectionBox = new SelectBox(40,40,getMaxLife());
|
selectionBox = new SelectBox(40,40,getMaxLife());
|
||||||
setLife(50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SelectBox getSelection() {
|
protected SelectBox getSelection() {
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ public abstract class Unit extends GameEntity{
|
||||||
* Updating the unit
|
* Updating the unit
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
|
weponTimer++;
|
||||||
if(getLife()<=0) {
|
if(getLife()<=0) {
|
||||||
removeUnit();
|
removeUnit();
|
||||||
}
|
}
|
||||||
|
|
@ -271,9 +271,7 @@ public abstract class Unit extends GameEntity{
|
||||||
WeaponHandler.getInstance().addWeapon(wepon);
|
WeaponHandler.getInstance().addWeapon(wepon);
|
||||||
weponTimer = 0;
|
weponTimer = 0;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
weponTimer++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
move(enamyPos.getX(),enamyPos.getY(), false);
|
move(enamyPos.getX(),enamyPos.getY(), false);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ public class BomberWeapon extends Weapon{
|
||||||
super(startPos);
|
super(startPos);
|
||||||
setVelocity(4);
|
setVelocity(4);
|
||||||
setRange(100);
|
setRange(100);
|
||||||
setDamage(30);
|
setDamage(40);
|
||||||
setReload(150);
|
setReload(150);
|
||||||
hit = false;
|
hit = false;
|
||||||
position = Map.getPosByPixel(startPos.getX(), startPos.getY());
|
position = Map.getPosByPixel(startPos.getX(), startPos.getY());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue