Added temporary display of hull and shields, to see weapon effects
This commit is contained in:
parent
4d29d2cbc2
commit
55615600b8
|
@ -105,6 +105,10 @@ module SpaceTac.Game {
|
|||
});
|
||||
this.placeShips();
|
||||
this.throwInitiative();
|
||||
this.play_order.forEach((ship: Ship) => {
|
||||
ship.updateAttributes();
|
||||
ship.restoreHealth();
|
||||
});
|
||||
this.advanceToNextShip(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ module SpaceTac.Game.Equipments {
|
|||
// Equipment: Gatling Gun
|
||||
export class GatlingGun extends AbstractWeapon {
|
||||
constructor() {
|
||||
super("Gatling Gun", 10, 20);
|
||||
super("Gatling Gun", 50, 100);
|
||||
|
||||
this.setRange(80, 150, false);
|
||||
this.setRange(300, 300, false);
|
||||
|
||||
this.ap_usage = new Range(3, 4);
|
||||
this.min_level = new IntegerRange(1, 3);
|
||||
|
|
|
@ -5,8 +5,13 @@ module SpaceTac.Game {
|
|||
|
||||
// Event logged when a ship moves
|
||||
export class AttributeChangeEvent extends BaseLogEvent {
|
||||
// Saved version of the attribute
|
||||
attribute: Attribute;
|
||||
|
||||
constructor(ship: Ship, attribute: Attribute) {
|
||||
super("attr", ship);
|
||||
|
||||
this.attribute = Tools.copyObject(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,12 +40,18 @@ module SpaceTac.View {
|
|||
this.view.action_bar.setShip(event.target.ship);
|
||||
break;
|
||||
case "move":
|
||||
var move_event: Game.MoveEvent = <Game.MoveEvent>event;
|
||||
var move_event = <Game.MoveEvent>event;
|
||||
var sprite = this.view.arena.findShipSprite(move_event.ship);
|
||||
if (sprite) {
|
||||
sprite.moveTo(move_event.target.x, move_event.target.y, move_event.facing_angle, true);
|
||||
}
|
||||
break;
|
||||
case "attr":
|
||||
var attr_event = <Game.AttributeChangeEvent>event;
|
||||
var item = this.view.ship_list.findItem(attr_event.ship);
|
||||
if (item) {
|
||||
item.attributeChanged(attr_event.attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,5 +54,17 @@ module SpaceTac.View {
|
|||
this.add(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find an item for a ship
|
||||
// Returns null if not found
|
||||
findItem(ship: Game.Ship): ShipListItem {
|
||||
var found: ShipListItem = null;
|
||||
this.ships.forEach((item: ShipListItem) => {
|
||||
if (item.ship === ship) {
|
||||
found = item;
|
||||
}
|
||||
});
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,13 @@ module SpaceTac.View {
|
|||
// One item in a ship list (used in BattleView)
|
||||
export class ShipListItem extends Phaser.Button {
|
||||
// Reference to the ship game object
|
||||
private ship: Game.Ship;
|
||||
ship: Game.Ship;
|
||||
|
||||
// Hull display
|
||||
hull: ValueBar;
|
||||
|
||||
// Shield display
|
||||
shield: ValueBar;
|
||||
|
||||
// Create a ship button for the battle ship list
|
||||
constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) {
|
||||
|
@ -19,6 +25,23 @@ module SpaceTac.View {
|
|||
this.onInputOut.add(() => {
|
||||
list.battleview.cursorOffShip(ship);
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue