Commit 17c0f18e authored by 18신대성's avatar 18신대성

룸대기화면에 대기중인 사람 그림으로 뜨게

parent 95b3b93e
...@@ -77,7 +77,7 @@ class GameRoom ...@@ -77,7 +77,7 @@ class GameRoom
{ {
this.roomId = GameServer.getRoomNumber(); this.roomId = GameServer.getRoomNumber();
this.roomIndex = -1; this.roomIndex = -1;
this.startCount = 2; this.startCount = 4;
this.maxPlayer = 100; this.maxPlayer = 100;
this.nextRank = 100; this.nextRank = 100;
...@@ -114,32 +114,47 @@ class GameRoom ...@@ -114,32 +114,47 @@ class GameRoom
enterRoom(playerSocket) enterRoom(playerSocket)
{ {
let playerInst = new Player(this, playerSocket.playerData); let playerInst = new Player(this, playerSocket.playerData);
this.currentPlayer.push(playerInst);
this.currentSocket.push(playerSocket);
playerSocket.playerData.playingData = playerInst; playerSocket.playerData.playingData = playerInst;
playerSocket.playerData.currentRoom = this; playerSocket.playerData.currentRoom = this;
playerSocket.playerData.isReceivable = true;
console.log('[' + playerInst.id + '] entered to room #' + this.roomId);
playerSocket.emit('enterRoom'); playerSocket.emit('enterRoom');
this.currentSocket.push(playerSocket);
this.announceToTarget(playerInst.id, 'syncRoomScene', this.currentPlayer);
this.currentPlayer.push(playerInst);
console.log('[' + playerInst.id + '] entered to room #' + this.roomId);
this.aliveCount++; this.aliveCount++;
if (this.currentPlayer.length >= this.startCount) if (this.currentPlayer.length >= this.startCount)
{ {
if (this.currentPhase === GameServer.Phase.READY) if (this.currentPhase === GameServer.Phase.READY)
{ {
this.endTime = Date.now() + 1000; // 테스트용 10초 this.endTime = Date.now() + 5000; // 테스트용 10초
this.announceToRoom('setCount', {isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length}); this.announceToRoom('setRoomCount',
{
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
isEnter: true, player: playerInst // 나중에는 플레이어의 외양데이터도 보내야됨
});
this.currentPhase = GameServer.Phase.COUNT; this.currentPhase = GameServer.Phase.COUNT;
} }
else if (this.currentPhase === GameServer.Phase.COUNT) else if (this.currentPhase === GameServer.Phase.COUNT)
{ {
this.announceToRoom('setCount', {isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length}); this.announceToRoom('setRoomCount',
{
isEnable: true, endTime: this.endTime, playerCount: this.currentPlayer.length,
isEnter: true, player: playerInst
});
} }
} }
else else
{ {
this.announceToRoom('setCount', {isEnable: false, endTime: 0, playerCount: this.currentPlayer.length}); this.announceToRoom('setRoomCount',
{
isEnable: false, endTime: 0, playerCount: this.currentPlayer.length,
isEnter: true, player: playerInst
});
this.currentPhase = GameServer.Phase.READY; this.currentPhase = GameServer.Phase.READY;
} }
} }
......
...@@ -6,7 +6,8 @@ BackGround.myCharacter = null; ...@@ -6,7 +6,8 @@ BackGround.myCharacter = null;
BackGround.loadImage = function(scene) BackGround.loadImage = function(scene)
{ {
scene.load.image('brainGround', 'assets/image/background/background_brain.png'); scene.load.image('brainGround', 'assets/image/background/background_brain.png');
scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png') scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png');
scene.load.image('roomBackground', 'assets/placeholder/roomBackground.png');
} }
BackGround.drawCharacter = function(scene) BackGround.drawCharacter = function(scene)
...@@ -22,4 +23,9 @@ BackGround.drawBrain = function(scene) ...@@ -22,4 +23,9 @@ BackGround.drawBrain = function(scene)
BackGround.drawMenu = function(scene) BackGround.drawMenu = function(scene)
{ {
scene.add.sprite(640, 360, 'menuBackground').setDisplaySize(1282, 722).setDepth(1); scene.add.sprite(640, 360, 'menuBackground').setDisplaySize(1282, 722).setDepth(1);
}
BackGround.drawRoom = function(scene)
{
scene.add.sprite(640, 360, 'roomBackground').setDisplaySize(1282, 722).setDepth(1);
} }
\ No newline at end of file
...@@ -21,12 +21,49 @@ socket.on('enterRoom', function() ...@@ -21,12 +21,49 @@ socket.on('enterRoom', function()
Audio.killSound(ScenesData.menuScene, 'login'); Audio.killSound(ScenesData.menuScene, 'login');
game.scene.remove('menuScene'); game.scene.remove('menuScene');
game.scene.start('roomScene'); game.scene.start('roomScene');
}); });
socket.on('setCount', function(msg) socket.on('syncRoomScene', function(msg)
{ {
ScenesData.roomScene.isCounting = msg.isEnable; setTimeout(function()
ScenesData.roomScene.endTime = msg.endTime; {
ScenesData.roomScene.peopleCount = msg.playerCount; for (let i = 0; i < msg.length; i++)
{
let randX = Math.random() * 1120 + 80;
let randY = Math.random() * 380 + 100;
var playerSet =
{
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2),
nickname: msg[i].nickname
}
ScenesData.roomScene.players.push(playerSet);
}
}, 100);
});
socket.on('setRoomCount', function(msg)
{
setTimeout(function()
{
ScenesData.roomScene.isCounting = msg.isEnable;
ScenesData.roomScene.endTime = msg.endTime;
ScenesData.roomScene.peopleCount = msg.playerCount;
if (msg.isEnter) // generate charactor
{
let randX = Math.random() * 1120 + 80;
let randY = Math.random() * 380 + 100;
var playerSet =
{
sprite: ScenesData.roomScene.add.sprite(randX, randY, 'playerStand').setOrigin(0.5, 0.5).setScale(0.2, 0.2),
nickname: msg.player.nickname
}
ScenesData.roomScene.players.push(playerSet);
}
else // remove charactor
{
}
}, 200);
}); });
// init game // init game
......
...@@ -42,30 +42,43 @@ var roomScene = new Phaser.Class( ...@@ -42,30 +42,43 @@ var roomScene = new Phaser.Class(
preload: function() preload: function()
{ {
ScenesData.roomScene = this; ScenesData.roomScene = this;
BackGround.loadImage(this);
this.load.image('playerStand', 'assets/image/character/pyeongmin/pyeong_stand.png');
}, },
create: function() create: function()
{ {
BackGround.drawRoom(this);
this.players = [];
this.isCounting = false; this.isCounting = false;
this.isCountEnd = false;
this.endTime = 0; this.endTime = 0;
this.peopleCount = 1; this.peopleCount = 1;
this.countText = this.add.text(640, 360, '사람들을 위해 대기중입니다...').setOrigin(0.5, 0.5).setColor('#000000'); this.countText = this.add.text(640, 360, '사람들을 위해 대기중입니다...').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(10).setPadding(5,5,5,5);
this.peopleText = this.add.text(640, 100, '1 / 10').setOrigin(0.5, 0.5).setColor('#000000'); this.peopleText = this.add.text(640, 80, '1 / 10').setOrigin(0.5, 0.5).setColor('#000000').setBackgroundColor('#ffffff').setDepth(10);
}, },
update: function() update: function()
{ {
this.peopleText.setText(this.peopleCount + ' / 10'); this.peopleText.setText(this.peopleCount + ' / 10');
if (this.isCounting) if (this.isCounting)
{ {
this.countText.setText(((this.endTime - Date.now()) / 1000).toFixed(1)); this.countText.setText(((this.endTime - Date.now()) / 1000).toFixed(1));
if (this.endTime - Date.now() < 0) if (this.endTime < Date.now())
{ {
//console.log('end Count'); //console.log('end Count');
socket.emit('endCount'); socket.emit('endCount');
this.isCounting = false; this.isCounting = false;
this.isCountEnd = true;
} }
} }
else if (this.isCountEnd)
{
this.countText.setText('잠시만 기다려주세요...');
}
else else
{ {
this.countText.setText('사람들을 위해 대기중입니다...'); this.countText.setText('사람들을 위해 대기중입니다...');
......
...@@ -137,12 +137,20 @@ io.on('connection', function(socket) ...@@ -137,12 +137,20 @@ io.on('connection', function(socket)
if (data.currentRoom.currentPhase === GameServer.Phase.READY || data.currentRoom.currentPhase === GameServer.Phase.COUNT) if (data.currentRoom.currentPhase === GameServer.Phase.READY || data.currentRoom.currentPhase === GameServer.Phase.COUNT)
{ {
data.currentRoom.exitRoom(data.id); data.currentRoom.exitRoom(data.id);
if (data.currentRoom.aliveCount < GameServer.startCount) if (data.currentRoom.aliveCount < data.currentRoom.startCount)
{ {
data.currentRoom.announceToRoom('setCount', {isEnable: false, endTime: 0, playerCount: data.currentRoom.currentPlayer.length}); data.currentRoom.announceToRoom('setRoomCount',
{
isEnable: false, endTime: 0, playerCount: data.currentRoom.currentPlayer.length,
isEnter: false, player: data.playingData
});
data.currentRoom.currentPhase = GameServer.Phase.READY; data.currentRoom.currentPhase = GameServer.Phase.READY;
} }
else data.currentRoom.announceToRoom('setCount', {isEnable: true, endTime: data.currentRoom.endTime, playerCount: data.currentRoom.currentPlayer.length}); else data.currentRoom.announceToRoom('setRoomCount',
{
isEnable: true, endTime: data.currentRoom.endTime, playerCount: data.currentRoom.currentPlayer.length,
isEnter: false, player: data.playingData
});
} }
else if (data.playingData.isAlive) else if (data.playingData.isAlive)
{ {
......
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