[common] tanks spawn types

This commit is contained in:
2018-02-02 20:53:26 +03:00
parent f9cb985059
commit 59cab68e3e
15 changed files with 202 additions and 52 deletions

View File

@@ -26,17 +26,28 @@ class Animate extends Bitmap {
}
}
private static var a = new BitmapData(1, 1);
public var playing(default, set):Bool;
private var frames:Array<BitmapData>;
public var frames(default, set):Array<BitmapData>;
private var index:Int;
public function new(frames:Array<BitmapData>) {
super(frames[0], PixelSnapping.AUTO, true);
this.frames = frames;
public function new(?frames:Array<BitmapData>) {
super(null, PixelSnapping.AUTO, true);
this.frames = frames == null ? [] : frames;
init();
instances.push(this);
}
public function set_frames(value:Array<BitmapData>):Array<BitmapData> {
if (value != null) {
frames = value;
bitmapData = frames[0];
index = 0;
}
return frames;
}
public function set_playing(value:Bool):Bool {
if (playing != value) {
playing = value;

View File

@@ -117,25 +117,34 @@ class BrickItem extends RenderItem<Brick, Shape> {
class TankItem extends RenderItem<Tank, Animate> {
private var type:String;
private var hits:Int;
public function new(value:Tank) {
super(value);
this.view = new Animate(getFrames().map(function(s) return Assets.getBitmapData(s)));
view = new Animate();
redraw();
}
override public function redraw():Void {
view.frames = getFrames().map(function(s) return Assets.getBitmapData(s));
}
private function getFrames():Array<String> {
var team = value.playerId.team;
var group = value.config.group;
var index = value.playerId.index;
if (group == 'human') group = 'player';
if (group == 'radiant') {
group = 'player';
if (team == 'radiant') {
index = 0;
}
if (group == 'dire') {
group = 'player';
if (team == 'dire') {
index = 1;
}
if (group == 'bot') index = 0;
if (team == 'human' || team == 'radiant' || team == 'dire') {
group = 'player';
}
if (team == 'bot') {
index = value.hits;
}
return [
'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-0.png',
'resources/images/tank/${group}/tank_${group.charAt(0)}${value.config.type}_${index}-1.png',
@@ -145,8 +154,10 @@ class TankItem extends RenderItem<Tank, Animate> {
override public function update():Void {
super.update();
var t = value.config.type;
if (t != this.type) {
var h = value.hits;
if (t != this.type || h != this.hits) {
this.type = t;
this.hits = h;
redraw();
}
view.playing = (value.mx !=0 || value.my != 0);

View File

@@ -24,7 +24,7 @@ class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrame
public function onShow():Void {
var state = Provider.get(GameState);
var c = ConfigBundle.get(state.type).levels;
var c = ConfigBundle.get(state.type).game.levels;
levels.data = [for (i in 0...c) i];
}

View File

@@ -1,4 +1,6 @@
levels: 36
game:
levels: 36
friendlyFire: false
map:
cellWidth: 22
@@ -39,6 +41,10 @@ bricks:
teams:
- id: human
spawnInterval: 0
tanks:
- group: human
type: 0
rate: 1
points:
- type: eagle
index: -1
@@ -57,6 +63,19 @@ teams:
direction: top
- id: bot
spawnInterval: 3000
tanks:
- group: bot
type: 0
rate: 0.5
- group: bot
type: 1
rate: 0.5
- group: bot
type: 2
rate: 0.5
- group: bot
type: 3
rate: 0.5
points:
- type: tank
index: -1
@@ -107,7 +126,7 @@ tanks:
bullet:
<<: *bullet
speed: 9.0
bullets: 3
bullets: 2
- type: 3
width: 42
@@ -159,4 +178,4 @@ tanks:
speed: 8.0
bullets: 1
score: 400
hits: 4
hits: 3

View File

@@ -1,4 +1,6 @@
levels: 36
game:
levels: 2
friendlyFire: true
map:
cellWidth: 22
@@ -36,8 +38,24 @@ bricks:
layer: 2
armor: 1
team_tanks: &team_tanks
tanks:
- group: any
type: 0
rate: 0.25
- group: any
type: 1
rate: 0.25
- group: any
type: 2
rate: 0.25
# - group: any
# type: 3
# rate: 0.25
teams:
- id: radiant
- <<: *team_tanks
id: radiant
spawnInterval: 0
points:
- type: eagle
@@ -49,28 +67,29 @@ teams:
index: 0
x: 0
y: 0
direction: top
direction: right
- type: tank
index: 1
x: 6
y: 10
direction: top
direction: right
- type: tank
index: 2
x: 6
y: 16
direction: top
direction: right
- type: tank
index: 3
x: 6
y: 22
direction: top
direction: right
- type: tank
index: 4
x: 10
y: 28
direction: top
- id: dire
direction: right
- <<: *team_tanks
id: dire
spawnInterval: 0
points:
- type: eagle
@@ -82,27 +101,27 @@ teams:
index: 0
x: 38
y: 28
direction: bottom
direction: left
- type: tank
index: 1
x: 32
y: 18
direction: bottom
direction: left
- type: tank
index: 2
x: 32
y: 12
direction: bottom
direction: left
- type: tank
index: 3
x: 32
y: 6
direction: bottom
direction: left
- type: tank
index: 4
x: 28
y: 0
direction: bottom
direction: left
bullet: &bullet
@@ -112,7 +131,7 @@ bullet: &bullet
piercing: 1
tanks:
radiant: &tanks
any:
- type: 0
width: 36
height: 36
@@ -130,5 +149,22 @@ tanks:
<<: *bullet
speed: 8.5
bullets: 1
dire:
- <<: *tanks
- type: 2
width: 40
height: 36
speed: 3.0
bullet:
<<: *bullet
speed: 9.0
bullets: 2
- type: 3
width: 42
height: 38
speed: 2.9
bullet:
<<: *bullet
speed: 9.0
piercing: 3
bullets: 2

View File

@@ -0,0 +1,30 @@
0000000000000000000000000000000000004400
0000000000000000000000000000000000004400
0000000000000000000000000000000000004444
0000000000000000000000000000000000004444
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
4444000000000000000000000000000000000000
4444000000000000000000000000000000000000
0044000000000000000000000000000000000000
0044000000000000000000000000000000000000