65 lines
No EOL
2 KiB
JavaScript
65 lines
No EOL
2 KiB
JavaScript
//
|
|
// happy420.js
|
|
// Release fx pills when entity is clicked
|
|
//
|
|
// Author: Elisa Lupin-Jimenez
|
|
// Copyright High Fidelity 2018
|
|
//
|
|
// Licensed under the Apache 2.0 License
|
|
// See accompanying license file or http://apache.org/
|
|
//
|
|
// All assets are under CC Attribution Non-Commerical
|
|
// http://creativecommons.org/licenses/
|
|
//
|
|
|
|
(function() {
|
|
var SOUND_URL = "https://hifi-content.s3.amazonaws.com/elisalj/mexico/sounds/PartyHorn4.wav";
|
|
var SOUND = SoundCache.getSound(SOUND_URL);
|
|
var PILL_URL = "https://hifi-content.s3.amazonaws.com/elisalj/hub/models/pill.fbx";
|
|
var SWALLOW_PILL_SCRIPT = "https://hifi-content.s3.amazonaws.com/elisalj/hub/swallow420Pill.js?01";
|
|
var PILL_AMOUNT = 10;
|
|
var LIFETIME = 30;
|
|
var SPAWN_POSITION;
|
|
|
|
var PILL;
|
|
|
|
var isInactive = true;
|
|
|
|
function dropPills() {
|
|
if (isInactive) {
|
|
isInactive = false;
|
|
Audio.playSound(SOUND, {volume: 0.5, position: SPAWN_POSITION});
|
|
for (var i = 0; i < PILL_AMOUNT; i++) {
|
|
Entities.addEntity(PILL);
|
|
}
|
|
Script.setTimeout(function() {
|
|
isInactive = true;
|
|
}, LIFETIME * 1000);
|
|
}
|
|
}
|
|
|
|
this.preload = function(entityID) {
|
|
SPAWN_POSITION = Entities.getEntityProperties(entityID, "position").position;
|
|
PILL = {
|
|
type: "Model",
|
|
shapeType: "capsule-z",
|
|
name: "420-pill",
|
|
modelURL: PILL_URL,
|
|
script: SWALLOW_PILL_SCRIPT,
|
|
lifetime: LIFETIME,
|
|
position: SPAWN_POSITION,
|
|
dynamic: true,
|
|
gravity: {x: 0, y: -9.8, z: 0},
|
|
velocity: {x:0, y: -0.1, z: 0},
|
|
collisionless: false,
|
|
userData : "{\"grabbableKey\":{\"grabbable\":true}}"
|
|
};
|
|
};
|
|
|
|
this.mousePressOnEntity = function(entityID, mouseEvent) {
|
|
print("pressed pills");
|
|
dropPills();
|
|
};
|
|
|
|
|
|
}); |