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,
193 LEARN_NO_FOOD_IN_PLACE:19,
200 var EWalkAnimation = {
231 NO_FOOD_IN_PLACE : 1,
249 include("./lib/Animation.js");
250 include("./lib/FormSprite.js");
251 include("./lib/Util.js");
254 var ObjSprite = enchant.Class.create(enchant.Sprite,{
255 initialize: function (w, h){
256 enchant.Sprite.call(this, w, h);
259 // // new BoxLabel(this.ctl,100, e.x, e.y);
260 // var box = new Box(this.ctl, 200, 200);
261 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
263 getStatusForDisplay: function (){
272 getWidth: function(){
275 getHeight: function(){
279 return (this.id !== null && this.id !== undefined);
281 removeAll: function(){
286 undefineAll: function (){
287 for(var key in this){
288 // if(this.hasOwnProperty(key)){
296 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
307 //-Event register [onactionstart,onactiontick,onactionend]
308 if(eventFunctions !== undefined){
309 for(var key in eventFunctions){
310 params[key] = eventFunctions[key];
313 return this.tween(params);
315 function plusFrameScale(frame, scale){
316 return (frame/2) * (1 - scale)
321 include("./lang/ja.js");
322 window.onload = function(){
323 var nodeSort = function (a, b){
324 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
327 else if(typeof a.id === "undefined"){
330 else if(typeof b.id === "undefined"){
335 if(a instanceof Box && b instanceof Box){
338 if(a instanceof Box){
341 if(b instanceof Box){
344 var budgeValue = 10 + 28;
345 var shadowValue = -28;
346 //okazariは他のbodyと比べて11低い
347 var okazariValue = 37 + 11;
348 var okazariReimuValue = 32;
350 var tweetValue = 288;
353 if(a.type == "shadow"){
354 ay += shadowValue * a.scaleValue;
356 else if(a.type == "body" && a.classname == "Okazari" && a.spname == "reimu"){
357 ay += okazariReimuValue * a.scaleValue - a.anim.cnt;
359 else if(a.type == "body"){
360 ay += bodyValue * a.scaleValue - a.anim.cnt;
362 else if(a.type == "tweet"){
363 ay += tweetValue * a.scaleValue;
365 else if(a.type == "budge"){
366 ay += budgeValue * a.scaleValue - a.anim.cnt;
368 else if(a.type == "kuki"){
369 ay += kukiValue * a.scaleValue - a.anim.cnt;
372 if(b.type == "shadow"){
373 by += shadowValue * b.scaleValue;
375 else if(b.type == "body" && b.classname == "Okazari" && b.spname == "reimu"){
376 by += okazariReimuValue * b.scaleValue - b.anim.cnt;
378 else if(b.type == "body" && b.classname == "Okazari"){
379 by += okazariValue * b.scaleValue - b.anim.cnt;
381 else if(b.type == "body"){
382 by += bodyValue * b.scaleValue - b.anim.cnt;
384 else if(b.type == "tweet"){
385 by += tweetValue * b.scaleValue;
387 else if(b.type == "budge"){
388 by += budgeValue * b.scaleValue - b.anim.cnt;
390 else if(b.type == "kuki"){
391 by += kukiValue * b.scaleValue - b.anim.cnt;
395 if(a instanceof SpriteGroup){
399 if(b instanceof SpriteGroup){
404 if(a instanceof Place){
405 ay += Math.round(a.height * 0.7);
407 if(b instanceof Place){
408 by += Math.round(b.height * 0.7);
410 // if(a.flgMiYukkuri){
411 // ay += CHARA_HEIGHT;
413 // if(b.flgMiYukkuri){
414 // by += CHARA_HEIGHT;
417 if(Math.round(ay) < Math.round(by))return -1;
418 else if(Math.round(ay) > Math.round(by))return 1;
419 if(a.id < b.id)return -1;
420 else if(a.id > b.id)return 1;
426 var def = new Object();
427 var foodGroup = new Group();
428 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
429 SpriteGroup.prototype.classname = "";
430 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
431 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
432 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
433 game = new Game(GAME_WIDTH, GAME_HEIGHT);
437 var tmpName = EResPathReimu.getName();
439 for(var _v in EResPathReimu){
440 if(typeof EResPathReimu[_v] === "function")continue;
441 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
447 for(var _v in EResPath){
448 _loadArr[i] = EResPath[_v];
451 game.preload(_loadArr);
452 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
453 var backgroundMap = new MapGroup(16, 16);
454 App.backgroundMap = backgroundMap;
455 include("./class.js");
456 include("./ctrl.js");
459 ctl.setBackgroundMap(backgroundMap);
460 var Action = enchant.Class.create({
461 initialize: function (yukkuri){
462 this.status = EAction.THINK;
463 this.yukkuri = yukkuri;
464 this.isMoving = false;
465 this.targetNode = null;
467 getStatus: function(){
470 setStatus: function(eaction){
471 this.status = eaction;
474 if(this.yukkuri.isDead()){
475 this.status = EAction.DEAD;
477 // else if(this.yukkuri.isSleep()){
478 // this.status = EAction.SLEEP;
487 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
489 this.setStatus(EAction.THINK);
490 console.log("wait cnt end");
493 case EAction.THINK_IN_HOME:
496 this.think_in_home();
498 case EAction.EAT_IN_HOME:
503 if(this.yukkuri.age%2 === 0){
504 this.yukkuri.changeFace();
506 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
509 case EAction.MOVE_TO_EAT_START:
510 this.move_to_eat_start();
512 case EAction.MOVE_TO_EAT_UNDERWAY:
518 case EAction.SLEEP_START:
521 case EAction.SLEEP_WAIT:
526 case EAction.EAT_START:
529 case EAction.EAT_WAIT:
531 case EAction.UNUN_START:
534 case EAction.UNUN_WAIT:
536 case EAction.MOVE_TO_COMMAND:
537 this.move_to_command();
539 case EAction.UNUN_SMELL_START:
540 this.unun_smell_start();
542 case EAction.COMMUNICATE_START:
543 this.communicate_start();
545 case EAction.COMMUNICATE_WAIT:
546 case EAction.COMMUNICATE_RECV:
547 if(this.yukkuri.communicateYukkuri != null){
548 var _s = this.yukkuri.communicateYukkuri.action.getStatus();
549 if(this.yukkuri.communicateYukkuri.isDead()
550 || (_s !== EAction.COMMUNICATE_START && _s !== EAction.COMMUNICATE_WAIT && _s !== EAction.COMMUNICATE_RECV)){
551 this.setStatus(EAction.THINK);
552 this.yukkuri.animation();
556 case EAction.MOVE_TO_PLACE_START_HOMELESS:
557 this.move_to_place_start_homeless();
559 case EAction.DECLARE_PLACE_HOMELESS:
560 this.declare_place_homeless();
562 case EAction.MOVE_TO_HUNT_START:
563 this.move_to_hunt_start();
565 case EAction.HUNT_START:
568 case EAction.MOVE_GOTO_HOME:
569 this.move_goto_home();
571 case EAction.IN_HOME:
576 this.yukkuri.reverse();
578 // thinkHavePlace: function(){
579 // var date = ctl.getDate();
580 // if(this.yukkuri.isPlaceRange()){
583 // if(date === EDate.EVENING
584 // || date === EDate.NIGHT
585 // || date === EDate.MIDNIGHT
587 // this.setStatus(EAction.MOVE_GOTO_HOME);
590 // else if(date === EDate.EVENING){
591 // // if(this.yukkuri.isItemsMax()){
592 // // this.setStatus(EAction.IN_HOME);
595 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
599 // if(this.yukkuri.isVeryKuhuku()){
603 // this.setStatus(EAction.MOVE_GOTO_HOME);
605 // else if(this.yukkuri.isSleep()){
606 // this.setStatus(EAction.SLEEP_START);
608 // else if(this.yukkuri.getUnun() >= 80){
609 // this.setStatus(EAction.UNUN_START);
612 // this.yukkuri.changeFace();
616 think_in_home: function(){
617 var date = ctl.getDate();
618 if((date === EDate.MIDNIGHT)
619 && !this.yukkuri.isSleep()
620 && !this.yukkuri.isVeryKuhuku()
624 "nextStatus":EAction.THINK_IN_HOME,
625 "myYukkuri": this.yukkuri
629 else if(date === EDate.EVENING){
632 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
633 this.setStatus(EAction.EAT_IN_HOME);
636 //marisa is hunting move
637 if(this.yukkuri.beforeHuntingFood !== null){
638 new MoveToHuntEvent({
640 "targetNode": this.yukkuri.beforeHuntingFood,
642 "myYukkuri": this.yukkuri
646 this.setStatus(EAction.WALK);
650 eat_in_home: function(){
652 "targetNode": this.yukkuri.getPlace(),
654 "myYukkuri": this.yukkuri
657 move_to_eat_start : function(){
660 "targetNode": this.targetNode,
662 "myYukkuri": this.yukkuri
668 walk : function(retryCounter){
669 if(retryCounter > 15){
671 this.status = EAction.NONE;
672 console.log("retryCount over");
675 if(this.yukkuri.formSprite.tlQueueLength() === 0){
676 // if(this.yukkuri.imgGroup.tl.queue.length === 0){
678 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
680 this.isMoving = false;
681 this.status = EAction.THINK;
685 var xpos = 150 + rand(40) - (retryCounter * 10);
686 var ypos = 150 + rand(40) - (retryCounter * 10);
688 this.yukkuri.vx = xpos;
689 this.yukkuri.vy = ypos;
690 this.yukkuri.direction = EDirection.RIGHT;
692 else if(rand(8) === 0){
694 this.yukkuri.vy = -ypos;
696 else if(rand(8) == 1){
697 this.yukkuri.vx = xpos;
698 this.yukkuri.vy = -ypos;
699 this.yukkuri.direction = EDirection.RIGHT;
701 else if(rand(8) == 2){
702 this.yukkuri.vx = xpos;
704 this.yukkuri.direction = EDirection.RIGHT;
706 else if(rand(8) == 3){
707 this.yukkuri.vx = xpos;
708 this.yukkuri.vy = ypos;
709 this.yukkuri.direction = EDirection.RIGHT;
711 else if(rand(8) == 4){
713 this.yukkuri.vy = ypos;
715 else if(rand(8) == 5){
716 this.yukkuri.vx = -xpos;
717 this.yukkuri.vy = ypos;
718 this.yukkuri.direction = EDirection.LEFT;
720 else if(rand(8) == 6){
721 this.yukkuri.vx = -xpos;
723 this.yukkuri.direction = EDirection.LEFT;
725 else if(rand(8) == 7){
726 this.yukkuri.vx = -xpos;
727 this.yukkuri.vy = -ypos;
728 this.yukkuri.direction = EDirection.LEFT;
730 if (this.yukkuri.vx || this.yukkuri.vy) {
731 var map = ctl.backgroundMap;
732 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
733 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
734 var x = this.yukkuri.getX() + this.yukkuri.vx;
735 var y = this.yukkuri.getY() + this.yukkuri.vy + this.yukkuri.getHeight() / 2;
736 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
737 // console.log("あたってないよ:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY());
738 // console.log("X:" + this.yukkuri.moveX);
739 // console.log("Y:" + this.yukkuri.moveY);
740 this.isMoving = true;
741 this.yukkuri.reverse();
742 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
743 mangMsg.output(this.yukkuri,EMsg.WALK);
745 this.targetNode = null;
747 // console.log("HIT:"+ this.yukkuri.getX() + ":" + this.yukkuri.getY() + "," + this.yukkuri.vx + ":" + this.yukkuri.vy);
748 this.walk(retryCounter+1);
754 sleep_start: function(){
757 "myYukkuri": this.yukkuri
761 mangMsg.output(this.yukkuri, EMsg.DEAD);
762 this.yukkuri.tlPause();
763 this.yukkuri.setBodyImage(EBody.DEAD);
765 eat_start: function(){
768 "targetNode": this.targetNode,
770 "myYukkuri": this.yukkuri
774 unun_start: function(){
777 "myYukkuri": this.yukkuri
780 unun_smell_start: function(){
783 "myYukkuri": this.yukkuri
786 communicate_start:function(){
787 new ComSayHelloSendEvent({
789 "targetNode": this.targetNode,
791 "myYukkuri": this.yukkuri
794 move_to_place_start_homeless:function(){
795 new MoveToPlaceStartHomelessEvent({
796 "targetNode": this.targetNode,
798 "myYukkuri": this.yukkuri
801 declare_place_homeless:function(){
802 new DeclarePlaceHomelessEvent({
803 "targetNode": this.targetNode,
805 "myYukkuri": this.yukkuri
808 move_to_hunt_start:function(){
809 new MoveToHuntEvent({
811 "targetNode": this.targetNode,
813 "myYukkuri": this.yukkuri
816 hunt_start:function(){
819 "targetNode": this.targetNode,
821 "myYukkuri": this.yukkuri
824 move_goto_home:function(){
825 var place = this.yukkuri.getPlace();
826 new MoveGotoHomeEvent({
830 "myYukkuri": this.yukkuri
834 var place = this.yukkuri.getPlace();
835 if(place != null && place.isWorld()){
840 "myYukkuri": this.yukkuri
843 if(place && !place.isWorld())place.undefineAll();
844 this.yukkuri.declarePlace(null);
845 this.setStatus(EAction.WAIT);
846 mangMsg.output(this.yukkuri, EMsg.LOST_HOUSE);
847 this.yukkuri.setFaceImage(EFace.CRY2);
849 "waitframe": FPS * 3.0,
851 "myYukkuri": this.yukkuri
855 move_to_command: function(){
856 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
857 new MoveToCommandEvent({
860 "myYukkuri": this.yukkuri
865 this.yukkuri.clearSearchObject();
866 var nodes = ctl.getObjs();
869 for (var key in nodes) {
870 var node = nodes[key];
871 if(node === null || node === undefined)continue;
872 if(this.yukkuri.id === node.id)continue;
876 && !(this.targetNode instanceof Unun)
877 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
879 this.yukkuri.addSearchObject(ESearch.UNUN, node);
882 else if (node instanceof Food && node.amount > 0) {
883 if(this.yukkuri.within(node, this.yukkuri.getRange())){
884 this.yukkuri.addSearchObject(ESearch.FOOD, node);
888 else if(node instanceof Yukkuri){
889 if(node.grow != EGrow.FRUIT_BABY && this.yukkuri.within(node, this.yukkuri.getRange())){
890 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
894 else if(node instanceof Place){
895 if(this.yukkuri instanceof Player){
897 if(this.yukkuri.within(node, this.yukkuri.getRange())){
898 this.yukkuri.addSearchObject(ESearch.PLACE, node);
902 this.status = EAction.WALK;
906 * Range範囲内のObjSprを管理する
907 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
911 var SearchObjectMang = enchant.Class.create({
912 initialize: function (){
914 this.currentCmdObject = null;
918 for(var key in ESearch){
919 var esearch = ESearch[key];
920 this.datas[esearch] = [];
923 add :function(esearch, node){
924 this.datas[esearch].push(node);
927 for(var key in ESearch){
928 var esearch = ESearch[key];
929 this.datas[esearch].length = 0;
931 // this.datas.length = 0;
934 get:function (esearch){
935 return this.datas[esearch];
937 getNear:function (esearch, yukkuri){
938 var objects = this.datas[esearch];
939 var nearDistance = null;
941 for(var i=0;i<objects.length;i++){
942 var object = objects[i];
943 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
944 if(nearDistance === null || nearDistance > nowDistance){
945 nearDistance = nowDistance;
951 callEvent: function(yukkuri){
952 if(yukkuri.cmdQueue.length !== 0){
953 this.currentCmdObject = yukkuri.cmdQueue.shift();
954 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
957 if(yukkuri.isSleep()){
958 yukkuri.action.setStatus(EAction.SLEEP_START);
961 else if(yukkuri.getUnun() >= 80){
962 yukkuri.action.setStatus(EAction.UNUN_START);
966 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
967 yukkuri.action.targetNode = yukkuri.getPlace();
968 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
971 if(yukkuri.isVeryKuhuku()){
973 var foods = this.get(ESearch.FOOD);
974 if(foods.length > 0){
975 var foods = this.get(ESearch.FOOD);
976 food = this.getNear(ESearch.FOOD, yukkuri);
978 yukkuri.action.targetNode = food;
979 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
983 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
984 yukkuri.action.setStatus(EAction.WALK);
989 if(foods.length === 0 && yukkuri.isPlace() && yukkuri.getPlace().isFood()){
990 yukkuri.action.targetNode = yukkuri.getPlace();
991 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
995 yukkuri.action.setStatus(EAction.WALK);
1001 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
1002 food = this.getNear(ESearch.FOOD, yukkuri);
1004 yukkuri.action.targetNode = food;
1005 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
1009 ununs = this.get(ESearch.UNUN);
1010 if(ununs.length !== 0){
1011 yukkuri.action.targetNode = yukkuri.getPlace();
1012 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
1015 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
1016 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
1017 yukkuri.action.targetNode = searchYukkuri;
1018 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
1021 if(!yukkuri.isPlace()){
1022 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
1023 if(searchYukkuri != null && !searchYukkuri.isOwner()){
1024 yukkuri.action.targetNode = searchYukkuri;
1025 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
1029 yukkuri.action.setStatus(EAction.WALK);
1034 var Event = enchant.Class.create({
1035 initialize: function (_data){
1038 onactionstart:function(self){
1039 return this._onactionstart;
1041 _onactionstart:function(e){
1042 if(typeof e === "undefined")return;
1044 onactiontick:function(self){
1046 if(typeof e === "undefined")return;
1049 onactionend:function(self){
1051 if(typeof e === "undefined")return;
1055 var WalkEvent = enchant.Class.create(Event,{
1056 initialize: function (_data){
1058 this.yukkuri = _data.myYukkuri;
1059 this.action = _data.action;
1061 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1062 this.action.setStatus(EAction.SLEEP_WAIT);
1063 this.yukkuri.setFaceImage(EFace.SLEEP);
1064 this.yukkuri.tlPause();
1066 this.yukkuri.addEventListener('enterframe', function() {
1067 var yukkuri = self.yukkuri;
1075 var SleepEvent = enchant.Class.create(Event,{
1076 initialize: function (_data){
1078 this.yukkuri = _data.myYukkuri;
1079 this.action = _data.action;
1081 mangMsg.output(this.yukkuri, EMsg.SLEEP);
1082 this.action.setStatus(EAction.SLEEP_WAIT);
1083 this.yukkuri.setFaceImage(EFace.SLEEP);
1084 this.yukkuri.tlPause();
1087 this.yukkuri.addEventListener('enterframe', function() {
1088 var yukkuri = self.yukkuri;
1089 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
1090 if(yukkuri.param.sleep <= 0){
1091 yukkuri.param.sleep = 0;
1092 this.removeEventListener("enterframe",arguments.callee);
1093 mangMsg.output(self.yukkuri, EMsg.GET_UP);
1094 yukkuri.setFaceImage(EFace.NORMAL);
1096 // self.action.setStatus(EAction.WAIT);
1097 if(self.data.nextStatus !== undefined){
1098 self.action.setStatus(self.data.nextStatus);
1100 self.action.setStatus(EAction.THINK);
1107 var UnunEvent = enchant.Class.create(Event,{
1108 initialize: function (_data){
1110 this.yukkuri = _data.myYukkuri;
1111 this.action = _data.action;
1112 this.action.setStatus(EAction.UNUN_WAIT);
1113 mangMsg.output(this.yukkuri, EMsg.UNUN);
1114 this.yukkuri.setFaceImage(EFace.HAPPY2);
1117 this.yukkuri.wait(sec, {
1118 "onactionend": this.onactionend(this)
1121 onactionend:function(self){
1123 if(typeof e === "undefined")return;
1124 self.yukkuri.unun();
1125 self.action.setStatus(EAction.WAIT);
1126 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1128 "waitframe": FPS * 1.5,
1129 "action": self.action,
1130 "myYukkuri": self.yukkuri
1135 var WaitEvent = enchant.Class.create(Event,{
1136 initialize: function (_data){
1138 this.yukkuri = _data.myYukkuri;
1139 this.action = _data.action;
1140 this.waitframe = _data.waitframe;
1141 this.yukkuri.wait(this.waitframe, {
1142 "onactionstart": this.onactionstart(this),
1143 "onactiontick": this.onactiontick(this),
1144 "onactionend": this.onactionend(this)
1147 onactionend:function(self){
1149 if(typeof e === "undefined")return;
1150 self.action.setStatus(EAction.THINK);
1154 var UnunSmellEvent = enchant.Class.create(Event,{
1155 initialize: function (_data){
1157 this.yukkuri = _data.myYukkuri;
1158 this.action = _data.action;
1159 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1160 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1161 this.yukkuri.setFaceImage(EFace.CRY1);
1163 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1164 this.yukkuri.wait(sec, {
1165 "onactionend": this.onactionend(this)
1168 onactionend:function(self){
1170 if(typeof e === "undefined")return;
1171 self.action.setStatus(EAction.WALK);
1176 var EatEvent = enchant.Class.create(Event,{
1177 initialize: function (_data){
1179 this.yukkuri = _data.myYukkuri;
1180 this.food = _data.targetNode;
1181 this.action = _data.action;
1182 this.action.setStatus(EAction.EAT_WAIT);
1184 var sec = BASE_FPS * 3;
1185 if(this.yukkuri.eat(this.food)){
1186 mangMsg.output(this.yukkuri, EMsg.EAT);
1187 this.yukkuri.setFaceImage(EFace.EAT2);
1190 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1191 this.yukkuri.setFaceImage(EFace.CRY2);
1193 this.yukkuri.wait(sec, {
1194 "onactionend": this.onactionend(this)
1197 onactionend:function(self){
1199 if(typeof e === "undefined")return;
1200 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku() || !self.food.isWorld()){
1201 self.action.setStatus(EAction.THINK);
1202 self.yukkuri.setFaceImage(EFace.NORMAL);
1204 self.action.setStatus(EAction.EAT_START);
1211 * -When yukkuri find Food.
1214 * targetNode: enchant.Node
1218 var MoveToEatEvent = enchant.Class.create(Event,{
1219 initialize: function (_data){
1221 this.yukkuri = this.data.myYukkuri;
1222 this.action = this.data.action;
1224 var yukkuri = this.yukkuri;
1225 var node = this.data.targetNode;
1227 if(this.data.type == "food"){
1228 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1229 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2 + yukkuri.getWidth() / 2;
1230 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2 + yukkuri.getHeight() / 2;
1231 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1232 var frame = distance + distance/5 + 1;
1233 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1234 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1236 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1238 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1239 "onactiontick": this.onactiontick(this),
1240 "onactionend": this.onactionend(this)
1244 onactiontick:function(self){
1246 if(typeof e === "undefined")return;
1249 onactionend:function(self){
1251 if(typeof e === "undefined")return;
1252 self.action.setStatus(EAction.EAT_START);
1256 var MoveToHuntEvent = enchant.Class.create(Event,{
1257 initialize: function (_data){
1259 this.yukkuri = this.data.myYukkuri;
1260 this.action = this.data.action;
1262 var yukkuri = this.yukkuri;
1263 var node = this.data.targetNode;
1266 var nodeWidth = node.width;
1267 var nodeHeight = node.height;
1271 if(this.data.type == "food"){
1272 this.action.setStatus(EAction.WAIT);
1273 yukkuri.vx = nodeX - yukkuri.getX() + yukkuri.getWidth() / 2;
1274 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2 + yukkuri.getHeight() / 2;
1275 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1276 var frame = distance + distance/5 + 1;
1277 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1278 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1280 mangMsg.output(yukkuri, EMsg.MOVE_TO_HUNTING);
1282 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1283 "onactionend": this.onactionend(this)
1287 onactionend:function(self){
1289 if(typeof e === "undefined")return;
1290 self.action.setStatus(EAction.HUNT_START);
1294 var HuntStartEvent = enchant.Class.create(Event,{
1295 initialize: function (_data){
1296 Event.call(this, _data);
1299 this.yukkuri = _data.myYukkuri;
1300 this.food = _data.targetNode;
1301 this.action = _data.action;
1302 this.action.setStatus(EAction.WAIT);
1303 this.huntingStatus = "hunting";
1305 // this.yukkuri.beforeHuntingFood = this.food;
1306 if(this.food.isWorld()){
1307 this.yukkuri.beforeHuntingFood = new MemoryFood(this.food);
1308 var sec = BASE_FPS * 8;
1309 if(this.yukkuri.hunt(this.food)){
1310 this.huntingStatus = "hunting";
1311 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1312 this.yukkuri.setFaceImage(EFace.HAPPY1);
1314 if(this.yukkuri.isItemsMax()){
1316 this.huntingStatus = "return";
1317 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1318 this.yukkuri.setFaceImage(EFace.NORMAL);
1321 this.huntingStatus = "cry";
1322 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1323 this.yukkuri.setFaceImage(EFace.CRY2);
1328 this.yukkuri.beforeHuntingFood = null;
1330 this.huntingStatus = "cry";
1331 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1332 this.yukkuri.setFaceImage(EFace.CRY2);
1335 this.yukkuri.wait(sec, {
1336 "onactiontick": this.onactiontick(this),
1337 "onactionend": this.onactionend(this)
1340 onactiontick:function(self){
1342 if(typeof e === "undefined")return;
1344 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1345 if(this.age%(BASE_FPS * 5) == 0){
1346 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1347 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1352 onactionend:function(self){
1354 if(typeof e === "undefined")return;
1355 if(self.huntingStatus == "hunting"){
1356 if(self.yukkuri.isItemsMax()){
1357 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1358 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1360 self.action.setStatus(EAction.HUNT_START);
1363 else if(self.huntingStatus == "return"){
1364 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1366 else if(self.huntingStatus === "cry"){
1367 // self.action.setStatus(EAction.THINK);
1368 self.action.setStatus(EAction.WALK);
1375 this.yukkuri = null;
1380 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1381 initialize: function (_data){
1383 this.yukkuri = this.data.myYukkuri;
1384 this.action = this.data.action;
1386 var yukkuri = this.yukkuri;
1387 var place = this.data.targetNode;
1389 if(this.data.type == "hunt_end"){
1390 this.action.setStatus(EAction.WAIT);
1391 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1392 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1393 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1394 var frame = distance + distance/2 + 1 ;
1395 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1396 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1398 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1400 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1401 "onactiontick": this.onactiontick(this),
1402 "onactionend": this.onactionend(this)
1406 onactiontick:function(self){
1408 if(typeof e === "undefined")return;
1409 if(this.age%(BASE_FPS * 5) == 0){
1410 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1414 onactionend:function(self){
1416 if(typeof e === "undefined")return;
1417 self.action.setStatus(EAction.IN_HOME);
1423 this.yukkuri = null;
1427 var InHomeEvent = enchant.Class.create(Event,{
1428 initialize: function (_data){
1430 this.yukkuri = this.data.myYukkuri;
1431 this.action = this.data.action;
1433 var yukkuri = this.yukkuri;
1434 var place = this.data.targetNode;
1436 if(yukkuri.isVeryKuhuku()){
1438 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1439 this.action.setStatus(EAction.EAT_IN_HOME);
1442 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1444 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1445 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1446 this.action.setStatus(EAction.THINK);
1449 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1450 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1455 this.action.setStatus(EAction.WAIT);
1456 var items = this.yukkuri.getItems();
1457 if(items.length > 0){
1458 place.setItems(items);
1462 var sec = BASE_FPS * 10;
1463 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1464 this.yukkuri.wait(sec, {
1465 "onactiontick": this.onactiontick(this),
1466 "onactionend": this.onactionend(this)
1469 onactiontick:function(self){
1471 if(typeof e === "undefined")return;
1472 if(this.age%(BASE_FPS * 5) == 0){
1473 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1477 onactionend:function(self){
1479 if(typeof e === "undefined")return;
1480 self.action.setStatus(EAction.THINK_IN_HOME);
1484 var EatInHomeEvent = enchant.Class.create(Event,{
1485 initialize: function (_data){
1487 this.yukkuri = _data.myYukkuri;
1488 this.place = _data.targetNode;
1489 this.action = _data.action;
1490 this.action.setStatus(EAction.EAT_WAIT);
1492 var sec = BASE_FPS * 3;
1493 var foodHash = this.place.getFoodHash();
1494 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1495 mangMsg.output(this.yukkuri, EMsg.EAT);
1496 this.yukkuri.setFaceImage(EFace.EAT2);
1499 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1500 this.yukkuri.setFaceImage(EFace.CRY2);
1503 this.yukkuri.wait(sec, {
1504 "onactionend": this.onactionend(this)
1507 onactionend:function(self){
1509 if(typeof e === "undefined")return;
1510 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1511 self.action.setStatus(EAction.EAT_IN_HOME);
1513 // new EatInHomeEvent({
1514 // "targetNode": self.place,
1515 // "action": self.action,
1516 // "myYukkuri": self.yukkuri
1519 self.action.setStatus(EAction.THINK_IN_HOME);
1520 self.yukkuri.setFaceImage(EFace.NORMAL);
1527 var MoveToCommandEvent = enchant.Class.create(Event,{
1528 initialize: function (_data){
1530 this.yukkuri = this.data.myYukkuri;
1531 this.action = this.data.action;
1532 // this.vx = this.data.cmdObject.vx;
1533 // this.vy = this.data.cmdObject.vy;
1534 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1537 var yukkuri = this.yukkuri;
1538 this.action.status = EAction.WAIT;
1539 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1540 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1541 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1542 var frame = distance + distance/2 + 1;
1543 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1545 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1547 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1548 "onactiontick": this.onactiontick(this),
1549 "onactionend": this.onactionend(this)
1552 onactiontick:function(self){
1554 if(typeof e === "undefined")return;
1557 onactionend:function(self){
1559 if(typeof e === "undefined")return;
1560 self.action.setStatus(EAction.THINK);
1565 * Say hello contact to send communication .
1567 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1568 initialize: function (_data){
1570 this.yukkuri = _data.myYukkuri;
1571 this.targetYukkuri = _data.targetNode;
1572 this.action = _data.action;
1573 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1574 // this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1575 // this.targetYukkuri.tlPause();
1576 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1577 this.yukkuri.send(this.targetYukkuri, {
1578 "actionStatus":EAction.COMMUNICATE_RECV,
1579 "yukkuri":this.yukkuri
1583 this.yukkuri.tlPause();
1584 this.yukkuri.syncDirection(this.targetYukkuri);
1586 this.yukkuri.addAddress(this.targetYukkuri);
1587 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1589 var sec = BASE_FPS * 2;
1590 this.yukkuri.wait(sec, {
1591 "onactiontick": this.onactiontick(this),
1592 "onactionend": this.onactionend(this)
1595 onactiontick:function(self){
1597 if(typeof e === "undefined")return;
1600 onactionend:function(self){
1602 if(typeof e === "undefined")return;
1603 new ComSayHelloRecvEvent({
1605 "targetNode": self.yukkuri,
1606 "action": self.targetYukkuri.action,
1607 "myYukkuri": self.targetYukkuri
1612 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1613 initialize: function (_data){
1615 this.yukkuri = _data.myYukkuri;
1616 this.targetYukkuri = _data.targetNode;
1617 this.action = _data.action;
1618 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1619 this.yukkuri.addAddress(this.targetYukkuri);
1620 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1622 var sec = BASE_FPS * 2;
1623 this.yukkuri.wait(sec, {
1624 "onactiontick": this.onactiontick(this),
1625 "onactionend": this.onactionend(this)
1628 onactiontick:function(self){
1630 if(typeof e === "undefined")return;
1633 onactionend:function(self){
1635 if(typeof e === "undefined")return;
1636 self.action.setStatus(EAction.THINK);
1638 self.yukkuri.action.setStatus(EAction.THINK);
1639 self.yukkuri.animation();
1640 self.targetYukkuri.action.setStatus(EAction.THINK);
1641 self.targetYukkuri.animation();
1645 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1646 initialize: function (_data){
1648 this.yukkuri = this.data.myYukkuri;
1649 this.action = this.data.action;
1651 var yukkuri = this.yukkuri;
1652 var node = this.data.targetNode;
1654 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1655 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1656 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1657 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1658 var frame = distance + distance/5 + 1;
1659 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1661 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1663 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1664 "onactionend": this.onactionend(this)
1667 onactionend:function(self){
1669 if(typeof e === "undefined")return;
1670 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1672 self.yukkuri = null;
1677 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1678 initialize: function (_data){
1680 this.yukkuri = _data.myYukkuri;
1681 this.place = _data.targetNode;
1682 this.action = _data.action;
1683 this.action.setStatus(EAction.WAIT);
1686 var sec = BASE_FPS * 3;
1687 this.yukkuri.declarePlace(this.place);
1688 this.place.setOwner(this.yukkuri);
1689 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1691 this.yukkuri.setFaceImage(EFace.NORMAL);
1692 this.yukkuri.wait(sec, {
1693 "onactionend": this.onactionend(this)
1696 onactionend:function(self){
1698 if(typeof e === "undefined")return;
1699 self.action.setStatus(EAction.THINK);
1704 var Food = enchant.Class.create(ObjSprite,{
1705 initialize: function (type, x, y){
1706 this.classname = "Food";
1707 //一つにつきgiveの値分、hunguryを減少させられる
1708 if(type == "apple"){
1709 ObjSprite.call(this,16,16);
1710 this.image = game.assets[EResPath.OBJECT];
1714 }else if(type == "grass"){
1715 ObjSprite.call(this,64,64);
1716 this.image = game.assets[EResPath.GRASS];
1723 foodGroup.addChild(this);
1724 this.addEventListener('enterframe', function(){
1725 if(this.amount <= 0){
1730 getAmount: function(){
1733 getGive: function(){
1737 var MemoryPlace = enchant.Class.create({
1738 // initialize: function (place){
1739 // if(place.x != null){
1740 // this.isWorld = true;
1742 // this.isWorld = false;
1744 // this.isWorld = (place.x != null);
1745 // this.x = place.x;
1746 // this.y = place.y;
1747 // this.width = place.width;
1748 // this.height = place.height;
1750 // isWorld: function(){
1751 // return this.isWorld;
1755 var MemoryFood = enchant.Class.create({
1756 initialize: function (food){
1758 this.isWorld = true;
1760 this.isWorld = false;
1762 this.isWorld = (food.x != null);
1765 this.width = food.width;
1766 this.height = food.height;
1768 isWorld: function(){
1769 return this.isWorld;
1772 var Place = enchant.Class.create(ObjSprite,{
1773 initialize: function (type, x, y){
1774 ObjSprite.call(this,128,128);
1775 this.image = game.assets[EResPath.PLACE_TREE];
1776 this.x = x - this.width / 2;
1777 this.y = y - this.height / 2;
1778 backgroundMap.addChild(this);
1781 for(var key in EFood){
1782 var efood = EFood[key];
1783 this.foods[efood] = 0;
1785 // this.addEventListener('enterframe', function(){
1786 // if(this.age%10 === 0 && this.age !== 0){
1787 // console.log("x/y " + this.x + "/" + this.y);
1789 // if(game.input.left){
1792 // if(game.input.right){
1795 // if(game.input.up){
1798 // if(game.input.down){
1803 getStatusForDisplay: function(){
1806 if(this.owner == null)ownerId = "なし";
1807 else ownerId = this.owner.id;
1808 ret += "プレイスID " + this.id + "\n";
1809 ret += "オーナーID " + ownerId + "\n";
1810 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1811 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1812 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1815 setItems:function(items){
1816 var len = items.length;
1817 for(var i=0; i<len; i++){
1818 var item = items[i];
1819 if(item instanceof Food){
1820 this.foods[EFood.NORMAL]++;
1827 for(var key in EFood){
1828 var efood = EFood[key];
1829 ret += this.foods[efood];
1833 getFoodHash:function(){
1834 if(this.foods[EFood.GREAT] !== 0){
1835 this.foods[EFood.GREAT]--;
1836 return {give:20,yukkuri:15,unun:20};
1838 else if(this.foods[EFood.NORMAL] !== 0){
1839 this.foods[EFood.NORMAL]--;
1840 return {give:10,yukkuri:5,unun:10};
1842 else if(this.foods[EFood.BAD] !== 0){
1843 this.foods[EFood.BAD]--;
1844 return {give:10,yukkuri:-2,unun:10};
1848 setOwner: function(yukkuri){
1849 this.owner = yukkuri;
1851 isOwner: function(){
1852 return this.owner !== null;
1855 var Unun = enchant.Class.create(ObjSprite,{
1856 initialize: function (x, y){
1857 this.classname = "Unun";
1858 ObjSprite.call(this,32,32);
1859 this.image = game.assets[EResPath.YUKKURI_UNUN];
1862 backgroundMap.addChild(this);
1863 // this.lifetime = 30 * 24 * 3;
1864 this.lifetime = 15 * 24;
1865 this.addEventListener('enterframe', this.runEnterframe(this));
1866 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1869 runEnterframe:function(self){
1871 if(typeof e === "undefined")return;
1872 if(this.age%BASE_FPS === 0 && this.age !== 0){
1874 if(self.lifetime <= 0){
1875 this.parentNode.removeChild(this);
1876 ctl.backgroundMap.removeChild(this);
1877 ctl.removeObj(this);
1885 var Okazari = enchant.Class.create(enchant.Sprite,{
1886 initialize: function(yukkuri){
1887 this.classname = "Okazari";
1888 if(yukkuri.myCode === "REIMU"){
1889 enchant.Sprite.call(this, 80, 32);
1890 this.image = game.assets[EResPathReimu.OKAZARI];
1891 this.x = -CHARA_WIDTH / 3 * 2;
1892 this.y = -yukkuri.getHeight()/5 * 2 - 4;
1894 enchant.Sprite.call(this, 64, 64);
1895 this.image = game.assets[EResPath.MARISA_OKAZARI];
1896 this.x = -CHARA_WIDTH / 2;
1897 this.y = -CHARA_HEIGHT / 2 - yukkuri.getHeight()/6;
1899 this.yukkuri = yukkuri;
1901 getWidth: function(){
1903 // return this.width * this.yukkuri.myScaleX;
1905 getHeight: function(){
1907 // return this.height * this.yukkuri.myScaleY;
1910 var Kuki = enchant.Class.create(ObjSprite,{
1911 initialize: function(yukkuri, x, y){
1912 this.classname = "Kuki";
1913 enchant.Sprite.call(this, 56, 40);
1914 this.image = game.assets[EResPath.KUKI];
1916 this.y = -CHARA_HEIGHT / 2 -CHARA_HEIGHT / 4 + y;
1917 this.owner = yukkuri;
1918 this.miYukkuris = [];
1920 addMiYukkuri: function(miYukkuri){
1921 miYukkuri.setX(miYukkuri.getX() + 30);
1922 miYukkuri.setY(miYukkuri.getY() - 30);
1923 this.miYukkuris.push(miYukkuri);
1931 getWidth: function(){
1933 // return this.width * this.yukkuri.myScaleX;
1935 getHeight: function(){
1937 // return this.height * this.yukkuri.myScaleY;
1940 var Address = enchant.Class.create({
1941 initialize: function(yukkuri){
1942 this.friendlyLv = 1;
1943 this.yukkuri = yukkuri;
1944 this.isGreeting = false;
1945 this.greetingWaitFrame = 0;
1947 "beginSayHello" : false,
1952 set:function(key, value){
1953 this.comMatrix[key] = value;
1956 return this.comMatrix[key];
1960 var Yukkuri = enchant.Class.create(ObjSprite,{
1961 initialize: function(x, y, grow){
1962 ObjSprite.call(this, 64, 64);
1963 this.searchObjectMang = new SearchObjectMang();
1967 this.myCode = "YUKKURI";
1968 this.myName = "ゆっくり";
1969 this.beforeHuntingFood = null;
1970 if(grow == EGrow.ADULT){
1975 else if(grow == EGrow.SUBADULT){
1976 this.myScaleX = 0.8;
1977 this.myScaleY = 0.8;
1980 else if(grow == EGrow.CHILD){
1981 this.myScaleX = 0.6;
1982 this.myScaleY = 0.6;
1985 else if(grow == EGrow.BABY){
1986 this.myScaleX = 0.3;
1987 this.myScaleY = 0.3;
1990 else if(grow == EGrow.FRUIT_BABY){
1991 this.myScaleX = 0.2;
1992 this.myScaleY = 0.2;
1993 this.mySize = "SSS";
1996 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1997 this.classname = "Yukkuri";
1998 this.addressBook = {};
1999 // this.imgGroup = new SpriteGroup();
2000 // this.imgBody = new SpriteGroup();
2001 // this.imgGroup.id = guid();
2002 // this.imgBody.id = guid();
2003 this.x = -CHARA_WIDTH / 2;
2004 this.y = -CHARA_HEIGHT / 2;
2007 this.image = game.assets[EResPath.YUKKURI_BASE];
2008 this.direction = EDirection.RIGHT;
2009 this.addEventListener('enterframe', this.runEnterframe);
2010 this.bodyStatus ={};
2011 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
2012 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
2013 this.walkAnimationStatus = EWalkAnimation.END;
2016 this.actionQueue = [];
2018 this.exValueHash = {};
2019 this.memoryHash = {};
2020 this.communicateYukkuri = {};
2021 for(var _v in EExSkill){
2022 var key = EExSkill[_v];
2023 this.exLvHash[key] = 0;
2024 this.exValueHash[key] = 0;
2027 this.formSprite = new FormSprite();
2029 runEnterframe:function(){
2030 // console.log("runEnterframe");
2031 // this.formSprite.run();
2032 // this.formSprite.addX(1);
2035 if(this.grow == EGrow.FRUIT_BABY){
2038 // this.kukis[0].miYukkuris[0].setX(this.getX());
2039 // this.kukis[0].miYukkuris[0].setY(this.getY());
2040 // var _x = this.imgBody.tl.node.x;
2041 // var _y = this.imgBody.tl.node.y;
2042 // var _gety = this.kukis[0].miYukkuris[0].getY();
2043 // this.kukis[0].miYukkuris[0].setOldY();
2044 // this.kukis[0].miYukkuris[0].animY(-_y);
2045 // this.kukis[0].direction = this.direction;
2047 // console.log(this.getX() + ":" + this.getY());
2049 if(this.isDead())return;
2055 this.runAnimation();
2056 // this.animation();
2064 if(this.direction == EDirection.RIGHT){
2065 this.formSprite.formScaleX(this.myScaleX);
2066 if(this instanceof Player){
2067 this.formSprite.setFixBudgeRight(5);
2069 this.formSprite.setFixKukiRight();
2070 // this.formSprite.formScaleY(this.myScale);
2072 // this.imgBody.scaleX = 1;
2074 else if(this.direction == EDirection.LEFT){
2075 this.formSprite.formScaleX(-this.myScaleX);
2076 if(this instanceof Player){
2077 this.formSprite.setFixBudgeLeft(5);
2078 this.formSprite.setFixKukiLeft();
2080 this.formSprite.setFixKukiLeft();
2081 // this.formSprite.formScaleY(this.myScale);
2082 // this.imgBody.scaleX = -1;
2085 tweet:function(text){
2086 text = text.replace(/%name%/g, this.myName);
2087 // this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
2088 this._tweet.text(text, this.getX() - this._tweet.width/4, this.getY() - this._tweet.height);
2090 moveTo:function(x, y, time){
2091 this.formSprite.tlMoveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2092 // this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
2094 moveBy:function(x, y, time, eventFunctions){
2095 this.formSprite.tlMoveBy(x, y, time, eventFunctions);
2099 // return self.getX() + x;
2100 // // return self.imgGroup.x + x;
2103 // return self.getY() + y;
2104 // // return self.imgGroup.y + y;
2107 // easing: enchant.Easing.SIN_EASEINOUT
2109 // //-Event register [onactionstart,onactiontick,onactionend]
2110 // if(eventFunctions !== undefined){
2111 // for(var key in eventFunctions){
2112 // params[key] = eventFunctions[key];
2115 // console.log("moveBy");
2116 // console.log("self.x:" + self.getX());
2117 // return this.formSprite.tlTween(params);
2118 // // return this.imgGroup.tl.tween(params);
2120 wait:function(frame, eventFunctions){
2121 this.moveBy(0,0,frame,eventFunctions);
2126 runAnimation: function(){
2127 this.formSprite.formRunAnimation();
2129 animation: function(){
2130 this.formSprite.formStartAnimation();
2132 // frame -= plusFrameScale(frame, this.getMyScale()) / 2;
2134 // move -= plusFrameScale(move, this.getMyScale());
2135 // if(this.walkAnimationStatus == EWalkAnimation.END){
2136 // this.imgBody.y = 0;
2137 // this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
2138 // "onactionstart": function(e){
2139 // this.walkAnimationStatus = EWalkAnimation.START;
2142 // .moveByEx(0, move, frame, enchant.Easing.SWING,
2144 // "onactionend": function(e){
2145 // this.walkAnimationStatus = EWalkAnimation.END;
2149 // this.imgBody.tl.loop();
2152 getMyScale: function(){
2153 return (this.myScaleX + this.myScaleY) / 2;
2155 getWidth: function(){
2156 return this.width * this.myScaleX;
2158 getHeight: function(){
2159 return this.height * this.myScaleY;
2162 this.formSprite.setX(x);
2163 // this.imgGroup.x = x;
2166 this.formSprite.setY(y);
2167 // this.imgGroup.y = y;
2170 return this.formSprite.getX();
2171 // return this.imgGroup.x;
2174 return this.formSprite.getY();
2175 // return this.imgGroup.y;
2178 this.formSprite.addX(x);
2179 // this.imgGroup.x += x;
2182 this.formSprite.addY(y);
2183 // this.imgGroup.y += y;
2185 // changeFace: function(erespath){
2186 // this.face.image = game.assets[erespath];
2188 loadParamsXML: function(url){
2189 var http = new JKL.ParseXML( url );
2190 return http.parse();
2192 runYukkuri: function(){
2193 if(this.param.hungry > 70){
2194 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
2195 this.param.yukkuri -= 1;
2198 else if(this.param.hungry < 10){
2199 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
2202 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
2203 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
2205 runHungry: function(){
2206 if(this.age%50 === 0 && this.age !== 0)this.param.hungry += ADD_HUNGRY;
2207 if(this.param.hungry >= 100)this.param.hungry = 100;
2209 runUnun: function(){
2210 if(this.age%50 === 0 && this.age !== 0)this.param.unun += 1;
2211 if(this.param.unun >= 100)this.param.unun = 100;
2213 runSleep: function(){
2214 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
2215 if(this.age%80 === 0 && this.age !== 0)this.param.sleep += 1;
2216 if(this.param.sleep >= 100){
2217 this.param.sleep = 100;
2221 runAddress: function(){
2222 for(var key in this.addressBook){
2223 var address = this.addressBook[key];
2225 if(address.isGreeting){
2226 address.greetingWaitFrame++;
2227 if(address.greetingWaitFrame >= DAY){
2228 address.greetingWaitFrame = 0;
2229 address.isGreeting = false;
2234 changeFace: function(){
2235 if(this.param.yukkuri >= 80){
2236 this.setFaceImage(EFace.HAPPY1);
2238 else if(this.param.yukkuri >= 50){
2239 this.setFaceImage(EFace.NORMAL);
2241 else if(this.param.yukkuri >= 30){
2242 this.setFaceImage(EFace.TIRED);
2244 else if(this.param.yukkuri >= 10){
2245 this.setFaceImage(EFace.CRY1);
2247 else if(this.param.yukkuri >= 1){
2248 this.setFaceImage(EFace.CRY2);
2251 getRange: function(){
2252 return this.param.range;
2254 isSleep: function(){
2255 return this.param.sleep >= 100;
2258 return this.param.yukkuri <= 0;
2260 isManpuku: function(){
2261 return this.param.hungry <= 20;
2263 isKuhuku: function(){
2264 return this.param.hungry >= 40;
2266 isVeryKuhuku: function(){
2267 return this.param.hungry >= 80;
2269 getYukkuri: function(){
2270 return this.param.yukkuri;
2272 setYukkuri: function(yukkuri){
2273 this.param.yukkuri = yukkuri;
2274 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2276 addYukkuri: function(yukkuri){
2277 this.param.yukkuri += yukkuri;
2278 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2280 getHungry: function(){
2281 return this.param.hungry;
2283 setHungry: function(hungry){
2284 this.param.hungry = hungry;
2285 if(this.param.hungry < 0)this.param.hungry = 0;
2287 getUnun: function(){
2288 return this.param.unun;
2290 getLooksNumber: function(){
2291 return this.param.looks;
2293 getLooksText: function(){
2294 if(this.param.looks == ELooks.GOOD_YUKKURI){
2297 if(this.param.looks == ELooks.NORMAL_YUKKURI){
2300 if(this.param.looks == ELooks.BAD_YUKKURI){
2305 setUnun: function(unun){
2306 this.param.unun = unun;
2307 if(this.param.unun < 0)this.param.unun = 0;
2311 if(food instanceof Food){
2313 if(food.amount > 0){
2315 this.setHungry(this.param.hungry - food.getGive());
2316 this.setUnun(this.getUnun() + food.getGive() / 4);
2317 this.setYukkuri(this.getYukkuri() + 5);
2320 this.setYukkuri(this.getYukkuri() - 5);
2326 this.setHungry(this.param.hungry - food.give);
2327 this.setUnun(this.getUnun() + food.unun);
2328 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2335 hunt:function(food){
2336 if(food.amount > 0){
2337 if(!this.isItemsMax()){
2339 this.items.push(food);
2340 this.setYukkuri(this.getYukkuri() + 1);
2346 declarePlace: function(place){
2349 getPlace:function(){
2352 isPlace: function(){
2353 return this.place !== null;
2357 if(this.direction == EDirection.RIGHT){
2358 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2360 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2362 // if(this.direction == EDirection.RIGHT){
2363 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2365 // new Unun(this.getX() + this.getWidth()/2 - this.getWidth()/5, this.getY() + this.getHeight() / 2 + this.getHeight() / 5 );
2369 setBodyImage: function(ebody){
2370 var path = this.bodyStatus[ebody];
2371 this.image = game.assets[path];
2374 // this.imgBody.tl.clear();
2375 // this.imgGroup.tl.clear();
2376 // this.imgBody.tl.unloop();
2377 // this.imgGroup.tl.unloop();
2378 // this.imgBody.y = 0;
2379 this.formSprite.formStopAnimation();
2381 tlResume: function(){
2382 // this.imgBody.tl.resume();
2383 // this.imgGroup.tl.resume();
2386 syncDirection:function(senderYukkuri){
2387 if(this.getX() > senderYukkuri.getX()){
2388 this.direction = EDirection.LEFT;
2389 senderYukkuri.direction = EDirection.RIGHT;
2391 this.direction = EDirection.RIGHT;
2392 senderYukkuri.direction = EDirection.LEFT;
2395 isCommunication: function(yukkuri){
2396 if(this.addressBook[yukkuri.id] === undefined) return true;
2397 if(this.addressBook[yukkuri.id].isGreeting) return false;
2400 addAddress: function(yukkuri){
2401 this.addressBook[yukkuri.id] = new Address(yukkuri);
2403 getAddress: function(yukkuri){
2404 if(this.addressBook[yukkuri.id] === undefined)return null;
2405 return this.addressBook[yukkuri.id];
2407 getStatusForDisplay: function (){
2409 var placeId = (this.place==null)?"無し" : this.place.id;
2410 ret += "ID " + this.id + "\n";
2411 ret += "プレイス " + placeId + "\n";
2412 ret += "ゆっくり " + this.getYukkuri() + "\n";
2413 ret += "空腹 " + this.getHungry() + "\n";
2414 ret += "うんうん " + this.getUnun() + "\n";
2415 ret += "もちもの " + this.items.length + "\n";
2416 ret += "容姿 " + this.getLooksText() + "\n";
2417 ret += "debug " + this.action.status + "\n";
2420 isItemsMax:function(){
2421 return this.items.length >= this.param.items_max;
2423 getItems:function(){
2426 addSearchObject:function(esearch, node){
2427 this.searchObjectMang.add(esearch, node)
2429 clearSearchObject:function(){
2430 this.searchObjectMang.clear()
2432 setFaceImage: function(eface){
2433 var path = this.faceStatus[eface];
2434 this.face.image = game.assets[path];
2436 myScale: function(_scaleX, _scaleY){
2437 this.formSprite.scale(_scaleX, _scaleY);
2438 // this.face.scale(_scaleX,_scaleY);
2439 // if(this.myCode === "REIMU"){
2440 // // this.okazari.x = -this.okazari.width / 2;
2441 // // this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2443 // // this.okazari.x = -CHARA_WIDTH /2;
2444 // // this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2446 // if(this.sub1 != null){
2447 // this.sub1.scale(_scaleX,_scaleY);
2450 // this.okazari.scale(_scaleX,_scaleY);
2451 // this.hear.scale(_scaleX,_scaleY);
2452 // this.scale(_scaleX,_scaleY);
2453 // if(this.shadow)this.shadow.scale(_scaleX, _scaleY);
2455 send: function(targetYukkuri, object, callback){
2456 this.communicateYukkuri = targetYukkuri;
2457 targetYukkuri.recv(object, callback);
2459 recv: function(object, callback){
2460 this.communicateYukkuri = object.yukkuri;
2462 this.action.setStatus(object.actionStatus);
2464 // this.actionQueue.push({
2466 // callback: callback
2469 addExValue: function(eexskill, plus){
2470 this.exValueHash[eexskill] += plus;
2471 if(this.exValueHash[eexskill] >= 100){
2472 this.exLvHash[eexskill] = 1;
2475 getExValue: function(eexskill){
2476 return this.exValueHash[eexskill];
2478 getExSkill: function(eexskill){
2479 return this.exLvHash[eexskill];
2482 setMemory: function(ememory, value){
2483 this.memoryHash[ememory] = value;
2485 getMemory: function(ememory){
2486 return this.memoryHash[ememory];
2488 damage: function(edamage){
2489 if(edamage == EDamage.PICOHAN){
2490 mangMsg.output(this, EMsg.DAMAGE);
2491 this.setFaceImage(EFace.CRY1);
2492 this.addYukkuri(-1);
2493 //現在の行動パターンから躾対象かセレクトする
2496 addKuki: function(){
2497 for(var i=0;i<this.kukis.length;i++){
2498 if(this.kukis[i].opacity == 0){
2499 this.kukis[i].opacity = 1.0;
2500 // var miMarisa = new MiMarisa(this.getX(), this.getY());
2501 var miMarisa = new MiMarisa(100, 100);
2503 // console.log(this.imgBody);
2504 // this.imgBody.addChild(miMarisa);
2505 this.kukis[i].addMiYukkuri(miMarisa);
2510 addAAA: function(kuki){
2511 this.formSprite.addChild(this.kukis[0],7,{type:"kuki",scaleValue:this.myScaleY});
2513 destruct: function(){
2517 var MiYukkuri = enchant.Class.create(Yukkuri,{
2518 initialize: function(x, y, grow){
2519 Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2523 setOldY: function(){
2524 this.imgGroup.y = this.oldY;
2528 this.oldX = this.imgGroup.x;
2529 this.imgGroup.x -= x;
2532 this.imgGroup.y = this.oldY;
2533 // this.oldY = this.imgGroup.y;
2534 this.imgGroup.y -= y;
2537 var MiMarisa = enchant.Class.create(MiYukkuri,{
2538 initialize: function(x, y, grow){
2539 Yukkuri.call(this,x,y, EGrow.FRUIT_BABY);
2540 this.classname = "Marisa";
2541 this.myCode = "MARISA";
2542 this.myName = "実まりさ";
2544 this.param = new MarisaParam();
2545 this.param.looks = ELooks.GOOD_YUKKURI;
2546 this.myName = "実まりちゃ";
2547 this.param.range /= 4;
2549 this.face = new enchant.Sprite(64, 64);
2550 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2551 this.face.x = -CHARA_WIDTH / 2;
2552 this.face.y = -CHARA_HEIGHT / 2;
2554 this.faceStatus ={};
2555 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2556 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2557 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2558 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2559 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2560 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2561 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2562 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2563 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2564 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2567 this.hear = new enchant.Sprite(64, 64);
2568 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2569 this.hear.x = -CHARA_WIDTH / 2;
2570 this.hear.y = -CHARA_HEIGHT / 2;
2572 this.okazari = new Okazari(this);
2574 this._tweet = new TTweet(this, 148, 64);
2576 this.formSprite.addChild(this, 1, {
2579 scaleValue:this.myScaleY
2582 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2583 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2584 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2585 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2586 this.myScale(this.myScaleX, this.myScaleY)
2587 if(this instanceof Player){
2588 this.budge = new enchant.Sprite(16, 16);
2589 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2590 this.budge.x = -this.getWidth()/2;
2591 this.budge.y = -this.getHeight()/2;
2592 this.budge.scale(this.myScaleX, this.myScaleY);
2593 this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
2594 this.formSprite.setX(x);
2595 this.formSprite.setY(y);
2597 this.formSprite.setX(x);
2598 this.formSprite.setY(y);
2600 this.action = new Action(this);
2605 var Marisa = enchant.Class.create(Yukkuri,{
2606 initialize: function(x, y, grow){
2607 Yukkuri.call(this,x,y, grow);
2608 this.classname = "Marisa";
2609 this.myCode = "MARISA";
2610 this.myName = "まりさ";
2612 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2613 // var json = net.load("./data/marisa/params.json");
2614 // this.param = json.root.param;
2615 this.param = new MarisaParam();
2616 this.param.looks = ELooks.GOOD_YUKKURI;
2617 if(this.grow == EGrow.BABY){
2618 this.myName = "まりちゃ";
2619 this.param.range /= 4;
2621 else if(this.grow == EGrow.CHILD){
2622 this.param.range /= 3;
2624 else if(this.grow == EGrow.SUBADULT){
2625 this.param.range *= 0.8;
2628 this.shadow = new enchant.Sprite(64, 64);
2629 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2630 this.shadow.x = 0 + this.x;
2631 this.shadow.y = this.getHeight() / 16 + this.y;
2633 this._style.zIndex = 5;
2635 this.face = new enchant.Sprite(64, 64);
2636 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2637 this.face.x = -CHARA_WIDTH / 2;
2638 this.face.y = -CHARA_HEIGHT / 2;
2640 this.faceStatus ={};
2641 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2642 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2643 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2644 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2645 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2646 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2647 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2648 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2649 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2650 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2653 this.hear = new enchant.Sprite(64, 64);
2654 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2655 this.hear.x = -CHARA_WIDTH / 2;
2656 this.hear.y = -CHARA_HEIGHT / 2;
2658 this.okazari = new Okazari(this);
2661 this.kukis[0] = new Kuki(this, 0, 0);
2662 this.kukis[1] = new Kuki(this, 10, 0);
2663 this.kukis[2] = new Kuki(this, 5, 5);
2664 this.kukis[3] = new Kuki(this, -5, 5);
2665 this._tweet = new TTweet(this, 148, 64);
2667 this.formSprite.addChild(this.shadow,0,{type:"shadow",shadowIndexFlg:true,scaleValue:this.myScaleY});
2668 this.formSprite.addChild(this, 1, {
2671 scaleValue:this.myScaleY
2674 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2675 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2676 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
2677 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2678 this.formSprite.addChild(this.kukis[0],7,{type:"kuki",scaleValue:this.myScaleY});
2681 // this.formSprite.addChildAll();
2682 // App.backgroundMap.addChild(this._tweet);
2683 // this.imgGroup.addChild(this.shadow);
2684 // this.imgBody.addChild(this);
2685 // this.imgBody.addChild(this.face);
2686 // this.imgBody.addChild(this.hear);
2687 // this.imgBody.addChild(this.okazari);
2688 // for(var i=0;i<this.kukis.length;i++){
2689 // this.imgBody.addChild(this.kukis[i]);
2690 // this.kukis[i].opacity = 0;
2693 // this.imgBody.addChild(new Kuki(this));
2694 this.myScale(this.myScaleX, this.myScaleY)
2695 if(this instanceof Player){
2696 this.budge = new enchant.Sprite(16, 16);
2697 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2698 this.budge.x = -this.getWidth()/2;
2699 this.budge.y = -this.getHeight()/2;
2700 this.budge.scale(this.myScaleX, this.myScaleY);
2701 this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
2702 this.formSprite.setX(x);
2703 this.formSprite.setY(y);
2705 // this.imgGroup.width = this.getWidth();
2706 // this.imgGroup.height = this.getHeight();
2707 // this.imgGroup.addChild(this.imgBody);
2709 // backgroundMap.addChild(this.imgGroup);
2710 // this._tweet = new TTweet(148, 64);
2712 // this.imgGroup.addChild(this._tweet);
2713 // this.imgGroup.x = x;
2714 // this.imgGroup.y = y;
2715 this.formSprite.setX(x);
2716 this.formSprite.setY(y);
2718 this.action = new Action(this);
2722 var Player = enchant.Class.create(Marisa,{
2723 initialize: function(x, y, grow){
2724 // this.runEnterframe = function(){
2726 if(grow === undefined)grow = EGrow.ADULT;
2727 Marisa.call(this, x, y, grow);
2728 this.classname = "Player";
2729 ctl.setPlayer(this);
2730 // this.removeEventListener('enterframe',this.runEnterframe);
2731 this.addEventListener('enterframe', function(){
2733 if(this.age%10 === 0 && this.age !== 0){
2734 // console.log("palyer:" + this.age);
2737 ///////////////////////////////////////////////
2738 //Action pattern debug
2739 if(game.input.left){
2740 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2742 this.direction = EDirection.LEFT;
2744 if(game.input.right){
2745 // for(var i=0;i<this.formSprite.spriteArray.length;i++){
2746 // var spr = this.formSprite.spriteArray[i];
2747 // console.log(i+":spry:" + spr.y);
2750 this.direction = EDirection.RIGHT;
2755 if(game.input.down){
2759 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2760 ///////////////////////////////////////////////
2762 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2763 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2765 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2767 //- Display the circle of search range.
2768 // fieldBg.image.clear();
2769 // fieldBg.image.context.beginPath();
2770 // fieldBg.image.context.fillStyle = '#ff0000';
2771 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2772 // fieldBg.image.context.fill();
2776 var Reimu = enchant.Class.create(Yukkuri,{
2777 initialize: function(x, y, grow){
2778 Yukkuri.call(this,x,y, grow);
2779 this.classname = "Reimu";
2780 this.myCode = "REIMU";
2781 this.myName = "れいむ";
2782 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2783 // var json = net.load("./data/reimu/params.json");
2784 // this.param = json.root.param;
2785 this.param = new ReimuParam();
2786 if(this.grow == EGrow.BABY){
2787 this.myName = "れいみゅ";
2788 this.param.range /= 4;
2790 else if(this.grow == EGrow.CHILD){
2791 this.param.range /= 3;
2793 else if(this.grow == EGrow.SUBADULT){
2794 this.param.range *= 0.8;
2796 this.shadow = new enchant.Sprite(64, 64);
2797 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2798 this.shadow.x = 0 + this.x;
2799 this.shadow.y = this.getWidth() / 16 + this.x;
2802 this.face = new enchant.Sprite(64, 64);
2803 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2804 this.face.x = -CHARA_WIDTH / 2;
2805 this.face.y = -CHARA_HEIGHT / 2;
2806 this.face._style.zIndex = 0;
2808 this.faceStatus ={};
2809 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2810 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2811 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2812 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2813 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2814 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2815 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2816 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2817 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2818 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2821 this.hear = new enchant.Sprite(64, 64);
2822 this.hear.image = game.assets[EResPathReimu.HEAR];
2823 this.hear.x = -CHARA_WIDTH / 2;
2824 this.hear.y = -CHARA_HEIGHT / 2;
2826 this.sub1 = new enchant.Sprite(64, 64);
2827 this.sub1.image = game.assets[EResPathReimu.SUB1];
2828 this.sub1.x = -CHARA_WIDTH / 2;
2829 this.sub1.y = -CHARA_HEIGHT / 2;
2832 this.okazari = new Okazari(this);
2833 this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
2834 this.formSprite.addChild(this, 1, {
2837 scaleValue:this.myScaleY
2839 this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
2840 this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
2841 this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY,spname:"reimu"});
2842 this.formSprite.addChild(this.sub1,5,{type:"body",scaleValue:this.myScaleY});
2843 this._tweet = new TTweet(this, 148, 64);
2844 this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
2846 this.myScale(this.myScaleX, this.myScaleY)
2847 if(this instanceof Player){
2848 this.budge = new enchant.Sprite(16, 16);
2849 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2850 this.imgBody.addChild(this.budge);
2851 this.budge.x -= this.getWidth()/2;
2852 this.budge.y -= this.getHeight()/2;
2853 this.budge.scale(this.myScaleX, this.myScaleX);
2856 this.formSprite.setX(x);
2857 this.formSprite.setY(y);
2859 this.action = new Action(this);
2861 this.exLvHash[EExSkill.KEKKAI] = 1;
2862 this.exValueHash[EExSkill.KEKKAI] = 100;
2866 game.onload = function(){
2870 def.ObjSprite = ObjSprite;
2871 def.Yukkuri = Yukkuri;
2872 def.nodeSort = nodeSort;
2873 mangTouch = new MangTouch(ctl);
2874 mangMsg = new MangMsg(ctl);
2875 ctl.setDefined(def);
2876 backgroundMap.image = game.assets[EResPath.MAP0];
2877 backgroundMap.loadData(_mapData);
2878 backgroundMap.collisionData = _collisionData;
2880 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
2881 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2882 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2883 fieldBg.image = fieldSurface;
2887 windowFront.image = windowSurface;
2890 windowFront.opacity = 0.5;
2892 windowSurface.context.fillStyle = '#000';
2893 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
2895 menuSurface.context.fillStyle = '#000';
2896 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
2897 menuBg.image = menuSurface;
2898 menuBg.x = EMenuPos.X;
2899 menuBg.y = EMenuPos.Y;
2900 backgroundMap.addChild(fieldBg);
2901 mangIcon = new MangIcon(ctl, menuBg);
2903 game.rootScene.addChild(backgroundMap);
2904 // game.rootScene.addChild(windowFront);
2905 // game.rootScene.addChild(gwindow);
2906 // var gwindow = new GWindow(ctl, {}, 0, 0, 80, 80);
2907 game.rootScene.addChild(menuBg);
2909 // var labelGroup = new LabelGroup();
2910 mangLabel = new MangLabel(ctl, menuBg);
2911 // var info = new Label("ゆっくり");
2912 // info.color = "#ffffff";
2913 // info.font = "14px 'Times New Roman'";
2915 // info.y = GAME_HEIGHT / 2;
2916 // labelGroup.addChild(info);
2917 // menuBg.addChild(labelGroup);
2920 // var food = new def.Food("apple", 200, 250);
2921 backgroundMap.addChild(foodGroup);
2922 // backgroundMap.addChild(placeGroup);
2923 // var mimarisa = new MiMarisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.FRUIT_BABY);
2924 var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.ADULT);
2925 // var player = new Player(0, 0);
2926 // console.log(player.getX());
2927 // player.addKuki();
2928 // player.addMiYukkuri(mimarisa)
2929 // player.createKuki();
2930 new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
2931 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.ADULT);
2932 // new Marisa(PALYER_INIT_X + 250, PALYER_INIT_Y + 200, EGrow.ADULT);
2933 // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
2934 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
2935 // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2936 // new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
2937 // new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
2938 // new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
2939 // new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
2940 // new Unun(100, 100);
2941 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2943 // var input = new Label("<form name='hoge' style='background-color:#ff0000;'>" +
2944 // "<input type='text' name='text'>" +
2945 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2948 // input.element.innerHTML = "<form name='hoge' style='background-color:#ff0000;'>" +
2949 // "<input type='text' name='text'>" +
2950 // // "<select name='input_item' id='input_item'><option name='none'>りんご</option></select>" +
2952 // menuBg.addChild(input);
2953 // game.rootScene.addChild(input);
2954 // var inputEvent = new Label('');
2956 // game.rootScene.addChild(output);
2957 // output.onenterframe = function(e) {
2958 // output.text = document.hoge.text.value;
2961 // enchant.Node.GAddEvent = function(){
2963 var popupStatus = null;
2964 var testFlg = false;
2966 game._element.addEventListener('mousemove', function (e) {
2967 var mang = mangTouch.get(ctl.getCurrentCommand());
2968 if(EMenuPos.X < e.layerX){
2969 var ex = e.layerX - EMenuPos.X;
2972 for(var i=0;i<mangIcon.cmdIcons.length;i++){
2973 var icon = mangIcon.cmdIcons[i];
2974 if(icon.x <= ex && ex <= (icon.x + ICON_WIDTH)
2975 && icon.y <= ey && ey <= (icon.y + ICON_HEIGHT)
2978 if(popupStatus !== i){
2979 ctl.popup.renew(game.rootScene, EMenuPos.X + 5, e.layerY + ICON_HEIGHT / 2, 80, 80);
2980 ctl.popup.setText(icon.text);
2988 ctl.popup.opacity = 0.9;
2989 ctl.popup.drawText();
2992 ctl.popup.opacity = 0;
2994 // console.log(e.layerX + ":" + e.layerY);
2997 // enchant.Core.instance._element.addEventListener('mousemove', function(e) {
2999 // game.rootScene.addEventListener('mousemove', function (e) {
3000 // console.log("mmmmmmmmm");
3004 game.rootScene.addEventListener('touchstart', function (e) {
3005 game.touched = true;
3006 var mang = mangTouch.get(ctl.getCurrentCommand());
3009 game.rootScene.addEventListener('touchmove', function (e) {
3010 var mang = mangTouch.get(ctl.getCurrentCommand());
3013 game.rootScene.addEventListener('touchend', function (e) {
3014 var mang = mangTouch.get(ctl.getCurrentCommand());
3016 game.touched = false;
3020 game.rootScene.addEventListener('enterframe', function(e){
3022 mangLabel.draw(player);
3023 if(this.age%BASE_FPS == 0 ){
3026 ctl.time += TIME_SPEED;
3028 this.addEventListener('enterframe', function(){
3029 //The priority processing of display instead of z-index
3031 backgroundMap.childNodes.sort(nodeSort);