コード例 #1
0
 def handleToonSwitchedTeams(self, toonId):
     DistributedPartyTeamActivity.handleToonSwitchedTeams(self, toonId)
     toon = base.cr.doId2do.get(toonId, None)
     if toon is None:
         return
     if self.view is not None:
         self.view.handleToonSwitchedTeams(toon)
 def announceGenerate(self):
     DistributedPartyTeamActivity.announceGenerate(self)
     for i in range(len(self.toonIds)):
         for toonId in self.toonIds[i]:
             toon = base.cr.doId2do.get(toonId, None)
             if toon:
                 self.view.handleToonJoined(toon, i, lateEntry=True)
コード例 #3
0
 def handleToonExited(self, toonId):
     toon = base.cr.doId2do.get(toonId, None)
     if toon is None:
         return
     if self.view is not None:
         self.view.handleToonExited(toon)
     DistributedPartyTeamActivity.handleToonExited(self, toonId)
 def handleToonSwitchedTeams(self, toonId):
     DistributedPartyTeamActivity.handleToonSwitchedTeams(self, toonId)
     toon = base.cr.doId2do.get(toonId, None)
     if toon is None:
         return
     if self.view is not None:
         self.view.handleToonSwitchedTeams(toon)
 def handleToonExited(self, toonId):
     toon = base.cr.doId2do.get(toonId, None)
     if toon is None:
         return
     if self.view is not None:
         self.view.handleToonExited(toon)
     DistributedPartyTeamActivity.handleToonExited(self, toonId)
コード例 #6
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
コード例 #7
0
 def announceGenerate(self):
     DistributedPartyTeamActivity.announceGenerate(self)
     for i in range(len(self.toonIds)):
         for toonId in self.toonIds[i]:
             toon = base.cr.doId2do.get(toonId, None)
             if toon:
                 self.view.handleToonJoined(toon, i, lateEntry=True)
コード例 #8
0
    def unload(self):
        DistributedPartyTeamActivity.unload(self)

        self.arrowKeys.destroy()
        self.unloadIntervals()
        self.unloadModels()
        self.unloadGuiElements()
        self.unloadSounds()

        # delete variables
        if hasattr(self, "toonIds"):
            del self.toonIds
        del self.buttons
        del self.arrowKeys
        del self.keyTTL
        del self.idealRate
        del self.keyRate
        del self.allOutMode
        del self.rateMatchAward

        del self.toonIdsToStartPositions
        del self.toonIdsToIsPullingFlags
        del self.toonIdsToRightHands
        del self.fallenToons
        del self.fallenPositions
        del self.unusedFallenPositionsIndices
        self.toonIdsToAnimIntervals.clear()
        del self.toonIdsToAnimIntervals
コード例 #9
0
 def generate(self):
     DistributedPartyTeamActivity.generate(self)
     self._hopOffFinishedSV = StateVar(True)
     self._rewardFinishedSV = StateVar(True)
     self._isWalkStateReadyFC = FunctionCall(
         self._testWalkStateReady, self._hopOffFinishedSV, self._rewardFinishedSV
     )
コード例 #10
0
 def load(self):
     DistributedPartyTeamActivity.load(self)
     self.loadModels()
     self.loadGuiElements()
     self.loadSounds()
     self.loadIntervals()
     self.arrowKeys = ArrowKeys()
コード例 #11
0
    def startActive(self):
        DistributedPartyTeamActivity.startActive(self)
        self.toonIdsToStartPositions.clear()
        self.toonIdsToIsPullingFlags.clear()
        for toonId in self.getToonIdsAsList():
            self.toonIdsToIsPullingFlags[toonId] = False
            toon = self.getAvatar(toonId)
            if toon:
                self.toonIdsToStartPositions[toonId] = toon.getPos(self.root)
            else:
                self.notify.warning(
                    "couldn't find toon %d assigning 0,0,0 to startPos" %
                    toonId)
                self.toonIdsToStartPositions[toonId] = Point3(0, 0, 0)

        self.unusedFallenPositionsIndices = [0, 1, 2, 3]
        self.setupInterval = Parallel(self.globalSetupInterval)
        if self.isLocalToonPlaying:
            self.keyTTL = []
            self.idealForce = 0.0
            self.keyRate = 0
            self.rateMatchAward = 0.0
            self.allOutMode = False
            self.setIdealRate(PartyGlobals.TugOfWarTargetRateList[0][1])
            self.setupInterval.append(self.localSetupInterval)
        self.setupInterval.start()
