Commit 71d38ba3 authored by 18손재민's avatar 18손재민

암흑 단어 구현

parent 7d728b9e
...@@ -154,7 +154,7 @@ socket.on('attacked', function(msg) // object attackData ...@@ -154,7 +154,7 @@ socket.on('attacked', function(msg) // object attackData
let attackedEvent = new Cycle(function() let attackedEvent = new Cycle(function()
{ {
if(!WordSpace.isInvincible) if(!WordSpace.isInvincible)
for (let i = 0; i < msg.multiple; i++) WordSpace.generateWord.Attack(ScenesData.gameScene, msg.text, msg.grade, msg.attacker, msg.isStrong, msg.isCountable, msg.isHeavy); for (let i = 0; i < msg.multiple; i++) WordSpace.generateWord.Attack(ScenesData.gameScene, msg.text, msg.grade, msg.attacker, msg.attackOption);
attackedEvent.currentCycle.destroy(); attackedEvent.currentCycle.destroy();
WordSpace.attackedEvents.splice(WordSpace.attackedEvents.findIndex(function(element) { WordSpace.attackedEvents.splice(WordSpace.attackedEvents.findIndex(function(element) {
return element.cert === (msg.text + msg.attacker); return element.cert === (msg.text + msg.attacker);
......
...@@ -12,7 +12,12 @@ Input.justPressed = ''; ...@@ -12,7 +12,12 @@ Input.justPressed = '';
Input.maxInput = 6; Input.maxInput = 6;
Input.attackMode = false; Input.attackMode = false;
Input.attackOption = null; Input.attackOption = {
wordCount: 0,
wordGrade: 0,
isHeavy: false,
isDark: false
};
Input.gameSceneEnterReaction = function() Input.gameSceneEnterReaction = function()
{ {
......
...@@ -160,6 +160,8 @@ var gameScene = new Phaser.Class( ...@@ -160,6 +160,8 @@ var gameScene = new Phaser.Class(
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.clean); WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.clean);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.heavy); WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.heavy);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.heavy); WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.heavy);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.dark);
WordSpace.generateWord.Item(ScenesData.gameScene, Enums.item.dark);
// for test // for test
WordSpace.attackGauge.add(11); WordSpace.attackGauge.add(11);
......
...@@ -137,18 +137,19 @@ class NormalWord extends WordObject ...@@ -137,18 +137,19 @@ class NormalWord extends WordObject
class AttackWord extends WordObject class AttackWord extends WordObject
{ {
constructor(text, _wordGrade, _playerData, _isStrong, _isCountable = true, _isHeavy = false, lenRate) constructor(text, _wordGrade, _playerData, _attackOption, lenRate)
{ {
super(text); super(text);
this.wordGrade = _wordGrade; this.wordGrade = _wordGrade;
this.wordWeight = _isStrong ? WordReader.strongAttackWeight[3 - this.wordGrade] : WordReader.attackWeight[3 - this.wordGrade]; this.wordWeight = _attackOption.isStrong ? WordReader.strongAttackWeight[3 - this.wordGrade] : WordReader.attackWeight[3 - this.wordGrade];
if(WordReader.getWordTyping(_playerData.nickname) > 9) if(WordReader.getWordTyping(_playerData.nickname) > 9)
this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9); this.wordWeight += this.wordWeight * 0.2 * (WordReader.getWordTyping(_playerData.nickname) - 9);
if(_isHeavy) this.wordWeight *= 2; if(_attackOption.isHeavy) this.wordWeight *= 2;
this.attacker = _playerData; this.attacker = _playerData;
if(!_isCountable) this.counterTime = 0; if(!_attackOption.isCountable) this.counterTime = 0;
else this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping / (Math.max(200, WordSpace.playerTyping) / 60) * 1.5 : else 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.isDark = _attackOption.isDark;
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);
} }
...@@ -157,16 +158,22 @@ class AttackWord extends WordObject ...@@ -157,16 +158,22 @@ 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.scale); .setTint(Phaser.Display.Color.GetColor(120, 120, 120)).setScale(this.scale);
this.maskBackground.alpha = 0.5; this.maskBackground.alpha = this.isDark ? 1 : 0.5;
this.shape = scene.make.graphics(); this.shape = scene.make.graphics();
var rect = new Phaser.Geom.Rectangle(0, 0, this.maskBackground.width * this.scale, this.maskBackground.height * this.scale); var rect = new Phaser.Geom.Rectangle(0, 0, this.maskBackground.width * this.scale, this.maskBackground.height * this.scale);
this.shape.fillStyle(0xffffff).fillRectShape(rect); this.shape.fillStyle(0xffffff).fillRectShape(rect);
this.mask = this.shape.createGeometryMask(); this.mask = this.shape.createGeometryMask();
this.maskBackground.setMask(this.mask);
this.maskStart = this.physicsObj.x; this.maskStart = this.physicsObj.x;
this.maskEnd = this.physicsObj.x - this.physicsObj.width * this.scale; this.maskEnd = this.physicsObj.x - this.physicsObj.width * this.scale;
if(this.isDark)
{
setTimeout(() => {
if(this.maskBackground != null && this.mask != null) this.maskBackground.setMask(this.mask);
}, 4000);
}
else this.maskBackground.setMask(this.mask);
} }
attract() attract()
...@@ -205,8 +212,12 @@ class AttackWord extends WordObject ...@@ -205,8 +212,12 @@ class AttackWord extends WordObject
target: this.attacker.id, target: this.attacker.id,
text: this.wordText, text: this.wordText,
grade: Math.min(3, this.wordGrade + 1), grade: Math.min(3, this.wordGrade + 1),
attackOption: {
isStrong: false, isStrong: false,
isCountable: false isCountable: false,
isHeavy: false,
isDark: false
},
} }
socket.emit('attack', attackData); socket.emit('attack', attackData);
} }
...@@ -328,9 +339,10 @@ class ItemWord extends WordObject ...@@ -328,9 +339,10 @@ class ItemWord extends WordObject
for(let i = 0; i < tempLenth; i++) WordSpace.wordGroup[i].destroy(); for(let i = 0; i < tempLenth; i++) WordSpace.wordGroup[i].destroy();
break; break;
case Enums.item.heavy: case Enums.item.heavy:
WordSpace.isHeavy = true; Input.attackOption.isHeavy = true;
break; break;
case Enums.item.dark: case Enums.item.dark:
Input.attackOption.isDark = true;
break; break;
default: default:
console.log("Item type is inappropriate. Item type : " + this.itemType); console.log("Item type is inappropriate. Item type : " + this.itemType);
......
...@@ -13,7 +13,6 @@ WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치 ...@@ -13,7 +13,6 @@ WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머 WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isTimerOn = false; WordSpace.isTimerOn = false;
WordSpace.isInvincible = false; WordSpace.isInvincible = false;
WordSpace.isHeavy = false;
WordSpace.pyeongminAnims = []; WordSpace.pyeongminAnims = [];
WordSpace.wordGroup = []; WordSpace.wordGroup = [];
...@@ -236,9 +235,9 @@ WordSpace.generateWord = ...@@ -236,9 +235,9 @@ WordSpace.generateWord =
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
}, },
Attack: function(scene, wordText, grade, attacker, isStrong, isCountable, isHeavy, lenRate) Attack: function(scene, wordText, grade, attacker, attackOption, lenRate)
{ {
word = new AttackWord(wordText, grade, attacker, isStrong, isCountable, isHeavy); word = new AttackWord(wordText, grade, attacker, attackOption);
WordSpace.pushWord(scene, word, lenRate); WordSpace.pushWord(scene, word, lenRate);
return word; return word;
}, },
...@@ -333,13 +332,15 @@ WordSpace.findWord = function(wordText) ...@@ -333,13 +332,15 @@ WordSpace.findWord = function(wordText)
else if (wordText === '공격' && WordSpace.attackGauge.value >= 3 && WordSpace.nameGroup.length > 0) // 공격모드 진입. else if (wordText === '공격' && WordSpace.attackGauge.value >= 3 && WordSpace.nameGroup.length > 0) // 공격모드 진입.
{ {
console.log('attack mode'); console.log('attack mode');
Input.attackOption = this.attackGauge.getAttackOption(); let tempAttackOption = this.attackGauge.getAttackOption();
Input.attackOption.wordCount = tempAttackOption.wordCount;
Input.attackOption.wordGrade = tempAttackOption.wordGrade;
Input.maxInput = Input.attackOption.wordCount; Input.maxInput = Input.attackOption.wordCount;
Input.attackMode = true; Input.attackMode = true;
WordSpace.attackGauge.pauseCycle(true); WordSpace.attackGauge.pauseCycle(true);
WordSpace.setPlayerTyping.add(wordText); WordSpace.setPlayerTyping.add(wordText);
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.attackWrite]); RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.attackWrite]);
RoomData.myself.playerImage.anims.msPerFrame /= (4 - WordSpace.attackGauge.getAttackOption().wordGrade); RoomData.myself.playerImage.anims.msPerFrame /= (4 - Input.attackOption.wordGrade);
} }
else // 오타 체크 else // 오타 체크
{ {
...@@ -421,8 +422,12 @@ WordSpace.attack = function(wordText, grade) ...@@ -421,8 +422,12 @@ WordSpace.attack = function(wordText, grade)
victim: target, victim: target,
text: wordText, text: wordText,
grade: grade, grade: grade,
attackOption: {
isStrong: element.isStrong, isStrong: element.isStrong,
isHeavy: WordSpace.isHeavy, isCountable: true,
isHeavy: Input.attackOption.isHeavy,
isDark: Input.attackOption.isDark
},
multiple: 1 multiple: 1
} }
WordSpace.makeAttackPaper(ScenesData.gameScene, RoomData.myself.position, target.position); WordSpace.makeAttackPaper(ScenesData.gameScene, RoomData.myself.position, target.position);
...@@ -443,7 +448,8 @@ WordSpace.attack = function(wordText, grade) ...@@ -443,7 +448,8 @@ WordSpace.attack = function(wordText, grade)
WordSpace.attackGauge.resetValue(); WordSpace.attackGauge.resetValue();
WordSpace.setPlayerTyping.add(wordText); WordSpace.setPlayerTyping.add(wordText);
RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.throw]); RoomData.myself.playerImage.play(WordSpace.pyeongminAnims[Enums.characterAnim.throw]);
WordSpace.isHeavy = false; Input.attackOption.isHeavy = false;
Input.attackOption.isDark = false;
} }
else WordSpace.attackGauge.cutValue(0.3); else WordSpace.attackGauge.cutValue(0.3);
Input.maxInput = 6; Input.maxInput = 6;
......
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