mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:47:11 +02:00
Add support for spinner to tutorial
This commit is contained in:
parent
80b53a30d7
commit
09652e24ef
1 changed files with 48 additions and 38 deletions
|
@ -491,6 +491,9 @@ var stepEquip = function(name) {
|
||||||
this.tagPart1 = name + "-part1";
|
this.tagPart1 = name + "-part1";
|
||||||
this.tagPart2 = name + "-part2";
|
this.tagPart2 = name + "-part2";
|
||||||
this.tempTag = name + "-temporary";
|
this.tempTag = name + "-temporary";
|
||||||
|
this.PART1 = 0;
|
||||||
|
this.PART2 = 1;
|
||||||
|
this.COMPLETE = 2;
|
||||||
}
|
}
|
||||||
stepEquip.prototype = {
|
stepEquip.prototype = {
|
||||||
start: function(onFinish) {
|
start: function(onFinish) {
|
||||||
|
@ -520,7 +523,7 @@ stepEquip.prototype = {
|
||||||
showEntitiesWithTag(this.tag);
|
showEntitiesWithTag(this.tag);
|
||||||
showEntitiesWithTag(this.tagPart1);
|
showEntitiesWithTag(this.tagPart1);
|
||||||
|
|
||||||
this.hasFinished = false;
|
this.currentPart = this.PART1;
|
||||||
|
|
||||||
var basketColliderID = findEntity({ name: GUN_BASKET_COLLIDER_NAME }, 10000);
|
var basketColliderID = findEntity({ name: GUN_BASKET_COLLIDER_NAME }, 10000);
|
||||||
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
var basketPosition = Entities.getEntityProperties(basketColliderID, 'position').position;
|
||||||
|
@ -545,56 +548,63 @@ stepEquip.prototype = {
|
||||||
this.gunID = createGun.bind(this)();
|
this.gunID = createGun.bind(this)();
|
||||||
print("Created", this.gunID);
|
print("Created", this.gunID);
|
||||||
this.onFinish = onFinish;
|
this.onFinish = onFinish;
|
||||||
|
Messages.subscribe('Tutorial-Spinner');
|
||||||
|
Messages.messageReceived.connect(this.onMessage.bind(this));
|
||||||
|
|
||||||
function onHit() {
|
// function onHit() {
|
||||||
hideEntitiesWithTag(this.tagPart1);
|
// }
|
||||||
showEntitiesWithTag(this.tagPart2);
|
//
|
||||||
print("HIT, wiating for unequip...");
|
// // When block collides with basket start step 2
|
||||||
Messages.subscribe('Hifi-Object-Manipulation');
|
// function checkCollides() {
|
||||||
Messages.messageReceived.connect(this.onMessage.bind(this));
|
// //print("CHECKING FOR PING PONG...");
|
||||||
}
|
// var ammoIDs = findEntities({ name: GUN_AMMO_NAME }, 15);
|
||||||
|
// for (var i = 0; i < ammoIDs.length; ++i) {
|
||||||
|
// if (Vec3.distance(basketPosition, Entities.getEntityProperties(ammoIDs[i], 'position').position) < 0.25) {
|
||||||
|
// Script.clearInterval(this.checkCollidesTimer);
|
||||||
|
// this.checkCollidesTimer = null;
|
||||||
|
// playSuccessSound();
|
||||||
|
// Script.setTimeout(onHit.bind(this), 1000);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.checkCollidesTimer = Script.setInterval(checkCollides.bind(this), 100);
|
||||||
|
|
||||||
// When block collides with basket start step 2
|
|
||||||
function checkCollides() {
|
|
||||||
//print("CHECKING FOR PING PONG...");
|
|
||||||
var ammoIDs = findEntities({ name: GUN_AMMO_NAME }, 15);
|
|
||||||
for (var i = 0; i < ammoIDs.length; ++i) {
|
|
||||||
if (Vec3.distance(basketPosition, Entities.getEntityProperties(ammoIDs[i], 'position').position) < 0.25) {
|
|
||||||
Script.clearInterval(this.checkCollidesTimer);
|
|
||||||
this.checkCollidesTimer = null;
|
|
||||||
playSuccessSound();
|
|
||||||
Script.setTimeout(onHit.bind(this), 1000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.checkCollidesTimer = Script.setInterval(checkCollides.bind(this), 100);
|
|
||||||
|
|
||||||
// If block gets too far away or hasn't been touched for X seconds, create a new block and destroy the old block
|
// 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, sender) {
|
onMessage: function(channel, message, sender) {
|
||||||
if (this.hasFinished) {
|
if (this.currentPart == this.COMPLETE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
print("Got message", channel, message, sender, MyAvatar.sessionUUID);
|
||||||
//if (sender === MyAvatar.sessionUUID) {
|
if (channel == "Tutorial-Spinner") {
|
||||||
var data = parseJSON(message);
|
if (this.currentPart == this.PART1 && message == "wasLit") {
|
||||||
print("Here", data.action, data.grabbedEntity, this.gunID);
|
hideEntitiesWithTag(this.tagPart1);
|
||||||
if (data.action == 'release' && data.grabbedEntity == this.gunID) {
|
showEntitiesWithTag(this.tagPart2);
|
||||||
try {
|
Messages.subscribe('Hifi-Object-Manipulation');
|
||||||
Messages.messageReceived.disconnect(this.onMessage);
|
|
||||||
} catch(e) {
|
|
||||||
}
|
|
||||||
playSuccessSound();
|
|
||||||
print("FINISHED");
|
|
||||||
Script.setTimeout(this.onFinish.bind(this), 1500);
|
|
||||||
this.hasFinished = true;
|
|
||||||
//this.onFinish();
|
|
||||||
}
|
}
|
||||||
//}
|
} else if (channel == "Hifi-Object-Manipulation") {
|
||||||
|
if (this.currentPart == this.PART2) {
|
||||||
|
var data = parseJSON(message);
|
||||||
|
print("Here", data.action, data.grabbedEntity, this.gunID);
|
||||||
|
if (data.action == 'release' && data.grabbedEntity == this.gunID) {
|
||||||
|
try {
|
||||||
|
Messages.messageReceived.disconnect(this.onMessage);
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
|
playSuccessSound();
|
||||||
|
print("FINISHED");
|
||||||
|
Script.setTimeout(this.onFinish.bind(this), 1500);
|
||||||
|
this.currentPart = this.COMPLETE;
|
||||||
|
//this.onFinish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
cleanup: function() {
|
cleanup: function() {
|
||||||
setControllerVisible("trigger", false);
|
setControllerVisible("trigger", false);
|
||||||
|
this.currentPart = this.COMPLETE;
|
||||||
try {
|
try {
|
||||||
Messages.messageReceived.disconnect(this.onMessage);
|
Messages.messageReceived.disconnect(this.onMessage);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
Loading…
Reference in a new issue