forked from adenlb/Vivid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudioCollisionMngr.cs
43 lines (35 loc) · 944 Bytes
/
audioCollisionMngr.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class audioCollisionMngr : MonoBehaviour {
Dictionary<Color, AudioSource> soundTable = new Dictionary<Color, AudioSource>();
public AudioSource red_sound;
public AudioSource blue_sound;
public AudioSource yellow_sound;
public AudioSource magenta_sound;
// Use this for initialization
void Start () {
soundTable [Color.red] = red_sound;
soundTable [Color.blue] = blue_sound;
soundTable [Color.yellow] = yellow_sound;
soundTable [Color.magenta] = magenta_sound;
}
bool inDict(Color c) {
return ((c == Color.red) ||
(c == Color.blue) ||
(c == Color.yellow) ||
(c == Color.magenta));
}
public void playColorClip(Color c) {
if (inDict (c)) {
(soundTable [c]).Play ();
}
}
public void stopColorClip(Color c) {
if (inDict (c)) {
if ((soundTable [c]).loop) {
(soundTable [c]).Stop ();
}
}
}
}