OSDN Git Service

辛夷祭初日の緊急修正多数。
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / GameStageClass.js
index 0cb9bce..7d16bdd 100644 (file)
-
-//
-//\83Q\81[\83\80\83X\83e\81[\83W
-//
-
-function GameStage(){
-       //****\83R\83\93\83X\83g\83\89\83N\83^****
-       //**\83C\83\93\83X\83^\83\93\83X\95Ï\90\94\90é\8c¾\81E\8f\89\8aú\89»**
-       //\83^\83C\83}\81[\83J\83E\83\93\83g\82ð\8f\89\8aú\89»
-       this.tickCount = 0;
-       //GameManager\82©\82ç\93n\82³\82ê\82é\83v\83\8d\83p\83e\83B
-       this.manager = null;
-       this.mainCanvas = null;
-       this.debugCanvas = null;
-       this.mainContext = null;
-       this.debugContext = null;
-       //StageObject\82Ì\83\8a\83X\83g
-       this.stageObjectList = new Array();
-       this.stageObjectLinearList = new Array();
-       this.globalStageObjectList = new Array();
-       this.pendingGlobalStageObjectData = new RequestData();
-       this.pendingGlobalStageObjectList = new Array();
-       //\8fÕ\93Ë\94»\92è\97pcanvas
-       this.collisionMapCanvas = null;
-       this.collisionMapContext = null;
-       this.debugMode = false;
-       //\94w\8ci\82Ì\89æ\91\9c\82Ìimg\83G\83\8c\83\81\83\93\83g\83I\83u\83W\83F\83N\83g\82ð\8ew\92è
-       this.background = null;
-       //\83\86\81[\83U\81[\82ª\91\80\8dì\82µ\82Ä\82¢\82é\83L\83\83\83\89\83N\83^\81[\83I\83u\83W\83F\83N\83g
-       this.userControlledCharacter = null;
-       //\90\85\96Ê\82Ìy\8dÀ\95W\81B0\82Å\96³\8cø
-       this.waterLevel = 0;
-       this.gravity = 700 / mainManager.tickPerSecond;
-       this.waterGravity = 700 / mainManager.tickPerSecond;
-       this.friction = 300 / mainManager.tickPerSecond;
-       this.waterFriction = 600 / mainManager.tickPerSecond;
-}
-GameStage.prototype = {
-       //\88È\89º\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82µ\82Ä\83X\83e\81[\83W\82ð\8dì\90¬\82·\82é\81B
-       keyDown: function(event){
-               //\83L\81[\93ü\97Í
-       },
-       keyUp: function(event){
-               //\83L\81[\93ü\97Í
-       },
-       timerTick: function(){
-               //\83^\83C\83}\81[
-               this.tickCount++;
-               //\91S\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8cv\8eZ
-               for(var sp in this.stageObjectList)
-               {
-                       var tickAllObjects = true;
-                       //\82Ü\82¸\81A\83N\83\89\83X\92è\8b`.tick() (\97á\82¦\82ÎBlockStageObjectClass.tick = function(){};) \82ª\92è\8b`\82³\82ê\82Ä\82½\82ç\8eÀ\8ds
-                       if(sp.tick){
-                               //\83N\83\89\83Xsp\82Ìtick\82Ì\96ß\82è\92l\82Í\81A\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83X\83^\83\93\83X\82Ìtick\82ð\8eÀ\8ds\82·\82é\95K\97v\82ª\82 \82é\82©\82Ç\82¤\82©
-                               tickAllObjects = sp.tick(this.stageObjectList[sp]);
-                       }
-                       
-                       //\8e\9f\82É\8ae\8eíStageObject\82Ìtick\82ð\8eÀ\8ds
-                       if(tickAllObjects)
-                       {
-                               for(var i = 0, i_max = this.stageObjectList[sp].length; i < i_max; i++){
-                                       var o = this.stageObjectList[sp][i];
-                                       if(o instanceof MovableStageObjectClass){
-                                               var g = this.gravity - o.antigravity;
-                                               var f = this.friction;
-                                               var h = f * 2;
-                                               //\8b¤\92Ê\89^\93®\8f\88\97\9d
-                                               if(this.waterLevel && this.waterLevel <= o.origin.y + o.size.y){
-                                                       //\90\85\92\86
-                                                       o.inWater = true;
-                                                       g = this.waterGravity - o.antigravity;
-                                                       f = this.waterFriction;
-                                                       var h = f * 4;
-                                                       if(o.movingSpeed.y < -f){
-                                                               o.movingSpeed.y += f;
-                                                       } else if(o.movingSpeed.y > f){
-                                                               o.movingSpeed.y -= f;
-                                                       } else{
-                                                               o.movingSpeed.y = 0;
-                                                       }
-                                                       o.movingSpeed.y += g;
-                                                       if(o.movingSpeed.x < -f){
-                                                               o.movingSpeed.x += f;
-                                                       } else if(o.movingSpeed.x > f){
-                                                               o.movingSpeed.x -= f;
-                                                       } else{
-                                                               o.movingSpeed.x = 0;
-                                                       }
-                                               } else{
-                                                       //\91å\8bC\92\86
-                                                       o.inWater = false;
-                                                       o.movingSpeed.y += g;
-                                                       if(o.movingSpeed.x < -h){
-                                                               o.movingSpeed.x += f;
-                                                       } else if(o.movingSpeed.x > h){
-                                                               o.movingSpeed.x -= f;
-                                                       } else{
-                                                               o.movingSpeed.x = 0;
-                                                       }
-                                               }
-                                       }
-                               }
-                               //\82±\82±\82Í\83\8b\81[\83v\8fI\97¹\92l\82ðlength\82Å\92¼\90Ú\8eæ\93¾\82µ\82È\82¯\82ê\82Î\82¢\82¯\82È\82¢\81i\8dí\8f\9c\82³\82ê\82é\83I\83u\83W\83F\83N\83g\82ª\82 \82é\89Â\94\\90«\82ª\82 \82é\82½\82ß\81j
-                               for(var i = 0; i < this.stageObjectList[sp].length; i++){
-                                       var o = this.stageObjectList[sp][i];
-                                       //\8ae\83I\83u\83W\83F\83N\83g\8f\88\97\9d
-                                       o.tick();
-                               }
-                       }
-               }
-               // \91\80\8dì\92\86\83L\83\83\83\89\82Ì\88Ú\93®\8f\88\97\9d
-               var c = this.userControlledCharacter;
-               if(c)
-               {
-                       if(this.manager.UIManager.keyState.jump)
-                       {
-                               if(c.onLadder){
-                                       //\82Í\82µ\82²\8fã\82é
-                                       c.movingSpeed.y = 0;
-                                       c.moveTo(c.origin.x, c.origin.y - 4);
-                               } else{
-                                       //\83W\83\83\83\93\83v
-                                       c.jump();
-                               }
-                       } else if(c.jumpEnd){
-                               if(!c.onLadder){
-                                       //\83W\83\83\83\93\83v\8cã\82Ì\8f\88\97\9d
-                                       c.jumpEnd();
-                               }
-                       }
-                       if(!(this.manager.UIManager.keyState.goLeft && this.manager.UIManager.keyState.goRight))
-                       {
-                               //\8d\89E
-                               if(this.manager.UIManager.keyState.goLeft){
-                                       c.goLeft();
-                               }
-                               if(this.manager.UIManager.keyState.goRight){
-                                       c.goRight();
-                               }
-                       }
-                       if(this.manager.UIManager.keyState.fire){
-                               c.fire();
-                       }
-               }
-       },
-       draw: function(){
-               this.drawBackground();
-               this.drawAsPoint(0, 0);
-               if(this.waterLevel){
-                       this.drawWater();
-               }
-       },
-       drawAsPoint: function(x, y){
-       
-               // \95\\8e¦\82Ì\8fd\82Ë\8d\87\82í\82¹\8f\87 : \91¼\82Ì\8d\80\96Ú < \83L\83\83\83\89 < forceTopMost==true\82Ì\8d\80\96Ú
-       
-               var characterList = [];
-               var topList = [];
-               var drawItem = function(stgobj)
-               {
-                       var px = stgobj.origin.x - x, py = stgobj.origin.y - y;
-                       
-                       if(px > -stgobj.size.x && py > -stgobj.size.y && px < 640 && py < 480)
-                       {
-                               stgobj.draw(px, py);
-                               if(this.debugMode){
-                                       stgobj.debugDraw(px, py);
-                               }
-                       }
-               };
-               
-               //\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dÄ\95`\89æ
-               //x, y\82Í\95`\89æ\88Ê\92u\82Ì\83I\83t\83Z\83b\83g
-               for(var sp in this.stageObjectList)
-               {
-                       //\8ae\8eíStageObject\82Ìdraw\82ð\8eÀ\8ds
-                       for(var i = 0, li = this.stageObjectList[sp].length; i < li; i++){
-                               var stgobj = this.stageObjectList[sp][i];
-                               if(stgobj.forceTopMost)
-                               {
-                                       topList.push(stgobj);
-                               }else if(stgobj instanceof CharacterClass)
-                               {
-                                       characterList.push(stgobj);
-                               }else
-                               {
-                                       drawItem(stgobj);
-                               }
-                       }
-               }
-               
-               for(var i in characterList)
-               {
-                       var stgobj = characterList[i];
-                       drawItem(stgobj);
-               }
-               
-               for(var i in topList)
-               {
-                       var stgobj = topList[i];
-                       drawItem(stgobj);
-               }
-       },
-       drawBackground: function(){
-               if(this.background)
-               {
-                       this.mainContext.drawImage(this.background, 0, 0);
-                       
-               } else{
-                       //\83L\83\83\83\93\83o\83X\82ð\91S\8fÁ\8b\8e
-                       this.mainContext.clearRect(0, 0, this.mainCanvas.width, this.mainCanvas.height);
-               }
-               if(this.collisionMapContext)
-               {
-                       this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height);
-               }
-       },
-       drawWater: function(){
-               //\90\85\95\94\95ª\82ð\95`\89æ\82·\82é\81B\8c©\82½\96Ú\82¾\82¯
-               this.mainContext.fillStyle = "rgba(100,128,255, 0.32)";
-               fillRect(this.mainContext, 0, this.waterLevel, this.mainCanvas.width, this.mainCanvas.height - this.waterLevel);
-       },
-       runStage: function(){
-               //\83X\83e\81[\83W\8f\89\8aú\89»\8f\88\97\9d
-               this.tickCount = 0;
-               //\8fÕ\93Ë\83}\83b\83v\8f\89\8aú\89»
-               this.collisionMapCanvas = createCanvas("collisionMapCanvas", this.mainCanvas.width, this.mainCanvas.height, this.mainCanvas.width, 0, 1, this.manager.mainArea);
-               this.collisionMapContext = this.collisionMapCanvas.getContext('2d');
-               this.collisionMapContext.fillStyle = "rgba(0,0,0, 0.2)";
-               this.collisionMapContext.strokeStyle = "rgba(0,0,0, 0.2)";
-       },
-       stopStage: function(){
-               //\83X\83e\81[\83W\8fI\97¹\8f\88\97\9d
-               destroyDOMObjectByID(this.collisionMapCanvas.id);
-               this.collisionMapCanvas = null;
-               this.collisionMapContext = null;
-               this.stageObjectList = new Array();
-               this.stageObjectLinearList = new Array();
-               this.globalStageObjectList = new Array();
-       },
-       addStageObject: function(aStageObject, isGlobalObject, isFromNetwork){
-               //stageObject\82ð\83\8a\83X\83g\82É\92Ç\89Á\82·\82é
-               //isGlobalObject:\83l\83b\83g\83\8f\81[\83N\8dX\90V\82ª\95K\97v\82È\8fê\8d\87true\82ð\93n\82·\81B\95s\97v\82È\8fê\8d\87\82Í\8fÈ\97ª\82Å\82«\82é\81B
-               //stageObjectList\82Í\83I\83u\83W\83F\83N\83g\82Ì\83N\83\89\83X\82²\82Æ\82Ì\98A\91z\94z\97ñ\82É\82È\82Á\82Ä\82¢\82é\81B
-               var sp = aStageObject.constructor;
-               if(this.stageObjectList[sp] == undefined)
-               {
-                       this.stageObjectList[sp] = [];
-               }
-               this.stageObjectList[sp].push(aStageObject);
-               this.stageObjectLinearList.push(aStageObject);
-               if(isGlobalObject){
-                       if(!isFromNetwork){
-                               this.pendingGlobalStageObjectData.append(this.pendingGlobalStageObjectData.length, aStageObject.getSyncData());
-                               this.pendingGlobalStageObjectList.push(aStageObject);
-                       } else{
-                               this.globalStageObjectList.push(aStageObject);
-                       }
-               }
-       },
-       removeStageObject: function(aStageObject){
-               //stageObject\82ð\83\8a\83X\83g\82©\82ç\8dí\8f\9c\82·\82é
-               var sp = aStageObject.constructor;
-               if(sp in this.stageObjectList)
-               {
-                       removeObjectFromArray(this.stageObjectList[sp], aStageObject);
-                       if(this.stageObjectList[sp].length == 0)
-                       {
-                               //\8bó\82É\82È\82Á\82½\83N\83\89\83X\82Ì\94z\97ñ\82Í\8dí\8f\9c\82·\82é
-                               removeObjectFromArray(this.stageObjectList, sp);
-                       }
-               }
-               removeObjectFromArray(this.stageObjectLinearList, aStageObject);
-               //globalStageObjectList\82©\82ç\8dí\8f\9c\81B\91\8dÝ\82µ\82È\82¢\8fê\8d\87\82Í\89½\82à\8bN\82«\82È\82¢\82Ì\82Å\82±\82ê\82Å\91å\8fä\95v
-               removeObjectFromArray(this.globalStageObjectList, aStageObject);
-       },
-       eachStageObject: function(f){
-               //\83\8a\83X\83g\8fã\82Ì\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\88ê\82Â\82¸\82Â\82ð\88ø\90\94\82Æ\82µ\82Ä\8aÖ\90\94f\82ð\82»\82ê\82¼\82ê\8eÀ\8ds\82·\82é\81B
-               //\8aÖ\90\94f\82ªfalse\82ð\95Ô\82µ\82½\8fê\8d\87\81A\82»\82±\82Å\8eÀ\8ds\82ð\92\86\92f\82µ\82Äfalse\82ð\95Ô\82·\81B
-               for(var sp in this.stageObjectList)
-               {
-                       for(var i = 0; i < this.stageObjectList[sp].length; i++){
-                               
-                               var stgobj = this.stageObjectList[sp][i];
-                               if(!f(stgobj)) return false;
-                       }
-               }
-               return true;
-       },
-       eachStageObjectById: function(id, f){
-               for(var sp in this.stageObjectList)
-               {
-                       for(i = 0; i < this.stageObjectList[sp].length; i++){
-                               
-                               var stgobj = this.stageObjectList[sp][i];
-                               if(stgobj.id == id)
-                               {
-                                       if(!f(stgobj)) return false;
-                               }
-                       }
-               }
-               return true;
-       },
-       eachOwnStageObject: function(f){
-               //\8e©\95ª\8e©\90g\82ª\8f\8a\97L\82·\82é\83I\83u\83W\83F\83N\83g\82·\82×\82Ä\82É\91Î\82µ\82Ä\8aÖ\90\94f\82ð\93K\97p\82·\82é
-               for(var sp in this.stageObjectList){
-                       for(var i = 0; i < this.stageObjectList[sp].length; i++){
-                               var stgobj = this.stageObjectList[sp][i];
-                               if(stgobj.ownerUID == this.manager.userID){
-                                       f(stgobj);
-                               }
-                       }
-               }
-       },
-       getGlobalStageObject: function(objid){
-               for(var i = 0; i < this.globalStageObjectList.length; i++){
-                       if(objid == this.globalStageObjectList[i].objectID){
-                               return this.globalStageObjectList[i];
-                       }
-               }
-               return null;
-       },
-       appendSyncDataTo: function(data){
-               for(var i = 0; i < this.globalStageObjectList.length; i++){
-                       var anObj = this.globalStageObjectList[i];
-                       if(anObj.ownerUID == this.manager.userID){
-                               anObj.bindAttribute();
-                               data.append(i, anObj.objectID + "|" + anObj.origin.x + "|" + anObj.origin.y + "|" + anObj.movingSpeed.x + "|" +  anObj.movingSpeed.y+ "|" + parseArrayToStringSource(anObj.attribute));
-                       }
-               }
-       },
-};
-
+\r
+//\r
+//\83Q\81[\83\80\83X\83e\81[\83W\r
+//\r
+\r
+function GameStage(){\r
+       //****\83R\83\93\83X\83g\83\89\83N\83^****\r
+       //**\83C\83\93\83X\83^\83\93\83X\95Ï\90\94\90é\8c¾\81E\8f\89\8aú\89»**\r
+       //\83^\83C\83}\81[\83J\83E\83\93\83g\82ð\8f\89\8aú\89»\r
+       this.tickCount = 0;\r
+       //GameManager\82©\82ç\93n\82³\82ê\82é\83v\83\8d\83p\83e\83B\r
+       this.manager = null;\r
+       this.mainCanvas = null;\r
+       this.debugCanvas = null;\r
+       this.mainContext = null;\r
+       this.debugContext = null;\r
+       //StageObject\82Ì\83\8a\83X\83g\r
+       this.stageObjectList = new Array();\r
+       this.stageObjectLinearList = new Array();\r
+       this.globalStageObjectList = new Array();\r
+       this.pendingGlobalStageObjectData = new RequestData();\r
+       this.pendingGlobalStageObjectList = new Array();\r
+       //\8fÕ\93Ë\94»\92è\97pcanvas\r
+       this.collisionMapCanvas = null;\r
+       this.collisionMapContext = null;\r
+       this.debugMode = false;\r
+       //\94w\8ci\82Ì\89æ\91\9c\82Ìimg\83G\83\8c\83\81\83\93\83g\83I\83u\83W\83F\83N\83g\82ð\8ew\92è\r
+       this.background = null;\r
+       //\83\86\81[\83U\81[\82ª\91\80\8dì\82µ\82Ä\82¢\82é\83L\83\83\83\89\83N\83^\81[\83I\83u\83W\83F\83N\83g\r
+       this.userControlledCharacter = null;\r
+       //\90\85\96Ê\82Ìy\8dÀ\95W\81B0\82Å\96³\8cø\r
+       this.waterLevel = 0;\r
+       this.gravity = 700 / mainManager.tickPerSecond;\r
+       this.waterGravity = 700 / mainManager.tickPerSecond;\r
+       this.friction = 300 / mainManager.tickPerSecond;\r
+       this.waterFriction = 600 / mainManager.tickPerSecond;\r
+}\r
+GameStage.prototype = {\r
+       //\88È\89º\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82µ\82Ä\83X\83e\81[\83W\82ð\8dì\90¬\82·\82é\81B\r
+       keyDown: function(event){\r
+               //\83L\81[\93ü\97Í\r
+       },\r
+       keyUp: function(event){\r
+               //\83L\81[\93ü\97Í\r
+       },\r
+       timerTick: function(){\r
+               //\83^\83C\83}\81[\r
+               this.tickCount++;\r
+               //\91S\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8cv\8eZ\r
+               for(var sp in this.stageObjectList)\r
+               {\r
+                       var tickAllObjects = true;\r
+                       //\82Ü\82¸\81A\83N\83\89\83X\92è\8b`.tick() (\97á\82¦\82ÎBlockStageObjectClass.tick = function(){};) \82ª\92è\8b`\82³\82ê\82Ä\82½\82ç\8eÀ\8ds\r
+                       if(sp.tick){\r
+                               //\83N\83\89\83Xsp\82Ìtick\82Ì\96ß\82è\92l\82Í\81A\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82Ì\83C\83\93\83X\83^\83\93\83X\82Ìtick\82ð\8eÀ\8ds\82·\82é\95K\97v\82ª\82 \82é\82©\82Ç\82¤\82©\r
+                               tickAllObjects = sp.tick(this.stageObjectList[sp]);\r
+                       }\r
+                       \r
+                       //\8e\9f\82É\8ae\8eíStageObject\82Ìtick\82ð\8eÀ\8ds\r
+                       if(tickAllObjects)\r
+                       {\r
+                               for(var i = 0, i_max = this.stageObjectList[sp].length; i < i_max; i++){\r
+                                       var o = this.stageObjectList[sp][i];\r
+                                       if(o instanceof MovableStageObjectClass){\r
+                                               var g = this.gravity - o.antigravity;\r
+                                               var f = this.friction;\r
+                                               var h = f * 2;\r
+                                               //\8b¤\92Ê\89^\93®\8f\88\97\9d\r
+                                               if(this.waterLevel && this.waterLevel <= o.origin.y + o.size.y){\r
+                                                       //\90\85\92\86\r
+                                                       o.inWater = true;\r
+                                                       g = this.waterGravity - o.antigravity;\r
+                                                       f = this.waterFriction;\r
+                                                       var h = f * 4;\r
+                                                       if(o.movingSpeed.y < -f){\r
+                                                               o.movingSpeed.y += f;\r
+                                                       } else if(o.movingSpeed.y > f){\r
+                                                               o.movingSpeed.y -= f;\r
+                                                       } else{\r
+                                                               o.movingSpeed.y = 0;\r
+                                                       }\r
+                                                       o.movingSpeed.y += g;\r
+                                                       if(o.movingSpeed.x < -f){\r
+                                                               o.movingSpeed.x += f;\r
+                                                       } else if(o.movingSpeed.x > f){\r
+                                                               o.movingSpeed.x -= f;\r
+                                                       } else{\r
+                                                               o.movingSpeed.x = 0;\r
+                                                       }\r
+                                               } else{\r
+                                                       //\91å\8bC\92\86\r
+                                                       o.inWater = false;\r
+                                                       o.movingSpeed.y += g;\r
+                                                       if(o.movingSpeed.x < -h){\r
+                                                               o.movingSpeed.x += f;\r
+                                                       } else if(o.movingSpeed.x > h){\r
+                                                               o.movingSpeed.x -= f;\r
+                                                       } else{\r
+                                                               o.movingSpeed.x = 0;\r
+                                                       }\r
+                                               }\r
+                                       }\r
+                               }\r
+                               //\82±\82±\82Í\83\8b\81[\83v\8fI\97¹\92l\82ðlength\82Å\92¼\90Ú\8eæ\93¾\82µ\82È\82¯\82ê\82Î\82¢\82¯\82È\82¢\81i\8dí\8f\9c\82³\82ê\82é\83I\83u\83W\83F\83N\83g\82ª\82 \82é\89Â\94\\90«\82ª\82 \82é\82½\82ß\81j\r
+                               for(var i = 0; i < this.stageObjectList[sp].length; i++){\r
+                                       var o = this.stageObjectList[sp][i];\r
+                                       //\8ae\83I\83u\83W\83F\83N\83g\8f\88\97\9d\r
+                                       if(o.tick()){\r
+                                               return;\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               // \91\80\8dì\92\86\83L\83\83\83\89\82Ì\88Ú\93®\8f\88\97\9d\r
+               var c = this.userControlledCharacter;\r
+               if(c)\r
+               {\r
+                       if(this.manager.UIManager.keyState.jump)\r
+                       {\r
+                               if(c.onLadder){\r
+                                       //\82Í\82µ\82²\8fã\82é\r
+                                       c.movingSpeed.y = 0;\r
+                                       c.moveTo(c.origin.x, c.origin.y - 4);\r
+                               } else{\r
+                                       //\83W\83\83\83\93\83v\r
+                                       c.jump();\r
+                               }\r
+                       } else if(c.jumpEnd){\r
+                               if(!c.onLadder){\r
+                                       //\83W\83\83\83\93\83v\8cã\82Ì\8f\88\97\9d\r
+                                       c.jumpEnd();\r
+                               }\r
+                       }\r
+                       if(!(this.manager.UIManager.keyState.goLeft && this.manager.UIManager.keyState.goRight))\r
+                       {\r
+                               //\8d\89E\r
+                               if(this.manager.UIManager.keyState.goLeft){\r
+                                       c.goLeft();\r
+                               }\r
+                               if(this.manager.UIManager.keyState.goRight){\r
+                                       c.goRight();\r
+                               }\r
+                       }\r
+                       if(this.manager.UIManager.keyState.fire){\r
+                               c.fire();\r
+                       }\r
+               }\r
+       },\r
+       draw: function(){\r
+               this.drawBackground();\r
+               this.drawAsPoint(0, 0);\r
+               if(this.waterLevel){\r
+                       this.drawWater();\r
+               }\r
+       },\r
+       drawAsPoint: function(x, y){\r
+       \r
+               // \95\\8e¦\82Ì\8fd\82Ë\8d\87\82í\82¹\8f\87 : \91¼\82Ì\8d\80\96Ú < \83L\83\83\83\89 < forceTopMost==true\82Ì\8d\80\96Ú\r
+       \r
+               var characterList = [];\r
+               var topList = [];\r
+               var drawItem = function(stgobj)\r
+               {\r
+                       var px = stgobj.origin.x - x, py = stgobj.origin.y - y;\r
+                       \r
+                       if(px > -stgobj.size.x && py > -stgobj.size.y && px < 640 && py < 480)\r
+                       {\r
+                               stgobj.draw(px, py);\r
+                               if(this.debugMode){\r
+                                       stgobj.debugDraw(px, py);\r
+                               }\r
+                       }\r
+               };\r
+               \r
+               //\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dÄ\95`\89æ\r
+               //x, y\82Í\95`\89æ\88Ê\92u\82Ì\83I\83t\83Z\83b\83g\r
+               for(var sp in this.stageObjectList)\r
+               {\r
+                       //\8ae\8eíStageObject\82Ìdraw\82ð\8eÀ\8ds\r
+                       for(var i = 0, li = this.stageObjectList[sp].length; i < li; i++){\r
+                               var stgobj = this.stageObjectList[sp][i];\r
+                               if(stgobj.forceTopMost)\r
+                               {\r
+                                       topList.push(stgobj);\r
+                               }else if(stgobj instanceof CharacterClass)\r
+                               {\r
+                                       characterList.push(stgobj);\r
+                               }else\r
+                               {\r
+                                       drawItem(stgobj);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               for(var i in characterList)\r
+               {\r
+                       var stgobj = characterList[i];\r
+                       drawItem(stgobj);\r
+               }\r
+               \r
+               for(var i in topList)\r
+               {\r
+                       var stgobj = topList[i];\r
+                       drawItem(stgobj);\r
+               }\r
+       },\r
+       drawBackground: function(){\r
+               if(this.background)\r
+               {\r
+                       this.mainContext.drawImage(this.background, 0, 0);\r
+                       \r
+               } else{\r
+                       //\83L\83\83\83\93\83o\83X\82ð\91S\8fÁ\8b\8e\r
+                       this.mainContext.clearRect(0, 0, this.mainCanvas.width, this.mainCanvas.height);\r
+               }\r
+               if(this.collisionMapContext)\r
+               {\r
+                       this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width, this.collisionMapCanvas.height);\r
+               }\r
+       },\r
+       drawWater: function(){\r
+               //\90\85\95\94\95ª\82ð\95`\89æ\82·\82é\81B\8c©\82½\96Ú\82¾\82¯\r
+               this.mainContext.fillStyle = "rgba(100,128,255, 0.32)";\r
+               fillRect(this.mainContext, 0, this.waterLevel, this.mainCanvas.width, this.mainCanvas.height - this.waterLevel);\r
+       },\r
+       runStage: function(){\r
+               //\83X\83e\81[\83W\8f\89\8aú\89»\8f\88\97\9d\r
+               this.tickCount = 0;\r
+               //\8fÕ\93Ë\83}\83b\83v\8f\89\8aú\89»\r
+               this.collisionMapCanvas = createCanvas("collisionMapCanvas", this.mainCanvas.width, this.mainCanvas.height, this.mainCanvas.width, 0, 1, this.manager.mainArea);\r
+               this.collisionMapContext = this.collisionMapCanvas.getContext('2d');\r
+               this.collisionMapContext.fillStyle = "rgba(0,0,0, 0.2)";\r
+               this.collisionMapContext.strokeStyle = "rgba(0,0,0, 0.2)";\r
+       },\r
+       stopStage: function(){\r
+               //\83X\83e\81[\83W\8fI\97¹\8f\88\97\9d\r
+               destroyDOMObjectByID(this.collisionMapCanvas.id);\r
+               this.collisionMapCanvas = null;\r
+               this.collisionMapContext = null;\r
+               this.stageObjectList = new Array();\r
+               this.stageObjectLinearList = new Array();\r
+               this.globalStageObjectList = new Array();\r
+       },\r
+       addStageObject: function(aStageObject, isGlobalObject, isFromNetwork){\r
+               //stageObject\82ð\83\8a\83X\83g\82É\92Ç\89Á\82·\82é\r
+               //isGlobalObject:\83l\83b\83g\83\8f\81[\83N\8dX\90V\82ª\95K\97v\82È\8fê\8d\87true\82ð\93n\82·\81B\95s\97v\82È\8fê\8d\87\82Í\8fÈ\97ª\82Å\82«\82é\81B\r
+               //stageObjectList\82Í\83I\83u\83W\83F\83N\83g\82Ì\83N\83\89\83X\82²\82Æ\82Ì\98A\91z\94z\97ñ\82É\82È\82Á\82Ä\82¢\82é\81B\r
+               var sp = aStageObject.constructor;\r
+               if(this.stageObjectList[sp] == undefined)\r
+               {\r
+                       this.stageObjectList[sp] = [];\r
+               }\r
+               this.stageObjectList[sp].push(aStageObject);\r
+               this.stageObjectLinearList.push(aStageObject);\r
+               if(isGlobalObject){\r
+                       if(!isFromNetwork){\r
+                               this.pendingGlobalStageObjectData.append(this.pendingGlobalStageObjectData.length, aStageObject.getSyncData());\r
+                               this.pendingGlobalStageObjectList.push(aStageObject);\r
+                       } else{\r
+                               this.globalStageObjectList.push(aStageObject);\r
+                       }\r
+               }\r
+       },\r
+       removeStageObject: function(aStageObject){\r
+               //stageObject\82ð\83\8a\83X\83g\82©\82ç\8dí\8f\9c\82·\82é\r
+               var sp = aStageObject.constructor;\r
+               if(sp in this.stageObjectList)\r
+               {\r
+                       removeObjectFromArray(this.stageObjectList[sp], aStageObject);\r
+                       if(this.stageObjectList[sp].length == 0)\r
+                       {\r
+                               //\8bó\82É\82È\82Á\82½\83N\83\89\83X\82Ì\94z\97ñ\82Í\8dí\8f\9c\82·\82é\r
+                               removeObjectFromArray(this.stageObjectList, sp);\r
+                       }\r
+               }\r
+               removeObjectFromArray(this.stageObjectLinearList, aStageObject);\r
+               //globalStageObjectList\82©\82ç\8dí\8f\9c\81B\91\8dÝ\82µ\82È\82¢\8fê\8d\87\82Í\89½\82à\8bN\82«\82È\82¢\82Ì\82Å\82±\82ê\82Å\91å\8fä\95v\r
+               removeObjectFromArray(this.globalStageObjectList, aStageObject);\r
+       },\r
+       eachStageObject: function(f){\r
+               //\83\8a\83X\83g\8fã\82Ì\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\88ê\82Â\82¸\82Â\82ð\88ø\90\94\82Æ\82µ\82Ä\8aÖ\90\94f\82ð\82»\82ê\82¼\82ê\8eÀ\8ds\82·\82é\81B\r
+               //\8aÖ\90\94f\82ªfalse\82ð\95Ô\82µ\82½\8fê\8d\87\81A\82»\82±\82Å\8eÀ\8ds\82ð\92\86\92f\82µ\82Äfalse\82ð\95Ô\82·\81B\r
+               for(var sp in this.stageObjectList)\r
+               {\r
+                       for(var i = 0; i < this.stageObjectList[sp].length; i++){\r
+                               \r
+                               var stgobj = this.stageObjectList[sp][i];\r
+                               if(!f(stgobj)) return false;\r
+                       }\r
+               }\r
+               return true;\r
+       },\r
+       eachStageObjectById: function(id, f){\r
+               for(var sp in this.stageObjectList)\r
+               {\r
+                       for(i = 0; i < this.stageObjectList[sp].length; i++){\r
+                               \r
+                               var stgobj = this.stageObjectList[sp][i];\r
+                               if(stgobj.id == id)\r
+                               {\r
+                                       if(!f(stgobj)) return false;\r
+                               }\r
+                       }\r
+               }\r
+               return true;\r
+       },\r
+       eachOwnStageObject: function(f){\r
+               //\8e©\95ª\8e©\90g\82ª\8f\8a\97L\82·\82é\83I\83u\83W\83F\83N\83g\82·\82×\82Ä\82É\91Î\82µ\82Ä\8aÖ\90\94f\82ð\93K\97p\82·\82é\r
+               for(var sp in this.stageObjectList){\r
+                       for(var i = 0; i < this.stageObjectList[sp].length; i++){\r
+                               var stgobj = this.stageObjectList[sp][i];\r
+                               if(stgobj.ownerUID == this.manager.userID){\r
+                                       f(stgobj);\r
+                               }\r
+                       }\r
+               }\r
+       },\r
+       getGlobalStageObject: function(objid){\r
+               for(var i = 0; i < this.globalStageObjectList.length; i++){\r
+                       if(objid == this.globalStageObjectList[i].objectID){\r
+                               return this.globalStageObjectList[i];\r
+                       }\r
+               }\r
+               return null;\r
+       },\r
+       appendSyncDataTo: function(data){\r
+               for(var i = 0; i < this.globalStageObjectList.length; i++){\r
+                       var anObj = this.globalStageObjectList[i];\r
+                       if(anObj.ownerUID == this.manager.userID){\r
+                               anObj.bindAttribute();\r
+                               data.append(i, anObj.objectID + "|" + anObj.origin.x + "|" + anObj.origin.y + "|" + anObj.movingSpeed.x + "|" +  anObj.movingSpeed.y+ "|" + parseArrayToStringSource(anObj.attribute));\r
+                       }\r
+               }\r
+       },\r
+};\r
+\r