mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-12 13:55:01 +02:00
Update tutorial: away.js toggle, turning based on controller
This commit is contained in:
parent
a062e6ab9a
commit
8c6ba204cd
1 changed files with 39 additions and 24 deletions
|
@ -65,6 +65,13 @@ var TELEPORT_PAD_NAME = "tutorial/teleport/pad"
|
||||||
|
|
||||||
var successSound = SoundCache.getSound("atp:/tutorial_sounds/good_one.L.wav");
|
var successSound = SoundCache.getSound("atp:/tutorial_sounds/good_one.L.wav");
|
||||||
|
|
||||||
|
|
||||||
|
var CHANNEL_AWAY_ENABLE = "Hifi-Away-Enable";
|
||||||
|
function setAwayEnabled(value) {
|
||||||
|
var message = value ? 'enable' : 'disable';
|
||||||
|
Messages.sendLocalMessage(CHANNEL_AWAY_ENABLE, message);
|
||||||
|
}
|
||||||
|
|
||||||
function beginsWithFilter(value, key) {
|
function beginsWithFilter(value, key) {
|
||||||
return value.indexOf(properties[key]) == 0;
|
return value.indexOf(properties[key]) == 0;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +266,7 @@ stepDisableControllers.prototype = {
|
||||||
setControllerPartLayer('tips', 'blank');
|
setControllerPartLayer('tips', 'blank');
|
||||||
|
|
||||||
hideEntitiesWithTag('finish');
|
hideEntitiesWithTag('finish');
|
||||||
|
setAwayEnabled(false);
|
||||||
|
|
||||||
onFinish();
|
onFinish();
|
||||||
},
|
},
|
||||||
|
@ -290,6 +298,7 @@ function reenableEverything() {
|
||||||
controllerDisplayManager.destroy();
|
controllerDisplayManager.destroy();
|
||||||
controllerDisplayManager = null;
|
controllerDisplayManager = null;
|
||||||
}
|
}
|
||||||
|
setAwayEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var stepEnableControllers = function(name) {
|
var stepEnableControllers = function(name) {
|
||||||
|
@ -361,7 +370,10 @@ StayInFrontOverlay.prototype = {
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
Overlays.deleteOverlay(this.overlayID);
|
Overlays.deleteOverlay(this.overlayID);
|
||||||
Script.update.disconnect(this.boundUpdate);
|
try {
|
||||||
|
Script.update.disconnect(this.boundUpdate);
|
||||||
|
} catch(e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -823,15 +835,8 @@ var stepTurnAround = function(name) {
|
||||||
this.tag = name;
|
this.tag = name;
|
||||||
this.tempTag = name + "-temporary";
|
this.tempTag = name + "-temporary";
|
||||||
|
|
||||||
|
this.onActionBound = this.onAction.bind(this);
|
||||||
//var name = "mapping-name";
|
this.numTimesTurnPressed = 0;
|
||||||
//var mapping = Controller.newMapping(name);
|
|
||||||
//mapping.from([Controller.Actions.StepYaw]).to(function() {
|
|
||||||
// print("STEPYAW");
|
|
||||||
//});
|
|
||||||
//Script.scriptEnding.connect(function() {
|
|
||||||
// Controller.disableMapping(name);
|
|
||||||
//});
|
|
||||||
}
|
}
|
||||||
stepTurnAround.prototype = {
|
stepTurnAround.prototype = {
|
||||||
start: function(onFinish) {
|
start: function(onFinish) {
|
||||||
|
@ -842,28 +847,38 @@ stepTurnAround.prototype = {
|
||||||
setControllerPartLayer('tips', 'arrows');
|
setControllerPartLayer('tips', 'arrows');
|
||||||
|
|
||||||
showEntitiesWithTag(this.tag);
|
showEntitiesWithTag(this.tag);
|
||||||
var hasTurnedAround = false;
|
|
||||||
|
this.numTimesTurnPressed = 0;
|
||||||
|
Controller.actionEvent.connect(this.onActionBound);
|
||||||
|
|
||||||
this.interval = Script.setInterval(function() {
|
this.interval = Script.setInterval(function() {
|
||||||
|
var FORWARD_THRESHOLD = 30;
|
||||||
|
var REQ_NUM_TIMES_PRESSED = 6;
|
||||||
|
|
||||||
var dir = Quat.getFront(MyAvatar.orientation);
|
var dir = Quat.getFront(MyAvatar.orientation);
|
||||||
var angle = Math.atan2(dir.z, dir.x);
|
var angle = Math.atan2(dir.z, dir.x);
|
||||||
var angleDegrees = ((angle / Math.PI) * 180);
|
var angleDegrees = ((angle / Math.PI) * 180);
|
||||||
if (!hasTurnedAround) {
|
|
||||||
if (Math.abs(angleDegrees) > 140) {
|
if (this.numTimesTurnPressed >= REQ_NUM_TIMES_PRESSED && Math.abs(angleDegrees) < FORWARD_THRESHOLD) {
|
||||||
hasTurnedAround = true;
|
Script.clearInterval(this.interval);
|
||||||
info("Half way turned around");
|
this.interval = null;
|
||||||
}
|
playSuccessSound();
|
||||||
} else {
|
onFinish();
|
||||||
if (Math.abs(angleDegrees) < 30) {
|
|
||||||
Script.clearInterval(this.interval);
|
|
||||||
this.interval = null;
|
|
||||||
info("Turned around");
|
|
||||||
playSuccessSound();
|
|
||||||
onFinish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.bind(this), 100);
|
}.bind(this), 100);
|
||||||
},
|
},
|
||||||
|
onAction: function(action, value) {
|
||||||
|
var STEP_YAW_ACTION = 6;
|
||||||
|
if (action == STEP_YAW_ACTION && value != 0) {
|
||||||
|
this.numTimesTurnPressed += 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
cleanup: function() {
|
cleanup: function() {
|
||||||
|
try {
|
||||||
|
Controller.actionEvent.disconnect(this.onActionBound);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
setControllerVisible("left", false);
|
setControllerVisible("left", false);
|
||||||
setControllerVisible("right", false);
|
setControllerVisible("right", false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue