Stop switching awareness states so fast
This commit is contained in:
@@ -704,10 +704,23 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.awareness_change_enabled = true;
|
this.awareness_change_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.startAwarenessTimer = function() {
|
||||||
|
this.awareness_change_enabled = false;
|
||||||
|
if ( this.awareness_timer !== null )
|
||||||
|
this.awareness_timer.stop();
|
||||||
|
this.awareness_timer = game.time.create(false);
|
||||||
|
this.awareness_timer.add(this.sprite_awareness_duration,
|
||||||
|
this.enableAwarenessChange,
|
||||||
|
this);
|
||||||
|
this.awareness_timer.start()
|
||||||
|
}
|
||||||
|
|
||||||
this.setAwarenessEffect = function(state) {
|
this.setAwarenessEffect = function(state) {
|
||||||
var animkey = "";
|
var animkey = "";
|
||||||
|
|
||||||
if ( hasState(this, state) == true ) {
|
if ( hasState(this, state) == true ) {
|
||||||
|
// restart the awareness timer
|
||||||
|
this.startAwarenessTimer();
|
||||||
return;
|
return;
|
||||||
} else if ( (state == STATE_LOSTHIM) &&
|
} else if ( (state == STATE_LOSTHIM) &&
|
||||||
(hasState(this, STATE_ALERTED) == false) &&
|
(hasState(this, STATE_ALERTED) == false) &&
|
||||||
@@ -719,15 +732,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
state != STATE_ALERTED ) {
|
state != STATE_ALERTED ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.awareness_change_enabled = false;
|
this.startAwarenessTimer();
|
||||||
if ( this.awareness_timer !== null )
|
|
||||||
this.awareness_timer.stop();
|
|
||||||
this.awareness_timer = game.time.create(false);
|
|
||||||
this.awareness_timer.add(this.sprite_awareness_duration,
|
|
||||||
this.enableAwarenessChange,
|
|
||||||
this);
|
|
||||||
this.awareness_timer.start()
|
|
||||||
|
|
||||||
setAwarenessState(this, state);
|
setAwarenessState(this, state);
|
||||||
|
|
||||||
if ( this.awareness_effect !== null ) {
|
if ( this.awareness_effect !== null ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user