Tanoda
SoundManager.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5[RequireComponent(typeof(AudioSource))]
6public class SoundManager : MonoBehaviour
7{
8 public static SoundManager instance;
9 private AudioSource _as;
10 [SerializeField]
11 private AudioClip success;
12 [SerializeField]
13 private AudioClip airBlow;
14 [SerializeField]
15 private AudioClip electricSrewDriver;
16 [SerializeField]
17 private AudioClip airDrill;
18 [SerializeField]
19 private AudioClip overLoad;
20 internal AudioSource audio;
21
22 void Start()
23 {
24 if (instance)
25 Destroy(this);
26
27 instance = this;
28 _as = GetComponent<AudioSource>();
29 audio = GetComponent<AudioSource>();
30 audio.loop = true;
31 }
32
33 public void PlaySuccessSound()
34 {
35 audio.loop = false;
36 _as.Stop();
37 _as.clip = success;
38 _as.Play();
39 }
40
41 public void PlayAirBlowSound()
42 {
43 audio.loop = true;
44 _as.Stop();
45 _as.clip = airBlow;
46 _as.Play();
47 }
48
50 {
51 audio.loop = true;
52 _as.Stop();
53 _as.clip = electricSrewDriver;
54 _as.Play();
55 }
56
57 public void PlayOverLoadSound()
58 {
59 audio.loop = true;
60 _as.Stop();
61 _as.clip = overLoad;
62 _as.Play();
63 }
64
65 public void PlayAirDrillSound()
66 {
67 audio.loop = true;
68 _as.Stop();
69 _as.clip = airDrill;
70 _as.Play();
71 }
72
73 public void StopSound()
74 {
75 _as.Stop();
76 }
77}
void PlayOverLoadSound()
Definition: SoundManager.cs:57
static SoundManager instance
Definition: SoundManager.cs:8
void StopSound()
Definition: SoundManager.cs:73
void PlayAirBlowSound()
Definition: SoundManager.cs:41
void PlayElectricScrewdriverSound()
Definition: SoundManager.cs:49
void PlayAirDrillSound()
Definition: SoundManager.cs:65
void PlaySuccessSound()
Definition: SoundManager.cs:33