[common] bonuses implemented

This commit is contained in:
2018-02-15 17:11:41 +03:00
parent 032fa0c0ad
commit 1ae84cf5a8
14 changed files with 187 additions and 67 deletions

View File

@@ -182,14 +182,23 @@ class TankItem extends RenderItem<Tank, Sprite> {
private var type:String;
private var hits:Int;
private var protected:Bool;
private var frozen:Bool;
private var tankView:Animate;
private var protectView:Animate;
public function new(value:Tank) {
super(value);
view = new Sprite();
tankView = new Animate();
view.addChild(tankView);
protectView = new Animate(
[for (i in 0...5) Assets.getBitmapData('resources/images/tank/protect/protect-0.png')].concat(
[for (i in 0...5) Assets.getBitmapData('resources/images/tank/protect/protect-1.png')])
);
protectView.visible = false;
view.addChild(protectView);
redraw();
}
@@ -200,6 +209,15 @@ class TankItem extends RenderItem<Tank, Sprite> {
frames[0], frames[0], frames[0],
frames[1], frames[1], frames[1],
];
if (value.protect.active) {
protectView.x = (tankView.frames[0].width - protectView.frames[0].width) / 2;
protectView.y = (tankView.frames[0].height - protectView.frames[0].height) / 2;
protectView.playing = true;
protectView.visible = true;
} else {
protectView.playing = false;
protectView.visible = false;
}
}
private function getFrames():Array<String> {
@@ -212,12 +230,16 @@ class TankItem extends RenderItem<Tank, Sprite> {
super.update();
var t = value.config.type;
var h = value.hits;
if (t != this.type || h != this.hits) {
var p = value.protect.active;
var f = value.freezing.active;
if (t != type || h != hits || p != protected || f != frozen) {
this.type = t;
this.hits = h;
this.protected = p;
this.frozen = f;
redraw();
}
tankView.playing = (value.mx !=0 || value.my != 0);
tankView.playing = !value.freezing.active && (value.mx !=0 || value.my != 0);
}
override public function dispose():Void {