def calcOneAmbientName(self, area): retval = None if area: parts = area.split('_') retval = SoundGlobals.getAmbientFromStr(parts[-1]) return retval
def calcOneAmbientName(self, area): retval = None if area: parts = area.split("_") retval = SoundGlobals.getAmbientFromStr(parts[-1]) return retval
def update(self): self.notify.debug('playlistLength = %d' % len(self.playlist)) if len(self.playlist) == 0: return None def compFunc(a, b): if a.priority < b.priority: return 1 elif a.priority > b.priority: return -1 return 0 self.playlist.sort(compFunc) self.notify.debug('playlist == ') for musicData in self.playlist: self.notify.debug(' musicData=%s' % musicData.name) if self.current == self.playlist[0]: return None elif self.current != None: if self.ambientDict[self.current.name].finalVolume > 0: self.notify.debug('calling requestFadeOut on %s' % self.current.name) self.requestFadeOut(self.current.name, removeFromPlaylist = False) self.current = self.playlist[0] if self.wantMusic: songLength = SoundGlobals.getMusicLength(self.current.name) if self.current.looping == False: if songLength is not None: taskMgr.doMethodLater(songLength, self.handleCurrentTrackFinished, 'currentTrackFinished', extraArgs = [ self.current.name]) else: self.notify.warning('non-looping song %s has no length!' % self.current.name) self.requestFadeIn(self.current.name, finalVolume = self.current.volume)
def calcAmbientNames(self): for i in xrange(2): area = self.areaNode[i] ambientName = self.calcOneAmbientName(area) self.ambientNames[i] = ambientName if not self.ambientNames[0] and not self.ambientNames[1]: self.ambientNames[1] = SoundGlobals.getAmbientFromStr(self.modelPath) self.notify.debug("Assuming self.ambientNames[1] = %s" % self.ambientNames[1])
def calcAmbientNames(self): for i in xrange(2): area = self.areaNode[i] ambientName = self.calcOneAmbientName(area) self.ambientNames[i] = ambientName if not self.ambientNames[0] and not self.ambientNames[1]: self.ambientNames[1] = SoundGlobals.getAmbientFromStr( self.modelPath) self.notify.debug('Assuming self.ambientNames[1] = %s' % self.ambientNames[1])
def cleanup(self): localAvatar.b_setInInvasion(False) base.options.setInvasion(False) PooledEffect.setGlobalLimit(200) messenger.send('grid-detail-changed', [base.options.terrain_detail_level]) base.options.setRuntimeSpecialEffects() render.clearFog() base.setNoticeSystem(1) if not localAvatar.belongsInJail(): base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA_COMBAT) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_INVASION_VICTORY) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_INVASION_DEFEAT) if not self.cleanedUp: islandMusic = SoundGlobals.getMainMusic(self.parentObj.uniqueId) if islandMusic and not localAvatar.belongsInJail(): base.musicMgr.request(islandMusic, priority=-1, volume=0.59999999999999998) for minimapObj in self.minimapObjs.values(): minimapObj.destroy() self.minimapObjs = {} if self.brigadeText: self.brigadeText.destroy() self.brigadeText = None if self.shipShowingIval: self.shipShowingIval.pause() self.shipShowingIval = None if self.shipHidingIval: self.shipHidingIval.pause() self.shipHidingIval = None if self.lerpFogIval: self.lerpFogIval.pause() self.lerpFogIval = None self.stopLightingEffects() taskMgr.remove('invasionWinCheer') if self.invasionShip: self.invasionShip.destroy() self.invasionShip = None if self.shipNode: self.shipNode.removeNode() self.shipNode = None self.cleanedUp = True
def cleanup(self): localAvatar.b_setInInvasion(False) base.options.setInvasion(False) PooledEffect.setGlobalLimit(200) messenger.send('grid-detail-changed', [ base.options.terrain_detail_level]) base.options.setRuntimeSpecialEffects() render.clearFog() base.setNoticeSystem(1) if not localAvatar.belongsInJail(): base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA_COMBAT) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_INVASION_VICTORY) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_INVASION_DEFEAT) if not self.cleanedUp: islandMusic = SoundGlobals.getMainMusic(self.parentObj.uniqueId) if islandMusic and not localAvatar.belongsInJail(): base.musicMgr.request(islandMusic, priority = -1, volume = 0.59999999999999998) for minimapObj in self.minimapObjs.values(): minimapObj.destroy() self.minimapObjs = { } if self.brigadeText: self.brigadeText.destroy() self.brigadeText = None if self.shipShowingIval: self.shipShowingIval.pause() self.shipShowingIval = None if self.shipHidingIval: self.shipHidingIval.pause() self.shipHidingIval = None if self.lerpFogIval: self.lerpFogIval.pause() self.lerpFogIval = None self.stopLightingEffects() taskMgr.remove('invasionWinCheer') if self.invasionShip: self.invasionShip.destroy() self.invasionShip = None if self.shipNode: self.shipNode.removeNode() self.shipNode = None self.cleanedUp = True
def requestSoundAndMusic(self): self.ambientName = SoundGlobals.getAmbientFromStr(self.modelPath) if not self.ambientName == SoundGlobals.AMBIENT_JUNGLE and self.ambientName == SoundGlobals.AMBIENT_CAVE or self.ambientName == SoundGlobals.AMBIENT_SWAMP: base.ambientMgr.requestFadeIn(self.ambientName, finalVolume = PiratesGlobals.DEFAULT_AMBIENT_VOLUME) if self.musicName: base.musicMgr.requestFadeOut(self.musicName) self.musicName = None if self.uniqueId == LocationIds.RAMBLESHACK_INSIDE and localAvatar.getTutorialState() < 2: self.musicName = SoundGlobals.MUSIC_COMBAT_A base.musicMgr.request(self.musicName, priority = 1, volume = 0.29999999999999999) elif 'tavern' in self.modelPath: self.musicName = random.choice((SoundGlobals.MUSIC_TAVERN_A, SoundGlobals.MUSIC_TAVERN_B, SoundGlobals.MUSIC_TAVERN_C)) base.musicMgr.request(self.musicName, priority = 1, volume = 0.5)
def offsetMusic(self, offset): if self.playlist and self.current: curMusic = self.ambientDict[self.current.name] if curMusic.activeInterval: curMusic.activeInterval.finish() curMusic.sfx.stop() curMusic.sfx.setTime(offset) curMusic.sfx.play() if self.current.looping == False: taskMgr.remove('currentTrackFinished') songLength = SoundGlobals.getMusicLength(self.current.name) if songLength is not None: taskMgr.doMethodLater(songLength - offset, self.handleCurrentTrackFinished, 'currentTrackFinished', extraArgs = [ self.current.name])
def stopCustomEffects(self): if self.envEffects: self.envEffects.delete() self.envEffects = None if 'swamp' in self.modelPath: base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_SWAMP, removeFromPlaylist = True) elif 'jungle' in self.modelPath: base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_JUNGLE, removeFromPlaylist = True) elif self.uniqueId in getLocationList(LocationIds.ANY_CAVE): base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_CAVE, removeFromPlaylist = True) base.musicMgr.requestFadeOut(SoundGlobals.getMainMusic(self.uniqueId), removeFromPlaylist = True) elif self.uniqueId == '1189479168.0sdnaik0': self.water.delete() self.water = None if base.cr.timeOfDayManager: base.cr.timeOfDayManager.removeTimeOfDayToggle('Day-Night Area Music')
def announceGenerate(self): DistributedObject.DistributedObject.announceGenerate(self) self.parentObj = self.getParentObj() self.linearFog = Fog('LinearInvasionFog') localAvatar.b_setInInvasion(True) base.options.setInvasion(True) PooledEffect.setGlobalLimit(20) messenger.send('grid-detail-changed', [Options.option_low]) base.options.setRuntimeSpecialEffects() base.setNoticeSystem(0) islandMusic = SoundGlobals.getMainMusic(self.parentObj.uniqueId) if islandMusic: base.musicMgr.requestFadeOut(islandMusic) base.musicMgr.request(SoundGlobals.MUSIC_TORMENTA, looping=True) numCapturePoints = InvasionGlobals.getTotalCapturePoints( self.holidayId) if base.launcher.getPhaseComplete(5): self.canPlaySfx = True else: self.canPlaySfx = False self.cleanedUp = False
def announceGenerate(self): DistributedObject.DistributedObject.announceGenerate(self) self.parentObj = self.getParentObj() self.linearFog = Fog('LinearInvasionFog') localAvatar.b_setInInvasion(True) base.options.setInvasion(True) PooledEffect.setGlobalLimit(20) messenger.send('grid-detail-changed', [ Options.option_low]) base.options.setRuntimeSpecialEffects() base.setNoticeSystem(0) islandMusic = SoundGlobals.getMainMusic(self.parentObj.uniqueId) if islandMusic: base.musicMgr.requestFadeOut(islandMusic) base.musicMgr.request(SoundGlobals.MUSIC_TORMENTA, looping = True) numCapturePoints = InvasionGlobals.getTotalCapturePoints(self.holidayId) if base.launcher.getPhaseComplete(5): self.canPlaySfx = True else: self.canPlaySfx = False self.cleanedUp = False
def __init__(self, gameObject): self.gameObject = gameObject MinigameFSM.__init__(self, 'PotionGameFSM') self.defaultTransitions = { 'Intro': [ 'Tutorial', 'RecipeSelect'], 'RecipeSelect': [ 'Tutorial', 'StartGame', 'Reset', 'ExitRequest', 'Exit'], 'Tutorial': [ 'Tutorial', 'RecipeSelect', 'Eval', 'Input', 'StartGame', 'SwitchRequest', 'ExitRequest', 'Reset', 'Exit'], 'ChestOpened': [ 'RecipeSelect', 'Eval', 'Input', 'Anim', 'Tutorial', 'ExitRequest', 'SwitchRequest', 'Results', 'Exit'], 'StartGame': [ 'Tutorial', 'Anim'], 'Anim': [ 'Eval', 'Reset', 'Results'], 'Eval': [ 'Results', 'Anim', 'Input', 'Tutorial', 'ExitRequest', 'SwitchRequest', 'Eval'], 'Input': [ 'Tutorial', 'StartGame', 'ExitRequest', 'SwitchRequest', 'Results', 'Anim', 'Eval', 'Reset', 'Exit'], 'Results': [ 'Reset', 'Exit', 'Tutorial', 'ExitRequest'], 'Reset': [ 'Reset', 'RecipeSelect', 'Tutorial', 'ExitRequest', 'SwitchRequest'], 'SwitchRequest': [ 'SwitchRequest', 'Reset', 'Eval', 'Tutorial', 'ExitRequest'], 'ExitRequest': [ 'ExitRequest', 'Exit', 'Eval', 'RecipeSelect', 'Tutorial', 'SwitchRequest'], 'Exit': [] } if not (self.Sfxs): PotionGameFSM.Sfxs = { 'Lose': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_LOSE), 'Win': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_WIN), 'Fill': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_FILL), 'Wrong': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_WRONG), 'NoDrop': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_CANTPLACE), 'Flip': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_FLIP), 'Drop1': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP), 'Drop2': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP_2), 'SoftDrop1': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP_SOFT), 'SoftDrop2': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP_SOFT_2), 'Match': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_MATCH), 'SoulMade': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_SOULMADE), 'SoulMatch': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_SOULMATCH) } self.matchMade = False self.ingredientMade = False self.gameStarted = False self.resultsShown = False self.animSeq = None if base.localAvatar.guiMgr.seaChestActive: base.localAvatar.guiMgr.hideSeaChest()
def __init__(self, gameObject): self.gameObject = gameObject MinigameFSM.__init__(self, 'PotionGameFSM') self.defaultTransitions = { 'Intro': ['Tutorial', 'RecipeSelect'], 'RecipeSelect': ['Tutorial', 'StartGame', 'Reset', 'ExitRequest', 'Exit'], 'Tutorial': [ 'Tutorial', 'RecipeSelect', 'Eval', 'Input', 'StartGame', 'SwitchRequest', 'ExitRequest', 'Reset', 'Exit' ], 'ChestOpened': [ 'RecipeSelect', 'Eval', 'Input', 'Anim', 'Tutorial', 'ExitRequest', 'SwitchRequest', 'Results', 'Exit' ], 'StartGame': ['Tutorial', 'Anim'], 'Anim': ['Eval', 'Reset', 'Results'], 'Eval': [ 'Results', 'Anim', 'Input', 'Tutorial', 'ExitRequest', 'SwitchRequest', 'Eval' ], 'Input': [ 'Tutorial', 'StartGame', 'ExitRequest', 'SwitchRequest', 'Results', 'Anim', 'Eval', 'Reset', 'Exit' ], 'Results': ['Reset', 'Exit', 'Tutorial', 'ExitRequest'], 'Reset': [ 'Reset', 'RecipeSelect', 'Tutorial', 'ExitRequest', 'SwitchRequest' ], 'SwitchRequest': ['SwitchRequest', 'Reset', 'Eval', 'Tutorial', 'ExitRequest'], 'ExitRequest': [ 'ExitRequest', 'Exit', 'Eval', 'RecipeSelect', 'Tutorial', 'SwitchRequest' ], 'Exit': [] } if not (self.Sfxs): PotionGameFSM.Sfxs = { 'Lose': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_LOSE), 'Win': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_WIN), 'Fill': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_FILL), 'Wrong': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_WRONG), 'NoDrop': SoundGlobals.loadSfx( SoundGlobals.SFX_MINIGAME_POTION_CANTPLACE), 'Flip': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_FLIP), 'Drop1': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP), 'Drop2': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_DROP_2), 'SoftDrop1': SoundGlobals.loadSfx( SoundGlobals.SFX_MINIGAME_POTION_DROP_SOFT), 'SoftDrop2': SoundGlobals.loadSfx( SoundGlobals.SFX_MINIGAME_POTION_DROP_SOFT_2), 'Match': SoundGlobals.loadSfx(SoundGlobals.SFX_MINIGAME_POTION_MATCH), 'SoulMade': SoundGlobals.loadSfx( SoundGlobals.SFX_MINIGAME_POTION_SOULMADE), 'SoulMatch': SoundGlobals.loadSfx( SoundGlobals.SFX_MINIGAME_POTION_SOULMATCH) } self.matchMade = False self.ingredientMade = False self.gameStarted = False self.resultsShown = False self.animSeq = None if base.localAvatar.guiMgr.seaChestActive: base.localAvatar.guiMgr.hideSeaChest()
def calcOneAmbientName(self, area): if not SoundGlobals.getAmbientFromStr(area.split('_')[-1]): pass return SoundGlobals.getAmbientFromStr(self.modelPath.split('_')[1])
def calcOneAmbientName(self, area): return SoundGlobals.getAmbientFromStr( area.split('_')[-1]) or SoundGlobals.getAmbientFromStr( self.modelPath.split('_')[1])
def initSfx(cls): for (name, effect) in cls.SfxNames.iteritems(): if name not in cls.sfx: sound = SoundGlobals.loadSfx(effect) if sound and sound.getActive(): cls.sfx[name] = sound
def startCustomEffects(self, interior=True, loadIslandMusic=False): if self.envEffects: self.envEffects.delete() self.envEffects = None if self.environment == 'Swamp': self.envEffects = SwampEffects.SwampEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False) base.musicMgr.request(SoundGlobals.MUSIC_SWAMP, priority=1, volume=0.6) elif self.environment == 'Jungle': self.envEffects = ForestEffects.ForestEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False) base.musicMgr.request(SoundGlobals.MUSIC_JUNGLE, priority=1, volume=0.6) elif self.environment == 'Cave': self.envEffects = CaveEffects.CaveEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=False) if self.uniqueId == LocationIds.RAVENS_COVE_MINE: base.musicMgr.request(SoundGlobals.getMainMusic(self.uniqueId), priority=1, volume=0.6) else: base.musicMgr.request(SoundGlobals.MUSIC_CAVE, priority=1, volume=0.6) elif self.uniqueId in ('1189479168.0sdnaik0', '1150922126.8akelts'): r = Reflection.getGlobalReflection() water = SeaPatch(self, reflection=r) water.loadSeaPatchFile('out.spf') self.water = water self.initializeIslandWaterParameters(self.geom) else: self.envEffects = EnvironmentEffects(self, self.modelPath) if interior: pass if loadIslandMusic: if not base.localAvatar.isInInvasion(): base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA) base.musicMgr.requestFadeOut( SoundGlobals.MUSIC_TORMENTA_COMBAT) def getCurrentIslandMusic(): priZeros = [] for music in base.musicMgr.playlist: if music.priority == 0: priZeros.append(music) return priZeros def changeMusic(music, pri): for priZero in getCurrentIslandMusic(): base.musicMgr.requestFadeOut(priZero.name, removeFromPlaylist=True) base.musicMgr.request(music, priority=0, volume=0.6) mainMusic = SoundGlobals.getMainMusic(self.uniqueId) altMusic = SoundGlobals.getAltMusic(self.uniqueId) if mainMusic and altMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True) todMgr = base.cr.timeOfDayManager todMgr.addTimeOfDayToggle('Day-Night Area Music', 6.0, 20.0, changeMusic, [mainMusic, 0], changeMusic, [altMusic, 0]) elif mainMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True) base.musicMgr.request(mainMusic, volume=0.6) elif altMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist=True) base.musicMgr.request(altMusic, volume=0.6) self.builder.initEffects() return
def startCustomEffects(self, interior = True, loadIslandMusic = False): if self.envEffects: self.envEffects.delete() self.envEffects = None if self.environment == 'Swamp': self.envEffects = SwampEffects.SwampEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False) base.musicMgr.request(SoundGlobals.MUSIC_SWAMP, priority = 1, volume = 0.59999999999999998) elif self.environment == 'Jungle': self.envEffects = ForestEffects.ForestEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False) base.musicMgr.request(SoundGlobals.MUSIC_JUNGLE, priority = 1, volume = 0.59999999999999998) elif self.environment == 'Cave': self.envEffects = CaveEffects.CaveEffects(self, self.modelPath) base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = False) if self.uniqueId == LocationIds.RAVENS_COVE_MINE: base.musicMgr.request(SoundGlobals.getMainMusic(self.uniqueId), priority = 1, volume = 0.59999999999999998) else: base.musicMgr.request(SoundGlobals.MUSIC_CAVE, priority = 1, volume = 0.59999999999999998) elif self.uniqueId in ('1189479168.0sdnaik0', '1150922126.8akelts'): r = Reflection.getGlobalReflection() water = SeaPatch(self, reflection = r) water.loadSeaPatchFile('out.spf') self.water = water self.initializeIslandWaterParameters(self.geom) else: self.envEffects = EnvironmentEffects(self, self.modelPath) if interior: pass if loadIslandMusic: if not base.localAvatar.isInInvasion(): base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA) base.musicMgr.requestFadeOut(SoundGlobals.MUSIC_TORMENTA_COMBAT) def getCurrentIslandMusic(): priZeros = [] for music in base.musicMgr.playlist: if music.priority == 0: priZeros.append(music) continue return priZeros def changeMusic(music, pri): for priZero in getCurrentIslandMusic(): base.musicMgr.requestFadeOut(priZero.name, removeFromPlaylist = True) base.musicMgr.request(music, priority = 0, volume = 0.59999999999999998) mainMusic = SoundGlobals.getMainMusic(self.uniqueId) altMusic = SoundGlobals.getAltMusic(self.uniqueId) if mainMusic and altMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True) todMgr = base.cr.timeOfDayManager todMgr.addTimeOfDayToggle('Day-Night Area Music', 6.0, 20.0, changeMusic, [ mainMusic, 0], changeMusic, [ altMusic, 0]) elif mainMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True) base.musicMgr.request(mainMusic, volume = 0.59999999999999998) elif altMusic: base.musicMgr.requestCurMusicFadeOut(removeFromPlaylist = True) base.musicMgr.request(altMusic, volume = 0.59999999999999998) self.builder.initEffects()