当前位置: 首页>>代码示例>>Python>>正文


Python ToonBarrier.cleanup方法代码示例

本文整理汇总了Python中toontown.ai.ToonBarrier.cleanup方法的典型用法代码示例。如果您正苦于以下问题:Python ToonBarrier.cleanup方法的具体用法?Python ToonBarrier.cleanup怎么用?Python ToonBarrier.cleanup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在toontown.ai.ToonBarrier的用法示例。


在下文中一共展示了ToonBarrier.cleanup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DistributedTwoDGameAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]
class DistributedTwoDGameAI(DistributedMinigameAI):
    notify = DirectNotifyGlobal.directNotify.newCategory('DistributedTwoDGameAI')

    def __init__(self, air, minigameId):
        try:
            self.DistributedTwoDGameAI_initialized
        except:
            self.DistributedTwoDGame_initialized = 1
            DistributedMinigameAI.__init__(self, air, minigameId)
            self.gameFSM = ClassicFSM.ClassicFSM('DistributedTwoDGameAI', [State.State('inactive', self.enterInactive, self.exitInactive, ['play']), State.State('play', self.enterPlay, self.exitPlay, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, ['inactive'])], 'inactive', 'inactive')
            self.addChildGameFSM(self.gameFSM)
            self.finishedBonusDict = {}
            self.finishedTimeLeftDict = {}
            self.numFallDownDict = {}
            self.numHitByEnemyDict = {}
            self.numSquishDict = {}
            self.treasuresCollectedDict = {}
            self.sectionsSelected = []
            self.enemyHealthTable = []
            self.treasureTakenTable = []
            self.sectionIndexList = []

    def generate(self):
        self.notify.debug('generate')
        DistributedMinigameAI.generate(self)

    def delete(self):
        self.notify.debug('delete')
        del self.gameFSM
        DistributedMinigameAI.delete(self)

    def setTrolleyZone(self, trolleyZone):
        DistributedMinigameAI.setTrolleyZone(self, trolleyZone)
        self.setupSections()

    def setGameReady(self):
        self.notify.debug('setGameReady')
        DistributedMinigameAI.setGameReady(self)
        self.numTreasures = ToonBlitzGlobals.NumTreasures
        self.numEnemies = ToonBlitzGlobals.NumEnemies
        self.numTreasuresTaken = 0
        self.numEnemiesKilled = 0
        for avId in self.scoreDict.keys():
            self.scoreDict[avId] = 0
            self.finishedBonusDict[avId] = 0
            self.finishedTimeLeftDict[avId] = -1
            self.numFallDownDict[avId] = 0
            self.numHitByEnemyDict[avId] = 0
            self.numSquishDict[avId] = 0
            self.treasuresCollectedDict[avId] = [0,
             0,
             0,
             0]

        for i in xrange(len(self.sectionsSelected)):
            sectionIndex = self.sectionsSelected[i][0]
            attribs = ToonBlitzGlobals.SectionTypes[sectionIndex]
            enemiesPool = attribs[3]
            self.enemyHealthTable += [[]]
            enemyIndicesSelected = self.sectionsSelected[i][1]
            for j in xrange(len(enemyIndicesSelected)):
                enemyIndex = enemyIndicesSelected[j]
                enemyType = enemiesPool[enemyIndex][0]
                self.enemyHealthTable[i] += [ToonBlitzGlobals.EnemyBaseHealth]
                self.enemyHealthTable[i][j] *= self.numPlayers
                if enemyType in ToonBlitzGlobals.EnemyHealthMultiplier:
                    self.enemyHealthTable[i][j] *= ToonBlitzGlobals.EnemyHealthMultiplier[enemyType]

            self.treasureTakenTable += [[]]
            treasureIndicesSelected = self.sectionsSelected[i][2]
            for j in xrange(len(treasureIndicesSelected)):
                self.treasureTakenTable[i] += [0]

            enemyIndicesSelected = self.sectionsSelected[i][1]
            for j in xrange(len(enemyIndicesSelected)):
                self.treasureTakenTable[i] += [0]

    def setGameStart(self, timestamp):
        self.notify.debug('setGameStart')
        DistributedMinigameAI.setGameStart(self, timestamp)
        self.gameFSM.request('play')

    def setGameAbort(self):
        self.notify.debug('setGameAbort')
        if self.gameFSM.getCurrentState():
            self.gameFSM.request('cleanup')
        DistributedMinigameAI.setGameAbort(self)

    def gameOver(self):
        self.notify.debug('gameOver')
        scoreList = []
        finishedBonusList = []
        timeLeftList = []
        treasureCollectedList = []
        playerErrorList = []
        for avId in self.avIdList:
            scoreList.append(self.scoreDict[avId])
            finishedBonusList.append(self.finishedBonusDict[avId])
            timeLeftList.append(self.finishedTimeLeftDict[avId])
            treasureCollectedList.append(self.treasuresCollectedDict[avId])
