cicaprojekt/cicaprojekt/Game.java

84 lines
2.1 KiB
Java
Raw Normal View History

package cicaprojekt;
2016-05-07 15:41:25 +00:00
import java.awt.*;
2016-05-07 12:04:42 +00:00
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Random;
public class Game {
2016-04-24 21:01:34 +00:00
private Player oneill;
2016-05-07 12:04:42 +00:00
private Player jaffa;
private PlayerBase replicator;
2016-04-24 21:01:34 +00:00
private Dungeon dungeon;
2016-05-07 12:04:42 +00:00
private Random random;
2016-04-24 21:01:34 +00:00
private FlowOfTime flowoftime;
2016-05-07 12:24:23 +00:00
private Display display;
public static Game instance = new Game();
2016-05-07 12:24:23 +00:00
private Game() {
2016-05-07 12:04:42 +00:00
dungeon = new Dungeon();
random = new Random();
2016-05-07 12:06:09 +00:00
flowoftime = new FlowOfTime();
2016-05-07 12:24:23 +00:00
display = new Display();
2016-05-07 12:04:42 +00:00
}
public void allZPMsCollected(GameoverCause cause) {
this.stopGame(cause);
2016-04-24 21:01:34 +00:00
}
2016-05-07 12:04:42 +00:00
public void startGame(File dungeonFile) throws IOException {
Stargate.init();
Map<String, Tile> players = dungeon.buildDungeon(dungeonFile, display);
2016-05-07 12:04:42 +00:00
oneill = new Player("O'Neill", players.get("oneill"), getRandomDirection());
jaffa = new Player("Jaffa", players.get("jaffa"), getRandomDirection());
replicator = new PlayerBase("Replicator", players.get("replicator"), getRandomDirection());
2016-05-07 12:06:09 +00:00
flowoftime.start(420*420);
2016-05-07 12:04:42 +00:00
}
private Direction getRandomDirection() {
return Direction.values()[random.nextInt(Direction.values().length)];
2016-04-24 21:01:34 +00:00
}
public void stopGame(GameoverCause cause) {
2016-04-24 21:01:34 +00:00
}
public void moveONeill(Direction direction) {
oneill.move(direction);
}
public void moveJaffa(Direction direction) {
jaffa.move(direction);
}
public void boxONeill() {
2016-05-07 14:22:59 +00:00
if(oneill.hasBox())
oneill.boxDrop();
else
oneill.boxLift();
}
public void boxJaffa() {
2016-05-07 14:22:59 +00:00
if(jaffa.hasBox())
jaffa.boxDrop();
else
jaffa.boxLift();
}
2016-05-07 15:41:25 +00:00
public void shootStargate(Color color) {
if(color == Color.YELLOW || color == Color.BLUE)
oneill.shootStargate(Stargate.get(color));
else
jaffa.shootStargate(Stargate.get(color));
}
public void updateDisplay() {
}
}