import {Directive, OnInit} from '@angular/core'; import {Router} from '@angular/router'; import {MicroLessonMetricsService} from '../../services/metrics/micro-lesson-metrics.service'; import {ScreenTypeOx} from 'ox-types'; import {GameService} from '../../services/game.service'; import {SoundOxService} from '../../services/sound-ox.service'; @Directive({ selector: '[mlLevelMenu]' }) export class LevelMenuDirective implements OnInit { public availableLevels: Map; constructor(public audio: SoundOxService, private router: Router, private sound: SoundOxService, private metricsService: MicroLessonMetricsService, private gameService: GameService) { this.availableLevels = new Map([[1, true], [2, true], [3, true], [4, true], [5, true]]); } ngOnInit() { /* this.game.clearExercise(); */ } onClickLevel(number: number) { if (this.availableLevels.get(number)) { this.sound.playSoundEffect('sounds/click.mp3', ScreenTypeOx.GamePreview, true, true, event => { /*this.metricsService.level = number;*/ /* this.game.currentLevel = number; */ this.gameService.currentLevel = number; this.router.navigate(['game'], {queryParams: {level: number}}); }); } else { this.sound.playSoundEffect('sounds/cantClick.mp3', ScreenTypeOx.GamePreview, true, true); } } }