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 var budgeValue = 10 + 28;
341 var shadowValue = -28;
342 //okazariは他のbodyと比べて11低い
343 var okazariValue = 37 + 11;
345 var tweetValue = 148;
347 if(a.type == "shadow"){
348 ay += shadowValue * a.scaleValue;
350 else if(a.type == "body" && a.classname == "Okazari"){
351 ay += okazariValue * a.scaleValue - a.anim.cnt;
353 else if(a.type == "body"){
354 ay += bodyValue * a.scaleValue - a.anim.cnt;
356 else if(a.type == "tweet"){
357 ay += tweetValue * a.scaleValue;
359 else if(a.type == "budge"){
360 ay += budgeValue * a.scaleValue - a.anim.cnt;
363 if(b.type == "shadow"){
364 by += shadowValue * b.scaleValue;
367 else if(b.type == "body" && b.classname == "Okazari"){
368 by += okazariValue * b.scaleValue - b.anim.cnt;
370 else if(b.type == "body"){
371 by += bodyValue * b.scaleValue - b.anim.cnt;
373 else if(b.type == "tweet"){
374 by += tweetValue * b.scaleValue;
376 else if(b.type == "budge"){
377 by += budgeValue * b.scaleValue - b.anim.cnt;
381 if(a instanceof SpriteGroup){
385 if(b instanceof SpriteGroup){
390 if(a instanceof Place){
391 ay += Math.round(a.height * 0.7);
393 if(b instanceof Place){
394 by += Math.round(b.height * 0.7);
396 // if(a.flgMiYukkuri){
397 // ay += CHARA_HEIGHT;
399 // if(b.flgMiYukkuri){
400 // by += CHARA_HEIGHT;
403 if(Math.round(ay) < Math.round(by))return -1;
404 else if(Math.round(ay) > Math.round(by))return 1;
405 if(a.id < b.id)return -1;
406 else if(a.id > b.id)return 1;
412 var def = new Object();
413 var foodGroup = new Group();
414 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
415 SpriteGroup.prototype.classname = "";
416 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
417 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
418 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
419 game = new Game(GAME_WIDTH, GAME_HEIGHT);
423 var tmpName = EResPathReimu.getName();
425 for(var _v in EResPathReimu){
426 if(typeof EResPathReimu[_v] === "function")continue;
427 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
433 for(var _v in EResPath){
434 _loadArr[i] = EResPath[_v];
437 game.preload(_loadArr);
438 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
439 var backgroundMap = new MapGroup(16, 16);
440 App.backgroundMap = backgroundMap;
441 include("./class.js");
442 include("./ctrl.js");
445 ctl.setBackgroundMap(backgroundMap);
446 var Action = enchant.Class.create({
447 initialize: function (yukkuri){
448 this.status = EAction.THINK;
449 this.yukkuri = yukkuri;
450 this.isMoving = false;
451 this.targetNode = null;
453 getStatus: function(){
456 setStatus: function(eaction){
457 this.status = eaction;
460 if(this.yukkuri.isDead()){
461 this.status = EAction.DEAD;
463 // else if(this.yukkuri.isSleep()){
464 // this.status = EAction.SLEEP;
473 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
475 this.setStatus(EAction.THINK);
476 console.log("wait cnt end");
479 case EAction.THINK_IN_HOME:
482 this.think_in_home();
484 case EAction.EAT_IN_HOME:
489 if(this.yukkuri.age%2 === 0){
490 this.yukkuri.changeFace();
492 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
495 case EAction.MOVE_TO_EAT_START:
496 this.move_to_eat_start();
498 case EAction.MOVE_TO_EAT_UNDERWAY:
504 case EAction.SLEEP_START:
507 case EAction.SLEEP_WAIT:
512 case EAction.EAT_START:
515 case EAction.EAT_WAIT:
517 case EAction.UNUN_START:
520 case EAction.UNUN_WAIT:
522 case EAction.MOVE_TO_COMMAND:
523 this.move_to_command();
525 case EAction.UNUN_SMELL_START:
526 this.unun_smell_start();
528 case EAction.COMMUNICATE_START:
529 this.communicate_start();
531 case EAction.COMMUNICATE_WAIT:
532 case EAction.COMMUNICATE_RECV:
533 if(this.yukkuri.communicateYukkuri != null){
534 var _s = this.yukkuri.communicateYukkuri.action.getStatus();
535 if(this.yukkuri.communicateYukkuri.isDead()
536 || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
537 this.setStatus(EAction.THINK);
538 this.yukkuri.animation();
542 case EAction.MOVE_TO_PLACE_START_HOMELESS:
543 this.move_to_place_start_homeless();
545 case EAction.DECLARE_PLACE_HOMELESS:
546 this.declare_place_homeless();
548 case EAction.MOVE_TO_HUNT_START:
549 this.move_to_hunt_start();
551 case EAction.HUNT_START:
554 case EAction.MOVE_GOTO_HOME:
555 this.move_goto_home();
557 case EAction.IN_HOME:
562 this.yukkuri.reverse();
564 // thinkHavePlace: function(){
565 // var date = ctl.getDate();
566 // if(this.yukkuri.isPlaceRange()){
569 // if(date === EDate.EVENING
570 // || date === EDate.NIGHT
571 // || date === EDate.MIDNIGHT
573 // this.setStatus(EAction.MOVE_GOTO_HOME);
576 // else if(date === EDate.EVENING){
577 // // if(this.yukkuri.isItemsMax()){
578 // // this.setStatus(EAction.IN_HOME);
581 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
585 // if(this.yukkuri.isVeryKuhuku()){
589 // this.setStatus(EAction.MOVE_GOTO_HOME);
591 // else if(this.yukkuri.isSleep()){
592 // this.setStatus(EAction.SLEEP_START);
594 // else if(this.yukkuri.getUnun() >= 80){
595 // this.setStatus(EAction.UNUN_START);
598 // this.yukkuri.changeFace();
602 think_in_home: function(){
603 var date = ctl.getDate();
604 if((date === EDate.MIDNIGHT)
605 && !this.yukkuri.isSleep()
606 && !this.yukkuri.isVeryKuhuku()
610 "nextStatus":EAction.THINK_IN_HOME,
611 "myYukkuri": this.yukkuri
615 else if(date === EDate.EVENING){
618 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
619 this.setStatus(EAction.EAT_IN_HOME);
622 //marisa is hunting move
623 if(this.yukkuri.beforeHuntingFood !== null){
624 new MoveToHuntEvent({
626 "targetNode": this.yukkuri.beforeHuntingFood,
628 "myYukkuri": this.yukkuri
632 this.setStatus(EAction.WALK);
636 eat_in_home: function(){
638 "targetNode": this.yukkuri.getPlace(),
640 "myYukkuri": this.yukkuri
643 move_to_eat_start : function(){
646 "targetNode": this.targetNode,
648 "myYukkuri": this.yukkuri
654 walk : function(retryCounter){
655 if(retryCounter > 15){
657 this.status = EAction.NONE;
658 console.log("retryCount over");
661 if(this.yukkuri.formSprite.tlQueueLength() === 0){
662 // if(this.yukkuri.imgGroup.tl.queue.length === 0){
664 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
666 this.isMoving = false;
667 this.status = EAction.THINK;
671 var xpos = 150 + rand(40) - (retryCounter * 10);
672 var ypos = 150 + rand(40) - (retryCounter * 10);
674 this.yukkuri.vx = xpos;
675 this.yukkuri.vy = ypos;
676 this.yukkuri.direction = EDirection.RIGHT;
678 else if(rand(8) === 0){
680 this.yukkuri.vy = -ypos;
682 else if(rand(8) == 1){
683 this.yukkuri.vx = xpos;
684 this.yukkuri.vy = -ypos;
685 this.yukkuri.direction = EDirection.RIGHT;
687 else if(rand(8) == 2){
688 this.yukkuri.vx = xpos;
690 this.yukkuri.direction = EDirection.RIGHT;
692 else if(rand(8) == 3){
693 this.yukkuri.vx = xpos;
694 this.yukkuri.vy = ypos;
695 this.yukkuri.direction = EDirection.RIGHT;
697 else if(rand(8) == 4){
699 this.yukkuri.vy = ypos;
701 else if(rand(8) == 5){
702 this.yukkuri.vx = -xpos;
703 this.yukkuri.vy = ypos;
704 this.yukkuri.direction = EDirection.LEFT;
706 else if(rand(8) == 6){
707 this.yukkuri.vx = -xpos;
709 this.yukkuri.direction = EDirection.LEFT;
711 else if(rand(8) == 7){
712 this.yukkuri.vx = -xpos;
713 this.yukkuri.vy = -ypos;
714 this.yukkuri.direction = EDirection.LEFT;
716 if (this.yukkuri.vx || this.yukkuri.vy) {
717 var map = ctl.backgroundMap;
718 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
719 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
720 var x = this.yukkuri.getX() + this.yukkuri.vx;
721 var y = this.yukkuri.getY() + this.yukkuri.vy + this.yukkuri.getHeight() / 2;
722 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
723 // console.log("あたってないよ:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY());
724 // console.log("X:" + this.yukkuri.moveX);
725 // console.log("Y:" + this.yukkuri.moveY);
726 this.isMoving = true;
727 this.yukkuri.reverse();
728 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
729 mangMsg.output(this.yukkuri,EMsg.WALK);
731 this.targetNode = null;
733 // console.log("HIT:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY() + "," + this.yukkuri.vx + ":" + this.yukkuri.vy);
734 this.walk(retryCounter+1);
740 sleep_start: function(){
743 "myYukkuri": this.yukkuri
747 mangMsg.output(this.yukkuri, EMsg.DEAD);
748 this.yukkuri.tlPause();
749 this.yukkuri.setBodyImage(EBody.DEAD);
751 eat_start: function(){
754 "targetNode": this.targetNode,
756 "myYukkuri": this.yukkuri
760 unun_start: function(){
763 "myYukkuri": this.yukkuri
766 unun_smell_start: function(){
769 "myYukkuri": this.yukkuri
772 communicate_start:function(){
773 new ComSayHelloSendEvent({
775 "targetNode": this.targetNode,
777 "myYukkuri": this.yukkuri
780 move_to_place_start_homeless:function(){
781 new MoveToPlaceStartHomelessEvent({
782 "targetNode": this.targetNode,
784 "myYukkuri": this.yukkuri
787 declare_place_homeless:function(){
788 new DeclarePlaceHomelessEvent({
789 "targetNode": this.targetNode,
791 "myYukkuri": this.yukkuri
794 move_to_hunt_start:function(){
795 new MoveToHuntEvent({
797 "targetNode": this.targetNode,
799 "myYukkuri": this.yukkuri
802 hunt_start:function(){
805 "targetNode": this.targetNode,
807 "myYukkuri": this.yukkuri
810 move_goto_home:function(){
811 var place = this.yukkuri.getPlace();
812 new MoveGotoHomeEvent({
816 "myYukkuri": this.yukkuri
820 var place = this.yukkuri.getPlace();
821 if(place != null && place.isWorld()){
826 "myYukkuri": this.yukkuri
829 if(place && !place.isWorld())place.undefineAll();
830 this.yukkuri.declarePlace(null);
831 this.setStatus(EAction.WAIT);
832 mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
833 this.yukkuri.setFaceImage(EFace.CRY2);
835 "waitframe": FPS * 3.0,
837 "myYukkuri": this.yukkuri
841 move_to_command: function(){
842 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
843 new MoveToCommandEvent({
846 "myYukkuri": this.yukkuri
851 this.yukkuri.clearSearchObject();
852 var nodes = ctl.getObjs();
855 for (var key in nodes) {
856 var node = nodes[key];
857 if(node === null || node === undefined)continue;
858 if(this.yukkuri.id === node.id)continue;
862 && !(this.targetNode instanceof Unun)
863 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
865 this.yukkuri.addSearchObject(ESearch.UNUN, node);
868 else if (node instanceof Food && node.amount > 0) {
869 if(this.yukkuri.within(node, this.yukkuri.getRange())){
870 this.yukkuri.addSearchObject(ESearch.FOOD, node);
874 else if(node instanceof Yukkuri){
875 if(node.grow != EGrow.FRUIT_BABY && this.yukkuri.within(node, this.yukkuri.getRange())){
876 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
880 else if(node instanceof Place){
881 if(this.yukkuri instanceof Player){
883 if(this.yukkuri.within(node, this.yukkuri.getRange())){
884 this.yukkuri.addSearchObject(ESearch.PLACE, node);
888 this.status = EAction.WALK;
892 * Range範囲内のObjSprを管理する
893 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
897 var SearchObjectMang = enchant.Class.create({
898 initialize: function (){
900 this.currentCmdObject = null;
904 for(var key in ESearch){
905 var esearch = ESearch[key];
906 this.datas[esearch] = [];
909 add :function(esearch, node){
910 this.datas[esearch].push(node);
913 for(var key in ESearch){
914 var esearch = ESearch[key];
915 this.datas[esearch].length = 0;
917 // this.datas.length = 0;
920 get:function (esearch){
921 return this.datas[esearch];
923 getNear:function (esearch, yukkuri){
924 var objects = this.datas[esearch];
925 var nearDistance = null;
927 for(var i=0;i<objects.length;i++){
928 var object = objects[i];
929 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
930 if(nearDistance === null || nearDistance > nowDistance){
931 nearDistance = nowDistance;
937 callEvent: function(yukkuri){
938 if(yukkuri.cmdQueue.length !== 0){
939 this.currentCmdObject = yukkuri.cmdQueue.shift();
940 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
944 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
945 yukkuri.action.targetNode = yukkuri.getPlace();
946 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
949 if(yukkuri.isVeryKuhuku()){
951 var foods = this.get(ESearch.FOOD);
952 if(foods.length > 0){
953 var foods = this.get(ESearch.FOOD);
954 food = this.getNear(ESearch.FOOD, yukkuri);
956 yukkuri.action.targetNode = food;
957 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
961 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
962 yukkuri.action.setStatus(EAction.WALK);
967 if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
968 yukkuri.action.targetNode = yukkuri.getPlace();
969 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
973 yukkuri.action.setStatus(EAction.WALK);
977 if(yukkuri.isSleep()){
978 yukkuri.action.setStatus(EAction.SLEEP_START);
982 else if(yukkuri.getUnun() >= 80){
983 yukkuri.action.setStatus(EAction.UNUN_START);
988 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
989 food = this.getNear(ESearch.FOOD, yukkuri);
991 yukkuri.action.targetNode = food;
992 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
996 ununs = this.get(ESearch.UNUN);
997 if(ununs.length !== 0){
998 yukkuri.action.targetNode = yukkuri.getPlace();
999 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
1002 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
1003 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
1004 yukkuri.action.targetNode = searchYukkuri;
1005 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
1008 if(!yukkuri.isPlace()){
1009 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
1010 if(searchYukkuri != null && !searchYukkuri.isOwner()){
1011 yukkuri.action.targetNode = searchYukkuri;
1012 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
1016 yukkuri.action.setStatus(EAction.WALK);
1021 var Event = enchant.Class.create({
1022 initialize: function (_data){
1025 onactionstart:function(self){
1026 return this._onactionstart;
1028 _onactionstart:function(e){
1029 if(typeof e === "undefined")return;
1031 onactiontick:function(self){
1033 if(typeof e === "undefined")return;
1036 onactionend:function(self){
1038 if(typeof e === "undefined")return;
1042 var WalkEvent = enchant.Class.create(Event,{
1043 initialize: function (_data){
1045 this.yukkuri = _data.myYukkuri;
1046 this.action = _data.action;
1048 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1049 this.action.setStatus(EAction.SLEEP_WAIT);
1050 this.yukkuri.setFaceImage(EFace.SLEEP);
1051 this.yukkuri.tlPause();
1053 this.yukkuri.addEventListener('enterframe', function() {
1054 var yukkuri = self.yukkuri;
1062 var SleepEvent = enchant.Class.create(Event,{
1063 initialize: function (_data){
1065 this.yukkuri = _data.myYukkuri;
1066 this.action = _data.action;
1068 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1069 this.action.setStatus(EAction.SLEEP_WAIT);
1070 this.yukkuri.setFaceImage(EFace.SLEEP);
1071 this.yukkuri.tlPause();
1074 this.yukkuri.addEventListener('enterframe', function() {
1075 var yukkuri = self.yukkuri;
1076 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
1077 if(yukkuri.param.sleep <= 0){
1078 yukkuri.param.sleep = 0;
1079 this.removeEventListener("enterframe",arguments.callee);
1080 mangMsg.output(self.yukkuri, EMsg.GET_UP);
1081 yukkuri.setFaceImage(EFace.NORMAL);
1083 // self.action.setStatus(EAction.WAIT);
1084 if(self.data.nextStatus !== undefined){
1085 self.action.setStatus(self.data.nextStatus);
1087 self.action.setStatus(EAction.THINK);
1094 var UnunEvent = enchant.Class.create(Event,{
1095 initialize: function (_data){
1097 this.yukkuri = _data.myYukkuri;
1098 this.action = _data.action;
1099 this.action.setStatus(EAction.UNUN_WAIT);
1100 mangMsg.output(this.yukkuri, EMsg.UNUN);
1101 this.yukkuri.setFaceImage(EFace.HAPPY2);
1104 this.yukkuri.wait(sec, {
1105 "onactionend": this.onactionend(this)
1108 onactionend:function(self){
1110 if(typeof e === "undefined")return;
1111 self.yukkuri.unun();
1112 self.action.setStatus(EAction.WAIT);
1113 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1115 "waitframe": FPS * 1.5,
1116 "action": self.action,
1117 "myYukkuri": self.yukkuri
1122 var WaitEvent = enchant.Class.create(Event,{
1123 initialize: function (_data){
1125 this.yukkuri = _data.myYukkuri;
1126 this.action = _data.action;
1127 this.waitframe = _data.waitframe;
1128 this.yukkuri.wait(this.waitframe, {
1129 "onactionstart": this.onactionstart(this),
1130 "onactiontick": this.onactiontick(this),
1131 "onactionend": this.onactionend(this)
1134 onactionend:function(self){
1136 if(typeof e === "undefined")return;
1137 self.action.setStatus(EAction.THINK);
1141 var UnunSmellEvent = enchant.Class.create(Event,{
1142 initialize: function (_data){
1144 this.yukkuri = _data.myYukkuri;
1145 this.action = _data.action;
1146 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1147 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1148 this.yukkuri.setFaceImage(EFace.CRY1);
1150 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1151 this.yukkuri.wait(sec, {
1152 "onactionend": this.onactionend(this)
1155 onactionend:function(self){
1157 if(typeof e === "undefined")return;
1158 self.action.setStatus(EAction.WALK);
1163 var EatEvent = enchant.Class.create(Event,{
1164 initialize: function (_data){
1166 this.yukkuri = _data.myYukkuri;
1167 this.food = _data.targetNode;
1168 this.action = _data.action;
1169 this.action.setStatus(EAction.EAT_WAIT);
1171 var sec = BASE_FPS * 3;
1172 if(this.yukkuri.eat(this.food)){
1173 mangMsg.output(this.yukkuri, EMsg.EAT);
1174 this.yukkuri.setFaceImage(EFace.EAT2);
1177 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1178 this.yukkuri.setFaceImage(EFace.CRY2);
1180 this.yukkuri.wait(sec, {
1181 "onactionend": this.onactionend(this)
1184 onactionend:function(self){
1186 if(typeof e === "undefined")return;
1187 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
1188 self.action.setStatus(EAction.THINK);
1189 self.yukkuri.setFaceImage(EFace.NORMAL);
1191 self.action.setStatus(EAction.EAT_START);
1198 * -When yukkuri find Food.
1201 * targetNode: enchant.Node
1205 var MoveToEatEvent = enchant.Class.create(Event,{
1206 initialize: function (_data){
1208 this.yukkuri = this.data.myYukkuri;
1209 this.action = this.data.action;
1211 var yukkuri = this.yukkuri;
1212 var node = this.data.targetNode;
1214 if(this.data.type == "food"){
1215 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1216 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2 + yukkuri.getWidth() / 2;
1217 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2 + yukkuri.getHeight() / 2;
1218 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1219 var frame = distance + distance/5 + 1;
1220 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1221 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1223 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1225 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1226 "onactiontick": this.onactiontick(this),
1227 "onactionend": this.onactionend(this)
1231 onactiontick:function(self){
1233 if(typeof e === "undefined")return;
1236 onactionend:function(self){
1238 if(typeof e === "undefined")return;
1239 self.action.setStatus(EAction.EAT_START);
1243 var MoveToHuntEvent = enchant.Class.create(Event,{
1244 initialize: function (_data){
1246 this.yukkuri = this.data.myYukkuri;
1247 this.action = this.data.action;
1249 var yukkuri = this.yukkuri;
1250 var node = this.data.targetNode;
1253 var nodeWidth = node.width;
1254 var nodeHeight = node.height;
1258 if(this.data.type == "food"){
1259 this.action.setStatus(EAction.WAIT);
1260 yukkuri.vx = nodeX - yukkuri.getX() + yukkuri.getWidth() / 2;
1261 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2 + yukkuri.getHeight() / 2;
1262 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1263 var frame = distance + distance/5 + 1;
1264 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1265 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1267 mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
1269 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1270 "onactionend": this.onactionend(this)
1274 onactionend:function(self){
1276 if(typeof e === "undefined")return;
1277 self.action.setStatus(EAction.HUNT_START);
1281 var HuntStartEvent = enchant.Class.create(Event,{
1282 initialize: function (_data){
1283 Event.call(this, _data);
1286 this.yukkuri = _data.myYukkuri;
1287 this.food = _data.targetNode;
1288 this.action = _data.action;
1289 this.action.setStatus(EAction.WAIT);
1290 this.huntingStatus = "hunting";
1292 // this.yukkuri.beforeHuntingFood = this.food;
1293 if(this.food.isWorld()){
1294 this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
1295 var sec = BASE_FPS * 8;
1296 if(this.yukkuri.hunt(this.food)){
1297 this.huntingStatus = "hunting";
1298 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1299 this.yukkuri.setFaceImage(EFace.HAPPY1);
1301 if(this.yukkuri.isItemsMax()){
1303 this.huntingStatus = "return";
1304 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1305 this.yukkuri.setFaceImage(EFace.NORMAL);
1308 this.huntingStatus = "cry";
1309 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1310 this.yukkuri.setFaceImage(EFace.CRY2);
1315 this.yukkuri.beforeHuntingFood = null;
1317 this.huntingStatus = "cry";
1318 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1319 this.yukkuri.setFaceImage(EFace.CRY2);
1322 this.yukkuri.wait(sec, {
1323 "onactiontick": this.onactiontick(this),
1324 "onactionend": this.onactionend(this)
1327 onactiontick:function(self){
1329 if(typeof e === "undefined")return;
1331 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1332 if(this.age%(BASE_FPS * 5) == 0){
1333 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1334 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1339 onactionend:function(self){
1341 if(typeof e === "undefined")return;
1342 if(self.huntingStatus == "hunting"){
1343 if(self.yukkuri.isItemsMax()){
1344 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1345 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1347 self.action.setStatus(EAction.HUNT_START);
1350 else if(self.huntingStatus == "return"){
1351 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1353 else if(self.huntingStatus === "cry"){
1354 // self.action.setStatus(EAction.THINK);
1355 self.action.setStatus(EAction.WALK);
1362 this.yukkuri = null;
1367 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1368 initialize: function (_data){
1370 this.yukkuri = this.data.myYukkuri;
1371 this.action = this.data.action;
1373 var yukkuri = this.yukkuri;
1374 var place = this.data.targetNode;
1376 if(this.data.type == "hunt_end"){
1377 this.action.setStatus(EAction.WAIT);
1378 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1379 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1380 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1381 var frame = distance + distance/2 + 1 ;
1382 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1383 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1385 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1387 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1388 "onactiontick": this.onactiontick(this),
1389 "onactionend": this.onactionend(this)
1393 onactiontick:function(self){
1395 if(typeof e === "undefined")return;
1396 if(this.age%(BASE_FPS * 5) == 0){
1397 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1401 onactionend:function(self){
1403 if(typeof e === "undefined")return;
1404 self.action.setStatus(EAction.IN_HOME);
1410 this.yukkuri = null;
1414 var InHomeEvent = enchant.Class.create(Event,{
1415 initialize: function (_data){
1417 this.yukkuri = this.data.myYukkuri;
1418 this.action = this.data.action;
1420 var yukkuri = this.yukkuri;
1421 var place = this.data.targetNode;
1423 if(yukkuri.isVeryKuhuku()){
1425 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1426 this.action.setStatus(EAction.EAT_IN_HOME);
1429 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1431 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1432 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1433 this.action.setStatus(EAction.THINK);
1436 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1437 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1442 this.action.setStatus(EAction.WAIT);
1443 var items = this.yukkuri.getItems();
1444 if(items.length > 0){
1445 place.setItems(items);
1449 var sec = BASE_FPS * 10;
1450 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1451 this.yukkuri.wait(sec, {
1452 "onactiontick": this.onactiontick(this),
1453 "onactionend": this.onactionend(this)
1456 onactiontick:function(self){
1458 if(typeof e === "undefined")return;
1459 if(this.age%(BASE_FPS * 5) == 0){
1460 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1464 onactionend:function(self){
1466 if(typeof e === "undefined")return;
1467 self.action.setStatus(EAction.THINK_IN_HOME);
1471 var EatInHomeEvent = enchant.Class.create(Event,{
1472 initialize: function (_data){
1474 this.yukkuri = _data.myYukkuri;
1475 this.place = _data.targetNode;
1476 this.action = _data.action;
1477 this.action.setStatus(EAction.EAT_WAIT);
1479 var sec = BASE_FPS * 3;
1480 var foodHash = this.place.getFoodHash();
1481 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1482 mangMsg.output(this.yukkuri, EMsg.EAT);
1483 this.yukkuri.setFaceImage(EFace.EAT2);
1486 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1487 this.yukkuri.setFaceImage(EFace.CRY2);
1490 this.yukkuri.wait(sec, {
1491 "onactionend": this.onactionend(this)
1494 onactionend:function(self){
1496 if(typeof e === "undefined")return;
1497 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1498 self.action.setStatus(EAction.EAT_IN_HOME);
1500 // new EatInHomeEvent({
1501 // "targetNode": self.place,
1502 // "action": self.action,
1503 // "myYukkuri": self.yukkuri
1506 self.action.setStatus(EAction.THINK_IN_HOME);
1507 self.yukkuri.setFaceImage(EFace.NORMAL);
1514 var MoveToCommandEvent = enchant.Class.create(Event,{
1515 initialize: function (_data){
1517 this.yukkuri = this.data.myYukkuri;
1518 this.action = this.data.action;
1519 // this.vx = this.data.cmdObject.vx;
1520 // this.vy = this.data.cmdObject.vy;
1521 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1524 var yukkuri = this.yukkuri;
1525 this.action.status = EAction.WAIT;
1526 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1527 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1528 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1529 var frame = distance + distance/2 + 1;
1530 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1532 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1534 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1535 "onactiontick": this.onactiontick(this),
1536 "onactionend": this.onactionend(this)
1539 onactiontick:function(self){
1541 if(typeof e === "undefined")return;
1544 onactionend:function(self){
1546 if(typeof e === "undefined")return;
1547 self.action.setStatus(EAction.THINK);
1552 * Say hello contact to send communication .
1554 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1555 initialize: function (_data){
1557 this.yukkuri = _data.myYukkuri;
1558 this.targetYukkuri = _data.targetNode;
1559 this.action = _data.action;
1560 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1561 // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1562 // this.targetYukkuri.tlPause();
1563 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1564 this.yukkuri.send(this.targetYukkuri, {
1565 "actionStatus":EAction.COMMUNICATE_RECV,
1566 "yukkuri":this.yukkuri
1570 this.yukkuri.tlPause();
1571 this.yukkuri.syncDirection(this.targetYukkuri);
1573 this.yukkuri.addAddress(this.targetYukkuri);
1574 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1576 var sec = BASE_FPS * 2;
1577 this.yukkuri.wait(sec, {
1578 "onactiontick": this.onactiontick(this),
1579 "onactionend": this.onactionend(this)
1582 onactiontick:function(self){
1584 if(typeof e === "undefined")return;
1587 onactionend:function(self){
1589 if(typeof e === "undefined")return;
1590 new ComSayHelloRecvEvent({
1592 "targetNode": self.yukkuri,
1593 "action": self.targetYukkuri.action,
1594 "myYukkuri": self.targetYukkuri
1599 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1600 initialize: function (_data){
1602 this.yukkuri = _data.myYukkuri;
1603 this.targetYukkuri = _data.targetNode;
1604 this.action = _data.action;
1605 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1606 this.yukkuri.addAddress(this.targetYukkuri);
1607 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1609 var sec = BASE_FPS * 2;
1610 this.yukkuri.wait(sec, {
1611 "onactiontick": this.onactiontick(this),
1612 "onactionend": this.onactionend(this)
1615 onactiontick:function(self){
1617 if(typeof e === "undefined")return;
1620 onactionend:function(self){
1622 if(typeof e === "undefined")return;
1623 self.action.setStatus(EAction.THINK);
1625 self.yukkuri.action.setStatus(EAction.THINK);
1626 self.yukkuri.animation();
1627 self.targetYukkuri.action.setStatus(EAction.THINK);
1628 self.targetYukkuri.animation();
1632 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1633 initialize: function (_data){
1635 this.yukkuri = this.data.myYukkuri;
1636 this.action = this.data.action;
1638 var yukkuri = this.yukkuri;
1639 var node = this.data.targetNode;
1641 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1642 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1643 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1644 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1645 var frame = distance + distance/5 + 1;
1646 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1648 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1650 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1651 "onactionend": this.onactionend(this)
1654 onactionend:function(self){
1656 if(typeof e === "undefined")return;
1657 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1659 self.yukkuri = null;
1664 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1665 initialize: function (_data){
1667 this.yukkuri = _data.myYukkuri;
1668 this.place = _data.targetNode;
1669 this.action = _data.action;
1670 this.action.setStatus(EAction.WAIT);
1673 var sec = BASE_FPS * 3;
1674 this.yukkuri.declarePlace(this.place);
1675 this.place.setOwner(this.yukkuri);
1676 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1678 this.yukkuri.setFaceImage(EFace.NORMAL);
1679 this.yukkuri.wait(sec, {
1680 "onactionend": this.onactionend(this)
1683 onactionend:function(self){
1685 if(typeof e === "undefined")return;
1686 self.action.setStatus(EAction.THINK);
1691 var Food = enchant.Class.create(ObjSprite,{
1692 initialize: function (type, x, y){
1693 this.classname = "Food";
1694 //一つにつきgiveの値分、hunguryを減少させられる
1695 if(type == "apple"){
1696 ObjSprite.call(this,16,16);
1697 this.image = game.assets[EResPath.OBJECT];
1701 }else if(type == "grass"){
1702 ObjSprite.call(this,64,64);
1703 this.image = game.assets[EResPath.GRASS];
1710 foodGroup.addChild(this);
1711 this.addEventListener('enterframe', function(){
1712 if(this.amount <= 0){
1717 getAmount: function(){
1720 getGive: function(){
1724 var MemoryPlace = enchant.Class.create({
1725 // initialize: function (place){
1726 // if(place.x != null){
1727 // this.isWorld = true;
1729 // this.isWorld = false;
1731 // this.isWorld = (place.x != null);
1732 // this.x = place.x;
1733 // this.y = place.y;
1734 // this.width = place.width;
1735 // this.height = place.height;
1737 // isWorld: function(){
1738 // return this.isWorld;
1742 var MemoryFood = enchant.Class.create({
1743 initialize: function (food){
1745 this.isWorld = true;
1747 this.isWorld = false;
1749 this.isWorld = (food.x != null);
1752 this.width = food.width;
1753 this.height = food.height;
1755 isWorld: function(){
1756 return this.isWorld;
1759 var Place = enchant.Class.create(ObjSprite,{
1760 initialize: function (type, x, y){
1761 ObjSprite.call(this,128,128);
1762 this.image = game.assets[EResPath.PLACE_TREE];
1763 this.x = x - this.width / 2;
1764 this.y = y - this.height / 2;
1765 backgroundMap.addChild(this);
1768 for(var key in EFood){
1769 var efood = EFood[key];
1770 this.foods[efood] = 0;
1772 // this.addEventListener('enterframe', function(){
1773 // if(this.age%10 === 0 && this.age !== 0){
1774 // console.log("x/y " + this.x + "/" + this.y);
1776 // if(game.input.left){
1779 // if(game.input.right){
1782 // if(game.input.up){
1785 // if(game.input.down){
1790 getStatusForDisplay: function(){
1793 if(this.owner == null)ownerId = "なし";
1794 else ownerId = this.owner.id;
1795 ret += "プレイスID " + this.id + "\n";
1796 ret += "オーナーID " + ownerId + "\n";
1797 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1798 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1799 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1802 setItems:function(items){
1803 var len = items.length;
1804 for(var i=0; i<len; i++){
1805 var item = items[i];
1806 if(item instanceof Food){
1807 this.foods[EFood.NORMAL]++;
1814 for(var key in EFood){
1815 var efood = EFood[key];
1816 ret += this.foods[efood];
1820 getFoodHash:function(){
1821 if(this.foods[EFood.GREAT] !== 0){
1822 this.foods[EFood.GREAT]--;
1823 return {give:20,yukkuri:15,unun:20};
1825 else if(this.foods[EFood.NORMAL] !== 0){
1826 this.foods[EFood.NORMAL]--;
1827 return {give:10,yukkuri:5,unun:10};
1829 else if(this.foods[EFood.BAD] !== 0){
1830 this.foods[EFood.BAD]--;
1831 return {give:10,yukkuri:-2,unun:10};
1835 setOwner: function(yukkuri){
1836 this.owner = yukkuri;
1838 isOwner: function(){
1839 return this.owner !== null;
1842 var Unun = enchant.Class.create(ObjSprite,{
1843 initialize: function (x, y){
1844 this.classname = "Unun";
1845 ObjSprite.call(this,32,32);
1846 this.image = game.assets[EResPath.YUKKURI_UNUN];
1849 backgroundMap.addChild(this);
1850 // this.lifetime = 30 * 24 * 3;
1851 this.lifetime = 15 * 24;
1852 this.addEventListener('enterframe', this.runEnterframe(this));
1853 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1856 runEnterframe:function(self){
1858 if(typeof e === "undefined")return;
1859 if(this.age%BASE_FPS === 0 && this.age !== 0){
1861 if(self.lifetime <= 0){
1862 this.parentNode.removeChild(this);
1863 ctl.backgroundMap.removeChild(this);
1864 ctl.removeObj(this);
1872 var Okazari = enchant.Class.create(enchant.Sprite,{
1873 initialize: function(yukkuri){
1874 this.classname = "Okazari";
1875 if(yukkuri.myCode === "REIMU"){
1876 enchant.Sprite.call(this, 80, 32);
1877 this.image = game.assets[EResPathReimu.OKAZARI];
1878 this.x = -CHARA_WIDTH / 2 - 1;
1881 enchant.Sprite.call(this, 64, 64);
1882 this.image = game.assets[EResPath.MARISA_OKAZARI];
1883 this.x = -CHARA_WIDTH / 2;
1884 this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
1886 this.yukkuri = yukkuri;
1888 getWidth: function(){
1890 // return this.width * this.yukkuri.myScaleX;
1892 getHeight: function(){
1894 // return this.height * this.yukkuri.myScaleY;
1897 var Kuki = enchant.Class.create(ObjSprite,{
1898 initialize: function(yukkuri, x, y){
1899 this.classname = "Kuki";
1900 enchant.Sprite.call(this, 56, 40);
1901 this.image = game.assets[EResPath.KUKI];
1903 this.y = -CHARA_HEIGHT / 2 -CHARA_HEIGHT / 4 + y;
1904 this.owner = yukkuri;
1905 this.miYukkuris = [];
1907 addMiYukkuri: function(miYukkuri){
1908 miYukkuri.setX(miYukkuri.getX() + 30);
1909 miYukkuri.setY(miYukkuri.getY() - 30);
1910 this.miYukkuris.push(miYukkuri);
1918 getWidth: function(){
1920 // return this.width * this.yukkuri.myScaleX;
1922 getHeight: function(){
1924 // return this.height * this.yukkuri.myScaleY;
1927 var Address = enchant.Class.create({
1928 initialize: function(yukkuri){
1929 this.friendlyLv = 1;
1930 this.yukkuri = yukkuri;
1931 this.isGreeting = false;
1932 this.greetingWaitFrame = 0;
1934 "beginSayHello" : false,
1939 set:function(key, value){
1940 this.comMatrix[key] = value;
1943 return this.comMatrix[key];
1947 var Yukkuri = enchant.Class.create(ObjSprite,{
1948 initialize: function(x, y, grow){
1949 ObjSprite.call(this, 64, 64);
1950 this.searchObjectMang = new SearchObjectMang();
1954 this.myCode = "YUKKURI";
1955 this.myName = "ゆっくり";
1956 this.beforeHuntingFood = null;
1957 if(grow == EGrow.ADULT){
1962 else if(grow == EGrow.SUBADULT){
1963 this.myScaleX = 0.8;
1964 this.myScaleY = 0.8;
1967 else if(grow == EGrow.CHILD){
1968 this.myScaleX = 0.6;
1969 this.myScaleY = 0.6;
1972 else if(grow == EGrow.BABY){
1973 this.myScaleX = 0.3;
1974 this.myScaleY = 0.3;
1977 else if(grow == EGrow.FRUIT_BABY){
1978 this.myScaleX = 0.2;
1979 this.myScaleY = 0.2;
1980 this.mySize = "SSS";
1983 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1984 this.classname = "Yukkuri";
1985 this.addressBook = {};
1986 // this.imgGroup = new SpriteGroup();
1987 // this.imgBody = new SpriteGroup();
1988 // this.imgGroup.id = guid();
1989 // this.imgBody.id = guid();
1990 this.x = -CHARA_WIDTH / 2;
1991 this.y = -CHARA_HEIGHT / 2;
1994 this.image = game.assets[EResPath.YUKKURI_BASE];
1995 this.direction = EDirection.RIGHT;
1996 this.addEventListener('enterframe', this.runEnterframe);
1997 this.bodyStatus ={};
1998 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
1999 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
2000 this.walkAnimationStatus = EWalkAnimation.END;
2003 this.actionQueue = [];
2005 this.exValueHash = {};
2006 this.memoryHash = {};
2007 this.communicateYukkuri = {};
2008 for(var _v in EExSkill){
2009 var key = EExSkill[_v];
2010 this.exLvHash[key] = 0;
2011 this.exValueHash[key] = 0;
2014 this.formSprite = new FormSprite();
2016 runEnterframe:function(){
2017 // console.log("runEnterframe");
2018 // this.formSprite.run();
2019 // this.formSprite.addX(1);
2022 if(this.grow == EGrow.FRUIT_BABY){
2025 // this.kukis[0].miYukkuris[0].setX(this.getX());
2026 // this.kukis[0].miYukkuris[0].setY(this.getY());
2027 // var _x = this.imgBody.tl.node.x;
2028 // var _y = this.imgBody.tl.node.y;
2029 // var _gety = this.kukis[0].miYukkuris[0].getY();
2030 // this.kukis[0].miYukkuris[0].setOldY();
2031 // this.kukis[0].miYukkuris[0].animY(-_y);
2033 // console.log(this.getX() + ":" + this.getY());
2035 if(this.isDead())return;
2041 this.formSprite.animation();
2049 if(this.direction == EDirection.RIGHT){
2050 this.formSprite.formScaleX(this.myScaleX);
2051 if(this instanceof Player){
2052 this.formSprite.setFixBudgeRight(5);
2054 // this.formSprite.formScaleY(this.myScale);
2056 // this.imgBody.scaleX = 1;
2058 else if(this.direction == EDirection.LEFT){
2059 this.formSprite.formScaleX(-this.myScaleX);
2060 if(this instanceof Player){
2061 this.formSprite.setFixBudgeLeft(5);
2063 // this.formSprite.formScaleY(this.myScale);
2064 // this.imgBody.scaleX = -1;
2067 tweet:function(text){
2068 text = text.replace(/%name%/g, this.myName);
2069 // this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
2070 this._tweet.text(text, this.getX() - this._tweet.width/4, this.getY() - this._tweet.height);
2072 moveTo:function(x, y, time){
2073 this.formSprite.tlMoveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2074 // this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2076 moveBy:function(x, y, time, eventFunctions){
2077 this.formSprite.tlMoveBy(x, y, time, eventFunctions);
2081 // return self.getX() + x;
2082 // // return self.imgGroup.x + x;
2085 // return self.getY() + y;
2086 // // return self.imgGroup.y + y;
2089 // easing: enchant.Easing.SIN_EASEINOUT
2091 // //-Event register [onactionstart,onactiontick,onactionend]
2092 // if(eventFunctions !== undefined){
2093 // for(var key in eventFunctions){
2094 // params[key] = eventFunctions[key];
2097 // console.log("moveBy");
2098 // console.log("self.x:" + self.getX());
2099 // return this.formSprite.tlTween(params);
2100 // // return this.imgGroup.tl.tween(params);
2102 wait:function(frame, eventFunctions){
2103 this.moveBy(0,0,frame,eventFunctions);
2109 animation: function(){
2110 this.formSprite.animation();
2112 // frame -= plusFrameScale(frame, this.getMyScale()) / 2;
2114 // move -= plusFrameScale(move, this.getMyScale());
2115 // if(this.walkAnimationStatus == EWalkAnimation.END){
2116 // this.imgBody.y = 0;
2117 // this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
2118 // "onactionstart": function(e){
2119 // this.walkAnimationStatus = EWalkAnimation.START;
2122 // .moveByEx(0, move, frame, enchant.Easing.SWING,
2124 // "onactionend": function(e){
2125 // this.walkAnimationStatus = EWalkAnimation.END;
2129 // this.imgBody.tl.loop();
2132 getMyScale: function(){
2133 return (this.myScaleX + this.myScaleY) / 2;
2135 getWidth: function(){
2136 return this.width * this.myScaleX;
2138 getHeight: function(){
2139 return this.height * this.myScaleY;
2142 this.formSprite.setX(x);
2143 // this.imgGroup.x = x;
2146 this.formSprite.setY(y);
2147 // this.imgGroup.y = y;
2150 return this.formSprite.getX();
2151 // return this.imgGroup.x;
2154 return this.formSprite.getY();
2155 // return this.imgGroup.y;
2158 this.formSprite.addX(x);
2159 // this.imgGroup.x += x;
2162 this.formSprite.addY(y);
2163 // this.imgGroup.y += y;
2165 // changeFace: function(erespath){
2166 // this.face.image = game.assets[erespath];
2168 loadParamsXML: function(url){
2169 var http = new JKL.ParseXML( url );
2170 return http.parse();
2172 runYukkuri: function(){
2173 if(this.param.hungry > 70){
2174 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
2175 this.param.yukkuri -= 1;
2178 else if(this.param.hungry < 10){
2179 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
2182 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
2183 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
2185 runHungry: function(){
2186 if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
2187 if(this.param.hungry >= 100)this.param.hungry = 100;
2189 runUnun: function(){
2190 if(this.age%50 === 0 && this.age !== 0)this.param.unun += 1;
2191 if(this.param.unun >= 100)this.param.unun = 100;
2193 runSleep: function(){
2194 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
2195 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
2196 if(this.param.sleep >= 100){
2197 this.param.sleep = 100;
2201 runAddress: function(){
2202 for(var key in this.addressBook){
2203 var address = this.addressBook[key];
2205 if(address.isGreeting){
2206 address.greetingWaitFrame++;
2207 if(address.greetingWaitFrame >= DAY){
2208 address.greetingWaitFrame = 0;
2209 address.isGreeting = false;
2214 changeFace: function(){
2215 if(this.param.yukkuri >= 80){
2216 this.setFaceImage(EFace.HAPPY1);
2218 else if(this.param.yukkuri >= 50){
2219 this.setFaceImage(EFace.NORMAL);
2221 else if(this.param.yukkuri >= 30){
2222 this.setFaceImage(EFace.TIRED);
2224 else if(this.param.yukkuri >= 10){
2225 this.setFaceImage(EFace.CRY1);
2227 else if(this.param.yukkuri >= 1){
2228 this.setFaceImage(EFace.CRY2);
2231 getRange: function(){
2232 return this.param.range;
2234 isSleep: function(){
2235 return this.param.sleep >= 100;
2238 return this.param.yukkuri <= 0;
2240 isManpuku: function(){
2241 return this.param.hungry <= 20;
2243 isKuhuku: function(){
2244 return this.param.hungry >= 40;
2246 isVeryKuhuku: function(){
2247 return this.param.hungry >= 80;
2249 getYukkuri: function(){
2250 return this.param.yukkuri;
2252 setYukkuri: function(yukkuri){
2253 this.param.yukkuri = yukkuri;
2254 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2256 addYukkuri: function(yukkuri){
2257 this.param.yukkuri += yukkuri;
2258 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2260 getHungry: function(){
2261 return this.param.hungry;
2263 setHungry: function(hungry){
2264 this.param.hungry = hungry;
2265 if(this.param.hungry < 0)this.param.hungry = 0;
2267 getUnun: function(){
2268 return this.param.unun;
2270 setUnun: function(unun){
2271 this.param.unun = unun;
2272 if(this.param.unun < 0)this.param.unun = 0;
2276 if(food instanceof Food){
2278 if(food.amount > 0){
2280 this.setHungry(this.param.hungry - food.getGive());
2281 this.setUnun(this.getUnun() + food.getGive() / 4);
2282 this.setYukkuri(this.getYukkuri() + 5);
2285 this.setYukkuri(this.getYukkuri() - 5);
2291 this.setHungry(this.param.hungry - food.give);
2292 this.setUnun(this.getUnun() + food.unun);
2293 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2300 hunt:function(food){
2301 if(food.amount > 0){
2302 if(!this.isItemsMax()){
2304 this.items.push(food);
2305 this.setYukkuri(this.getYukkuri() + 1);
2311 declarePlace: function(place){
2314 getPlace:function(){
2317 isPlace: function(){
2318 return this.place !== null;
2322 if(this.direction == EDirection.RIGHT){
2323 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2325 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2327 // if(this.direction == EDirection.RIGHT){
2328 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2330 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2334 setBodyImage: function(ebody){
2335 var path = this.bodyStatus[ebody];
2336 this.image = game.assets[path];
2339 // this.imgBody.tl.clear();
2340 // this.imgGroup.tl.clear();
2341 // this.imgBody.tl.unloop();
2342 // this.imgGroup.tl.unloop();
2343 // this.imgBody.y = 0;
2346 tlResume: function(){
2347 // this.imgBody.tl.resume();
2348 // this.imgGroup.tl.resume();
2351 syncDirection:function(senderYukkuri){
2352 if(this.getX() > senderYukkuri.getX()){
2353 this.direction = EDirection.LEFT;
2354 senderYukkuri.direction = EDirection.RIGHT;
2356 this.direction = EDirection.RIGHT;
2357 senderYukkuri.direction = EDirection.LEFT;
2360 isCommunication: function(yukkuri){
2361 if(this.addressBook[yukkuri.id] === undefined) return true;
2362 if(this.addressBook[yukkuri.id].isGreeting) return false;
2365 addAddress: function(yukkuri){
2366 this.addressBook[yukkuri.id] = new Address(yukkuri);
2368 getAddress: function(yukkuri){
2369 if(this.addressBook[yukkuri.id] === undefined)return null;
2370 return this.addressBook[yukkuri.id];
2372 getStatusForDisplay: function (){
2374 var placeId = (this.place==null)?"無し" : this.place.id;
2375 ret += "ID " + this.id + "\n";
2376 ret += "プレイス " + placeId + "\n";
2377 ret += "ゆっくり " + this.getYukkuri() + "\n";
2378 ret += "空腹 " + this.getHungry() + "\n";
2379 ret += "うんうん " + this.getUnun() + "\n";
2380 ret += "もちもの " + this.items.length + "\n";
2381 ret += "debug " + this.action.status + "\n";
2384 isItemsMax:function(){
2385 return this.items.length >= this.param.items_max;
2387 getItems:function(){
2390 addSearchObject:function(esearch, node){
2391 this.searchObjectMang.add(esearch, node)
2393 clearSearchObject:function(){
2394 this.searchObjectMang.clear()
2396 setFaceImage: function(eface){
2397 var path = this.faceStatus[eface];
2398 this.face.image = game.assets[path];
2400 myScale: function(_scaleX, _scaleY){
2401 this.formSprite.scale(_scaleX, _scaleY);
2402 // this.face.scale(_scaleX,_scaleY);
2403 // if(this.myCode === "REIMU"){
2404 // // this.okazari.x = -this.okazari.width / 2;
2405 // // this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2407 // // this.okazari.x = -CHARA_WIDTH /2;
2408 // // this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2410 // if(this.sub1 != null){
2411 // this.sub1.scale(_scaleX,_scaleY);
2414 // this.okazari.scale(_scaleX,_scaleY);
2415 // this.hear.scale(_scaleX,_scaleY);
2416 // this.scale(_scaleX,_scaleY);
2417 // if(this.shadow)this.shadow.scale(_scaleX, _scaleY);
2419 send: function(targetYukkuri, object, callback){
2420 this.communicateYukkuri = targetYukkuri;
2421 targetYukkuri.recv(object, callback);
2423 recv: function(object, callback){
2424 this.communicateYukkuri = object.yukkuri;
2426 this.action.setStatus(object.actionStatus);
2428 // this.actionQueue.push({
2430 // callback: callback
2433 addExValue: function(eexskill, plus){
2434 this.exValueHash[eexskill] += plus;
2435 if(this.exValueHash[eexskill] >= 100){
2436 this.exLvHash[eexskill] = 1;
2439 getExValue: function(eexskill){
2440 return this.exValueHash[eexskill];
2442 getExSkill: function(eexskill){
2443 return this.exLvHash[eexskill];
2446 setMemory: function(ememory, value){
2447 this.memoryHash[ememory] = value;
2449 getMemory: function(ememory){
2450 return this.memoryHash[ememory];
2452 damage: function(edamage){
2453 if(edamage == EDamage.PICOHAN){
2454 mangMsg.output(this, EMsg.DAMAGE);
2455 this.setFaceImage(EFace.CRY1);
2456 this.addYukkuri(-1);
2457 //現在の行動パターンから躾対象かセレクトする
2460 addKuki: function(){
2461 for(var i=0;i<this.kukis.length;i++){
2462 if(this.kukis[i].opacity == 0){
2463 this.kukis[i].opacity = 1.0;
2464 var miMarisa = new MiMarisa(this.getX(), this.getY());
2466 // console.log(this.imgBody);
2467 // this.imgBody.addChild(miMarisa);
2468 this.kukis[i].addMiYukkuri(miMarisa);
2473 destruct: function(){
2477 // var MiYukkuri = enchant.Class.create(Yukkuri,{
2478 // initialize: function(x, y, grow){
2479 // Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2483 // setOldY: function(){
2484 // this.imgGroup.y = this.oldY;
2487 // animX: function(x){
2488 // this.oldX = this.imgGroup.x;
2489 // this.imgGroup.x -= x;
2491 // animY: function(y){
2492 // this.imgGroup.y = this.oldY;
2493 // // this.oldY = this.imgGroup.y;
2494 // this.imgGroup.y -= y;
2497 // var MiMarisa = enchant.Class.create(MiYukkuri,{
2498 // initialize: function(x, y, grow){
2499 // MiYukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2500 // this.classname = "MiMarisa";
2501 // this.myCode = "MIMARISA";
2502 // this.myName = "実まりさ";
2504 // this.param = new MarisaParam();
2505 // this.param.range = 0;
2506 // this.param.looks = ELooks.GOOD_YUKKURI;
2509 // this.face = new enchant.Sprite(64, 64);
2510 // this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2511 // this.face.x = -CHARA_WIDTH / 2;
2512 // this.face.y = -CHARA_HEIGHT / 2;
2514 // this.faceStatus ={};
2515 // this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2516 // this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2517 // this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2518 // this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2519 // this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2520 // this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2521 // this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2522 // this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2523 // this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2524 // this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2526 // this.hear = new enchant.Sprite(64, 64);
2527 // this.hear.image = game.assets[EResPath.MARISA_HEAR];
2528 // this.hear.x = -CHARA_WIDTH / 2;
2529 // this.hear.y = -CHARA_HEIGHT / 2;
2531 // this.okazari = new Okazari(this);
2534 // // this.imgBody.addChild(this);
2535 // // this.imgBody.addChild(this.face);
2536 // // this.imgBody.addChild(this.hear);
2537 // // this.imgBody.addChild(this.okazari);
2538 // this.myScale(this.myScaleX, this.myScaleY)
2539 // // this.imgGroup.width = this.getWidth();
2540 // // this.imgGroup.height = this.getHeight();
2541 // // this.imgGroup.addChild(this.imgBody);
2542 // // this.imgGroup.flgMiYukkuri = true;
2543 // // backgroundMap.addChild(this.imgGroup);
2544 // this._tweet = new TTweet(148, 64);
2546 // this.imgGroup.addChild(this._tweet);
2547 // this.imgGroup.x = x;
2548 // this.imgGroup.y = y;
2550 // this.action = new Action(this);
2551 // ctl.addObj(this);
2555 var Marisa = enchant.Class.create(Yukkuri,{
2556 initialize: function(x, y, grow){
2557 Yukkuri.call(this,x,y, grow);
2558 this.classname = "Marisa";
2559 this.myCode = "MARISA";
2560 this.myName = "まりさ";
2562 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2563 // var json = net.load("./data/marisa/params.json");
2564 // this.param = json.root.param;
2565 this.param = new MarisaParam();
2566 this.param.looks = ELooks.GOOD_YUKKURI;
2567 if(this.grow == EGrow.BABY){
2568 this.myName = "まりちゃ";
2569 this.param.range /= 4;
2571 else if(this.grow == EGrow.CHILD){
2572 this.param.range /= 3;
2574 else if(this.grow == EGrow.SUBADULT){
2575 this.param.range *= 0.8;
2578 this.shadow = new enchant.Sprite(64, 64);
2579 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2580 this.shadow.x = 0 + this.x;
2581 this.shadow.y = this.getHeight() / 16 + this.y;
2583 this._style.zIndex = 5;
2585 this.face = new enchant.Sprite(64, 64);
2586 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2587 this.face.x = -CHARA_WIDTH / 2;
2588 this.face.y = -CHARA_HEIGHT / 2;
2590 this.faceStatus ={};
2591 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2592 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2593 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2594 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2595 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2596 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2597 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2598 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2599 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2600 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2603 this.hear = new enchant.Sprite(64, 64);
2604 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2605 this.hear.x = -CHARA_WIDTH / 2;
2606 this.hear.y = -CHARA_HEIGHT / 2;
2608 this.okazari = new Okazari(this);
2611 this.kukis[0] = new Kuki(this, 0, 0);
2612 this.kukis[1] = new Kuki(this, 10, 0);
2613 this.kukis[2] = new Kuki(this, 5, 5);
2614 this.kukis[3] = new Kuki(this, -5, 5);
2615 this._tweet = new TTweet(this, 148, 64);
2617 this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
2618 this.formSprite.addChild(this, 1, {
2621 scaleValue:this.myScaleY
2623 // this.formSprite.add(this.face,2,{type:"body",scaleValue:this.myScaleY});
2624 // this.formSprite.add(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2625 // this.formSprite.add(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2626 // this.formSprite.add(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2627 // this.formSprite.addChildAll();
2628 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2629 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2630 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2631 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2632 // this.formSprite.addChildAll();
2634 // App.backgroundMap.addChild(this._tweet);
2635 // this.imgGroup.addChild(this.shadow);
2636 // this.imgBody.addChild(this);
2637 // this.imgBody.addChild(this.face);
2638 // this.imgBody.addChild(this.hear);
2639 // this.imgBody.addChild(this.okazari);
2640 // for(var i=0;i<this.kukis.length;i++){
2641 // this.imgBody.addChild(this.kukis[i]);
2642 // this.kukis[i].opacity = 0;
2645 // this.imgBody.addChild(new Kuki(this));
2646 this.myScale(this.myScaleX, this.myScaleY)
2647 if(this instanceof Player){
2648 this.budge = new enchant.Sprite(16, 16);
2649 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2650 this.budge.x = -this.getWidth()/2;
2651 this.budge.y = -this.getHeight()/2;
2652 this.budge.scale(this.myScaleX, this.myScaleY);
2653 this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
2654 this.formSprite.setX(x);
2655 this.formSprite.setY(y);
2657 // this.imgGroup.width = this.getWidth();
2658 // this.imgGroup.height = this.getHeight();
2659 // this.imgGroup.addChild(this.imgBody);
2661 // backgroundMap.addChild(this.imgGroup);
2662 // this._tweet = new TTweet(148, 64);
2664 // this.imgGroup.addChild(this._tweet);
2665 // this.imgGroup.x = x;
2666 // this.imgGroup.y = y;
2669 this.action = new Action(this);
2673 var Player = enchant.Class.create(Marisa,{
2674 initialize: function(x, y, grow){
2675 // this.runEnterframe = function(){
2677 if(grow === undefined)grow = EGrow.ADULT;
2678 Marisa.call(this, x, y, grow);
2679 this.classname = "Player";
2680 ctl.setPlayer(this);
2681 // this.removeEventListener('enterframe',this.runEnterframe);
2682 this.addEventListener('enterframe', function(){
2684 if(this.age%10 === 0 && this.age !== 0){
2685 // console.log("palyer:" + this.age);
2688 ///////////////////////////////////////////////
2689 //Action pattern debug
2690 if(game.input.left){
2691 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2693 this.direction = EDirection.LEFT;
2695 if(game.input.right){
2696 for(var i=0;i<this.formSprite.spriteArray.length;i++){
2697 var spr = this.formSprite.spriteArray[i];
2698 console.log(i+":spry:" + spr.y);
2701 this.direction = EDirection.RIGHT;
2706 if(game.input.down){
2710 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2711 ///////////////////////////////////////////////
2713 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2714 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2716 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2718 //- Display the circle of search range.
2719 // fieldBg.image.clear();
2720 // fieldBg.image.context.beginPath();
2721 // fieldBg.image.context.fillStyle = '#ff0000';
2722 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2723 // fieldBg.image.context.fill();
2727 var Reimu = enchant.Class.create(Yukkuri,{
2728 initialize: function(x, y, grow){
2729 Yukkuri.call(this,x,y, grow);
2730 this.classname = "Reimu";
2731 this.myCode = "REIMU";
2732 this.myName = "れいむ";
2734 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2735 // var json = net.load("./data/reimu/params.json");
2736 // this.param = json.root.param;
2737 this.param = new ReimuParam();
2738 if(this.grow == EGrow.BABY){
2739 this.myName = "れいみゅ";
2740 this.param.range /= 4;
2742 else if(this.grow == EGrow.CHILD){
2743 this.param.range /= 3;
2745 else if(this.grow == EGrow.SUBADULT){
2746 this.param.range *= 0.8;
2748 this.shadow = new enchant.Sprite(64, 64);
2749 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2750 this.shadow.x = 0 + this.x;
2751 this.shadow.y = this.getWidth() / 16 + this.x;
2752 this.shadow.image._element.style.zIndex = 2;
2754 this._style.zIndex = 5;
2756 this.face = new enchant.Sprite(64, 64);
2757 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2758 this.face.x = -CHARA_WIDTH / 2;
2759 this.face.y = -CHARA_HEIGHT / 2;
2760 this.face._style.zIndex = 0;
2762 this.faceStatus ={};
2763 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2764 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2765 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2766 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2767 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2768 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2769 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2770 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2771 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2772 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2775 this.hear = new enchant.Sprite(64, 64);
2776 this.hear.image = game.assets[EResPathReimu.HEAR];
2777 this.hear.x = -CHARA_WIDTH / 2;
2778 this.hear.y = -CHARA_HEIGHT / 2;
2780 this.sub1 = new enchant.Sprite(64, 64);
2781 this.sub1.image = game.assets[EResPathReimu.SUB1];
2782 this.sub1.x = -CHARA_WIDTH / 2;
2783 this.sub1.y = -CHARA_HEIGHT / 2;
2785 this.okazari = new Okazari(this);
2788 // this.imgGroup.addChild(this.shadow);
2789 // this.imgBody.addChild(this.okazari);
2790 // this.imgBody.addChild(this);
2791 // this.imgBody.addChild(this.face);
2792 // this.imgBody.addChild(this.hear);
2793 // this.imgBody.addChild(this.sub1);
2794 this.myScale(this.myScaleX, this.myScaleY)
2795 if(this instanceof Player){
2796 this.budge = new enchant.Sprite(16, 16);
2797 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2798 this.imgBody.addChild(this.budge);
2799 this.budge.x -= this.getWidth()/2;
2800 this.budge.y -= this.getHeight()/2;
2801 this.budge.scale(this.myScaleX, this.myScaleX);
2803 // this.imgGroup.width = this.getWidth();
2804 // this.imgGroup.height = this.getHeight();
2805 // this.imgGroup.addChild(this.imgBody);
2806 // backgroundMap.addChild(this.imgGroup);
2807 this._tweet = new TTweet(this, 148, 64);
2808 backgroundMap.addChild(this._tweet);
2811 // this.imgGroup.addChild(this._tweet);
2812 // this.imgGroup.x = x;
2813 // this.imgGroup.y = y;
2816 this.action = new Action(this);
2818 this.exLvHash[EExSkill.KEKKAI] = 1;
2819 this.exValueHash[EExSkill.KEKKAI] = 100;
2823 game.onload = function(){
2827 def.ObjSprite = ObjSprite;
2828 def.Yukkuri = Yukkuri;
2829 def.nodeSort = nodeSort;
2830 mangTouch = new MangTouch(ctl);
2831 mangMsg = new MangMsg(ctl);
2832 ctl.setDefined(def);
2833 backgroundMap.image = game.assets[EResPath.MAP0];
2834 backgroundMap.loadData(_mapData);
2835 backgroundMap.collisionData = _collisionData;
2837 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
2838 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2839 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2840 fieldBg.image = fieldSurface;
2844 windowFront.image = windowSurface;
2847 windowFront.opacity = 0.5;
2849 windowSurface.context.fillStyle = '#000';
2850 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
2852 menuSurface.context.fillStyle = '#000';
2853 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
2854 menuBg.image = menuSurface;
2855 menuBg.x = EMenuPos.X;
2856 menuBg.y = EMenuPos.Y;
2857 backgroundMap.addChild(fieldBg);
2858 mangIcon = new MangIcon(ctl, menuBg);
2860 game.rootScene.addChild(backgroundMap);
2861 // game.rootScene.addChild(windowFront);
2862 // game.rootScene.addChild(gwindow);
2863 // var gwindow = new GWindow(ctl, {}, 0, 0, 80, 80);
2864 game.rootScene.addChild(menuBg);
2866 // var labelGroup = new LabelGroup();
2867 mangLabel = new MangLabel(ctl, menuBg);
2868 // var info = new Label("ゆっくり");
2869 // info.color = "#ffffff";
2870 // info.font = "14px 'Times New Roman'";
2872 // info.y = GAME_HEIGHT / 2;
2873 // labelGroup.addChild(info);
2874 // menuBg.addChild(labelGroup);
2877 // var food = new def.Food("apple", 200, 250);
2878 backgroundMap.addChild(foodGroup);
2879 // backgroundMap.addChild(placeGroup);
2880 var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.ADULT);
2881 // var player = new Player(0, 0);
2882 // console.log(player.getX());
2883 // player.addKuki();
2884 // player.createKuki();
2885 // new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
2886 // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
2887 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
2888 // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2889 // // new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
2890 // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
2891 // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
2892 // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
2893 // new Unun(100, 100);
2894 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2896 // var input = new Label("<form name='hoge' style='background-color:#ff0000;'>" +
2897 // "<input type='text' name='text'>" +
2898 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2901 // input.element.innerHTML = "<form name='hoge' style='background-color:#ff0000;'>" +
2902 // "<input type='text' name='text'>" +
2903 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2905 // menuBg.addChild(input);
2906 // game.rootScene.addChild(input);
2907 // var inputEvent = new Label('');
2909 // game.rootScene.addChild(output);
2910 // output.onenterframe = function(e) {
2911 // output.text = document.hoge.text.value;
2914 // enchant.Node.GAddEvent = function(){
2916 var popupStatus = null;
2917 var testFlg = false;
2919 game._element.addEventListener('mousemove', function (e) {
2920 var mang = mangTouch.get(ctl.getCurrentCommand());
2921 if(EMenuPos.X < e.layerX){
2922 var ex = e.layerX - EMenuPos.X;
2925 for(var i=0;i<mangIcon.cmdIcons.length;i++){
2926 var icon = mangIcon.cmdIcons[i];
2927 if(icon.x <= ex && ex <= (icon.x + ICON_WIDTH)
2928 && icon.y <= ey && ey <= (icon.y + ICON_HEIGHT)
2931 if(popupStatus !== i){
2932 ctl.popup.renew(game.rootScene, EMenuPos.X + 5, e.layerY + ICON_HEIGHT / 2, 80, 80);
2933 ctl.popup.setText(icon.text);
2941 ctl.popup.opacity = 0.9;
2942 ctl.popup.drawText();
2945 ctl.popup.opacity = 0;
2947 // console.log(e.layerX + ":" + e.layerY);
2950 // enchant.Core.instance._element.addEventListener('mousemove', function(e) {
2952 // game.rootScene.addEventListener('mousemove', function (e) {
2953 // console.log("mmmmmmmmm");
2957 game.rootScene.addEventListener('touchstart', function (e) {
2958 game.touched = true;
2959 var mang = mangTouch.get(ctl.getCurrentCommand());
2962 game.rootScene.addEventListener('touchmove', function (e) {
2963 var mang = mangTouch.get(ctl.getCurrentCommand());
2966 game.rootScene.addEventListener('touchend', function (e) {
2967 var mang = mangTouch.get(ctl.getCurrentCommand());
2969 game.touched = false;
2973 game.rootScene.addEventListener('enterframe', function(e){
2975 mangLabel.draw(player);
2976 if(this.age%BASE_FPS == 0 ){
2979 ctl.time += TIME_SPEED;
2981 this.addEventListener('enterframe', function(){
2982 //The priority processing of display instead of z-index
2984 backgroundMap.childNodes.sort(nodeSort);