this.player = null;
this.objArray = {};
this.def = null;
+ this.objSprite = null;
+ this.mangTouch = null;
+ this.time = (HOUR * 24 + HOUR * 6) ;
+ this.min = 0;
+ this.hour = 0;
+ this.day = 0;
+ // this.popup = new GWindow(game.rootScene,0,0,100,100);
+ this.popup = new GPopup(game.rootScene,0,0,100,100);
+ // this.popup = new GWindow(this, {
+ // x: 0,
+ // y: 0,
+ // width: 100,
+ // height: 40,
+ // color: "#ff0000",
+ // });
+ // this.popup.opacity = 0;
+ },
+ calcTime:function(){
+ // var sec = ctl.time/BASE_FPS;
+ var sec = ctl.time/BASE_FPS;
+ this.min = Math.floor(sec % 60);
+ var _min = sec / 60;
+ this.hour = Math.floor(_min % 24);
+ this.day = Math.floor(_min / 24 % 30);
},
init : function (game){
this.game = game;
},
+ getDate : function(){
+ if(this.hour >= 5 && this.hour < 11)return EDate.MORNING;
+ if(this.hour >= 11 && this.hour < 13)return EDate.NOON;
+ if(this.hour >= 13 && this.hour < 17)return EDate.AFTERNOON;
+ if(this.hour >= 17 && this.hour < 20)return EDate.EVENING;
+ if(this.hour >= 20 && this.hour < 24)return EDate.NIGHT;
+ if(this.hour >= 0 && this.hour < 5)return EDate.MIDNIGHT;
+ },
setDefined:function(def){
this.def = def;
},
delete this.objArray[obj.id];
},
setMenuBg: function (menuBg){
- console.log("setMenuBg");
this.menuBg = menuBg;
},
setBackgroundMap: function(backgroundMap){
setPlayer: function(player){
this.player = player;
},
+ setTime: function(time){
+ this.time = time;
+ },
+ setCurrentObjSprite: function(objSprite){
+ this.objSprite = objSprite;
+ },
+ getCurrentObjSprite: function(objSprite){
+ return this.objSprite;
+ },
+ isCollision : function (e, node){
+ var ex = e.x - ctl.backgroundMap.x;
+ var ey = e.y - ctl.backgroundMap.y;
+ if(node.getX() <= ex && node.getX() + node.getWidth() >= ex
+ && node.getY() <= ey && node.getY() + node.getHeight() >= ey){
+ return true;
+ }
+ return false;
+ },
/**
* [setCurrentCommand description]
* @param {ECommand} cmd [description]
enchant.Sprite.call(this, x, y);
this.ecmd = ecmd;
this.index = index;
+ this.text = "";
},
isCurrent: function(){
return (this.index * 2)%2 !== 0;
this.frame = (this.index * 2);
}
});
+var ICON_TEXT = [
+"クリックアイコンです。\nフィールドのスクロールや\n各オブジェクトのステータスが見れます。",
+"命令アイコンです。\nプレイヤーゆっくりに\n移動命令を出せます。",
+"食物アイコンです。\nゆっくりが食べる\n食べ物を設置できます。",
+"家アイコンです。\nゆっくりが住む事のできる\nプレイスを設置できます。",
+"ゴミ箱アイコンです。\n配置したオブジェクトを削除できます。",
+"しつけアイコンです。\nゆっくりに対してアクションが出来ます。",
+];
var MangIcon = enchant.Class.create({
initialize: function (ctl, menuBg){
var self = this;
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(40, 40, value, index);
+ 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 = 40 * index;
- this.cmdIcons[value].y = 4;
-
+ 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;
+ this.cmdIcons[value].text = ICON_TEXT[value];
// odd equals current. even equals not current.
this.cmdIcons[value].frame = (this.ctl.getCurrentCommand() == value)? index * 2 + 1: index * 2;
menuBg.addChild(this.cmdIcons[value]);
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];
+ if(node === null || node === undefined)continue;
+ 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
+ ){
+ // new BoxLabel(this.ctl,100, e.x, e.y);
+ var box = new Box(this.ctl, node, e.x - ctl.backgroundMap.x, e.y - ctl.backgroundMap.y, 200, 200);
+ box.drawBox();
+ // var menuWindow = new MenuWindow(this.ctl, node, e.x, e.y, 300, 300);
+ // menuWindow.draw();
+ // new GWindow(game.rootScene,0,0,100,100);
+ // ctl.popup.renew(game.rootScene,640,0,100,100);
+ // ctl.popup.setText("aaaaaa");
+ // ctl.popup.drawText();
+ break;
+ }
+ }
+
},
touchmove : function(e){
var backgroundMap = this.ctl.backgroundMap;
touchend : function(e){
}
});
+/**
+ * プレイヤーゆっくりの移動を支持
+ */
var WorldTargetTouchEvent = enchant.Class.create(ATouchEvent,{
initialize: function (ctl){
this.ctl = ctl;
var backgroundMap = this.ctl.backgroundMap;
addEffect(this.ctl.backgroundMap, -backgroundMap.x + e.x, -backgroundMap.y + e.y);
this.ctl.player.tweet("ゆっくりりかいしたよ!");
- var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
- var vy = (-backgroundMap.y + e.y) - this.ctl.player.getY() ;
+ // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
+ // var vy = (-backgroundMap.y + e.y) - this.ctl.player.getY() ;
+ //移動先のx,y
+ //action status
+ //
+ ctl.player.cmdQueue.push(new CommandQueueObject({
+ touchX:(-backgroundMap.x + e.x),
+ touchY:(-backgroundMap.y + e.y),
+ date:ctl.getDate(),
+ actionStatus:EAction.MOVE_TO_COMMAND
+ }));
// this.ctl.player.action.setStatus(EAction.MOVE_TO_COMMAND);
// new MoveCommandEvent({
// "vx": vx,
var backgroundMap = this.ctl.backgroundMap;
var tx = -backgroundMap.x + e.x;
var ty = -backgroundMap.y + e.y;
- new ctl.def.Food("apple", tx, ty);
+ // new ctl.def.Food("apple", tx, ty);
+ new ctl.def.Food("grass", tx, ty);
+ }
+ }
+});
+var WorldPlaceTouchEvent = 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 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){
+ 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 this.ctl.def.Yukkuri)){
+ continue;
+ }
+ nx -= node.getWidth() / 2;
+ ny -= node.getHeight() / 2;
+ if( nx <= tx
+ && (nx + node.getWidth()) >= tx
+ && ny <= ty
+ && (ny + node.getHeight()) >= ty
+ ){
+ node.damage(EDamage.PICOHAN);
+
+ break;
+ }
+ }
+ }
+});
var MangTouch = enchant.Class.create({
initialize: function (ctl){
this.mang[ECommand.WORLD_CURSOR] = new WorldCursorTouchEvent(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){
return this.mang[ecmd];
"yukkuri" : {
label: null,
init: function(){
- var TEXT = M.LABEL_YUKKURI;
+ var TEXT = M.LABEL.YUKKURI;
var label = new Label(TEXT);
label.color = COLOR;
label.font = FONT;
"hungry" : {
label: null,
init: function(){
- var TEXT = M.LABEL_HUNGRY;
+ var TEXT = M.LABEL.HUNGRY;
var label = new Label(TEXT);
label.color = COLOR;
label.font = FONT;
"unun" : {
label: null,
init: function(){
- var TEXT = M.LABEL_UNUN;
+ var TEXT = M.LABEL.UNUN;
var label = new Label(TEXT);
label.color = COLOR;
label.font = FONT;
"sleep" : {
label: null,
init: function(){
- var TEXT = M.LABEL_SLEEP;
+ var TEXT = M.LABEL.SLEEP;
var label = new Label(TEXT);
label.color = COLOR;
label.font = FONT;
"stress" : {
label: null,
init: function(){
- var TEXT = M.LABEL_STRESS;
+ var TEXT = M.LABEL.STRESS;
var label = new Label(TEXT);
label.color = COLOR;
label.font = FONT;
labelGroup.addChild(labelObj.label);
}
menuBg.addChild(labelGroup);
+
+ //datetime
+ var dateLabel = new Label("時間");
+ dateLabel.color = COLOR;
+ dateLabel.font = FONT;
+ dateLabel.x = self.START_XPOS;
+ dateLabel.y = 4;
+ // dateLabel.textWidth = menuBg.image.context.measureText(TEXT).width;
+ dateLabel.addEventListener("enterframe", function(){
+ // console.log("min:" + ctl.min + ":" + ctl.hour + ":" + ctl.day);
+ this.text = "時間:" + ctl.day + "日 " + ctl.hour + ":" + ctl.min;
+ });
+ menuBg.addChild(dateLabel);
+
},
draw: function(yukkuriObj){
for(var key in this.labelParams){
var labelObj = this.labelParams[key];
labelObj.draw(yukkuriObj);
}
-
}
});
+var CommandQueueObject = enchant.Class.create({
+ initialize: function (_data){
+ this.touchX = _data.touchX;
+ this.touchY = _data.touchY;
+ this.date = _data.date;
+ this.actionStatus = _data.actionStatus;
+ }
+});
+
var MangMsg = enchant.Class.create({
initialize: function (ctl){
this.ctl = ctl;
},
- output:function(yukkuri, emsg){
+ output:function(yukkuri, emsg, targetYukkuri){
//var M = yukkuri.getMsg();
+ var myCode = yukkuri.myCode;
+ var mySize = yukkuri.mySize;
+ if(myCode === null || myCode === undefined){
+ myCode = "BASE";
+ mySize = "L";
+ }
+
if(emsg == EMsg.WALK){
if(rand(4) === 0){
- yukkuri.tweet(M.WALK1);
+ yukkuri.tweet(M.get(myCode,mySize,"WALK1"));
}
else if(rand(4) === 1){
- yukkuri.tweet(M.WALK2);
+ yukkuri.tweet(M.get(myCode,mySize,"WALK2"));
}
else if(rand(4) === 2){
- yukkuri.tweet(M.WALK3);
+ yukkuri.tweet(M.get(myCode,mySize,"WALK3"));
}
else if(rand(4) === 3){
- yukkuri.tweet(M.WALK4);
+ yukkuri.tweet(M.get(myCode,mySize,"WALK4"));
}
}
else if(emsg == EMsg.EAT){
if(rand(3) === 0){
- yukkuri.tweet(M.EAT1);
+ yukkuri.tweet(M.get(myCode,mySize,"EAT1"));
}
else if(rand(3) === 1){
- yukkuri.tweet(M.EAT2);
+ yukkuri.tweet(M.get(myCode,mySize,"EAT2"));
}
else if(rand(3) === 2){
- yukkuri.tweet(M.EAT3);
+ yukkuri.tweet(M.get(myCode,mySize,"EAT3"));
}
}
else if(emsg == EMsg.GET_UP){
- yukkuri.tweet(M.GET_UP1);
+ yukkuri.tweet(M.get(myCode,mySize,"GET_UP1"));
}
else if(emsg == EMsg.SLEEP){
- yukkuri.tweet(M.SLEEP1);
+ yukkuri.tweet(M.get(myCode,mySize,"SLEEP1"));
}
else if(emsg == EMsg.DEAD){
- yukkuri.tweet(M.DEAD1);
+ yukkuri.tweet(M.get(myCode,mySize,"DEAD1"));
}
else if(emsg == EMsg.UNUN){
if(rand(2) === 0){
- yukkuri.tweet(M.UNUN1);
+ yukkuri.tweet(M.get(myCode,mySize,"UNUN1"));
}else{
- yukkuri.tweet(M.UNUN2);
+ yukkuri.tweet(M.get(myCode,mySize,"UNUN2"));
}
}
else if(emsg == EMsg.UNUN_END){
- yukkuri.tweet(M.UNUN_END1);
+ yukkuri.tweet(M.get(myCode,mySize,"UNUN_END1"));
}
else if(emsg == EMsg.UNUN_SMELL){
- yukkuri.tweet(M.UNUN_SPELL1);
+ yukkuri.tweet(M.get(myCode,mySize,"UNUN_SPELL1"));
}
else if(emsg == EMsg.EAT_FAILED){
- yukkuri.tweet(M.EAT_FAILED1);
- }
- else if(emsg == EMsg.GREETING){
- yukkuri.tweet(M.GREETING1);
+ yukkuri.tweet(M.get(myCode,mySize,"EAT_FAILED1"));
}
+ else if(emsg == EMsg.SAY_HELLO){
+ if(yukkuri.getAddress(targetYukkuri) === null){
+ yukkuri.tweet(M.get(myCode,mySize,"SAY_HELLO1"));
+ }else{
+ yukkuri.tweet(M.get(myCode,mySize,"SAY_HELLO2"));
+ }
+ }
+ else if(emsg == EMsg.TARGETING_EAT){
+ yukkuri.tweet(M.get(myCode,mySize,"TARGETING_EAT1"));
+ }
+ else if(emsg == EMsg.DECLARE_PLACE){
+ yukkuri.tweet(M.get(myCode,mySize,"DECLARE_PLACE1"));
+ }
+ else if(emsg == EMsg.REHUNT){
+ yukkuri.tweet(M.get(myCode,mySize,"REHUNT1"));
+ }
+ else if(emsg == EMsg.HUNT_ESCAPE){
+ yukkuri.tweet(M.get(myCode,mySize,"HUNT_ESCAPE1"));
+ }
+ else if(emsg == EMsg.MOVE_GOTO_HOME){
+ yukkuri.tweet(M.get(myCode,mySize,"MOVE_GOTO_HOME1"));
+ }
+ else if(emsg == EMsg.YYUYYU){
+ if(rand(2) === 0){
+ yukkuri.tweet(M.get(myCode,mySize,"YYUYYU1"));
+ }else{
+ yukkuri.tweet(M.get(myCode,mySize,"YYUYYU2"));
+ }
+ }
+ else if(emsg == EMsg.HUNTING_MESSAGE){
+ var num = rand(6) + 1;
+ yukkuri.tweet(M.get(myCode,mySize,"HUNTING_MESSAGE" + num));
+ }
+ else if(emsg == EMsg.LEARN_NO_FOOD_IN_PLACE){
+ 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));
+ }
+ else if(emsg == EMsg.DAMAGE){
+ var num = rand(1) + 1;
+ yukkuri.tweet(M.get(myCode,mySize,"DAMAGE" + num));
+ }
}
});