le niveau sait maintenant lorsque quelqu'un a réussi à allumer toute les lignes reliés à la fin

master
pisouvigne 5 years ago
parent 7887900dda
commit ed949a8221

@ -92,5 +92,18 @@ function checkLineSwitch(switchId) {
return false; return false;
} }
function checkEnd(){
let ter = true;
endLines.forEach(function(element){
if(stage.findOne("#line"+element).stroke() == "black"){
ter = false;
}
});
if(ter){
setTimeout(() => { alert("Niveau terminé"); }, 40);
}
}

@ -2,11 +2,13 @@ function initAllSwitch() {
switchs.forEach(function (element) { switchs.forEach(function (element) {
let switche = stage.findOne("#" + element); let switche = stage.findOne("#" + element);
switche.on('click', function () { switche.on('click', function () {
let colorrect = switche.fill() == colorSwitchInnactiveBackground ? colorSwitchActiveBackground : colorSwitchInnactiveBackground; let colorrect = switche.fill() == colorSwitchInnactiveBackground ? colorSwitchActiveBackground : colorSwitchInnactiveBackground;
switche.fill(colorrect); switche.fill(colorrect);
changeLineColor(switche.id3); changeLineColor(switche.id3);
checkAllSortieLogique(); checkAllSortieLogique();
layer.draw(); layer.draw();
checkEnd();
}); });
switche.on('mouseover', function () { switche.on('mouseover', function () {
document.body.style.cursor = "pointer"; document.body.style.cursor = "pointer";
@ -16,6 +18,7 @@ function initAllSwitch() {
}); });
}); });
} }
function initLayer() { function initLayer() {

@ -68,7 +68,6 @@
initEnd(); initEnd();
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save