arena: Added sticky effects indicator on ships
This commit is contained in:
parent
d1fa45bf7a
commit
9de1ebcad2
1
TODO
1
TODO
|
@ -17,7 +17,6 @@
|
||||||
* Menu: end appear animation when a button is clicked
|
* Menu: end appear animation when a button is clicked
|
||||||
* Menu: allow to delete cloud saves
|
* Menu: allow to delete cloud saves
|
||||||
* Arena: hide dead drones from tactical view
|
* Arena: hide dead drones from tactical view
|
||||||
* Arena: add sticky effects indicators on ships
|
|
||||||
* Arena: add power indicator in ship hover information
|
* Arena: add power indicator in ship hover information
|
||||||
* Arena: temporarily show ship information when it changes
|
* Arena: temporarily show ship information when it changes
|
||||||
* Arena: display important changes (damages, effects...) instead of attribute changes
|
* Arena: display important changes (damages, effects...) instead of attribute changes
|
||||||
|
|
BIN
out/assets/images/battle/arena/ship-effect-bad.png
Normal file
BIN
out/assets/images/battle/arena/ship-effect-bad.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 410 B |
BIN
out/assets/images/battle/arena/ship-effect-good.png
Normal file
BIN
out/assets/images/battle/arena/ship-effect-good.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 413 B |
|
@ -47,6 +47,8 @@ module TS.SpaceTac.UI {
|
||||||
this.loadImage("battle/arena/ship-hull-full.png");
|
this.loadImage("battle/arena/ship-hull-full.png");
|
||||||
this.loadImage("battle/arena/ship-shield-base.png");
|
this.loadImage("battle/arena/ship-shield-base.png");
|
||||||
this.loadImage("battle/arena/ship-shield-full.png");
|
this.loadImage("battle/arena/ship-shield-full.png");
|
||||||
|
this.loadImage("battle/arena/ship-effect-good.png");
|
||||||
|
this.loadImage("battle/arena/ship-effect-bad.png");
|
||||||
this.loadImage("battle/arena/stasis.png");
|
this.loadImage("battle/arena/stasis.png");
|
||||||
this.loadImage("battle/arena/target.png");
|
this.loadImage("battle/arena/target.png");
|
||||||
this.loadImage("battle/arena/blast.png");
|
this.loadImage("battle/arena/blast.png");
|
||||||
|
|
|
@ -22,5 +22,21 @@ module TS.SpaceTac.UI.Specs {
|
||||||
let t2 = <Phaser.Text>sprite.effects.getChildAt(1);
|
let t2 = <Phaser.Text>sprite.effects.getChildAt(1);
|
||||||
expect(t2.text).toBe("shield +12");
|
expect(t2.text).toBe("shield +12");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("adds sticky effects display", function () {
|
||||||
|
let ship = nn(testgame.battleview.battle.playing_ship);
|
||||||
|
let sprite = nn(testgame.battleview.arena.findShipSprite(ship));
|
||||||
|
|
||||||
|
expect(sprite.sticky_effects.children.length).toBe(0);
|
||||||
|
|
||||||
|
ship.addStickyEffect(new StickyEffect(new BaseEffect("test")));
|
||||||
|
expect(sprite.sticky_effects.children.length).toBe(1);
|
||||||
|
|
||||||
|
ship.addStickyEffect(new StickyEffect(new BaseEffect("test")));
|
||||||
|
expect(sprite.sticky_effects.children.length).toBe(2);
|
||||||
|
|
||||||
|
ship.cleanStickyEffects();
|
||||||
|
expect(sprite.sticky_effects.children.length).toBe(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,33 +2,34 @@ module TS.SpaceTac.UI {
|
||||||
// Ship sprite in the arena (BattleView)
|
// Ship sprite in the arena (BattleView)
|
||||||
export class ArenaShip extends Phaser.Group {
|
export class ArenaShip extends Phaser.Group {
|
||||||
// Link to the view
|
// Link to the view
|
||||||
battleview: BattleView;
|
battleview: BattleView
|
||||||
|
|
||||||
// Link to displayed ship
|
// Link to displayed ship
|
||||||
ship: Ship;
|
ship: Ship
|
||||||
|
|
||||||
// Boolean to indicate if it is an enemy ship
|
// Boolean to indicate if it is an enemy ship
|
||||||
enemy: boolean;
|
enemy: boolean
|
||||||
|
|
||||||
// Ship sprite
|
// Ship sprite
|
||||||
sprite: Phaser.Button;
|
sprite: Phaser.Button
|
||||||
|
|
||||||
// Statis effect
|
// Statis effect
|
||||||
stasis: Phaser.Image;
|
stasis: Phaser.Image
|
||||||
|
|
||||||
// Target effect
|
// Target effect
|
||||||
target: Phaser.Image;
|
target: Phaser.Image
|
||||||
|
|
||||||
// Hover information
|
// Hover information
|
||||||
info: Phaser.Group;
|
info: Phaser.Group
|
||||||
info_hull: ValueBar;
|
info_hull: ValueBar
|
||||||
info_shield: ValueBar;
|
info_shield: ValueBar
|
||||||
|
|
||||||
// Frame to indicate the owner of the ship, and if it is playing
|
// Frame to indicate the owner of the ship, and if it is playing
|
||||||
frame: Phaser.Image;
|
frame: Phaser.Image
|
||||||
|
|
||||||
// Effects display
|
// Effects display
|
||||||
effects: Phaser.Group;
|
sticky_effects: Phaser.Group
|
||||||
|
effects: Phaser.Group
|
||||||
|
|
||||||
// Create a ship sprite usable in the Arena
|
// Create a ship sprite usable in the Arena
|
||||||
constructor(parent: Arena, ship: Ship) {
|
constructor(parent: Arena, ship: Ship) {
|
||||||
|
@ -76,6 +77,8 @@ module TS.SpaceTac.UI {
|
||||||
this.add(this.info);
|
this.add(this.info);
|
||||||
|
|
||||||
// Effects display
|
// Effects display
|
||||||
|
this.sticky_effects = new Phaser.Group(this.game);
|
||||||
|
this.add(this.sticky_effects);
|
||||||
this.effects = new Phaser.Group(this.game);
|
this.effects = new Phaser.Group(this.game);
|
||||||
this.add(this.effects);
|
this.add(this.effects);
|
||||||
|
|
||||||
|
@ -88,6 +91,13 @@ module TS.SpaceTac.UI {
|
||||||
|
|
||||||
// Set location
|
// Set location
|
||||||
this.position.set(ship.arena_x, ship.arena_y);
|
this.position.set(ship.arena_x, ship.arena_y);
|
||||||
|
|
||||||
|
// Log processing
|
||||||
|
this.battleview.log_processor.registerForShip(ship, event => {
|
||||||
|
if (event instanceof EffectAddedEvent || event instanceof EffectRemovedEvent || event instanceof EffectDurationChangedEvent) {
|
||||||
|
this.updateStickyEffects();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,5 +184,21 @@ module TS.SpaceTac.UI {
|
||||||
this.info_shield.setValue(event.value.get(), this.ship.getAttribute("shield_capacity"));
|
this.info_shield.setValue(event.value.get(), this.ship.getAttribute("shield_capacity"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the stick effects
|
||||||
|
*/
|
||||||
|
updateStickyEffects() {
|
||||||
|
this.sticky_effects.removeAll();
|
||||||
|
|
||||||
|
let count = this.ship.sticky_effects.length
|
||||||
|
if (count) {
|
||||||
|
let positions = UITools.evenlySpace(70, 10, count);
|
||||||
|
this.ship.sticky_effects.forEach((effect, index) => {
|
||||||
|
let dot = new Phaser.Image(this.game, positions[index] - 40, -47, `battle-arena-ship-effect-${effect.isBeneficial() ? "good" : "bad"}`);
|
||||||
|
this.sticky_effects.add(dot);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,17 @@ module TS.SpaceTac.UI {
|
||||||
this.forwarding.push(callback);
|
this.forwarding.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a sub-subscriber, to receive events for a specific ship
|
||||||
|
*/
|
||||||
|
registerForShip(ship: Ship, callback: LogSubscriber) {
|
||||||
|
this.register(event => {
|
||||||
|
if (event instanceof BaseLogShipEvent && event.ship === ship) {
|
||||||
|
callback(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Introduce a delay in event processing
|
* Introduce a delay in event processing
|
||||||
*/
|
*/
|
||||||
|
@ -105,8 +116,6 @@ module TS.SpaceTac.UI {
|
||||||
this.processDroneDestroyedEvent(event);
|
this.processDroneDestroyedEvent(event);
|
||||||
} else if (event instanceof DroneAppliedEvent) {
|
} else if (event instanceof DroneAppliedEvent) {
|
||||||
this.processDroneAppliedEvent(event);
|
this.processDroneAppliedEvent(event);
|
||||||
} else if (event instanceof EffectAddedEvent || event instanceof EffectRemovedEvent || event instanceof EffectDurationChangedEvent) {
|
|
||||||
this.processEffectEvent(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,11 +210,6 @@ module TS.SpaceTac.UI {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sticky effect on ship added, changed or removed
|
|
||||||
private processEffectEvent(event: EffectAddedEvent | EffectRemovedEvent | EffectDurationChangedEvent): void {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
// New drone deployed
|
// New drone deployed
|
||||||
private processDroneDeployedEvent(event: DroneDeployedEvent): void {
|
private processDroneDeployedEvent(event: DroneDeployedEvent): void {
|
||||||
let duration = this.view.arena.addDrone(event.drone, !event.initial);
|
let duration = this.view.arena.addDrone(event.drone, !event.initial);
|
||||||
|
|
Loading…
Reference in a new issue