Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
HS_ParticleEndSound Class Reference
Inheritance diagram for HS_ParticleEndSound:

Classes

class  Pool
 

Public Member Functions

GameObject SpawnFromPool (string tag, Vector3 position)
 
void LateUpdate ()
 

Public Attributes

float poolReturnTimer = 1.5f
 
float explosionMinVolume = 0.3f
 
float explosionMaxVolume = 0.7f
 
float explosionPitchMin = 0.75f
 
float explosionPitchMax = 1.25f
 
float shootMinVolume = 0.05f
 
float shootMaxVolume = 0.1f
 
float shootPitchMin = 0.75f
 
float shootPitchMax = 1.25f
 
AudioClip[] audioExplosion
 
AudioClip[] audioShot
 
List< Poolpools
 
Dictionary< string, Queue< GameObject > > poolDictionary
 

Static Public Attributes

static HS_ParticleEndSound SharedInstance
 

Private Member Functions

void Awake ()
 
void Start ()
 
IEnumerator LateCall (GameObject soundInstance)
 

Detailed Description

Definition at line 6 of file HS_ParticleEndSound.cs.

Member Function Documentation

◆ Awake()

void HS_ParticleEndSound.Awake ( )
inlineprivate

Definition at line 46 of file HS_ParticleEndSound.cs.

47 {
48 SharedInstance = this;
49 }
static HS_ParticleEndSound SharedInstance

References SharedInstance.

◆ LateCall()

IEnumerator HS_ParticleEndSound.LateCall ( GameObject  soundInstance)
inlineprivate

Definition at line 118 of file HS_ParticleEndSound.cs.

119 {
120 yield return new WaitForSeconds(poolReturnTimer);
121 soundInstance.SetActive(value: false);
122 }

References poolReturnTimer.

Referenced by LateUpdate().

◆ LateUpdate()

void HS_ParticleEndSound.LateUpdate ( )
inline

Definition at line 93 of file HS_ParticleEndSound.cs.

94 {
95 ParticleSystem.Particle[] array = new ParticleSystem.Particle[GetComponent<ParticleSystem>().particleCount];
96 int particles = GetComponent<ParticleSystem>().GetParticles(array);
97 for (int i = 0; i < particles; i++)
98 {
99 if (audioExplosion.Length != 0 && array[i].remainingLifetime < Time.deltaTime)
100 {
101 GameObject gameObject = SharedInstance.SpawnFromPool("AudioExplosion", array[i].position);
102 if (gameObject != null)
103 {
104 StartCoroutine(LateCall(gameObject));
105 }
106 }
107 if (audioShot.Length != 0 && array[i].remainingLifetime >= array[i].startLifetime - Time.deltaTime)
108 {
109 GameObject gameObject2 = SharedInstance.SpawnFromPool("AudioShot", array[i].position);
110 if (gameObject2 != null)
111 {
112 StartCoroutine(LateCall(gameObject2));
113 }
114 }
115 }
116 }
IEnumerator LateCall(GameObject soundInstance)
GameObject SpawnFromPool(string tag, Vector3 position)

References audioExplosion, audioShot, LateCall(), SharedInstance, and SpawnFromPool().

◆ SpawnFromPool()

GameObject HS_ParticleEndSound.SpawnFromPool ( string  tag,
Vector3  position 
)
inline

Definition at line 78 of file HS_ParticleEndSound.cs.

79 {
80 if (!poolDictionary.ContainsKey(tag))
81 {
82 Debug.LogWarning("Pool with tag" + tag + " does not excist.");
83 return null;
84 }
85 GameObject gameObject = poolDictionary[tag].Dequeue();
86 gameObject.SetActive(value: true);
87 position.z = 0f;
88 gameObject.transform.position = position;
89 poolDictionary[tag].Enqueue(gameObject);
90 return gameObject;
91 }
Dictionary< string, Queue< GameObject > > poolDictionary

References Debug, and poolDictionary.

Referenced by LateUpdate().

◆ Start()

