diff --git a/tutorial/tutorial.js b/tutorial/tutorial.js index 231783716f..884420c154 100644 --- a/tutorial/tutorial.js +++ b/tutorial/tutorial.js @@ -11,7 +11,7 @@ Script.include("entityData.js"); Script.include("viveHandsv2.js"); Script.include("lighter/createButaneLighter.js"); -Script.include('ownershipToken.js'); +Script.include("tutorialEntityIDs.js"); if (!Function.prototype.bind) { Function.prototype.bind = function(oThis) { @@ -57,9 +57,6 @@ function info() { var NEAR_BOX_SPAWN_NAME = "tutorial/nearGrab/box_spawn"; var FAR_BOX_SPAWN_NAME = "tutorial/farGrab/box_spawn"; -var NEAR_BASKET_COLLIDER_NAME = "tutorial/nearGrab/basket_collider"; -var FAR_BASKET_COLLIDER_NAME = "tutorial/farGrab/basket_collider"; -var GUN_BASKET_COLLIDER_NAME = "tutorial/equip/basket_collider"; var GUN_SPAWN_NAME = "tutorial/gun_spawn"; var TELEPORT_PAD_NAME = "tutorial/teleport/pad" @@ -218,19 +215,6 @@ function isFunction(functionToCheck) { return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; } - var defaultTransform = { - position: { - x: 0.2459, - y: 0.9011, - z: 0.7266 - }, - rotation: { - x: 0, - y: 0, - z: 0, - w: 1 - } - }; function playSuccessSound() { Audio.playSound(successSound, { position: MyAvatar.position, @@ -393,20 +377,6 @@ stepOrient.prototype = { var tag = this.tag; - var defaultTransform = { - position: { - x: 0.2459, - y: 0.9011, - z: 0.7266 - }, - rotation: { - x: 0, - y: 0, - z: 0, - w: 1 - } - }; - // Spawn content set debug("raise hands...", this.tag); editEntitiesWithTag(this.tag, { visible: true }); @@ -428,7 +398,6 @@ stepOrient.prototype = { }, cleanup: function() { if (this.active) { - //location = "/tutorial"; this.active = false; } if (this.overlay) { @@ -463,20 +432,6 @@ stepRaiseAboveHead.prototype = { var STATE_HANDS_UP = 2; this.state = STATE_START; - var defaultTransform = { - position: { - x: 0.2459, - y: 0.9011, - z: 0.7266 - }, - rotation: { - x: 0, - y: 0, - z: 0, - w: 1 - } - }; - debug("raise hands...", this.tag); editEntitiesWithTag(this.tag, { visible: true }); @@ -554,16 +509,11 @@ stepNearGrab.prototype = { return spawnWithTag([birdFirework1], null, this.tempTag)[0]; } - // Enabled grab - // Create table ? - // Create blocks and basket this.birdIDs = []; this.birdIDs.push(createBlock.bind(this)()); this.birdIDs.push(createBlock.bind(this)()); this.birdIDs.push(createBlock.bind(this)()); this.positionWatcher = new PositionWatcher(this.birdIDs, boxSpawnPosition, -0.4, 4); - - // If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block }, onMessage: function(channel, message, seneder) { if (this.finished) { @@ -997,6 +947,29 @@ stepCleanupFinish.prototype = { function showEntitiesWithTag(tag) { + var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag]; + if (entities) { + for (entityID in entities) { + var data = entities[entityID]; + + var collisionless = data.visible === false ? true : false; + if (data.collidable !== undefined) { + collisionless = data.collidable === true ? false : true; + } + if (data.soundKey) { + data.soundKey.playing = true; + } + var newProperties = { + visible: data.visible == false ? false : true, + collisionless: collisionless, + userData: JSON.stringify(data), + }; + Entities.editEntity(entityID, newProperties); + } + } + + // Dynamic method, suppressed for now + return; editEntitiesWithTag(tag, function(entityID) { var userData = Entities.getEntityProperties(entityID, "userData").userData; var data = parseJSON(userData); @@ -1005,7 +978,6 @@ function showEntitiesWithTag(tag) { collisionless = data.collidable === true ? false : true; } if (data.soundKey) { - debug("Setting sound key to true"); data.soundKey.playing = true; } var newProperties = { @@ -1017,6 +989,26 @@ function showEntitiesWithTag(tag) { }); } function hideEntitiesWithTag(tag) { + var entities = TUTORIAL_TAG_TO_ENTITY_IDS_MAP[tag]; + if (entities) { + for (entityID in entities) { + var data = entities[entityID]; + + if (data.soundKey) { + data.soundKey.playing = false; + } + var newProperties = { + visible: false, + collisionless: 1, + ignoreForCollisions: 1, + userData: JSON.stringify(data), + }; + Entities.editEntity(entityID, newProperties); + } + } + + // Dynamic method, suppressed for now + return; editEntitiesWithTag(tag, function(entityID) { var userData = Entities.getEntityProperties(entityID, "userData").userData; var data = parseJSON(userData); @@ -1049,10 +1041,8 @@ TutorialManager = function() { currentStep = null; startedTutorialAt = Date.now(); STEPS = [ - //new stepCleanupFinish("finish"); new stepDisableControllers("step0"), new stepOrient("orient"), - //new stepWelcome("welcome"), new stepRaiseAboveHead("raiseHands"), new stepNearGrab("nearGrab"), new stepFarGrab("farGrab"), @@ -1101,6 +1091,7 @@ TutorialManager = function() { return true; } }.bind(this); + this.restartStep = function() { if (currentStep) { currentStep.cleanup(); diff --git a/tutorial/tutorialEntityIDs.js b/tutorial/tutorialEntityIDs.js new file mode 100644 index 0000000000..38bd06e5ff --- /dev/null +++ b/tutorial/tutorialEntityIDs.js @@ -0,0 +1,151 @@ +TUTORIAL_TAG_TO_ENTITY_IDS_MAP = { + "teleport": { + "{ff064b9e-7fa4-4693-a386-a67b9f92a948}": { + "tag": "teleport" + }, + "{4478f7b5-d3ac-4213-9a7b-ad8cd69575b8}": { + "tag": "teleport" + } + }, + "finish": { + "{340e05b5-88df-4b2b-b43c-756dd714d6d8}": { + "tag": "finish" + } + }, + "door": { + "{9c5b0fee-e695-4516-94cd-153371e3857b}": { + "tag": "door" + } + }, + "farGrab": { + "{70fcd96c-cd59-4f23-9ca5-a167f2f85680}": { + "visible": false, + "tag": "farGrab" + }, + "{ff7b9793-0d94-4f18-bc09-4ab589126e60}": { + "tag": "farGrab" + }, + "{fdd77d2c-af36-41c1-ba57-74b7ae79d996}": { + "tag": "farGrab" + }, + "{e11700f6-bc9a-411f-9ddc-bf265d4e3ccf}": { + "tag": "farGrab" + }, + "{95850c56-cd1c-42b9-ab6b-a163a6f2878f}": { + "tag": "farGrab" + } + }, + "nearGrab": { + "{55c861ef-60ca-4722-a6c5-9c6967966ec5}": { + "tag": "nearGrab" + }, + "{644d655b-ae66-43b1-9bab-a44b9a8ad632}": { + "tag": "nearGrab" + }, + "{88221a22-b710-4d35-852b-5257b0aa77dc}": { + "tag": "nearGrab" + }, + "{8bf0baa1-88d0-448a-a782-100d4413bd82}": { + "tag": "nearGrab" + }, + "{5cf22b9c-fb22-4854-8821-554422980b24}": { + "visible": false, + "tag": "nearGrab" + } + }, + "equip-part1": { + "{d73822ca-0a34-4cf4-a530-3258ac459a14}": { + "tag": "equip-part1" + }, + "{97ced5e7-fc81-40f9-a9e8-f85b4b30f24c}": { + "tag": "equip-part1" + }, + "{8572d991-5777-45df-97bf-7243d7b12f81}": { + "tag": "equip-part1" + }, + "{da5ea72e-54b6-41ac-b711-742b062b6968}": { + "tag": "equip-part1" + }, + "{c8944a13-9acb-4d77-b1ee-851845e98357}": { + "tag": "equip-part1" + }, + "{e9481c78-1a21-43f7-b54c-58f2efdf3c8f}": { + "tag": "equip-part1" + }, + "{ca3c28f3-15fc-4349-a85e-eaca0fad6434}": { + "tag": "equip-part1" + }, + "{09ddcb94-52a7-4f50-a5a2-db9db28fc519}": { + "tag": "equip-part1" + }, + "{dd13fcd5-616f-4749-ab28-2e1e8bc512e9}": { + "tag": "equip-part1" + } + }, + "equip-part2": { + "{8b92eec5-aeed-4368-bce0-432cc9ad4c51}": { + "tag": "equip-part2" + }, + "{6307cd16-dd1d-4988-a339-578178436b45}": { + "tag": "equip-part2" + } + }, + "turnAround": { + "{ce74b3ca-d1c7-4980-bd98-2d488095a39e}": { + "tag": "turnAround" + } + }, + "bothGrab": { + "{14792a6e-dc6f-4e7a-843f-4b109b06b5a4}": { + "visible": false, + "tag": "bothGrab", + "collidable": true + }, + "{215dcd14-88fc-4604-9033-cbd2a660178a}": { + "tag": "bothGrab" + }, + "{fbc2e40d-0633-45ac-b1c9-97fc8465f93b}": { + "tag": "bothGrab" + }, + "{6752dad6-109d-4dc5-aef7-dc8509468cf4}": { + "tag": "bothGrab" + }, + "{178e2c71-dff5-4231-8d28-df47fddf4709}": { + "soundKey": { + "playbackGapRange": 0, + "url": "atp:/sounds/crackling_fire.L.wav", + "volume": 0.5, + "playbackGap": 5, + "playing": false, + "loop": true + }, + "tag": "bothGrab" + }, + "{52445ac5-8730-4457-827e-6c076d2c609c}": { + "tag": "bothGrab" + } + }, + "raiseHands": { + "{7139e45d-25cf-470b-b133-c0fda0099d2b}": { + "tag": "raiseHands" + } + }, + "equip": { + "{e7897c9c-f4fa-4989-a383-28af56c2e544}": { + "visible": false, + "tag": "equip" + }, + "{9df518da-9e65-4b76-8a79-eeefdb0b7310}": { + "visible": false, + "tag": "equip" + }, + "{1a77c20e-5d9b-4b54-bf20-1416141a7ca8}": { + "tag": "equip" + } + }, + "orient": { + "{95d233ab-ed0a-46e1-b047-1c542688ef3f}": { + "tag": "orient" + } + } +}