コード例 #12
0
 def __init__(self, cr):
     DistributedPartyTeamActivity.__init__(
         self,
         cr,
         PartyGlobals.ActivityIds.PartyCog,
         startDelay=PartyGlobals.CogActivityStartDelay,
         balanceTeams=PartyGlobals.CogActivityBalanceTeams)
コード例 #13
0
 def setToonsPlaying(self, leftTeamToonIds, rightTeamToonIds):
     DistributedPartyTeamActivity.setToonsPlaying(self, leftTeamToonIds, rightTeamToonIds)
     self.toonIdsToRightHands.clear()
     for toonId in self.getToonIdsAsList():
         toon = self.getAvatar(toonId)
         if toon:
             self.toonIdsToRightHands[toonId] = toon.getRightHands()[0]
コード例 #14
0
 def setToonsPlaying(self, leftTeamToonIds, rightTeamToonIds):
     DistributedPartyTeamActivity.setToonsPlaying(self, leftTeamToonIds, rightTeamToonIds)
     self.toonIdsToRightHands.clear()
     for toonId in self.getToonIdsAsList():
         toon = self.getAvatar(toonId)
         if toon:
             self.toonIdsToRightHands[toonId] = toon.getRightHands()[0]
コード例 #15
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
コード例 #16
0
 def generate(self):
     DistributedPartyTeamActivity.generate(self)
     self._hopOffFinishedSV = StateVar(True)
     self._rewardFinishedSV = StateVar(True)
     self._isWalkStateReadyFC = FunctionCall(self._testWalkStateReady,
                                             self._hopOffFinishedSV,
                                             self._rewardFinishedSV)
コード例 #17
0
 def handleToonJoined(self, toonId):
     DistributedPartyTeamActivity.handleToonJoined(self, toonId)
     self.toonIdsToAnimIntervals[toonId] = None
     if toonId == base.localAvatar.doId:
         base.cr.playGame.getPlace().fsm.request("activity")
         camera.wrtReparentTo(self.root)
         self.cameraMoveIval = LerpPosHprInterval(
             camera, 1.5, PartyGlobals.TugOfWarCameraPos, PartyGlobals.TugOfWarCameraInitialHpr, other=self.root
         )
         self.cameraMoveIval.start()
         self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam)
         self.notify.debug("posIndex: %d" % self.localToonPosIndex)
         toon = self.getAvatar(toonId)
         targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex]
         if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
             toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
         targetH = fitDestAngle2Src(toon.getH(self.root), PartyGlobals.TugOfWarHeadings[self.localToonTeam])
         travelVector = targetPos - toon.getPos(self.root)
         duration = travelVector.length() / 5.0
         if self.toonIdsToAnimIntervals[toonId] is not None:
             self.toonIdsToAnimIntervals[toonId].finish()
         self.toonIdsToAnimIntervals[toonId] = Sequence(
             Func(toon.startPosHprBroadcast, 0.1),
             Func(toon.b_setAnimState, "run"),
             LerpPosHprInterval(toon, duration, targetPos, VBase3(targetH, 0.0, 0.0), other=self.root),
             Func(toon.stopPosHprBroadcast),
             Func(toon.b_setAnimState, "neutral"),
         )
         self.toonIdsToAnimIntervals[toonId].start()
     return