void HS_ParticleEndSound.Start ( )
inlineprivate

Definition at line 51 of file HS_ParticleEndSound.cs.

52 {
53 poolDictionary = new Dictionary<string, Queue<GameObject>>();
54 foreach (Pool pool in pools)
55 {
57 GameObject gameObject = UnityEngine.Object.Instantiate(pool.prefab);
58 AudioSource component = gameObject.GetComponent<AudioSource>();
59 if (pool.tag == "AudioExplosion")
60 {
61 component.clip = audioExplosion[UnityEngine.Random.Range(0, audioExplosion.Length)];
62 component.volume = UnityEngine.Random.Range(explosionMinVolume, explosionMaxVolume);
63 component.pitch = UnityEngine.Random.Range(explosionPitchMin, explosionPitchMax);
64 }
65 else if (pool.tag == "AudioShot")
66 {
67 component.clip = audioShot[UnityEngine.Random.Range(0, audioExplosion.Length)];
68 component.volume = UnityEngine.Random.Range(shootMinVolume, shootMaxVolume);
69 component.pitch = UnityEngine.Random.Range(shootPitchMin, shootPitchMax);
70 }
71 gameObject.transform.parent = base.gameObject.transform;
72 gameObject.SetActive(value: false);
73 queue.Enqueue(gameObject);
74 poolDictionary.Add(pool.tag, queue);
75 }
76 }
Definition: Queue.cs:2

References audioExplosion, audioShot, explosionMaxVolume, explosionMinVolume, explosionPitchMax, explosionPitchMin, poolDictionary, pools, HS_ParticleEndSound.Pool.prefab, shootMaxVolume, shootMinVolume, shootPitchMax, shootPitchMin, and HS_ParticleEndSound.Pool.tag.

Member Data Documentation

◆ audioExplosion

AudioClip [] HS_ParticleEndSound.audioExplosion

Definition at line 36 of file HS_ParticleEndSound.cs.

Referenced by LateUpdate(), and Start().

◆ audioShot

AudioClip [] HS_ParticleEndSound.audioShot

Definition at line 38 of file HS_ParticleEndSound.cs.

Referenced by LateUpdate(), and Start().

◆ explosionMaxVolume

float HS_ParticleEndSound.explosionMaxVolume = 0.7f

Definition at line 22 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ explosionMinVolume

float HS_ParticleEndSound.explosionMinVolume = 0.3f

Definition at line 20 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ explosionPitchMax

float HS_ParticleEndSound.explosionPitchMax = 1.25f

Definition at line 26 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ explosionPitchMin

float HS_ParticleEndSound.explosionPitchMin = 0.75f

Definition at line 24 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ poolDictionary

Dictionary<string, Queue<GameObject> > HS_ParticleEndSound.poolDictionary

Definition at line 44 of file HS_ParticleEndSound.cs.

Referenced by SpawnFromPool(), and Start().

◆ poolReturnTimer

float HS_ParticleEndSound.poolReturnTimer = 1.5f

Definition at line 18 of file HS_ParticleEndSound.cs.

Referenced by LateCall().

◆ pools

List<Pool> HS_ParticleEndSound.pools

Definition at line 42 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ SharedInstance

HS_ParticleEndSound HS_ParticleEndSound.SharedInstance
static

Definition at line 40 of file HS_ParticleEndSound.cs.

Referenced by Awake(), and LateUpdate().

◆ shootMaxVolume

float HS_ParticleEndSound.shootMaxVolume = 0.1f

Definition at line 30 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ shootMinVolume

float HS_ParticleEndSound.shootMinVolume = 0.05f

Definition at line 28 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ shootPitchMax

float HS_ParticleEndSound.shootPitchMax = 1.25f

Definition at line 34 of file HS_ParticleEndSound.cs.

Referenced by Start().

◆ shootPitchMin

float HS_ParticleEndSound.shootPitchMin = 0.75f

Definition at line 32 of file HS_ParticleEndSound.cs.

Referenced by Start().


The documentation for this class was generated from the following file: