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

97 lines
2.4 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;
2007-04-19 12:38:30 +00:00
import ei.game.player.Player;
import ei.game.scene.SelectBox;
import ei.game.scene.weapons.MachineGun;
import ei.game.scene.weapons.Weapon;
public class APU extends Unit{
private SelectBox selectionBox;
private Sprite sprite;
2007-04-23 13:58:47 +00:00
private Sound gunSound;
2007-04-23 16:25:27 +00:00
private Sound moveSound[] = new Sound[2];
2007-04-23 13:58:47 +00:00
private Sound attackSound;
private Sound selectSound;
2007-04-19 12:38:30 +00:00
public APU(Player p) {
this(0, 0, p);
}
public APU(int x, int y, Player p){
super(100, new Vector2i(x,y), p);
this.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");
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(40,40,getMaxLife());
}
protected SelectBox getSelection() {
return selectionBox;
}
/**
* Returns the weapon connected to this type
* of unit.
*/
public Weapon getWeapon(Vector2f startPos) {
return new MachineGun(startPos);
}
/**
* This unit type is now destroyed.
*/
public void destroyed(){
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;
}
}