Commit 9a631207 authored by 18신대성's avatar 18신대성

공격게이지 추가

parent 842dd18f
...@@ -10,9 +10,47 @@ WordSpace.wordPhysicsGroup = null; ...@@ -10,9 +10,47 @@ WordSpace.wordPhysicsGroup = null;
WordSpace.gravityPoint = {x: 400, y: 300}; WordSpace.gravityPoint = {x: 400, y: 300};
WordSpace.wordCycle = null; WordSpace.attackGauge =
WordSpace.resetCycle = function(scene, _delay)
{ {
value: 0,
add: function(plus)
{
if (this.value + plus > 11) this.value = 11;
else this.value += plus;
this.text.setText('게이지: ' + this.value.toFixed(1));
},
sub: function(minus)
{
if (this.value - minus < 0) this.value = 0;
else this.value -= minus;
this.text.setText('게이지: ' + this.value.toFixed(1));
},
resetValue: function() {this.value = 0;},
cutValue: function(cutOut) {this.value *= (1-cutOut);},
resetCycle: function(scene)
{
var option =
{
delay: 300,
callback: function()
{
WordSpace.attackGauge.sub(0.1);
},
loop: true
};
this.currentCycle = scene.time.addEvent(option);
this.text = scene.add.text(100,100,'게이지: ' + this.value.toFixed(1)).setColor('#ffffff');
},
pauseCycle: function(bool) {this.currentCycle.paused = bool;}
// showValue: 아래쪽에 바의 길이로 게이지 표시, 색으로 게이지의 강도 표현
}
WordSpace.wordCycle =
{
currentCycle: null,
resetCycle: function(scene, _delay)
{
var option = var option =
{ {
delay: _delay, delay: _delay,
...@@ -23,13 +61,14 @@ WordSpace.resetCycle = function(scene, _delay) ...@@ -23,13 +61,14 @@ WordSpace.resetCycle = function(scene, _delay)
callbackScope: scene, callbackScope: scene,
loop: true loop: true
}; };
if (this.wordCycle != null) if (this.currentCycle != null)
{ {
this.wordCycle = this.wordCycle.reset(option); this.currentCycle = this.currentCycle.reset(option);
} }
else else
{ {
this.wordCycle = scene.time.addEvent(option); this.currentCycle = scene.time.addEvent(option);
}
} }
} }
...@@ -60,6 +99,14 @@ WordSpace.findWord = function(word) ...@@ -60,6 +99,14 @@ WordSpace.findWord = function(word)
}); });
if (found != undefined) if (found != undefined)
{ {
switch(found.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;
}
found.destroy(); found.destroy();
} }
} }
\ No newline at end of file
...@@ -31,7 +31,8 @@ function create() ...@@ -31,7 +31,8 @@ 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.resetCycle(this, 2000); WordSpace.wordCycle.resetCycle(this, 2000);
WordSpace.attackGauge.resetCycle(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