Commit e274a43f authored by 18류지석's avatar 18류지석

시작 단어 10개 생성, 5개 미만 시 대기시간 초기화, 호패 생성 시간 조절

parent 340846c4
...@@ -29,6 +29,7 @@ class WordObject ...@@ -29,6 +29,7 @@ class WordObject
fontStyle: (this.wordWeight > 5 ? 'bold' : '') fontStyle: (this.wordWeight > 5 ? 'bold' : '')
}).setColor('#000000').setOrigin(0.5,0.5); }).setColor('#000000').setOrigin(0.5,0.5);
WordSpace.totalWeight += this.wordWeight; WordSpace.totalWeight += this.wordWeight;
WordSpace.totalWordNum += 1;
WordSpace.setGameOverTimer(); WordSpace.setGameOverTimer();
//console.log("Total weight : " + WordSpace.totalWeight); //console.log("Total weight : " + WordSpace.totalWeight);
} }
...@@ -37,6 +38,7 @@ class WordObject ...@@ -37,6 +38,7 @@ class WordObject
{ {
console.log(this.generationCode + ': ' + this.wordText + ' destroyed'); console.log(this.generationCode + ': ' + this.wordText + ' destroyed');
WordSpace.totalWeight -= this.wordWeight; WordSpace.totalWeight -= this.wordWeight;
WordSpace.totalWordNum -= 1;
this.wordObj.destroy(); this.wordObj.destroy();
const groupIdx = WordSpace.wordGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this); const groupIdx = WordSpace.wordGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (groupIdx > -1) WordSpace.wordGroup.splice(groupIdx, 1); if (groupIdx > -1) WordSpace.wordGroup.splice(groupIdx, 1);
......
...@@ -8,6 +8,7 @@ WordSpace.isImageLoaded = false; ...@@ -8,6 +8,7 @@ WordSpace.isImageLoaded = false;
WordSpace.nextWordCode = 0; WordSpace.nextWordCode = 0;
WordSpace.totalWeight = 0; //현재 단어 무게 총합 WordSpace.totalWeight = 0; //현재 단어 무게 총합
WordSpace.totalWordNum = 0;
WordSpace.brainCapacity = 100; //수용 가능한 단어 무게 최대치 WordSpace.brainCapacity = 100; //수용 가능한 단어 무게 최대치
WordSpace.defeatTime = 5000; WordSpace.defeatTime = 5000;
WordSpace.gameOverTimer = null; //게임 오버 판정 타이머 WordSpace.gameOverTimer = null; //게임 오버 판정 타이머
...@@ -39,6 +40,15 @@ WordSpace.getSpawnPoint = function() ...@@ -39,6 +40,15 @@ WordSpace.getSpawnPoint = function()
return {x:_x, y:_y}; return {x:_x, y:_y};
} }
WordSpace.spaceInitiate = function(scene)
{
let arr = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1]
arr.forEach(function(element)
{
WordSpace.generateWord(scene, SelectWord.selectWord(element));
});
}
WordSpace.AdjustVarByPhase = function(typingRate, phase) WordSpace.AdjustVarByPhase = function(typingRate, phase)
{ {
if(phase == WordSpace.Phase.READY) if(phase == WordSpace.Phase.READY)
...@@ -192,6 +202,15 @@ WordSpace.nameCycle = ...@@ -192,6 +202,15 @@ WordSpace.nameCycle =
} }
} }
WordSpace.genWordByProb = function(scene)
{
let wordRnd = Math.random();
let wordIdx = wordRnd < WordSpace.GradeProb[0] ? 3 :
wordRnd < WordSpace.GradeProb[1] ? 2 :
wordRnd < WordSpace.GradeProb[2] ? 1 : 0;
WordSpace.generateWord(scene, SelectWord.selectWord(wordIdx));
}
WordSpace.wordCycle = WordSpace.wordCycle =
{ {
delay: 0, delay: 0,
...@@ -205,11 +224,7 @@ WordSpace.wordCycle = ...@@ -205,11 +224,7 @@ WordSpace.wordCycle =
delay: _delay, delay: _delay,
callback: function() callback: function()
{ {
let wordRnd = Math.random(); WordSpace.genWordByProb(scene);
let wordIdx = wordRnd < WordSpace.GradeProb[0] ? 3 :
wordRnd < WordSpace.GradeProb[1] ? 2 :
wordRnd < WordSpace.GradeProb[2] ? 1 : 0;
WordSpace.generateWord(this, SelectWord.selectWord(wordIdx));
}, },
callbackScope: scene, callbackScope: scene,
loop: true loop: true
...@@ -320,6 +335,12 @@ WordSpace.findWord = function(wordText) ...@@ -320,6 +335,12 @@ WordSpace.findWord = function(wordText)
} }
weightest.destroy(); 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);
while(WordSpace.totalWordNum < 5)
{
WordSpace.genWordByProb(WordSpace.gameSceneForTest);
WordSpace.wordCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.WordSpawnDelay, 0);
}
} }
else if (wordText === '공격' && WordSpace.attackGauge.value >= 3) // 공격모드 진입. else if (wordText === '공격' && WordSpace.attackGauge.value >= 3) // 공격모드 진입.
{ {
......
...@@ -37,6 +37,7 @@ function create() ...@@ -37,6 +37,7 @@ function create()
WordSpace.varAdjustCycle.resetCycle(this, 100, 0); WordSpace.varAdjustCycle.resetCycle(this, 100, 0);
WordSpace.attackGauge.resetCycle(this); WordSpace.attackGauge.resetCycle(this);
CSVParsing.CSVParse(this); CSVParsing.CSVParse(this);
WordSpace.spaceInitiate(this);
} }
function update() function update()
......
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