this.currentCommand = ECommand.WORLD_CURSOR;
this.backgroundMap = null;
this.player = null;
- this.objArray = [];
+ this.objArray = {};
this.def = null;
this.objSprite = null;
this.mangTouch = null;
- this.time = HOUR * 24 + HOUR * 6;
+ 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;
delete this.objArray[obj.id];
},
setMenuBg: function (menuBg){
- console.log("setMenuBg");
this.menuBg = menuBg;
},
setBackgroundMap: function(backgroundMap){
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]);
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;
if(node instanceof Box
|| node instanceof this.ctl.def.Food
+ || node instanceof this.ctl.def.Unun
){
continue;
}
// 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;
}
}
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 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_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){
dateLabel.color = COLOR;
dateLabel.font = FONT;
dateLabel.x = self.START_XPOS;
- dateLabel.y = GAME_HEIGHT - 30;
+ dateLabel.y = 4;
// dateLabel.textWidth = menuBg.image.context.measureText(TEXT).width;
dateLabel.addEventListener("enterframe", function(){
// console.log("min:" + ctl.min + ":" + ctl.hour + ":" + ctl.day);
}
}
});
+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;
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{
else if(emsg == EMsg.DECLARE_PLACE){
yukkuri.tweet(M.get(myCode,mySize,"DECLARE_PLACE1"));
}
- else if(emsg == EMsg.HUNT){
- yukkuri.tweet(M.get(myCode,mySize,"HUNT1"));
- }
else if(emsg == EMsg.REHUNT){
yukkuri.tweet(M.get(myCode,mySize,"REHUNT1"));
}
yukkuri.tweet(M.get(myCode,mySize,"MOVE_GOTO_HOME1"));
}
else if(emsg == EMsg.YYUYYU){
- yukkuri.tweet(M.get(myCode,mySize,"YYUYYU1"));
+ 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));
}
}