OSDN Git Service

パン玉が三回バウンドで消滅するようになった。
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / FireObjectClass.js
1 var FireObjectClass = function(stage, args){
2         FireObjectClass.base.apply(this, arguments);
3         
4         this.fireVelocity = new Point2D(600, 100);
5         this.isPhantom = true;
6         this.size.x = 32;
7         this.size.y = 32;
8         this.movingSpeed.y = -this.fireVelocity.y;
9         this.chasingRange = 0;
10         this.isItemCollector = true;
11         this.boundPower = 400;
12         this.boundCount = 0;
13         this.maxBoundCount = 3;
14 }.extend(EnemyCharacterClass, {
15         className: "FireObjectClass",
16         fire: function(ownerObj){
17                 this.origin.x = ownerObj.origin.x + 32;
18                 this.origin.y = ownerObj.origin.y;
19                 var fvx = this.fireVelocity.x;
20                 if(ownerObj.direction == 0){
21                         //右
22                         fvx = -fvx;
23                         this.origin.x = ownerObj.origin.x - 32;
24                 }
25                 this.movingSpeed.x = fvx;
26                 ownerObj.ownerStage.addStageObject(this);
27         },
28
29         objectAttacked : function(obj, obj_x, obj_y)
30         {
31                 if(obj instanceof MainCharacterClass)
32                 {
33                         //メインキャラクターに衝突された
34                         //ダメージの開始・終了処理
35                         if(this.collidingDirection & CollideTop){
36                                 if(!this.hurting){
37                                         //自分自身のダメージ有効
38                                         this.hurting = true;
39                                         this.hurtPerTickCount = this.hurtPerTickBase;
40                                 }
41                         } else{
42                                 if(this.collidingDirection & (CollideLeft | CollideRight)){
43                                         if(!this.damaging){
44                                                 //メインキャラクタへのダメージ有効
45                                                 this.damaging = true;
46                                                 this.damagePerTickCount = this.damagePerTickBase;
47                                         }
48                                 }
49                         }
50                 }
51                 if(obj instanceof EnemyCharacterClass)
52                 {
53                         //ダメージの開始・終了処理
54                         obj.damage(this.touchDamage);
55                         this.ownerStage.removeStageObject(this);
56                 }
57                 if((obj instanceof BlockClass || obj instanceof SlopeBlockClass) && this.lastCollidedTick + 10 < this.ownerStage.manager.tickCount){
58                         this.movingSpeed.y -= this.boundPower;
59                         this.boundCount++;
60                         if(this.maxBoundCount <= this.boundCount){
61                                 this.ownerStage.removeStageObject(this);
62                         }
63                 }
64                 
65                 this.lastCollidedTick = this.ownerStage.manager.tickCount;
66         },
67
68 });