예제 #1
0
 def announceGenerate(self):
     # TODO - for some reason this is getting called hundreds of times when there are multiple districts
     DistributedObject.DistributedObject.announceGenerate(self)
     self.sendUpdate("enteredParty", [])
     globalClock.syncFrameTime()
     self.startPartyClock()
     base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu()
     self.spawnTitleText()
     messenger.send(self.generatedEvent)
     if config.GetBool("show-debug-party-grid", 0):
         self.testGrid = NodePath("test_grid")
         self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom)
         for i in xrange(len(self.grid)):
             for j in xrange(len(self.grid[i])):
                 cm = CardMaker("gridsquare")
                 np = NodePath(cm.generate())
                 np.setScale(12)
                 np.setP(-90.0)
                 np.setPos(
                     PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0,
                     PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0,
                     0.1,
                 )
                 np.reparentTo(self.testGrid)
                 if self.grid[i][j]:
                     np.setColorScale(0.0, 1.0, 0.0, 1.0)
                 else:
                     np.setColorScale(1.0, 0.0, 0.0, 1.0)
예제 #2
0
 def announceGenerate(self):
     #TODO - for some reason this is getting called hundreds of times when there are multiple districts
     DistributedObject.DistributedObject.announceGenerate(self)
     self.sendUpdate('enteredParty', [])
     globalClock.syncFrameTime()
     self.startPartyClock()
     base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu()
     self.spawnTitleText()
     messenger.send(self.generatedEvent)
     if config.GetBool('show-debug-party-grid', 0):
         self.testGrid = NodePath('test_grid')
         self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom)
         for i in range(len(self.grid)):
             for j in range(len(self.grid[i])):
                 cm = CardMaker('gridsquare')
                 np = NodePath(cm.generate())
                 np.setScale(12)
                 np.setP(-90.0)
                 np.setPos(
                     PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0,
                     PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0,
                     0.1)
                 np.reparentTo(self.testGrid)
                 if self.grid[i][j]:
                     np.setColorScale(0.0, 1.0, 0.0, 1.0)
                 else:
                     np.setColorScale(1.0, 0.0, 0.0, 1.0)
예제 #3
0
 def announceGenerate(self):
     assert(self.notify.debug("announceGenerate()"))
     DistributedObject.DistributedObject.announceGenerate(self)
     self.sendUpdate("avIdEnteredParty", [base.localAvatar.doId])
     # we probably just spent a lot of time loading, so
     # tell globalClock to update the frame timestamp
     globalClock.syncFrameTime()
     self.startPartyClock()
     base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu()
     self.spawnTitleText()
     if config.GetBool('show-debug-party-grid', 0):
         # Debug grid
         self.testGrid = NodePath("test_grid")
         self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom)
         for i in range(len(self.grid)):
             for j in range(len(self.grid[i])):
                 cm = CardMaker("gridsquare")
                 np = NodePath(cm.generate())
                 np.setScale(12)
                 np.setP(-90.0)
                 np.setPos(PartyUtils.convertDistanceFromPartyGrid(j,0)-6.0, PartyUtils.convertDistanceFromPartyGrid(i,1)-6.0, 0.1)
                 np.reparentTo(self.testGrid)
                 if self.grid[i][j]:
                     np.setColorScale(0.0, 1.0, 0.0, 1.0)
                 else:
                     np.setColorScale(1.0, 0.0, 0.0, 1.0)
 def generate(self):
     DistributedObjectAI.generate(self)
     actId2Class = {
         ActivityIds.PartyJukebox: DistributedPartyJukeboxActivityAI,
         ActivityIds.PartyTrampoline: DistributedPartyTrampolineActivityAI,
         ActivityIds.PartyVictoryTrampoline: DistributedPartyVictoryTrampolineActivityAI,
         ActivityIds.PartyCatch: DistributedPartyCatchActivityAI,
         ActivityIds.PartyDance: DistributedPartyDanceActivityAI, 
         ActivityIds.PartyTugOfWar: DistributedPartyTugOfWarActivityAI,
         ActivityIds.PartyFireworks: DistributedPartyFireworksActivityAI,
         ActivityIds.PartyJukebox40: DistributedPartyJukebox40ActivityAI,
         ActivityIds.PartyDance20: DistributedPartyDance20ActivityAI,
         ActivityIds.PartyCog: DistributedPartyCogActivityAI,
     }
     for activity in self.info['activities']:
         actId = activity[0]
         if actId in actId2Class:
             act = actId2Class[actId](self.air, self.doId, activity)
             act.generateWithRequired(self.zoneId)
             self.activities.append(act)
         elif actId == ActivityIds.PartyCannon:
             if not self.cannonActivity:
                 self.cannonActivity = DistributedPartyCannonActivityAI(self.air, self.doId, activity)
                 self.cannonActivity.generateWithRequired(self.zoneId)
             act = DistributedPartyCannonAI(self.air)
             act.setActivityDoId(self.cannonActivity.doId)
             x, y, h = activity[1:]
             x = PartyUtils.convertDistanceFromPartyGrid(x, 0)
             y = PartyUtils.convertDistanceFromPartyGrid(y, 1)
             h *= PartyGridHeadingConverter
             act.setPosHpr(x,y,0,h,0,0)
             act.generateWithRequired(self.zoneId)
             self.activities.append(act)
