public void SoundToPosition(Vector2 point, bool madeByPlayer, Noise.Source source, Vector2 secondaryPosition) { if (!madeByPlayer) { return; } bool tooFar = GetTooFar(point); // Ignore noises outside of patrol zone... Should they at least look? if (!canSeePlayer && tooFar) { if (clearView) { SetAwareness(State.Suspicious); navigator.SetDestination(route[0], true); } // Possibly call in backup return; } if (!canSeePlayer) { SetAwareness(State.Suspicious); } if (source == Noise.Source.Grenade && Vector2.Distance(transform.position, point) < Globals.GRENADE_YELLOW_RANGE) { navigator.SetDestination(secondaryPosition, true); } else { // If it's a distraction, walk navigator.SetDestination(point, source != Noise.Source.Distract); } }
protected override void SelfDestruct() { float noiseVolume = 0; Noise.Source source = Noise.Source.Distract; switch (type) { case Type.Distract: SoundManager.instance.Play(SoundManager.Sound.Glass); noiseVolume = Globals.DISTRACTION_VOLUME; source = Noise.Source.Distract; break; case Type.Frag: // Explosion GameObject explosion = Instantiate(Globals.EXPLOSION, transform.position, Quaternion.identity); explosion.transform.localScale = (0.2f + (0.4f * Globals.GRENADE_YELLOW_RANGE)) * Vector2.one; // Damage DamageRadius(); // Noise volume SoundManager.instance.Play(SoundManager.Sound.Explosion); noiseVolume = Globals.GRENADE_VOLUME; source = Noise.Source.Grenade; break; case Type.Gas: SpawnGas(); noiseVolume = Globals.DISTRACTION_VOLUME; break; } // Noise GameObject tempNoise = Instantiate(Globals.NOISE, transform.position, Quaternion.identity); Vector2 secondaryPosition = (userTag == "Player" ? (Vector2)user.transform.position : Vector2.zero); tempNoise.GetComponent <Noise>().Initialize(userTag == "Player", noiseVolume, source, secondaryPosition); Destroy(gameObject); }