public void AudioDestroyed(AudioEventMonoB mb, AudioSource audioSource, Transform owner, AudioEventMonoB.AudioType audType) { if (onAudioDestroyed != null) { onAudioDestroyed(mb, audioSource, owner, audType); } }
public void PlayRandomSoundAsWeaponChild(List <GameObject> availableSounds, Transform owner, bool setAsParent = true, Transform alternateParent = null) { if (availableSounds.Count > 0) { int rand = Random.Range(0, availableSounds.Count); GameObject randSound = Instantiate(availableSounds[rand], transform.position, transform.rotation) as GameObject; if (randSound) { if (setAsParent && !alternateParent) { randSound.transform.SetParent(transform); } else if (setAsParent && alternateParent) { randSound.transform.SetParent(alternateParent); } randSound.transform.localPosition = Vector3.zero; AudioEventMonoB audioEventMonoB = randSound.GetComponent <AudioEventMonoB>(); if (audioEventMonoB) { audioEventMonoB.owner = owner; } } } }
public void AudioAdded(AudioEventMonoB mb, AudioSource audioSource, Transform owner, AudioEventMonoB.AudioType audType) { if (onAudioStartedInstantiated != null) { onAudioStartedInstantiated(mb, audioSource, owner, audType); } }
public void RemoveAudio(AudioEventMonoB aemb) { if (audiosBeingPlayed.Contains(aemb)) { audiosBeingPlayed.Remove(aemb); AudioDestroyed(aemb, aemb.audioSc, aemb.owner, aemb.audioType); } }
public void OnAudioRemoved(AudioEventMonoB mb, AudioSource audSrc, Transform owner, AudioEventMonoB.AudioType audType) { if (owner != null && (owner == ai.Transform || ai.Memory.isFriend(owner))) { return; } mb.onAudioPlaying -= OnPlayingAudio; for (int i = 0; i < currentlyListeningSources.Count; i++) { if (currentlyListeningSources[i].audioSource == audSrc) { currentlyListeningSources.RemoveAt(i); } } }
public void PlayRandomSoundAsWeaponChild(List <GameObject> availableSounds, Transform owner) { if (availableSounds.Count > 0) { int randFireSound = Random.Range(0, availableSounds.Count); GameObject randSound = Instantiate(availableSounds[randFireSound], transform.position, transform.rotation) as GameObject; if (randSound) { randSound.transform.SetParent(transform); AudioEventMonoB audioEventMonoB = randSound.GetComponent <AudioEventMonoB>(); if (audioEventMonoB) { audioEventMonoB.owner = owner; } } } }
public void OnAudioAdded(AudioEventMonoB mb, AudioSource audSrc, Transform owner, AudioEventMonoB.AudioType audType) { if (owner != null && (owner == ai.Transform || ai.Memory.isFriend(owner))) { return; } mb.onAudioPlaying += OnPlayingAudio; var info = ai.Memory.GetSuspicionWithBaseTransform <InformationSuspicion>(owner); if (info != null) { currentlyListeningSources.Add(new ListeningSourceVar(info, owner ? owner : audSrc.transform, audSrc)); } else { // Create info InformationSuspicion newInfo = new InformationSuspicion("Unknown source Audio", audSrc.transform.position, 0); ai.Memory.Add(newInfo); // Add to listened infos for quick access currentlyListeningSources.Add(new ListeningSourceVar(newInfo, owner ? owner : audSrc.transform, audSrc)); } }
public void AddBeingPlayedAudio(AudioEventMonoB aemb) { audiosBeingPlayed.Add(aemb); AudioAdded(aemb, aemb.audioSc, aemb.owner, aemb.audioType); }
public void SecFire ( Transform owner, Transform target, Vector3 firingToPos, ref float _weaponBodyBob, ref float _randomHandTwistSign, Quaternion xq, LayerMask bulletMask ) { if (!SecFireGp) { return; } GunAtt gunAtt = GetComponent <GunAtt>(); SecFireGp.currentClipCapacity -= 1; float xSpread = 0, ySpread = 0, bodySpread = 0; bodySpread = SecFireGp.bodySpread; xSpread = (float)(Random.value - 0.5) * (SecFireGp.spreadAmount - spreadDecreaser); ySpread = (float)(Random.Range(.35f, 1f) - 0.5) * (SecFireGp.spreadAmount - spreadDecreaser); if (SecFireGp.fireSounds.Count > 0) { int randFireSound = Random.Range(0, SecFireGp.fireSounds.Count); GameObject fireSound = Instantiate(SecFireGp.fireSounds[randFireSound], transform.position, transform.rotation) as GameObject; if (fireSound) { fireSound.transform.SetParent(transform); AudioEventMonoB audioEventMonoB = fireSound.GetComponent <AudioEventMonoB>(); if (audioEventMonoB) { audioEventMonoB.owner = owner; } } } if (SecFireGp.animator) { SecFireGp.animator.SetTrigger("Fire"); } // empty shell if (SecFireGp.emptyShellPosition && SecFireGp.EmptyShellPrefab) { Vector3 randomEmptyShellForce = new Vector3(Random.Range(SecFireGp.emptyShellMinForce.x, SecFireGp.emptyShellMaxForce.x), Random.Range(SecFireGp.emptyShellMinForce.y, SecFireGp.emptyShellMaxForce.y), Random.Range(SecFireGp.emptyShellMinForce.z, SecFireGp.emptyShellMaxForce.z)); GameObject goEmptyShell = Instantiate(SecFireGp.EmptyShellPrefab, SecFireGp.emptyShellPosition.position, SecFireGp.emptyShellPosition.rotation) as GameObject; goEmptyShell.GetComponent <Rigidbody>().AddForce(SecFireGp.emptyShellPosition.rotation * randomEmptyShellForce, ForceMode.Impulse); goEmptyShell.transform.SetParent(decals.transform, true); } // muzzle flash if (SecFireGp.muzzleFlashPrefab) { GameObject goMuzzle = Instantiate(SecFireGp.muzzleFlashPrefab, SecFireGp.muzzleFlashPosRot.position, SecFireGp.muzzleFlashPosRot.rotation) as GameObject; goMuzzle.transform.SetParent(gunAtt.transform, true); } #region Raycast Fire if (!SecFireGp.isFiringProjectile) { if (!SecFireGp.isShotGun) { Vector3 bulletDir = xq * (firingToPos - SecFireGp.spawn.position).normalized; RaycastHit[] hits = Physics.RaycastAll(gunAtt.spawn.position, bulletDir, gunAtt.maxBulletDistance, bulletMask); // raycastAll - get hits gunAtt.SortArray(ref hits); // sort raycast hits by distance ManageHits(hits, SecFireGp.bulletPower, bulletDir, SecFireGp.bulletForceToRigidbodys, SecFireGp.damage + (SecFireGp.currentProjectilePrefab.GetComponent <RaycastBullet>().damage), SecFireGp.bulletSpeed, SecFireGp.bulletTrailExitForce, SecFireGp.bulletTrailPrefab, SecFireGp.bulletTrailExitPosRot, bulletDir, bulletMask); } else { for (int i = 0; i < SecFireGp.shrapnelCount; i++) { Vector3 bulletDir = xq * Quaternion.Euler(Random.Range(-SecFireGp.maxshrapnelSpread, SecFireGp.maxshrapnelSpread), Random.Range(-SecFireGp.maxshrapnelSpread, SecFireGp.maxshrapnelSpread), 0) * (firingToPos - SecFireGp.spawn.position).normalized; //Debug.DrawRay(gunAtt.spawn.position, bulletDir * 55, Color.red); RaycastHit[] hits = Physics.RaycastAll(SecFireGp.spawn.position, bulletDir, SecFireGp.maxBulletDistance, bulletMask); // raycastAll - get hits gunAtt.SortArray(ref hits); // sort raycast hits ManageHits(hits, SecFireGp.bulletPower, bulletDir, SecFireGp.bulletForceToRigidbodys, SecFireGp.damage + (SecFireGp.currentProjectilePrefab.GetComponent <RaycastBullet>().damage), SecFireGp.bulletSpeed, SecFireGp.bulletTrailExitForce, SecFireGp.bulletTrailPrefab, SecFireGp.bulletTrailExitPosRot, bulletDir, bulletMask); } } } #endregion Raycast Fire #region Projectile Fire else { //if (SecFireGp.firesCurClipObject && SecFireGp.curClipObject.GetComponent<Projectile>()) //{ // gunAtt.curClipObject.SetParent(null); // gunAtt.curClipObject.forward = xq * (firingToPos - gunAtt.spawn.position).normalized; // gunAtt.curClipObject.GetComponent<Projectile>().EnableProjectile(); //} //else { Instantiate(SecFireGp.projectilePrefab, gunAtt.spawn.position, xq); } } #endregion Projectile Fire // Apply Spreads after Fire target.localPosition = new Vector3(xSpread, ySpread, 0) + target.localPosition; _weaponBodyBob = bodySpread; _randomHandTwistSign = Random.Range(-1, 1); }