1
0
Fork 0

Added display of temporary effects in ship list (no graphics yet)

This commit is contained in:
Michaël Lemaire 2015-04-22 22:03:59 +02:00
parent 0650605db9
commit 477b51bd9f
10 changed files with 67 additions and 11 deletions

3
TODO
View file

@ -1,5 +1,6 @@
* Display active effects on ships
* Add a cheat system, to use for development (win battle, revive killed ship ...)
* Add a defeat screen (game over for now)
* Add a victory screen, with looting
* Add retreat from battle
* Refactor the tooltip system to use it more
* Flash ship icons that receive damage

View file

@ -155,7 +155,7 @@ module SpaceTac.Game {
min_duration: number = 1, max_duration: number = null): void {
var template = new EffectTemplate(effect);
template.addModifier("value", new Range(min_value, max_value));
template.addModifier("duration", new Range(min_duration, max_duration));
template.addModifier("duration", new IntegerRange(min_duration, max_duration));
this.target_effects.push(template);
}

View file

@ -25,5 +25,9 @@ module SpaceTac.Game {
ship.setAttribute(ship.attributes.getRawAttr(this.attrcode), this.value);
}
}
}
getFullCode(): string {
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
}
}
}

View file

@ -18,5 +18,9 @@ module SpaceTac.Game {
this.attrcode = attrcode;
this.value = value;
}
getFullCode(): string {
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
}
}
}

View file

@ -18,5 +18,9 @@ module SpaceTac.Game {
this.attrcode = attrcode;
this.value = value;
}
getFullCode(): string {
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
}
}
}

View file

@ -26,5 +26,10 @@ module SpaceTac.Game {
singleApply(ship: Ship, on_stick: boolean): void {
// Abstract
}
// Get a full code, that can be used to identify this effect (for example: "attrlimit-aprecovery")
getFullCode(): string {
return this.code;
}
}
}

View file

@ -12,7 +12,7 @@ module SpaceTac.Game {
previous: number;
constructor(ship: Ship, effect: TemporaryEffect, previous: number) {
super("effectadd", ship);
super("effectduration", ship);
this.effect = effect;
this.previous = previous;

View file

@ -0,0 +1,15 @@
module SpaceTac.View {
"use strict";
// Icon to display an effect currently applied on a ship
export class EffectDisplay extends Phaser.Image {
constructor(game: Phaser.Game, effect: Game.TemporaryEffect) {
var key = "battle-effect-" + effect.getFullCode();
super(game, 115, 22, key, 0);
var style = {font: "bold 12px Arial", fill: "#d0d020"};
var duration = new Phaser.Text(this.game, 0, 0, effect.duration.toString(), style);
this.addChild(duration);
}
}
}

View file

@ -54,6 +54,11 @@ module SpaceTac.View {
case "endbattle":
this.processEndBattleEvent(<Game.EndBattleEvent>event);
break;
case "effectadd":
case "effectduration":
case "effectdel":
this.processEffectEvent(event);
break;
}
}
@ -141,5 +146,13 @@ module SpaceTac.View {
// TODO Game over ?
}
}
// Temporary effect on ship added, changed or removed
private processEffectEvent(event: Game.BaseLogEvent): void {
var item = this.view.ship_list.findItem(event.ship);
if (item) {
item.updateEffects();
}
}
}
}

View file

@ -30,6 +30,9 @@ module SpaceTac.View {
// Enemy indicator
layer_enemy: Phaser.Image;
// Active effects group
active_effects: Phaser.Group;
// Create a ship button for the battle ship list
constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) {
this.ship = ship;
@ -61,23 +64,32 @@ module SpaceTac.View {
this.layer_hover.visible = false;
this.addChild(this.layer_hover);
this.hull = ValueBar.newStyled(list.battleview.game, "battle-shiplist-hull", 76, 23);
this.hull = ValueBar.newStyled(list.battleview.game, "battle-shiplist-hull", 76, 26);
this.addChild(this.hull);
this.shield = ValueBar.newStyled(list.battleview.game, "battle-shiplist-shield", 76, 35);
this.shield = ValueBar.newStyled(list.battleview.game, "battle-shiplist-shield", 76, 44);
this.addChild(this.shield);
this.ap = ValueBar.newStyled(list.battleview.game, "battle-shiplist-ap", 76, 47);
this.addChild(this.ap);
this.active_effects = new Phaser.Group(this.game);
this.addChild(this.active_effects);
this.updateAttributes();
this.updateEffects();
}
// Update attributes from associated ship
updateAttributes() {
this.attributeChanged(this.ship.hull);
this.attributeChanged(this.ship.shield);
this.attributeChanged(this.ship.ap_current);
}
// Update effects applied on the ship
updateEffects() {
this.active_effects.removeAll(true);
this.ship.temporary_effects.forEach((effect: Game.TemporaryEffect) => {
var icon = new EffectDisplay(this.game, effect);
this.active_effects.addChild(icon);
});
}
// Called when an attribute for this ship changed through the battle log
@ -86,8 +98,6 @@ module SpaceTac.View {
this.hull.setValue(attribute.current, attribute.maximal);
} else if (attribute.code === Game.AttributeCode.Shield) {
this.shield.setValue(attribute.current, attribute.maximal);
} else if (attribute.code === Game.AttributeCode.AP) {
this.ap.setValue(attribute.current, attribute.maximal);
}
}