AISprite turn faster or slower in turnUnseenDirection depending on state

This commit is contained in:
2014-06-26 07:22:15 -07:00
parent 5ac3159e38
commit 76b4cfd1bd

View File

@@ -347,6 +347,11 @@ var AISprite = function(game, x, y, key, frame) {
alertedState = (typeof alertedState == 'undefined' ? STATE_ALERTED : alertedState); alertedState = (typeof alertedState == 'undefined' ? STATE_ALERTED : alertedState);
visual = (typeof visual == 'undefined' ? false : visual); visual = (typeof visual == 'undefined' ? false : visual);
movingstate = (typeof alertedState == 'undefined' ? STATE_NONE : movingstate); 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) ) if ( game.physics.arcade.collide(this, target) )
return; return;
@@ -358,9 +363,12 @@ var AISprite = function(game, x, y, key, frame) {
this.path_set(target, true, maxsteps, useNearestWalkable); this.path_set(target, true, maxsteps, useNearestWalkable);
this.path_tween_start(movingstate); this.path_tween_start(movingstate);
} else { } else {
if ( isSet(this.rotation_timer) == false ) { if ( this.rotation_timer == null ) {
this.rotation_timer = game.time.create(false); 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() this.rotation_timer.start()
} }
} }