108
108
AddTag("creature");
109
109
SetCollider(new RectangleCollider(16, 16));
111
alert = Assets::RequestAudio("alert.ogg");
112
freakout = Assets::RequestAudio("freakout.ogg");
113
111
skitter1 = Audio::NewDeck(Assets::RequestAudio("skitter1.ogg"));
114
112
skitter1->SetLoops(0); //loop indefinitely
113
alert = Assets::RequestAudio("alert.ogg");
115
114
sniff = Audio::NewDeck(Assets::RequestAudio("sniff.ogg"));
116
115
sniff->SetLoops(0);
203
204
|| Collide("player")
207
direction = (player->position - position).GetNormalized();
208
maxspeed = 0; // give them a running start
211
// TODO: big yellow ping
216
// Go back to IDLE if:
218
// * we stalk for more than 10-15s
219
if ((aiTime > 15.0f) || Collide("wall"))
221
// play frustrated noise?
225
maxspeed = DEFAULT_MAXSPEED;
226
direction = Vector2::zero;
229
else if (state == "hunt")
231
aiTime += Monocle::deltaTime;
232
noiseTime += Monocle::deltaTime;
234
if ((aiTime > 1.0f) && (maxspeed != DEFAULT_MAXSPEED))
235
maxspeed = DEFAULT_MAXSPEED;
237
// if we hear the player (
238
Player *player = ((DarkScene *)scene)->player;
239
if ( (player->position - position).GetSquaredMagnitude() <
240
pow(player->noisiness, 2) )
242
direction = (player->position - position).GetNormalized();
244
if (noiseTime > 1.0f) {
246
// TODO: big yellow ping
251
// I guess chill out if it's been a while
252
if (aiTime > 15.0f) {
255
direction = Vector2::zero;
259
// if we collide with you... game over?
208
direction = (player->position - position).GetNormalized();
209
//maxspeed = DEFAULT_MAXSPEED;
210
// Play hunt noise (REEET!)
215
//after 6 or 7 seconds on the noiseTime clock, play sound and ping again
216
// if we hit a wall, call off the search?
217
//we'll want to play that sound again
218
// do others go ALERT if we start stalking?
219
//probably a timeout here too.
262
222
velocity += direction * ACCELERATION * Monocle::deltaTime;
293
253
Vector2 distance = ((DarkScene *)scene)->player->position - position;
294
254
if (state == "stalk")
296
float vol = (distance.GetMagnitude() / -250.0f) + 1.0f;
256
float vol = (distance.GetMagnitude() / 250.0f) + 1.0f;
297
257
sniff->SetVolume(vol);
299
259
sprite->Play("slowmove");