public void update(int delta) { if (enabled) { if (musicPlaying == null) { musicDelay -= delta; if (musicDelay <= 0) { musicPlaying = music.get((int) (Math.random() * music.size())); musicPlaying.playAsMusic(1.0f, 1.0f, false); soundStore.setSoundVolume(0.5f); } } else if (!soundStore.isMusicPlaying()) { musicPlaying.stop(); musicDelay = (int) (Math.random() * 90000) + 30000; musicPlaying = null; soundStore.setSoundVolume(0.75f); } if (ambientMusicPlaying == null) { ambientMusicDelay -= delta; if (ambientMusicDelay <= 0) { ambientMusicPlaying = ambientMusic.get((int) (Math.random() * ambientMusic.size())); ambientMusicPlaying.playAsSoundEffect(1.0f, (float) Math.random() * 0.2f + 1f, false); } } else if (!ambientMusicPlaying.isPlaying()) { ambientMusicPlaying.stop(); ambientMusicDelay = (int) (Math.random() * 6000) + 1000; ambientMusicPlaying = null; } if (ambientNoisePlaying[0] == null) { ambientNoiseDelay[0] -= delta; if (ambientNoiseDelay[0] <= 0) { ambientNoisePlaying[0] = ambientNoise.get((int) (Math.random() * ambientNoise.size())); ambientNoisePlaying[0].playAsSoundEffect(1.0f, (float) Math.random() * 0.2f + 1f, false); } } else if (!ambientNoisePlaying[0].isPlaying()) { ambientNoisePlaying[0].stop(); ambientNoiseDelay[0] = (int) (Math.random() * 16000) + 1000; ambientNoisePlaying[0] = null; } if (ambientNoisePlaying[1] == null) { ambientNoiseDelay[1] -= delta; if (ambientNoiseDelay[1] <= 0) { ambientNoisePlaying[1] = ambientNoise.get((int) (Math.random() * ambientNoise.size())); ambientNoisePlaying[1].playAsSoundEffect(1.0f, (float) Math.random() * 0.2f + 1f, false); } } else if (!ambientNoisePlaying[1].isPlaying()) { ambientNoisePlaying[1].stop(); ambientNoiseDelay[1] = (int) (Math.random() * 16000) + 1000; ambientNoisePlaying[1] = null; } soundStore.poll(delta); } }