Added sound effect (temp) when you hit a ball, plus added a check to ensure the game doesn't hang waiting for balls out of the arena.

This commit is contained in:
Cain Kilgore 2017-06-18 07:27:49 +01:00
parent 135beb2d48
commit 394560c979
3 changed files with 15 additions and 2 deletions

View file

@ -11,6 +11,8 @@
(function() { (function() {
Script.include('utils.js'); Script.include('utils.js');
var BOOF_SOUND = SoundCache.getSound(Script.resolvePath("sounds/boof.wav"));
function Enemy() { function Enemy() {
} }
Enemy.prototype = { Enemy.prototype = {
@ -74,6 +76,11 @@
type: 'ParticleEffect' type: 'ParticleEffect'
}; };
Audio.playSound(BOOF_SOUND, {
volume: 1.0,
position: Entities.getEntityProperties(entityA, 'position').position
});
Entities.addEntity(smokeImage); Entities.addEntity(smokeImage);
Messages.sendMessage(this.gameChannel, JSON.stringify({ Messages.sendMessage(this.gameChannel, JSON.stringify({

View file

@ -336,6 +336,13 @@ ShortbowGameManager.prototype = {
volume: 1.0, volume: 1.0,
position: this.rootPosition position: this.rootPosition
}); });
var liveChecker = setInterval(function() {
if (this.livesLeft <= 0) {
this.endGame();
clearInterval(liveChecker);
}
}, 1000);
}, },
startNextWave: function() { startNextWave: function() {
if (this.gameState !== GAME_STATES.BETWEEN_WAVES) { if (this.gameState !== GAME_STATES.BETWEEN_WAVES) {
@ -464,11 +471,11 @@ ShortbowGameManager.prototype = {
print("EXPIRING: ", enemy.id); print("EXPIRING: ", enemy.id);
Entities.deleteEntity(enemy.id); Entities.deleteEntity(enemy.id);
this.remainingEnemies.splice(i, 1); this.remainingEnemies.splice(i, 1);
// Play the sound when you hit an enemy
Audio.playSound(TARGET_HIT_SOUND, { Audio.playSound(TARGET_HIT_SOUND, {
volume: 1.0, volume: 1.0,
position: this.rootPosition position: this.rootPosition
}); });
print("CAINK - BALL KILLED");
this.setScore(this.score + POINTS_PER_KILL); this.setScore(this.score + POINTS_PER_KILL);
enemiesEscaped = true; enemiesEscaped = true;
} }
@ -562,7 +569,6 @@ ShortbowGameManager.prototype = {
} }
}, },
onEnemyKilled: function(entityID, position) { onEnemyKilled: function(entityID, position) {
if (this.gameState !== GAME_STATES.PLAYING) { if (this.gameState !== GAME_STATES.PLAYING) {
return; return;
} }