Commit 87fcc532 authored by 18손재민's avatar 18손재민

메뉴 정렬 구현함

parent 04cc9c45
...@@ -29,7 +29,7 @@ socket.on('setId', function(msg) // {str, num playerNum} ...@@ -29,7 +29,7 @@ socket.on('setId', function(msg) // {str, num playerNum}
// init game // init game
socket.on('enterRoom', function() socket.on('enterRoom', function()
{ {
fbClient.updateUserData('recentHopae', PlayerData.nickname); fbClient.updateUserData('recentHopae', PlayerData.currentHopae);
Audio.killSound(ScenesData.menuScene, 'login'); Audio.killSound(ScenesData.menuScene, 'login');
ScenesData.changeScene('roomScene'); ScenesData.changeScene('roomScene');
}); });
......
...@@ -251,7 +251,7 @@ class UserData ...@@ -251,7 +251,7 @@ class UserData
[ [
{name: prompt("첫번째 호패의 닉네임을 입력해주세요.\n(반드시 한글만 사용해주세요 띄어쓰기도 금지)"), type: 'wood'} {name: prompt("첫번째 호패의 닉네임을 입력해주세요.\n(반드시 한글만 사용해주세요 띄어쓰기도 금지)"), type: 'wood'}
]; ];
this.recentHopae = ''; this.recentHopae = null;
this.title = []; this.title = [];
this.money = 0; this.money = 0;
this.item = []; this.item = [];
......
...@@ -35,7 +35,6 @@ Input.menuSceneEnterReaction = function() ...@@ -35,7 +35,6 @@ Input.menuSceneEnterReaction = function()
if (Input.finalInput.length > 1) if (Input.finalInput.length > 1)
{ {
PlayerData.nickname = Input.finalInput; PlayerData.nickname = Input.finalInput;
ScenesData.menuScene.currentHopae.setText('현재 호패 : ' + PlayerData.nickname);
Input.reset(); Input.reset();
} }
else else
......
...@@ -36,72 +36,75 @@ var menuScene = new Phaser.Class( ...@@ -36,72 +36,75 @@ var menuScene = new Phaser.Class(
{ {
BackGround.drawBackground(this); BackGround.drawBackground(this);
Audio.loopSound(this, 'login'); Audio.loopSound(this, 'login');
PlayerData.nickname = (PlayerData.userData.recentHopae == '') ? PlayerData.userData.hopae[0].name : PlayerData.userData.recentHopae; PlayerData.currentHopae = (PlayerData.userData.recentHopae == null) ? PlayerData.userData.hopae[0] : PlayerData.userData.recentHopae;
PlayerData.nickname = PlayerData.currentHopae.name;
this.userName = this.add.text(100, 100, '내 이름 : ' + PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40); this.userName = this.add.text(100, 100, '내 이름 : ' + PlayerData.userData.userName).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.money = this.add.text(100, 200, '소지 엽전 : ' + PlayerData.userData.money).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40); this.money = this.add.text(100, 200, '소지 엽전 : ' + PlayerData.userData.money).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.setOtherHopae = function() this.organizeHopae = function()
{ {
this.otherHopae = []; this.myHopae = [];
this.myHopae.push({
name: PlayerData.currentHopae.name,
type: PlayerData.currentHopae.type,
});
for(let i = 0; i < PlayerData.userData.hopae.length; i++) for(let i = 0; i < PlayerData.userData.hopae.length; i++)
if(PlayerData.userData.hopae[i].name != PlayerData.nickname) if(PlayerData.userData.hopae[i].name != PlayerData.currentHopae.name)
this.otherHopae.push( this.myHopae.push({
{
name: PlayerData.userData.hopae[i].name, name: PlayerData.userData.hopae[i].name,
type: PlayerData.userData.hopae[i].type, type: PlayerData.userData.hopae[i].type,
}); });
} }
this.setOtherHopae();
this.createHopaeMenu = function() this.createHopaeMenu = function()
{ {
this.otherHopaeObject = []; this.hopaeMenuObject = [];
for(let i = 0; i < this.otherHopae.length; i++) for(let i = 0; i < this.myHopae.length; i++)
{ {
let temp = UIObject.createButton(this, UIObject.createLabel(this, 300, 300, 10, let temp = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 10,
'nameBgr' + ScenesData.menuScene.otherHopae[i].name.length, 1, ScenesData.menuScene.otherHopae[i].name, 25, '#ffffff', 0.45, 0.5), 0, 0, 0, 'nameBgr' + ScenesData.menuScene.myHopae[i].name.length, 1, 'left', ScenesData.menuScene.myHopae[i].name, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function() function()
{ {
PlayerData.nickname = ScenesData.menuScene.otherHopae[i].name; PlayerData.currentHopae = ScenesData.menuScene.myHopae[i];
ScenesData.menuScene.setOtherHopae(); PlayerData.nickname = ScenesData.menuScene.myHopae[i].name;
ScenesData.menuScene.currentHopae.destroy(); ScenesData.menuScene.organizeHopae();
ScenesData.menuScene.currentHopaeBtn.destroy();
ScenesData.menuScene.createCurrentHopae(); ScenesData.menuScene.createCurrentHopae();
ScenesData.menuScene.currentHopae.setEnable(true); ScenesData.menuScene.hopaeMenuObject.forEach(function(element){
ScenesData.menuScene.otherHopaeObject.forEach(function(element){
ScenesData.menuScene.tweens.add({ ScenesData.menuScene.tweens.add({
targets: element, targets: element,
y: 0, y: 0,
duration: 200, duration: 200,
ease: 'Linear', ease: 'Linear',
loop: 0, loop: 0,
onComplete: function(){element.destroy()} onComplete: function(){element.destroy();}
}); });
}); });
}); });
ScenesData.menuScene.tweens.add({ ScenesData.menuScene.tweens.add({
targets: temp, targets: temp,
y: 50 * (i + 1), y: 50 * i,
duration: 500, duration: 500,
ease: 'Bounce', ease: 'Bounce',
loop: 0 loop: 0
}); });
temp.count = i; this.hopaeMenuObject.push(temp);
temp.total = this.otherHopae.length;
this.otherHopaeObject.push(temp);
} }
} }
this.createCurrentHopae = function() this.createCurrentHopae = function()
{ {
this.currentHopae = UIObject.createButton(this, UIObject.createLabel(this, 300, 300, 10, this.currentHopaeBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 300, 10,
'nameBgr' + PlayerData.nickname.length, 1, PlayerData.nickname, 25, '#ffffff', 0.45, 0.5), 0, 0, 0, 'nameBgr' + PlayerData.nickname.length, 1, 'left', PlayerData.nickname, 25, '#ffffff', 0.45, 0.5), 0, 0, 0,
function() function()
{ {
ScenesData.menuScene.currentHopae.setEnable(false); ScenesData.menuScene.currentHopaeBtn.destroy();
ScenesData.menuScene.createHopaeMenu(); ScenesData.menuScene.createHopaeMenu();
}) })
} }
this.organizeHopae();
this.createCurrentHopae(); this.createCurrentHopae();
this.myCharacter = this.add.sprite(game.config.width / 2, game.config.height / 2 - 200, 'pyeongminStand').setOrigin(0.5, 0.5).setDepth(5).setScale(0.8); this.myCharacter = this.add.sprite(game.config.width / 2, game.config.height / 2 - 200, 'pyeongminStand').setOrigin(0.5, 0.5).setDepth(5).setScale(0.8);
...@@ -117,8 +120,8 @@ var menuScene = new Phaser.Class( ...@@ -117,8 +120,8 @@ var menuScene = new Phaser.Class(
}), }),
actions: [ actions: [
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '', 50), UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'center', '', 50),
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '아니오', 50) UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'center', '아니오', 50)
], ],
space: { space: {
...@@ -157,20 +160,20 @@ var menuScene = new Phaser.Class( ...@@ -157,20 +160,20 @@ var menuScene = new Phaser.Class(
}); });
this.gameStartBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, 900, 5, 'pyeongminWrite', 0.5), 1, 0, 2, this.gameStartBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, 900, 5, 'pyeongminWrite', 0.5, 'center'), 1, 0, 2,
function() function()
{ {
ScenesData.menuScene.gameStartBtn.setEnable(false); ScenesData.menuScene.gameStartBtn.setEnable(false);
ScenesData.menuScene.roomEnterDialog.setVisible(true).popUp(200); ScenesData.menuScene.roomEnterDialog.setVisible(true).popUp(200);
}) })
this.shopBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 100, 900, 5, 'pyeongminThrow', 0.5), 1, 0, 2, this.shopBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width - 100, 900, 5, 'pyeongminThrow', 0.5, 'center'), 1, 0, 2,
function() function()
{ {
console.log('상점 입장'); console.log('상점 입장');
}) })
this.hopaeBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 900, 5, 'pyeongminThrow', 0.5), 1, 0, 2, this.hopaeBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 900, 5, 'pyeongminThrow', 0.5, 'center'), 1, 0, 2,
function() function()
{ {
ScenesData.changeScene('hopaeScene'); ScenesData.changeScene('hopaeScene');
...@@ -209,7 +212,7 @@ var hopaeScene = new Phaser.Class( ...@@ -209,7 +212,7 @@ var hopaeScene = new Phaser.Class(
BackGround.drawBackground(this); BackGround.drawBackground(this);
Input.inputField.generate(this, function(){}, Input.inputField.generate(this, function(){},
UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 10, 'nameBgr6', 2, '', 50, '#ffffff').getElement('text').setOrigin(0.45,0.5), true); UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 10, 'nameBgr6', 2, 'center', '', 50, '#ffffff').getElement('text').setOrigin(0.45,0.5), true);
this.checkDialog = this.rexUI.add.dialog({ this.checkDialog = this.rexUI.add.dialog({
x: game.config.width / 2, x: game.config.width / 2,
...@@ -223,8 +226,8 @@ var hopaeScene = new Phaser.Class( ...@@ -223,8 +226,8 @@ var hopaeScene = new Phaser.Class(
}), }),
actions: [ actions: [
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '', 50), UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'center', '', 50),
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '아니오', 50) UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'center', '아니오', 50)
], ],
space: { space: {
...@@ -261,7 +264,7 @@ var hopaeScene = new Phaser.Class( ...@@ -261,7 +264,7 @@ var hopaeScene = new Phaser.Class(
{ {
this.checkDialog.setVisible(false); this.checkDialog.setVisible(false);
this.errorMsg = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 10, 'panel', 1, this.errorMsg = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 10, 'panel', 1, 'center',
'엽전이 부족합니다', 50, '#000000').layout().popUp(200), 0, 0, 0, '엽전이 부족합니다', 50, '#000000').layout().popUp(200), 0, 0, 0,
function() function()
{ {
...@@ -282,10 +285,10 @@ var hopaeScene = new Phaser.Class( ...@@ -282,10 +285,10 @@ var hopaeScene = new Phaser.Class(
.on('button.out', function (button, groupName, index) { .on('button.out', function (button, groupName, index) {
//console.log('button out'); //console.log('button out');
}); });
this.warningText = UIObject.createLabel(this, game.config.width / 2, game.config.height / 2 - 100, 2, 'panel', 1, this.warningText = UIObject.createLabel(this, game.config.width / 2, game.config.height / 2 - 100, 2, 'panel', 1, 'center',
'이름 타수가 많아 플레이에 패널티가 있을 수 있습니다', 40, '#000000').setVisible(false).layout(); '이름 타수가 많아 플레이에 패널티가 있을 수 있습니다', 40, '#000000').setVisible(false).layout();
this.checkBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, 900, 5, 'pyeongminWrite', 0.5), 1, 0, 2, this.checkBtn = UIObject.createButton(this, UIObject.createLabel(this, game.config.width / 2, 900, 5, 'pyeongminWrite', 0.5, 'center'), 1, 0, 2,
function() function()
{ {
if(Input.checkProperInput(Input.inputField.text.text)) if(Input.checkProperInput(Input.inputField.text.text))
...@@ -295,7 +298,7 @@ var hopaeScene = new Phaser.Class( ...@@ -295,7 +298,7 @@ var hopaeScene = new Phaser.Class(
} }
}) })
this.backBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 900, 5, 'pyeongminWrite', 0.5), 1, 0, 2, this.backBtn = UIObject.createButton(this, UIObject.createLabel(this, 100, 900, 5, 'pyeongminWrite', 0.5, 'center'), 1, 0, 2,
function() function()
{ {
ScenesData.changeScene('menuScene'); ScenesData.changeScene('menuScene');
...@@ -424,7 +427,7 @@ var gameScene = new Phaser.Class( ...@@ -424,7 +427,7 @@ var gameScene = new Phaser.Class(
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
Input.inputField.generate(this, Input.gameSceneEnterReaction, Input.inputField.generate(this, Input.gameSceneEnterReaction,
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2, game.config.height * 25 / 36, 10, 'inputfield', 1, '', 25, '#000000').getElement('text')); UIObject.createLabel(ScenesData.gameScene, game.config.width / 2, game.config.height * 25 / 36, 10, 'inputfield', 1, 'center', '', 25, '#000000').getElement('text'));
WordSpace.attackGauge.generate(this); WordSpace.attackGauge.generate(this);
WordSpace.spaceInitiate(this); WordSpace.spaceInitiate(this);
......
var UIObject = UIObject || {}; var UIObject = UIObject || {};
UIObject.createLabel = function (scene, x, y, depth, image, size, text = '', textSize = 24, textColor = '#000000', textOriginX = 0.5, textOriginY = 0.5) { UIObject.createLabel = function (scene, x, y, depth, image, size, align, text = '', textSize = 24, textColor = '#000000', textOriginX = 0.5, textOriginY = 0.5) {
return scene.rexUI.add.label({ var temp = scene.rexUI.add.label({
/*width: width, /*width: width,
height: height,*/ height: height,*/
x: x, x: x,
...@@ -20,6 +20,20 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, text = '', tex ...@@ -20,6 +20,20 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, text = '', tex
bottom: 10 bottom: 10
} }
}); });
switch(align)
{
case 'left':
temp.x += temp.getElement('background').width / 2;
break;
case 'right':
temp.x -= temp.getElement('background').width / 2;
break;
case 'center':
break;
default:
break;
}
return temp;
} }
UIObject.createButton = function(scene, buttonGameObject, overFrame, outFrame, downFrame, clickCallback) { UIObject.createButton = function(scene, buttonGameObject, overFrame, outFrame, downFrame, clickCallback) {
......
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