var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var ListenAndWrite;
(function (_ListenAndWrite) {
    var ListenAndWrite = (function (_super) {
        __extends(ListenAndWrite, _super);
        function ListenAndWrite(game, name, x, y, json) {
            _super.call(this, game, name, x, y, json);
        }
        ListenAndWrite.prototype.preload = function () {
            _super.prototype.preload.call(this);
            this.game.load.onLoadComplete.addOnce(this.create, this);
            this.PREFIX = this.Elements.TaskPrefix;
            this.loadGraphics();
            this.game.load.start();
        };
        ListenAndWrite.prototype.loadGraphics = function () {
            for (var i = 0; i < this.Elements.Graphics.length; i++)
                this.game.load.image(this.PREFIX + this.Elements.Graphics[i].key, this.Elements.Graphics[i].src);
        };
        ListenAndWrite.prototype.create = function () {
            if (this.json.isStandalone) {
                _super.prototype.create.call(this);
            }
            if (this.json.isFirst == true) {
                EU.loadVocabulary(this);
            }
            ;
            this.createFillQuestion();
            this.createButtons();
            EU.createStaticElements(this);
            EU.createSelectableElements(this);
            EU.createFillElements(this);
        };
        ListenAndWrite.prototype.init = function (json) {
            _super.prototype.init.call(this, json);
            this.Elements = json.GameData;
        };
        ListenAndWrite.prototype.createFillQuestion = function () {
            var question;
            var flag = false;
            while (flag == false) {
                flag = true;
                this.categoryIndex = Math.floor((Math.random() * EU.groups.length));
                this.wordIndex = Math.floor((Math.random() * EU.groups[this.categoryIndex].vocabulary.length));
                EU.Log(this.categoryIndex + " " + this.wordIndex);
				if (this.categoryIndex == 0 && this.wordIndex == 0){
					question = "canoeing";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 1){
					question = "cycling";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 2){
					question = "hiking";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 3){
					question = "horse riding";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 4){
					question = "basketball";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 5){
					question = "football";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 6){
					question = "volleyball";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 7){
					question = "rock climbing";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 8){
					question = "running";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 9){
					question = "sailing";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 10){
					question = "scuba diving";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 11){
					question = "skiing";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 12){
					question = "snowboarding";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 13){
					question = "swimming";
				}
				if (this.categoryIndex == 0 && this.wordIndex == 14){
					question = "windsurfing";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 0){
					question = "beach";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 1){
					question = "dessert";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 2){
					question = "field";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 3){
					question = "forest";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 4){
					question = "hill";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 5){
					question = "island";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 6){
					question = "lake";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 7){
					question = "meadow";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 8){
					question = "mountain";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 9){
					question = "ocean";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 10){
					question = "pond";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 11){
					question = "river";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 12){
					question = "sea";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 13){
					question = "valley";
				}
				if (this.categoryIndex == 1 && this.wordIndex == 14){
					question = "waterfall";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 0){
					question = "cello";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 1){
					question = "clarinet";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 2){
					question = "cymbals";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 3){
					question = "double bass";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 4){
					question = "drums";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 5){
					question = "flute";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 6){
					question = "guitar";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 7){
					question = "harfa";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 8){
					question = "piano";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 9){
					question = "saxophone";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 10){
					question = "tambourine";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 11){
					question = "trumpet";
				}
				if (this.categoryIndex == 2 && this.wordIndex == 12){
					question = "violin";
				}
                EU.Log(question);
                for (var i = 0; i < EU.usedWords.length; i++) {
                    if (EU.usedWords[i] == question) {
                        flag = false;
                        break;
                    }
                    flag = true;
                }
            }
            EU.usedWords.push(question);
			if (this.categoryIndex == 0 && this.wordIndex == 0){
				this.json.Lector = "canoeing.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 1){
				this.json.Lector = "cycling.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 2){
				this.json.Lector = "hiking.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 3){
				this.json.Lector = "horseriding.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 4){
				this.json.Lector = "basketball.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 5){
				this.json.Lector = "football.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 6){
				this.json.Lector = "volleyball.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 7){
				this.json.Lector = "rockclimbing.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 8){
				this.json.Lector = "running.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 9){
				this.json.Lector = "sailing.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 10){
				this.json.Lector = "scubadiving.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 11){
				this.json.Lector = "skiing.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 12){
				this.json.Lector = "snowboarding.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 13){
				this.json.Lector = "swimming.mp3";
			}
			if (this.categoryIndex == 0 && this.wordIndex == 14){
				this.json.Lector = "windsurfing.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 0){
				this.json.Lector = "beach.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 1){
				this.json.Lector = "dessert.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 2){
				this.json.Lector = "field.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 3){
				this.json.Lector = "forest.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 4){
				this.json.Lector = "hill.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 5){
				this.json.Lector = "island.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 6){
				this.json.Lector = "lake.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 7){
				this.json.Lector = "meadow.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 8){
				this.json.Lector = "mountain.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 9){
				this.json.Lector = "ocean.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 10){
				this.json.Lector = "pond.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 11){
				this.json.Lector = "river.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 12){
				this.json.Lector = "sea.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 13){
				this.json.Lector = "valley.mp3";
			}
			if (this.categoryIndex == 1 && this.wordIndex == 14){
				this.json.Lector = "waterfall.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 0){
				this.json.Lector = "cello.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 1){
				this.json.Lector = "clarinet.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 2){
				this.json.Lector = "cymbals.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 3){
				this.json.Lector = "doublebass.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 4){
				this.json.Lector = "drums.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 5){
				this.json.Lector = "flute.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 6){
				this.json.Lector = "guitar.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 7){
				this.json.Lector = "harfa.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 8){
				this.json.Lector = "piano.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 9){
				this.json.Lector = "saxophone.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 10){
				this.json.Lector = "tambourine.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 11){
				this.json.Lector = "trumpet.mp3";
			}
			if (this.categoryIndex == 2 && this.wordIndex == 12){
				this.json.Lector = "violin.mp3";
			}
            this.Elements.FillElements.el.push({
                "pos": this.Elements.Position,
                "Answer": question
            });
        };
        ListenAndWrite.prototype.createButtons = function () {
            var el = this.game.add.text(1200, 770, "NEXT WORD", { font: "60px Arial", fill: 'blue', });
            el.setShadow(5, 5, "lightblue");
            el.inputEnabled = true;
            el.events.onInputDown.add(this.nextTask, this);
            this.addChild(el);
            if (this.json.isFirst != true) {
                var el2 = this.game.add.text(100, 770, "PREVIOUS WORD", { font: "60px Arial", fill: 'blue', });
                el2.setShadow(5, 5, "lightblue");
                el2.inputEnabled = true;
                el2.events.onInputDown.add(this.prevTask, this);
                this.addChild(el2);
            }
            var el3 = this.game.add.text(670, 200, "SAY AGAIN", { font: "60px Arial", fill: 'blue', });
            el3.setShadow(5, 5, "lightblue");
            el3.inputEnabled = true;
            el3.events.onInputDown.add(this.playLector, this);
            this.addChild(el3);
        };
        ListenAndWrite.prototype.checkIfEverythingIsCorrect = function () {
            EU.Log("Selectables: " + EU.checkIfSelectablesAreCorrect(this));
            EU.Log("Fills: " + EU.checkIfFillsAreCorrect(this));
            if (EU.checkIfSelectablesAreCorrect(this) && EU.checkIfFillsAreCorrect(this)) {
                EU.Log("Correct!!!");
                EU.setGameCompletion(this.parent, 1);
                return true;
            }
            EU.setGameCompletion(this.parent, 0);
            return false;
        };
        return ListenAndWrite;
    })(Base.BasicGroup);
    _ListenAndWrite.ListenAndWrite = ListenAndWrite;
})(ListenAndWrite || (ListenAndWrite = {}));
//# sourceMappingURL=ListenAndWrite.js.map