mirror of
https://github.com/overte-org/overte.git
synced 2025-04-11 01:42:11 +02:00
Add more debug to tutorial, new firecrackers, and adjust fuse
This commit is contained in:
parent
ab8e5759b0
commit
e9099b77a5
7 changed files with 356 additions and 100 deletions
|
@ -31,14 +31,26 @@ function resolveHardware(path) {
|
|||
return resolveInner(Controller.Hardware, parts, 0);
|
||||
}
|
||||
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("controllerDisplay.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
createControllerDisplay = function(config) {
|
||||
var controllerDisplay = {
|
||||
overlays: [],
|
||||
partOverlays: {},
|
||||
parts: {},
|
||||
mappingName: "mapping-display",
|
||||
partOverlays: {
|
||||
},
|
||||
parts: {
|
||||
},
|
||||
mappingName: "mapping-display-" + Math.random(),
|
||||
|
||||
setVisible: function(visible) {
|
||||
debug("Setting visible", this.overlays.length);
|
||||
for (var i = 0; i < this.overlays.length; ++i) {
|
||||
Overlays.editOverlay(this.overlays[i], {
|
||||
visible: visible
|
||||
|
@ -166,7 +178,7 @@ createControllerDisplay = function(config) {
|
|||
} else if (part.type === "static") {
|
||||
// do nothing
|
||||
} else {
|
||||
print("TYPE NOT SUPPORTED: ", part.type);
|
||||
debug("TYPE NOT SUPPORTED: ", part.type);
|
||||
}
|
||||
|
||||
controllerDisplay.overlays.push(overlayID);
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
birdFirework1 = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
"created": "2016-09-13T23:05:08Z",
|
||||
"dimensions": {
|
||||
"x": 0.10120716691017151,
|
||||
"y": 0.12002291530370712,
|
||||
"z": 0.18833979964256287
|
||||
},
|
||||
fireworkURLs = [
|
||||
"atp:/tutorial_models/bomb1.fbx",
|
||||
"atp:/tutorial_models/bomb2.fbx",
|
||||
"atp:/tutorial_models/bomb3.fbx",
|
||||
"atp:/tutorial_models/bomb4.fbx",
|
||||
"atp:/tutorial_models/bomb5.fbx",
|
||||
"atp:/tutorial_models/bomb6.fbx",
|
||||
];
|
||||
|
||||
fireworkBaseProps = {
|
||||
"collisionsWillMove": 1,
|
||||
velocity: {
|
||||
x: 0,
|
||||
|
@ -20,7 +21,7 @@ birdFirework1 = {
|
|||
"z": 0
|
||||
},
|
||||
"id": "{1c4061bc-b2e7-4435-bc47-3fcc39ae6624}",
|
||||
"modelURL": "atp:/tutorial_models/birdStatue15.fbx",
|
||||
"modelURL": "atp:/tutorial_models/bomb1.fbx",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0.11612319946289062,
|
||||
|
@ -44,15 +45,8 @@ birdFirework1 = {
|
|||
"userData": "{\n \"hifiHomeKey\": {\n \"reset\": true\n }\n}"
|
||||
} ;
|
||||
|
||||
|
||||
birdFirework2 = {
|
||||
"clientOnly": 0,
|
||||
"collisionsWillMove": 1,
|
||||
"created": "2016-09-12T22:56:48Z",
|
||||
"dimensions": {
|
||||
"x": 0.098819166421890259,
|
||||
"y": 0.11143554747104645,
|
||||
"z": 0.18833979964256287
|
||||
},
|
||||
"collisionsWillMove": 1,
|
||||
velocity: {
|
||||
x: 0,
|
||||
|
@ -66,7 +60,8 @@ birdFirework2 = {
|
|||
"z": 0
|
||||
},
|
||||
"id": "{ba067084-8d0f-4eeb-a8a1-c6814527c1bb}",
|
||||
"modelURL": "atp:/tutorial_models/statuebird4.fbx",
|
||||
//"modelURL": "atp:/tutorial_models/statuebird4.fbx",
|
||||
"modelURL": "atp:/tutorial_models/bomb2.fbx",
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"x": 0,
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
(function() {
|
||||
|
||||
function debug() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("fire.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
|
||||
var _this = this;
|
||||
|
||||
function Fire() {
|
||||
|
@ -54,30 +60,45 @@
|
|||
|
||||
var colors = [RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET];
|
||||
|
||||
var firePitSoundURL = Script.resolvePath("fire_burst.wav");
|
||||
debug("Firepit burst sound url is: ", firePitSoundURL);
|
||||
|
||||
var explodeTextureURL = Script.resolvePath("explode.png");
|
||||
debug("Firepit explode texture url is: ", explodeTextureURL);
|
||||
|
||||
Fire.prototype = {
|
||||
preload: function(entityID) {
|
||||
debug("Preload");
|
||||
this.entityID = entityID;
|
||||
this.EXPLOSION_SOUND = SoundCache.getSound("atp:/firepit/fire_burst.wav");
|
||||
this.EXPLOSION_SOUND = SoundCache.getSound(firePitSoundURL);
|
||||
},
|
||||
collisionWithEntity: function(myID, otherID, collisionInfo) {
|
||||
debug("Collided with entity: ", myID, otherID);
|
||||
var otherProps = Entities.getEntityProperties(otherID);
|
||||
var data = null;
|
||||
try {
|
||||
data = JSON.parse(otherProps.userData)
|
||||
data = JSON.parse(otherProps.userData);
|
||||
} catch (err) {
|
||||
print('ERROR GETTING USERDATA!');
|
||||
debug('ERROR GETTING USERDATA!');
|
||||
}
|
||||
if (data === null || "") {
|
||||
debug("Data is null or empty", data);
|
||||
return;
|
||||
} else {
|
||||
debug("Got data", data);
|
||||
if (data.hasOwnProperty('hifiHomeKey')) {
|
||||
debug("Has hifiHomeKey");
|
||||
if (data.hifiHomeKey.reset === true) {
|
||||
debug("Reset is true");
|
||||
_this.playSoundAtCurrentPosition();
|
||||
_this.explodeWithColor();
|
||||
Entities.deleteEntity(otherID)
|
||||
debug("Sending local message");
|
||||
Messages.sendLocalMessage('Entity-Exploded', JSON.stringify({
|
||||
entityID: otherID,
|
||||
position: Entities.getEntityProperties(this.entityID).position
|
||||
}));
|
||||
debug("Done sending local message");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +158,7 @@
|
|||
"alphaStart": -0.2,
|
||||
"alphaFinish": 0.5,
|
||||
"emitterShouldTrail": 0,
|
||||
"textures": "atp:/firepit/explode.png",
|
||||
"textures": explodeTextureURL,
|
||||
"type": "ParticleEffect",
|
||||
lifetime: 1,
|
||||
position: myProps.position
|
||||
|
|
|
@ -14,10 +14,14 @@
|
|||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(self, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("fuse.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
var active = false;
|
||||
|
||||
var fuseSound = SoundCache.getSound("atp:/tutorial_sounds/fuse.wav");
|
||||
function getChildProperties(entityID, propertyNames) {
|
||||
var childEntityIDs = Entities.getChildrenIDs(entityID);
|
||||
|
@ -33,12 +37,20 @@
|
|||
};
|
||||
Fuse.prototype = {
|
||||
light: function() {
|
||||
debug("LIT", this.entityID);
|
||||
var anim = Entities.getEntityProperties(this.entityID, ['animation']).animation;
|
||||
debug("Received light()", this.entityID);
|
||||
|
||||
if (anim.currentFrame < 140) {
|
||||
var visible = Entities.getEntityProperties(this.entityID, ['visible']).visible;
|
||||
if (!visible) {
|
||||
debug("Fuse is not visible, returning");
|
||||
return;
|
||||
}
|
||||
|
||||
if (active) {
|
||||
debug("Fuse is active, returning");
|
||||
return;
|
||||
}
|
||||
active = true;
|
||||
|
||||
Entities.editEntity(this.entityID, {
|
||||
animation: {
|
||||
currentFrame: 1,
|
||||
|
@ -56,6 +68,7 @@
|
|||
|
||||
var childrenProps = getChildProperties(this.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
debug("Updating: ", childEntityID);
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
Entities.editEntity(childEntityID, {
|
||||
|
@ -70,13 +83,15 @@
|
|||
|
||||
var self = this;
|
||||
Script.setTimeout(function() {
|
||||
debug("BLOW UP");
|
||||
var spinnerID = Utils.findEntity({ name: "tutorial/equip/spinner" }, 20);
|
||||
debug("Setting off fireworks");
|
||||
//var spinnerID = Utils.findEntity({ name: "tutorial/equip/spinner" }, 20);
|
||||
var spinnerID = "{dd13fcd5-616f-4749-ab28-2e1e8bc512e9}";
|
||||
Entities.callEntityMethod(spinnerID, "onLit");
|
||||
injector.stop();
|
||||
|
||||
var childrenProps = getChildProperties(self.entityID, ['type']);
|
||||
for (var childEntityID in childrenProps) {
|
||||
debug("Updating: ", childEntityID);
|
||||
var props = childrenProps[childEntityID];
|
||||
if (props.type == "ParticleEffect") {
|
||||
Entities.editEntity(childEntityID, {
|
||||
|
@ -90,8 +105,14 @@
|
|||
}
|
||||
|
||||
}, 4900);
|
||||
|
||||
Script.setTimeout(function() {
|
||||
debug("Setting fuse to inactive");
|
||||
active = false;
|
||||
}, 10000);
|
||||
},
|
||||
preload: function(entityID) {
|
||||
debug("Preload");
|
||||
this.entityID = entityID;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
};
|
||||
Fuse.prototype = {
|
||||
onLit: function() {
|
||||
print("LIT", this.entityID);
|
||||
var fuseID = Utils.findEntity({ name: "tutorial/equip/fuse" }, 20);
|
||||
print("fuseCollider.js | Lit", this.entityID);
|
||||
//var fuseID = Utils.findEntity({ name: "tutorial/equip/fuse" }, 20);
|
||||
var fuseID = "{c8944a13-9acb-4d77-b1ee-851845e98357}"
|
||||
Entities.callEntityMethod(fuseID, "light");
|
||||
},
|
||||
preload: function(entityID) {
|
||||
|
|
|
@ -32,7 +32,7 @@ if (!Function.prototype.bind) {
|
|||
|
||||
if (this.prototype) {
|
||||
// Function.prototype doesn't have a prototype property
|
||||
fNOP.prototype = this.prototype;
|
||||
fNOP.prototype = this.prototype;
|
||||
}
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
|
@ -40,26 +40,36 @@ if (!Function.prototype.bind) {
|
|||
};
|
||||
}
|
||||
|
||||
var DEBUG = false;
|
||||
var DEBUG = true;
|
||||
function debug() {
|
||||
if (DEBUG) {
|
||||
print.apply(this, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("tutorial.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
var INFO = true;
|
||||
function info() {
|
||||
if (INFO) {
|
||||
print.apply(this, arguments);
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift("tutorial.js | ");
|
||||
print.apply(this, args);
|
||||
}
|
||||
}
|
||||
|
||||
// Return a number between min (inclusive) and max (exclusive)
|
||||
function randomInt(min, max) {
|
||||
return min + Math.floor(Math.random() * (max - min))
|
||||
}
|
||||
|
||||
var NEAR_BOX_SPAWN_NAME = "tutorial/nearGrab/box_spawn";
|
||||
var FAR_BOX_SPAWN_NAME = "tutorial/farGrab/box_spawn";
|
||||
var GUN_SPAWN_NAME = "tutorial/gun_spawn";
|
||||
var TELEPORT_PAD_NAME = "tutorial/teleport/pad"
|
||||
|
||||
var successSound = SoundCache.getSound("atp:/tutorial_sounds/good_one.L.wav");
|
||||
var firecrackerSound = SoundCache.getSound("atp:/tutorial_sounds/Pops_Firecracker.wav");
|
||||
|
||||
|
||||
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||
|
@ -205,7 +215,7 @@ function findEntitiesWithTag(tag) {
|
|||
return findEntities({ userData: "" }, 10000, function(properties, key, value) {
|
||||
data = parseJSON(value);
|
||||
return data.tag == tag;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// From http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type
|
||||
|
@ -222,6 +232,15 @@ function playSuccessSound() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function playFirecrackerSound(position) {
|
||||
Audio.playSound(firecrackerSound, {
|
||||
position: position,
|
||||
volume: 0.7,
|
||||
loop: false
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
|
@ -340,13 +359,11 @@ stepOrient.prototype = {
|
|||
var tag = this.tag;
|
||||
|
||||
// Spawn content set
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
debug("Orient: Checking for hands above head...");
|
||||
debug("Orient | Checking for hands above head");
|
||||
if (MyAvatar.getLeftPalmPosition().y > (MyAvatar.getHeadPosition().y + 0.1)) {
|
||||
Script.clearInterval(this.checkIntervalID);
|
||||
this.checkIntervalID = null;
|
||||
|
@ -359,6 +376,7 @@ stepOrient.prototype = {
|
|||
this.checkIntervalID = Script.setInterval(checkForHandsAboveHead.bind(this), 500);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Orient | Cleanup");
|
||||
if (this.active) {
|
||||
this.active = false;
|
||||
}
|
||||
|
@ -394,13 +412,12 @@ stepRaiseAboveHead.prototype = {
|
|||
var STATE_HANDS_UP = 2;
|
||||
this.state = STATE_START;
|
||||
|
||||
debug("raise hands...", this.tag);
|
||||
editEntitiesWithTag(this.tag, { visible: true });
|
||||
|
||||
// Wait 2 seconds before starting to check for hands
|
||||
this.checkIntervalID = null;
|
||||
function checkForHandsAboveHead() {
|
||||
debug("Raise above head: Checking hands...");
|
||||
debug("RaiseAboveHead | Checking hands");
|
||||
if (this.state == STATE_START) {
|
||||
if (MyAvatar.getLeftPalmPosition().y < (MyAvatar.getHeadPosition().y - 0.1)) {
|
||||
this.state = STATE_HANDS_DOWN;
|
||||
|
@ -418,6 +435,7 @@ stepRaiseAboveHead.prototype = {
|
|||
this.checkIntervalID = Script.setInterval(checkForHandsAboveHead.bind(this), 500);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("RaiseAboveHead | Cleanup");
|
||||
if (this.checkIntervalID) {
|
||||
Script.clearInterval(this.checkIntervalID);
|
||||
this.checkIntervalID = null
|
||||
|
@ -459,22 +477,18 @@ stepNearGrab.prototype = {
|
|||
showEntitiesWithTag(this.tag, { visible: true });
|
||||
showEntitiesWithTag('bothGrab', { visible: true });
|
||||
|
||||
var boxSpawnID = findEntity({ name: NEAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
function createBlock() {
|
||||
//Step1BlockData.position = boxSpawnPosition;
|
||||
birdFirework1.position = boxSpawnPosition;
|
||||
return spawnWithTag([birdFirework1], null, this.tempTag)[0];
|
||||
var boxSpawnPosition = getEntityWithName(NEAR_BOX_SPAWN_NAME).position;
|
||||
function createBlock(fireworkNumber) {
|
||||
fireworkBaseProps.position = boxSpawnPosition;
|
||||
fireworkBaseProps.modelURL = fireworkURLs[fireworkNumber % fireworkURLs.length];
|
||||
debug("Creating firework with url: ", fireworkBaseProps.modelURL);
|
||||
return spawnWithTag([fireworkBaseProps], null, this.tempTag)[0];
|
||||
}
|
||||
|
||||
this.birdIDs = [];
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)(0));
|
||||
this.birdIDs.push(createBlock.bind(this)(1));
|
||||
this.birdIDs.push(createBlock.bind(this)(2));
|
||||
this.positionWatcher = new PositionWatcher(this.birdIDs, boxSpawnPosition, -0.4, 4);
|
||||
},
|
||||
onMessage: function(channel, message, seneder) {
|
||||
|
@ -482,10 +496,12 @@ stepNearGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
debug("NearGrab | Got entity-exploded message: ", message);
|
||||
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
debug("NearGrab | It's one of the firecrackers");
|
||||
playFirecrackerSound(data.position);
|
||||
playSuccessSound();
|
||||
this.finished = true;
|
||||
this.onFinish();
|
||||
|
@ -493,7 +509,7 @@ stepNearGrab.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("cleaning up near grab");
|
||||
debug("NearGrab | Cleanup");
|
||||
this.finished = true;
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
@ -540,21 +556,18 @@ stepFarGrab.prototype = {
|
|||
// Spawn content set
|
||||
showEntitiesWithTag(this.tag);
|
||||
|
||||
var boxSpawnID = findEntity({ name: FAR_BOX_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
debug("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
var boxSpawnPosition = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
function createBlock() {
|
||||
birdFirework1.position = boxSpawnPosition;
|
||||
return spawnWithTag([birdFirework1], null, this.tempTag)[0];
|
||||
var boxSpawnPosition = getEntityWithName(FAR_BOX_SPAWN_NAME).position;
|
||||
function createBlock(fireworkNumber) {
|
||||
fireworkBaseProps.position = boxSpawnPosition;
|
||||
fireworkBaseProps.modelURL = fireworkURLs[fireworkNumber % fireworkURLs.length];
|
||||
debug("Creating firework with url: ", fireworkBaseProps.modelURL);
|
||||
return spawnWithTag([fireworkBaseProps], null, this.tempTag)[0];
|
||||
}
|
||||
|
||||
this.birdIDs = [];
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)());
|
||||
this.birdIDs.push(createBlock.bind(this)(3));
|
||||
this.birdIDs.push(createBlock.bind(this)(4));
|
||||
this.birdIDs.push(createBlock.bind(this)(5));
|
||||
this.positionWatcher = new PositionWatcher(this.birdIDs, boxSpawnPosition, -0.4, 4);
|
||||
},
|
||||
onMessage: function(channel, message, seneder) {
|
||||
|
@ -562,9 +575,11 @@ stepFarGrab.prototype = {
|
|||
return;
|
||||
}
|
||||
if (channel == "Entity-Exploded") {
|
||||
debug("TUTORIAL: Got entity-exploded message");
|
||||
debug("FarGrab | Got entity-exploded message: ", message);
|
||||
var data = parseJSON(message);
|
||||
if (this.birdIDs.indexOf(data.entityID) >= 0) {
|
||||
debug("FarGrab | It's one of the firecrackers");
|
||||
playFirecrackerSound(data.position);
|
||||
playSuccessSound();
|
||||
this.finished = true;
|
||||
this.onFinish();
|
||||
|
@ -572,6 +587,7 @@ stepFarGrab.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("FarGrab | Cleanup");
|
||||
this.finished = true;
|
||||
setControllerVisible("trigger", false);
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
@ -586,12 +602,13 @@ stepFarGrab.prototype = {
|
|||
};
|
||||
|
||||
function PositionWatcher(entityIDs, originalPosition, minY, maxDistance) {
|
||||
debug("Creating position watcher");
|
||||
this.watcherIntervalID = Script.setInterval(function() {
|
||||
for (var i = 0; i < entityIDs.length; ++i) {
|
||||
var entityID = entityIDs[i];
|
||||
var props = Entities.getEntityProperties(entityID, ['position']);
|
||||
if (props.position.y < minY || Vec3.distance(originalPosition, props.position) > maxDistance) {
|
||||
Entities.editEntity(entityID, {
|
||||
Entities.editEntity(entityID, {
|
||||
position: originalPosition,
|
||||
velocity: { x: 0, y: -0.01, z: 0 },
|
||||
angularVelocity: { x: 0, y: 0, z: 0 }
|
||||
|
@ -603,6 +620,7 @@ function PositionWatcher(entityIDs, originalPosition, minY, maxDistance) {
|
|||
|
||||
PositionWatcher.prototype = {
|
||||
destroy: function() {
|
||||
debug("Destroying position watcher");
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
}
|
||||
};
|
||||
|
@ -644,40 +662,47 @@ stepEquip.prototype = {
|
|||
|
||||
this.currentPart = this.PART1;
|
||||
|
||||
function createGun() {
|
||||
var boxSpawnID = findEntity({ name: GUN_SPAWN_NAME }, 10000);
|
||||
if (!boxSpawnID) {
|
||||
info("Error creating block, cannot find spawn");
|
||||
return null;
|
||||
}
|
||||
function createLighter() {
|
||||
//var boxSpawnID = findEntity({ name: GUN_SPAWN_NAME }, 10000);
|
||||
//if (!boxSpawnID) {
|
||||
//info("Error creating block, cannot find spawn");
|
||||
//return null;
|
||||
//}
|
||||
|
||||
var transform = {};
|
||||
|
||||
transform.position = Entities.getEntityProperties(boxSpawnID, 'position').position;
|
||||
transform.rotation = Entities.getEntityProperties(boxSpawnID, 'rotation').rotation;
|
||||
var boxSpawnProps = getEntityWithName(GUN_SPAWN_NAME);
|
||||
transform.position = boxSpawnProps.position;
|
||||
transform.rotation = boxSpawnProps.rotation;
|
||||
transform.velocity = { x: 0, y: -0.01, z: 0 };
|
||||
transform.angularVelocity = { x: 0, y: 0, z: 0 };
|
||||
this.spawnTransform = transform;
|
||||
return doCreateButaneLighter(transform).id;
|
||||
}
|
||||
|
||||
|
||||
this.gunID = createGun.bind(this)();
|
||||
this.startWatchingGun();
|
||||
debug("Created", this.gunID);
|
||||
this.lighterID = createLighter.bind(this)();
|
||||
this.startWatchingLighter();
|
||||
debug("Created lighter", this.lighterID);
|
||||
this.onFinish = onFinish;
|
||||
},
|
||||
startWatchingGun: function() {
|
||||
startWatchingLighter: function() {
|
||||
if (!this.watcherIntervalID) {
|
||||
debug("Starting to watch lighter position");
|
||||
this.watcherIntervalID = Script.setInterval(function() {
|
||||
var props = Entities.getEntityProperties(this.gunID, ['position']);
|
||||
if (props.position.y < -0.4
|
||||
debug("Checking lighter position");
|
||||
var props = Entities.getEntityProperties(this.lighterID, ['position']);
|
||||
if (props.position.y < -0.4
|
||||
|| Vec3.distance(this.spawnTransform.position, props.position) > 4) {
|
||||
Entities.editEntity(this.gunID, this.spawnTransform);
|
||||
debug("Moving lighter back to table");
|
||||
Entities.editEntity(this.lighterID, this.spawnTransform);
|
||||
}
|
||||
}.bind(this), 1000);
|
||||
}
|
||||
},
|
||||
stopWatchingGun: function() {
|
||||
if (this.watcherIntervalID) {
|
||||
debug("Stopping watch of lighter position");
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
this.watcherIntervalID = null;
|
||||
}
|
||||
|
@ -687,24 +712,27 @@ stepEquip.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
debug("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
debug("Equip | Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||
|
||||
if (channel == "Tutorial-Spinner") {
|
||||
if (this.currentPart == this.PART1 && message == "wasLit") {
|
||||
this.currentPart = this.PART2;
|
||||
debug("Equip | Starting part 2");
|
||||
Script.setTimeout(function() {
|
||||
debug("Equip | Starting part 3");
|
||||
this.currentPart = this.PART3;
|
||||
hideEntitiesWithTag(this.tagPart1);
|
||||
showEntitiesWithTag(this.tagPart2);
|
||||
setControllerPartLayer('tips', 'grip');
|
||||
Messages.subscribe('Hifi-Object-Manipulation');
|
||||
debug("Equip | Finished starting part 3");
|
||||
}.bind(this), 9000);
|
||||
}
|
||||
} else if (channel == "Hifi-Object-Manipulation") {
|
||||
if (this.currentPart == this.PART3) {
|
||||
var data = parseJSON(message);
|
||||
if (data.action == 'release' && data.grabbedEntity == this.gunID) {
|
||||
info("got release");
|
||||
if (data.action == 'release' && data.grabbedEntity == this.lighterID) {
|
||||
debug("Equip | Got release, finishing step");
|
||||
this.stopWatchingGun();
|
||||
this.currentPart = this.COMPLETE;
|
||||
playSuccessSound();
|
||||
|
@ -714,6 +742,7 @@ stepEquip.prototype = {
|
|||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Equip | Got yaw action");
|
||||
if (this.watcherIntervalID) {
|
||||
Script.clearInterval(this.watcherIntervalID);
|
||||
this.watcherIntervalID = null;
|
||||
|
@ -764,6 +793,7 @@ stepTurnAround.prototype = {
|
|||
Controller.actionEvent.connect(this.onActionBound);
|
||||
|
||||
this.interval = Script.setInterval(function() {
|
||||
debug("TurnAround | Checking if finished", this.numTimesTurnPressed);
|
||||
var FORWARD_THRESHOLD = 30;
|
||||
var REQ_NUM_TIMES_PRESSED = 6;
|
||||
|
||||
|
@ -782,10 +812,12 @@ stepTurnAround.prototype = {
|
|||
onAction: function(action, value) {
|
||||
var STEP_YAW_ACTION = 6;
|
||||
if (action == STEP_YAW_ACTION && value != 0) {
|
||||
debug("TurnAround | Got yaw action");
|
||||
this.numTimesTurnPressed += 1;
|
||||
}
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("TurnAround | Cleanup");
|
||||
try {
|
||||
Controller.actionEvent.disconnect(this.onActionBound);
|
||||
} catch (e) {
|
||||
|
@ -826,22 +858,23 @@ stepTeleport.prototype = {
|
|||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'none');
|
||||
|
||||
// Wait until touching teleport pad...
|
||||
var padID = findEntity({ name: TELEPORT_PAD_NAME }, 100);
|
||||
var padProps = Entities.getEntityProperties(padID, ["position", "dimensions"]);
|
||||
//var padID = findEntity({ name: TELEPORT_PAD_NAME }, 100);
|
||||
//var padProps = Entities.getEntityProperties(padID, ["position", "dimensions"]);
|
||||
var padProps = getEntityWithName(TELEPORT_PAD_NAME);
|
||||
var xMin = padProps.position.x - padProps.dimensions.x / 2;
|
||||
var xMax = padProps.position.x + padProps.dimensions.x / 2;
|
||||
var zMin = padProps.position.z - padProps.dimensions.z / 2;
|
||||
var zMax = padProps.position.z + padProps.dimensions.z / 2;
|
||||
function checkCollides() {
|
||||
debug("Checking if on pad...");
|
||||
debug("Teleport | Checking if on pad...");
|
||||
|
||||
var pos = MyAvatar.position;
|
||||
|
||||
debug('x', pos.x, xMin, xMax);
|
||||
debug('z', pos.z, zMin, zMax);
|
||||
debug('Teleport | x', pos.x, xMin, xMax);
|
||||
debug('Teleport | z', pos.z, zMin, zMax);
|
||||
|
||||
if (pos.x > xMin && pos.x < xMax && pos.z > zMin && pos.z < zMax) {
|
||||
debug("On teleport pad");
|
||||
debug("Teleport | On teleport pad");
|
||||
Script.clearInterval(this.checkCollidesTimer);
|
||||
this.checkCollidesTimer = null;
|
||||
playSuccessSound();
|
||||
|
@ -853,6 +886,7 @@ stepTeleport.prototype = {
|
|||
showEntitiesWithTag(this.tag);
|
||||
},
|
||||
cleanup: function() {
|
||||
debug("Teleport | Cleanup");
|
||||
setControllerPartLayer('touchpad', 'blank');
|
||||
setControllerPartLayer('tips', 'blank');
|
||||
|
||||
|
@ -982,6 +1016,13 @@ function hideEntitiesWithTag(tag) {
|
|||
});
|
||||
}
|
||||
|
||||
// Return the entity properties for an entity with a given name if it is in our
|
||||
// cached list of entities. Otherwise, return undefined.
|
||||
function getEntityWithName(name) {
|
||||
debug("Getting entity with name:", name);
|
||||
return TUTORIAL_NAME_TO_ENTITY_PROPERTIES_MAP[name];
|
||||
}
|
||||
|
||||
|
||||
TutorialManager = function() {
|
||||
var STEPS;
|
||||
|
@ -1000,7 +1041,7 @@ TutorialManager = function() {
|
|||
STEPS = [
|
||||
new stepDisableControllers("step0"),
|
||||
new stepOrient("orient"),
|
||||
new stepRaiseAboveHead("raiseHands"),
|
||||
//new stepRaiseAboveHead("raiseHands"),
|
||||
new stepNearGrab("nearGrab"),
|
||||
new stepFarGrab("farGrab"),
|
||||
new stepEquip("equip"),
|
||||
|
@ -1017,6 +1058,7 @@ TutorialManager = function() {
|
|||
}
|
||||
|
||||
this.onFinish = function() {
|
||||
debug("onFinish", currentStepNum);
|
||||
if (currentStep && currentStep.shouldLog !== false) {
|
||||
var timeToFinishStep = (Date.now() - startedLastStepAt) / 1000;
|
||||
var tutorialTimeElapsed = (Date.now() - startedTutorialAt) / 1000;
|
||||
|
|
|
@ -148,4 +148,168 @@ TUTORIAL_TAG_TO_ENTITY_IDS_MAP = {
|
|||
"tag": "orient"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TUTORIAL_NAME_TO_ENTITY_PROPERTIES_MAP = {
|
||||
"tutorial/gun_spawn": {
|
||||
"userData": "{\"tag\":\"equip\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.0649842768907547,
|
||||
"x": 0.0649842768907547,
|
||||
"z": 0.0649842768907547
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 0,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.6283726096153259,
|
||||
"x": 0.6865367293357849,
|
||||
"scale": 0.11255607008934021,
|
||||
"z": 0.3359576463699341
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"y": 0.6846506595611572,
|
||||
"x": 0.7428147792816162,
|
||||
"z": 0.3922356963157654
|
||||
},
|
||||
"rotation": {
|
||||
"y": 0.7066605091094971,
|
||||
"x": 0.7066605091094971,
|
||||
"z": -0.025131583213806152,
|
||||
"w": -0.025101065635681152
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{9df518da-9e65-4b76-8a79-eeefdb0b7310}",
|
||||
"name": "tutorial/gun_spawn"
|
||||
},
|
||||
"tutorial/nearGrab/box_spawn": {
|
||||
"userData": "{\"tag\":\"nearGrab\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.08225371688604355,
|
||||
"x": 0.08225371688604355,
|
||||
"z": 0.08225371688604355
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.738319456577301,
|
||||
"x": 0.8985498547554016,
|
||||
"scale": 0.14246761798858643,
|
||||
"z": 0.29067665338516235
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
"y": 0.8095532655715942,
|
||||
"x": 0.9697836637496948,
|
||||
"z": 0.36191046237945557
|
||||
},
|
||||
"rotation": {
|
||||
"y": -1.52587890625e-05,
|
||||
"x": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05,
|
||||
"w": 1
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{5cf22b9c-fb22-4854-8821-554422980b24}",
|
||||
"name": "tutorial/nearGrab/box_spawn"
|
||||
},
|
||||
"tutorial/farGrab/box_spawn": {
|
||||
"userData": "{\"tag\":\"farGrab\",\"visible\":false}",
|
||||
"dimensions": {
|
||||
"y": 0.37358683347702026,
|
||||
"x": 0.37358683347702026,
|
||||
"z": 0.37358683347702026
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"color": {
|
||||
"blue": 255,
|
||||
"green": 0,
|
||||
"red": 255
|
||||
},
|
||||
"queryAACube": {
|
||||
"y": 0.3304251432418823,
|
||||
"x": 3.0951309204101562,
|
||||
"scale": 0.647071361541748,
|
||||
"z": 0.18027013540267944
|
||||
},
|
||||
"visible": 0,
|
||||
"shape": "Cube",
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"position": {
|
||||
x: 3.4866,
|
||||
y: 0.6716,
|
||||
z: 0.4789
|
||||
},
|
||||
"rotation": {
|
||||
"y": -1.52587890625e-05,
|
||||
"x": -1.52587890625e-05,
|
||||
"z": -1.52587890625e-05,
|
||||
"w": 1
|
||||
},
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Box",
|
||||
"id": "{70fcd96c-cd59-4f23-9ca5-a167f2f85680}",
|
||||
"name": "tutorial/farGrab/box_spawn"
|
||||
},
|
||||
"tutorial/teleport/pad": {
|
||||
"userData": "{\"tag\":\"teleport\"}",
|
||||
"rotation": {
|
||||
"y": -0.9702650308609009,
|
||||
"x": -2.1246911273919977e-05,
|
||||
"z": -4.222852112434339e-06,
|
||||
"w": 0.2420452982187271
|
||||
},
|
||||
"dimensions": {
|
||||
"y": 0.4365682601928711,
|
||||
"x": 2.1751723289489746,
|
||||
"z": 2.175173044204712
|
||||
},
|
||||
"collisionless": 1,
|
||||
"created": "2016-09-08T18:38:24Z",
|
||||
"queryAACube": {
|
||||
"y": -1.7979401350021362,
|
||||
"x": 7.5136213302612305,
|
||||
"scale": 3.106983184814453,
|
||||
"z": -1.4602710008621216
|
||||
},
|
||||
"visible": 0,
|
||||
"angularVelocity": {
|
||||
"y": -0.5235987901687622,
|
||||
"x": 0,
|
||||
"z": 0
|
||||
},
|
||||
"clientOnly": 0,
|
||||
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
|
||||
"angularDamping": 0,
|
||||
"position": {
|
||||
"y": -0.2444484978914261,
|
||||
"x": 9.067112922668457,
|
||||
"z": 0.09322060644626617
|
||||
},
|
||||
"modelURL": "atp:/alan/dev/Teleport-Pad.fbx",
|
||||
"ignoreForCollisions": 1,
|
||||
"type": "Model",
|
||||
"id": "{4478f7b5-d3ac-4213-9a7b-ad8cd69575b8}",
|
||||
"name": "tutorial/teleport/pad"
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue