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 KUKI : './data/system/kuki.png',
73 MIYUKKURI : './data/system/miyukkuri.png',
74 // PLACE_TREE : './data/system/rapture.png',
80 FACE_NORMAL : './data/reimu/face_normal1.png',
81 FACE_TIRED : './data/reimu/face_tired1.png',
82 FACE_ANGRY : './data/reimu/face_angry1.png',
83 FACE_CRY1 : './data/reimu/face_cry1.png',
84 FACE_CRY2 : './data/reimu/face_cry2.png',
85 FACE_EAT1 : './data/reimu/face_eat1.png',
86 FACE_EAT2 : './data/reimu/face_eat2.png',
87 FACE_HAPPY1 : './data/reimu/face_happy1.png',
88 FACE_HAPPY2 : './data/reimu/face_happy2.png',
89 FACE_SLEEP : './data/reimu/face_sleep1.png',
90 HEAR : './data/reimu/hear1.png',
91 OKAZARI : './data/reimu/okazari.png',
92 SUB1 : './data/reimu/sub1.png',
119 WORLD_PICOPICO_HUMMER: 5,
126 HEIGHT : GAME_HEIGHT,
132 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
143 MOVE_TO_EAT_START: 10,
144 MOVE_TO_EAT_UNDERWAY: 11,
148 UNUN_SMELL_START : 15,
149 UNUN_SMELL_WAIT : 16,
152 COMMUNICATE_START : 19,
153 COMMUNICATE_WAIT: 20,
154 COMMUNICATE_RECV: 21,
155 MOVE_TO_PLACE_START_HOMELESS: 22,
156 MOVE_TO_PLACE_HOMELESS_UNDERWAY: 23,
157 DECLARE_PLACE_HOMELESS: 24,
158 MOVE_TO_HUNT_START: 25,
194 LEARN_NO_FOOD_IN_PLACE:19,
201 var EWalkAnimation = {
232 NO_FOOD_IN_PLACE : 1,
250 include("./lib/Animation.js");
251 include("./lib/FormSprite.js");
252 include("./lib/Util.js");
255 var ObjSprite = enchant.Class.create(enchant.Sprite,{
256 initialize: function (w, h){
257 enchant.Sprite.call(this, w, h);
260 // // new BoxLabel(this.ctl,100, e.x, e.y);
261 // var box = new Box(this.ctl, 200, 200);
262 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
264 getStatusForDisplay: function (){
273 getWidth: function(){
276 getHeight: function(){
280 return (this.id !== null && this.id !== undefined);
282 removeAll: function(){
287 undefineAll: function (){
288 for(var key in this){
289 // if(this.hasOwnProperty(key)){
297 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
308 //-Event register [onactionstart,onactiontick,onactionend]
309 if(eventFunctions !== undefined){
310 for(var key in eventFunctions){
311 params[key] = eventFunctions[key];
314 return this.tween(params);
316 function plusFrameScale(frame, scale){
317 return (frame/2) * (1 - scale)
322 include("./lang/ja.js");
323 window.onload = function(){
324 var nodeSort = function (a, b){
325 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
328 else if(typeof a.id === "undefined"){
331 else if(typeof b.id === "undefined"){
336 if(a instanceof Box && b instanceof Box){
339 if(a instanceof Box){
342 if(b instanceof Box){
345 var budgeValue = 10 + 28;
346 var shadowValue = -28;
347 //okazariは他のbodyと比べて11低い
348 var okazariValue = 37 + 11;
349 var okazariReimuValue = 32;
351 var tweetValue = 288;
353 var miYukkuriValue = 363;
355 if(a.type == "shadow"){
356 ay += shadowValue * a.scaleValue;
358 else if(a.type == "body" && a.classname == "Okazari" && a.spname == "reimu"){
359 ay += okazariReimuValue * a.scaleValue - a.anim.cnt;
361 else if(a.type == "body"){
362 ay += bodyValue * a.scaleValue - a.anim.cnt;
364 else if(a.type == "tweet"){
365 ay += tweetValue * a.scaleValue;
367 else if(a.type == "budge"){
368 ay += budgeValue * a.scaleValue - a.anim.cnt;
370 else if(a.type == "kuki"){
371 ay += kukiValue * a.scaleValue - a.anim.cnt;
375 if(b.type == "shadow"){
376 by += shadowValue * b.scaleValue;
378 else if(b.type == "body" && b.classname == "Okazari" && b.spname == "reimu"){
379 by += okazariReimuValue * b.scaleValue - b.anim.cnt;
381 else if(b.type == "body" && b.classname == "Okazari"){
382 by += okazariValue * b.scaleValue - b.anim.cnt;
384 else if(b.type == "body"){
385 by += bodyValue * b.scaleValue - b.anim.cnt;
387 else if(b.type == "tweet"){
388 by += tweetValue * b.scaleValue;
390 else if(b.type == "budge"){
391 by += budgeValue * b.scaleValue - b.anim.cnt;
393 else if(b.type == "kuki"){
394 by += kukiValue * b.scaleValue - b.anim.cnt;
399 if(a instanceof SpriteGroup){
403 if(b instanceof SpriteGroup){
407 if(a instanceof MiYukkuri){
408 ay += miYukkuriValue * a.scaleValue - a.anim.cnt;
410 if(b instanceof MiYukkuri){
412 by += miYukkuriValue * b.scaleValue - b.anim.cnt;
415 if(a instanceof Place){
416 ay += Math.round(a.height * 0.7);
418 if(b instanceof Place){
419 by += Math.round(b.height * 0.7);
421 // if(a.flgMiYukkuri){
422 // ay += CHARA_HEIGHT;
424 // if(b.flgMiYukkuri){
425 // by += CHARA_HEIGHT;
428 if(Math.round(ay) < Math.round(by))return -1;
429 else if(Math.round(ay) > Math.round(by))return 1;
430 if(a.id < b.id)return -1;
431 else if(a.id > b.id)return 1;
437 var def = new Object();
438 var foodGroup = new Group();
439 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
440 SpriteGroup.prototype.classname = "";
441 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
442 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
443 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
444 game = new Game(GAME_WIDTH, GAME_HEIGHT);
448 var tmpName = EResPathReimu.getName();
450 for(var _v in EResPathReimu){
451 if(typeof EResPathReimu[_v] === "function")continue;
452 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
458 for(var _v in EResPath){
459 _loadArr[i] = EResPath[_v];
462 game.preload(_loadArr);
463 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
464 var backgroundMap = new MapGroup(16, 16);
465 App.backgroundMap = backgroundMap;
466 include("./class.js");
467 include("./ctrl.js");
470 ctl.setBackgroundMap(backgroundMap);
471 var Action = enchant.Class.create({
472 initialize: function (yukkuri){
473 this.status = EAction.THINK;
474 this.yukkuri = yukkuri;
475 this.isMoving = false;
476 this.targetNode = null;
478 getStatus: function(){
481 setStatus: function(eaction){
482 this.status = eaction;
485 if(this.yukkuri.isDead()){
486 this.status = EAction.DEAD;
488 // else if(this.yukkuri.isSleep()){
489 // this.status = EAction.SLEEP;
498 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
500 this.setStatus(EAction.THINK);
501 console.log("wait cnt end");
504 case EAction.THINK_IN_HOME:
507 this.think_in_home();
509 case EAction.EAT_IN_HOME:
514 if(this.yukkuri.age%2 === 0){
515 this.yukkuri.changeFace();
517 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
520 case EAction.MOVE_TO_EAT_START:
521 this.move_to_eat_start();
523 case EAction.MOVE_TO_EAT_UNDERWAY:
529 case EAction.SLEEP_START:
532 case EAction.SLEEP_WAIT:
537 case EAction.EAT_START:
540 case EAction.EAT_WAIT:
542 case EAction.UNUN_START:
545 case EAction.UNUN_WAIT:
547 case EAction.MOVE_TO_COMMAND:
548 this.move_to_command();
550 case EAction.UNUN_SMELL_START:
551 this.unun_smell_start();
553 case EAction.COMMUNICATE_START:
554 this.communicate_start();
556 case EAction.COMMUNICATE_WAIT:
557 case EAction.COMMUNICATE_RECV:
558 if(this.yukkuri.communicateYukkuri != null){
559 var _s = this.yukkuri.communicateYukkuri.action.getStatus();
560 if(this.yukkuri.communicateYukkuri.isDead()
561 || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
562 this.setStatus(EAction.THINK);
563 this.yukkuri.animation();
567 case EAction.MOVE_TO_PLACE_START_HOMELESS:
568 this.move_to_place_start_homeless();
570 case EAction.DECLARE_PLACE_HOMELESS:
571 this.declare_place_homeless();
573 case EAction.MOVE_TO_HUNT_START:
574 this.move_to_hunt_start();
576 case EAction.HUNT_START:
579 case EAction.MOVE_GOTO_HOME:
580 this.move_goto_home();
582 case EAction.IN_HOME:
587 this.yukkuri.reverse();
589 // thinkHavePlace: function(){
590 // var date = ctl.getDate();
591 // if(this.yukkuri.isPlaceRange()){
594 // if(date === EDate.EVENING
595 // || date === EDate.NIGHT
596 // || date === EDate.MIDNIGHT
598 // this.setStatus(EAction.MOVE_GOTO_HOME);
601 // else if(date === EDate.EVENING){
602 // // if(this.yukkuri.isItemsMax()){
603 // // this.setStatus(EAction.IN_HOME);
606 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
610 // if(this.yukkuri.isVeryKuhuku()){
614 // this.setStatus(EAction.MOVE_GOTO_HOME);
616 // else if(this.yukkuri.isSleep()){
617 // this.setStatus(EAction.SLEEP_START);
619 // else if(this.yukkuri.getUnun() >= 80){
620 // this.setStatus(EAction.UNUN_START);
623 // this.yukkuri.changeFace();
627 think_in_home: function(){
628 var date = ctl.getDate();
629 if((date === EDate.MIDNIGHT)
630 && !this.yukkuri.isSleep()
631 && !this.yukkuri.isVeryKuhuku()
635 "nextStatus":EAction.THINK_IN_HOME,
636 "myYukkuri": this.yukkuri
640 else if(date === EDate.EVENING){
643 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
644 this.setStatus(EAction.EAT_IN_HOME);
647 //marisa is hunting move
648 if(this.yukkuri.beforeHuntingFood !== null){
649 new MoveToHuntEvent({
651 "targetNode": this.yukkuri.beforeHuntingFood,
653 "myYukkuri": this.yukkuri
657 this.setStatus(EAction.WALK);
661 eat_in_home: function(){
663 "targetNode": this.yukkuri.getPlace(),
665 "myYukkuri": this.yukkuri
668 move_to_eat_start : function(){
671 "targetNode": this.targetNode,
673 "myYukkuri": this.yukkuri
679 walk : function(retryCounter){
680 if(retryCounter > 15){
682 this.status = EAction.NONE;
683 console.log("retryCount over");
686 if(this.yukkuri.formSprite.tlQueueLength() === 0){
687 // if(this.yukkuri.imgGroup.tl.queue.length === 0){
689 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
691 this.isMoving = false;
692 this.status = EAction.THINK;
696 var xpos = 150 + rand(40) - (retryCounter * 10);
697 var ypos = 150 + rand(40) - (retryCounter * 10);
699 this.yukkuri.vx = xpos;
700 this.yukkuri.vy = ypos;
701 this.yukkuri.setDirection(EDirection.RIGHT);
703 else if(rand(8) === 0){
705 this.yukkuri.vy = -ypos;
707 else if(rand(8) == 1){
708 this.yukkuri.vx = xpos;
709 this.yukkuri.vy = -ypos;
710 this.yukkuri.setDirection(EDirection.RIGHT);
712 else if(rand(8) == 2){
713 this.yukkuri.vx = xpos;
715 this.yukkuri.setDirection(EDirection.RIGHT);
717 else if(rand(8) == 3){
718 this.yukkuri.vx = xpos;
719 this.yukkuri.vy = ypos;
720 this.yukkuri.setDirection(EDirection.RIGHT);
722 else if(rand(8) == 4){
724 this.yukkuri.vy = ypos;
726 else if(rand(8) == 5){
727 this.yukkuri.vx = -xpos;
728 this.yukkuri.vy = ypos;
729 this.yukkuri.setDirection(EDirection.LEFT);
731 else if(rand(8) == 6){
732 this.yukkuri.vx = -xpos;
734 this.yukkuri.setDirection(EDirection.LEFT);
736 else if(rand(8) == 7){
737 this.yukkuri.vx = -xpos;
738 this.yukkuri.vy = -ypos;
739 this.yukkuri.setDirection(EDirection.LEFT);
741 if (this.yukkuri.vx || this.yukkuri.vy) {
742 var map = ctl.backgroundMap;
743 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
744 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
745 var x = this.yukkuri.getX() + this.yukkuri.vx;
746 var y = this.yukkuri.getY() + this.yukkuri.vy + this.yukkuri.getHeight() / 2;
747 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
748 // console.log("あたってないよ:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY());
749 // console.log("X:" + this.yukkuri.moveX);
750 // console.log("Y:" + this.yukkuri.moveY);
751 this.isMoving = true;
752 this.yukkuri.reverse();
753 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
754 mangMsg.output(this.yukkuri,EMsg.WALK);
756 this.targetNode = null;
758 // console.log("HIT:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY() + "," + this.yukkuri.vx + ":" + this.yukkuri.vy);
759 this.walk(retryCounter+1);
765 sleep_start: function(){
768 "myYukkuri": this.yukkuri
772 mangMsg.output(this.yukkuri, EMsg.DEAD);
773 this.yukkuri.tlPause();
774 this.yukkuri.setBodyImage(EBody.DEAD);
776 eat_start: function(){
779 "targetNode": this.targetNode,
781 "myYukkuri": this.yukkuri
785 unun_start: function(){
788 "myYukkuri": this.yukkuri
791 unun_smell_start: function(){
794 "myYukkuri": this.yukkuri
797 communicate_start:function(){
798 new ComSayHelloSendEvent({
800 "targetNode": this.targetNode,
802 "myYukkuri": this.yukkuri
805 move_to_place_start_homeless:function(){
806 new MoveToPlaceStartHomelessEvent({
807 "targetNode": this.targetNode,
809 "myYukkuri": this.yukkuri
812 declare_place_homeless:function(){
813 new DeclarePlaceHomelessEvent({
814 "targetNode": this.targetNode,
816 "myYukkuri": this.yukkuri
819 move_to_hunt_start:function(){
820 new MoveToHuntEvent({
822 "targetNode": this.targetNode,
824 "myYukkuri": this.yukkuri
827 hunt_start:function(){
830 "targetNode": this.targetNode,
832 "myYukkuri": this.yukkuri
835 move_goto_home:function(){
836 var place = this.yukkuri.getPlace();
837 new MoveGotoHomeEvent({
841 "myYukkuri": this.yukkuri
845 var place = this.yukkuri.getPlace();
846 if(place != null && place.isWorld()){
851 "myYukkuri": this.yukkuri
854 if(place && !place.isWorld())place.undefineAll();
855 this.yukkuri.declarePlace(null);
856 this.setStatus(EAction.WAIT);
857 mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
858 this.yukkuri.setFaceImage(EFace.CRY2);
860 "waitframe": FPS * 3.0,
862 "myYukkuri": this.yukkuri
866 move_to_command: function(){
867 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
868 new MoveToCommandEvent({
871 "myYukkuri": this.yukkuri
876 this.yukkuri.clearSearchObject();
877 var nodes = ctl.getObjs();
880 for (var key in nodes) {
881 var node = nodes[key];
882 if(node === null || node === undefined)continue;
883 if(this.yukkuri.id === node.id)continue;
887 && !(this.targetNode instanceof Unun)
888 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
890 this.yukkuri.addSearchObject(ESearch.UNUN, node);
893 else if (node instanceof Food && node.amount > 0) {
894 if(this.yukkuri.within(node, this.yukkuri.getRange())){
895 this.yukkuri.addSearchObject(ESearch.FOOD, node);
899 else if(node instanceof Yukkuri){
900 if(node.grow != EGrow.FRUIT_BABY && this.yukkuri.within(node, this.yukkuri.getRange())){
901 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
905 else if(node instanceof Place){
906 if(this.yukkuri instanceof Player){
908 if(this.yukkuri.within(node, this.yukkuri.getRange())){
909 this.yukkuri.addSearchObject(ESearch.PLACE, node);
913 this.status = EAction.WALK;
917 * Range範囲内のObjSprを管理する
918 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
922 var SearchObjectMang = enchant.Class.create({
923 initialize: function (){
925 this.currentCmdObject = null;
929 for(var key in ESearch){
930 var esearch = ESearch[key];
931 this.datas[esearch] = [];
934 add :function(esearch, node){
935 this.datas[esearch].push(node);
938 for(var key in ESearch){
939 var esearch = ESearch[key];
940 this.datas[esearch].length = 0;
942 // this.datas.length = 0;
945 get:function (esearch){
946 return this.datas[esearch];
948 getNear:function (esearch, yukkuri){
949 var objects = this.datas[esearch];
950 var nearDistance = null;
952 for(var i=0;i<objects.length;i++){
953 var object = objects[i];
954 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
955 if(nearDistance === null || nearDistance > nowDistance){
956 nearDistance = nowDistance;
962 callEvent: function(yukkuri){
963 if(yukkuri.cmdQueue.length !== 0){
964 this.currentCmdObject = yukkuri.cmdQueue.shift();
965 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
968 if(yukkuri.isSleep()){
969 yukkuri.action.setStatus(EAction.SLEEP_START);
972 else if(yukkuri.getUnun() >= 80){
973 yukkuri.action.setStatus(EAction.UNUN_START);
977 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
978 yukkuri.action.targetNode = yukkuri.getPlace();
979 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
982 if(yukkuri.isVeryKuhuku()){
984 var foods = this.get(ESearch.FOOD);
985 if(foods.length > 0){
986 var foods = this.get(ESearch.FOOD);
987 food = this.getNear(ESearch.FOOD, yukkuri);
989 yukkuri.action.targetNode = food;
990 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
994 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
995 yukkuri.action.setStatus(EAction.WALK);
1000 if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
1001 yukkuri.action.targetNode = yukkuri.getPlace();
1002 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
1006 yukkuri.action.setStatus(EAction.WALK);
1012 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
1013 food = this.getNear(ESearch.FOOD, yukkuri);
1015 yukkuri.action.targetNode = food;
1016 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
1020 ununs = this.get(ESearch.UNUN);
1021 if(ununs.length !== 0){
1022 yukkuri.action.targetNode = yukkuri.getPlace();
1023 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
1026 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
1027 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
1028 yukkuri.action.targetNode = searchYukkuri;
1029 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
1032 if(!yukkuri.isPlace()){
1033 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
1034 if(searchYukkuri != null && !searchYukkuri.isOwner()){
1035 yukkuri.action.targetNode = searchYukkuri;
1036 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
1040 yukkuri.action.setStatus(EAction.WALK);
1045 var Event = enchant.Class.create({
1046 initialize: function (_data){
1049 onactionstart:function(self){
1050 return this._onactionstart;
1052 _onactionstart:function(e){
1053 if(typeof e === "undefined")return;
1055 onactiontick:function(self){
1057 if(typeof e === "undefined")return;
1060 onactionend:function(self){
1062 if(typeof e === "undefined")return;
1066 var WalkEvent = enchant.Class.create(Event,{
1067 initialize: function (_data){
1069 this.yukkuri = _data.myYukkuri;
1070 this.action = _data.action;
1072 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1073 this.action.setStatus(EAction.SLEEP_WAIT);
1074 this.yukkuri.setFaceImage(EFace.SLEEP);
1075 this.yukkuri.tlPause();
1077 this.yukkuri.addEventListener('enterframe', function() {
1078 var yukkuri = self.yukkuri;
1086 var SleepEvent = enchant.Class.create(Event,{
1087 initialize: function (_data){
1089 this.yukkuri = _data.myYukkuri;
1090 this.action = _data.action;
1092 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1093 this.action.setStatus(EAction.SLEEP_WAIT);
1094 this.yukkuri.setFaceImage(EFace.SLEEP);
1095 this.yukkuri.tlPause();
1098 this.yukkuri.addEventListener('enterframe', function() {
1099 var yukkuri = self.yukkuri;
1100 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
1101 if(yukkuri.param.sleep <= 0){
1102 yukkuri.param.sleep = 0;
1103 this.removeEventListener("enterframe",arguments.callee);
1104 mangMsg.output(self.yukkuri, EMsg.GET_UP);
1105 yukkuri.setFaceImage(EFace.NORMAL);
1107 // self.action.setStatus(EAction.WAIT);
1108 if(self.data.nextStatus !== undefined){
1109 self.action.setStatus(self.data.nextStatus);
1111 self.action.setStatus(EAction.THINK);
1118 var UnunEvent = enchant.Class.create(Event,{
1119 initialize: function (_data){
1121 this.yukkuri = _data.myYukkuri;
1122 this.action = _data.action;
1123 this.action.setStatus(EAction.UNUN_WAIT);
1124 mangMsg.output(this.yukkuri, EMsg.UNUN);
1125 this.yukkuri.setFaceImage(EFace.HAPPY2);
1128 this.yukkuri.wait(sec, {
1129 "onactionend": this.onactionend(this)
1132 onactionend:function(self){
1134 if(typeof e === "undefined")return;
1135 self.yukkuri.unun();
1136 self.action.setStatus(EAction.WAIT);
1137 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1139 "waitframe": FPS * 1.5,
1140 "action": self.action,
1141 "myYukkuri": self.yukkuri
1146 var WaitEvent = enchant.Class.create(Event,{
1147 initialize: function (_data){
1149 this.yukkuri = _data.myYukkuri;
1150 this.action = _data.action;
1151 this.waitframe = _data.waitframe;
1152 this.yukkuri.wait(this.waitframe, {
1153 "onactionstart": this.onactionstart(this),
1154 "onactiontick": this.onactiontick(this),
1155 "onactionend": this.onactionend(this)
1158 onactionend:function(self){
1160 if(typeof e === "undefined")return;
1161 self.action.setStatus(EAction.THINK);
1165 var UnunSmellEvent = enchant.Class.create(Event,{
1166 initialize: function (_data){
1168 this.yukkuri = _data.myYukkuri;
1169 this.action = _data.action;
1170 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1171 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1172 this.yukkuri.setFaceImage(EFace.CRY1);
1174 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1175 this.yukkuri.wait(sec, {
1176 "onactionend": this.onactionend(this)
1179 onactionend:function(self){
1181 if(typeof e === "undefined")return;
1182 self.action.setStatus(EAction.WALK);
1187 var EatEvent = enchant.Class.create(Event,{
1188 initialize: function (_data){
1190 this.yukkuri = _data.myYukkuri;
1191 this.food = _data.targetNode;
1192 this.action = _data.action;
1193 this.action.setStatus(EAction.EAT_WAIT);
1195 var sec = BASE_FPS * 3;
1196 if(this.yukkuri.eat(this.food)){
1197 mangMsg.output(this.yukkuri, EMsg.EAT);
1198 this.yukkuri.setFaceImage(EFace.EAT2);
1201 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1202 this.yukkuri.setFaceImage(EFace.CRY2);
1204 this.yukkuri.wait(sec, {
1205 "onactionend": this.onactionend(this)
1208 onactionend:function(self){
1210 if(typeof e === "undefined")return;
1211 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
1212 self.action.setStatus(EAction.THINK);
1213 self.yukkuri.setFaceImage(EFace.NORMAL);
1215 self.action.setStatus(EAction.EAT_START);
1222 * -When yukkuri find Food.
1225 * targetNode: enchant.Node
1229 var MoveToEatEvent = enchant.Class.create(Event,{
1230 initialize: function (_data){
1232 this.yukkuri = this.data.myYukkuri;
1233 this.action = this.data.action;
1235 var yukkuri = this.yukkuri;
1236 var node = this.data.targetNode;
1238 if(this.data.type == "food"){
1239 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1240 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2 + yukkuri.getWidth() / 2;
1241 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2 + yukkuri.getHeight() / 2;
1242 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1243 var frame = distance + distance/5 + 1;
1244 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1245 yukkuri.setAutoDirection();
1247 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1249 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1250 "onactiontick": this.onactiontick(this),
1251 "onactionend": this.onactionend(this)
1255 onactiontick:function(self){
1257 if(typeof e === "undefined")return;
1260 onactionend:function(self){
1262 if(typeof e === "undefined")return;
1263 self.action.setStatus(EAction.EAT_START);
1267 var MoveToHuntEvent = enchant.Class.create(Event,{
1268 initialize: function (_data){
1270 this.yukkuri = this.data.myYukkuri;
1271 this.action = this.data.action;
1273 var yukkuri = this.yukkuri;
1274 var node = this.data.targetNode;
1277 var nodeWidth = node.width;
1278 var nodeHeight = node.height;
1282 if(this.data.type == "food"){
1283 this.action.setStatus(EAction.WAIT);
1284 yukkuri.vx = nodeX - yukkuri.getX() + yukkuri.getWidth() / 2;
1285 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2 + yukkuri.getHeight() / 2;
1286 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1287 var frame = distance + distance/5 + 1;
1288 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1289 yukkuri.setAutoDirection();
1291 mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
1293 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1294 "onactionend": this.onactionend(this)
1298 onactionend:function(self){
1300 if(typeof e === "undefined")return;
1301 self.action.setStatus(EAction.HUNT_START);
1305 var HuntStartEvent = enchant.Class.create(Event,{
1306 initialize: function (_data){
1307 Event.call(this, _data);
1310 this.yukkuri = _data.myYukkuri;
1311 this.food = _data.targetNode;
1312 this.action = _data.action;
1313 this.action.setStatus(EAction.WAIT);
1314 this.huntingStatus = "hunting";
1316 // this.yukkuri.beforeHuntingFood = this.food;
1317 if(this.food.isWorld()){
1318 this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
1319 var sec = BASE_FPS * 8;
1320 if(this.yukkuri.hunt(this.food)){
1321 this.huntingStatus = "hunting";
1322 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1323 this.yukkuri.setFaceImage(EFace.HAPPY1);
1325 if(this.yukkuri.isItemsMax()){
1327 this.huntingStatus = "return";
1328 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1329 this.yukkuri.setFaceImage(EFace.NORMAL);
1332 this.huntingStatus = "cry";
1333 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1334 this.yukkuri.setFaceImage(EFace.CRY2);
1339 this.yukkuri.beforeHuntingFood = null;
1341 this.huntingStatus = "cry";
1342 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1343 this.yukkuri.setFaceImage(EFace.CRY2);
1346 this.yukkuri.wait(sec, {
1347 "onactiontick": this.onactiontick(this),
1348 "onactionend": this.onactionend(this)
1351 onactiontick:function(self){
1353 if(typeof e === "undefined")return;
1355 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1356 if(this.age%(BASE_FPS * 5) == 0){
1357 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1358 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1363 onactionend:function(self){
1365 if(typeof e === "undefined")return;
1366 if(self.huntingStatus == "hunting"){
1367 if(self.yukkuri.isItemsMax()){
1368 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1369 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1371 self.action.setStatus(EAction.HUNT_START);
1374 else if(self.huntingStatus == "return"){
1375 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1377 else if(self.huntingStatus === "cry"){
1378 // self.action.setStatus(EAction.THINK);
1379 self.action.setStatus(EAction.WALK);
1386 this.yukkuri = null;
1391 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1392 initialize: function (_data){
1394 this.yukkuri = this.data.myYukkuri;
1395 this.action = this.data.action;
1397 var yukkuri = this.yukkuri;
1398 var place = this.data.targetNode;
1400 if(this.data.type == "hunt_end"){
1401 this.action.setStatus(EAction.WAIT);
1402 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1403 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1404 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1405 var frame = distance + distance/2 + 1 ;
1406 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1407 yukkuri.setAutoDirection();
1410 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1412 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1413 "onactiontick": this.onactiontick(this),
1414 "onactionend": this.onactionend(this)
1418 onactiontick:function(self){
1420 if(typeof e === "undefined")return;
1421 if(this.age%(BASE_FPS * 5) == 0){
1422 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1426 onactionend:function(self){
1428 if(typeof e === "undefined")return;
1429 self.action.setStatus(EAction.IN_HOME);
1435 this.yukkuri = null;
1439 var InHomeEvent = enchant.Class.create(Event,{
1440 initialize: function (_data){
1442 this.yukkuri = this.data.myYukkuri;
1443 this.action = this.data.action;
1445 var yukkuri = this.yukkuri;
1446 var place = this.data.targetNode;
1448 if(yukkuri.isVeryKuhuku()){
1450 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1451 this.action.setStatus(EAction.EAT_IN_HOME);
1454 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1456 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1457 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1458 this.action.setStatus(EAction.THINK);
1461 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1462 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1467 this.action.setStatus(EAction.WAIT);
1468 var items = this.yukkuri.getItems();
1469 if(items.length > 0){
1470 place.setItems(items);
1474 var sec = BASE_FPS * 10;
1475 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1476 this.yukkuri.wait(sec, {
1477 "onactiontick": this.onactiontick(this),
1478 "onactionend": this.onactionend(this)
1481 onactiontick:function(self){
1483 if(typeof e === "undefined")return;
1484 if(this.age%(BASE_FPS * 5) == 0){
1485 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1489 onactionend:function(self){
1491 if(typeof e === "undefined")return;
1492 self.action.setStatus(EAction.THINK_IN_HOME);
1496 var EatInHomeEvent = enchant.Class.create(Event,{
1497 initialize: function (_data){
1499 this.yukkuri = _data.myYukkuri;
1500 this.place = _data.targetNode;
1501 this.action = _data.action;
1502 this.action.setStatus(EAction.EAT_WAIT);
1504 var sec = BASE_FPS * 3;
1505 var foodHash = this.place.getFoodHash();
1506 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1507 mangMsg.output(this.yukkuri, EMsg.EAT);
1508 this.yukkuri.setFaceImage(EFace.EAT2);
1511 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1512 this.yukkuri.setFaceImage(EFace.CRY2);
1515 this.yukkuri.wait(sec, {
1516 "onactionend": this.onactionend(this)
1519 onactionend:function(self){
1521 if(typeof e === "undefined")return;
1522 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1523 self.action.setStatus(EAction.EAT_IN_HOME);
1525 // new EatInHomeEvent({
1526 // "targetNode": self.place,
1527 // "action": self.action,
1528 // "myYukkuri": self.yukkuri
1531 self.action.setStatus(EAction.THINK_IN_HOME);
1532 self.yukkuri.setFaceImage(EFace.NORMAL);
1539 var MoveToCommandEvent = enchant.Class.create(Event,{
1540 initialize: function (_data){
1542 this.yukkuri = this.data.myYukkuri;
1543 this.action = this.data.action;
1544 // this.vx = this.data.cmdObject.vx;
1545 // this.vy = this.data.cmdObject.vy;
1546 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1549 var yukkuri = this.yukkuri;
1550 this.action.status = EAction.WAIT;
1551 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1552 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1553 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1554 var frame = distance + distance/2 + 1;
1555 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1557 yukkuri.setAutoDirection();
1559 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1560 "onactiontick": this.onactiontick(this),
1561 "onactionend": this.onactionend(this)
1564 onactiontick:function(self){
1566 if(typeof e === "undefined")return;
1569 onactionend:function(self){
1571 if(typeof e === "undefined")return;
1572 self.action.setStatus(EAction.THINK);
1577 * Say hello contact to send communication .
1579 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1580 initialize: function (_data){
1582 this.yukkuri = _data.myYukkuri;
1583 this.targetYukkuri = _data.targetNode;
1584 this.action = _data.action;
1585 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1586 // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1587 // this.targetYukkuri.tlPause();
1588 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1589 this.yukkuri.send(this.targetYukkuri, {
1590 "actionStatus":EAction.COMMUNICATE_RECV,
1591 "yukkuri":this.yukkuri
1595 this.yukkuri.tlPause();
1596 this.yukkuri.syncDirection(this.targetYukkuri);
1598 this.yukkuri.addAddress(this.targetYukkuri);
1599 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1601 var sec = BASE_FPS * 2;
1602 this.yukkuri.wait(sec, {
1603 "onactiontick": this.onactiontick(this),
1604 "onactionend": this.onactionend(this)
1607 onactiontick:function(self){
1609 if(typeof e === "undefined")return;
1612 onactionend:function(self){
1614 if(typeof e === "undefined")return;
1615 new ComSayHelloRecvEvent({
1617 "targetNode": self.yukkuri,
1618 "action": self.targetYukkuri.action,
1619 "myYukkuri": self.targetYukkuri
1624 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1625 initialize: function (_data){
1627 this.yukkuri = _data.myYukkuri;
1628 this.targetYukkuri = _data.targetNode;
1629 this.action = _data.action;
1630 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1631 this.yukkuri.addAddress(this.targetYukkuri);
1632 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1634 var sec = BASE_FPS * 2;
1635 this.yukkuri.wait(sec, {
1636 "onactiontick": this.onactiontick(this),
1637 "onactionend": this.onactionend(this)
1640 onactiontick:function(self){
1642 if(typeof e === "undefined")return;
1645 onactionend:function(self){
1647 if(typeof e === "undefined")return;
1648 self.action.setStatus(EAction.THINK);
1650 self.yukkuri.action.setStatus(EAction.THINK);
1651 self.yukkuri.animation();
1652 self.targetYukkuri.action.setStatus(EAction.THINK);
1653 self.targetYukkuri.animation();
1657 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1658 initialize: function (_data){
1660 this.yukkuri = this.data.myYukkuri;
1661 this.action = this.data.action;
1663 var yukkuri = this.yukkuri;
1664 var node = this.data.targetNode;
1666 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1667 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1668 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1669 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1670 var frame = distance + distance/5 + 1;
1671 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1673 yukkuri.setAutoDirection();
1675 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1676 "onactionend": this.onactionend(this)
1679 onactionend:function(self){
1681 if(typeof e === "undefined")return;
1682 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1684 self.yukkuri = null;
1689 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1690 initialize: function (_data){
1692 this.yukkuri = _data.myYukkuri;
1693 this.place = _data.targetNode;
1694 this.action = _data.action;
1695 this.action.setStatus(EAction.WAIT);
1698 var sec = BASE_FPS * 3;
1699 this.yukkuri.declarePlace(this.place);
1700 this.place.setOwner(this.yukkuri);
1701 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1703 this.yukkuri.setFaceImage(EFace.NORMAL);
1704 this.yukkuri.wait(sec, {
1705 "onactionend": this.onactionend(this)
1708 onactionend:function(self){
1710 if(typeof e === "undefined")return;
1711 self.action.setStatus(EAction.THINK);
1716 var Food = enchant.Class.create(ObjSprite,{
1717 initialize: function (type, x, y){
1718 this.classname = "Food";
1719 //一つにつきgiveの値分、hunguryを減少させられる
1720 if(type == "apple"){
1721 ObjSprite.call(this,16,16);
1722 this.image = game.assets[EResPath.OBJECT];
1726 }else if(type == "grass"){
1727 ObjSprite.call(this,64,64);
1728 this.image = game.assets[EResPath.GRASS];
1735 foodGroup.addChild(this);
1736 this.addEventListener('enterframe', function(){
1737 if(this.amount <= 0){
1742 getAmount: function(){
1745 getGive: function(){
1749 var MemoryPlace = enchant.Class.create({
1750 // initialize: function (place){
1751 // if(place.x != null){
1752 // this.isWorld = true;
1754 // this.isWorld = false;
1756 // this.isWorld = (place.x != null);
1757 // this.x = place.x;
1758 // this.y = place.y;
1759 // this.width = place.width;
1760 // this.height = place.height;
1762 // isWorld: function(){
1763 // return this.isWorld;
1767 var MemoryFood = enchant.Class.create({
1768 initialize: function (food){
1770 this.isWorld = true;
1772 this.isWorld = false;
1774 this.isWorld = (food.x != null);
1777 this.width = food.width;
1778 this.height = food.height;
1780 isWorld: function(){
1781 return this.isWorld;
1784 var Place = enchant.Class.create(ObjSprite,{
1785 initialize: function (type, x, y){
1786 ObjSprite.call(this,128,128);
1787 this.image = game.assets[EResPath.PLACE_TREE];
1788 this.x = x - this.width / 2;
1789 this.y = y - this.height / 2;
1790 backgroundMap.addChild(this);
1793 for(var key in EFood){
1794 var efood = EFood[key];
1795 this.foods[efood] = 0;
1797 // this.addEventListener('enterframe', function(){
1798 // if(this.age%10 === 0 && this.age !== 0){
1799 // console.log("x/y " + this.x + "/" + this.y);
1801 // if(game.input.left){
1804 // if(game.input.right){
1807 // if(game.input.up){
1810 // if(game.input.down){
1815 getStatusForDisplay: function(){
1818 if(this.owner == null)ownerId = "なし";
1819 else ownerId = this.owner.id;
1820 ret += "プレイスID " + this.id + "\n";
1821 ret += "オーナーID " + ownerId + "\n";
1822 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1823 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1824 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1827 setItems:function(items){
1828 var len = items.length;
1829 for(var i=0; i<len; i++){
1830 var item = items[i];
1831 if(item instanceof Food){
1832 this.foods[EFood.NORMAL]++;
1839 for(var key in EFood){
1840 var efood = EFood[key];
1841 ret += this.foods[efood];
1845 getFoodHash:function(){
1846 if(this.foods[EFood.GREAT] !== 0){
1847 this.foods[EFood.GREAT]--;
1848 return {give:20,yukkuri:15,unun:20};
1850 else if(this.foods[EFood.NORMAL] !== 0){
1851 this.foods[EFood.NORMAL]--;
1852 return {give:10,yukkuri:5,unun:10};
1854 else if(this.foods[EFood.BAD] !== 0){
1855 this.foods[EFood.BAD]--;
1856 return {give:10,yukkuri:-2,unun:10};
1860 setOwner: function(yukkuri){
1861 this.owner = yukkuri;
1863 isOwner: function(){
1864 return this.owner !== null;
1867 var Unun = enchant.Class.create(ObjSprite,{
1868 initialize: function (x, y){
1869 this.classname = "Unun";
1870 ObjSprite.call(this,32,32);
1871 this.image = game.assets[EResPath.YUKKURI_UNUN];
1874 backgroundMap.addChild(this);
1875 // this.lifetime = 30 * 24 * 3;
1876 this.lifetime = 15 * 24;
1877 this.addEventListener('enterframe', this.runEnterframe(this));
1878 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1881 runEnterframe:function(self){
1883 if(typeof e === "undefined")return;
1884 if(this.age%BASE_FPS === 0 && this.age !== 0){
1886 if(self.lifetime <= 0){
1887 this.parentNode.removeChild(this);
1888 ctl.backgroundMap.removeChild(this);
1889 ctl.removeObj(this);
1897 var Okazari = enchant.Class.create(enchant.Sprite,{
1898 initialize: function(yukkuri){
1899 this.classname = "Okazari";
1900 if(yukkuri.myCode === "REIMU"){
1901 enchant.Sprite.call(this, 80, 32);
1902 this.image = game.assets[EResPathReimu.OKAZARI];
1903 this.x = -CHARA_WIDTH / 3 * 2;
1904 this.y = -yukkuri.getHeight()/5 * 2 - 4;
1906 enchant.Sprite.call(this, 64, 64);
1907 this.image = game.assets[EResPath.MARISA_OKAZARI];
1908 this.x = -CHARA_WIDTH / 2;
1909 this.y = -CHARA_HEIGHT / 2 - yukkuri.getHeight()/6;
1911 this.yukkuri = yukkuri;
1913 getWidth: function(){
1915 // return this.width * this.yukkuri.myScaleX;
1917 getHeight: function(){
1919 // return this.height * this.yukkuri.myScaleY;
1922 var Kuki = enchant.Class.create(ObjSprite,{
1923 initialize: function(yukkuri, x, y){
1924 this.classname = "Kuki";
1925 enchant.Sprite.call(this, 56, 40);
1926 this.image = game.assets[EResPath.KUKI];
1928 this.y = -CHARA_HEIGHT / 2 -CHARA_HEIGHT / 4 + y;
1929 this.owner = yukkuri;
1930 this.miYukkuris = [];
1932 addMiYukkuri: function(miYukkuri){
1933 // miYukkuri.setX(miYukkuri.getX() + 30);
1934 // miYukkuri.setY(miYukkuri.getY() - 30);
1935 this.miYukkuris.push(miYukkuri);
1937 getMiYukkuris: function(){
1938 return this.miYukkuris;
1946 getWidth: function(){
1948 // return this.width * this.yukkuri.myScaleX;
1950 getHeight: function(){
1952 // return this.height * this.yukkuri.myScaleY;
1955 var Address = enchant.Class.create({
1956 initialize: function(yukkuri){
1957 this.friendlyLv = 1;
1958 this.yukkuri = yukkuri;
1959 this.isGreeting = false;
1960 this.greetingWaitFrame = 0;
1962 "beginSayHello" : false,
1967 set:function(key, value){
1968 this.comMatrix[key] = value;
1971 return this.comMatrix[key];
1975 var Yukkuri = enchant.Class.create(ObjSprite,{
1976 initialize: function(x, y, grow){
1977 ObjSprite.call(this, 64, 64);
1978 this.searchObjectMang = new SearchObjectMang();
1982 this.myCode = "YUKKURI";
1983 this.myName = "ゆっくり";
1984 this.beforeHuntingFood = null;
1985 if(grow == EGrow.ADULT){
1990 else if(grow == EGrow.SUBADULT){
1991 this.myScaleX = 0.8;
1992 this.myScaleY = 0.8;
1995 else if(grow == EGrow.CHILD){
1996 this.myScaleX = 0.6;
1997 this.myScaleY = 0.6;
2000 else if(grow == EGrow.BABY){
2001 this.myScaleX = 0.3;
2002 this.myScaleY = 0.3;
2005 else if(grow == EGrow.FRUIT_BABY){
2006 this.myScaleX = 0.2;
2007 this.myScaleY = 0.2;
2008 this.mySize = "SSS";
2011 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
2012 this.classname = "Yukkuri";
2013 this.addressBook = {};
2014 // this.imgGroup = new SpriteGroup();
2015 // this.imgBody = new SpriteGroup();
2016 // this.imgGroup.id = guid();
2017 // this.imgBody.id = guid();
2018 this.x = -CHARA_WIDTH / 2;
2019 this.y = -CHARA_HEIGHT / 2;
2022 this.image = game.assets[EResPath.YUKKURI_BASE];
2023 this.setDirection(EDirection.RIGHT);
2024 this.addEventListener('enterframe', this.runEnterframe);
2025 this.bodyStatus ={};
2026 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
2027 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
2028 this.walkAnimationStatus = EWalkAnimation.END;
2031 this.actionQueue = [];
2033 this.exValueHash = {};
2034 this.memoryHash = {};
2035 this.communicateYukkuri = {};
2036 for(var _v in EExSkill){
2037 var key = EExSkill[_v];
2038 this.exLvHash[key] = 0;
2039 this.exValueHash[key] = 0;
2042 this.formSprite = new FormSprite();
2044 runEnterframe:function(){
2045 // console.log("runEnterframe");
2046 // this.formSprite.run();
2047 // this.formSprite.addX(1);
2050 if(this.grow == EGrow.FRUIT_BABY){
2053 // this.kukis[0].miYukkuris[0].setX(this.getX());
2054 // this.kukis[0].miYukkuris[0].setY(this.getY());
2055 // var _x = this.imgBody.tl.node.x;
2056 // var _y = this.imgBody.tl.node.y;
2057 // var _gety = this.kukis[0].miYukkuris[0].getY();
2058 // this.kukis[0].miYukkuris[0].setOldY();
2059 // this.kukis[0].miYukkuris[0].animY(-_y);
2060 // this.kukis[0].direction = this.direction;
2062 // console.log(this.getX() + ":" + this.getY());
2064 if(this.isDead())return;
2070 this.runAnimation();
2071 // this.animation();
2079 if(this.direction == EDirection.RIGHT){
2080 this.formSprite.formScaleX(this.myScaleX);
2081 if(this instanceof Player){
2082 this.formSprite.setFixBudgeRight(5);
2085 this.formSprite.setFixKukiRight();
2086 var len = this.kukis.length;
2087 for(var i=0;i<len;i++){
2088 var kuki = this.kukis[i];
2089 var miYukkuris = kuki.getMiYukkuris();
2090 if(!miYukkuris)continue;
2091 var miyukkuriLength = miYukkuris.length;
2092 for(var j=0;j<miyukkuriLength;j++){
2093 // miYukkuris[j].scaleX = 1;
2094 // miYukkuris[j].scale(-1, 1);
2097 // this.formSprite.formScaleY(this.myScale);
2099 // this.imgBody.scaleX = 1;
2101 else if(this.direction == EDirection.LEFT){
2102 this.formSprite.formScaleX(-this.myScaleX);
2103 if(this instanceof Player){
2104 this.formSprite.setFixBudgeLeft(5);
2105 this.formSprite.setFixKukiLeft();
2107 this.formSprite.setFixKukiLeft();
2108 var len = this.kukis.length;
2109 for(var i=0;i<len;i++){
2110 var kuki = this.kukis[i];
2111 var miYukkuris = kuki.getMiYukkuris();
2112 if(!miYukkuris)continue;
2113 var miyukkuriLength = miYukkuris.length;
2114 for(var j=0;j<miyukkuriLength;j++){
2115 // miYukkuris[j].scaleX = -1;
2116 // miYukkuris[j].scale(-1, 1);
2120 // this.formSprite.formScaleY(this.myScale);
2121 // this.imgBody.scaleX = -1;
2124 tweet:function(text){
2125 text = text.replace(/%name%/g, this.myName);
2126 // this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
2127 this._tweet.text(text, this.getX() - this._tweet.width/4, this.getY() - this._tweet.height);
2129 moveTo:function(x, y, time){
2130 this.formSprite.tlMoveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2131 // this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2133 moveBy:function(x, y, time, eventFunctions){
2134 this.formSprite.tlMoveBy(x, y, time, eventFunctions);
2138 // return self.getX() + x;
2139 // // return self.imgGroup.x + x;
2142 // return self.getY() + y;
2143 // // return self.imgGroup.y + y;
2146 // easing: enchant.Easing.SIN_EASEINOUT
2148 // //-Event register [onactionstart,onactiontick,onactionend]
2149 // if(eventFunctions !== undefined){
2150 // for(var key in eventFunctions){
2151 // params[key] = eventFunctions[key];
2154 // console.log("moveBy");
2155 // console.log("self.x:" + self.getX());
2156 // return this.formSprite.tlTween(params);
2157 // // return this.imgGroup.tl.tween(params);
2159 wait:function(frame, eventFunctions){
2160 this.moveBy(0,0,frame,eventFunctions);
2165 runAnimation: function(){
2166 this.formSprite.formRunAnimation();
2168 animation: function(){
2169 this.formSprite.formStartAnimation();
2171 // frame -= plusFrameScale(frame, this.getMyScale()) / 2;
2173 // move -= plusFrameScale(move, this.getMyScale());
2174 // if(this.walkAnimationStatus == EWalkAnimation.END){
2175 // this.imgBody.y = 0;
2176 // this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
2177 // "onactionstart": function(e){
2178 // this.walkAnimationStatus = EWalkAnimation.START;
2181 // .moveByEx(0, move, frame, enchant.Easing.SWING,
2183 // "onactionend": function(e){
2184 // this.walkAnimationStatus = EWalkAnimation.END;
2188 // this.imgBody.tl.loop();
2191 getMyScale: function(){
2192 return (this.myScaleX + this.myScaleY) / 2;
2194 getWidth: function(){
2195 return this.width * this.myScaleX;
2197 getHeight: function(){
2198 return this.height * this.myScaleY;
2201 this.formSprite.setX(x);
2202 // this.imgGroup.x = x;
2205 this.formSprite.setY(y);
2206 // this.imgGroup.y = y;
2209 return this.formSprite.getX();
2210 // return this.imgGroup.x;
2213 return this.formSprite.getY();
2214 // return this.imgGroup.y;
2217 this.formSprite.addX(x);
2218 // this.imgGroup.x += x;
2221 this.formSprite.addY(y);
2222 // this.imgGroup.y += y;
2224 // changeFace: function(erespath){
2225 // this.face.image = game.assets[erespath];
2227 loadParamsXML: function(url){
2228 var http = new JKL.ParseXML( url );
2229 return http.parse();
2231 runYukkuri: function(){
2232 if(this.param.hungry > 70){
2233 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
2234 this.param.yukkuri -= 1;
2237 else if(this.param.hungry < 10){
2238 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
2241 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
2242 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
2244 var x = this.getX();
2245 var y = this.getY();
2247 var kukiLength = this.kukis.length;
2250 for(var i=0;i<kukiLength;i++){
2251 var kuki = this.kukis[i];
2252 yukkuris = kuki.getMiYukkuris();
2253 var yukkuriLength = yukkuris.length;
2254 for(var j=0;j<yukkuriLength;j++){
2255 var yukkuri = yukkuris[j];
2256 //TODO ここに方向によってXの値の加算減算をつける
2257 yukkuri.setX(x - 20);
2264 runHungry: function(){
2265 if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
2266 if(this.param.hungry >= 100)this.param.hungry = 100;
2268 runUnun: function(){
2269 if(this.age%50 === 0 && this.age !== 0)this.param.unun += 1;
2270 if(this.param.unun >= 100)this.param.unun = 100;
2272 runSleep: function(){
2273 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
2274 if(this.age%80 === 0 && this.age !== 0)this.param.sleep += 1;
2275 if(this.param.sleep >= 100){
2276 this.param.sleep = 100;
2280 runAddress: function(){
2281 for(var key in this.addressBook){
2282 var address = this.addressBook[key];
2284 if(address.isGreeting){
2285 address.greetingWaitFrame++;
2286 if(address.greetingWaitFrame >= DAY){
2287 address.greetingWaitFrame = 0;
2288 address.isGreeting = false;
2293 changeFace: function(){
2294 if(this.param.yukkuri >= 80){
2295 this.setFaceImage(EFace.HAPPY1);
2297 else if(this.param.yukkuri >= 50){
2298 this.setFaceImage(EFace.NORMAL);
2300 else if(this.param.yukkuri >= 30){
2301 this.setFaceImage(EFace.TIRED);
2303 else if(this.param.yukkuri >= 10){
2304 this.setFaceImage(EFace.CRY1);
2306 else if(this.param.yukkuri >= 1){
2307 this.setFaceImage(EFace.CRY2);
2310 getRange: function(){
2311 return this.param.range;
2313 isSleep: function(){
2314 return this.param.sleep >= 100;
2317 return this.param.yukkuri <= 0;
2319 isManpuku: function(){
2320 return this.param.hungry <= 20;
2322 isKuhuku: function(){
2323 return this.param.hungry >= 40;
2325 isVeryKuhuku: function(){
2326 return this.param.hungry >= 80;
2328 getYukkuri: function(){
2329 return this.param.yukkuri;
2331 setYukkuri: function(yukkuri){
2332 this.param.yukkuri = yukkuri;
2333 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2335 addYukkuri: function(yukkuri){
2336 this.param.yukkuri += yukkuri;
2337 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2339 getHungry: function(){
2340 return this.param.hungry;
2342 setHungry: function(hungry){
2343 this.param.hungry = hungry;
2344 if(this.param.hungry < 0)this.param.hungry = 0;
2346 getUnun: function(){
2347 return this.param.unun;
2349 getLooksNumber: function(){
2350 return this.param.looks;
2352 getLooksText: function(){
2353 if(this.param.looks == ELooks.GOOD_YUKKURI){
2356 if(this.param.looks == ELooks.NORMAL_YUKKURI){
2359 if(this.param.looks == ELooks.BAD_YUKKURI){
2364 setUnun: function(unun){
2365 this.param.unun = unun;
2366 if(this.param.unun < 0)this.param.unun = 0;
2370 if(food instanceof Food){
2372 if(food.amount > 0){
2374 this.setHungry(this.param.hungry - food.getGive());
2375 this.setUnun(this.getUnun() + food.getGive() / 4);
2376 this.setYukkuri(this.getYukkuri() + 5);
2379 this.setYukkuri(this.getYukkuri() - 5);
2385 this.setHungry(this.param.hungry - food.give);
2386 this.setUnun(this.getUnun() + food.unun);
2387 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2394 hunt:function(food){
2395 if(food.amount > 0){
2396 if(!this.isItemsMax()){
2398 this.items.push(food);
2399 this.setYukkuri(this.getYukkuri() + 1);
2405 declarePlace: function(place){
2408 getPlace:function(){
2411 isPlace: function(){
2412 return this.place !== null;
2416 if(this.direction == EDirection.RIGHT){
2417 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2419 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2421 // if(this.direction == EDirection.RIGHT){
2422 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2424 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2428 setBodyImage: function(ebody){
2429 var path = this.bodyStatus[ebody];
2430 this.image = game.assets[path];
2433 // this.imgBody.tl.clear();
2434 // this.imgGroup.tl.clear();
2435 // this.imgBody.tl.unloop();
2436 // this.imgGroup.tl.unloop();
2437 // this.imgBody.y = 0;
2438 this.formSprite.formStopAnimation();
2440 tlResume: function(){
2441 // this.imgBody.tl.resume();
2442 // this.imgGroup.tl.resume();
2445 syncDirection:function(senderYukkuri){
2446 if(this.getX() > senderYukkuri.getX()){
2447 // this.direction = EDirection.LEFT;
2448 // senderYukkuri.direction = EDirection.RIGHT;
2449 this.setDirection(EDirection.LEFT);
2450 senderYukkuri.setDirection(EDirection.RIGHT);
2452 this.setDirection(EDirection.RIGHT);
2453 senderYukkuri.setDirection(EDirection.LEFT);
2456 isCommunication: function(yukkuri){
2457 if(this.addressBook[yukkuri.id] === undefined) return true;
2458 if(this.addressBook[yukkuri.id].isGreeting) return false;
2461 addAddress: function(yukkuri){
2462 this.addressBook[yukkuri.id] = new Address(yukkuri);
2464 getAddress: function(yukkuri){
2465 if(this.addressBook[yukkuri.id] === undefined)return null;
2466 return this.addressBook[yukkuri.id];
2468 getStatusForDisplay: function (){
2470 var placeId = (this.place==null)?"無し" : this.place.id;
2471 ret += "ID " + this.id + "\n";
2472 ret += "プレイス " + placeId + "\n";
2473 ret += "ゆっくり " + this.getYukkuri() + "\n";
2474 ret += "空腹 " + this.getHungry() + "\n";
2475 ret += "うんうん " + this.getUnun() + "\n";
2476 ret += "もちもの " + this.items.length + "\n";
2477 ret += "容姿 " + this.getLooksText() + "\n";
2478 ret += "debug " + this.action.status + "\n";
2481 isItemsMax:function(){
2482 return this.items.length >= this.param.items_max;
2484 getItems:function(){
2487 addSearchObject:function(esearch, node){
2488 this.searchObjectMang.add(esearch, node)
2490 clearSearchObject:function(){
2491 this.searchObjectMang.clear()
2493 setFaceImage: function(eface){
2494 var path = this.faceStatus[eface];
2495 this.face.image = game.assets[path];
2497 myScale: function(_scaleX, _scaleY){
2498 this.formSprite.scale(_scaleX, _scaleY);
2499 // this.face.scale(_scaleX,_scaleY);
2500 // if(this.myCode === "REIMU"){
2501 // // this.okazari.x = -this.okazari.width / 2;
2502 // // this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2504 // // this.okazari.x = -CHARA_WIDTH /2;
2505 // // this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2507 // if(this.sub1 != null){
2508 // this.sub1.scale(_scaleX,_scaleY);
2511 // this.okazari.scale(_scaleX,_scaleY);
2512 // this.hear.scale(_scaleX,_scaleY);
2513 // this.scale(_scaleX,_scaleY);
2514 // if(this.shadow)this.shadow.scale(_scaleX, _scaleY);
2516 send: function(targetYukkuri, object, callback){
2517 this.communicateYukkuri = targetYukkuri;
2518 targetYukkuri.recv(object, callback);
2520 recv: function(object, callback){
2521 this.communicateYukkuri = object.yukkuri;
2523 this.action.setStatus(object.actionStatus);
2525 // this.actionQueue.push({
2527 // callback: callback
2530 addExValue: function(eexskill, plus){
2531 this.exValueHash[eexskill] += plus;
2532 if(this.exValueHash[eexskill] >= 100){
2533 this.exLvHash[eexskill] = 1;
2536 getExValue: function(eexskill){
2537 return this.exValueHash[eexskill];
2539 getExSkill: function(eexskill){
2540 return this.exLvHash[eexskill];
2543 setMemory: function(ememory, value){
2544 this.memoryHash[ememory] = value;
2546 getMemory: function(ememory){
2547 return this.memoryHash[ememory];
2549 damage: function(edamage){
2550 if(edamage == EDamage.PICOHAN){
2551 mangMsg.output(this, EMsg.DAMAGE);
2552 this.setFaceImage(EFace.CRY1);
2553 this.addYukkuri(-1);
2554 //現在の行動パターンから躾対象かセレクトする
2557 // addKuki: function(){
2558 // for(var i=0;i<this.kukis.length;i++){
2559 // if(this.kukis[i].opacity == 0){
2560 // this.kukis[i].opacity = 1.0;
2561 // // var miMarisa = new MiMarisa(this.getX(), this.getY());
2562 // var miMarisa = new MiMarisa(100, 100);
2564 // // console.log(this.imgBody);
2565 // // this.imgBody.addChild(miMarisa);
2566 // this.kukis[i].addMiYukkuri(miMarisa);
2571 addKuki: function(kuki){
2572 this.kukis.push(kuki);
2573 var length = this.kukis.length;
2574 this.formSprite.addChild(kuki,1000 + length,{type:"kuki",scaleValue:this.myScaleY});
2576 addMiYukkuri: function(index){
2577 var kuki = this.kukis[index];
2578 var miYukkuri = new MiMarisa(this, 10, -30);
2579 // var x = this.getX();
2580 // var y = this.getY();
2581 kuki.addMiYukkuri(miYukkuri);
2584 setAutoDirection:function(){
2585 this.direction = this.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
2587 setDirection: function(direction){
2588 this.direction = direction;
2590 var kukiLength = this.kukis.length
2591 for(var i=0;i<kukiLength;i++){
2592 var kuki = this.kukis[i];
2593 var miYukkuris = kuki.getMiYukkuris();
2594 var miyukkuriLength = miYukkuris.length;
2595 for(var j=0;j<miyukkuriLength;j++){
2596 miYukkuris[j].direction = direction;
2601 destruct: function(){
2605 var MiYukkuri = enchant.Class.create(ObjSprite, {
2606 initialize: function(param){
2607 ObjSprite.call(this,14,14);
2611 this.classname = "MiYukkuri";
2612 this.image = game.assets[EResPath.MIYUKKURI];
2615 this.addX = param.addX;
2616 this.addY = param.addY;
2617 this.scaleValue = 1;
2620 backgroundMap.addChild(this);
2626 this.x = x + this.addX;
2629 this.y = y + this.addY;
2631 setOldY: function(){
2632 this.imgGroup.y = this.oldY;
2636 this.oldX = this.imgGroup.x;
2637 this.imgGroup.x -= x;
2640 this.imgGroup.y = this.oldY;
2641 // this.oldY = this.imgGroup.y;
2642 this.imgGroup.y -= y;
2644 scaleX: function(x){
2649 var MiMarisa = enchant.Class.create(MiYukkuri,{
2650 initialize: function(parentYukkuri, addX, addY){
2651 var x = parentYukkuri.getX();
2652 var y = parentYukkuri.getY();
2653 if(addX === undefined){
2656 if(addY === undefined){
2659 MiYukkuri.call(this, {x:x, y:y,addX:addX, addY:addY});
2660 this.classname = "MiMarisa";
2661 this.myCode = "MI_MARISA";
2662 this.myName = "実まりちゃ";
2664 // this.classname = "Marisa";
2665 // this.myCode = "MARISA";
2666 // this.myName = "実まりさ";
2668 // this.param = new MarisaParam();
2669 // this.param.looks = ELooks.GOOD_YUKKURI;
2670 // this.myName = "実まりちゃ";
2671 // this.param.range /= 4;
2673 // this.face = new enchant.Sprite(64, 64);
2674 // this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2675 // this.face.x = -CHARA_WIDTH / 2;
2676 // this.face.y = -CHARA_HEIGHT / 2;
2678 // this.faceStatus ={};
2679 // this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2680 // this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2681 // this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2682 // this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2683 // this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2684 // this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2685 // this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2686 // this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2687 // this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2688 // this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2691 // this.hear = new enchant.Sprite(64, 64);
2692 // this.hear.image = game.assets[EResPath.MARISA_HEAR];
2693 // this.hear.x = -CHARA_WIDTH / 2;
2694 // this.hear.y = -CHARA_HEIGHT / 2;
2696 // this.okazari = new Okazari(this);
2698 // this._tweet = new TTweet(this, 148, 64);
2700 // this.formSprite.addChild(this, 1, {
2701 // mainIndexFlg:true,
2703 // scaleValue:this.myScaleY
2706 // this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2707 // this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2708 // this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2709 // this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2710 // this.myScale(this.myScaleX, this.myScaleY)
2711 // if(this instanceof Player){
2712 // this.budge = new enchant.Sprite(16, 16);
2713 // this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2714 // this.budge.x = -this.getWidth()/2;
2715 // this.budge.y = -this.getHeight()/2;
2716 // this.budge.scale(this.myScaleX, this.myScaleY);
2717 // this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
2718 // this.formSprite.setX(x);
2719 // this.formSprite.setY(y);
2721 // this.formSprite.setX(x);
2722 // this.formSprite.setY(y);
2723 // this.animation();
2724 // this.action = new Action(this);
2725 // ctl.addObj(this);
2729 var Marisa = enchant.Class.create(Yukkuri,{
2730 initialize: function(x, y, grow){
2731 Yukkuri.call(this,x,y, grow);
2732 this.classname = "Marisa";
2733 this.myCode = "MARISA";
2734 this.myName = "まりさ";
2736 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2737 // var json = net.load("./data/marisa/params.json");
2738 // this.param = json.root.param;
2739 this.param = new MarisaParam();
2740 this.param.looks = ELooks.GOOD_YUKKURI;
2741 if(this.grow == EGrow.BABY){
2742 this.myName = "まりちゃ";
2743 this.param.range /= 4;
2745 else if(this.grow == EGrow.CHILD){
2746 this.param.range /= 3;
2748 else if(this.grow == EGrow.SUBADULT){
2749 this.param.range *= 0.8;
2752 this.shadow = new enchant.Sprite(64, 64);
2753 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2754 this.shadow.x = 0 + this.x;
2755 this.shadow.y = this.getHeight() / 16 + this.y;
2757 this._style.zIndex = 5;
2759 this.face = new enchant.Sprite(64, 64);
2760 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2761 this.face.x = -CHARA_WIDTH / 2;
2762 this.face.y = -CHARA_HEIGHT / 2;
2764 this.faceStatus ={};
2765 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2766 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2767 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2768 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2769 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2770 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2771 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2772 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2773 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2774 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2777 this.hear = new enchant.Sprite(64, 64);
2778 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2779 this.hear.x = -CHARA_WIDTH / 2;
2780 this.hear.y = -CHARA_HEIGHT / 2;
2782 this.okazari = new Okazari(this);
2785 this.kukis[0] = new Kuki(this, 0, 0);
2786 // this.kukis[1] = new Kuki(this, 10, 0);
2787 // this.kukis[2] = new Kuki(this, 5, 5);
2788 // this.kukis[3] = new Kuki(this, -5, 5);
2789 this._tweet = new TTweet(this, 148, 64);
2791 this.formSprite.addChild(this.shadow,0,{type:"shadow",shadowIndexFlg:true,scaleValue:this.myScaleY});
2792 this.formSprite.addChild(this, 1, {
2795 scaleValue:this.myScaleY
2798 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2799 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2800 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2801 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2802 this.formSprite.addChild(this.kukis[0],7,{type:"kuki",scaleValue:this.myScaleY});
2805 // this.formSprite.addChildAll();
2806 // App.backgroundMap.addChild(this._tweet);
2807 // this.imgGroup.addChild(this.shadow);
2808 // this.imgBody.addChild(this);
2809 // this.imgBody.addChild(this.face);
2810 // this.imgBody.addChild(this.hear);
2811 // this.imgBody.addChild(this.okazari);
2812 // for(var i=0;i<this.kukis.length;i++){
2813 // this.imgBody.addChild(this.kukis[i]);
2814 // this.kukis[i].opacity = 0;
2817 // this.imgBody.addChild(new Kuki(this));
2818 this.myScale(this.myScaleX, this.myScaleY)
2819 if(this instanceof Player){
2820 this.budge = new enchant.Sprite(16, 16);
2821 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2822 this.budge.x = -this.getWidth()/2;
2823 this.budge.y = -this.getHeight()/2;
2824 this.budge.scale(this.myScaleX, this.myScaleY);
2825 this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
2826 this.formSprite.setX(x);
2827 this.formSprite.setY(y);
2829 // this.imgGroup.width = this.getWidth();
2830 // this.imgGroup.height = this.getHeight();
2831 // this.imgGroup.addChild(this.imgBody);
2833 // backgroundMap.addChild(this.imgGroup);
2834 // this._tweet = new TTweet(148, 64);
2836 // this.imgGroup.addChild(this._tweet);
2837 // this.imgGroup.x = x;
2838 // this.imgGroup.y = y;
2839 this.formSprite.setX(x);
2840 this.formSprite.setY(y);
2842 this.action = new Action(this);
2846 var Player = enchant.Class.create(Marisa,{
2847 initialize: function(x, y, grow){
2848 // this.runEnterframe = function(){
2850 if(grow === undefined)grow = EGrow.ADULT;
2851 Marisa.call(this, x, y, grow);
2852 this.classname = "Player";
2853 ctl.setPlayer(this);
2854 // this.removeEventListener('enterframe',this.runEnterframe);
2855 this.addEventListener('enterframe', function(){
2857 if(this.age%10 === 0 && this.age !== 0){
2858 // console.log("palyer:" + this.age);
2861 ///////////////////////////////////////////////
2862 //Action pattern debug
2863 if(game.input.left){
2864 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2866 this.direction = EDirection.LEFT;
2868 if(game.input.right){
2869 // for(var i=0;i<this.formSprite.spriteArray.length;i++){
2870 // var spr = this.formSprite.spriteArray[i];
2871 // console.log(i+":spry:" + spr.y);
2874 this.direction = EDirection.RIGHT;
2879 if(game.input.down){
2883 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2884 ///////////////////////////////////////////////
2886 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2887 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2889 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2891 //- Display the circle of search range.
2892 // fieldBg.image.clear();
2893 // fieldBg.image.context.beginPath();
2894 // fieldBg.image.context.fillStyle = '#ff0000';
2895 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2896 // fieldBg.image.context.fill();
2900 var Reimu = enchant.Class.create(Yukkuri,{
2901 initialize: function(x, y, grow){
2902 Yukkuri.call(this,x,y, grow);
2903 this.classname = "Reimu";
2904 this.myCode = "REIMU";
2905 this.myName = "れいむ";
2906 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2907 // var json = net.load("./data/reimu/params.json");
2908 // this.param = json.root.param;
2909 this.param = new ReimuParam();
2910 if(this.grow == EGrow.BABY){
2911 this.myName = "れいみゅ";
2912 this.param.range /= 4;
2914 else if(this.grow == EGrow.CHILD){
2915 this.param.range /= 3;
2917 else if(this.grow == EGrow.SUBADULT){
2918 this.param.range *= 0.8;
2920 this.shadow = new enchant.Sprite(64, 64);
2921 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2922 this.shadow.x = 0 + this.x;
2923 this.shadow.y = this.getWidth() / 16 + this.x;
2926 this.face = new enchant.Sprite(64, 64);
2927 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2928 this.face.x = -CHARA_WIDTH / 2;
2929 this.face.y = -CHARA_HEIGHT / 2;
2930 this.face._style.zIndex = 0;
2932 this.faceStatus ={};
2933 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2934 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2935 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2936 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2937 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2938 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2939 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2940 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2941 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2942 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2945 this.hear = new enchant.Sprite(64, 64);
2946 this.hear.image = game.assets[EResPathReimu.HEAR];
2947 this.hear.x = -CHARA_WIDTH / 2;
2948 this.hear.y = -CHARA_HEIGHT / 2;
2950 this.sub1 = new enchant.Sprite(64, 64);
2951 this.sub1.image = game.assets[EResPathReimu.SUB1];
2952 this.sub1.x = -CHARA_WIDTH / 2;
2953 this.sub1.y = -CHARA_HEIGHT / 2;
2956 this.okazari = new Okazari(this);
2957 this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
2958 this.formSprite.addChild(this, 1, {
2961 scaleValue:this.myScaleY
2963 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2964 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2965 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY,spname:"reimu"});
2966 this.formSprite.addChild(this.sub1,5,{type:"body",scaleValue:this.myScaleY});
2967 this._tweet = new TTweet(this, 148, 64);
2968 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2970 this.myScale(this.myScaleX, this.myScaleY)
2971 if(this instanceof Player){
2972 this.budge = new enchant.Sprite(16, 16);
2973 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2974 this.imgBody.addChild(this.budge);
2975 this.budge.x -= this.getWidth()/2;
2976 this.budge.y -= this.getHeight()/2;
2977 this.budge.scale(this.myScaleX, this.myScaleX);
2980 this.formSprite.setX(x);
2981 this.formSprite.setY(y);
2983 this.action = new Action(this);
2985 this.exLvHash[EExSkill.KEKKAI] = 1;
2986 this.exValueHash[EExSkill.KEKKAI] = 100;
2990 game.onload = function(){
2994 def.ObjSprite = ObjSprite;
2995 def.Yukkuri = Yukkuri;
2996 def.nodeSort = nodeSort;
2997 mangTouch = new MangTouch(ctl);
2998 mangMsg = new MangMsg(ctl);
2999 ctl.setDefined(def);
3000 backgroundMap.image = game.assets[EResPath.MAP0];
3001 backgroundMap.loadData(_mapData);
3002 backgroundMap.collisionData = _collisionData;
3004 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
3005 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
3006 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
3007 fieldBg.image = fieldSurface;
3011 windowFront.image = windowSurface;
3014 windowFront.opacity = 0.5;
3016 windowSurface.context.fillStyle = '#000';
3017 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
3019 menuSurface.context.fillStyle = '#000';
3020 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
3021 menuBg.image = menuSurface;
3022 menuBg.x = EMenuPos.X;
3023 menuBg.y = EMenuPos.Y;
3024 backgroundMap.addChild(fieldBg);
3025 mangIcon = new MangIcon(ctl, menuBg);
3027 game.rootScene.addChild(backgroundMap);
3028 // game.rootScene.addChild(windowFront);
3029 // game.rootScene.addChild(gwindow);
3030 // var gwindow = new GWindow(ctl, {}, 0, 0, 80, 80);
3031 game.rootScene.addChild(menuBg);
3033 // var labelGroup = new LabelGroup();
3034 mangLabel = new MangLabel(ctl, menuBg);
3035 // var info = new Label("ゆっくり");
3036 // info.color = "#ffffff";
3037 // info.font = "14px 'Times New Roman'";
3039 // info.y = GAME_HEIGHT / 2;
3040 // labelGroup.addChild(info);
3041 // menuBg.addChild(labelGroup);
3044 // var food = new def.Food("apple", 200, 250);
3045 backgroundMap.addChild(foodGroup);
3046 // backgroundMap.addChild(placeGroup);
3047 // var mimarisa = new MiMarisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.FRUIT_BABY);
3048 var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.ADULT);
3050 player.addMiYukkuri(0);
3051 // var player = new Player(0, 0);
3052 // console.log(player.getX());
3053 // player.addKuki();
3054 // player.addMiYukkuri(mimarisa)
3055 // player.createKuki();
3056 new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
3058 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.ADULT);
3059 // new Marisa(PALYER_INIT_X + 250, PALYER_INIT_Y + 200, EGrow.ADULT);
3060 // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
3061 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
3062 // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
3063 // new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
3064 // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
3065 // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
3066 // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
3067 // new Unun(100, 100);
3068 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
3070 // var input = new Label("<form name='hoge' style='background-color:#ff0000;'>" +
3071 // "<input type='text' name='text'>" +
3072 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
3075 // input.element.innerHTML = "<form name='hoge' style='background-color:#ff0000;'>" +
3076 // "<input type='text' name='text'>" +
3077 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
3079 // menuBg.addChild(input);
3080 // game.rootScene.addChild(input);
3081 // var inputEvent = new Label('');
3083 // game.rootScene.addChild(output);
3084 // output.onenterframe = function(e) {
3085 // output.text = document.hoge.text.value;
3088 // enchant.Node.GAddEvent = function(){
3090 var popupStatus = null;
3091 var testFlg = false;
3093 game._element.addEventListener('mousemove', function (e) {
3094 var mang = mangTouch.get(ctl.getCurrentCommand());
3095 if(EMenuPos.X < e.layerX){
3096 var ex = e.layerX - EMenuPos.X;
3099 for(var i=0;i<mangIcon.cmdIcons.length;i++){
3100 var icon = mangIcon.cmdIcons[i];
3101 if(icon.x <= ex && ex <= (icon.x + ICON_WIDTH)
3102 && icon.y <= ey && ey <= (icon.y + ICON_HEIGHT)
3105 if(popupStatus !== i){
3106 ctl.popup.renew(game.rootScene, EMenuPos.X + 5, e.layerY + ICON_HEIGHT / 2, 80, 80);
3107 ctl.popup.setText(icon.text);
3115 ctl.popup.opacity = 0.9;
3116 ctl.popup.drawText();
3119 ctl.popup.opacity = 0;
3121 // console.log(e.layerX + ":" + e.layerY);
3124 // enchant.Core.instance._element.addEventListener('mousemove', function(e) {
3126 // game.rootScene.addEventListener('mousemove', function (e) {
3127 // console.log("mmmmmmmmm");
3131 game.rootScene.addEventListener('touchstart', function (e) {
3132 game.touched = true;
3133 var mang = mangTouch.get(ctl.getCurrentCommand());
3136 game.rootScene.addEventListener('touchmove', function (e) {
3137 var mang = mangTouch.get(ctl.getCurrentCommand());
3140 game.rootScene.addEventListener('touchend', function (e) {
3141 var mang = mangTouch.get(ctl.getCurrentCommand());
3143 game.touched = false;
3147 game.rootScene.addEventListener('enterframe', function(e){
3149 mangLabel.draw(player);
3150 if(this.age%BASE_FPS == 0 ){
3153 ctl.time += TIME_SPEED;
3155 this.addEventListener('enterframe', function(){
3156 //The priority processing of display instead of z-index
3158 backgroundMap.childNodes.sort(nodeSort);