AudioManager
How do I use Audio Manager
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
56 | AudioManager (); | 1 |
101 | void AudioManager(){ | 2 |
File name: Structure.cs
Copy
46 void OnCollisionEnter2D(Collision2D collision){
47 if(collision.relativeVelocity.magnitude > damageCounter){
48 hitpoints -= Mathf.RoundToInt (collision.relativeVelocity.magnitude);
49 UpdateScoreStatus (Mathf.RoundToInt (collision.relativeVelocity.magnitude));
50 }
51
52
53 if (hitpoints <= 50) {
54 spriteRenderer.sprite = sprite [0];
55 if(counter == 2){
56 AudioManager ();
57 counter--;
58 }
59
60 }
61
62 if(hitpoints <= 30){
63 spriteRenderer.sprite = sprite [1];
64 if(counter == 1){
65 AudioManager ();
66 counter--;
67 }
68 }
69
70
71 if(hitpoints <= 0){
72 Destroyed ();
73
74 if(collision.gameObject.CompareTag("Player Bullet")){
75 bounce = collision.transform.GetComponent
76 bounce.y = 0f;
77 collision.transform.GetComponent
78 }
79 }
80 }
File name: Structure.cs
Copy
101 void AudioManager(){
102 switch (structure) {
103 case StructureType.Wood:
104 if(GameController.instance != null && MusicController.instance != null){
105 if(GameController.instance.isMusicOn){
106 if (gameObject != null) {
107 AudioSource.PlayClipAtPoint (woodSound, transform.position);
108 }
109 }
110 }
111 break;
112
113 case StructureType.Stone:
114 if(GameController.instance != null && MusicController.instance != null){
115 if(GameController.instance.isMusicOn){
116 if (gameObject != null) {
117 AudioSource.PlayClipAtPoint (stoneSound, transform.position);
118 }
119 }
120 }
121 break;
122
123 case StructureType.Glass:
124 if(GameController.instance != null && MusicController.instance != null){
125 if(GameController.instance.isMusicOn){
126 if (gameObject != null) {
127 AudioSource.PlayClipAtPoint (glassSound, transform.position);
128 }
129 }
130 }
131 break;
132 }
133 }
Download file with original file name:AudioManager
AudioManager 110 lượt xem
Gõ tìm kiếm nhanh...