diff --git a/www/assets/sound/claim.mp3 b/www/assets/sound/claim.mp3 new file mode 100644 index 0000000..dfe5d5d Binary files /dev/null and b/www/assets/sound/claim.mp3 differ diff --git a/www/assets/sound/coin.mp3 b/www/assets/sound/coin.mp3 new file mode 100644 index 0000000..052b500 Binary files /dev/null and b/www/assets/sound/coin.mp3 differ diff --git a/www/assets/sound/error.mp3 b/www/assets/sound/error.mp3 new file mode 100644 index 0000000..4fad50d Binary files /dev/null and b/www/assets/sound/error.mp3 differ diff --git a/www/assets/sound/levelup.mp3 b/www/assets/sound/levelup.mp3 new file mode 100644 index 0000000..5d45459 Binary files /dev/null and b/www/assets/sound/levelup.mp3 differ diff --git a/www/assets/sound/refill.mp3 b/www/assets/sound/refill.mp3 new file mode 100644 index 0000000..3ae1d4c Binary files /dev/null and b/www/assets/sound/refill.mp3 differ diff --git a/www/assets/sound/woosh.mp3 b/www/assets/sound/woosh.mp3 new file mode 100644 index 0000000..8fe1740 Binary files /dev/null and b/www/assets/sound/woosh.mp3 differ diff --git a/www/js/music.js b/www/js/music.js index 266d193..aaf5908 100644 --- a/www/js/music.js +++ b/www/js/music.js @@ -20,8 +20,10 @@ var audio_stay_stopped = false; var audio_doneplaying = true; var audio_isplaying = false; var audio; +var sound; var MUSIC_DIR = getWwwFolderPath() + "assets/audio/"; +var SOUND_DIR = getWwwFolderPath() + "assets/sound/"; function queuesong(song) { if (audio_isplaying) { @@ -61,6 +63,14 @@ function playAudio() { audio.play({playAudioWhenScreenIsLocked: false}); } +function playSound(soundname) { + if (localStorage.getItem("sounds") === "mute") { + return; + } + sound = new Media(SOUND_DIR + soundname + ".mp3", null, null, null); + sound.play({playAudioWhenScreenIsLocked: false}); +} + document.addEventListener("pause", function () { audio.pause(); audio_doneplaying = false; diff --git a/www/js/shop.js b/www/js/shop.js index f271aa6..e474315 100644 --- a/www/js/shop.js +++ b/www/js/shop.js @@ -38,10 +38,12 @@ function buycoins(productId) { }); }) .then(function () { + playSound("coin"); showSuccessMessage("Thanks for your purchase!"); refreshcoins(); }) .catch(function (err) { + playSound("error"); console.log("Error: " + err.message); showErrorMessage("Error: " + err.message); }); @@ -67,10 +69,12 @@ function buycoins(productId) { }); }) .then(function () { + playSound("coin"); showSuccessMessage("Thanks for your purchase!"); refreshcoins(); }) .catch(function (err) { + playSound("error"); console.log("Error: " + err.message); showErrorMessage("Error: " + err.message); }); @@ -87,8 +91,10 @@ function buyitem(id, cost) { lang: USER_LANGUAGE }, function (data) { if (data.status == 'OK') { + playSound("coin"); showSuccessMessage(data.message); } else { + playSound("error"); showErrorMessage(data.message); } loadstorefront(); diff --git a/www/screens/inventory.html b/www/screens/inventory.html index dda8991..f87243c 100644 --- a/www/screens/inventory.html +++ b/www/screens/inventory.html @@ -61,6 +61,7 @@ content = ""; } if (content == '') { + playSound("error"); showErrorMessage("There is nobody nearby to give an item to."); } else { $('#nearby-players-dropdown').html(content); @@ -84,6 +85,7 @@ syncStats(); showSuccessMessage("Transferred!"); } else { + playSound("error"); showErrorMessage(data.message); } }).fail(function () { @@ -101,6 +103,7 @@ loadinventory(); syncStats(); } else { + playSound("error"); showErrorMessage(data.message); } }).fail(function () { diff --git a/www/screens/place.html b/www/screens/place.html index 34cb0fd..492080e 100644 --- a/www/screens/place.html +++ b/www/screens/place.html @@ -184,16 +184,22 @@ case 3: $('#place-log').prepend("Attacking....
"); } + if (data.levelup === true) { + playSound("levelup"); + } else { + playSound("woosh"); + } resync(); } else { + playSound("error"); $('#capturebtn').text(data.message); $('#capturebtn').removeClass('btn-primary'); $('#capturebtn').addClass('btn-warning'); $('#place-log').prepend(data.message + "
"); resync(); } - //alert(data.message); }).fail(function () { + playSound("error"); $('#capturebtn').text("Try that again."); $('#capturebtn').removeClass('btn-primary'); $('#capturebtn').addClass('btn-warning'); @@ -223,7 +229,13 @@ case 3: $('#place-log').prepend("Recharging....
"); } + if (data.levelup === true) { + playSound("levelup"); + } else { + playSound("refill"); + } } else { + playSound("error"); $('#refillbtn').text(data.message); $('#refillbtn').removeClass('btn-primary'); $('#refillbtn').addClass('btn-warning'); @@ -231,6 +243,7 @@ } resync(); }).fail(function () { + playSound("error"); $('#refillbtn').text("Try that again."); $('#refillbtn').removeClass('btn-primary'); $('#refillbtn').addClass('btn-warning'); @@ -251,16 +264,22 @@ if (data.status === 'OK') { $('#capturebtn').text(data.message); $('#place-log').prepend("Claimed!
"); + if (data.levelup === true) { + playSound("levelup"); + } else { + playSound("claim"); + } resync(); } else { + playSound("error"); $('#capturebtn').text(data.message); $('#capturebtn').removeClass('btn-primary'); $('#capturebtn').addClass('btn-warning'); $('#place-log').prepend(data.message + "
"); resync(); } - //alert(data.message); }).fail(function () { + playSound("error"); $('#capturebtn').text("Try that again."); $('#capturebtn').removeClass('btn-primary'); $('#capturebtn').addClass('btn-warning'); diff --git a/www/screens/settings.html b/www/screens/settings.html index ff6de50..487a512 100644 --- a/www/screens/settings.html +++ b/www/screens/settings.html @@ -29,6 +29,9 @@
Turn music off
+
+ Turn sounds off +
Link with Munzee account
@@ -54,6 +57,11 @@ } else { $('#toggle-music-onoff-label').text("off"); } + if (localStorage.getItem("sounds") == "mute") { + $('#toggle-sounds-onoff-label').text("on"); + } else { + $('#toggle-sounds-onoff-label').text("off"); + } } function toggleMusic() { @@ -66,6 +74,15 @@ } loadToggles(); } + + function toggleSounds() { + if (localStorage.getItem("sounds") == "mute") { + localStorage.setItem("sounds", ""); + } else { + localStorage.setItem("sounds", "mute"); + } + loadToggles(); + } loadToggles();