1046 lines
45 KiB
JavaScript
1046 lines
45 KiB
JavaScript
//
|
|
// stageManager.js
|
|
//
|
|
// Created by Rebecca Stankus on 06/11/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 TABLET_BUTTON_IMAGE = Script.resolvePath('svg/dnd-i.svg');
|
|
var TABLET_BUTTON_PRESSED = Script.resolvePath('svg/dnd-a.svg');
|
|
var MAGIC_MISSILE_SOUND = SoundCache.getSound(Script.resolvePath("sounds/magicMissile.mp3"));
|
|
var FIREWATER_SOUND = SoundCache.getSound(Script.resolvePath("sounds/fireWater.mp3"));
|
|
var MENDING_SOUND = SoundCache.getSound(Script.resolvePath("sounds/mending.mp3"));
|
|
var SHIELD_SOUND = SoundCache.getSound(Script.resolvePath("sounds/shield.mp3"));
|
|
var LIGHT_SOUND = SoundCache.getSound(Script.resolvePath("sounds/light.mp3"));
|
|
var PROTECTION_FROM_EVIL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/protectionFromEvil.mp3"));
|
|
var DETECT_MAGIC_SOUND = SoundCache.getSound(Script.resolvePath("sounds/detectMagic.mp3"));
|
|
var SLEEP_SOUND = SoundCache.getSound(Script.resolvePath("sounds/sleep.mp3"));
|
|
var IDENTIFY_SOUND = SoundCache.getSound(Script.resolvePath("sounds/identify.mp3"));
|
|
var CHARM_PERSON_SOUND = SoundCache.getSound(Script.resolvePath("sounds/charmPerson.mp3"));
|
|
var FEATHER_FALL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/featherFall.mp3"));
|
|
var INVISIBILITY_SOUND = SoundCache.getSound(Script.resolvePath("sounds/invisibility.mp3?001"));
|
|
var PRESERVE_SOUND = SoundCache.getSound(Script.resolvePath("sounds/preserve.mp3"));
|
|
var LEVITATE_SOUND = SoundCache.getSound(Script.resolvePath("sounds/levitate.mp3"));
|
|
var MIRROR_IMAGE_SOUND = SoundCache.getSound(Script.resolvePath("sounds/mirrorImage.mp3"));
|
|
var STRENGTH_SOUND = SoundCache.getSound(Script.resolvePath("sounds/strength.mp3"));
|
|
var DARKNESS_SOUND = SoundCache.getSound(Script.resolvePath("sounds/darkness.mp3"));
|
|
var DETECT_EVIL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/detectEvil.mp3"));
|
|
var LOCATE_OBJECT_SOUND = SoundCache.getSound(Script.resolvePath("sounds/locateObject.mp3"));
|
|
var ZEPHYR_SOUND = SoundCache.getSound(Script.resolvePath("sounds/zephyr.mp3"));
|
|
var WEB_SOUND = SoundCache.getSound(Script.resolvePath("sounds/web.mp3"));
|
|
var SHATTER_SOUND = SoundCache.getSound(Script.resolvePath("sounds/shatter.mp3"));
|
|
var FIREBALL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/fireball.mp3"));
|
|
var FLY_SOUND = SoundCache.getSound(Script.resolvePath("sounds/fly.mp3"));
|
|
var LIGHTNING_BOLT_SOUND = SoundCache.getSound(Script.resolvePath("sounds/lightningBolt.mp3?000"));
|
|
var HOLD_PERSON_SOUND = SoundCache.getSound(Script.resolvePath("sounds/holdPerson.mp3"));
|
|
var WIND_WALL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/windWall.mp3?000"));
|
|
var CLAIRVOYANCE_SOUND = SoundCache.getSound(Script.resolvePath("sounds/clairvoyance.mp3"));
|
|
var MONSTER_SUMMONING_I_SOUND = SoundCache.getSound(Script.resolvePath("sounds/monsterSummoningI.mp3"));
|
|
var PROTECTION_FROM_EVIL_3_SOUND = SoundCache.getSound(Script.resolvePath("sounds/protectionFromEvil3.mp3"));
|
|
var SEPIA_SNAKE_SIGIL_SOUND = SoundCache.getSound(Script.resolvePath("sounds/sepiaSnakeSigil.mp3"));
|
|
var WATER_BREATHING_SOUND = SoundCache.getSound(Script.resolvePath("sounds/waterBreathing.mp3"));
|
|
var FLAME_ARROW_SOUND = SoundCache.getSound(Script.resolvePath("sounds/flameArrow.mp3"));
|
|
|
|
var audioVolume = 0.7;
|
|
var tablet = Tablet.getTablet('com.highfidelity.interface.tablet.system');
|
|
var appPage = Script.resolvePath('dnd.html?007');
|
|
var button = tablet.addButton({
|
|
text: 'D&D MAGIC',
|
|
icon: TABLET_BUTTON_IMAGE,
|
|
activeIcon: TABLET_BUTTON_PRESSED
|
|
});
|
|
var open = false;
|
|
var injector;
|
|
|
|
function onClicked() {
|
|
if (open) {
|
|
tablet.gotoHomeScreen();
|
|
} else {
|
|
tablet.gotoWebScreen(appPage);
|
|
}
|
|
}
|
|
|
|
function getPosition() {
|
|
var direction = Quat.getFront(MyAvatar.orientation);
|
|
var distance = 0.5;
|
|
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance));
|
|
position.y += 0.4;
|
|
return position;
|
|
}
|
|
|
|
function onWebEventReceived(event) {
|
|
event = JSON.parse(event);
|
|
if (event.app === 'DnDMagic') {
|
|
switch (event.type) {
|
|
case 'magicMissile':
|
|
var animationURL = Script.resolvePath("animations/SpellKarateStyle.fbx");
|
|
var animation = AnimationCache.getAnimation(animationURL);
|
|
MyAvatar.overrideAnimation(animationURL, 30, false, 0, animation.frames.length);
|
|
playSound(MAGIC_MISSILE_SOUND, 0.6);
|
|
var particles = [];
|
|
particles[0] = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 3,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures: Script.resolvePath("images/lightning.jpg"),
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
MyAvatar.restoreAnimation();
|
|
particles.forEach(function(missile) {
|
|
Entities.editEntity(missile, { emitRate: 0 });
|
|
});
|
|
}, animation.frames.length/30*1000);
|
|
break;
|
|
case 'fireWater':
|
|
print("fireWater");
|
|
animationURL = Script.resolvePath("animations/earthShakeSpell.fbx");
|
|
animation = AnimationCache.getAnimation(animationURL);
|
|
MyAvatar.overrideAnimation(animationURL, 30, false, 0, animation.frames.length/3);
|
|
playSound(FIREWATER_SOUND, 0.2);
|
|
Script.setTimeout(function() {
|
|
MyAvatar.restoreAnimation();
|
|
}, animation.frames.length/30/3*1000);
|
|
break;
|
|
case 'mending':
|
|
playSound(MENDING_SOUND, 0.1);
|
|
break;
|
|
case 'shield':
|
|
print("shield");
|
|
animationURL = Script.resolvePath("animations/spellThrowDown.fbx");
|
|
animation = AnimationCache.getAnimation(animationURL);
|
|
MyAvatar.overrideAnimation(animationURL, 30, false, 0, animation.frames.length);
|
|
playSound(SHIELD_SOUND, 0.4);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 3,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 1000);
|
|
Script.setTimeout(function() {
|
|
MyAvatar.restoreAnimation();
|
|
}, animation.frames.length/30*1000);
|
|
break;
|
|
case 'light':
|
|
print("light");
|
|
playSound(LIGHT_SOUND, 0.2);
|
|
Entities.addEntity({
|
|
type:"Light",
|
|
lifetime: 5,
|
|
dimensions:{
|
|
x:12.349760055541992,
|
|
y:12.349760055541992,
|
|
z:12.349760055541992
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:72,
|
|
blue:0
|
|
},
|
|
isSpotlight:0,
|
|
intensity:10,
|
|
falloffRadius:3,
|
|
exponent:0,
|
|
cutoff:90,
|
|
position: getPosition()
|
|
}, 'avatar');
|
|
break;
|
|
case 'protectionFromEvil':
|
|
print("protectionFromEvil");
|
|
playSound(PROTECTION_FROM_EVIL_SOUND, 0.5);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 10,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 3000);
|
|
break;
|
|
case 'detectMagic':
|
|
print("detectMagic");
|
|
playSound(DETECT_MAGIC_SOUND, 0.8);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 8,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:255,
|
|
blue:0
|
|
},
|
|
colorStart:{
|
|
red:0,
|
|
green:255,
|
|
blue:0
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 3000);
|
|
break;
|
|
case 'sleep':
|
|
animationURL = Script.resolvePath("animations/spellThrowDown.fbx");
|
|
animation = AnimationCache.getAnimation(animationURL);
|
|
MyAvatar.overrideAnimation(animationURL, 30, false, 0, animation.frames.length);
|
|
playSound(SLEEP_SOUND, 0.6);
|
|
Script.setTimeout(function() {
|
|
MyAvatar.restoreAnimation();
|
|
}, animation.frames.length/30*1000);
|
|
break;
|
|
case 'identify':
|
|
print("identify");
|
|
playSound(IDENTIFY_SOUND, 0.6);
|
|
break;
|
|
case 'charmPerson':
|
|
print("charmPerson");
|
|
playSound(CHARM_PERSON_SOUND, 1);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 3,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:255,
|
|
green:0,
|
|
blue:0
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:255,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 1000);
|
|
break;
|
|
case 'featherFall':
|
|
print("featherFall");
|
|
playSound(FEATHER_FALL_SOUND, 0.8);
|
|
break;
|
|
case 'invisibility':
|
|
print("invisibility");
|
|
playSound(INVISIBILITY_SOUND, 0.5);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 3,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 1000);
|
|
break;
|
|
case 'preserve':
|
|
print("preserve");
|
|
playSound(PRESERVE_SOUND, 0.4);
|
|
break;
|
|
case 'levitate':
|
|
print("levitate");
|
|
playSound(LEVITATE_SOUND, 0.7);
|
|
break;
|
|
case 'mirrorImage':
|
|
print("mirrorImage");
|
|
playSound(MIRROR_IMAGE_SOUND, 0.8);
|
|
break;
|
|
case 'strength':
|
|
print("strength");
|
|
playSound(STRENGTH_SOUND, 0.7);
|
|
break;
|
|
case 'darkness':
|
|
print("darkness");
|
|
playSound(DARKNESS_SOUND, 0.7);
|
|
break;
|
|
case 'detectEvil':
|
|
print("detectEvil");
|
|
playSound(DETECT_EVIL_SOUND, 0.8);
|
|
break;
|
|
case 'locateObject':
|
|
print("locateObject");
|
|
playSound(LOCATE_OBJECT_SOUND, 0.6);
|
|
break;
|
|
case 'zephyr':
|
|
print("zephyr");
|
|
playSound(ZEPHYR_SOUND, 0.6);
|
|
break;
|
|
case 'web':
|
|
print("web");
|
|
playSound(WEB_SOUND, 0.6);
|
|
break;
|
|
case 'shatter':
|
|
print("shatter");
|
|
playSound(SHATTER_SOUND, 0.6);
|
|
break;
|
|
case 'fireball':
|
|
print("fireball");
|
|
playSound(FIREBALL_SOUND, 0.7);
|
|
var particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
position:getPosition(),
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
lifetime: 8,
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:2530,
|
|
lifespan:2.869999885559082,
|
|
emitRate:212,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:0
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:0,
|
|
blue:0
|
|
},
|
|
colorFinish:{
|
|
red:255,
|
|
green:85,
|
|
blue:0
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png"
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 300);
|
|
break;
|
|
case 'fly':
|
|
print("fly");
|
|
playSound(FLY_SOUND, 0.3);
|
|
break;
|
|
case 'lightningBolt':
|
|
print("lightningBolt");
|
|
playSound(LIGHTNING_BOLT_SOUND, 0.05);
|
|
break;
|
|
case 'holdPerson':
|
|
print("holdPerson");
|
|
playSound(HOLD_PERSON_SOUND, 0.5);
|
|
break;
|
|
case 'windWall':
|
|
print("windWall");
|
|
playSound(WIND_WALL_SOUND, 0.8);
|
|
break;
|
|
case 'clairvoyance':
|
|
print("clairvoyance");
|
|
playSound(CLAIRVOYANCE_SOUND, 0.8);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 3,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 1000);
|
|
break;
|
|
case 'monsterSummoningI':
|
|
animationURL = Script.resolvePath("animations/spellThrowDown.fbx");
|
|
animation = AnimationCache.getAnimation(animationURL);
|
|
MyAvatar.overrideAnimation(animationURL, 30, false, 0, animation.frames.length);
|
|
playSound(MONSTER_SUMMONING_I_SOUND, 0.8);
|
|
Script.setTimeout(function() {
|
|
MyAvatar.restoreAnimation();
|
|
}, animation.frames.length/30*1000);
|
|
break;
|
|
case 'protectionFromEvil3':
|
|
print("protectionFromEvil3");
|
|
playSound(PROTECTION_FROM_EVIL_3_SOUND, 0.8);
|
|
particle = Entities.addEntity({
|
|
type:"ParticleEffect",
|
|
lifetime: 10,
|
|
dimensions:{
|
|
x:6.315893650054932,
|
|
y:6.315893650054932,
|
|
z:6.315893650054932
|
|
},
|
|
collisionless:0,
|
|
collisionMask:31,
|
|
collidesWith:"static,dynamic,kinematic,myAvatar,otherAvatar,",
|
|
dynamic:0,
|
|
collisionsWillMove:0,
|
|
name:"Orange/Yellow Orb",
|
|
collisionSoundURL:"",
|
|
color:{
|
|
red:255,
|
|
green:200,
|
|
blue:0
|
|
},
|
|
isEmitting:1,
|
|
maxParticles:100,
|
|
lifespan:0.5,
|
|
emitRate:100,
|
|
emitSpeed:0.0003000000142492354,
|
|
speedSpread:1,
|
|
emitOrientation:{
|
|
x:-0.7072288393974304,
|
|
y:-0.000015258539860951714,
|
|
z:-0.000015258539860951714,
|
|
w:0.7069846391677856
|
|
},
|
|
emitDimensions:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
emitRadiusStart:1,
|
|
polarStart:0,
|
|
polarFinish:3.1415998935699463,
|
|
azimuthStart:-3.1415998935699463,
|
|
azimuthFinish:3.1415998935699463,
|
|
emitAcceleration:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
accelerationSpread:{
|
|
x:0,
|
|
y:0,
|
|
z:0
|
|
},
|
|
particleRadius:0.20000000298023224,
|
|
radiusSpread:9,
|
|
radiusStart:0.20000000298023224,
|
|
radiusFinish:0.20000000298023224,
|
|
colorSpread:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
colorStart:{
|
|
red:255,
|
|
green:255,
|
|
blue:255
|
|
},
|
|
colorFinish:{
|
|
red:0,
|
|
green:0,
|
|
blue:255
|
|
},
|
|
alpha:0.10000000149011612,
|
|
alphaSpread:0,
|
|
alphaStart:0.10000000149011612,
|
|
alphaFinish:0.10000000149011612,
|
|
emitterShouldTrail:1,
|
|
shapeType:"none",
|
|
textures:"http://hifi-content.s3.amazonaws.com/alan/dev/Particles/Bokeh-Particle.png",
|
|
position:getPosition()
|
|
}, 'avatar');
|
|
Script.setTimeout(function() {
|
|
Entities.editEntity(particle, {emitRate: 0});
|
|
}, 2000);
|
|
break;
|
|
case 'sepiaSnakeSigil':
|
|
print("sepiaSnakeSigil");
|
|
playSound(SEPIA_SNAKE_SIGIL_SOUND, 0.8);
|
|
break;
|
|
case 'waterBreathing':
|
|
print("waterBreathing");
|
|
playSound(WATER_BREATHING_SOUND, 0.8);
|
|
break;
|
|
case 'flameArrow':
|
|
print("flameArrow");
|
|
playSound(FLAME_ARROW_SOUND, 0.8);
|
|
break;
|
|
default:
|
|
print("error in detecting event.type");
|
|
}
|
|
}
|
|
}
|
|
|
|
function onScreenChanged(type, url) {
|
|
open = (url === appPage);
|
|
button.editProperties({isActive: open});
|
|
}
|
|
|
|
function appEnding() {
|
|
button.clicked.disconnect(onClicked);
|
|
tablet.removeButton(button);
|
|
tablet.screenChanged.disconnect(onScreenChanged);
|
|
tablet.webEventReceived.disconnect(onWebEventReceived);
|
|
}
|
|
|
|
function playSound(sound, volume) {
|
|
if (sound.downloaded) {
|
|
if (injector) {
|
|
injector.stop();
|
|
}
|
|
injector = Audio.playSound(sound, {
|
|
position: MyAvatar.position,
|
|
volume: volume
|
|
});
|
|
}
|
|
}
|
|
|
|
button.clicked.connect(onClicked);
|
|
tablet.screenChanged.connect(onScreenChanged);
|
|
tablet.webEventReceived.connect(onWebEventReceived);
|
|
|
|
Script.scriptEnding.connect(appEnding);
|
|
}());
|