Commit 7c1db744 authored by 18손재민's avatar 18손재민 Committed by 18손재민

일반 단어 클래스 분리, 이제 호패는 개별적인 공격 게이지 감소치를 가짐

게임 오버 타이머 수정, 호패 생성 주기 수정함
parent a7b69339
......@@ -298,7 +298,6 @@ Input.inputField =
Input.convInput = Input.removeConVow(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
WordSpace.resetGameOverTimer();
Input.reset();
});
// upside 10 keys
......
......@@ -57,9 +57,7 @@ var gameScene = new Phaser.Class(
WordSpace.attackGauge.resetCycle(this);
WordSpace.wordCycle.resetCycle(this, 3000, 0, true);
WordSpace.nameCycle.resetCycle(this, 3000, 0, true);
WordSpace.varAdjustCycle.resetCycle(this, 100);
WordSpace.varAdjustCycle.resetCycle(this, 100, 0, true);
WordSpace.setPlayerTyping.initiate(this);
......@@ -71,6 +69,7 @@ var gameScene = new Phaser.Class(
{
element.attract();
});
WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ WordSpace.brainCapacity+' (전체)');
WordSpace.setPlayerTyping.add('');
}
});
\ No newline at end of file
......@@ -39,6 +39,7 @@ class WordObject
console.log(this.generationCode + ': ' + this.wordText + ' destroyed');
WordSpace.totalWeight -= this.wordWeight;
WordSpace.totalWordNum -= 1;
WordSpace.resetGameOverTimer();
this.wordObj.destroy();
const groupIdx = WordSpace.wordGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (groupIdx > -1) WordSpace.wordGroup.splice(groupIdx, 1);
......@@ -65,6 +66,26 @@ class WordObject
isEqualObject(_generationCode) { return _generationCode === this.generationCode; }
}
class NormalWord extends WordObject
{
constructor(text)
{
super(text);
}
destroy()
{
switch(this.wordGrade)
{
case 0: WordSpace.attackGauge.add(2.5); break;
case 1: WordSpace.attackGauge.add(1.5); break;
case 2: WordSpace.attackGauge.add(0.9); break;
case 3: WordSpace.attackGauge.add(0.5); break;
default: console.log('[ERR] wrong grade of word'); break;
}
super.destroy();
}
}
class AttackWord extends WordObject
{
constructor(text, _wordGrade, _attacker, isStrong)
......@@ -77,16 +98,21 @@ class AttackWord extends WordObject
this.wordWeight *= isStrong ? 3 : 2;
this.attacker = _attacker;
//서버 사용하게 되면 PlayerTyping을 피격자의 것으로 바꿔야 함
/*this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping * (WordSpace.playerTyping / 60) * 2 :
((5 - _wordGrade) * 2.5 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 3) * (WordSpace.playerTyping / 60) * 2);*/
this.counterTime = WordSpace.gameTimer.now + 10000;
this.counterTime = WordSpace.gameTimer.now + 1000 * (this.wordTyping <= (5 - _wordGrade) * 2.5 ? this.wordTyping * (WordSpace.playerTyping / 60) * 2 :
((5 - _wordGrade) * 2.5 + (this.wordTyping - (5 - _wordGrade) * 2.5) * 3) * (WordSpace.playerTyping / 60) * 2);
console.log('Attack text : ' + text + ', Attacker : ' + this.attacker + ', Weight : ' + this.wordWeight);
console.log('Counter time : ' + this.counterTime);
console.log(WordSpace.playerTyping);
}
destroy()
{
switch(this.wordGrade)
{
case 0: WordSpace.attackGauge.add(2.5); break;
case 1: WordSpace.attackGauge.add(1.5); break;
case 2: WordSpace.attackGauge.add(0.9); break;
case 3: WordSpace.attackGauge.add(0.5); break;
default: console.log('[ERR] wrong grade of word'); break;
}
if(WordSpace.gameTimer.now < this.counterTime) WordSpace.generateWord.Name(WordSpace.gameSceneForTest, true);
super.destroy();
}
......@@ -100,5 +126,10 @@ class NameWord extends WordObject
this.wordWeight = 2;
this.isStrong = _isStrong;
console.log('Name : ' + text + ', Strong : ' + this.isStrong + ', Weight : ' + this.wordWeight);
}
}
destroy()
{
WordSpace.attackGauge.add(this.wordTyping * 0.1);
super.destroy();
}
}
......@@ -9,9 +9,8 @@ WordSpace.isImageLoaded = false;
WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 200; //수용 가능한 단어 무게 최대치
WordSpace.brainCapacity = 50; //수용 가능한 단어 무게 최대치
WordSpace.defeatTime = 5000;
WordSpace.gameOverTimer = null; //게임 오버 판정 타이머
WordSpace.gameTimer = null; //현재 게임 플레이 시간 타이머
WordSpace.isTimerOn = false;
......@@ -242,7 +241,7 @@ WordSpace.generateWord =
{
Normal: function(scene, grade, lenRate)
{
word = new WordObject(SelectWord.selectWord(grade));
word = new NormalWord(SelectWord.selectWord(grade));
WordSpace.pushWord(scene, word, lenRate);
},
Attack: function(scene, wordText, grade, attacker, isStrong, lenRate)
......@@ -270,13 +269,12 @@ WordSpace.pushWord = function(scene, word, lenRate)
object1.topObj.attract();
});
WordSpace.wordPhysicsGroup.add(word.physicsObj);
WordSpace.weightTextObjForTest.setText('뇌의 무게: (현재) '+WordSpace.totalWeight+' / '+ this.brainCapacity+' (전체)');
}
function gameOver()
{
WordSpace.wordCycle.currentCycle.remove();
WordSpace.nameCycle.currentCycle.remove();
//To Do
console.log('defeat');
}
......@@ -287,8 +285,9 @@ WordSpace.setGameOverTimer = function()
//만약 현재 단어 무게 총합이 뇌 용량보다 크다면 타이머를 시작함
if(this.brainCapacity < this.totalWeight && !this.isTimerOn)
{
WordSpace.gameOverCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.defeatTime, false);
this.isTimerOn = true;
WordSpace.gameOverCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.defeatTime, 0, false);
console.log('Game over timer On');
}
}
......@@ -296,8 +295,9 @@ WordSpace.resetGameOverTimer = function()
{
if(this.brainCapacity >= this.totalWeight && this.isTimerOn)
{
this.gameOverTimer.remove();
this.isTimerOn = false;
WordSpace.gameOverCycle.currentCycle.paused = true;
console.log('Game over timer Off');
}
}
......@@ -314,18 +314,8 @@ WordSpace.findWord = function(wordText)
{
if (weightest.wordWeight < element.wordWeight) weightest = element;
});
switch(weightest.wordGrade) // 이부분 나중에 더 효율적으로 바꿀수있지 않을까
{
case 0: WordSpace.attackGauge.add(2.5); break;
case 1: WordSpace.attackGauge.add(1.5); break;
case 2: WordSpace.attackGauge.add(0.9); break;
case 3: WordSpace.attackGauge.add(0.5); break;
default: console.log('[ERR] wrong grade of word'); break;
}
//if(typeof(weightest) == 'AttackWord')
console.log(weightest instanceof AttackWord);
weightest.destroy();
WordSpace.nameCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.NameSpawnDelay, WordSpace.nameCycle.currentCycle.getElapsed() + WordSpace.NameSpawnReduce);
WordSpace.nameCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.NameSpawnDelay, WordSpace.nameCycle.currentCycle.getElapsed() + WordSpace.NameSpawnReduce, true);
while(WordSpace.totalWordNum < 5)
{
......
......@@ -30,7 +30,7 @@ socket.on('idSet', function(msg) // {str, num}
});
//test
window.addEventListener("message", function(event)
/*window.addEventListener("message", function(event)
{
var sub = 0;
if(event.data == "tick"){
......@@ -126,4 +126,4 @@ window.addEventListener("message", function(event)
alert("Your browser does not support postMessage. Sorry but you will be forced to default to the standard setInterval and setTimeout functions. This means you may experience pauses in your game when you navigate away from the tab it is playing in.");
}
});
})(this);
})(this);*/
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