diff --git a/www/js/home_controller.js b/www/js/home_controller.js index 593337f..a8a1f63 100644 --- a/www/js/home_controller.js +++ b/www/js/home_controller.js @@ -13,10 +13,14 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ //Globale-Sounddatei var mentorsound=''; - var boingsound=''; + var farmhaussound=''; + var windradsound=''; + var kornspeichersound=''; var mentor_is_speakting=false; - var boing_is_sounding=false; + var farmhaus_is_sounding=false; + var windrad_is_sounding=false; + var kornspeicher_is_sounding=false; $scope.$on("$ionicView.beforeEnter", function(event, data){ /* @@ -80,7 +84,7 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ //Soundfile freigeben mentorsound.release(); - + mentor_is_speakting=false; $scope.CSSKlickSuchspiel=false; $scope.showmentor=false; $state.go('suchspiel'); @@ -88,30 +92,19 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ $scope.animate_farmhaus=function(){ $scope.CSSFarmhaus=true; - playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); - $timeout(function () { - $scope.CSSFarmhaus=false; - }, 2000); + playsound('farmhaussound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], farmhaussound_stop,'1.0'); } $scope.animate_windrad=function(){ $scope.CSSWindrad=true; - playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); - $timeout(function () { - $scope.CSSWindrad=false; - }, 2000); + playsound('windradsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], windradsound_stop,'1.0'); } $scope.animate_kornspeicher=function(){ - //SetBackgroundpic - //$rootScope.backgroundimage = "img/ufo.png"; $scope.CSSKornspeicher=true; - playsound('boingsound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], boingsound_stop,'1.0'); - $timeout(function () { - $scope.CSSKornspeicher=false; - }, 2000); + playsound('kornspeichersound', $scope.boingsound_action[getRandomInt(0, $scope.boingsound_action.length - 1)], kornspeichersound_stop,'1.0'); } $scope.baumhaus_actiondo=function(){ @@ -131,15 +124,15 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ $ionicPlatform.ready(function() { - if (playtype=='boingsound'){ + if (playtype=='farmhaussound'){ - if (boing_is_sounding==false){ + if (farmhaus_is_sounding==false){ try{ //versuchen Soundfile freizugeben - boingsound.release(); + farmhaussound.release(); } catch(e){ @@ -147,10 +140,54 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ console.log("Sounddatei nicht da"); } - boingsound = new Media(soundfile, callbackfunction ,null); - boingsound.play(); - boingsound.setVolume(volume); - boing_is_sounding=true; + farmhaussound = new Media(soundfile, callbackfunction ,null); + farmhaussound.play(); + farmhaussound.setVolume(volume); + farmhaus_is_sounding=true; + } + } + else if (playtype=='windradsound'){ + + + if (windrad_is_sounding==false){ + + try{ + + //versuchen Soundfile freizugeben + windradsound.release(); + } + catch(e){ + + //Soundfile Objekt gabs nicht oder Freigabefehler + console.log("Sounddatei nicht da"); + } + + windradsound = new Media(soundfile, callbackfunction ,null); + windradsound.play(); + windradsound.setVolume(volume); + windrad_is_sounding=true; + } + } + else if (playtype=='kornspeichersound'){ + + + if (kornspeicher_is_sounding==false){ + + try{ + + //versuchen Soundfile freizugeben + kornspeichersound.release(); + } + catch(e){ + + //Soundfile Objekt gabs nicht oder Freigabefehler + console.log("Sounddatei nicht da"); + } + + kornspeichersound = new Media(soundfile, callbackfunction ,null); + kornspeichersound.play(); + kornspeichersound.setVolume(volume); + kornspeicher_is_sounding=true; } } else if (playtype=='mentorsound'){ @@ -180,10 +217,28 @@ appControllers.controller('home', function($scope, $rootScope, $ionicPlatform, $ } - function boingsound_stop(){ - //Soundfile freigeben - boingsound.release(); - boing_is_sounding=false; + function windradsound_stop(){ + + $timeout(function () { $scope.CSSWindrad=false; }, 0); + windradsound.release(); + windrad_is_sounding=false; + + } + + function kornspeichersound_stop(){ + + $timeout(function () { $scope.CSSKornspeicher=false; }, 0); + kornspeichersound.release(); + kornspeicher_is_sounding=false; + + } + + function farmhaussound_stop(){ + + $timeout(function () { $scope.CSSFarmhaus=false; }, 0); + farmhaussound.release(); + farmhaus_is_sounding=false; + } diff --git a/www/js/suchspiel_controller.js b/www/js/suchspiel_controller.js index c996485..82823e1 100644 --- a/www/js/suchspiel_controller.js +++ b/www/js/suchspiel_controller.js @@ -28,9 +28,11 @@ $scope.CSSAusblendung=''; $scope.CSSEinblendung=''; $scope.CSSFalscheAntwort = false; $scope.CCSInittimer = false; +$scope.CSSKlickedItem = 99; //SpieleTimer -$scope.Spielzeit = 10; +$scope.Spielzeit = 90; +$scope.SpielzeitTimerWait=false; $scope.showgametimer = false; //Spielzeit vorbei @@ -216,14 +218,27 @@ function mentorausblenden(){ * Antwort prüfen */ $scope.PlayerAnswer = function(src) { - + + if ($scope.gamelock==false){ + /* + * Item wurde geklickt, hüpfen lassen + */ + $scope.CSSKlickedItem = src; + + /* + * Item wurde geklickt, zurücksetzen + */ + $timeout(function () { + $scope.CSSKlickedItem = 99; + }, 1000); /* * Einblende-effekte zurücksetzen */ $scope.CSSEinblendung=''; + /* * Prüfen ob schon einmal geklickt wurde @@ -341,10 +356,13 @@ function kartegeben(){ } $scope.cardindex=$scope.cardindex + 1; }, 0); + /* * Interner Zähler bis alle Karten gegeben wurden */ if ($scope.cardindex < 7 ){ + //Spielzeit anhalten + $timeout(function () { $scope.SpielzeitTimerWait = true; }, 0); playsound('gamesound', $scope.kartegebensound, kartegeben,'1.0'); } else{ @@ -358,15 +376,23 @@ function kartegeben(){ $scope.gamelock=false; //Zeit messen $scope.rundenstart = new Date().getTime(); + + //Spielzeit laufen lassen + $timeout(function () { $scope.SpielzeitTimerWait=false; }, 0); + /* * Mentor anzeigen und Sound wiedergeben */ $scope.showmentor=true; + playsound('gamesound', $scope.spiele[$scope.randomid].sound, mentorausblenden,'1.0'); + console.log("ELSE-Zweig Einblende -ID: " + $scope.CSSEinblendung); console.log("CardIndex: " + $scope.cardindex); console.log("Zufallsid: " + $scope.randomid); console.log("Tiersuchen: " + $scope.spiele[$scope.randomid].bild); + console.log("SpieleTimerWait: " + $scope.SpielzeitTimerWait) + } console.log("Einblende funktion ID: " + $scope.CSSEinblendung); } @@ -377,7 +403,10 @@ function kartegeben(){ function karteausblenden(){ $timeout(function () { $scope.showmentorbravo=false; $scope.showmentor=false;}, 0); - + + //Spielzeit anhalten + $scope.SpielzeitTimerWait=true; + if ($scope.spielvorbei==false){ if ($scope.cardindex < 8 ){ @@ -438,10 +467,17 @@ function minispielintro(){ function SpieleTimer(){ if ($scope.Spielzeit > 0){ - $scope.Spielzeit=$scope.Spielzeit - 1; - $timeout(function () { - SpieleTimer(); - }, 1000); + + if ($scope.SpielzeitTimerWait == false){ + + $scope.Spielzeit=$scope.Spielzeit - 1; + + } + $timeout(function () { + SpieleTimer(); + }, 1000); + + } else{ diff --git a/www/templates/suchspiel.html b/www/templates/suchspiel.html index 47a5694..eec56c8 100644 --- a/www/templates/suchspiel.html +++ b/www/templates/suchspiel.html @@ -11,7 +11,7 @@