var CHARA_HEIGHT = 64;
var GAME_WIDTH = 800;
var GAME_HEIGHT = 600;
-var FPS = 20;
+var FPS = 50;
var BASE_FPS = 20;
var HUNGRY_MAX = 100;
var MIN = BASE_FPS;
MOVE_GOTO_HOME: 28,
IN_HOME: 29,
THINK_IN_HOME: 30,
+ EAT_IN_HOME: 31,
NONE: 9999
};
var EDirection = {
this.observe();
switch(this.status){
case EAction.WAIT:
-
+ this.waitCnt++;
+ if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
+ this.waitCnt = 0;
+ this.setStatus(EAction.THINK);
+ console.log("wait cnt end");
+ }
break;
case EAction.THINK_IN_HOME:
+ this.waitCnt = 0;
+ this.search();
this.think_in_home();
break;
+ case EAction.EAT_IN_HOME:
+ this.eat_in_home();
+ break;
case EAction.THINK:
+ this.waitCnt = 0;
if(this.yukkuri.age%2 === 0){
this.yukkuri.changeFace();
this.search();
if((date === EDate.MIDNIGHT || date === EDate.NIGHT)
&& !this.yukkuri.isSleep()){
//sleep
-
+ new SleepEvent({
+ "action": this,
+ "nextStatus":EAction.THINK_IN_HOME,
+ "myYukkuri": this.yukkuri
+ });
+ return;
}
else if(date === EDate.EVENING){
//QK
}
}
},
+ eat_in_home: function(){
+ new EatInHomeEvent({
+ "targetNode": this.yukkuri.getPlace(),
+ "action": this,
+ "myYukkuri": this.yukkuri
+ });
+ },
move_to_eat_start : function(){
new MoveToEatEvent({
"type": 'food',
return ret;
},
callEvent: function(yukkuri){
- ununs = this.get(ESearch.UNUN);
- if(ununs.length !== 0){
+ if(yukkuri.isItemsMax() && yukkuri.isPlace()){
yukkuri.action.targetNode = yukkuri.getPlace();
- yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
+ yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
return;
}
if(yukkuri.isVeryKuhuku()){
return;
}
}
+ ununs = this.get(ESearch.UNUN);
+ if(ununs.length !== 0){
+ yukkuri.action.targetNode = yukkuri.getPlace();
+ yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
+ return;
+ }
var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
yukkuri.action.targetNode = searchYukkuri;
yukkuri.setFaceImage(EFace.NORMAL);
yukkuri.tlResume();
// self.action.setStatus(EAction.WAIT);
- if(this.data.nextStatus !== undefined){
- self.action.setStatus(this.data.nextStatus);
+ if(self.data.nextStatus !== undefined){
+ self.action.setStatus(self.data.nextStatus);
}else{
self.action.setStatus(EAction.THINK);
}
onactionend:function(self){
return function(e){
if(typeof e === "undefined")return;
- if(self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
+ if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
self.action.setStatus(EAction.THINK);
self.yukkuri.setFaceImage(EFace.NORMAL);
}else{
this.yukkuri.setFaceImage(EFace.HAPPY1);
}else{
if(this.yukkuri.isItemsMax()){
+ sec = 1;
this.huntingStatus = "return";
- mangMsg.output(this.yukkuri, EMsg.REHUNT);
+ // mangMsg.output(this.yukkuri, EMsg.REHUNT);
this.yukkuri.setFaceImage(EFace.NORMAL);
}else{
+ sec = BASE_FPS * 3;
this.huntingStatus = "cry";
mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
this.yukkuri.setFaceImage(EFace.CRY2);
if(self.huntingStatus == "hunting"){
if(self.yukkuri.isItemsMax()){
self.action.setStatus(EAction.MOVE_GOTO_HOME);
- mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
+ // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
}else{
self.action.setStatus(EAction.HUNT_START);
}
}
else if(self.huntingStatus == "return"){
- self.action.setStatus(EAction.THINK);
+ self.action.setStatus(EAction.MOVE_GOTO_HOME);
}
else if(self.huntingStatus === "cry"){
self.action.setStatus(EAction.THINK);
}
+ self.release();
};
+ },
+ release:function(){
+ this.action = null;
+ this.yukkuri = null;
+ this.food = null;
+ this.data = null;
}
});
var MoveGotoHomeEvent = enchant.Class.create(Event,{
this.action.setStatus(EAction.WAIT);
yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
+ // console.log("place.x:" + place.x);
+ // console.log("place.y:" + place.y);
+ // console.log("yukkuri.getX():" + yukkuri.getX());
+ // console.log("yukkuri.getY():" + yukkuri.getY());
+ // console.log("yukkuri.vx:" + yukkuri.vx);
+ // console.log("yukkuri.vy:" + yukkuri.vy);
var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
var frame = distance + distance/2 + 1 ;
frame += plusFrameScale(frame, this.yukkuri.getMyScale());
return function(e){
if(typeof e === "undefined")return;
self.action.setStatus(EAction.IN_HOME);
+ self.release();
};
+ },
+ release:function(){
+ this.action = null;
+ this.yukkuri = null;
+ this.data = null;
}
});
var InHomeEvent = enchant.Class.create(Event,{
var place = this.data.targetNode;
if(yukkuri.isVeryKuhuku()){
if(place.isFood()){
- new EatInHomeEvent({
- "targetNode": place,
- "action": this.action,
- "myYukkuri": yukkuri
- });
+ this.action.setStatus(EAction.EAT_IN_HOME);
return;
}else{
- mangMsg.output(self.yukkuri, EMsg.EAT_FAILED);
+ mangMsg.output(yukkuri, EMsg.EAT_FAILED);
}
}
this.action.setStatus(EAction.WAIT);
onactionend:function(self){
return function(e){
if(typeof e === "undefined")return;
- if(self.place.isFood() && self.yukkuri.isManpuku()){
-
- self.action.setStatus(EAction.THINK);
- self.yukkuri.setFaceImage(EFace.NORMAL);
+ if(self.place.isFood() && !self.yukkuri.isManpuku()){
+ self.action.setStatus(EAction.EAT_IN_HOME);
+
+ // new EatInHomeEvent({
+ // "targetNode": self.place,
+ // "action": self.action,
+ // "myYukkuri": self.yukkuri
+ // });
}else{
- new EatInHomeEvent({
- "targetNode": self.place,
- "action": self.action,
- "myYukkuri": self.yukkuri
- });
+ self.action.setStatus(EAction.THINK_IN_HOME);
+ self.yukkuri.setFaceImage(EFace.NORMAL);
}
};
}
this.image = game.assets[EResPath.GRASS];
this.frame = 0;
this.give = 10;
- this.amount = 2;
+ this.amount = 20;
}
this.x = x;
this.y = y;
this.x = x;
this.y = y;
backgroundMap.addChild(this);
- this.lifetime = 60 * 24 * 3;
+ this.lifetime = 30 * 24 * 3;
this.addEventListener('enterframe', this.runEnterframe(this));
// game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
backgroundMap.addChild(foodGroup);
// backgroundMap.addChild(placeGroup);
var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
- // 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 Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
+ 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 Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
// new Unun(100, 100);
// new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
var touchX = 0;