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         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                 //発射
37                 var fvx = this.fireVelocity.x;
38                 if(ownerObj.direction == 0){
39                         //右
40                         fvx = -fvx;
41                         this.origin.x = ownerObj.origin.x - 32;
42                 }
43                 this.movingSpeed.x = fvx;
44                 this.movingSpeed.y = -this.fireVelocity.y
45                 
46                 // 初期位置で壁などに引っかかっていないか確認
47                 if(this.canMoveTo(this.origin.x, this.origin.y)){
48                         ownerObj.ownerStage.addStageObject(this);
49                 }
50                 this.livingTick = 0;
51         },
52         
53         tick: function(){
54                 this.livingTick++;
55                 if(this.livingTick > this.maxLivingTick){
56                         this.ownerStage.removeStageObject(this);
57                 }
58                 FireObjectClass.base.prototype.tick.apply(this);
59         },
60         objectAttacked : function(obj, obj_x, obj_y, direction)
61         {
62                 if(obj === this.ownerStage.userControlledCharacter)
63                 {
64                         //メインキャラクターに衝突された
65                         //ダメージの開始・終了処理
66                         if(direction & CollideTop){
67                                 if(!this.hurting){
68                                         //自分自身のダメージ有効
69                                         this.hurting = true;
70                                         this.hurtPerTickCount = this.hurtPerTickBase;
71                                 }
72                         } else{
73                                 if(direction & (CollideLeft | CollideRight)){
74                                         if(!this.damaging){
75                                                 //メインキャラクタへのダメージ有効
76                                                 this.damaging = true;
77                                                 this.damagePerTickCount = this.damagePerTickBase;
78                                         }
79                                 }
80                         }
81                 }
82                 if(obj instanceof EnemyCharacterClass)
83                 {
84                         //ダメージの開始・終了処理
85                         obj.damage(this.touchDamage);
86                         this.ownerStage.removeStageObject(this);
87                 }
88                 if((obj instanceof BlockClass || obj instanceof SlopeBlockClass) && this.lastCollidedTick + 10 < this.ownerStage.manager.tickCount && !obj.isPhantom){
89                         this.movingSpeed.y -= this.boundPower;
90                         this.boundCount++;
91                         if(this.maxBoundCount <= this.boundCount){
92                                 this.ownerStage.removeStageObject(this);
93                         }
94                 }
95                 
96                 this.lastCollidedTick = this.ownerStage.manager.tickCount;
97         },
98
99 });