本文整理汇总了Python中toontown.racing.RaceGlobals类的典型用法代码示例。如果您正苦于以下问题:Python RaceGlobals类的具体用法?Python RaceGlobals怎么用?Python RaceGlobals使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RaceGlobals类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: createRace
def createRace(self):
self.raceZone = self.air.allocateZone()
avatars = []
for block in self.startingBlocks:
if block.avId != 0:
avatars.append(block.avId)
self.sendUpdateToAvatarId(block.avId, 'setRaceZone', [self.raceZone])
race = DistributedRaceAI(self.air)
race.setZoneId(self.raceZone)
race.setTrackId(self.trackId)
race.setRaceType(self.trackType)
race.setAvatars(avatars)
if self.trackType == RaceGlobals.Circuit:
race.setCircuitLoop(RaceGlobals.getCircuitLoop(self.trackId))
else:
race.setCircuitLoop([])
race.setStartingPlaces(range(len(avatars)))
race.setLapCount(3)
race.generateWithRequired(self.raceZone)
for avId in avatars:
if avId in self.air.doId2do:
av = self.air.doId2do[avId]
entryFee = RaceGlobals.getEntryFee(self.trackId, self.trackType)
if av.getTickets() < entryFee:
self.air.writeServerEvent('suspicious', avId, 'Toon somehow lost tickets between entering a race and it leaving!')
av.b_setTickets(0)
else:
av.b_setTickets(av.getTickets() - entryFee)
self.b_setState('WaitEmpty', globalClockDelta.getRealNetworkTime())
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:29,代码来源:DistributedRacePadAI.py
示例2: avatarFinished
def avatarFinished(self, avId):
if not avId in self.avatars:
self.air.writeServerEvent('suspicious', avId, 'Toon tried to finish in a race they\'re not in!')
return
if avId in self.finishedAvatars:
self.air.writeServerEvent('suspicious', avId, 'Toon tried to finish in a race twice!')
return
self.finishedAvatars.append(avId)
av = self.air.doId2do.get(avId)
place = len(self.finishedAvatars)
entryFee = RaceGlobals.getEntryFee(self.trackId, self.raceType)
bonus = 0
totalTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) - self.startTime
qualify = False
if totalTime < RaceGlobals.getQualifyingTime(self.trackId):
qualify = True
if self.raceType == RaceGlobals.Practice:
winnings = RaceGlobals.PracticeWinnings
trophies = []
elif qualify:
offset = 4 - len(self.avatarProgress) # self.avatarProgress contains the amount of STARTING players.
winnings = entryFee * RaceGlobals.Winnings[(place+offset)-1]
trophies = self.calculateTrophies(avId, place == 1, qualify, totalTime)
else:
winnings = 0
trophies = []
av.b_setTickets(av.getTickets() + winnings)
if av.getTickets() > RaceGlobals.MaxTickets:
av.b_setTickets(RaceGlobals.MaxTickets)
self.sendUpdate('setPlace', [avId, totalTime, place, entryFee, qualify, max((winnings-entryFee), 0), bonus, trophies, [], 0])
开发者ID:CalebSmith376,项目名称:src,代码行数:32,代码来源:DistributedRaceAI.py
示例3: avatarFinished
def avatarFinished(self, avId):
if not avId in self.avatars:
self.air.writeServerEvent("suspicious", avId, "Toon tried to finish in a race they're not in!")
return
if avId in self.finishedAvatars:
self.air.writeServerEvent("suspicious", avId, "Toon tried to finish in a race twice!")
return
self.finishedAvatars.append(avId)
av = self.air.doId2do.get(avId)
place = len(self.finishedAvatars)
listPlace = place + (4 - len(self.avatarProgress)) - 1
entryFee = RaceGlobals.getEntryFee(self.trackId, self.raceType)
bonus = 0
totalTime = globalClockDelta.networkToLocalTime(globalClockDelta.getRealNetworkTime()) - self.startTime
qualify = False
if totalTime < RaceGlobals.getQualifyingTime(self.trackId):
qualify = True
self.air.leaderboardMgr.submitRace(self.trackId, av.getName(), totalTime)
if self.raceType == RaceGlobals.Practice:
winnings = RaceGlobals.PracticeWinnings
trophies = []
elif qualify:
winnings = entryFee * RaceGlobals.Winnings[listPlace]
trophies = self.calculateTrophies(avId, place == 1, qualify, totalTime)
else:
winnings = 0
trophies = []
av.b_setTickets(av.getTickets() + winnings)
if av.getTickets() > RaceGlobals.MaxTickets:
av.b_setTickets(RaceGlobals.MaxTickets)
av.addStat(ToontownGlobals.STAT_RACING)
points = []
if self.circuitPoints:
avIndex = self.avatars.index(avId)
points = self.circuitPoints[avIndex]
points[0] += points[1]
points[1] = RaceGlobals.CircuitPoints[place - 1]
self.sendUpdate(
"setPlace",
[avId, totalTime, place, entryFee, qualify, max((winnings - entryFee), 0), bonus, trophies, points, 0],
)
if self.circuitPoints:
self.circuitWinnings[avIndex] += winnings
self.sendUpdate("setCircuitPlace", [avId, place, entryFee, self.circuitWinnings[avIndex], bonus, trophies])
if len(self.finishedAvatars) == len(self.avatars):
del self.circuitLoop[0]
self.sendUpdate("setCircuitLoop", [self.circuitLoop])
self.sendUpdate("endCircuitRace")
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:51,代码来源:DistributedRaceAI.py
示例4: findRacingPads
def findRacingPads(self, dnaGroup, zoneId, area, padType='racing_pad'):
racingPads = []
racingPadGroups = []
if isinstance(dnaGroup, DNAGroup) and (padType in dnaGroup.getName()):
racingPadGroups.append(dnaGroup)
if padType == 'racing_pad':
nameInfo = dnaGroup.getName().split('_')
racingPad = DistributedRacePadAI(simbase.air)
racingPad.setArea(zoneId)
racingPad.nameType = nameInfo[3]
racingPad.index = int(nameInfo[2])
nextRaceInfo = RaceGlobals.getNextRaceInfo(-1, racingPad.nameType, racingPad.index)
racingPad.setTrackInfo([nextRaceInfo[0], nextRaceInfo[1]])
racingPad.generateWithRequired(zoneId)
elif padType == 'viewing_pad':
racingPad = DistributedViewPadAI(simbase.air)
racingPad.setArea(zoneId)
racingPad.generateWithRequired(zoneId)
else:
self.notify.error('Invalid racing pad type: ' + padType)
racingPads.append(racingPad)
elif isinstance(dnaGroup, DNAVisGroup):
zoneId = ZoneUtil.getTrueZoneId(int(dnaGroup.getName().split(':')[0]), zoneId)
for i in xrange(dnaGroup.getNumChildren()):
(foundRacingPads, foundRacingPadGroups) = self.findRacingPads(dnaGroup.at(i), zoneId, area, padType=padType)
racingPads.extend(foundRacingPads)
racingPadGroups.extend(foundRacingPadGroups)
return (racingPads, racingPadGroups)
开发者ID:nate97,项目名称:src,代码行数:30,代码来源:GSHoodAI.py
示例5: __handleEnterSphere
def __handleEnterSphere(self, collEntry):
if base.localAvatar.doId == self.lastAvId and globalClock.getFrameCount() <= self.lastFrame + 1:
self.notify.debug('Ignoring duplicate entry for avatar.')
return
if base.localAvatar.hp > 0:
def handleEnterRequest(self = self):
self.ignore('stoppedAsleep')
if hasattr(self.dialog, 'doneStatus') and self.dialog.doneStatus == 'ok':
self.d_requestEnter(base.cr.isPaid())
elif self.cr and not self.isDisabled():
self.cr.playGame.getPlace().setState('walk')
else:
self.notify.warning('Warning! Object has already been disabled.')
self.dialog.ignoreAll()
self.dialog.cleanup()
del self.dialog
self.cr.playGame.getPlace().fsm.request('stopped')
self.accept('stoppedAsleep', handleEnterRequest)
doneEvent = 'enterRequest|dialog'
if self.kartPad.isPractice():
msg = TTLocalizer.StartingBlock_EnterPractice
else:
raceName = TTLocalizer.KartRace_RaceNames[self.kartPad.trackType]
numTickets = RaceGlobals.getEntryFee(self.kartPad.trackId, self.kartPad.trackType)
msg = TTLocalizer.StartingBlock_EnterNonPractice % (raceName, numTickets)
self.dialog = TTGlobalDialog(msg, doneEvent, 4)
self.dialog.accept(doneEvent, handleEnterRequest)
开发者ID:FelixBucket,项目名称:ToontownFritzServer,代码行数:29,代码来源:DistributedStartingBlock.py
示例6: requestEnter
def requestEnter(self, isPaid):
avId = self.air.getAvatarIdFromSender()
av = self.air.doId2do.get(avId)
if not av:
self.air.writeServerEvent(
'suspicious', avId=avId,
issue='Toon tried to board a starting block, but is not on the district!')
return
if not av.hasKart():
self.sendUpdateToAvatarId(
avId, 'rejectEnter', [
KartGlobals.ERROR_CODE.eNoKart])
return
if av.getTickets() < RaceGlobals.getEntryFee(
self.pad.trackId, self.pad.trackType):
self.sendUpdateToAvatarId(
avId, 'rejectEnter', [
KartGlobals.ERROR_CODE.eTickets])
return
if self.pad.state == 'AllAboard' or self.pad.state == 'WaitBoarding':
self.sendUpdateToAvatarId(
avId, 'rejectEnter', [
KartGlobals.ERROR_CODE.eBoardOver])
return
if self.avId != 0:
if self.avId == avId:
self.air.writeServerEvent(
'suspicious', avId=avId,
issue='Toon tried to board the same starting block twice!')
self.sendUpdateToAvatarId(
avId, 'rejectEnter', [
KartGlobals.ERROR_CODE.eOccupied])
return
self.b_setOccupied(avId)
self.b_setMovie(KartGlobals.ENTER_MOVIE)
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:35,代码来源:DistributedStartingBlockAI.py
示例7: calculateTrophies
def calculateTrophies(self, avId, won, qualify, time):
av = self.air.doId2do[avId]
kartingHistory = av.getKartingHistory()
avTrophies = av.getKartingTrophies()
numTrophies = 0
for i in range(30):
if avTrophies[i] != 0:
numTrophies += 1
oldLaffBoost = int(numTrophies / 10)
genre = RaceGlobals.getTrackGenre(self.trackId)
trophies = []
if won:
kartingHistory[genre] += 1
kartingHistory[3] += 1
if kartingHistory[3] > RaceGlobals.TotalWonRaces:
avTrophies[RaceGlobals.TotalWins] = 1
trophies.append(RaceGlobals.TotalWins)
for i in range(3):
if kartingHistory[genre] >= RaceGlobals.WonRaces[
i] and avTrophies[RaceGlobals.AllWinsList[genre][i]] != 1:
avTrophies[RaceGlobals.AllWinsList[genre][i]] = 1
trophies.append(RaceGlobals.AllWinsList[genre][i])
if qualify:
kartingHistory[genre + 4] += 1
kartingHistory[7] += 1
if kartingHistory[7] >= RaceGlobals.TotalQualifiedRaces and avTrophies[
RaceGlobals.TotalQuals] != 1:
avTrophies[RaceGlobals.TotalQuals] = 1
trophies.append(RaceGlobals.TotalQuals)
for i in range(3):
if kartingHistory[
genre +
4] >= RaceGlobals.QualifiedRaces[i] and avTrophies[
RaceGlobals.AllQualsList[genre][i]] != 1:
avTrophies[RaceGlobals.AllQualsList[genre][i]] = 1
trophies.append(RaceGlobals.AllQualsList[genre][i])
av.b_setKartingHistory(kartingHistory)
pKartingBest = av.getKartingPersonalBestAll()
trackIndex = TTLocalizer.KartRace_TrackNames.keys().index(self.trackId)
if pKartingBest[trackIndex] > time or not pKartingBest[trackIndex]:
pKartingBest[trackIndex] = time
av.b_setKartingPersonalBest(pKartingBest)
gTourTrophy = True
for bestTime in pKartingBest:
if not bestTime:
gTourTrophy = False
if gTourTrophy:
if avTrophies[RaceGlobals.GrandTouring] != 1:
avTrophies[RaceGlobals.GrandTouring] = 1
trophies.append(RaceGlobals.GrandTouring)
newLaffBoost = int((len(trophies) + numTrophies) / 10)
if newLaffBoost - oldLaffBoost != 0:
for i in range(newLaffBoost):
if avTrophies[RaceGlobals.TrophyCups[i]] != 1:
avTrophies[RaceGlobals.TrophyCups[i]] = 1
trophies.append(RaceGlobals.TrophyCups[i])
av.b_setMaxHp(av.getMaxHp() + newLaffBoost - oldLaffBoost)
av.toonUp(av.getMaxHp())
av.b_setKartingTrophies(avTrophies)
return trophies
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:60,代码来源:DistributedRaceAI.py
示例8: updateTunnelSignText
def updateTunnelSignText(self):
self.notify.debugStateCall(self)
trackNameString = TTLocalizer.KartRace_TrackNames[self.trackId]
if not self.trackNameNode:
self.notify.warning('invalid trackNameNode, just returning')
return
self.trackNameNode.setText(trackNameString)
trackTypeString = TTLocalizer.KartRace_RaceNames[self.trackType]
self.trackTypeNode.setText(trackTypeString)
deposit = 0
if self.trackType:
deposit = RaceGlobals.getEntryFee(self.trackId, self.trackType)
depositString = TTLocalizer.KartRace_DepositPhrase + str(deposit)
self.depositNode.setText(depositString)
time = RaceGlobals.TrackDict[self.trackId][1]
secs, hundredths = divmod(time, 1)
min, sec = divmod(secs, 60)
timeText = '%02d:%02d:%02d' % (min, sec, hundredths * 100)
qualifyString = TTLocalizer.KartRace_QualifyPhrase + timeText
self.qualifyNode.setText(qualifyString)
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:20,代码来源:DistributedRacePad.py
示例9: spawn
def spawn(air, zone, element, match):
index = int(match.group(1))
dest = match.group(2)
pad = DistributedRacePadAI(air)
pad.setArea(zone)
pad.nameType = dest
pad.index = index
nri = RaceGlobals.getNextRaceInfo(-1, dest, index)
pad.setTrackInfo(nri[:2])
pad.generateWithRequired(zone)
for child in element.children:
if isinstance(child, DNAProp) and child.code == 'gs_parkingspot':
index = int(child.name[15:])
x, y, z = child.getPos()
h, p, r = child.getHpr()
startingBlock = DistributedStartingBlockAI(air)
startingBlock.setPosHpr(x, y, z, h, p, r)
startingBlock.setPadDoId(pad.getDoId())
startingBlock.setPadLocationId(index)
startingBlock.generateWithRequired(zone)
pad.addStartingBlock(startingBlock)
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:21,代码来源:DistributedRacePadAI.py
示例10: changeTrack
def changeTrack(self):
nri = RaceGlobals.getNextRaceInfo(self.trackId, self.nameType, self.index)
self.b_setTrackInfo([nri[0], nri[1]])
taskMgr.doMethodLater(30, DistributedRacePadAI.changeTrack, 'changeTrack%i' % self.doId, [self])
开发者ID:nate97,项目名称:src,代码行数:4,代码来源:DistributedRacePadAI.py
示例11: getTunnelSign
def getTunnelSign(self):
cPadId = RaceGlobals.RaceInfo2RacePadId(self.trackId, self.trackType)
genreId = RaceGlobals.getTrackGenre(self.trackId)
tunnelName = RaceGlobals.getTunnelSignName(genreId, cPadId)
self.tunnelSign = self.cr.playGame.hood.loader.geom.find(
'**/' + tunnelName)
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:6,代码来源:DistributedRacePad.py
示例12: _createObjects
def _createObjects(self, group, zone):
if group.getName()[:13] == 'fishing_pond_':
visGroup = group.getVisGroup()
pondZone = 0
if visGroup is None:
pondZone = zone
else:
pondZone = int(visGroup.getName().split(':')[0])
pondIndex = int(group.getName()[13:])
pond = DistributedFishingPondAI(simbase.air)
pond.setArea(zone)
pond.generateWithRequired(pondZone)
#self.ponds[pondIndex] = pond
bingoManager = DistributedPondBingoManagerAI(simbase.air)
bingoManager.setPondDoId(pond.getDoId())
bingoManager.generateWithRequired(pondZone)
#temporary, until we have scheduled stuff
bingoManager.createGame()
pond.bingoMgr = bingoManager
simbase.air.fishManager.ponds[zone] = pond
for i in range(FishingTargetGlobals.getNumTargets(zone)):
target = DistributedFishingTargetAI(simbase.air)
target.setPondDoId(pond.getDoId())
target.generateWithRequired(pondZone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:13] == 'fishing_spot_':
spot = DistributedFishingSpotAI(simbase.air)
spot.setPondDoId(pond.getDoId())
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
spot.setPosHpr(x, y, z, h, p, r)
spot.generateWithRequired(pondZone)
NPCToons.createNpcsInZone(simbase.air, pondZone)
elif group.getName()[:10] == 'racing_pad':
index, dest = group.getName()[11:].split('_', 2)
index = int(index)
pad = DistributedRacePadAI(simbase.air)
pad.setArea(zone)
pad.nameType = dest
pad.index = index
nri = RaceGlobals.getNextRaceInfo(-1, dest, index)
pad.setTrackInfo([nri[0], nri[1]])
pad.generateWithRequired(zone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:14] == 'starting_block':
spotIndex = int(posSpot.getName()[15:])
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
startingBlock = DistributedStartingBlockAI(simbase.air)
startingBlock.setPosHpr(x, y, z, h, p, r)
startingBlock.setPadDoId(pad.getDoId())
startingBlock.setPadLocationId(index)
startingBlock.generateWithRequired(zone)
pad.addStartingBlock(startingBlock)
elif group.getName()[:11] == 'viewing_pad':
pad = DistributedViewPadAI(simbase.air)
pad.setArea(zone)
pad.generateWithRequired(zone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:14] == 'starting_block':
spotIndex = int(posSpot.getName()[15:])
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
startingBlock = DistributedViewingBlockAI(simbase.air)
startingBlock.setPosHpr(x, y, z, h, p, r)
startingBlock.setPadDoId(pad.getDoId())
startingBlock.setPadLocationId(0)
startingBlock.generateWithRequired(zone)
pad.addStartingBlock(startingBlock)
if group.getName()[:15] == 'prop_party_gate':
gate = DistributedPartyGateAI(simbase.air)
gate.setArea(zone)
gate.generateWithRequired(zone)
for i in range(group.getNumChildren()):
self._createObjects(group.at(i), zone)
开发者ID:OldToontown,项目名称:OldToontown,代码行数:85,代码来源:DNASpawnerAI.py
示例13: _createObjects
def _createObjects(self, group, zone):
if group.getName()[:13] == "fishing_pond_":
visGroup = group.getVisGroup()
pondZone = 0
if visGroup is None:
pondZone = zone
else:
pondZone = int(visGroup.getName().split(":")[0])
pondIndex = int(group.getName()[13:])
pond = DistributedFishingPondAI(simbase.air)
pond.setArea(zone)
pond.generateWithRequired(pondZone)
bingoManager = DistributedPondBingoManagerAI(simbase.air)
bingoManager.setPondDoId(pond.getDoId())
bingoManager.generateWithRequired(pondZone)
# temporary, until we have scheduled stuff
bingoManager.createGame()
pond.bingoMgr = bingoManager
simbase.air.fishManager.ponds[zone] = pond
for i in range(FishingTargetGlobals.getNumTargets(zone)):
target = DistributedFishingTargetAI(simbase.air)
target.setPondDoId(pond.getDoId())
target.generateWithRequired(pondZone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:13] == "fishing_spot_":
posSpot = group.atAsNode(i)
spot = DistributedFishingSpotAI(simbase.air)
spot.setPondDoId(pond.getDoId())
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
spot.setPosHpr(x, y, z, h, p, r)
spot.generateWithRequired(pondZone)
NPCToons.createNpcsInZone(simbase.air, pondZone)
elif group.getName()[:10] == "racing_pad":
index, dest = group.getName()[11:].split("_", 2)
index = int(index)
pad = DistributedRacePadAI(simbase.air)
pad.setArea(zone)
pad.nameType = dest
pad.index = index
nri = RaceGlobals.getNextRaceInfo(-1, dest, index)
pad.setTrackInfo([nri[0], nri[1]])
pad.generateWithRequired(zone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:14] == "starting_block":
spotIndex = int(posSpot.getName()[15:])
posSpot = group.atAsNode(i)
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
startingBlock = DistributedStartingBlockAI(simbase.air)
startingBlock.setPosHpr(x, y, z, h, p, r)
startingBlock.setPadDoId(pad.getDoId())
startingBlock.setPadLocationId(index)
startingBlock.generateWithRequired(zone)
pad.addStartingBlock(startingBlock)
elif group.getName()[:11] == "viewing_pad":
pad = DistributedViewPadAI(simbase.air)
pad.setArea(zone)
pad.generateWithRequired(zone)
for i in range(group.getNumChildren()):
posSpot = group.at(i)
if posSpot.getName()[:14] == "starting_block":
spotIndex = int(posSpot.getName()[15:])
posSpot = group.atAsNode(i)
x, y, z = posSpot.getPos()
h, p, r = posSpot.getHpr()
startingBlock = DistributedViewingBlockAI(simbase.air)
startingBlock.setPosHpr(x, y, z, h, p, r)
startingBlock.setPadDoId(pad.getDoId())
startingBlock.setPadLocationId(0)
startingBlock.generateWithRequired(zone)
pad.addStartingBlock(startingBlock)
elif group.getName()[:13] == "picnic_table_" and zone != 7000:
pos = group.getPos()
hpr = group.getHpr()
nameInfo = group.getName().split("_")
picnicTable = DistributedPicnicBasketAI.DistributedPicnicBasketAI(
simbase.air, nameInfo[2], pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2]
)
picnicTable.generateWithRequired(zone)
picnicTable.start()
elif group.getName() == "prop_game_table_DNARoot" and config.GetBool("want-oz-game-tables", True):
pos = group.getPos()
hpr = group.getHpr()
nameInfo = group.getName().split("_")
tableIndex = int(group.parent.getName().split("_")[-1])
picnicTable = DistributedPicnicTableAI.DistributedPicnicTableAI(
simbase.air, zone, nameInfo[2], pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2]
#.........这里部分代码省略.........
开发者ID:vincent15k,项目名称:Toontown-House,代码行数:101,代码来源:DNASpawnerAI.py
注:本文中的toontown.racing.RaceGlobals类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论