1var game; 2var sh; 3function castleGame(json) { 4 (function (sh) { 5 class App extends Phaser.Game { 6 constructor(json) { 7 App.json = json; 8 9 let config = { 10 type: Phaser.CANVAS, 11 width: App.CANVAS_WIDTH, 12 height: App.CANVAS_HEIGHT, 13 parent: 'game-container', 14 dom: { 15 createContainer: false 16 }, 17 scale: { 18 parent: 'game-container', 19 width: App.CANVAS_WIDTH, 20 height: App.CANVAS_HEIGHT, 21 mode: Phaser.Scale.FIT, 22 autoCenter: Phaser.Scale.CENTER_BOTH 23 }, 24 transparent: true, 25 scene: { 26 create: () => { 27 this.scene.add('Boot', sh.scene.Boot, true); 28 } 29 } 30 }; 31 super(config); 32 window.addEventListener('scroll', () => this.scale.refresh()); 33 } 34 } 35 App.CANVAS_WIDTH = 980; 36 App.CANVAS_HEIGHT = 600; 37 sh.App = App; 38 })(sh || (sh = {})); 39 40 game = new sh.App(json); 41 window.ACTIVE_GAME = game; 42 43 var delayedCalls = []; 44 function delayedCall(delay, callback, args, callbackScope) { 45 let scene = game.scene.getAt(0); 46 if (scene) { 47 let dc = scene.time.delayedCall(delay, callback, args, callbackScope); 48 delayedCalls.push(dc); 49 return dc; 50 } 51 let t = setTimeout(callback, delay); 52 delayedCalls.push(t); 53 return t; 54 } 55 56 function pauseAllDelayedCalls() { 57 for (let dc of delayedCalls) { 58 if (dc instanceof Phaser.Time.TimerEvent) { 59 dc.paused = true; 60 } 61 } 62 } 63 64 function resumeAllDelayedCalls() { 65 for (let dc of delayedCalls) { 66 if (dc instanceof Phaser.Time.TimerEvent) { 67 dc.paused = false; 68 } 69 } 70 } 71 72 function destroyAllDelayedCalls() { 73 for (let dc of delayedCalls) { 74 if (dc instanceof Phaser.Time.TimerEvent) { 75 dc.remove(false); 76 } 77 else { 78 clearTimeout(dc); 79 } 80 } 81 delayedCalls = []; 82 } 83 84 function setPageBackground(bg) { 85 // document.querySelector("html").style.backgroundImage = "url(https://storage.googleapis.com/quran-era-web.appspot.com/assets/games/castle/imgs/" + bg + ".jpg)"; 86 } 87 88 function setupButton(btn, frame) { 89 btn.on('pointerdown', () => { btn.setFrame(frame + '_hover' + '0000'); }); 90 btn.on('pointerover', () => { btn.setFrame(frame + '_hover' + '0000'); game.scene.getAt(0).sound.add("button hover").play(); }); 91 btn.on('pointerout', () => { btn.setFrame(frame + '0000'); }); 92 btn.on('pointerup', () => { btn.setFrame(frame + '0000'); game.scene.getAt(0).sound.add('activity selection - button selection').play(); }); 93 } 94 95 function setupButtonTextureBased(btn, texture, hoverTexture, downTexture) { 96 btn.on('pointerdown', () => { btn.setTexture(downTexture ?? hoverTexture); }); 97 btn.on('pointerover', () => { btn.setTexture(hoverTexture); game.scene.getAt(0).sound.add("button hover").play(); }); 98 btn.on('pointerout', () => { btn.setTexture(texture); }); 99 btn.on('pointerup', () => { btn.setTexture(texture); game.scene.getAt(0).sound.add('activity selection - button selection').play(); }); 100 } 101 102 (function (sh) { 103 var core; 104 (function (core) { 105 class Gameplay { 106 constructor() { 107 this.currentRound = 0; 108 this.currentLetter = 0; 109 this.correctAnswersCount = 0; 110 this.wrongAnswersCount = 0; 111 this.correctAnswersCountThisRound = 0; 112 this.wrongAnswersCountThisRound = 0; 113 this.reset(); 114 let json = game.cache.json.get('gameplay'); 115 this.wrongAnswersToLose = json["wrongAnswersToLose"]; 116 this.numberOfQuestionsPerRound = json["numberOfQuestionsPerRound"]; 117 this.lettersConfig = JSON.parse(JSON.stringify(json["lettersConfig"])); 118 this.rounds = JSON.parse(JSON.stringify(json["rounds"])); 119 this.numberOfRounds = json["numberOfRounds"] ?? this.rounds.length; 120 this.useImages = Boolean(game.cache.json.get('gameplay')["useImages"]); 121 } 122 setupCallbacks(onComplete, onLose) { 123 this.onComplete = onComplete; 124 this.onLose = onLose; 125 } 126 onLetterChosen(forceNewRound) { 127 if (forceNewRound || this.isNewRound()) { 128 return this.nextRound(); 129 } 130 return false; 131 } 132 nextRound() { 133 this.correctAnswersCountThisRound = 0; 134 this.wrongAnswersCountThisRound = 0; 135 this.currentRound++; 136 if (this.isRoundsComplete()) { 137 this.onComplete(this.correctAnswersCount, this.correctAnswersCount); 138 return true; 139 } 140 141 return false; 142 } 143 getCorrectLetterName() { 144 return this.rounds[this.currentRound]['correctLetterName']; 145 } 146 isCorrectLetterAudioQuestionEnable() { 147 return this.rounds[this.currentRound]['audioQuestionEnable']; 148 } 149 getCorrectAudioKey() { 150 return this.lettersConfig[this.getCorrectLetterName()]['correctAudioKey']; 151 } 152 getLetterSoundSfxAudioKey(letter) { 153 return "Q-" + letter; 154 } 155 getCorrectAndLetterSoundSfxAudioKey() { 156 return "Q-" + this.getCorrectLetterName(); 157 } 158 onCorrectAnswer() { 159 this.correctAnswersCountThisRound++; 160 this.correctAnswersCount++; 161 return this.onLetterChosen(); 162 } 163 onWrongAnswer(forceNewRound) { 164 this.wrongAnswersCountThisRound++; 165 this.wrongAnswersCount++; 166 if (this.wrongAnswersCount >= this.wrongAnswersToLose) { 167 this.onLose(this.correctAnswersCount, this.correctAnswersCount); 168 return true; 169 } 170 else { 171 this.onLetterChosen(forceNewRound); 172 } 173 return false; 174 } 175 176 getMaxTotalAnswersCount() { 177 return this.wrongAnswersToLose + this.numberOfRounds - 1; 178 } 179 180 getCurrentTotalAnswersCount() { 181 return this.correctAnswersCount + this.wrongAnswersCount; 182 } 183 isNewRound() { 184 return this.correctAnswersCountThisRound >= 1 || (this.correctAnswersCountThisRound + this.wrongAnswersCountThisRound) === 3 || (this.correctAnswersCountThisRound + this.wrongAnswersCountThisRound) === 0; 185 } 186 isRoundsComplete() { 187 return this.currentRound >= this.numberOfRounds && this.wrongAnswersCount < this.wrongAnswersToLose; 188 } 189 reset() { 190 this.currentRound = 0; 191 this.correctAnswersCount = 0; 192 this.wrongAnswersCount = 0; 193 } 194 getCurrentRoundLetters() { 195 return this.rounds[this.currentRound]["letters"]; 196 } 197 } 198 core.Gameplay = Gameplay; 199 })(core = sh.core || (sh.core = {})); 200 })(sh || (sh = {})); 201 202 (function (sh) { 203 var scene; 204 (function (scene) { 205 class Boot extends Phaser.Scene { 206 init() { 207 //var sm = new FitScaleManager(this.game); 208 //sm.setup(); 209 //this.game.scale.transformX = (pageX) => { 210 // let offsetLeft = 0; 211 // let parentElement = game.canvas.parentElement; 212 // while (parentElement) { 213 // if (parentElement.offsetLeft) { 214 // offsetLeft = parentElement.offsetLeft; 215 // break; 216 // } 217 // parentElement = parentElement.parentElement; 218 // } 219 // return (pageX - offsetLeft) * this.game.scale.displayScale.x; 220 //}; 221 //this.game.scale.transformY = (pageY) => { 222 // let offsetTop = 0; 223 // let parentElement = game.canvas.parentElement; 224 // while (parentElement) { 225 // if (parentElement.offsetTop) { 226 // offsetTop = parentElement.offsetTop; 227 // break; 228 // } 229 // parentElement = parentElement.parentElement; 230 // } 231 // return (pageY - offsetTop) * this.game.scale.displayScale.y; 232 //}; 233 } 234 create() { 235 game.scene.remove('Boot'); 236 game.scene.add('Preloader', sh.scene.Preloader, true); 237 } 238 } 239 scene.Boot = Boot; 240 })(scene = sh.scene || (sh.scene = {})); 241 })(sh || (sh = {})); 242 243 (function (sh) { 244 var scene; 245 (function (scene) {
246 var Gameplay = sh.core.Gameplay; 247 class MainScene extends Phaser.Scene { 248 create() { 249 this.gameplay = new Gameplay(); 250 this.gameplayScreen = new sh.screen.GameplayScreen(this, this.gameplay); 251 this.children.add(this.gameplayScreen); 252 this.gameplayScreen.showInstructionPage(); 253 document.getElementById("game-container").style.visibility = "unset"; 254 } 255 } 256 scene.MainScene = MainScene; 257 })(scene = sh.scene || (sh.scene = {})); 258 })(sh || (sh = {})); 259 260 (function (sh) { 261 var scene; 262 (function (scene) { 263 class Preloader extends Phaser.Scene { 264 preload() { 265 this.load.json('gameplay', sh.App.json); 266 } 267 create() { 268 let json = game.cache.json.get('gameplay'); 269 let lettersConfig = json["lettersConfig"]; 270 271 for (let letterName in lettersConfig) { 272 if (json["useImages"]) this.load.image(letterName, "https://storage.googleapis.com/quran-era-web.appspot.com/assets/games/castle/imgs/letters/" + letterName + ".png"); 273 } 274 275 let rounds = json['rounds']; 276 277 for (var i = 0; i < rounds.length; i++) { 278 var letters = rounds[i]['letters']; 279 280 for (var a = 0; a < letters.length; a++) { 281 var letter = letters[a]; 282 283 this.load.audio(letter, "https://storage.googleapis.com/quran-era-web.appspot.com/assets/games/castle/sound/mp3/letters/" + letter + ".mp3"); 284 285 this.load.audio("Q-" + letter, "https://storage.googleapis.com/quran-era-web.appspot.com/assets/games/castle/sound/mp3/letters/Sounds of the letters/" + letter + ".mp3"); 286 } 287 } 288 289 let progressTxt = this.add.text(game.scale.width / 2, game.scale.height / 2 + 50, "", { 290 "fontFamily": "QuranErafont", 291 "fontSize": 25, 292 "color": "#333333", 293 "align": 'center' 294 }); 295 progressTxt.setOrigin(0.5, 0.5); 296 this.load.pack('preloader', 'https://storage.googleapis.com/quran-era-web.appspot.com/assets/games/castle/pack.json?v=13'); 297 this.load.on('progress', (value) => { 298 progressTxt.text = Math.ceil(value * 100) + "%"; 299 }, this); 300 this.load.on('complete', () => { 301 this.nextScene(); 302 }); 303 this.load.start(); 304 } 305 static playAnim(animKey, sprite, onComplete = null) { 306 let mainScene = game.scene.getScene('ScreenMain'); 307 let data = Preloader.ANIMS_DATA[animKey]; 308 if (!mainScene.anims.exists(animKey)) { 309 mainScene.anims.create({ 310 key: animKey, 311 frames: mainScene.anims.generateFrameNames(data['atlas'], { 312 start: data['start'], end: data['end'], zeroPad: data['padNum'], 313 prefix: data['prefix'], suffix: '' 314 }), 315 frameRate: data['frameRate'], 316 repeat: data['repeat'] 317 }); 318 } 319 if (sprite.anims.currentAnim) { 320 sprite.anims.currentAnim.off('complete'); 321 } 322 sprite.anims.stop(); 323 // sprite.setTexture(data['atlas']); 324 sprite.play(animKey); 325 sprite.anims.currentAnim.once('complete', () => { 326 if (onComplete) 327 onComplete(); 328 }); 329 return sprite; 330 } 331 nextScene() { 332 game.scene.remove('Preloader'); 333 game.scene.add('ScreenMain', sh.scene.MainScene, true); 334 } 335 } 336 Preloader.ANIMS_DATA = { 337 'chestClosed': { 338 'start': 0, 339 'end': 0, 340 'padNum': 2, 341 'prefix': 'Treasure opened_1', 342 'repeat': 0, 343 'frameRate': 24, 344 'atlas': 'chestOpen-atlas' 345 }, 346 'chestOpen': { 347 'start': 0, 348 'end': 74, 349 'padNum': 2, 350 'prefix': 'Treasure opened_1', 351 'repeat': 0, 352 'frameRate': 24, 353 'atlas': 'chestOpen-atlas' 354 }, 355 'chestOpened': { 356 'start': 74, 357 'end': 74, 358 'padNum': 2, 359 'prefix': 'Treasure opened_1', 360 'repeat': 0, 361 'frameRate': 24, 362 'atlas': 'chestOpen-atlas' 363 }, 364 'gamesOpened': { 365 'start': 74, 366 'end': 74, 367 'padNum': 2, 368 'prefix': 'Gates Open _1', 369 'repeat': 0, 370 'frameRate': 24, 371 'atlas': 'gamesOpen-atlas' 372 }, 373 'gamesOpen': { 374 'start': 0, 375 'end': 74, 376 'padNum': 2, 377 'prefix': 'Gates Open _1', 378 'repeat': 0, 379 'frameRate': 24, 380 'atlas': 'gamesOpen-atlas' 381 }, 382 'gamesClosed': { 383 'start': 0, 384 'end': 0, 385 'padNum': 2, 386 'prefix': 'Gates Open _1', 387 'repeat': 0, 388 'frameRate': 24, 389 'atlas': 'gamesOpen-atlas' 390 }, 391 'flame': { 392 'start': 0, 393 'end': 74, 394 'padNum': 2, 395 'prefix': 'Flame _1', 396 'repeat': -1, 397 'frameRate': 24, 398 'atlas': 'flame-atlas' 399 } 400 }; 401 scene.Preloader = Preloader; 402 })(scene = sh.scene || (sh.scene = {})); 403 })(sh || (sh = {})); 404 (function (sh) { 405 var screen;
406 (function (screen) { 407 class AreYouSureWindow extends Phaser.GameObjects.Container { 408 constructor(scene, onYes, onNo) { 409 super(scene); 410 this._areYouSurePage = new Phaser.GameObjects.Image(this.scene, -105, 0 - 48, 'Exit warning'); 411 this._areYouSurePage.setOrigin(0, 0); 412 this._areYouSurePage.setInteractive(); 413 this._btnSureYes = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2 - 95, 485 - 50, 'btnYES1'); 414 this._btnSureYes.setInteractive({ cursor: 'pointer' }); 415 this._btnSureYes.on('pointerup', () => { 416 onYes; 417 window.CLOSE_GAME(); 418 }); 419 var modalTextStyle = { 420 backgroundColor: 'transparent', 421 stroke: '#ffffff', 422 strokeThickness: 2, 423 lineSpacing: 15, 424 fontFamily: 'Kids Rock DEMO', 425 fontSize: 27, 426 color: '#43425d', 427 wordWrap: true, 428 align: 'center' 429 }; 430 var modalText = this.scene.add.text(game.scale.width / 2 + 12, game.scale.height / 2, "Your progress in this activity will not be saved. \n Are you sure you want to exit? ", modalTextStyle); 431 modalText.setOrigin(0.5, 0.5); 432 433 setupButtonTextureBased(this._btnSureYes, 'btnYES1', 'btnYES2'); 434 this._btnSureNo = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2 + 95, 485 - 50, 'btnNO1'); 435 this._btnSureNo.setInteractive({ cursor: 'pointer' }); 436 this._btnSureNo.on('pointerup', onNo); 437 setupButtonTextureBased(this._btnSureNo, 'btnNO1', 'btnNO2'); 438 this.add(this._areYouSurePage); 439 this.add(this._btnSureYes); 440 this.add(this._btnSureNo); 441 this.add(modalText); 442 } 443 } 444 screen.AreYouSureWindow = AreYouSureWindow; 445 })(screen = sh.screen || (sh.screen = {})); 446 })(sh || (sh = {})); 447 448 (function (sh) { 449 var screen; 450 (function (screen) { 451 class CompleteWindow extends Phaser.GameObjects.Container { 452 constructor(scene, onBack, onReplay, onNext) { 453 super(scene); 454 this.music = null; 455 this.setPosition(-104.5, -48); 456 this._bgComplete = new Phaser.GameObjects.Image(this.scene, 0, 0, 'Completion page LATEST UPDATED'); 457 this._bgComplete.setOrigin(0, 0); 458 this._bgComplete.setInteractive(); 459 this._cup = new Phaser.GameObjects.Image(this.scene, 400, 410, 'Trophy'); 460 this._btnReplay = new Phaser.GameObjects.Image(this.scene, 720, 570, 'btnReplay1'); 461 let _CollectedPoints = new Phaser.GameObjects.Image(this.scene, 620, 440, 'Collected Points'); 462 this.totalScoreTxt = this.scene.add.text(845, 352, "", { 463 "fontFamily": "Kids Rock Demo", 464 "fontSize": 35, 465 "color": "#F49F1C", 466 "align": 'center', 467 'stroke': '#70451A', 468 'strokeThickness': 6 469 }); 470 this.totalScoreTxt.setOrigin(0.5, 0.5); 471 let grd = this.totalScoreTxt.context.createLinearGradient(0, 0, 0, this.totalScoreTxt.height); 472 grd.addColorStop(0, '#FFFF00'); 473 grd.addColorStop(1, '#C17316'); 474 this.totalScoreTxt.setFill(grd); 475 this.starScoreTxt = this.scene.add.text(648, 433, "", { 476 "fontFamily": "Kids Rock Demo", 477 "fontSize": 24, 478 "color": "#FFFFFF", 479 "align": 'center' 480 }); 481 this.starScoreTxt.setOrigin(0.5, 0.5); 482 this.add([ 483 this._bgComplete, 484 _CollectedPoints, 485 this._cup, 486 this._btnReplay, 487 this.totalScoreTxt, 488 this.starScoreTxt 489 ]); 490 491 this._btnReplay.setInteractive({ cursor: 'pointer' }); 492 this._btnReplay.once('pointerup', () => { 493 onReplay(this._btnReplay); 494 if (this.music) { 495 this.music.stop(); 496 } 497 }); 498 setupButtonTextureBased(this._btnReplay, 'btnReplay1', 'btnReplay2'); 499 } 500 show(score, starScore) { 501 this._cup.scale = 1.25; 502 this.scene.tweens.add({ 503 targets: this._cup, 504 "scale": 1, 505 duration: 500, 506 ease: Phaser.Math.Easing.Back.Out 507 }); 508 this.totalScoreTxt.text = String(5); 509 this.starScoreTxt.text = String(starScore); 510 // let music = this.scene.sound.add("viktory"); 511 this.music = this.scene.sound.add("Activity completion fantastic"); 512 this.music.play(); 513 } 514 } 515 screen.CompleteWindow = CompleteWindow; 516 })(screen = sh.screen || (sh.screen = {})); 517 })(sh || (sh = {})); 518 519 (function (sh) { 520 var screen;
521 (function (screen) { 522 class GameplayScreen extends Phaser.GameObjects.Container { 523 constructor(scene, gameplay) { 524 super(scene); 525 this.carsPositions = [{ x: 198, y: 595 }, { x: 490, y: 595 }, { x: 790, y: 595 }]; 526 this.bgMusic = null; 527 this.correctAudio = null; 528 this.wfsnd = null; 529 this.showCompleteWindow = (score, starScore) => { 530 let completeWindow = new screen.CompleteWindow(this.scene, (target) => { 531 this.playBtnClickAnim(target); 532 }, (target) => { 533 this.playBtnClickAnim(target); 534 this.destroyGameplay(); 535 this.remove(completeWindow); 536 this.showInstructionPage(); 537 }, (target) => { 538 this.playBtnClickAnim(target); 539 }); 540 this.setLettersInputEnabled(false); 541 delayedCall(8000, () => { 542 setPageBackground("bg-blue"); 543 this.add(completeWindow); 544 completeWindow.show(score, starScore); 545 if (this.bgMusic) this.bgMusic.stop(); 546 }); 547 }; 548 this.showLoseWindow = (score, starScore) => { 549 let tryAgainWindow = new screen.TryAgainWindow(this.scene, (target) => { 550 this.playBtnClickAnim(target); 551 }, (target) => { 552 this.playBtnClickAnim(target); 553 this.destroyGameplay(); 554 this.remove(tryAgainWindow); 555 this.showInstructionPage(); 556 }); 557 this.setLettersInputEnabled(false); 558 delayedCall(2500, () => { 559 setPageBackground("bg-blue"); 560 this.add(tryAgainWindow); 561 tryAgainWindow.show(score, starScore); 562 if (this.bgMusic) this.bgMusic.stop(); 563 }); 564 }; 565 this.gameplay = gameplay; 566 window["t"] = this; 567 } 568 createHexagons() { 569 if (this.bgContainer) { 570 this.gameplayContainer.remove(this.bgContainer); 571 } 572 this.bgContainer = new Phaser.GameObjects.Container(this.scene); 573 574 let prev_gameStageBack = this._gameStageBack; 575 576 this._gameStageBack = new Phaser.GameObjects.Image(this.scene, 491, 350, this.gameplay.currentRound >= this.gameplay.numberOfRounds - 1/*2*/ ? '_gameStageBackBright' : '_gameStageBack'); //bg 577 this._gameStageBack.setScale(0.5, 0.5); 578 this._gameStageBack.setOrigin(0.5, 0.5); 579 this.bgContainer.add(this._gameStageBack); 580 window['this._gameStageBack'] = this._gameStageBack; 581 this._gameStageBack.alpha = 0; 582 583 if (prev_gameStageBack) { 584 prev_gameStageBack.setPosition(game.scale.width / 2, game.scale.height / 2); 585 prev_gameStageBack.setScale(1, 1); 586 this.bgContainer.add(prev_gameStageBack); 587 window['prev_gameStageBack'] = prev_gameStageBack; 588 this.scene.tweens.add({ 589 targets: prev_gameStageBack, 590 alpha: 0, 591 duration: 250, 592 // delay: 200 + _k*250, 593 onComplete: () => { 594 this.bgContainer.remove(prev_gameStageBack); 595 } 596 }); 597 598 this._gameStage = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2, game.scale.height / 2, this.gameplay.currentRound >= this.gameplay.numberOfRounds - 1 ? 'bgBright' : 'bgDark'); 599 window['this._gameStage'] = this._gameStage; 600 this._gameStage.setOrigin(0.5, 0.5); 601 this._gameStage.setInteractive(); 602 // this._gameStage.alpha = 0; 603 /* this.scene.tweens.add({ 604 targets: this._gameStage, 605 alpha: 1, 606 duration: 250, 607 // delay: 200 + _k*250, 608 onComplete: ()=>{ 609 // this.bgContainer.remove(prev_gameStageBack); 610 } 611 }); */ 612 this.bgContainer.add(this._gameStage); 613 } else { 614 this._gameStage = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2, game.scale.height / 2, this.gameplay.currentRound >= this.gameplay.numberOfRounds - 1 ? 'bgBright' : 'bgDark'); 615 window['this._gameStage'] = this._gameStage; 616 this._gameStage.setOrigin(0.5, 0.5); 617 this._gameStage.setInteractive(); 618 this.bgContainer.add(this._gameStage); 619 } 620 this._gameStage.setScale(1.01, 1); 621 this.gameplayContainer.addAt([ 622 this.bgContainer 623 ], 0); 624 625 if (this.contentContainer && this.contentContainer.parentContainer) { 626 this.contentContainer.parentContainer.remove(this.contentContainer); 627 } 628 this.contentContainer = new Phaser.GameObjects.Container(this.scene, 0, 0); 629 this.gameplayContainer.add(this.contentContainer); 630 window['this.contentContainer'] = this.contentContainer; 631 632 this.gate = this.scene.add.sprite(490, 300, 'gamesOpen-atlas'); 633 sh.scene.Preloader.playAnim('gamesClosed', this.gate); 634 this.contentContainer.addAt(this.gate); 635 636 this.flame = this.scene.add.sprite(490, 300, 'flame-atlas'); 637 this.flame.setScale(1.7); 638 sh.scene.Preloader.playAnim('flame', this.flame); 639 window['this.flame'] = this.flame; 640 this.contentContainer.addAt(this.flame); 641 642 let _k = 0; 643 var shadowPositions = [{ x: 208, y: 545 }, { x: 500, y: 545 }, { x: 800, y: 545 }]; 644 for (let sp of shadowPositions) { 645 let shadow = new Phaser.GameObjects.Image(this.scene, sp.x, sp.y, 'shadow'); 646 647 this.contentContainer.add(shadow); 648 649 // if (this.gameplay.currentRound > 0) { 650 shadow.alpha = 0; 651 shadow.setScale(0.5); 652 this.scene.tweens.add({ 653 targets: shadow, 654 alpha: 1, 655 scaleY: 1, 656 scaleX: 1, 657 duration: 150, 658 delay: 250 + _k * 200 659 }); 660 // } 661 _k++; 662 } 663 664 if (this.gameplay.currentRound > 0) { 665 this.contentContainer.alpha = 0; 666 this.scene.tweens.add({ 667 targets: this.contentContainer, 668 alpha: 1, 669 duration: 250, 670 // delay: 200 671 }); 672 } 673 674 this.speakers = []; 675 let _i = 0; 676 var jarr = [1, 2, 3]; 677 678 // if (this.gameplay.currentRound > 0) { 679 delayedCall(350, () => this.scene.sound.add('Blocks appearing in each round').play()) 680 // } 681 682 for (let p of this.carsPositions) { 683 let hc = new Phaser.GameObjects.Container(this.scene, this.carsPositions[_i]['x'], this.carsPositions[_i]['y']); 684 var j = Phaser.Utils.Array.RemoveRandomElement(jarr); 685 686 let h = this.scene.add.sprite(0, 0, 'chestOpen-atlas'); 687 sh.scene.Preloader.playAnim('chestClosed', h); 688 689 h.setOrigin(0.5, 1); 690 hc.add(h); 691 hc["bg"] = h; 692 693 hc["selector"] = new Phaser.GameObjects.Image(this.scene, 20, -220, 'greenSelector'); 694 hc.add(hc["selector"]); 695 696 hc["defX"] = p['x']; 697 hc["defY"] = p['y']; 698 this.speakers.push(hc); 699 this.contentContainer.add(hc); 700 hc['index'] = _i; 701 702 // if (this.gameplay.currentRound > 0) { 703 // hc.y -= 800; 704 hc.alpha = 0; 705 this.scene.tweens.add({ 706 targets: hc, 707 alpha: 1, 708 duration: 150, 709 delay: 350 + _i * 150 710 }); 711 // } 712 713 let playBtn = new Phaser.GameObjects.Image(this.scene, 40, -75, 'btnPlaySnd'); 714 hc.add(playBtn); 715 hc["playBtn"] = playBtn; 716 setupButtonTextureBased(playBtn, 'btnPlaySnd', 'btnPlaySndHover', 'btnPlaySndDown'); 717 playBtn.on('pointerdown', () => { 718 for (let _hc of this.speakers) { 719 if (_hc["playBtn"]["sound"]) _hc["playBtn"]["sound"].stop(); 720 } 721 722 if (!playBtn["sound"]) { 723 playBtn["sound"] = this.scene.sound.add(this.gameplay.getLetterSoundSfxAudioKey(hc["letter"])); 724 } 725 playBtn["sound"].play(); 726 727 if (this.gameplay.correctAnswersCount == 0) { 728 if (!hc["handIcon"] || !hc["handIcon"].visible) return; 729 730 hc['handIcon'].visible = false; 731 732 playBtn["sound"].once('complete', () => { 733 if (hc['index'] > 0) { 734 var nextSpeaker = this.speakers[hc['index'] - 1]; 735 nextSpeaker["handIcon"].visible = true; 736 nextSpeaker["playBtn"].setInteractive({ cursor: 'pointer' }); 737 } else { 738 if (this.gameplay.currentRound == 0) { 739 for (let __hc of this.speakers) { 740 let correctAnswer = __hc["letter"] && __hc["letter"] == this.gameplay.getCorrectLetterName(); 741 if (correctAnswer) { 742 delayedCall(350, () => { 743 __hc["handIcon"].visible = true; 744 __hc["handIcon"].setPosition(55, -200); 745 }) 746 } 747 } 748 } 749 750 for (let _hc of this.speakers) { 751 _hc["selector"].alpha = 0; 752 this.scene.tweens.add({ 753 targets: _hc["selector"], 754 alpha: 1, 755 duration: 150, 756 delay: 200 757 }); 758 _hc["selector"].visible = true; 759 } 760 this.scene.sound.add('Movement fx').play(); 761 } 762 }); 763 } else { 764 let __hc = this.speakers[hc['index']]; 765 __hc["selector"].alpha = 0; 766 this.scene.tweens.add({ 767 targets: __hc["selector"], 768 alpha: 1, 769 duration: 150, 770 delay: 200 771 }); 772 __hc["selector"].visible = true; 773 this.scene.sound.add('Movement fx').play(); 774 } 775 }); 776 777 if (this.gameplay.correctAnswersCount == 0) { 778 hc["selector"].visible = false; 779 780 let handIcon = new Phaser.GameObjects.Image(this.scene, 75, -60, 'Hand Icon'); 781 hc.add(handIcon); 782 hc["handIcon"] = handIcon; 783 this.scene.tweens.add({ 784 targets: handIcon, 785 angle: -5, 786 scaleY: 0.95, 787 scaleX: 0.95, 788 duration: 500, 789 yoyo: true, 790 repeat: -1, 791 }); 792 793 if (_i == 2) { 794 handIcon.visible = false; 795 delayedCall(5200, () => { 796 handIcon.visible = true; 797 playBtn.setInteractive({ cursor: 'pointer' }); 798 }); 799 } else { 800 handIcon.visible = false; 801 } 802 } else { 803 hc["selector"].visible = false; 804 playBtn.setInteractive({ cursor: 'pointer' }); 805 } 806 807 _i++; 808 } 809 window['this.cars'] = this.speakers; 810 811 this.imgFrame = new Phaser.GameObjects.Image(this.scene, 490, 85, 'Frame'); 812 this.imgFrame.setScale(1.0373) 813 window['this.imgFrame'] = this.imgFrame; 814 this.contentContainer.add(this.imgFrame); 815 816 this.questionContainer = new Phaser.GameObjects.Container(this.scene, 980 / 2, 85); window['this.questionContainer'] = this.questionContainer; 817 818 if (this.gameplay.useImages) { 819 this.questionWordText = new Phaser.GameObjects.Image(this.scene, -3, 0, this.gameplay.getCorrectLetterName()); 820 } else { 821 this.questionWordText = this.scene.add.text(-3, 0, this.gameplay.getCorrectLetterName(), { 822 "fontFamily": "QuranErafont", 823 "fontSize": 65, 824 "color": "#333333", 825 "align": 'center' 826 }); 827 this.questionWordText.setOrigin(0.5, 0.5); 828 this.questionWordText.se
828tPadding({ left: 0, right: 0, top: 65, bottom: 65 }); 829 } 830 if (this.questionWordText.width > 275) this.questionWordText.setScale(275 / this.questionWordText.width); 831 window['this.questionWordText'] = this.questionWordText; 832 this.questionContainer.add(this.questionWordText); 833 this.contentContainer.add(this.questionContainer); 834 this.questionContainer.alpha = 0; 835 this.scene.tweens.add({ 836 targets: this.questionContainer, 837 alpha: 1, 838 duration: 400, 839 delay: 500 840 }); 841 } 842 createLetters() { 843 this.letters = this.gameplay.getCurrentRoundLetters(); 844 } 845 showGameplay() { 846 this.isLost = false; 847 setPageBackground("bg-australia"); 848 this.bgMusic = this.scene.sound.add("bg_sound"); 849 this.bgMusic.play(); 850 this.bgMusic.loop = true; 851 852 this.gameplay.reset(); 853 854 window['this.bgContainer'] = this.bgContainer; 855 this._btnClose = new Phaser.GameObjects.Image(this.scene, 1025 - 105, 100 - 50, 'x Button'); 856 this._btnClose.setInteractive({ cursor: 'pointer' }); 857 this._btnClose["defScale"] = this._btnClose.scale; 858 setupButtonTextureBased(this._btnClose, 'x Button', 'x Button HOVER EFFECT'); 859 this.gameplayContainer = new Phaser.GameObjects.Container(this.scene); 860 if (this.___gameStageBack) this.remove(this.___gameStageBack); 861 else this.___gameStageBack = new Phaser.GameObjects.Image(this.scene, 490, 300, '_gameStageBack'); 862 window['this.___gameStageBack'] = this.___gameStageBack; 863 if (!this.tallyContainer) this.tallyContainer = new Phaser.GameObjects.Container(this.scene); 864 this.tallyContainer.removeAll(); 865 this.addAt(this.gameplayContainer, 0); 866 this.addAt(this.___gameStageBack, 0); 867 this.add([ 868 this.tallyContainer, 869 this._btnClose 870 ]); 871 window['this._gameStage'] = this._gameStage; 872 window['this.gameplayContainer'] = this.gameplayContainer; 873 874 this.createBeehives(); 875 this.shuffleOutHexagons(); 876 this.gameplay.setupCallbacks(this.showCompleteWindow, this.showLoseWindow); 877 } 878 createBeehives() { 879 let startX = 940; 880 let startY = 110; 881 let dy = 35; 882 let _BeehiveEmptyArrayPositions = []; 883 for (let i = 0; i < this.gameplay.getMaxTotalAnswersCount(); i++) { 884 _BeehiveEmptyArrayPositions.push({ x: startX, y: startY + i * dy }); 885 } 886 this._BeehiveEmptyArray = []; window["_BeehiveEmptyArray"] = this._BeehiveEmptyArray; 887 this._Beehive = []; 888 for (let p of _BeehiveEmptyArrayPositions) { 889 let _BeehiveEmpty = new Phaser.GameObjects.Image(this.scene, p['x'], p['y'], 'Beehive 1 Empty'); 890 this._BeehiveEmptyArray.push(_BeehiveEmpty); 891 _BeehiveEmpty.visible = false; 892 let _Beehive = new Phaser.GameObjects.Image(this.scene, p['x'], p['y'], 'Beehive 1'); 893 this._Beehive.push(_Beehive); 894 } 895 for (let bea of this._BeehiveEmptyArray) { 896 this.tallyContainer.add(bea); 897 } 898 for (let bee of this._Beehive) { 899 this.tallyContainer.add(bee); 900 bee.visible = false; 901 } 902 } 903 randomizeLettersPosition() { 904 let hx = this.speakers.slice(); 905 for (let l of this.letters) { 906 if (hx.length == 0) 907 return; 908 let hc = Phaser.Utils.Array.RemoveRandomElement(hx); 909 hc["letter"] = l; 910 } 911 } 912 shuffleOutHexagons() { 913 this.createHexagons(); 914 915 let setLettersInputEnabled = () => { 916 // if (this.correctAudio && this.correctAudio.isPlaying) { 917 delayedCall(/* (this.correctAudio.duration * 0.75) * */ 1000, () => { 918 this.setLettersInputEnabled(true); 919 }); 920 // } 921 // else { 922 // this.setLettersInputEnabled(true); 923 // } 924 }; 925 926 if (!this.gameplay.isRoundsComplete()) { 927 let c = this.gameplay.getCurrentTotalAnswersCount(); 928 delayedCall(500, () => { 929 if (this.gameplay.isCorrectLetterAudioQuestionEnable() && c == 0) { 930 this.playCorrectAudio(); 931 } 932 setLettersInputEnabled(); 933 }); 934 } 935 936 if (this.sfxCarAccelerating) { 937 this.sfxCarAccelerating.stop(); 938 this.sfxCarAccelerating = null; 939 } 940 if (this.sfxWrong) { 941 this.sfxWrong.stop(); 942 this.sfxWrong = null; 943 } 944 945 if (!this.gameplay.isRoundsComplete()) { 946 this.createLetters(); 947 this.randomizeLettersPosition(); 948 } 949 950 this.setLettersInputEnabled(false); 951 // Phaser.Utils.Array.Shuffle(this.carsPositions); 952 let cars = this.speakers; 953 for (let i = 0; i < cars.length; i++) { 954 let hc = cars[i]; 955 hc["defX"] = this.carsPositions[i]["x"]; 956 hc["defY"] = this.carsPositions[i]["y"]; 957 958 this.scene.tweens.killTweensOf(hc); 959 }
960 for (let c of cars) this.gameplayContainer.remove(c); 961 this.speakers.sort((c1, c2) => c1.y - c2.y); 962 // for (let c of cars) this.gameplayContainer.add(c); 963 964 this.createInput(); 965 966 if (this.gameplay.currentRound > 0) { 967 if (this.gameplay.currentRound == this.gameplay.numberOfRounds - 1) { 968 this.garden = new Phaser.GameObjects.Image(this.scene, 491, 350, 'garden'); 969 this.garden.setOrigin(0.5, 0.5); 970 this.garden.setScale(0.5, 0.5); 971 this.garden.setInteractive(); 972 this.bgContainer.add(this.garden); 973 window['this.garden'] = this.garden; 974 this.garden.alpha = 0; 975 976 this.bgBright = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2, game.scale.height / 2, 'bgBright'); 977 this.bgBright.setOrigin(0.5, 0.5); 978 this.bgBright.setInteractive(); 979 this.bgContainer.add(this.bgBright); 980 /* this.bgBright.alpha = 0; 981 this.scene.tweens.add({ 982 targets: this.bgBright, 983 alpha: 1, 984 duration: 500 985 }); */ 986 987 this.bgMusic.stop(); 988 this.bgMusic = this.scene.sound.add("Garden ambience"); 989 this.bgMusic.play(); 990 this.bgMusic.loop = true; 991 } 992 993 this.gameplayContainer.setScale(1, 1); 994 this.gameplayContainer.setPosition(0, 0); 995 996 /* this.gameplayContainer.alpha = 0; 997 this.scene.tweens.add({ 998 targets: this.gameplayContainer, 999 alpha: 1, 1000 duration: 350 1001 }); */ 1002 1003 /* this.gameplayContainer.setPosition(-1720, -1110); 1004 this.gameplayContainer.setScale(4.5,4.5); 1005 this.scene.tweens.add({ 1006 targets: this.gameplayContainer, 1007 x: 0, 1008 y: 0, 1009 scaleX: 1, 1010 scaleY: 1, 1011 duration: 1000, 1012 ease: Phaser.Math.Easing.Quartic.Out 1013 }); 1014 this.gate.alpha = 0; 1015 this.scene.tweens.add({ 1016 targets: this.gate, 1017 alpha: 1, 1018 duration: 500 1019 }); */ 1020 } 1021 } 1022 shuffleInHexagons() { 1023 let positions = this.carsPositions.slice(); 1024 this.setLettersInputEnabled(false); 1025 1026 // delayedCall(600, () => { 1027 // this.scene.sound.add('move to centre').play(); 1028 this.shuffleOutHexagons(); 1029 // }); 1030 window['t'] = this; 1031 } 1032 moveIntoGatesAnimation(moveInDuration, onComplete) { 1033 this.scene.sound.add('Metal gate opens').play(); 1034 sh.scene.Preloader.playAnim('gamesOpen', this.gate); 1035 let __gameStageBack = this._gameStageBack; 1036 delayedCall(2000, () => { 1037 this.scene.sound.add('Entering another room sound').play(); 1038 this.scene.tweens.add({ 1039 targets: this.gameplayContainer, 1040 x: -1720, 1041 y: -1120, 1042 scaleX: 4.5, 1043 scaleY: 4.5, 1044 duration: moveInDuration, 1045 onComplete: onComplete, 1046 ease: Phaser.Math.Easing.Quartic.In 1047 }); 1048 if (this.garden) { 1049 this.scene.tweens.add({ 1050 targets: this.garden, 1051 y: 315, 1052 duration: moveInDuration - 125, 1053 ease: Phaser.Math.Easing.Quartic.In 1054 }); 1055 this.scene.tweens.add({ 1056 targets: this.garden, 1057 scaleX: 1 / 4.5 * 1.005, 1058 scaleY: 1 / 4.5 * 1.005, 1059 duration: moveInDuration, 1060 ease: Phaser.Math.Easing.Quartic.In 1061 }); 1062 } 1063 if (__gameStageBack) { 1064 this.scene.tweens.add({ 1065 targets: __gameStageBack, 1066 y: 315, 1067 duration: moveInDuration - 125, 1068 ease: Phaser.Math.Easing.Quartic.In 1069 }); 1070 this.scene.tweens.add({ 1071 targets: __gameStageBack, 1072 scaleX: 1 / 4.5, 1073 scaleY: 1 / 4.5, 1074 duration: moveInDuration, 1075 ease: Phaser.Math.Easing.Quartic.In 1076 }); 1077 } 1078 }); 1079 } 1080 createInput() { 1081 for (let hc of this.speakers) { 1082 let correctAnswer = hc["letter"] && hc["letter"] == this.gameplay.getCorrectLetterName(); 1083 hc["selector"].once('pointerup', () => { 1084 if (hc["handIcon"]) hc["handIcon"].visible = false; 1085 1086 this.scene.tweens.add({ 1087 targets: hc["selector"], 1088 scaleX: 0.9, 1089 scaleY: 0.9, 1090 duration: 100, 1091 yoyo: true 1092 }); 1093 // if (hc["Wrong Box"].visible) return; 1094 // this.playBtnClickAnim(hc); 1095 let lost = false; 1096 if (correctAnswer) { 1097 if (this.gameplay.currentRound >= this.gameplay.numberOfRounds - 1) { 1098 this.scene.tweens.add({ 1099 targets: this.garden, 1100 alpha: 1, 1101 duration: 500 1102 }); 1103 } else { 1104 this.scene.tweens.add({ 1105 targets: this._gameStageBack, 1106 alpha: 1, 1107 duration: 500 1108 }); 1109 } 1110 1111 hc.parentContainer.bringToTop(hc); 1112 sh.scene.Preloader.playAnim('chestOpen', hc["bg"]); 1113 1114 this.scene.sound.add('Correct selection - chest opens').play(); 1115 1116 this.setLettersInputEnabled(false); 1117 hc["selector"].setTexture("greenSelectorCorrect"); 1118 1119 let completed = this.onCorrectAnswer(); 1120 1121 for (let _hc of this.speakers) { 1122 _hc["selector"].visible = false; 1123 _hc["playBtn"].disableInteractive(); 1124 } 1125 1126 delayedCall(1050, () => { 1127 /* this.scene.tweens.add({ 1128 targets: this.questionContainer, 1129 alpha: 0, 1130 duration: 400, 1131 delay: 650 1132 }); */ 1133 // this.scene.sound.add('Text from earth popping up').play(); 1134 }); 1135 delayedCall(1550, () => { 1136 /* for (let _sp of this.speakers) { 1137 this.scene.tweens.add({ 1138 targets: _sp, 1139 duration: 250, 1140 delay: 250, 1141 alpha: 0 1142 }); 1143 } */ 1144 1145 this.moveIntoGatesAnimation(completed ? 1000 : 1000, () => { 1146 delayedCall(completed ? 0 : 250, () => { 1147 if (!completed) { 1148 this.shuffleInHexagons(); 1149 } else { 1150 delayedCall(700, () => this.scene.sound.add('Final celebration').play()); 1151 1152 /* this.garden = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2, game.scale.height / 2, 'garden'); 1153 this.garden.setOrigin(0.5, 0.5); 1154 this.garden.setInteractive(); 1155 this.gameplayContainer.add(this.garden); 1156 this.garden.alpha = 0; 1157 this.scene.tweens.add({ 1158 targets: this.garden, 1159 alpha: 1, 1160 duration: 350 1161 }); */ 1162 1163 /* this.gameplayContainer.setScale(1,1); 1164 this.gameplayContainer.setPosition(0, 0); */ 1165 } 1166 }); 1167 }); 1168 }); 1169 } 1170 else { 1171 hc["selector"].setTexture('redSelector'); 1172 1173 this.scene.tweens.add({ 1174 targets: hc["selector"], 1175 alpha: 0, 1176 duration: 500, 1177 delay: 200 1178 }); 1179 1180 lost = this.onWrongAnswer(); 1181 if (!lost) { 1182 // this.shuffleInHexagons(); 1183 } else { 1184 this.setLettersInputEnabled(false); 1185 for (let sp of this.speakers) { 1186 sp["playBtn"].disableInteractive(); 1187 } 1188 this.isLost = true; 1189 } 1190 } 1191 }); 1192 } 1193 1194 this._btnClose.on('pointerup', () => { 1195 this.playBtnClickAnim(this._btnClose); 1196 this.onCloseClick(); 1197 }); 1198 } 1199 hideAllUnusedBeehives() { 1200 let i = this.gameplay.getCurrentTotalAnswersCount(); 1201 for (let k = i + 1; k < this._BeehiveEmptyArray.length; k++) { 1202 this._BeehiveEmptyArray[k].visible = false; 1203 this._Beehive[k].visible = false; 1204 } 1205 } 1206 onCorrectAnswer() { 1207 let i = this.gameplay.getCurrentTotalAnswersCount(); 1208 if (i < this._BeehiveEmptyArray.length) { 1209 this._BeehiveEmptyArray[i].visible = false; 1210 this._Beehive[i].visible = true; 1211 } 1212 this.hideAllUnusedBeehives(); 1213 let completed = this.gameplay.onCorrectAnswer(); 1214 this.scene.sound.add('Correct sfx').play(); 1215 // this.sfxCarAccelerating = this.scene.sound.add('Car accelerating'); 1216 // this.sfxCarAccelerating.play(); 1217 // delayedCall(250, () => { 1218 // this.scene.sound.add(this.gameplay.getCorrectAndLetterSoundSfxAudioKey()).play(); 1219 // }); 1220 return completed; 1221 } 1222 onWrongAnswer(forceNewRound) { 1223 let i = this.gameplay.getCurrentTotalAnswersCount(); 1224 if (i < this._BeehiveEmptyArray.length) { 1225 this._BeehiveEmptyArray[i].visible = true; 1226 this._Beehive[i].visible = false; 1227 } 1228 this.hideAllUnusedBeehives(); 1229 let lost = this.gameplay.onWrongAnswer(forceNewRound); 1230 this.sfxWrong = this.scene.sound.add("wrong sfx"); 1231 this.sfxWrong.play(); 1232 return lost; 1233 } 1234 playCorrectAudio() { 1235 if (this.correctAudio) { 1236 this.correctAudio.stop(); 1237 } 1238 this.correctAudio = this.scene.sound.add("questionAudio"/* this.gameplay.getCorrectAudioKey() */); 1239 this.correctAudio.play(); 1240 if (this.areYouSureWindow && this.areYouSureWindow.parentContainer == this) { 1241 this.correctAudio.pause(); 1242 } 1243 } 1244 onSoundClick() { 1245 this.playCorrectAudio(); 1246 } 1247 onCloseClick() { 1248 this.showAreYouSurePage(); 1249 this.scene.sound.add('warning page pop up sfx').play(); 1250 } 1251 playBtnClickAnim(target) { 1252 let sc = target["defScale"] ? target["defScale"] : 1; 1253 target.scaleX = target.scaleY = sc; 1254 this.scene.tweens.add({ 1255 targets: target, 1256 "scaleX": 0.9 * sc, 1257 "scaleY": 0.9 * sc, 1258 duration: 100, 1259 yoyo: true 1260 }); 1261 } 1262 showInstructionPage() {
1263 setPageBackground("bg-blue"); 1264 this.instructionPage = new screen.InstructionPage(this.scene, (target) => { 1265 this.playBtnClickAnim(target); 1266 this.remove(this.instructionPage); 1267 this.showGameplay(); 1268 if (this.wfsnd) { 1269 this.wfsnd.stop(); 1270 } 1271 }, (target) => { 1272 this.playBtnClickAnim(target); 1273 if (this.wfsnd) { 1274 this.wfsnd.stop(); 1275 } 1276 if (!game.cache.json.get('gameplay')['welcomeAudioDisabled']) { 1277 this.wfsnd = this.scene.sound.add("Welcome Find the sound"); 1278 this.wfsnd.play(); 1279 } 1280 }); 1281 this.add(this.instructionPage); 1282 try { 1283 if (!game.cache.json.get('gameplay')['welcomeAudioDisabled']) { 1284 this.wfsnd = this.scene.sound.add("Welcome Find the sound"); 1285 this.wfsnd.play(); 1286 } 1287 } 1288 catch (e) { 1289 console.error(e); 1290 } 1291 } 1292 showAreYouSurePage() { 1293 /* for (let j = 0; j < this.cars.length; j++) { 1294 if (this.cars[j]["raceTween"]) { 1295 this.cars[j]["raceTween"].pause(); 1296 } 1297 } */ 1298 1299 pauseAllDelayedCalls(); 1300 setPageBackground("bg-blue"); 1301 this.pauseSounds(); 1302 if (!this.areYouSureWindow) this.areYouSureWindow = new screen.AreYouSureWindow(this.scene, () => { 1303 this.remove(this.areYouSureWindow); 1304 this.destroyGameplay(); 1305 this.showInstructionPage(); 1306 }, () => { 1307 this.remove(this.areYouSureWindow); 1308 this.unpauseSounds(); 1309 resumeAllDelayedCalls(); 1310 1311 /* for (let j = 0; j < this.cars.length; j++) { 1312 if (this.cars[j]["raceTween"]) { 1313 this.cars[j]["raceTween"].resume(); 1314 } 1315 } */ 1316 1317 setPageBackground("bg-australia"); 1318 }); 1319 this.add(this.areYouSureWindow); 1320 } 1321 setLettersInputEnabled(enabled) { 1322 if (enabled) { 1323 for (let hc of this.speakers) { 1324 hc["selector"].setInteractive({ cursor: 'pointer' }); 1325 } 1326 } 1327 else { 1328 for (let hc of this.speakers) { 1329 hc["selector"].disableInteractive(); 1330 } 1331 } 1332 } 1333 pauseSounds() { 1334 if (this.correctAudio) 1335 this.correctAudio.pause(); 1336 if (this.bgMusic) 1337 this.bgMusic.pause(); 1338 } 1339 unpauseSounds() { 1340 if (this.correctAudio) 1341 this.correctAudio.resume(); 1342 if (this.bgMusic) 1343 this.bgMusic.resume(); 1344 } 1345 destroyGameplay() { 1346 this.setLettersInputEnabled(false); 1347 this.remove(this.gameplayContainer); 1348 this.scene.sound.stopAll(); 1349 destroyAllDelayedCalls(); 1350 } 1351 } 1352 screen.GameplayScreen = GameplayScreen; 1353 })(screen = sh.screen || (sh.screen = {})); 1354 })(sh || (sh = {})); 1355 (function (sh) { 1356 var screen;
1357 (function (screen) { 1358 class InstructionPage extends Phaser.GameObjects.Container { 1359 constructor(scene, onPlayClick, onSndClick) { 1360 super(scene); 1361 this._instructionPage = new Phaser.GameObjects.Image(this.scene, 0 - 105, 0 - 48, 'Instructions page ALL ACTIVITY TITLEs'); 1362 this._instructionPage.setOrigin(0, 0); 1363 this._instructionPage.setInteractive(); 1364 1365 this._instructionPageTitle = this.scene.add.text(475, 110, sh.App.json.instructionTitle ?? 'Castle', { 1366 "fontFamily": "Kids Rock DEMO", 1367 "fontSize": 35, 1368 "color": "#43425D", 1369 "align": 'center' 1370 }); 1371 this._instructionPageTitle.setOrigin(0.5, 0.5); 1372 window['this._instructionPageTitle'] = this._instructionPageTitle; 1373 this._instructionPageTitle.setStroke('#ffffff', 5); 1374 // Apply the gradient fill. 1375 const gradient = this._instructionPageTitle.context.createLinearGradient(0, 0, 0, this._instructionPageTitle.height); 1376 gradient.addColorStop(0, '#eeef67'); 1377 gradient.addColorStop(0.55, '#e98c2c'); 1378 gradient.addColorStop(1, '#91301a'); 1379 this._instructionPageTitle.setFill(gradient); 1380 1381 this._btnPlay = new Phaser.GameObjects.Image(this.scene, game.scale.width / 2, 480 - 50, 'btnPLAY1'); 1382 this._btnPlay.setInteractive({ cursor: 'pointer' }); 1383 this._btnPlay.once('pointerup', onPlayClick); 1384 setupButtonTextureBased(this._btnPlay, 'btnPLAY1', 'btnPLAY2'); 1385 this.instrTxt = this.scene.add.text(game.scale.width / 2, game.scale.height / 2, "Listen to the code and match it to\n the word.", { 1386 "fontFamily": "Kids Rock DEMO", 1387 "fontSize": 30, 1388 "lineSpacing": 15, 1389 "color": "#43425D", 1390 "align": 'center' 1391 }); 1392 this.instrTxt.setOrigin(0.5, 0.5); 1393 this._btnSoundInstruction = new Phaser.GameObjects.Image(this.scene, 800 - 105, 156 - 50, 'Sound'); 1394 this._btnSoundInstruction.setInteractive({ cursor: 'pointer' }); 1395 this._btnSoundInstruction.on('pointerup', onSndClick); 1396 this._btnSoundInstruction["defScale"] = this._btnSoundInstruction.scale; 1397 setupButtonTextureBased(this._btnSoundInstruction, 'Sound', 'Sound HOVER EFFECT'); 1398 this.add(this._instructionPage); 1399 this.add(this._instructionPageTitle); 1400 this.add(this.instrTxt); 1401 this.add(this._btnPlay); 1402 this.add(this._btnSoundInstruction); 1403 } 1404 } 1405 screen.InstructionPage = InstructionPage; 1406 })(screen = sh.screen || (sh.screen = {})); 1407 })(sh || (sh = {})); 1408 (function (sh) { 1409 var screen; 1410 (function (screen) { 1411 class TryAgainWindow extends Phaser.GameObjects.Container { 1412 constructor(scene, onBack, onReplay) { 1413 super(scene); 1414 this.music = null; 1415 this.setPosition(-106, -48); 1416 this._bg = new Phaser.GameObjects.Image(this.scene, 0, 0, 'Try again page'); 1417 this._bg.setOrigin(0, 0); 1418 this._bg.setInteractive(); 1419 this._star = new Phaser.GameObjects.Image(this.scene, 400, 415, 'Break Star'); 1420 this._btnReplay = new Phaser.GameObjects.Image(this.scene, 765, 580, 'btnReplay1'); 1421 this.totalScoreTxt = this.scene.add.text(850, 355, "", { 1422 "fontFamily": "Kids Rock Demo", 1423 "fontSize": 35, 1424 "color": "#F49F1C", 1425 "align": 'center', 1426 'stroke': '#70451A', 1427 'strokeThickness': 6 1428 }); 1429 this.totalScoreTxt.setOrigin(0.5, 0.5); 1430 let grd = this.totalScoreTxt.context.createLinearGradient(0, 0, 0, this.totalScoreTxt.height); 1431 grd.addColorStop(0, '#FFFF00'); 1432 grd.addColorStop(1, '#C17316'); 1433 this.totalScoreTxt.setFill(grd); 1434 this.starScoreTxt = this.scene.add.text(635, 431, "", { 1435 "fontFamily": "Kids Rock Demo", 1436 "fontSize": 24, 1437 "color": "#FFFFFF", 1438 "align": 'center' 1439 }); 1440 this.starScoreTxt.setOrigin(0.5, 0.5); 1441 this.add([ 1442 this._bg, 1443 this._star, 1444 this._btnReplay, 1445 this.totalScoreTxt, 1446 this.starScoreTxt 1447 ]); 1448 1449 this._btnReplay.setInteractive({ cursor: 'pointer' }); 1450 this._btnReplay.once('pointerup', () => { 1451 onReplay(this._btnReplay); 1452 if (this.music) { 1453 this.music.stop(); 1454 } 1455 }); 1456 setupButtonTextureBased(this._btnReplay, 'btnReplay1', 'btnReplay2'); 1457 } 1458 show(score, starScore) { 1459 this._star.scale = 1.25; 1460 this.scene.tweens.add({ 1461 targets: this._star, 1462 "scale": 1, 1463 duration: 500, 1464 ease: Phaser.Math.Easing.Back.Out 1465 }); 1466 this.totalScoreTxt.text = String(5); 1467 this.starScoreTxt.text = String(0); 1468 this.music = this.scene.sound.add("Fail - close one"); 1469 this.music.play(); 1470 } 1471 } 1472 screen.TryAgainWindow = TryAgainWindow; 1473 })(screen = sh.screen || (sh.screen = {})); 1474 })(sh || (sh = {})); 1475} 1476 1477function destroyCastleGame() { 1478 if (game) { 1479 game.destroy(); 1480 } 1481}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.