Minispiel ausgegliedert
This commit is contained in:
@@ -105,7 +105,11 @@ angular.module('kinderspiel', ['ionic', 'ngCordova','ngAnimate', 'ngDraggable',
|
||||
templateUrl: 'templates/suchspiel.html',
|
||||
controller: 'Suchspiel'
|
||||
})
|
||||
|
||||
.state('minispiel1', {
|
||||
url: '/minispiel1',
|
||||
templateUrl: 'templates/minispiel1.html',
|
||||
controller: 'Minispiel1'
|
||||
})
|
||||
|
||||
/*
|
||||
* Standard-Route setzen
|
||||
|
||||
174
www/js/minispiel1_controller.js
Normal file
174
www/js/minispiel1_controller.js
Normal file
@@ -0,0 +1,174 @@
|
||||
appControllers.controller('Minispiel1', function($scope, $ionicPlatform, $cordovaMedia, backgroundsounds_mediahandler, $state, $timeout,$q, $http) {
|
||||
|
||||
|
||||
/*
|
||||
* Initialisierung
|
||||
*/
|
||||
|
||||
//Minispiel
|
||||
$scope.showteddybear=false;
|
||||
$scope.teddyback=false;
|
||||
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
|
||||
/*
|
||||
* Sounds definieren
|
||||
*/
|
||||
//Globale MediaVariable fure Soundeffekte
|
||||
var gamesound='';
|
||||
var lachensound='';
|
||||
|
||||
|
||||
$scope.lachensounds=[];
|
||||
$scope.gamesounds=[];
|
||||
/*
|
||||
* Spiele IntroSounds laden
|
||||
* Typen: successsound -> Bravo, super, tollgemacht Sounds
|
||||
* Typen: failuresound -> Leider daneben, versuchs nochmal
|
||||
* Typen: cardsound -> Kartenlegegeräusch
|
||||
* Typen: solutionsound -> Auflösungsgeräusch, das wäre das Tier gewesen
|
||||
* Typen: gameoversound -> Spielzu ende Zeit für minispiel etc.
|
||||
* Typen: backgroundmusic -> Hintergrundmusik
|
||||
*/
|
||||
$http.get('spielsets/minispielset1/systemsounds.json').success(function(data) {
|
||||
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
|
||||
if (data[i].type=='lachensound'){
|
||||
$scope.lachensounds.push(data[i].sound);
|
||||
}
|
||||
else if (data[i].type=='gamesound'){
|
||||
$scope.gamesounds.push(data[i].sound);
|
||||
}
|
||||
else if (data[i].type=='backgroundmusic'){
|
||||
backgroundsounds_mediahandler.setbackgroundsoundfile(data[i].sound);
|
||||
backgroundsounds_mediahandler.playbackgroundmusic();
|
||||
}
|
||||
|
||||
}//for-Schleife
|
||||
|
||||
});//$http
|
||||
|
||||
|
||||
playsound('gamesound', $scope.gamesounds[0], minispielstart,'1.0');
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Play-Sound
|
||||
* playtype-> Bravo,Falsch oder Gamesound
|
||||
* soundfile-> Pfad zur sounddatei
|
||||
* callbackfunction-> Funktion die nach erfolgreichem abspielen gestarte wird
|
||||
* volume-> Lautstärke z.B. 1.0
|
||||
*/
|
||||
function playsound(playtype, soundfile, callbackfunction, volume){
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
|
||||
if (playtype=='lachensound'){
|
||||
|
||||
try{
|
||||
|
||||
//versuchen Soundfile freizugeben
|
||||
lachensound.release();
|
||||
|
||||
}
|
||||
catch(e){
|
||||
|
||||
//Soundfile Objekt gabs nicht oder Freigabefehler
|
||||
console.log("Sounddatei nicht da");
|
||||
}
|
||||
|
||||
lachensound = new Media(soundfile, callbackfunction ,null);
|
||||
lachensound.play();
|
||||
|
||||
}
|
||||
else if (playtype=='gamesound'){
|
||||
|
||||
try{
|
||||
|
||||
//versuchen Soundfile freizugeben
|
||||
gamesound.release();
|
||||
|
||||
}
|
||||
catch(e){
|
||||
|
||||
//Soundfile Objekt gabs nicht oder Freigabefehler
|
||||
console.log("Sounddatei nicht da");
|
||||
}
|
||||
|
||||
gamesound = new Media(soundfile, callbackfunction ,null);
|
||||
gamesound.play();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function minispielstart(){
|
||||
$timeout(function () {
|
||||
$scope.showteddybear=true;
|
||||
$scope.teddyback=true;
|
||||
}, 10);
|
||||
$timeout(function () {
|
||||
$scope.showteddybear=false;
|
||||
$state.go('home');
|
||||
}, 30000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MiniSpiel kitzel den Teddy
|
||||
*/
|
||||
$scope.teddyaction = function() {
|
||||
$scope.teddyanimation=getRandomInt(1,4);
|
||||
$scope.teddyback=false;
|
||||
$scope.teddyani1=false;
|
||||
$scope.teddyani2=false;
|
||||
$scope.teddyani3=false;
|
||||
$scope.teddyani4=false;
|
||||
|
||||
if ($scope.teddyanimation==1){
|
||||
$scope.teddyani1=true;
|
||||
playsound('lachensound', $scope.lachensounds[getRandomInt(0, $scope.lachensounds.length - 1)], null,'1.0');
|
||||
}
|
||||
if ($scope.teddyanimation==2){
|
||||
$scope.teddyani2=true;
|
||||
playsound('lachensound', $scope.lachensounds[getRandomInt(0, $scope.lachensounds.length - 1)], null,'1.0');
|
||||
}
|
||||
if ($scope.teddyanimation==3){
|
||||
$scope.teddyani3=true;
|
||||
playsound('lachensound', $scope.lachensounds[getRandomInt(0, $scope.lachensounds.length - 1)], null,'1.0');
|
||||
}
|
||||
if ($scope.teddyanimation==4){
|
||||
$scope.teddyani4=true;
|
||||
playsound('lachensound', $scope.lachensounds[getRandomInt(0, $scope.lachensounds.length - 1)], null,'1.0');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Zufallsgenerator um per Zufall neue Aufgabe definieren
|
||||
*/
|
||||
function getRandomInt(min, max) {
|
||||
var tmpInt=0;
|
||||
min = Math.ceil(min);
|
||||
max = Math.floor(max);
|
||||
tmpInt = Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
if (tmpInt > max){
|
||||
tmpInt=max;
|
||||
}
|
||||
|
||||
if (tmpInt < min){
|
||||
tmpInt=min;
|
||||
}
|
||||
return tmpInt;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -30,7 +30,7 @@ $scope.CSSFalscheAntwort = false;
|
||||
$scope.CCSInittimer = false;
|
||||
|
||||
//SpieleTimer
|
||||
$scope.Spielzeit = 90;
|
||||
$scope.Spielzeit = 10;
|
||||
$scope.showgametimer = false;
|
||||
|
||||
//Spielzeit vorbei
|
||||
@@ -51,11 +51,6 @@ $scope.gamelock=true;
|
||||
$scope.rundenstart = '';
|
||||
$scope.rundenende = '';
|
||||
|
||||
//Minispiel
|
||||
$scope.showteddybear=false;
|
||||
$scope.teddyback=false;
|
||||
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
|
||||
/*
|
||||
@@ -117,20 +112,6 @@ $ionicPlatform.ready(function() {
|
||||
|
||||
});//$http
|
||||
|
||||
/*
|
||||
* Minispiel
|
||||
*/
|
||||
var minispielsound = new Media('/android_asset/www/sounds/minispiel/kitzeldenbaeren.mp3', minispielstart,null);
|
||||
var minispielsound1 = new Media('/android_asset/www/sounds/minispiel/lachen1.mp3', null,null);
|
||||
var minispielsound2 = new Media('/android_asset/www/sounds/minispiel/lachen2.mp3', null,null);
|
||||
|
||||
|
||||
/*
|
||||
* Sounds in $Scope referenzieren
|
||||
*/
|
||||
$scope.minispielsound=minispielsound;
|
||||
$scope.minispielsound1=minispielsound1;
|
||||
$scope.minispielsound2=minispielsound2;
|
||||
|
||||
});
|
||||
|
||||
@@ -435,28 +416,14 @@ function spielende(){
|
||||
playsound('gamesound', $scope.spielendesound, minispielintro,'1.0');
|
||||
}, 10);
|
||||
|
||||
//$scope.showteddybear=true
|
||||
|
||||
}
|
||||
|
||||
function minispielintro(){
|
||||
$scope.minispielsound.play();
|
||||
$state.go('minispiel1');
|
||||
}
|
||||
|
||||
|
||||
function minispielstart(){
|
||||
$timeout(function () {
|
||||
$scope.showmentorbravo=false;
|
||||
$scope.showteddybear=true;
|
||||
$scope.teddyback=true;
|
||||
}, 10);
|
||||
$timeout(function () {
|
||||
$scope.showteddybear=false;
|
||||
$state.go('home');
|
||||
}, 30000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SpieleTimer Funktion
|
||||
@@ -600,36 +567,4 @@ function inittimer(){
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* MiniSpiel kitzel den Teddy
|
||||
*/
|
||||
$scope.teddyaction = function() {
|
||||
$scope.teddyanimation=getRandomInt(1,4);
|
||||
$scope.teddyback=false;
|
||||
$scope.teddyani1=false;
|
||||
$scope.teddyani2=false;
|
||||
$scope.teddyani3=false;
|
||||
$scope.teddyani4=false;
|
||||
|
||||
if ($scope.teddyanimation==1){
|
||||
$scope.teddyani1=true;
|
||||
$scope.minispielsound1.play();
|
||||
}
|
||||
if ($scope.teddyanimation==2){
|
||||
$scope.teddyani2=true;
|
||||
$scope.minispielsound2.play();
|
||||
}
|
||||
if ($scope.teddyanimation==3){
|
||||
$scope.teddyani3=true;
|
||||
$scope.minispielsound1.play();
|
||||
}
|
||||
if ($scope.teddyanimation==4){
|
||||
$scope.teddyani4=true;
|
||||
$scope.minispielsound2.play();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user