2 //////////////////////////////////////
4 CanvasLayer初期化後にcanvasのコンテキストを操作する
6 // var initCanvas = CanvasLayer.prototype.initialize;
8 // CanvasLayer.prototype.initialize = function() {
9 // initCanvas.call(this);
10 // console.log("canvas");
12 // // 拡大時の処理をNearest Neighbor方式に切り替え
13 // // ただしChromeとFireFoxでのみ動作
14 // this.context.imageSmoothingEnabled = false;
15 // this.context.webkitImageSmoothingEnabled = false;
16 // this.context.mozImageSmoothingEnabled = false;
24 var LabelGroup = enchant.Class.mixClasses(Label, Group,true);
26 //////////////////////////////////////
28 //////////////////////////////////////
30 var PALYER_INIT_X = 100;
31 var PALYER_INIT_Y = 100;
33 var CHARA_HEIGHT = 64;
35 var GAME_HEIGHT = 600;
42 // var DAY = HOUR * 24;
44 var GAME_START_TIME = HOUR * 6;
50 YUKKURI_BASE : './data/yukkuri_base.png',
51 YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
52 YUKKURI_UNUN : './data/unun.png',
53 YUKKURI_SHADOW : './data/shadow.png',
54 MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
55 MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
56 MARISA_FACE_ANGRY : './data/marisa/face_angry1.png',
57 MARISA_FACE_CRY1 : './data/marisa/face_cry1.png',
58 MARISA_FACE_CRY2 : './data/marisa/face_cry2.png',
59 MARISA_FACE_EAT1 : './data/marisa/face_eat1.png',
60 MARISA_FACE_EAT2 : './data/marisa/face_eat2.png',
61 MARISA_FACE_HAPPY1 : './data/marisa/face_happy1.png',
62 MARISA_FACE_HAPPY2 : './data/marisa/face_happy2.png',
63 MARISA_FACE_SLEEP : './data/marisa/face_sleep1.png',
64 MARISA_HEAR : './data/marisa/hear1.png',
65 MARISA_OKAZARI : './data/marisa/okazari.png',
66 OBJECT : './data/object.png',
67 MAP0 : './data/map0.png',
68 COMMAND : './data/command.png',
69 PLACE_TREE : './data/system/place_tree.png',
70 GRASS : './data/system/grass.png',
71 PLAYER_BADGE : './data/system/player_badge.png',
72 // PLACE_TREE : './data/system/rapture.png',
78 FACE_NORMAL : './data/reimu/face_normal1.png',
79 FACE_TIRED : './data/reimu/face_tired1.png',
80 FACE_ANGRY : './data/reimu/face_angry1.png',
81 FACE_CRY1 : './data/reimu/face_cry1.png',
82 FACE_CRY2 : './data/reimu/face_cry2.png',
83 FACE_EAT1 : './data/reimu/face_eat1.png',
84 FACE_EAT2 : './data/reimu/face_eat2.png',
85 FACE_HAPPY1 : './data/reimu/face_happy1.png',
86 FACE_HAPPY2 : './data/reimu/face_happy2.png',
87 FACE_SLEEP : './data/reimu/face_sleep1.png',
88 HEAR : './data/reimu/hear1.png',
89 OKAZARI : './data/reimu/okazari.png',
90 SUB1 : './data/reimu/sub1.png',
117 WORLD_PICOPICO_HUMMER: 5,
124 HEIGHT : GAME_HEIGHT,
130 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
141 MOVE_TO_EAT_START: 10,
142 MOVE_TO_EAT_UNDERWAY: 11,
146 UNUN_SMELL_START : 15,
147 UNUN_SMELL_WAIT : 16,
150 COMMUNICATE_START : 19,
151 COMMUNICATE_WAIT: 20,
152 COMMUNICATE_RECV: 21,
153 MOVE_TO_PLACE_START_HOMELESS: 22,
154 MOVE_TO_PLACE_HOMELESS_UNDERWAY: 23,
155 DECLARE_PLACE_HOMELESS: 24,
156 MOVE_TO_HUNT_START: 25,
189 LEARN_NO_FOOD_IN_PLACE:19,
196 var EWalkAnimation = {
226 NO_FOOD_IN_PLACE : 1,
235 var ObjSprite = enchant.Class.create(enchant.Sprite,{
236 initialize: function (w, h){
237 enchant.Sprite.call(this, w, h);
240 // // new BoxLabel(this.ctl,100, e.x, e.y);
241 // var box = new Box(this.ctl, 200, 200);
242 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
244 getStatusForDisplay: function (){
253 getWidth: function(){
256 getHeight: function(){
260 return (this.id !== null && this.id !== undefined);
262 removeAll: function(){
267 undefineAll: function (){
268 for(var key in this){
269 // if(this.hasOwnProperty(key)){
277 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
288 //-Event register [onactionstart,onactiontick,onactionend]
289 if(eventFunctions !== undefined){
290 for(var key in eventFunctions){
291 params[key] = eventFunctions[key];
294 return this.tween(params);
296 function plusFrameScale(frame, scale){
297 return (frame/2) * (1 - scale)
302 include("./lang/ja.js");
303 window.onload = function(){
304 var nodeSort = function (a, b){
305 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
308 else if(typeof a.id === "undefined"){
311 else if(typeof b.id === "undefined"){
316 if(a instanceof Box && b instanceof Box){
319 if(a instanceof Box){
322 if(b instanceof Box){
325 if(a instanceof SpriteGroup){
329 if(b instanceof SpriteGroup){
334 if(a instanceof Place){
335 ay += Math.round(a.height * 0.7);
337 if(b instanceof Place){
338 by += Math.round(b.height * 0.7);
341 if(ay < by)return -1;
342 else if(ay > by)return 1;
343 if(a.id < b.id)return -1;
344 else if(a.id > b.id)return 1;
350 var def = new Object();
351 var foodGroup = new Group();
352 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
353 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
354 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
355 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
356 game = new Game(GAME_WIDTH, GAME_HEIGHT);
360 var tmpName = EResPathReimu.getName();
362 for(var _v in EResPathReimu){
363 if(typeof EResPathReimu[_v] === "function")continue;
364 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
370 for(var _v in EResPath){
371 _loadArr[i] = EResPath[_v];
374 game.preload(_loadArr);
375 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
376 var backgroundMap = new MapGroup(16, 16);
377 include("./class.js");
378 include("./ctrl.js");
381 ctl.setBackgroundMap(backgroundMap);
382 var Action = enchant.Class.create({
383 initialize: function (yukkuri){
384 this.status = EAction.THINK;
385 this.yukkuri = yukkuri;
386 this.isMoving = false;
387 this.targetNode = null;
389 getStatus: function(){
392 setStatus: function(eaction){
393 this.status = eaction;
396 if(this.yukkuri.isDead()){
397 this.status = EAction.DEAD;
399 // else if(this.yukkuri.isSleep()){
400 // this.status = EAction.SLEEP;
409 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
411 this.setStatus(EAction.THINK);
412 console.log("wait cnt end");
415 case EAction.THINK_IN_HOME:
418 this.think_in_home();
420 case EAction.EAT_IN_HOME:
425 if(this.yukkuri.age%2 === 0){
426 this.yukkuri.changeFace();
428 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
431 case EAction.MOVE_TO_EAT_START:
432 this.move_to_eat_start();
434 case EAction.MOVE_TO_EAT_UNDERWAY:
440 case EAction.SLEEP_START:
443 case EAction.SLEEP_WAIT:
448 case EAction.EAT_START:
451 case EAction.EAT_WAIT:
453 case EAction.UNUN_START:
456 case EAction.UNUN_WAIT:
458 case EAction.MOVE_TO_COMMAND:
459 this.move_to_command();
461 case EAction.UNUN_SMELL_START:
462 this.unun_smell_start();
464 case EAction.COMMUNICATE_START:
465 this.communicate_start();
467 case EAction.COMMUNICATE_WAIT:
468 case EAction.COMMUNICATE_RECV:
469 if(this.yukkuri.communicateYukkuri != null){
470 var _s = this.yukkuri.communicateYukkuri.action.getStatus();
471 if(this.yukkuri.communicateYukkuri.isDead()
472 || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
473 this.setStatus(EAction.THINK);
474 this.yukkuri.animation();
478 case EAction.MOVE_TO_PLACE_START_HOMELESS:
479 this.move_to_place_start_homeless();
481 case EAction.DECLARE_PLACE_HOMELESS:
482 this.declare_place_homeless();
484 case EAction.MOVE_TO_HUNT_START:
485 this.move_to_hunt_start();
487 case EAction.HUNT_START:
490 case EAction.MOVE_GOTO_HOME:
491 this.move_goto_home();
493 case EAction.IN_HOME:
498 this.yukkuri.reverse();
500 // thinkHavePlace: function(){
501 // var date = ctl.getDate();
502 // if(this.yukkuri.isPlaceRange()){
505 // if(date === EDate.EVENING
506 // || date === EDate.NIGHT
507 // || date === EDate.MIDNIGHT
509 // this.setStatus(EAction.MOVE_GOTO_HOME);
512 // else if(date === EDate.EVENING){
513 // // if(this.yukkuri.isItemsMax()){
514 // // this.setStatus(EAction.IN_HOME);
517 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
521 // if(this.yukkuri.isVeryKuhuku()){
525 // this.setStatus(EAction.MOVE_GOTO_HOME);
527 // else if(this.yukkuri.isSleep()){
528 // this.setStatus(EAction.SLEEP_START);
530 // else if(this.yukkuri.getUnun() >= 80){
531 // this.setStatus(EAction.UNUN_START);
534 // this.yukkuri.changeFace();
538 think_in_home: function(){
539 var date = ctl.getDate();
540 if((date === EDate.MIDNIGHT)
541 && !this.yukkuri.isSleep()
542 && !this.yukkuri.isVeryKuhuku()
546 "nextStatus":EAction.THINK_IN_HOME,
547 "myYukkuri": this.yukkuri
551 else if(date === EDate.EVENING){
554 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
555 this.setStatus(EAction.EAT_IN_HOME);
558 //marisa is hunting move
559 if(this.yukkuri.beforeHuntingFood !== null){
560 new MoveToHuntEvent({
562 "targetNode": this.yukkuri.beforeHuntingFood,
564 "myYukkuri": this.yukkuri
568 this.setStatus(EAction.WALK);
572 eat_in_home: function(){
574 "targetNode": this.yukkuri.getPlace(),
576 "myYukkuri": this.yukkuri
579 move_to_eat_start : function(){
582 "targetNode": this.targetNode,
584 "myYukkuri": this.yukkuri
590 walk : function(retryCounter){
591 if(retryCounter > 15){
593 this.status = EAction.NONE;
594 console.log("retryCount over");
597 if(this.yukkuri.imgGroup.tl.queue.length === 0){
599 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
601 this.isMoving = false;
602 this.status = EAction.THINK;
606 var xpos = 150 + rand(40) - (retryCounter * 10);
607 var ypos = 150 + rand(40) - (retryCounter * 10);
610 this.yukkuri.vy = -ypos;
612 else if(rand(8) == 1){
613 this.yukkuri.vx = xpos;
614 this.yukkuri.vy = -ypos;
615 this.yukkuri.direction = EDirection.RIGHT;
617 else if(rand(8) == 2){
618 this.yukkuri.vx = xpos;
620 this.yukkuri.direction = EDirection.RIGHT;
622 else if(rand(8) == 3){
623 this.yukkuri.vx = xpos;
624 this.yukkuri.vy = ypos;
625 this.yukkuri.direction = EDirection.RIGHT;
627 else if(rand(8) == 4){
629 this.yukkuri.vy = ypos;
631 else if(rand(8) == 5){
632 this.yukkuri.vx = -xpos;
633 this.yukkuri.vy = ypos;
634 this.yukkuri.direction = EDirection.LEFT;
636 else if(rand(8) == 6){
637 this.yukkuri.vx = -xpos;
639 this.yukkuri.direction = EDirection.LEFT;
641 else if(rand(8) == 7){
642 this.yukkuri.vx = -xpos;
643 this.yukkuri.vy = -ypos;
644 this.yukkuri.direction = EDirection.LEFT;
646 if (this.yukkuri.vx || this.yukkuri.vy) {
647 var map = ctl.backgroundMap;
648 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
649 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
650 var x = this.yukkuri.imgGroup.x + this.yukkuri.vx;
651 var y = this.yukkuri.imgGroup.y + this.yukkuri.vy + this.yukkuri.height / 2;
652 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
653 // console.log("あたってないよ:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
654 // console.log("X:" + this.yukkuri.moveX);
655 // console.log("Y:" + this.yukkuri.moveY);
656 this.isMoving = true;
657 this.yukkuri.reverse();
658 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
659 mangMsg.output(this.yukkuri,EMsg.WALK);
661 this.targetNode = null;
663 // console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
664 this.walk(retryCounter+1);
670 sleep_start: function(){
673 "myYukkuri": this.yukkuri
677 mangMsg.output(this.yukkuri, EMsg.DEAD);
678 this.yukkuri.tlPause();
679 this.yukkuri.setBodyImage(EBody.DEAD);
681 eat_start: function(){
684 "targetNode": this.targetNode,
686 "myYukkuri": this.yukkuri
690 unun_start: function(){
693 "myYukkuri": this.yukkuri
696 unun_smell_start: function(){
699 "myYukkuri": this.yukkuri
702 communicate_start:function(){
703 new ComSayHelloSendEvent({
705 "targetNode": this.targetNode,
707 "myYukkuri": this.yukkuri
710 move_to_place_start_homeless:function(){
711 new MoveToPlaceStartHomelessEvent({
712 "targetNode": this.targetNode,
714 "myYukkuri": this.yukkuri
717 declare_place_homeless:function(){
718 new DeclarePlaceHomelessEvent({
719 "targetNode": this.targetNode,
721 "myYukkuri": this.yukkuri
724 move_to_hunt_start:function(){
725 new MoveToHuntEvent({
727 "targetNode": this.targetNode,
729 "myYukkuri": this.yukkuri
732 hunt_start:function(){
735 "targetNode": this.targetNode,
737 "myYukkuri": this.yukkuri
740 move_goto_home:function(){
741 var place = this.yukkuri.getPlace();
742 new MoveGotoHomeEvent({
746 "myYukkuri": this.yukkuri
750 var place = this.yukkuri.getPlace();
751 if(place != null && place.isWorld()){
756 "myYukkuri": this.yukkuri
759 if(place && !place.isWorld())place.undefineAll();
760 this.yukkuri.declarePlace(null);
761 this.setStatus(EAction.WAIT);
762 mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
763 this.yukkuri.setFaceImage(EFace.CRY2);
765 "waitframe": FPS * 3.0,
767 "myYukkuri": this.yukkuri
771 move_to_command: function(){
772 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
773 new MoveToCommandEvent({
776 "myYukkuri": this.yukkuri
781 this.yukkuri.clearSearchObject();
782 var nodes = ctl.getObjs();
785 for (var key in nodes) {
786 var node = nodes[key];
787 if(node === null || node === undefined)continue;
788 if(this.yukkuri.id === node.id)continue;
792 && !(this.targetNode instanceof Unun)
793 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
795 this.yukkuri.addSearchObject(ESearch.UNUN, node);
798 else if (node instanceof Food && node.amount > 0) {
799 if(this.yukkuri.within(node, this.yukkuri.getRange())){
800 this.yukkuri.addSearchObject(ESearch.FOOD, node);
804 else if(node instanceof Yukkuri){
805 if(this.yukkuri.within(node, this.yukkuri.getRange())){
806 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
810 else if(node instanceof Place){
811 if(this.yukkuri instanceof Player){
813 if(this.yukkuri.within(node, this.yukkuri.getRange())){
814 this.yukkuri.addSearchObject(ESearch.PLACE, node);
818 this.status = EAction.WALK;
822 * Range範囲内のObjSprを管理する
823 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
827 var SearchObjectMang = enchant.Class.create({
828 initialize: function (){
830 this.currentCmdObject = null;
834 for(var key in ESearch){
835 var esearch = ESearch[key];
836 this.datas[esearch] = [];
839 add :function(esearch, node){
840 this.datas[esearch].push(node);
843 for(var key in ESearch){
844 var esearch = ESearch[key];
845 this.datas[esearch].length = 0;
847 // this.datas.length = 0;
850 get:function (esearch){
851 return this.datas[esearch];
853 getNear:function (esearch, yukkuri){
854 var objects = this.datas[esearch];
855 var nearDistance = null;
857 for(var i=0;i<objects.length;i++){
858 var object = objects[i];
859 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
860 if(nearDistance === null || nearDistance > nowDistance){
861 nearDistance = nowDistance;
867 callEvent: function(yukkuri){
868 if(yukkuri.cmdQueue.length !== 0){
869 this.currentCmdObject = yukkuri.cmdQueue.shift();
870 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
874 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
875 yukkuri.action.targetNode = yukkuri.getPlace();
876 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
879 if(yukkuri.isVeryKuhuku()){
881 var foods = this.get(ESearch.FOOD);
882 if(foods.length > 0){
883 var foods = this.get(ESearch.FOOD);
884 food = this.getNear(ESearch.FOOD, yukkuri);
886 yukkuri.action.targetNode = food;
887 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
891 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
892 yukkuri.action.setStatus(EAction.WALK);
897 if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
898 yukkuri.action.targetNode = yukkuri.getPlace();
899 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
903 yukkuri.action.setStatus(EAction.WALK);
907 if(yukkuri.isSleep()){
908 yukkuri.action.setStatus(EAction.SLEEP_START);
912 else if(yukkuri.getUnun() >= 80){
913 yukkuri.action.setStatus(EAction.UNUN_START);
918 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
919 food = this.getNear(ESearch.FOOD, yukkuri);
921 yukkuri.action.targetNode = food;
922 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
926 ununs = this.get(ESearch.UNUN);
927 if(ununs.length !== 0){
928 yukkuri.action.targetNode = yukkuri.getPlace();
929 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
932 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
933 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
934 yukkuri.action.targetNode = searchYukkuri;
935 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
938 if(!yukkuri.isPlace()){
939 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
940 if(searchYukkuri != null && !searchYukkuri.isOwner()){
941 yukkuri.action.targetNode = searchYukkuri;
942 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
946 yukkuri.action.setStatus(EAction.WALK);
951 var Event = enchant.Class.create({
952 initialize: function (_data){
955 onactionstart:function(self){
956 return this._onactionstart;
958 _onactionstart:function(e){
959 if(typeof e === "undefined")return;
961 onactiontick:function(self){
963 if(typeof e === "undefined")return;
966 onactionend:function(self){
968 if(typeof e === "undefined")return;
972 var WalkEvent = enchant.Class.create(Event,{
973 initialize: function (_data){
975 this.yukkuri = _data.myYukkuri;
976 this.action = _data.action;
978 mangMsg.output(this.yukkuri, EMsg.SLEEP);
979 this.action.setStatus(EAction.SLEEP_WAIT);
980 this.yukkuri.setFaceImage(EFace.SLEEP);
981 this.yukkuri.tlPause();
983 this.yukkuri.addEventListener('enterframe', function() {
984 var yukkuri = self.yukkuri;
992 var SleepEvent = enchant.Class.create(Event,{
993 initialize: function (_data){
995 this.yukkuri = _data.myYukkuri;
996 this.action = _data.action;
998 mangMsg.output(this.yukkuri, EMsg.SLEEP);
999 this.action.setStatus(EAction.SLEEP_WAIT);
1000 this.yukkuri.setFaceImage(EFace.SLEEP);
1001 this.yukkuri.tlPause();
1004 this.yukkuri.addEventListener('enterframe', function() {
1005 var yukkuri = self.yukkuri;
1006 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
1007 if(yukkuri.param.sleep <= 0){
1008 yukkuri.param.sleep = 0;
1009 this.removeEventListener("enterframe",arguments.callee);
1010 mangMsg.output(self.yukkuri, EMsg.GET_UP);
1011 yukkuri.setFaceImage(EFace.NORMAL);
1013 // self.action.setStatus(EAction.WAIT);
1014 if(self.data.nextStatus !== undefined){
1015 self.action.setStatus(self.data.nextStatus);
1017 self.action.setStatus(EAction.THINK);
1024 var UnunEvent = enchant.Class.create(Event,{
1025 initialize: function (_data){
1027 this.yukkuri = _data.myYukkuri;
1028 this.action = _data.action;
1029 this.action.setStatus(EAction.UNUN_WAIT);
1030 mangMsg.output(this.yukkuri, EMsg.UNUN);
1031 this.yukkuri.setFaceImage(EFace.HAPPY2);
1034 this.yukkuri.wait(sec, {
1035 "onactionend": this.onactionend(this)
1038 onactionend:function(self){
1040 if(typeof e === "undefined")return;
1041 self.yukkuri.unun();
1042 self.action.setStatus(EAction.WAIT);
1043 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1045 "waitframe": FPS * 1.5,
1046 "action": self.action,
1047 "myYukkuri": self.yukkuri
1052 var WaitEvent = enchant.Class.create(Event,{
1053 initialize: function (_data){
1055 this.yukkuri = _data.myYukkuri;
1056 this.action = _data.action;
1057 this.waitframe = _data.waitframe;
1058 this.yukkuri.wait(this.waitframe, {
1059 "onactionstart": this.onactionstart(this),
1060 "onactiontick": this.onactiontick(this),
1061 "onactionend": this.onactionend(this)
1064 onactionend:function(self){
1066 if(typeof e === "undefined")return;
1067 self.action.setStatus(EAction.THINK);
1071 var UnunSmellEvent = enchant.Class.create(Event,{
1072 initialize: function (_data){
1074 this.yukkuri = _data.myYukkuri;
1075 this.action = _data.action;
1076 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1077 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1078 this.yukkuri.setFaceImage(EFace.CRY1);
1080 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1081 this.yukkuri.wait(sec, {
1082 "onactionend": this.onactionend(this)
1085 onactionend:function(self){
1087 if(typeof e === "undefined")return;
1088 self.action.setStatus(EAction.WALK);
1093 var EatEvent = enchant.Class.create(Event,{
1094 initialize: function (_data){
1096 this.yukkuri = _data.myYukkuri;
1097 this.food = _data.targetNode;
1098 this.action = _data.action;
1099 this.action.setStatus(EAction.EAT_WAIT);
1102 var sec = BASE_FPS * 3;
1103 if(this.yukkuri.eat(this.food)){
1104 mangMsg.output(this.yukkuri, EMsg.EAT);
1105 this.yukkuri.setFaceImage(EFace.EAT2);
1108 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1109 this.yukkuri.setFaceImage(EFace.CRY2);
1111 this.yukkuri.wait(sec, {
1112 "onactionend": this.onactionend(this)
1115 onactionend:function(self){
1117 if(typeof e === "undefined")return;
1118 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
1119 self.action.setStatus(EAction.THINK);
1120 self.yukkuri.setFaceImage(EFace.NORMAL);
1122 self.action.setStatus(EAction.EAT_START);
1129 * -When yukkuri find Food.
1132 * targetNode: enchant.Node
1136 var MoveToEatEvent = enchant.Class.create(Event,{
1137 initialize: function (_data){
1139 this.yukkuri = this.data.myYukkuri;
1140 this.action = this.data.action;
1142 var yukkuri = this.yukkuri;
1143 var node = this.data.targetNode;
1145 if(this.data.type == "food"){
1146 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1147 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
1148 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
1149 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1150 var frame = distance + distance/5 + 1;
1151 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1152 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1154 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1156 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1157 "onactiontick": this.onactiontick(this),
1158 "onactionend": this.onactionend(this)
1162 onactiontick:function(self){
1164 if(typeof e === "undefined")return;
1167 onactionend:function(self){
1169 if(typeof e === "undefined")return;
1170 self.action.setStatus(EAction.EAT_START);
1174 var MoveToHuntEvent = enchant.Class.create(Event,{
1175 initialize: function (_data){
1177 this.yukkuri = this.data.myYukkuri;
1178 this.action = this.data.action;
1180 var yukkuri = this.yukkuri;
1181 var node = this.data.targetNode;
1184 var nodeWidth = node.width;
1185 var nodeHeight = node.height;
1189 if(this.data.type == "food"){
1190 this.action.setStatus(EAction.WAIT);
1191 yukkuri.vx = nodeX - yukkuri.getX() + nodeWidth / 2;
1192 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2;
1193 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1194 var frame = distance + distance/5 + 1;
1195 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1196 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1198 mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
1200 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1201 "onactionend": this.onactionend(this)
1205 onactionend:function(self){
1207 if(typeof e === "undefined")return;
1208 self.action.setStatus(EAction.HUNT_START);
1212 var HuntStartEvent = enchant.Class.create(Event,{
1213 initialize: function (_data){
1214 Event.call(this, _data);
1217 this.yukkuri = _data.myYukkuri;
1218 this.food = _data.targetNode;
1219 this.action = _data.action;
1220 this.action.setStatus(EAction.WAIT);
1221 this.huntingStatus = "hunting";
1223 // this.yukkuri.beforeHuntingFood = this.food;
1224 if(this.food.isWorld()){
1225 this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
1226 var sec = BASE_FPS * 8;
1227 if(this.yukkuri.hunt(this.food)){
1228 this.huntingStatus = "hunting";
1229 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1230 this.yukkuri.setFaceImage(EFace.HAPPY1);
1232 if(this.yukkuri.isItemsMax()){
1234 this.huntingStatus = "return";
1235 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1236 this.yukkuri.setFaceImage(EFace.NORMAL);
1239 this.huntingStatus = "cry";
1240 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1241 this.yukkuri.setFaceImage(EFace.CRY2);
1246 this.yukkuri.beforeHuntingFood = null;
1248 this.huntingStatus = "cry";
1249 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1250 this.yukkuri.setFaceImage(EFace.CRY2);
1253 this.yukkuri.wait(sec, {
1254 "onactiontick": this.onactiontick(this),
1255 "onactionend": this.onactionend(this)
1258 onactiontick:function(self){
1260 if(typeof e === "undefined")return;
1262 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1263 if(this.age%(BASE_FPS * 5) == 0){
1264 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1265 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1270 onactionend:function(self){
1272 if(typeof e === "undefined")return;
1273 if(self.huntingStatus == "hunting"){
1274 if(self.yukkuri.isItemsMax()){
1275 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1276 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1278 self.action.setStatus(EAction.HUNT_START);
1281 else if(self.huntingStatus == "return"){
1282 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1284 else if(self.huntingStatus === "cry"){
1285 // self.action.setStatus(EAction.THINK);
1286 self.action.setStatus(EAction.WALK);
1293 this.yukkuri = null;
1298 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1299 initialize: function (_data){
1301 this.yukkuri = this.data.myYukkuri;
1302 this.action = this.data.action;
1304 var yukkuri = this.yukkuri;
1305 var place = this.data.targetNode;
1307 if(this.data.type == "hunt_end"){
1308 this.action.setStatus(EAction.WAIT);
1309 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1310 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1311 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1312 var frame = distance + distance/2 + 1 ;
1313 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1314 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1316 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1318 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1319 "onactiontick": this.onactiontick(this),
1320 "onactionend": this.onactionend(this)
1324 onactiontick:function(self){
1326 if(typeof e === "undefined")return;
1327 if(this.age%(BASE_FPS * 5) == 0){
1328 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1332 onactionend:function(self){
1334 if(typeof e === "undefined")return;
1335 self.action.setStatus(EAction.IN_HOME);
1341 this.yukkuri = null;
1345 var InHomeEvent = enchant.Class.create(Event,{
1346 initialize: function (_data){
1348 this.yukkuri = this.data.myYukkuri;
1349 this.action = this.data.action;
1351 var yukkuri = this.yukkuri;
1352 var place = this.data.targetNode;
1354 if(yukkuri.isVeryKuhuku()){
1356 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1357 this.action.setStatus(EAction.EAT_IN_HOME);
1360 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1362 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1363 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1364 this.action.setStatus(EAction.THINK);
1367 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1368 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1373 this.action.setStatus(EAction.WAIT);
1374 var items = this.yukkuri.getItems();
1375 if(items.length > 0){
1376 place.setItems(items);
1380 var sec = BASE_FPS * 10;
1381 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1382 this.yukkuri.wait(sec, {
1383 "onactiontick": this.onactiontick(this),
1384 "onactionend": this.onactionend(this)
1387 onactiontick:function(self){
1389 if(typeof e === "undefined")return;
1390 if(this.age%(BASE_FPS * 5) == 0){
1391 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1395 onactionend:function(self){
1397 if(typeof e === "undefined")return;
1398 self.action.setStatus(EAction.THINK_IN_HOME);
1402 var EatInHomeEvent = enchant.Class.create(Event,{
1403 initialize: function (_data){
1405 this.yukkuri = _data.myYukkuri;
1406 this.place = _data.targetNode;
1407 this.action = _data.action;
1408 this.action.setStatus(EAction.EAT_WAIT);
1410 var sec = BASE_FPS * 3;
1411 var foodHash = this.place.getFoodHash();
1412 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1413 mangMsg.output(this.yukkuri, EMsg.EAT);
1414 this.yukkuri.setFaceImage(EFace.EAT2);
1417 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1418 this.yukkuri.setFaceImage(EFace.CRY2);
1421 this.yukkuri.wait(sec, {
1422 "onactionend": this.onactionend(this)
1425 onactionend:function(self){
1427 if(typeof e === "undefined")return;
1428 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1429 self.action.setStatus(EAction.EAT_IN_HOME);
1431 // new EatInHomeEvent({
1432 // "targetNode": self.place,
1433 // "action": self.action,
1434 // "myYukkuri": self.yukkuri
1437 self.action.setStatus(EAction.THINK_IN_HOME);
1438 self.yukkuri.setFaceImage(EFace.NORMAL);
1445 var MoveToCommandEvent = enchant.Class.create(Event,{
1446 initialize: function (_data){
1448 this.yukkuri = this.data.myYukkuri;
1449 this.action = this.data.action;
1450 // this.vx = this.data.cmdObject.vx;
1451 // this.vy = this.data.cmdObject.vy;
1452 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1455 var yukkuri = this.yukkuri;
1456 this.action.status = EAction.WAIT;
1457 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1458 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1459 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1460 var frame = distance + distance/2 + 1;
1461 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1463 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1465 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1466 "onactiontick": this.onactiontick(this),
1467 "onactionend": this.onactionend(this)
1470 onactiontick:function(self){
1472 if(typeof e === "undefined")return;
1475 onactionend:function(self){
1477 if(typeof e === "undefined")return;
1478 self.action.setStatus(EAction.THINK);
1483 * Say hello contact to send communication .
1485 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1486 initialize: function (_data){
1488 this.yukkuri = _data.myYukkuri;
1489 this.targetYukkuri = _data.targetNode;
1490 this.action = _data.action;
1491 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1492 // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1493 // this.targetYukkuri.tlPause();
1494 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1495 this.yukkuri.send(this.targetYukkuri, {
1496 "actionStatus":EAction.COMMUNICATE_RECV,
1497 "yukkuri":this.yukkuri
1501 this.yukkuri.tlPause();
1502 this.yukkuri.syncDirection(this.targetYukkuri);
1504 this.yukkuri.addAddress(this.targetYukkuri);
1505 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1507 var sec = BASE_FPS * 2;
1508 this.yukkuri.wait(sec, {
1509 "onactiontick": this.onactiontick(this),
1510 "onactionend": this.onactionend(this)
1513 onactiontick:function(self){
1515 if(typeof e === "undefined")return;
1518 onactionend:function(self){
1520 if(typeof e === "undefined")return;
1521 new ComSayHelloRecvEvent({
1523 "targetNode": self.yukkuri,
1524 "action": self.targetYukkuri.action,
1525 "myYukkuri": self.targetYukkuri
1530 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1531 initialize: function (_data){
1533 this.yukkuri = _data.myYukkuri;
1534 this.targetYukkuri = _data.targetNode;
1535 this.action = _data.action;
1536 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1537 this.yukkuri.addAddress(this.targetYukkuri);
1538 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1540 var sec = BASE_FPS * 2;
1541 this.yukkuri.wait(sec, {
1542 "onactiontick": this.onactiontick(this),
1543 "onactionend": this.onactionend(this)
1546 onactiontick:function(self){
1548 if(typeof e === "undefined")return;
1551 onactionend:function(self){
1553 if(typeof e === "undefined")return;
1554 self.action.setStatus(EAction.THINK);
1556 self.yukkuri.action.setStatus(EAction.THINK);
1557 self.yukkuri.animation();
1558 self.targetYukkuri.action.setStatus(EAction.THINK);
1559 self.targetYukkuri.animation();
1563 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1564 initialize: function (_data){
1566 this.yukkuri = this.data.myYukkuri;
1567 this.action = this.data.action;
1569 var yukkuri = this.yukkuri;
1570 var node = this.data.targetNode;
1572 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1573 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1574 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1575 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1576 var frame = distance + distance/5 + 1;
1577 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1579 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1582 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1583 "onactionend": this.onactionend(this)
1586 onactionend:function(self){
1588 if(typeof e === "undefined")return;
1589 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1591 self.yukkuri = null;
1596 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1597 initialize: function (_data){
1599 this.yukkuri = _data.myYukkuri;
1600 this.place = _data.targetNode;
1601 this.action = _data.action;
1602 this.action.setStatus(EAction.WAIT);
1605 var sec = BASE_FPS * 3;
1606 this.yukkuri.declarePlace(this.place);
1607 this.place.setOwner(this.yukkuri);
1608 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1610 this.yukkuri.setFaceImage(EFace.NORMAL);
1611 this.yukkuri.wait(sec, {
1612 "onactionend": this.onactionend(this)
1615 onactionend:function(self){
1617 if(typeof e === "undefined")return;
1618 self.action.setStatus(EAction.THINK);
1623 var Food = enchant.Class.create(ObjSprite,{
1624 initialize: function (type, x, y){
1625 this.classname = "Food";
1626 //一つにつきgiveの値分、hunguryを減少させられる
1627 if(type == "apple"){
1628 ObjSprite.call(this,16,16);
1629 this.image = game.assets[EResPath.OBJECT];
1633 }else if(type == "grass"){
1634 ObjSprite.call(this,64,64);
1635 this.image = game.assets[EResPath.GRASS];
1642 foodGroup.addChild(this);
1643 this.addEventListener('enterframe', function(){
1644 if(this.amount <= 0){
1649 getAmount: function(){
1652 getGive: function(){
1656 var MemoryPlace = enchant.Class.create({
1657 // initialize: function (place){
1658 // if(place.x != null){
1659 // this.isWorld = true;
1661 // this.isWorld = false;
1663 // this.isWorld = (place.x != null);
1664 // this.x = place.x;
1665 // this.y = place.y;
1666 // this.width = place.width;
1667 // this.height = place.height;
1669 // isWorld: function(){
1670 // return this.isWorld;
1674 var MemoryFood = enchant.Class.create({
1675 initialize: function (food){
1677 this.isWorld = true;
1679 this.isWorld = false;
1681 this.isWorld = (food.x != null);
1684 this.width = food.width;
1685 this.height = food.height;
1687 isWorld: function(){
1688 return this.isWorld;
1691 var Place = enchant.Class.create(ObjSprite,{
1692 initialize: function (type, x, y){
1693 ObjSprite.call(this,128,128);
1694 this.image = game.assets[EResPath.PLACE_TREE];
1695 this.x = x - this.width / 2;
1696 this.y = y - this.height / 2;
1697 backgroundMap.addChild(this);
1700 for(var key in EFood){
1701 var efood = EFood[key];
1702 this.foods[efood] = 0;
1704 // this.addEventListener('enterframe', function(){
1705 // if(this.age%10 === 0 && this.age !== 0){
1706 // console.log("x/y " + this.x + "/" + this.y);
1708 // if(game.input.left){
1711 // if(game.input.right){
1714 // if(game.input.up){
1717 // if(game.input.down){
1722 getStatusForDisplay: function(){
1725 if(this.owner == null)ownerId = "なし";
1726 else ownerId = this.owner.id;
1727 ret += "プレイスID " + this.id + "\n";
1728 ret += "オーナーID " + ownerId + "\n";
1729 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1730 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1731 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1734 setItems:function(items){
1735 var len = items.length;
1736 for(var i=0; i<len; i++){
1737 var item = items[i];
1738 if(item instanceof Food){
1739 this.foods[EFood.NORMAL]++;
1746 for(var key in EFood){
1747 var efood = EFood[key];
1748 ret += this.foods[efood];
1752 getFoodHash:function(){
1753 if(this.foods[EFood.GREAT] !== 0){
1754 this.foods[EFood.GREAT]--;
1755 return {give:20,yukkuri:15,unun:20};
1757 else if(this.foods[EFood.NORMAL] !== 0){
1758 this.foods[EFood.NORMAL]--;
1759 return {give:10,yukkuri:5,unun:10};
1761 else if(this.foods[EFood.BAD] !== 0){
1762 this.foods[EFood.BAD]--;
1763 return {give:10,yukkuri:-2,unun:10};
1767 setOwner: function(yukkuri){
1768 this.owner = yukkuri;
1770 isOwner: function(){
1771 return this.owner !== null;
1774 var Unun = enchant.Class.create(ObjSprite,{
1775 initialize: function (x, y){
1776 this.classname = "Unun";
1777 ObjSprite.call(this,32,32);
1778 this.image = game.assets[EResPath.YUKKURI_UNUN];
1781 backgroundMap.addChild(this);
1782 // this.lifetime = 30 * 24 * 3;
1783 this.lifetime = 15 * 24;
1784 this.addEventListener('enterframe', this.runEnterframe(this));
1785 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1788 runEnterframe:function(self){
1790 if(typeof e === "undefined")return;
1791 if(this.age%BASE_FPS === 0 && this.age !== 0){
1793 if(self.lifetime <= 0){
1794 this.parentNode.removeChild(this);
1795 ctl.backgroundMap.removeChild(this);
1796 ctl.removeObj(this);
1804 var Okazari = enchant.Class.create(enchant.Sprite,{
1805 initialize: function(yukkuri){
1806 this.classname = "Okazari";
1807 if(yukkuri.myCode === "REIMU"){
1808 enchant.Sprite.call(this, 80, 32);
1809 this.image = game.assets[EResPathReimu.OKAZARI];
1810 this.x = -CHARA_WIDTH / 2 - 1;
1813 enchant.Sprite.call(this, 64, 64);
1814 this.image = game.assets[EResPath.MARISA_OKAZARI];
1815 this.x = -CHARA_WIDTH / 2;
1816 this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
1818 this.yukkuri = yukkuri;
1820 getWidth: function(){
1822 // return this.width * this.yukkuri.myScaleX;
1824 getHeight: function(){
1826 // return this.height * this.yukkuri.myScaleY;
1829 var Address = enchant.Class.create({
1830 initialize: function(yukkuri){
1831 this.friendlyLv = 1;
1832 this.yukkuri = yukkuri;
1833 this.isGreeting = false;
1834 this.greetingWaitFrame = 0;
1836 "beginSayHello" : false,
1841 set:function(key, value){
1842 this.comMatrix[key] = value;
1845 return this.comMatrix[key];
1849 var Yukkuri = enchant.Class.create(ObjSprite,{
1850 initialize: function(x, y, grow){
1851 ObjSprite.call(this, 64, 64);
1852 this.searchObjectMang = new SearchObjectMang();
1856 this.myCode = "YUKKURI";
1857 this.myName = "ゆっくり";
1858 this.beforeHuntingFood = null;
1859 if(grow == EGrow.ADULT){
1864 else if(grow == EGrow.SUBADULT){
1865 this.myScaleX = 0.8;
1866 this.myScaleY = 0.8;
1869 else if(grow == EGrow.CHILD){
1870 this.myScaleX = 0.6;
1871 this.myScaleY = 0.6;
1874 else if(grow == EGrow.BABY){
1875 this.myScaleX = 0.3;
1876 this.myScaleY = 0.3;
1880 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1881 this.classname = "Yukkuri";
1882 this.addressBook = {};
1883 this.imgGroup = new SpriteGroup();
1884 this.imgBody = new SpriteGroup();
1885 this.imgGroup.id = guid();
1886 this.imgBody.id = guid();
1887 this.x = -CHARA_WIDTH / 2;
1888 this.y = -CHARA_HEIGHT / 2;
1891 this.image = game.assets[EResPath.YUKKURI_BASE];
1892 this.direction = EDirection.RIGHT;
1893 this.addEventListener('enterframe', this.runEnterframe);
1894 this.bodyStatus ={};
1895 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
1896 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
1897 this.walkAnimationStatus = EWalkAnimation.END;
1900 this.actionQueue = [];
1902 this.exValueHash = {};
1903 this.memoryHash = {};
1904 this.communicateYukkuri = {};
1905 for(var _v in EExSkill){
1906 var key = EExSkill[_v];
1907 this.exLvHash[key] = 0;
1908 this.exValueHash[key] = 0;
1912 runEnterframe:function(){
1915 if(this.isDead())return;
1926 if(this.direction == EDirection.RIGHT){
1927 this.imgBody.scaleX = 1;
1929 else if(this.direction == EDirection.LEFT){
1930 this.imgBody.scaleX = -1;
1933 tweet:function(text){
1934 text = text.replace(/%name%/g, this.myName);
1935 this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
1937 moveTo:function(x, y, time){
1938 this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
1940 moveBy:function(x, y, time, eventFunctions){
1944 return self.imgGroup.x + x;
1947 return self.imgGroup.y + y;
1950 easing: enchant.Easing.SIN_EASEINOUT
1952 //-Event register [onactionstart,onactiontick,onactionend]
1953 if(eventFunctions !== undefined){
1954 for(var key in eventFunctions){
1955 params[key] = eventFunctions[key];
1958 return this.imgGroup.tl.tween(params);
1960 wait:function(frame, eventFunctions){
1961 this.moveBy(0,1,frame,eventFunctions);
1966 animation: function(){
1969 frame -= plusFrameScale(frame, this.getMyScale()) / 2;
1971 move -= plusFrameScale(move, this.getMyScale());
1972 if(this.walkAnimationStatus == EWalkAnimation.END){
1974 this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
1975 "onactionstart": function(e){
1976 this.walkAnimationStatus = EWalkAnimation.START;
1979 .moveByEx(0, move, frame, enchant.Easing.SWING,
1981 "onactionend": function(e){
1982 this.walkAnimationStatus = EWalkAnimation.END;
1987 this.imgBody.tl.loop();
1990 getMyScale: function(){
1991 return (this.myScaleX + this.myScaleY) / 2;
1993 getWidth: function(){
1994 return this.width * this.myScaleX;
1996 getHeight: function(){
1997 return this.height * this.myScaleY;
2000 return this.imgGroup.x;
2003 return this.imgGroup.y;
2006 this.imgGroup.x += x;
2008 // this.shadow.x += x;
2009 // this._tweet.x += x;
2012 this.imgGroup.y += y;
2014 // this.shadow.y += y;
2015 // this._tweet.y += y;
2017 // changeFace: function(erespath){
2018 // this.face.image = game.assets[erespath];
2020 loadParamsXML: function(url){
2021 var http = new JKL.ParseXML( url );
2022 return http.parse();
2024 runYukkuri: function(){
2025 if(this.param.hungry > 70){
2026 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
2027 this.param.yukkuri -= 1;
2030 else if(this.param.hungry < 10){
2031 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
2034 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
2035 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
2037 runHungry: function(){
2038 if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
2039 if(this.param.hungry >= 100)this.param.hungry = 100;
2041 runUnun: function(){
2042 if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
2043 if(this.param.unun >= 100)this.param.unun = 100;
2045 runSleep: function(){
2046 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
2047 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
2048 if(this.param.sleep >= 100){
2049 this.param.sleep = 100;
2053 runAddress: function(){
2054 for(var key in this.addressBook){
2055 var address = this.addressBook[key];
2057 if(address.isGreeting){
2058 address.greetingWaitFrame++;
2059 if(address.greetingWaitFrame >= DAY){
2060 address.greetingWaitFrame = 0;
2061 address.isGreeting = false;
2066 changeFace: function(){
2067 if(this.param.yukkuri >= 80){
2068 this.setFaceImage(EFace.HAPPY1);
2070 else if(this.param.yukkuri >= 50){
2071 this.setFaceImage(EFace.NORMAL);
2073 else if(this.param.yukkuri >= 30){
2074 this.setFaceImage(EFace.TIRED);
2076 else if(this.param.yukkuri >= 10){
2077 this.setFaceImage(EFace.CRY1);
2079 else if(this.param.yukkuri >= 1){
2080 this.setFaceImage(EFace.CRY2);
2083 getRange: function(){
2084 return this.param.range;
2086 isSleep: function(){
2087 return this.param.sleep >= 100;
2090 return this.param.yukkuri <= 0;
2092 isManpuku: function(){
2093 return this.param.hungry <= 20;
2095 isKuhuku: function(){
2096 return this.param.hungry >= 40;
2098 isVeryKuhuku: function(){
2099 return this.param.hungry >= 80;
2101 getYukkuri: function(){
2102 return this.param.yukkuri;
2104 setYukkuri: function(yukkuri){
2105 this.param.yukkuri = yukkuri;
2106 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2108 addYukkuri: function(yukkuri){
2109 this.param.yukkuri += yukkuri;
2110 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2112 getHungry: function(){
2113 return this.param.hungry;
2115 setHungry: function(hungry){
2116 this.param.hungry = hungry;
2117 if(this.param.hungry < 0)this.param.hungry = 0;
2119 getUnun: function(){
2120 return this.param.unun;
2122 setUnun: function(unun){
2123 this.param.unun = unun;
2124 if(this.param.unun < 0)this.param.unun = 0;
2128 if(food instanceof Food){
2130 if(food.amount > 0){
2132 this.setHungry(this.param.hungry - food.getGive());
2133 this.setUnun(this.getUnun() + food.getGive() / 4);
2134 this.setYukkuri(this.getYukkuri() + 5);
2137 this.setYukkuri(this.getYukkuri() - 5);
2143 this.setHungry(this.param.hungry - food.give);
2144 this.setUnun(this.getUnun() + food.unun);
2145 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2152 hunt:function(food){
2153 if(food.amount > 0){
2154 if(!this.isItemsMax()){
2156 this.items.push(food);
2157 this.setYukkuri(this.getYukkuri() + 1);
2163 declarePlace: function(place){
2166 getPlace:function(){
2169 isPlace: function(){
2170 return this.place !== null;
2174 if(this.direction == EDirection.RIGHT){
2175 new Unun(this.getX(), this.getY() + this.getHeight()/5 );
2177 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2181 setBodyImage: function(ebody){
2182 var path = this.bodyStatus[ebody];
2183 this.image = game.assets[path];
2186 // this.imgBody.tl.pause();
2187 // this.imgGroup.tl.pause();
2188 this.imgBody.tl.clear();
2189 this.imgGroup.tl.clear();
2190 this.imgBody.tl.unloop();
2191 this.imgGroup.tl.unloop();
2195 tlResume: function(){
2196 // this.imgBody.tl.resume();
2197 // this.imgGroup.tl.resume();
2200 syncDirection:function(senderYukkuri){
2201 if(this.getX() > senderYukkuri.getX()){
2202 this.direction = EDirection.LEFT;
2203 senderYukkuri.direction = EDirection.RIGHT;
2205 this.direction = EDirection.RIGHT;
2206 senderYukkuri.direction = EDirection.LEFT;
2209 isCommunication: function(yukkuri){
2210 if(this.addressBook[yukkuri.id] === undefined) return true;
2211 if(this.addressBook[yukkuri.id].isGreeting) return false;
2214 addAddress: function(yukkuri){
2215 this.addressBook[yukkuri.id] = new Address(yukkuri);
2217 getAddress: function(yukkuri){
2218 if(this.addressBook[yukkuri.id] === undefined)return null;
2219 return this.addressBook[yukkuri.id];
2221 getStatusForDisplay: function (){
2223 var placeId = (this.place==null)?"無し" : this.place.id;
2224 ret += "ID " + this.id + "\n";
2225 ret += "プレイス " + placeId + "\n";
2226 ret += "ゆっくり " + this.getYukkuri() + "\n";
2227 ret += "空腹 " + this.getHungry() + "\n";
2228 ret += "うんうん " + this.getUnun() + "\n";
2229 ret += "もちもの " + this.items.length + "\n";
2230 ret += "debug " + this.action.status + "\n";
2233 isItemsMax:function(){
2234 return this.items.length >= this.param.items_max;
2236 getItems:function(){
2239 addSearchObject:function(esearch, node){
2240 this.searchObjectMang.add(esearch, node)
2242 clearSearchObject:function(){
2243 this.searchObjectMang.clear()
2245 setFaceImage: function(eface){
2246 var path = this.faceStatus[eface];
2247 this.face.image = game.assets[path];
2249 myScale: function(_scaleX, _scaleY){
2250 this.face.scale(_scaleX,_scaleY);
2251 if(this.myCode === "REIMU"){
2252 this.okazari.x = -this.okazari.width / 2;
2253 this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2255 this.okazari.x = -CHARA_WIDTH /2;
2256 this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2258 if(this.sub1 != null){
2259 this.sub1.scale(_scaleX,_scaleY);
2262 this.okazari.scale(_scaleX,_scaleY);
2263 this.hear.scale(_scaleX,_scaleY);
2264 this.scale(_scaleX,_scaleY);
2265 this.shadow.scale(_scaleX, _scaleY);
2267 send: function(targetYukkuri, object, callback){
2268 this.communicateYukkuri = targetYukkuri;
2269 targetYukkuri.recv(object, callback);
2271 recv: function(object, callback){
2272 this.communicateYukkuri = object.yukkuri;
2274 this.action.setStatus(object.actionStatus);
2276 // this.actionQueue.push({
2278 // callback: callback
2281 addExValue: function(eexskill, plus){
2282 this.exValueHash[eexskill] += plus;
2283 if(this.exValueHash[eexskill] >= 100){
2284 this.exLvHash[eexskill] = 1;
2287 getExValue: function(eexskill){
2288 return this.exValueHash[eexskill];
2290 getExSkill: function(eexskill){
2291 return this.exLvHash[eexskill];
2294 setMemory: function(ememory, value){
2295 this.memoryHash[ememory] = value;
2297 getMemory: function(ememory){
2298 return this.memoryHash[ememory];
2300 damage: function(edamage){
2301 if(edamage == EDamage.PICOHAN){
2302 mangMsg.output(this, EMsg.DAMAGE);
2303 this.setFaceImage(EFace.CRY1);
2304 this.addYukkuri(-1);
2305 //現在の行動パターンから躾対象かセレクトする
2308 destruct: function(){
2312 var Marisa = enchant.Class.create(Yukkuri,{
2313 initialize: function(x, y, grow){
2314 Yukkuri.call(this,x,y, grow);
2315 this.classname = "Marisa";
2316 this.myCode = "MARISA";
2317 this.myName = "まりさ";
2319 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2320 // var json = net.load("./data/marisa/params.json");
2321 // this.param = json.root.param;
2322 this.param = new MarisaParam();
2323 if(this.grow == EGrow.BABY){
2324 this.myName = "まりちゃ";
2325 this.param.range /= 4;
2327 else if(this.grow == EGrow.CHILD){
2328 this.param.range /= 3;
2330 else if(this.grow == EGrow.SUBADULT){
2331 this.param.range *= 0.8;
2334 this.shadow = new enchant.Sprite(64, 64);
2335 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2336 this.shadow.x = 0 + this.x;
2337 this.shadow.y = this.getWidth() / 16 + this.x;
2339 this._style.zIndex = 5;
2341 this.face = new enchant.Sprite(64, 64);
2342 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2343 this.face.x = -CHARA_WIDTH / 2;
2344 this.face.y = -CHARA_HEIGHT / 2;
2346 this.faceStatus ={};
2347 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2348 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2349 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2350 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2351 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2352 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2353 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2354 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2355 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2356 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2359 this.hear = new enchant.Sprite(64, 64);
2360 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2361 this.hear.x = -CHARA_WIDTH / 2;
2362 this.hear.y = -CHARA_HEIGHT / 2;
2364 this.okazari = new Okazari(this);
2368 this.imgGroup.addChild(this.shadow);
2369 this.imgBody.addChild(this);
2370 this.imgBody.addChild(this.face);
2371 this.imgBody.addChild(this.hear);
2372 this.imgBody.addChild(this.okazari);
2373 this.myScale(this.myScaleX, this.myScaleY)
2374 if(this instanceof Player){
2375 // this.myScaleX = 0.5;
2376 // this.myScaleY = 0.5;
2378 this.budge = new enchant.Sprite(16, 16);
2379 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2380 this.imgBody.addChild(this.budge);
2381 this.budge.x -= this.getWidth()/2;
2382 this.budge.y -= this.getHeight()/2;
2383 this.budge.scale(this.myScaleX, this.myScaleX);
2385 this.imgGroup.width = this.getWidth();
2386 this.imgGroup.height = this.getHeight();
2387 this.imgGroup.addChild(this.imgBody);
2388 backgroundMap.addChild(this.imgGroup);
2389 this._tweet = new TTweet(148, 64);
2391 this.imgGroup.addChild(this._tweet);
2392 this.imgGroup.x = x;
2393 this.imgGroup.y = y;
2396 this.action = new Action(this);
2400 var Player = enchant.Class.create(Marisa,{
2401 initialize: function(x, y){
2402 // this.runEnterframe = function(){
2404 Marisa.call(this, x, y, EGrow.ADULT);
2405 this.classname = "Player";
2406 ctl.setPlayer(this);
2407 // this.removeEventListener('enterframe',this.runEnterframe);
2408 this.addEventListener('enterframe', function(){
2411 if(this.age%10 === 0 && this.age !== 0){
2412 // console.log("palyer:" + this.age);
2415 ///////////////////////////////////////////////
2416 //Action pattern debug
2417 if(game.input.left){
2418 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2420 this.direction = EDirection.LEFT;
2422 if(game.input.right){
2424 this.direction = EDirection.RIGHT;
2429 if(game.input.down){
2433 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2434 ///////////////////////////////////////////////
2436 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2437 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2439 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2441 //- Display the circle of search range.
2442 // fieldBg.image.clear();
2443 // fieldBg.image.context.beginPath();
2444 // fieldBg.image.context.fillStyle = '#ff0000';
2445 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2446 // fieldBg.image.context.fill();
2450 var Reimu = enchant.Class.create(Yukkuri,{
2451 initialize: function(x, y, grow){
2452 Yukkuri.call(this,x,y, grow);
2453 this.classname = "Reimu";
2454 this.myCode = "REIMU";
2455 this.myName = "れいむ";
2457 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2458 // var json = net.load("./data/reimu/params.json");
2459 // this.param = json.root.param;
2460 this.param = new ReimuParam();
2461 if(this.grow == EGrow.BABY){
2462 this.myName = "れいみゅ";
2463 this.param.range /= 4;
2465 else if(this.grow == EGrow.CHILD){
2466 this.param.range /= 3;
2468 else if(this.grow == EGrow.SUBADULT){
2469 this.param.range *= 0.8;
2471 this.shadow = new enchant.Sprite(64, 64);
2472 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2473 this.shadow.x = 0 + this.x;
2474 this.shadow.y = this.getWidth() / 16 + this.x;
2475 this.shadow.image._element.style.zIndex = 2;
2477 this._style.zIndex = 5;
2479 this.face = new enchant.Sprite(64, 64);
2480 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2481 this.face.x = -CHARA_WIDTH / 2;
2482 this.face.y = -CHARA_HEIGHT / 2;
2483 this.face._style.zIndex = 0;
2485 this.faceStatus ={};
2486 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2487 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2488 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2489 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2490 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2491 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2492 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2493 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2494 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2495 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2498 this.hear = new enchant.Sprite(64, 64);
2499 this.hear.image = game.assets[EResPathReimu.HEAR];
2500 this.hear.x = -CHARA_WIDTH / 2;
2501 this.hear.y = -CHARA_HEIGHT / 2;
2503 this.sub1 = new enchant.Sprite(64, 64);
2504 this.sub1.image = game.assets[EResPathReimu.SUB1];
2505 this.sub1.x = -CHARA_WIDTH / 2;
2506 this.sub1.y = -CHARA_HEIGHT / 2;
2508 this.okazari = new Okazari(this);
2510 // this.imgGroup._style.zIndex = 1;
2513 this.imgGroup.addChild(this.shadow);
2514 this.imgBody.addChild(this.okazari);
2515 this.imgBody.addChild(this);
2516 this.imgBody.addChild(this.face);
2517 this.imgBody.addChild(this.hear);
2518 this.imgBody.addChild(this.sub1);
2519 this.myScale(this.myScaleX, this.myScaleY)
2520 if(this instanceof Player){
2521 // this.myScaleX = 0.5;
2522 // this.myScaleY = 0.5;
2524 this.budge = new enchant.Sprite(16, 16);
2525 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2526 this.imgBody.addChild(this.budge);
2527 this.budge.x -= this.getWidth()/2;
2528 this.budge.y -= this.getHeight()/2;
2529 this.budge.scale(this.myScaleX, this.myScaleX);
2531 this.imgGroup.width = this.getWidth();
2532 this.imgGroup.height = this.getHeight();
2533 this.imgGroup.addChild(this.imgBody);
2534 backgroundMap.addChild(this.imgGroup);
2535 this._tweet = new TTweet(148, 64);
2537 this.imgGroup.addChild(this._tweet);
2538 this.imgGroup.x = x;
2539 this.imgGroup.y = y;
2542 this.action = new Action(this);
2544 this.exLvHash[EExSkill.KEKKAI] = 1;
2545 this.exValueHash[EExSkill.KEKKAI] = 100;
2549 game.onload = function(){
2553 def.ObjSprite = ObjSprite;
2554 def.Yukkuri = Yukkuri;
2555 def.nodeSort = nodeSort;
2556 mangTouch = new MangTouch(ctl);
2557 mangMsg = new MangMsg(ctl);
2558 ctl.setDefined(def);
2559 backgroundMap.image = game.assets[EResPath.MAP0];
2560 backgroundMap.loadData(_mapData);
2561 backgroundMap.collisionData = _collisionData;
2563 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
2564 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2565 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2566 fieldBg.image = fieldSurface;
2570 windowFront.image = windowSurface;
2573 windowFront.opacity = 0.5;
2575 windowSurface.context.fillStyle = '#000';
2576 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
2578 menuSurface.context.fillStyle = '#000';
2579 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
2580 menuBg.image = menuSurface;
2581 menuBg.x = EMenuPos.X;
2582 menuBg.y = EMenuPos.Y;
2583 backgroundMap.addChild(fieldBg);
2584 mangIcon = new MangIcon(ctl, menuBg);
2586 game.rootScene.addChild(backgroundMap);
2587 // game.rootScene.addChild(windowFront);
2588 // game.rootScene.addChild(gwindow);
2589 // var gwindow = new GWindow(ctl, {}, 0, 0, 80, 80);
2590 game.rootScene.addChild(menuBg);
2592 // var labelGroup = new LabelGroup();
2593 mangLabel = new MangLabel(ctl, menuBg);
2594 // var info = new Label("ゆっくり");
2595 // info.color = "#ffffff";
2596 // info.font = "14px 'Times New Roman'";
2598 // info.y = GAME_HEIGHT / 2;
2599 // labelGroup.addChild(info);
2600 // menuBg.addChild(labelGroup);
2603 // var food = new def.Food("apple", 200, 250);
2604 backgroundMap.addChild(foodGroup);
2605 // backgroundMap.addChild(placeGroup);
2606 var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
2607 new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
2608 new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
2609 new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
2610 new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2611 // new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
2612 new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
2613 // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
2614 // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
2615 // new Unun(100, 100);
2616 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2618 // var input = new Label("<form name='hoge' style='background-color:#ff0000;'>" +
2619 // "<input type='text' name='text'>" +
2620 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2623 // input.element.innerHTML = "<form name='hoge' style='background-color:#ff0000;'>" +
2624 // "<input type='text' name='text'>" +
2625 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2627 // menuBg.addChild(input);
2628 // game.rootScene.addChild(input);
2629 // var inputEvent = new Label('');
2631 // game.rootScene.addChild(output);
2632 // output.onenterframe = function(e) {
2633 // output.text = document.hoge.text.value;
2636 // enchant.Node.GAddEvent = function(){
2638 var popupStatus = null;
2639 var testFlg = false;
2641 game._element.addEventListener('mousemove', function (e) {
2642 var mang = mangTouch.get(ctl.getCurrentCommand());
2643 if(EMenuPos.X < e.layerX){
2644 var ex = e.layerX - EMenuPos.X;
2647 // console.log("ex:" + ex);
2648 for(var i=0;i<mangIcon.cmdIcons.length;i++){
2649 var icon = mangIcon.cmdIcons[i];
2650 if(icon.x <= ex && ex <= (icon.x + ICON_WIDTH)
2651 && icon.y <= ey && ey <= (icon.y + ICON_HEIGHT)
2654 if(popupStatus !== i){
2655 ctl.popup.renew(game.rootScene, EMenuPos.X + 5, e.layerY + ICON_HEIGHT / 2, 80, 80);
2656 ctl.popup.setText(icon.text);
2664 ctl.popup.opacity = 0.9;
2665 ctl.popup.drawText();
2668 ctl.popup.opacity = 0;
2670 // console.log(e.layerX + ":" + e.layerY);
2673 // enchant.Core.instance._element.addEventListener('mousemove', function(e) {
2675 // game.rootScene.addEventListener('mousemove', function (e) {
2676 // console.log("mmmmmmmmm");
2680 game.rootScene.addEventListener('touchstart', function (e) {
2681 game.touched = true;
2682 var mang = mangTouch.get(ctl.getCurrentCommand());
2685 game.rootScene.addEventListener('touchmove', function (e) {
2686 var mang = mangTouch.get(ctl.getCurrentCommand());
2689 game.rootScene.addEventListener('touchend', function (e) {
2690 var mang = mangTouch.get(ctl.getCurrentCommand());
2692 game.touched = false;
2696 game.rootScene.addEventListener('enterframe', function(e){
2698 mangLabel.draw(player);
2699 if(this.age%BASE_FPS == 0 ){
2702 ctl.time += TIME_SPEED;
2704 this.addEventListener('enterframe', function(){
2705 //The priority processing of display instead of z-index
2707 backgroundMap.childNodes.sort(nodeSort);