Making townsfolk report you to a guard
This commit is contained in:
@@ -20,6 +20,8 @@ STATE_FACE_UP = 1 << 8;
|
|||||||
STATE_FACE_DOWN = 1 << 9;
|
STATE_FACE_DOWN = 1 << 9;
|
||||||
STATE_MOVING = 1 << 10;
|
STATE_MOVING = 1 << 10;
|
||||||
|
|
||||||
|
STATE_RUNNINGTOLIGHT = 1 << 11;
|
||||||
|
|
||||||
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
|
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
|
||||||
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);
|
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);
|
||||||
STATES_FACE = (STATE_FACE_LEFT | STATE_FACE_RIGHT | STATE_FACE_DOWN | STATE_FACE_UP);
|
STATES_FACE = (STATE_FACE_LEFT | STATE_FACE_RIGHT | STATE_FACE_DOWN | STATE_FACE_UP);
|
||||||
@@ -1059,8 +1061,11 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.target = nearestInGroup(this, aiSprites, "townsfolk-guard");
|
this.target = nearestInGroup(this, aiSprites, "townsfolk-guard");
|
||||||
}
|
}
|
||||||
if ( this.target !== null ) {
|
if ( this.target !== null ) {
|
||||||
if ( this.target.canSeeSprite(this) == true ||
|
if ( (this.target.canSeeSprite(this) == true) ||
|
||||||
game.physics.arcade.collide(this, this.target) == true ) {
|
(game.physics.arcade.collide(this, this.target) == true) ) {
|
||||||
|
if ( hasState(this, STATE_RUNNINGTOLIGHT) == true ) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
console.log("My target can see me!");
|
console.log("My target can see me!");
|
||||||
this.path_tween_stop();
|
this.path_tween_stop();
|
||||||
this.path_purge();
|
this.path_purge();
|
||||||
@@ -1068,6 +1073,8 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.target = nearestInGroup(this, staticLights);
|
this.target = nearestInGroup(this, staticLights);
|
||||||
console.log("Running to the nearest light");
|
console.log("Running to the nearest light");
|
||||||
console.log(this.target);
|
console.log(this.target);
|
||||||
|
addState(this, STATE_RUNNINGTOLIGHT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.chasetarget(this.target,
|
this.chasetarget(this.target,
|
||||||
STATE_ALERTED,
|
STATE_ALERTED,
|
||||||
|
|||||||
Reference in New Issue
Block a user