56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
//
|
|
// 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 _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");
|
|
sound = JSON.parse(params[0]);
|
|
},
|
|
|
|
playSound: function() {
|
|
if (sound && sound.downloaded) {
|
|
// print("sound");
|
|
Audio.playSound(sound, {
|
|
position: Entities.getEntityProperties(_this.entityID, 'position').position,
|
|
volume: 1
|
|
});
|
|
}
|
|
},
|
|
|
|
mousePressOnEntity: function(entityID, mouseEvent) {
|
|
if (mouseEvent.isLeftButton) {
|
|
print("My id is ", MyAvatar.sessionUUID, " and the parentID of the card is ", Entities.getEntityProperties(card, 'parentID').parentID);
|
|
var bingoCardParent = Entities.getEntityProperties(bingoCard, 'parentID').parentID;
|
|
if (bingoCardParent === "{00000000-0000-0000-0000-000000000001}" || MyAvatar.sessionUUID === bingoCardParent) {
|
|
_this.playSound();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
return new BingoHeader();
|
|
});
|