refactor audio-related code to use AudioLibrary module

This commit is contained in:
jorsi
2020-05-30 23:33:10 -04:00
parent a340584136
commit 18e8af9809
13 changed files with 164 additions and 174 deletions
+9 -1
View File
@@ -124,5 +124,13 @@ var AudioLibrary = {
CRASH: '/audio/crash.wav', CRASH: '/audio/crash.wav',
REINFORCE_HULL: '/audio/reinforce-hull.wav', REINFORCE_HULL: '/audio/reinforce-hull.wav',
UPGRADE_ENGINE: '/audio/upgrade-engine.wav', UPGRADE_ENGINE: '/audio/upgrade-engine.wav',
LIFT_OFF: '/audio/lift-off.wav' LIFT_OFF: '/audio/lift-off.wav',
PUNCH: '/audio/punch.wav',
STAB: '/audio/stab.wav',
SWING: '/audio/swing.wav',
SLASH: '/audio/slash.wav',
THRUST: '/audio/thrust.wav',
SHOOT: '/audio/shoot.wav',
BLAST: '/audio/blast.wav',
TANGLE: '/audio/tangle.wav'
}; };
+7 -7
View File
@@ -339,12 +339,12 @@ var Events = {
eatMeat: function(btn) { eatMeat: function(btn) {
Events.doHeal('cured meat', World.meatHeal(), btn); Events.doHeal('cured meat', World.meatHeal(), btn);
AudioEngine.playSound(Events.SOUNDS['eat-meat']); AudioEngine.playSound(AudioLibrary.EAT_MEAT);
}, },
useMeds: function(btn) { useMeds: function(btn) {
Events.doHeal('medicine', World.medsHeal(), btn); Events.doHeal('medicine', World.medsHeal(), btn);
AudioEngine.playSound(Events.SOUNDS['use-meds']); AudioEngine.playSound(AudioLibrary.USE_MEDS);
}, },
useWeapon: function(btn) { useWeapon: function(btn) {
@@ -447,7 +447,7 @@ var Events = {
Events.updateFighterDiv(enemy); Events.updateFighterDiv(enemy);
// play hit sound // play hit sound
AudioEngine.playSound(Events.SOUNDS['enemy-hit']); AudioEngine.playSound(AudioLibrary.ENEMY_HIT);
} }
} else { } else {
if(dmg == 'stun') { if(dmg == 'stun') {
@@ -524,7 +524,7 @@ var Events = {
clearTimeout(Events._enemyAttackTimer); clearTimeout(Events._enemyAttackTimer);
Events.endEvent(); Events.endEvent();
World.die(); World.die();
AudioEngine.playSound(Events.SOUNDS['lose-fight']); AudioEngine.playSound(AudioLibrary.LOSE_FIGHT);
} }
}); });
} }
@@ -542,7 +542,7 @@ var Events = {
return; return;
} }
Events.endFight(); Events.endFight();
AudioEngine.playSound(Events.SOUNDS['win-fight']); AudioEngine.playSound(AudioLibrary.WIN_FIGHT);
$('#enemy').animate({opacity: 0}, 300, 'linear', function() { $('#enemy').animate({opacity: 0}, 300, 'linear', function() {
Engine.setTimeout(function() { Engine.setTimeout(function() {
var scene = Events.activeEvent().scenes[Events.activeScene]; var scene = Events.activeEvent().scenes[Events.activeScene];
@@ -1025,7 +1025,7 @@ var Events = {
} else { } else {
var r = Math.floor(Math.random()*(possibleEvents.length)); var r = Math.floor(Math.random()*(possibleEvents.length));
Events.startEvent(possibleEvents[r]); Events.startEvent(possibleEvents[r]);
AudioEngine.playSound(Events.SOUNDS['trigger-event']); AudioEngine.playSound(AudioLibrary.TRIGGER_EVENT);
AudioEngine.playEventMusic(possibleEvents[r].audio); AudioEngine.playEventMusic(possibleEvents[r].audio);
} }
} }
@@ -1047,7 +1047,7 @@ var Events = {
// play audio only when fight is possible // play audio only when fight is possible
if (possibleFights.length > 0) { if (possibleFights.length > 0) {
AudioEngine.playSound(Events.SOUNDS['trigger-fight']); AudioEngine.playSound(AudioLibrary.TRIGGER_FIGHT);
AudioEngine.playEventMusic(possibleFights[r].audio); AudioEngine.playEventMusic(possibleFights[r].audio);
} }
}, },
+10 -10
View File
@@ -39,7 +39,7 @@ Events.Encounters = [
notification: _('a snarling beast leaps out of the underbrush') notification: _('a snarling beast leaps out of the underbrush')
} }
}, },
audio: '/audio/snarling-beast.wav' audio: AudioLibrary.ENCOUNTER_SNARLING_BEAST
}, },
{ /* Gaunt Man */ { /* Gaunt Man */
title: _('A Gaunt Man'), title: _('A Gaunt Man'),
@@ -77,7 +77,7 @@ Events.Encounters = [
notification: _('a gaunt man approaches, a crazed look in his eye') notification: _('a gaunt man approaches, a crazed look in his eye')
} }
}, },
audio: '/audio/gaunt-man.wav' audio: AudioLibrary.ENCOUNTER_GAUNT_MAN
}, },
{ /* Strange Bird */ { /* Strange Bird */
title: _('A Strange Bird'), title: _('A Strange Bird'),
@@ -115,7 +115,7 @@ Events.Encounters = [
notification: _('a strange looking bird speeds across the plains') notification: _('a strange looking bird speeds across the plains')
} }
}, },
audio: '/audio/strange-bird.wav' audio: AudioLibrary.ENCOUNTER_STRANGE_BIRD
}, },
/* Tier 2*/ /* Tier 2*/
{ /* Shivering Man */ { /* Shivering Man */
@@ -159,7 +159,7 @@ Events.Encounters = [
notification: _('a shivering man approaches and attacks with surprising strength') notification: _('a shivering man approaches and attacks with surprising strength')
} }
}, },
audio: '/audio/shivering-man.wav' audio: AudioLibrary.ENCOUNTER_SHIVERING_MAN
}, },
{ /* Man-eater */ { /* Man-eater */
title: _('A Man-Eater'), title: _('A Man-Eater'),
@@ -197,7 +197,7 @@ Events.Encounters = [
notification: _('a large creature attacks, claws freshly bloodied') notification: _('a large creature attacks, claws freshly bloodied')
} }
}, },
audio: '/audio/man-eater.wav' audio: AudioLibrary.ENCOUNTER_MAN_EATER
}, },
{ /* Scavenger */ { /* Scavenger */
title: _('A Scavenger'), title: _('A Scavenger'),
@@ -240,7 +240,7 @@ Events.Encounters = [
notification: _('a scavenger draws close, hoping for an easy score') notification: _('a scavenger draws close, hoping for an easy score')
} }
}, },
audio: '/audio/scavenger.wav' audio: AudioLibrary.ENCOUNTER_SCAVENGER
}, },
{ /* Huge Lizard */ { /* Huge Lizard */
title: _('A Huge Lizard'), title: _('A Huge Lizard'),
@@ -278,7 +278,7 @@ Events.Encounters = [
notification: _('the grass thrashes wildly as a huge lizard pushes through') notification: _('the grass thrashes wildly as a huge lizard pushes through')
} }
}, },
audio: '/audio/huge-lizard.wav' audio: AudioLibrary.ENCOUNTER_HUGE_LIZARD
}, },
/* Tier 3*/ /* Tier 3*/
{ /* Feral Terror */ { /* Feral Terror */
@@ -317,7 +317,7 @@ Events.Encounters = [
notification: _('a beast, wilder than imagining, erupts out of the foliage') notification: _('a beast, wilder than imagining, erupts out of the foliage')
} }
}, },
audio: '/audio/feral-terror.wav' audio: AudioLibrary.ENCOUNTER_FERAL_TERROR
}, },
{ /* Soldier */ { /* Soldier */
title: _('A Soldier'), title: _('A Soldier'),
@@ -361,7 +361,7 @@ Events.Encounters = [
notification: _('a soldier opens fire from across the desert') notification: _('a soldier opens fire from across the desert')
} }
}, },
audio: '/audio/soldier.wav' audio: AudioLibrary.ENCOUNTER_SOLDIER
}, },
{ /* Sniper */ { /* Sniper */
title: _('A Sniper'), title: _('A Sniper'),
@@ -405,6 +405,6 @@ Events.Encounters = [
notification: _('a shot rings out, from somewhere in the long grass') notification: _('a shot rings out, from somewhere in the long grass')
} }
}, },
audio: '/audio/sniper.wav' audio: AudioLibrary.ENCOUNTER_SNIPER
} }
]; ];
+1 -1
View File
@@ -62,6 +62,6 @@ Events.Global = [
} }
} }
}, },
audio: '/audio/thief.wav' audio: AudioLibrary.EVENT_THIEF
} }
]; ];
+6 -6
View File
@@ -64,7 +64,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/ruined-trap.wav' audio: AudioLibrary.EVENT_RUINED_TRAP
}, },
{ /* Hut fire */ { /* Hut fire */
title: _('Fire'), title: _('Fire'),
@@ -91,7 +91,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/hut-fire.wav' audio: AudioLibrary.EVENT_HUT_FIRE
}, },
{ /* Sickness */ { /* Sickness */
title: _('Sickness'), title: _('Sickness'),
@@ -149,7 +149,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/sickness.wav' audio: AudioLibrary.EVENT_SICKNESS
}, },
{ /* Plague */ { /* Plague */
@@ -221,7 +221,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/plague.wav' audio: AudioLibrary.EVENT_PLAGUE
}, },
{ /* Beast attack */ { /* Beast attack */
@@ -256,7 +256,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/beast-attack.wav' audio: AudioLibrary.EVENT_BEAST_ATTACK
}, },
{ /* Soldier attack */ { /* Soldier attack */
@@ -291,7 +291,7 @@ Events.Outside = [
} }
} }
}, },
audio: '/audio/soldier-attack.wav' audio: AudioLibrary.EVENT_SOLDIER_ATTACK
} }
]; ];
+10 -10
View File
@@ -48,7 +48,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/nomad.wav' audio: AudioLibrary.EVENT_NOMAD
}, },
{ /* Noises Outside -- gain wood/fur */ { /* Noises Outside -- gain wood/fur */
title: _('Noises'), title: _('Noises'),
@@ -100,7 +100,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/noises-outside.wav' audio: AudioLibrary.EVENT_NOISES_OUTSIDE
}, },
{ /* Noises Inside -- trade wood for better good */ { /* Noises Inside -- trade wood for better good */
title: _('Noises'), title: _('Noises'),
@@ -187,7 +187,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/noises-inside.wav' audio: AudioLibrary.EVENT_NOISES_INSIDE
}, },
{ /* The Beggar -- trade fur for better good */ { /* The Beggar -- trade fur for better good */
title: _('The Beggar'), title: _('The Beggar'),
@@ -259,7 +259,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/beggar.wav' audio: AudioLibrary.EVENT_BEGGAR
}, },
{/* The Shady Builder */ {/* The Shady Builder */
title: _('The Shady Builder'), title: _('The Shady Builder'),
@@ -316,7 +316,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/shady-builder.wav' audio: AudioLibrary.EVENT_SHADY_BUILDER
}, },
{ /* Mysterious Wanderer -- wood gambling */ { /* Mysterious Wanderer -- wood gambling */
@@ -396,7 +396,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/mysterious-wanderer.wav' audio: AudioLibrary.EVENT_MYSTERIOUS_WANDERER
}, },
{ /* Mysterious Wanderer -- fur gambling */ { /* Mysterious Wanderer -- fur gambling */
@@ -476,7 +476,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/mysterious-wanderer.wav' audio: AudioLibrary.EVENT_MYSTERIOUS_WANDERER
}, },
{ /* The Scout -- Map Merchant */ { /* The Scout -- Map Merchant */
@@ -519,7 +519,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/scout.wav' audio: AudioLibrary.EVENT_SCOUT
}, },
{ /* The Wandering Master */ { /* The Wandering Master */
@@ -593,7 +593,7 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/wandering-master.wav' audio: AudioLibrary.EVENT_WANDERING_MASTER
}, },
{ /* The Sick Man */ { /* The Sick Man */
@@ -682,6 +682,6 @@ Events.Room = [
} }
} }
}, },
audio: '/audio/sick-man.wav' audio: AudioLibrary.EVENT_SICK_MAN
} }
]; ];
+13 -13
View File
@@ -29,7 +29,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/friendly-outpost.wav' audio: AudioLibrary.EVENT_FRIENDLY_OUTPOST
}, },
"swamp": { /* Swamp */ "swamp": { /* Swamp */
title: _('A Murky Swamp'), title: _('A Murky Swamp'),
@@ -87,7 +87,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/swamp.wav' audio: AudioLibrary.EVENT_SWAMP
}, },
"cave": { /* Cave */ "cave": { /* Cave */
title: _('A Damp Cave'), title: _('A Damp Cave'),
@@ -519,7 +519,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/cave.wav' audio: AudioLibrary.EVENT_CAVE
}, },
"town": { /* Town */ "town": { /* Town */
title: _('A Deserted Town'), title: _('A Deserted Town'),
@@ -1237,7 +1237,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/town.wav' audio: AudioLibrary.EVENT_TOWN
}, },
"city": { /* City */ "city": { /* City */
title: _('A Ruined City'), title: _('A Ruined City'),
@@ -2933,7 +2933,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/city.wav' audio: AudioLibrary.EVENT_CITY
}, },
"house": { /* Abandoned House */ "house": { /* Abandoned House */
title: _('An Old House'), title: _('An Old House'),
@@ -3051,7 +3051,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/house.wav' audio: AudioLibrary.EVENT_HOUSE
}, },
"battlefield": { /* Discovering an old battlefield */ "battlefield": { /* Discovering an old battlefield */
title: _('A Forgotten Battlefield'), title: _('A Forgotten Battlefield'),
@@ -3105,7 +3105,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/battlefield.wav' audio: AudioLibrary.EVENT_BATTLEFIELD
}, },
"borehole": { /* Admiring a huge borehole */ "borehole": { /* Admiring a huge borehole */
title: _('A Huge Borehole'), title: _('A Huge Borehole'),
@@ -3135,7 +3135,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/borehole.wav' audio: AudioLibrary.EVENT_BOREHOLE
}, },
"ship": { /* Finding a way off this rock */ "ship": { /* Finding a way off this rock */
title: _('A Crashed Ship'), title: _('A Crashed Ship'),
@@ -3159,7 +3159,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/crashed-ship.wav' audio: AudioLibrary.EVENT_CRASHED_SHIP
}, },
"sulphurmine": { /* Clearing the Sulphur Mine */ "sulphurmine": { /* Clearing the Sulphur Mine */
title: _('The Sulphur Mine'), title: _('The Sulphur Mine'),
@@ -3309,7 +3309,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/sulphurmine.wav' audio: AudioLibrary.EVENT_SULPHUR_MINE
}, },
"coalmine": { /* Clearing the Coal Mine */ "coalmine": { /* Clearing the Coal Mine */
title: _('The Coal Mine'), title: _('The Coal Mine'),
@@ -3452,7 +3452,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/coalmine.wav' audio: AudioLibrary.EVENT_COAL_MINE
}, },
"ironmine": { /* Clearing the Iron Mine */ "ironmine": { /* Clearing the Iron Mine */
title: _('The Iron Mine'), title: _('The Iron Mine'),
@@ -3529,7 +3529,7 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/ironmine.wav' audio: AudioLibrary.EVENT_IRON_MINE
}, },
"cache": { /* Cache - contains some of supplies from previous game */ "cache": { /* Cache - contains some of supplies from previous game */
@@ -3582,6 +3582,6 @@ Events.Setpieces = {
} }
} }
}, },
audio: '/audio/destroyed-village.wav' audio: AudioLibrary.EVENT_DESTROYED_VILLAGE
} }
}; };
+18 -23
View File
@@ -587,14 +587,29 @@ var Outside = {
Outside.updateVillage(true); Outside.updateVillage(true);
Engine.moveStoresView($('#village'), transition_diff); Engine.moveStoresView($('#village'), transition_diff);
Outside.setMusic();
// set music
var numberOfHuts = $SM.get('game.buildings["hut"]', true);
if(numberOfHuts === 0) {
AudioEngine.changeMusic(AudioLibrary.MUSIC_SILENT_FOREST);
} else if(numberOfHuts == 1) {
AudioEngine.changeMusic(AudioLibrary.MUSIC_LONELY_HUT);
} else if(numberOfHuts <= 4) {
AudioEngine.changeMusic(AudioLibrary.MUSIC_TINY_VILLAGE);
} else if(numberOfHuts <= 8) {
AudioEngine.changeMusic(AudioLibrary.MUSIC_MODEST_VILLAGE);
} else if(numberOfHuts <= 14) {
AudioEngine.changeMusic(AudioLibrary.MUSIC_LARGE_VILLAGE);
} else {
AudioEngine.changeMusic(AudioLibrary.MUSIC_RAUCOUS_VILLAGE);
}
}, },
gatherWood: function() { gatherWood: function() {
Notifications.notify(Outside, _("dry brush and dead branches litter the forest floor")); Notifications.notify(Outside, _("dry brush and dead branches litter the forest floor"));
var gatherAmt = $SM.get('game.buildings["cart"]', true) > 0 ? 50 : 10; var gatherAmt = $SM.get('game.buildings["cart"]', true) > 0 ? 50 : 10;
$SM.add('stores.wood', gatherAmt); $SM.add('stores.wood', gatherAmt);
AudioEngine.playSound(Outside.SOUNDS['gather-wood']); AudioEngine.playSound(AudioLibrary.GATHER_WOOD);
}, },
checkTraps: function() { checkTraps: function() {
@@ -635,7 +650,7 @@ var Outside = {
Notifications.notify(Outside, s); Notifications.notify(Outside, s);
$SM.addM('stores', drops); $SM.addM('stores', drops);
AudioEngine.playSound(Outside.SOUNDS['check-traps']); AudioEngine.playSound(AudioLibrary.CHECL_TRAPS);
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
@@ -678,25 +693,5 @@ var Outside = {
scrollByX( $('#storesContainer'), momentum ); scrollByX( $('#storesContainer'), momentum );
Outside._STORES_OFFSET += momentum; Outside._STORES_OFFSET += momentum;
},
setMusic: function () {
var numberOfHuts = $SM.get('game.buildings["hut"]', true);
var currentMusic = 0;
if(numberOfHuts === 0) {
currentMusic = 0;
} else if(numberOfHuts == 1) {
currentMusic = 1;
} else if(numberOfHuts <= 4) {
currentMusic = 2;
} else if(numberOfHuts <= 8) {
currentMusic = 3;
} else if(numberOfHuts <= 14) {
currentMusic = 4;
} else {
currentMusic = 5;
}
Outside.currentMusic = currentMusic;
AudioEngine.changeMusic(Outside.MUSIC[currentMusic]);
} }
}; };
+3 -6
View File
@@ -303,7 +303,8 @@ var Path = {
Path.setTitle(); Path.setTitle();
Path.updateOutfitting(); Path.updateOutfitting();
Path.updatePerks(true); Path.updatePerks(true);
Path.setMusic();
AudioEngine.changeMusic(AudioLibrary.MUSIC_PATH);
Engine.moveStoresView($('#perks'), transition_diff); Engine.moveStoresView($('#perks'), transition_diff);
}, },
@@ -319,7 +320,7 @@ var Path = {
World.onArrival(); World.onArrival();
$('#outerSlider').animate({left: '-700px'}, 300); $('#outerSlider').animate({left: '-700px'}, 300);
Engine.activeModule = World; Engine.activeModule = World;
AudioEngine.playSound(Path.SOUNDS['embark']); AudioEngine.playSound(AudioLibrary.EMBARK);
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
@@ -358,9 +359,5 @@ var Path = {
scrollByX( $('#storesContainer'), momentum ); scrollByX( $('#storesContainer'), momentum );
Path._STORES_OFFSET += momentum; Path._STORES_OFFSET += momentum;
},
setMusic: function () {
AudioEngine.changeMusic(Path.MUSIC[0]);
} }
}; };
+60 -62
View File
@@ -24,7 +24,7 @@ var Room = {
'wood': 10 + (n * 10) 'wood': 10 + (n * 10)
}; };
}, },
audio: '/audio/build-trap.wav' audio: AudioLibrary.BUILD_TRAP
}, },
'cart': { 'cart': {
name: _('cart'), name: _('cart'),
@@ -38,7 +38,7 @@ var Room = {
'wood': 30 'wood': 30
}; };
}, },
audio: '/audio/build-cart.wav' audio: AudioLibrary.BUILD_CART
}, },
'hut': { 'hut': {
name: _('hut'), name: _('hut'),
@@ -54,7 +54,7 @@ var Room = {
'wood': 100 + (n * 50) 'wood': 100 + (n * 50)
}; };
}, },
audio: '/audio/build-hut.wav' audio: AudioLibrary.BUILD_HUT
}, },
'lodge': { 'lodge': {
name: _('lodge'), name: _('lodge'),
@@ -70,7 +70,7 @@ var Room = {
meat: 5 meat: 5
}; };
}, },
audio: '/audio/build-lodge.wav' audio: AudioLibrary.BUILD_LODGE
}, },
'trading post': { 'trading post': {
name: _('trading post'), name: _('trading post'),
@@ -85,7 +85,7 @@ var Room = {
'fur': 100 'fur': 100
}; };
}, },
audio: '/audio/build-trading-post.wav' audio: AudioLibrary.BUILD_TRADING_POST
}, },
'tannery': { 'tannery': {
name: _('tannery'), name: _('tannery'),
@@ -100,7 +100,7 @@ var Room = {
'fur': 50 'fur': 50
}; };
}, },
audio: '/audio/build-tannery.wav' audio: AudioLibrary.BUILD_TANNERY
}, },
'smokehouse': { 'smokehouse': {
name: _('smokehouse'), name: _('smokehouse'),
@@ -115,7 +115,7 @@ var Room = {
'meat': 50 'meat': 50
}; };
}, },
audio: '/audio/build-smokehouse.wav' audio: AudioLibrary.BUILD_SMOKEHOUSE
}, },
'workshop': { 'workshop': {
name: _('workshop'), name: _('workshop'),
@@ -131,7 +131,7 @@ var Room = {
'scales': 10 'scales': 10
}; };
}, },
audio: '/audio/build-workshop.wav' audio: AudioLibrary.BUILD_WORKSHOP
}, },
'steelworks': { 'steelworks': {
name: _('steelworks'), name: _('steelworks'),
@@ -147,7 +147,7 @@ var Room = {
'coal': 100 'coal': 100
}; };
}, },
audio: '/audio/build-steelworks.wav' audio: AudioLibrary.BUILD_STEELWORKS
}, },
'armoury': { 'armoury': {
name: _('armoury'), name: _('armoury'),
@@ -163,7 +163,7 @@ var Room = {
'sulphur': 50 'sulphur': 50
}; };
}, },
audio: '/audio/build-armoury.wav' audio: AudioLibrary.BUILD_ARMOURY
}, },
'torch': { 'torch': {
name: _('torch'), name: _('torch'),
@@ -176,7 +176,7 @@ var Room = {
'cloth': 1 'cloth': 1
}; };
}, },
audio: '/audio/craft-torch.wav' audio: AudioLibrary.CRAFT_TORCH
}, },
'waterskin': { 'waterskin': {
name: _('waterskin'), name: _('waterskin'),
@@ -189,7 +189,7 @@ var Room = {
'leather': 50 'leather': 50
}; };
}, },
audio: '/audio/craft-waterskin.wav' audio: AudioLibrary.CRAFT_WATERSKIN
}, },
'cask': { 'cask': {
name: _('cask'), name: _('cask'),
@@ -203,7 +203,7 @@ var Room = {
'iron': 20 'iron': 20
}; };
}, },
audio: '/audio/craft-cask.wav' audio: AudioLibrary.CRAFT_CASK
}, },
'water tank': { 'water tank': {
name: _('water tank'), name: _('water tank'),
@@ -217,7 +217,7 @@ var Room = {
'steel': 50 'steel': 50
}; };
}, },
audio: '/audio/craft-water-tank.wav' audio: AudioLibrary.CRAFT_WATER_TANK
}, },
'bone spear': { 'bone spear': {
name: _('bone spear'), name: _('bone spear'),
@@ -230,7 +230,7 @@ var Room = {
'teeth': 5 'teeth': 5
}; };
}, },
audio: '/audio/craft-bone-spear.wav' audio: AudioLibrary.CRAFT_BONE_SPEAR
}, },
'rucksack': { 'rucksack': {
name: _('rucksack'), name: _('rucksack'),
@@ -243,7 +243,7 @@ var Room = {
'leather': 200 'leather': 200
}; };
}, },
audio: '/audio/craft-rucksack.wav' audio: AudioLibrary.CRAFT_RUCKSACK
}, },
'wagon': { 'wagon': {
name: _('wagon'), name: _('wagon'),
@@ -257,7 +257,7 @@ var Room = {
'iron': 100 'iron': 100
}; };
}, },
audio: '/audio/craft-wagon.wav' audio: AudioLibrary.CRAFT_WAGON
}, },
'convoy': { 'convoy': {
name: _('convoy'), name: _('convoy'),
@@ -272,7 +272,7 @@ var Room = {
'steel': 100 'steel': 100
}; };
}, },
audio: '/audio/craft-convoy.wav' audio: AudioLibrary.CRAFT_CONVOY
}, },
'l armour': { 'l armour': {
name: _('l armour'), name: _('l armour'),
@@ -285,7 +285,7 @@ var Room = {
'scales': 20 'scales': 20
}; };
}, },
audio: '/audio/craft-leather-armour.wav' audio: AudioLibrary.CRAFT_LEATHER_ARMOUR
}, },
'i armour': { 'i armour': {
name: _('i armour'), name: _('i armour'),
@@ -298,7 +298,7 @@ var Room = {
'iron': 100 'iron': 100
}; };
}, },
audio: '/audio/craft-iron-armour.wav' audio: AudioLibrary.CRAFT_IRON_ARMOUR
}, },
's armour': { 's armour': {
name: _('s armour'), name: _('s armour'),
@@ -311,7 +311,7 @@ var Room = {
'steel': 100 'steel': 100
}; };
}, },
audio: '/audio/craft-steel-armour.wav' audio: AudioLibrary.CRAFT_STEEL_ARMOUR
}, },
'iron sword': { 'iron sword': {
name: _('iron sword'), name: _('iron sword'),
@@ -325,7 +325,7 @@ var Room = {
'iron': 20 'iron': 20
}; };
}, },
audio: '/audio/craft-iron-sword.wav' audio: AudioLibrary.CRAFT_IRON_SWORD
}, },
'steel sword': { 'steel sword': {
name: _('steel sword'), name: _('steel sword'),
@@ -339,7 +339,7 @@ var Room = {
'steel': 20 'steel': 20
}; };
}, },
audio: '/audio/craft-steel-sword.wav' audio: AudioLibrary.CRAFT_STEEL_SWORD
}, },
'rifle': { 'rifle': {
name: _('rifle'), name: _('rifle'),
@@ -352,7 +352,7 @@ var Room = {
'sulphur': 50 'sulphur': 50
}; };
}, },
audio: '/audio/craft-rifle.wav' audio: AudioLibrary.CRAFT_RIFLE
} }
}, },
@@ -362,14 +362,14 @@ var Room = {
cost: function () { cost: function () {
return { fur: 150 }; return { fur: 150 };
}, },
audio: '/audio/buy-scales.wav' audio: AudioLibrary.BUY_SCALES
}, },
'teeth': { 'teeth': {
type: 'good', type: 'good',
cost: function () { cost: function () {
return { fur: 300 }; return { fur: 300 };
}, },
audio: '/audio/buy-teeth.wav' audio: AudioLibrary.BUY_TEETH
}, },
'iron': { 'iron': {
type: 'good', type: 'good',
@@ -379,7 +379,7 @@ var Room = {
'scales': 50 'scales': 50
}; };
}, },
audio: '/audio/buy-iron.wav' audio: AudioLibrary.BUY_IRON
}, },
'coal': { 'coal': {
type: 'good', type: 'good',
@@ -389,7 +389,7 @@ var Room = {
'teeth': 50 'teeth': 50
}; };
}, },
audio: '/audio/buy-coal.wav' audio: AudioLibrary.BUY_COAL
}, },
'steel': { 'steel': {
type: 'good', type: 'good',
@@ -400,7 +400,7 @@ var Room = {
'teeth': 50 'teeth': 50
}; };
}, },
audio: '/audio/buy-steel.wav' audio: AudioLibrary.BUY_STEEL
}, },
'medicine': { 'medicine': {
type: 'good', type: 'good',
@@ -409,7 +409,7 @@ var Room = {
'scales': 50, 'teeth': 30 'scales': 50, 'teeth': 30
}; };
}, },
audio: '/audio/buy-medicine.wav' audio: AudioLibrary.BUY_MEDICINE
}, },
'bullets': { 'bullets': {
type: 'good', type: 'good',
@@ -418,7 +418,7 @@ var Room = {
'scales': 10 'scales': 10
}; };
}, },
audio: '/audio/buy-bullets.wav' audio: AudioLibrary.BUY_BULLETS
}, },
'energy cell': { 'energy cell': {
type: 'good', type: 'good',
@@ -428,7 +428,7 @@ var Room = {
'teeth': 10 'teeth': 10
}; };
}, },
audio: '/audio/buy-energy-cell.wav' audio: AudioLibrary.BUY_ENERGY_CELL
}, },
'bolas': { 'bolas': {
type: 'weapon', type: 'weapon',
@@ -437,7 +437,7 @@ var Room = {
'teeth': 10 'teeth': 10
}; };
}, },
audio: '/audio/buy-bolas.wav' audio: AudioLibrary.BUY_BOLAS
}, },
'grenade': { 'grenade': {
type: 'weapon', type: 'weapon',
@@ -447,7 +447,7 @@ var Room = {
'teeth': 50 'teeth': 50
}; };
}, },
audio: '/audio/buy-grenade.wav' audio: AudioLibrary.BUY_GRENADES
}, },
'bayonet': { 'bayonet': {
type: 'weapon', type: 'weapon',
@@ -457,7 +457,7 @@ var Room = {
'teeth': 250 'teeth': 250
}; };
}, },
audio: '/audio/buy-bayonet.wav' audio: AudioLibrary.BUY_BAYONET
}, },
'alien alloy': { 'alien alloy': {
type: 'good', type: 'good',
@@ -468,7 +468,7 @@ var Room = {
'teeth': 300 'teeth': 300
}; };
}, },
audio: '/audio/buy-alien-alloy.wav' audio: AudioLibrary.BUY_ALIEN_ALLOY
}, },
'compass': { 'compass': {
type: 'special', type: 'special',
@@ -480,7 +480,7 @@ var Room = {
teeth: 10 teeth: 10
}; };
}, },
audio: '/audio/buy-compass.wav' audio: AudioLibrary.BUY_COMPASS
} }
}, },
@@ -601,7 +601,27 @@ var Room = {
} }
Engine.moveStoresView(null, transition_diff); Engine.moveStoresView(null, transition_diff);
Room.setMusic();
// set music based on fire level
var fireValue = $SM.get('game.fire.value');
switch (fireValue) {
case 0:
AudioEngine.changeMusic(AudioLibrary.MUSIC_FIRE0);
break;
case 1:
AudioEngine.changeMusic(AudioLibrary.MUSIC_FIRE1);
break;
case 2:
AudioEngine.changeMusic(AudioLibrary.MUSIC_FIRE2);
break;
case 3:
AudioEngine.changeMusic(AudioLibrary.MUSIC_FIRE3);
break;
case 4:
AudioEngine.changeMusic(AudioLibrary.MUSIC_FIRE4);
break;
}
Room.currentMusic = fireValue;
}, },
TempEnum: { TempEnum: {
@@ -682,7 +702,7 @@ var Room = {
$SM.set('stores.wood', wood - 5); $SM.set('stores.wood', wood - 5);
} }
$SM.set('game.fire', Room.FireEnum.Burning); $SM.set('game.fire', Room.FireEnum.Burning);
AudioEngine.playSound(Room.SOUNDS['light-fire']); AudioEngine.playSound(AudioLibrary.LIGHT_FIRE);
Room.onFireChange(); Room.onFireChange();
}, },
@@ -699,7 +719,7 @@ var Room = {
if ($SM.get('game.fire.value') < 4) { if ($SM.get('game.fire.value') < 4) {
$SM.set('game.fire', Room.FireEnum.fromInt($SM.get('game.fire.value') + 1)); $SM.set('game.fire', Room.FireEnum.fromInt($SM.get('game.fire.value') + 1));
} }
AudioEngine.playSound(Room.SOUNDS['stoke-fire']); AudioEngine.playSound(AudioLibrary.STOKE_FIRE);
Room.onFireChange(); Room.onFireChange();
}, },
@@ -1214,27 +1234,5 @@ var Room = {
} else if (e.stateName.indexOf('game.buildings') === 0) { } else if (e.stateName.indexOf('game.buildings') === 0) {
Room.updateBuildButtons(); Room.updateBuildButtons();
} }
},
setMusic: function () {
var fireValue = $SM.get('game.fire.value');
switch (fireValue) {
case 0:
AudioEngine.changeMusic(Room.MUSIC[fireValue]);
break;
case 1:
AudioEngine.changeMusic(Room.MUSIC[fireValue]);
break;
case 2:
AudioEngine.changeMusic(Room.MUSIC[fireValue]);
break;
case 3:
AudioEngine.changeMusic(Room.MUSIC[fireValue]);
break;
case 4:
AudioEngine.changeMusic(Room.MUSIC[fireValue]);
break;
}
Room.currentMusic = fireValue;
} }
}; };
+4 -8
View File
@@ -90,7 +90,7 @@ var Ship = {
Notifications.notify(Ship, _('somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.')); Notifications.notify(Ship, _('somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.'));
$SM.set('game.spaceShip.seenShip', true); $SM.set('game.spaceShip.seenShip', true);
} }
Ship.setMusic(); AudioEngine.changeMusic(AudioLibrary.MUSIC_SHIP);
Engine.moveStoresView(null, transition_diff); Engine.moveStoresView(null, transition_diff);
}, },
@@ -112,7 +112,7 @@ var Ship = {
Button.setDisabled($('#liftoffButton', Ship.panel), false); Button.setDisabled($('#liftoffButton', Ship.panel), false);
} }
$('#hullRow .row_val', Ship.panel).text($SM.get('game.spaceShip.hull')); $('#hullRow .row_val', Ship.panel).text($SM.get('game.spaceShip.hull'));
AudioEngine.playSound(Ship.SOUNDS['reinforce-hull']); AudioEngine.playSound(AudioLibrary.REINFORCE_HULL);
}, },
upgradeEngine: function() { upgradeEngine: function() {
@@ -123,7 +123,7 @@ var Ship = {
$SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_THRUSTER); $SM.add('stores["alien alloy"]', -Ship.ALLOY_PER_THRUSTER);
$SM.add('game.spaceShip.thrusters', 1); $SM.add('game.spaceShip.thrusters', 1);
$('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters')); $('#engineRow .row_val', Ship.panel).text($SM.get('game.spaceShip.thrusters'));
AudioEngine.playSound(Ship.SOUNDS['upgrade-engine']); AudioEngine.playSound(AudioLibrary.UPGRADE_ENGINE);
}, },
getMaxHull: function() { getMaxHull: function() {
@@ -168,14 +168,10 @@ var Ship = {
$('#outerSlider').animate({top: '700px'}, 300); $('#outerSlider').animate({top: '700px'}, 300);
Space.onArrival(); Space.onArrival();
Engine.activeModule = Space; Engine.activeModule = Space;
AudioEngine.playSound(Ship.SOUNDS['lift-off']); AudioEngine.playSound(AudioLibrary.LIFT_OFF);
}, },
handleStateUpdates: function(e){ handleStateUpdates: function(e){
},
setMusic: function () {
AudioEngine.changeMusic(Ship.MUSIC[0]);
} }
}; };
+10 -10
View File
@@ -53,7 +53,7 @@ var Space = {
Space.hull = Ship.getMaxHull(); Space.hull = Ship.getMaxHull();
Space.altitude = 0; Space.altitude = 0;
Space.setTitle(); Space.setTitle();
AudioEngine.changeMusic(Space.MUSIC[0]); AudioEngine.changeMusic(AudioLibrary.MUSIC_SPACE);
Space.updateHull(); Space.updateHull();
Space.up = Space.up =
@@ -74,22 +74,22 @@ var Space = {
var t; var t;
if(Space.altitude < 10) { if(Space.altitude < 10) {
t = _("Troposphere"); t = _("Troposphere");
AudioEngine.changeMusic(Space.MUSIC[1]); AudioEngine.changeMusic(AudioLibrary.MUSIC_TROPOSPHERE);
} else if(Space.altitude < 20) { } else if(Space.altitude < 20) {
t = _("Stratosphere"); t = _("Stratosphere");
AudioEngine.changeMusic(Space.MUSIC[2]); AudioEngine.changeMusic(AudioLibrary.MUSIC_STRATOSPHERE);
} else if(Space.altitude < 30) { } else if(Space.altitude < 30) {
t = _("Mesosphere"); t = _("Mesosphere");
AudioEngine.changeMusic(Space.MUSIC[3]); AudioEngine.changeMusic(AudioLibrary.MUSIC_MESOSPHERE);
} else if(Space.altitude < 45) { } else if(Space.altitude < 45) {
t = _("Thermosphere"); t = _("Thermosphere");
AudioEngine.changeMusic(Space.MUSIC[4]); AudioEngine.changeMusic(AudioLibrary.MUSIC_THERMOSPHERE);
} else if(Space.altitude < 60){ } else if(Space.altitude < 60){
t = _("Exosphere"); t = _("Exosphere");
AudioEngine.changeMusic(Space.MUSIC[5]); AudioEngine.changeMusic(AudioLibrary.MUSIC_EXOSPHERE);
} else { } else {
t = _("Space"); t = _("Space");
AudioEngine.changeMusic(Space.MUSIC[0]); AudioEngine.changeMusic(AudioLibrary.MUSIC_SPACE);
} }
document.title = t; document.title = t;
} }
@@ -145,7 +145,7 @@ var Space = {
// play random asteroid hit // play random asteroid hit
var r = Math.floor(Math.random() * 2) + 1; var r = Math.floor(Math.random() * 2) + 1;
AudioEngine.playSound(Space.SOUNDS['asteroid-hit-' + r]); AudioEngine.playSound(AudioLibrary['ASTEROID_HIT' + r]);
if(Space.hull === 0) { if(Space.hull === 0) {
Space.crash(); Space.crash();
@@ -369,7 +369,7 @@ var Space = {
Ship.onArrival(); Ship.onArrival();
Button.cooldown($('#liftoffButton')); Button.cooldown($('#liftoffButton'));
Engine.event('progress', 'crash'); Engine.event('progress', 'crash');
AudioEngine.playSound(Space.SOUNDS['crash']); AudioEngine.playSound(AudioLibrary.CRASH);
}, },
endGame: function() { endGame: function() {
@@ -392,7 +392,7 @@ var Space = {
} }
delete Outside._popTimeout; delete Outside._popTimeout;
AudioEngine.changeMusic(Space.MUSIC[6]); AudioEngine.changeMusic(AudioLibrary.MUSIC_ENDING);
$('#hullRemaining', Space.panel).animate({opacity: 0}, 500, 'linear'); $('#hullRemaining', Space.panel).animate({opacity: 0}, 500, 'linear');
Space.ship.animate({ Space.ship.animate({
top: '350px', top: '350px',
+13 -17
View File
@@ -46,35 +46,35 @@ var World = {
type: 'unarmed', type: 'unarmed',
damage: 1, damage: 1,
cooldown: 2, cooldown: 2,
audio: '/audio/punch.wav' audio: AudioLibrary.PUNCH
}, },
'bone spear': { 'bone spear': {
verb: _('stab'), verb: _('stab'),
type: 'melee', type: 'melee',
damage: 2, damage: 2,
cooldown: 2, cooldown: 2,
audio: '/audio/stab.wav' audio: AudioLibrary.STAB
}, },
'iron sword': { 'iron sword': {
verb: _('swing'), verb: _('swing'),
type: 'melee', type: 'melee',
damage: 4, damage: 4,
cooldown: 2, cooldown: 2,
audio: '/audio/swing.wav' audio: AudioLibrary.SWING
}, },
'steel sword': { 'steel sword': {
verb: _('slash'), verb: _('slash'),
type: 'melee', type: 'melee',
damage: 6, damage: 6,
cooldown: 2, cooldown: 2,
audio: '/audio/slash.wav' audio: AudioLibrary.SLASH
}, },
'bayonet': { 'bayonet': {
verb: _('thrust'), verb: _('thrust'),
type: 'melee', type: 'melee',
damage: 8, damage: 8,
cooldown: 2, cooldown: 2,
audio: '/audio/thrust.wav' audio: AudioLibrary.THRUST
}, },
'rifle': { 'rifle': {
verb: _('shoot'), verb: _('shoot'),
@@ -82,7 +82,7 @@ var World = {
damage: 5, damage: 5,
cooldown: 1, cooldown: 1,
cost: { 'bullets': 1 }, cost: { 'bullets': 1 },
audio: '/audio/shoot.wav' audio: AudioLibrary.SHOOT
}, },
'laser rifle': { 'laser rifle': {
verb: _('blast'), verb: _('blast'),
@@ -90,7 +90,7 @@ var World = {
damage: 8, damage: 8,
cooldown: 1, cooldown: 1,
cost: { 'energy cell': 1 }, cost: { 'energy cell': 1 },
audio: '/audio/blast.wav' audio: AudioLibrary.BLAST
}, },
'grenade': { 'grenade': {
verb: _('lob'), verb: _('lob'),
@@ -98,7 +98,7 @@ var World = {
damage: 15, damage: 15,
cooldown: 5, cooldown: 5,
cost: { 'grenade': 1 }, cost: { 'grenade': 1 },
audio: '/audio/lob.wav' audio: AudioLibrary.LOB
}, },
'bolas': { 'bolas': {
verb: _('tangle'), verb: _('tangle'),
@@ -106,7 +106,7 @@ var World = {
damage: 'stun', damage: 'stun',
cooldown: 15, cooldown: 15,
cost: { 'bolas': 1 }, cost: { 'bolas': 1 },
audio: '/audio/tangle.wav' audio: AudioLibrary.TANGLE
} }
}, },
@@ -358,7 +358,7 @@ var World = {
// play random footstep // play random footstep
var randomFootstep = Math.floor(Math.random() * 2) + 1; var randomFootstep = Math.floor(Math.random() * 2) + 1;
AudioEngine.playSound(World.SOUNDS['footsteps-' + randomFootstep]); AudioEngine.playSound(AudioLibrary['FOOTSTEPS' + randomFootstep]);
if(World.checkDanger()) { if(World.checkDanger()) {
if(World.danger) { if(World.danger) {
@@ -478,7 +478,7 @@ var World = {
$SM.addPerk('slow metabolism'); $SM.addPerk('slow metabolism');
} }
World.die(); World.die();
AudioEngine.playSound(World.SOUNDS['death-starved']); AudioEngine.playSound(AudioLibrary.DEATH_STARVED);
return false; return false;
} }
} else { } else {
@@ -508,7 +508,7 @@ var World = {
$SM.addPerk('desert rat'); $SM.addPerk('desert rat');
} }
World.die(); World.die();
AudioEngine.playSound(World.SOUNDS['death-dehydrated']); AudioEngine.playSound(AudioLibrary.DEATH_DEHYDRATED);
return false; return false;
} }
} else { } else {
@@ -1022,7 +1022,7 @@ var World = {
World.curPos = World.copyPos(World.VILLAGE_POS); World.curPos = World.copyPos(World.VILLAGE_POS);
World.drawMap(); World.drawMap();
World.setTitle(); World.setTitle();
World.setMusic(); AudioEngine.changeMusic(AudioLibrary.MUSIC_WORLD);
World.dead = false; World.dead = false;
$('div#bagspace-world > div').empty(); $('div#bagspace-world > div').empty();
World.updateSupplies(); World.updateSupplies();
@@ -1039,9 +1039,5 @@ var World = {
handleStateUpdates: function(e){ handleStateUpdates: function(e){
},
setMusic: function () {
AudioEngine.changeMusic(World.MUSIC[0]);
} }
}; };