OSDN Git Service

辛夷祭初日の緊急修正多数。
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / StageObjectClass.js
index a4d03df..dd74138 100644 (file)
-//
-//\83L\83\83\83\89\83N\83^\81[
-//
-
-function StageObject(ownerStage, args){
-       this.ownerStage = ownerStage;
-       //\8d\8fã\8b÷\82Ì\8dÀ\95W
-       this.origin = new Point2D(10, 10);
-       //\8d\8fã\82©\82ç\89E\89º\82Ü\82Å\82Ì\83T\83C\83Y
-       this.size = new Point2D(32, 32);
-       this.attribute = {};
-       this.constructorArgs = args;
-       this.opacity = 1.0;             // \93§\96¾\93x\81@(\93§\96¾) 0.0 \81` 1.0 (\95s\93§\96¾)
-       this.ownerUID = 0;
-       this.objectID = 0;
-       // PCDSL\82È\82Ç\82©\82ç\97\98\97p\82Å\82«\82éID
-       this.id = "";
-       //0\88È\8aO\82Ì\8fê\8d\87\81A\83l\83b\83g\83\8f\81[\83N\93¯\8aú\8e\9e\82É\83A\83C\83e\83\80\82Í\91S\91Ì\82Å\82½\82¾\88ê\82Â\82¾\82¯!!(\83l\83b\83g\83\8f\81[\83N\93¯\8aú\96³\8cø\82È\82ç\96³\8e\8b\82³\82ê\82é)
-       this.extObjectId = 0;
-       
-       this.isPhantom = false;
-       //\93\96\82½\82è\94»\92è\82Ì\83}\81[\83W\83\93\82Ì\8ew\92è
-       this.collisionMargin = new OffsetBox(0, 0, 0, 0);
-       this.collidingRange  = 6;
-       //\8fÕ\93Ë\95û\8cü\83t\83\89\83O\82Í\81A\88Ú\93®\82·\82é\83I\83u\83W\83F\83N\83g\82È\82ç\88Ú\93®\8e\9e\82É\92è\8aú\93I\82É\83`\83F\83b\83N\82ð\82©\82¯\82Ä\90Ý\92è\82µ\82Ü\82·\81B
-       //\82»\82ê\88È\8aO\82Ì\8fê\8d\87\82Í\94C\88Ó\82Ì\83^\83C\83~\83\93\83O\82ÅchecktouchingDirection\82ð\8cÄ\82Ñ\8fo\82·\82×\82µ\81B
-       this.touchingDirection = 0;
-       this.collidedObjects = new Array();
-       
-       this.forceTopMost = false;
-}
-StageObject.prototype = {
-       className:"StageObject",
-       tick: function(){
-               //\8dÄ\95`\89æ\82Ì\83^\83C\83~\83\93\83O\82²\82Æ\82É\8cÄ\82Î\82ê\82é\81B
-       },
-       draw: function(x, y){
-               //\8eÀ\8dÛ\82Ì\95`\89æ\82Ì\82Ý\82ð\8ds\82¤\81B\8cv\8eZ\82Ítick\82Å\8ds\82¤\81B
-               //\83\86\81[\83U\81[\96¼\82ð\95\\8e¦
-               if(this.ownerUID != 0){
-                       var c = this.ownerStage.mainContext;
-                       c.save();
-                       c.font = "normal 12px sans-serif";
-                       drawText(c, this.ownerStage.manager.userManager.getUserNameByUID(this.ownerUID), x, y - 20);
-                       c.restore();
-               }
-       },
-       debugDraw: function(x, y){
-               //\8fÕ\93Ë\83}\83b\83v\82É\95`\89æ
-               var c = this.ownerStage.collisionMapContext;
-               c.save();
-               c.beginPath();
-               c.moveTo(x + this.collisionMargin.left, y + this.collisionMargin.top);
-               c.lineTo(x + this.collisionMargin.left, y + this.size.y - this.collisionMargin.bottom);
-               c.lineTo(x + this.size.x - this.collisionMargin.right, y + this.size.y - this.collisionMargin.bottom);
-               c.lineTo(x + this.size.x - this.collisionMargin.right, y + this.collisionMargin.top);
-               c.closePath();
-               c.stroke();
-               c.restore();
-       },
-       bindAttribute: function(attr)
-       {
-               //\8dX\90V\83f\81[\83^\82ð\8f\80\94õ\82·\82é\82Æ\82«\82É\8cÄ\82Î\82ê\82é
-               this.attribute["sX"] = this.size.x;
-               this.attribute["sY"] = this.size.y;
-       },
-       updateAttribute: function()
-       {
-               //\8dX\90V\83f\81[\83^\82ª\97\88\82½\82Æ\82«\82É\8cÄ\82Î\82ê\82é
-               if(this.attribute.sX){
-                       this.size.x = this.attribute.sX;
-               }
-               if(this.attribute.sY){
-                       this.size.y = this.attribute.sY;
-               }
-       },
-       // 1 - - +
-       // |     |
-       // |     |
-       // + - - 2
-       isOverlappedWith: function(x1, y1, x2, y2){
-               //\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é
-               //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B
-               //true\82©\82ÂisPhantom==false\82Ì\8e\9e\82Í\8fÕ\93Ë\82·\82é\81B
-               var o = this.origin;
-               var c = this.collisionMargin;
-               var s = this.size;
-               return (x2 >= (o.x + c.left)) && (x1 < (o.x + s.x - c.right)) && (y2 >= (o.y + c.top)) && (y1 < (o.y + s.y - c.bottom));
-       },
-       isOverlappedWithLocatedObject: function(obj, x, y){
-               //(x, y)\82Éobj\82ª\82 \82é\82Æ\82«\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\94Í\88Í\82É\81A\8e©\95ª\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é
-               //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B]
-               var c = obj.collisionMargin;
-               var s = obj.size;
-               return this.isOverlappedWith(x + c.left, y + c.top, x + s.x - c.right - 1, y + s.y - c.bottom - 1);
-       },
-       //     + - - +
-       //     |     |
-       // + - 0 - - + - +
-       // |   |     |   |
-       // |   |     |   |
-       // + - + - - 1 - +
-       //     |     |
-       //     + - - +
-       checkTouchingDirection: function(){
-               //\8fÕ\93Ë\95û\8cü\82ð\92²\82×\82é\81B
-               this.touchingDirection = 0;
-               this.collidedObjects = new Array();
-               var d = this.ownerStage.stageObjectLinearList;
-               for(var i = 0, i_max = d.length; i < i_max; i++){
-                       var obj = d[i];
-                       var c = this.collisionMargin;
-                       var r = this.collidingRange;
-                       // CollisonBody
-                       var cbx0 = this.origin.x + c.left;
-                       var cby0 = this.origin.y + c.top;
-                       var cbx1 = this.origin.x + this.size.x - 1 - c.right;
-                       var cby1 = this.origin.y + this.size.y - 1 - c.bottom;
-                       // CollisionFrame\94Í\88Í\93à\82©\8am\94F
-                       if(obj.isOverlappedWith(cbx0 - r, cby0 - r, cbx1 + r, cby1 + r) && obj !== this && !obj.isPhantom){
-                               //\8fÕ\93Ë\82Ì\89Â\94\\90«\82ª\82 \82é\82Ì\82Å\8am\94F
-                               if(obj.isOverlappedWith(cbx0, cby0, cbx1, cby1)){
-                                       //body
-                                       this.touchingDirection |= CollideBody;
-                               }
-                               if(obj.isOverlappedWith(cbx0, cby0 - r, cbx1, cby0 - 1)){
-                                       //top
-                                       this.touchingDirection |= CollideTop;
-                               }
-                               if(obj.isOverlappedWith(cbx0, cby1 + 1, cbx1, cby1 + r)){
-                                       //bottom
-                                       this.touchingDirection |= CollideBottom;
-                               }
-                               if(obj.isOverlappedWith(cbx0 - r, cby0, cbx0 - 1, cby1)){
-                                       //left
-                                       this.touchingDirection |= CollideLeft;
-                               }
-                               if(obj.isOverlappedWith(cbx1 + 1, cby0, cbx1 + r, cby1)){
-                                       //right
-                                       this.touchingDirection |= CollideRight;
-                               }
-                       }
-               }
-       },
-       getSyncData: function(){
-               this.bindAttribute();
-               return this.origin.x.toString() + "|" + 
-                       this.origin.y.toString() + "|" + 
-                       this.movingSpeed.x.toString() + "|" +  
-                       this.movingSpeed.y.toString() + "|" + 
-                       this.className + "|" + 
-                       parseArrayToStringSource(this.attribute) + "|" + 
-                       parseArrayToStringSource(this.constructorArgs);
-       },
-};
-
+//\r
+//\83L\83\83\83\89\83N\83^\81[\r
+//\r
+\r
+function StageObject(ownerStage, args){\r
+       this.ownerStage = ownerStage;\r
+       //\8d\8fã\8b÷\82Ì\8dÀ\95W\r
+       this.origin = new Point2D(10, 10);\r
+       //\8d\8fã\82©\82ç\89E\89º\82Ü\82Å\82Ì\83T\83C\83Y\r
+       this.size = new Point2D(32, 32);\r
+       this.attribute = {};\r
+       this.constructorArgs = args;\r
+       this.opacity = 1.0;             // \93§\96¾\93x\81@(\93§\96¾) 0.0 \81` 1.0 (\95s\93§\96¾)\r
+       this.ownerUID = 0;\r
+       this.objectID = 0;\r
+       // PCDSL\82È\82Ç\82©\82ç\97\98\97p\82Å\82«\82éID\r
+       this.id = "";\r
+       //0\88È\8aO\82Ì\8fê\8d\87\81A\83l\83b\83g\83\8f\81[\83N\93¯\8aú\8e\9e\82É\83A\83C\83e\83\80\82Í\91S\91Ì\82Å\82½\82¾\88ê\82Â\82¾\82¯!!(\83l\83b\83g\83\8f\81[\83N\93¯\8aú\96³\8cø\82È\82ç\96³\8e\8b\82³\82ê\82é)\r
+       this.extObjectId = 0;\r
+       \r
+       this.isPhantom = false;\r
+       //\93\96\82½\82è\94»\92è\82Ì\83}\81[\83W\83\93\82Ì\8ew\92è\r
+       this.collisionMargin = new OffsetBox(0, 0, 0, 0);\r
+       this.collidingRange  = 6;\r
+       //\8fÕ\93Ë\95û\8cü\83t\83\89\83O\82Í\81A\88Ú\93®\82·\82é\83I\83u\83W\83F\83N\83g\82È\82ç\88Ú\93®\8e\9e\82É\92è\8aú\93I\82É\83`\83F\83b\83N\82ð\82©\82¯\82Ä\90Ý\92è\82µ\82Ü\82·\81B\r
+       //\82»\82ê\88È\8aO\82Ì\8fê\8d\87\82Í\94C\88Ó\82Ì\83^\83C\83~\83\93\83O\82ÅchecktouchingDirection\82ð\8cÄ\82Ñ\8fo\82·\82×\82µ\81B\r
+       this.touchingDirection = 0;\r
+       this.collidedObjects = new Array();\r
+       \r
+       this.forceTopMost = false;\r
+}\r
+StageObject.prototype = {\r
+       className:"StageObject",\r
+       tick: function(){\r
+               //\8dÄ\95`\89æ\82Ì\83^\83C\83~\83\93\83O\82²\82Æ\82É\8cÄ\82Î\82ê\82é\81B\r
+       },\r
+       draw: function(x, y){\r
+               //\8eÀ\8dÛ\82Ì\95`\89æ\82Ì\82Ý\82ð\8ds\82¤\81B\8cv\8eZ\82Ítick\82Å\8ds\82¤\81B\r
+               //\83\86\81[\83U\81[\96¼\82ð\95\\8e¦\r
+               if(this.ownerUID != 0){\r
+                       var c = this.ownerStage.mainContext;\r
+                       c.save();\r
+                       c.font = "normal 12px sans-serif";\r
+                       drawText(c, this.ownerStage.manager.userManager.getUserNameByUID(this.ownerUID), x, y - 20);\r
+                       c.restore();\r
+               }\r
+       },\r
+       debugDraw: function(x, y){\r
+               //\8fÕ\93Ë\83}\83b\83v\82É\95`\89æ\r
+               var c = this.ownerStage.collisionMapContext;\r
+               c.save();\r
+               c.beginPath();\r
+               c.moveTo(x + this.collisionMargin.left, y + this.collisionMargin.top);\r
+               c.lineTo(x + this.collisionMargin.left, y + this.size.y - this.collisionMargin.bottom);\r
+               c.lineTo(x + this.size.x - this.collisionMargin.right, y + this.size.y - this.collisionMargin.bottom);\r
+               c.lineTo(x + this.size.x - this.collisionMargin.right, y + this.collisionMargin.top);\r
+               c.closePath();\r
+               c.stroke();\r
+               c.restore();\r
+       },\r
+       bindAttribute: function(attr)\r
+       {\r
+               //\8dX\90V\83f\81[\83^\82ð\8f\80\94õ\82·\82é\82Æ\82«\82É\8cÄ\82Î\82ê\82é\r
+               this.attribute["sX"] = this.size.x;\r
+               this.attribute["sY"] = this.size.y;\r
+       },\r
+       updateAttribute: function()\r
+       {\r
+               //\8dX\90V\83f\81[\83^\82ª\97\88\82½\82Æ\82«\82É\8cÄ\82Î\82ê\82é\r
+               if(this.attribute.sX){\r
+                       this.size.x = this.attribute.sX;\r
+               }\r
+               if(this.attribute.sY){\r
+                       this.size.y = this.attribute.sY;\r
+               }\r
+       },\r
+       // 1 - - +\r
+       // |     |\r
+       // |     |\r
+       // + - - 2\r
+       isOverlappedWith: function(x1, y1, x2, y2){\r
+               //\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é\r
+               //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B\r
+               //true\82©\82ÂisPhantom==false\82Ì\8e\9e\82Í\8fÕ\93Ë\82·\82é\81B\r
+               var o = this.origin;\r
+               var c = this.collisionMargin;\r
+               var s = this.size;\r
+               return (x2 >= (o.x + c.left)) && (x1 < (o.x + s.x - c.right)) && (y2 >= (o.y + c.top)) && (y1 < (o.y + s.y - c.bottom));\r
+       },\r
+       isOverlappedWithLocatedObject: function(obj, x, y){\r
+               //(x, y)\82Éobj\82ª\82 \82é\82Æ\82«\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\94Í\88Í\82É\81A\8e©\95ª\82Ì\83I\83u\83W\83F\83N\83g\96{\91Ì\95\94\95ª\82É\8fd\82È\82é\82©\82Ç\82¤\82©\82ð\92²\82×\82é\r
+               //\82±\82Ì\8aÖ\90\94\82ªfalse\82ð\95Ô\82µ\82½\8e\9e\82Ì\88ø\90\94\82Ì\94Í\88Í\82Ö\82Í\83I\83u\83W\83F\83N\83g\82ª\88Ú\93®\82Å\82«\82é\81B]\r
+               var c = obj.collisionMargin;\r
+               var s = obj.size;\r
+               return this.isOverlappedWith(x + c.left, y + c.top, x + s.x - c.right - 1, y + s.y - c.bottom - 1);\r
+       },\r
+       //     + - - +\r
+       //     |     |\r
+       // + - 0 - - + - +\r
+       // |   |     |   |\r
+       // |   |     |   |\r
+       // + - + - - 1 - +\r
+       //     |     |\r
+       //     + - - +\r
+       checkTouchingDirection: function(){\r
+               //\8fÕ\93Ë\95û\8cü\82ð\92²\82×\82é\81B\r
+               this.touchingDirection = 0;\r
+               this.collidedObjects = new Array();\r
+               var d = this.ownerStage.stageObjectLinearList;\r
+               for(var i = 0, i_max = d.length; i < i_max; i++){\r
+                       var obj = d[i];\r
+                       var c = this.collisionMargin;\r
+                       var r = this.collidingRange;\r
+                       // CollisonBody\r
+                       var cbx0 = this.origin.x + c.left;\r
+                       var cby0 = this.origin.y + c.top;\r
+                       var cbx1 = this.origin.x + this.size.x - 1 - c.right;\r
+                       var cby1 = this.origin.y + this.size.y - 1 - c.bottom;\r
+                       // CollisionFrame\94Í\88Í\93à\82©\8am\94F\r
+                       if(obj.isOverlappedWith(cbx0 - r, cby0 - r, cbx1 + r, cby1 + r) && obj !== this && !obj.isPhantom){\r
+                               //\8fÕ\93Ë\82Ì\89Â\94\\90«\82ª\82 \82é\82Ì\82Å\8am\94F\r
+                               if(obj.isOverlappedWith(cbx0, cby0, cbx1, cby1)){\r
+                                       //body\r
+                                       this.touchingDirection |= CollideBody;\r
+                               }\r
+                               if(obj.isOverlappedWith(cbx0, cby0 - r, cbx1, cby0 - 1)){\r
+                                       //top\r
+                                       this.touchingDirection |= CollideTop;\r
+                               }\r
+                               if(obj.isOverlappedWith(cbx0, cby1 + 1, cbx1, cby1 + r)){\r
+                                       //bottom\r
+                                       this.touchingDirection |= CollideBottom;\r
+                               }\r
+                               if(obj.isOverlappedWith(cbx0 - r, cby0, cbx0 - 1, cby1)){\r
+                                       //left\r
+                                       this.touchingDirection |= CollideLeft;\r
+                               }\r
+                               if(obj.isOverlappedWith(cbx1 + 1, cby0, cbx1 + r, cby1)){\r
+                                       //right\r
+                                       this.touchingDirection |= CollideRight;\r
+                               }\r
+                               \r
+                       }\r
+               }\r
+       },\r
+       getSyncData: function(){\r
+               this.bindAttribute();\r
+               return this.origin.x.toString() + "|" + \r
+                       this.origin.y.toString() + "|" + \r
+                       this.movingSpeed.x.toString() + "|" +  \r
+                       this.movingSpeed.y.toString() + "|" + \r
+                       this.className + "|" + \r
+                       parseArrayToStringSource(this.attribute) + "|" + \r
+                       parseArrayToStringSource(this.constructorArgs);\r
+       },\r
+};\r
+\r