diff --git a/package.json b/package.json index f7d9287..bf42d5f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tankz", - "version": "0.16.5", + "version": "0.16.6", "private": true, "devDependencies": { "dateformat": "^3.0.3", diff --git a/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml b/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml index 04ac771..d9a975d 100644 --- a/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml +++ b/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml @@ -27,6 +27,8 @@ views: text: DeathMatch - $type: haxework.view.SpriteView style: line + geometry.width: 250 + geometry.margin: [0, 10] - $type: haxework.view.form.ButtonView style: button.menu +onPress: ~switcher.change('record') diff --git a/src/common/haxe/ru/m/tankz/config/Config.hx b/src/common/haxe/ru/m/tankz/config/Config.hx index 35434eb..5e5b71f 100644 --- a/src/common/haxe/ru/m/tankz/config/Config.hx +++ b/src/common/haxe/ru/m/tankz/config/Config.hx @@ -46,11 +46,13 @@ typedef BulletConfig = { var height:Float; var speed:Float; var piercing:Int; + var layer:Int; } typedef WeaponConfig = { var bullet:BulletConfig; var count:Int; + var queue:Int; } typedef TankConfig = { diff --git a/src/common/haxe/ru/m/tankz/core/Bullet.hx b/src/common/haxe/ru/m/tankz/core/Bullet.hx index cdb9d23..2485c86 100644 --- a/src/common/haxe/ru/m/tankz/core/Bullet.hx +++ b/src/common/haxe/ru/m/tankz/core/Bullet.hx @@ -16,7 +16,7 @@ class Bullet extends MobileEntity { super(id, rect, config.speed, Direction.RIGHT); this.playerId = playerId; this.config = config; - this.layer = 2; + this.layer = this.config.layer; } private inline function get_tankId():Int { diff --git a/src/common/haxe/ru/m/tankz/core/Weapon.hx b/src/common/haxe/ru/m/tankz/core/Weapon.hx index 54ee78d..ec726bc 100644 --- a/src/common/haxe/ru/m/tankz/core/Weapon.hx +++ b/src/common/haxe/ru/m/tankz/core/Weapon.hx @@ -6,9 +6,27 @@ class Weapon { public var config(default, null):WeaponConfig; public var count(default, default):Int; + public var queue(default, default):Int; + public var available(get, null):Bool; public function new(config:WeaponConfig) { this.config = config; - this.count = 0; + this.count = this.config.count; + this.queue = 0; + } + + private function get_available():Bool { + return (count < 0 || count > 0) && queue < config.queue; + } + + public function use():Void { + queue++; + if (count > 0) { + count--; + } + } + + public function release():Void { + queue--; } } diff --git a/src/common/haxe/ru/m/tankz/game/GameRunner.hx b/src/common/haxe/ru/m/tankz/game/GameRunner.hx index 61dc2f4..f95a35c 100644 --- a/src/common/haxe/ru/m/tankz/game/GameRunner.hx +++ b/src/common/haxe/ru/m/tankz/game/GameRunner.hx @@ -263,7 +263,7 @@ class GameRunner extends Game implements EngineListener { var tank:Tank = cast engine.entities.get(tankId); var player = getPlayer(tank.playerId); var weapon:Weapon = tank.weapons.length > index - 1 ? tank.weapons[index] : null; - if (weapon != null && !tank.freezing && weapon.count < weapon.config.count) { + if (weapon != null && !tank.freezing && weapon.available) { var rect = tank.rect; var point = rect.center.add(new Point(rect.width / 4 * rect.direction.x, rect.height / 4 * rect.direction.y)); var bullet = builder.buildBullet(point, rect.direction, player.id, weapon.config.bullet); @@ -286,7 +286,7 @@ class GameRunner extends Game implements EngineListener { player.state.tank = info; case SPAWN(BULLET(id, _, _, _)): var bullet:Bullet = engine.getEntity(id); - bullet.weapon.count++; + bullet.weapon.use(); case CHANGE(BRICK(id, type)): engine.map.bricksById[id].config = config.getBrick(type); case DESTROY(EAGLE(id, shot)): @@ -350,7 +350,7 @@ class GameRunner extends Game implements EngineListener { engine.destroy(id); case DESTROY(BULLET(id)): var bullet:Bullet = engine.getEntity(id); - bullet.weapon.count--; + bullet.weapon.release(); var side:Line = bullet.rect.getSide(bullet.rect.direction.reverse()).move( // ToDo: move new Point(bullet.rect.direction.x * 5, bullet.rect.direction.y * 5) diff --git a/src/common/haxe/ru/m/tankz/map/Grid.hx b/src/common/haxe/ru/m/tankz/map/Grid.hx index 32ced1a..51a34f9 100644 --- a/src/common/haxe/ru/m/tankz/map/Grid.hx +++ b/src/common/haxe/ru/m/tankz/map/Grid.hx @@ -35,7 +35,7 @@ class GridCell { } public inline function getCollision(layer:Int):Bool { - return this.layer >= layer && this.layer < 3; + return this.layer == -1 || (this.layer >= layer && this.layer < 3); } } @@ -59,7 +59,7 @@ class Grid { } private function buildBorderCell(cellX:Int, cellY:Int):GridCell { - return new GridCell(cellX, cellY, cellWidth, cellHeight, 2, -1); + return new GridCell(cellX, cellY, cellWidth, cellHeight, -1, -1); } public function getCells(line:Line):Array { diff --git a/src/common/resources/config/classic.yaml b/src/common/resources/config/classic.yaml index 24675ad..d3fce64 100644 --- a/src/common/resources/config/classic.yaml +++ b/src/common/resources/config/classic.yaml @@ -10,7 +10,7 @@ map: height: 26 bricks: - - {type: border, index: -1, layer: 2, armor: -1} + - {type: border, index: -1, layer: -1, armor: -1} - {type: none, index: 0, layer: 0, armor: 0} - {type: ace, index: 1, layer: 0, armor: 0} - {type: bush, index: 2, layer: 3, armor: 0} @@ -54,6 +54,7 @@ bullet: &bullet height: 12 speed: 0 piercing: 1 + layer: 2 tanks: - type: human0 @@ -65,7 +66,8 @@ tanks: skin: pa weapons: - bullet: {<<: *bullet, speed: 8.0} - count: 1 + queue: 1 + count: -1 - type: human1 upgrade: human2 @@ -76,7 +78,8 @@ tanks: skin: pb weapons: - bullet: {<<: *bullet, speed: 8.5} - count: 1 + queue: 1 + count: -1 - type: human2 upgrade: human3 @@ -86,7 +89,8 @@ tanks: skin: pc weapons: - bullet: {<<: *bullet, speed: 9.0} - count: 2 + queue: 2 + count: -1 - type: human3 downgrade: human2 @@ -96,7 +100,8 @@ tanks: skin: pd weapons: - bullet: {<<: *bullet, speed: 9.0, piercing: 3} - count: 2 + queue: 2 + count: -1 - type: bot0 width: 38 @@ -106,7 +111,8 @@ tanks: skin: ba weapons: - bullet: {<<: *bullet, speed: 7.0} - count: 1 + queue: 1 + count: -1 - type: bot1 width: 40 @@ -116,7 +122,8 @@ tanks: skin: bb weapons: - bullet: {<<: *bullet, speed: 7.0} - count: 1 + queue: 1 + count: -1 - type: bot2 width: 38 @@ -126,7 +133,8 @@ tanks: skin: bc weapons: - bullet: {<<: *bullet, speed: 9.0} - count: 1 + queue: 1 + count: -1 - type: bot3 width: 40 @@ -137,7 +145,8 @@ tanks: skin: bd weapons: - bullet: {<<: *bullet, speed: 8.0} - count: 1 + queue: 1 + count: -1 bonuses: - {score: 500, factory: freeze.team, type: clock, duration: 10} diff --git a/src/common/resources/config/death.yaml b/src/common/resources/config/death.yaml index 487792a..ba82b10 100644 --- a/src/common/resources/config/death.yaml +++ b/src/common/resources/config/death.yaml @@ -10,7 +10,7 @@ map: height: 20 bricks: - - {type: border, index: -1, layer: 2, armor: -1} + - {type: border, index: -1, layer: -1, armor: -1} - {type: none, index: 0, layer: 0, armor: 0} - {type: ace, index: 1, layer: 0, armor: 0} - {type: bush, index: 2, layer: 3, armor: 0} @@ -70,12 +70,6 @@ points: - {team: eta, type: tank, index: 0, direction: right, x: 4, y: 2} - {team: theta, type: tank, index: 0, direction: right, x: 6, y: 2} -bullet: &bullet - width: 12 - height: 12 - speed: 0 - piercing: 1 - tanks: - type: default width: 38 @@ -84,9 +78,11 @@ tanks: score: 100 skin: pc weapons: - - bullet: {<<: *bullet, speed: 12.0} - count: 2 - - bullet: {<<: *bullet, speed: 4.0, width: 16, height: 16, piercing: 4} - count: 1 + - bullet: {width: 12, height: 12, speed: 12.0, piercing: 1, layer: 2} + queue: 2 + count: -1 + - bullet: {width: 16, height: 16, speed: 4.0, piercing: 4, layer: 4} + queue: 1 + count: 3 bonuses: [] diff --git a/src/common/resources/config/dota.yaml b/src/common/resources/config/dota.yaml index f67ce9c..e63814e 100644 --- a/src/common/resources/config/dota.yaml +++ b/src/common/resources/config/dota.yaml @@ -10,7 +10,7 @@ map: height: 30 bricks: - - {type: border, index: -1, layer: 2, armor: -1} + - {type: border, index: -1, layer: -1, armor: -1} - {type: none, index: 0, layer: 0, armor: 0} - {type: ace, index: 1, layer: 0, armor: 0} - {type: bush, index: 2, layer: 3, armor: 0} @@ -82,6 +82,7 @@ bullet: &bullet height: 12 speed: 0 piercing: 1 + layer: 2 tanks: - type: slow @@ -92,7 +93,8 @@ tanks: skin: bc weapons: - bullet: {<<: *bullet, speed: 12.0} - count: 1 + queue: 1 + count: -1 - type: fast width: 40 @@ -102,7 +104,8 @@ tanks: skin: bb weapons: - bullet: {<<: *bullet, speed: 8.0} - count: 1 + queue: 1 + count: -1 bonuses: - {score: 100, factory: freeze.team, type: clock, duration: 10}