// Use this for initialization void Start() { currentHealth = maxHealth; stateMachine = GetComponent <StateMachine>(); animator = GetComponent <Animator>(); noiseEmitter = GetComponent <NoiseEmitter>(); effectIndicators = GetComponentInChildren <EffectIndicatorController>(); IsSelected = new ReactiveProperty <bool>(); IsSelected.Subscribe(x => animator.SetBool("selected", x)); legsAnimator = legsObject.GetComponent <Animator>(); bodyAnimator = bodyObject.GetComponent <Animator>(); }
private void OnParticleCollision(GameObject soundPulse) { if (soundPulse.tag == "SuspiciousSound") { NoiseEmitter suspectedNoise = soundPulse.GetComponent <NoiseEmitter>(); Noise detectedNoise = suspectedNoise.noise; bool idRecognized = false; if (SoundIDs.Count > 0) { foreach (int soundID in SoundIDs) { // Debug.Log(soundID); if (detectedNoise.noiseID == soundID) { idRecognized = true; } } } if (idRecognized) { // Debug.Log("Noticed Same ID, Ignoring"); return; } else { float detectedVolume = detectedNoise.volume; if (detectedVolume > threshold) { patrolling = false; SoundIDs.Enqueue(detectedNoise.noiseID); timeSinceLastIDQueueRefresh = Time.time; noisesDetected.Add(detectedNoise); Debug.Log("Heard Something: Move to investigate"); Prioritize(); } } } }
private void Awake() { noiseEmitter = gameObject.GetComponentInChildren <NoiseEmitter>(); }