OSDN Git Service

update
[yukkurioverwint/YukkuriOverwinter.git] / main.js
diff --git a/main.js b/main.js
index 9da106e..f59aff5 100644 (file)
--- a/main.js
+++ b/main.js
@@ -163,6 +163,9 @@ var EAction = {
        EAT_IN_HOME: 31,
        NONE: 9999
 };
+var EDeepSay = {
+
+}
 var EDirection = {
        LEFT : 0,
        RIGHT: 1,
@@ -235,9 +238,9 @@ var EDamage = {
        PICOHAN : 1
 };
 var ELooks = {
-       GOOD_YUKKURI : 0,
-       NORMAL_YUKKURI : 1,
-       BAD_YUKKURI : 2,
+       GOOD_YUKKURI : 3,
+       NORMAL_YUKKURI : 2,
+       BAD_YUKKURI : 1,
 };
 var EAnimStatus = {
        UP : 0,
@@ -245,6 +248,7 @@ var EAnimStatus = {
 };
 include("./lib/Animation.js"); 
 include("./lib/FormSprite.js"); 
+include("./lib/Util.js"); 
 
 
 var ObjSprite = enchant.Class.create(enchant.Sprite,{
@@ -343,7 +347,8 @@ window.onload = function(){
                var okazariValue = 37 + 11;
                var okazariReimuValue = 32;
                var bodyValue = 37;
-               var tweetValue = 188;
+               var tweetValue = 288;
+               var kukiValue = 43;
 
                if(a.type == "shadow"){
                        ay += shadowValue * a.scaleValue;
@@ -360,11 +365,13 @@ window.onload = function(){
                else if(a.type == "budge"){
                        ay += budgeValue * a.scaleValue - a.anim.cnt;
                }
+               else if(a.type == "kuki"){
+                       ay += kukiValue * a.scaleValue - a.anim.cnt;
+               }
 
                if(b.type == "shadow"){
                        by += shadowValue * b.scaleValue;
                }
-
                else if(b.type == "body" && b.classname == "Okazari" && b.spname == "reimu"){
                        by += okazariReimuValue * b.scaleValue - b.anim.cnt;
                }
@@ -380,6 +387,9 @@ window.onload = function(){
                else if(b.type == "budge"){
                        by += budgeValue * b.scaleValue - b.anim.cnt;
                }
+               else if(b.type == "kuki"){
+                       by += kukiValue * b.scaleValue - b.anim.cnt;
+               }
 
 
                if(a instanceof SpriteGroup){
@@ -2055,6 +2065,7 @@ window.onload = function(){
                                if(this instanceof Player){
                                        this.formSprite.setFixBudgeRight(5);
                                }
+                               this.formSprite.setFixKukiRight();
                                // this.formSprite.formScaleY(this.myScale);
 
                                // this.imgBody.scaleX = 1;
@@ -2063,6 +2074,7 @@ window.onload = function(){
                                this.formSprite.formScaleX(-this.myScaleX);
                                if(this instanceof Player){
                                        this.formSprite.setFixBudgeLeft(5);
+                                       this.formSprite.setFixKukiLeft();
                                }
                                // this.formSprite.formScaleY(this.myScale);
                                // this.imgBody.scaleX = -1;
@@ -2273,6 +2285,21 @@ window.onload = function(){
                getUnun: function(){
                        return this.param.unun;
                },
+               getLooksNumber: function(){
+                       return this.param.looks;
+               },
+               getLooksText: function(){
+                       if(this.param.looks == ELooks.GOOD_YUKKURI){
+                               return "びゆん";
+                       }
+                       if(this.param.looks == ELooks.NORMAL_YUKKURI){
+                               return "ぼんゆん";
+                       }
+                       if(this.param.looks == ELooks.BAD_YUKKURI){
+                               return "ぶさゆん";
+                       }
+                       return "";
+               },
                setUnun: function(unun){
                        this.param.unun = unun;
                        if(this.param.unun < 0)this.param.unun = 0;
@@ -2384,6 +2411,7 @@ window.onload = function(){
                        ret += "空腹  " + this.getHungry() + "\n";
                        ret += "うんうん  " + this.getUnun() + "\n";
                        ret += "もちもの  " + this.items.length + "\n";
+                       ret += "容姿  " + this.getLooksText() + "\n";
                        ret += "debug  " + this.action.status + "\n";
                        return ret;
                },
@@ -2480,84 +2508,94 @@ window.onload = function(){
 
                }
        });
-       // var MiYukkuri = enchant.Class.create(Yukkuri,{
-       //      initialize: function(x, y, grow){
-       //              Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
-       //              this.oldX = x;
-       //              this.oldY = y;
-       //      },
-       //      setOldY: function(){
-       //              this.imgGroup.y = this.oldY;
-
-       //      },
-       //      animX: function(x){
-       //              this.oldX = this.imgGroup.x;
-       //              this.imgGroup.x -= x;
-       //      },
-       //      animY: function(y){
-       //              this.imgGroup.y = this.oldY;
-       //              // this.oldY = this.imgGroup.y;
-       //              this.imgGroup.y -= y;
-       //      }
-       // }); 
-       // var MiMarisa = enchant.Class.create(MiYukkuri,{
-       //      initialize: function(x, y, grow){
-       //              MiYukkuri.call(this,x,y, EGrow.FRUIT_BABY);
-       //              this.classname = "MiMarisa";
-       //              this.myCode = "MIMARISA";
-       //              this.myName = "実まりさ";
-
-       //              this.param = new MarisaParam();
-       //              this.param.range = 0;
-       //              this.param.looks = ELooks.GOOD_YUKKURI;
-
-
-       //              this.face = new enchant.Sprite(64, 64);
-       //              this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
-       //              this.face.x = -CHARA_WIDTH / 2;
-       //              this.face.y = -CHARA_HEIGHT / 2;
-
-       //              this.faceStatus ={};
-       //              this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
-       //              this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
-       //              this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
-       //              this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
-       //              this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
-       //              this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
-       //              this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
-       //              this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
-       //              this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
-       //              this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
-
-       //              this.hear = new enchant.Sprite(64, 64);
-       //              this.hear.image = game.assets[EResPath.MARISA_HEAR];
-       //              this.hear.x = -CHARA_WIDTH / 2;
-       //              this.hear.y = -CHARA_HEIGHT / 2;
-
-       //              this.okazari = new Okazari(this);
-
-
-       //              // this.imgBody.addChild(this);
-       //              // this.imgBody.addChild(this.face);
-       //              // this.imgBody.addChild(this.hear);
-       //              // this.imgBody.addChild(this.okazari);
-       //              this.myScale(this.myScaleX, this.myScaleY)
-       //              // this.imgGroup.width = this.getWidth();
-       //              // this.imgGroup.height = this.getHeight();
-       //              // this.imgGroup.addChild(this.imgBody);
-       //              // this.imgGroup.flgMiYukkuri = true;
-       //              // backgroundMap.addChild(this.imgGroup);
-       //              this._tweet = new TTweet(148, 64);
-
-       //              this.imgGroup.addChild(this._tweet);
-       //              this.imgGroup.x = x;
-       //              this.imgGroup.y = y;
-
-       //              this.action = new Action(this);
-       //              ctl.addObj(this);
-       //      }
-
-       // });
+       var MiYukkuri = enchant.Class.create(Yukkuri,{
+               initialize: function(x, y, grow){
+                       Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
+                       this.oldX = x;
+                       this.oldY = y;
+               },
+               setOldY: function(){
+                       this.imgGroup.y = this.oldY;
+
+               },
+               animX: function(x){
+                       this.oldX = this.imgGroup.x;
+                       this.imgGroup.x -= x;
+               },
+               animY: function(y){
+                       this.imgGroup.y = this.oldY;
+                       // this.oldY = this.imgGroup.y;
+                       this.imgGroup.y -= y;
+               }
+       }); 
+       var MiMarisa = enchant.Class.create(MiYukkuri,{
+               initialize: function(x, y, grow){
+                       Yukkuri.call(this,x,y, grow);
+                       this.classname = "Marisa";
+                       this.myCode = "MARISA";
+                       this.myName = "実まりさ";
+
+                       this.param = new MarisaParam();
+                       this.param.looks = ELooks.GOOD_YUKKURI;
+                       this.myName = "実まりちゃ";
+                       this.param.range /= 4;
+
+                       this.face = new enchant.Sprite(64, 64);
+                       this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
+                       this.face.x = -CHARA_WIDTH / 2;
+                       this.face.y = -CHARA_HEIGHT / 2;
+
+                       this.faceStatus ={};
+                       this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
+                       this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
+                       this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
+                       this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
+                       this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
+                       this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
+                       this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
+                       this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
+                       this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
+                       this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
+
+
+                       this.hear = new enchant.Sprite(64, 64);
+                       this.hear.image = game.assets[EResPath.MARISA_HEAR];
+                       this.hear.x = -CHARA_WIDTH / 2;
+                       this.hear.y = -CHARA_HEIGHT / 2;
+
+                       this.okazari = new Okazari(this);
+
+                       this._tweet = new TTweet(this, 148, 64);
+
+                       this.formSprite.addChild(this, 1, {
+                               mainIndexFlg:true,
+                               type : "body",
+                               scaleValue:this.myScaleY
+                       });
+
+                       this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
+                       this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
+                       this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
+                       this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
+                       this.myScale(this.myScaleX, this.myScaleY)
+                       if(this instanceof Player){
+                               this.budge = new enchant.Sprite(16, 16);
+                               this.budge.image = game.assets[EResPath.PLAYER_BADGE];
+                               this.budge.x = -this.getWidth()/2;
+                               this.budge.y = -this.getHeight()/2;
+                               this.budge.scale(this.myScaleX, this.myScaleY);
+                               this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
+                               this.formSprite.setX(x);
+                               this.formSprite.setY(y);
+                       }
+                       this.formSprite.setX(x);
+                       this.formSprite.setY(y);
+                       this.animation();
+                       this.action = new Action(this);
+                       ctl.addObj(this);
+               }
+
+       });
        var Marisa = enchant.Class.create(Yukkuri,{
                initialize: function(x, y, grow){
                        Yukkuri.call(this,x,y, grow);
@@ -2626,17 +2664,15 @@ window.onload = function(){
                                type : "body",
                                scaleValue:this.myScaleY
                        });
-                       // this.formSprite.add(this.face,2,{type:"body",scaleValue:this.myScaleY});
-                       // this.formSprite.add(this.hear,3,{type:"body",scaleValue:this.myScaleY});
-                       // this.formSprite.add(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
-                       // this.formSprite.add(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
-                       // this.formSprite.addChildAll();
+
                        this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
                        this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
                        this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
                        this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
-                       // this.formSprite.addChildAll();
+                       this.formSprite.addChild(this.kukis[0],7,{type:"kuki",scaleValue:this.myScaleY});
+
 
+                       // this.formSprite.addChildAll();
                        // App.backgroundMap.addChild(this._tweet);
                        // this.imgGroup.addChild(this.shadow);
                        // this.imgBody.addChild(this);
@@ -2696,15 +2732,15 @@ window.onload = function(){
                                //Action pattern  debug
                                if(game.input.left){
                                        // this.changeFace(EResPath.MARISA_FACE_TIRED);
-                                       this.moveX(-10);
+                                       // this.moveX(-10);
                                        this.direction = EDirection.LEFT;
                                }
                                if(game.input.right){
-                                       for(var i=0;i<this.formSprite.spriteArray.length;i++){
-                                               var spr = this.formSprite.spriteArray[i];
-                                               console.log(i+":spry:" + spr.y);
-                                       }
-                                       this.moveX(10);
+                                       // for(var i=0;i<this.formSprite.spriteArray.length;i++){
+                                       //      var spr = this.formSprite.spriteArray[i];
+                                       //      console.log(i+":spry:" + spr.y);
+                                       // }
+                                       // this.moveX(10);
                                        this.direction = EDirection.RIGHT;
                                }
                                if(game.input.up){
@@ -2798,14 +2834,9 @@ window.onload = function(){
                        this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
                        this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY,spname:"reimu"});
                        this.formSprite.addChild(this.sub1,5,{type:"body",scaleValue:this.myScaleY});
-                       // this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
+                       this._tweet = new TTweet(this, 148, 64);
+                       this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
 
-                       // this.imgGroup.addChild(this.shadow);
-                       // this.imgBody.addChild(this.okazari);
-                       // this.imgBody.addChild(this);
-                       // this.imgBody.addChild(this.face);
-                       // this.imgBody.addChild(this.hear);
-                       // this.imgBody.addChild(this.sub1);
                        this.myScale(this.myScaleX, this.myScaleY)
                        if(this instanceof Player){
                                this.budge = new enchant.Sprite(16, 16);
@@ -2815,17 +2846,6 @@ window.onload = function(){
                                this.budge.y -= this.getHeight()/2;
                                this.budge.scale(this.myScaleX, this.myScaleX);
                        }
-                       // this.imgGroup.width = this.getWidth();
-                       // this.imgGroup.height = this.getHeight();
-                       // this.imgGroup.addChild(this.imgBody);
-                       // backgroundMap.addChild(this.imgGroup);
-                       this._tweet = new TTweet(this, 148, 64);
-                       backgroundMap.addChild(this._tweet);
-
-
-                       // this.imgGroup.addChild(this._tweet);
-                       // this.imgGroup.x = x;
-                       // this.imgGroup.y = y;
 
                        this.formSprite.setX(x);
                        this.formSprite.setY(y);
@@ -2897,13 +2917,14 @@ window.onload = function(){
                var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.ADULT);
                // var player = new Player(0, 0);
                // console.log(player.getX());
-               // player.addKuki();
+               player.addKuki();
                // player.createKuki();
                // new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
                // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
                // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
                // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
-               //new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
+               // new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
+               new MiMarisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.FRUIT_BABY);
                // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
                // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
                // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);