[client] added ogg sounds
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package ru.m.tankz;
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
import ru.m.tankz.sound.SoundManager;
|
import ru.m.tankz.sound.SoundManager;
|
||||||
import flash.events.KeyboardEvent;
|
import flash.events.KeyboardEvent;
|
||||||
import flash.text.Font;
|
import flash.text.Font;
|
||||||
@@ -91,6 +92,11 @@ class Client implements IConnectionHandler {
|
|||||||
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
Provider.setFactory(Game, ClassicGame, ClassicGame.TYPE);
|
||||||
Provider.setFactory(Game, DotaGame, DotaGame.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);
|
view.switcher.change(StartFrame.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
|||||||
timer = new Timer(10);
|
timer = new Timer(10);
|
||||||
timer.run = updateEngine;
|
timer.run = updateEngine;
|
||||||
state.text = stateString(game);
|
state.text = stateString(game);
|
||||||
|
Provider.get(SoundManager).play('start');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stop():Void {
|
private function stop():Void {
|
||||||
|
|||||||
@@ -37,7 +37,13 @@ class StartFrame extends VGroupView implements ViewBuilder implements StartFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onShow():Void {
|
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 {
|
public function onPress(view:ButtonView):Void {
|
||||||
|
|||||||
@@ -2,19 +2,29 @@ package ru.m.tankz.sound;
|
|||||||
|
|
||||||
import ru.m.tankz.core.EntityType;
|
import ru.m.tankz.core.EntityType;
|
||||||
import ru.m.tankz.engine.Engine;
|
import ru.m.tankz.engine.Engine;
|
||||||
import flash.media.Sound;
|
import openfl.media.Sound;
|
||||||
import openfl.utils.Assets;
|
import openfl.utils.Assets;
|
||||||
|
|
||||||
|
|
||||||
class SoundManager implements EngineListener {
|
class SoundManager implements EngineListener {
|
||||||
private static var TAG(default, never):String = 'SoundManager';
|
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 new() {}
|
||||||
|
|
||||||
public function play(id:String):Void {
|
public function play(id:String):Void {
|
||||||
L.d(TAG, 'player: ${id}');
|
L.d(TAG, 'play: ${id}');
|
||||||
var sound:Sound = Assets.getSound('resources/sounds/${id}.mp3');
|
var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}');
|
||||||
sound.play();
|
if (sound != null) {
|
||||||
|
sound.play();
|
||||||
|
} else {
|
||||||
|
L.w(TAG, 'Sound "${id}" not found');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSpawn(entity:EntityType):Void {
|
public function onSpawn(entity:EntityType):Void {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ presets:
|
|||||||
- {<<: *human, index: 0, color: 0xFFFF00}
|
- {<<: *human, index: 0, color: 0xFFFF00}
|
||||||
- id: bot
|
- id: bot
|
||||||
spawnInterval: 3000
|
spawnInterval: 3000
|
||||||
life: 20
|
life: 1
|
||||||
players:
|
players:
|
||||||
- {<<: *bot, index: 0}
|
- {<<: *bot, index: 0}
|
||||||
- {<<: *bot, index: 1}
|
- {<<: *bot, index: 1}
|
||||||
|
|||||||
BIN
src/client/resources/sounds/bonus_add.ogg
Normal file
BIN
src/client/resources/sounds/bonus_add.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/bonus_get.ogg
Normal file
BIN
src/client/resources/sounds/bonus_get.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/boom_bot.ogg
Normal file
BIN
src/client/resources/sounds/boom_bot.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/boom_player.ogg
Normal file
BIN
src/client/resources/sounds/boom_player.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/bullet_block.ogg
Normal file
BIN
src/client/resources/sounds/bullet_block.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/bullet_hit.ogg
Normal file
BIN
src/client/resources/sounds/bullet_hit.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/bullet_wall.ogg
Normal file
BIN
src/client/resources/sounds/bullet_wall.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/button.ogg
Normal file
BIN
src/client/resources/sounds/button.ogg
Normal file
Binary file not shown.
4
src/client/resources/sounds/convert.sh
Executable file
4
src/client/resources/sounds/convert.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
for file in *.mp3
|
||||||
|
do avconv -i "${file}" "`echo ${file%.mp3}.ogg`";
|
||||||
|
done
|
||||||
BIN
src/client/resources/sounds/game_over.ogg
Normal file
BIN
src/client/resources/sounds/game_over.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/live.ogg
Normal file
BIN
src/client/resources/sounds/live.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/move_bot.ogg
Normal file
BIN
src/client/resources/sounds/move_bot.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/move_player.ogg
Normal file
BIN
src/client/resources/sounds/move_player.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/pause.ogg
Normal file
BIN
src/client/resources/sounds/pause.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/score.ogg
Normal file
BIN
src/client/resources/sounds/score.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/shot.ogg
Normal file
BIN
src/client/resources/sounds/shot.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/slide.ogg
Normal file
BIN
src/client/resources/sounds/slide.ogg
Normal file
Binary file not shown.
BIN
src/client/resources/sounds/start.ogg
Normal file
BIN
src/client/resources/sounds/start.ogg
Normal file
Binary file not shown.
@@ -16,6 +16,7 @@ enum EntityChange {
|
|||||||
DEATH;
|
DEATH;
|
||||||
HIT;
|
HIT;
|
||||||
LIVE_UP;
|
LIVE_UP;
|
||||||
|
TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ class CollisionProcessor implements EngineListener {
|
|||||||
if (!tank.protect.active) {
|
if (!tank.protect.active) {
|
||||||
if (tank.config.downgrade != null) {
|
if (tank.config.downgrade != null) {
|
||||||
tank.config = engine.config.getTank(tank.config.downgrade);
|
tank.config = engine.config.getTank(tank.config.downgrade);
|
||||||
|
engine.change(tank, EntityChange.TYPE);
|
||||||
} else if (tank.hits > 0) {
|
} else if (tank.hits > 0) {
|
||||||
tank.hits--;
|
tank.hits--;
|
||||||
engine.change(tank, EntityChange.HIT);
|
engine.change(tank, EntityChange.HIT);
|
||||||
@@ -138,6 +140,7 @@ class Engine implements ControlHandler {
|
|||||||
case TankAction.UPGRADE:
|
case TankAction.UPGRADE:
|
||||||
if (tank.config.upgrade != null) {
|
if (tank.config.upgrade != null) {
|
||||||
tank.config = config.getTank(tank.config.upgrade);
|
tank.config = config.getTank(tank.config.upgrade);
|
||||||
|
change(tank, EntityChange.TYPE);
|
||||||
}
|
}
|
||||||
case TankAction.STOP:
|
case TankAction.STOP:
|
||||||
tank.stop();
|
tank.stop();
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ class Game implements EngineListener {
|
|||||||
tank.bonus = false;
|
tank.bonus = false;
|
||||||
spawnBonus();
|
spawnBonus();
|
||||||
}
|
}
|
||||||
|
case [EntityType.TANK(tank), EntityChange.TYPE]:
|
||||||
|
getPlayer(tank.playerId).state.tank = tank.config.type;
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,10 +259,11 @@ class Game implements EngineListener {
|
|||||||
case 'star':
|
case 'star':
|
||||||
if (tank.config.upgrade != null) {
|
if (tank.config.upgrade != null) {
|
||||||
tank.config = config.getTank(tank.config.upgrade);
|
tank.config = config.getTank(tank.config.upgrade);
|
||||||
|
engine.change(tank, EntityChange.TYPE);
|
||||||
} else {
|
} else {
|
||||||
tank.hits++;
|
tank.hits++;
|
||||||
|
engine.change(tank, EntityChange.HIT);
|
||||||
}
|
}
|
||||||
engine.change(tank);
|
|
||||||
case 'grenade':
|
case 'grenade':
|
||||||
for (t in engine.iterTanks(alienTank(tank.playerId.team))) {
|
for (t in engine.iterTanks(alienTank(tank.playerId.team))) {
|
||||||
engine.destroy(t);
|
engine.destroy(t);
|
||||||
@@ -291,6 +294,7 @@ class Game implements EngineListener {
|
|||||||
for (team in teams) {
|
for (team in teams) {
|
||||||
for (player in team.players) {
|
for (player in team.players) {
|
||||||
if (player.config.control == Control.HUMAN) {
|
if (player.config.control == Control.HUMAN) {
|
||||||
|
player.state.life++;
|
||||||
save.addPlayerState(player.id, player.state);
|
save.addPlayerState(player.id, player.state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user