예제 #5
0
 def generate(self):
     DistributedObjectAI.generate(self)
     actId2Class = {
         ActivityIds.PartyJukebox: DistributedPartyJukeboxActivityAI,
         ActivityIds.PartyTrampoline: DistributedPartyTrampolineActivityAI,
         ActivityIds.PartyVictoryTrampoline:
         DistributedPartyVictoryTrampolineActivityAI,
         ActivityIds.PartyCatch: DistributedPartyCatchActivityAI,
         ActivityIds.PartyDance: DistributedPartyDanceActivityAI,
         ActivityIds.PartyTugOfWar: DistributedPartyTugOfWarActivityAI,
         ActivityIds.PartyFireworks: DistributedPartyFireworksActivityAI,
         ActivityIds.PartyJukebox40: DistributedPartyJukebox40ActivityAI,
         ActivityIds.PartyDance20: DistributedPartyDance20ActivityAI,
         ActivityIds.PartyCog: DistributedPartyCogActivityAI
     }
     for activity in self.info['activities']:
         actId = activity[0]
         if actId in actId2Class:
             act = actId2Class[actId](self.air, self.doId, activity)
             act.generateWithRequired(self.zoneId)
             self.activities.append(act)
         elif actId == ActivityIds.PartyCannon:
             if not self.cannonActivity:
                 self.cannonActivity = DistributedPartyCannonActivityAI(
                     self.air, self.doId, activity)
                 self.cannonActivity.generateWithRequired(self.zoneId)
             act = DistributedPartyCannonAI(self.air)
             act.setActivityDoId(self.cannonActivity.doId)
             x, y, h = activity[1:]
             x = PartyUtils.convertDistanceFromPartyGrid(x, 0)
             y = PartyUtils.convertDistanceFromPartyGrid(y, 1)
             h *= PartyGridHeadingConverter
             act.setPosHpr(x, y, 0, h, 0, 0)
             act.generateWithRequired(self.zoneId)
             self.activities.append(act)
    def getClearSquarePositions(self):
        clearPositions = []
        for y in xrange(len(self.grid)):
            for x in xrange(len(self.grid[0])):
                if self.grid[y][x]:
                    pos = (PartyUtils.convertDistanceFromPartyGrid(x, 0), PartyUtils.convertDistanceFromPartyGrid(y, 1), 0.1)
                    clearPositions.append(pos)

        return clearPositions
