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 // PLACE_TREE : './data/system/rapture.png',
79 FACE_NORMAL : './data/reimu/face_normal1.png',
80 FACE_TIRED : './data/reimu/face_tired1.png',
81 FACE_ANGRY : './data/reimu/face_angry1.png',
82 FACE_CRY1 : './data/reimu/face_cry1.png',
83 FACE_CRY2 : './data/reimu/face_cry2.png',
84 FACE_EAT1 : './data/reimu/face_eat1.png',
85 FACE_EAT2 : './data/reimu/face_eat2.png',
86 FACE_HAPPY1 : './data/reimu/face_happy1.png',
87 FACE_HAPPY2 : './data/reimu/face_happy2.png',
88 FACE_SLEEP : './data/reimu/face_sleep1.png',
89 HEAR : './data/reimu/hear1.png',
90 OKAZARI : './data/reimu/okazari.png',
91 SUB1 : './data/reimu/sub1.png',
118 WORLD_PICOPICO_HUMMER: 5,
125 HEIGHT : GAME_HEIGHT,
131 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
142 MOVE_TO_EAT_START: 10,
143 MOVE_TO_EAT_UNDERWAY: 11,
147 UNUN_SMELL_START : 15,
148 UNUN_SMELL_WAIT : 16,
151 COMMUNICATE_START : 19,
152 COMMUNICATE_WAIT: 20,
153 COMMUNICATE_RECV: 21,
154 MOVE_TO_PLACE_START_HOMELESS: 22,
155 MOVE_TO_PLACE_HOMELESS_UNDERWAY: 23,
156 DECLARE_PLACE_HOMELESS: 24,
157 MOVE_TO_HUNT_START: 25,
190 LEARN_NO_FOOD_IN_PLACE:19,
197 var EWalkAnimation = {
228 NO_FOOD_IN_PLACE : 1,
246 include("./lib/Animation.js");
247 include("./lib/FormSprite.js");
250 var ObjSprite = enchant.Class.create(enchant.Sprite,{
251 initialize: function (w, h){
252 enchant.Sprite.call(this, w, h);
255 // // new BoxLabel(this.ctl,100, e.x, e.y);
256 // var box = new Box(this.ctl, 200, 200);
257 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
259 getStatusForDisplay: function (){
268 getWidth: function(){
271 getHeight: function(){
275 return (this.id !== null && this.id !== undefined);
277 removeAll: function(){
282 undefineAll: function (){
283 for(var key in this){
284 // if(this.hasOwnProperty(key)){
292 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
303 //-Event register [onactionstart,onactiontick,onactionend]
304 if(eventFunctions !== undefined){
305 for(var key in eventFunctions){
306 params[key] = eventFunctions[key];
309 return this.tween(params);
311 function plusFrameScale(frame, scale){
312 return (frame/2) * (1 - scale)
317 include("./lang/ja.js");
318 window.onload = function(){
319 var nodeSort = function (a, b){
320 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
323 else if(typeof a.id === "undefined"){
326 else if(typeof b.id === "undefined"){
331 if(a instanceof Box && b instanceof Box){
334 if(a instanceof Box){
337 if(b instanceof Box){
340 if(a.type == "shadow"){
341 ay += -28 * a.scaleValue;
343 if(b.type == "shadow"){
344 by += -28 * b.scaleValue;
346 if(a.classname == "Okazari"){
347 ay += 11 * a.scaleValue;
349 if(b.classname == "Okazari"){
350 by += 11 * b.scaleValue;
352 if(a.type == "body"){
353 ay += 32 * a.scaleValue;
355 else if(a.type == "tweet"){
356 ay += 148 * a.scaleValue;
358 if(b.type == "body"){
359 by += 32 * b.scaleValue;
361 else if(b.type == "tweet"){
362 by += 148 * b.scaleValue;
365 if(a instanceof SpriteGroup){
369 if(b instanceof SpriteGroup){
374 if(a instanceof Place){
375 ay += Math.round(a.height * 0.7);
377 if(b instanceof Place){
378 by += Math.round(b.height * 0.7);
387 if(ay < by)return -1;
388 else if(ay > by)return 1;
389 if(a.id < b.id)return -1;
390 else if(a.id > b.id)return 1;
396 var def = new Object();
397 var foodGroup = new Group();
398 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
399 SpriteGroup.prototype.classname = "";
400 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
401 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
402 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
403 game = new Game(GAME_WIDTH, GAME_HEIGHT);
407 var tmpName = EResPathReimu.getName();
409 for(var _v in EResPathReimu){
410 if(typeof EResPathReimu[_v] === "function")continue;
411 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
417 for(var _v in EResPath){
418 _loadArr[i] = EResPath[_v];
421 game.preload(_loadArr);
422 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
423 var backgroundMap = new MapGroup(16, 16);
424 App.backgroundMap = backgroundMap;
425 include("./class.js");
426 include("./ctrl.js");
429 ctl.setBackgroundMap(backgroundMap);
430 var Action = enchant.Class.create({
431 initialize: function (yukkuri){
432 this.status = EAction.THINK;
433 this.yukkuri = yukkuri;
434 this.isMoving = false;
435 this.targetNode = null;
437 getStatus: function(){
440 setStatus: function(eaction){
441 this.status = eaction;
444 if(this.yukkuri.isDead()){
445 this.status = EAction.DEAD;
447 // else if(this.yukkuri.isSleep()){
448 // this.status = EAction.SLEEP;
457 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
459 this.setStatus(EAction.THINK);
460 console.log("wait cnt end");
463 case EAction.THINK_IN_HOME:
466 this.think_in_home();
468 case EAction.EAT_IN_HOME:
473 if(this.yukkuri.age%2 === 0){
474 this.yukkuri.changeFace();
476 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
479 case EAction.MOVE_TO_EAT_START:
480 this.move_to_eat_start();
482 case EAction.MOVE_TO_EAT_UNDERWAY:
488 case EAction.SLEEP_START:
491 case EAction.SLEEP_WAIT:
496 case EAction.EAT_START:
499 case EAction.EAT_WAIT:
501 case EAction.UNUN_START:
504 case EAction.UNUN_WAIT:
506 case EAction.MOVE_TO_COMMAND:
507 this.move_to_command();
509 case EAction.UNUN_SMELL_START:
510 this.unun_smell_start();
512 case EAction.COMMUNICATE_START:
513 this.communicate_start();
515 case EAction.COMMUNICATE_WAIT:
516 case EAction.COMMUNICATE_RECV:
517 if(this.yukkuri.communicateYukkuri != null){
518 var _s = this.yukkuri.communicateYukkuri.action.getStatus();
519 if(this.yukkuri.communicateYukkuri.isDead()
520 || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
521 this.setStatus(EAction.THINK);
522 this.yukkuri.animation();
526 case EAction.MOVE_TO_PLACE_START_HOMELESS:
527 this.move_to_place_start_homeless();
529 case EAction.DECLARE_PLACE_HOMELESS:
530 this.declare_place_homeless();
532 case EAction.MOVE_TO_HUNT_START:
533 this.move_to_hunt_start();
535 case EAction.HUNT_START:
538 case EAction.MOVE_GOTO_HOME:
539 this.move_goto_home();
541 case EAction.IN_HOME:
546 this.yukkuri.reverse();
548 // thinkHavePlace: function(){
549 // var date = ctl.getDate();
550 // if(this.yukkuri.isPlaceRange()){
553 // if(date === EDate.EVENING
554 // || date === EDate.NIGHT
555 // || date === EDate.MIDNIGHT
557 // this.setStatus(EAction.MOVE_GOTO_HOME);
560 // else if(date === EDate.EVENING){
561 // // if(this.yukkuri.isItemsMax()){
562 // // this.setStatus(EAction.IN_HOME);
565 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
569 // if(this.yukkuri.isVeryKuhuku()){
573 // this.setStatus(EAction.MOVE_GOTO_HOME);
575 // else if(this.yukkuri.isSleep()){
576 // this.setStatus(EAction.SLEEP_START);
578 // else if(this.yukkuri.getUnun() >= 80){
579 // this.setStatus(EAction.UNUN_START);
582 // this.yukkuri.changeFace();
586 think_in_home: function(){
587 var date = ctl.getDate();
588 if((date === EDate.MIDNIGHT)
589 && !this.yukkuri.isSleep()
590 && !this.yukkuri.isVeryKuhuku()
594 "nextStatus":EAction.THINK_IN_HOME,
595 "myYukkuri": this.yukkuri
599 else if(date === EDate.EVENING){
602 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
603 this.setStatus(EAction.EAT_IN_HOME);
606 //marisa is hunting move
607 if(this.yukkuri.beforeHuntingFood !== null){
608 new MoveToHuntEvent({
610 "targetNode": this.yukkuri.beforeHuntingFood,
612 "myYukkuri": this.yukkuri
616 this.setStatus(EAction.WALK);
620 eat_in_home: function(){
622 "targetNode": this.yukkuri.getPlace(),
624 "myYukkuri": this.yukkuri
627 move_to_eat_start : function(){
630 "targetNode": this.targetNode,
632 "myYukkuri": this.yukkuri
638 walk : function(retryCounter){
639 if(retryCounter > 15){
641 this.status = EAction.NONE;
642 console.log("retryCount over");
645 if(this.yukkuri.formSprite.tlQueueLength() === 0){
646 // if(this.yukkuri.imgGroup.tl.queue.length === 0){
648 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
650 this.isMoving = false;
651 this.status = EAction.THINK;
655 var xpos = 150 + rand(40) - (retryCounter * 10);
656 var ypos = 150 + rand(40) - (retryCounter * 10);
658 this.yukkuri.vx = xpos;
659 this.yukkuri.vy = ypos;
660 this.yukkuri.direction = EDirection.RIGHT;
662 else if(rand(8) === 0){
664 this.yukkuri.vy = -ypos;
666 else if(rand(8) == 1){
667 this.yukkuri.vx = xpos;
668 this.yukkuri.vy = -ypos;
669 this.yukkuri.direction = EDirection.RIGHT;
671 else if(rand(8) == 2){
672 this.yukkuri.vx = xpos;
674 this.yukkuri.direction = EDirection.RIGHT;
676 else if(rand(8) == 3){
677 this.yukkuri.vx = xpos;
678 this.yukkuri.vy = ypos;
679 this.yukkuri.direction = EDirection.RIGHT;
681 else if(rand(8) == 4){
683 this.yukkuri.vy = ypos;
685 else if(rand(8) == 5){
686 this.yukkuri.vx = -xpos;
687 this.yukkuri.vy = ypos;
688 this.yukkuri.direction = EDirection.LEFT;
690 else if(rand(8) == 6){
691 this.yukkuri.vx = -xpos;
693 this.yukkuri.direction = EDirection.LEFT;
695 else if(rand(8) == 7){
696 this.yukkuri.vx = -xpos;
697 this.yukkuri.vy = -ypos;
698 this.yukkuri.direction = EDirection.LEFT;
700 if (this.yukkuri.vx || this.yukkuri.vy) {
701 var map = ctl.backgroundMap;
702 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
703 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
704 var x = this.yukkuri.getX() + this.yukkuri.vx;
705 var y = this.yukkuri.getY() + this.yukkuri.vy + this.yukkuri.getHeight() / 2;
706 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
707 // console.log("あたってないよ:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY());
708 // console.log("X:" + this.yukkuri.moveX);
709 // console.log("Y:" + this.yukkuri.moveY);
710 this.isMoving = true;
711 this.yukkuri.reverse();
712 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
713 mangMsg.output(this.yukkuri,EMsg.WALK);
715 this.targetNode = null;
717 // console.log("HIT:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY() + "," + this.yukkuri.vx + ":" + this.yukkuri.vy);
718 this.walk(retryCounter+1);
724 sleep_start: function(){
727 "myYukkuri": this.yukkuri
731 mangMsg.output(this.yukkuri, EMsg.DEAD);
732 this.yukkuri.tlPause();
733 this.yukkuri.setBodyImage(EBody.DEAD);
735 eat_start: function(){
738 "targetNode": this.targetNode,
740 "myYukkuri": this.yukkuri
744 unun_start: function(){
747 "myYukkuri": this.yukkuri
750 unun_smell_start: function(){
753 "myYukkuri": this.yukkuri
756 communicate_start:function(){
757 new ComSayHelloSendEvent({
759 "targetNode": this.targetNode,
761 "myYukkuri": this.yukkuri
764 move_to_place_start_homeless:function(){
765 new MoveToPlaceStartHomelessEvent({
766 "targetNode": this.targetNode,
768 "myYukkuri": this.yukkuri
771 declare_place_homeless:function(){
772 new DeclarePlaceHomelessEvent({
773 "targetNode": this.targetNode,
775 "myYukkuri": this.yukkuri
778 move_to_hunt_start:function(){
779 new MoveToHuntEvent({
781 "targetNode": this.targetNode,
783 "myYukkuri": this.yukkuri
786 hunt_start:function(){
789 "targetNode": this.targetNode,
791 "myYukkuri": this.yukkuri
794 move_goto_home:function(){
795 var place = this.yukkuri.getPlace();
796 new MoveGotoHomeEvent({
800 "myYukkuri": this.yukkuri
804 var place = this.yukkuri.getPlace();
805 if(place != null && place.isWorld()){
810 "myYukkuri": this.yukkuri
813 if(place && !place.isWorld())place.undefineAll();
814 this.yukkuri.declarePlace(null);
815 this.setStatus(EAction.WAIT);
816 mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
817 this.yukkuri.setFaceImage(EFace.CRY2);
819 "waitframe": FPS * 3.0,
821 "myYukkuri": this.yukkuri
825 move_to_command: function(){
826 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
827 new MoveToCommandEvent({
830 "myYukkuri": this.yukkuri
835 this.yukkuri.clearSearchObject();
836 var nodes = ctl.getObjs();
839 for (var key in nodes) {
840 var node = nodes[key];
841 if(node === null || node === undefined)continue;
842 if(this.yukkuri.id === node.id)continue;
846 && !(this.targetNode instanceof Unun)
847 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
849 this.yukkuri.addSearchObject(ESearch.UNUN, node);
852 else if (node instanceof Food && node.amount > 0) {
853 if(this.yukkuri.within(node, this.yukkuri.getRange())){
854 this.yukkuri.addSearchObject(ESearch.FOOD, node);
858 else if(node instanceof Yukkuri){
859 if(node.grow != EGrow.FRUIT_BABY && this.yukkuri.within(node, this.yukkuri.getRange())){
860 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
864 else if(node instanceof Place){
865 if(this.yukkuri instanceof Player){
867 if(this.yukkuri.within(node, this.yukkuri.getRange())){
868 this.yukkuri.addSearchObject(ESearch.PLACE, node);
872 this.status = EAction.WALK;
876 * Range範囲内のObjSprを管理する
877 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
881 var SearchObjectMang = enchant.Class.create({
882 initialize: function (){
884 this.currentCmdObject = null;
888 for(var key in ESearch){
889 var esearch = ESearch[key];
890 this.datas[esearch] = [];
893 add :function(esearch, node){
894 this.datas[esearch].push(node);
897 for(var key in ESearch){
898 var esearch = ESearch[key];
899 this.datas[esearch].length = 0;
901 // this.datas.length = 0;
904 get:function (esearch){
905 return this.datas[esearch];
907 getNear:function (esearch, yukkuri){
908 var objects = this.datas[esearch];
909 var nearDistance = null;
911 for(var i=0;i<objects.length;i++){
912 var object = objects[i];
913 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
914 if(nearDistance === null || nearDistance > nowDistance){
915 nearDistance = nowDistance;
921 callEvent: function(yukkuri){
922 if(yukkuri.cmdQueue.length !== 0){
923 this.currentCmdObject = yukkuri.cmdQueue.shift();
924 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
928 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
929 yukkuri.action.targetNode = yukkuri.getPlace();
930 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
933 if(yukkuri.isVeryKuhuku()){
935 var foods = this.get(ESearch.FOOD);
936 if(foods.length > 0){
937 var foods = this.get(ESearch.FOOD);
938 food = this.getNear(ESearch.FOOD, yukkuri);
940 yukkuri.action.targetNode = food;
941 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
945 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
946 yukkuri.action.setStatus(EAction.WALK);
951 if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
952 yukkuri.action.targetNode = yukkuri.getPlace();
953 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
957 yukkuri.action.setStatus(EAction.WALK);
961 if(yukkuri.isSleep()){
962 yukkuri.action.setStatus(EAction.SLEEP_START);
966 else if(yukkuri.getUnun() >= 80){
967 yukkuri.action.setStatus(EAction.UNUN_START);
972 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
973 food = this.getNear(ESearch.FOOD, yukkuri);
975 yukkuri.action.targetNode = food;
976 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
980 ununs = this.get(ESearch.UNUN);
981 if(ununs.length !== 0){
982 yukkuri.action.targetNode = yukkuri.getPlace();
983 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
986 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
987 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
988 yukkuri.action.targetNode = searchYukkuri;
989 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
992 if(!yukkuri.isPlace()){
993 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
994 if(searchYukkuri != null && !searchYukkuri.isOwner()){
995 yukkuri.action.targetNode = searchYukkuri;
996 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
1000 yukkuri.action.setStatus(EAction.WALK);
1005 var Event = enchant.Class.create({
1006 initialize: function (_data){
1009 onactionstart:function(self){
1010 return this._onactionstart;
1012 _onactionstart:function(e){
1013 if(typeof e === "undefined")return;
1015 onactiontick:function(self){
1017 if(typeof e === "undefined")return;
1020 onactionend:function(self){
1022 if(typeof e === "undefined")return;
1026 var WalkEvent = enchant.Class.create(Event,{
1027 initialize: function (_data){
1029 this.yukkuri = _data.myYukkuri;
1030 this.action = _data.action;
1032 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1033 this.action.setStatus(EAction.SLEEP_WAIT);
1034 this.yukkuri.setFaceImage(EFace.SLEEP);
1035 this.yukkuri.tlPause();
1037 this.yukkuri.addEventListener('enterframe', function() {
1038 var yukkuri = self.yukkuri;
1046 var SleepEvent = enchant.Class.create(Event,{
1047 initialize: function (_data){
1049 this.yukkuri = _data.myYukkuri;
1050 this.action = _data.action;
1052 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1053 this.action.setStatus(EAction.SLEEP_WAIT);
1054 this.yukkuri.setFaceImage(EFace.SLEEP);
1055 this.yukkuri.tlPause();
1058 this.yukkuri.addEventListener('enterframe', function() {
1059 var yukkuri = self.yukkuri;
1060 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
1061 if(yukkuri.param.sleep <= 0){
1062 yukkuri.param.sleep = 0;
1063 this.removeEventListener("enterframe",arguments.callee);
1064 mangMsg.output(self.yukkuri, EMsg.GET_UP);
1065 yukkuri.setFaceImage(EFace.NORMAL);
1067 // self.action.setStatus(EAction.WAIT);
1068 if(self.data.nextStatus !== undefined){
1069 self.action.setStatus(self.data.nextStatus);
1071 self.action.setStatus(EAction.THINK);
1078 var UnunEvent = enchant.Class.create(Event,{
1079 initialize: function (_data){
1081 this.yukkuri = _data.myYukkuri;
1082 this.action = _data.action;
1083 this.action.setStatus(EAction.UNUN_WAIT);
1084 mangMsg.output(this.yukkuri, EMsg.UNUN);
1085 this.yukkuri.setFaceImage(EFace.HAPPY2);
1088 this.yukkuri.wait(sec, {
1089 "onactionend": this.onactionend(this)
1092 onactionend:function(self){
1094 if(typeof e === "undefined")return;
1095 self.yukkuri.unun();
1096 self.action.setStatus(EAction.WAIT);
1097 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1099 "waitframe": FPS * 1.5,
1100 "action": self.action,
1101 "myYukkuri": self.yukkuri
1106 var WaitEvent = enchant.Class.create(Event,{
1107 initialize: function (_data){
1109 this.yukkuri = _data.myYukkuri;
1110 this.action = _data.action;
1111 this.waitframe = _data.waitframe;
1112 this.yukkuri.wait(this.waitframe, {
1113 "onactionstart": this.onactionstart(this),
1114 "onactiontick": this.onactiontick(this),
1115 "onactionend": this.onactionend(this)
1118 onactionend:function(self){
1120 if(typeof e === "undefined")return;
1121 self.action.setStatus(EAction.THINK);
1125 var UnunSmellEvent = enchant.Class.create(Event,{
1126 initialize: function (_data){
1128 this.yukkuri = _data.myYukkuri;
1129 this.action = _data.action;
1130 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1131 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1132 this.yukkuri.setFaceImage(EFace.CRY1);
1134 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1135 this.yukkuri.wait(sec, {
1136 "onactionend": this.onactionend(this)
1139 onactionend:function(self){
1141 if(typeof e === "undefined")return;
1142 self.action.setStatus(EAction.WALK);
1147 var EatEvent = enchant.Class.create(Event,{
1148 initialize: function (_data){
1150 this.yukkuri = _data.myYukkuri;
1151 this.food = _data.targetNode;
1152 this.action = _data.action;
1153 this.action.setStatus(EAction.EAT_WAIT);
1155 var sec = BASE_FPS * 3;
1156 if(this.yukkuri.eat(this.food)){
1157 mangMsg.output(this.yukkuri, EMsg.EAT);
1158 this.yukkuri.setFaceImage(EFace.EAT2);
1161 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1162 this.yukkuri.setFaceImage(EFace.CRY2);
1164 this.yukkuri.wait(sec, {
1165 "onactionend": this.onactionend(this)
1168 onactionend:function(self){
1170 if(typeof e === "undefined")return;
1171 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
1172 self.action.setStatus(EAction.THINK);
1173 self.yukkuri.setFaceImage(EFace.NORMAL);
1175 self.action.setStatus(EAction.EAT_START);
1182 * -When yukkuri find Food.
1185 * targetNode: enchant.Node
1189 var MoveToEatEvent = enchant.Class.create(Event,{
1190 initialize: function (_data){
1192 this.yukkuri = this.data.myYukkuri;
1193 this.action = this.data.action;
1195 var yukkuri = this.yukkuri;
1196 var node = this.data.targetNode;
1198 if(this.data.type == "food"){
1199 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1200 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
1201 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
1202 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1203 var frame = distance + distance/5 + 1;
1204 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1205 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1207 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1209 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1210 "onactiontick": this.onactiontick(this),
1211 "onactionend": this.onactionend(this)
1215 onactiontick:function(self){
1217 if(typeof e === "undefined")return;
1220 onactionend:function(self){
1222 if(typeof e === "undefined")return;
1223 self.action.setStatus(EAction.EAT_START);
1227 var MoveToHuntEvent = enchant.Class.create(Event,{
1228 initialize: function (_data){
1230 this.yukkuri = this.data.myYukkuri;
1231 this.action = this.data.action;
1233 var yukkuri = this.yukkuri;
1234 var node = this.data.targetNode;
1237 var nodeWidth = node.width;
1238 var nodeHeight = node.height;
1242 if(this.data.type == "food"){
1243 this.action.setStatus(EAction.WAIT);
1244 yukkuri.vx = nodeX - yukkuri.getX();
1245 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2;
1246 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1247 var frame = distance + distance/5 + 1;
1248 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1249 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1251 mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
1253 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1254 "onactionend": this.onactionend(this)
1258 onactionend:function(self){
1260 if(typeof e === "undefined")return;
1261 self.action.setStatus(EAction.HUNT_START);
1265 var HuntStartEvent = enchant.Class.create(Event,{
1266 initialize: function (_data){
1267 Event.call(this, _data);
1270 this.yukkuri = _data.myYukkuri;
1271 this.food = _data.targetNode;
1272 this.action = _data.action;
1273 this.action.setStatus(EAction.WAIT);
1274 this.huntingStatus = "hunting";
1276 // this.yukkuri.beforeHuntingFood = this.food;
1277 if(this.food.isWorld()){
1278 this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
1279 var sec = BASE_FPS * 8;
1280 if(this.yukkuri.hunt(this.food)){
1281 this.huntingStatus = "hunting";
1282 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1283 this.yukkuri.setFaceImage(EFace.HAPPY1);
1285 if(this.yukkuri.isItemsMax()){
1287 this.huntingStatus = "return";
1288 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1289 this.yukkuri.setFaceImage(EFace.NORMAL);
1292 this.huntingStatus = "cry";
1293 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1294 this.yukkuri.setFaceImage(EFace.CRY2);
1299 this.yukkuri.beforeHuntingFood = null;
1301 this.huntingStatus = "cry";
1302 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1303 this.yukkuri.setFaceImage(EFace.CRY2);
1306 this.yukkuri.wait(sec, {
1307 "onactiontick": this.onactiontick(this),
1308 "onactionend": this.onactionend(this)
1311 onactiontick:function(self){
1313 if(typeof e === "undefined")return;
1315 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1316 if(this.age%(BASE_FPS * 5) == 0){
1317 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1318 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1323 onactionend:function(self){
1325 if(typeof e === "undefined")return;
1326 if(self.huntingStatus == "hunting"){
1327 if(self.yukkuri.isItemsMax()){
1328 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1329 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1331 self.action.setStatus(EAction.HUNT_START);
1334 else if(self.huntingStatus == "return"){
1335 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1337 else if(self.huntingStatus === "cry"){
1338 // self.action.setStatus(EAction.THINK);
1339 self.action.setStatus(EAction.WALK);
1346 this.yukkuri = null;
1351 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1352 initialize: function (_data){
1354 this.yukkuri = this.data.myYukkuri;
1355 this.action = this.data.action;
1357 var yukkuri = this.yukkuri;
1358 var place = this.data.targetNode;
1360 if(this.data.type == "hunt_end"){
1361 this.action.setStatus(EAction.WAIT);
1362 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1363 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1364 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1365 var frame = distance + distance/2 + 1 ;
1366 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1367 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1369 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1371 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1372 "onactiontick": this.onactiontick(this),
1373 "onactionend": this.onactionend(this)
1377 onactiontick:function(self){
1379 if(typeof e === "undefined")return;
1380 if(this.age%(BASE_FPS * 5) == 0){
1381 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1385 onactionend:function(self){
1387 if(typeof e === "undefined")return;
1388 self.action.setStatus(EAction.IN_HOME);
1394 this.yukkuri = null;
1398 var InHomeEvent = enchant.Class.create(Event,{
1399 initialize: function (_data){
1401 this.yukkuri = this.data.myYukkuri;
1402 this.action = this.data.action;
1404 var yukkuri = this.yukkuri;
1405 var place = this.data.targetNode;
1407 if(yukkuri.isVeryKuhuku()){
1409 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1410 this.action.setStatus(EAction.EAT_IN_HOME);
1413 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1415 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1416 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1417 this.action.setStatus(EAction.THINK);
1420 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1421 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1426 this.action.setStatus(EAction.WAIT);
1427 var items = this.yukkuri.getItems();
1428 if(items.length > 0){
1429 place.setItems(items);
1433 var sec = BASE_FPS * 10;
1434 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1435 this.yukkuri.wait(sec, {
1436 "onactiontick": this.onactiontick(this),
1437 "onactionend": this.onactionend(this)
1440 onactiontick:function(self){
1442 if(typeof e === "undefined")return;
1443 if(this.age%(BASE_FPS * 5) == 0){
1444 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1448 onactionend:function(self){
1450 if(typeof e === "undefined")return;
1451 self.action.setStatus(EAction.THINK_IN_HOME);
1455 var EatInHomeEvent = enchant.Class.create(Event,{
1456 initialize: function (_data){
1458 this.yukkuri = _data.myYukkuri;
1459 this.place = _data.targetNode;
1460 this.action = _data.action;
1461 this.action.setStatus(EAction.EAT_WAIT);
1463 var sec = BASE_FPS * 3;
1464 var foodHash = this.place.getFoodHash();
1465 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1466 mangMsg.output(this.yukkuri, EMsg.EAT);
1467 this.yukkuri.setFaceImage(EFace.EAT2);
1470 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1471 this.yukkuri.setFaceImage(EFace.CRY2);
1474 this.yukkuri.wait(sec, {
1475 "onactionend": this.onactionend(this)
1478 onactionend:function(self){
1480 if(typeof e === "undefined")return;
1481 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1482 self.action.setStatus(EAction.EAT_IN_HOME);
1484 // new EatInHomeEvent({
1485 // "targetNode": self.place,
1486 // "action": self.action,
1487 // "myYukkuri": self.yukkuri
1490 self.action.setStatus(EAction.THINK_IN_HOME);
1491 self.yukkuri.setFaceImage(EFace.NORMAL);
1498 var MoveToCommandEvent = enchant.Class.create(Event,{
1499 initialize: function (_data){
1501 this.yukkuri = this.data.myYukkuri;
1502 this.action = this.data.action;
1503 // this.vx = this.data.cmdObject.vx;
1504 // this.vy = this.data.cmdObject.vy;
1505 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1508 var yukkuri = this.yukkuri;
1509 this.action.status = EAction.WAIT;
1510 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1511 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1512 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1513 var frame = distance + distance/2 + 1;
1514 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1516 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1518 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1519 "onactiontick": this.onactiontick(this),
1520 "onactionend": this.onactionend(this)
1523 onactiontick:function(self){
1525 if(typeof e === "undefined")return;
1528 onactionend:function(self){
1530 if(typeof e === "undefined")return;
1531 self.action.setStatus(EAction.THINK);
1536 * Say hello contact to send communication .
1538 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1539 initialize: function (_data){
1541 this.yukkuri = _data.myYukkuri;
1542 this.targetYukkuri = _data.targetNode;
1543 this.action = _data.action;
1544 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1545 // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1546 // this.targetYukkuri.tlPause();
1547 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1548 this.yukkuri.send(this.targetYukkuri, {
1549 "actionStatus":EAction.COMMUNICATE_RECV,
1550 "yukkuri":this.yukkuri
1554 this.yukkuri.tlPause();
1555 this.yukkuri.syncDirection(this.targetYukkuri);
1557 this.yukkuri.addAddress(this.targetYukkuri);
1558 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1560 var sec = BASE_FPS * 2;
1561 this.yukkuri.wait(sec, {
1562 "onactiontick": this.onactiontick(this),
1563 "onactionend": this.onactionend(this)
1566 onactiontick:function(self){
1568 if(typeof e === "undefined")return;
1571 onactionend:function(self){
1573 if(typeof e === "undefined")return;
1574 new ComSayHelloRecvEvent({
1576 "targetNode": self.yukkuri,
1577 "action": self.targetYukkuri.action,
1578 "myYukkuri": self.targetYukkuri
1583 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1584 initialize: function (_data){
1586 this.yukkuri = _data.myYukkuri;
1587 this.targetYukkuri = _data.targetNode;
1588 this.action = _data.action;
1589 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1590 this.yukkuri.addAddress(this.targetYukkuri);
1591 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1593 var sec = BASE_FPS * 2;
1594 this.yukkuri.wait(sec, {
1595 "onactiontick": this.onactiontick(this),
1596 "onactionend": this.onactionend(this)
1599 onactiontick:function(self){
1601 if(typeof e === "undefined")return;
1604 onactionend:function(self){
1606 if(typeof e === "undefined")return;
1607 self.action.setStatus(EAction.THINK);
1609 self.yukkuri.action.setStatus(EAction.THINK);
1610 self.yukkuri.animation();
1611 self.targetYukkuri.action.setStatus(EAction.THINK);
1612 self.targetYukkuri.animation();
1616 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1617 initialize: function (_data){
1619 this.yukkuri = this.data.myYukkuri;
1620 this.action = this.data.action;
1622 var yukkuri = this.yukkuri;
1623 var node = this.data.targetNode;
1625 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1626 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1627 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1628 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1629 var frame = distance + distance/5 + 1;
1630 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1632 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1634 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1635 "onactionend": this.onactionend(this)
1638 onactionend:function(self){
1640 if(typeof e === "undefined")return;
1641 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1643 self.yukkuri = null;
1648 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1649 initialize: function (_data){
1651 this.yukkuri = _data.myYukkuri;
1652 this.place = _data.targetNode;
1653 this.action = _data.action;
1654 this.action.setStatus(EAction.WAIT);
1657 var sec = BASE_FPS * 3;
1658 this.yukkuri.declarePlace(this.place);
1659 this.place.setOwner(this.yukkuri);
1660 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1662 this.yukkuri.setFaceImage(EFace.NORMAL);
1663 this.yukkuri.wait(sec, {
1664 "onactionend": this.onactionend(this)
1667 onactionend:function(self){
1669 if(typeof e === "undefined")return;
1670 self.action.setStatus(EAction.THINK);
1675 var Food = enchant.Class.create(ObjSprite,{
1676 initialize: function (type, x, y){
1677 this.classname = "Food";
1678 //一つにつきgiveの値分、hunguryを減少させられる
1679 if(type == "apple"){
1680 ObjSprite.call(this,16,16);
1681 this.image = game.assets[EResPath.OBJECT];
1685 }else if(type == "grass"){
1686 ObjSprite.call(this,64,64);
1687 this.image = game.assets[EResPath.GRASS];
1694 foodGroup.addChild(this);
1695 this.addEventListener('enterframe', function(){
1696 if(this.amount <= 0){
1701 getAmount: function(){
1704 getGive: function(){
1708 var MemoryPlace = enchant.Class.create({
1709 // initialize: function (place){
1710 // if(place.x != null){
1711 // this.isWorld = true;
1713 // this.isWorld = false;
1715 // this.isWorld = (place.x != null);
1716 // this.x = place.x;
1717 // this.y = place.y;
1718 // this.width = place.width;
1719 // this.height = place.height;
1721 // isWorld: function(){
1722 // return this.isWorld;
1726 var MemoryFood = enchant.Class.create({
1727 initialize: function (food){
1729 this.isWorld = true;
1731 this.isWorld = false;
1733 this.isWorld = (food.x != null);
1736 this.width = food.width;
1737 this.height = food.height;
1739 isWorld: function(){
1740 return this.isWorld;
1743 var Place = enchant.Class.create(ObjSprite,{
1744 initialize: function (type, x, y){
1745 ObjSprite.call(this,128,128);
1746 this.image = game.assets[EResPath.PLACE_TREE];
1747 this.x = x - this.width / 2;
1748 this.y = y - this.height / 2;
1749 backgroundMap.addChild(this);
1752 for(var key in EFood){
1753 var efood = EFood[key];
1754 this.foods[efood] = 0;
1756 // this.addEventListener('enterframe', function(){
1757 // if(this.age%10 === 0 && this.age !== 0){
1758 // console.log("x/y " + this.x + "/" + this.y);
1760 // if(game.input.left){
1763 // if(game.input.right){
1766 // if(game.input.up){
1769 // if(game.input.down){
1774 getStatusForDisplay: function(){
1777 if(this.owner == null)ownerId = "なし";
1778 else ownerId = this.owner.id;
1779 ret += "プレイスID " + this.id + "\n";
1780 ret += "オーナーID " + ownerId + "\n";
1781 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1782 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1783 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1786 setItems:function(items){
1787 var len = items.length;
1788 for(var i=0; i<len; i++){
1789 var item = items[i];
1790 if(item instanceof Food){
1791 this.foods[EFood.NORMAL]++;
1798 for(var key in EFood){
1799 var efood = EFood[key];
1800 ret += this.foods[efood];
1804 getFoodHash:function(){
1805 if(this.foods[EFood.GREAT] !== 0){
1806 this.foods[EFood.GREAT]--;
1807 return {give:20,yukkuri:15,unun:20};
1809 else if(this.foods[EFood.NORMAL] !== 0){
1810 this.foods[EFood.NORMAL]--;
1811 return {give:10,yukkuri:5,unun:10};
1813 else if(this.foods[EFood.BAD] !== 0){
1814 this.foods[EFood.BAD]--;
1815 return {give:10,yukkuri:-2,unun:10};
1819 setOwner: function(yukkuri){
1820 this.owner = yukkuri;
1822 isOwner: function(){
1823 return this.owner !== null;
1826 var Unun = enchant.Class.create(ObjSprite,{
1827 initialize: function (x, y){
1828 this.classname = "Unun";
1829 ObjSprite.call(this,32,32);
1830 this.image = game.assets[EResPath.YUKKURI_UNUN];
1833 backgroundMap.addChild(this);
1834 // this.lifetime = 30 * 24 * 3;
1835 this.lifetime = 15 * 24;
1836 this.addEventListener('enterframe', this.runEnterframe(this));
1837 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1840 runEnterframe:function(self){
1842 if(typeof e === "undefined")return;
1843 if(this.age%BASE_FPS === 0 && this.age !== 0){
1845 if(self.lifetime <= 0){
1846 this.parentNode.removeChild(this);
1847 ctl.backgroundMap.removeChild(this);
1848 ctl.removeObj(this);
1856 var Okazari = enchant.Class.create(enchant.Sprite,{
1857 initialize: function(yukkuri){
1858 this.classname = "Okazari";
1859 if(yukkuri.myCode === "REIMU"){
1860 enchant.Sprite.call(this, 80, 32);
1861 this.image = game.assets[EResPathReimu.OKAZARI];
1862 this.x = -CHARA_WIDTH / 2 - 1;
1865 enchant.Sprite.call(this, 64, 64);
1866 this.image = game.assets[EResPath.MARISA_OKAZARI];
1867 this.x = -CHARA_WIDTH / 2;
1868 this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
1870 this.yukkuri = yukkuri;
1872 getWidth: function(){
1874 // return this.width * this.yukkuri.myScaleX;
1876 getHeight: function(){
1878 // return this.height * this.yukkuri.myScaleY;
1881 var Kuki = enchant.Class.create(ObjSprite,{
1882 initialize: function(yukkuri, x, y){
1883 this.classname = "Kuki";
1884 enchant.Sprite.call(this, 56, 40);
1885 this.image = game.assets[EResPath.KUKI];
1887 this.y = -CHARA_HEIGHT / 2 -CHARA_HEIGHT / 4 + y;
1888 this.owner = yukkuri;
1889 this.miYukkuris = [];
1891 addMiYukkuri: function(miYukkuri){
1892 miYukkuri.setX(miYukkuri.getX() + 30);
1893 miYukkuri.setY(miYukkuri.getY() - 30);
1894 this.miYukkuris.push(miYukkuri);
1902 getWidth: function(){
1904 // return this.width * this.yukkuri.myScaleX;
1906 getHeight: function(){
1908 // return this.height * this.yukkuri.myScaleY;
1911 var Address = enchant.Class.create({
1912 initialize: function(yukkuri){
1913 this.friendlyLv = 1;
1914 this.yukkuri = yukkuri;
1915 this.isGreeting = false;
1916 this.greetingWaitFrame = 0;
1918 "beginSayHello" : false,
1923 set:function(key, value){
1924 this.comMatrix[key] = value;
1927 return this.comMatrix[key];
1931 var Yukkuri = enchant.Class.create(ObjSprite,{
1932 initialize: function(x, y, grow){
1933 ObjSprite.call(this, 64, 64);
1934 this.searchObjectMang = new SearchObjectMang();
1938 this.myCode = "YUKKURI";
1939 this.myName = "ゆっくり";
1940 this.beforeHuntingFood = null;
1941 if(grow == EGrow.ADULT){
1946 else if(grow == EGrow.SUBADULT){
1947 this.myScaleX = 0.8;
1948 this.myScaleY = 0.8;
1951 else if(grow == EGrow.CHILD){
1952 this.myScaleX = 0.6;
1953 this.myScaleY = 0.6;
1956 else if(grow == EGrow.BABY){
1957 this.myScaleX = 0.3;
1958 this.myScaleY = 0.3;
1961 else if(grow == EGrow.FRUIT_BABY){
1962 this.myScaleX = 0.2;
1963 this.myScaleY = 0.2;
1964 this.mySize = "SSS";
1967 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1968 this.classname = "Yukkuri";
1969 this.addressBook = {};
1970 // this.imgGroup = new SpriteGroup();
1971 // this.imgBody = new SpriteGroup();
1972 // this.imgGroup.id = guid();
1973 // this.imgBody.id = guid();
1974 this.x = -CHARA_WIDTH / 2;
1975 this.y = -CHARA_HEIGHT / 2;
1978 this.image = game.assets[EResPath.YUKKURI_BASE];
1979 this.direction = EDirection.RIGHT;
1980 this.addEventListener('enterframe', this.runEnterframe);
1981 this.bodyStatus ={};
1982 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
1983 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
1984 this.walkAnimationStatus = EWalkAnimation.END;
1987 this.actionQueue = [];
1989 this.exValueHash = {};
1990 this.memoryHash = {};
1991 this.communicateYukkuri = {};
1992 for(var _v in EExSkill){
1993 var key = EExSkill[_v];
1994 this.exLvHash[key] = 0;
1995 this.exValueHash[key] = 0;
1998 this.formSprite = new FormSprite();
2000 runEnterframe:function(){
2001 // console.log("runEnterframe");
2002 // this.formSprite.run();
2003 // this.formSprite.addX(1);
2006 if(this.grow == EGrow.FRUIT_BABY){
2009 // this.kukis[0].miYukkuris[0].setX(this.getX());
2010 // this.kukis[0].miYukkuris[0].setY(this.getY());
2011 // var _x = this.imgBody.tl.node.x;
2012 // var _y = this.imgBody.tl.node.y;
2013 // var _gety = this.kukis[0].miYukkuris[0].getY();
2014 // this.kukis[0].miYukkuris[0].setOldY();
2015 // this.kukis[0].miYukkuris[0].animY(-_y);
2017 // console.log(this.getX() + ":" + this.getY());
2019 if(this.isDead())return;
2025 this.formSprite.animation();
2033 if(this.direction == EDirection.RIGHT){
2034 this.formSprite.formScaleX(this.myScaleX);
2035 // this.formSprite.formScaleY(this.myScale);
2037 // this.imgBody.scaleX = 1;
2039 else if(this.direction == EDirection.LEFT){
2040 this.formSprite.formScaleX(-this.myScaleX);
2041 // this.formSprite.formScaleY(this.myScale);
2042 // this.imgBody.scaleX = -1;
2045 tweet:function(text){
2046 text = text.replace(/%name%/g, this.myName);
2047 // this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
2048 this._tweet.text(text, this.getX() - this._tweet.width/4, this.getY() - this._tweet.height);
2050 moveTo:function(x, y, time){
2051 this.formSprite.tlMoveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2052 // this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2054 moveBy:function(x, y, time, eventFunctions){
2055 this.formSprite.tlMoveBy(x, y, time, eventFunctions);
2059 // return self.getX() + x;
2060 // // return self.imgGroup.x + x;
2063 // return self.getY() + y;
2064 // // return self.imgGroup.y + y;
2067 // easing: enchant.Easing.SIN_EASEINOUT
2069 // //-Event register [onactionstart,onactiontick,onactionend]
2070 // if(eventFunctions !== undefined){
2071 // for(var key in eventFunctions){
2072 // params[key] = eventFunctions[key];
2075 // console.log("moveBy");
2076 // console.log("self.x:" + self.getX());
2077 // return this.formSprite.tlTween(params);
2078 // // return this.imgGroup.tl.tween(params);
2080 wait:function(frame, eventFunctions){
2081 this.moveBy(0,0,frame,eventFunctions);
2087 animation: function(){
2088 this.formSprite.animation();
2090 // frame -= plusFrameScale(frame, this.getMyScale()) / 2;
2092 // move -= plusFrameScale(move, this.getMyScale());
2093 // if(this.walkAnimationStatus == EWalkAnimation.END){
2094 // this.imgBody.y = 0;
2095 // this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
2096 // "onactionstart": function(e){
2097 // this.walkAnimationStatus = EWalkAnimation.START;
2100 // .moveByEx(0, move, frame, enchant.Easing.SWING,
2102 // "onactionend": function(e){
2103 // this.walkAnimationStatus = EWalkAnimation.END;
2107 // this.imgBody.tl.loop();
2110 getMyScale: function(){
2111 return (this.myScaleX + this.myScaleY) / 2;
2113 getWidth: function(){
2114 return this.width * this.myScaleX;
2116 getHeight: function(){
2117 return this.height * this.myScaleY;
2120 this.formSprite.setX(x);
2121 // this.imgGroup.x = x;
2124 this.formSprite.setY(y);
2125 // this.imgGroup.y = y;
2128 return this.formSprite.getX();
2129 // return this.imgGroup.x;
2132 return this.formSprite.getY();
2133 // return this.imgGroup.y;
2136 this.formSprite.addX(x);
2137 // this.imgGroup.x += x;
2140 this.formSprite.addY(y);
2141 // this.imgGroup.y += y;
2143 // changeFace: function(erespath){
2144 // this.face.image = game.assets[erespath];
2146 loadParamsXML: function(url){
2147 var http = new JKL.ParseXML( url );
2148 return http.parse();
2150 runYukkuri: function(){
2151 if(this.param.hungry > 70){
2152 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
2153 this.param.yukkuri -= 1;
2156 else if(this.param.hungry < 10){
2157 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
2160 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
2161 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
2163 runHungry: function(){
2164 if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
2165 if(this.param.hungry >= 100)this.param.hungry = 100;
2167 runUnun: function(){
2168 if(this.age%50 === 0 && this.age !== 0)this.param.unun += 1;
2169 if(this.param.unun >= 100)this.param.unun = 100;
2171 runSleep: function(){
2172 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
2173 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
2174 if(this.param.sleep >= 100){
2175 this.param.sleep = 100;
2179 runAddress: function(){
2180 for(var key in this.addressBook){
2181 var address = this.addressBook[key];
2183 if(address.isGreeting){
2184 address.greetingWaitFrame++;
2185 if(address.greetingWaitFrame >= DAY){
2186 address.greetingWaitFrame = 0;
2187 address.isGreeting = false;
2192 changeFace: function(){
2193 if(this.param.yukkuri >= 80){
2194 this.setFaceImage(EFace.HAPPY1);
2196 else if(this.param.yukkuri >= 50){
2197 this.setFaceImage(EFace.NORMAL);
2199 else if(this.param.yukkuri >= 30){
2200 this.setFaceImage(EFace.TIRED);
2202 else if(this.param.yukkuri >= 10){
2203 this.setFaceImage(EFace.CRY1);
2205 else if(this.param.yukkuri >= 1){
2206 this.setFaceImage(EFace.CRY2);
2209 getRange: function(){
2210 return this.param.range;
2212 isSleep: function(){
2213 return this.param.sleep >= 100;
2216 return this.param.yukkuri <= 0;
2218 isManpuku: function(){
2219 return this.param.hungry <= 20;
2221 isKuhuku: function(){
2222 return this.param.hungry >= 40;
2224 isVeryKuhuku: function(){
2225 return this.param.hungry >= 80;
2227 getYukkuri: function(){
2228 return this.param.yukkuri;
2230 setYukkuri: function(yukkuri){
2231 this.param.yukkuri = yukkuri;
2232 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2234 addYukkuri: function(yukkuri){
2235 this.param.yukkuri += yukkuri;
2236 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2238 getHungry: function(){
2239 return this.param.hungry;
2241 setHungry: function(hungry){
2242 this.param.hungry = hungry;
2243 if(this.param.hungry < 0)this.param.hungry = 0;
2245 getUnun: function(){
2246 return this.param.unun;
2248 setUnun: function(unun){
2249 this.param.unun = unun;
2250 if(this.param.unun < 0)this.param.unun = 0;
2254 if(food instanceof Food){
2256 if(food.amount > 0){
2258 this.setHungry(this.param.hungry - food.getGive());
2259 this.setUnun(this.getUnun() + food.getGive() / 4);
2260 this.setYukkuri(this.getYukkuri() + 5);
2263 this.setYukkuri(this.getYukkuri() - 5);
2269 this.setHungry(this.param.hungry - food.give);
2270 this.setUnun(this.getUnun() + food.unun);
2271 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2278 hunt:function(food){
2279 if(food.amount > 0){
2280 if(!this.isItemsMax()){
2282 this.items.push(food);
2283 this.setYukkuri(this.getYukkuri() + 1);
2289 declarePlace: function(place){
2292 getPlace:function(){
2295 isPlace: function(){
2296 return this.place !== null;
2300 if(this.direction == EDirection.RIGHT){
2301 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2303 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2305 // if(this.direction == EDirection.RIGHT){
2306 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2308 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2312 setBodyImage: function(ebody){
2313 var path = this.bodyStatus[ebody];
2314 this.image = game.assets[path];
2317 // this.imgBody.tl.clear();
2318 // this.imgGroup.tl.clear();
2319 // this.imgBody.tl.unloop();
2320 // this.imgGroup.tl.unloop();
2321 // this.imgBody.y = 0;
2324 tlResume: function(){
2325 // this.imgBody.tl.resume();
2326 // this.imgGroup.tl.resume();
2329 syncDirection:function(senderYukkuri){
2330 if(this.getX() > senderYukkuri.getX()){
2331 this.direction = EDirection.LEFT;
2332 senderYukkuri.direction = EDirection.RIGHT;
2334 this.direction = EDirection.RIGHT;
2335 senderYukkuri.direction = EDirection.LEFT;
2338 isCommunication: function(yukkuri){
2339 if(this.addressBook[yukkuri.id] === undefined) return true;
2340 if(this.addressBook[yukkuri.id].isGreeting) return false;
2343 addAddress: function(yukkuri){
2344 this.addressBook[yukkuri.id] = new Address(yukkuri);
2346 getAddress: function(yukkuri){
2347 if(this.addressBook[yukkuri.id] === undefined)return null;
2348 return this.addressBook[yukkuri.id];
2350 getStatusForDisplay: function (){
2352 var placeId = (this.place==null)?"無し" : this.place.id;
2353 ret += "ID " + this.id + "\n";
2354 ret += "プレイス " + placeId + "\n";
2355 ret += "ゆっくり " + this.getYukkuri() + "\n";
2356 ret += "空腹 " + this.getHungry() + "\n";
2357 ret += "うんうん " + this.getUnun() + "\n";
2358 ret += "もちもの " + this.items.length + "\n";
2359 ret += "debug " + this.action.status + "\n";
2362 isItemsMax:function(){
2363 return this.items.length >= this.param.items_max;
2365 getItems:function(){
2368 addSearchObject:function(esearch, node){
2369 this.searchObjectMang.add(esearch, node)
2371 clearSearchObject:function(){
2372 this.searchObjectMang.clear()
2374 setFaceImage: function(eface){
2375 var path = this.faceStatus[eface];
2376 this.face.image = game.assets[path];
2378 myScale: function(_scaleX, _scaleY){
2379 this.formSprite.scale(_scaleX, _scaleY);
2380 // this.face.scale(_scaleX,_scaleY);
2381 // if(this.myCode === "REIMU"){
2382 // // this.okazari.x = -this.okazari.width / 2;
2383 // // this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2385 // // this.okazari.x = -CHARA_WIDTH /2;
2386 // // this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2388 // if(this.sub1 != null){
2389 // this.sub1.scale(_scaleX,_scaleY);
2392 // this.okazari.scale(_scaleX,_scaleY);
2393 // this.hear.scale(_scaleX,_scaleY);
2394 // this.scale(_scaleX,_scaleY);
2395 // if(this.shadow)this.shadow.scale(_scaleX, _scaleY);
2397 send: function(targetYukkuri, object, callback){
2398 this.communicateYukkuri = targetYukkuri;
2399 targetYukkuri.recv(object, callback);
2401 recv: function(object, callback){
2402 this.communicateYukkuri = object.yukkuri;
2404 this.action.setStatus(object.actionStatus);
2406 // this.actionQueue.push({
2408 // callback: callback
2411 addExValue: function(eexskill, plus){
2412 this.exValueHash[eexskill] += plus;
2413 if(this.exValueHash[eexskill] >= 100){
2414 this.exLvHash[eexskill] = 1;
2417 getExValue: function(eexskill){
2418 return this.exValueHash[eexskill];
2420 getExSkill: function(eexskill){
2421 return this.exLvHash[eexskill];
2424 setMemory: function(ememory, value){
2425 this.memoryHash[ememory] = value;
2427 getMemory: function(ememory){
2428 return this.memoryHash[ememory];
2430 damage: function(edamage){
2431 if(edamage == EDamage.PICOHAN){
2432 mangMsg.output(this, EMsg.DAMAGE);
2433 this.setFaceImage(EFace.CRY1);
2434 this.addYukkuri(-1);
2435 //現在の行動パターンから躾対象かセレクトする
2438 addKuki: function(){
2439 for(var i=0;i<this.kukis.length;i++){
2440 if(this.kukis[i].opacity == 0){
2441 this.kukis[i].opacity = 1.0;
2442 var miMarisa = new MiMarisa(this.getX(), this.getY());
2444 // console.log(this.imgBody);
2445 // this.imgBody.addChild(miMarisa);
2446 this.kukis[i].addMiYukkuri(miMarisa);
2451 destruct: function(){
2455 // var MiYukkuri = enchant.Class.create(Yukkuri,{
2456 // initialize: function(x, y, grow){
2457 // Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2461 // setOldY: function(){
2462 // this.imgGroup.y = this.oldY;
2465 // animX: function(x){
2466 // this.oldX = this.imgGroup.x;
2467 // this.imgGroup.x -= x;
2469 // animY: function(y){
2470 // this.imgGroup.y = this.oldY;
2471 // // this.oldY = this.imgGroup.y;
2472 // this.imgGroup.y -= y;
2475 // var MiMarisa = enchant.Class.create(MiYukkuri,{
2476 // initialize: function(x, y, grow){
2477 // MiYukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2478 // this.classname = "MiMarisa";
2479 // this.myCode = "MIMARISA";
2480 // this.myName = "実まりさ";
2482 // this.param = new MarisaParam();
2483 // this.param.range = 0;
2484 // this.param.looks = ELooks.GOOD_YUKKURI;
2487 // this.face = new enchant.Sprite(64, 64);
2488 // this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2489 // this.face.x = -CHARA_WIDTH / 2;
2490 // this.face.y = -CHARA_HEIGHT / 2;
2492 // this.faceStatus ={};
2493 // this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2494 // this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2495 // this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2496 // this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2497 // this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2498 // this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2499 // this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2500 // this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2501 // this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2502 // this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2504 // this.hear = new enchant.Sprite(64, 64);
2505 // this.hear.image = game.assets[EResPath.MARISA_HEAR];
2506 // this.hear.x = -CHARA_WIDTH / 2;
2507 // this.hear.y = -CHARA_HEIGHT / 2;
2509 // this.okazari = new Okazari(this);
2512 // // this.imgBody.addChild(this);
2513 // // this.imgBody.addChild(this.face);
2514 // // this.imgBody.addChild(this.hear);
2515 // // this.imgBody.addChild(this.okazari);
2516 // this.myScale(this.myScaleX, this.myScaleY)
2517 // // this.imgGroup.width = this.getWidth();
2518 // // this.imgGroup.height = this.getHeight();
2519 // // this.imgGroup.addChild(this.imgBody);
2520 // // this.imgGroup.flgMiYukkuri = true;
2521 // // backgroundMap.addChild(this.imgGroup);
2522 // this._tweet = new TTweet(148, 64);
2524 // this.imgGroup.addChild(this._tweet);
2525 // this.imgGroup.x = x;
2526 // this.imgGroup.y = y;
2528 // this.action = new Action(this);
2529 // ctl.addObj(this);
2533 var Marisa = enchant.Class.create(Yukkuri,{
2534 initialize: function(x, y, grow){
2535 Yukkuri.call(this,x,y, grow);
2536 this.classname = "Marisa";
2537 this.myCode = "MARISA";
2538 this.myName = "まりさ";
2540 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2541 // var json = net.load("./data/marisa/params.json");
2542 // this.param = json.root.param;
2543 this.param = new MarisaParam();
2544 this.param.looks = ELooks.GOOD_YUKKURI;
2545 if(this.grow == EGrow.BABY){
2546 this.myName = "まりちゃ";
2547 this.param.range /= 4;
2549 else if(this.grow == EGrow.CHILD){
2550 this.param.range /= 3;
2552 else if(this.grow == EGrow.SUBADULT){
2553 this.param.range *= 0.8;
2556 this.shadow = new enchant.Sprite(64, 64);
2557 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2558 this.shadow.x = 0 + this.x;
2559 this.shadow.y = this.getHeight() / 16 + this.y;
2561 this._style.zIndex = 5;
2563 this.face = new enchant.Sprite(64, 64);
2564 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2565 this.face.x = -CHARA_WIDTH / 2;
2566 this.face.y = -CHARA_HEIGHT / 2;
2568 this.faceStatus ={};
2569 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2570 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2571 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2572 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2573 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2574 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2575 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2576 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2577 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2578 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2581 this.hear = new enchant.Sprite(64, 64);
2582 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2583 this.hear.x = -CHARA_WIDTH / 2;
2584 this.hear.y = -CHARA_HEIGHT / 2;
2586 this.okazari = new Okazari(this);
2589 this.kukis[0] = new Kuki(this, 0, 0);
2590 this.kukis[1] = new Kuki(this, 10, 0);
2591 this.kukis[2] = new Kuki(this, 5, 5);
2592 this.kukis[3] = new Kuki(this, -5, 5);
2593 this._tweet = new TTweet(this, 148, 64);
2595 this.formSprite.add(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
2596 this.formSprite.add(this, 1, {
2599 scaleValue:this.myScaleY
2601 this.formSprite.add(this.face,2,{type:"body",scaleValue:this.myScaleY});
2602 this.formSprite.add(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2603 this.formSprite.add(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2604 this.formSprite.add(this._tweet,5,{type:"tweet",scaleValue:this.myScaleY});
2605 this.formSprite.addChildAll();
2606 this.formSprite.setX(x);
2607 this.formSprite.setY(y);
2608 // App.backgroundMap.addChild(this._tweet);
2609 // this.imgGroup.addChild(this.shadow);
2610 // this.imgBody.addChild(this);
2611 // this.imgBody.addChild(this.face);
2612 // this.imgBody.addChild(this.hear);
2613 // this.imgBody.addChild(this.okazari);
2614 // for(var i=0;i<this.kukis.length;i++){
2615 // this.imgBody.addChild(this.kukis[i]);
2616 // this.kukis[i].opacity = 0;
2619 // this.imgBody.addChild(new Kuki(this));
2620 this.myScale(this.myScaleX, this.myScaleY)
2621 if(this instanceof Player){
2622 // this.myScaleX = 0.5;
2623 // this.myScaleY = 0.5;
2625 this.budge = new enchant.Sprite(16, 16);
2626 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2627 // this.imgBody.addChild(this.budge);
2628 this.budge.x -= this.getWidth()/2;
2629 this.budge.y -= this.getHeight()/2;
2630 this.budge.scale(this.myScaleX, this.myScaleX);
2632 // this.imgGroup.width = this.getWidth();
2633 // this.imgGroup.height = this.getHeight();
2634 // this.imgGroup.addChild(this.imgBody);
2636 // backgroundMap.addChild(this.imgGroup);
2637 // this._tweet = new TTweet(148, 64);
2639 // this.imgGroup.addChild(this._tweet);
2640 // this.imgGroup.x = x;
2641 // this.imgGroup.y = y;
2644 this.action = new Action(this);
2648 var Player = enchant.Class.create(Marisa,{
2649 initialize: function(x, y, grow){
2650 // this.runEnterframe = function(){
2652 if(grow === undefined)grow = EGrow.ADULT;
2653 Marisa.call(this, x, y, grow);
2654 this.classname = "Player";
2655 ctl.setPlayer(this);
2656 // this.removeEventListener('enterframe',this.runEnterframe);
2657 this.addEventListener('enterframe', function(){
2659 if(this.age%10 === 0 && this.age !== 0){
2660 // console.log("palyer:" + this.age);
2663 ///////////////////////////////////////////////
2664 //Action pattern debug
2665 if(game.input.left){
2666 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2668 this.direction = EDirection.LEFT;
2670 if(game.input.right){
2671 for(var i=0;i<this.formSprite.spriteArray.length;i++){
2672 var spr = this.formSprite.spriteArray[i];
2673 console.log(i+":spry:" + spr.y);
2676 this.direction = EDirection.RIGHT;
2681 if(game.input.down){
2685 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2686 ///////////////////////////////////////////////
2688 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2689 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2691 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2693 //- Display the circle of search range.
2694 // fieldBg.image.clear();
2695 // fieldBg.image.context.beginPath();
2696 // fieldBg.image.context.fillStyle = '#ff0000';
2697 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2698 // fieldBg.image.context.fill();
2702 var Reimu = enchant.Class.create(Yukkuri,{
2703 initialize: function(x, y, grow){
2704 Yukkuri.call(this,x,y, grow);
2705 this.classname = "Reimu";
2706 this.myCode = "REIMU";
2707 this.myName = "れいむ";
2709 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2710 // var json = net.load("./data/reimu/params.json");
2711 // this.param = json.root.param;
2712 this.param = new ReimuParam();
2713 if(this.grow == EGrow.BABY){
2714 this.myName = "れいみゅ";
2715 this.param.range /= 4;
2717 else if(this.grow == EGrow.CHILD){
2718 this.param.range /= 3;
2720 else if(this.grow == EGrow.SUBADULT){
2721 this.param.range *= 0.8;
2723 this.shadow = new enchant.Sprite(64, 64);
2724 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2725 this.shadow.x = 0 + this.x;
2726 this.shadow.y = this.getWidth() / 16 + this.x;
2727 this.shadow.image._element.style.zIndex = 2;
2729 this._style.zIndex = 5;
2731 this.face = new enchant.Sprite(64, 64);
2732 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2733 this.face.x = -CHARA_WIDTH / 2;
2734 this.face.y = -CHARA_HEIGHT / 2;
2735 this.face._style.zIndex = 0;
2737 this.faceStatus ={};
2738 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2739 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2740 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2741 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2742 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2743 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2744 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2745 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2746 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2747 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2750 this.hear = new enchant.Sprite(64, 64);
2751 this.hear.image = game.assets[EResPathReimu.HEAR];
2752 this.hear.x = -CHARA_WIDTH / 2;
2753 this.hear.y = -CHARA_HEIGHT / 2;
2755 this.sub1 = new enchant.Sprite(64, 64);
2756 this.sub1.image = game.assets[EResPathReimu.SUB1];
2757 this.sub1.x = -CHARA_WIDTH / 2;
2758 this.sub1.y = -CHARA_HEIGHT / 2;
2760 this.okazari = new Okazari(this);
2763 // this.imgGroup.addChild(this.shadow);
2764 // this.imgBody.addChild(this.okazari);
2765 // this.imgBody.addChild(this);
2766 // this.imgBody.addChild(this.face);
2767 // this.imgBody.addChild(this.hear);
2768 // this.imgBody.addChild(this.sub1);
2769 this.myScale(this.myScaleX, this.myScaleY)
2770 if(this instanceof Player){
2771 this.budge = new enchant.Sprite(16, 16);
2772 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2773 this.imgBody.addChild(this.budge);
2774 this.budge.x -= this.getWidth()/2;
2775 this.budge.y -= this.getHeight()/2;
2776 this.budge.scale(this.myScaleX, this.myScaleX);
2778 // this.imgGroup.width = this.getWidth();
2779 // this.imgGroup.height = this.getHeight();
2780 // this.imgGroup.addChild(this.imgBody);
2781 // backgroundMap.addChild(this.imgGroup);
2782 this._tweet = new TTweet(this, 148, 64);
2783 backgroundMap.addChild(this._tweet);
2786 // this.imgGroup.addChild(this._tweet);
2787 // this.imgGroup.x = x;
2788 // this.imgGroup.y = y;
2791 this.action = new Action(this);
2793 this.exLvHash[EExSkill.KEKKAI] = 1;
2794 this.exValueHash[EExSkill.KEKKAI] = 100;
2798 game.onload = function(){
2802 def.ObjSprite = ObjSprite;
2803 def.Yukkuri = Yukkuri;
2804 def.nodeSort = nodeSort;
2805 mangTouch = new MangTouch(ctl);
2806 mangMsg = new MangMsg(ctl);
2807 ctl.setDefined(def);
2808 backgroundMap.image = game.assets[EResPath.MAP0];
2809 backgroundMap.loadData(_mapData);
2810 backgroundMap.collisionData = _collisionData;
2812 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
2813 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2814 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2815 fieldBg.image = fieldSurface;
2819 windowFront.image = windowSurface;
2822 windowFront.opacity = 0.5;
2824 windowSurface.context.fillStyle = '#000';
2825 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
2827 menuSurface.context.fillStyle = '#000';
2828 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
2829 menuBg.image = menuSurface;
2830 menuBg.x = EMenuPos.X;
2831 menuBg.y = EMenuPos.Y;
2832 backgroundMap.addChild(fieldBg);
2833 mangIcon = new MangIcon(ctl, menuBg);
2835 game.rootScene.addChild(backgroundMap);
2836 // game.rootScene.addChild(windowFront);
2837 // game.rootScene.addChild(gwindow);
2838 // var gwindow = new GWindow(ctl, {}, 0, 0, 80, 80);
2839 game.rootScene.addChild(menuBg);
2841 // var labelGroup = new LabelGroup();
2842 mangLabel = new MangLabel(ctl, menuBg);
2843 // var info = new Label("ゆっくり");
2844 // info.color = "#ffffff";
2845 // info.font = "14px 'Times New Roman'";
2847 // info.y = GAME_HEIGHT / 2;
2848 // labelGroup.addChild(info);
2849 // menuBg.addChild(labelGroup);
2852 // var food = new def.Food("apple", 200, 250);
2853 backgroundMap.addChild(foodGroup);
2854 // backgroundMap.addChild(placeGroup);
2855 var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2856 // var player = new Player(0, 0);
2857 // console.log(player.getX());
2858 // player.addKuki();
2859 // player.createKuki();
2860 new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
2861 new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
2862 new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
2863 new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2864 // // new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
2865 // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
2866 // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
2867 // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
2868 // new Unun(100, 100);
2869 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2871 // var input = new Label("<form name='hoge' style='background-color:#ff0000;'>" +
2872 // "<input type='text' name='text'>" +
2873 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2876 // input.element.innerHTML = "<form name='hoge' style='background-color:#ff0000;'>" +
2877 // "<input type='text' name='text'>" +
2878 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2880 // menuBg.addChild(input);
2881 // game.rootScene.addChild(input);
2882 // var inputEvent = new Label('');
2884 // game.rootScene.addChild(output);
2885 // output.onenterframe = function(e) {
2886 // output.text = document.hoge.text.value;
2889 // enchant.Node.GAddEvent = function(){
2891 var popupStatus = null;
2892 var testFlg = false;
2894 game._element.addEventListener('mousemove', function (e) {
2895 var mang = mangTouch.get(ctl.getCurrentCommand());
2896 if(EMenuPos.X < e.layerX){
2897 var ex = e.layerX - EMenuPos.X;
2900 for(var i=0;i<mangIcon.cmdIcons.length;i++){
2901 var icon = mangIcon.cmdIcons[i];
2902 if(icon.x <= ex && ex <= (icon.x + ICON_WIDTH)
2903 && icon.y <= ey && ey <= (icon.y + ICON_HEIGHT)
2906 if(popupStatus !== i){
2907 ctl.popup.renew(game.rootScene, EMenuPos.X + 5, e.layerY + ICON_HEIGHT / 2, 80, 80);
2908 ctl.popup.setText(icon.text);
2916 ctl.popup.opacity = 0.9;
2917 ctl.popup.drawText();
2920 ctl.popup.opacity = 0;
2922 // console.log(e.layerX + ":" + e.layerY);
2925 // enchant.Core.instance._element.addEventListener('mousemove', function(e) {
2927 // game.rootScene.addEventListener('mousemove', function (e) {
2928 // console.log("mmmmmmmmm");
2932 game.rootScene.addEventListener('touchstart', function (e) {
2933 game.touched = true;
2934 var mang = mangTouch.get(ctl.getCurrentCommand());
2937 game.rootScene.addEventListener('touchmove', function (e) {
2938 var mang = mangTouch.get(ctl.getCurrentCommand());
2941 game.rootScene.addEventListener('touchend', function (e) {
2942 var mang = mangTouch.get(ctl.getCurrentCommand());
2944 game.touched = false;
2948 game.rootScene.addEventListener('enterframe', function(e){
2950 mangLabel.draw(player);
2951 if(this.age%BASE_FPS == 0 ){
2954 ctl.time += TIME_SPEED;
2956 this.addEventListener('enterframe', function(){
2957 //The priority processing of display instead of z-index
2959 backgroundMap.childNodes.sort(nodeSort);