#.........这里部分代码省略.........
开发者ID:CalmBit,项目名称:ToonboxSource,代码行数:103,代码来源:DistributedTwoDGameAI.py

示例2: DistributedGolfHoleAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]
class DistributedGolfHoleAI(DistributedPhysicsWorldAI.DistributedPhysicsWorldAI, FSM, GolfHoleBase.GolfHoleBase):
    defaultTransitions = {'Off': ['Cleanup', 'WaitTee'],
     'WaitTee': ['WaitSwing',
                 'Cleanup',
                 'WaitTee',
                 'WaitPlayback'],
     'WaitSwing': ['WaitPlayback',
                   'Cleanup',
                   'WaitSwing',
                   'WaitTee'],
     'WaitPlayback': ['WaitSwing',
                      'Cleanup',
                      'WaitTee',
                      'WaitPlayback'],
     'Cleanup': ['Off']}
    id = 0
    notify = directNotify.newCategory('DistributedGolfHoleAI')

    def __init__(self, zoneId, golfCourse, holeId):
        FSM.__init__(self, 'Golf_%s_FSM' % self.id)
        DistributedPhysicsWorldAI.DistributedPhysicsWorldAI.__init__(self, simbase.air)
        GolfHoleBase.GolfHoleBase.__init__(self)
        self.zoneId = zoneId
        self.golfCourse = golfCourse
        self.holeId = holeId
        self.avIdList = golfCourse.avIdList[:]
        self.watched = [0,
         0,
         0,
         0]
        self.barrierPlayback = None
        self.trustedPlayerId = None
        self.activeGolferIndex = None
        self.activeGolferId = None
        self.holeInfo = GolfGlobals.HoleInfo[self.holeId]
        self.teeChosen = {}
        for avId in self.avIdList:
            self.teeChosen[avId] = -1

        self.ballPos = {}
        for avId in self.avIdList:
            self.ballPos[avId] = Vec3(0, 0, 0)

        self.playStarted = False
        return

    def curGolfBall(self):
        return self.ball

    def generate(self):
        DistributedPhysicsWorldAI.DistributedPhysicsWorldAI.generate(self)
        self.ball = self.createBall()
        self.createRays()
        if len(self.teePositions) > 1:
            startPos = self.teePositions[1]
        else:
            startPos = self.teePositions[0]
        startPos += Vec3(0, 0, GolfGlobals.GOLF_BALL_RADIUS)
        self.ball.setPosition(startPos)

    def delete(self):
        self.notify.debug('__delete__')
        DistributedPhysicsWorldAI.DistributedPhysicsWorldAI.delete(self)
        self.notify.debug('calling self.terrainModel.removeNode')
        self.terrainModel.removeNode()
        self.notify.debug('self.barrierPlayback is %s' % self.barrierPlayback)
        if self.barrierPlayback:
            self.notify.debug('calling self.barrierPlayback.cleanup')
            self.barrierPlayback.cleanup()
            self.notify.debug('calling self.barrierPlayback = None')
            self.barrierPlayback = None
        self.activeGolferId = None
        return

    def setZoneId(self, zoneId):
        self.zoneId = zoneId

    def setAvatarReadyHole(self):
        self.notify.debugStateCall(self)
        avId = self.air.getAvatarIdFromSender()
        self.golfCourse.avatarReadyHole(avId)

    def startPlay(self):
        self.notify.debug('startPlay')
        self.playStarted = True
        self.numGolfers = len(self.golfCourse.getGolferIds())
        self.selectNextGolfer()

    def selectNextGolfer(self):
        self.notify.debug('selectNextGolfer, old golferIndex=%s old golferId=%s' % (self.activeGolferIndex, self.activeGolferId))
        if self.golfCourse.isCurHoleDone():
            return
        if self.activeGolferIndex == None:
            self.activeGolferIndex = 0
            self.activeGolferId = self.golfCourse.getGolferIds()[self.activeGolferIndex]
        else:
            self.activeGolferIndex += 1
            if self.activeGolferIndex >= len(self.golfCourse.getGolferIds()):
                self.activeGolferIndex = 0
            self.activeGolferId = self.golfCourse.getGolferIds()[self.activeGolferIndex]
