// // bingoHeader.js // // created by Rebecca Stankus on 10/12/18 // Copyright 2018 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // (function() { var SOUND_EFFECT_VOLUME = 0.1; var _this; var sound; var bingoCard; var BingoHeader = function() { _this = this; }; BingoHeader.prototype = { remotelyCallable: ['setSound'], preload: function(entityID){ _this.entityID = entityID; bingoCard = Entities.getEntityProperties(_this.entityID, 'parentID').parentID; }, setSound: function(thisID, params) { print("setting sound to url ", params[0]); sound = (SoundCache.getSound(Script.resolvePath(params[0]))); }, playSound: function() { if (sound && sound.downloaded) { // print("sound"); Audio.playSound(sound, { position: Entities.getEntityProperties(_this.entityID, 'position').position, volume: SOUND_EFFECT_VOLUME }); } }, mousePressOnEntity: function(entityID, mouseEvent) { print("mouse press"); if (mouseEvent.isLeftButton) { // print("My id is ", MyAvatar.sessionUUID, " and the parentID of the card is ", Entities.getEntityProperties(bingoCard, 'parentID').parentID); var bingoCardParent = Entities.getEntityProperties(bingoCard, 'parentID').parentID; if (bingoCardParent === "{00000000-0000-0000-0000-000000000001}" || MyAvatar.sessionUUID === bingoCardParent) { print("playing sound"); _this.playSound(); } } } }; return new BingoHeader(); });