Added action points display in action bar
This commit is contained in:
parent
3a5e963240
commit
ca4f493b65
|
@ -12,10 +12,14 @@ module SpaceTac.View {
|
|||
// Progress bar displaying action points
|
||||
actionpoints: ValueBar;
|
||||
|
||||
// Current ship, whose actions are displayed
|
||||
ship: Game.Ship;
|
||||
|
||||
// Create an empty action bar
|
||||
constructor(battleview: BattleView) {
|
||||
this.battleview = battleview;
|
||||
this.actions = [];
|
||||
this.ship = null;
|
||||
|
||||
super(battleview.game, 170, 0, "ui-battle-actionbar");
|
||||
battleview.ui.add(this);
|
||||
|
@ -23,7 +27,6 @@ module SpaceTac.View {
|
|||
// Action points progress bar
|
||||
this.actionpoints = new ValueBar(battleview.game, 119, 76, "ui-battle-actionpointsempty");
|
||||
this.actionpoints.setBarImage("ui-battle-actionpointsfull");
|
||||
this.actionpoints.setValue(50, 100);
|
||||
this.addChild(this.actionpoints);
|
||||
}
|
||||
|
||||
|
@ -42,6 +45,16 @@ module SpaceTac.View {
|
|||
return icon;
|
||||
}
|
||||
|
||||
// Update the action points indicator
|
||||
updateActionPoints(): void {
|
||||
if (this.ship) {
|
||||
this.actionpoints.setValue(this.ship.ap_current.current, this.ship.ap_current.maximal);
|
||||
this.actionpoints.visible = true;
|
||||
} else {
|
||||
this.actionpoints.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set action icons from selected ship
|
||||
setShip(ship: Game.Ship): void {
|
||||
var action_bar = this;
|
||||
|
@ -51,6 +64,15 @@ module SpaceTac.View {
|
|||
actions.forEach((action: Game.BaseAction) => {
|
||||
action_bar.addAction(ship, action);
|
||||
});
|
||||
|
||||
this.ship = ship;
|
||||
|
||||
this.updateActionPoints();
|
||||
}
|
||||
|
||||
// Called by an action icon when the action has been applied
|
||||
actionEnded(): void {
|
||||
this.updateActionPoints();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ module SpaceTac.View {
|
|||
|
||||
// Icon to activate a ship capability (move, fire...)
|
||||
export class ActionIcon extends Phaser.Button {
|
||||
// Link to the parent bar
|
||||
bar: ActionBar;
|
||||
|
||||
// Link to the parent battle view
|
||||
battleview: BattleView;
|
||||
|
@ -18,6 +20,7 @@ module SpaceTac.View {
|
|||
|
||||
// Create an icon for a single ship action
|
||||
constructor(bar: ActionBar, x: number, y: number, ship: Game.Ship, action: Game.BaseAction) {
|
||||
this.bar = bar;
|
||||
this.battleview = bar.battleview;
|
||||
this.ship = ship;
|
||||
this.action = action;
|
||||
|
@ -64,6 +67,7 @@ module SpaceTac.View {
|
|||
|
||||
if (this.action.apply(this.battleview.battle, this.ship, target)) {
|
||||
this.battleview.exitTargettingMode();
|
||||
this.bar.actionEnded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue