var EResPath = {
YUKKURI_BASE : './data/yukkuri_base.png',
YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
+ YUKKURI_UNUN : './data/unun.png',
YUKKURI_SHADOW : './data/shadow.png',
MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
MOVE_TO_EAT_START: 10,
MOVE_TO_EAT_UNDERWAY: 11,
MOVE_TO_COMMAND: 12,
+ UNUN_START : 13,
+ UNUN_WAIT : 14,
+ UNUN_SMELL_START : 15,
+ UNUN_SMELL_WAIT : 16,
NONE: 9999
};
var EDirection = {
EAT: 2,
GET_UP: 3,
DEAD: 4,
+ UNUN: 5,
+ UNUN_END: 6,
+ UNUN_SMELL_START: 7,
+ SEARCH_FOOD: 8,
};
include("./lang/ja.js");
window.onload = function(){
act : function(){
this.observe();
switch(this.status){
+ case EAction.WAIT:
+
+ break;
case EAction.THINK:
if(this.yukkuri.age%2 === 0){
- this.yukkuri.param.yukkuri --;
- this.yukkuri.changeFace();
- this.search();
+ if(this.yukkuri.getUnun() >= 80){
+ this.setStatus(EAction.UNUN_START);
+ }else{
+ // this.yukkuri.param.yukkuri -= 1;
+ this.yukkuri.changeFace();
+ this.search();
+ }
+
}
break;
case EAction.MOVE_TO_EAT_START:
break;
case EAction.EAT_WAIT:
break;
+ case EAction.UNUN_START:
+ this.unun_start();
+ break;
+ case EAction.UNUN_WAIT:
+ break;
case EAction.MOVE_TO_COMMAND:
this.move_to_command();
break;
+ case EAction.UNUN_SMELL_START:
+ this.unun_smell_start();
+ break;
}
},
this.yukkuri.vy = 0;
}else{
// this.isMoving = true;
- var xpos = 150 - (retryCounter * 10);
- var ypos = 150 - (retryCounter * 10);
+ var xpos = 150 + rand(40) - (retryCounter * 10);
+ var ypos = 150 + rand(40) - (retryCounter * 10);
if(rand(8) === 0){
this.yukkuri.vx = 0;
this.yukkuri.vy = -ypos;
this.yukkuri.reverse();
this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
mangMsg.output(this.yukkuri,EMsg.WALK);
+ //うんうんくさい対策
+ this.targetNode = null;
}else{
// console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
this.walk(retryCounter+1);
});
},
+ unun_start: function(){
+ new UnunEvent({
+ "action": this,
+ "myYukkuri": this.yukkuri
+ });
+ },
+ unun_smell_start: function(){
+ new UnunSmellEvent({
+ "action": this,
+ "myYukkuri": this.yukkuri
+ });
+ },
move_to_command: function(){
},
search : function(){
var nodes = ctl.getObjs();
- // l = game.rootScene.childNodes.length;
- // l = game.rootScene.childNodes.length;
l = nodes.length;
- // for (var i = 0; i < l; i++) {
+ var ununFlg = false;
+
for (var key in nodes) {
var node = nodes[key];
- if (node instanceof Food) {
+ if (!ununFlg
+ && node instanceof Unun
+ && !(this.targetNode instanceof Unun)
+ && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
+ ununFlg = true;
+ this.targetNode = node;
+ this.setStatus(EAction.UNUN_SMELL_START);
+ return;
+ }
+ else if (node instanceof Food) {
if(this.yukkuri.isKuhuku() && this.yukkuri.within(node, this.yukkuri.getRange())){
//A yukkuri to go to the food area
};
}
});
+ var UnunEvent = enchant.Class.create(Event,{
+ initialize: function (_data){
+ this.data = _data;
+ this.yukkuri = _data.myYukkuri;
+ this.action = _data.action;
+ this.action.setStatus(EAction.UNUN_WAIT);
+ mangMsg.output(this.yukkuri, EMsg.UNUN);
+ this.yukkuri.setFaceImage(EFace.HAPPY2);
+ var sec = FPS * 3;
+
+ this.yukkuri.wait(sec, {
+ "onactionstart": this.onactionstart(this),
+ "onactiontick": this.onactiontick(this),
+ "onactionend": this.onactionend(this)
+ });
+ },
+ onactionstart:function(self){
+ return function(e){
+ if(typeof e === "undefined")return;
+ };
+ },
+ onactiontick:function(self){
+ return function(e){
+ if(typeof e === "undefined")return;
+ };
+ },
+ onactionend:function(self){
+ return function(e){
+ if(typeof e === "undefined")return;
+ self.yukkuri.unun();
+ self.action.setStatus(EAction.WAIT);
+ mangMsg.output(self.yukkuri, EMsg.UNUN_END);
+ new WaitEvent({
+ "waitframe": FPS * 1.5,
+ "action": self.action,
+ "myYukkuri": self.yukkuri
+ });
+ };
+ }
+ });
+ var WaitEvent = enchant.Class.create(Event,{
+ initialize: function (_data){
+ this.data = _data;
+ this.yukkuri = _data.myYukkuri;
+ this.action = _data.action;
+ this.waitframe = _data.waitframe;
+ this.yukkuri.wait(this.waitframe, {
+ "onactionstart": this.onactionstart(this),
+ "onactiontick": this.onactiontick(this),
+ "onactionend": this.onactionend(this)
+ });
+ },
+ onactionend:function(self){
+ return function(e){
+ if(typeof e === "undefined")return;
+ self.action.setStatus(EAction.THINK);
+ };
+ }
+ });
+ var UnunSmellEvent = enchant.Class.create(Event,{
+ initialize: function (_data){
+ this.data = _data;
+ this.yukkuri = _data.myYukkuri;
+ this.action = _data.action;
+ this.action.setStatus(EAction.UNUN_SMELL_WAIT);
+ mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
+ this.yukkuri.setFaceImage(EFace.CRY1);
+ var sec = FPS * 3;
+ this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
+ this.yukkuri.wait(sec, {
+ "onactionstart": this.onactionstart(this),
+ "onactiontick": this.onactiontick(this),
+ "onactionend": this.onactionend(this)
+ });
+ },
+ onactionend:function(self){
+ return function(e){
+ if(typeof e === "undefined")return;
+ self.action.setStatus(EAction.THINK);
+ };
+ }
+ });
var EatEvent = enchant.Class.create(Event,{
initialize: function (_data){
onactionstart:function(self){
return function(e){
if(typeof e === "undefined")return;
- console.log("moveEvent onactionstart");
self.yukkuri.tweet("ゆゆ??\nたべものさん\nはっけんなのぜ!");
};
},
//一つにつきgiveの値分、hunguryを減少させられる
this.give = 40;
this.amount = 3;
- // backgroundMap.addChild(this);
foodGroup.addChild(this);
this.addEventListener('enterframe', function(){
if(this.amount <= 0){
return this.give;
}
});
+ var Unun = enchant.Class.create(ObjSprite,{
+ initialize: function (x, y){
+ this.classname = "Unun";
+ ObjSprite.call(this,32,32);
+ this.image = game.assets[EResPath.YUKKURI_UNUN];
+ this.x = x;
+ this.y = y;
+ backgroundMap.addChild(this);
+ }
+ });
var Okazari = enchant.Class.create(enchant.Sprite,{
initialize: function(){
this.classname = "Okazari";
},
runEnterframe:function(){
this.act();
+ if(this.isDead())return;
this.runYukkuri();
this.runHungry();
+ this.runUnun();
this.runSleep();
},
reverse:function(){
// this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
// this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
},
+ getWidth: function(){
+ return this.width;
+ },
+ getHeight: function(){
+ return this.height;
+ },
getX: function(){
return this.imgGroup.x;
},
if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
if(this.param.hungry >= 100)this.param.hungry = 100;
},
+ runUnun: function(){
+ if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
+ if(this.param.unun >= 100)this.param.unun = 100;
+ },
runSleep: function(){
if(!this.isSleeping){
if(this.age%100 === 0 && this.age !== 0)this.param.sleep++;
isKuhuku: function(){
return this.param.hungry >= 40;
},
+ getYukkuri: function(){
+ return this.param.yukkuri;
+ },
+ setYukkuri: function(yukkuri){
+ this.param.yukkuri = yukkuri;
+ if(this.param.yukkuri < 0)this.param.yukkuri = 0;
+ },
getHungry: function(){
return this.param.hungry;
},
this.param.hungry = hungry;
if(this.param.hungry < 0)this.param.hungry = 0;
},
+ getUnun: function(){
+ return this.param.unun;
+ },
+ setUnun: function(unun){
+ this.param.unun = unun;
+ if(this.param.unun < 0)this.param.unun = 0;
+ },
+
eat:function(food){
food.amount--;
this.setHungry(this.param.hungry - food.getGive());
+ this.setUnun(this.getUnun() + food.getGive() / 4);
+ this.setYukkuri(this.getYukkuri() + 5);
+ },
+ unun:function(){
+ if(this.direction == EDirection.RIGHT){
+ new Unun(this.getX(), this.getY() + this.getHeight()/5 );
+ }else{
+ new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
+ }
+ this.setUnun(0);
},
setBodyImage: function(ebody){
var path = this.bodyStatus[ebody];