OSDN Git Service

grass function / unun bug fix
authornagoling <>
Fri, 11 Oct 2013 13:25:06 +0000 (22:25 +0900)
committernagomi <nagomi@192.168.1.23>
Fri, 11 Oct 2013 13:25:06 +0000 (22:25 +0900)
ctrl.js
main.js

diff --git a/ctrl.js b/ctrl.js
index e342162..a575257 100644 (file)
--- a/ctrl.js
+++ b/ctrl.js
@@ -215,7 +215,8 @@ var WorldAppleTouchEvent = enchant.Class.create(ATouchEvent,{
                        var backgroundMap = this.ctl.backgroundMap;
                        var tx = -backgroundMap.x + e.x;
                        var ty = -backgroundMap.y + e.y;
-                       new ctl.def.Food("apple", tx, ty);
+                       // new ctl.def.Food("apple", tx, ty);
+                       new ctl.def.Food("grass", tx, ty);
                }
        }
 });
diff --git a/main.js b/main.js
index 411c9ce..aa2ad7f 100644 (file)
--- a/main.js
+++ b/main.js
@@ -17,7 +17,7 @@ var CHARA_WIDTH = 64;
 var CHARA_HEIGHT = 64;
 var GAME_WIDTH = 800;
 var GAME_HEIGHT = 600;
-var FPS = 20;
+var FPS = 80;
 var BASE_FPS = 20;
 var HUNGRY_MAX = 100;
 var MIN = BASE_FPS;
@@ -46,6 +46,7 @@ var EResPath = {
        COMMAND : './data/command.png',
        OKAZARI : './data/okazari.png',
        PLACE_TREE : './data/system/place_tree.png',
+       GRASS : './data/system/grass.png',
        // PLACE_TREE : './data/system/rapture.png',
 };
 var EFace = {
@@ -123,7 +124,7 @@ var EMsg = {
        DEAD: 4,
        UNUN: 5,
        UNUN_END: 6,
-       UNUN_SMELL_START: 7,
+       UNUN_SMELL: 7,
        SEARCH_FOOD: 8,
        EAT_FAILED: 9,
        SAY_HELLO: 10,
@@ -280,10 +281,10 @@ window.onload = function(){
                                break;
                                case EAction.THINK:
                                        if(this.yukkuri.age%2 === 0){
-                                               // if(this.yukkuri.isPlace()){
-
-                                               // }
-                                               // else{
+                                               if(this.yukkuri.isPlace()){
+                                                       this.searchHavePlace();
+                                               }
+                                               else{
                                                        if(this.yukkuri.isSleep()){
                                                                this.setStatus(EAction.SLEEP_START);
                                                        }
@@ -295,7 +296,7 @@ window.onload = function(){
                                                                this.yukkuri.changeFace();
                                                                this.search();
                                                        }
-                                               // }
+                                               }
 
                                        }
                                break;
@@ -498,6 +499,52 @@ window.onload = function(){
                move_to_command: function(){
 
                },
+               searchHavePlace: function(){
+                       var nodes = ctl.getObjs();
+                       l = nodes.length;
+                       var ununFlg = false;
+
+                       for (var key in nodes) {
+                               var node = nodes[key];
+                               if(this.yukkuri.id === node.id)continue;
+                               if (!ununFlg
+                                       && node instanceof Unun
+                                       && !(this.targetNode instanceof Unun)
+                                       && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
+                                       ununFlg = true;
+                                       this.targetNode = node;
+                                       this.setStatus(EAction.UNUN_SMELL_START);
+                                       return;
+                               }
+                               else if (node instanceof Food) {
+                                       if(this.yukkuri.isKuhuku() && this.yukkuri.within(node, this.yukkuri.getRange())){
+
+                                               //A yukkuri to go to the food area
+                                               this.targetNode = node;
+                                               this.setStatus(EAction.MOVE_TO_EAT_START);
+
+                                               return;
+                                       }else{
+                                               //not hunbry or not food.
+                                       }
+                               }
+                               else if(node instanceof Yukkuri){
+                                       if(this.yukkuri.isCommunication(node) && this.yukkuri.within(node, this.yukkuri.getRange())){
+                                               this.targetNode = node;
+                                               this.setStatus(EAction.COMMUNICATE_START);
+                                               return;
+                                       }
+                               }
+                               else if(node instanceof Place){
+                                       if(!node.isOwner() && !this.yukkuri.isPlace() && this.yukkuri.within(node, this.yukkuri.getRange())){
+                                               this.targetNode = node;
+                                               this.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
+                                               return;
+                                       }
+                               }
+                       }
+                       this.status =  EAction.WALK;
+               },
                search : function(){
                        var nodes = ctl.getObjs();
                        l = nodes.length;
@@ -670,8 +717,6 @@ window.onload = function(){
                        var sec = FPS * 3;
                        this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
                        this.yukkuri.wait(sec, {
-                               "onactionstart": this.onactionstart(this),
-                               "onactiontick": this.onactiontick(this),
                                "onactionend": this.onactionend(this)
                        });
                },
@@ -945,14 +990,22 @@ window.onload = function(){
        var Food = enchant.Class.create(ObjSprite,{
                initialize: function (type, x, y){
                        this.classname = "Food";
-                       ObjSprite.call(this,16,16);
-                       this.image = game.assets[EResPath.OBJECT];
-                       this.frame = 15;
+                       //一つにつきgiveの値分、hunguryを減少させられる
+                       if(type == "apple"){
+                               ObjSprite.call(this,16,16);
+                               this.image = game.assets[EResPath.OBJECT];
+                               this.frame = 15;
+                               this.give = 40;
+                               this.amount = 3;
+                       }else if(type == "grass"){
+                               ObjSprite.call(this,64,64);
+                               this.image = game.assets[EResPath.GRASS];
+                               this.frame = 0;
+                               this.give = 10;
+                               this.amount = 50;
+                       }
                        this.x = x;
                        this.y = y;
-                       //一つにつきgiveの値分、hunguryを減少させられる
-                       this.give = 40;
-                       this.amount = 3;
                        foodGroup.addChild(this);
                        this.addEventListener('enterframe', function(){
                                if(this.amount <= 0){