本文整理汇总了Python中toontown.toon.NPCToons.isZoneProtected方法的典型用法代码示例。如果您正苦于以下问题:Python NPCToons.isZoneProtected方法的具体用法?Python NPCToons.isZoneProtected怎么用?Python NPCToons.isZoneProtected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类toontown.toon.NPCToons
的用法示例。
在下文中一共展示了NPCToons.isZoneProtected方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createInitialSuitBuildings
# 需要导入模块: from toontown.toon import NPCToons [as 别名]
# 或者: from toontown.toon.NPCToons import isZoneProtected [as 别名]
def createInitialSuitBuildings(self):
if self.buildingMgr is None:
return
# If we aren't at our minimum number of buildings, let's spawn some!
suitBlockCount = len(self.buildingMgr.getSuitBlocks())
if suitBlockCount < self.targetNumSuitBuildings:
for _ in xrange(self.targetNumSuitBuildings - suitBlockCount):
blockNumber = random.choice(self.buildingMgr.getToonBlocks())
building = self.buildingMgr.getBuilding(blockNumber)
if building is None:
continue
if NPCToons.isZoneProtected(building.getExteriorAndInteriorZoneId()[1]):
continue
suitName = self.air.suitInvasionManager.getInvadingCog()[0]
if suitName is None:
suitName = self.defaultSuitName
suitType = None
suitTrack = None
if suitName is not None:
suitType = SuitDNA.getSuitType(suitName)
suitTrack = SuitDNA.getSuitDept(suitName)
(suitLevel, suitType, suitTrack) = self.pickLevelTypeAndTrack(None, suitType, suitTrack)
building.suitTakeOver(suitTrack, suitLevel, None)
# Save the building manager's state:
self.buildingMgr.save()
示例2: chooseDestination
# 需要导入模块: from toontown.toon import NPCToons [as 别名]
# 或者: from toontown.toon.NPCToons import isZoneProtected [as 别名]
def chooseDestination(self, suit, startTime, toonBlockTakeover=None,
cogdoTakeover=None, minPathLen=None, maxPathLen=None):
possibles = []
backup = []
if toonBlockTakeover is not None:
suit.attemptingTakeover = 1
blockNumber = toonBlockTakeover
if blockNumber in self.buildingFrontDoors:
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
elif suit.attemptingTakeover:
for blockNumber in self.buildingMgr.getToonBlocks():
building = self.buildingMgr.getBuilding(blockNumber)
(extZoneId, intZoneId) = building.getExteriorAndInteriorZoneId()
if not NPCToons.isZoneProtected(intZoneId):
if blockNumber in self.buildingFrontDoors:
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
if cogdoTakeover is None:
if suit.dna.dept in ALLOWED_FO_TRACKS:
cogdoTakeover = random.random() < self.CogdoRatio
elif self.buildingMgr:
for blockNumber in self.buildingMgr.getSuitBlocks():
track = self.buildingMgr.getBuildingTrack(blockNumber)
if (track == suit.track) and (blockNumber in self.buildingSideDoors):
for doorPoint in self.buildingSideDoors[blockNumber]:
possibles.append((blockNumber, doorPoint))
backup = []
for p in self.streetPointList:
backup.append((None, p))
if self.notify.getDebug():
self.notify.debug('Choosing destination point from %s+%s possibles.' % (len(possibles), len(backup)))
if len(possibles) == 0:
possibles = backup
backup = []
if minPathLen is None:
if suit.attemptingTakeover:
minPathLen = self.MIN_TAKEOVER_PATH_LEN
else:
minPathLen = self.MIN_PATH_LEN
if maxPathLen is None:
maxPathLen = self.MAX_PATH_LEN
retryCount = 0
while (len(possibles) > 0) and (retryCount < 50):
p = random.choice(possibles)
possibles.remove(p)
if len(possibles) == 0:
possibles = backup
backup = []
path = self.genPath(suit.startPoint, p[1], minPathLen, maxPathLen)
if path and (not self.pathCollision(path, startTime)):
suit.endPoint = p[1]
suit.minPathLen = minPathLen
suit.maxPathLen = maxPathLen
suit.buildingDestination = p[0]
suit.buildingDestinationIsCogdo = cogdoTakeover
suit.setPath(path)
return 1
retryCount += 1
return 0
示例3: chooseDestination
# 需要导入模块: from toontown.toon import NPCToons [as 别名]
# 或者: from toontown.toon.NPCToons import isZoneProtected [as 别名]
def chooseDestination(self, suit, startTime, toonBlockTakeover = None, cogdoTakeover = None, minPathLen = None, maxPathLen = None):
possibles = []
backup = []
if toonBlockTakeover != None:
suit.attemptingTakeover = 1
blockNumber = toonBlockTakeover
if self.buildingFrontDoors.has_key(blockNumber):
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
elif suit.attemptingTakeover:
for blockNumber in self.buildingMgr.getToonBlocks():
building = self.buildingMgr.getBuilding(blockNumber)
(extZoneId, intZoneId) = building.getExteriorAndInteriorZoneId()
if not NPCToons.isZoneProtected(intZoneId):
if self.buildingFrontDoors.has_key(blockNumber):
if not self.isBlockSuitTarget(blockNumber):
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
if cogdoTakeover is None:
if suit.dna.dept in ALLOWED_FO_TRACKS:
cogdoTakeover = random.random() < self.CogdoRatio
elif self.buildingMgr and 0:
for blockNumber in self.buildingMgr.getSuitBlocks():
track = self.buildingMgr.getBuildingTrack(blockNumber)
if track == suit.track and self.buildingSideDoors.has_key(blockNumber):
for doorPoint in self.buildingSideDoors[blockNumber]:
possibles.append((blockNumber, doorPoint))
backup = []
for p in self.streetPointList:
backup.append((None, p))
if self.notify.getDebug():
self.notify.debug('Choosing destination point from %d+%d possibles.' % (len(possibles), len(backup)))
if len(possibles) == 0:
possibles = backup
backup = []
if minPathLen == None:
if suit.attemptingTakeover:
minPathLen = self.MIN_TAKEOVER_PATH_LEN
else:
minPathLen = self.MIN_PATH_LEN
if maxPathLen == None:
maxPathLen = self.MAX_PATH_LEN
retryCount = 0
while len(possibles) > 0 and retryCount < 50:
p = random.choice(possibles)
possibles.remove(p)
if len(possibles) == 0:
possibles = backup
backup = []
try:
path = self.genPath(suit.startPoint, p[1], minPathLen, maxPathLen)
except Exception as e:
print self.zoneId, e
exit()
if path and not self.pathCollision(path, startTime):
suit.endPoint = p[1]
suit.minPathLen = minPathLen
suit.maxPathLen = maxPathLen
suit.buildingDestination = p[0]
if suit.buildingDestination is not None and self.zoneId == 7100:
print 'DSP assigned %r buildingDestination to %s/%s' % (suit, p[0], p[1].getIndex())
suit.buildingDestinationIsCogdo = cogdoTakeover
suit.setPath(path)
return 1
retryCount += 1
return 0
示例4: chooseDestination
# 需要导入模块: from toontown.toon import NPCToons [as 别名]
# 或者: from toontown.toon.NPCToons import isZoneProtected [as 别名]
def chooseDestination(
self, suit, startTime, toonBlockTakeover=None, cogdoTakeover=None, minPathLen=None, maxPathLen=None
):
possibles = []
backup = []
if cogdoTakeover is None:
cogdoTakeover = False
if toonBlockTakeover != None:
suit.attemptingTakeover = 1
blockNumber = toonBlockTakeover
if self.buildingFrontDoors.has_key(blockNumber):
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
elif suit.attemptingTakeover:
for blockNumber in self.buildingMgr.getToonBlocks():
building = self.buildingMgr.getBuilding(blockNumber)
extZoneId, intZoneId = building.getExteriorAndInteriorZoneId()
if not NPCToons.isZoneProtected(intZoneId):
if self.buildingFrontDoors.has_key(blockNumber):
possibles.append((blockNumber, self.buildingFrontDoors[blockNumber]))
else:
if self.buildingMgr:
for blockNumber in self.buildingMgr.getSuitBlocks():
track = self.buildingMgr.getBuildingTrack(blockNumber)
if track == suit.track and self.buildingSideDoors.has_key(blockNumber):
for doorPoint in self.buildingSideDoors[blockNumber]:
possibles.append((blockNumber, doorPoint))
backup = []
for p in self.streetPointList:
backup.append((None, p))
if self.notify.getDebug():
self.notify.debug("Choosing destination point from %d+%d possibles." % (len(possibles), len(backup)))
if len(possibles) == 0:
possibles = backup
backup = []
if minPathLen == None:
if suit.attemptingTakeover:
minPathLen = self.MIN_TAKEOVER_PATH_LEN
else:
minPathLen = self.MIN_PATH_LEN
if maxPathLen == None:
maxPathLen = self.MAX_PATH_LEN
retryCount = 0
while len(possibles) > 0 and retryCount < 50:
p = random.choice(possibles)
possibles.remove(p)
if len(possibles) == 0:
possibles = backup
backup = []
path = self.genPath(suit.startPoint, p[1], minPathLen, maxPathLen)
if path and not self.pathCollision(path, startTime):
suit.endPoint = p[1]
suit.minPathLen = minPathLen
suit.maxPathLen = maxPathLen
suit.buildingDestination = p[0]
suit.buildingDestinationIsCogdo = cogdoTakeover
suit.setPath(self.dnaData.suitGraph, path)
return 1
retryCount += 1
return 0