コード例 #18
0
    def startConclusion(self, losingTeam):
        DistributedPartyTeamActivity.startConclusion(self, losingTeam)
        if self.isLocalToonPlaying:
            self._rewardFinishedSV.set(False)
            if losingTeam == PartyGlobals.TeamActivityNeitherTeam:
                self.setStatus(TTLocalizer.PartyTeamActivityGameTie)
            else:
                self.setStatus(TTLocalizer.PartyTugOfWarGameEnd)
            self.showStatus()
        if losingTeam == PartyGlobals.TeamActivityNeitherTeam:
            for toonId in self.getToonIdsAsList():
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('neutral')

        else:
            for toonId in self.toonIds[losingTeam]:
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('neutral')

            for toonId in self.toonIds[1 - losingTeam]:
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('victory')

        for ival in self.toonIdsToAnimIntervals.values():
            if ival is not None:
                ival.finish()

        return
コード例 #19
0
 def load(self):
     DistributedPartyTeamActivity.load(self)
     self.loadModels()
     self.loadGuiElements()
     self.loadSounds()
     self.loadIntervals()
     self.arrowKeys = ArrowKeys()
コード例 #20
0
 def handleToonJoined(self, toonId):
     DistributedPartyTeamActivity.handleToonJoined(self, toonId)
     toon = base.cr.doId2do.get(toonId, None)
     team = self.getTeam(toonId)
     if toon is not None and self.view is not None:
         self.view.handleToonJoined(toon, team)
     return
コード例 #21
0
    def startActive(self):
        DistributedPartyTeamActivity.startActive(self)
        self.toonIdsToStartPositions.clear()
        self.toonIdsToIsPullingFlags.clear()
        for toonId in self.getToonIdsAsList():
            self.toonIdsToIsPullingFlags[toonId] = False
            toon = self.getAvatar(toonId)
            if toon:
                self.toonIdsToStartPositions[toonId] = toon.getPos(self.root)
            else:
                self.notify.warning("couldn't find toon %d assigning 0,0,0 to startPos" % toonId)
                self.toonIdsToStartPositions[toonId] = Point3(0, 0, 0)

        self.unusedFallenPositionsIndices = [0,
         1,
         2,
         3]
        self.setupInterval = Parallel(self.globalSetupInterval)
        if self.isLocalToonPlaying:
            self.keyTTL = []
            self.idealForce = 0.0
            self.keyRate = 0
            self.rateMatchAward = 0.0
            self.allOutMode = False
            self.setIdealRate(PartyGlobals.TugOfWarTargetRateList[0][1])
            self.setupInterval.append(self.localSetupInterval)
        self.setupInterval.start()
コード例 #22
0
    def startConclusion(self, losingTeam):
        DistributedPartyTeamActivity.startConclusion(self, losingTeam)
        if self.isLocalToonPlaying:
            self._rewardFinishedSV.set(False)
            if losingTeam == PartyGlobals.TeamActivityNeitherTeam:
                self.setStatus(TTLocalizer.PartyTeamActivityGameTie)
            else:
                self.setStatus(TTLocalizer.PartyTugOfWarGameEnd)
            self.showStatus()
        if losingTeam == PartyGlobals.TeamActivityNeitherTeam:
            for toonId in self.getToonIdsAsList():
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('neutral')

        else:
            for toonId in self.toonIds[losingTeam]:
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('neutral')

            for toonId in self.toonIds[1 - losingTeam]:
                if self.getAvatar(toonId):
                    self.getAvatar(toonId).loop('victory')

        for ival in self.toonIdsToAnimIntervals.values():
            if ival is not None:
                ival.finish()

        return
コード例 #23
0
    def startRules(self):
        DistributedPartyTeamActivity.startRules(self)

        self.setUpRopes()
        # display rules to the local toon if we have one
        if self.isLocalToonPlaying:
            self.showControls()
コード例 #24
0
 def handleToonJoined(self, toonId):
     DistributedPartyTeamActivity.handleToonJoined(self, toonId)
     toon = base.cr.doId2do.get(toonId, None)
     team = self.getTeam(toonId)
     if toon is not None and self.view is not None:
         self.view.handleToonJoined(toon, team)
     return
