Commit 0acaaf7f authored by 18신대성's avatar 18신대성

단어 최대입력 구현, 게이지에 따라 최대입력 변하게 만듬

parent 19715838
......@@ -6,8 +6,10 @@ Input.convInput = ''; // converted input
Input.isShifted = false;
Input.pressCount = 0;
Input.justPressed = '';
Input.maxInput = 5;
Input.attackMode = false;
Input.attackOption = null;
Input.reset = function()
{
......@@ -62,6 +64,7 @@ Input.convert = function()
if (this.input[i] >= ''.charCodeAt(0)) vowels.push(krInput.length - 1); // 모음일 경우
}
}
if (vowels.length > 5) return false;
//console.log(vowels);
//console.log(krInput);
......@@ -163,7 +166,8 @@ Input.convert = function()
}
}
}
//console.log('_____end_convert_____');
return true;
//console.log('_____end_convert_____');
}
Input.convertToLast = function(word)
......@@ -291,7 +295,7 @@ Input.inputField =
});
scene.input.keyboard.on('keydown-ENTER', function()
{
if (Input.attackMode) WordSpace.attack(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
Input.reset();
});
......@@ -352,10 +356,13 @@ Input.pushInput = function(inputKey)
}
}
else output = inputKey.charCodeAt(0);
Input.input.push(output);
this.input.push(output);
//console.log(Input.input);
Input.convert();
Input.inputField.text.setText(Input.convInput);
this.pressCount++;
if (!this.convert() || this.convInput.length > this.maxInput)
{
this.input.pop();
this.convert();
}
this.inputField.text.setText(Input.convInput);
}
}
\ No newline at end of file
......@@ -24,7 +24,6 @@ class WordObject
{
var random = WordSpace.getSpawnPoint();
this.physicsObj = scene.physics.add.sprite(random.x, random.y, 'wordBgr' + this.wordGrade + '_' + Math.min(Math.max(2, this.wordText.length), 6));
this.physicsObj.body.bounce.set(0.5);
this.wordObj = scene.add.text(random.x, random.y, this.wordText, {fontSize: '18pt', fontFamily: '"궁서", 궁서체, serif'}).setColor('#000000').setOrigin(0.5,0.5);
WordSpace.totalWeight += this.wordWeight;
WordSpace.setGameOverTimer();
......
......@@ -60,6 +60,14 @@ WordSpace.attackGauge =
},
pauseCycle: function(bool) {this.currentCycle.paused = bool;},
// showValue: 아래쪽에 바의 길이로 게이지 표시, 색으로 게이지의 강도 표현
getAttackOption: function()
{
if (this.value < 3) return {wordCount: 0, wordGrade: -1};
else if (this.value < 5) return {wordCount: 2, wordGrade: 3};
else if (this.value < 7) return {wordCount: 3, wordGrade: 2};
else if (this.value < 10) return {wordCount: 4, wordGrade: 1};
else return {wordCount: 5, wordGrade: 0};
}
}
WordSpace.wordCycle =
......@@ -108,9 +116,10 @@ WordSpace.loadImage = function(scene)
WordSpace.gameSceneForTest = scene; // for test
}
WordSpace.generateWord = function(scene, wordText)
WordSpace.generateWord = function(scene, wordText, grade)
{
word = new WordObject(wordText);
if (typeof grade != 'undefined') word.wordGrade = grade;
word.instantiate(scene);
WordSpace.wordGroup.push(word);
WordSpace.wordForcedGroup.push(word);
......@@ -167,7 +176,8 @@ WordSpace.findWord = function(wordText)
else if (wordText === '공격' && WordSpace.attackGauge.value > 3) // 공격모드 진입.
{
console.log('attack mode');
// 이부분에서 최대 단어수 결정
Input.attackOption = this.attackGauge.getAttackOption();
Input.maxInput = Input.attackOption.wordCount;
Input.attackMode = true;
WordSpace.attackGauge.pauseCycle(true);
}
......@@ -177,12 +187,12 @@ WordSpace.findWord = function(wordText)
}
}
WordSpace.attack = function(wordText)
WordSpace.attack = function(wordText, grade)
{
if (wordText != '')
{
console.log('attack ' + wordText);
WordSpace.generateWord(WordSpace.gameSceneForTest, wordText); // for test
console.log('attack ' + wordText + ', grade: ' + grade);
WordSpace.generateWord(WordSpace.gameSceneForTest, wordText, grade); // for test
// 이부분에서 게이지에 따라 급수 결정
// 이부분은 서버 잘써야함
WordSpace.attackGauge.resetValue();
......@@ -191,6 +201,7 @@ WordSpace.attack = function(wordText)
{
WordSpace.attackGauge.cutValue(0.3);
}
Input.maxInput = 5;
Input.attackMode = false;
WordSpace.attackGauge.pauseCycle(false);
}
\ No newline at end of file
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