Commit 340846c4 authored by 18류지석's avatar 18류지석

페이즈, 단어 생성 확률, 생성 시간, 등급관련 수정

parent 303a919d
...@@ -27,7 +27,7 @@ CSVParsing.CSVParse = function(scene) { ...@@ -27,7 +27,7 @@ CSVParsing.CSVParse = function(scene) {
CSVParsing.gradeArray.grade2.push(allRows[singleRow].trim()); CSVParsing.gradeArray.grade2.push(allRows[singleRow].trim());
} else if(grade==1) { } else if(grade==1) {
CSVParsing.gradeArray.grade1.push(allRows[singleRow].trim()); CSVParsing.gradeArray.grade1.push(allRows[singleRow].trim());
} else { } else if(grade==0) {
CSVParsing.gradeArray.grade0.push(allRows[singleRow].trim()); CSVParsing.gradeArray.grade0.push(allRows[singleRow].trim());
} }
} }
......
...@@ -47,9 +47,10 @@ WordReader.getWordTyping = function(stringText) ...@@ -47,9 +47,10 @@ WordReader.getWordTyping = function(stringText)
//입력 받은 단어의 등급을 반환함 //입력 받은 단어의 등급을 반환함
WordReader.getWordGrade = function(_wordTyping) WordReader.getWordGrade = function(_wordTyping)
{ {
return 2 <= _wordTyping && _wordTyping < 7 ? 3 : return 4 <= _wordTyping && _wordTyping < 7 ? 3 :
7 <= _wordTyping && _wordTyping < 12 ? 2 : 7 <= _wordTyping && _wordTyping < 12 ? 2 :
12 <= _wordTyping && _wordTyping < 17 ? 1 : 0; 12 <= _wordTyping && _wordTyping < 17 ? 1 :
17 <= _wordTyping && _wordTyping < 26 ? 0 : -1;
} }
WordReader.getWordWeight = function(_wordGrade) WordReader.getWordWeight = function(_wordGrade)
......
...@@ -17,6 +17,17 @@ WordSpace.wordGroup = []; ...@@ -17,6 +17,17 @@ WordSpace.wordGroup = [];
WordSpace.wordForcedGroup = []; WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null; WordSpace.wordPhysicsGroup = null;
WordSpace.GradeProb = [0.35, 0.6, 0.8];
WordSpace.Phase = {READY: 0, START: 1, MAIN: 2, MUSIC: 3};
WordSpace.CurrentPhase = WordSpace.Phase.READY;
WordSpace.PlayerTyping = 0;
WordSpace.PlayerTypingRate = 0;
WordSpace.WordSpawnDelay = 3000;
WordSpace.NameSpawnDelay = 3000;
WordSpace.NameSpawnReduce = 1000;
WordSpace.gravityPoint = {x: 640, y: 300}; WordSpace.gravityPoint = {x: 640, y: 300};
WordSpace.getSpawnPoint = function() WordSpace.getSpawnPoint = function()
{ {
...@@ -28,6 +39,57 @@ WordSpace.getSpawnPoint = function() ...@@ -28,6 +39,57 @@ WordSpace.getSpawnPoint = function()
return {x:_x, y:_y}; return {x:_x, y:_y};
} }
WordSpace.AdjustVarByPhase = function(typingRate, phase)
{
if(phase == WordSpace.Phase.READY)
{
}
else if(phase == WordSpace.Phase.START)
{
WordSpace.WordSpawnDelay = 3000;
WordSpace.NameSpawnDelay = 6000;
WordSpace.NameSpawnReduce = 1000;
WordSpace.GradeProb[0] = 0.35;
WordSpace.GradeProb[1] = 1 - 0.4 * typingRate;
WordSpace.GradeProb[2] = 1;
}
else if(phase == WordSpace.Phase.MAIN)
{
WordSpace.WordSpawnDelay = 3000 - typingRate * 1000;
WordSpace.NameSpawnDelay = 6000;
WordSpace.NameSpawnReduce = 1000;
WordSpace.GradeProb[0] = 0.4 - 0.4 * typingRate;
WordSpace.GradeProb[1] = 0.8 - 0.4 * typingRate;
WordSpace.GradeProb[2] = 1 - 0.2 * typingRate;
}
else if(phase == WordSpace.Phase.MUSIC)
{
WordSpace.WordSpawnDelay = 1500;
WordSpace.NameSpawnDelay = 4000;
WordSpace.NameSpawnReduce = 500;
WordSpace.GradeProb[0] = 0.2 - 0.2 * typingRate;
WordSpace.GradeProb[1] = 0.8 - 0.5 * typingRate;
WordSpace.GradeProb[2] = 0.9 - 0.2 * typingRate;
}
WordSpace.wordCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.WordSpawnDelay, WordSpace.wordCycle.currentCycle.getElapsed());
WordSpace.nameCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.NameSpawnDelay, WordSpace.nameCycle.currentCycle.getElapsed());
}
WordSpace.GetPhase = function()
{
//서버통신하셈~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//임시
WordSpace.CurrentPhase = WordSpace.Phase.START;
}
WordSpace.GetPlayerTypingRate = function()
{
//서버통신하셈~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//임시
WordSpace.PlayerTypingRate = 0.5;
}
WordSpace.attackGauge = WordSpace.attackGauge =
{ {
value: 0, value: 0,
...@@ -72,19 +134,81 @@ WordSpace.attackGauge = ...@@ -72,19 +134,81 @@ WordSpace.attackGauge =
} }
} }
WordSpace.varAdjustCycle =
{
currentCycle: null,
resetCycle : function(scene, _delay)
{
this.delay = _delay;
var option =
{
delay: _delay,
callback: function()
{
//나중에는 메세지 분석해서 Phase랑 PlayerTypingRate 받겠지만 일단 이렇게 해둠
WordSpace.GetPhase();
WordSpace.GetPlayerTypingRate();
WordSpace.AdjustVarByPhase(WordSpace.PlayerTypingRate, WordSpace.CurrentPhase);
},
callbackScope: scene,
loop: true
};
if (this.currentCycle != null)
{
this.currentCycle = this.currentCycle.reset(option);
}
else
{
this.currentCycle = scene.time.addEvent(option);
}
}
}
WordSpace.nameCycle =
{
currentCycle: null,
resetCycle: function(scene, _delay, _startAt)
{
this.delay = _delay;
var option =
{
startAt: _startAt,
delay: _delay,
callback: function()
{
console.log("호패 on");
},
callbackScope: scene,
loop: true
};
if (this.currentCycle != null)
{
this.currentCycle = this.currentCycle.reset(option);
}
else
{
this.currentCycle = scene.time.addEvent(option);
}
}
}
WordSpace.wordCycle = WordSpace.wordCycle =
{ {
delay: 0, delay: 0,
currentCycle: null, currentCycle: null,
resetCycle: function(scene, _delay) resetCycle: function(scene, _delay, _startAt)
{ {
this.delay = _delay; this.delay = _delay;
var option = var option =
{ {
startAt: _startAt,
delay: _delay, delay: _delay,
callback: function() callback: function()
{ {
let wordIdx = Math.floor(Math.random() * 4); let wordRnd = Math.random();
let wordIdx = wordRnd < WordSpace.GradeProb[0] ? 3 :
wordRnd < WordSpace.GradeProb[1] ? 2 :
wordRnd < WordSpace.GradeProb[2] ? 1 : 0;
WordSpace.generateWord(this, SelectWord.selectWord(wordIdx)); WordSpace.generateWord(this, SelectWord.selectWord(wordIdx));
}, },
callbackScope: scene, callbackScope: scene,
...@@ -195,8 +319,9 @@ WordSpace.findWord = function(wordText) ...@@ -195,8 +319,9 @@ WordSpace.findWord = function(wordText)
default: console.log('[ERR] wrong grade of word'); break; default: console.log('[ERR] wrong grade of word'); break;
} }
weightest.destroy(); weightest.destroy();
WordSpace.nameCycle.resetCycle(WordSpace.gameSceneForTest, WordSpace.NameSpawnDelay, WordSpace.nameCycle.currentCycle.getElapsed() + WordSpace.NameSpawnReduce);
} }
else if (wordText === '공격' && WordSpace.attackGauge.value > 3) // 공격모드 진입. else if (wordText === '공격' && WordSpace.attackGauge.value >= 3) // 공격모드 진입.
{ {
console.log('attack mode'); console.log('attack mode');
Input.attackOption = this.attackGauge.getAttackOption(); Input.attackOption = this.attackGauge.getAttackOption();
......
...@@ -32,7 +32,9 @@ function create() ...@@ -32,7 +32,9 @@ function create()
BackGround.drawBrain(this); BackGround.drawBrain(this);
Input.inputField.generate(this); Input.inputField.generate(this);
WordSpace.wordPhysicsGroup = this.physics.add.group(); WordSpace.wordPhysicsGroup = this.physics.add.group();
WordSpace.wordCycle.resetCycle(this, 3000); WordSpace.wordCycle.resetCycle(this, 3000, 0);
WordSpace.nameCycle.resetCycle(this, 3000, 0);
WordSpace.varAdjustCycle.resetCycle(this, 100, 0);
WordSpace.attackGauge.resetCycle(this); WordSpace.attackGauge.resetCycle(this);
CSVParsing.CSVParse(this); CSVParsing.CSVParse(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