Commit 4719dad0 authored by 18손재민's avatar 18손재민

호패 입력 씬 wip, 현재 호패 입력 받을 때 엽전이 불가능할 경우 끄는 기능 구현 wip

parent e42c19f3
...@@ -199,68 +199,38 @@ FirebaseClient.prototype.signInWithPopup = function(provider) ...@@ -199,68 +199,38 @@ FirebaseClient.prototype.signInWithPopup = function(provider)
FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = false) FirebaseClient.prototype.updateUserData = function(key, valueChanged, replace = false)
{ {
var beforeData = PlayerData.userData; var beforeData = PlayerData.userData;
var updates = {};
switch(key) switch(key)
{ {
case 'exp': case 'exp':
updates.exp = replace ? (valueChanged) : (beforeData.exp + valueChanged); beforeData.exp = replace ? (valueChanged) : (beforeData.exp + valueChanged);
beforeData.exp = updates.exp;
break; break;
case 'rank': case 'rank':
updates.rank = replace ? (valueChanged) : (beforeData.rank + valueChanged); beforeData.rank = replace ? (valueChanged) : (beforeData.rank + valueChanged);
beforeData.rank = updates.rank;
break; break;
case 'hopae': case 'hopae':
if (beforeData.hopae != null) if (beforeData.hopae != null) beforeData.hopae.push(valueChanged);
{ else beforeData.hopae = [valueChanged];
updates.hopae.push(valueChanged);
beforeData.hopae.push(valueChanged);
}
else
{
beforeData.hopae = [valueChanged];
updates.hopae = [valueChanged];
}
break; break;
case 'recentHopae': case 'recentHopae':
updates.recentHopae = valueChanged; beforeData.recentHopae = valueChanged;
beforeData.recentHopae = updates.recentHopae;
break; break;
case 'title': case 'title':
if (beforeData.title != null) if (beforeData.title != null) beforeData.title.push(valueChanged);
{ else beforeData.title = [valueChanged];
updates.title.push(valueChanged);
beforeData.title.push(valueChanged);
}
else
{
beforeData.title = [valueChanged];
updates.title = [valueChanged];
}
break; break;
case 'money': case 'money':
updates.money = replace ? (valueChanged) : (beforeData.money + valueChanged); beforeData.money = replace ? (valueChanged) : (beforeData.money + valueChanged);;
beforeData.money = updates.money;
break; break;
case 'item': case 'item':
if (beforeData.item != null) if (beforeData.item != null) beforeData.item.push(valueChanged);
{ else beforeData.item = [valueChanged];
updates.item.push(valueChanged);
beforeData.item.push(valueChanged);
}
else
{
beforeData.item = [valueChanged];
updates.item = [valueChanged];
}
break; break;
default: default:
console.log('[ERROR] database has no key for ' + key); console.log('[ERROR] database has no key for ' + key);
break; break;
} }
PlayerData.userData = beforeData; PlayerData.userData = beforeData;
console.log(updates.recentHopae); return this.database.ref('/user-data/' + this.auth.currentUser.uid).update(beforeData);
return this.database.ref('/user-data/' + this.auth.currentUser.uid).update(updates);
} }
document.addEventListener('DOMContentLoaded', function() document.addEventListener('DOMContentLoaded', function()
......
...@@ -336,7 +336,7 @@ Input.inputField = ...@@ -336,7 +336,7 @@ Input.inputField =
{ {
generate: function(scene, enterCallback, text) generate: function(scene, enterCallback, text)
{ {
this.text = text.setFontFamily('궁서'); this.text = text;
//this.text = scene.add.text(background.x, background.y, "", {font: fontSize + 'pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000').setDepth(10); //this.text = scene.add.text(background.x, background.y, "", {font: fontSize + 'pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000').setDepth(10);
scene.input.keyboard.on('keyup', function() {Input.pressCount--; Input.justPressed = ''; console.log(Input.finalInput);}) scene.input.keyboard.on('keyup', function() {Input.pressCount--; Input.justPressed = ''; console.log(Input.finalInput);})
......
...@@ -37,24 +37,18 @@ var menuScene = new Phaser.Class( ...@@ -37,24 +37,18 @@ var menuScene = new Phaser.Class(
BackGround.drawBackground(this); BackGround.drawBackground(this);
Audio.loopSound(this, 'login'); Audio.loopSound(this, 'login');
Input.inputField.generate(this, Input.menuSceneEnterReaction,
UIObject.createLabel(this, game.config.width / 2, game.config.height * 25 / 36, 10, 'inputfield', 1, '', 25, '#000000').getElement('text'));
//Input.inputField.generate(this, Input.menuSceneEnterReaction, this.add.sprite(game.config.width / 2, game.config.height * 25 / 36, 'inputfield').setDepth(10), 25);
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.currentHopae = this.add.text(100, 300, '현재 호패 : ' + PlayerData.userData.recentHopae).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40); this.currentHopae = this.add.text(100, 300, '현재 호패 : ' + PlayerData.userData.recentHopae).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40);
this.allHopae = ''; this.myHopae = [];
PlayerData.userData.hopae.forEach(function(element) {this.allHopae += (element.name + ' ')}); for(let i = 0; i < PlayerData.userData.hopae.length; i++)
this.hopae = this.add.text(100, 400, '내 호패들 : ' + allHopae).setOrigin(0, 0.5).setColor('#000000').setDepth(10).setPadding(5,5,5,5).setFontSize(40); {
this.myHopae.push(UIObject.createLabel(this, 300, 400 + 50 * i, 10, 'nameBgr6', 1, PlayerData.userData.hopae[i].name, 25, '#ffffff'));
}
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);
PlayerData.nickname = PlayerData.userData.recentHopae; PlayerData.nickname = PlayerData.userData.recentHopae;
this.roomEnterDialog = this.rexUI.add.dialog({ this.roomEnterDialog = this.rexUI.add.dialog({
x: game.config.width / 2, x: game.config.width / 2,
y: game.config.height / 2, y: game.config.height / 2,
...@@ -64,7 +58,7 @@ var menuScene = new Phaser.Class( ...@@ -64,7 +58,7 @@ var menuScene = new Phaser.Class(
title: this.rexUI.add.label({ title: this.rexUI.add.label({
background: this.rexUI.add.roundRectangle(0, 0, 100, 40, 20, 0x1b0000), background: this.rexUI.add.roundRectangle(0, 0, 100, 40, 20, 0x1b0000),
text: this.add.text(0, 0, '대기실에 참가하시겠습니까?', { text: this.add.text(0, 0, '대기실에 참가하시겠습니까?', {
fontSize: '24px' font: '50pt 궁서'
}).setOrigin(0.5, 0.5), }).setOrigin(0.5, 0.5),
space: { space: {
left: 15, left: 15,
...@@ -75,12 +69,12 @@ var menuScene = new Phaser.Class( ...@@ -75,12 +69,12 @@ var menuScene = new Phaser.Class(
}), }),
content: this.add.text(0, 0, '대기실에 참가하시겠습니까?', { content: this.add.text(0, 0, '대기실에 참가하시겠습니까?', {
fontSize: '24px' font: '50pt 궁서'
}), }),
actions: [ actions: [
UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'Yes'), UIObject.createLabel(this, 0, 0, 0, 'button', 1, '', 50),
UIObject.createLabel(this, 0, 0, 0, 'button', 1, 'No') UIObject.createLabel(this, 0, 0, 0, 'button', 1, '아니오', 50)
], ],
space: { space: {
...@@ -135,6 +129,14 @@ var menuScene = new Phaser.Class( ...@@ -135,6 +129,14 @@ var menuScene = new Phaser.Class(
}).on('click', function(button, gameObject, pointer){ }).on('click', function(button, gameObject, pointer){
console.log('상점 입장'); console.log('상점 입장');
}, this); }, this);
this.hopaeBtn = this.button.add(new Button(this, 100, 900, 'pyeongminThrow', 1, 0, 2).setScale(0.5).setDepth(5),
{
enabled: true, mode: 0
}).on('click', function(button, gameObject, pointer){
console.log('호패 입장');
ScenesData.changeScene('hopaeScene');
}, this);
} }
}); });
...@@ -170,7 +172,84 @@ var hopaeScene = new Phaser.Class( ...@@ -170,7 +172,84 @@ var hopaeScene = new Phaser.Class(
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')); UIObject.createLabel(this, game.config.width / 2, game.config.height / 2, 10, 'nameBgr6', 2, '', 50, '#ffffff').getElement('text'));
this.checkDialog = this.rexUI.add.dialog({
x: game.config.width / 2,
y: game.config.height / 2,
background: this.add.sprite(game.config.width / 2, game.config.height / 2, 'panel').setOrigin(0.5, 0.5),
content: this.add.text(0, 0, '이 이름으로 하시겠습니까?\n변경에는 엽전이 소모됩니다.', {
font: '50pt 궁서',
color: '#000000'
}),
actions: [
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '', 50),
UIObject.createLabel(this, 0, 0, 0, 'button', 1, '아니오', 50)
],
space: {
title: 25,
content: 25,
action: 100,
left: 20,
right: 20,
top: 20,
bottom: 20,
},
align: {
actions: 'center' // 'center'|'left'|'right'
},
expand: {
content: false, // Content is a pure text object
}
}).layout().setDepth(10).setVisible(false);
this.checkDialog
.on('button.click', function (button, groupName, index) {
if(index == 0)
{
if(1 == 0)
{
fbClient.updateUserData('hopae', {name: Input.inputField.text.text, type: 'wood'});
ScenesData.changeScene('menuScene');
}
else
{
this.checkDialog.setVisible(false);
this.shopBtn = this.button.add(new Button(this, game.config.width / 2, game.config.height / 2, 'pyeongminThrow', 1, 0, 2).setScale(0.5).setDepth(10),
{
enabled: true, mode: 0
}).on('click', function(button, gameObject, pointer){
}, this);
}
}
else
{
this.checkDialog.setVisible(false);
this.checkBtn.setEnable(true);
}
}, this)
.on('button.over', function (button, groupName, index) {
//console.log('button over');
})
.on('button.out', function (button, groupName, index) {
//console.log('button out');
});
this.checkBtn = this.button.add(new Button(this, game.config.width / 2, 900, 'pyeongminWrite', 1, 0, 2).setScale(0.5).setDepth(5),
{
enabled: true, mode: 0
}).on('click', function(button, gameObject, pointer){
console.log('호패 확인');
this.checkBtn.setEnable(false);
ScenesData.hopaeScene.checkDialog.setVisible(true).popUp(200);
}, this);
} }
}); });
...@@ -342,5 +421,6 @@ var gameScene = new Phaser.Class( ...@@ -342,5 +421,6 @@ var gameScene = new Phaser.Class(
ScenesData.changeScene = function(scene) ScenesData.changeScene = function(scene)
{ {
game.scene.stop(ScenesData.currentScene); game.scene.stop(ScenesData.currentScene);
ScenesData.currentScene = game.scene.start(scene); game.scene.start(scene);
ScenesData.currentScene = scene;
} }
\ No newline at end of file
...@@ -9,7 +9,7 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, text = '', tex ...@@ -9,7 +9,7 @@ UIObject.createLabel = function (scene, x, y, depth, image, size, text = '', tex
text: scene.add.text(x, y, text, { text: scene.add.text(x, y, text, {
fontSize: textSize + 'pt' fontSize: textSize + 'pt'
}).setDepth(depth).setOrigin(0.5, 0.5).setColor(textColor), }).setDepth(depth).setOrigin(0.5, 0.5).setColor(textColor).setFontFamily('궁서'),
space: { space: {
left: 10, left: 10,
......
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