this.currentCommand = ECommand.WORLD_CURSOR;
this.backgroundMap = null;
this.player = null;
- this.objArray = [];
+ this.objArray = {};
this.def = null;
this.objSprite = null;
this.mangTouch = null;
delete this.objArray[obj.id];
},
setMenuBg: function (menuBg){
- console.log("setMenuBg");
this.menuBg = menuBg;
},
setBackgroundMap: function(backgroundMap){
this.ctl = ctl;
this.cmdIcons = [];
var index = 0;
+ var POS_NUMBER = 4;
+ var HEIGHT_TOP_MARGIN = 2;
for (var key in ECommand) {
var value = ECommand[key];
this.cmdIcons[value] = new CommandIcon(ICON_WIDTH, ICON_HEIGHT, value, index);
this.cmdIcons[value].image = this.ctl.game.assets[EResPath.COMMAND];
- this.cmdIcons[value].x = ICON_WIDTH * index + 5;
- this.cmdIcons[value].y = ICON_HEIGHT + 2;
+ this.cmdIcons[value].x = ICON_WIDTH * (index%POS_NUMBER) + 5;
+ var yindex = parseInt(index/POS_NUMBER) + 1;
+ this.cmdIcons[value].y = ICON_HEIGHT * yindex + HEIGHT_TOP_MARGIN;
// odd equals current. even equals not current.
this.cmdIcons[value].frame = (this.ctl.getCurrentCommand() == value)? index * 2 + 1: index * 2;
var tx = this.touchX;
var ty = this.touchY;
var nodes = this.ctl.getObjs();
- nodes.sort(ctl.def.nodeSort);
+
+ // nodes.sort(ctl.def.nodeSort);
for (var id in nodes) {
var node = nodes[id];
+ if(node === null || node === undefined)continue;
var nx = node.getX();
var ny = node.getY();
if(node == null)continue;
}
});
+var WorldRemoveTouchEvent = enchant.Class.create(ATouchEvent,{
+ initialize: function (ctl){
+ this.ctl = ctl;
+ this.touchX = 0;
+ this.touchY = 0;
+ },
+ touchstart :function(e){
+ this.touchX = e.x - this.ctl.backgroundMap.x;
+ this.touchY = e.y - this.ctl.backgroundMap.y;
+ var tx = this.touchX;
+ var ty = this.touchY;
+ var nodes = this.ctl.getObjs();
+ // nodes.sort(ctl.def.nodeSort);
+ for (var id in nodes) {
+ var node = nodes[id];
+ var nx = node.getX();
+ var ny = node.getY();
+ if(node == null)continue;
+ // if(node instanceof Box
+ // || node instanceof this.ctl.def.Food
+ // || node instanceof this.ctl.def.Unun
+ // ){
+ // continue;
+ // }
+ if(node instanceof this.ctl.def.Yukkuri){
+ nx -= node.getWidth() / 2;
+ ny -= node.getHeight() / 2;
+ }
+ if( nx <= tx
+ && (nx + node.getWidth()) >= tx
+ && ny <= ty
+ && (ny + node.getHeight()) >= ty
+ ){
+ if(node instanceof this.ctl.def.Yukkuri){
+ mangMsg.output(node, EMsg.REMOVE_YUKKURI);
+ node.setFaceImage(EFace.CRY1);
+ }
+ else if(node instanceof this.ctl.def.Place){
+ node.removeAll();
+ }
+ else{
+ node.removeAll();
+ node.undefineAll();
+ }
+
+ break;
+ }
+ }
+ }
+});
+var WorldPicoPicoHummerTouchEvent = enchant.Class.create(ATouchEvent,{
+ initialize: function (ctl){
+ this.ctl = ctl;
+ this.touchX = 0;
+ this.touchY = 0;
+ },
+ touchstart :function(e){
+ // if(e.x >= 0 && e.x <= EFieldPos.WIDTH){
+ // var backgroundMap = this.ctl.backgroundMap;
+ // var tx = -backgroundMap.x + e.x;
+ // var ty = -backgroundMap.y + e.y;
+ // new ctl.def.Place("tree", tx, ty);
+ // }
+ }
+});
var MangTouch = enchant.Class.create({
initialize: function (ctl){
this.mang[ECommand.WORLD_TARGET] = new WorldTargetTouchEvent(ctl);
this.mang[ECommand.WORLD_APPLE] = new WorldAppleTouchEvent(ctl);
this.mang[ECommand.WORLD_PLACE] = new WorldPlaceTouchEvent(ctl);
+ this.mang[ECommand.WORLD_REMOVE] = new WorldRemoveTouchEvent(ctl);
+ this.mang[ECommand.WORLD_PICOPICO_HUMMER] = new WorldPicoPicoHummerTouchEvent(ctl);
ctl.mangTouch = this;
},
get: function(ecmd){
var num = 1;
yukkuri.tweet(M.get(myCode,mySize,"LEARN_NO_FOOD_IN_PLACE" + num));
}
+ else if(emsg == EMsg.REMOVE_YUKKURI){
+ var num = 1;
+ yukkuri.tweet(M.get(myCode,mySize,"REMOVE_YUKKURI" + num));
+ }
+ else if(emsg == EMsg.LOST_HOUSE){
+ var num = 1;
+ yukkuri.tweet(M.get(myCode,mySize,"LOST_HOUSE" + num));
+ }
+ else if(emsg == EMsg.MOVE_TO_HUNTING){
+ var num = 1;
+ yukkuri.tweet(M.get(myCode,mySize,"MOVE_TO_HUNTING" + num));
+ }
}
});
//////////////////////////////////////
//define
//////////////////////////////////////
+var ADD_HUNGRY = 1;
var PALYER_INIT_X = 100;
var PALYER_INIT_Y = 100;
var CHARA_WIDTH = 64;
WORLD_TARGET: 1,
WORLD_APPLE: 2,
WORLD_PLACE: 3,
+ WORLD_REMOVE: 4,
+ WORLD_PICOPICO_HUMMER: 5,
};
var EMenuPos = {
MOVE_GOTO_HOME:17,
HUNTING_MESSAGE:18,
LEARN_NO_FOOD_IN_PLACE:19,
+ REMOVE_YUKKURI:20,
+ LOST_HOUSE:21,
+ MOVE_TO_HUNTING:22,
+
};
var EWalkAnimation = {
START: 0,
getHeight: function(){
return this.height;
},
+ isWorld: function(){
+ return (this.id !== null && this.id !== undefined);
+ },
removeAll: function(){
this.remove();
ctl.removeObj(this);
+ this.id = null;
+ },
+ undefineAll: function (){
+ for(var key in this){
+ // if(this.hasOwnProperty(key)){
+ delete this[key];
+ // }
+ }
}
});
},
act : function(){
-
this.observe();
switch(this.status){
case EAction.WAIT:
this.communicate_start();
break;
case EAction.COMMUNICATE_WAIT:
- break;
case EAction.COMMUNICATE_RECV:
+ if(this.yukkuri.communicateYukkuri != null){
+ var _s = this.yukkuri.communicateYukkuri.action.getStatus();
+ if(this.yukkuri.communicateYukkuri.isDead()
+ || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
+ this.setStatus(EAction.THINK);
+ this.yukkuri.animation();
+ }
+ }
break;
case EAction.MOVE_TO_PLACE_START_HOMELESS:
this.move_to_place_start_homeless();
},
in_home:function(){
var place = this.yukkuri.getPlace();
- new InHomeEvent({
- "type": 'hunt_end',
- "targetNode": place,
- "action": this,
- "myYukkuri": this.yukkuri
- });
+ if(place != null && place.isWorld()){
+ new InHomeEvent({
+ "type": 'hunt_end',
+ "targetNode": place,
+ "action": this,
+ "myYukkuri": this.yukkuri
+ });
+ }else{
+ if(place && !place.isWorld())place.undefineAll();
+ this.yukkuri.declarePlace(null);
+ this.setStatus(EAction.WAIT);
+ mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
+ this.yukkuri.setFaceImage(EFace.CRY2);
+ new WaitEvent({
+ "waitframe": FPS * 3.0,
+ "action": this,
+ "myYukkuri": this.yukkuri
+ });
+ }
},
move_to_command: function(){
var obj = this.yukkuri.searchObjectMang.currentCmdObject;
var ununFlg = false;
for (var key in nodes) {
var node = nodes[key];
+ if(node === null || node === undefined)continue;
if(this.yukkuri.id === node.id)continue;
//うんうん臭いを検索
if (
return;
}
- if(foods.length === 0 && yukkuri.isPlace()){
- //家があるなら家に帰宅
+ //家があるなら家に帰宅
+ if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
yukkuri.action.targetNode = yukkuri.getPlace();
yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
return;
- }else{
}
+ //たべものを探しに行く
+ yukkuri.action.setStatus(EAction.WALK);
+ return;
}
if(yukkuri.isSleep()){
onactionend:function(self){
return function(e){
if(typeof e === "undefined")return;
- if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
+ if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
self.action.setStatus(EAction.THINK);
self.yukkuri.setFaceImage(EFace.NORMAL);
}else{
frame += plusFrameScale(frame, this.yukkuri.getMyScale());
yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
yukkuri.reverse();
+ mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
- "onactionstart": this.onactionstart(this),
"onactiontick": this.onactiontick(this),
"onactionend": this.onactionend(this)
});
}
},
- onactionstart:function(self){
- return function(e){
- if(typeof e === "undefined")return;
- mangMsg.output(self.yukkuri, EMsg.TARGETING_EAT);
- };
- },
onactiontick:function(self){
return function(e){
if(typeof e === "undefined")return;
frame += plusFrameScale(frame, this.yukkuri.getMyScale());
yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
yukkuri.reverse();
- mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
+ mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
"onactionend": this.onactionend(this)
this.action.setStatus(EAction.WAIT);
this.huntingStatus = "hunting";
this.tick = 0;
- this.yukkuri.beforeHuntingFood = this.food;
- var sec = BASE_FPS * 8;
- if(this.yukkuri.hunt(this.food)){
- this.huntingStatus = "hunting";
- mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
- this.yukkuri.setFaceImage(EFace.HAPPY1);
- }else{
- if(this.yukkuri.isItemsMax()){
- sec = 1;
- this.huntingStatus = "return";
- // mangMsg.output(this.yukkuri, EMsg.REHUNT);
- this.yukkuri.setFaceImage(EFace.NORMAL);
+ // this.yukkuri.beforeHuntingFood = this.food;
+ if(this.food.isWorld()){
+ this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
+ var sec = BASE_FPS * 8;
+ if(this.yukkuri.hunt(this.food)){
+ this.huntingStatus = "hunting";
+ mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
+ this.yukkuri.setFaceImage(EFace.HAPPY1);
}else{
- sec = BASE_FPS * 3;
- this.huntingStatus = "cry";
- mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
- this.yukkuri.setFaceImage(EFace.CRY2);
+ if(this.yukkuri.isItemsMax()){
+ sec = 1;
+ this.huntingStatus = "return";
+ // 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);
+ }
}
+
+ }else{
+ this.yukkuri.beforeHuntingFood = null;
+ sec = BASE_FPS * 3;
+ this.huntingStatus = "cry";
+ mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
+ this.yukkuri.setFaceImage(EFace.CRY2);
}
this.yukkuri.wait(sec, {
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());
this.targetYukkuri = _data.targetNode;
this.action = _data.action;
this.action.setStatus(EAction.COMMUNICATE_WAIT);
+ // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
+ // this.targetYukkuri.tlPause();
mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
+ this.yukkuri.send(this.targetYukkuri, {
+ "actionStatus":EAction.COMMUNICATE_RECV,
+ "yukkuri":this.yukkuri
+ });
- this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
- this.targetYukkuri.tlPause();
this.yukkuri.tlPause();
this.yukkuri.syncDirection(this.targetYukkuri);
return this.give;
}
});
+ var MemoryPlace = enchant.Class.create({
+ // initialize: function (place){
+ // if(place.x != null){
+ // this.isWorld = true;
+ // }else{
+ // this.isWorld = false;
+ // }
+ // this.isWorld = (place.x != null);
+ // this.x = place.x;
+ // this.y = place.y;
+ // this.width = place.width;
+ // this.height = place.height;
+ // },
+ // isWorld: function(){
+ // return this.isWorld;
+ // }
+
+ });
+ var MemoryFood = enchant.Class.create({
+ initialize: function (food){
+ if(food.x != null){
+ this.isWorld = true;
+ }else{
+ this.isWorld = false;
+ }
+ this.isWorld = (food.x != null);
+ this.x = food.x;
+ this.y = food.y;
+ this.width = food.width;
+ this.height = food.height;
+ },
+ isWorld: function(){
+ return this.isWorld;
+ }
+ });
var Place = enchant.Class.create(ObjSprite,{
initialize: function (type, x, y){
ObjSprite.call(this,128,128);
this.x = x;
this.y = y;
backgroundMap.addChild(this);
- this.lifetime = 30 * 24 * 3;
+ // this.lifetime = 30 * 24 * 3;
+ this.lifetime = 15 * 24;
this.addEventListener('enterframe', this.runEnterframe(this));
// game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
};
}
- // runEnterframe: function(){
- // console.log("enterframe:" + this.id);
- // }
});
var Okazari = enchant.Class.create(enchant.Sprite,{
initialize: function(yukkuri){
this.exLvHash = {};
this.exValueHash = {};
this.memoryHash = {};
+ this.communicateYukkuri = {};
for(var _v in EExSkill){
var key = EExSkill[_v];
this.exLvHash[key] = 0;
else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
},
runHungry: function(){
- if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
+ if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
if(this.param.hungry >= 100)this.param.hungry = 100;
},
runUnun: function(){
this.shadow.scale(_scaleX, _scaleY);
},
send: function(targetYukkuri, object, callback){
+ this.communicateYukkuri = targetYukkuri;
targetYukkuri.recv(object, callback);
},
recv: function(object, callback){
- this.actionQueue.push({
- object : object,
- actionStatus : EAction.COMMUNICATE_RECV,
- callback: callback
- });
+ this.communicateYukkuri = object.yukkuri;
+ this.tlPause();
+ this.action.setStatus(object.actionStatus);
+
+ // this.actionQueue.push({
+ // object : object,
+ // callback: callback
+ // });
},
addExValue: function(eexskill, plus){
this.exValueHash[eexskill] += plus;
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 Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
- 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);
+ // 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);
// new Unun(100, 100);
// new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
var touchX = 0;