Added character sheet to map view
This commit is contained in:
parent
760c8ddf27
commit
b25e2dc248
|
@ -83,7 +83,7 @@ module TS.SpaceTac.UI {
|
||||||
this.ship_list = new ShipList(this);
|
this.ship_list = new ShipList(this);
|
||||||
this.ship_tooltip = new ShipTooltip(this);
|
this.ship_tooltip = new ShipTooltip(this);
|
||||||
this.add.existing(this.ship_tooltip);
|
this.add.existing(this.ship_tooltip);
|
||||||
this.character_sheet = new CharacterSheet(this);
|
this.character_sheet = new CharacterSheet(this, -this.getWidth());
|
||||||
this.add.existing(this.character_sheet);
|
this.add.existing(this.character_sheet);
|
||||||
|
|
||||||
// "Battle" animation
|
// "Battle" animation
|
||||||
|
|
|
@ -4,9 +4,9 @@ module TS.SpaceTac.UI.Specs {
|
||||||
|
|
||||||
it("displays fleet and ship information", function () {
|
it("displays fleet and ship information", function () {
|
||||||
let view = testgame.baseview;
|
let view = testgame.baseview;
|
||||||
let sheet = new CharacterSheet(view);
|
let sheet = new CharacterSheet(view, -1000);
|
||||||
|
|
||||||
expect(sheet.x).toEqual(-sheet.width);
|
expect(sheet.x).toEqual(-1000);
|
||||||
|
|
||||||
let fleet = new Fleet();
|
let fleet = new Fleet();
|
||||||
let ship1 = fleet.addShip();
|
let ship1 = fleet.addShip();
|
||||||
|
|
|
@ -3,6 +3,10 @@ module TS.SpaceTac.UI {
|
||||||
* Character sheet, displaying ship characteristics
|
* Character sheet, displaying ship characteristics
|
||||||
*/
|
*/
|
||||||
export class CharacterSheet extends Phaser.Image {
|
export class CharacterSheet extends Phaser.Image {
|
||||||
|
// X positions
|
||||||
|
xshown: number;
|
||||||
|
xhidden: number;
|
||||||
|
|
||||||
// Currently displayed fleet
|
// Currently displayed fleet
|
||||||
fleet: Fleet;
|
fleet: Fleet;
|
||||||
|
|
||||||
|
@ -27,10 +31,12 @@ module TS.SpaceTac.UI {
|
||||||
// Attributes and skills
|
// Attributes and skills
|
||||||
attributes: { [key: string]: Phaser.Text } = {};
|
attributes: { [key: string]: Phaser.Text } = {};
|
||||||
|
|
||||||
constructor(view: BaseView) {
|
constructor(view: BaseView, xhidden = -2000, xshown = 0) {
|
||||||
super(view.game, 0, 0, "character-sheet");
|
super(view.game, 0, 0, "character-sheet");
|
||||||
|
|
||||||
this.x = -this.width;
|
this.x = xhidden;
|
||||||
|
this.xshown = xshown;
|
||||||
|
this.xhidden = xhidden;
|
||||||
this.inputEnabled = true;
|
this.inputEnabled = true;
|
||||||
|
|
||||||
let close_button = new Phaser.Button(this.game, view.getWidth(), 0, "character-close", () => this.hide());
|
let close_button = new Phaser.Button(this.game, view.getWidth(), 0, "character-close", () => this.hide());
|
||||||
|
@ -136,17 +142,24 @@ module TS.SpaceTac.UI {
|
||||||
this.updateFleet(ship.fleet);
|
this.updateFleet(ship.fleet);
|
||||||
|
|
||||||
if (animate) {
|
if (animate) {
|
||||||
this.game.tweens.create(this).to({ x: 0 }, 800, Phaser.Easing.Circular.InOut, true);
|
this.game.tweens.create(this).to({ x: this.xshown }, 800, Phaser.Easing.Circular.InOut, true);
|
||||||
} else {
|
} else {
|
||||||
this.x = 0;
|
this.x = this.xshown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide the sheet
|
* Hide the sheet
|
||||||
*/
|
*/
|
||||||
hide() {
|
hide(animate = true) {
|
||||||
this.game.tweens.create(this).to({ x: -this.width }, 800, Phaser.Easing.Circular.InOut, true);
|
this.portraits.children.forEach((portrait: Phaser.Button) => portrait.loadTexture("character-ship"));
|
||||||
|
|
||||||
|
if (animate) {
|
||||||
|
this.game.tweens.create(this).to({ x: this.xhidden }, 800, Phaser.Easing.Circular.InOut, true);
|
||||||
|
} else {
|
||||||
|
this.x = this.xhidden;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ module TS.SpaceTac.UI {
|
||||||
// Button to jump to another system
|
// Button to jump to another system
|
||||||
button_jump: Phaser.Button;
|
button_jump: Phaser.Button;
|
||||||
|
|
||||||
|
// Character sheet
|
||||||
|
character_sheet: CharacterSheet;
|
||||||
|
|
||||||
// Zoom level
|
// Zoom level
|
||||||
zoom = 0;
|
zoom = 0;
|
||||||
|
|
||||||
|
@ -69,8 +72,13 @@ module TS.SpaceTac.UI {
|
||||||
this.group.addChild(this.button_jump);
|
this.group.addChild(this.button_jump);
|
||||||
|
|
||||||
this.setZoom(2);
|
this.setZoom(2);
|
||||||
this.add.button(1830, 100, "map-zoom-in", () => this.setZoom(this.zoom + 1)).anchor.set(0.5, 0.5);
|
this.add.button(1520, 100, "map-zoom-in", () => this.setZoom(this.zoom + 1)).anchor.set(0.5, 0.5);
|
||||||
this.add.button(1830, 980, "map-zoom-out", () => this.setZoom(this.zoom - 1)).anchor.set(0.5, 0.5);
|
this.add.button(1520, 980, "map-zoom-out", () => this.setZoom(this.zoom - 1)).anchor.set(0.5, 0.5);
|
||||||
|
|
||||||
|
this.character_sheet = new CharacterSheet(this, this.getWidth() - 307);
|
||||||
|
this.character_sheet.show(this.player.fleet.ships[0], false);
|
||||||
|
this.character_sheet.hide(false);
|
||||||
|
this.add.existing(this.character_sheet);
|
||||||
|
|
||||||
this.gameui.audio.startMusic("walking-along");
|
this.gameui.audio.startMusic("walking-along");
|
||||||
|
|
||||||
|
@ -124,7 +132,7 @@ module TS.SpaceTac.UI {
|
||||||
*/
|
*/
|
||||||
setCamera(x: number, y: number, span: number, duration = 500, easing = Phaser.Easing.Cubic.InOut) {
|
setCamera(x: number, y: number, span: number, duration = 500, easing = Phaser.Easing.Cubic.InOut) {
|
||||||
let scale = 1000 / span;
|
let scale = 1000 / span;
|
||||||
this.tweens.create(this.group.position).to({ x: 960 - x * scale, y: 540 - y * scale }, duration, easing).start();
|
this.tweens.create(this.group.position).to({ x: 800 - x * scale, y: 540 - y * scale }, duration, easing).start();
|
||||||
this.tweens.create(this.group.scale).to({ x: scale, y: scale }, duration, easing).start();
|
this.tweens.create(this.group.scale).to({ x: scale, y: scale }, duration, easing).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue