diff --git a/assets/goblin-a1.mp3 b/assets/goblin-a1.mp3 new file mode 100644 index 0000000..8e1012a Binary files /dev/null and b/assets/goblin-a1.mp3 differ diff --git a/assets/goblin-a2.mp3 b/assets/goblin-a2.mp3 new file mode 100644 index 0000000..fedd49e Binary files /dev/null and b/assets/goblin-a2.mp3 differ diff --git a/assets/goblin-a3.mp3 b/assets/goblin-a3.mp3 new file mode 100644 index 0000000..a07ff7b Binary files /dev/null and b/assets/goblin-a3.mp3 differ diff --git a/assets/goblin-b.mp3 b/assets/goblin-b.mp3 new file mode 100644 index 0000000..a8e9d84 Binary files /dev/null and b/assets/goblin-b.mp3 differ diff --git a/assets/goblin-c.mp3 b/assets/goblin-c.mp3 new file mode 100644 index 0000000..6ea8c5f Binary files /dev/null and b/assets/goblin-c.mp3 differ diff --git a/assets/goblin-intro.mp3 b/assets/goblin-intro.mp3 new file mode 100644 index 0000000..48e947d Binary files /dev/null and b/assets/goblin-intro.mp3 differ diff --git a/assets/goblin-outro.mp3 b/assets/goblin-outro.mp3 new file mode 100644 index 0000000..2e750cf Binary files /dev/null and b/assets/goblin-outro.mp3 differ diff --git a/src/GameScene.js b/src/GameScene.js index f60757c..d274d12 100644 --- a/src/GameScene.js +++ b/src/GameScene.js @@ -17,7 +17,7 @@ export class GameScene extends Phaser.Scene { this.numberOfJewels = 4; this.startRows = 3; this.level = 1; - this.matchesNeeded = 10; + this.matchesNeeded = 8; this.score = 0; this.ally = 'goblin'; @@ -27,6 +27,7 @@ export class GameScene extends Phaser.Scene { this.isDestroying = false; this.isMovingUp = false; this.isPlayingVideo = false; + this.isPlayingAudio = false; // Add selectedJewel property this.selectedJewel = null; @@ -56,11 +57,21 @@ export class GameScene extends Phaser.Scene { this.load.audio('level-up', 'assets/level-up.mp3'); this.load.audio('switch', 'assets/switch.mp3'); - // Ally Videos - this.load.video('goblin-resting', 'assets/goblin-resting.mp4'); - this.load.video('goblin-excited', 'assets/goblin-excited.mp4'); - this.load.video('goblin-pleased', 'assets/goblin-pleased.mp4'); - this.load.video('goblin-match', 'assets/goblin-match.mp4'); + // Ally Assets + const allys = ['goblin']; + allys.forEach((ally) => { + this.load.video(`${ally}-resting`, 'assets/goblin-resting.mp4'); + this.load.video(`${ally}-excited`, 'assets/goblin-excited.mp4'); + this.load.video(`${ally}-pleased`, 'assets/goblin-pleased.mp4'); + this.load.video(`${ally}-match`, 'assets/goblin-match.mp4'); + this.load.audio(`${ally}-a1`, 'assets/goblin-a1.mp3'); + this.load.audio(`${ally}-a2`, 'assets/goblin-a2.mp3'); + this.load.audio(`${ally}-a3`, 'assets/goblin-a3.mp3'); + this.load.audio(`${ally}-b`, 'assets/goblin-b.mp3'); + this.load.audio(`${ally}-c`, 'assets/goblin-c.mp3'); + this.load.audio(`${ally}-intro`, 'assets/goblin-intro.mp3'); + this.load.audio(`${ally}-outro`, 'assets/goblin-outro.mp3'); + }); } create() { @@ -73,7 +84,7 @@ export class GameScene extends Phaser.Scene { this.createStart(); // Background Music - this.bgMusic = this.sound.add('goblin-music', { volume: 0.5 }); + this.bgMusic = this.sound.add('goblin-music', { volume: 0.2 }); this.bgMusic.loop = true; this.bgMusic.play(); @@ -131,6 +142,9 @@ export class GameScene extends Phaser.Scene { this.allyVideo = this.add.video(350, 610, `${this.ally}-resting`).setOrigin(0.5); this.allyVideo.play(true); + this.time.delayedCall(500, () => { + this.sound.play(`${this.ally}-intro`); + }); } update(time, delta) { @@ -519,6 +533,7 @@ export class GameScene extends Phaser.Scene { // If we found matches, destroy them and play video if (matchedJewels.size > 0) { this.playVideo(matchedJewels.size); + this.playAudio(matchedJewels.size); const scoreMatches = matchedJewels.size / 3; const scoreAdd = Math.ceil(scoreMatches ** 2) * 10; this.score += scoreAdd; @@ -551,7 +566,28 @@ export class GameScene extends Phaser.Scene { this.time.delayedCall(5000, () => { this.isPlayingVideo = false; showVideo.destroy(); - console.log('end video'); + }); + } + + playAudio(amount) { + if (this.isPlayingAudio === true) { + return; + } + + this.isPlayingAudio = true; + let audio = null; + + if (amount >= 5) { + audio = `${this.ally}-c`; + } else if (amount >= 4) { + audio = `${this.ally}-b`; + } else { + const rand = Phaser.Math.Between(1, 3); + audio = `${this.ally}-a${rand}`; + } + this.sound.play(audio); + this.time.delayedCall(2000, () => { + this.isPlayingAudio = false; }); } diff --git a/src/config.js b/src/config.js index 7e35a18..1d696de 100644 --- a/src/config.js +++ b/src/config.js @@ -1,42 +1,50 @@ export const LEVEL_CONFIG = { 1: { numberOfJewels: 4, - matchesNeeded: 12, - moveInterval: 12000 + matchesNeeded: 8, + moveInterval: 12000, + ally: 'goblin' }, 2: { numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 12000 + matchesNeeded: 8, + moveInterval: 12000, + ally: 'goblin' }, 3: { numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 11000 + matchesNeeded: 9, + moveInterval: 11000, + ally: 'goblin' }, 4: { numberOfJewels: 5, - matchesNeeded: 12, - moveInterval: 10000 + matchesNeeded: 10, + moveInterval: 10000, + ally: 'goblin' }, 5: { numberOfJewels: 5, matchesNeeded: 12, - moveInterval: 9000 + moveInterval: 9000, + ally: 'goblin' }, 6: { numberOfJewels: 5, matchesNeeded: 12, - moveInterval: 8000 + moveInterval: 8000, + ally: 'goblin' }, 7: { numberOfJewels: 5, matchesNeeded: 12, - moveInterval: 7000 + moveInterval: 7000, + ally: 'goblin' }, 8: { numberOfJewels: 5, matchesNeeded: 12, - moveInterval: 6000 + moveInterval: 6000, + ally: 'goblin' } };