Added display of temporary effects in ship list (no graphics yet)
This commit is contained in:
parent
0650605db9
commit
477b51bd9f
3
TODO
3
TODO
|
@ -1,5 +1,6 @@
|
||||||
* Display active effects on ships
|
|
||||||
* Add a cheat system, to use for development (win battle, revive killed ship ...)
|
* Add a cheat system, to use for development (win battle, revive killed ship ...)
|
||||||
* Add a defeat screen (game over for now)
|
* Add a defeat screen (game over for now)
|
||||||
* Add a victory screen, with looting
|
* Add a victory screen, with looting
|
||||||
* Add retreat from battle
|
* Add retreat from battle
|
||||||
|
* Refactor the tooltip system to use it more
|
||||||
|
* Flash ship icons that receive damage
|
|
@ -155,7 +155,7 @@ module SpaceTac.Game {
|
||||||
min_duration: number = 1, max_duration: number = null): void {
|
min_duration: number = 1, max_duration: number = null): void {
|
||||||
var template = new EffectTemplate(effect);
|
var template = new EffectTemplate(effect);
|
||||||
template.addModifier("value", new Range(min_value, max_value));
|
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);
|
this.target_effects.push(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,5 +25,9 @@ module SpaceTac.Game {
|
||||||
ship.setAttribute(ship.attributes.getRawAttr(this.attrcode), this.value);
|
ship.setAttribute(ship.attributes.getRawAttr(this.attrcode), this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
getFullCode(): string {
|
||||||
|
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,9 @@ module SpaceTac.Game {
|
||||||
this.attrcode = attrcode;
|
this.attrcode = attrcode;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFullCode(): string {
|
||||||
|
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,5 +18,9 @@ module SpaceTac.Game {
|
||||||
this.attrcode = attrcode;
|
this.attrcode = attrcode;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFullCode(): string {
|
||||||
|
return this.code + "-" + AttributeCode[this.attrcode].toLowerCase().replace("_", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,10 @@ module SpaceTac.Game {
|
||||||
singleApply(ship: Ship, on_stick: boolean): void {
|
singleApply(ship: Ship, on_stick: boolean): void {
|
||||||
// Abstract
|
// Abstract
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get a full code, that can be used to identify this effect (for example: "attrlimit-aprecovery")
|
||||||
|
getFullCode(): string {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ module SpaceTac.Game {
|
||||||
previous: number;
|
previous: number;
|
||||||
|
|
||||||
constructor(ship: Ship, effect: TemporaryEffect, previous: number) {
|
constructor(ship: Ship, effect: TemporaryEffect, previous: number) {
|
||||||
super("effectadd", ship);
|
super("effectduration", ship);
|
||||||
|
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
this.previous = previous;
|
this.previous = previous;
|
||||||
|
|
15
src/app/view/battle/EffectDisplay.ts
Normal file
15
src/app/view/battle/EffectDisplay.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,6 +54,11 @@ module SpaceTac.View {
|
||||||
case "endbattle":
|
case "endbattle":
|
||||||
this.processEndBattleEvent(<Game.EndBattleEvent>event);
|
this.processEndBattleEvent(<Game.EndBattleEvent>event);
|
||||||
break;
|
break;
|
||||||
|
case "effectadd":
|
||||||
|
case "effectduration":
|
||||||
|
case "effectdel":
|
||||||
|
this.processEffectEvent(event);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,5 +146,13 @@ module SpaceTac.View {
|
||||||
// TODO Game over ?
|
// 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ module SpaceTac.View {
|
||||||
// Enemy indicator
|
// Enemy indicator
|
||||||
layer_enemy: Phaser.Image;
|
layer_enemy: Phaser.Image;
|
||||||
|
|
||||||
|
// Active effects group
|
||||||
|
active_effects: Phaser.Group;
|
||||||
|
|
||||||
// Create a ship button for the battle ship list
|
// Create a ship button for the battle ship list
|
||||||
constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) {
|
constructor(list: ShipList, x: number, y: number, ship: Game.Ship, owned: boolean) {
|
||||||
this.ship = ship;
|
this.ship = ship;
|
||||||
|
@ -61,23 +64,32 @@ module SpaceTac.View {
|
||||||
this.layer_hover.visible = false;
|
this.layer_hover.visible = false;
|
||||||
this.addChild(this.layer_hover);
|
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.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.addChild(this.shield);
|
||||||
|
|
||||||
this.ap = ValueBar.newStyled(list.battleview.game, "battle-shiplist-ap", 76, 47);
|
this.active_effects = new Phaser.Group(this.game);
|
||||||
this.addChild(this.ap);
|
this.addChild(this.active_effects);
|
||||||
|
|
||||||
this.updateAttributes();
|
this.updateAttributes();
|
||||||
|
this.updateEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update attributes from associated ship
|
// Update attributes from associated ship
|
||||||
updateAttributes() {
|
updateAttributes() {
|
||||||
this.attributeChanged(this.ship.hull);
|
this.attributeChanged(this.ship.hull);
|
||||||
this.attributeChanged(this.ship.shield);
|
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
|
// 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);
|
this.hull.setValue(attribute.current, attribute.maximal);
|
||||||
} else if (attribute.code === Game.AttributeCode.Shield) {
|
} else if (attribute.code === Game.AttributeCode.Shield) {
|
||||||
this.shield.setValue(attribute.current, attribute.maximal);
|
this.shield.setValue(attribute.current, attribute.maximal);
|
||||||
} else if (attribute.code === Game.AttributeCode.AP) {
|
|
||||||
this.ap.setValue(attribute.current, attribute.maximal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue