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

이제 공격 시 종이 뭉치가 날아감

parent 8e41673e
...@@ -31,7 +31,7 @@ BackGround.drawCharacter = function(scene) ...@@ -31,7 +31,7 @@ BackGround.drawCharacter = function(scene)
element.playerImage.flipX = element.position.x < game.config.width / 2 ? true : false; element.playerImage.flipX = element.position.x < game.config.width / 2 ? true : false;
element.nicknameText = scene.add.text(element.position.x, element.position.y - 90, element.nickname) element.nicknameText = scene.add.text(element.position.x, element.position.y - 90, element.nickname)
.setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(1); .setOrigin(0.5,0.5).setColor('#000000').setPadding(0.5,0.5,0.5,0.5).setDepth(1);
} 6 }
}); });
} }
......
...@@ -153,6 +153,17 @@ var gameScene = new Phaser.Class( ...@@ -153,6 +153,17 @@ var gameScene = new Phaser.Class(
// for test // for test
WordSpace.attackGauge.add(11); WordSpace.attackGauge.add(11);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
}, },
update: function() update: function()
...@@ -172,6 +183,9 @@ var gameScene = new Phaser.Class( ...@@ -172,6 +183,9 @@ var gameScene = new Phaser.Class(
//테스트용 //테스트용
tempNames += element.wordText + (element.isStrong?' [강]':'') + '\n'; tempNames += element.wordText + (element.isStrong?' [강]':'') + '\n';
}); });
WordSpace.attackPaperGroup.forEach(function(element){
element.moveObject(element);
});
WordSpace.nameWordTextForTest.setText('현재 가진 호패들 : \n' + tempNames); WordSpace.nameWordTextForTest.setText('현재 가진 호패들 : \n' + tempNames);
WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ WordSpace.brainCapacity+' (전체)'); WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ WordSpace.brainCapacity+' (전체)');
......
...@@ -276,6 +276,9 @@ class NameWord extends WordObject ...@@ -276,6 +276,9 @@ class NameWord extends WordObject
duration: 2000, duration: 2000,
repeat: 0 repeat: 0
}); });
/*setTimeout(() => {
WordSpace.movingObjects.pop();
}, 2000);*/
//이동경로 디버그 //이동경로 디버그
/*var graphics = ScenesData.gameScene.add.graphics(); /*var graphics = ScenesData.gameScene.add.graphics();
......
var WordReader = WordReader || {}; var WordReader = WordReader || {};
WordReader.normalWeight = [3, 5, 7, 10];
WordReader.attackWeight = [6, 8, 12, 15];
WordReader.strongAttackWeight = [10, 13, 16, 20];
//초성의 타수를 반환함 //초성의 타수를 반환함
WordReader.firstSound = function(charText) WordReader.firstSound = function(charText)
{ {
...@@ -54,6 +58,32 @@ WordReader.getWordGrade = function(_wordTyping) ...@@ -54,6 +58,32 @@ WordReader.getWordGrade = function(_wordTyping)
17 <= _wordTyping && _wordTyping < 26 ? 0 : -1; 17 <= _wordTyping && _wordTyping < 26 ? 0 : -1;
} }
WordReader.normalWeight = [3, 5, 7, 10]; WordReader.getEditDistance = function(input, check) {
WordReader.attackWeight = [6, 8, 12, 15]; var inputWords = [], checkWords = []
WordReader.strongAttackWeight = [10, 13, 16, 20]; for(let i = 0; i < input.length; i++)
\ No newline at end of file {
inputWords.push(parseInt(((input[i].charCodeAt(0) - parseInt('0xac00',16)) /28) / 21) + parseInt('0x1100',16));
inputWords.push(parseInt(((input[i].charCodeAt(0)- parseInt('0xac00',16)) / 28) % 21) + parseInt('0x1161',16));
inputWords.push(parseInt((input[i].charCodeAt(0) - parseInt('0xac00',16)) % 28) + parseInt('0x11A8') -1);
}
for(let i = 0; i < check.length; i++)
{
checkWords.push(parseInt(((check[i].charCodeAt(0) - parseInt('0xac00',16)) /28) / 21) + parseInt('0x1100',16));
checkWords.push(parseInt(((check[i].charCodeAt(0)- parseInt('0xac00',16)) / 28) % 21) + parseInt('0x1161',16));
checkWords.push(parseInt((check[i].charCodeAt(0) - parseInt('0xac00',16)) % 28) + parseInt('0x11A8') -1);
}
var matrix = [];
var i, j;
for(i = 0; i <= checkWords.length; i++) // increment along the first column of each row
matrix[i] = [i];
for(j = 0; j <= inputWords.length; j++) // increment each column in the first row
matrix[0][j] = j;
for(i = 1; i <= checkWords.length; i++) // Fill in the rest of the matrix
for(j = 1; j <= inputWords.length; j++){
if(checkWords[i-1] == inputWords[j-1]) matrix[i][j] = matrix[i-1][j-1];
else matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution
Math.min(matrix[i][j-1] + 1, // insertion
matrix[i-1][j] + 1)); // deletion
}
return matrix[checkWords.length][inputWords.length];
}
\ No newline at end of file
...@@ -16,6 +16,7 @@ WordSpace.pyeongminAnims = []; ...@@ -16,6 +16,7 @@ WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = []; WordSpace.wordGroup = [];
WordSpace.nameGroup = []; WordSpace.nameGroup = [];
WordSpace.attackPaperGroup = [];
WordSpace.wordForcedGroup = []; WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null; WordSpace.wordPhysicsGroup = null;
...@@ -196,6 +197,7 @@ WordSpace.loadImage = function(scene) ...@@ -196,6 +197,7 @@ WordSpace.loadImage = function(scene)
scene.load.spritesheet('wordBreak', 'assets/image/word/wordbreak.png', { frameWidth: 180, frameHeight: 180 }); scene.load.spritesheet('wordBreak', 'assets/image/word/wordbreak.png', { frameWidth: 180, frameHeight: 180 });
scene.load.spritesheet('pyeongminWrite', 'assets/image/character/pyeongmin/write/pyeong_write.png', { frameWidth: 490, frameHeight: 423 }); scene.load.spritesheet('pyeongminWrite', 'assets/image/character/pyeongmin/write/pyeong_write.png', { frameWidth: 490, frameHeight: 423 });
scene.load.spritesheet('pyeongminThrow', 'assets/image/character/pyeongmin/throw/pyeong_throw.png', { frameWidth: 490, frameHeight: 423 }); scene.load.spritesheet('pyeongminThrow', 'assets/image/character/pyeongmin/throw/pyeong_throw.png', { frameWidth: 490, frameHeight: 423 });
scene.load.image('attackPapaer', 'assets/image/etc/paper_crumbled.png');
WordSpace.weightTextObjForTest = scene.add.text(100, 75, '뇌의 무게: (현재) 0 / ' + this.brainCapacity + ' (전체)').setDepth(10).setColor('#000000'); WordSpace.weightTextObjForTest = scene.add.text(100, 75, '뇌의 무게: (현재) 0 / ' + this.brainCapacity + ' (전체)').setDepth(10).setColor('#000000');
WordSpace.killLogTextForTest = scene.add.text(1000, 50, WordSpace.killLogForTest).setDepth(10).setColor('#000000').setAlign('right'); WordSpace.killLogTextForTest = scene.add.text(1000, 50, WordSpace.killLogForTest).setDepth(10).setColor('#000000').setAlign('right');
...@@ -345,14 +347,14 @@ WordSpace.findWord = function(wordText) ...@@ -345,14 +347,14 @@ WordSpace.findWord = function(wordText)
{ {
if(element instanceof AttackWord) if(element instanceof AttackWord)
{ {
tempDist = WordSpace.getEditDistance(wordText, element.wordText); tempDist = WordReader.getEditDistance(wordText, element.wordText);
attackWords.push(element); attackWords.push(element);
if(tempDist <= minDist) minDist = tempDist; if(tempDist <= minDist) minDist = tempDist;
} }
}); });
attackWords.some(function(element) attackWords.some(function(element)
{ {
if(WordSpace.getEditDistance(wordText, element.wordText) == minDist) if(WordReader.getEditDistance(wordText, element.wordText) == minDist)
{ {
console.log('Attack word : ' + element.wordText + ' of ' + element.attacker.nickname + ' 오타임'); console.log('Attack word : ' + element.wordText + ' of ' + element.attacker.nickname + ' 오타임');
let victimData = let victimData =
...@@ -405,6 +407,33 @@ WordSpace.attack = function(wordText, grade) ...@@ -405,6 +407,33 @@ WordSpace.attack = function(wordText, grade)
socket.emit('attack', attackData); socket.emit('attack', attackData);
element.physicsObj.destroy(); element.physicsObj.destroy();
element.wordObj.destroy(); element.wordObj.destroy();
var attackPaper = ScenesData.gameScene.add.sprite(BackGround.myCharacter.x, BackGround.myCharacter.y, 'attackPapaer').setScale(0.5).setDepth(3);
attackPaper.throwTarget = RoomData.players.find(function(_element) {
return _element.id == element.ownerId;
}).playerImage;
attackPaper.follower = { t: 0, vec: new Phaser.Math.Vector2() };
attackPaper.path = new Phaser.Curves.Spline([
BackGround.myCharacter.x, BackGround.myCharacter.y,
(BackGround.myCharacter.x + attackPaper.throwTarget.x) / 2, Math.min(BackGround.myCharacter.y, attackPaper.throwTarget.y) - 100,
attackPaper.throwTarget.x, attackPaper.throwTarget.y - 10
]);
ScenesData.gameScene.tweens.add({
targets: attackPaper.follower,
t: 1,
ease: 'Linear',
duration: 4000,
repeat: 0,
onComplete: function() {
attackPaper.destroy();
WordSpace.attackPaperGroup = [];
}
});
attackPaper.moveObject = function(obj)
{
obj.path.getPoint(obj.follower.t, obj.follower.vec);
obj.setPosition(obj.follower.vec.x, obj.follower.vec.y);
}
WordSpace.attackPaperGroup.push(attackPaper);
}); });
WordSpace.generateWord.Name(ScenesData.gameScene, false, null); WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
WordSpace.generateWord.Name(ScenesData.gameScene, false, null); WordSpace.generateWord.Name(ScenesData.gameScene, false, null);
...@@ -449,33 +478,3 @@ WordSpace.nameQueue = ...@@ -449,33 +478,3 @@ WordSpace.nameQueue =
this.shuffle(); this.shuffle();
} }
} }
WordSpace.getEditDistance = function(input, check) {
var inputWords = [], checkWords = []
for(let i = 0; i < input.length; i++)
{
inputWords.push(parseInt(((input[i].charCodeAt(0) - parseInt('0xac00',16)) /28) / 21) + parseInt('0x1100',16));
inputWords.push(parseInt(((input[i].charCodeAt(0)- parseInt('0xac00',16)) / 28) % 21) + parseInt('0x1161',16));
inputWords.push(parseInt((input[i].charCodeAt(0) - parseInt('0xac00',16)) % 28) + parseInt('0x11A8') -1);
}
for(let i = 0; i < check.length; i++)
{
checkWords.push(parseInt(((check[i].charCodeAt(0) - parseInt('0xac00',16)) /28) / 21) + parseInt('0x1100',16));
checkWords.push(parseInt(((check[i].charCodeAt(0)- parseInt('0xac00',16)) / 28) % 21) + parseInt('0x1161',16));
checkWords.push(parseInt((check[i].charCodeAt(0) - parseInt('0xac00',16)) % 28) + parseInt('0x11A8') -1);
}
var matrix = [];
var i, j;
for(i = 0; i <= checkWords.length; i++) // increment along the first column of each row
matrix[i] = [i];
for(j = 0; j <= inputWords.length; j++) // increment each column in the first row
matrix[0][j] = j;
for(i = 1; i <= checkWords.length; i++) // Fill in the rest of the matrix
for(j = 1; j <= inputWords.length; j++){
if(checkWords[i-1] == inputWords[j-1]) matrix[i][j] = matrix[i-1][j-1];
else matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution
Math.min(matrix[i][j-1] + 1, // insertion
matrix[i-1][j] + 1)); // deletion
}
return matrix[checkWords.length][inputWords.length];
}
\ 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