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


Python ZoneUtil.getCanonicalSafeZoneId方法代码示例

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


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

示例1: petAdopted

# 需要导入模块: from src.toontown.hood import ZoneUtil [as 别名]
# 或者: from src.toontown.hood.ZoneUtil import getCanonicalSafeZoneId [as 别名]
 def petAdopted(self, petNum, nameIndex):
     avId = self.air.getAvatarIdFromSender()
     if self.busy != avId:
         self.air.writeServerEvent('suspicious', avId, 'DistributedNPCPetshopAI.petAdopted busy with %s' % self.busy)
         self.notify.warning('somebody called petAdopted that I was not busy with! avId: %s' % avId)
         return
     av = simbase.air.doId2do.get(avId)
     if av:
         from src.toontown.hood import ZoneUtil
         zoneId = ZoneUtil.getCanonicalSafeZoneId(self.zoneId)
         if petNum not in xrange(0, len(self.petSeeds)):
             self.air.writeServerEvent('suspicious', avId, 'DistributedNPCPetshopAI.petAdopted and no such pet!')
             self.notify.warning('somebody called petAdopted on a non-existent pet! avId: %s' % avId)
             return
         cost = PetUtil.getPetCostFromSeed(self.petSeeds[petNum], zoneId)
         if cost > av.getTotalMoney():
             self.air.writeServerEvent('suspicious', avId, "DistributedNPCPetshopAI.petAdopted and toon doesn't have enough money!")
             self.notify.warning("somebody called petAdopted and didn't have enough money to adopt! avId: %s" % avId)
             return
         if av.petId != 0:
             simbase.air.petMgr.deleteToonsPet(avId)
         gender = petNum % len(PetDNA.PetGenders)
         if nameIndex not in xrange(0, len(TTLocalizer.PetNameDictionary) - 1):
             self.air.writeServerEvent('avoid_crash', avId, "DistributedNPCPetclerkAI.petAdopted and didn't have valid nameIndex!")
             self.notify.warning("somebody called petAdopted and didn't have valid nameIndex to adopt! avId: %s" % avId)
             return
         simbase.air.petMgr.createNewPetFromSeed(avId, self.petSeeds[petNum], nameIndex=nameIndex, gender=gender, safeZoneId=zoneId)
         self.notify.warning("Created new pet from seed")
         self.transactionType = 'adopt'
         bankPrice = min(av.getBankMoney(), cost)
         walletPrice = cost - bankPrice
         av.b_setBankMoney(av.getBankMoney() - bankPrice)
         av.b_setMoney(av.getMoney() - walletPrice)
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:35,代码来源:DistributedNPCPetclerkAI.py

示例2: makePetList

# 需要导入模块: from src.toontown.hood import ZoneUtil [as 别名]
# 或者: from src.toontown.hood.ZoneUtil import getCanonicalSafeZoneId [as 别名]
        def makePetList(self):
            self.numPets = len(self.petSeeds)
            self.curPet = 0
            self.petDNA = []
            self.petName = []
            self.petDesc = []
            self.petCost = []
            for i in xrange(self.numPets):
                random.seed(self.petSeeds[i])
                zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
                name, dna, traitSeed = PetUtil.getPetInfoFromSeed(self.petSeeds[i], zoneId)
                cost = PetUtil.getPetCostFromSeed(self.petSeeds[i], zoneId)
                traits = PetTraits.PetTraits(traitSeed, zoneId)
                traitList = traits.getExtremeTraitDescriptions()
                numGenders = len(PetDNA.PetGenders)
                gender = i % numGenders
                PetDNA.setGender(dna, gender)
                self.petDNA.append(dna)
                self.petName.append(TTLocalizer.PetshopUnknownName)
                descList = []
                descList.append(TTLocalizer.PetshopDescGender % PetDNA.getGenderString(gender=gender))
                if traitList:
                    descList.append(TTLocalizer.PetshopDescTrait % traitList[0])
                else:
                    descList.append(TTLocalizer.PetshopDescTrait % TTLocalizer.PetshopDescStandard)
                traitList.extend(['',
                 '',
                 '',
                 ''])
                for trait in traitList[1:4]:
                    descList.append('\t%s' % trait)

                descList.append(TTLocalizer.PetshopDescCost % cost)
                self.petDesc.append('\n'.join(descList))
                self.petCost.append(cost)
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:37,代码来源:PetshopGUI.py

示例3: __init__

# 需要导入模块: from src.toontown.hood import ZoneUtil [as 别名]
# 或者: from src.toontown.hood.ZoneUtil import getCanonicalSafeZoneId [as 别名]
 def __init__(self, doneEvent, petSeed, petNameIndex):
     zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
     name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)
     name = TTLocalizer.getPetName(petNameIndex)
     cost = PetUtil.getPetCostFromSeed(petSeed, zoneId)
     model = loader.loadModel('phase_4/models/gui/AdoptPet')
     modelPos = (0, 0, -0.3)
     modelScale = 0.055
     DirectFrame.__init__(self, relief=None, state='normal', geom=model, geom_color=ToontownGlobals.GlobalDialogColor, geom_scale=modelScale, frameSize=(-1, 1, -1, 1), pos=modelPos, text=TTLocalizer.PetshopAdoptConfirm % (name, cost), text_wordwrap=12, text_scale=0.05, text_pos=(0, 0.55), text_fg=text0Color)
     self.initialiseoptions(PetshopGUI.AdoptPetDlg)
     self.petView = self.attachNewNode('petView')
     self.petView.setPos(-0.13, 0, 0.8)
     self.petModel = Pet.Pet(forGui=1)
     self.petModel.setDNA(dna)
     self.petModel.fitAndCenterHead(0.395, forGui=1)
     self.petModel.reparentTo(self.petView)
     self.petModel.setH(130)
     self.petModel.setScale(0.125)
     self.petModel.enterNeutralHappy()
     self.moneyDisplay = DirectLabel(parent=self, relief=None, text=str(base.localAvatar.getTotalMoney()), text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.225, 0.33), text_font=ToontownGlobals.getSignFont())
     self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange)
     self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange)
     okImageList = (model.find('**/CheckButtonUp'), model.find('**/CheckButtonDown'), model.find('**/CheckButtonRollover'))
     cancelImageList = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelRollover'))
     cancelIcon = model.find('**/CancelIcon')
     checkIcon = model.find('**/CheckIcon')
     self.cancelButton = DirectButton(parent=self, relief=None, image=cancelImageList, geom=cancelIcon, scale=modelScale, text=('', TTLocalizer.PetshopGoBack), text_pos=(-5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [0]))
     self.okButton = DirectButton(parent=self, relief=None, image=okImageList, geom=checkIcon, scale=modelScale, text=('', TTLocalizer.PetshopAdopt), text_pos=(5.8, 4.4), text_scale=0.7, pressEffect=False, command=lambda : messenger.send(doneEvent, [1]))
     model.removeNode()
     return
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:32,代码来源:PetshopGUI.py


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