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 //////////////////////////////////////
29 var PALYER_INIT_X = 100;
30 var PALYER_INIT_Y = 100;
32 var CHARA_HEIGHT = 64;
34 var GAME_HEIGHT = 600;
40 // var DAY = HOUR * 24;
42 var GAME_START_TIME = HOUR * 6;
45 YUKKURI_BASE : './data/yukkuri_base.png',
46 YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
47 YUKKURI_UNUN : './data/unun.png',
48 YUKKURI_SHADOW : './data/shadow.png',
49 MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
50 MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
51 MARISA_FACE_ANGRY : './data/marisa/face_angry1.png',
52 MARISA_FACE_CRY1 : './data/marisa/face_cry1.png',
53 MARISA_FACE_CRY2 : './data/marisa/face_cry2.png',
54 MARISA_FACE_EAT1 : './data/marisa/face_eat1.png',
55 MARISA_FACE_EAT2 : './data/marisa/face_eat2.png',
56 MARISA_FACE_HAPPY1 : './data/marisa/face_happy1.png',
57 MARISA_FACE_HAPPY2 : './data/marisa/face_happy2.png',
58 MARISA_FACE_SLEEP : './data/marisa/face_sleep1.png',
59 MARISA_HEAR : './data/marisa/hear1.png',
60 OBJECT : './data/object.png',
61 MAP0 : './data/map0.png',
62 COMMAND : './data/command.png',
63 OKAZARI : './data/okazari.png',
64 PLACE_TREE : './data/system/place_tree.png',
65 GRASS : './data/system/grass.png',
66 PLAYER_BADGE : './data/system/player_badge.png',
67 // PLACE_TREE : './data/system/rapture.png',
102 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
113 MOVE_TO_EAT_START: 10,
114 MOVE_TO_EAT_UNDERWAY: 11,
118 UNUN_SMELL_START : 15,
119 UNUN_SMELL_WAIT : 16,
122 COMMUNICATE_START : 19,
123 COMMUNICATE_WAIT: 20,
124 COMMUNICATE_RECV: 21,
125 MOVE_TO_PLACE_START_HOMELESS: 22,
126 MOVE_TO_PLACE_HOMELESS_UNDERWAY: 23,
127 DECLARE_PLACE_HOMELESS: 24,
128 MOVE_TO_HUNT_START: 25,
159 var EWalkAnimation = {
177 var ObjSprite = enchant.Class.create(enchant.Sprite,{
178 initialize: function (w, h){
179 enchant.Sprite.call(this, w, h);
184 // // new BoxLabel(this.ctl,100, e.x, e.y);
185 // var box = new Box(this.ctl, 200, 200);
187 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
190 getStatusForDisplay: function (){
199 getWidth: function(){
202 getHeight: function(){
205 removeAll: function(){
212 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
223 //-Event register [onactionstart,onactiontick,onactionend]
224 if(eventFunctions !== undefined){
225 for(var key in eventFunctions){
226 params[key] = eventFunctions[key];
229 return this.tween(params);
231 function plusFrameScale(frame, scale){
232 return (frame/2) * (1 - scale)
237 include("./lang/ja.js");
238 window.onload = function(){
239 var nodeSort = function (a, b){
240 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
243 else if(typeof a.id === "undefined"){
246 else if(typeof b.id === "undefined"){
251 if(a instanceof Box && b instanceof Box){
254 if(a instanceof Box){
257 if(b instanceof Box){
260 if(a instanceof SpriteGroup){
264 if(b instanceof SpriteGroup){
269 if(a instanceof Place){
270 ay += Math.round(a.height * 0.7);
272 if(b instanceof Place){
273 by += Math.round(b.height * 0.7);
276 if(ay < by)return -1;
277 else if(ay > by)return 1;
278 if(a.id < b.id)return -1;
279 else if(a.id > b.id)return 1;
285 var def = new Object();
286 var foodGroup = new Group();
287 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
288 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
289 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
290 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
291 var game = new Game(GAME_WIDTH, GAME_HEIGHT);
295 for(var _v in EResPath){
296 _loadArr[i] = EResPath[_v];
299 game.preload(_loadArr);
300 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
301 var backgroundMap = new MapGroup(16, 16);
302 include("./class.js");
303 include("./ctrl.js");
306 ctl.setBackgroundMap(backgroundMap);
307 var Action = enchant.Class.create({
308 initialize: function (yukkuri){
309 this.status = EAction.THINK;
310 this.yukkuri = yukkuri;
311 this.isMoving = false;
312 this.targetNode = null;
314 getStatus: function(){
317 setStatus: function(eaction){
318 this.status = eaction;
321 if(this.yukkuri.isDead()){
322 this.status = EAction.DEAD;
324 // else if(this.yukkuri.isSleep()){
325 // this.status = EAction.SLEEP;
337 if(this.yukkuri.age%2 === 0){
338 if(this.yukkuri.isPlace()){
339 if(this.yukkuri.isSleep()){
340 this.setStatus(EAction.SLEEP_START);
342 else if(this.yukkuri.getUnun() >= 80){
343 this.setStatus(EAction.UNUN_START);
346 this.yukkuri.changeFace();
347 this.searchHavePlace();
351 if(this.yukkuri.isSleep()){
352 this.setStatus(EAction.SLEEP_START);
354 else if(this.yukkuri.getUnun() >= 80){
355 this.setStatus(EAction.UNUN_START);
358 // this.yukkuri.param.yukkuri -= 1;
359 this.yukkuri.changeFace();
366 case EAction.MOVE_TO_EAT_START:
367 this.move_to_eat_start();
369 case EAction.MOVE_TO_EAT_UNDERWAY:
375 case EAction.SLEEP_START:
378 case EAction.SLEEP_WAIT:
383 case EAction.EAT_START:
386 case EAction.EAT_WAIT:
388 case EAction.UNUN_START:
391 case EAction.UNUN_WAIT:
393 case EAction.MOVE_TO_COMMAND:
394 this.move_to_command();
396 case EAction.UNUN_SMELL_START:
397 this.unun_smell_start();
399 case EAction.COMMUNICATE_START:
400 this.communicate_start();
402 case EAction.COMMUNICATE_WAIT:
404 case EAction.COMMUNICATE_RECV:
406 case EAction.MOVE_TO_PLACE_START_HOMELESS:
407 this.move_to_place_start_homeless();
409 case EAction.DECLARE_PLACE_HOMELESS:
410 this.declare_place_homeless();
412 case EAction.MOVE_TO_HUNT_START:
413 this.move_to_hunt_start();
415 case EAction.HUNT_START:
418 case EAction.GOTO_HOME:
421 case EAction.HOME_RETURN:
426 this.yukkuri.reverse();
429 move_to_eat_start : function(){
432 "targetNode": this.targetNode,
434 "myYukkuri": this.yukkuri
440 walk : function(retryCounter){
441 if(retryCounter > 15){
443 this.status = EAction.NONE;
444 console.log("retryCount over");
447 if(this.yukkuri.imgGroup.tl.queue.length === 0){
449 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
451 this.isMoving = false;
452 this.status = EAction.THINK;
456 var xpos = 150 + rand(40) - (retryCounter * 10);
457 var ypos = 150 + rand(40) - (retryCounter * 10);
460 this.yukkuri.vy = -ypos;
462 else if(rand(8) == 1){
463 this.yukkuri.vx = xpos;
464 this.yukkuri.vy = -ypos;
465 this.yukkuri.direction = EDirection.RIGHT;
467 else if(rand(8) == 2){
468 this.yukkuri.vx = xpos;
470 this.yukkuri.direction = EDirection.RIGHT;
472 else if(rand(8) == 3){
473 this.yukkuri.vx = xpos;
474 this.yukkuri.vy = ypos;
475 this.yukkuri.direction = EDirection.RIGHT;
477 else if(rand(8) == 4){
479 this.yukkuri.vy = ypos;
481 else if(rand(8) == 5){
482 this.yukkuri.vx = -xpos;
483 this.yukkuri.vy = ypos;
484 this.yukkuri.direction = EDirection.LEFT;
486 else if(rand(8) == 6){
487 this.yukkuri.vx = -xpos;
489 this.yukkuri.direction = EDirection.LEFT;
491 else if(rand(8) == 7){
492 this.yukkuri.vx = -xpos;
493 this.yukkuri.vy = -ypos;
494 this.yukkuri.direction = EDirection.LEFT;
496 if (this.yukkuri.vx || this.yukkuri.vy) {
497 var map = ctl.backgroundMap;
498 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
499 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
500 var x = this.yukkuri.imgGroup.x + this.yukkuri.vx;
501 var y = this.yukkuri.imgGroup.y + this.yukkuri.vy + this.yukkuri.height / 2;
502 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
503 // console.log("あたってないよ:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
504 // console.log("X:" + this.yukkuri.moveX);
505 // console.log("Y:" + this.yukkuri.moveY);
506 this.isMoving = true;
507 this.yukkuri.reverse();
508 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
509 mangMsg.output(this.yukkuri,EMsg.WALK);
511 this.targetNode = null;
513 // console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
514 this.walk(retryCounter+1);
520 sleep_start: function(){
523 "myYukkuri": this.yukkuri
527 mangMsg.output(this.yukkuri, EMsg.DEAD);
528 this.yukkuri.tlPause();
529 this.yukkuri.setBodyImage(EBody.DEAD);
531 eat_start: function(){
534 "targetNode": this.targetNode,
536 "myYukkuri": this.yukkuri
540 unun_start: function(){
543 "myYukkuri": this.yukkuri
546 unun_smell_start: function(){
549 "myYukkuri": this.yukkuri
552 communicate_start:function(){
553 new ComSayHelloSendEvent({
555 "targetNode": this.targetNode,
557 "myYukkuri": this.yukkuri
560 move_to_place_start_homeless:function(){
561 new MoveToPlaceStartHomelessEvent({
562 "targetNode": this.targetNode,
564 "myYukkuri": this.yukkuri
567 declare_place_homeless:function(){
568 new DeclarePlaceHomelessEvent({
569 "targetNode": this.targetNode,
571 "myYukkuri": this.yukkuri
574 move_to_hunt_start:function(){
575 new MoveToHuntEvent({
577 "targetNode": this.targetNode,
579 "myYukkuri": this.yukkuri
582 hunt_start:function(){
585 "targetNode": this.targetNode,
587 "myYukkuri": this.yukkuri
590 goto_home:function(){
591 var place = this.yukkuri.getPlace();
596 "myYukkuri": this.yukkuri
599 return_home:function(){
600 var place = this.yukkuri.getPlace();
601 new ReturnHomeEvent({
605 "myYukkuri": this.yukkuri
608 move_to_command: function(){
611 searchHavePlace: function(){
612 var nodes = ctl.getObjs();
616 for (var key in nodes) {
617 var node = nodes[key];
618 if(this.yukkuri.id === node.id)continue;
620 && node instanceof Unun
621 && !(this.targetNode instanceof Unun)
622 && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
624 this.targetNode = node;
625 this.setStatus(EAction.UNUN_SMELL_START);
628 else if (node instanceof Food) {
629 if(!this.yukkuri.isItemsMax() && this.yukkuri.within(node, this.yukkuri.getRange())){
631 //A yukkuri to go to the food area
632 this.targetNode = node;
633 this.setStatus(EAction.MOVE_TO_HUNT_START);
637 //not hunbry or not food.
640 else if(node instanceof Yukkuri){
641 if(this.yukkuri.isCommunication(node) && this.yukkuri.within(node, this.yukkuri.getRange())){
642 this.targetNode = node;
643 this.setStatus(EAction.COMMUNICATE_START);
647 else if(node instanceof Place){
648 if(!node.isOwner() && !this.yukkuri.isPlace() && this.yukkuri.within(node, this.yukkuri.getRange())){
649 this.targetNode = node;
650 this.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
655 this.status = EAction.WALK;
658 var nodes = ctl.getObjs();
662 for (var key in nodes) {
663 var node = nodes[key];
664 if(this.yukkuri.id === node.id)continue;
666 && node instanceof Unun
667 && !(this.targetNode instanceof Unun)
668 && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
670 this.targetNode = node;
671 this.setStatus(EAction.UNUN_SMELL_START);
674 else if (node instanceof Food) {
675 if(this.yukkuri.isKuhuku() && this.yukkuri.within(node, this.yukkuri.getRange())){
677 //A yukkuri to go to the food area
678 this.targetNode = node;
679 this.setStatus(EAction.MOVE_TO_EAT_START);
683 //not hunbry or not food.
686 else if(node instanceof Yukkuri){
687 if(this.yukkuri.isCommunication(node) && this.yukkuri.within(node, this.yukkuri.getRange())){
688 this.targetNode = node;
689 this.setStatus(EAction.COMMUNICATE_START);
693 else if(node instanceof Place){
694 if(!node.isOwner() && !this.yukkuri.isPlace() && this.yukkuri.within(node, this.yukkuri.getRange())){
695 this.targetNode = node;
696 this.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
701 this.status = EAction.WALK;
704 var Event = enchant.Class.create({
705 initialize: function (_data){
707 onactionstart:function(self){
709 if(typeof e === "undefined")return;
712 onactiontick:function(self){
714 if(typeof e === "undefined")return;
717 onactionend:function(self){
719 if(typeof e === "undefined")return;
723 var WalkEvent = enchant.Class.create(Event,{
724 initialize: function (_data){
726 this.yukkuri = _data.myYukkuri;
727 this.action = _data.action;
729 mangMsg.output(this.yukkuri, EMsg.SLEEP);
730 this.action.setStatus(EAction.SLEEP_WAIT);
731 this.yukkuri.setFaceImage(EFace.SLEEP);
732 this.yukkuri.tlPause();
734 this.yukkuri.addEventListener('enterframe', function() {
735 var yukkuri = self.yukkuri;
743 var SleepEvent = enchant.Class.create(Event,{
744 initialize: function (_data){
746 this.yukkuri = _data.myYukkuri;
747 this.action = _data.action;
749 mangMsg.output(this.yukkuri, EMsg.SLEEP);
750 this.action.setStatus(EAction.SLEEP_WAIT);
751 this.yukkuri.setFaceImage(EFace.SLEEP);
752 this.yukkuri.tlPause();
755 this.yukkuri.addEventListener('enterframe', function() {
756 var yukkuri = self.yukkuri;
757 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
758 if(yukkuri.param.sleep <= 0){
759 yukkuri.param.sleep = 0;
760 this.removeEventListener("enterframe",arguments.callee);
761 mangMsg.output(self.yukkuri, EMsg.GET_UP);
762 yukkuri.setFaceImage(EFace.NORMAL);
764 // self.action.setStatus(EAction.WAIT);
765 self.action.setStatus(EAction.THINK);
771 var UnunEvent = enchant.Class.create(Event,{
772 initialize: function (_data){
774 this.yukkuri = _data.myYukkuri;
775 this.action = _data.action;
776 this.action.setStatus(EAction.UNUN_WAIT);
777 mangMsg.output(this.yukkuri, EMsg.UNUN);
778 this.yukkuri.setFaceImage(EFace.HAPPY2);
781 this.yukkuri.wait(sec, {
782 "onactionend": this.onactionend(this)
785 onactionend:function(self){
787 if(typeof e === "undefined")return;
789 self.action.setStatus(EAction.WAIT);
790 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
792 "waitframe": FPS * 1.5,
793 "action": self.action,
794 "myYukkuri": self.yukkuri
799 var WaitEvent = enchant.Class.create(Event,{
800 initialize: function (_data){
802 this.yukkuri = _data.myYukkuri;
803 this.action = _data.action;
804 this.waitframe = _data.waitframe;
805 this.yukkuri.wait(this.waitframe, {
806 "onactionstart": this.onactionstart(this),
807 "onactiontick": this.onactiontick(this),
808 "onactionend": this.onactionend(this)
811 onactionend:function(self){
813 if(typeof e === "undefined")return;
814 self.action.setStatus(EAction.THINK);
818 var UnunSmellEvent = enchant.Class.create(Event,{
819 initialize: function (_data){
821 this.yukkuri = _data.myYukkuri;
822 this.action = _data.action;
823 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
824 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
825 this.yukkuri.setFaceImage(EFace.CRY1);
827 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
828 this.yukkuri.wait(sec, {
829 "onactionend": this.onactionend(this)
832 onactionend:function(self){
834 if(typeof e === "undefined")return;
835 self.action.setStatus(EAction.THINK);
840 var EatEvent = enchant.Class.create(Event,{
841 initialize: function (_data){
843 this.yukkuri = _data.myYukkuri;
844 this.food = _data.targetNode;
845 this.action = _data.action;
846 this.action.setStatus(EAction.EAT_WAIT);
849 var sec = BASE_FPS * 3;
850 if(this.yukkuri.eat(this.food)){
851 mangMsg.output(this.yukkuri, EMsg.EAT);
852 this.yukkuri.setFaceImage(EFace.EAT2);
855 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
856 this.yukkuri.setFaceImage(EFace.CRY2);
858 this.yukkuri.wait(sec, {
859 "onactionend": this.onactionend(this)
862 onactionend:function(self){
864 if(typeof e === "undefined")return;
865 if(self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
866 self.action.setStatus(EAction.THINK);
867 self.yukkuri.setFaceImage(EFace.NORMAL);
869 self.action.setStatus(EAction.EAT_START);
876 * -When yukkuri find Food.
879 * targetNode: enchant.Node
883 var MoveToEatEvent = enchant.Class.create(Event,{
884 initialize: function (_data){
886 this.yukkuri = this.data.myYukkuri;
887 this.action = this.data.action;
889 var yukkuri = this.yukkuri;
890 var node = this.data.targetNode;
892 if(this.data.type == "food"){
893 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
894 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
895 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
896 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
897 var frame = distance + distance/5 + 1;
898 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
899 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
902 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
903 "onactionstart": this.onactionstart(this),
904 "onactiontick": this.onactiontick(this),
905 "onactionend": this.onactionend(this)
909 onactionstart:function(self){
911 if(typeof e === "undefined")return;
912 mangMsg.output(EMsg.TARGETING_EAT);
915 onactiontick:function(self){
917 if(typeof e === "undefined")return;
920 onactionend:function(self){
922 if(typeof e === "undefined")return;
923 self.action.setStatus(EAction.EAT_START);
927 var MoveToHuntEvent = enchant.Class.create(Event,{
928 initialize: function (_data){
930 this.yukkuri = this.data.myYukkuri;
931 this.action = this.data.action;
933 var yukkuri = this.yukkuri;
934 var node = this.data.targetNode;
936 if(this.data.type == "food"){
937 this.action.setStatus(EAction.WAIT);
938 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
939 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
940 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
941 var frame = distance + distance/5 + 1;
942 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
943 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
945 mangMsg.output(EMsg.TARGETING_EAT);
947 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
948 "onactionend": this.onactionend(this)
952 onactionend:function(self){
954 if(typeof e === "undefined")return;
955 self.action.setStatus(EAction.HUNT_START);
959 var HuntStartEvent = enchant.Class.create(Event,{
960 initialize: function (_data){
962 this.yukkuri = _data.myYukkuri;
963 this.food = _data.targetNode;
964 this.action = _data.action;
965 this.action.setStatus(EAction.WAIT);
968 var sec = BASE_FPS * 8;
969 if(this.yukkuri.hunt(this.food)){
970 mangMsg.output(this.yukkuri, EMsg.HUNT);
971 this.yukkuri.setFaceImage(EFace.HAPPY1);
973 if(this.yukkuri.isItemsMax()){
974 mangMsg.output(this.yukkuri, EMsg.REHUNT);
975 this.yukkuri.setFaceImage(EFace.NORMAL);
977 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
978 this.yukkuri.setFaceImage(EFace.CRY2);
981 this.yukkuri.wait(sec, {
982 "onactiontick": this.onactiontick(this),
983 "onactionend": this.onactionend(this)
986 onactiontick:function(self){
988 if(typeof e === "undefined")return;
989 if(this.age%(BASE_FPS * 3) == 0){
990 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
994 onactionend:function(self){
996 if(typeof e === "undefined")return;
997 console.log("onactionend");
998 self.action.setStatus(EAction.GOTO_HOME);
999 mangMsg.output(self.yukkuri, EMsg.GOTO_HOME);
1003 var GotoHomeEvent = enchant.Class.create(Event,{
1004 initialize: function (_data){
1006 this.yukkuri = this.data.myYukkuri;
1007 this.action = this.data.action;
1009 var yukkuri = this.yukkuri;
1010 var place = this.data.targetNode;
1012 if(this.data.type == "hunt_end"){
1013 this.action.setStatus(EAction.WAIT);
1014 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1015 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1016 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1017 var frame = distance + distance/2 + 1 ;
1018 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1019 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1021 mangMsg.output(this.yukkuri, EMsg.GOTO_HOME)
1023 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1024 "onactiontick": this.onactiontick(this),
1025 "onactionend": this.onactionend(this)
1029 onactiontick:function(self){
1031 if(typeof e === "undefined")return;
1032 if(this.age%(BASE_FPS * 5) == 0){
1033 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1037 onactionend:function(self){
1039 if(typeof e === "undefined")return;
1040 self.action.setStatus(EAction.HOME_RETURN);
1045 var ReturnHomeEvent = enchant.Class.create(Event,{
1046 initialize: function (_data){
1048 this.yukkuri = this.data.myYukkuri;
1049 this.action = this.data.action;
1051 var yukkuri = this.yukkuri;
1052 var place = this.data.targetNode;
1053 if(this.data.type == "hunt_end"){
1054 this.action.setStatus(EAction.WAIT);
1055 var items = this.yukkuri.getItems();
1056 if(items.length > 0){
1057 place.setItems(items);
1061 var sec = BASE_FPS * 10;
1062 this.yukkuri.wait(sec, {
1063 "onactiontick": this.onactiontick(this),
1064 "onactionend": this.onactionend(this)
1068 onactiontick:function(self){
1070 if(typeof e === "undefined")return;
1071 if(this.age%(BASE_FPS * 5) == 0){
1072 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1076 onactionend:function(self){
1078 if(typeof e === "undefined")return;
1079 self.action.setStatus(EAction.THINK);
1085 var MoveCommandEvent = enchant.Class.create(Event,{
1086 initialize: function (_data){
1088 this.yukkuri = this.data.myYukkuri;
1089 this.action = this.data.action;
1090 this.vx = this.data.vx;
1091 this.vy = this.data.vy;
1093 var yukkuri = this.yukkuri;
1094 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1095 yukkuri.vx = node.x - yukkuri.getX();
1096 yukkuri.vy = node.y - yukkuri.getY();
1097 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1098 var frame = distance + 1;
1099 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1101 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1102 "onactionstart": this.onactionstart(this),
1103 "onactiontick": this.onactiontick(this),
1104 "onactionend": this.onactionend(this)
1107 onactionstart:function(self){
1109 if(typeof e === "undefined")return;
1112 onactiontick:function(self){
1114 if(typeof e === "undefined")return;
1117 onactionend:function(self){
1119 if(typeof e === "undefined")return;
1120 self.action.setStatus(EAction.THINK);
1125 * Say hello contact to send communication .
1127 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1128 initialize: function (_data){
1130 this.yukkuri = _data.myYukkuri;
1131 this.targetYukkuri = _data.targetNode;
1132 this.action = _data.action;
1133 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1135 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1137 this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1138 this.targetYukkuri.tlPause();
1139 this.yukkuri.tlPause();
1140 this.yukkuri.syncDirection(this.targetYukkuri);
1142 this.yukkuri.addAddress(this.targetYukkuri);
1143 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1145 var sec = BASE_FPS * 2;
1146 this.yukkuri.wait(sec, {
1147 "onactiontick": this.onactiontick(this),
1148 "onactionend": this.onactionend(this)
1151 onactiontick:function(self){
1153 if(typeof e === "undefined")return;
1156 onactionend:function(self){
1158 if(typeof e === "undefined")return;
1159 new ComSayHelloRecvEvent({
1161 "targetNode": self.yukkuri,
1162 "action": self.targetYukkuri.action,
1163 "myYukkuri": self.targetYukkuri
1168 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1169 initialize: function (_data){
1171 this.yukkuri = _data.myYukkuri;
1172 this.targetYukkuri = _data.targetNode;
1173 this.action = _data.action;
1174 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1175 this.yukkuri.addAddress(this.targetYukkuri);
1176 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1178 var sec = BASE_FPS * 2;
1179 this.yukkuri.wait(sec, {
1180 "onactiontick": this.onactiontick(this),
1181 "onactionend": this.onactionend(this)
1184 onactiontick:function(self){
1186 if(typeof e === "undefined")return;
1189 onactionend:function(self){
1191 if(typeof e === "undefined")return;
1192 self.action.setStatus(EAction.THINK);
1194 self.yukkuri.action.setStatus(EAction.THINK);
1195 self.yukkuri.animation();
1196 self.targetYukkuri.action.setStatus(EAction.THINK);
1197 self.targetYukkuri.animation();
1201 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1202 initialize: function (_data){
1204 this.yukkuri = this.data.myYukkuri;
1205 this.action = this.data.action;
1207 var yukkuri = this.yukkuri;
1208 var node = this.data.targetNode;
1210 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1211 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1212 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1213 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1214 var frame = distance + distance/5 + 1;
1215 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1217 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1220 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1221 "onactionend": this.onactionend(this)
1224 onactionend:function(self){
1226 if(typeof e === "undefined")return;
1227 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1229 self.yukkuri = null;
1234 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1235 initialize: function (_data){
1237 this.yukkuri = _data.myYukkuri;
1238 this.place = _data.targetNode;
1239 this.action = _data.action;
1240 this.action.setStatus(EAction.WAIT);
1243 var sec = BASE_FPS * 3;
1244 this.yukkuri.declarePlace(this.place);
1245 this.place.setOwner(this.yukkuri);
1246 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1248 this.yukkuri.setFaceImage(EFace.NORMAL);
1249 this.yukkuri.wait(sec, {
1250 "onactionend": this.onactionend(this)
1253 onactionend:function(self){
1255 if(typeof e === "undefined")return;
1256 self.action.setStatus(EAction.THINK);
1261 var Food = enchant.Class.create(ObjSprite,{
1262 initialize: function (type, x, y){
1263 this.classname = "Food";
1264 //一つにつきgiveの値分、hunguryを減少させられる
1265 if(type == "apple"){
1266 ObjSprite.call(this,16,16);
1267 this.image = game.assets[EResPath.OBJECT];
1271 }else if(type == "grass"){
1272 ObjSprite.call(this,64,64);
1273 this.image = game.assets[EResPath.GRASS];
1280 foodGroup.addChild(this);
1281 this.addEventListener('enterframe', function(){
1282 if(this.amount <= 0){
1287 getAmount: function(){
1290 getGive: function(){
1294 var Place = enchant.Class.create(ObjSprite,{
1295 initialize: function (type, x, y){
1296 ObjSprite.call(this,128,128);
1297 this.image = game.assets[EResPath.PLACE_TREE];
1298 this.x = x - this.width / 2;
1299 this.y = y - this.height / 2;
1300 backgroundMap.addChild(this);
1302 this.foodsGraet = 0;
1303 this.foodsNormal = 0;
1305 // this.addEventListener('enterframe', function(){
1306 // if(this.age%10 === 0 && this.age !== 0){
1307 // console.log("x/y " + this.x + "/" + this.y);
1309 // if(game.input.left){
1312 // if(game.input.right){
1315 // if(game.input.up){
1318 // if(game.input.down){
1323 getStatusForDisplay: function(){
1326 if(this.owner == null)ownerId = "なし";
1327 else ownerId = this.owner.id;
1328 ret += "プレイスID " + this.id + "\n";
1329 ret += "オーナーID " + ownerId + "\n";
1330 ret += "食料うめぇ " + this.foodsGraet + "\n";
1331 ret += "食料それなりー " + this.foodsNormal + "\n";
1332 ret += "食料にがにが " + this.foodsBad + "\n";
1335 setItems:function(items){
1336 var len = items.length;
1337 for(var i=0; i<len; i++){
1338 var item = items[i];
1339 if(item instanceof Food){
1345 setOwner: function(yukkuri){
1346 this.owner = yukkuri;
1348 isOwner: function(){
1349 return this.owner !== null;
1352 var Unun = enchant.Class.create(ObjSprite,{
1353 initialize: function (x, y){
1354 this.classname = "Unun";
1355 ObjSprite.call(this,32,32);
1356 this.image = game.assets[EResPath.YUKKURI_UNUN];
1359 backgroundMap.addChild(this);
1360 this.lifetime = 60 * 24 * 3;
1361 this.addEventListener('enterframe', this.runEnterframe(this));
1362 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1365 runEnterframe:function(self){
1367 if(typeof e === "undefined")return;
1368 if(this.age%BASE_FPS === 0 && this.age !== 0){
1370 if(self.lifetime <= 0){
1371 this.parentNode.removeChild(this);
1372 ctl.backgroundMap.removeChild(this);
1373 ctl.removeObj(this);
1380 // runEnterframe: function(){
1381 // console.log("enterframe:" + this.id);
1384 var Okazari = enchant.Class.create(enchant.Sprite,{
1385 initialize: function(yukkuri){
1386 this.classname = "Okazari";
1387 enchant.Sprite.call(this, 64, 64);
1388 this.image = game.assets[EResPath.OKAZARI];
1389 this.yukkuri = yukkuri;
1390 this.x = -CHARA_WIDTH / 2;
1391 this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
1393 getWidth: function(){
1395 // return this.width * this.yukkuri.myScaleX;
1397 getHeight: function(){
1399 // return this.height * this.yukkuri.myScaleY;
1402 var Address = enchant.Class.create({
1403 initialize: function(yukkuri){
1404 this.friendlyLv = 1;
1405 this.yukkuri = yukkuri;
1406 this.isGreeting = false;
1407 this.greetingWaitFrame = 0;
1409 "beginSayHello" : false,
1414 set:function(key, value){
1415 this.comMatrix[key] = value;
1418 return this.comMatrix[key];
1422 var Yukkuri = enchant.Class.create(ObjSprite,{
1423 initialize: function(x, y, grow){
1424 ObjSprite.call(this, 64, 64);
1426 this.myCode = "YUKKURI";
1427 this.myName = "ゆっくり";
1428 if(grow == EGrow.ADULT){
1433 else if(grow == EGrow.SUBADULT){
1434 this.myScaleX = 0.8;
1435 this.myScaleY = 0.8;
1438 else if(grow == EGrow.CHILD){
1439 this.myScaleX = 0.6;
1440 this.myScaleY = 0.6;
1443 else if(grow == EGrow.BABY){
1444 this.myScaleX = 0.3;
1445 this.myScaleY = 0.3;
1449 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1450 this.classname = "Yukkuri";
1451 this.addressBook = {};
1452 this.imgGroup = new SpriteGroup();
1453 this.imgBody = new SpriteGroup();
1454 this.imgGroup.id = guid();
1455 this.imgBody.id = guid();
1456 this.x = -CHARA_WIDTH / 2;
1457 this.y = -CHARA_HEIGHT / 2;
1460 this.image = game.assets[EResPath.YUKKURI_BASE];
1461 this.direction = EDirection.RIGHT;
1462 this.addEventListener('enterframe', this.runEnterframe);
1463 this.bodyStatus ={};
1464 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
1465 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
1466 this.walkAnimationStatus = EWalkAnimation.END;
1470 runEnterframe:function(){
1473 if(this.isDead())return;
1484 if(this.direction == EDirection.RIGHT){
1485 this.imgBody.scaleX = 1;
1487 else if(this.direction == EDirection.LEFT){
1488 this.imgBody.scaleX = -1;
1491 tweet:function(text){
1492 text = text.replace(/%name%/g, this.myName);
1493 this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
1495 moveTo:function(x, y, time){
1496 this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
1498 moveBy:function(x, y, time, eventFunctions){
1502 return self.imgGroup.x + x;
1505 return self.imgGroup.y + y;
1508 easing: enchant.Easing.SIN_EASEINOUT
1510 //-Event register [onactionstart,onactiontick,onactionend]
1511 if(eventFunctions !== undefined){
1512 for(var key in eventFunctions){
1513 params[key] = eventFunctions[key];
1516 return this.imgGroup.tl.tween(params);
1518 wait:function(frame, eventFunctions){
1519 this.moveBy(0,1,frame,eventFunctions);
1524 animation: function(){
1527 frame += plusFrameScale(frame, this.getMyScale());
1529 move -= plusFrameScale(move, this.getMyScale());
1530 if(this.walkAnimationStatus == EWalkAnimation.END){
1532 this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
1533 "onactionstart": function(e){
1534 this.walkAnimationStatus = EWalkAnimation.START;
1537 .moveByEx(0, move, frame, enchant.Easing.SWING,
1539 "onactionend": function(e){
1540 this.walkAnimationStatus = EWalkAnimation.END;
1545 this.imgBody.tl.loop();
1548 getMyScale: function(){
1549 return (this.myScaleX + this.myScaleY) / 2;
1551 getWidth: function(){
1552 return this.width * this.myScaleX;
1554 getHeight: function(){
1555 return this.height * this.myScaleY;
1558 return this.imgGroup.x;
1561 return this.imgGroup.y;
1564 this.imgGroup.x += x;
1566 // this.shadow.x += x;
1567 // this._tweet.x += x;
1570 this.imgGroup.y += y;
1572 // this.shadow.y += y;
1573 // this._tweet.y += y;
1575 // changeFace: function(erespath){
1576 // this.face.image = game.assets[erespath];
1578 loadParamsXML: function(url){
1579 var http = new JKL.ParseXML( url );
1580 return http.parse();
1582 runYukkuri: function(){
1583 if(this.param.hungry > 70){
1584 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
1585 this.param.yukkuri -= 1;
1588 else if(this.param.hungry < 10){
1589 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
1592 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
1593 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
1595 runHungry: function(){
1596 if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
1597 if(this.param.hungry >= 100)this.param.hungry = 100;
1599 runUnun: function(){
1600 if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
1601 if(this.param.unun >= 100)this.param.unun = 100;
1603 runSleep: function(){
1604 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
1605 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
1606 if(this.param.sleep >= 100){
1607 this.param.sleep = 100;
1611 runAddress: function(){
1612 for(var key in this.addressBook){
1613 var address = this.addressBook[key];
1615 if(address.isGreeting){
1616 address.greetingWaitFrame++;
1617 if(address.greetingWaitFrame >= DAY){
1618 address.greetingWaitFrame = 0;
1619 address.isGreeting = false;
1624 changeFace: function(){
1625 if(this.param.yukkuri >= 80){
1626 this.setFaceImage(EFace.HAPPY1);
1628 else if(this.param.yukkuri >= 50){
1629 this.setFaceImage(EFace.NORMAL);
1631 else if(this.param.yukkuri >= 30){
1632 this.setFaceImage(EFace.TIRED);
1634 else if(this.param.yukkuri >= 10){
1635 this.setFaceImage(EFace.CRY1);
1637 else if(this.param.yukkuri >= 1){
1638 this.setFaceImage(EFace.CRY2);
1641 getRange: function(){
1642 return this.param.range;
1644 isSleep: function(){
1645 return this.param.sleep >= 100;
1648 return this.param.yukkuri <= 0;
1650 isManpuku: function(){
1651 return this.param.hungry <= 20;
1653 isKuhuku: function(){
1654 return this.param.hungry >= 40;
1656 getYukkuri: function(){
1657 return this.param.yukkuri;
1659 setYukkuri: function(yukkuri){
1660 this.param.yukkuri = yukkuri;
1661 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
1663 getHungry: function(){
1664 return this.param.hungry;
1666 setHungry: function(hungry){
1667 this.param.hungry = hungry;
1668 if(this.param.hungry < 0)this.param.hungry = 0;
1670 getUnun: function(){
1671 return this.param.unun;
1673 setUnun: function(unun){
1674 this.param.unun = unun;
1675 if(this.param.unun < 0)this.param.unun = 0;
1679 if(food.amount > 0){
1681 this.setHungry(this.param.hungry - food.getGive());
1682 this.setUnun(this.getUnun() + food.getGive() / 4);
1683 this.setYukkuri(this.getYukkuri() + 5);
1686 this.setYukkuri(this.getYukkuri() - 5);
1690 hunt:function(food){
1691 if(food.amount > 0){
1692 if(!this.isItemsMax()){
1694 this.items.push(food);
1695 this.setYukkuri(this.getYukkuri() + 1);
1701 declarePlace: function(place){
1704 getPlace:function(){
1707 isPlace: function(){
1708 return this.place !== null;
1712 if(this.direction == EDirection.RIGHT){
1713 new Unun(this.getX(), this.getY() + this.getHeight()/5 );
1715 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
1719 setBodyImage: function(ebody){
1720 var path = this.bodyStatus[ebody];
1721 this.image = game.assets[path];
1724 // this.imgBody.tl.pause();
1725 // this.imgGroup.tl.pause();
1726 this.imgBody.tl.clear();
1727 this.imgGroup.tl.clear();
1728 this.imgBody.tl.unloop();
1729 this.imgGroup.tl.unloop();
1733 tlResume: function(){
1734 // this.imgBody.tl.resume();
1735 // this.imgGroup.tl.resume();
1738 syncDirection:function(senderYukkuri){
1739 if(this.getX() > senderYukkuri.getX()){
1740 this.direction = EDirection.LEFT;
1741 senderYukkuri.direction = EDirection.RIGHT;
1743 this.direction = EDirection.RIGHT;
1744 senderYukkuri.direction = EDirection.LEFT;
1747 isCommunication: function(yukkuri){
1748 if(this.addressBook[yukkuri.id] === undefined) return true;
1749 if(this.addressBook[yukkuri.id].isGreeting) return false;
1752 addAddress: function(yukkuri){
1753 this.addressBook[yukkuri.id] = new Address(yukkuri);
1755 getAddress: function(yukkuri){
1756 if(this.addressBook[yukkuri.id] === undefined)return null;
1757 return this.addressBook[yukkuri.id];
1759 getStatusForDisplay: function (){
1761 var placeId = (this.place==null)?"無し" : this.place.id;
1762 ret += "ID " + this.id + "\n";
1763 ret += "プレイス " + placeId + "\n";
1764 ret += "ゆっくり " + this.getYukkuri() + "\n";
1765 ret += "空腹 " + this.getHungry() + "\n";
1766 ret += "うんうん " + this.getUnun() + "\n";
1769 isItemsMax:function(){
1770 return this.items.length >= this.param.items_max;
1772 getItems:function(){
1775 destruct: function(){
1779 var Marisa = enchant.Class.create(Yukkuri,{
1780 initialize: function(x, y, grow){
1781 Yukkuri.call(this,x,y, grow);
1782 this.classname = "Marisa";
1783 this.myCode = "MARISA";
1784 this.myName = "まりさ";
1786 // var xml = this.loadParamsXML("./data/marisa/params.xml");
1787 var json = net.load("./data/marisa/params.json");
1788 this.param = json.root.param;
1789 if(this.grow == EGrow.BABY){
1790 this.myName = "まりちゃ";
1791 this.param.range /= 4;
1793 else if(this.grow == EGrow.CHILD){
1794 this.param.range /= 3;
1796 else if(this.grow == EGrow.SUBADULT){
1797 this.param.range *= 0.8;
1799 this.shadow = new enchant.Sprite(64, 64);
1800 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
1801 this.shadow.x = 0 + this.x;
1802 this.shadow.y = this.getWidth() / 16 + this.x;
1803 this.shadow.image._element.style.zIndex = 2;
1805 this._style.zIndex = 5;
1807 this.face = new enchant.Sprite(64, 64);
1808 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
1809 this.face.x = -CHARA_WIDTH / 2;
1810 this.face.y = -CHARA_HEIGHT / 2;
1811 this.face._style.zIndex = 0;
1813 this.faceStatus ={};
1814 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
1815 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
1816 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
1817 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
1818 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
1819 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
1820 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
1821 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
1822 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
1823 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
1826 this.hear = new enchant.Sprite(64, 64);
1827 this.hear.image = game.assets[EResPath.MARISA_HEAR];
1828 this.hear.x = -CHARA_WIDTH / 2;
1829 this.hear.y = -CHARA_HEIGHT / 2;
1830 this.hear._style.zIndex = 0;
1832 this.okazari = new Okazari(this);
1834 // this.imgGroup._style.zIndex = 1;
1837 this.imgGroup.addChild(this.shadow);
1838 this.imgBody.addChild(this);
1839 this.imgBody.addChild(this.face);
1840 this.imgBody.addChild(this.hear);
1841 this.imgBody.addChild(this.okazari);
1842 this.myScale(this.myScaleX, this.myScaleY)
1843 if(this instanceof Player){
1844 // this.myScaleX = 0.5;
1845 // this.myScaleY = 0.5;
1847 this.budge = new enchant.Sprite(16, 16);
1848 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
1849 this.imgBody.addChild(this.budge);
1850 this.budge.x -= this.getWidth()/2;
1851 this.budge.y -= this.getHeight()/2;
1852 this.budge.scale(this.myScaleX, this.myScaleX);
1854 this.imgGroup.width = this.getWidth();
1855 this.imgGroup.height = this.getHeight();
1856 this.imgGroup.addChild(this.imgBody);
1857 backgroundMap.addChild(this.imgGroup);
1858 this._tweet = new TTweet(148, 64);
1860 this.imgGroup.addChild(this._tweet);
1861 this.imgGroup.x = x;
1862 this.imgGroup.y = y;
1865 this.action = new Action(this);
1867 // this.imgGroup.scale(_scaleX,_scaleX);
1868 // this.scale(scale,scale);
1870 myScale: function(_scaleX, _scaleY){
1871 this.face.scale(_scaleX,_scaleY);
1872 this.okazari.x = -32;
1873 this.okazari.y = -32 - this.getWidth()/6;
1874 this.okazari.scale(_scaleX,_scaleY);
1875 this.hear.scale(_scaleX,_scaleY);
1876 this.scale(_scaleX,_scaleY);
1877 this.shadow.scale(_scaleX, _scaleY);
1880 setFaceImage: function(eface){
1881 var path = this.faceStatus[eface];
1882 this.face.image = game.assets[path];
1885 var Player = enchant.Class.create(Marisa,{
1886 initialize: function(x, y){
1887 // this.runEnterframe = function(){
1889 Marisa.call(this, x, y, EGrow.ADULT);
1890 this.classname = "Player";
1891 ctl.setPlayer(this);
1892 // this.removeEventListener('enterframe',this.runEnterframe);
1893 this.addEventListener('enterframe', function(){
1896 if(this.age%10 === 0 && this.age !== 0){
1897 // console.log("palyer:" + this.age);
1900 ///////////////////////////////////////////////
1901 //Action pattern debug
1902 if(game.input.left){
1903 // this.changeFace(EResPath.MARISA_FACE_TIRED);
1905 this.direction = EDirection.LEFT;
1907 if(game.input.right){
1909 this.direction = EDirection.RIGHT;
1914 if(game.input.down){
1918 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
1919 ///////////////////////////////////////////////
1921 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
1922 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
1924 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
1926 //- Display the circle of search range.
1927 // fieldBg.image.clear();
1928 // fieldBg.image.context.beginPath();
1929 // fieldBg.image.context.fillStyle = '#ff0000';
1930 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
1931 // fieldBg.image.context.fill();
1935 game.onload = function(){
1938 def.ObjSprite = ObjSprite;
1939 def.Yukkuri = Yukkuri;
1940 def.nodeSort = nodeSort;
1941 mangTouch = new MangTouch(ctl);
1942 mangMsg = new MangMsg(ctl);
1943 ctl.setDefined(def);
1944 backgroundMap.image = game.assets[EResPath.MAP0];
1945 backgroundMap.loadData(_mapData);
1946 backgroundMap.collisionData = _collisionData;
1948 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
1949 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
1950 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
1951 fieldBg.image = fieldSurface;
1955 windowFront.image = windowSurface;
1958 windowFront.opacity = 0.5;
1960 windowSurface.context.fillStyle = '#000';
1961 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
1964 menuSurface.context.fillStyle = '#000';
1965 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
1966 menuBg.image = menuSurface;
1967 menuBg.x = EMenuPos.X;
1968 menuBg.y = EMenuPos.Y;
1969 backgroundMap.addChild(fieldBg);
1970 mangIcon = new MangIcon(ctl, menuBg);
1972 game.rootScene.addChild(backgroundMap);
1973 game.rootScene.addChild(windowFront);
1974 game.rootScene.addChild(menuBg);
1976 // var labelGroup = new LabelGroup();
1977 mangLabel = new MangLabel(ctl, menuBg);
1978 // var info = new Label("ゆっくり");
1979 // info.color = "#ffffff";
1980 // info.font = "14px 'Times New Roman'";
1982 // info.y = GAME_HEIGHT / 2;
1983 // labelGroup.addChild(info);
1984 // menuBg.addChild(labelGroup);
1987 // var food = new def.Food("apple", 200, 250);
1988 backgroundMap.addChild(foodGroup);
1989 // backgroundMap.addChild(placeGroup);
1990 var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
1991 // new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
1992 // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
1993 // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
1994 // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
1995 // new Unun(100, 100);
1996 new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2000 game.rootScene.addEventListener('touchstart', function (e) {
2001 game.touched = true;
2002 var mang = mangTouch.get(ctl.getCurrentCommand());
2005 game.rootScene.addEventListener('touchmove', function (e) {
2006 var mang = mangTouch.get(ctl.getCurrentCommand());
2009 game.rootScene.addEventListener('touchend', function (e) {
2010 var mang = mangTouch.get(ctl.getCurrentCommand());
2012 game.touched = false;
2016 game.rootScene.addEventListener('enterframe', function(){
2018 mangLabel.draw(player);
2019 if(this.age%BASE_FPS == 0 ){
2024 this.addEventListener('enterframe', function(){
2025 //The priority processing of display instead of z-index
2027 backgroundMap.childNodes.sort(nodeSort);