content/hifi-content/liv/dev/Spider/ScaryZoneServer.js
2022-02-14 02:04:11 +01:00

37 lines
No EOL
1.2 KiB
JavaScript

(function() {
var AUDIO_CLIP_URL_SCARY = Script.resolvePath("./resources/help-me-scary.wav");
var SPIDER_ENTITY_ID = "{7c26a8fc-2167-4e31-9237-f1bafb3ae04f}";
var AUDIO_POSITION = {x: 15.22, y:-3.58, z: -76.9};
var audioElement;
var ScaryZone = function() {
};
ScaryZone.prototype = {
remotelyCallable: ['startZoneEffect', 'leaveZoneEffect'],
preload: function(entityID) {
audioElement = SoundCache.getSound(AUDIO_CLIP_URL_SCARY);
},
unload: function() {
},
startZoneEffect : function() {
if (audioElement.downloaded) {
Audio.playSound(audioElement, {
position: AUDIO_POSITION,
volume: Math.random(),
pitch: 1
});
Script.setTimeout(function(){
Entities.editEntity(SPIDER_ENTITY_ID, {'visible' : true});
}, 10000);
Script.setTimeout(function() {
Entities.editEntity(SPIDER_ENTITY_ID, {'visible' : false});
}, 20000);
}
},
leaveZoneEffect : function() {
}
};
return new ScaryZone();
});