AIController.scare C# (CSharp) Method

scare() protected method

protected scare ( Vector3 scaredPosition ) : void
scaredPosition Vector3
return void
	protected virtual void scare (Vector3 scaredPosition)
	{
		if (panicked)
			return;
		// Play only if not scared so that sounds only plays once for a scare, and then can be played again when scare cooldown is up
		if (!scared)
		{
			// Play alert sound when NPC gets scared
			AudioClip gasp = null;
			// Get skin type to know which NPC sounds to play
			if (this.SkinType.Equals (NPCSkinType.Bopper))
			{
				gasp = (AudioClip)bopperAlertSounds[Random.Range (0, bopperAlertSounds.Length)];
			}
			else if (this.SkinType.Equals (NPCSkinType.Hippie))
			{
				gasp = (AudioClip)hippieAlertSounds[Random.Range (0, hippieAlertSounds.Length)];
			}
			else if (this.SkinType.Equals (NPCSkinType.Hottie))
			{
				gasp = (AudioClip)hottieAlertSounds[Random.Range (0, hottieAlertSounds.Length)];
			}
			else if (this.SkinType.Equals (NPCSkinType.MowerMan))
			{
				gasp = (AudioClip)mowerAlertSounds[Random.Range (0, mowerAlertSounds.Length)];
			}
			else if (this.SkinType.Equals (NPCSkinType.OldMan))
			{
				gasp = (AudioClip)oldmanAlertSounds[Random.Range (0, oldmanAlertSounds.Length)];
			}
			
			audio.PlayOneShot (gasp, 1.0f);
		}

		alertTexture.renderer.enabled = false;
		scaredTexture.renderer.enabled = true;
		lureTexture.renderer.enabled = false;

		scared = true;
		scaredTimeLeft = scaredCooldownSeconds;
		moveDir = transform.position - scaredPosition;
		broadcastAlertLevelChanged (AlertLevelType.Scared);

	}