evil-inside/src/ei/game/scene/units/APU.java

119 lines
3 KiB
Java
Raw Normal View History

2007-04-19 12:38:30 +00:00
package ei.game.scene.units;
import ei.engine.math.Vector2f;
import ei.engine.math.Vector2i;
import ei.engine.scene.Sprite;
2007-04-23 13:58:47 +00:00
import ei.engine.sound.Sound;
import ei.game.gamestate.InGameState;
import ei.game.network.entities.NetworkUnit;
2007-04-19 12:38:30 +00:00
import ei.game.player.Player;
import ei.game.scene.SelectBox;
import ei.game.scene.weapons.Explotion;
2007-04-19 12:38:30 +00:00
import ei.game.scene.weapons.MachineGun;
import ei.game.scene.weapons.Weapon;
/**
*
* @author Jesper Lundin
*
*/
public class APU extends NetworkUnit{
2007-04-19 12:38:30 +00:00
private SelectBox selectionBox;
private Sprite sprite;
2007-04-23 13:58:47 +00:00
private Sound gunSound;
private Sound[] moveSound;
2007-04-23 13:58:47 +00:00
private Sound attackSound;
private Sound selectSound;
public APU(Player p, InGameState inGameState) {
super(70, p, inGameState);
2007-04-19 12:38:30 +00:00
}
public APU(int x, int y, Player p, InGameState inGameState){
super(70, new Vector2i(x,y), p, inGameState);
}
public void init(){
setBuildTime(200);
setPrice(200);
}
public void initGraphics(){
sprite = new Sprite("APU", "data/units/apu/apu0000.png");
2007-04-19 12:38:30 +00:00
sprite.setSize(new Vector2f(40,40));
getNode().add(sprite);
2007-04-23 19:33:27 +00:00
2007-04-23 13:58:47 +00:00
gunSound = new Sound("gunSound", "data/sounds/machinegun.wav");
moveSound = new Sound[2];
2007-04-23 16:25:27 +00:00
moveSound[0] = new Sound("moveSound", "data/sounds/APUmove1.wav");
moveSound[1] = new Sound("moveSound", "data/sounds/APUmove2.wav");
2007-04-23 13:58:47 +00:00
selectSound = new Sound("selectSound", "data/sounds/APUselect.wav");
2007-04-23 15:24:59 +00:00
attackSound = new Sound("attackSound", "data/sounds/APUattack.wav");
2007-04-23 19:33:27 +00:00
gunSound.setLocation(getNode().getLocation());
moveSound[0].setLocation(getNode().getLocation());
moveSound[1].setLocation(getNode().getLocation());
selectSound.setLocation(getNode().getLocation());
attackSound.setLocation(getNode().getLocation());
2007-04-19 12:38:30 +00:00
selectionBox = new SelectBox(0,40,40,getMaxLife());
2007-04-19 12:38:30 +00:00
}
protected SelectBox getSelection() {
return selectionBox;
}
/**
* Returns the weapon connected to this type
* of unit.
*/
public Weapon getWeapon(Vector2f startPos) {
return new MachineGun(startPos, getInGameState());
2007-04-19 12:38:30 +00:00
}
/**
* This unit type is now destroyed.
*/
public void destroyed(){
getInGameState().getWeaponHandler().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY()), getInGameState()));
2007-04-23 13:58:47 +00:00
}
public Sound getGunSound() {
return gunSound;
}
public Sound getMoveSound() {
2007-04-23 16:25:27 +00:00
return moveSound[(int)(Math.random()*2)];
2007-04-23 13:58:47 +00:00
}
public Sound getSelectSound() {
return selectSound;
2007-04-19 12:38:30 +00:00
}
2007-04-23 15:24:59 +00:00
public Sound getAttackSound() {
return attackSound;
}
2007-04-19 12:38:30 +00:00
/**
* returns the velocity of the unit type.
* @return
*/
public float getVelocity() {
return 2;
}
/**
* Manages the sprite connected to this unit.
* @param s
*/
public void setSprite(Sprite s) {
this.sprite = s;
}
/**
* returns the sprite connected to this type
* of unit.
* @return
*/
public Sprite getSprite() {
return this.sprite;
}
@Override
public int getMaintenanceCost() {
return 50;
}
2007-04-19 12:38:30 +00:00
}