OSDN Git Service

BreadItemWidgetClass.js
[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         this.maxLivingTick = 120;
15         this.livingTick = 0;
16 }.extend(EnemyCharacterClass, {
17         className: "FireObjectClass",
18         fire: function(ownerObj, x, y){
19                 //発射位置の調整
20                 if(!x){
21                         x = 32;
22                 }
23                 if(ownerObj.direction == 0){
24                         //右
25                         this.origin.x = ownerObj.origin.x - x;
26                 } else{
27                         //左
28                         this.origin.x = ownerObj.origin.x + x;
29                 }
30                 if(!y){
31                         this.origin.y = ownerObj.origin.y;
32                 } else{
33                         this.origin.y = ownerObj.origin.y + y;
34                 }
35                 //発射
36                 var fvx = this.fireVelocity.x;
37                 if(ownerObj.direction == 0){
38                         //右
39                         fvx = -fvx;
40                         this.origin.x = ownerObj.origin.x - 32;
41                 }
42                 this.movingSpeed.x = fvx;
43                 this.movingSpeed.y = -this.fireVelocity.y
44                 ownerObj.ownerStage.addStageObject(this);
45                 this.livingTick = 0;
46         },
47         
48         tick: function(){
49                 this.livingTick++;
50                 if(this.livingTick > this.maxLivingTick){
51                         this.ownerStage.removeStageObject(this);
52                 }
53                 FireObjectClass.base.prototype.tick.apply(this);
54         },
55         objectAttacked : function(obj, obj_x, obj_y, direction)
56         {
57                 if(obj instanceof MainCharacterClass)
58                 {
59                         //メインキャラクターに衝突された
60                         //ダメージの開始・終了処理
61                         if(direction & CollideTop){
62                                 if(!this.hurting){
63                                         //自分自身のダメージ有効
64                                         this.hurting = true;
65                                         this.hurtPerTickCount = this.hurtPerTickBase;
66                                 }
67                         } else{
68                                 if(direction & (CollideLeft | CollideRight)){
69                                         if(!this.damaging){
70                                                 //メインキャラクタへのダメージ有効
71                                                 this.damaging = true;
72                                                 this.damagePerTickCount = this.damagePerTickBase;
73                                         }
74                                 }
75                         }
76                 }
77                 if(obj instanceof EnemyCharacterClass)
78                 {
79                         //ダメージの開始・終了処理
80                         obj.damage(this.touchDamage);
81                         this.ownerStage.removeStageObject(this);
82                 }
83                 if((obj instanceof BlockClass || obj instanceof SlopeBlockClass) && this.lastCollidedTick + 10 < this.ownerStage.manager.tickCount && !obj.isPhantom){
84                         this.movingSpeed.y -= this.boundPower;
85                         this.boundCount++;
86                         if(this.maxBoundCount <= this.boundCount){
87                                 this.ownerStage.removeStageObject(this);
88                         }
89                 }
90                 
91                 this.lastCollidedTick = this.ownerStage.manager.tickCount;
92         },
93
94 });