예제 #7
0
 def loadDecorations(self):
     self.decorationsList = []
     for decorBase in self.partyInfo.decors:
         self.decorationsList.append(
             Decoration(
                 PartyGlobals.DecorationIds.getString(decorBase.decorId),
                 PartyUtils.convertDistanceFromPartyGrid(decorBase.x, 0),
                 PartyUtils.convertDistanceFromPartyGrid(decorBase.y, 1),
                 PartyUtils.convertDegreesFromPartyGrid(decorBase.h)))
    def getClearSquarePositions(self):
        clearPositions = []
        for y in range(len(self.grid)):
            for x in range(len(self.grid[0])):
                if self.grid[y][x]:
                    pos = (PartyUtils.convertDistanceFromPartyGrid(x, 0), PartyUtils.convertDistanceFromPartyGrid(y, 1), 0.1)
                    clearPositions.append(pos)

        return clearPositions
예제 #9
0
 def loadDecorations(self):
     self.decorationsList = []
     for decorBase in self.partyInfo.decors:
         self.decorationsList.append(
             Decoration(
                 PartyGlobals.DecorationIds.getString(decorBase.decorId),
                 PartyUtils.convertDistanceFromPartyGrid(decorBase.x, 0),
                 PartyUtils.convertDistanceFromPartyGrid(decorBase.y, 1),
                 PartyUtils.convertDegreesFromPartyGrid(decorBase.h),
             )
         )
예제 #10
0
    def getClearSquarePositions(self):
        """
        Return a list of (x,y,z) positions at the center of a clear square in the party.
        """
        clearPositions = []

        for y in range(len(self.grid)):
            for x in range(len(self.grid[0])):
                if self.grid[y][x]:
                    pos = (PartyUtils.convertDistanceFromPartyGrid(x,0), PartyUtils.convertDistanceFromPartyGrid(y,1), 0.1)
                    clearPositions.append(pos)

        return clearPositions
예제 #11
0
 def handleToonExited(self, toonId):
     DistributedPartyTeamActivity.handleToonExited(self, toonId)
     if toonId == base.localAvatar.doId:
         self.cameraMoveIval.pause()
         if toonId not in self.fallenToons:
             if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[
                     toonId] is not None:
                 self.toonIdsToAnimIntervals[toonId].finish()
             toon = self.getAvatar(toonId)
             targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
             targetPos = self.hopOffPositions[self.getTeam(toonId)][
                 self.getIndex(toonId, self.getTeam(toonId))]
             hopOffAnim = Sequence(
                 Func(toon.startPosHprBroadcast, 0.1),
                 toon.hprInterval(0.2,
                                  VBase3(targetH, 0.0, 0.0),
                                  other=self.root),
                 Func(toon.b_setAnimState, 'jump', 1.0), Wait(0.4),
                 PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0,
                                           self.root),
                 Func(toon.stopPosHprBroadcast),
                 Func(toon.sendCurrentPosition),
                 Func(self.hopOffFinished, toonId))
             self.toonIdsToAnimIntervals[toonId] = hopOffAnim
             self._hopOffFinishedSV.set(False)
             self.toonIdsToAnimIntervals[toonId].start()
         else:
             self._hopOffFinishedSV.set(True)
             del self.toonIdsToAnimIntervals[toonId]
     return
 def handleToonExited(self, toonId):
     DistributedPartyTeamActivity.handleToonExited(self, toonId)
     if toonId == base.localAvatar.doId:
         self.cameraMoveIval.pause()
         if toonId not in self.fallenToons:
             if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[toonId] is not None:
                 self.toonIdsToAnimIntervals[toonId].finish()
             toon = self.getAvatar(toonId)
             targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
             targetPos = self.hopOffPositions[self.getTeam(toonId)][self.getIndex(toonId, self.getTeam(toonId))]
             hopOffAnim = Sequence(
                 Func(toon.startPosHprBroadcast, 0.1),
                 toon.hprInterval(0.2, VBase3(targetH, 0.0, 0.0), other=self.root),
                 Func(toon.b_setAnimState, "jump", 1.0),
                 Wait(0.4),
                 PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0, self.root),
                 Func(toon.stopPosHprBroadcast),
                 Func(toon.sendCurrentPosition),
                 Func(self.hopOffFinished, toonId),
             )
             self.toonIdsToAnimIntervals[toonId] = hopOffAnim
             self._hopOffFinishedSV.set(False)
             self.toonIdsToAnimIntervals[toonId].start()
         else:
             self._hopOffFinishedSV.set(True)
             del self.toonIdsToAnimIntervals[toonId]
     return
 def announceGenerate(self):
     DistributedObject.DistributedObject.announceGenerate(self)
     self.sendUpdate('enteredParty', [])
     globalClock.syncFrameTime()
     self.startPartyClock()
     base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu()
     self.spawnTitleText()
     messenger.send(self.generatedEvent)
     if config.GetBool('show-debug-party-grid', 0):
         self.testGrid = NodePath('test_grid')
         self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom)
         for i in range(len(self.grid)):
             for j in range(len(self.grid[i])):
                 cm = CardMaker('gridsquare')
                 np = NodePath(cm.generate())
                 np.setScale(12)
                 np.setP(-90.0)
                 np.setPos(PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1)
                 np.reparentTo(self.testGrid)
                 if self.grid[i][j]:
                     np.setColorScale(0.0, 1.0, 0.0, 1.0)
                 else:
                     np.setColorScale(1.0, 0.0, 0.0, 1.0)
