class CogdoFlyingPlayer(FSM):
    notify = DirectNotifyGlobal.directNotify.newCategory('CogdoFlyingPlayer')

    def __init__(self, toon):
        FSM.__init__(self, 'CogdoFlyingPlayer')
        self.toon = toon
        self.toon.reparentTo(render)
        self.legalEaglesTargeting = []
        self.activeBuffs = []
        self.initModels()
        self.initIntervals()
        self.netTimeSentToStartDeath = 0
        self.backpackState = -1
        self.lastBackpackState = -1
        self.lastPropellerSpinRate = Globals.Gameplay.NormalPropSpeed
        self.propellerSpinRate = Globals.Gameplay.NormalPropSpeed
        self.setFuelState(Globals.Gameplay.FuelStates.FuelNoPropeller)
        self.setOldFuelState(self.fuelState)
        CogdoFlyingPlayer.setBlades(
            self, Globals.Gameplay.FuelStates.FuelNoPropeller)
        self.setBackpackState(Globals.Gameplay.BackpackStates.Normal)

    def initModels(self):
        self.createPropeller()
        self.createRedTapeRing()

    def createPropeller(self):
        self.propellerSmoke = DustCloud.DustCloud(self.toon, wantSound=False)
        self.propellerSmoke.setBillboardPointEye()
        self.propellerSmoke.setBin('fixed', 5002)
        self.backpack = CogdoUtil.loadFlyingModel('propellerPack')
        self.backpack.setScale(1.3)
        self.backpack.setHpr(180.0, 0.0, 0.0)
        self.backpackInstances = []
        self.backpackTextureCard = CogdoUtil.loadFlyingModel(
            'propellerPack_card')
        parts = self.toon.getTorsoParts()
        for part in parts:
            backpackInstance = part.attachNewNode('backpackInstance')
            animal = self.toon.style.getAnimal()
            bodyScale = ToontownGlobals.toonBodyScales[animal]
            backpackHeight = ToontownGlobals.torsoHeightDict[
                self.toon.style.torso] * bodyScale - 0.5
            backpackInstance.setPos(0.0, -0.325, backpackHeight)
            self.backpackInstances.append(backpackInstance)
            self.backpack.instanceTo(backpackInstance)

        self.propInstances = []
        self.propeller = CogdoUtil.loadFlyingModel('toonPropeller')
        for part in self.backpackInstances:
            propInstance = part.attachNewNode('propInstance')
            propInstance.setPos(0.0, -0.275, 0.0)
            propInstance.setHpr(0.0, 20.0, 0.0)
            propInstance.setScale(1.0, 1.0, 1.25)
            self.propInstances.append(propInstance)
            self.propeller.instanceTo(propInstance)

        self.blades = []
        self.activeBlades = []
        index = 1
        blade = self.propeller.find('**/propeller%d' % index)
        while not blade.isEmpty():
            self.blades.append(blade)
            index += 1
            blade = self.propeller.find('**/propeller%d' % index)

        for blade in self.blades:
            self.activeBlades.append(blade)

    def createRedTapeRing(self):
        self.redTapeRing = CogdoUtil.loadFlyingModel('redTapeRing')
        self.redTapeRing.setTwoSided(True)
        self.redTapeRing.reparentTo(self.toon)
        self.redTapeRing.hide()
        self.redTapeRing.setScale(1.25)
        self.redTapeRing.setZ(self.toon.getHeight() / 2.0)

    def initIntervals(self):
        self.baseSpinDuration = 1.0
        self.propellerSpinLerp = LerpFunctionInterval(
            self.propeller.setH,
            fromData=0.0,
            toData=360.0,
            duration=self.baseSpinDuration,
            name='%s.propellerSpinLerp-%s' %
            (self.__class__.__name__, self.toon.doId))
        singleBlinkTime = Globals.Gameplay.TargetedWarningSingleBlinkTime
        blinkTime = Globals.Gameplay.TargetedWarningBlinkTime
        self.blinkLoop = Sequence(
            Wait(singleBlinkTime / 2.0),
            Func(self.setBackpackTexture,
                 Globals.Gameplay.BackpackStates.Attacked),
            Wait(singleBlinkTime / 2.0),
            Func(self.setBackpackTexture,
                 Globals.Gameplay.BackpackStates.Targeted),
            name='%s.blinkLoop-%s' % (self.__class__.__name__, self.toon.doId))
        self.blinkWarningSeq = Sequence(
            Func(self.blinkLoop.loop),
            Wait(blinkTime),
            Func(self.blinkLoop.clearToInitial),
            name='%s.blinkWarningSeq-%s' %
            (self.__class__.__name__, self.toon.doId))
        dur = Globals.Gameplay.BackpackRefuelDuration
        self.refuelSeq = Sequence(
            Func(self.setPropellerSpinRate, Globals.Gameplay.RefuelPropSpeed),
            Wait(dur),
            Func(self.returnBackpackToLastStateFunc),
            name='%s.refuelSeq-%s' % (self.__class__.__name__, self.toon.doId))
        scale = self.redTapeRing.getScale()
        pulseTime = 1.0
        self.pulseBubbleSeq = Parallel(
            Sequence(
                LerpFunctionInterval(self.redTapeRing.setScale,
                                     fromData=scale,
                                     toData=scale * 1.1,
                                     duration=pulseTime / 2.0,
                                     blendType='easeInOut'),
                LerpFunctionInterval(self.redTapeRing.setScale,
                                     fromData=scale * 1.1,
                                     toData=scale,
                                     duration=pulseTime / 2.0,
                                     blendType='easeInOut')),
            LerpHprInterval(self.redTapeRing,
                            pulseTime,
                            Vec3(360, 0, 0),
                            startHpr=Vec3(0, 0, 0)),
            name='%s.pulseBubbleSeq-%s' %
            (self.__class__.__name__, self.toon.doId))
        bouncePercent = 1.2
        scaleTime = 0.5
        scaleBounceTime = 0.25
        self.popUpBubbleLerp = LerpScaleInterval(self.redTapeRing,
                                                 scaleTime,
                                                 scale * bouncePercent,
                                                 startScale=0.0,
                                                 blendType='easeInOut')
        self.popUpBubbleSeq = Sequence(
            Func(self.updateLerpStartScale, self.popUpBubbleLerp,
                 self.redTapeRing),
            Func(self.redTapeRing.show),
            self.popUpBubbleLerp,
            LerpScaleInterval(self.redTapeRing,
                              scaleBounceTime,
                              scale,
                              startScale=scale * bouncePercent,
                              blendType='easeInOut'),
            Func(self.pulseBubbleSeq.loop),
            name='%s.popUpBubbleSeq-%s' %
            (self.__class__.__name__, self.toon.doId))
        self.removeBubbleLerp = LerpScaleInterval(self.redTapeRing,
                                                  scaleBounceTime,
                                                  scale * bouncePercent,
                                                  startScale=scale,
                                                  blendType='easeInOut')
        self.removeBubbleSeq = Sequence(
            Func(self.pulseBubbleSeq.clearToInitial),
            Func(self.updateLerpStartScale, self.removeBubbleLerp,
                 self.redTapeRing),
            self.removeBubbleLerp,
            LerpScaleInterval(self.redTapeRing,
                              scaleTime,
                              0.0,
                              startScale=scale * bouncePercent,
                              blendType='easeInOut'),
            Func(self.redTapeRing.hide),
            name='%s.removeBubbleSeq-%s' %
            (self.__class__.__name__, self.toon.doId))
        self.redTapeRing.setScale(0.0)
        self.deathInterval = Sequence(
            Parallel(
                LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)),
                LerpFunctionInterval(self.toon.setScale,
                                     fromData=1.0,
                                     toData=0.1,
                                     duration=1.0)),
            Func(self.toon.stash),
            name='%s.deathInterval-%s' %
            (self.__class__.__name__, self.toon.doId))
        self.spawnInterval = Sequence(
            Func(self.toon.stash),
            Func(self.resetToon),
            Wait(1.0),
            Func(self.toon.setAnimState, 'TeleportIn'),
            Func(self.toon.unstash),
            name='%s.spawnInterval-%s' %
            (self.__class__.__name__, self.toon.doId))
        singleBlinkTime = Globals.Gameplay.InvulSingleBlinkTime
        blinkTime = Globals.Gameplay.InvulBlinkTime
        invulBuffTime = Globals.Gameplay.InvulBuffTime
        self.blinkBubbleLoop = Sequence(
            LerpFunctionInterval(self.redTapeRing.setAlphaScale,
                                 fromData=1.0,
                                 toData=0.0,
                                 duration=singleBlinkTime / 2.0,
                                 blendType='easeInOut'),
            LerpFunctionInterval(self.redTapeRing.setAlphaScale,
                                 fromData=0.0,
                                 toData=1.0,
                                 duration=singleBlinkTime / 2.0,
                                 blendType='easeInOut'),
            name='%s.blinkBubbleLoop-%s' %
            (self.__class__.__name__, self.toon.doId))
        self.blinkBubbleSeq = Sequence(
            Wait(invulBuffTime - blinkTime),
            Func(self.blinkBubbleLoop.loop),
            Wait(blinkTime),
            Func(self.blinkBubbleLoop.finish),
            name='%s.blinkBubbleSeq-%s' %
            (self.__class__.__name__, self.toon.doId))

    def returnBackpackToLastStateFunc(self):
        if self.backpackState == Globals.Gameplay.BackpackStates.Refuel:
            self.returnBackpackToLastState()

    def setPropellerSpinRateFunc(self):
        if self.propellerSpinRate == Globals.Gameplay.RefuelPropSpeed:
            self.setPropellerSpinRate(self.lastPropellerSpinRate)

    def returnBackpackToLastState(self):
        self.setBackpackState(self.lastBackpackState)

    def setBackpackState(self, state):
        if state == self.backpackState:
            return
        self.lastBackpackState = self.backpackState
        self.backpackState = state
        self.blinkWarningSeq.clearToInitial()
        self.refuelSeq.clearToInitial()
        self.blinkLoop.clearToInitial()
        if self.lastBackpackState == Globals.Gameplay.BackpackStates.Refuel:
            self.setPropellerSpinRateFunc()
        if state in Globals.Gameplay.BackpackStates:
            if state == Globals.Gameplay.BackpackStates.Normal:
                pass
            elif state == Globals.Gameplay.BackpackStates.Targeted:
                pass
            elif state == Globals.Gameplay.BackpackStates.Refuel:
                self.refuelSeq.start()
            elif state == Globals.Gameplay.BackpackStates.Attacked:
                self.blinkWarningSeq.start()
            self.setBackpackTexture(state)

    def setBackpackTexture(self, state):
        texName = Globals.Gameplay.BackpackState2TextureName[state]
        tex = self.backpackTextureCard.findTexture(texName)
        self.backpack.setTexture(tex, 1)

    def updateLerpStartScale(self, lerp, nodepath):
        lerp.setStartScale(nodepath.getScale())

    def handleEnterGatherable(self, gatherable, elapsedTime):
        if gatherable.type == Globals.Level.GatherableTypes.InvulPowerup:
            self.blinkBubbleSeq.clearToInitial()
            self.blinkBubbleSeq.start(elapsedTime)
            self.removeBubbleSeq.clearToInitial()
            self.popUpBubbleSeq.start()
            if gatherable.type not in self.activeBuffs:
                self.activeBuffs.append(gatherable.type)
        elif gatherable.type == Globals.Level.GatherableTypes.Propeller:
            self.setBackpackState(Globals.Gameplay.BackpackStates.Refuel)

    def handleDebuffPowerup(self, pickupType, elapsedTime):
        if pickupType == Globals.Level.GatherableTypes.InvulPowerup:
            self.blinkBubbleSeq.finish()
            self.popUpBubbleSeq.clearToInitial()
            self.removeBubbleSeq.start()
            if pickupType in self.activeBuffs:
                self.activeBuffs.remove(pickupType)

    def isBuffActive(self, pickupType):
        if pickupType in self.activeBuffs:
            return True
        return False

    def isInvulnerable(self):
        if Globals.Level.GatherableTypes.InvulPowerup in self.activeBuffs:
            return True
        return False

    def setFuelState(self, fuelState):
        self.fuelState = fuelState

    def setOldFuelState(self, fuelState):
        self.oldFuelState = fuelState

    def hasFuelStateChanged(self):
        if self.fuelState != self.oldFuelState:
            return True
        else:
            return False

    def updatePropellerSmoke(self):
        if not self.hasFuelStateChanged():
            return
        if self.fuelState in [
                Globals.Gameplay.FuelStates.FuelNoPropeller,
                Globals.Gameplay.FuelStates.FuelNormal
        ]:
            self.propellerSmoke.stop()
        elif self.fuelState in [
                Globals.Gameplay.FuelStates.FuelVeryLow,
                Globals.Gameplay.FuelStates.FuelEmpty
        ]:
            self.propellerSmoke.stop()
            self.propellerSmoke.setScale(0.25)
            self.propellerSmoke.setZ(self.toon.getHeight() + 2.5)
            self.propellerSmoke.loop(rate=48)
        elif self.fuelState in [Globals.Gameplay.FuelStates.FuelLow]:
            self.propellerSmoke.stop()
            self.propellerSmoke.setScale(0.0825)
            self.propellerSmoke.setZ(self.toon.getHeight() + 2.0)
            self.propellerSmoke.loop(rate=24)

    def resetBlades(self):
        self.setBlades(len(self.blades))

    def setAsLegalEagleTarget(self, legalEagle):
        if legalEagle not in self.legalEaglesTargeting:
            self.legalEaglesTargeting.append(legalEagle)

    def removeAsLegalEagleTarget(self, legalEagle):
        if legalEagle in self.legalEaglesTargeting:
            self.legalEaglesTargeting.remove(legalEagle)

    def isLegalEagleTarget(self):
        if len(self.legalEaglesTargeting) > 0:
            return True
        else:
            return False

    def setBlades(self, fuelState):
        if fuelState not in Globals.Gameplay.FuelStates:
            return
        numBlades = fuelState - 1
        if len(self.activeBlades) != numBlades:
            for i in xrange(len(self.activeBlades)):
                blade = self.activeBlades.pop()
                blade.stash()

            if numBlades > len(self.blades):
                numBlades = len(self.blades)
            if numBlades > 0:
                for i in xrange(numBlades):
                    blade = self.blades[i]
                    self.activeBlades.append(blade)
                    blade.unstash()

            if fuelState == Globals.Gameplay.FuelStates.FuelNoPropeller:
                for prop in self.propInstances:
                    prop.hide()

            else:
                for prop in self.propInstances:
                    prop.show()

            self.setFuelState(fuelState)
            self.updatePropellerSmoke()
            self.setOldFuelState(self.fuelState)

    def bladeLost(self):
        if len(self.activeBlades) > 0:
            blade = self.activeBlades.pop()
            blade.stash()
            self.setFuelState(len(self.activeBlades) + 1)
            self.updatePropellerSmoke()
            self.setOldFuelState(self.fuelState)

    def setPropellerSpinRate(self, newRate):
        self.lastPropellerSpinRate = self.propellerSpinRate
        self.propellerSpinRate = newRate
        self.notify.debug(
            '(%s) New propeller speed:%s, old propeller speed:%s' %
            (self.toon.doId, self.propellerSpinRate,
             self.lastPropellerSpinRate))
        self.propellerSpinLerp.setPlayRate(newRate)

    def died(self, elapsedTime):
        self.deathInterval.start(elapsedTime)
        self.propellerSmoke.stop()

    def spawn(self, elapsedTime):
        self.spawnInterval.start(elapsedTime)

    def resetToon(self):
        self.toon.setScale(1.0)

    def enable(self):
        self.toon.setAnimState('Happy', 1.0)
        self.toon.setForceJumpIdle(True)
        self.toon.setSpeed(0, 0)
        self.setPropellerSpinRate(Globals.Gameplay.NormalPropSpeed)
        self.propellerSpinLerp.loop()

    def disable(self):
        pass

    def unload(self):
        self.ignoreAll()
        if self.toon:
            self.toon.showName()
        self.backpackTextureCard.removeNode()
        del self.backpackTextureCard
        self.refuelSeq.clearToInitial()
        del self.refuelSeq
        self.pulseBubbleSeq.clearToInitial()
        del self.pulseBubbleSeq
        self.blinkBubbleLoop.clearToInitial()
        del self.blinkBubbleLoop
        self.blinkBubbleSeq.clearToInitial()
        del self.blinkBubbleSeq
        self.popUpBubbleLerp.clearToInitial()
        del self.popUpBubbleLerp
        self.popUpBubbleSeq.clearToInitial()
        del self.popUpBubbleSeq
        self.removeBubbleLerp.clearToInitial()
        del self.removeBubbleLerp
        self.removeBubbleSeq.clearToInitial()
        del self.removeBubbleSeq
        self.propellerSmoke.destroy()
        del self.propellerSmoke
        self.blinkWarningSeq.clearToInitial()
        del self.blinkWarningSeq
        self.blinkLoop.clearToInitial()
        del self.blinkLoop
        self.redTapeRing.removeNode()
        del self.redTapeRing
        self.propellerSpinLerp.clearToInitial()
        del self.propellerSpinLerp
        for prop in self.propInstances:
            prop.removeNode()

        del self.propInstances[:]
        self.propeller.removeNode()
        del self.propeller
        for backpack in self.backpackInstances:
            backpack.removeNode()

        del self.backpackInstances[:]
        self.backpack.removeNode()
        del self.backpack
        del self.activeBuffs[:]
        del self.legalEaglesTargeting[:]
        del self.toon
        self.toon = None
        if self.deathInterval:
            self.deathInterval.clearToInitial()
            self.deathInterval = None
        if self.spawnInterval:
            self.spawnInterval.clearToInitial()
            self.spawnInterval = None
        return

    def start(self):
        swapAvatarShadowPlacer(self.toon,
                               self.toon.uniqueName('toonShadowPlacer'))
        self.toon.startSmooth()

    def exit(self):
        self.toon.setForceJumpIdle(False)
        self.propellerSmoke.reparentTo(hidden)
        self.propellerSmoke.stop()
        if self.toon:
            CogdoFlyingPlayer.resetToon(self)
            self.toon.setActiveShadow(0)
            self.toon.deleteDropShadow()
            self.toon.initializeDropShadow()
            self.toon.setActiveShadow(1)
        else:
            self.notify.warning("There's no toon in offstage, this is bad!")
