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


Python pets.PetUtil类代码示例

本文整理汇总了Python中toontown.pets.PetUtil的典型用法代码示例。如果您正苦于以下问题:Python PetUtil类的具体用法?Python PetUtil怎么用?Python PetUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: makePetList

        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:BmanGames,项目名称:ToontownStride,代码行数:35,代码来源:PetshopGUI.py

示例2: __init__

 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:BmanGames,项目名称:ToontownStride,代码行数:30,代码来源:PetshopGUI.py

示例3: petAdopted

 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 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:BmanGames,项目名称:ToontownStride,代码行数:33,代码来源:DistributedNPCPetclerkAI.py

示例4: createPet

 def createPet(self, ownerId, seed):
     zoneId = self.interiorZone
     safeZoneId = ZoneUtil.getCanonicalSafeZoneId(zoneId)
     (name, dna, traitSeed) = PetUtil.getPetInfoFromSeed(seed, safeZoneId)
     pet = DistributedPetAI.DistributedPetAI(self.air, dna=dna)
     pet.setOwnerId(ownerId)
     pet.setPetName(name)
     pet.traits = PetTraits.PetTraits(traitSeed=traitSeed, safeZoneId=safeZoneId)
     pet.generateWithRequired(zoneId)
     pet.setPos(0, 0, 0)
     pet.b_setParent(ToontownGlobals.SPRender)
开发者ID:snoopdogg420,项目名称:src,代码行数:11,代码来源:PetshopBuildingAI.py

示例5: __init__

    def __init__(self, air, avId, petSeed, nameIndex, gender, zoneId):
        name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)

        self.air = air
        self.avId = avId
        self.petSeed = petSeed
        self.traitSeed = traitSeed
        self.nameIndex= nameIndex
        self.dna=dna
        self.zoneId = ZoneUtil.getCanonicalSafeZoneId(zoneId)
        self.traits = PetTraits.PetTraits(traitSeed=traitSeed, safeZoneId=zoneId)
        self.gender = gender
        self.petId = None
        self.name = None
开发者ID:snoopdogg420,项目名称:src,代码行数:14,代码来源:PetManagerAI.py

示例6: __init__

        def __init__(self, doneEvent, petSeed, gender):
            zoneId = ZoneUtil.getCanonicalSafeZoneId(base.localAvatar.getZoneId())
            name, dna, traitSeed = PetUtil.getPetInfoFromSeed(petSeed, zoneId)
            self.gui = loader.loadModel('phase_4/models/gui/PetNamePanel')
            self.guiScale = 0.09
            DirectFrame.__init__(self, relief=None, geom=self.gui, geom_scale=self.guiScale, state='normal', frameSize=(-1, 1, -1, 1))
            self.initialiseoptions(PetshopGUI.NamePicker)
            self.petView = self.attachNewNode('petView')
            self.petView.setPos(-0.21, 0, -0.04)
            self.petModel = Pet.Pet(forGui=1)
            self.petModel.setDNA(dna)
            self.petModel.fitAndCenterHead(0.435, forGui=1)
            self.petModel.reparentTo(self.petView)
            self.petModel.setH(225)
            self.petModel.enterNeutralHappy()
            self.ng = PetNameGenerator.PetNameGenerator()
            if gender == 1:
                self.allNames = self.ng.boyFirsts
            else:
                self.allNames = self.ng.girlFirsts
            self.allNames += self.ng.neutralFirsts
            self.allNames.sort()
            self.checkNames()
            self.letters = []
            for name in self.allNames:
                if name[0:TTLocalizer.PGUIcharLength] not in self.letters:
                    self.letters.append(name[0:TTLocalizer.PGUIcharLength])

            self.curLetter = self.letters[0]
            self.curNames = []
            self.curName = ''
            self.alphabetList = self.makeScrollList(self.gui, (-0.012, 0, -0.075), (1, 0.8, 0.8, 1), self.letters, self.makeLabel, [TextNode.ACenter, 'alphabet'], 6)
            self.nameList = None
            self.rebuildNameList()
            self.randomButton = DirectButton(parent=self, relief=None, image=(self.gui.find('**/RandomUpButton'), self.gui.find('**/RandomDownButton'), self.gui.find('**/RandomRolloverButton')), scale=self.guiScale, text=TTLocalizer.RandomButton, text_pos=(-0.8, -5.7), text_scale=0.8, text_fg=text2Color, pressEffect=False, command=self.randomName)
            self.nameResult = DirectLabel(parent=self, relief=None, scale=self.guiScale, text='', text_align=TextNode.ACenter, text_pos=(-1.85, 2.6), text_fg=text0Color, text_scale=0.6, text_wordwrap=8)
            self.submitButton = DirectButton(parent=self, relief=None, image=(self.gui.find('**/SubmitUpButton'), self.gui.find('**/SubmitDownButton'), self.gui.find('**/SubmitRolloverButton')), scale=self.guiScale, text=TTLocalizer.PetshopAdopt, text_pos=(3.3, -5.7), text_scale=TTLocalizer.PGUIsubmitButton, text_fg=text0Color, pressEffect=False, command=lambda : messenger.send(doneEvent, [self.ng.returnUniqueID(self.curName)]))
            model = loader.loadModel('phase_4/models/gui/PetShopInterface')
            modelScale = 0.1
            cancelImageList = (model.find('**/CancelButtonUp'), model.find('**/CancelButtonDown'), model.find('**/CancelButtonRollover'))
            cancelIcon = model.find('**/CancelIcon')
            self.cancelButton = DirectButton(parent=self, relief=None, pos=(-0.04, 0, -0.47), image=cancelImageList, geom=cancelIcon, scale=modelScale, pressEffect=False, command=lambda : messenger.send(doneEvent, [-1]))
            self.randomName()
            return
开发者ID:MasterLoopyBM,项目名称:c0d3,代码行数:44,代码来源:PetshopGUI.py


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