Commit 6e58f527 authored by 18손재민's avatar 18손재민

반격 오류 수정

parent 4c0e1367
...@@ -337,6 +337,7 @@ class Player ...@@ -337,6 +337,7 @@ class Player
this.position = null; this.position = null;
this.killCount = 0; this.killCount = 0;
this.earnedStrongHopae = 0; this.earnedStrongHopae = 0;
this.attackSucceed = 0;
this.isAlive = false; this.isAlive = false;
this.isInThisRoom = true; this.isInThisRoom = true;
......
...@@ -167,7 +167,6 @@ socket.on('someoneAttacked', function(msg) // {Id attackerId, Id victimId} ...@@ -167,7 +167,6 @@ socket.on('someoneAttacked', function(msg) // {Id attackerId, Id victimId}
}); });
socket.on('attacked', function(msg) // object attackData socket.on('attacked', function(msg) // object attackData
{ {
//console.log('attacked by ' + msg.attacker.nickname);
let attackedEvent = new Cycle(function() let attackedEvent = new Cycle(function()
{ {
if(!WordSpace.isInvincible) if(!WordSpace.isInvincible)
...@@ -242,7 +241,7 @@ socket.on('defeat', function(msg) // object player ...@@ -242,7 +241,7 @@ socket.on('defeat', function(msg) // object player
if(msg.id == RoomData.myself.id) if(msg.id == RoomData.myself.id)
{ {
RoomData.myself = RoomData.players[msg.index]; RoomData.myself = RoomData.players[msg.index];
backToMenu(); backToMenu(false);
} }
}); });
socket.on('gameEnd', function(msg) // object player socket.on('gameEnd', function(msg) // object player
...@@ -250,7 +249,7 @@ socket.on('gameEnd', function(msg) // object player ...@@ -250,7 +249,7 @@ 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)
{ {
backToMenu(); backToMenu(true);
} }
}); });
...@@ -262,6 +261,7 @@ socket.on('attackSucceed', function(msg) ...@@ -262,6 +261,7 @@ socket.on('attackSucceed', function(msg)
tempWord.physicsObj.setPosition(victimPos.x, victimPos.y); tempWord.physicsObj.setPosition(victimPos.x, victimPos.y);
tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y); tempWord.wordObj.setPosition(tempWord.physicsObj.x, tempWord.physicsObj.y);
tempWord.destroy(); tempWord.destroy();
RoomData.myself.attackSucceed += 1;
}); });
// out game // out game
...@@ -272,8 +272,23 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname} ...@@ -272,8 +272,23 @@ socket.on('userDisconnect', function(msg) // {num index , num id, str nickname}
RoomData.aliveCount--; RoomData.aliveCount--;
}); });
var backToMenu = function() var backToMenu = function(isWin)
{ {
let earnedMoney = 0;
if(isWin) earnedMoney += 20;
earnedMoney += RoomData.myself.killCount * 3;
earnedMoney += parseInt(WordSpace.playerTypingRate / 10);
earnedMoney += Math.max(20, Math.pow(RoomData.myself.attackSucceed, 2));
earnedMoney += parseInt(20 * (1 - (RoomData.myself.rank - 1) / (RoomData.players.length - 1)));
var temp = function(){
socket.emit('exitFromRoom', RoomData.myself.id);
fbClient.updateUserData('killCount', RoomData.myself.killCount);
fbClient.updateUserData('money', earnedMoney);
ScenesData.changeScene('menuScene');
}
ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({ ScenesData.gameScene.backToMenuDialog = ScenesData.gameScene.rexUI.add.dialog({
x: game.config.width / 2, x: game.config.width / 2,
y: game.config.height / 2, y: game.config.height / 2,
...@@ -292,7 +307,7 @@ var backToMenu = function() ...@@ -292,7 +307,7 @@ var backToMenu = function()
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 50, 0, UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 50, 0,
'button', 1, 'center', '획득 강호패 : ' + RoomData.myself.earnedStrongHopae + '', 30).layout(), 'button', 1, 'center', '획득 강호패 : ' + RoomData.myself.earnedStrongHopae + '', 30).layout(),
UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 150, 0, UIObject.createLabel(ScenesData.gameScene, game.config.width / 2 + 120, game.config.height / 2 + 150, 0,
'button', 1, 'center', '획득 골드 : ' + 10, 30).layout() 'button', 1, 'center', '획득 골드 : ' + earnedMoney + '', 30).layout()
], ],
align: { align: {
...@@ -317,13 +332,6 @@ var backToMenu = function() ...@@ -317,13 +332,6 @@ var backToMenu = function()
actions: 'center' // 'center'|'left'|'right' actions: 'center' // 'center'|'left'|'right'
} }
}).setDepth(10); }).setDepth(10);
var temp = function(){
//WordSpace.resetGame();
socket.emit('exitFromRoom', RoomData.myself.id);
fbClient.updateUserData('killCount', RoomData.myself.killCount);
fbClient.updateUserData('money', 10);
ScenesData.changeScene('menuScene');
}
ScenesData.gameScene.backToMenuDialog ScenesData.gameScene.backToMenuDialog
.on('button.click', function (button, groupName, index) { .on('button.click', function (button, groupName, index) {
......
...@@ -210,6 +210,7 @@ class AttackWord extends WordObject ...@@ -210,6 +210,7 @@ class AttackWord extends WordObject
attackerId: RoomData.myself.id, attackerId: RoomData.myself.id,
victimId: this.attacker.id, victimId: this.attacker.id,
text: this.wordText, text: this.wordText,
multiple: 1,
grade: Math.min(3, this.wordGrade + 1), grade: Math.min(3, this.wordGrade + 1),
attackOption: { attackOption: {
isStrong: false, isStrong: false,
......
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