本文整理汇总了Python中direct.interval.MetaInterval.Parallel.start方法的典型用法代码示例。如果您正苦于以下问题:Python Parallel.start方法的具体用法?Python Parallel.start怎么用?Python Parallel.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.interval.MetaInterval.Parallel
的用法示例。
在下文中一共展示了Parallel.start方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: animateArrival
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
def animateArrival(self):
"""
Cheesy animation introducing viewer to the DESK and TYPEWRITER
:return:
"""
camMoveInterval = LerpPosInterval(self.base.camera, 2, self.cameraTarget)
camHprInterval = LerpHprInterval(self.base.camera, 2, self.cameraHprTarget)
dropKeyboardInterval = LerpPosInterval(self.typewriterNP, 2,
self.typewriterTarget,
startPos=self.typewriterStart,
blendType='easeOut')
sequence = Parallel(camMoveInterval, camHprInterval, dropKeyboardInterval)
sequence.setDoneEvent('arrivalFinished')
def arrivalFinished():
self.activateTypewriter()
self.base.ignore('enter')
self.base.ignore('esc')
self.base.accept('arrivalFinished', arrivalFinished)
sequence.start()
# for the impatient...
def cancelStartupSequence():
sequence.finish()
self.base.acceptOnce('enter', cancelStartupSequence)
self.base.acceptOnce('esc', cancelStartupSequence)
示例2: pieThrow
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
def pieThrow(self, avId, timestamp, heading, pos, power):
toon = self.activity.getAvatar(avId)
if toon is None:
return
tossTrack, pieTrack, flyPie = self.getTossPieInterval(toon, pos[0], pos[1], pos[2], heading, 0, 0, power)
if avId == base.localAvatar.doId:
flyPie.setTag('throwerId', str(avId))
collSphere = CollisionSphere(0, 0, 0, 0.5)
collSphere.setTangible(0)
name = 'PieSphere-%d' % avId
collSphereName = self.activity.uniqueName(name)
collNode = CollisionNode(collSphereName)
collNode.setFromCollideMask(ToontownGlobals.PieBitmask)
collNode.addSolid(collSphere)
collNP = flyPie.attachNewNode(collNode)
base.cTrav.addCollider(collNP, self.pieHandler)
self.toonPieEventNames[collNP] = 'pieHit-' + collSphereName
self.accept(self.toonPieEventNames[collNP], self.handlePieCollision)
else:
player = self.players.get(avId)
if player is not None:
player.faceForward()
def matchRunningAnim(toon = toon):
toon.playingAnim = None
toon.setSpeed(toon.forwardSpeed, toon.rotateSpeed)
newTossTrack = Sequence(tossTrack, Func(matchRunningAnim))
pieTrack = Parallel(newTossTrack, pieTrack, name='PartyCogActivity.pieTrack-%d-%s' % (avId, timestamp))
elapsedTime = globalClockDelta.localElapsedTime(timestamp)
if elapsedTime < 16.0 / 24.0:
elapsedTime = 16.0 / 24.0
pieTrack.start(elapsedTime)
self.pieIvals.append(pieTrack)
self.toonPieTracks[avId] = pieTrack
示例3: DistributedPartyTugOfWarActivity
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
class DistributedPartyTugOfWarActivity(DistributedPartyTeamActivity):
notify = directNotify.newCategory('DistributedPartyTugOfWarActivity')
def __init__(self, cr):
DistributedPartyTeamActivity.__init__(self, cr, PartyGlobals.ActivityIds.PartyTugOfWar, startDelay=PartyGlobals.TugOfWarStartDelay)
self.buttons = [0, 1]
self.arrowKeys = None
self.keyTTL = []
self.idealRate = 0.0
self.keyRate = 0
self.allOutMode = False
self.rateMatchAward = 0.0
self.toonIdsToStartPositions = {}
self.toonIdsToIsPullingFlags = {}
self.toonIdsToRightHands = {}
self.fallenToons = []
self.fallenPositions = []
self.unusedFallenPositionsIndices = [0,
1,
2,
3]
self.toonIdsToAnimIntervals = {}
self.tugRopes = []
return
def generate(self):
DistributedPartyTeamActivity.generate(self)
self._hopOffFinishedSV = StateVar(True)
self._rewardFinishedSV = StateVar(True)
self._isWalkStateReadyFC = FunctionCall(self._testWalkStateReady, self._hopOffFinishedSV, self._rewardFinishedSV)
def delete(self):
self._isWalkStateReadyFC.destroy()
self._hopOffFinishedSV.destroy()
self._rewardFinishedSV.destroy()
DistributedPartyTeamActivity.delete(self)
def handleToonJoined(self, toonId):
DistributedPartyTeamActivity.handleToonJoined(self, toonId)
self.toonIdsToAnimIntervals[toonId] = None
if toonId == base.localAvatar.doId:
base.cr.playGame.getPlace().fsm.request('activity')
camera.wrtReparentTo(self.root)
self.cameraMoveIval = LerpPosHprInterval(camera, 1.5, PartyGlobals.TugOfWarCameraPos, PartyGlobals.TugOfWarCameraInitialHpr, other=self.root)
self.cameraMoveIval.start()
self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam)
self.notify.debug('posIndex: %d' % self.localToonPosIndex)
toon = self.getAvatar(toonId)
targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex]
if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
targetH = fitDestAngle2Src(toon.getH(self.root), PartyGlobals.TugOfWarHeadings[self.localToonTeam])
travelVector = targetPos - toon.getPos(self.root)
duration = travelVector.length() / 5.0
if self.toonIdsToAnimIntervals[toonId] is not None:
self.toonIdsToAnimIntervals[toonId].finish()
self.toonIdsToAnimIntervals[toonId] = Sequence(Func(toon.startPosHprBroadcast, 0.1), Func(toon.b_setAnimState, 'run'), LerpPosHprInterval(toon, duration, targetPos, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.stopPosHprBroadcast), Func(toon.b_setAnimState, 'neutral'))
self.toonIdsToAnimIntervals[toonId].start()
return
def handleToonExited(self, toonId):
DistributedPartyTeamActivity.handleToonExited(self, toonId)
if toonId == base.localAvatar.doId:
self.cameraMoveIval.pause()
if toonId not in self.fallenToons:
if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[toonId] is not None:
self.toonIdsToAnimIntervals[toonId].finish()
toon = self.getAvatar(toonId)
targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
targetPos = self.hopOffPositions[self.getTeam(toonId)][self.getIndex(toonId, self.getTeam(toonId))]
hopOffAnim = Sequence(Func(toon.startPosHprBroadcast, 0.1), toon.hprInterval(0.2, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.b_setAnimState, 'jump', 1.0), Wait(0.4), PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0, self.root), Func(toon.stopPosHprBroadcast), Func(toon.sendCurrentPosition), Func(self.hopOffFinished, toonId))
self.toonIdsToAnimIntervals[toonId] = hopOffAnim
self._hopOffFinishedSV.set(False)
self.toonIdsToAnimIntervals[toonId].start()
else:
self._hopOffFinishedSV.set(True)
del self.toonIdsToAnimIntervals[toonId]
return
def handleRewardDone(self):
self._rewardFinishedSV.set(True)
def _testWalkStateReady(self, hoppedOff, rewardFinished):
if hoppedOff and rewardFinished:
DistributedPartyTeamActivity.handleRewardDone(self)
def hopOffFinished(self, toonId):
if hasattr(self, 'toonIdsToAnimIntervals') and toonId in self.toonIdsToAnimIntervals:
del self.toonIdsToAnimIntervals[toonId]
if toonId == base.localAvatar.doId:
if hasattr(self._hopOffFinishedSV, '_value'):
self._hopOffFinishedSV.set(True)
def handleToonShifted(self, toonId):
if toonId == base.localAvatar.doId:
self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam)
if self.toonIdsToAnimIntervals[toonId] is not None:
self.toonIdsToAnimIntervals[toonId].finish()
toon = self.getAvatar(toonId)
targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex]
#.........这里部分代码省略.........
示例4: PartyCog
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
#.........这里部分代码省略.........
def unload(self):
self.request('Off')
self.clearHitInterval()
if self.hole is not None:
self.hole.removeNode()
self.hole = None
if self.actor is not None:
self.actor.cleanup()
self.actor.removeNode()
self.actor = None
if self.root is not None:
self.root.removeNode()
self.root = None
if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
self.kaboomTrack.finish()
self.kaboomTrack = None
if self.resetRollIval is not None and self.resetRollIval.isPlaying():
self.resetRollIval.finish()
self.resetRollIval = None
if self.hitInterval is not None and self.hitInterval.isPlaying():
self.hitInterval.finish()
self.hitInterval = None
del self.upSound
del self.pieHitSound
return
def enterStatic(self):
pass
def exitStatic(self):
pass
def enterActive(self, startTime):
self.root.setR(0.0)
updateTask = Task.Task(self.updateTask)
updateTask.startTime = startTime
taskMgr.add(updateTask, 'PartyCog.update-%d' % self.id)
def exitActive(self):
taskMgr.remove('PartyCog.update-%d' % self.id)
taskMgr.remove('PartyCog.bounceTask-%d' % self.id)
self.clearHitInterval()
self.resetRollIval = self.root.hprInterval(0.5, Point3(self.root.getH(), 0.0, 0.0), blendType='easeInOut')
self.resetRollIval.start()
self.actor.stop()
def enterDown(self):
if self.oldState == 'Off':
downAnimControl = self.actor.getAnimControl('down')
self.actor.pose('down', downAnimControl.getNumFrames() - 1)
return
self.clearHitInterval()
startScale = self.hole.getScale()
endScale = Point3(5, 5, 5)
self.hitInterval = Sequence(LerpFunc(self.setAlongSpline, duration=1.0, fromData=self.currentT, toData=0.0), LerpScaleInterval(self.hole, duration=0.175, scale=endScale, startScale=startScale, blendType='easeIn'), Parallel(SoundInterval(self.upSound, volume=0.6, node=self.actor, cutOff=PartyGlobals.PARTY_COG_CUTOFF), ActorInterval(self.actor, 'down', loop=0)), LerpScaleInterval(self.hole, duration=0.175, scale=Point3(3, 3, 3), startScale=endScale, blendType='easeOut'))
self.hitInterval.start()
def exitDown(self):
self.root.setR(0.0)
self.root.setH(0.0)
self.targetDistance = 0.0
self.targetFacing = 0.0
self.currentT = 0.0
self.setAlongSpline(0.0)
self.clearHitInterval()
示例5: DistributedMazeGame
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
#.........这里部分代码省略.........
45,
42,
38,
33],
16: [47,
46,
46,
45,
43,
40,
37,
33]},
9000: {4: [43, 32],
8: [44,
42,
38,
32],
12: [44,
43,
42,
40,
36,
32],
16: [44,
44,
43,
42,
40,
38,
35,
32]}}
self.CELL_WIDTH = MazeData.CELL_WIDTH
self.MAX_FRAME_MOVE = self.CELL_WIDTH / 2
startOffset = 3
self.startPosHTable = [[Point3(0, startOffset, self.TOON_Z), 0],
[Point3(0, -startOffset, self.TOON_Z), 180],
[Point3(startOffset, 0, self.TOON_Z), 270],
[Point3(-startOffset, 0, self.TOON_Z), 90]]
self.camOffset = Vec3(0, -19, 45)
def load(self):
self.notify.debug('load')
DistributedMinigame.load(self)
self.__defineConstants()
mazeName = MazeGameGlobals.getMazeName(self.doId, self.numPlayers, MazeData.mazeNames)
self.maze = Maze.Maze(mazeName)
model = loader.loadModel('phase_3.5/models/props/mickeySZ')
self.treasureModel = model.find('**/mickeySZ')
model.removeNode()
self.treasureModel.setScale(1.6)
self.treasureModel.setP(-90)
self.music = base.loadMusic('phase_4/audio/bgm/MG_toontag.ogg')
self.toonHitTracks = {}
self.scorePanels = []
def unload(self):
self.notify.debug('unload')
DistributedMinigame.unload(self)
del self.toonHitTracks
self.maze.destroy()
del self.maze
self.treasureModel.removeNode()
del self.treasureModel
del self.music
self.removeChildGameFSM(self.gameFSM)
del self.gameFSM
示例6: MazeSuit
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
class MazeSuit(DirectObject):
COLL_SPHERE_NAME = 'MazeSuitSphere'
COLLISION_EVENT_NAME = 'MazeSuitCollision'
MOVE_IVAL_NAME = 'moveMazeSuit'
DIR_UP = 0
DIR_DOWN = 1
DIR_LEFT = 2
DIR_RIGHT = 3
oppositeDirections = [
DIR_DOWN,
DIR_UP,
DIR_RIGHT,
DIR_LEFT]
directionHs = [
0,
180,
90,
270]
DEFAULT_SPEED = 4.0
SUIT_Z = 0.10000000000000001
def __init__(self, serialNum, maze, randomNumGen, cellWalkPeriod, difficulty, suitDnaName = 'f', startTile = None, ticFreq = MazeGameGlobals.SUIT_TIC_FREQ, walkSameDirectionProb = MazeGameGlobals.WALK_SAME_DIRECTION_PROB, walkTurnAroundProb = MazeGameGlobals.WALK_TURN_AROUND_PROB, uniqueRandomNumGen = True, walkAnimName = None):
self.serialNum = serialNum
self.maze = maze
if uniqueRandomNumGen:
self.rng = RandomNumGen(randomNumGen)
else:
self.rng = randomNumGen
self.difficulty = difficulty
self._walkSameDirectionProb = walkSameDirectionProb
self._walkTurnAroundProb = walkTurnAroundProb
if not walkAnimName:
pass
self._walkAnimName = 'walk'
self.suit = Suit.Suit()
d = SuitDNA.SuitDNA()
d.newSuit(suitDnaName)
self.suit.setDNA(d)
if startTile is None:
defaultStartPos = MazeGameGlobals.SUIT_START_POSITIONS[self.serialNum]
self.startTile = (defaultStartPos[0] * self.maze.width, defaultStartPos[1] * self.maze.height)
else:
self.startTile = startTile
self.ticFreq = ticFreq
self.ticPeriod = int(cellWalkPeriod)
self.cellWalkDuration = float(self.ticPeriod) / float(self.ticFreq)
self.turnDuration = 0.59999999999999998 * self.cellWalkDuration
def destroy(self):
self.suit.delete()
def uniqueName(self, str):
return str + `self.serialNum`
def gameStart(self, gameStartTime):
self.gameStartTime = gameStartTime
self.initCollisions()
self.startWalkAnim()
self.occupiedTiles = [
(self.nextTX, self.nextTY)]
n = 20
self.nextThinkTic = self.serialNum * self.ticFreq / n
self.fromPos = Point3(0, 0, 0)
self.toPos = Point3(0, 0, 0)
self.fromHpr = Point3(0, 0, 0)
self.toHpr = Point3(0, 0, 0)
self.moveIval = WaitInterval(1.0)
def gameEnd(self):
self.moveIval.pause()
del self.moveIval
self.shutdownCollisions()
self.suit.loop('neutral')
def initCollisions(self):
self.collSphere = CollisionSphere(0, 0, 0, 2.0)
self.collSphere.setTangible(0)
self.collNode = CollisionNode(self.uniqueName(self.COLL_SPHERE_NAME))
self.collNode.setIntoCollideMask(ToontownGlobals.WallBitmask)
self.collNode.addSolid(self.collSphere)
self.collNodePath = self.suit.attachNewNode(self.collNode)
self.collNodePath.hide()
self.accept(self.uniqueName('enter' + self.COLL_SPHERE_NAME), self.handleEnterSphere)
def shutdownCollisions(self):
self.ignore(self.uniqueName('enter' + self.COLL_SPHERE_NAME))
del self.collSphere
self.collNodePath.removeNode()
del self.collNodePath
del self.collNode
def handleEnterSphere(self, collEntry):
messenger.send(self.COLLISION_EVENT_NAME, [
#.........这里部分代码省略.........
示例7: MusicBox
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
class MusicBox(DirectObject):
def __init__(self):
# Our standard title and instructions text
self.title = OnscreenText(text="Panda3D: Tutorial - Music Box",
parent=base.a2dBottomCenter,
pos=(0, 0.08), scale=0.08,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, .5))
self.escapeText = OnscreenText(text="ESC: Quit", parent=base.a2dTopLeft,
fg=(1, 1, 1, 1), pos=(0.06, -0.1),
align=TextNode.ALeft, scale=.05)
# Set up the key input
self.accept('escape', sys.exit)
# Fix the camera position
base.disableMouse()
# Loading sounds is done in a similar way to loading other things
# Loading the main music box song
self.musicBoxSound = loader.loadMusic('music/musicbox.ogg')
self.musicBoxSound.setVolume(.5) # Volume is a percentage from 0 to 1
# 0 means loop forever, 1 (default) means
# play once. 2 or higher means play that many times
self.musicBoxSound.setLoopCount(0)
# Set up a simple light.
self.plight = PointLight("light")
self.plight.setColor((0.7, 0.7, 0.5, 1))
light_path = base.render.attachNewNode(self.plight)
light_path.setPos(0, 0, 20)
base.render.setLight(light_path)
alight = AmbientLight("ambient")
alight.setColor((0.3, 0.3, 0.4, 1))
base.render.setLight(base.render.attachNewNode(alight))
# Enable per-pixel lighting
base.render.setShaderAuto()
# Sound objects do not have a pause function, just play and stop. So we will
# Use this variable to keep track of where the sound is at when it was stoped
# to impliment pausing
self.musicTime = 0
# Loading the open/close effect
# loadSFX and loadMusic are identical. They are often used for organization
#(loadMusic is used for background music, loadSfx is used for other effects)
self.lidSfx = loader.loadSfx('music/openclose.ogg')
# The open/close file has both effects in it. Fortunatly we can use intervals
# to easily define parts of a sound file to play
self.lidOpenSfx = SoundInterval(self.lidSfx, duration=2, startTime=0)
self.lidCloseSfx = SoundInterval(self.lidSfx, startTime=5)
# For this tutorial, it seemed appropriate to have on screen controls.
# The following code creates them.
# This is a label for a slider
self.sliderText = OnscreenText("Volume", pos=(-0.1, 0.87), scale=.07,
fg=(1, 1, 1, 1), shadow=(0, 0, 0, 1))
# The slider itself. It calls self.setMusicBoxVolume when changed
self.slider = DirectSlider(pos=(-0.1, 0, .75), scale=0.8, value=.50,
command=self.setMusicBoxVolume)
# A button that calls self.toggleMusicBox when pressed
self.button = DirectButton(pos=(.9, 0, .75), text="Open",
scale=.1, pad=(.2, .2),
rolloverSound=None, clickSound=None,
command=self.toggleMusicBox)
# A variable to represent the state of the simulation. It starts closed
self.boxOpen = False
# Here we load and set up the music box. It was modeled in a complex way, so
# setting it up will be complicated
self.musicBox = loader.loadModel('models/MusicBox')
self.musicBox.setPos(0, 60, -9)
self.musicBox.reparentTo(render)
# Just like the scene graph contains hierarchies of nodes, so can
# models. You can get the NodePath for the node using the find
# function, and then you can animate the model by moving its parts
# To see the hierarchy of a model, use, the ls function
# self.musicBox.ls() prints out the entire hierarchy of the model
# Finding pieces of the model
self.Lid = self.musicBox.find('**/lid')
self.Panda = self.musicBox.find('**/turningthing')
# This model was made with the hinge in the wrong place
# this is here so we have something to turn
self.HingeNode = self.musicBox.find(
'**/box').attachNewNode('nHingeNode')
self.HingeNode.setPos(.8659, 6.5, 5.4)
# WRT - ie with respect to. Reparents the object without changing
# its position, size, or orientation
self.Lid.wrtReparentTo(self.HingeNode)
self.HingeNode.setHpr(0, 90, 0)
# This sets up an interval to play the close sound and actually close the box
# at the same time.
self.lidClose = Parallel(
self.lidCloseSfx,
LerpHprInterval(self.HingeNode, 2.0, (0, 90, 0), blendType='easeInOut'))
#.........这里部分代码省略.........
示例8: DistributedPartyDanceActivityBase
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
class DistributedPartyDanceActivityBase(DistributedPartyActivity):
notify = directNotify.newCategory('DistributedPartyDanceActivity')
def __init__(self, cr, actId, dancePatternToAnims, model = 'phase_13/models/parties/danceFloor'):
DistributedPartyActivity.__init__(self, cr, actId, ActivityTypes.Continuous)
self.model = model
self.danceFloor = None
self.localToonDancing = False
self.keyCodes = None
self.gui = None
self.currentCameraMode = None
self.orthoWalk = None
self.cameraParallel = None
self.localToonDanceSequence = None
self.localPatternsMatched = []
self.dancePatternToAnims = dancePatternToAnims
self.dancingToonFSMs = {}
return
def generateInit(self):
self.notify.debug('generateInit')
DistributedPartyActivity.generateInit(self)
self.keyCodes = KeyCodes(patterns=self.dancePatternToAnims.keys())
self.gui = KeyCodesGui(self.keyCodes)
self.__initOrthoWalk()
self.activityFSM = DanceActivityFSM(self)
def announceGenerate(self):
DistributedPartyActivity.announceGenerate(self)
self.activityFSM.request('Active')
def load(self):
DistributedPartyActivity.load(self)
self.danceFloor = loader.loadModel(self.model)
self.danceFloor.reparentTo(self.getParentNodePath())
self.danceFloor.setPos(self.x, self.y, 0.0)
self.danceFloor.setH(self.h)
self.danceFloor.wrtReparentTo(render)
self.sign.setPos(22, -22, 0)
floor = self.danceFloor.find('**/danceFloor_mesh')
self.danceFloorSequence = Sequence(Wait(0.3), Func(floor.setH, floor, 36))
discoBall = self.danceFloor.find('**/discoBall_mesh')
self.discoBallSequence = Parallel(discoBall.hprInterval(6.0, Vec3(360, 0, 0)), Sequence(discoBall.posInterval(3, Point3(0, 0, 1), blendType='easeInOut'), discoBall.posInterval(3, Point3(0, 0, 0), blendType='easeInOut')))
def unload(self):
DistributedPartyActivity.unload(self)
self.activityFSM.request('Disabled')
if self.localToonDanceSequence is not None:
self.localToonDanceSequence.finish()
if self.localToonDancing:
self.__localStopDancing()
self.ignoreAll()
if self.discoBallSequence is not None:
self.discoBallSequence.finish()
if self.danceFloorSequence is not None:
self.danceFloorSequence.finish()
del self.danceFloorSequence
del self.discoBallSequence
del self.localToonDanceSequence
if self.danceFloor is not None:
self.danceFloor.removeNode()
self.danceFloor = None
self.__destroyOrthoWalk()
for toonId in self.dancingToonFSMs.keys():
self.dancingToonFSMs[toonId].destroy()
del self.dancingToonFSMs[toonId]
del self.dancingToonFSMs
del self.cameraParallel
del self.currentCameraMode
if self.keyCodes is not None:
self.keyCodes.destroy()
del self.keyCodes
del self.activityFSM
del self.gui
del self.localPatternsMatched
return
def handleToonDisabled(self, toonId):
self.notify.debug('handleToonDisabled avatar ' + str(toonId) + ' disabled')
if self.dancingToonFSMs.has_key(toonId):
self.dancingToonFSMs[toonId].request('cleanup')
self.dancingToonFSMs[toonId].destroy()
del self.dancingToonFSMs[toonId]
def getTitle(self):
self.notify.warning('define title for this dance activity')
return TTLocalizer.PartyDanceActivityTitle
def getInstructions(self):
self.notify.warning('define instructions for this dance activity')
return TTLocalizer.PartyDanceActivityInstructions
def startActive(self):
self.accept('enter' + DANCE_FLOOR_COLLISION, self.__handleEnterDanceFloor)
self.accept('exit' + DANCE_FLOOR_COLLISION, self.__handleExitDanceFloor)
self.danceFloorSequence.loop()
self.discoBallSequence.loop()
def finishActive(self):
#.........这里部分代码省略.........
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leaked-Source,代码行数:103,代码来源:DistributedPartyDanceActivityBase.py
示例9: __init__
# 需要导入模块: from direct.interval.MetaInterval import Parallel [as 别名]
# 或者: from direct.interval.MetaInterval.Parallel import start [as 别名]
#.........这里部分代码省略.........
return
def destroy(self):
self.cleanUpIvals()
self.toon = None
self.locator = None
self.position = None
self.pieHitSound = None
self.splat = None
return
def cleanUpIvals(self):
if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
self.kaboomTrack.finish()
self.kaboomTrack = None
return
def faceForward(self):
self.toon.setH(0)
def setToonStartPosition(self, position):
self.position = position
def updateToonPosition(self):
self.toon.setPos(self.activity.root, self.position)
self.toon.setH(self.locator, 0.0)
def setTeam(self, team):
self.team = team
self.locator = self.activity.view.teamLocators[self.team]
self.teamSpot = self.activity.getIndex(self.toon.doId, self.team)
def entersActivity(self):
self.locator = self.activity.view.teamLocators[self.team]
def exitsActivity(self):
offset = 0
if self.teamSpot:
offset = 4.0 * self.teamSpot
self.toon.wrtReparentTo(render)
self.toon.setPos(self.locator, offset, -35.0, 0.0)
self.toon.setH(self.activity.root, 0.0)
self.locator = None
return
def enable(self):
if self.enabled:
return
self.toon.wrtReparentTo(self.locator)
self.enabled = True
def disable(self):
if not self.enabled:
return
self.toon.wrtReparentTo(render)
self.enabled = False
self.cleanUpIvals()
def hitBody(self):
points = PartyGlobals.CogActivityHitPoints
self.score += points
return points
def hitHead(self):
points = PartyGlobals.CogActivityHitPointsForHead
self.score += points
return points
def resetScore(self):
self.score = 0
def respondToPieHit(self, timestamp, pos):
if self.netTimeSentToStartByHit < timestamp:
self.__showSplat(pos)
if self.netTimeSentToStartByHit < timestamp:
self.netTimeSentToStartByHit = timestamp
else:
self.activity.notify.debug('PartyCogPlayer respondToPieHit self.netTimeSentToStartByHit = %s' % self.netTimeSentToStartByHit)
def __showSplat(self, position):
if self.kaboomTrack is not None and self.kaboomTrack.isPlaying():
self.kaboomTrack.finish()
if not self.pieHitSound:
self.notify.warning('Trying to play hit sound on destroyed player')
return
splatName = 'splat-creampie'
self.splat = globalPropPool.getProp(splatName)
self.splat.setBillboardPointEye()
self.splat.reparentTo(render)
self.splat.setPos(self.toon, position)
self.splat.setY(self.toon, bound(self.splat.getY(), self.toon.getHeight() / 2.0, position.getY()))
self.splat.setAlphaScale(1.0)
targetscale = 0.75
def setSplatAlpha(amount):
self.splat.setAlphaScale(amount)
self.kaboomTrack = Parallel(SoundInterval(self.pieHitSound, node=self.toon, volume=1.0, cutOff=PartyGlobals.PARTY_COG_CUTOFF), Sequence(Func(self.splat.showThrough), Parallel(Sequence(LerpScaleInterval(self.splat, duration=0.175, scale=targetscale, startScale=Point3(0.1, 0.1, 0.1), blendType='easeOut'), Wait(0.175)), Sequence(Wait(0.1), LerpFunc(setSplatAlpha, duration=1.0, fromData=1.0, toData=0.0, blendType='easeOut'))), Func(self.splat.cleanup), Func(self.splat.removeNode)))
self.kaboomTrack.start()
return