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
|
|
|
|
*/
|
2018-05-15 14:57:45 +00:00
|
|
|
export class ArenaDrone extends UIContainer {
|
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
|
2018-05-15 14:57:45 +00:00
|
|
|
sprite: UIButton
|
2017-02-08 18:54:02 +00:00
|
|
|
|
|
|
|
// Radius
|
2018-05-15 14:57:45 +00:00
|
|
|
radius: UIGraphics
|
2017-02-08 18:54:02 +00:00
|
|
|
|
2017-02-15 21:15:31 +00:00
|
|
|
// Activation effect
|
2018-05-15 14:57:45 +00:00
|
|
|
activation: UIGraphics
|
2017-05-22 23:00:02 +00:00
|
|
|
|
2017-02-09 00:00:35 +00:00
|
|
|
constructor(battleview: BattleView, drone: Drone) {
|
2018-05-15 14:57:45 +00:00
|
|
|
super(battleview);
|
2017-02-08 18:54:02 +00:00
|
|
|
|
2017-05-10 17:48:28 +00:00
|
|
|
this.view = battleview;
|
2017-02-08 18:54:02 +00:00
|
|
|
this.drone = drone;
|
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
let builder = new UIBuilder(battleview, this);
|
|
|
|
|
|
|
|
this.radius = builder.graphics("radius");
|
|
|
|
this.radius.fillStyle(0xe9f2f9, 0.1);
|
|
|
|
this.radius.fillCircle(0, 0, drone.radius);
|
2018-03-29 22:57:53 +00:00
|
|
|
this.radius.lineStyle(2, 0xe9f2f9, 0.5);
|
2018-05-15 14:57:45 +00:00
|
|
|
this.radius.strokeCircle(0, 0, drone.radius);
|
2017-02-08 18:54:02 +00:00
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
this.activation = builder.graphics("activation", 0, 0, false);
|
|
|
|
this.activation.fillStyle(0xe9f2f9, 0.0);
|
|
|
|
this.activation.fillCircle(0, 0, drone.radius);
|
2017-02-15 21:15:31 +00:00
|
|
|
this.activation.lineStyle(2, 0xe9f2f9, 0.7);
|
2018-05-15 14:57:45 +00:00
|
|
|
this.activation.strokeCircle(0, 0, drone.radius);
|
2017-05-22 23:00:02 +00:00
|
|
|
|
2018-05-15 14:57:45 +00:00
|
|
|
this.sprite = builder.button(`action-${drone.code}`, 0, 0, undefined, () => this.drone.getDescription(), undefined, { center: true });
|
|
|
|
this.sprite.setScale(0.1, 0.1);
|
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 {
|
2018-05-15 14:57:45 +00:00
|
|
|
this.activation.setScale(0.001, 0.001);
|
2017-02-15 21:15:31 +00:00
|
|
|
this.activation.visible = true;
|
2018-05-15 14:57:45 +00:00
|
|
|
let tween = this.view.animations.addAnimation(this.activation, { scaleX: 1, scaleY: 1 }, 500).then(() => this.activation.setVisible(false));
|
2017-02-15 21:15:31 +00:00
|
|
|
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
|
|
|
*/
|
2018-06-11 17:10:06 +00:00
|
|
|
async setDestroyed(speed = 1): Promise<void> {
|
|
|
|
if (speed) {
|
|
|
|
this.view.animations.addAnimation<UIContainer>(this, { alpha: 0.3 }, 300 / speed, undefined, 200 / speed);
|
|
|
|
await this.view.animations.addAnimation(this.radius, { scaleX: 0, scaleY: 0 }, 500 / speed);
|
|
|
|
}
|
2018-06-10 22:58:42 +00:00
|
|
|
this.destroy();
|
2017-05-10 23:13:56 +00:00
|
|
|
}
|
2017-05-21 16:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the tactical mode display
|
|
|
|
*/
|
|
|
|
setTacticalMode(active: boolean) {
|
2018-05-15 14:57:45 +00:00
|
|
|
this.sprite.setScale(active ? 0.2 : 0.1);
|
2017-05-21 16:39:02 +00:00
|
|
|
}
|
2017-02-08 18:54:02 +00:00
|
|
|
}
|
|
|
|
}
|