From 7f9f7fd39c55382f6786595898e68a1b3e44b00f Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sun, 15 Jun 2014 14:16:19 -0700 Subject: [PATCH] Working on effect bubbles (visual indicators for awareness state changes) --- moonlight/js/moonlight-skulk.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index 1efef0d..37ae2e1 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -697,6 +697,12 @@ var AISprite = function(game, x, y, key, frame) { this.setAwarenessEffect = function(state) { var animkey = ""; + if ( (state == STATE_LOSTHIM) && (hasState(this, STATE_ALERTED) == false)) { + return; + } else if ( (state == STATE_ALERTED) && (hasState(this, STATE_ALERTED) == true) ) { + return; + } + setAwarenessState(this, state); if ( this.awareness_effect !== null ) { @@ -1277,13 +1283,9 @@ GameState.prototype.update = function() if ( x.collide_with_player == false ) return; if ( x.canSeeSprite(player, false) == true ) { - if ( hasState(x, STATE_ALERTED) == false ) { - x.setAwarenessEffect(x, STATE_ALERTED); - } + x.setAwarenessEffect(x, STATE_ALERTED); } else { - if ( hasState(x, STATE_ALERTED) == true ) { - x.setAwarenessEffect(x, STATE_LOSTHIM); - } + x.setAwarenessEffect(x, STATE_LOSTHIM); } this.physics.arcade.collide(x, player); }