コード例 #25
0
    def __init__(self, cr):
        """
        cr: instance of ClientRepository
        """
        DistributedPartyTeamActivity.__init__(
            self,
            cr,
            PartyGlobals.ActivityIds.PartyTugOfWar,
            startDelay=PartyGlobals.TugOfWarStartDelay)
        assert (self.notify.debug("__init__"))

        # these are the indices of the active buttons
        self.buttons = [0, 1]

        # these variables are used for calculation how fast the player is pressing the keys
        self.arrowKeys = None
        self.keyTTL = []
        self.idealRate = 0.0
        self.keyRate = 0
        self.allOutMode = False
        self.rateMatchAward = 0.0  # bonus for consistently hitting the ideal rate

        self.toonIdsToStartPositions = {}  # initial positions of toons
        self.toonIdsToIsPullingFlags = {}  # whether or not a toon is pulling
        self.toonIdsToRightHands = {}  # used for setting up ropes
        self.fallenToons = []  # toons in the water
        self.fallenPositions = []
        self.unusedFallenPositionsIndices = [0, 1, 2, 3]
        self.toonIdsToAnimIntervals = {}
        self.tugRopes = []
コード例 #26
0
    def finishWaitForServer(self):
        DistributedPartyTeamActivity.finishWaitForServer(self)

        # check for a non-standard transition and do additional cleanup as needed
        if self.activityFSM.getCurrentOrNextState() == "WaitForEnough":
            self.hideRopes()
            self.hideControls()
コード例 #27
0
 def startActive(self):
     DistributedPartyTeamActivity.startActive(self)
     self.view.startActivity(self.getCurrentActivityTime())
     self.view.closeArenaDoors()
     if not self.isLocalToonPlaying:
         self.view.showArenaDoorTimers(
             self._duration + PartyGlobals.CogActivityConclusionDuration +
             1.0 - self.getCurrentActivityTime())
コード例 #28
0
 def finishActive(self):
     DistributedPartyTeamActivity.finishActive(self)
     self.hideControls()
     self.disableKeys()
     self.setupInterval.pause()
     self.reportToServerInterval.pause()
     self.updateKeyPressRateInterval.pause()
     self.updateIdealRateInterval.pause()
     self.hideRopes()
コード例 #29
0
 def finishActive(self):
     DistributedPartyTeamActivity.finishActive(self)
     self.hideControls()
     self.disableKeys()
     self.setupInterval.pause()
     self.reportToServerInterval.pause()
     self.updateKeyPressRateInterval.pause()
     self.updateIdealRateInterval.pause()
     self.hideRopes()
コード例 #30
0
    def setToonsPlaying(self, leftTeamToonIds, rightTeamToonIds):
        """Overrides DistributedPartyActivity's setToonsPlaying"""
        DistributedPartyTeamActivity.setToonsPlaying(self, leftTeamToonIds,
                                                     rightTeamToonIds)

        # update table of right hands
        self.toonIdsToRightHands.clear()
        for toonId in self.getToonIdsAsList():
            toon = self.getAvatar(toonId)
            if toon:
                self.toonIdsToRightHands[toonId] = toon.getRightHands()[0]
コード例 #31
0
 def __init__(self,
              cr,
              arenaModel='phase_13/models/parties/cogPieArena_model',
              texture=None):
     DistributedPartyTeamActivity.__init__(
         self,
         cr,
         PartyGlobals.ActivityIds.PartyCog,
         startDelay=PartyGlobals.CogActivityStartDelay,
         balanceTeams=PartyGlobals.CogActivityBalanceTeams)
     self.arenaModel = arenaModel
     self.texture = texture
