OK, I have a question about implementation strategy... I'm working on implementing customizable sound effects via a card script SVar "SoundEffect". However, that brings up an important point because the enumeration SoundEffectType is a finite thing, so it's impossible to dynamically add a new enumeration element or to spawn any instances of SoundEffectType that are not elements of the enumeration.
I thought of using the getCardSpecialEffect method in EventVisualizer to play that back, but that's a part of EventVisualizer, not a part of SoundSystem, so I thought it might be a bad idea to play sounds directly from there. Anyhow, here's the code I currently have in mind:
- Code: Select all
private static boolean getSpecificCardEffect(final Card c) {
if (null != c) {
String effect = c.getSVar("SoundEffect");
if (!effect.isEmpty()) {
AudioClip specialClip = new AudioClip(effect);
if (specialClip != null) {
specialClip.play();
}
return true;
}
}
return false;
}
I think this kind of breaks the purpose of EventVisualizer to abstract from direct calls to the sound system; however, just putting this code into SoundSystem as e.g.:
- Code: Select all
public boolean play(String resourceName) {
if (!resourceName.isEmpty()) {
AudioClip specialClip = new AudioClip(resourceName);
if (specialClip != null) {
specialClip.play();
return true;
}
}
return false;
}
Also won't work because in that case, a dependency will have to be introduced between EventVisualizer and SoundSystem, which, once again, will defeat the original purpose of abstraction.
I'm ready to listen to your suggestions, because, honestly, I'm out of any good ones.
- Agetian