2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.UI {
|
2017-02-08 18:54:02 +00:00
|
|
|
/**
|
|
|
|
* Drone sprite in the arena
|
|
|
|
*/
|
|
|
|
export class ArenaDrone extends Phaser.Group {
|
2017-05-10 17:48:28 +00:00
|
|
|
// Link to view
|
2017-05-22 23:00:02 +00:00
|
|
|
view: BattleView
|
2017-05-10 17:48:28 +00:00
|
|
|
|
2017-02-08 18:54:02 +00:00
|
|
|
// Link to displayed drone
|
2017-05-22 23:00:02 +00:00
|
|
|
drone: Drone
|
2017-02-08 18:54:02 +00:00
|
|
|
|
|
|
|
// Sprite
|
2017-05-22 23:00:02 +00:00
|
|
|
sprite: Phaser.Button
|
2017-02-08 18:54:02 +00:00
|
|
|
|
|
|
|
// Radius
|
2017-05-22 23:00:02 +00:00
|
|
|
radius: Phaser.Graphics
|
2017-02-08 18:54:02 +00:00
|
|
|
|
2017-02-15 21:15:31 +00:00
|
|
|
// Activation effect
|
2017-05-22 23:00:02 +00:00
|
|
|
activation: Phaser.Graphics
|
|
|
|
|
2017-02-09 00:00:35 +00:00
|
|
|
constructor(battleview: BattleView, drone: Drone) {
|
2017-02-08 18:54:02 +00:00
|
|
|
super(battleview.game);
|
|
|
|
|
2017-05-10 17:48:28 +00:00
|
|
|
this.view = battleview;
|
2017-02-08 18:54:02 +00:00
|
|
|
this.drone = drone;
|
|
|
|
|
|
|
|
this.radius = new Phaser.Graphics(this.game, 0, 0);
|
2017-02-15 21:15:31 +00:00
|
|
|
this.radius.lineStyle(2, 0xe9f2f9, 0.3);
|
2017-02-08 18:54:02 +00:00
|
|
|
this.radius.beginFill(0xe9f2f9, 0.0);
|
|
|
|
this.radius.drawCircle(0, 0, drone.radius * 2);
|
|
|
|
this.radius.endFill();
|
2017-05-22 23:00:02 +00:00
|
|
|
this.add(this.radius);
|
2017-02-08 18:54:02 +00:00
|
|
|
|
2017-02-15 21:15:31 +00:00
|
|
|
this.activation = new Phaser.Graphics(this.game, 0, 0);
|
|
|
|
this.activation.lineStyle(2, 0xe9f2f9, 0.7);
|
|
|
|
this.activation.beginFill(0xe9f2f9, 0.0);
|
|
|
|
this.activation.drawCircle(0, 0, drone.radius * 2);
|
|
|
|
this.activation.endFill();
|
|
|
|
this.activation.visible = false;
|
2017-05-22 23:00:02 +00:00
|
|
|
this.add(this.activation);
|
2017-02-15 21:15:31 +00:00
|
|
|
|
2017-10-10 22:32:46 +00:00
|
|
|
let name = this.view.getFirstImage(`equipment-${drone.code}`, `battle-actions-deploy-${drone.code}`);
|
|
|
|
this.sprite = this.view.newButton(name);
|
2017-02-08 18:54:02 +00:00
|
|
|
this.sprite.anchor.set(0.5, 0.5);
|
|
|
|
this.sprite.scale.set(0.1, 0.1);
|
2017-05-22 23:00:02 +00:00
|
|
|
this.add(this.sprite);
|
|
|
|
|
2017-05-14 21:08:36 +00:00
|
|
|
this.view.tooltip.bindDynamicText(this.sprite, () => {
|
2017-08-24 23:02:32 +00:00
|
|
|
return this.drone.getDescription();
|
2017-05-14 21:08:36 +00:00
|
|
|
});
|
2017-02-08 18:54:02 +00:00
|
|
|
}
|
2017-02-15 21:15:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the activation animation
|
|
|
|
*
|
|
|
|
* Return the animation duration
|
|
|
|
*/
|
|
|
|
setApplied(): number {
|
|
|
|
this.activation.scale.set(0.001, 0.001);
|
|
|
|
this.activation.visible = true;
|
|
|
|
let tween = this.game.tweens.create(this.activation.scale).to({ x: 1, y: 1 }, 500);
|
|
|
|
tween.onComplete.addOnce(() => this.activation.visible = false);
|
|
|
|
tween.start();
|
|
|
|
return 500;
|
|
|
|
}
|
2017-05-14 21:08:36 +00:00
|
|
|
|
2017-05-10 23:13:56 +00:00
|
|
|
/**
|
|
|
|
* Set the sprite as destroyed
|
2017-11-14 00:07:06 +00:00
|
|
|
*
|
|
|
|
* Return the animation duration
|
2017-05-10 23:13:56 +00:00
|
|
|
*/
|
2017-11-14 00:07:06 +00:00
|
|
|
setDestroyed(): number {
|
2017-05-10 23:13:56 +00:00
|
|
|
this.game.tweens.create(this).to({ alpha: 0.3 }, 300).delay(200).start();
|
|
|
|
|
|
|
|
let tween = this.game.tweens.create(this.radius.scale).to({ x: 0, y: 0 }, 500);
|
|
|
|
tween.onComplete.addOnce(() => {
|
2017-08-24 23:02:32 +00:00
|
|
|
this.destroy();
|
2017-05-10 23:13:56 +00:00
|
|
|
});
|
|
|
|
tween.start();
|
2017-11-14 00:07:06 +00:00
|
|
|
|
|
|
|
return 500;
|
2017-05-10 23:13:56 +00:00
|
|
|
}
|
2017-05-21 16:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the tactical mode display
|
|
|
|
*/
|
|
|
|
setTacticalMode(active: boolean) {
|
2017-05-22 23:00:02 +00:00
|
|
|
this.sprite.scale.set(active ? 0.2 : 0.1);
|
2017-05-21 16:39:02 +00:00
|
|
|
}
|
2017-02-08 18:54:02 +00:00
|
|
|
}
|
|
|
|
}
|