-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSoundbank.java
More file actions
385 lines (254 loc) · 9.97 KB
/
Copy pathSoundbank.java
File metadata and controls
385 lines (254 loc) · 9.97 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
package com.smiths;
import com.smiths.R;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
//sound effect manager
public class Soundbank {
static SoundPool sounds;
private static int attack1;
private static int coin;
private static int swoosh1;
private static int yell1;
private static int yell2;
private static int yell3;
private static int swordcollision;
private static int dualswordcombo;
private static int spinjump;
private static int gong;
private static int shurikenthrow;
private static int shurikenhit;
private static int hurt1;
private static int levelupsound;
private static int angelsound1;
private static int angelsound2;
private static int angelsound3;
private static int timedown;
private static int timeup;
private static int smokebomb;
private static int extraninja;
private static int smokebombpickup;
private static int swish;
private static int swishkill;
private static int gold;
private static int shurikenpickup;
private static int smallgong;
private static int groundpound;
private static int healthup;
private static int shurikencollision;
public Soundbank() {
// TODO Auto-generated constructor stub
}
public void loadSound(Context context) {
//sound = true; // should there be sound?
sounds = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
// three ref. to the sounds I need in the application
attack1 = sounds.load(context, R.raw.attack1, 1);
coin = sounds.load(context, R.raw.coin, 1);
swoosh1 = sounds.load(context, R.raw.swoosh1, 1);
dualswordcombo = sounds.load(context, R.raw.dualswordcombo, 1);
spinjump = sounds.load(context, R.raw.spinjump, 1);
timedown = sounds.load(context, R.raw.timedown, 1);
timeup = sounds.load(context, R.raw.timeup, 1);
gong = sounds.load(context, R.raw.gong, 1);
yell1 = sounds.load(context, R.raw.yell1, 1);
yell2 = sounds.load(context, R.raw.yell2, 1);
yell3 = sounds.load(context, R.raw.yell3, 1);
shurikenthrow = sounds.load(context, R.raw.shurikenthrow, 1);
shurikenhit = sounds.load(context, R.raw.shurikenhit, 1);
shurikencollision = sounds.load(context,R.raw.shurikencollision,1);
hurt1 = sounds.load(context, R.raw.hurt1, 1);
swish = sounds.load(context, R.raw.swish, 1);
swishkill=sounds.load(context, R.raw.swishkill, 1);
swordcollision=sounds.load(context, R.raw.swordcollide, 1);
angelsound1 = sounds.load(context, R.raw.angelsound1, 1);
angelsound2 = sounds.load(context, R.raw.angelsound2, 1);
angelsound3 = sounds.load(context, R.raw.angelsound3, 1);
levelupsound = sounds.load(context, R.raw.levelupsound, 1);
smokebomb = sounds.load(context, R.raw.smokebomb, 1);
extraninja = sounds.load(context, R.raw.extraninja, 1);
smokebombpickup = sounds.load(context, R.raw.smokebombpickup, 1);
gold = sounds.load(context, R.raw.gold, 1);
shurikenpickup = sounds.load(context, R.raw.shurikenpickup, 1);
smallgong = sounds.load(context, R.raw.smallgong, 1);
groundpound = sounds.load(context, R.raw.groundpound, 1);
healthup = sounds.load(context, R.raw.healthup, 1);
// the music that is played at the beginning and when there is only 10 seconds left in a game
//music = MediaPlayer.create(context, R.raw.sakurakoto);
}
public void playHurt(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch -.5;}
sounds.play(hurt1, 1, 1, 1, 0, (float) pitch);
}
public void playTimeDOWN(boolean sound) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
sounds.play(timedown, 1, 1, 1, 0, (float) pitch);
}
public void playTimeUP(boolean sound) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
sounds.play(timeup, 1, 1, 1, 0, (float) pitch);
}
public void playHit(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch -.5;}
sounds.play(attack1, 1, 1, 1, 0, (float) pitch);
}
public void playCoin(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .8 + (random*.3);
if(slowed == true){pitch = pitch -.5;}
sounds.play(coin, 1, 1, 1, 0, (float) pitch);
}
public void playSpinjump(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch -.5;}
sounds.play(spinjump, 1, 1, 1, 0, (float) pitch);
}
public void playDualSwordCombo(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch -.5;}
sounds.play(dualswordcombo, 1, 1, 1, 0, (float) pitch);
}
public void playShurikenCollision(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch -.5;}
sounds.play(shurikencollision, 1, 1, 1, 0, (float) pitch);
}
public void playYell(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
int random = (int)(Math.random()*3);
if(random == 0)
{
sounds.play(yell1, 1, 1, 1, 0, 1);
}
if(random == 1)
{
sounds.play(yell2, 1, 1, 1, 0, 1);
}
if(random == 2)
{
sounds.play(yell3, 1, 1, 1, 0, 1);
}
if(random == 3)
{
sounds.play(yell3, 1, 1, 1, 0, 1);
}
//if (sound == false) return; // if sound is turned off no need to continue
}
public void playSwoosh(boolean sound, boolean slowed) {if (sound == false) {return;}
int random = (int)(Math.random()*3);//this random is never used?
double pitch = 1;
if(slowed == true){pitch = pitch -.85;}
sounds.play(swoosh1, 1, 1, 1, 0, (float) pitch);
//if (sound == false) return; // if sound is turned off no need to continue
}
public void playAngel(boolean sound, boolean slowed) {if (sound == false) {return;}
int random = (int)(Math.random()*3);
double pitch = 1;
if(slowed == true){pitch = .5;}
if(random == 0)
{
sounds.play(angelsound1, 1, 1, 1, 0, (float) pitch);
}
if(random == 1)
{
sounds.play(angelsound2, 1, 1, 1, 0, (float) pitch);
}
if(random == 2)
{
sounds.play(angelsound3, 1, 1, 1, 0, (float) pitch);
}
if(random == 3)
{
sounds.play(angelsound3, 1, 1, 1, 0, (float) pitch);
}
}
public void playGong(boolean sound) {if (sound == false) {return;}
sounds.play(gong, 1, 1, 1, 0, 1);
}
public void playSmallGong(boolean sound) {if (sound == false) {return;}
sounds.play(smallgong, 1, 1, 1, 0, 1);
}
public void playLevelup(boolean sound) {if (sound == false) {return;}
sounds.play(levelupsound, 1, 1, 1, 0, 1);
}
public void playShurikenthrow(boolean sound) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
sounds.play(shurikenthrow, 1, 1, 1, 0, (float)pitch);
}
public void playShurikenhit(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch - .5;}
sounds.play(shurikenhit, 1, 1, 1, 0, (float)pitch);
}
public void playExplosion(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
sounds.play(smokebomb, 1, 1, 1, 0, 1);
}
public void playNewNinja(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
float pitch = 1;
sounds.play(extraninja, 1, 1, 1, 0, pitch);
}
public void playShurikengrab(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
// TODO Auto-generated method stub
sounds.play(shurikenpickup, 1, 1, 1, 0, 1);
}
public void playHealthup(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
sounds.play(healthup, 1, 1, 1, 0, 1);
}
public void playGroundpound(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
// TODO Auto-generated method stub
sounds.play(groundpound, 1, 1, 1, 0, 1);
}
public void playLevelComplete(boolean sound) {if (sound == false) {return;}
sounds.play(gong, 1, 1, 1, 0, 1);
}
public void playGold(boolean sound) {if (sound == false) {return;}
// TODO Auto-generated method stub
sounds.play(gold, 1, 1, 1, 0, 1);
}
public void playSmokeBombPickup(boolean sound, boolean slowed) {if ((sound == false)||(slowed == true)) {return;}
// TODO Auto-generated method stub
sounds.play(smokebombpickup, 1, 1, 1, 0, 1);
}
public void playSwish(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch - .5;}
sounds.play(swish, 1, 1, 1, 0, (float) pitch);
}
public void playSwishKill(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch - .5;}
sounds.play(swishkill, 1, 1, 1, 0, (float) pitch);
}
public void playSwordCollision(boolean sound, boolean slowed) {if (sound == false) {return;}
double random = Math.random();
double pitch = .7 + (random*.5);
if(slowed == true){pitch = pitch - .5;}
sounds.play(swordcollision, 1, 1, 1, 0, (float) pitch);
}
public void playHadoken(boolean sFX) {
// TODO Auto-generated method stub
sounds.play(yell1, 1, 1, 1, 0, 1);
sounds.play(smokebomb, 1, 1, 1, 0, 1);
}
public void playDSCombo1(boolean sFX, boolean sloMoON) {
// TODO Auto-generated method stub
}
public void playJewel(boolean sFX, boolean sloMoON) {
// TODO Auto-generated method stub
}
public void playBlackPearl(boolean sFX, boolean sloMoON) {
// TODO Auto-generated method stub
}
}