Close #54 : AI now resume paths after colliding with each other
This commit is contained in:
@@ -76,7 +76,7 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
this.awareness_change_enabled = true;
|
||||
}
|
||||
|
||||
this.enableAwarenessChange = function(state) {
|
||||
this.enableConversation = function(state) {
|
||||
delState(this, STATE_CONVERSATION_DISABLED);
|
||||
}
|
||||
|
||||
@@ -85,12 +85,30 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
if ( isSet(this.conversation_timer) )
|
||||
this.conversation_timer.stop();
|
||||
this.conversation_timer = game.time.create(false);
|
||||
this.conversation_timer.add(this.sprite_conversation_duration,
|
||||
this.enableConversationChange,
|
||||
this.conversation_timer.add(30000,
|
||||
this.enableConversation,
|
||||
this);
|
||||
this.conversation_timer.start()
|
||||
}
|
||||
|
||||
this.enableCollision = function()
|
||||
{
|
||||
delState(this, STATE_COLLISION_DISABLED);
|
||||
}
|
||||
|
||||
this.startCollisionTimer = function(duration)
|
||||
{
|
||||
duration = (typeof duration == 'undefined' ? 5000 : duration);
|
||||
addState(this, STATE_COLLISION_DISABLED);
|
||||
if ( isSet(this.collision_timer) )
|
||||
this.collision_timer.stop();
|
||||
this.collision_timer = game.time.create(false);
|
||||
this.collision_timer.add(duration,
|
||||
this.enableCollision,
|
||||
this);
|
||||
this.collision_timer.start()
|
||||
}
|
||||
|
||||
this.startAwarenessTimer = function() {
|
||||
this.awareness_change_enabled = false;
|
||||
if ( isSet(this.awareness_timer) )
|
||||
@@ -685,7 +703,7 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
|
||||
this.collide_with_AI = function(spr)
|
||||
{
|
||||
if ( spr == this )
|
||||
if ( spr == this || hasState(this, STATE_COLLISION_DISABLED) == true )
|
||||
return;
|
||||
|
||||
this.path_tween_stop();
|
||||
@@ -708,6 +726,9 @@ var AISprite = function(game, x, y, key, frame) {
|
||||
spr.path_purge();
|
||||
addState(spr, STATE_CONVERSING);
|
||||
setMovingState(spr, getFaceState(spr));
|
||||
} else {
|
||||
this.startCollisionTimer();
|
||||
spr.startCollisionTimer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ STATE_CONVERSING = 1 << 14;
|
||||
STATE_CONVERSING_YOURTURN = 1 << 15;
|
||||
STATE_CONVERSATION_DISABLED = 1 << 16;
|
||||
|
||||
STATE_COLLISION_DISABLED = 1 << 17;
|
||||
|
||||
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
|
||||
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);
|
||||
STATES_FACE = (STATE_FACE_LEFT | STATE_FACE_RIGHT | STATE_FACE_DOWN | STATE_FACE_UP);
|
||||
|
||||
@@ -400,6 +400,8 @@ function purgeConversation(obj1, obj2)
|
||||
obj2.clearWordBubble();
|
||||
obj1.startConversationTimer();
|
||||
obj2.startConversationTimer();
|
||||
obj1.startCollisionTimer();
|
||||
obj2.startCollisionTimer();
|
||||
}
|
||||
|
||||
function setConversation(obj1, obj2)
|
||||
|
||||
Reference in New Issue
Block a user