OSDN Git Service

Merge branch 'master' of https://scm.sourceforge.jp/gitroot/h58pcdgame/GameScriptCore...
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / FreeItemClass.js
index cf680ed..dc29c58 100644 (file)
@@ -13,35 +13,79 @@ var FreeItemClass = function(stage, args){
        //null\82Å\89½\82à\82µ\82È\82¢\83A\83C\83e\83\80\82É\82È\82é
        this.callback = args[1];
        
-       //\90G\82ê\91±\82¯\82½\82Æ\82«\82É\89½tick\82¨\82«\82É
+       //\8dÅ\8cã\82É\83L\83\83\83\89\82É\8fæ\82ç\82ê\82Ä\82¢\82é\8fó\91Ô\82Å\82È\82­\82È\82Á\82Ä\82©\82ç\89½tick\82Å\8dÄ\82Ñ\8eæ\93¾\82Å\82«\82é\82©\81B
        //\82 \81A\88ê\89\9e\81BPCDSL\82©\82ç\8ae\83v\83\8d\83p\83e\83B\82ð\8ew\92è\82·\82é\95û\96@\82ª\82 \82é\82Ì\82Å\88ø\90\94\82É\97p\88Ó\82·\82é\95K\97v\82Í\82 \82è\82Ü\82¹\82ñ\81B
-       this.touchInterval = 100;
+       this.touchInterval = 0;
        this.lastTouchedTickCount = -9999;
        
+       //\8c»\8dÝ\8fÕ\93Ë\92\86\82Ì\81i\8fã\82É\82©\82Ô\82³\82Á\82Ä\82¢\82é\81j\83L\83\83\83\89\82ª\82¢\82é\82©
+       this.isCollided = false;
+       
+       //\8c»\8dÝ\8fã\82É\82©\82Ô\82³\82Á\82Ä\82¢\82é\89Â\94\\90«\82Ì\82 \82é\83L\83\83\83\89
+       this.collidedList = [];
+
 }.extend(ItemClass, {
        draw: function(x, y){
                this.ownerStage.mainContext.globalAlpha = this.opacity;
                this.ownerStage.mainContext.drawImage(this.image, x, y, 32, 32);
                this.ownerStage.mainContext.globalAlpha = 1.0;
        },
-       itemAttacked : function(obj, obj_x, obj_y)
-       {
-               if(this.ownerStage.manager.tickCount - this.lastTouchedTickCount > this.touchInterval)
+       tick: function(){
+               if(this.isCollided)
                {
-                       this.lastTouchedTickCount = this.ownerStage.manager.tickCount;
-                       if(this.callback)
+                       for(var i = 0; i < this.collidedList.length; i++)
                        {
-                               this.callback();
+                               var character = this.collidedList[i];
+                               if(character.isCollided(this, character.origin.x, character.origin.y))
+                               {
+                                       //\8c»\8dÝ\8fÕ\93Ë\92\86\82Ì\83L\83\83\83\89\82ð\8c©\82Â\82¯\82½
+                                       return;
+                               }
                        }
                        
-                       if(this.times > 0)
+                       //\8fÕ\93Ë\92\86\82Ì\83L\83\83\83\89\82ª\82¢\82È\82¢
+                       this.isCollided = false;
+                       this.collidedList = [];
+               }
+       },
+       itemAttacked : function(obj, obj_x, obj_y)
+       {
+               var tickCount = this.ownerStage.manager.tickCount
+               if(!this.isCollided)
+               {
+                       this.isCollided = true;
+                       if(tickCount - this.lastTouchedTickCount >= this.touchInterval)
                        {
-                               this.times--;
-                               if(this.times == 0)
+                               if(this.callback)
+                               {
+                                       this.callback(obj, obj_x, obj_y);
+                               }
+                               
+                               if(this.times > 0)
                                {
-                                       this.ownerStage.removeStageObject(this);
+                                       this.times--;
+                                       if(this.times == 0)
+                                       {
+                                               this.ownerStage.removeStageObject(this);
+                                       }
                                }
                        }
                }
+               
+               //\8dÅ\8cã\82É\90G\82ç\82ê\82½\8e\9e\8aÔ\82ð\8bL\98^
+               this.lastTouchedTickCount = tickCount;
+               
+               //this.collidedList\82É\90G\82ç\82ê\82Ä\82¢\82é\89Â\94\\90«\82Ì\82 \82é\83L\83\83\83\89\92Ç\89Á\8f\88\97\9d
+               for(var i = 0; i < this.collidedList; i++)
+               {
+                       if(this.collidedList[i] == obj)
+                       {
+                               return;
+                       }
+               }
+               
+               //this.collidedList\82É\82Ü\82¾\92Ç\89Á\82³\82ê\82Ä\82¢\82È\82¢
+               this.collidedList.push(obj);
+               
        }
 });
\ No newline at end of file