#.........这里部分代码省略.........
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:103,代码来源:DistributedGolfHoleAI.py

示例3: DistributedMinigameAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]

#.........这里部分代码省略.........
            self.stateDict[avId] = EXPECTED
            self.scoreDict[avId] = DEFAULT_POINTS
            self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs = [
                avId])
        
        
        def allAvatarsJoined(self = self):
            self.notify.debug('BASE: all avatars joined')
            self.b_setGameReady()
            self.frameworkFSM.request('frameworkWaitClientsReady')

        
        def handleTimeout(avIds, self = self):
            self.notify.debug('BASE: timed out waiting for clients %s to join' % avIds)
            self.setGameAbort()

        self._DistributedMinigameAI__barrier = ToonBarrier('waitClientsJoin', self.uniqueName('waitClientsJoin'), self.avIdList, JOIN_TIMEOUT, allAvatarsJoined, handleTimeout)

    
    def setAvatarJoined(self):
        if self.frameworkFSM.getCurrentState().getName() != 'frameworkWaitClientsJoin':
            self.notify.debug('BASE: Ignoring setAvatarJoined message')
            return None
        
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug('BASE: setAvatarJoined: avatar id joined: ' + str(avId))
        self.air.writeServerEvent('minigame_joined', avId, '%s|%s' % (self.minigameId, self.trolleyZone))
        self.stateDict[avId] = JOINED
        self.notify.debug('BASE: setAvatarJoined: new states: ' + str(self.stateDict))
        self._DistributedMinigameAI__barrier.clear(avId)

    
    def exitFrameworkWaitClientsJoin(self):
        self._DistributedMinigameAI__barrier.cleanup()
        del self._DistributedMinigameAI__barrier

    
    def enterFrameworkWaitClientsReady(self):
        self.notify.debug('BASE: enterFrameworkWaitClientsReady')
        
        def allAvatarsReady(self = self):
            self.notify.debug('BASE: all avatars ready')
            self.frameworkFSM.request('frameworkGame')

        
        def handleTimeout(avIds, self = self):
            self.notify.debug("BASE: timed out waiting for clients %s to report 'ready'" % avIds)
            self.setGameAbort()

        self._DistributedMinigameAI__barrier = ToonBarrier('waitClientsReady', self.uniqueName('waitClientsReady'), self.avIdList, READY_TIMEOUT, allAvatarsReady, handleTimeout)
        for avId in self.stateDict.keys():
            if self.stateDict[avId] == READY:
                self._DistributedMinigameAI__barrier.clear(avId)
                continue
        
        self.notify.debug('  safezone: %s' % self.getSafezoneId())
        self.notify.debug('difficulty: %s' % self.getDifficulty())

    
    def setAvatarReady(self):
        if self.frameworkFSM.getCurrentState().getName() not in [
            'frameworkWaitClientsReady',
            'frameworkWaitClientsJoin']:
            self.notify.debug('BASE: Ignoring setAvatarReady message')
            return None
        
开发者ID:ponyboy837,项目名称:Toontown-2003-Server,代码行数:69,代码来源:DistributedMinigameAI.py

