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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 |
using
UnityEngine; using
System.Collections; /// <summary> /// 音效管理器 /// </summary> public
class SoundManager : MonoBehaviour { public
static AudioSource SoundEffAudio; //播放器 public
static bool isInitSounds; //是否初始化 #region 系统 public
static AudioClip Item; public
static AudioClip BuySell; #endregion #region 战斗 public
static AudioClip AttackEff; public
static AudioClip Wound; public
static AudioClip Thrown; public
static AudioClip Bomb; #endregion #region 技能 public
static AudioClip accel; public
static AudioClip blackhole; public
static AudioClip blessed; public
static AudioClip dash; public
static AudioClip fireball; public
static AudioClip firebomb; public
static AudioClip healing; public
static AudioClip nightmare; public
static AudioClip speed; public
static AudioClip thrown; public
static AudioClip qiu; public
static AudioClip wind; #endregion void
Start() { //添加播放器 if (SoundEffAudio == null ) SoundEffAudio = transform.Find( "SoundEff" ).gameObject.AddComponent<AudioSource>(); if (!isInitSounds){ //系统 Item = Resources.Load( "Sound/SoundEffects/system/item" ) as
AudioClip; BuySell = Resources.Load( "Sound/SoundEffects/system/buysell" ) as
AudioClip; //战斗 AttackEff = Resources.Load( "Sound/SoundEffects/other/attack" ) as
AudioClip; Wound = Resources.Load( "Sound/SoundEffects/other/wound" ) as
AudioClip; Thrown = Resources.Load( "Sound/SoundEffects/other/thrown" ) as
AudioClip; Bomb = Resources.Load( "Sound/SoundEffects/other/bomb" ) as
AudioClip; //技能 accel = Resources.Load( "Sound/SoundEffects/skill/accel" ) as
AudioClip; blackhole = Resources.Load( "Sound/SoundEffects/skill/blackhole" ) as
AudioClip; blessed = Resources.Load( "Sound/SoundEffects/skill/blessed" ) as
AudioClip; dash = Resources.Load( "Sound/SoundEffects/skill/dash" ) as
AudioClip; fireball = Resources.Load( "Sound/SoundEffects/skill/fireball" ) as
AudioClip; firebomb = Resources.Load( "Sound/SoundEffects/skill/firebomb" ) as
AudioClip; healing = Resources.Load( "Sound/SoundEffects/skill/healing" ) as
AudioClip; nightmare = Resources.Load( "Sound/SoundEffects/skill/nightmare" ) as
AudioClip; speed = Resources.Load( "Sound/SoundEffects/skill/speed" ) as
AudioClip; thrown = Resources.Load( "Sound/SoundEffects/skill/thrown" ) as
AudioClip; qiu = Resources.Load( "Sound/SoundEffects/skill/qiu" ) as
AudioClip; wind = Resources.Load( "Sound/SoundEffects/skill/wind" ) as
AudioClip; Debug.Log( "SoundManager.Start 初始化音效资源" ); isInitSounds = true ; } } /// <summary> /// 播放音效(音效) /// </summary> public
static void PlaySoundEff(AudioSource audio, AudioClip clip){ audio.volume = UISetting.SoundEffectsVolume; audio.PlayOneShot(clip); } /// <summary> /// 播放音效(音效名称) /// </summary> public
static void PlaySoundEff(AudioSource audio, string
name){ AudioClip clip = null ; switch (name){ case
"accel" : clip = accel; break ; case
"blackhole" : clip = blackhole; break ; case
"blessed" : clip = blessed; break ; case
"dash" : clip = dash; break ; case
"fireball" : clip = fireball; break ; case
"firebomb" : clip = firebomb; break ; case
"healing" : clip = healing; break ; case
"nightmare" : clip = nightmare; break ; case
"speed" : clip = speed; break ; case
"thrown" : clip = thrown; break ; case
"qiu" : clip = qiu; break ; case
"wind" : clip = wind; break ; } PlaySoundEff(audio,clip); } /// <summary> /// 播放音效(内置播放器) /// </summary> public
static void PlaySoundEff(AudioClip clip){ SoundEffAudio.volume = UISetting.SoundEffectsVolume; SoundEffAudio.PlayOneShot(clip); } } |
原文:http://www.cnblogs.com/xiao-wei-wei/p/3546656.html