def __init__(self):
     self._serialNum = -1
     self._memoModel = CogdoUtil.loadModel('memo', 'shared').find('**/memo')
     self._propellerModel = CogdoUtil.loadFlyingModel('propellers').find('**/mesh')
     self._powerUpModels = {}
     for type, modelName in Globals.Level.PowerupType2Model.items():
         model = CogdoUtil.loadFlyingModel(modelName).find('**/' + Globals.Level.PowerupType2Node[type])
         self._powerUpModels[type] = model
         model.setTransparency(True)
         model.setScale(0.5)
 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 initFlash(self):
     model = CogdoUtil.loadFlyingModel('gatherableFlash_card')
     texName = Globals.Level.GatherableType2TextureName[self.type]
     tex = model.findTexture(texName)
     tex.setWrapU(Texture.WMRepeat)
     tex.setWrapV(Texture.WMRepeat)
     del model
     self.ts = TextureStage('ts')
     self.ts.setMode(TextureStage.MCombine)
     self.ts.setSort(1)
     self.ts.setCombineRgb(TextureStage.CMInterpolate,
                           TextureStage.CSPrevious, TextureStage.COSrcColor,
                           TextureStage.CSTexture, TextureStage.COSrcColor,
                           TextureStage.CSConstant, TextureStage.COSrcColor)
     self.ts.setCombineAlpha(
         TextureStage.CMInterpolate, TextureStage.CSPrevious,
         TextureStage.COSrcAlpha, TextureStage.CSTexture,
         TextureStage.COSrcAlpha, TextureStage.CSConstant,
         TextureStage.COSrcAlpha)
     self._model.setTexture(self.ts, tex)
     dur = Globals.Gameplay.GatherableFlashTime
     self.flashLoop = Sequence(
         LerpFunctionInterval(self.setTextureAlphaFunc,
                              fromData=1.0,
                              toData=0.25,
                              duration=dur / 2.0,
                              blendType='easeInOut'),
         LerpFunctionInterval(self.setTextureAlphaFunc,
                              fromData=0.25,
                              toData=1.0,
                              duration=dur / 2.0,
                              blendType='easeInOut'),
         Wait(1.0),
         name='%s.flashLoop-%s' % (self.__class__.__name__, self.serialNum))
Пример #4
0
 def _initModel(self):
     self._laffMeterModel = loader.loadModel(
         'phase_3/models/gui/laff_o_meter')
     self._model = CogdoUtil.loadFlyingModel('progressMeter', group='gui')
     self._model.reparentTo(self)
     self._model.setBin('fixed', 0)
     self._lineStart = self._model.find('**/start_loc').getZ()
     self._lineEnd = self._model.find('**/end_loc').getZ()
     self._lineDistance = abs(self._lineEnd - self._lineStart)
Пример #5
0
    def loadAndBuildLevel(self, safezoneId):
        levelNode = NodePath('level')
        frameModel = CogdoUtil.loadFlyingModel('level')
        startPlatformModel = CogdoUtil.loadFlyingModel('levelStart')
        ver = '_org' if self.isOrg else ''
        endPlatformModel = CogdoUtil.loadFlyingModel('levelEnd%s' % ver)
        for fan in frameModel.findAllMatches('**/*wallFan'):
            fan.flattenStrong()

        frameModel.find('**/fogOpaque').setBin('background', 1)
        frameModel.find('**/ceiling').setBin('background', 2)
        frameModel.find('**/fogTranslucent_bm').setBin('fixed', 1)
        frameModel.find('**/wallR').setBin('opaque', 2)
        frameModel.find('**/wallL').setBin('opaque', 2)
        frameModel.find('**/fogTranslucent_top').setBin('fixed', 2)
        frameModel.getChildren().reparentTo(levelNode)
        if not self.isOrg:
            levelNode.hide()
        self._level = CogdoFlyingLevel(self._parent, levelNode,
                                       startPlatformModel, endPlatformModel,
                                       self.quadLengthUnits,
                                       self.quadVisibiltyAhead,
                                       self.quadVisibiltyBehind)
        if Globals.Dev.WantTempLevel:
            quads = Globals.Dev.DevQuadsOrder
        else:
            levelInfo = Globals.Level.DifficultyOrder[safezoneId]
            quads = []
            for difficulty in levelInfo:
                quadList = Globals.Level.QuadsByDifficulty[difficulty]
                quads.append(quadList[self._rng.randint(0, len(quadList) - 1)])

        for i in quads:
            ver = '_org' if self.isOrg else ''
            filePath = CogdoUtil.getModelPath('quadrant%i%s' % (i, ver),
                                              'flying')
            quadModel = loader.loadModel(filePath)
            for np in quadModel.findAllMatches('**/*lightCone*'):
                CogdoUtil.initializeLightCone(np, 'fixed', 3)

            self._level.appendQuadrant(quadModel)

        self._level.ready()