コード例 #32
0
    def announceGenerate(self):
        DistributedPartyTeamActivity.announceGenerate(self)

        # Because setToonsPlaying is a required field
        # And load is called at announceGenerate
        # The toons that are in that activity to be positioned
        # in the view after we get all the data and the view is loaded.
        for i in range(len(self.toonIds)):
            for toonId in self.toonIds[i]:
                toon = base.cr.doId2do.get(toonId, None)
                if toon:
                    self.view.handleToonJoined(toon, i, lateEntry=True)
コード例 #33
0
    def startActive(self):
        DistributedPartyTeamActivity.startActive(self)

        self.view.startActivity(self.getCurrentActivityTime())
        self.view.closeArenaDoors()

        # That extra second for lag + door intervals and so forth...
        # But show only if the local Toon is not playing in the activity.
        if not self.isLocalToonPlaying:
            self.view.showArenaDoorTimers(
                (self._duration + PartyGlobals.CogActivityConclusionDuration +
                 1.0) - self.getCurrentActivityTime())
コード例 #34
0
    def load(self):
        """
        Load the necessary assets
        """
        DistributedPartyTeamActivity.load(self)

        assert (self.notify.debug("load"))

        self.loadModels()
        self.loadGuiElements()
        self.loadSounds()
        self.loadIntervals()
        self.arrowKeys = ArrowKeys()
コード例 #35
0
    def handleToonJoined(self, toonId):
        """
        Whenever a new toon joins the activity, this function is called.
        
        Parameters:
            toonId -- doId of the toon that joined
        """
        DistributedPartyTeamActivity.handleToonJoined(self, toonId)

        toon = base.cr.doId2do.get(toonId, None)
        team = self.getTeam(toonId)

        if toon is not None and self.view is not None:
            self.view.handleToonJoined(toon, team)
コード例 #36
0
    def handleToonSwitchedTeams(self, toonId):
        """
        Whenever a toon's switches teams, this method is called.
        
        Parameters:
            toonId -- doId of the toon that switched
        """
        DistributedPartyTeamActivity.handleToonSwitchedTeams(self, toonId)
        toon = base.cr.doId2do.get(toonId, None)

        if toon is None:
            return

        if self.view is not None:
            self.view.handleToonSwitchedTeams(toon)
コード例 #37
0
    def handleToonJoined(self, toonId):
        DistributedPartyTeamActivity.handleToonJoined(self, toonId)

        self.toonIdsToAnimIntervals[toonId] = None

        if toonId == base.localAvatar.doId:
            base.cr.playGame.getPlace().fsm.request("activity")

            # set camera to a 3rd person view of play area
            camera.wrtReparentTo(self.root)
            self.cameraMoveIval = LerpPosHprInterval(
                camera,
                1.5,
                PartyGlobals.TugOfWarCameraPos,
                PartyGlobals.TugOfWarCameraInitialHpr,
                other=self.root,
            )
            self.cameraMoveIval.start()

            self.localToonPosIndex = self.getIndex(base.localAvatar.doId,
                                                   self.localToonTeam)
            self.notify.debug("posIndex: %d" % self.localToonPosIndex)

            toon = self.getAvatar(toonId)
            targetPos = self.dockPositions[self.localToonTeam][
                self.localToonPosIndex]
            # prevent toons from clipping through the dock by warping them to dock height
            if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
                toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
            targetH = fitDestAngle2Src(
                toon.getH(self.root),
                PartyGlobals.TugOfWarHeadings[self.localToonTeam])
            travelVector = targetPos - toon.getPos(self.root)
            duration = travelVector.length() / 5.0
            if self.toonIdsToAnimIntervals[toonId] is not None:
                self.toonIdsToAnimIntervals[toonId].finish()
            self.toonIdsToAnimIntervals[toonId] = Sequence(
                Func(toon.startPosHprBroadcast, 0.1),
                Func(toon.b_setAnimState, "run"),
                LerpPosHprInterval(toon,
                                   duration,
                                   targetPos,
                                   VBase3(targetH, 0.0, 0.0),
                                   other=self.root),
                Func(toon.stopPosHprBroadcast),
                Func(toon.b_setAnimState, "neutral"),
            )
            self.toonIdsToAnimIntervals[toonId].start()
