diff --git a/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js b/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js index 3abdaa46fb..1ff114012c 100644 --- a/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js +++ b/unpublishedScripts/marketplace/shortbow/enemyClientEntity.js @@ -11,6 +11,8 @@ (function() { Script.include('utils.js'); + var BOOF_SOUND = SoundCache.getSound(Script.resolvePath("sounds/boof.wav")); + function Enemy() { } Enemy.prototype = { @@ -38,13 +40,93 @@ this.entityIDsThatHaveCollidedWithMe.push(entityB); var colliderName = Entities.getEntityProperties(entityB, 'name').name; - if (colliderName.indexOf("projectile") > -1) { + var smokeImage = { + "alpha": 0.89999997615814209, + "alphaFinish": 0.89999997615814209, + "alphaStart": 0.89999997615814209, + "azimuthFinish": 0.40000000596046448, + "clientOnly": 0, + "color": { + "blue": 57, + "green": 254, + "red": 255 + }, + "colorFinish": { + "blue": 57, + "green": 254, + "red": 255 + }, + "colorSpread": { + "blue": 130, + "green": 130, + "red": 130 + }, + "colorStart": { + "blue": 57, + "green": 254, + "red": 255 + }, + "created": "2017-01-10T19:17:07Z", + "dimensions": { + "x": 1.7600001096725464, + "y": 1.7600001096725464, + "z": 1.7600001096725464 + }, + "emitAcceleration": { + "x": 0, + "y": 0, + "z": 0 + }, + "emitOrientation": { + "w": 0.7070610523223877, + "x": -0.70715254545211792, + "y": -1.5258869098033756e-05, + "z": -1.5258869098033756e-05 + }, + "emitRate": 25.200000762939453, + "emitSpeed": 0, + "id": "{0273087c-a676-4ac2-93ff-f2440517dfb7}", + "lastEdited": 1485295831550663, + "lastEditedBy": "{dfe734a0-8289-47f6-a1a6-cf3f6d57adac}", + "lifespan": 0.5, + "lifetime": 0.5, + "locked": 1, + "owningAvatarID": "{00000000-0000-0000-0000-000000000000}", + "particleRadius": 0.30099999904632568, + "polarFinish": 3, + "position": Entities.getEntityProperties(entityA, 'position').position, + "queryAACube": { + "scale": 3.0484094619750977, + "x": -1.5242047309875488, + "y": -1.5242047309875488, + "z": -1.5242047309875488 + }, + "radiusFinish": 0.30099999904632568, + "radiusStart": 0.30099999904632568, + "rotation": { + "w": 0.086696967482566833, + "x": -0.53287714719772339, + "y": 0.80860012769699097, + "z": -0.23394235968589783 + }, + "textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png", + "type": "ParticleEffect" + }; + + Audio.playSound(BOOF_SOUND, { + volume: 1.0, + position: Entities.getEntityProperties(entityA, 'position').position + }); + + Entities.addEntity(smokeImage); + Messages.sendMessage(this.gameChannel, JSON.stringify({ type: "enemy-killed", entityID: this.entityID, position: Entities.getEntityProperties(this.entityID, 'position').position })); + Entities.deleteEntity(this.entityID); } else if (colliderName.indexOf("GateCollider") > -1) { Messages.sendMessage(this.gameChannel, JSON.stringify({ diff --git a/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js b/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js index 9f0d8c93f3..e33200721e 100644 --- a/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js +++ b/unpublishedScripts/marketplace/shortbow/shortbowGameManager.js @@ -336,6 +336,13 @@ ShortbowGameManager.prototype = { volume: 1.0, position: this.rootPosition }); + + var liveChecker = setInterval(function() { + if (this.livesLeft <= 0) { + this.endGame(); + clearInterval(liveChecker); + } + }, 1000); }, startNextWave: function() { if (this.gameState !== GAME_STATES.BETWEEN_WAVES) { @@ -464,6 +471,7 @@ ShortbowGameManager.prototype = { print("EXPIRING: ", enemy.id); Entities.deleteEntity(enemy.id); this.remainingEnemies.splice(i, 1); + // Play the sound when you hit an enemy Audio.playSound(TARGET_HIT_SOUND, { volume: 1.0, position: this.rootPosition @@ -561,10 +569,10 @@ ShortbowGameManager.prototype = { } }, onEnemyKilled: function(entityID, position) { - if (this.gameState !== GAME_STATES.PLAYING) { + if (this.gameState !== GAME_STATES.PLAYING) { return; } - + for (var i = this.remainingEnemies.length - 1; i >= 0; --i) { var enemy = this.remainingEnemies[i]; if (enemy.id === entityID) { @@ -573,7 +581,6 @@ ShortbowGameManager.prototype = { volume: 1.0, position: this.rootPosition }); - // Update score this.setScore(this.score + POINTS_PER_KILL); print("SCORE: ", this.score); @@ -592,6 +599,7 @@ ShortbowGameManager.prototype = { for (var i = this.remainingEnemies.length - 1; i >= 0; --i) { var enemy = this.remainingEnemies[i]; if (enemy.id === entityID) { + Entities.deleteEntity(enemy.id); this.remainingEnemies.splice(i, 1); this.setLivesLeft(this.livesLeft - 1); diff --git a/unpublishedScripts/marketplace/shortbow/sounds/boof.wav b/unpublishedScripts/marketplace/shortbow/sounds/boof.wav new file mode 100644 index 0000000000..8f404546f5 Binary files /dev/null and b/unpublishedScripts/marketplace/shortbow/sounds/boof.wav differ