using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class clickToMove : MonoBehaviour
{
private Vector3 newPosition;
private GameObject Point;
private UnityEngine.AI.NavMeshAgent Agent;
private Animator animator;
// Start is called before the first frame update
void Start()
{
Point = GameObject.Find("Point");
newPosition = transform.position;
Point.GetComponent<MeshRenderer>().enabled = false;
Agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
animator = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
Move();
}
void Move()
{
if (Input.GetMouseButtonUp(0))
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit))
{
//Debug.Log(hit.collider.name);
newPosition = new Vector3(hit.point.x, transform.position.y, hit.point.z);
Point.transform.position = new Vector3(newPosition.x, transform.position.y + 0.05f, newPosition.z);
Point.GetComponent<MeshRenderer>().enabled = true;
animator.SetBool("isWalking", true);
Agent.SetDestination(newPosition);
}
else
{
}
}
if(transform.position == Agent.destination)
{
Point.GetComponent<MeshRenderer>().enabled = false;
animator.SetBool("isWalking", false);
}
}
}
@import url('https://fonts.googleapis.com/css?family=Montserrat');
*
{
margin:0px;
padding:0px;
}
*, *:after, *:before {
box-sizing: border-box;
}
input, button, li, a
{
cursor:pointer;
margin:5px;
color:white;
transition:color 1s ease;
font-family:"Montserra";
}
nav a
{
font-size:1.2em;
}
input
{
background:none;
font-family:"Montserra";
border:none;
}
input:hover, button:hover, li:hover, a:hover
{
color:silver;
}
input:focus
{
outline: none !important;border:none;
border-bottom:1px solid white;
}
::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: white;
opacity: 0.8; /* Firefox */
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: white;
}
::-ms-input-placeholder { /* Microsoft Edge */
color: white;
}
pre{
white-space: pre-wrap;
word-wrap: break-word;
text-align: justify;
tab-size:4;
}
html
{
height:100%;
font-family:"Montserra";
color:white;
}
body
{
height:100%;
text-align:center;
}
.bl
{
display:block;
}
#over
{
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
transition:ease 1s opacity;
text-shadow:
}
h1 {
color:rgba(255, 255, 255, 0.8);
font-size: calc(1em + 20vw) ;
font-weight: 900;
text-shadow: 2px 2px 20px rgba(0, 0, 0, 0.5);
font-family:"Montserra"; letter-spacing:2px;
}
#a,#b,#c,#d, #e, #f, #g, #h
{
display:none;
width:100%;
height:100%;
text-align:left;
padding:0px;
margin:0px;
}
code
{
display:block;
overflow:auto;
}
#interact{
display:inline-block;
vertical-align:top;
width:50%;
height:100%;
}
#unity-container
{
display:inline-block;
width:50%;
height:100%;
}
#speach
{
display:block;
margin-top:2%;
display:inline-block;
}
#speach p
{
display:inline-block;vertical-align:top;
}
.voice,.unknow
{
height:90px;
width:90px;
padding:0px;
margin:0px;
}
#voix,#inconnu
{
width:100%;
height:100%;
}
.inl
{
display:inline-block;
vertical-align:top;
margin:3px;
}
.txtSha
{
text-shadow:1px 1px 0 #8c098a;
}
.txtShaDeux
{
text-shadow:1px 1px 0 silver;
}
.ulDisplay
{
display:block;
border:2px solid red;
}
.topnav {
overflow: hidden;
}
.topnav #menu_mobile{
display: none;
}
.topnav a {
color: white;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
display: block;
}
.topnav a.icon {
background: black;
display: block;
position: absolute;
right: 0;
top: 0;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
#titre_menu_mobile{
border:none;
color:white;
width:100%;
padding-top:5px;
padding-bottom:5px;
font-family:"Montserra";
}
#btMobile
{
position:absolute;
top:0px;
right:0px;
padding:8px;
background: none;
border:none;
color:white;
}
.ava_male
{
width:86px;
height:86px;
margin:auto;
background:url('https://www.optimages.fr/lecteur/male.png') no-repeat top;
background-size:100% 100%;
}
.ava_female
{
width:86px;
height:86px;
margin:auto;
background:url('https://www.optimages.fr/lecteur/female.png') no-repeat top;
background-size:100% 100%;
}
.iconel
{
margin-left:10px;
}
.rotateIcon
{
margin-right:15px;
transform-origin: center;
transform: rotate(-75deg);
}
#avatar
{
display:none;
}
.blockM{height:50%;border:2px solid silver;}
.star{ font-family:"Montserra"; letter-spacing:2px;font-size:2.5em;}
.heade{width:100%;height:20%; text-align:left;}
.middle{width:100%;height:70%;overflow:auto;padding:0px;}
.foot{width:100%;padding:2%;height:10%;}
.itale{cursor:pointer;transition:ease 0.5s color;font-style:italic;margin-left:5px;}
.itale:hover{color:silver;}
#unity-canvas
{
width:200px;
height:200px;
display:none;
}
#header-unity{
position:absolute;
font-family:"Montserra";
width:50%;
text-align:center;
padding:5px;
display:none;
}
#goInter{
cursor:pointer;width:auto;margin:0px;padding:5px;background:none;
font-family:"Montserra";
letter-spacing:2px;
color:white;
border-radius:0px;
transition:color 1s ease;
}
#autoPlay
{
float:left;display:inline-block;cursor:pointer;background:none;
padding-left:8px;
padding-right:8px;
padding-top:4px;
padding-bottom:4px;
margin:0px;
font-family:"Montserra";
letter-spacing:2px;
color:white;
transition:color 1s ease;
}
#unity-build-title {display:inline-block;font-family: arial;}
#unity-fullscreen-button {float:right;display:inline-block;cursor:pointer; padding:8px;}
#autoPlay:hover, #goInter:hover, #unity-fullscreen-button:hover
{
color:silver;
}
#navM{
display:none;
width:100%;
height:auto;
}
@media screen and (max-width: 840px) {
#unity-container, #interact{
display:block;
width:100%;
}
#header-unity
{
width:95%;
}
#unity-container{
border:none;
border-bottom:1px dashed silver;
}
#navP
{
display:none;
}
#navM{
display:block;
}
.middle
{
height:auto;
}
pre{
tab-size:2;
}
}
@media screen and (max-width: 640px) {
pre{
tab-size:0;
}
}
var buildUrl = "Build";
var loaderUrl = buildUrl + "/version2.loader.js";
var instance = "none";
var interG;
var btInteract = document.getElementById('goInter');
// Sur la ligne suivante, vous devez inclure les préfixes des implémentations que vous souhaitez tester.
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
// N'UTILISEZ PAS "var indexedDB = ..." si vous n'êtes pas dans une fonction.
// De plus, vous pourriez avoir besoin de réferences à des objets window.IDB*:
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange
var config = {
dataUrl: buildUrl + "/version2.data.gz",
frameworkUrl: buildUrl + "/version2.framework.js.gz",
codeUrl: buildUrl + "/version2.wasm.gz",
streamingAssetsUrl: "StreamingAssets",
companyName: "DefaultCompany",
productName: "cavernes",
productVersion: "0.1",
};
var container = document.querySelector("#unity-container");
var canvas = document.querySelector("#unity-canvas");
var loadingBar = document.querySelector("#unity-loading-bar");
var progressBarFull = document.querySelector("#unity-progress-bar-full");
var fullscreenButton = document.querySelector("#unity-fullscreen-button");
var mobileWarning = document.querySelector("#unity-mobile-warning");
var interact, indic = false;
function init()
{
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
container.className = "unity-mobile";
config.devicePixelRatio = 1;
mobileWarning.style.display = "block";
setTimeout(() => {
mobileWarning.style.display = "none";
}, 5000);
} else {
}
loadingBar.style.display = "block";
var script = document.createElement("script");
script.src = loaderUrl;
script.onload = () => {
createUnityInstance(canvas, config, (progress) => {
progressBarFull.style.width = 100 * progress + "%";
}).then((unityInstance) => {
loadingBar.style.display = "none";
instance = unityInstance;
fitToContainer();
canvas.style.width = '100%';
canvas.style.height = '100%';
document.getElementById('header-unity').style.display = 'block';
mySystemLaunching();
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});
fullscreenButton.onclick = () => {
unityInstance.SetFullscreen(1);
};
}).catch((message) => {
alert(message);
});
};
document.body.appendChild(script);
}
var newMenu = function()
{
var menu = new Object();
menu.inter;
menu.listAnchor;
menu.listMobile;
menu.ids ='a';
menu.bt = document.getElementById('autoPlay');
menu.btMobile = document.getElementById('btMobile');
menu.launch = function()
{
menu.bt.addEventListener('mouseup', menu.autoAnim);
menu.inter = setTimeout(menu.open,500);
};
menu.open = function()
{
document.getElementsByTagName('h1')[0].style.opacity = "1";
clearTimeout(menu.inter);
menu.inter = setTimeout(menu.close,1000);
};
menu.close = function()
{
clearTimeout(menu.inter);
document.getElementsByTagName('h1')[0].style.opacity = "0";
document.getElementById('over').style.opacity = "0";
menu.inter = setTimeout(menu.iniatilise, 1000);
};
menu.iniatilise = function()
{
document.getElementById('over').style.display='none';
menu.listAnchor = document.getElementById('menu').getElementsByTagName('a');
menu.listMobile = document.getElementById('menu_mobile').getElementsByTagName('a');
for(var i=0;i<menu.listAnchor.length;i++)
{
menu.listAnchor[i].addEventListener('mousedown', menu.showBlock);
}
for(i=0;i<menu.listMobile.length;i++)
{
menu.listMobile[i].addEventListener('mousedown', menu.showBlock);
}
document.getElementById('a').style.display = "block";
fitToContainer(canvas);
menu.btMobile.addEventListener('mouseup', menu.ouvreMobileMenu);
btInteract.addEventListener('mouseup', lanceAnim);
autoInitAnim();
};
menu.showBlock = function(evt)
{
var tmpTab = evt.target.href.split('#');
var newid = tmpTab[1];
document.getElementById(menu.ids).style.display = "none";
menu.ids = newid;
document.getElementById('titre_menu').innerHTML = evt.target.innerHTML;
document.getElementById('titre_menu_mobile').innerHTML = evt.target.innerHTML;
document.getElementById(newid).style.display = "block";
menu.verifMobileClick();
};
menu.autoAnim = function()
{
autoInitAnim();
};
menu.verifMobileClick = function()
{
var x = document.getElementById("menu_mobile");
if (x.style.display === "block") {
x.style.display = "none";
}
};
menu.ouvreMobileMenu = function()
{
var x = document.getElementById("menu_mobile");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
};
return menu;
};
function autoInitAnim()
{
//after anim css execute
setTimeout(function()
{
if(indic == false)
{
//show anim load scene
if(document.getElementById('control').classList.contains("fa-play"))
{
document.getElementById('control').classList.remove = 'fas fa-play';
document.getElementById('control').className = "fas fa-stop";
}
canvas.style.display = 'block';
indic = true;
}
else
{
//unshow anim load scene init light
//canvas.style.display = 'none';
document.getElementById('control').classList.remove = 'fas fa-stop';
document.getElementById('control').className = "fas fa-play";
indic = false
}
instance.SendMessage('jsObject', 'launch', '');
}, 1200);
}
function mySystemLaunching()
{
var dt = new Date();
document.getElementById('year').innerHTML += String(dt.getFullYear());
interact = newMenu();
interact.launch();
}
//interact
var action = 0;
var audioAlarm;
var Elise, inconnu;
var myTts = newTts();
var myManage = newTools();
function lanceAnim()
{
//inconnu.parle("/audio/1.mp3", 'Qu’est-ce qui s’est passé ?', none);
//Elise.parle("bonjour", action_man);
btInteract.style.display = 'none';
inconnu = newPerso('inconnu', 'inconnu', myTts.setOrigin);
Elise = newPerso('voix', 'voix', myTts.set);
action_man();
}
function action_man()
{
action = action + 1;
switch(action)
{
case 1:
multiSpeak([[3, inconnu.parle, "https://www.optimages.fr/lecteur/audio/1.mp3", 'Qu’est-ce qui s’est passé ?', recursifWait, "Discour Speach"], [2, Elise.parle, "bonjour", recursifWait, "Discour Speach"], [3, inconnu.parle, "https://www.optimages.fr/lecteur/audio/2.mp3", "Qui êtes-vous ? l'inconnu cherche du regard", recursifWait, "Discour Speach"], [3, inconnu.parle, "https://www.optimages.fr/lecteur/audio/3.mp3", "il se trouve debout près d'un caisson cryogénique, qui se trouve dans une caverne, il aperçoit d’autres caissons", recursifWait, "Description Vocale"],
[2, Elise.parle, "Je m’appelle Elise. je suis la pour aider pendant votre réveil", setEliseSurName, "Discour Speach"]]);
break;
case 2:
myManage.addList('Votre nom ?', ['oui', 'non'], name, 'Insére Nom');
break;
case 3:
myManage.addInputSystem(name_deux);
break;
case 4:
myManage.addList('Votre prénom ?', ['oui', 'non'], surname, "Insére Prénom");
break;
case 5:
myManage.addInputSystem(surname_deux);
break;
case 6:
myManage.addList('Est-tu conscient par degrés ?', ['quoi', 'quel corps', '???uwu', "t'as pris t'est médoc ce matin?", "on m'apelle le king"], corp);
break;
case 7:
myManage.addList('Choisit ta couverture agent', ["Militaire", "Scientifique", "Personnel médicale", "Ingénieur", "Pilote", "Colon"], corp_deux);
break;
case 8:
multiSpeak([[3,inconnu.parle, "https://www.optimages.fr/lecteur/audio/4.mp3", 'Ok Elise la mémoire me revient, je suis un agent fréquentielle, on me nomme l’oeil !', recursifWait, "In Memory"], [2, Elise.parle, "Je sais qui vous êtes" , finish, "Suspend"]]);
break;
case 9:
myManage.addList('Voulez-vous le bracelet ?', ['oui', 'non'], getBracelet, "Vérification Dominance");
break;
default:
console.log('action default');
break;
}
}
function name(cc)
{
myManage.effaceList();
if(cc == 'non')
{
inconnu.name = 'Snowden';
action = action + 1;
Elise.parle("Et souvenez-vous de votre prénom Monsieur "+inconnu.name, action_man, "Demande Prénom");
}
else
{
Elise.parle("Ok quel est t'il ?", action_man, "Insérez votre nom");
}
}
function name_deux(evt)
{
if(document.getElementById('inp').value.length == 0)
{
}
else
{
nom = document.getElementById('inp').value;
myManage.effaceInputSystem();
inconnu.name = String(nom);
Elise.parle("Et souvenez-vous de votre prénom Monsieur "+inconnu.name, action_man, "Demande Prénom");
}
}
function surname(cc)
{
myManage.effaceList();
if(cc == 'non')
{
inconnu.surname = 'Edward';
action = action + 1;
Elise.parle("ok Monsieur "+inconnu.name+" "+inconnu.surname+' enchanter', action_man, "Discour Speach");
}
else
{
Elise.parle("Ok quel est t'il ?", action_man, "Insére Prénom");
}
}
function surname_deux(evt)
{
if(document.getElementById('inp').value.length == 0)
{
}
else
{
nom = document.getElementById('inp').value;
myManage.effaceInputSystem();
inconnu.surname = String(nom);
console.log(inconnu.surname);
Elise.parle("ok Monsieur "+inconnu.name+" "+inconnu.surname+' enchanter', action_man, "Discour Speach");
}
}
function corp(cc)
{
myManage.effaceList();
Elise.parle("Militaire. Scientifique. Personnel médicale. Ingénieur. Pilote. Colon?", action_man, "Précision Speach");
}
function corp_deux(cc)
{
myManage.effaceList();
Elise.parle("D'accord votre métier de couverture sera "+cc, action_man, "Affectation Agent");
}
function setEliseSurName()
{
Elise.surname = 'Elise';
Elise.parle("Vous souvenez-vous de votre nom de famille ?", action_man, "Demande Nom");
}
function getBracelet()
{
myManage.effaceList();
audioAlarm = new Audio();
audioAlarm.addEventListener('loadedmetadata', brabra);
audioAlarm.src = "https://www.optimages.fr/lecteur/audio/alarme.mp3";
function brabra()
{
audioAlarm.play();
Elise.parle("Notre couverture est compromise partez!", sametime, "Alert!!!");
};
}
function sametime()
{
var fInter = setTimeout(brabra, 3000);
function brabra()
{
clearTimeout(fInter);
if(audioAlarm.paused)
{
}
else
{
audioAlarm.pause();
}
console.log('mes+fondu');
};
}
function finish()
{
console.log('bracelet speak');
Elise.parle("A votre droite vous trouverez un bracelet", action_man, "Demande Bracelet");
}
function fitToContainer(canvas){
if(instance != 'none')
{
var h = document.getElementById('a').offsetHeight;
var d = document.querySelector("#unity-container");
d.style.height = '100%';
}
}
window.onload = init;
const TTS_PATH = "tts.php";
var interClass, tmpTab;
var newTts = function()
{
var tts = new Object();
tts.xhr;
tts.formulaire;
tts.sortie = 'none';
tts.audio;
tts.inter;
tts.inTxt;
tts.txt;
tts.callback;
tts.name;
tts.sur;
tts.sex;
tts.describe;
tts.speedSpeach = 1000;
tts.set = function(txt, callback, description, nn, ss, sex)
{
tts.callback = callback;
tts.sex = sex;
tts.txt = txt;
tts.name = nn;
tts.describe = description;
tts.sur = ss;
tts.inTxt = document.getElementById('speach');
tts.sortie = 'none';
tts.audio = new Audio();
tts.xhr = tts.newRequest();
tts.xhr.open('POST', TTS_PATH, true);
tts.xhr.addEventListener('load', tts.reqFinish);
tts.formulaire = new FormData();
tts.formulaire.append('tts', 'ok');
tts.formulaire.append('text', txt);
tts.xhr.send(tts.formulaire);
};
tts.setOrigin = function(src, txt, callback, description, nn, ss, sex)
{
tts.callback = callback;
tts.txt = txt;
tts.name = nn;
tts.sur = ss;
tts.sex = sex;
tts.describe = description;
tts.audio = new Audio();
tts.audio.addEventListener('loadedmetadata', tts.autoSpeak);
tts.audio.src = src;
};
tts.reqFinish = function()
{
tts.sortie=tts.formateSortie(tts.xhr.responseText);
tts.audio.addEventListener('loadedmetadata', tts.autoSpeak);
tts.audio.src = tts.sortie;
};
tts.autoSpeak = function()
{
tts.speedSpeach = Math.round((tts.audio.duration * 1000) / tts.txt.length);
tts.switchBackground();
document.getElementById('name').innerHTML = tts.name+" "+tts.sur;
tabStr = tts.txt.split('');
document.getElementById('description').innerHTML = tts.describe;
document.getElementById('speach').innerHTML = '';
cara = '';
tts.inter = setInterval(animTxt, tts.speedSpeach);
tts.audio.play();
function animTxt()
{
if(tabStr.length <= 0)
{
clearInterval(tts.inter);
if(tts.audio.paused)
{
tts.audio.removeEventListener('loadedmetadata', tts.autoSpeak);
if(tts.callback != "none")
{
tts.callback();
}
else
{
console.log('aucune action detecter fin speach simple fusion');
}
}
else
{
tts.inter = setInterval(animTxt, tts.speedSpeach);
}
}
else
{
cara = tabStr.shift();
document.getElementById('speach').innerHTML += cara;
}
}
};
tts.switchBackground = function()
{
var par = document.getElementById('avatar');
if(tts.sex == "m")
{
if (par.classList.contains("ava_female"))
{
par.classList.remove("ava_female");
par.className = "ava_male";
}
}
else
{
if(par.classList.contains("ava_male"))
{
par.classList.remove("ava_male");
par.className = "ava_female";
}
}
};
tts.newRequest = function()
{
var xhr = null;
if (window.XMLHttpRequest || window.ActiveXObject) {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
} else {
xhr = new XMLHttpRequest();
}
} else {
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
return null;
}
return xhr;
};
tts.formateSortie = function(out)
{
var retour;
if(IsJsonValid(out)){retour = JSON.parse(out)}else{retour = out;}
function IsJsonValid(str)
{
try
{
JSON.parse(str);
}
catch(e)
{
return false;
}
return true;
};
return retour;
};
return tts;
}
var newTools = function()
{
var tools = new Object();
tools.callFunc;
tools.choix = [];
tools.addList = function(titre, choix, callback)
{
tools.callFunc = callback;
tools.choix = choix;
var par = document.getElementById('containsInter');
var li, ids;
var node;
var div = document.createElement('div');
div.className ='w3-dropdown-click';
div.setAttribute('id', 'myList');
par.appendChild(div);
var btList = document.createElement('button');
btList.innerHTML= titre+" ";
btList.setAttribute('id', 'btHoving');
btList.className = "w3-button w3-theme-l1 w3-hover-text-theme";
div.appendChild(btList);
document.getElementById("btHoving").addEventListener('mouseup', tools.setShow);
document.getElementById("btHoving").innerHTML += '▽';
var ul = document.createElement('div');
ul.className = "w3-dropdown-content w3-bar-block w3-card-4 w3-animate-zoom";
ul.setAttribute('id', 'myList_ul');
for(var t=0;t<choix.length;t++)
{
li = document.createElement('a');
node = document.createTextNode(choix[t]);
li.appendChild(node);
li.setAttribute('id', choix[t]);
li.className = "w3-bar-item w3-button";
ul.appendChild(li);
li.addEventListener('mouseup', tools.getChoixManage);
}
div.appendChild(ul);
};
tools.setShow = function(evt)
{
var x = document.getElementById("myList_ul");
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
};
tools.getChoixManage =function(evt)
{
choix = evt.currentTarget.id;
tools.callFunc(choix);
};
tools.effaceList = function()
{
effaceAllChildren(document.getElementById('myList_ul'));
effaceAllChildren(document.getElementById('myList'));
effaceAllChildren(document.getElementById('containsInter'));
tools.choix = [];
function effaceAllChildren(elem)
{
while(elem.firstChild)
{
elem.removeChild(elem.firstChild);
}
};
};
tools.addInputSystem = function(callback)
{
tools.callFunc = callback;
var par = document.getElementById('containsInter');
var inp = document.createElement('input');
inp.setAttribute('type', 'text');
inp.type='text';
var bt = document.createElement('button');
bt.innerHTML = 'Répondre ';
bt.setAttribute('id', 'bti');
bt.className = "w3-button w3-theme-l1 w3-hover-text-theme";
bt.addEventListener('mouseup', tools.callFunc);
par.appendChild(inp);
inp.setAttribute('id', 'inp');
inp.setAttribute('value', '');
inp.setAttribute('autocomplete', 'off');
inp.placeholder="enter your name";
inp.setAttribute('spellcheck', 'false');
inp.className = "w3-hover-text-theme";
inp.style.borderBottom = "1px solid white";
inp.focus();
inp.addEventListener('keydown', tools.controlInputUser);
par.appendChild(bt);
document.getElementById('bti').innerHTML += '▽';
};
tools.controlInputUser = function(evt)
{
var car = String.fromCharCode(evt.keyCode).toLowerCase();
if(car.match(/[\w]/i))
{
document.getElementById('inp').value += car;
}
else
{
if(parseInt(evt.keyCode) == 8)
{
document.getElementById('inp').value = document.getElementById('inp').value.slice(0, -1);
}
else
{
}
}
};
tools.effaceInputSystem = function()
{
var elem = document.getElementById('inp');
elem.removeEventListener('keydown', tools.controlInputUser);
var sel = document.getElementById('containsInter');
sel.removeChild(elem);
elem = document.getElementById('bti');
elem.removeEventListener('mouseup', tools.callFunc);
sel.removeChild(elem);
};
return tools;
}
var newPerso = function(name, surname, refTts)
{
var perso = new Object();
perso.name = name;
perso.surname = surname;
perso.system_audio = refTts;
perso.tabTmp = [];
perso.checkAva = 0;
perso.parle = function(un, deux, troi, quatre = "none")
{
if(perso.checkAva == 0)
{
perso.checkAva = 1;
document.getElementById('avatar').style.display = "block";
}
if(quatre == "none")
{
//txt, callback
perso.system_audio(un , deux, troi, capitalizeFirst(Elise.name), capitalizeFirst(Elise.surname), "f");
}
else
{
//src, txt, callback
perso.system_audio(un , deux, troi, quatre, capitalizeFirst(inconnu.name), capitalizeFirst(inconnu.surname), "m");
}
function capitalizeFirst(txt)
{
return txt.charAt(0).toUpperCase() + txt.slice(1);
};
};
return perso;
}
function multiSpeak(tab)
{
//interClass = setInterval();
tmpTab = tab;
recursifWait();
}
function recursifWait()
{
var interClass = setTimeout(enchaine, 500);
function enchaine()
{
clearTimeout(interClass);
var dede;
if(tmpTab.length != 0)
{
dede = tmpTab.shift();
//console.log(dede);
if(dede[0] == 2)
{
dede[1](dede[2], dede[3], dede[4]);
}
else
{
dede[1](dede[2], dede[3], dede[4], dede[5]);
}
}
else
{
console.log('multi speak finish');
}
};
}
<?php
header("Access-Control-Allow-Origin: *");
function formateTxtForVoice($txt)
{
//$txt = strtolower($txt);
//$txt = self::str_to_noaccent($txt);
$chaine = preg_replace("#[^a-zA-Z0-9,\s|ç|è|é|ê|ë|à|á|â|ã|ä|å|ì|í|î|ï|ð|ò|ó|ô|õ|ö|ù|ú|û|ü|ý|ÿ|']#", '', $txt);
$tmp_tab = [];
if(strpos(',', $chaine) === false)
{
$tab = explode(',', $chaine);
$size = sizeof($tab);
for($i =0; $i < $size;$i++)
{
$taille = strlen($tab[$i]);
if($taille > 100)
{
$str_temp = wordwrap($tab[$i], 75, ",");
$retab = explode(',', $str_temp);
$ttai = sizeof($retab);
for($y = 0;$y < $ttai;$y++)
{
if(preg_match("#[a-zA-Z0-9]#", $retab[$y]) != 1)
{
}
else
{
array_push($tmp_tab, trim($retab[$y]));
}
}
}
else
{
if(preg_match("#[a-zA-Z0-9]#", $tab[$i]) != 1)
{
}
else
{
array_push($tmp_tab, trim($tab[$i]));
}
}
}
}
else
{
$taille = strlen($chaine);
if($taille > 100)
{
$str_temp = wordwrap($chaine, 90, ",");
$retab = explode(',', $str_temp);
$ttai = sizeof($retab);
for($i = 0;$i < $ttai;$i++)
{
if(preg_match("#[a-zA-Z0-9]#", $tab[$i]) != 1)
{
}
else
{
array_push($tmp_tab, trim($retab[$y]));
}
}
}
else
{
$tmp_tab[0] = trim($chaine);
}
}
return $tmp_tab;
}
if(isset($_POST['tts']))
{
$target = urlencode('fr');
$tabCurl = [];
$mh = curl_multi_init();
$data = [];
$tabTmp = formateTxtForVoice($_POST['text']);
for($i = 0;$i < sizeof($tabTmp);$i++)
{
$tabCurl[$i] = curl_init();
$strin = urlencode($tabTmp[$i]);
curl_setopt($tabCurl[$i], CURLOPT_URL, 'http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q='.$strin.'&tl='.$target.'');
curl_setopt($tabCurl[$i], CURLOPT_RETURNTRANSFER, true);
curl_setopt($tabCurl[$i], CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($tabCurl[$i], CURLOPT_SSL_VERIFYHOST, false);
curl_multi_add_handle($mh,$tabCurl[$i]);
}
do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);
for($i = 0;$i < sizeof($tabCurl);$i++)
{
$data[$i] = curl_multi_getcontent($tabCurl[$i]);
$data[$i] = base64_encode($data[$i]);
$data[$i] = 'data:audio/mpeg;base64,' . $data[$i];
curl_multi_remove_handle($mh, $tabCurl[$i]);
}
curl_multi_close($mh);
}
else
{
$data = 'none';
}
echo json_encode($data);
?>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class camMove : MonoBehaviour
{
private Transform TargetLookAt;
private Animator animator;
private bool animTest = false;
private bool finAnim = false;
private float Distance = 8.0f;
private float DistanceMin = 3.0f;
private float DistanceMax = 5.0f;
private float mouseX = 0.0f;
private float mouseY = 0.0f;
private float startingDistance = 0.0f;
private float desiredDistance = 0.0f;
private float X_MouseSensitivity = 5.0f;
private float Y_MouseSensitivity = 5.0f;
private float MouseWheelSensitivity = 5.0f;
private float Y_MinLimit = 0.0f;
private float Y_MaxLimit = 90.0f;
private float DistanceSmooth = 0.05f;
private float velocityDistance = 0.0f;
private Vector3 desiredPosition = Vector3.zero;
private float X_Smooth = 0.05f;
private float Y_Smooth = 0.1f;
private float velX = 0.0f;
private float velY = 0.0f;
private float velZ = 0.0f;
private Vector3 position = Vector3.zero;
private GameObject Canvas;
void Start()
{
TargetLookAt = GameObject.Find("Player").transform;
animator = Camera.main.GetComponent<Animator>();
Canvas = GameObject.Find("Panel");
Canvas.gameObject.SetActive(false);
Distance = Mathf.Clamp(Distance, DistanceMin, DistanceMax);
startingDistance = Distance;
}
void LateUpdate()
{
if (animator.GetCurrentAnimatorStateInfo(0).IsName("moving") && animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.99)
{
animTest = true;
}
if(animTest == true && animator.GetCurrentAnimatorStateInfo(0).IsName("moving") == false)
{
finAnim = true;
animator.enabled = !animator.enabled;
animTest = false;
TargetLookAt.Rotate(0, -90.0f, 0);
TargetLookAt.Translate(0.50f, 0, 0);
Canvas.gameObject.SetActive(true);
Reset();
}
if(finAnim == true)
{
if (TargetLookAt == null)
return;
HandlePlayerInput();
CalculateDesiredPosition();
UpdatePosition();
}
}
void HandlePlayerInput()
{
var deadZone = 0.01; // mousewheel deadZone
if (Input.GetMouseButton(1))
{
mouseX += Input.GetAxis("Mouse X") * X_MouseSensitivity;
mouseY -= Input.GetAxis("Mouse Y") * Y_MouseSensitivity;
}
// this is where the mouseY is limited - Helper script
mouseY = Mathf.Clamp(mouseY, Y_MinLimit, Y_MaxLimit);
// get Mouse Wheel Input
if (Input.GetAxis("Mouse ScrollWheel") < -deadZone || Input.GetAxis("Mouse ScrollWheel") > deadZone)
{
desiredDistance = Mathf.Clamp(Distance - (Input.GetAxis("Mouse ScrollWheel") * MouseWheelSensitivity), DistanceMin, DistanceMax);
}
}
void CalculateDesiredPosition()
{
// Evaluate distance
Distance = Mathf.SmoothDamp(Distance, desiredDistance, ref velocityDistance, DistanceSmooth);
// Calculate desired position -> Note : mouse inputs reversed to align to WorldSpace Axis
desiredPosition = CalculatePosition(mouseY, mouseX, Distance);
}
Vector3 CalculatePosition(float rotationX, float rotationY, float distance)
{
Vector3 direction = new Vector3(0, 0, -distance);
Quaternion rotation = Quaternion.Euler(rotationX, rotationY, 0);
return TargetLookAt.position + (rotation * direction);
}
void UpdatePosition()
{
float posX = Mathf.SmoothDamp(position.x, desiredPosition.x, ref velX, X_Smooth);
float posY = Mathf.SmoothDamp(position.y, desiredPosition.y, ref velY, Y_Smooth);
float posZ = Mathf.SmoothDamp(position.z, desiredPosition.z, ref velZ, X_Smooth);
position = new Vector3(posX, posY, posZ);
transform.position = position;
transform.LookAt(TargetLookAt);
}
void Reset()
{
mouseX = 90.0f;
mouseY = transform.position.y + 25.0f;
Distance = DistanceMin+1.0f;
desiredDistance = Distance;
}
void ClampAngle(float angle, float min, float max)
{
while (angle < -360 || angle > 360)
{
if (angle < -360)
angle += 360;
if (angle > 360)
angle -= 360;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class jsScript : MonoBehaviour
{
// Start is called before the first frame update
void launch()
{
Scene scene = SceneManager.GetActiveScene();
if (scene.name == "init")
{
SceneManager.LoadScene("myScene");
}
else
{
SceneManager.LoadScene("init");
}
}
}