本文整理汇总了Python中otp.nametag.NametagGroup.NametagGroup.manage方法的典型用法代码示例。如果您正苦于以下问题:Python NametagGroup.manage方法的具体用法?Python NametagGroup.manage怎么用?Python NametagGroup.manage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类otp.nametag.NametagGroup.NametagGroup
的用法示例。
在下文中一共展示了NametagGroup.manage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Avatar
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
#.........这里部分代码省略.........
self.b_setPageNumber(self.__chatParagraph, pageNumber)
return
def __updatePageChat(self):
if self.__chatPageNumber != None and self.__chatPageNumber[0] == self.__chatParagraph:
pageNumber = self.__chatPageNumber[1]
if pageNumber >= 0:
if not self.__chatSet:
if len(self.__chatDialogueList) > 0:
dialogue = self.__chatDialogueList[0]
else:
dialogue = None
self.setChatAbsolute(self.__chatMessage, self.__chatFlags, dialogue)
self.__chatSet = 1
if pageNumber < self.nametag.getNumChatPages():
self.nametag.setPageNumber(pageNumber)
if pageNumber > 0:
if len(self.__chatDialogueList) > pageNumber:
dialogue = self.__chatDialogueList[pageNumber]
else:
dialogue = None
self.playCurrentDialogue(dialogue, self.__chatFlags)
else:
self.clearChat()
else:
self.clearChat()
return
def getAirborneHeight(self):
height = self.getPos(self.shadowPlacer.shadowNodePath)
return height.getZ() + 0.025
def initializeNametag3d(self):
self.deleteNametag3d()
nametagNode = self.nametag.getNametag3d()
self.nametagNodePath = self.nametag3d.attachNewNode(nametagNode)
iconNodePath = self.nametag.getNameIcon()
for cJoint in self.getNametagJoints():
cJoint.clearNetTransforms()
cJoint.addNetTransform(nametagNode)
def nametagAmbientLightChanged(self, newlight):
self.nametag3d.setLightOff()
if newlight:
self.nametag3d.setLight(newlight)
def deleteNametag3d(self):
if self.nametagNodePath:
self.nametagNodePath.removeNode()
self.nametagNodePath = None
return
def initializeBodyCollisions(self, collIdStr):
self.collTube = CollisionTube(0, 0, 0.5, 0, 0, self.height - self.getRadius(), self.getRadius())
self.collNode = CollisionNode(collIdStr)
self.collNode.addSolid(self.collTube)
self.collNodePath = self.attachNewNode(self.collNode)
if self.ghostMode:
self.collNode.setCollideMask(OTPGlobals.GhostBitmask)
else:
self.collNode.setCollideMask(OTPGlobals.WallBitmask)
def stashBodyCollisions(self):
if hasattr(self, 'collNodePath'):
self.collNodePath.stash()
def unstashBodyCollisions(self):
if hasattr(self, 'collNodePath'):
self.collNodePath.unstash()
def disableBodyCollisions(self):
if hasattr(self, 'collNodePath'):
self.collNodePath.removeNode()
del self.collNodePath
self.collTube = None
return
def addActive(self):
if base.wantNametags:
try:
Avatar.ActiveAvatars.remove(self)
except ValueError:
pass
Avatar.ActiveAvatars.append(self)
self.nametag.manage(base.marginManager)
self.accept(self.nametag.getUniqueId(), self.clickedNametag)
def removeActive(self):
if base.wantNametags:
try:
Avatar.ActiveAvatars.remove(self)
except ValueError:
pass
self.nametag.unmanage(base.marginManager)
self.ignore(self.nametag.getUniqueId())
def loop(self, animName, restart = 1, partName = None, fromFrame = None, toFrame = None):
return Actor.loop(self, animName, restart, partName, fromFrame, toFrame)
示例2: DistributedDoor
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
class DistributedDoor(DistributedObject.DistributedObject, DelayDeletable):
deferFor = 1
def __init__(self, cr):
DistributedObject.DistributedObject.__init__(self, cr)
self.openSfx = base.loadSfx('phase_3.5/audio/sfx/Door_Open_1.ogg')
self.closeSfx = base.loadSfx('phase_3.5/audio/sfx/Door_Close_1.ogg')
self.nametag = None
self.fsm = ClassicFSM.ClassicFSM('DistributedDoor_right', [State.State('off', self.enterOff, self.exitOff, ['closing',
'closed',
'opening',
'open']),
State.State('closing', self.enterClosing, self.exitClosing, ['closed', 'opening']),
State.State('closed', self.enterClosed, self.exitClosed, ['opening']),
State.State('opening', self.enterOpening, self.exitOpening, ['open']),
State.State('open', self.enterOpen, self.exitOpen, ['closing', 'open'])], 'off', 'off')
self.fsm.enterInitialState()
self.exitDoorFSM = ClassicFSM.ClassicFSM('DistributedDoor_left', [State.State('off', self.exitDoorEnterOff, self.exitDoorExitOff, ['closing',
'closed',
'opening',
'open']),
State.State('closing', self.exitDoorEnterClosing, self.exitDoorExitClosing, ['closed', 'opening']),
State.State('closed', self.exitDoorEnterClosed, self.exitDoorExitClosed, ['opening']),
State.State('opening', self.exitDoorEnterOpening, self.exitDoorExitOpening, ['open']),
State.State('open', self.exitDoorEnterOpen, self.exitDoorExitOpen, ['closing', 'open'])], 'off', 'off')
self.exitDoorFSM.enterInitialState()
self.specialDoorTypes = {DoorTypes.EXT_HQ: 0,
DoorTypes.EXT_COGHQ: 0,
DoorTypes.INT_COGHQ: 0,
DoorTypes.EXT_KS: 0,
DoorTypes.INT_KS: 0}
self.doorX = 1.5
return
def generate(self):
DistributedObject.DistributedObject.generate(self)
self.avatarTracks = []
self.avatarExitTracks = []
self.avatarIDList = []
self.avatarExitIDList = []
self.doorTrack = None
self.doorExitTrack = None
return
def disable(self):
self.clearNametag()
taskMgr.remove(self.checkIsDoorHitTaskName())
self.ignore(self.getEnterTriggerEvent())
self.ignore(self.getExitTriggerEvent())
self.ignore('clearOutToonInterior')
self.fsm.request('off')
self.exitDoorFSM.request('off')
if self.__dict__.has_key('building'):
del self.building
self.finishAllTracks()
self.avatarIDList = []
self.avatarExitIDList = []
if hasattr(self, 'tempDoorNodePath'):
self.tempDoorNodePath.removeNode()
del self.tempDoorNodePath
DistributedObject.DistributedObject.disable(self)
def delete(self):
del self.fsm
del self.exitDoorFSM
del self.openSfx
del self.closeSfx
DistributedObject.DistributedObject.delete(self)
def wantsNametag(self):
return not ZoneUtil.isInterior(self.zoneId)
def setupNametag(self):
if not self.wantsNametag():
return
if self.doorIndex != 0:
# Avoid duplicated nametags (eg hq doors)
return
if self.nametag == None:
self.nametag = NametagGroup()
self.nametag.setFont(ToontownGlobals.getBuildingNametagFont())
if TTLocalizer.BuildingNametagShadow:
self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow)
self.nametag.setContents(Nametag.CName)
self.nametag.setColorCode(NametagGroup.CCToonBuilding)
self.nametag.setActive(0)
self.nametag.setAvatar(self.getDoorNodePath())
self.nametag.setObjectCode(self.block)
name = self.cr.playGame.dnaStore.getTitleFromBlockNumber(self.block)
self.nametag.setName(name)
self.nametag.manage(base.marginManager)
def clearNametag(self):
if self.nametag != None:
#.........这里部分代码省略.........
示例3: DistributedHouse
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
class DistributedHouse(DistributedObject.DistributedObject):
notify = directNotify.newCategory('DistributedHouse')
def __init__(self, cr):
DistributedObject.DistributedObject.__init__(self, cr)
self.houseType = 0
self.avId = -1
self.ownerId = 0
self.colorIndex = 0
self.house = None
self.name = ''
self.namePlate = None
self.nameText = None
self.nametag = None
self.floorMat = None
self.matText = None
self.randomGenerator = None
self.housePosInd = 0
self.house_loaded = 0
return
def disable(self):
DistributedObject.DistributedObject.disable(self)
def delete(self):
self.notify.debug('delete')
self.unload()
self.clearNametag()
if self.namePlate:
self.namePlate.removeNode()
del self.namePlate
self.namePlate = None
if self.floorMat:
self.floorMat.removeNode()
del self.floorMat
self.floorMat = None
if self.house:
self.house.removeNode()
del self.house
self.house_loaded = 0
del self.randomGenerator
DistributedObject.DistributedObject.delete(self)
return
def clearNametag(self):
if self.nametag != None:
self.nametag.unmanage(base.marginManager)
self.nametag.setAvatar(NodePath())
self.nametag.destroy()
self.nametag = None
return
def load(self):
self.notify.debug('load')
if not self.house_loaded:
if self.houseType >= len(self.cr.playGame.hood.loader.houseModels):
self.houseType = HouseGlobals.HOUSE_DEFAULT
houseModel = self.cr.playGame.hood.loader.houseModels[self.houseType]
self.house = houseModel.copyTo(self.cr.playGame.hood.loader.houseNode[self.housePosInd])
self.house_loaded = 1
self.cr.playGame.hood.loader.houseId2house[self.doId] = self.house
if self.houseType == HouseGlobals.HOUSE_DEFAULT:
self.__setHouseColor()
if self.houseType == HouseGlobals.HOUSE_DEFAULT or self.houseType == HouseGlobals.HOUSE_TEST:
self.__setupDoor()
else:
self.__setupDoorCustom()
messenger.send('houseLoaded-%d' % self.doId)
def announceGenerate(self):
DistributedObject.DistributedObject.announceGenerate(self)
messenger.send('setBuilding-' + str(self.doId))
def __setupDoor(self):
self.notify.debug('setupDoor')
self.dnaStore = self.cr.playGame.dnaStore
doorModelName = 'door_double_round_ul'
if doorModelName[-1:] == 'r':
doorModelName = doorModelName[:-1] + 'l'
else:
doorModelName = doorModelName[:-1] + 'r'
door = self.dnaStore.findNode(doorModelName)
door_origin = self.house.find('**/door_origin')
door_origin.setHpr(90, 0, 0)
door_origin.setScale(0.6, 0.6, 0.8)
door_origin.setPos(door_origin, 0.5, 0, 0.0)
doorNP = door.copyTo(door_origin)
self.door_origin = door_origin
self.randomGenerator = random.Random()
self.randomGenerator.seed(self.doId)
houseColor = HouseGlobals.stairWood
color = Vec4(houseColor[0], houseColor[1], houseColor[2], 1)
setupDoor(doorNP, door_origin, door_origin, self.dnaStore, str(self.colorIndex), color)
self.__setupNamePlate()
self.__setupFloorMat()
self.__setupNametag()
def __setupDoorCustom(self):
self.randomGenerator = random.Random()
self.randomGenerator.seed(self.doId)
#.........这里部分代码省略.........
示例4: DistributedKnockKnockDoor
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
class DistributedKnockKnockDoor(DistributedAnimatedProp.DistributedAnimatedProp):
def __init__(self, cr):
DistributedAnimatedProp.DistributedAnimatedProp.__init__(self, cr)
self.fsm.setName('DistributedKnockKnockDoor')
self.rimshot = None
self.knockSfx = None
return
def generate(self):
DistributedAnimatedProp.DistributedAnimatedProp.generate(self)
self.avatarTracks = []
self.avatarId = 0
def announceGenerate(self):
DistributedAnimatedProp.DistributedAnimatedProp.announceGenerate(self)
self.accept('exitKnockKnockDoorSphere_' + str(self.propId), self.exitTrigger)
self.acceptAvatar()
def disable(self):
self.ignore('exitKnockKnockDoorSphere_' + str(self.propId))
self.ignore('enterKnockKnockDoorSphere_' + str(self.propId))
DistributedAnimatedProp.DistributedAnimatedProp.disable(self)
def delete(self):
DistributedAnimatedProp.DistributedAnimatedProp.delete(self)
if self.rimshot:
self.rimshot = None
if self.knockSfx:
self.knockSfx = None
return
def acceptAvatar(self):
self.acceptOnce('enterKnockKnockDoorSphere_' + str(self.propId), self.enterTrigger)
def setAvatarInteract(self, avatarId):
DistributedAnimatedProp.DistributedAnimatedProp.setAvatarInteract(self, avatarId)
def avatarExit(self, avatarId):
if avatarId == self.avatarId:
for track in self.avatarTracks:
track.finish()
DelayDelete.cleanupDelayDeletes(track)
self.avatarTracks = []
def knockKnockTrack(self, avatar, duration):
if avatar == None:
return
self.rimshot = base.loadSfx('phase_5/audio/sfx/AA_heal_telljoke.ogg')
self.knockSfx = base.loadSfx('phase_5/audio/sfx/GUI_knock_3.ogg')
joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)]
place = base.cr.playGame.getPlace()
doorName = TTLocalizer.DoorNametag
if place:
zone = place.getZoneId()
branch = ZoneUtil.getBranchZone(zone)
if branch == ToontownGlobals.SillyStreet:
if self.propId in KnockKnockContestJokes[ToontownGlobals.SillyStreet].keys():
joke = KnockKnockContestJokes[ToontownGlobals.SillyStreet][self.propId]
doorName = KnockKnockDoorNames[self.propId]
elif branch == ToontownGlobals.LoopyLane:
if self.propId in KnockKnockContestJokes[ToontownGlobals.LoopyLane].keys():
joke = KnockKnockContestJokes[ToontownGlobals.LoopyLane][self.propId]
elif branch == ToontownGlobals.PunchlinePlace:
if self.propId == 1:
joke = KnockKnockContestJokes[ToontownGlobals.PunchlinePlace]
elif branch == ToontownGlobals.PolarPlace:
if self.propId in KnockKnockContestJokes[ToontownGlobals.PolarPlace].keys():
joke = KnockKnockContestJokes[ToontownGlobals.PolarPlace][self.propId]
self.nametag = None
self.nametagNP = None
doorNP = render.find('**/KnockKnockDoorSphere_' + str(self.propId) + ';+s')
if doorNP.isEmpty():
self.notify.warning('Could not find KnockKnockDoorSphere_%s' % self.propId)
return
self.nametag = NametagGroup()
self.nametag.setAvatar(doorNP)
self.nametag.setFont(ToontownGlobals.getToonFont())
self.nametag.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setName(doorName)
self.nametag.setActive(0)
self.nametag.manage(base.marginManager)
self.nametag.getNametag3d().setBillboardOffset(4)
nametagNode = self.nametag.getNametag3d()
self.nametagNP = render.attachNewNode(nametagNode)
self.nametagNP.setName('knockKnockDoor_nt_' + str(self.propId))
pos = doorNP.node().getSolid(0).getCenter()
self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2))
d = duration * 0.125
track = Sequence(Parallel(Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d)), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4)), Func(self.cleanupTrack))
track.delayDelete = DelayDelete.DelayDelete(avatar, 'knockKnockTrack')
return track
def cleanupTrack(self):
avatar = self.cr.doId2do.get(self.avatarId, None)
if avatar:
avatar.clearChat()
if self.nametag:
self.nametag.unmanage(base.marginManager)
#.........这里部分代码省略.........
示例5: PartyPlanner
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
#.........这里部分代码省略.........
self.frame = DirectFrame(parent=aspect2d, geom=self.gui.find('**/background'), relief=None, scale=0.85, pos=(0.05, 0.0, 0.1))
self.titleScale = TTLocalizer.PPtitleScale
self._createNavButtons()
self.welcomePage = self._createWelcomePage()
self.welcomePage.hide()
self.datePage = self._createDatePage()
self.datePage.hide()
self.timePage = self._createTimePage()
self.timePage.hide()
self.guestPage = self._createGuestPage()
self.guestPage.hide()
self.partyEditorPage = self._createPartyEditorPage()
self.partyEditorPage.hide()
self.invitationPage = self._createInvitationPage()
self.invitationPage.hide()
self.farewellPage = self._createFarewellPage()
self.farewellPage.hide()
return
def _createNavButtons(self):
self.quitButton = DirectButton(parent=self.frame, relief=None, geom=(self.gui.find('**/cancelButton_up'), self.gui.find('**/cancelButton_down'), self.gui.find('**/cancelButton_rollover')), command=self.__acceptExit)
self.nextButton = DirectButton(parent=self.frame, relief=None, geom=(self.gui.find('**/bottomNext_button/nextButton_up'), self.gui.find('**/bottomNext_button/nextButton_down'), self.gui.find('**/bottomNext_button/nextButton_rollover')), command=self.__nextItem, state=DirectGuiGlobals.DISABLED)
self.prevButton = DirectButton(parent=self.frame, relief=None, geom=(self.gui.find('**/bottomPrevious_button/previousButton_up'), self.gui.find('**/bottomPrevious_button/previousButton_down'), self.gui.find('**/bottomPrevious_button/previousButton_rollover')), command=self.__prevItem, state=DirectGuiGlobals.DISABLED)
self.currentItem = None
return
def __createNametag(self, parent):
if self.nametagGroup == None:
self.nametagGroup = NametagGroup()
self.nametagGroup.setFont(ToontownGlobals.getToonFont())
self.nametagGroup.setSpeechFont(ToontownGlobals.getToonFont())
self.nametagGroup.setActive(0)
self.nametagGroup.setAvatar(self.partyPlannerHead)
self.nametagGroup.manage(base.marginManager)
self.nametagGroup.setColorCode(self.nametagGroup.CCNonPlayer)
self.nametagGroup.getNametag2d().setContents(0)
self.nametagNode = NametagFloat2d()
self.nametagNode.setContents(Nametag.CName)
self.nametagGroup.addNametag(self.nametagNode)
self.nametagGroup.setName(base.cr.partyManager.getPartyPlannerName())
self.nametagNP = parent.attachNewNode(self.nametagNode)
nametagPos = self.gui.find('**/step_01_partymanPeteNametag_locator').getPos()
self.nametagNP.setPosHprScale(nametagPos[0], 0, nametagPos[2], 0, 0, 0, 0.1, 1, 0.1)
self.chatNode = NametagFloat2d()
self.chatNode.setContents(Nametag.CSpeech | Nametag.CThought)
self.nametagGroup.addNametag(self.chatNode)
self.nametagGroup.setChat(TTLocalizer.PartyPlannerInstructions, CFSpeech)
self.chatNP = parent.attachNewNode(self.chatNode)
chatPos = self.gui.find('**/step_01_partymanPeteText_locator').getPos()
self.chatNP.setPosHprScale(chatPos[0], 0, chatPos[2], 0, 0, 0, 0.08, 1, 0.08)
return
def clearNametag(self):
if self.nametagGroup != None:
self.nametagGroup.unmanage(base.marginManager)
self.nametagGroup.removeNametag(self.nametagNode)
self.nametagGroup.removeNametag(self.chatNode)
self.nametagNP.removeNode()
self.chatNP.removeNode()
del self.nametagNP
del self.chatNP
del self.nametagNode
del self.chatNode
self.nametagGroup.setAvatar(NodePath())
self.nametagGroup.destroy()
self.nametagGroup = None
示例6: DistributedElevatorExt
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
class DistributedElevatorExt(DistributedElevator.DistributedElevator):
def __init__(self, cr):
DistributedElevator.DistributedElevator.__init__(self, cr)
self.nametag = None
self.currentFloor = -1
return
def setupElevator(self):
if self.isSetup:
self.elevatorSphereNodePath.removeNode()
self.leftDoor = self.bldg.leftDoor
self.rightDoor = self.bldg.rightDoor
DistributedElevator.DistributedElevator.setupElevator(self)
self.setupNametag()
def disable(self):
self.clearNametag()
DistributedElevator.DistributedElevator.disable(self)
def setupNametag(self):
if self.nametag == None:
self.nametag = NametagGroup()
self.nametag.setFont(ToontownGlobals.getBuildingNametagFont())
if TTLocalizer.BuildingNametagShadow:
self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow)
self.nametag.setContents(Nametag.CName)
self.nametag.setColorCode(NametagGroup.CCSuitBuilding)
self.nametag.setActive(0)
self.nametag.setAvatar(self.getElevatorModel())
name = self.cr.playGame.dnaData.getBlock(self.bldg.block).title
if not name:
name = TTLocalizer.CogsInc
else:
name += TTLocalizer.CogsIncExt
self.nametag.setName(name)
self.nametag.manage(base.marginManager)
return
def clearNametag(self):
if self.nametag != None:
self.nametag.unmanage(base.marginManager)
self.nametag.setAvatar(NodePath())
self.nametag.destroy()
self.nametag = None
return
def getBldgDoorOrigin(self):
return self.bldg.getSuitDoorOrigin()
def gotBldg(self, buildingList):
self.bldgRequest = None
self.bldg = buildingList[0]
if not self.bldg:
self.notify.error('setBldgDoId: elevator %d cannot find bldg %d!' % (self.doId, self.bldgDoId))
return
if self.getBldgDoorOrigin():
self.bossLevel = self.bldg.getBossLevel()
self.setupElevator()
else:
self.notify.warning('setBldgDoId: elevator %d cannot find suitDoorOrigin for bldg %d!' % (self.doId, self.bldgDoId))
return
def setFloor(self, floorNumber):
if self.currentFloor >= 0:
if self.bldg.floorIndicator[self.currentFloor]:
self.bldg.floorIndicator[self.currentFloor].setColor(LIGHT_OFF_COLOR)
if floorNumber >= 0:
if self.bldg.floorIndicator[floorNumber]:
self.bldg.floorIndicator[floorNumber].setColor(LIGHT_ON_COLOR)
self.currentFloor = floorNumber
def handleEnterSphere(self, collEntry):
self.notify.debug('Entering Elevator Sphere....')
if hasattr(localAvatar, 'boardingParty') and localAvatar.boardingParty and localAvatar.boardingParty.getGroupLeader(localAvatar.doId) and localAvatar.boardingParty.getGroupLeader(localAvatar.doId) != localAvatar.doId:
base.localAvatar.elevatorNotifier.showMe(TTLocalizer.ElevatorGroupMember)
elif self.allowedToEnter(self.zoneId):
self.cr.playGame.getPlace().detectedElevatorCollision(self)
else:
place = base.cr.playGame.getPlace()
if place:
place.fsm.request('stopped')
self.dialog = TeaserPanel.TeaserPanel(pageName='cogHQ', doneFunc=self.handleOkTeaser)
def handleEnterElevator(self):
if hasattr(localAvatar, 'boardingParty') and localAvatar.boardingParty and localAvatar.boardingParty.getGroupLeader(localAvatar.doId):
if localAvatar.boardingParty.getGroupLeader(localAvatar.doId) == localAvatar.doId:
localAvatar.boardingParty.handleEnterElevator(self)
elif self.elevatorTripId and localAvatar.lastElevatorLeft == self.elevatorTripId:
self.rejectBoard(base.localAvatar.doId, REJECT_SHUFFLE)
elif base.localAvatar.hp > 0:
toon = base.localAvatar
self.sendUpdate('requestBoard', [])
else:
self.notify.warning('Tried to board elevator with hp: %d' % base.localAvatar.hp)
def enterWaitEmpty(self, ts):
self.elevatorSphereNodePath.unstash()
self.forceDoorsOpen()
self.accept(self.uniqueName('enterelevatorSphere'), self.handleEnterSphere)
#.........这里部分代码省略.........
示例7: DistributedKnockKnockDoor
# 需要导入模块: from otp.nametag.NametagGroup import NametagGroup [as 别名]
# 或者: from otp.nametag.NametagGroup.NametagGroup import manage [as 别名]
class DistributedKnockKnockDoor(DistributedAnimatedProp.DistributedAnimatedProp):
def __init__(self, cr):
DistributedAnimatedProp.DistributedAnimatedProp.__init__(self, cr)
self.fsm.setName("DistributedKnockKnockDoor")
self.rimshot = None
self.knockSfx = None
def generate(self):
DistributedAnimatedProp.DistributedAnimatedProp.generate(self)
self.avatarTracks = []
self.avatarId = 0
def announceGenerate(self):
DistributedAnimatedProp.DistributedAnimatedProp.announceGenerate(self)
self.accept("exitKnockKnockDoorSphere_" + str(self.propId), self.exitTrigger)
self.acceptAvatar()
def disable(self):
self.ignoreAll()
DistributedAnimatedProp.DistributedAnimatedProp.disable(self)
def delete(self):
DistributedAnimatedProp.DistributedAnimatedProp.delete(self)
if self.rimshot:
self.rimshot = None
if self.knockSfx:
self.knockSfx = None
def acceptAvatar(self):
self.acceptOnce("enterKnockKnockDoorSphere_" + str(self.propId), self.enterTrigger)
def setAvatarInteract(self, avatarId):
DistributedAnimatedProp.DistributedAnimatedProp.setAvatarInteract(self, avatarId)
def avatarExit(self, avatarId):
if avatarId == self.avatarId:
self.stopTracks()
def knockKnockTrack(self, avatar, duration):
if avatar is None:
return
self.rimshot = base.loadSfx("phase_5/audio/sfx/AA_heal_telljoke.ogg")
self.knockSfx = base.loadSfx("phase_5/audio/sfx/GUI_knock_%s.ogg" % random.randint(1, 4))
joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)]
place = base.cr.playGame.getPlace()
doorName = TTLocalizer.DoorNametag
self.nametag = None
self.nametagNP = None
doorNP = render.find("**/KnockKnockDoorSphere_" + str(self.propId) + ";+s")
if doorNP.isEmpty():
self.notify.warning("Could not find KnockKnockDoorSphere_%s" % self.propId)
return
self.nametag = NametagGroup()
self.nametag.setAvatar(doorNP)
self.nametag.setFont(ToontownGlobals.getToonFont())
self.nametag.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setName(doorName)
self.nametag.setActive(0)
self.nametag.manage(base.marginManager)
self.nametag.getNametag3d().setBillboardOffset(4)
nametagNode = self.nametag.getNametag3d()
self.nametagNP = render.attachNewNode(nametagNode)
self.nametagNP.setName("knockKnockDoor_nt_" + str(self.propId))
pos = doorNP.getBounds().getCenter()
self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2))
d = duration * 0.125
track = Sequence(
Parallel(
Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)),
Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech),
Wait(d),
),
Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0),
Wait(d),
Func(self.nametag.setChat, joke[0], CFSpeech),
Wait(d),
Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0),
Wait(d),
Func(self.nametag.setChat, joke[1], CFSpeech),
)
if avatar == base.localAvatar:
track.append(Func(self.sendUpdate, "requestToonup"))
track.append(Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4)))
track.append(Func(self.cleanupTrack))
track.delayDelete = DelayDelete.DelayDelete(avatar, "knockKnockTrack")
return track
def cleanupTrack(self):
avatar = self.cr.doId2do.get(self.avatarId)
if avatar:
avatar.clearChat()
if self.nametag:
self.nametag.unmanage(base.marginManager)
self.nametagNP.removeNode()
self.nametag.destroy()
#.........这里部分代码省略.........