示例4: DistributedPatternGameAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]
class DistributedPatternGameAI(DistributedMinigameAI):
    def __init__(self, air, minigameId):
        try:
            self.DistributedPatternGameAI_initialized
        except:
            self.DistributedPatternGameAI_initialized = 1
            DistributedMinigameAI.__init__(self, air, minigameId)
            self.gameFSM = ClassicFSM.ClassicFSM(
                "DistributedPatternGameAI",
                [
                    State.State("off", self.enterInactive, self.exitInactive, ["waitClientsReady", "cleanup"]),
                    State.State(
                        "waitClientsReady",
                        self.enterWaitClientsReady,
                        self.exitWaitClientsReady,
                        ["generatePattern", "cleanup"],
                    ),
                    State.State(
                        "generatePattern",
                        self.enterGeneratePattern,
                        self.exitGeneratePattern,
                        ["waitForResults", "cleanup"],
                    ),
                    State.State(
                        "waitForResults",
                        self.enterWaitForResults,
                        self.exitWaitForResults,
                        ["waitClientsReady", "cleanup"],
                    ),
                    State.State("cleanup", self.enterCleanup, self.exitCleanup, []),
                ],
                "off",
                "cleanup",
            )
            self.addChildGameFSM(self.gameFSM)

    def delete(self):
        self.notify.debug("delete")
        del self.gameFSM
        DistributedMinigameAI.delete(self)

    def setGameReady(self):
        self.notify.debug("setGameReady")
        DistributedMinigameAI.setGameReady(self)
        self.__initGameVars()

    def setGameStart(self, timestamp):
        self.notify.debug("setGameStart")
        DistributedMinigameAI.setGameStart(self, timestamp)
        self.gameFSM.request("waitClientsReady")

    def setGameAbort(self):
        self.notify.debug("setGameAbort")
        if self.gameFSM.getCurrentState():
            self.gameFSM.request("cleanup")
        DistributedMinigameAI.setGameAbort(self)

    def gameOver(self):
        self.notify.debug("gameOver")
        self.gameFSM.request("cleanup")
        DistributedMinigameAI.gameOver(self)

    def enterInactive(self):
        self.notify.debug("enterInactive")

    def exitInactive(self):
        pass

    def __initGameVars(self):
        self.pattern = []
        self.round = 0
        self.perfectResults = {}
        for avId in self.avIdList:
            self.perfectResults[avId] = 1

        self.readyClients = []
        self.timeoutTaskName = self.uniqueName("PatternGameResultsTimeout")

    def enterWaitClientsReady(self):
        self.notify.debug("enterWaitClientsReady")
        self.nextRoundBarrier = ToonBarrier(
            "nextRoundReady",
            self.uniqueName("nextRoundReady"),
            self.avIdList,
            PatternGameGlobals.ClientsReadyTimeout,
            self.__allPlayersReady,
            self.__clientsReadyTimeout,
        )
        for avId in self.readyClients:
            self.nextRoundBarrier.clear(avId)

    def reportPlayerReady(self):
        if not self._inState("waitClientsReady"):
            return
        avId = self.air.getAvatarIdFromSender()
        if avId not in self.avIdList:
            self.notify.warning("Got reportPlayerReady from an avId: %s not in our list: %s" % (avId, self.avIdList))
        else:
            self.readyClients.append(avId)
            self.nextRoundBarrier.clear(avId)
#.........这里部分代码省略.........
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:103,代码来源:DistributedPatternGameAI.py

示例5: DistributedCatchGameAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]
class DistributedCatchGameAI(DistributedMinigameAI):
    
    def __init__(self, air, minigameId):
        
        try:
            pass
        except:
            self.DistributedCatchGameAI_initialized = 1
            DistributedMinigameAI.__init__(self, air, minigameId)
            self.gameFSM = ClassicFSM.ClassicFSM('DistributedCatchGameAI', [
                State.State('inactive', self.enterInactive, self.exitInactive, [
                    'play']),
                State.State('play', self.enterPlay, self.exitPlay, [
                    'cleanup']),
                State.State('cleanup', self.enterCleanup, self.exitCleanup, [
                    'inactive'])], 'inactive', 'inactive')
            self.addChildGameFSM(self.gameFSM)


    
    def generate(self):
        self.notify.debug('generate')
        DistributedMinigameAI.generate(self)

    
    def delete(self):
        self.notify.debug('delete')
        del self.gameFSM
        DistributedMinigameAI.delete(self)

    
    def setGameReady(self):
        self.notify.debug('setGameReady')
        DistributedMinigameAI.setGameReady(self)

    
    def setGameStart(self, timestamp):
        self.notify.debug('setGameStart')
        DistributedMinigameAI.setGameStart(self, timestamp)
        self.gameFSM.request('play')

    
    def setGameAbort(self):
        self.notify.debug('setGameAbort')
        if self.gameFSM.getCurrentState():
            self.gameFSM.request('cleanup')
        
        DistributedMinigameAI.setGameAbort(self)

    
    def gameOver(self):
        self.notify.debug('gameOver')
        self.notify.debug('fruits: %s, fruits caught: %s' % (self.numFruits, self.fruitsCaught))
        perfect = self.fruitsCaught >= self.numFruits
        for avId in self.avIdList:
            self.scoreDict[avId] = max(1, int(self.scoreDict[avId] / 2))
            if perfect:
                self.notify.debug('PERFECT GAME!')
                self.scoreDict[avId] += round(self.numFruits / 4.0)
                self.logAllPerfect()
                continue
        
        self.gameFSM.request('cleanup')
        DistributedMinigameAI.gameOver(self)

    
    def enterInactive(self):
        self.notify.debug('enterInactive')

    
    def exitInactive(self):
        pass

    
    def enterPlay(self):
        self.notify.debug('enterPlay')
        self.caughtList = [
            0] * 100
        table = CatchGameGlobals.NumFruits[self.numPlayers - 1]
        self.numFruits = table[self.getSafezoneId()]
        self.notify.debug('numFruits: %s' % self.numFruits)
        self.fruitsCaught = 0
        
        def allToonsDone(self = self):
            self.notify.debug('allToonsDone')
            self.sendUpdate('setEveryoneDone')
            if not CatchGameGlobals.EndlessGame:
                self.gameOver()
            

        
        def handleTimeout(avIds, self = self):
            self.notify.debug('handleTimeout: avatars %s did not report "done"' % avIds)
            self.setGameAbort()

        self.doneBarrier = ToonBarrier('waitClientsDone', self.uniqueName('waitClientsDone'), self.avIdList, CatchGameGlobals.GameDuration + MinigameGlobals.latencyTolerance, allToonsDone, handleTimeout)

    
    def exitPlay(self):
        del self.caughtList
