Commit 5af28e1d authored by 18손재민's avatar 18손재민

Merge branch 'sound'

# Conflicts:
#	js/Client.js
#	js/ScenesData.js
#	js/WordObject.js
parents 4ecd322b 083dc35e
No preview for this file type
...@@ -3,10 +3,28 @@ var Audio = Audio || {} ...@@ -3,10 +3,28 @@ var Audio = Audio || {}
var bgm; var bgm;
Audio.loadSound = function(scene) Audio.loadSound = function(scene)
{ {
scene.load.audio('login', 'assets/sound/newLogin.ogg'); // 게임 시작 전 BGM
scene.load.audio('login', 'assets/sound/login.ogg');
scene.load.audio('inRoom', 'assets/sound/waitingRoom.ogg');
// 징 소리
scene.load.audio('startGame', 'assets/sound/startGame.ogg'); scene.load.audio('startGame', 'assets/sound/startGame.ogg');
// 게임 진행 중 효과음들
scene.load.audio('attack', 'assets/sound/attackShort.ogg'); scene.load.audio('attack', 'assets/sound/attackShort.ogg');
scene.load.audio('inRoom', 'assets/sound/roomBGM.ogg'); scene.load.audio('Bagazi', 'assets/sound/Bagazi_ddak.ogg');
scene.load.audio('getItem', 'assets/sound/getItem.ogg');
scene.load.audio('killLog', 'assets/sound/killLog.ogg');
scene.load.audio('killWord', 'assets/sound/killWord.ogg');
// 페이즈별 인게임 BGM
scene.load.audio('Phase1', 'assets/sound/Phase1.ogg');
scene.load.audio('Phase2', 'assets/sound/Phase2.ogg');
scene.load.audio('Phase3', 'assets/sound/Phase3.ogg');
// 승패 BGM
scene.load.audio('victory', 'assets/sound/victory.ogg');
scene.load.audio('defeat', 'assets/sound/defeat.ogg');
} }
Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용 Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용
...@@ -36,6 +54,5 @@ Audio.killSound = function(scene, title) ...@@ -36,6 +54,5 @@ Audio.killSound = function(scene, title)
{ {
bgm.setLoop(false); bgm.setLoop(false);
bgm.stop(); bgm.stop();
console.log('killSound');
} }
...@@ -152,7 +152,9 @@ socket.on('someoneAttacked', function(msg) // {Id attackerId, Id victimId} ...@@ -152,7 +152,9 @@ socket.on('someoneAttacked', function(msg) // {Id attackerId, Id victimId}
WordSpace.makeAttackPaper(ScenesData.gameScene, attackerPos, victimPos, msg.multiple); WordSpace.makeAttackPaper(ScenesData.gameScene, attackerPos, victimPos, msg.multiple);
}); });
socket.on('attacked', function(msg) // object attackData socket.on('attacked', function(msg) // object attackData
{ {
Audio.playSound(ScenesData.gameScene, 'Bagazi');
let attackedEvent = new Cycle(function() let attackedEvent = new Cycle(function()
{ {
if(!WordSpace.isInvincible) if(!WordSpace.isInvincible)
...@@ -204,6 +206,15 @@ socket.on('defeat', function(msg) // object player ...@@ -204,6 +206,15 @@ socket.on('defeat', function(msg) // object player
let position = RoomData.findPlayer(msg.id).position; let position = RoomData.findPlayer(msg.id).position;
let nicknameText = RoomData.findPlayer(msg.id).nicknameText; let nicknameText = RoomData.findPlayer(msg.id).nicknameText;
let earnedStrongHopae = RoomData.findPlayer(msg.id).earnedStrongHopae; let earnedStrongHopae = RoomData.findPlayer(msg.id).earnedStrongHopae;
if(WordSpace.CurrentPhase == 1)
Audio.killSound(ScenesData.gameScene, 'Phase1');
if(WordSpace.CurrentPhase == 2)
Audio.killSound(ScenesData.gameScene, 'Phase2');
if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3');
Audio.playSound(ScenesData.gameScene, 'defeat');
RoomData.players[msg.index] = msg; RoomData.players[msg.index] = msg;
RoomData.players[msg.index].playerImage = playerImage; RoomData.players[msg.index].playerImage = playerImage;
RoomData.players[msg.index].position = position; RoomData.players[msg.index].position = position;
...@@ -219,6 +230,9 @@ socket.on('defeat', function(msg) // object player ...@@ -219,6 +230,9 @@ socket.on('defeat', function(msg) // object player
{ {
let lastAttacker = RoomData.findPlayer(msg.lastAttack.attackerId); let lastAttacker = RoomData.findPlayer(msg.lastAttack.attackerId);
let attackWord = msg.lastAttack.word; let attackWord = msg.lastAttack.word;
Audio.playSound(ScenesData.gameScene, 'killLog');
console.log(victim.nickname + ' defeated by ' + lastAttacker.nickname + ', with ' + msg.lastAttack.word); console.log(victim.nickname + ' defeated by ' + lastAttacker.nickname + ', with ' + msg.lastAttack.word);
if(WordSpace.lastAttackGroup.length != 0) if(WordSpace.lastAttackGroup.length != 0)
{ {
...@@ -355,6 +369,15 @@ socket.on('defeat', function(msg) // object player ...@@ -355,6 +369,15 @@ socket.on('defeat', function(msg) // object player
socket.on('gameEnd', function(msg) // number winnerId socket.on('gameEnd', function(msg) // number winnerId
{ {
const winner = RoomData.findPlayer(msg); const winner = RoomData.findPlayer(msg);
if(WordSpace.CurrentPhase == 1)
Audio.killSound(ScenesData.gameScene, 'Phase1');
if(WordSpace.CurrentPhase == 2)
Audio.killSound(ScenesData.gameScene, 'Phase2');
if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3');
Audio.playSound(ScenesData.gameScene, 'victory');
console.log(winner.nickname + ' Win!!!!!!'); console.log(winner.nickname + ' Win!!!!!!');
if(msg == RoomData.myself.id) if(msg == RoomData.myself.id)
{ {
......
...@@ -20,6 +20,7 @@ var menuScene = new Phaser.Class( ...@@ -20,6 +20,7 @@ var menuScene = new Phaser.Class(
ResourceLoader.loadImage(this); ResourceLoader.loadImage(this);
CSVParsing.loadText(this); CSVParsing.loadText(this);
Audio.loadSound(this); Audio.loadSound(this);
this.load.scenePlugin({ this.load.scenePlugin({
key: 'rexuiplugin', key: 'rexuiplugin',
url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js', url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',
...@@ -35,7 +36,7 @@ var menuScene = new Phaser.Class( ...@@ -35,7 +36,7 @@ var menuScene = new Phaser.Class(
create: function() create: function()
{ {
BackGround.drawMenu(this); BackGround.drawMenu(this);
Audio.loopSound(this, 'login'); Audio.playSound(this, 'login');
ScenesData.menuScene.tutorialFrame = 0; ScenesData.menuScene.tutorialFrame = 0;
ScenesData.menuScene.tutorialImage = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 11, ScenesData.menuScene.tutorialImage = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 11,
'tutorialImage', 1, 'center'), -2, -2, -2, 'tutorialImage', 1, 'center'), -2, -2, -2,
...@@ -438,6 +439,7 @@ var gameScene = new Phaser.Class( ...@@ -438,6 +439,7 @@ var gameScene = new Phaser.Class(
preload: function() preload: function()
{ {
ScenesData.gameScene = this; ScenesData.gameScene = this;
Audio.loadSound(this);
this.load.scenePlugin({ this.load.scenePlugin({
key: 'rexuiplugin', key: 'rexuiplugin',
url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js', url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',
...@@ -461,6 +463,14 @@ var gameScene = new Phaser.Class( ...@@ -461,6 +463,14 @@ var gameScene = new Phaser.Class(
BackGround.drawBrain(this); BackGround.drawBrain(this);
BackGround.drawCharacter(this); BackGround.drawCharacter(this);
Audio.playSound(this, 'startGame'); Audio.playSound(this, 'startGame');
if(WordSpace.CurrentPhase == 1)
Audio.loopSound(this, 'Phase1');
else if(WordSpace.CurrentPhase == 2)
Audio.loopSound(this, 'Phase2');
else
Audio.loopSound(this, 'Phase3');
WordSpace.attackPaperGroup = this.physics.add.group(); WordSpace.attackPaperGroup = this.physics.add.group();
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
...@@ -514,6 +524,7 @@ var gameScene = new Phaser.Class( ...@@ -514,6 +524,7 @@ var gameScene = new Phaser.Class(
ScenesData.changeScene = function(sceneKey) ScenesData.changeScene = function(sceneKey)
{ {
Audio.killSound(ScenesData.menuScene, 'login');
ScenesData.currentScene.scene.start(sceneKey); ScenesData.currentScene.scene.start(sceneKey);
Input.input = []; Input.input = [];
Input.converted = ''; Input.converted = '';
......
...@@ -57,6 +57,7 @@ class WordObject ...@@ -57,6 +57,7 @@ class WordObject
setTimeout(function() { setTimeout(function() {
breakAnim.destroy(); breakAnim.destroy();
}, 200); }, 200);
Audio.playSound(ScenesData.gameScene, 'killWord');
} }
attract() attract()
......
...@@ -192,6 +192,7 @@ WordSpace.generateWord = ...@@ -192,6 +192,7 @@ WordSpace.generateWord =
Item: function(scene, itemType, lenRate) Item: function(scene, itemType, lenRate)
{ {
word = new ItemWord(itemType); word = new ItemWord(itemType);
Audio.playSound(ScenesData.gameScene, 'getItem');
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
} }
...@@ -482,6 +483,13 @@ WordSpace.changePhase = function(newPhase) ...@@ -482,6 +483,13 @@ WordSpace.changePhase = function(newPhase)
console.log('phase changed from ' + WordSpace.CurrentPhase + ' to ' + newPhase); console.log('phase changed from ' + WordSpace.CurrentPhase + ' to ' + newPhase);
WordSpace.CurrentPhase = newPhase; WordSpace.CurrentPhase = newPhase;
if(WordSpace.CurrentPhase == 1)
Audio.killSound('gameScene', 'Phase1');
else if(WordSpace.CurrentPhase == 2)
Audio.killSound('gameScene', 'Phase2');
else
Audio.killSound('gameScene', 'Phase3');
//WordSpace.pauseCycle(true); //WordSpace.pauseCycle(true);
// 여기서 종이 드르륵 열면됨 // 여기서 종이 드르륵 열면됨
let phaseChangeBgr = ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'phase' + newPhase).setOrigin(0.5, 0.5).setDepth(9.9).play('phase' + newPhase + 'Anim'); let phaseChangeBgr = ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'phase' + newPhase).setOrigin(0.5, 0.5).setDepth(9.9).play('phase' + newPhase + 'Anim');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment