// soccer // // Created for HiFi Hackathon on 10/26/2018 // (function() { var RESET_SOUND = SoundCache.getSound(Script.resolvePath('assets/sounds/teamRemove.wav')); var SEARCH_RADIUS = 2; var _this; var audioVolume = 1; var injector; var scoreBoardPosition; var Goal = function() { _this = this; }; Goal.prototype = { preload: function(entityID) { _this.entityID = entityID; }, mousePressOnEntity: function() { Entities.findEntities(MyAvatar.position, SEARCH_RADIUS).forEach(function(entityNearMe) { var properties = Entities.getEntityProperties(entityNearMe, ['parentID','name']); if (properties.name === "Team Marker") { if (properties.parentID === MyAvatar.sessionUUID) { Entities.deleteEntity(entityNearMe); } } }); _this.playSound(RESET_SOUND, 1, 0); }, playSound: function(sound, volume, localOnly) { // print("sound"); if (sound.downloaded) { if (injector) { injector.stop(); } injector = Audio.playSound(sound, { position: scoreBoardPosition, volume: audioVolume }); } } }; return new Goal(); });