#.........这里部分代码省略.........
开发者ID:OldToontown,项目名称:OldToontown,代码行数:103,代码来源:DistributedCatchGameAI.py

示例6: DistributedGolfCourseAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]
class DistributedGolfCourseAI(DistributedObjectAI.DistributedObjectAI, FSM):
    notify = directNotify.newCategory('DistributedGolfCourseAI')
    defaultTransitions = {'Off': ['WaitJoin'],
     'WaitJoin': ['WaitReadyCourse', 'Cleanup'],
     'WaitReadyCourse': ['WaitReadyHole', 'Cleanup'],
     'WaitReadyHole': ['PlayHole',
                       'Cleanup',
                       'WaitLeaveHole',
                       'WaitReward'],
     'PlayHole': ['PlayHole',
                  'WaitLeaveHole',
                  'Cleanup',
                  'WaitReward'],
     'WaitLeaveHole': ['WaitReadyHole',
                       'WaitLeaveCourse',
                       'Cleanup',
                       'WaitReward'],
     'WaitReward': ['WaitLeaveCourse', 'Cleanup', 'WaitLeaveHole'],
     'WaitLeaveCourse': ['Cleanup'],
     'Cleanup': ['Off']}

    def __init__(self, zoneId, avIds, courseId, preferredHoleId = None):
        FSM.__init__(self, 'GolfCourse_%s_FSM' % zoneId)
        DistributedObjectAI.DistributedObjectAI.__init__(self, simbase.air)
        self.notify.debug('GOLF COURSE: init')
        self.zoneId = zoneId
        self.currentHole = None
        self.avIdList = []
        self.avStateDict = {}
        self.addExpectedGolfers(avIds)
        self.courseId = courseId
        self.preferredHoleId = preferredHoleId
        self.courseInfo = GolfGlobals.CourseInfo[self.courseId]
        self.numHoles = self.courseInfo['numHoles']
        self.holeIds = self.calcHolesToUse()
        self.notify.debug('self.holeIds = %s' % self.holeIds)
        self.numHolesPlayed = 0
        self.curHoleIndex = 0
        self.trophyListLen = 0
        self.courseBestListLen = 0
        self.holeBestListLen = 0
        self.cupListLen = 0
        self.scores = {}
        self.aimTimes = {}
        self.startingHistory = {}
        self.endingHistory = {}
        self.startingHoleBest = {}
        self.endingHoleBest = {}
        self.startingCourseBest = {}
        self.endingCourseBest = {}
        self.startingCups = {}
        self.endingCups = {}
        self.initHistory()
        self.newTrophies = {}
        self.newHoleBest = {}
        self.newCourseBest = {}
        self.newCups = {}
        self.drivingToons = []
        self.__barrier = None
        self.winnerByTieBreak = 0
        return

    def initHistory(self):
        for avId in self.avIdList:
            av = simbase.air.doId2do.get(avId)
            if av:
                history = av.getGolfHistory()
                self.startingHistory[avId] = history[:]
                self.endingHistory[avId] = history[:]
                holeBest = av.getGolfHoleBest()
                self.startingHoleBest[avId] = holeBest[:]
                self.endingHoleBest[avId] = holeBest[:]
                courseBest = av.getGolfCourseBest()
                self.startingCourseBest[avId] = courseBest[:]
                self.endingCourseBest[avId] = courseBest[:]

    def generate(self):
        DistributedObjectAI.DistributedObjectAI.generate(self)
        self.grabGolfers()

    def delete(self):
        self.notify.debug('GOLF COURSE: delete: deleting AI GolfCourse object')
        if hasattr(self, 'rewardBarrier'):
            self.rewardBarrier.cleanup()
            del self.rewardBarrier
        if self.currentHole:
            self.notify.debug('calling requestDelete on hole %d' % self.currentHole.doId)
            self.currentHole.requestDelete()
            self.currentHole = None
        self.ignoreAll()
        self.air.deallocateZone(self.zoneId)
        if self.__barrier:
            self.__barrier.cleanup()
            self.__barrier = None
        DistributedObjectAI.DistributedObjectAI.delete(self)
        return

    def load(self):
        self.b_setCourseReady()
        self.request('WaitReadyCourse')
