evil-inside/src/ei/game/gamestate/InGameState.java

84 lines
2 KiB
Java
Raw Normal View History

package ei.game.gamestate;
import ei.engine.scene.Node;
2007-04-23 15:24:59 +00:00
import ei.engine.sound.Sound;
import ei.engine.state.GameState;
2007-04-23 16:26:39 +00:00
import ei.game.hud.InGameHud;
import ei.game.input.InGameMouseInput;
import ei.game.player.HumanPlayer;
import ei.game.player.PlayerHandler;
import ei.game.scene.Map;
2007-04-19 12:30:43 +00:00
import ei.game.scene.units.APU;
2007-04-18 16:08:10 +00:00
import ei.game.scene.units.Bomber;
2007-04-04 16:28:57 +00:00
import ei.game.scene.units.Tank;
2007-04-18 11:56:07 +00:00
import ei.game.scene.weapons.WeaponHandler;
public class InGameState extends GameState{
private Node rootNode;
2007-04-23 16:26:39 +00:00
private InGameHud hud;
2007-04-04 16:28:57 +00:00
private static Map map;
2007-04-23 15:24:59 +00:00
private Sound music;
public InGameState(String name){
super(name);
rootNode = new Node("InGameNode");
2007-04-04 16:28:57 +00:00
map = new Map(20,20);
2007-04-23 13:49:48 +00:00
map.init("data/map/default");
2007-04-04 16:00:09 +00:00
InGameMouseInput mouse = new InGameMouseInput(map);
super.getInput().addInput(mouse);
HumanPlayer player = new HumanPlayer();
2007-04-18 16:08:10 +00:00
Tank t1 = new Tank(player);
2007-04-17 15:55:22 +00:00
player.addUnit(t1);
2007-04-18 16:08:10 +00:00
Tank t2 = new Tank(1,0, player);
2007-04-17 15:55:22 +00:00
player.addUnit(t2);
2007-04-18 16:08:10 +00:00
player.addUnit(new Tank(2,0, player));
player.addUnit(new Bomber(3, 0, player));
2007-04-23 16:25:27 +00:00
player.addUnit(new Bomber(6, 0, player));
player.addUnit(new Bomber(7, 0, player));
2007-04-19 12:30:43 +00:00
player.addUnit(new APU(4, 0, player));
2007-04-23 13:58:47 +00:00
player.addUnit(new APU(5, 0, player));
2007-04-23 19:33:27 +00:00
//player.addUnit(new CommandCenter(10, 10, player));
2007-04-17 15:55:22 +00:00
PlayerHandler.getInstance().addPlayer(player);
2007-04-18 11:56:07 +00:00
rootNode.add(map.getMapNode());
rootNode.add(PlayerHandler.getInstance().getNode());
2007-04-18 11:56:07 +00:00
rootNode.add(WeaponHandler.getInstance().getNode());
2007-04-23 15:24:59 +00:00
music = new Sound("music", "data/sounds/ei.ogg");
music.loop();
2007-04-18 11:56:07 +00:00
2007-04-23 16:26:39 +00:00
hud = new InGameHud(player);
rootNode.add(hud.getNode());
}
/**
* Renders the gamestate
*/
public void render() {
rootNode.render();
}
/**
* Updates the gamestate
*/
public void update() {
PlayerHandler.getInstance().update();
2007-04-18 11:56:07 +00:00
WeaponHandler.getInstance().update();
2007-04-23 16:26:39 +00:00
hud.update();
2007-03-15 19:26:15 +00:00
rootNode.update();
}
/**
*Returns the map of the game
*
* @return The map of the game
*/
2007-04-04 16:28:57 +00:00
public static Map getMap() {
return map;
}
}