1 var EnemyCharacterClass = function(stage, args){
2 EnemyCharacterClass.base.apply(this, arguments);
4 this.movingVelocity = 150;
6 //メインキャラクターを追跡する場合はtrue
8 //メインキャラクターを感知する範囲(原点距離がこれ以内の場合に追跡をする。)
9 this.chasingRange = 200;
10 //メインキャラクターに与えるダメージの設定
11 this.touchDamage = 10;
12 this.damagePerTickBase = 60;
13 this.damagePerTickCount = this.damagePerTickBase;
14 this.damageLastTick = 0;
15 this.damaging = false;
16 //メインキャラクターから受けるダメージの設定
18 this.hurtPerTickBase = 60;
19 this.hurtPerTickCount = this.hurtPerTickBase;
20 this.hurtLastTick = 0;
24 this.HP = this.max_HP;
25 }.extend(OperatedCharacterClass, {
26 className: "EnemyCharacterClass",
30 var main = this.ownerStage.userControlledCharacter;
31 var distX = main.origin.x - this.origin.x;
32 if(this.chasing && Math.abs(distX) <= this.chasingRange && Math.abs(this.origin.y - main.origin.y) <= this.chasingRange){
40 if(this.collidingDirection & CollideTop){
44 this.hurtPerTickCount = this.hurtPerTickBase;
48 // this.damaging = false;
55 if(this.collidingDirection & (CollideLeft | CollideRight)){
58 // this.damaging = true;
59 // this.damagePerTickCount = this.damagePerTickBase;
66 if(this.damagePerTickCount == this.damagePerTickBase){
67 this.ownerStage.manager.userManager.damage(this.touchDamage);
68 this.damagePerTickCount--;
70 this.damagePerTickCount--;
71 if(this.damagePerTickCount <= 0){
72 this.damagePerTickCount = this.damagePerTickBase;
78 if(this.hurtPerTickCount == this.hurtPerTickBase){
80 this.hurtPerTickCount--;
82 this.ownerStage.removeStageObject(this);
85 this.hurtPerTickCount--;
86 if(this.hurtPerTickCount <= 0){
87 this.hurtPerTickCount = this.hurtPerTickBase;
92 if(this.origin.y > 1000)
94 this.ownerStage.removeStageObject(this);
97 EnemyCharacterClass.base.prototype.tick.apply(this);
100 EnemyCharacterClass.base.prototype.draw.apply(this, arguments);
101 this.ownerStage.mainContext.save();
102 this.ownerStage.mainContext.fillStyle = "rgba(255,255,255,0.5)";
103 this.ownerStage.mainContext.strokeStyle = "rgba(0, 0, 0, 1)";
104 this.ownerStage.mainContext.font = "normal 12px sans-serif";
105 drawText(this.ownerStage.mainContext, this.HP, x, y - 20);
106 this.ownerStage.mainContext.restore();