2015-03-12 00:00:00 +00:00
|
|
|
module SpaceTac.View {
|
|
|
|
// Router to other states
|
|
|
|
export class Router extends Phaser.State {
|
|
|
|
create() {
|
2015-04-07 00:00:00 +00:00
|
|
|
var ui = <GameUI>this.game;
|
|
|
|
var session = ui.session;
|
2015-03-12 00:00:00 +00:00
|
|
|
|
2015-04-07 00:00:00 +00:00
|
|
|
if (!session) {
|
2015-03-12 00:00:00 +00:00
|
|
|
// No universe, go back to main menu
|
2015-03-19 00:00:00 +00:00
|
|
|
this.game.state.start("mainmenu", true, false);
|
2015-04-07 00:00:00 +00:00
|
|
|
} else if (session.getBattle()) {
|
2015-03-12 00:00:00 +00:00
|
|
|
// A battle is raging, go to it
|
2015-04-07 00:00:00 +00:00
|
|
|
this.game.state.start("battle", true, false, session.player, session.getBattle());
|
|
|
|
} else if (ui.getFocusedStar()) {
|
|
|
|
// Go to the focused star system
|
|
|
|
this.game.state.start("starsystem", true, false, ui.star, session.player);
|
2015-03-19 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
// Go to the universe map
|
2015-04-07 00:00:00 +00:00
|
|
|
this.game.state.start("universe", true, false, session.universe, session.player);
|
2015-03-12 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|