diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx index c5ee375..6c361e5 100755 --- a/src/client/haxe/ru/m/tankz/render/Render.hx +++ b/src/client/haxe/ru/m/tankz/render/Render.hx @@ -149,8 +149,8 @@ class Render extends SpriteView implements IRender { entryLayer.addChild(item.view); item.update(); playAnimate(item.rect.center, AnimateBundle.tankSpawn()); - case SPAWN(BULLET(id, rect, playerId, piercing)): - var item = new BulletRenderItem(rect, piercing); + case SPAWN(BULLET(id, rect, playerId, skin)): + var item = new BulletRenderItem(rect, skin); items.set(id, item); entryLayer.addChild(item.view); item.update(); diff --git a/src/client/haxe/ru/m/tankz/render/RenderUtil.hx b/src/client/haxe/ru/m/tankz/render/RenderUtil.hx index 818a918..ecef110 100644 --- a/src/client/haxe/ru/m/tankz/render/RenderUtil.hx +++ b/src/client/haxe/ru/m/tankz/render/RenderUtil.hx @@ -19,8 +19,7 @@ class RenderUtil { return Assets.getBitmapData('resources/image/bonus/${type}.png'); } - public static function bulletImage(piercing:Int = 0):BitmapData { - var type = piercing > 1 ? 'piercing' : 'normal'; - return Assets.getBitmapData('resources/image/bullet/${type}.png'); + public static function bulletImage(skin:String):BitmapData { + return Assets.getBitmapData('resources/image/bullet/${skin}.png'); } } diff --git a/src/client/haxe/ru/m/tankz/render/item/BulletRenderItem.hx b/src/client/haxe/ru/m/tankz/render/item/BulletRenderItem.hx index 311b6ad..d637575 100644 --- a/src/client/haxe/ru/m/tankz/render/item/BulletRenderItem.hx +++ b/src/client/haxe/ru/m/tankz/render/item/BulletRenderItem.hx @@ -3,19 +3,19 @@ package ru.m.tankz.render.item; import ru.m.geom.Rectangle; class BulletRenderItem extends BitmapRenderItem { - public var piercing(default, set):Int = -1; + public var skin(default, set):String; - public function new(rect:Rectangle, piercing:Int) { + public function new(rect:Rectangle, skin:String) { super(rect); - this.piercing = piercing; + this.skin = skin; move(rect.position); } - private function set_piercing(value:Int):Int { - if (piercing != value) { - piercing = value; - image = RenderUtil.bulletImage(piercing); + private function set_skin(value:String):String { + if (skin != value) { + skin = value; + image = RenderUtil.bulletImage(skin); } - return piercing; + return skin; } } diff --git a/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx b/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx index 8130b49..a319052 100644 --- a/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx +++ b/src/client/haxe/ru/m/tankz/storage/SettingsStorage.hx @@ -11,7 +11,7 @@ import ru.m.tankz.control.Control; class SettingsStorage extends SharedObjectStorage { - private static inline var VERSION = 4; + private static inline var VERSION = 4.1; public function new() { super('settings_${VERSION}'); @@ -38,6 +38,7 @@ class SettingsStorage extends SharedObjectStorage { MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)}, SHOT(0) => {device: device, action: KEY(0)}, SHOT(1) => {device: device, action: KEY(1)}, + SHOT(2) => {device: device, action: KEY(2)}, ]; } @@ -64,6 +65,7 @@ class SettingsStorage extends SharedObjectStorage { MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.D)}, SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.SPACE)}, SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.Q)}, + SHOT(2) => {device: KEYBOARD, action: KEY(Keyboard.E)}, ], 1 => [ MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.UP)}, @@ -71,7 +73,8 @@ class SettingsStorage extends SharedObjectStorage { MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.DOWN)}, MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)}, SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_0)}, - SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_DECIMAL)}, + SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_1)}, + SHOT(3) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_2)}, ], ]; } diff --git a/src/client/resources/image/bullet/mine.png b/src/client/resources/image/bullet/mine.png new file mode 100644 index 0000000..2de8cc4 Binary files /dev/null and b/src/client/resources/image/bullet/mine.png differ diff --git a/src/client/resources/image/bullet/rocket.png b/src/client/resources/image/bullet/rocket.png new file mode 100644 index 0000000..597864b Binary files /dev/null and b/src/client/resources/image/bullet/rocket.png differ diff --git a/src/common/haxe/ru/m/tankz/config/Config.hx b/src/common/haxe/ru/m/tankz/config/Config.hx index 5e5b71f..9445a37 100644 --- a/src/common/haxe/ru/m/tankz/config/Config.hx +++ b/src/common/haxe/ru/m/tankz/config/Config.hx @@ -47,6 +47,7 @@ typedef BulletConfig = { var speed:Float; var piercing:Int; var layer:Int; + var skin:String; } typedef WeaponConfig = { diff --git a/src/common/haxe/ru/m/tankz/core/Weapon.hx b/src/common/haxe/ru/m/tankz/core/Weapon.hx index ec726bc..5f9b204 100644 --- a/src/common/haxe/ru/m/tankz/core/Weapon.hx +++ b/src/common/haxe/ru/m/tankz/core/Weapon.hx @@ -16,7 +16,7 @@ class Weapon { } private function get_available():Bool { - return (count < 0 || count > 0) && queue < config.queue; + return (count < 0 || count > 0) && (config.queue < 0 || queue < config.queue); } public function use():Void { diff --git a/src/common/haxe/ru/m/tankz/game/EventUtil.hx b/src/common/haxe/ru/m/tankz/game/EventUtil.hx index 89907f8..e1e8587 100644 --- a/src/common/haxe/ru/m/tankz/game/EventUtil.hx +++ b/src/common/haxe/ru/m/tankz/game/EventUtil.hx @@ -50,7 +50,7 @@ class EventUtil { } public static function buildBulletSpawn(bullet:Bullet):GameEvent { - return SPAWN(BULLET(bullet.id, bullet.rect.clone(), bullet.playerId, bullet.config.piercing)); + return SPAWN(BULLET(bullet.id, bullet.rect.clone(), bullet.playerId, bullet.config.skin)); } public static function buildMove(entity:Entity):GameEvent { diff --git a/src/common/haxe/ru/m/tankz/game/GameEvent.hx b/src/common/haxe/ru/m/tankz/game/GameEvent.hx index 1eb2527..f1ec4cd 100644 --- a/src/common/haxe/ru/m/tankz/game/GameEvent.hx +++ b/src/common/haxe/ru/m/tankz/game/GameEvent.hx @@ -39,7 +39,7 @@ enum SpawnEvent { BRICK(bricks:Array); EAGLE(id:Int, rect:Rectangle, teamId:TeamId); TANK(id:Int, rect:Rectangle, playerId:PlayerId, info:TankInfo); - BULLET(id:Int, rect:Rectangle, playerId:PlayerId, piercing:Int); + BULLET(id:Int, rect:Rectangle, playerId:PlayerId, skin:String); BONUS(id:Int, rect:Rectangle, type:BonusType); } diff --git a/src/common/haxe/ru/m/tankz/game/GameRunner.hx b/src/common/haxe/ru/m/tankz/game/GameRunner.hx index f95a35c..1697533 100644 --- a/src/common/haxe/ru/m/tankz/game/GameRunner.hx +++ b/src/common/haxe/ru/m/tankz/game/GameRunner.hx @@ -156,7 +156,7 @@ class GameRunner extends Game implements EngineListener { tank.rect.lean(cell.rect); emitTankMove(tank); case [BULLET(bullet), BULLET(other_bullet)]: - if (bullet.playerId != other_bullet.playerId) { + if (bullet.playerId != other_bullet.playerId && bullet.layer > 0 && other_bullet.layer > 0) { gameEventSignal.emit(DESTROY(BULLET(bullet.id))); gameEventSignal.emit(DESTROY(BULLET(other_bullet.id))); } @@ -166,8 +166,8 @@ class GameRunner extends Game implements EngineListener { gameEventSignal.emit(DESTROY(BULLET(bullet.id))); case [TANK(tank), BONUS(bonus)]: gameEventSignal.emit(DESTROY(BONUS(bonus.id, {tankId: tank.id, score: bonus.config.score}))); - case [BULLET(bullet), TANK(tank)]/* | [TANK(tank), BULLET(bullet)]*/: - if (bullet.tankId == tank.id || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) { + case [BULLET(bullet), TANK(tank)] | [TANK(tank), BULLET(bullet)]: + if (bullet.playerId == tank.playerId || (!config.game.friendlyFire && tank.playerId.team == bullet.playerId.team)) { // Nothing } else { if (!tank.protect) { diff --git a/src/common/resources/config/classic.yaml b/src/common/resources/config/classic.yaml index d3fce64..1db3c1d 100644 --- a/src/common/resources/config/classic.yaml +++ b/src/common/resources/config/classic.yaml @@ -55,6 +55,7 @@ bullet: &bullet speed: 0 piercing: 1 layer: 2 + skin: normal tanks: - type: human0 @@ -99,7 +100,7 @@ tanks: speed: 2.9 skin: pd weapons: - - bullet: {<<: *bullet, speed: 9.0, piercing: 3} + - bullet: {<<: *bullet, speed: 9.0, piercing: 3, skin: piercing} queue: 2 count: -1 diff --git a/src/common/resources/config/death.yaml b/src/common/resources/config/death.yaml index ba82b10..1f9559a 100644 --- a/src/common/resources/config/death.yaml +++ b/src/common/resources/config/death.yaml @@ -78,11 +78,14 @@ tanks: score: 100 skin: pc weapons: - - bullet: {width: 12, height: 12, speed: 12.0, piercing: 1, layer: 2} + - bullet: {width: 12, height: 12, speed: 12.0, piercing: 1, layer: 2, skin: normal} queue: 2 count: -1 - - bullet: {width: 16, height: 16, speed: 4.0, piercing: 4, layer: 4} + - bullet: {width: 16, height: 16, speed: 4.0, piercing: 4, layer: 4, skin: rocket} queue: 1 count: 3 + - bullet: {width: 20, height: 20, speed: 0.0, piercing: 1, layer: 0, skin: mine} + queue: -1 + count: 3 bonuses: [] diff --git a/src/common/resources/config/dota.yaml b/src/common/resources/config/dota.yaml index e63814e..18942f7 100644 --- a/src/common/resources/config/dota.yaml +++ b/src/common/resources/config/dota.yaml @@ -83,6 +83,7 @@ bullet: &bullet speed: 0 piercing: 1 layer: 2 + skin: normal tanks: - type: slow