コード例 #1
0
 def setupStartSection(self):
     self.startSectionNP = NodePath('StartSection')
     self.startSectionNP.reparentTo(self.game.assetMgr.world)
     self.startSectionNP.setX(-48)
     # Creating the wall
     self.startWall = self.game.assetMgr.startingWall.copyTo(
         self.startSectionNP)
     self.startWall.setPos(-28, 0, 4)
     self.startWall.setScale(0.8)
     # Creating the pipe
     self.startPipe = self.game.assetMgr.startingPipe.copyTo(
         self.startSectionNP)
     self.startPipe.setPos(12, 0, 44)
     # Creating the arrow
     self.startArrow = self.game.assetMgr.arrow.copyTo(self.startSectionNP)
     self.startArrow.setPos(23, 1.5, 12.76)
     # Creating level blocks
     # We don't create a section for the start section. It does not have a spawnPoint
     # TODO: We could make it a section, dunno if it'll break.
     for index in range(len(ToonBlitzGlobals.BlockListStart)):
         blockAttribs = ToonBlitzGlobals.BlockListStart[index]
         fileName = ToonBlitzGlobals.BlockTypes[blockAttribs[0]][0]
         blockIndex = int(fileName[-1])
         blockType = self.game.assetMgr.blockTypes[blockIndex]
         sectionizedId = 'start-' + str(index)
         newBlock = TwoDBlock.TwoDBlock(blockType, sectionizedId,
                                        blockAttribs)
         newBlock.model.reparentTo(self.startSectionNP)
コード例 #2
0
    def load(self, sectionInfo):
        self.sectionTypeNum = sectionInfo[0]
        enemyIndicesSelected = sectionInfo[1]
        treasureIndicesSelected = sectionInfo[2]
        spawnPointIndicesSelected = sectionInfo[3]
        stomperIndicesSelected = sectionInfo[4]
        attribs = ToonBlitzGlobals.SectionTypes[self.sectionTypeNum]
        self.length = attribs[1]
        self.blockList = attribs[2]
        enemiesPool = attribs[3]
        treasuresPool = attribs[4]
        spawnPointsPool = attribs[5]
        stompersPool = attribs[6]
        self.enemyList = []
        for enemyIndex in enemyIndicesSelected:
            self.enemyList.append(enemiesPool[enemyIndex])

        self.treasureList = []
        for treasure in treasureIndicesSelected:
            treasureIndex = treasure[0]
            treasureValue = treasure[1]
            treasureAttribs = treasuresPool[treasureIndex]
            self.treasureList.append((treasureAttribs, treasureValue))

        self.spawnPointList = []
        for spawnPointIndex in spawnPointIndicesSelected:
            self.spawnPointList.append(spawnPointsPool[spawnPointIndex])

        self.stomperList = []
        for stomperIndex in stomperIndicesSelected:
            self.stomperList.append(stompersPool[stomperIndex])

        self.blocksNP = NodePath('Blocks')
        self.blocksNP.reparentTo(self.sectionNP)
        if self.blockList[0][1][0] != (0, 0, 12):
            self.notify.warning(
                'First block of section %s does not start at (0, 0, 12)' %
                self.sectionTypeNum)

        for index in range(0, len(self.blockList)):
            blockAttribs = self.blockList[index]
            fileName = ToonBlitzGlobals.BlockTypes[blockAttribs[0]][0]
            blockIndex = int(fileName[-1])
            blockType = self.sectionMgr.game.assetMgr.blockTypes[blockIndex]
            sectionizedId = self.getSectionizedId(index)
            newBlock = TwoDBlock.TwoDBlock(blockType, sectionizedId,
                                           blockAttribs)
            newBlock.model.reparentTo(self.blocksNP)
            self.blocks.append(newBlock)

        self.enemyMgr = TwoDEnemyMgr.TwoDEnemyMgr(self, self.enemyList)
        self.treasureMgr = TwoDTreasureMgr.TwoDTreasureMgr(
            self, self.treasureList, self.enemyList)
        self.spawnPointMgr = TwoDSpawnPointMgr.TwoDSpawnPointMgr(
            self, self.spawnPointList)
        self.stomperMgr = TwoDStomperMgr.TwoDStomperMgr(self, self.stomperList)
        if self.sectionTypeNum == 'end':
            self.spawnPointMgr.setupLastSavePointHandle()
コード例 #3
0
 def setupStartSection(self):
     self.startSectionNP = NodePath('StartSection')
     self.startSectionNP.reparentTo(self.game.assetMgr.world)
     self.startSectionNP.setX(-48)
     self.startWall = self.game.assetMgr.startingWall.copyTo(self.startSectionNP)
     self.startWall.setPos(-28, 0, 4)
     self.startWall.setScale(0.8)
     self.startPipe = self.game.assetMgr.startingPipe.copyTo(self.startSectionNP)
     self.startPipe.setPos(12, 0, 44)
     self.startArrow = self.game.assetMgr.arrow.copyTo(self.startSectionNP)
     self.startArrow.setPos(23, 1.5, 12.76)
     for index in xrange(len(ToonBlitzGlobals.BlockListStart)):
         blockAttribs = ToonBlitzGlobals.BlockListStart[index]
         fileName = ToonBlitzGlobals.BlockTypes[blockAttribs[0]][0]
         blockIndex = int(fileName[(-1)])
         blockType = self.game.assetMgr.blockTypes[blockIndex]
         sectionizedId = 'start-' + str(index)
         newBlock = TwoDBlock.TwoDBlock(blockType, sectionizedId, blockAttribs)
         newBlock.model.reparentTo(self.startSectionNP)