Commit 008e21b6 authored by 18손재민's avatar 18손재민

반격시간 표시 wip, 현재 반격 시간 표시 마스크가 단어 크기와 맞지 않는 이슈 있음

parent 93ded99d
...@@ -95,6 +95,8 @@ var gameScene = new Phaser.Class( ...@@ -95,6 +95,8 @@ var gameScene = new Phaser.Class(
create: function() create: function()
{ {
WordSpace.gameTimer = new Phaser.Time.Clock(this);
WordSpace.gameTimer.start();
WordSpace.loadAnimation(this); WordSpace.loadAnimation(this);
CSVParsing.CSVParse(this); CSVParsing.CSVParse(this);
BackGround.drawBrain(this); BackGround.drawBrain(this);
......
...@@ -53,6 +53,7 @@ class WordObject ...@@ -53,6 +53,7 @@ class WordObject
}); });
if (!this.isNameWord) this.wordObj.setColor('#000000').setOrigin(0.5,0.5); if (!this.isNameWord) this.wordObj.setColor('#000000').setOrigin(0.5,0.5);
else this.wordObj.setColor('#ffffff').setOrigin(0.45,0.5); else this.wordObj.setColor('#ffffff').setOrigin(0.45,0.5);
this.createdTime = WordSpace.gameTimer.now;
WordSpace.totalWeight += this.wordWeight; WordSpace.totalWeight += this.wordWeight;
WordSpace.totalWordNum += 1; WordSpace.totalWordNum += 1;
WordSpace.setGameOverTimer(); WordSpace.setGameOverTimer();
...@@ -145,8 +146,9 @@ class AttackWord extends WordObject ...@@ -145,8 +146,9 @@ class AttackWord extends WordObject
this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9); this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9);
this.wordWeight *= isStrong ? 3 : 2; this.wordWeight *= isStrong ? 3 : 2;
this.attacker = _playerData; this.attacker = _playerData;
this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5 : /*this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5 :
((5 - _wordGrade) * 3 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 2.5) / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5); ((5 - _wordGrade) * 3 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 2.5) / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5);*/
this.counterTime = WordSpace.gameTimer.now + 10000;
console.log('Attack text : ' + text + ', Attacker : ' + this.attacker.nickname + ', Weight : ' + this.wordWeight); console.log('Attack text : ' + text + ', Attacker : ' + this.attacker.nickname + ', Weight : ' + this.wordWeight);
console.log('Counter time : ' + this.counterTime); console.log('Counter time : ' + this.counterTime);
} }
...@@ -154,24 +156,39 @@ class AttackWord extends WordObject ...@@ -154,24 +156,39 @@ class AttackWord extends WordObject
{ {
super.instantiate(scene, lenRate); super.instantiate(scene, lenRate);
this.maskBackground = scene.physics.add.sprite(this.physicsObj.x, this.physicsObj.y, 'wordBgr' + this.wordGrade + '_' + Math.min(Math.max(2, this.wordText.length), 6)) this.maskBackground = scene.physics.add.sprite(this.physicsObj.x, this.physicsObj.y, 'wordBgr' + this.wordGrade + '_' + Math.min(Math.max(2, this.wordText.length), 6))
.setTint(Phaser.Display.Color.GetColor(120, 120, 120)).setScale(this.physicsObj.scale); .setTint(Phaser.Display.Color.GetColor(120, 120, 120)).setScale(this.scale);
this.maskBackground.alpha = 0.5;
console.log('scale ' + this.scale);
console.log('this.physicsObj.width ' + this.physicsObj.width);
console.log('this.physicsObj.height ' + this.physicsObj.height);
console.log('this.physicsObj.body.width ' + this.physicsObj.body.width);
console.log('this.physicsObj.body.height ' + this.physicsObj.body.height);
this.shape = scene.make.graphics(); this.shape = scene.make.graphics();
var rect = new Phaser.Geom.Rectangle(0, 0, this.maskBackground.width, this.maskBackground.height); var rect = new Phaser.Geom.Rectangle(0, 0, this.physicsObj.width, this.physicsObj.height);
this.shape.fillStyle(0xffffff); console.log(rect);
this.shape.fillRectShape(rect); console.log(this.shape);
this.shape.fillStyle(0xffffff).fillRectShape(rect);
this.mask = this.shape.createGeometryMask(); this.mask = this.shape.createGeometryMask();
this.maskBackground.setMask(this.mask); this.maskBackground.setMask(this.mask);
this.maskStart = this.physicsObj.x;
this.maskEnd = this.physicsObj.x - this.physicsObj.width;
} }
attract() attract()
{ {
super.attract(); super.attract();
this.maskBackground.setPosition(this.physicsObj.x, this.physicsObj.y); if(WordSpace.gameTimer.now < this.counterTime)
this.mask.x = this.physicsObj.x; {
this.mask.y = this.physicsObj.y; this.maskBackground.setPosition(this.physicsObj.x, this.physicsObj.y);
this.shape.x = this.physicsObj.x + (this.maskEnd - this.maskStart) *
((WordSpace.gameTimer.now - this.createdTime) / (this.counterTime - this.createdTime)) - this.physicsObj.width / 2;
this.shape.y = this.physicsObj.y - this.physicsObj.height / 2;
}
else if(this.maskBackground != null) this.maskBackground.destroy();
} }
destroy() destroy()
{ {
switch(this.wordGrade) switch(this.wordGrade)
...@@ -188,7 +205,7 @@ class AttackWord extends WordObject ...@@ -188,7 +205,7 @@ class AttackWord extends WordObject
let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, this.attacker); let tempWord = WordSpace.generateWord.Name(ScenesData.gameScene, true, this.attacker);
tempWord.destroy(); tempWord.destroy();
} }
//WordSpace.nameGroup.push(new NameWord(this.attacker, true)); if(this.maskBackground != null) this.maskBackground.destroy();
super.destroy(); super.destroy();
} }
} }
......
...@@ -426,8 +426,6 @@ WordSpace.setPlayerTyping = ...@@ -426,8 +426,6 @@ WordSpace.setPlayerTyping =
}, },
initiate: function(scene) initiate: function(scene)
{ {
WordSpace.gameTimer = new Phaser.Time.Clock(scene);
WordSpace.gameTimer.start();
this.text = scene.add.text(100,200,'현재 타수 : ' + WordSpace.playerTyping.toFixed(1)).setDepth(10).setColor('#000000'); this.text = scene.add.text(100,200,'현재 타수 : ' + WordSpace.playerTyping.toFixed(1)).setDepth(10).setColor('#000000');
} }
} }
......
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