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

게임 종료 시 UI 구현 wip

parent b54eea87
...@@ -328,9 +328,11 @@ class Player ...@@ -328,9 +328,11 @@ class Player
this.nickname = playerData.nickname; this.nickname = playerData.nickname;
this.playerImage = null; this.playerImage = null;
this.position = null; this.position = null;
this.isInThisRoom = true; this.killCount = 0;
this.earnedStrongHopae = 0;
this.isAlive = false; this.isAlive = false;
this.isInThisRoom = true;
this.rank = -1; this.rank = -1;
this.playerTyping = 0; this.playerTyping = 0;
......
...@@ -215,8 +215,6 @@ socket.on('defeat', function(msg) // object player ...@@ -215,8 +215,6 @@ socket.on('defeat', function(msg) // object player
repeat: 0, // -1: infinity repeat: 0, // -1: infinity
yoyo: false, yoyo: false,
onComplete: function () { onComplete: function () {
setTimeout(function() { setTimeout(function() {
ScenesData.gameScene.tweens.add({ ScenesData.gameScene.tweens.add({
targets: itemBag, targets: itemBag,
...@@ -227,14 +225,13 @@ socket.on('defeat', function(msg) // object player ...@@ -227,14 +225,13 @@ socket.on('defeat', function(msg) // object player
repeat: 0, // -1: infinity repeat: 0, // -1: infinity
yoyo: false }); yoyo: false });
}, 1500); }, 1500);
}, },
onCompleteScope: ScenesData.gameScene onCompleteScope: ScenesData.gameScene
}); });
setTimeout(function() { setTimeout(function() {
itemBag.destroy(); itemBag.destroy();
}, 3000); }, 3000);
RoomData.myself.killCount++;
} }
} }
else else
...@@ -243,21 +240,16 @@ socket.on('defeat', function(msg) // object player ...@@ -243,21 +240,16 @@ socket.on('defeat', function(msg) // object player
WordSpace.killLogForTest += ('\n--Suicide->' + RoomData.findPlayer(msg.id).nickname); WordSpace.killLogForTest += ('\n--Suicide->' + RoomData.findPlayer(msg.id).nickname);
} }
if(msg.id == RoomData.myself.id) if(msg.id == RoomData.myself.id)
{ {
setTimeout(() => { backToMenu();
socket.emit('defeat');
ScenesData.changeScene('menuScene');
}, 2000);
} }
}); });
socket.on('gameEnd', function(msg) // object player socket.on('gameEnd', function(msg) // object player
{ {
console.log(msg.nickname + ' Win!!!!!!'); console.log(msg.nickname + ' Win!!!!!!');
if(msg.id == RoomData.myself.id) if(msg.id == RoomData.myself.id)
{ {
setTimeout(() => { backToMenu();
ScenesData.changeScene('menuScene');
}, 2000);
} }
}); });
...@@ -277,4 +269,71 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname} ...@@ -277,4 +269,71 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname}
//console.log(msg.index + ' / ' + msg.id + ' / ' + msg.nickname + ' disconnected'); //console.log(msg.index + ' / ' + msg.id + ' / ' + msg.nickname + ' disconnected');
RoomData.players[msg.index] = msg; RoomData.players[msg.index] = msg;
RoomData.aliveCount--; RoomData.aliveCount--;
}); });
\ No newline at end of file
var backToMenu = function()
{
ScenesData.gameScene.roomEnterDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2,
y: game.config.height / 2,
background: ScenesData.gameScene.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
content: ScenesData.gameScene.roomEnterDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2,
y: game.config.height / 2,
choices: [
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 - 100, game.config.height / 2 - 100, 0, 'playerStand', 1, 'center'),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 100, game.config.height / 2 - 150, 0, 'button', 1, 'center', '등수 : ' + RoomData.myself.rank + '', 30),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 100, game.config.height / 2 - 50, 0, 'button', 1, 'center', '킬 수 : ' + RoomData.myself.killCount + '', 30),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 100, game.config.height / 2 + 50, 0, 'button', 1, 'center', '획득 강호패 : ' + RoomData.myself.earnedStrongHopae + '', 30),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 100, game.config.height / 2 + 150, 0, 'button', 1, 'center', '획득 골드 : ' + 10, 30)
],
space: {
choice: 20,
left: 20,
right: 20,
top: 300,
bottom: 20,
},
align: {
choices: 'center' // 'center'|'left'|'right'
}
}),
space: {
action: 0,
left: 20,
right: 20,
top: 20,
bottom: 20,
},
align: {
actions: 'center' // 'center'|'left'|'right'
}
}).setDepth(10);
/*ScenesData.gameScene.roomEnterDialog
.on('button.click', function (button, groupName, index) {
if(index == 0) socket.emit('enterRoom', PlayerData.nickname);
else
{
ScenesData.gameScene.roomEnterDialog.setVisible(false);
ScenesData.gameScene.gameStartBtn.setEnable(true);
}
}, ScenesData.gameScene)
.on('button.over', function (button, groupName, index) {
//console.log('button over');
})
.on('button.out', function (button, groupName, index) {
//console.log('button out');
});
setTimeout(() => {
socket.emit('defeat');
fbClient.updateUserData('killCount', RoomData.myself.killCount);
ScenesData.changeScene('menuScene');
}, 2000);*/
}
\ No newline at end of file
...@@ -230,6 +230,9 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = ...@@ -230,6 +230,9 @@ FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace =
if (beforeData.item != null) beforeData.item.push(valueChanged); if (beforeData.item != null) beforeData.item.push(valueChanged);
else beforeData.item = [valueChanged]; else beforeData.item = [valueChanged];
break; break;
case 'killCount':
beforeData.killCount = replace ? (valueChanged) : (beforeData.killCount + valueChanged);
break;
default: default:
console.log('[ERROR] database has no key for ' + key); console.log('[ERROR] database has no key for ' + key);
break; break;
...@@ -271,5 +274,6 @@ class UserData ...@@ -271,5 +274,6 @@ class UserData
this.title = []; this.title = [];
this.money = 0; this.money = 0;
this.item = []; this.item = [];
this.killCount = 0;
} }
} }
\ No newline at end of file
...@@ -236,6 +236,7 @@ class NameWord extends WordObject ...@@ -236,6 +236,7 @@ class NameWord extends WordObject
this.wordWeight = 2; this.wordWeight = 2;
this.isStrong = _isStrong; this.isStrong = _isStrong;
this.isActive = true; this.isActive = true;
if(_isStrong) RoomData.myself.earnedStrongHopae++;
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight); //console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
} }
instantiate(scene, lenRate) instantiate(scene, lenRate)
......
...@@ -225,7 +225,6 @@ function gameOver() ...@@ -225,7 +225,6 @@ function gameOver()
ScenesData.gameScene.add.text(game.config.width / 2, game.config.height / 2, '패배', {fontSize: '30pt'}) ScenesData.gameScene.add.text(game.config.width / 2, game.config.height / 2, '패배', {fontSize: '30pt'})
.setPadding(5,5,5,5).setOrigin(0.5, 0.5).setDepth(10) .setPadding(5,5,5,5).setOrigin(0.5, 0.5).setDepth(10)
.setColor('#000000').setBackgroundColor('#ffffff'); .setColor('#000000').setBackgroundColor('#ffffff');
//alert('defeat');
} }
//게임 오버 판정을 위한 타이머 //게임 오버 판정을 위한 타이머
...@@ -487,3 +486,5 @@ WordSpace.nameQueue = ...@@ -487,3 +486,5 @@ WordSpace.nameQueue =
this.shuffle(); this.shuffle();
} }
} }
WordSpace.gameOverUI
\ No newline at end of file
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