partey_workadventure/maps/Tuto/scriptTuto.js

84 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-03-23 16:00:24 +01:00
var isFirstTimeTuto = false;
var textFirstPopup = 'Hey ! This is how to start a discussion with someone ! You can be 4 max in a bubble.';
var textSecondPopup = 'You can also use the chat to communicate ! ';
var targetObjectTutoBubble ='Tutobubble';
var targetObjectTutoChat ='tutoChat';
var targetObjectTutoExplanation ='tutoExplanation';
var popUpExplanation = undefined;
var enterSoundUrl = "webrtc-in.mp3";
var exitSoundUrl = "webrtc-out.mp3";
var soundConfig = {
volume : 0.2,
loop : false
}
2021-03-23 16:00:24 +01:00
function launchTuto (){
WA.openPopup(targetObjectTutoBubble, textFirstPopup, [
{
label: "Next",
className: "popUpElement",
callback: (popup) => {
popup.close();
WA.openPopup(targetObjectTutoChat, textSecondPopup, [
{
label: "Open Chat",
className: "popUpElement",
callback: (popup1) => {
2021-03-28 16:36:02 +02:00
WA.sendChatMessage("Hey you can talk here too!", 'WA Guide');
2021-03-23 16:00:24 +01:00
popup1.close();
2021-04-08 09:41:53 +02:00
WA.openPopup("TutoFinal","You are good to go! Go through the gate to meet the dev team and discover the features !",[
2021-03-23 16:00:24 +01:00
{
2021-03-28 16:36:02 +02:00
label: "Got it!",
2021-03-23 16:00:24 +01:00
className : "success",callback:(popup2 => {
popup2.close();
WA.restorePlayerControl();
WA.loadSound(winSoundUrl).play(soundConfig);
2021-03-23 16:00:24 +01:00
})
}
])
}
}
])
}
}
]);
WA.disablePlayerControl();
}
WA.onEnterZone('popupZone', () => {
WA.displayBubble();
WA.loadSound(enterSoundUrl).play(soundConfig);
2021-03-23 16:00:24 +01:00
if (!isFirstTimeTuto) {
isFirstTimeTuto = true;
launchTuto();
}
2021-03-28 16:36:02 +02:00
else {
popUpExplanation = WA.openPopup(targetObjectTutoExplanation, 'Do you want to review the explanation?', [
{
label: "No",
className: "error",
callback: (popup) => {
popup.close();
}
},
{
label: "Yes",
className: "success",
callback: (popup) => {
popup.close();
launchTuto();
}
2021-03-23 16:00:24 +01:00
}
2021-03-28 16:36:02 +02:00
])
}
2021-03-23 16:00:24 +01:00
});
WA.onLeaveZone('popupZone', () => {
if (popUpExplanation !== undefined) popUpExplanation.close();
WA.removeBubble();
WA.loadSound(exitSoundUrl).play(soundConfig);
2021-03-23 16:00:24 +01:00
})