diff --git a/src/client/haxe/ru/m/tankz/Client.hx b/src/client/haxe/ru/m/tankz/Client.hx index 881cd68..6352cc9 100755 --- a/src/client/haxe/ru/m/tankz/Client.hx +++ b/src/client/haxe/ru/m/tankz/Client.hx @@ -1,5 +1,6 @@ package ru.m.tankz; +import openfl.Assets; import ru.m.tankz.sound.SoundManager; import flash.events.KeyboardEvent; import flash.text.Font; @@ -91,6 +92,11 @@ class Client implements IConnectionHandler { Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE); Provider.setFactory(Game, DotaGame, DotaGame.TYPE); + L.d(TAG, 'resources'); + for (resource in Assets.list()) { + L.d(TAG, '\t${resource}'); + } + view.switcher.change(StartFrame.ID); } diff --git a/src/client/haxe/ru/m/tankz/frame/GameFrame.hx b/src/client/haxe/ru/m/tankz/frame/GameFrame.hx index 3b0e1c1..a6895f7 100755 --- a/src/client/haxe/ru/m/tankz/frame/GameFrame.hx +++ b/src/client/haxe/ru/m/tankz/frame/GameFrame.hx @@ -54,6 +54,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand timer = new Timer(10); timer.run = updateEngine; state.text = stateString(game); + Provider.get(SoundManager).play('start'); } private function stop():Void { diff --git a/src/client/haxe/ru/m/tankz/frame/StartFrame.hx b/src/client/haxe/ru/m/tankz/frame/StartFrame.hx index a34f5a3..843d5c2 100644 --- a/src/client/haxe/ru/m/tankz/frame/StartFrame.hx +++ b/src/client/haxe/ru/m/tankz/frame/StartFrame.hx @@ -37,7 +37,13 @@ class StartFrame extends VGroupView implements ViewBuilder implements StartFrame } public function onShow():Void { - classic_load.visible = Provider.get(SaveStorage).read(ClassicGame.TYPE) != null; + var save:GameSave = Provider.get(SaveStorage).read(ClassicGame.TYPE); + if (save != null) { + classic_load.visible = true; + classic_load.text = 'Load (Level ${save.state.level})'; + } else { + classic_load.visible = false; + } } public function onPress(view:ButtonView):Void { diff --git a/src/client/haxe/ru/m/tankz/sound/SoundManager.hx b/src/client/haxe/ru/m/tankz/sound/SoundManager.hx index 593b8b7..b825956 100644 --- a/src/client/haxe/ru/m/tankz/sound/SoundManager.hx +++ b/src/client/haxe/ru/m/tankz/sound/SoundManager.hx @@ -2,19 +2,29 @@ package ru.m.tankz.sound; import ru.m.tankz.core.EntityType; import ru.m.tankz.engine.Engine; -import flash.media.Sound; +import openfl.media.Sound; import openfl.utils.Assets; class SoundManager implements EngineListener { private static var TAG(default, never):String = 'SoundManager'; + #if flash + private static var type:String = 'mp3'; + #else + private static var type:String = 'ogg'; + #end + public function new() {} public function play(id:String):Void { - L.d(TAG, 'player: ${id}'); - var sound:Sound = Assets.getSound('resources/sounds/${id}.mp3'); - sound.play(); + L.d(TAG, 'play: ${id}'); + var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}'); + if (sound != null) { + sound.play(); + } else { + L.w(TAG, 'Sound "${id}" not found'); + } } public function onSpawn(entity:EntityType):Void { diff --git a/src/client/resources/classic/config.yaml b/src/client/resources/classic/config.yaml index f6c8b45..9465947 100644 --- a/src/client/resources/classic/config.yaml +++ b/src/client/resources/classic/config.yaml @@ -43,7 +43,7 @@ presets: - {<<: *human, index: 0, color: 0xFFFF00} - id: bot spawnInterval: 3000 - life: 20 + life: 1 players: - {<<: *bot, index: 0} - {<<: *bot, index: 1} diff --git a/src/client/resources/sounds/bonus_add.ogg b/src/client/resources/sounds/bonus_add.ogg new file mode 100644 index 0000000..f415c8e Binary files /dev/null and b/src/client/resources/sounds/bonus_add.ogg differ diff --git a/src/client/resources/sounds/bonus_get.ogg b/src/client/resources/sounds/bonus_get.ogg new file mode 100644 index 0000000..becd824 Binary files /dev/null and b/src/client/resources/sounds/bonus_get.ogg differ diff --git a/src/client/resources/sounds/boom_bot.ogg b/src/client/resources/sounds/boom_bot.ogg new file mode 100644 index 0000000..9bb32f7 Binary files /dev/null and b/src/client/resources/sounds/boom_bot.ogg differ diff --git a/src/client/resources/sounds/boom_player.ogg b/src/client/resources/sounds/boom_player.ogg new file mode 100644 index 0000000..11247b8 Binary files /dev/null and b/src/client/resources/sounds/boom_player.ogg differ diff --git a/src/client/resources/sounds/bullet_block.ogg b/src/client/resources/sounds/bullet_block.ogg new file mode 100644 index 0000000..1d5c0f2 Binary files /dev/null and b/src/client/resources/sounds/bullet_block.ogg differ diff --git a/src/client/resources/sounds/bullet_hit.ogg b/src/client/resources/sounds/bullet_hit.ogg new file mode 100644 index 0000000..7e78c64 Binary files /dev/null and b/src/client/resources/sounds/bullet_hit.ogg differ diff --git a/src/client/resources/sounds/bullet_wall.ogg b/src/client/resources/sounds/bullet_wall.ogg new file mode 100644 index 0000000..1913979 Binary files /dev/null and b/src/client/resources/sounds/bullet_wall.ogg differ diff --git a/src/client/resources/sounds/button.ogg b/src/client/resources/sounds/button.ogg new file mode 100644 index 0000000..c067a28 Binary files /dev/null and b/src/client/resources/sounds/button.ogg differ diff --git a/src/client/resources/sounds/convert.sh b/src/client/resources/sounds/convert.sh new file mode 100755 index 0000000..99c613a --- /dev/null +++ b/src/client/resources/sounds/convert.sh @@ -0,0 +1,4 @@ +#!/bin/bash +for file in *.mp3 + do avconv -i "${file}" "`echo ${file%.mp3}.ogg`"; +done diff --git a/src/client/resources/sounds/game_over.ogg b/src/client/resources/sounds/game_over.ogg new file mode 100644 index 0000000..3190d42 Binary files /dev/null and b/src/client/resources/sounds/game_over.ogg differ diff --git a/src/client/resources/sounds/live.ogg b/src/client/resources/sounds/live.ogg new file mode 100644 index 0000000..0530a09 Binary files /dev/null and b/src/client/resources/sounds/live.ogg differ diff --git a/src/client/resources/sounds/move_bot.ogg b/src/client/resources/sounds/move_bot.ogg new file mode 100644 index 0000000..e2fe97c Binary files /dev/null and b/src/client/resources/sounds/move_bot.ogg differ diff --git a/src/client/resources/sounds/move_player.ogg b/src/client/resources/sounds/move_player.ogg new file mode 100644 index 0000000..4eb849a Binary files /dev/null and b/src/client/resources/sounds/move_player.ogg differ diff --git a/src/client/resources/sounds/pause.ogg b/src/client/resources/sounds/pause.ogg new file mode 100644 index 0000000..9852316 Binary files /dev/null and b/src/client/resources/sounds/pause.ogg differ diff --git a/src/client/resources/sounds/score.ogg b/src/client/resources/sounds/score.ogg new file mode 100644 index 0000000..9c766ec Binary files /dev/null and b/src/client/resources/sounds/score.ogg differ diff --git a/src/client/resources/sounds/shot.ogg b/src/client/resources/sounds/shot.ogg new file mode 100644 index 0000000..1d46963 Binary files /dev/null and b/src/client/resources/sounds/shot.ogg differ diff --git a/src/client/resources/sounds/slide.ogg b/src/client/resources/sounds/slide.ogg new file mode 100644 index 0000000..7c1da05 Binary files /dev/null and b/src/client/resources/sounds/slide.ogg differ diff --git a/src/client/resources/sounds/start.ogg b/src/client/resources/sounds/start.ogg new file mode 100644 index 0000000..d08d9c0 Binary files /dev/null and b/src/client/resources/sounds/start.ogg differ diff --git a/src/common/haxe/ru/m/tankz/engine/Engine.hx b/src/common/haxe/ru/m/tankz/engine/Engine.hx index 9610dd4..c8fe5e3 100755 --- a/src/common/haxe/ru/m/tankz/engine/Engine.hx +++ b/src/common/haxe/ru/m/tankz/engine/Engine.hx @@ -16,6 +16,7 @@ enum EntityChange { DEATH; HIT; LIVE_UP; + TYPE; } @@ -54,6 +55,7 @@ class CollisionProcessor implements EngineListener { if (!tank.protect.active) { if (tank.config.downgrade != null) { tank.config = engine.config.getTank(tank.config.downgrade); + engine.change(tank, EntityChange.TYPE); } else if (tank.hits > 0) { tank.hits--; engine.change(tank, EntityChange.HIT); @@ -138,6 +140,7 @@ class Engine implements ControlHandler { case TankAction.UPGRADE: if (tank.config.upgrade != null) { tank.config = config.getTank(tank.config.upgrade); + change(tank, EntityChange.TYPE); } case TankAction.STOP: tank.stop(); diff --git a/src/common/haxe/ru/m/tankz/game/Game.hx b/src/common/haxe/ru/m/tankz/game/Game.hx index 3d220f6..2578adb 100644 --- a/src/common/haxe/ru/m/tankz/game/Game.hx +++ b/src/common/haxe/ru/m/tankz/game/Game.hx @@ -178,6 +178,8 @@ class Game implements EngineListener { tank.bonus = false; spawnBonus(); } + case [EntityType.TANK(tank), EntityChange.TYPE]: + getPlayer(tank.playerId).state.tank = tank.config.type; case _: } } @@ -257,10 +259,11 @@ class Game implements EngineListener { case 'star': if (tank.config.upgrade != null) { tank.config = config.getTank(tank.config.upgrade); + engine.change(tank, EntityChange.TYPE); } else { tank.hits++; + engine.change(tank, EntityChange.HIT); } - engine.change(tank); case 'grenade': for (t in engine.iterTanks(alienTank(tank.playerId.team))) { engine.destroy(t); @@ -291,6 +294,7 @@ class Game implements EngineListener { for (team in teams) { for (player in team.players) { if (player.config.control == Control.HUMAN) { + player.state.life++; save.addPlayerState(player.id, player.state); } }