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

게임 종료 시 UI 구현 wip

parent b54eea87
......@@ -328,9 +328,11 @@ class Player
this.nickname = playerData.nickname;
this.playerImage = null;
this.position = null;
this.isInThisRoom = true;
this.killCount = 0;
this.earnedStrongHopae = 0;
this.isAlive = false;
this.isInThisRoom = true;
this.rank = -1;
this.playerTyping = 0;
......
......@@ -215,8 +215,6 @@ socket.on('defeat', function(msg) // object player
repeat: 0, // -1: infinity
yoyo: false,
onComplete: function () {
setTimeout(function() {
ScenesData.gameScene.tweens.add({
targets: itemBag,
......@@ -227,14 +225,13 @@ socket.on('defeat', function(msg) // object player
repeat: 0, // -1: infinity
yoyo: false });
}, 1500);
},
onCompleteScope: ScenesData.gameScene
});
setTimeout(function() {
itemBag.destroy();
}, 3000);
RoomData.myself.killCount++;
}
}
else
......@@ -243,21 +240,16 @@ socket.on('defeat', function(msg) // object player
WordSpace.killLogForTest += ('\n--Suicide->' + RoomData.findPlayer(msg.id).nickname);
}
if(msg.id == RoomData.myself.id)
{
setTimeout(() => {
socket.emit('defeat');
ScenesData.changeScene('menuScene');
}, 2000);
{
backToMenu();
}
});
socket.on('gameEnd', function(msg) // object player
{
console.log(msg.nickname + ' Win!!!!!!');
if(msg.id == RoomData.myself.id)
{
setTimeout(() => {
ScenesData.changeScene('menuScene');
}, 2000);
{
backToMenu();
}
});
......@@ -277,4 +269,71 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname}
//console.log(msg.index + ' / ' + msg.id + ' / ' + msg.nickname + ' disconnected');
RoomData.players[msg.index] = msg;
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 =
if (beforeData.item != null) beforeData.item.push(valueChanged);
else beforeData.item = [valueChanged];
break;
case 'killCount':
beforeData.killCount = replace ? (valueChanged) : (beforeData.killCount + valueChanged);
break;
default:
console.log('[ERROR] database has no key for ' + key);
break;
......@@ -271,5 +274,6 @@ class UserData
this.title = [];
this.money = 0;
this.item = [];
this.killCount = 0;
}
}
\ No newline at end of file
......@@ -236,6 +236,7 @@ class NameWord extends WordObject
this.wordWeight = 2;
this.isStrong = _isStrong;
this.isActive = true;
if(_isStrong) RoomData.myself.earnedStrongHopae++;
//console.log('Name : ' + player.nickname + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
}
instantiate(scene, lenRate)
......
......@@ -225,7 +225,6 @@ function gameOver()
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)
.setColor('#000000').setBackgroundColor('#ffffff');
//alert('defeat');
}
//게임 오버 판정을 위한 타이머
......@@ -487,3 +486,5 @@ WordSpace.nameQueue =
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