From 76b4cfd1bd097a9326e7f6621808967e53b73262 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Thu, 26 Jun 2014 07:22:15 -0700 Subject: [PATCH] AISprite turn faster or slower in turnUnseenDirection depending on state --- moonlight/src/AISprite.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index dd1f6ff..6a94b06 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -347,6 +347,11 @@ var AISprite = function(game, x, y, key, frame) { alertedState = (typeof alertedState == 'undefined' ? STATE_ALERTED : alertedState); visual = (typeof visual == 'undefined' ? false : visual); movingstate = (typeof alertedState == 'undefined' ? STATE_NONE : movingstate); + var rotation_times = {}; + rotation_times["" + STATE_UNAWARE] = 5000; + rotation_times["" + STATE_CONCERNED] = 1000; + rotation_times["" + STATE_ALERTED] = 250; + rotation_times["" + STATE_LOSTHIM] = 1000; if ( game.physics.arcade.collide(this, target) ) return; @@ -358,9 +363,12 @@ var AISprite = function(game, x, y, key, frame) { this.path_set(target, true, maxsteps, useNearestWalkable); this.path_tween_start(movingstate); } else { - if ( isSet(this.rotation_timer) == false ) { + if ( this.rotation_timer == null ) { this.rotation_timer = game.time.create(false); - timerev = this.rotation_timer.add(250, this.turnUnseenDirection, this); + timerev = this.rotation_timer.add( + rotation_times["" + getAwarenessState(this)], + this.turnUnseenDirection, + this); this.rotation_timer.start() } }