#.........这里部分代码省略.........
开发者ID:AdrianF98,项目名称:Toontown-Rewritten,代码行数:103,代码来源:DistributedGolfCourseAI.py

示例7: DistributedMinigameAI

# 需要导入模块: from toontown.ai import ToonBarrier [as 别名]
# 或者: from toontown.ai.ToonBarrier import cleanup [as 别名]

#.........这里部分代码省略.........
            self.scoreDict[avId] = DEFAULT_POINTS
            self.acceptOnce(self.air.getAvatarExitEvent(avId), self.handleExitedAvatar, extraArgs=[avId])

        def allAvatarsJoined(self=self):
            self.notify.debug("BASE: all avatars joined")
            self.b_setGameReady()
            self.frameworkFSM.request("frameworkWaitClientsReady")

        def handleTimeout(avIds, self=self):
            self.notify.debug("BASE: timed out waiting for clients %s to join" % avIds)
            self.setGameAbort()

        self.__barrier = ToonBarrier(
            "waitClientsJoin",
            self.uniqueName("waitClientsJoin"),
            self.avIdList,
            JOIN_TIMEOUT,
            allAvatarsJoined,
            handleTimeout,
        )

    def setAvatarJoined(self):
        if self.frameworkFSM.getCurrentState().getName() != "frameworkWaitClientsJoin":
            self.notify.debug("BASE: Ignoring setAvatarJoined message")
            return
        avId = self.air.getAvatarIdFromSender()
        self.notify.debug("BASE: setAvatarJoined: avatar id joined: " + str(avId))
        self.air.writeServerEvent("minigame_joined", avId, "%s|%s" % (self.minigameId, self.trolleyZone))
        self.stateDict[avId] = JOINED
        self.notify.debug("BASE: setAvatarJoined: new states: " + str(self.stateDict))
        self.__barrier.clear(avId)

    def exitFrameworkWaitClientsJoin(self):
        self.__barrier.cleanup()
        del self.__barrier

    def enterFrameworkWaitClientsReady(self):
        self.notify.debug("BASE: enterFrameworkWaitClientsReady")

        def allAvatarsReady(self=self):
            self.notify.debug("BASE: all avatars ready")
            self.frameworkFSM.request("frameworkGame")

        def handleTimeout(avIds, self=self):
            self.notify.debug("BASE: timed out waiting for clients %s to report 'ready'" % avIds)
            self.setGameAbort()

        self.__barrier = ToonBarrier(
            "waitClientsReady",
            self.uniqueName("waitClientsReady"),
            self.avIdList,
            READY_TIMEOUT,
            allAvatarsReady,
            handleTimeout,
        )
        for avId in self.stateDict.keys():
            if self.stateDict[avId] == READY:
                self.__barrier.clear(avId)

        self.notify.debug("  safezone: %s" % self.getSafezoneId())
        self.notify.debug("difficulty: %s" % self.getDifficulty())

    def setAvatarReady(self):
        if self.frameworkFSM.getCurrentState().getName() not in [
            "frameworkWaitClientsReady",
            "frameworkWaitClientsJoin",
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:70,代码来源:DistributedMinigameAI.py


注:本文中的toontown.ai.ToonBarrier.cleanup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。