2014-12-31 00:00:00 +00:00
|
|
|
module SpaceTac.View {
|
2015-01-07 00:00:00 +00:00
|
|
|
"use strict";
|
|
|
|
|
2014-12-30 00:00:00 +00:00
|
|
|
// One item in a ship list (used in BattleView)
|
|
|
|
export class ShipListItem extends Phaser.Button {
|
2014-12-31 00:00:00 +00:00
|
|
|
// Reference to the ship game object
|
2015-01-28 00:00:00 +00:00
|
|
|
ship: Game.Ship;
|
|
|
|
|
|
|
|
// Hull display
|
|
|
|
hull: ValueBar;
|
|
|
|
|
|
|
|
// Shield display
|
|
|
|
shield: ValueBar;
|
2014-12-31 00:00:00 +00:00
|
|
|
|
2014-12-30 00:00:00 +00:00
|
|
|
// Create a ship button for the battle ship list
|
2015-01-14 00:00:00 +00:00
|
|
|
constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) {
|
2014-12-31 00:00:00 +00:00
|
|
|
this.ship = ship;
|
|
|
|
|
2015-01-23 00:00:00 +00:00
|
|
|
super(list.battleview.game, x, y, owned ? "battle-shiplist-own" : "battle-shiplist-enemy");
|
2014-12-31 00:00:00 +00:00
|
|
|
|
2014-12-31 00:00:00 +00:00
|
|
|
this.input.useHandCursor = true;
|
2014-12-31 00:00:00 +00:00
|
|
|
this.onInputOver.add(() => {
|
2015-01-14 00:00:00 +00:00
|
|
|
list.battleview.cursorOnShip(ship);
|
2014-12-31 00:00:00 +00:00
|
|
|
});
|
|
|
|
this.onInputOut.add(() => {
|
2015-01-14 00:00:00 +00:00
|
|
|
list.battleview.cursorOffShip(ship);
|
2014-12-31 00:00:00 +00:00
|
|
|
});
|
2015-01-28 00:00:00 +00:00
|
|
|
|
|
|
|
this.hull = ValueBar.newStandard(list.battleview.game, 40, 0);
|
|
|
|
this.hull.scale.set(0.1, 0.1);
|
|
|
|
this.addChild(this.hull);
|
|
|
|
|
|
|
|
this.shield = ValueBar.newStandard(list.battleview.game, 40, 20);
|
|
|
|
this.shield.scale.set(0.1, 0.1);
|
|
|
|
this.addChild(this.shield);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Called when an attribute for this ship changed through the battle log
|
|
|
|
attributeChanged(attribute: Game.Attribute): void {
|
|
|
|
if (attribute.code === Game.AttributeCode.Hull) {
|
|
|
|
this.hull.setValue(attribute.current, attribute.maximal);
|
|
|
|
} else if (attribute.code === Game.AttributeCode.Shield) {
|
|
|
|
this.shield.setValue(attribute.current, attribute.maximal);
|
|
|
|
}
|
2014-12-30 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-07 00:00:00 +00:00
|
|
|
}
|