Пример #6
0
    def _initModel(self):
        self.setPos(Globals.Gui.FuelPos2D[0], 0.0, Globals.Gui.FuelPos2D[1])
        self.gui = CogdoUtil.loadFlyingModel('propellerMeter', group='gui')
        self.gui.reparentTo(self)
        self.gui.setBin('fixed', 0)
        self.healthBar = self.gui.find('**/healthBar')
        self.healthBar.setBin('fixed', 1)
        self.healthBar.setColor(*Globals.Gui.FuelNormalColor)
        bottomBarLocator = self.gui.find('**/bottomOfBar_loc')
        bottomBarPos = bottomBarLocator.getPos(render)
        topBarLocator = self.gui.find('**/topOfBar_loc')
        topBarPos = topBarLocator.getPos(render)
        zDist = topBarPos.getZ() - bottomBarPos.getZ()
        self.fuelLowIndicator = self.gui.find('**/fuelLowIndicator')
        self.fuelLowIndicator.setBin('fixed', 2)
        pos = self.fuelLowIndicator.getPos(render)
        newPos = pos
        newPos.setZ(bottomBarPos.getZ() + zDist * Globals.Gameplay.FuelLowAmt)
        self.fuelLowIndicator.setPos(render, newPos)
        self.fuelVeryLowIndicator = self.gui.find('**/fuelVeryLowIndicator')
        self.fuelVeryLowIndicator.setBin('fixed', 2)
        pos = self.fuelVeryLowIndicator.getPos(render)
        newPos = pos
        newPos.setZ(bottomBarPos.getZ() +
                    zDist * Globals.Gameplay.FuelVeryLowAmt)
        self.fuelVeryLowIndicator.setPos(render, newPos)
        self.propellerMain = self.gui.find('**/propellers')
        self.propellerMain.setBin('fixed', 3)
        self.propellerHead = self.gui.find('**/propellerHead')
        self.propellerHead.setBin('fixed', 4)
        self.blades = []
        self.activeBlades = []
        index = 1
        blade = self.propellerMain.find('**/propeller%d' % index)
        while not blade.isEmpty():
            self.blades.append(blade)
            index += 1
            blade = self.propellerMain.find('**/propeller%d' % index)

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

        self.bladeNumberLabel = DirectLabel(
            parent=self.propellerHead,
            relief=None,
            pos=(Globals.Gui.FuelNumBladesPos2D[0], 0,
                 Globals.Gui.FuelNumBladesPos2D[1]),
            scale=Globals.Gui.FuelNumBladesScale,
            text=str(len(self.activeBlades)),
            text_align=TextNode.ACenter,
            text_fg=(0.0, 0.0, -0.002, 1),
            text_shadow=(0.75, 0.75, 0.75, 1),
            text_font=ToontownGlobals.getInterfaceFont())
        self.bladeNumberLabel.setBin('fixed', 5)
        return
    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)
Пример #8
0
 def __init__(self, nest, index, suitDnaName='le'):
     FSM.__init__(self, 'CogdoFlyingLegalEagle')
     self.defaultTransitions = {
         'Off': ['Roost'],
         'Roost': ['TakeOff', 'Off'],
         'TakeOff': ['LockOnToon', 'LandOnNest', 'Off'],
         'LockOnToon': ['RetreatToNest', 'ChargeUpAttack', 'Off'],
         'ChargeUpAttack': ['RetreatToNest', 'Attack', 'Off'],
         'Attack': ['RetreatToSky', 'Off'],
         'RetreatToSky': ['Cooldown', 'Off'],
         'Cooldown': ['LockOnToon', 'LandOnNest', 'Off'],
         'RetreatToNest': ['LandOnNest', 'Off'],
         'LandOnNest': ['Roost', 'Off']
     }
     self.index = index
     self.nest = nest
     self.target = None
     self.isEagleInterested = False
     self.collSphere = None
     self.suit = Suit.Suit()
     d = SuitDNA.SuitDNA()
     d.newSuit(suitDnaName)
     self.suit.setDNA(d)
     self.suit.reparentTo(render)
     swapAvatarShadowPlacer(self.suit, 'legalEagle-%sShadowPlacer' % index)
     self.suit.setPos(self.nest.getPos(render))
     self.suit.setHpr(-180, 0, 0)
     self.suit.stash()
     self.prop = None
     self.attachPropeller()
     head = self.suit.find('**/joint_head')
     self.interestConeOrigin = self.nest.attachNewNode('fakeHeadNodePath')
     self.interestConeOrigin.setPos(
         render,
         head.getPos(render) +
         Vec3(0, Globals.LegalEagle.InterestConeOffset, 0))
     self.attackTargetPos = None
     self.startOfRetreatToSkyPos = None
     pathModel = CogdoUtil.loadFlyingModel('legalEaglePaths')
     self.chargeUpMotionPath = Mopath.Mopath(name='chargeUpMotionPath-%i' %
                                             self.index)
     self.chargeUpMotionPath.loadNodePath(pathModel.find('**/charge_path'))
     self.retreatToSkyMotionPath = Mopath.Mopath(
         name='retreatToSkyMotionPath-%i' % self.index)
     self.retreatToSkyMotionPath.loadNodePath(
         pathModel.find('**/retreat_path'))
     audioMgr = base.cogdoGameAudioMgr
     self._screamSfx = audioMgr.createSfx('legalEagleScream', self.suit)
     self.initIntervals()
     self.suit.nametag.setNametag2d(None)
     self.suit.nametag.setNametag3d(None)
     return
Пример #9
0
 def __init__(self):
     self._index = -1
     self._whirlwindModel = CogdoUtil.loadFlyingModel('whirlwind').find(
         '**/whirlwind')
     self._fanModel = CogdoUtil.loadFlyingModel('streamer').find(
         '**/streamer')