1
0
Fork 0
spacetac/src/ui/battle/ArenaDrone.ts

59 lines
1.8 KiB
TypeScript
Raw Normal View History

2017-02-09 00:00:35 +00:00
module TS.SpaceTac.UI {
2017-02-08 18:54:02 +00:00
/**
* Drone sprite in the arena
*/
export class ArenaDrone extends Phaser.Group {
// Link to displayed drone
2017-02-09 00:00:35 +00:00
drone: Drone;
2017-02-08 18:54:02 +00:00
// Sprite
sprite: Phaser.Image;
2017-02-08 18:54:02 +00:00
// Radius
radius: Phaser.Graphics;
// Activation effect
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);
this.drone = drone;
this.radius = new Phaser.Graphics(this.game, 0, 0);
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();
this.addChild(this.radius);
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;
this.addChild(this.activation);
this.sprite = new Phaser.Image(this.game, 0, 0, `battle-actions-deploy-${drone.code}`);
2017-02-08 18:54:02 +00:00
this.sprite.anchor.set(0.5, 0.5);
this.sprite.scale.set(0.1, 0.1);
this.addChild(this.sprite);
}
/**
* 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-02-08 18:54:02 +00:00
}
}