Added fleet location display on map
This commit is contained in:
parent
40925d54e1
commit
f7eb13abe1
|
@ -27,6 +27,12 @@ module SpaceTac.Game {
|
|||
this.battle = null;
|
||||
}
|
||||
|
||||
// Set the current location of the fleet
|
||||
setLocation(location: StarLocation): void {
|
||||
this.location = location;
|
||||
this.player.setVisited(this.location.star);
|
||||
}
|
||||
|
||||
// Add a ship in this fleet
|
||||
addShip(ship: Ship): void {
|
||||
if (this.ships.indexOf(ship) < 0) {
|
||||
|
|
|
@ -38,7 +38,7 @@ module SpaceTac.Game {
|
|||
var universe = new Universe();
|
||||
universe.generate();
|
||||
universe.player = new Game.Player();
|
||||
universe.player.setVisited(universe.stars[0]);
|
||||
universe.player.fleet.setLocation(universe.stars[0].locations[0]);
|
||||
return universe;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ module SpaceTac.View {
|
|||
this.loadImage("common/standard-bar-background.png");
|
||||
this.loadImage("common/standard-bar-foreground.png");
|
||||
this.loadImage("map/star-icon.png");
|
||||
this.loadImage("map/fleet-icon.png");
|
||||
this.loadImage("map/planet-icon.png");
|
||||
this.loadImage("map/warp-icon.png");
|
||||
this.loadImage("map/button-back.png");
|
||||
|
|
|
@ -33,8 +33,15 @@ module SpaceTac.View {
|
|||
|
||||
this.drawLocations();
|
||||
|
||||
// Draw fleet location
|
||||
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);
|
||||
|
||||
// Back button
|
||||
this.add.button(0, 0, "map-button-back", this.onBackClicked, this);
|
||||
this.add.button(0, 0, "map-button-back", this.onBackClicked, this).input.useHandCursor = true;
|
||||
}
|
||||
|
||||
// Leaving the view, unbind and destroy
|
||||
|
@ -45,7 +52,6 @@ module SpaceTac.View {
|
|||
|
||||
// Redraw the locations map
|
||||
drawLocations(): void {
|
||||
console.log(this.star.locations);
|
||||
this.locations.removeAll(true, true);
|
||||
this.star.locations.forEach((location: Game.StarLocation) => {
|
||||
var key = "map-" + Game.StarLocationType[location.type].toLowerCase() + "-icon";
|
||||
|
|
|
@ -32,6 +32,12 @@ module SpaceTac.View {
|
|||
|
||||
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);
|
||||
|
||||
// Inputs
|
||||
this.input.keyboard.addKey(Phaser.Keyboard.R).onUp.addOnce(this.revealAll, this);
|
||||
}
|
||||
|
@ -62,6 +68,7 @@ module SpaceTac.View {
|
|||
sprite.onInputUp.add(() => {
|
||||
this.game.state.start("starsystem", true, false, star, this.player);
|
||||
});
|
||||
sprite.input.useHandCursor = true;
|
||||
|
||||
this.stars.addChild(sprite);
|
||||
}
|
||||
|
|
BIN
src/assets/images/map/fleet-icon.png
Normal file
BIN
src/assets/images/map/fleet-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Loading…
Reference in a new issue