AI returns to their origin when they cant move and are in wandering state. AI gets their facing state from the map. Guards can re-encounter you while traveling back to the origin.

This commit is contained in:
2014-06-27 18:04:34 -07:00
parent 6873a1ba53
commit 9709a87fb0
4 changed files with 26 additions and 14 deletions

View File

@@ -514,15 +514,18 @@ var AISprite = function(game, x, y, key, frame) {
this.action_wander = function()
{
var newstate = STATE_NONE;
if ( this.sprite_canmove == false) {
if ( this.x !== this.origin.x ||
this.y !== this.origin.y ) {
this.chasetarget(this.origin,
STATE_NONE,
STATE_MOVING,
false,
1000);
false);
} else {
setMovingState(this, faceStateFromString(this.sprite_facing));
this.animations.stop();
this.animations.play(getMovingAnimationName(this));
this.animations.stop();
}
return;
}
@@ -597,7 +600,7 @@ var AISprite = function(game, x, y, key, frame) {
addAnimation(this, 'bipedrunright');
addAnimation(this, 'bipedrunup');
addAnimation(this, 'bipedrundown');
setMovingState(this, STATE_FACE_DOWN);
setMovingState(this, faceStateFromString(this.sprite_facing));
setSpriteMovement(this);
this.ready_to_update = true;
}
@@ -620,6 +623,7 @@ var AISprite = function(game, x, y, key, frame) {
game.physics.arcade.enable(this);
this.body.immovable = true;
pathfinder_grid = [];
this.sprite_facing = "down";
this.walkables = [];
this.path = [];
this.state_changed_at = new Phaser.Point(this.x, this.y);
@@ -642,7 +646,7 @@ var AISprite = function(game, x, y, key, frame) {
this.view_distance = 32 * 5;
this.timer = null;
this.rotation_timer = null;
this.origin = new Phaser.Point(x/32, y/32);
this.origin = new Phaser.Point(x, y);
this.bubble_immediate = false;
this.bubble_text = null;
this.enable_word_bubble = false;