Пример #2
0
class CogdoFlyingPlayer(FSM):
    notify = DirectNotifyGlobal.directNotify.newCategory('CogdoFlyingPlayer')

    def __init__(self, toon):
        FSM.__init__(self, 'CogdoFlyingPlayer')
        self.toon = toon
        self.toon.reparentTo(render)
        self.legalEaglesTargeting = []
        self.activeBuffs = []
        self.initModels()
        self.initIntervals()
        self.netTimeSentToStartDeath = 0
        self.backpackState = -1
        self.lastBackpackState = -1
        self.lastPropellerSpinRate = Globals.Gameplay.NormalPropSpeed
        self.propellerSpinRate = Globals.Gameplay.NormalPropSpeed
        self.setFuelState(Globals.Gameplay.FuelStates.FuelNoPropeller)
        self.setOldFuelState(self.fuelState)
        CogdoFlyingPlayer.setBlades(self, Globals.Gameplay.FuelStates.FuelNoPropeller)
        self.setBackpackState(Globals.Gameplay.BackpackStates.Normal)

    def initModels(self):
        self.createPropeller()
        self.createRedTapeRing()

    def createPropeller(self):
        self.propellerSmoke = DustCloud.DustCloud(self.toon, wantSound=False)
        self.propellerSmoke.setBillboardPointEye()
        self.propellerSmoke.setBin('fixed', 5002)
        self.backpack = CogdoUtil.loadFlyingModel('propellerPack')
        self.backpack.setScale(1.3)
        self.backpack.setHpr(180.0, 0.0, 0.0)
        self.backpackInstances = []
        self.backpackTextureCard = CogdoUtil.loadFlyingModel('propellerPack_card')
        parts = self.toon.getTorsoParts()
        for part in parts:
            backpackInstance = part.attachNewNode('backpackInstance')
            animal = self.toon.style.getAnimal()
            bodyScale = ToontownGlobals.toonBodyScales[animal]
            backpackHeight = ToontownGlobals.torsoHeightDict[self.toon.style.torso] * bodyScale - 0.5
            backpackInstance.setPos(0.0, -0.325, backpackHeight)
            self.backpackInstances.append(backpackInstance)
            self.backpack.instanceTo(backpackInstance)

        self.propInstances = []
        self.propeller = CogdoUtil.loadFlyingModel('toonPropeller')
        for part in self.backpackInstances:
            propInstance = part.attachNewNode('propInstance')
            propInstance.setPos(0.0, -0.275, 0.0)
            propInstance.setHpr(0.0, 20.0, 0.0)
            propInstance.setScale(1.0, 1.0, 1.25)
            self.propInstances.append(propInstance)
            self.propeller.instanceTo(propInstance)

        self.blades = []
        self.activeBlades = []
        index = 1
        blade = self.propeller.find('**/propeller%d' % index)
        while not blade.isEmpty():
            self.blades.append(blade)
            index += 1
            blade = self.propeller.find('**/propeller%d' % index)

        for blade in self.blades:
            self.activeBlades.append(blade)

    def createRedTapeRing(self):
        self.redTapeRing = CogdoUtil.loadFlyingModel('redTapeRing')
        self.redTapeRing.setTwoSided(True)
        self.redTapeRing.reparentTo(self.toon)
        self.redTapeRing.hide()
        self.redTapeRing.setScale(1.25)
        self.redTapeRing.setZ(self.toon.getHeight() / 2.0)

    def initIntervals(self):
        self.baseSpinDuration = 1.0
        self.propellerSpinLerp = LerpFunctionInterval(self.propeller.setH, fromData=0.0, toData=360.0, duration=self.baseSpinDuration, name='%s.propellerSpinLerp-%s' % (self.__class__.__name__, self.toon.doId))
        singleBlinkTime = Globals.Gameplay.TargetedWarningSingleBlinkTime
        blinkTime = Globals.Gameplay.TargetedWarningBlinkTime
        self.blinkLoop = Sequence(Wait(singleBlinkTime / 2.0), Func(self.setBackpackTexture, Globals.Gameplay.BackpackStates.Attacked), Wait(singleBlinkTime / 2.0), Func(self.setBackpackTexture, Globals.Gameplay.BackpackStates.Targeted), name='%s.blinkLoop-%s' % (self.__class__.__name__, self.toon.doId))
        self.blinkWarningSeq = Sequence(Func(self.blinkLoop.loop), Wait(blinkTime), Func(self.blinkLoop.clearToInitial), name='%s.blinkWarningSeq-%s' % (self.__class__.__name__, self.toon.doId))
        dur = Globals.Gameplay.BackpackRefuelDuration
        self.refuelSeq = Sequence(Func(self.setPropellerSpinRate, Globals.Gameplay.RefuelPropSpeed), Wait(dur), Func(self.returnBackpackToLastStateFunc), name='%s.refuelSeq-%s' % (self.__class__.__name__, self.toon.doId))
        scale = self.redTapeRing.getScale()
        pulseTime = 1.0
        self.pulseBubbleSeq = Parallel(Sequence(LerpFunctionInterval(self.redTapeRing.setScale, fromData=scale, toData=scale * 1.1, duration=pulseTime / 2.0, blendType='easeInOut'), LerpFunctionInterval(self.redTapeRing.setScale, fromData=scale * 1.1, toData=scale, duration=pulseTime / 2.0, blendType='easeInOut')), LerpHprInterval(self.redTapeRing, pulseTime, Vec3(360, 0, 0), startHpr=Vec3(0, 0, 0)), name='%s.pulseBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId))
        bouncePercent = 1.2
        scaleTime = 0.5
        scaleBounceTime = 0.25
        self.popUpBubbleLerp = LerpScaleInterval(self.redTapeRing, scaleTime, scale * bouncePercent, startScale=0.0, blendType='easeInOut')
        self.popUpBubbleSeq = Sequence(Func(self.updateLerpStartScale, self.popUpBubbleLerp, self.redTapeRing), Func(self.redTapeRing.show), self.popUpBubbleLerp, LerpScaleInterval(self.redTapeRing, scaleBounceTime, scale, startScale=scale * bouncePercent, blendType='easeInOut'), Func(self.pulseBubbleSeq.loop), name='%s.popUpBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId))
        self.removeBubbleLerp = LerpScaleInterval(self.redTapeRing, scaleBounceTime, scale * bouncePercent, startScale=scale, blendType='easeInOut')
        self.removeBubbleSeq = Sequence(Func(self.pulseBubbleSeq.clearToInitial), Func(self.updateLerpStartScale, self.removeBubbleLerp, self.redTapeRing), self.removeBubbleLerp, LerpScaleInterval(self.redTapeRing, scaleTime, 0.0, startScale=scale * bouncePercent, blendType='easeInOut'), Func(self.redTapeRing.hide), name='%s.removeBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId))
        self.redTapeRing.setScale(0.0)
        self.deathInterval = Sequence(Parallel(LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)), LerpFunctionInterval(self.toon.setScale, fromData=1.0, toData=0.1, duration=1.0)), Func(self.toon.stash), name='%s.deathInterval-%s' % (self.__class__.__name__, self.toon.doId))
        self.spawnInterval = Sequence(Func(self.toon.stash), Func(self.resetToon), Wait(1.0), Func(self.toon.setAnimState, 'TeleportIn'), Func(self.toon.unstash), name='%s.spawnInterval-%s' % (self.__class__.__name__, self.toon.doId))
        singleBlinkTime = Globals.Gameplay.InvulSingleBlinkTime
        blinkTime = Globals.Gameplay.InvulBlinkTime
        invulBuffTime = Globals.Gameplay.InvulBuffTime
        self.blinkBubbleLoop = Sequence(LerpFunctionInterval(self.redTapeRing.setAlphaScale, fromData=1.0, toData=0.0, duration=singleBlinkTime / 2.0, blendType='easeInOut'), LerpFunctionInterval(self.redTapeRing.setAlphaScale, fromData=0.0, toData=1.0, duration=singleBlinkTime / 2.0, blendType='easeInOut'), name='%s.blinkBubbleLoop-%s' % (self.__class__.__name__, self.toon.doId))
        self.blinkBubbleSeq = Sequence(Wait(invulBuffTime - blinkTime), Func(self.blinkBubbleLoop.loop), Wait(blinkTime), Func(self.blinkBubbleLoop.finish), name='%s.blinkBubbleSeq-%s' % (self.__class__.__name__, self.toon.doId))

    def returnBackpackToLastStateFunc(self):
        if self.backpackState == Globals.Gameplay.BackpackStates.Refuel:
            self.returnBackpackToLastState()

    def setPropellerSpinRateFunc(self):
        if self.propellerSpinRate == Globals.Gameplay.RefuelPropSpeed:
            self.setPropellerSpinRate(self.lastPropellerSpinRate)

    def returnBackpackToLastState(self):
        self.setBackpackState(self.lastBackpackState)

    def setBackpackState(self, state):
        if state == self.backpackState:
            return
        self.lastBackpackState = self.backpackState
        self.backpackState = state
        self.blinkWarningSeq.clearToInitial()
        self.refuelSeq.clearToInitial()
        self.blinkLoop.clearToInitial()
        if self.lastBackpackState == Globals.Gameplay.BackpackStates.Refuel:
            self.setPropellerSpinRateFunc()
        if state in Globals.Gameplay.BackpackStates:
            if state == Globals.Gameplay.BackpackStates.Normal:
                pass
            elif state == Globals.Gameplay.BackpackStates.Targeted:
                pass
            elif state == Globals.Gameplay.BackpackStates.Refuel:
                self.refuelSeq.start()
            elif state == Globals.Gameplay.BackpackStates.Attacked:
                self.blinkWarningSeq.start()
            self.setBackpackTexture(state)

    def setBackpackTexture(self, state):
        texName = Globals.Gameplay.BackpackState2TextureName[state]
        tex = self.backpackTextureCard.findTexture(texName)
        self.backpack.setTexture(tex, 1)

    def updateLerpStartScale(self, lerp, nodepath):
        lerp.setStartScale(nodepath.getScale())

    def handleEnterGatherable(self, gatherable, elapsedTime):
        if gatherable.type == Globals.Level.GatherableTypes.InvulPowerup:
            self.blinkBubbleSeq.clearToInitial()
            self.blinkBubbleSeq.start(elapsedTime)
            self.removeBubbleSeq.clearToInitial()
            self.popUpBubbleSeq.start()
            if gatherable.type not in self.activeBuffs:
                self.activeBuffs.append(gatherable.type)
        elif gatherable.type == Globals.Level.GatherableTypes.Propeller:
            self.setBackpackState(Globals.Gameplay.BackpackStates.Refuel)

    def handleDebuffPowerup(self, pickupType, elapsedTime):
        if pickupType == Globals.Level.GatherableTypes.InvulPowerup:
            self.blinkBubbleSeq.finish()
            self.popUpBubbleSeq.clearToInitial()
            self.removeBubbleSeq.start()
            if pickupType in self.activeBuffs:
                self.activeBuffs.remove(pickupType)

    def isBuffActive(self, pickupType):
        if pickupType in self.activeBuffs:
            return True
        return False

    def isInvulnerable(self):
        if Globals.Level.GatherableTypes.InvulPowerup in self.activeBuffs:
            return True
        return False

    def setFuelState(self, fuelState):
        self.fuelState = fuelState

    def setOldFuelState(self, fuelState):
        self.oldFuelState = fuelState

    def hasFuelStateChanged(self):
        if self.fuelState != self.oldFuelState:
            return True
        else:
            return False

    def updatePropellerSmoke(self):
        if not self.hasFuelStateChanged():
            return
        if self.fuelState in [Globals.Gameplay.FuelStates.FuelNoPropeller, Globals.Gameplay.FuelStates.FuelNormal]:
            self.propellerSmoke.stop()
        elif self.fuelState in [Globals.Gameplay.FuelStates.FuelVeryLow, Globals.Gameplay.FuelStates.FuelEmpty]:
            self.propellerSmoke.stop()
            self.propellerSmoke.setScale(0.25)
            self.propellerSmoke.setZ(self.toon.getHeight() + 2.5)
            self.propellerSmoke.loop(rate=48)
        elif self.fuelState in [Globals.Gameplay.FuelStates.FuelLow]:
            self.propellerSmoke.stop()
            self.propellerSmoke.setScale(0.0825)
            self.propellerSmoke.setZ(self.toon.getHeight() + 2.0)
            self.propellerSmoke.loop(rate=24)

    def resetBlades(self):
        self.setBlades(len(self.blades))

    def setAsLegalEagleTarget(self, legalEagle):
        if legalEagle not in self.legalEaglesTargeting:
            self.legalEaglesTargeting.append(legalEagle)

    def removeAsLegalEagleTarget(self, legalEagle):
        if legalEagle in self.legalEaglesTargeting:
            self.legalEaglesTargeting.remove(legalEagle)

    def isLegalEagleTarget(self):
        if len(self.legalEaglesTargeting) > 0:
            return True
        else:
            return False

    def setBlades(self, fuelState):
        if fuelState not in Globals.Gameplay.FuelStates:
            return
        numBlades = fuelState - 1
        if len(self.activeBlades) != numBlades:
            for i in xrange(len(self.activeBlades)):
                blade = self.activeBlades.pop()
                blade.stash()

            if numBlades > len(self.blades):
                numBlades = len(self.blades)
            if numBlades > 0:
                for i in xrange(numBlades):
                    blade = self.blades[i]
                    self.activeBlades.append(blade)
                    blade.unstash()

            if fuelState == Globals.Gameplay.FuelStates.FuelNoPropeller:
                for prop in self.propInstances:
                    prop.hide()

            else:
                for prop in self.propInstances:
                    prop.show()

            self.setFuelState(fuelState)
            self.updatePropellerSmoke()
            self.setOldFuelState(self.fuelState)

    def bladeLost(self):
        if len(self.activeBlades) > 0:
            blade = self.activeBlades.pop()
            blade.stash()
            self.setFuelState(len(self.activeBlades) + 1)
            self.updatePropellerSmoke()
            self.setOldFuelState(self.fuelState)

    def setPropellerSpinRate(self, newRate):
        self.lastPropellerSpinRate = self.propellerSpinRate
        self.propellerSpinRate = newRate
        self.notify.debug('(%s) New propeller speed:%s, old propeller speed:%s' % (self.toon.doId, self.propellerSpinRate, self.lastPropellerSpinRate))
        self.propellerSpinLerp.setPlayRate(newRate)

    def died(self, elapsedTime):
        self.deathInterval.start(elapsedTime)
        self.propellerSmoke.stop()

    def spawn(self, elapsedTime):
        self.spawnInterval.start(elapsedTime)

    def resetToon(self):
        self.toon.setScale(1.0)

    def enable(self):
        self.toon.setAnimState('Happy', 1.0)
        self.toon.setForceJumpIdle(True)
        self.toon.setSpeed(0, 0)
        self.setPropellerSpinRate(Globals.Gameplay.NormalPropSpeed)
        self.propellerSpinLerp.loop()

    def disable(self):
        pass

    def unload(self):
        self.ignoreAll()
        if self.toon:
            self.toon.showName()
        self.backpackTextureCard.removeNode()
        del self.backpackTextureCard
        self.refuelSeq.clearToInitial()
        del self.refuelSeq
        self.pulseBubbleSeq.clearToInitial()
        del self.pulseBubbleSeq
        self.blinkBubbleLoop.clearToInitial()
        del self.blinkBubbleLoop
        self.blinkBubbleSeq.clearToInitial()
        del self.blinkBubbleSeq
        self.popUpBubbleLerp.clearToInitial()
        del self.popUpBubbleLerp
        self.popUpBubbleSeq.clearToInitial()
        del self.popUpBubbleSeq
        self.removeBubbleLerp.clearToInitial()
        del self.removeBubbleLerp
        self.removeBubbleSeq.clearToInitial()
        del self.removeBubbleSeq
        self.propellerSmoke.destroy()
        del self.propellerSmoke
        self.blinkWarningSeq.clearToInitial()
        del self.blinkWarningSeq
        self.blinkLoop.clearToInitial()
        del self.blinkLoop
        self.redTapeRing.removeNode()
        del self.redTapeRing
        self.propellerSpinLerp.clearToInitial()
        del self.propellerSpinLerp
        for prop in self.propInstances:
            prop.removeNode()

        del self.propInstances[:]
        self.propeller.removeNode()
        del self.propeller
        for backpack in self.backpackInstances:
            backpack.removeNode()

        del self.backpackInstances[:]
        self.backpack.removeNode()
        del self.backpack
        del self.activeBuffs[:]
        del self.legalEaglesTargeting[:]
        del self.toon
        self.toon = None
        if self.deathInterval:
            self.deathInterval.clearToInitial()
            self.deathInterval = None
        if self.spawnInterval:
            self.spawnInterval.clearToInitial()
            self.spawnInterval = None
        return

    def start(self):
        swapAvatarShadowPlacer(self.toon, self.toon.uniqueName('toonShadowPlacer'))
        self.toon.startSmooth()

    def exit(self):
        self.toon.setForceJumpIdle(False)
        self.propellerSmoke.reparentTo(hidden)
        self.propellerSmoke.stop()
        if self.toon:
            CogdoFlyingPlayer.resetToon(self)
            self.toon.setActiveShadow(0)
            self.toon.deleteDropShadow()
            self.toon.initializeDropShadow()
            self.toon.setActiveShadow(1)
        else:
            self.notify.warning("There's no toon in offstage, this is bad!")
Пример #3
0
class CogdoFlyingLocalPlayer(CogdoFlyingPlayer):
    def __init__(self, game, toon):
        CogdoFlyingPlayer.__init__(self, toon)
        self.velocity = Vec3(0.0, 0.0, 0.0)
        self.lastVelocity = Vec3(0.0, 0.0, 0.0)
        self.instantaneousVelocity = Vec3(0.0, 0.0, 0.0)
        self.oldPos = Vec3(0.0, 0.0, 0.0)
        self.game = game
        self.inputMgr = CogdoFlyingInputManager()
        self.cameraMgr = CogdoFlyingCameraManager(self, camera, render)
        self.guiMgr = CogdoFlyingGuiManager(self)

        self.checkpointPlatform = None

        self.fuel = 0.0
        self.props = {}

        self.initModels()
        self.initIntervals()

        self.propSound = base.loadSfx('phase_4/audio/sfx/TB_propeller.wav')

    def initModels(self):
        # We place the propeller prop on all 3 lod's
        self.placePropeller('1000')
        self.placePropeller('500')
        self.placePropeller('250')

    def placePropeller(self, lod):
        prop = BattleProps.globalPropPool.getProp('propeller')
        prop.setScale(1.1)

        self.props[lod] = prop

        head = base.localAvatar.getPart('head', lod)

        if head.isEmpty():
            return

        prop.reparentTo(head)
        animal = base.localAvatar.style.getAnimal()
        if (animal == 'dog') or (animal == 'bear') or (animal == 'horse'):
            torso = base.localAvatar.style.torso
            legs = base.localAvatar.style.legs
            if ((torso == 'ls') or (torso == 'ld')) and (legs == 'l'):
                prop.setZ(-1.3)
            else:
                prop.setZ(-0.7)
        elif (animal == 'mouse') or (animal == 'duck'):
            prop.setZ(0.5)
        elif (animal == 'cat'):
            prop.setZ(-0.3)
        elif (animal == 'rabbit'):
            prop.setZ(-0.5)
        elif (animal == 'monkey'):
            prop.setZ(0.3)
        elif (animal == 'pig'):
            prop.setZ(-0.7)

    def initIntervals(self):
        self.deathInterval = Sequence(
            Func(self.inputMgr.disable),
            Parallel(
                LerpHprInterval(self.toon, 1.0, Vec3(720, 0, 0)),
                LerpFunctionInterval(self.toon.setScale,
                                     fromData=1.0,
                                     toData=0.0,
                                     duration=1.0)),
            Func(self.resetToon),
            Wait(
                0.5
            ),  # Added this because with no pause here the FreeFly prop sound was attached to the old toon pos
            Func(self.request, "FreeFly"),
            name="%s.deathInterval" % (self.__class__.__name__))

        self.refuelInterval = Sequence(
            Func(self.guiMgr.setRefuelLerpFromData),
            Func(self.guiMgr.messageLabel.unstash),
            Parallel(
                self.guiMgr.refuelLerp,
                Sequence(
                    Func(self.guiMgr.setMessageLabelText, "Refueling"),
                    Wait(0.5),
                    Func(self.guiMgr.setMessageLabelText, "Refueling."),
                    Wait(0.5),
                    Func(self.guiMgr.setMessageLabelText, "Refueling.."),
                    Wait(0.5),
                    Func(self.guiMgr.setMessageLabelText, "Refueling..."),
                    Wait(0.5),
                ),
            ),
            Func(self.resetFuel),
            Func(self.guiMgr.messageLabel.stash),
            Func(self.request, "FreeFly"),
            name="%s.refuelInterval" % (self.__class__.__name__))

        self.waitingForWinInterval = Sequence(
            Func(self.guiMgr.setMessageLabelText, "Waiting for other players"),
            Wait(1.5),
            Func(self.guiMgr.setMessageLabelText,
                 "Waiting for other players."),
            Wait(1.5),
            Func(self.guiMgr.setMessageLabelText,
                 "Waiting for other players.."),
            Wait(1.5),
            Func(self.guiMgr.setMessageLabelText,
                 "Waiting for other players..."),
            Wait(1.5),
            name="%s.waitingForWinInterval" % (self.__class__.__name__))

        self.winInterval = Sequence(Func(self.guiMgr.setMessageLabelText, ""),
                                    Wait(1.0),
                                    Func(self.guiMgr.winLabel.unstash),
                                    Wait(2.0),
                                    Func(self.guiMgr.winLabel.stash),
                                    Wait(0.5),
                                    Func(messenger.send, "escape"),
                                    name="%s.waitingForWinInterval" %
                                    (self.__class__.__name__))

        self.slowPropTrack = Parallel(
            ActorInterval(self.props['1000'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=1.0),
            ActorInterval(self.props['500'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=1.0),
            ActorInterval(self.props['250'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=1.0),
        )
        self.fastPropTrack = Parallel(
            ActorInterval(self.props['1000'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=2.0),
            ActorInterval(self.props['500'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=2.0),
            ActorInterval(self.props['250'],
                          'propeller',
                          startFrame=8,
                          endFrame=23,
                          playRate=2.0),
        )

    def onstage(self):
        #        print "local player onstage"
        CogdoFlyingPlayer.onstage(self)
        self.toon.reparentTo(render)
        self.toon.hideName()
        self.toon.setSpeed(0, 0)
        #        self.toon.setAnimState('Happy',1.0)
        self.toon.loop('jump-idle')
        # When we had the toon in anim state swim we needed this so that the
        # player wasn't getting stuck to floors
        self.toon.controlManager.currentControls.setGravity(0)
        #        print "setting gravity to 0"
        self.resetToon()
        self.cameraMgr.enable()
        self.cameraMgr.update()

    def offstage(self):
        #print "local player offstage"
        CogdoFlyingPlayer.offstage(self)
        self.cameraMgr.disable()
        base.localAvatar.controlManager.currentControls.setGravity(32.174 *
                                                                   2.0)
        self.toon.showName()

        #self.unload()

    def unload(self):
        #        print "unloading CogdoFlyingLocalPlayer"
        self.toon.showName()
        CogdoFlyingPlayer.unload(self)

        self.checkpointPlatform = None

        self.cameraMgr.disable()
        del self.cameraMgr

        base.localAvatar.controlManager.currentControls.setGravity(32.174 *
                                                                   2.0)
        del self.game

        self.inputMgr.destroy()
        del self.inputMgr

        self.props['1000'].detachNode()
        self.props['500'].detachNode()
        self.props['250'].detachNode()
        self.props.clear()

        self.slowPropTrack.clearToInitial()
        del self.slowPropTrack

        self.fastPropTrack.clearToInitial()
        del self.fastPropTrack

        del self.propSound

        self.deathInterval.clearToInitial()
        del self.deathInterval

        self.refuelInterval.clearToInitial()
        del self.refuelInterval

        self.guiMgr.destroy()
        self.guiMgr = None

    def setCheckpointPlatform(self, platform):
        self.checkpointPlatform = platform

    def resetToon(self):
        #        print "Reset toon"
        #        print "------------------------"
        #        self.checkpointPlatform.ls()
        self.toon.setPos(
            render,
            self.checkpointPlatform.find("**/start_p1").getPos(render))
        self.toon.setHpr(render, 0, 0, 0)
        self.toon.setScale(1.0)
        #        self.toon.loop('jump-idle')
        self.toon.collisionsOn()
        #        self.toon.stopBobSwimTask()
        #        self.toon.getGeomNode().setZ(1.0)
        self.resetFuel()

    def resetFuel(self):
        self.fuel = CogdoFlyingGameGlobals.FlyingGame.FUEL_START_AMT

    def isFuelLeft(self):
        return self.fuel > 0.0

    def __updateToonMovement(self):
        # move the local toon
        dt = globalClock.getDt()
        leftPressed = self.inputMgr.arrowKeys.leftPressed()
        rightPressed = self.inputMgr.arrowKeys.rightPressed()
        upPressed = self.inputMgr.arrowKeys.upPressed()
        downPressed = self.inputMgr.arrowKeys.downPressed()
        jumpPressed = self.inputMgr.arrowKeys.jumpPressed()

        #        print leftPressed,rightPressed,upPressed,downPressed,jumpPressed
        self.instantaneousVelocity = (self.toon.getPos() - self.oldPos) / dt
        self.oldPos = self.toon.getPos()
        toonPos = self.toon.getPos()

        self.lastVelocity = Vec3(self.velocity)

        # Adds boost to velocity values and calculates toon pos changes
        if leftPressed:
            self.velocity[
                0] -= CogdoFlyingGameGlobals.FlyingGame.TOON_ACCELERATION[
                    "turning"] * dt
        if rightPressed:
            self.velocity[
                0] += CogdoFlyingGameGlobals.FlyingGame.TOON_ACCELERATION[
                    "turning"] * dt
        if upPressed:
            self.velocity[
                1] += CogdoFlyingGameGlobals.FlyingGame.TOON_ACCELERATION[
                    "forward"] * dt
        if downPressed:
            self.velocity[
                1] -= CogdoFlyingGameGlobals.FlyingGame.TOON_ACCELERATION[
                    "backward"] * dt

#        print jumpPressed
        if jumpPressed and self.isFuelLeft():
            self.velocity[
                2] += CogdoFlyingGameGlobals.FlyingGame.TOON_ACCELERATION[
                    "vertical"] * dt
            if self.state == "FreeFly" and self.isInTransition() == False:
                #print "Going to flying up"
                self.request("FlyingUp")
        else:
            if self.state == "FlyingUp" and self.isInTransition() == False:
                #print "Going to free fly"
                self.request("FreeFly")

        toonPos += self.velocity * dt

        # TODO:flying: death probably needs to happen on the server...
        if (CogdoFlyingGameGlobals.FlyingGame.DISABLE_DEATH) or \
           (base.config.GetBool('cogdo-flying-game-disable-death', 0)):
            pass
        else:
            # Tests to see whether the toon has dropped low enough to die
            if toonPos[2] < 0.0 and self.state in ["FreeFly", "FlyingUp"]:
                self.request("Death")

        toonPos[2] = clamp(toonPos[2], self.game.downLimit, self.game.upLimit)
        toonPos[0] = clamp(toonPos[0], self.game.leftLimit,
                           self.game.rightLimit)

        # Sets toon position based on velocity
        self.toon.setPos(toonPos)

        #print "Before degrades:",self.velocity

        # Degrades left/right velocity values back to normal
        minVal = -CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["turning"]
        maxVal = CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["turning"]
        if (not leftPressed
                and not rightPressed) or (self.velocity[0] > maxVal
                                          or self.velocity[0] < minVal):
            if self.velocity[0] > 0.0:
                self.velocity[
                    0] -= CogdoFlyingGameGlobals.FlyingGame.TOON_DECELERATION[
                        "turning"] * dt
                self.velocity[0] = clamp(self.velocity[0], 0.0, maxVal)
            elif self.velocity[0] < 0.0:
                self.velocity[
                    0] += CogdoFlyingGameGlobals.FlyingGame.TOON_DECELERATION[
                        "turning"] * dt
                self.velocity[0] = clamp(self.velocity[0], minVal, 0.0)

        # Degrades forward/backward velocity values back to normal
        minVal = -CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["backward"]
        maxVal = CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["forward"]
        if (not upPressed and not downPressed) or (self.velocity[1] > maxVal or
                                                   self.velocity[1] < minVal):
            if self.velocity[1] > 0.0:
                self.velocity[
                    1] -= CogdoFlyingGameGlobals.FlyingGame.TOON_DECELERATION[
                        "forward"] * dt
                self.velocity[1] = clamp(self.velocity[1], 0.0, maxVal)
            elif self.velocity[1] < 0.0:
                self.velocity[
                    1] += CogdoFlyingGameGlobals.FlyingGame.TOON_DECELERATION[
                        "backward"] * dt
                self.velocity[1] = clamp(self.velocity[1], minVal, 0.0)

        # Degrades boost/fall velocity values back to normal
        minVal = -CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["vertical"]
        maxVal = CogdoFlyingGameGlobals.FlyingGame.TOON_VEL_MAX["vertical"]
        if self.velocity[2] > minVal:
            if not self.inputMgr.arrowKeys.jumpPressed():
                self.velocity[
                    2] -= CogdoFlyingGameGlobals.FlyingGame.TOON_DECELERATION[
                        "vertical"] * dt

            self.velocity[2] = clamp(self.velocity[2], minVal, maxVal)

        #print self.lastVelocity, self.velocity


#        if self.lastVelocity != self.velocity:
#            print "Velocity:",self.velocity

    def __updateFuel(self):
        dt = globalClock.getDt()

        if CogdoFlyingGameGlobals.FlyingGame.INFINITE_FUEL:
            self.fuel = CogdoFlyingGameGlobals.FlyingGame.FUEL_START_AMT
        else:
            if self.fuel > 0.0:
                self.fuel -= CogdoFlyingGameGlobals.FlyingGame.FUEL_BURN_RATE * dt
            elif self.fuel < 0.0:
                self.fuel = 0.0

    def update(self):
        if self.state not in ["Inactive", "Refuel", "WaitingForWin", "Win"]:
            self.__updateToonMovement()
            self.__updateFuel()
            self.cameraMgr.update()
            self.guiMgr.update()

    def enterInactive(self):
        CogdoFlyingPlayer.enterInactive(self)
        self.inputMgr.disable()

    def exitInactive(self):
        CogdoFlyingPlayer.exitInactive(self)
        self.inputMgr.enable()

    def enterRefuel(self):
        CogdoFlyingPlayer.enterInactive(self)
        self.inputMgr.disable()
        self.refuelInterval.start()

    def exitRefuel(self):
        CogdoFlyingPlayer.exitInactive(self)
        self.inputMgr.enable()

    def enterFreeFly(self):
        CogdoFlyingPlayer.enterFreeFly(self)
        self.slowPropTrack.loop()
        base.playSfx(self.propSound, node=self.toon, looping=1)
        self.propSound.setPlayRate(0.9)

    def exitFreeFly(self):
        CogdoFlyingPlayer.exitFreeFly(self)
        self.slowPropTrack.clearToInitial()
        self.propSound.stop()

    def enterFlyingUp(self):
        CogdoFlyingPlayer.enterFlyingUp(self)
        self.fastPropTrack.loop()
        base.playSfx(self.propSound, node=self.toon, looping=1)
        self.propSound.setPlayRate(1.1)

    def exitFlyingUp(self):
        CogdoFlyingPlayer.exitFlyingUp(self)
        self.fastPropTrack.clearToInitial()
        self.propSound.stop()

    def enterDeath(self):
        CogdoFlyingPlayer.enterDeath(self)
        self.inputMgr.disable()
        self.deathInterval.start()

    def exitDeath(self):
        CogdoFlyingPlayer.exitDeath(self)
        self.inputMgr.enable()

    def enterWaitingForWin(self):
        CogdoFlyingPlayer.enterDeath(self)
        self.inputMgr.disable()
        self.guiMgr.messageLabel.unstash()
        self.waitingForWinInterval.loop()

    def exitWaitingForWin(self):
        CogdoFlyingPlayer.exitDeath(self)
        self.waitingForWinInterval.clearToInitial()
        self.guiMgr.messageLabel.stash()
        self.inputMgr.enable()

    def enterWin(self):
        CogdoFlyingPlayer.enterDeath(self)
        self.inputMgr.disable()
        self.winInterval.start()

    def exitWin(self):
        CogdoFlyingPlayer.exitDeath(self)
        self.inputMgr.enable()