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

단어 무게 총합 구현 및 게임 오버 임시로 구현함. 현재 단어 무게가 뇌 용량을 넘어선 채로 3초간 유지되면 게임 오버됨.

단어를 삭제하는 기능이 없는 관계로 나중에 타이머 리셋하는 기능 구현할 것.
parent f30281f5
......@@ -6,7 +6,7 @@ class WordObject
this.wordText = text;
//this.wordText = Input.removeConVow(text);
this.wordTyping = WordReader.getWordTyping(this.wordText);
this.wordGrade = WordReader.getwordWeight(this.wordTyping);
this.wordGrade = WordReader.getWordGrade(this.wordTyping);
this.wordWeight = (function(_wordGrade)
{
var temp = 0;
......@@ -15,6 +15,9 @@ class WordObject
_wordGrade == 1 ? 7 : 10;
return temp;
})(this.wordGrade);
WordSpace.totalWeight += this.wordWeight;
WordSpace.setGameOverTimer();
console.log("Total weight : " + WordSpace.totalWeight);
//console.log("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n');
}
......
......@@ -3,6 +3,11 @@ var WordSpace = WordSpace || {};
WordSpace.isImageLoaded = false;
WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.brainCapacity = 20; //수용 가능한 단어 무게 최대치
WordSpace.defeatTime = 3000;
WordSpace.gameOverTimer = null; //게임 오버 판정 타이머
WordSpace.isTimerOn = false;
WordSpace.wordGroup = [];
WordSpace.wordForcedGroup = [];
......@@ -51,3 +56,20 @@ WordSpace.generateWord = function(scene)
scene.physics.add.collider(word.physicsObj, BackGround.brainGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
}
function gameOver()
{
this.wordCycle.paused = true;
//To Do
}
//게임 오버 판정을 위한 타이머
WordSpace.setGameOverTimer = function()
{
//만약 현재 단어 무게 총합이 뇌 용량보다 크다면 타이머를 시작함
if(this.brainCapacity < this.totalWeight && !this.isTimerOn)
{
this.gameOverTimer = setTimeout(gameOver.bind(this), this.defeatTime);
isTimerOn = true;
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ var config = {
}
};
var game = new Phaser.Game(config);
var game = new Phaser.Game(config)
// load assets
function preload()
......
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