Fixed some display issues with universe and system maps
This commit is contained in:
parent
be807ae51a
commit
f48df7155a
|
@ -30,8 +30,10 @@ module SpaceTac.View {
|
|||
create() {
|
||||
this.locations = this.add.group();
|
||||
|
||||
this.scaling = 720 / (this.star.radius * 2);
|
||||
this.locations.position.set(this.star.radius * this.scaling, this.star.radius * this.scaling);
|
||||
var display_margin = 50;
|
||||
var display_width = 720 - (display_margin * 2);
|
||||
this.scaling = display_width / (this.star.radius * 2);
|
||||
this.locations.position.set(display_margin + display_width / 2, display_margin + display_width / 2);
|
||||
this.locations.scale.set(this.scaling);
|
||||
|
||||
// Buttons
|
||||
|
@ -58,14 +60,21 @@ module SpaceTac.View {
|
|||
this.drawLocations();
|
||||
|
||||
// Draw fleet
|
||||
if (this.player.fleet.location.star === this.star) {
|
||||
this.drawFleet();
|
||||
}
|
||||
|
||||
// Buttons
|
||||
this.button_jump.visible = this.player.fleet.location.jump_dest !== null;
|
||||
}
|
||||
|
||||
// Draw the fleet marker
|
||||
drawFleet(): void {
|
||||
var location = this.player.fleet.location;
|
||||
var fleet = this.add.sprite(location.x, location.y, "map-fleet-icon", 0, this.locations);
|
||||
fleet.scale.set(1.0 / this.scaling, 1.0 / this.scaling);
|
||||
fleet.anchor.set(0.5, -0.5);
|
||||
this.game.tweens.create(fleet).to({angle: -360}, 5000, undefined, true, 0, -1);
|
||||
|
||||
// Buttons
|
||||
this.button_jump.visible = this.player.fleet.location.jump_dest !== null;
|
||||
}
|
||||
|
||||
// Redraw the locations map
|
||||
|
|
|
@ -26,17 +26,13 @@ module SpaceTac.View {
|
|||
create() {
|
||||
this.stars = this.add.group();
|
||||
|
||||
this.scaling = 720 / (this.universe.radius * 2);
|
||||
this.stars.position.set(this.universe.radius * this.scaling, this.universe.radius * this.scaling);
|
||||
var display_margin = 50;
|
||||
var display_width = 720 - (display_margin * 2);
|
||||
this.scaling = display_width / (this.universe.radius * 2);
|
||||
this.stars.position.set(display_margin + display_width / 2, display_margin + display_width / 2);
|
||||
this.stars.scale.set(this.scaling);
|
||||
|
||||
this.drawStars();
|
||||
|
||||
var location = this.player.fleet.location.star;
|
||||
var fleet = this.add.sprite(location.x, location.y, "map-fleet-icon", 0, this.stars);
|
||||
fleet.scale.set(1.0 / this.scaling, 1.0 / this.scaling);
|
||||
fleet.anchor.set(0.5, -0.5);
|
||||
this.game.tweens.create(fleet).to({angle: -360}, 5000, undefined, true, 0, -1);
|
||||
this.drawAll();
|
||||
|
||||
// Inputs
|
||||
this.input.keyboard.addKey(Phaser.Keyboard.R).onUp.addOnce(this.revealAll, this);
|
||||
|
@ -48,9 +44,26 @@ module SpaceTac.View {
|
|||
this.player = null;
|
||||
}
|
||||
|
||||
// Redraw the star map
|
||||
drawStars(): void {
|
||||
// Redraw the whole scene
|
||||
drawAll(): void {
|
||||
this.stars.removeAll(true, true);
|
||||
|
||||
this.drawStars();
|
||||
|
||||
this.drawFleet();
|
||||
}
|
||||
|
||||
// Draw the fleet marker
|
||||
drawFleet(): void {
|
||||
var location = this.player.fleet.location.star;
|
||||
var fleet = this.add.sprite(location.x, location.y, "map-fleet-icon", 0, this.stars);
|
||||
fleet.scale.set(1.0 / this.scaling, 1.0 / this.scaling);
|
||||
fleet.anchor.set(0.5, -0.5);
|
||||
this.game.tweens.create(fleet).to({angle: -360}, 5000, undefined, true, 0, -1);
|
||||
}
|
||||
|
||||
// Draw the stars and links
|
||||
drawStars(): void {
|
||||
this.universe.starlinks.forEach((link: Game.StarLink) => {
|
||||
if (this.player.hasVisited(link.first) || this.player.hasVisited(link.second)) {
|
||||
var line = this.add.graphics(0, 0, this.stars);
|
||||
|
@ -87,7 +100,7 @@ module SpaceTac.View {
|
|||
this.universe.stars.forEach((star: Game.Star) => {
|
||||
this.player.setVisited(star);
|
||||
});
|
||||
this.drawStars();
|
||||
this.drawAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue