Example #1
0
    def setCourseReady(self, numHoles, holeIds, coursePar):
        self.notify.debug('GOLF COURSE: received setCourseReady')
        if self.state == 'Cleanup':
            return
        self.numHoles = numHoles
        self.holeIds = holeIds
        self.coursePar = coursePar
        for avId in self.avIdList:
            blankScoreList = [0] * self.numHoles
            self.scores[avId] = blankScoreList

        self.request('WaitStartHole')
        for avId in self.avIdList:
            av = base.cr.doId2do.get(avId)
            if av:
                av.show()
                av.reparentTo(render)
                av.setPos(0, 0, -100)
            else:
                self.notify.warning('avId =%d does not exist')

        self.scoreBoard = GolfScoreBoard.GolfScoreBoard(self)
        toonPanelsStart = 0.3
        whichToon = 0
        color = 0
        tpDiff = -0.45
        headPanel = loader.loadModel('phase_6/models/golf/headPanel')
        if self.numPlayers > 0:
            for avId in self.avIdList:
                if not self.localAvId == avId:
                    av = base.cr.doId2do.get(avId)
                    if av:
                        tPanels = ToonHeadFrame.ToonHeadFrame(
                            av, GolfGlobals.PlayerColors[color], headPanel)
                        tPanels.reparentTo(aspect2d)
                        tPanels.setPos(base.a2dTopLeft.getPos()[0] + 0.1875, 0,
                                       toonPanelsStart + whichToon * tpDiff)
                        tPanels.setScale(0.3, 1, 0.7)
                        tPanels.head.setPos(0, 10, 0.18)
                        tPanels.head.setScale(0.47, 0.2, 0.2)
                        tPanels.tag1.setPos(0.3, 10, 0.18)
                        tPanels.tag1.setScale(0.1283, 0.055, 0.055)
                        tPanels.tag2.setPos(0, 10, 0.43)
                        tPanels.tag2.setScale(0.117, 0.05, 0.05)
                        self.toonPanels.append(tPanels)
                        whichToon = whichToon + 1
                        color += 1
                else:
                    color += 1

            base.setCellsActive(base.leftCells, 0)

        else:
            self.toonPanels = None
        for avId in self.exitedAvIdList:
            if avId not in self.exitedToonsWithPanels:
                self.exitMessageForToon(avId)
 def parseToonHead(self, line):
     if len(line) == 5:
         token, toonName, x, z, toggle = line
         scale = 1.0
     else:
         token, toonName, x, z, toggle, scale = line
     toon = self.getVar(toonName)
     toonId = toon.getDoId()
     toonHeadFrame = self.toonHeads.get(toonId)
     if not toonHeadFrame:
         toonHeadFrame = ToonHeadFrame.ToonHeadFrame(toon)
         toonHeadFrame.tag1Node
         toonHeadFrame.hide()
         self.toonHeads[toonId] = toonHeadFrame
         self.setVar('%sToonHead' % toonName, toonHeadFrame)
     if toggle:
         return Sequence(Func(toonHeadFrame.setPos, x, 0, z), Func(toonHeadFrame.setScale, scale), Func(toonHeadFrame.show))
     else:
         return Func(toonHeadFrame.hide)