Refactored a little, AISprites now keep track of where their state changed
This commit is contained in:
@@ -90,6 +90,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
state != STATE_ALERTED ) {
|
state != STATE_ALERTED ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
||||||
this.startAwarenessTimer();
|
this.startAwarenessTimer();
|
||||||
setAwarenessState(this, state);
|
setAwarenessState(this, state);
|
||||||
|
|
||||||
@@ -288,12 +289,12 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
null);
|
null);
|
||||||
tween.onStart.add(function() {
|
tween.onStart.add(function() {
|
||||||
setMovingState(this._object, this.movingstate);
|
setMovingState(this._object, this.movingstate);
|
||||||
this._object.animations.play("bipedrun" + spriteFacing(this._object));
|
this._object.animations.play(getMovingAnimationName(this._object));
|
||||||
}, tween);
|
}, tween);
|
||||||
tween.onComplete.add(function() {
|
tween.onComplete.add(function() {
|
||||||
this._object.path_index += 1;
|
this._object.path_index += 1;
|
||||||
setMovingState(this._object, getFaceState(this._object));
|
setMovingState(this._object, getFaceState(this._object));
|
||||||
this._object.animations.play("bipedrun" + spriteFacing(this._object));
|
this._object.animations.play(getMovingAnimationName(this._object));
|
||||||
this._object.animations.stop();
|
this._object.animations.stop();
|
||||||
}, tween);
|
}, tween);
|
||||||
if ( i > 0 ) {
|
if ( i > 0 ) {
|
||||||
@@ -318,7 +319,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
STATE_FACE_RIGHT, STATE_FACE_UP];
|
STATE_FACE_RIGHT, STATE_FACE_UP];
|
||||||
setMovingState(this, directions[game.rnd.integerInRange(0, 3)]);
|
setMovingState(this, directions[game.rnd.integerInRange(0, 3)]);
|
||||||
this.animations.stop();
|
this.animations.stop();
|
||||||
this.animations.play("bipedrun" + spriteFacing(this));
|
this.animations.play(getMovingAnimationName(this));
|
||||||
this.animations.stop();
|
this.animations.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +334,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
}
|
}
|
||||||
setMovingState(this, newdirection);
|
setMovingState(this, newdirection);
|
||||||
this.animations.stop();
|
this.animations.stop();
|
||||||
this.animations.play("bipedrun" + spriteFacing(this));
|
this.animations.play(getMovingAnimationName(this));
|
||||||
this.animations.stop();
|
this.animations.stop();
|
||||||
if ( this.rotation_timer !== null ) {
|
if ( this.rotation_timer !== null ) {
|
||||||
this.rotation_timer.stop();
|
this.rotation_timer.stop();
|
||||||
@@ -509,6 +510,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.animations.destroy();
|
this.animations.destroy();
|
||||||
this.clearWordBubble();
|
this.clearWordBubble();
|
||||||
this.state = STATE_UNAWARE;
|
this.state = STATE_UNAWARE;
|
||||||
|
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
||||||
this.sprite_can_see_lightmeter = Number(this.sprite_can_see_lightmeter);
|
this.sprite_can_see_lightmeter = Number(this.sprite_can_see_lightmeter);
|
||||||
this.sprite_canmove = parseBoolean(this.sprite_canmove);
|
this.sprite_canmove = parseBoolean(this.sprite_canmove);
|
||||||
this.sprite_awareness_duration = parseInt(this.sprite_awareness_duration);
|
this.sprite_awareness_duration = parseInt(this.sprite_awareness_duration);
|
||||||
@@ -551,6 +553,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
pathfinder_grid = [];
|
pathfinder_grid = [];
|
||||||
this.walkables = [];
|
this.walkables = [];
|
||||||
this.path = [];
|
this.path = [];
|
||||||
|
this.state_changed_at = new Phaser.Point(this.x, this.y);
|
||||||
this.target = null;
|
this.target = null;
|
||||||
this.path_tweens = [];
|
this.path_tweens = [];
|
||||||
this.path_maximum_steps = 4;
|
this.path_maximum_steps = 4;
|
||||||
|
|||||||
Reference in New Issue
Block a user