THINK : 4,
WALK : 5,
DEAD: 6,
+ MOVE: 7
};
var EDirection = {
LEFT : 0,
this.yukkuri = yukkuri;
this.isMoving = false;
},
- act : function(){
- // console.log(this.yukkuri);
+ observe: function(){
if(this.yukkuri.isDead()){
this.status = EAction.DEAD;
}
+ if(this.yukkuri.isSleep()){
+ this.status = EAction.SLEEP;
+ }
+
+ },
+ act : function(){
+ this.observe();
switch(this.status){
case EAction.THINK:
// this.status = EAction.WALK;
this.search();
}
break;
+ case EAction.MOVE:
+ this.move();
+ break;
//Random Walk
case EAction.WALK:
this.walk(0);
break;
+ case EAction.SLEEP:
+ this.sleep();
+ break;
case EAction.DEAD:
this.dead();
break;
}
},
+ move : function(){
+
+ },
walk : function(retryCounter){
if(retryCounter > 15){
retryCounter = 0;
}
}
},
+ sleep: function(){
+ var yukkuri = this.yukkuri;
+
+ if(yukkuri.isSleeping){
+ if(yukkuri.age%10 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
+ if(yukkuri.param.sleep <= 0){
+ yukkuri.param.sleep = 0;
+ yukkuri.isSleeping = false;
+ yukkuri.tweet("ゆっくりおきるよ!");
+ this.status = EAction.THINK;
+ }
+ }
+ },
dead : function(){
this.yukkuri.tweet("もっとゆっくりしたかった…");
this.yukkuri.imgBody.tl.clear();
// this.yukkuri.imgGroup.tl.removeFromScene();
},
search : function(){
- this.status = EAction.WALK;
if(true)return;
for (var i = 0, l = game.rootScene.childNodes.length; i < l; i++) {
var node = game.rootScene.childNodes[i];
if (node instanceof Food) {
if(this.yukkuri.within(node, this.yukkuri.range)){
- // console.log("yes:");
+ //A yukkuri to go to the food area
+ this.status = EAction.MOVE;
+ new MoveEvent({
+ "type": 'food',
+ "targetNode": node,
+ "myYukkuri": this.yukkuri
+ });
}else{
// console.log("no:");
}
}
}
+ this.status = EAction.WALK;
+ }
+ });
+ var MoveEvent = enchant.Class.create({
+ initialize: function (dataObj){
+ this.move
}
+
});
var Food = enchant.Class.create(enchant.Sprite,{
initialize: function (type, x, y){
this.image = game.assets[EResPath.YUKKURI_BASE];
this.direction = EDirection.RIGHT;
this.addEventListener('enterframe', this.runEnterframe);
+ this.isSleeping = false;
},
runEnterframe:function(){
this.runYukkuri();
if(this.age%100 === 0 && this.age !== 0)this.param.hungry++;
if(this.param.hungry >= 100)this.param.hungry = 100;
},
+ runSleep: function(){
+ if(!this.isSleeping){
+ if(this.age%100 === 0 && this.age !== 0)this.param.sleep++;
+ if(this.param.sleep >= 100){
+ this.param.sleep = 100;
+ this.isSleeping = true;
+ }
+
+ }
+ },
+ isSleep: function(){
+ return this.isSleeping;
+ },
isDead: function(){
return this.param.yukkuri <= 0;
},