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;
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 = {
DEAD: 4,
UNUN: 5,
UNUN_END: 6,
- UNUN_SMELL_START: 7,
+ UNUN_SMELL: 7,
SEARCH_FOOD: 8,
EAT_FAILED: 9,
SAY_HELLO: 10,
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);
}
this.yukkuri.changeFace();
this.search();
}
- // }
+ }
}
break;
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;
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)
});
},
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){