コード例 #38
0
    def handleToonExited(self, toonId):
        """
        Whenever a toon exits the activity, this function is called.
        
        Parameters:
            toonId -- doId of the toon that exited
        """
        toon = base.cr.doId2do.get(toonId, None)

        if toon is None:
            return

        if self.view is not None:
            self.view.handleToonExited(toon)

        DistributedPartyTeamActivity.handleToonExited(self, toonId)
コード例 #39
0
 def startConclusion(self, data):
     DistributedPartyTeamActivity.startConclusion(self, data)
     if self.isLocalToonPlaying:
         winner = 2
         if data[PartyGlobals.TeamActivityTeams.LeftTeam] > data[PartyGlobals.TeamActivityTeams.RightTeam]:
             winner = PartyGlobals.TeamActivityTeams.LeftTeam
         elif data[PartyGlobals.TeamActivityTeams.LeftTeam] < data[PartyGlobals.TeamActivityTeams.RightTeam]:
             winner = PartyGlobals.TeamActivityTeams.RightTeam
         if winner < 2:
             if self.getTeam(base.localAvatar.doId) == winner:
                 resultsText = TTLocalizer.PartyTeamActivityLocalAvatarTeamWins
             else:
                 resultsText = TTLocalizer.PartyTeamActivityWins % TTLocalizer.PartyCogTeams[winner]
         else:
             resultsText = TTLocalizer.PartyTeamActivityGameTie
         self.view.showResults(resultsText, winner, data)
コード例 #40
0
 def __init__(self, cr):
     DistributedPartyTeamActivity.__init__(self, cr, PartyGlobals.ActivityIds.PartyTugOfWar, startDelay=PartyGlobals.TugOfWarStartDelay)
     self.buttons = [0, 1]
     self.arrowKeys = None
     self.keyTTL = []
     self.idealRate = 0.0
     self.keyRate = 0
     self.allOutMode = False
     self.rateMatchAward = 0.0
     self.toonIdsToStartPositions = {}
     self.toonIdsToIsPullingFlags = {}
     self.toonIdsToRightHands = {}
     self.fallenToons = []
     self.fallenPositions = []
     self.unusedFallenPositionsIndices = [0,
      1,
      2,
      3]
     self.toonIdsToAnimIntervals = {}
     self.tugRopes = []
コード例 #41
0
 def handleToonJoined(self, toonId):
     DistributedPartyTeamActivity.handleToonJoined(self, toonId)
     self.toonIdsToAnimIntervals[toonId] = None
     if toonId == base.localAvatar.doId:
         base.cr.playGame.getPlace().fsm.request('activity')
         camera.wrtReparentTo(self.root)
         self.cameraMoveIval = LerpPosHprInterval(
             camera,
             1.5,
             PartyGlobals.TugOfWarCameraPos,
             PartyGlobals.TugOfWarCameraInitialHpr,
             other=self.root)
         self.cameraMoveIval.start()
         self.localToonPosIndex = self.getIndex(base.localAvatar.doId,
                                                self.localToonTeam)
         self.notify.debug('posIndex: %d' % self.localToonPosIndex)
         toon = self.getAvatar(toonId)
         targetPos = self.dockPositions[self.localToonTeam][
             self.localToonPosIndex]
         if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
             toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
         targetH = fitDestAngle2Src(
             toon.getH(self.root),
             PartyGlobals.TugOfWarHeadings[self.localToonTeam])
         travelVector = targetPos - toon.getPos(self.root)
         duration = travelVector.length() / 5.0
         if self.toonIdsToAnimIntervals[toonId] is not None:
             self.toonIdsToAnimIntervals[toonId].finish()
         self.toonIdsToAnimIntervals[toonId] = Sequence(
             Func(toon.startPosHprBroadcast, 0.1),
             Func(toon.b_setAnimState, 'run'),
             LerpPosHprInterval(toon,
                                duration,
                                targetPos,
                                VBase3(targetH, 0.0, 0.0),
                                other=self.root),
             Func(toon.stopPosHprBroadcast),
             Func(toon.b_setAnimState, 'neutral'))
         self.toonIdsToAnimIntervals[toonId].start()
     return
