[common] bonuses implemented
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -22,7 +22,7 @@ player:
|
||||
control: human
|
||||
life: 3
|
||||
tanks:
|
||||
- {type: human0, rate: 1}
|
||||
- {type: human0, rate: 1, protect: 5}
|
||||
bot: &bot
|
||||
control: bot
|
||||
life: -1
|
||||
|
||||
@@ -31,15 +31,25 @@ player: &player
|
||||
life: -1
|
||||
control: bot
|
||||
tanks:
|
||||
- {type: slow, rate: 0.5}
|
||||
- {type: fast, rate: 0.5}
|
||||
- {type: slow, rate: 0.5, protect: 3, bonus: 0}
|
||||
- {type: fast, rate: 0.5, protect: 3, bonus: 0}
|
||||
|
||||
human1: &human1
|
||||
<<: *player
|
||||
control: human
|
||||
color: 0xf055a0
|
||||
|
||||
human2: &human2
|
||||
<<: *player
|
||||
control: human
|
||||
color: 0xa055f0
|
||||
|
||||
presets:
|
||||
- id: player1
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *human1, index: 0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
@@ -55,8 +65,8 @@ presets:
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *player, index: 1, control: human, color: 0xf055a0}
|
||||
- {<<: *human1, index: 0}
|
||||
- {<<: *human1, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
- {<<: *player, index: 4}
|
||||
@@ -71,14 +81,14 @@ presets:
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *human1, index: 0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
- {<<: *player, index: 4}
|
||||
- <<: *dire
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xa055f0}
|
||||
- {<<: *human2, index: 0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
|
||||
Reference in New Issue
Block a user