Commit eaeeecb9 authored by 18손재민's avatar 18손재민

Merge branch 'wordspace' into release

parents 6f6149a7 2c245f69
...@@ -143,7 +143,8 @@ class GameRoom ...@@ -143,7 +143,8 @@ class GameRoom
{ {
if (this.currentPhase === GameServer.Phase.READY) if (this.currentPhase === GameServer.Phase.READY)
{ {
this.endTime = Date.now() + 30000; // 방 대기 시간 this.countStartTime = Date.now();
this.endTime = 30000; // 방 대기 시간
this.announceToRoom('setRoomCount', this.announceToRoom('setRoomCount',
{ {
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length, isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
...@@ -153,6 +154,7 @@ class GameRoom ...@@ -153,6 +154,7 @@ class GameRoom
} }
else if (this.currentPhase === GameServer.Phase.COUNT) else if (this.currentPhase === GameServer.Phase.COUNT)
{ {
this.endTime = this.endTime - (Time.now() - this.countStartTime);
this.announceToRoom('setRoomCount', this.announceToRoom('setRoomCount',
{ {
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length, isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
...@@ -264,32 +266,26 @@ class GameRoom ...@@ -264,32 +266,26 @@ class GameRoom
console.table(this.currentPlayer); console.table(this.currentPlayer);
this.announceToRoom('startGame'); this.announceToRoom('startGame');
this.startTime = Date.now(); this.startTime = Date.now();
setTimeout(function()
{
if (this.currentPhase === GameServer.Phase.START) this.checkPhase(Date.now());
}.bind(this), 6000);
} }
checkPhase(checkTime) checkPhase(checkTime)
{ {
if (this.currentPhase === GameServer.Phase.START) if (this.currentPhase === GameServer.Phase.START)
{ {
if (this.phaseChanger < 0 && checkTime - this.startTime > 1000) if (checkTime - this.startTime > 6000)
{ {
this.currentPhase = GameServer.Phase.MAIN; this.currentPhase = GameServer.Phase.MAIN;
this.rateArrangePoint = 150; this.rateArrangePoint = 150;
this.announceToRoom('changePhase', GameServer.Phase.MAIN); this.announceToRoom('changePhase', GameServer.Phase.MAIN);
} }
else if (this.phaseChanger < 0)
{
this.phaseChanger = setTimeout(function(room)
{
room.currentPhase = GameServer.Phase.MAIN;
room.rateArrangePoint = 150;
room.announceToRoom('changePhase', GameServer.Phase.MAIN);
room.phaseChanger = -1;
}, 60000 - (checkTime - this.startTime), this);
}
} }
else if (this.currentPhase === GameServer.Phase.MAIN) else if (this.currentPhase === GameServer.Phase.MAIN)
{ {
let playerLimit = Math.min(Math.round(this.currentPlayer.length / 5), 3); let playerLimit = Math.max(Math.round(this.currentPlayer.length / 5), 3);
if (this.aliveCount <= playerLimit) if (this.aliveCount <= playerLimit)
{ {
this.currentPhase = GameServer.Phase.MUSIC; this.currentPhase = GameServer.Phase.MUSIC;
......
This diff is collapsed.
This diff is collapsed.
...@@ -29,12 +29,13 @@ Audio.loadSound = function(scene) ...@@ -29,12 +29,13 @@ Audio.loadSound = function(scene)
Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용 Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용
{ {
bgm = scene.sound.add(title); let sound = scene.sound.add(title);
bgm.play(); sound.play();
} }
Audio.loopSound = function(scene, title) // 반복재생할 때 사용 Audio.loopSound = function(scene, title) // 반복재생할 때 사용
{ {
if (bgm != null) this.killSound(scene, title);
bgm = scene.sound.add(title); bgm = scene.sound.add(title);
bgm.setLoop(true); bgm.setLoop(true);
bgm.play(); bgm.play();
...@@ -56,3 +57,4 @@ Audio.killSound = function(scene, title) ...@@ -56,3 +57,4 @@ Audio.killSound = function(scene, title)
bgm.stop(); bgm.stop();
} }
// 전반적으로 함수 수정 필요..
\ No newline at end of file
...@@ -52,6 +52,11 @@ BackGround.drawMenu = function(scene) ...@@ -52,6 +52,11 @@ BackGround.drawMenu = function(scene)
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'menuBackground').setDisplaySize(game.config.width, game.config.height).setDepth(3); scene.add.sprite(game.config.width / 2, game.config.height / 2, 'menuBackground').setDisplaySize(game.config.width, game.config.height).setDepth(3);
} }
BackGround.drawShop = function(scene)
{
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'shopBackground').setDisplaySize(game.config.width, game.config.height).setDepth(3);
}
BackGround.drawRoom = function(scene) BackGround.drawRoom = function(scene)
{ {
scene.add.sprite(game.config.width / 2, game.config.height / 2, 'roomBackground').setDisplaySize(game.config.width, game.config.height).setDepth(5.2); scene.add.sprite(game.config.width / 2, game.config.height / 2, 'roomBackground').setDisplaySize(game.config.width, game.config.height).setDepth(5.2);
......
...@@ -70,7 +70,7 @@ socket.on('setRoomCount', function(msg) ...@@ -70,7 +70,7 @@ socket.on('setRoomCount', function(msg)
setTimeout(function() setTimeout(function()
{ {
ScenesData.roomScene.isCounting = msg.isEnable; ScenesData.roomScene.isCounting = msg.isEnable;
ScenesData.roomScene.endTime = msg.endTime; ScenesData.roomScene.endTime = Date.now() + msg.endTime;
ScenesData.roomScene.peopleCount = msg.playerCount; ScenesData.roomScene.peopleCount = msg.playerCount;
if (msg.isEnter) // generate character if (msg.isEnter) // generate character
...@@ -207,14 +207,7 @@ socket.on('defeat', function(msg) // object player ...@@ -207,14 +207,7 @@ socket.on('defeat', function(msg) // object player
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;
...@@ -361,6 +354,7 @@ socket.on('defeat', function(msg) // object player ...@@ -361,6 +354,7 @@ socket.on('defeat', function(msg) // object player
} }
if(msg.id == RoomData.myself.id) if(msg.id == RoomData.myself.id)
{ {
Audio.loopSound(ScenesData.gameScene, 'defeat');
RoomData.myself = RoomData.players[msg.index]; RoomData.myself = RoomData.players[msg.index];
setTimeout(() => { setTimeout(() => {
gameEndMenu(false); gameEndMenu(false);
...@@ -378,10 +372,10 @@ socket.on('gameEnd', function(msg) // number winnerId ...@@ -378,10 +372,10 @@ socket.on('gameEnd', function(msg) // number winnerId
if(WordSpace.CurrentPhase == 3) if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3'); 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)
{ {
Audio.loopSound(ScenesData.gameScene, 'victory');
RoomData.myself.rank = 1; RoomData.myself.rank = 1;
setTimeout(() => { setTimeout(() => {
gameEndMenu(true); gameEndMenu(true);
...@@ -393,7 +387,6 @@ socket.on('attackSucceed', function(msg) ...@@ -393,7 +387,6 @@ socket.on('attackSucceed', function(msg)
{ {
//console.log('client'); //console.log('client');
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, RoomData.findPlayer(msg.victimId)); let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, RoomData.findPlayer(msg.victimId));
tempWord.instantiate(ScenesData.gameScene);
let victimPos = RoomData.findPlayer(msg.victimId).position; let victimPos = RoomData.findPlayer(msg.victimId).position;
tempWord.physicsObj.setPosition(victimPos.x, victimPos.y); tempWord.physicsObj.setPosition(victimPos.x, victimPos.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y); tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
...@@ -417,10 +410,9 @@ var gameEndMenu = function(isWin) ...@@ -417,10 +410,9 @@ var gameEndMenu = function(isWin)
let earnedMoney = 0; let earnedMoney = 0;
if(isWin) earnedMoney += 20; if(isWin) earnedMoney += 20;
earnedMoney += RoomData.myself.killCount * 3; earnedMoney += RoomData.myself.killCount * 3;
earnedMoney += parseInt(WordSpace.playerTyping / 10); earnedMoney += parseInt(WordSpace.playerTyping / 40);
earnedMoney += Math.max(20, Math.pow(RoomData.myself.attackSucceed, 2)); earnedMoney += Math.max(20, Math.pow(RoomData.myself.attackSucceed, 2));
earnedMoney += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1))); earnedMoney += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1)));
earnedMoney = parseInt(earnedMoney / 40);
Input.inputField.text.destroy(); Input.inputField.text.destroy();
...@@ -432,7 +424,6 @@ var gameEndMenu = function(isWin) ...@@ -432,7 +424,6 @@ var gameEndMenu = function(isWin)
ScenesData.changeScene('menuScene'); ScenesData.changeScene('menuScene');
} }
ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({ ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2, x: game.config.width / 2,
y: game.config.height / 2, y: game.config.height / 2,
......
...@@ -266,6 +266,7 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -266,6 +266,7 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
break; break;
case 'skin': case 'skin':
beforeData.skin = valueChanged; beforeData.skin = valueChanged;
break;
default: default:
console.log('[ERROR] database has no key for ' + key); console.log('[ERROR] database has no key for ' + key);
break; break;
......
...@@ -387,7 +387,7 @@ Input.inputField = ...@@ -387,7 +387,7 @@ Input.inputField =
Input.pushInput = function(inputKey) Input.pushInput = function(inputKey)
{ {
if ((ScenesData.currentScene != 'gameScene' || RoomData.myself.isAlive) && this.justPressed != inputKey) if (!WordSpace.isGameOver && RoomData.myself.isAlive && this.justPressed != inputKey)
{ {
this.justPressed = inputKey; this.justPressed = inputKey;
let output; let output;
......
...@@ -7,6 +7,7 @@ ResourceLoader.loadBackGround = function(scene) ...@@ -7,6 +7,7 @@ ResourceLoader.loadBackGround = function(scene)
scene.load.image('gameBackground', 'assets/image/background/background_brain.png'); scene.load.image('gameBackground', 'assets/image/background/background_brain.png');
scene.load.image('menuBackground', 'assets/image/UI/main/mainBackground.png'); scene.load.image('menuBackground', 'assets/image/UI/main/mainBackground.png');
scene.load.image('roomBackground', 'assets/placeholder/roomBackground.png'); scene.load.image('roomBackground', 'assets/placeholder/roomBackground.png');
scene.load.image('shopBackground', 'assets/image/UI/shop/shop_background.png');
} }
ResourceLoader.loadImage = function(scene) ResourceLoader.loadImage = function(scene)
...@@ -65,6 +66,7 @@ ResourceLoader.loadImage = function(scene) ...@@ -65,6 +66,7 @@ ResourceLoader.loadImage = function(scene)
scene.load.image('friendlyPlayBtn', 'assets/image/UI/main/friendlyPlay.png'); scene.load.image('friendlyPlayBtn', 'assets/image/UI/main/friendlyPlay.png');
scene.load.image('rankPlayBtn', 'assets/image/UI/main/rankPlay.png'); scene.load.image('rankPlayBtn', 'assets/image/UI/main/rankPlay.png');
scene.load.image('shopBtn', 'assets/image/UI/main/shop.png'); scene.load.image('shopBtn', 'assets/image/UI/main/shop.png');
scene.load.image('boughtItem', 'assets/image/UI/shop/bought_item.png');
scene.load.image('hopaeManageBtn', 'assets/image/UI/main/hopaeManage.png'); scene.load.image('hopaeManageBtn', 'assets/image/UI/main/hopaeManage.png');
scene.load.image('helpBtn', 'assets/image/UI/main/help.png'); scene.load.image('helpBtn', 'assets/image/UI/main/help.png');
...@@ -75,6 +77,8 @@ ResourceLoader.loadImage = function(scene) ...@@ -75,6 +77,8 @@ ResourceLoader.loadImage = function(scene)
scene.load.image('noBtn', 'assets/image/UI/decisionBtn/no.png'); scene.load.image('noBtn', 'assets/image/UI/decisionBtn/no.png');
scene.load.image('spectateBtn', 'assets/image/UI/decisionBtn/spectate.png'); scene.load.image('spectateBtn', 'assets/image/UI/decisionBtn/spectate.png');
scene.load.image('yesBtn', 'assets/image/UI/decisionBtn/yes.png'); scene.load.image('yesBtn', 'assets/image/UI/decisionBtn/yes.png');
scene.load.image('buyBtn', 'assets/image/UI/decisionBtn/buy.png');
scene.load.image('equipBtn', 'assets/image/UI/decisionBtn/equip.png');
...@@ -156,6 +160,4 @@ ResourceLoader.loadAnimation = function(scene) ...@@ -156,6 +160,4 @@ ResourceLoader.loadAnimation = function(scene)
repeat: 0 repeat: 0
}); });
} }
} }
\ No newline at end of file
This diff is collapsed.
...@@ -218,6 +218,13 @@ function gameOver() ...@@ -218,6 +218,13 @@ function gameOver()
{ {
WordSpace.pauseCycle(true); WordSpace.pauseCycle(true);
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');
socket.emit('defeated'); socket.emit('defeated');
console.log('defeat'); console.log('defeat');
} }
...@@ -486,11 +493,11 @@ WordSpace.changePhase = function(newPhase) ...@@ -486,11 +493,11 @@ WordSpace.changePhase = function(newPhase)
WordSpace.CurrentPhase = newPhase; WordSpace.CurrentPhase = newPhase;
if(WordSpace.CurrentPhase == 1) if(WordSpace.CurrentPhase == 1)
Audio.killSound('gameScene', 'Phase1'); Audio.loopSound(ScenesData.currentScene, 'Phase1');
else if(WordSpace.CurrentPhase == 2) else if(WordSpace.CurrentPhase == 2)
Audio.killSound('gameScene', 'Phase2'); Audio.loopSound(ScenesData.currentScene, 'Phase2');
else else
Audio.killSound('gameScene', 'Phase3'); Audio.loopSound(ScenesData.currentScene, 'Phase3');
//WordSpace.pauseCycle(true); //WordSpace.pauseCycle(true);
// 여기서 종이 드르륵 열면됨 // 여기서 종이 드르륵 열면됨
......
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