예제 #14
0
    def handleToonExited(self, toonId):
        DistributedPartyTeamActivity.handleToonExited(self, toonId)

        # clean up local toon stuff
        if toonId == base.localAvatar.doId:
            self.cameraMoveIval.pause()

            # make toon jump off the dock if needed
            if toonId not in self.fallenToons:
                # finish any existing interval for that toon
                if toonId in self.toonIdsToAnimIntervals and \
                   self.toonIdsToAnimIntervals[toonId] is not None:
                    self.toonIdsToAnimIntervals[toonId].finish()
                toon = self.getAvatar(toonId)
                # clamp targetHeading to minimize spin
                targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
                targetPos = self.hopOffPositions[self.getTeam(toonId)][
                    self.getIndex(toonId, self.getTeam(toonId))]
                hopOffAnim = Sequence(
                    Func(toon.startPosHprBroadcast, 0.1),
                    toon.hprInterval(0.2,
                                     VBase3(targetH, 0.0, 0.0),
                                     other=self.root),
                    Func(toon.b_setAnimState, "jump", 1.0),
                    Wait(0.4),
                    PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0,
                                              self.root),
                    Func(toon.stopPosHprBroadcast),
                    # make sure toon ends up on the ground on remote clients
                    Func(toon.sendCurrentPosition),
                    Func(self.hopOffFinished, toonId),
                )
                self.toonIdsToAnimIntervals[toonId] = hopOffAnim
                self._hopOffFinishedSV.set(False)
                self.toonIdsToAnimIntervals[toonId].start()
            # local toons not on the dock are put back into the walk state
            else:
                self._hopOffFinishedSV.set(True)
                del self.toonIdsToAnimIntervals[toonId]
 def setPartyClockInfo(self, x, y, h):
     x = PartyUtils.convertDistanceFromPartyGrid(x, 0)
     y = PartyUtils.convertDistanceFromPartyGrid(y, 1)
     h = PartyUtils.convertDegreesFromPartyGrid(h)
     self.partyClockInfo = (x, y, h)
     self.loadPartyCountdownTimer()
예제 #16
0
 def setPartyClockInfo(self, x, y, h):
     x = PartyUtils.convertDistanceFromPartyGrid(x, 0)
     y = PartyUtils.convertDistanceFromPartyGrid(y, 1)
     h = PartyUtils.convertDegreesFromPartyGrid(h)
     self.partyClockInfo = (x, y, h)
     self.loadPartyCountdownTimer()