コード例 #42
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]
コード例 #43
0
 def unload(self):
     DistributedPartyTeamActivity.unload(self)
     self.arrowKeys.destroy()
     self.unloadIntervals()
     self.unloadModels()
     self.unloadGuiElements()
     self.unloadSounds()
     if hasattr(self, 'toonIds'):
         del self.toonIds
     del self.buttons
     del self.arrowKeys
     del self.keyTTL
     del self.idealRate
     del self.keyRate
     del self.allOutMode
     del self.rateMatchAward
     del self.toonIdsToStartPositions
     del self.toonIdsToIsPullingFlags
     del self.toonIdsToRightHands
     del self.fallenToons
     del self.fallenPositions
     del self.unusedFallenPositionsIndices
     self.toonIdsToAnimIntervals.clear()
     del self.toonIdsToAnimIntervals
コード例 #44
0
 def finishConclusion(self):
     self.view.hideResults()
     DistributedPartyTeamActivity.finishConclusion(self)
     self.view.hideArenaDoorTimers()
コード例 #45
0
 def unload(self):
     if hasattr(self, 'view') and self.view is not None:
         self.view.unload()
         del self.view
     DistributedPartyTeamActivity.unload(self)
     return
コード例 #46
0
 def finishWaitForServer(self):
     DistributedPartyTeamActivity.finishWaitForServer(self)
     if self.activityFSM.getCurrentOrNextState() == 'WaitForEnough':
         self.hideRopes()
         self.hideControls()
コード例 #47
0
 def startRules(self):
     DistributedPartyTeamActivity.startRules(self)
     self.setUpRopes()
     if self.isLocalToonPlaying:
         self.showControls()
コード例 #48
0
 def finishWaitToStart(self):
     DistributedPartyTeamActivity.finishWaitToStart(self)
     self.__disableCollisions()
コード例 #49
0
 def delete(self):
     self._isWalkStateReadyFC.destroy()
     self._hopOffFinishedSV.destroy()
     self._rewardFinishedSV.destroy()
     DistributedPartyTeamActivity.delete(self)
コード例 #50
0
 def startWaitForEnough(self):
     DistributedPartyTeamActivity.startWaitForEnough(self)
     self.__enableCollisions()
コード例 #51
0
 def enable(self):
     DistributedPartyTeamActivity.enable(self)
コード例 #52
0
 def disable(self):
     DistributedPartyTeamActivity.disable(self)
コード例 #53
0
 def _testWalkStateReady(self, hoppedOff, rewardFinished):
     if hoppedOff and rewardFinished:
         DistributedPartyTeamActivity.handleRewardDone(self)
コード例 #54
0
 def load(self):
     DistributedPartyTeamActivity.load(self)
     self.view = PartyCogActivity(self, self.arenaModel, self.texture)
     self.view.load()
コード例 #55
0
 def finishConclusion(self):
     DistributedPartyTeamActivity.finishConclusion(self)
     self.fallenToons = []
コード例 #56
0
 def finishWaitForEnough(self):
     DistributedPartyTeamActivity.finishWaitForEnough(self)
     self.__disableCollisions()
コード例 #57
0
 def setAdvantage(self, advantage):
     DistributedPartyTeamActivity.setAdvantage(self, advantage)
     if self.isLocalToonPlaying:
         self.setIdealRate(PartyGlobals.TugOfWarTargetRateList[0][1])
コード例 #58
0
 def startWaitToStart(self, waitStartTimestamp):
     DistributedPartyTeamActivity.startWaitToStart(self, waitStartTimestamp)
     self.__enableCollisions()