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

Merge branch 'wordspace' into release

parents 6f6149a7 2c245f69
......@@ -143,7 +143,8 @@ class GameRoom
{
if (this.currentPhase === GameServer.Phase.READY)
{
this.endTime = Date.now() + 30000; // 방 대기 시간
this.countStartTime = Date.now();
this.endTime = 30000; // 방 대기 시간
this.announceToRoom('setRoomCount',
{
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
......@@ -153,6 +154,7 @@ class GameRoom
}
else if (this.currentPhase === GameServer.Phase.COUNT)
{
this.endTime = this.endTime - (Time.now() - this.countStartTime);
this.announceToRoom('setRoomCount',
{
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
......@@ -264,32 +266,26 @@ class GameRoom
console.table(this.currentPlayer);
this.announceToRoom('startGame');
this.startTime = Date.now();
setTimeout(function()
{
if (this.currentPhase === GameServer.Phase.START) this.checkPhase(Date.now());
}.bind(this), 6000);
}
checkPhase(checkTime)
{
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.rateArrangePoint = 150;
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)
{
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)
{
this.currentPhase = GameServer.Phase.MUSIC;
......
......@@ -29,12 +29,13 @@ Audio.loadSound = function(scene)
Audio.playSound = function(scene, title) // 한 번만 재생할 때 사용
{
bgm = scene.sound.add(title);
bgm.play();
let sound = scene.sound.add(title);
sound.play();
}
Audio.loopSound = function(scene, title) // 반복재생할 때 사용
{
if (bgm != null) this.killSound(scene, title);
bgm = scene.sound.add(title);
bgm.setLoop(true);
bgm.play();
......@@ -56,3 +57,4 @@ Audio.killSound = function(scene, title)
bgm.stop();
}
// 전반적으로 함수 수정 필요..
\ No newline at end of file
......@@ -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);
}
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)
{
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)
setTimeout(function()
{
ScenesData.roomScene.isCounting = msg.isEnable;
ScenesData.roomScene.endTime = msg.endTime;
ScenesData.roomScene.endTime = Date.now() + msg.endTime;
ScenesData.roomScene.peopleCount = msg.playerCount;
if (msg.isEnter) // generate character
......@@ -207,14 +207,7 @@ socket.on('defeat', function(msg) // object player
let nicknameText = RoomData.findPlayer(msg.id).nicknameText;
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].playerImage = playerImage;
RoomData.players[msg.index].position = position;
......@@ -361,6 +354,7 @@ socket.on('defeat', function(msg) // object player
}
if(msg.id == RoomData.myself.id)
{
Audio.loopSound(ScenesData.gameScene, 'defeat');
RoomData.myself = RoomData.players[msg.index];
setTimeout(() => {
gameEndMenu(false);
......@@ -378,10 +372,10 @@ socket.on('gameEnd', function(msg) // number winnerId
if(WordSpace.CurrentPhase == 3)
Audio.killSound(ScenesData.gameScene, 'Phase3');
Audio.playSound(ScenesData.gameScene, 'victory');
console.log(winner.nickname + ' Win!!!!!!');
if(msg == RoomData.myself.id)
{
Audio.loopSound(ScenesData.gameScene, 'victory');
RoomData.myself.rank = 1;
setTimeout(() => {
gameEndMenu(true);
......@@ -393,7 +387,6 @@ socket.on('attackSucceed', function(msg)
{
//console.log('client');
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, RoomData.findPlayer(msg.victimId));
tempWord.instantiate(ScenesData.gameScene);
let victimPos = RoomData.findPlayer(msg.victimId).position;
tempWord.physicsObj.setPosition(victimPos.x, victimPos.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
......@@ -417,10 +410,9 @@ var gameEndMenu = function(isWin)
let earnedMoney = 0;
if(isWin) earnedMoney += 20;
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 += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1)));
earnedMoney = parseInt(earnedMoney / 40);
Input.inputField.text.destroy();
......@@ -432,7 +424,6 @@ var gameEndMenu = function(isWin)
ScenesData.changeScene('menuScene');
}
ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2,
y: game.config.height / 2,
......
......@@ -266,6 +266,7 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
break;
case 'skin':
beforeData.skin = valueChanged;
break;
default:
console.log('[ERROR] database has no key for ' + key);
break;
......
......@@ -387,7 +387,7 @@ Input.inputField =
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;
let output;
......
......@@ -7,6 +7,7 @@ ResourceLoader.loadBackGround = function(scene)
scene.load.image('gameBackground', 'assets/image/background/background_brain.png');
scene.load.image('menuBackground', 'assets/image/UI/main/mainBackground.png');
scene.load.image('roomBackground', 'assets/placeholder/roomBackground.png');
scene.load.image('shopBackground', 'assets/image/UI/shop/shop_background.png');
}
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('rankPlayBtn', 'assets/image/UI/main/rankPlay.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('helpBtn', 'assets/image/UI/main/help.png');
......@@ -75,6 +77,8 @@ ResourceLoader.loadImage = function(scene)
scene.load.image('noBtn', 'assets/image/UI/decisionBtn/no.png');
scene.load.image('spectateBtn', 'assets/image/UI/decisionBtn/spectate.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)
repeat: 0
});
}
}
\ No newline at end of file
......@@ -20,7 +20,6 @@ var menuScene = new Phaser.Class(
ResourceLoader.loadImage(this);
CSVParsing.loadText(this);
Audio.loadSound(this);
this.load.scenePlugin({
key: 'rexuiplugin',
url: 'https://raw.githubusercontent.com/rexrainbow/phaser3-rex-notes/master/plugins/dist/rexuiplugin.min.js',
......@@ -37,7 +36,7 @@ var menuScene = new Phaser.Class(
{
ResourceLoader.loadAnimation(this);
BackGround.drawMenu(this);
Audio.playSound(this, 'login');
Audio.loopSound(this, 'login');
ScenesData.menuScene.tutorialFrame = 0;
ScenesData.menuScene.tutorialImage = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 11,
'tutorialImage', 1, 'center'), -2, -2, -2,
......@@ -68,8 +67,8 @@ var menuScene = new Phaser.Class(
PlayerData.currentHopae = (PlayerData.userData.recentHopae == null) ? PlayerData.userData.hopae[0] : PlayerData.userData.recentHopae;
PlayerData.nickname = PlayerData.currentHopae.name;
this.userName = this.add.text(250, 75, PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
this.money = this.add.text(950, 70, PlayerData.userData.money).setOrigin(1, 0.5).setColor('#ffffff').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
this.userName = this.add.text(250, 75, PlayerData.userData.userName.length < 10 ? PlayerData.userData.userName : PlayerData.userData.userName.substr(0, 8) + '...').setOrigin(0, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
this.money = this.add.text(950, 70, PlayerData.userData.money + '').setOrigin(1, 0.5).setColor('#ffffff').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
this.organizeHopae = function()
{
......@@ -290,8 +289,8 @@ var hopaeScene = new Phaser.Class(
{
if(PlayerData.userData.hopae === undefined || PlayerData.userData.hopae.length == 0 || PlayerData.userData.money > 0)
{
if(!(PlayerData.userData.hopae === undefined || PlayerData.userData.hopae.length == 0))fbClient.updateUserData('money', -1);
fbClient.updateUserData('hopae', {name: Input.inputField.text.text, type: 'wood'});
if(PlayerData.userData.hopae === undefined || PlayerData.userData.hopae.length == 0) fbClient.updateUserData('money', -1);
ScenesData.changeScene('menuScene');
}
else
......@@ -368,11 +367,11 @@ var shopScene = new Phaser.Class(
create: function()
{
BackGround.drawBackground(this);
BackGround.drawShop(this);
this.currentSkin = this.add.sprite(500, game.config.height / 2, Enums.characterSkin[PlayerData.userData.skin] + 'Stand')
.setOrigin(0.5, 0.5).setDepth(5).setScale(0.8);
this.money = this.add.text(200, 70, PlayerData.userData.money + "").setOrigin(1, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
this.money = this.add.text(400, 260, PlayerData.userData.money + "").setOrigin(1, 0.5).setColor('#ffffff').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont');
......@@ -380,7 +379,7 @@ var shopScene = new Phaser.Class(
price: 0,
itemName: this.add.text(game.config.width - 500, 300, '평민').setOrigin(1, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont'),
itemPrice: this.add.text(game.config.width - 200, 300, '0냥').setOrigin(1, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont'),
buyBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 600, 300, 5, 'button', 1, 'center', '구매하기'), -1, -1, -1,
buyBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 600, 300, 5, 'buyBtn', 1, 'center'), -1, -1, -1,
function()
{
if(PlayerData.userData.money >= ScenesData.shopScene.pyeongminItem.price)
......@@ -391,9 +390,10 @@ var shopScene = new Phaser.Class(
fbClient.updateUserData('money', -ScenesData.shopScene.pyeongminItem.price);
ScenesData.shopScene.money.setText(PlayerData.userData.money + '');
ScenesData.shopScene.pyeongminItem.useBtn.setVisible(true);
ScenesData.shopScene.pyeongminItem.boughtSign.setVisible(true);
}
}),
useBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 300, 5, 'button', 1, 'center', '사용하기'), -1, -1, -1,
useBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 300, 5, 'equipBtn', 1, 'center'), -1, -1, -1,
function()
{
if(PlayerData.userData.item.includes(0))
......@@ -402,16 +402,18 @@ var shopScene = new Phaser.Class(
ScenesData.shopScene.sunbiItem.useBtn.setVisible(true);
fbClient.updateUserData('skin', 0);
ScenesData.shopScene.currentSkin.destroy();
ScenesData.shopScene.currentSkin = ScenesData.shopScene.add.sprite(500, game.config.height / 2, Enums.characterSkin[PlayerData.userData.skin] + 'Stand')
ScenesData.shopScene.add.sprite(500, game.config.height / 2, Enums.characterSkin[PlayerData.userData.skin] + 'Stand')
.setOrigin(0.5, 0.5).setDepth(5).setScale(0.8);
}
})
}),
boughtSign: UIObject.createLabel(ScenesData.shopScene, game.config.width - 400, 300, 5, 'boughtItem', 1, 'center').setVisible(false)
}
this.pyeongminItem.buyBtn.setEnable(PlayerData.userData.money < ScenesData.shopScene.pyeongminItem.price ? false : true);
if(PlayerData.userData.item.includes(0))
{
this.pyeongminItem.buyBtn.setVisible(false);
this.pyeongminItem.boughtSign.setVisible(true);
this.pyeongminItem.itemPrice.setText('보유중');
}
if(PlayerData.userData.skin == 0 || !PlayerData.userData.item.includes(0)) this.pyeongminItem.useBtn.setVisible(false);
......@@ -422,7 +424,7 @@ var shopScene = new Phaser.Class(
price: 100,
itemName: this.add.text(game.config.width - 500, 400, '선비').setOrigin(1, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont'),
itemPrice: this.add.text(game.config.width - 200, 400, '100냥').setOrigin(1, 0.5).setColor('#000000').setDepth(9.9).setPadding(5,5,5,5).setFont('40pt sejongFont'),
buyBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 400, 5, 'button', 1, 'center', '구매하기'), -1, -1, -1,
buyBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 400, 5, 'buyBtn', 1, 'center'), -1, -1, -1,
function()
{
if(PlayerData.userData.money >= ScenesData.shopScene.sunbiItem.price)
......@@ -433,9 +435,10 @@ var shopScene = new Phaser.Class(
fbClient.updateUserData('money', -ScenesData.shopScene.sunbiItem.price);
ScenesData.shopScene.money.setText(PlayerData.userData.money + '');
ScenesData.shopScene.sunbiItem.useBtn.setVisible(true);
ScenesData.shopScene.sunbiItem.boughtSign.setVisible(true);
}
}),
useBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 400, 5, 'button', 1, 'center', '사용하기'), -1, -1, -1,
useBtn: UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 800, 400, 5, 'equipBtn', 1, 'center'), -1, -1, -1,
function()
{
if(PlayerData.userData.item.includes(1))
......@@ -447,13 +450,15 @@ var shopScene = new Phaser.Class(
ScenesData.shopScene.currentSkin = ScenesData.shopScene.add.sprite(500, game.config.height / 2, Enums.characterSkin[PlayerData.userData.skin] + 'Stand')
.setOrigin(0.5, 0.5).setDepth(5).setScale(0.8);
}
})
}),
boughtSign: UIObject.createLabel(ScenesData.shopScene, game.config.width - 400, 400, 5, 'boughtItem', 1, 'center').setVisible(false)
}
this.sunbiItem.buyBtn.setEnable(PlayerData.userData.money < ScenesData.shopScene.sunbiItem.price ? false : true);
if(PlayerData.userData.item.includes(1))
{
this.sunbiItem.buyBtn.setVisible(false);
this.sunbiItem.boughtSign.setVisible(true);
this.sunbiItem.itemPrice.setText('보유중');
}
if(PlayerData.userData.skin == 1 || !PlayerData.userData.item.includes(1)) this.sunbiItem.useBtn.setVisible(false);
......@@ -595,13 +600,6 @@ var gameScene = new Phaser.Class(
BackGround.drawCharacter(this);
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.wordPhysicsGroup = this.physics.add.group();
......@@ -656,6 +654,11 @@ var gameScene = new Phaser.Class(
ScenesData.changeScene = function(sceneKey)
{
Audio.killSound(ScenesData.menuScene, 'login');
Audio.killSound(ScenesData.currentScene, 'victory');
Audio.killSound(ScenesData.currentScene, 'defeat');
// Audio.killSound(ScenesData.gameScene, 'victory');
// Audio.killSound(ScenesData.gameScene, 'defeat');
ScenesData.currentScene.scene.start(sceneKey);
Input.input = [];
Input.converted = '';
......
......@@ -218,6 +218,13 @@ function gameOver()
{
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');
console.log('defeat');
}
......@@ -486,11 +493,11 @@ WordSpace.changePhase = function(newPhase)
WordSpace.CurrentPhase = newPhase;
if(WordSpace.CurrentPhase == 1)
Audio.killSound('gameScene', 'Phase1');
Audio.loopSound(ScenesData.currentScene, 'Phase1');
else if(WordSpace.CurrentPhase == 2)
Audio.killSound('gameScene', 'Phase2');
Audio.loopSound(ScenesData.currentScene, 'Phase2');
else
Audio.killSound('gameScene', 'Phase3');
Audio.loopSound(ScenesData.currentScene, 'Phase3');
//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