First Ally Complete
This commit is contained in:
parent
23940c0dbd
commit
fd7e0909e8
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue