PlaySoundsPlayer
How do I use Play Sounds Player
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
22 | public void PlaySoundsPlayer(int soundNumber) | 1 |
59 | sounds.PlaySoundsPlayer(0); | 2 |
108 | sounds.PlaySoundsPlayer(3); | 3 |
128 | sounds.PlaySoundsPlayer(1); | 4 |
File name: SoundManager.cs
Copy
22 public void PlaySoundsPlayer(int soundNumber)
23 {
24 if (SystemScr.mute)
25 return;
26
27 if (soundNumber == 0)
28 audSources[0].clip = shot;
29 else if (soundNumber == 1)
30 audSources[0].clip = p_harm;
31 else if (soundNumber == 2)
32 audSources[0].clip = p_dead;
33 else if(soundNumber == 3)
34 audSources[0].clip = pickup;
35
36 audSources[0].Play();
37 }
File name: PlayerControl.cs
Copy
49 void ShootOrPauseControls()
50 {
51 if (!SystemScr.paused)
52 {
53 if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
54 {
55 GameObject p_bullet = pools.GetPoolableObject("p_bullet");
56
57 if (p_bullet != null && maxBulletsOnScreen > 0)
58 {
59 sounds.PlaySoundsPlayer(0);
60 p_bullet.SetActive(true);
61 p_bullet.GetComponent
62 }
63 }
64 }
65 if (Input.GetKeyDown(KeyCode.Escape))
66 {
67 ui.Pause_btn();
68 }
69 }
File name: PlayerControl.cs
Copy
100 void OnTriggerEnter(Collider col)
101 {
102 if (col.tag == "Enemy" || col.tag == "Danger")
103 {
104 GetDamage();
105 }
106 if (col.tag == "Bonus")
107 {
108 sounds.PlaySoundsPlayer(3);
109 GetBonusEffect(col.GetComponent
110 ui.ShowLives(lifeCurrent);
111 col.gameObject.SetActive(false);
112 }
113 }
File name: PlayerControl.cs
Copy
115 public void GetDamage(int damage = 1)
116 {
117 if (immortal)
118 return;
119
120 immortal = true;
121
122 lifeCurrent-= damage;
123
124 ui.ShowLives(lifeCurrent);
125
126 if (lifeCurrent > 0)
127 {
128 sounds.PlaySoundsPlayer(1);
129 StartCoroutine("Immortality");
130 }
131 else
132 {
133 sounds.PlaySoundsPlayer(2);
134 Die();
135 }
136 }
PlaySoundsPlayer 113 lượt xem
Gõ tìm kiếm nhanh...