本文整理汇总了Python中direct.fsm.ClassicFSM.ClassicFSM.getStates方法的典型用法代码示例。如果您正苦于以下问题:Python ClassicFSM.getStates方法的具体用法?Python ClassicFSM.getStates怎么用?Python ClassicFSM.getStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.fsm.ClassicFSM.ClassicFSM
的用法示例。
在下文中一共展示了ClassicFSM.getStates方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Toon
# 需要导入模块: from direct.fsm.ClassicFSM import ClassicFSM [as 别名]
# 或者: from direct.fsm.ClassicFSM.ClassicFSM import getStates [as 别名]
class Toon(Avatar.Avatar, ToonHead, ToonDNA.ToonDNA):
def __init__(self, cr, mat = 0):
self.cr = cr
try:
self.Toon_initialized
return
except:
self.Toon_initialized = 1
Avatar.Avatar.__init__(self, mat)
ToonDNA.ToonDNA.__init__(self)
ToonHead.__init__(self, cr)
self.forwardSpeed = 0.0
self.rotateSpeed = 0.0
self.avatarType = CIGlobals.Toon
self.track = None
self.standWalkRunReverse = None
self.playingAnim = None
self.tag = None
self.money = 0
self.lookAtTrack = None
self.portal1 = None
self.portal2 = None
self.gunAttached = False
self.gun = None
self.tokenIcon = None
self.tokenIconIval = None
self.backpack = None
self.forcedTorsoAnim = None
self.fallSfx = base.audio3d.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.mp3')
base.audio3d.attachSoundToObject(self.fallSfx, self)
self.eyes = loader.loadTexture('phase_3/maps/eyes.jpg', 'phase_3/maps/eyes_a.rgb')
self.myTaskId = random.uniform(0, 1231231232132131231232L)
self.closedEyes = loader.loadTexture('phase_3/maps/eyesClosed.jpg', 'phase_3/maps/eyesClosed_a.rgb')
self.soundChatBubble = loader.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.mp3')
self.shadowCaster = None
self.chatSoundDict = {}
self.animFSM = ClassicFSM('Toon', [State('off', self.enterOff, self.exitOff),
State('neutral', self.enterNeutral, self.exitNeutral),
State('swim', self.enterSwim, self.exitSwim),
State('walk', self.enterWalk, self.exitWalk),
State('run', self.enterRun, self.exitRun),
State('openBook', self.enterOpenBook, self.exitOpenBook),
State('readBook', self.enterReadBook, self.exitReadBook),
State('closeBook', self.enterCloseBook, self.exitCloseBook),
State('teleportOut', self.enterTeleportOut, self.exitTeleportOut),
State('teleportIn', self.enterTeleportIn, self.exitTeleportIn),
State('died', self.enterDied, self.exitDied),
State('fallFWD', self.enterFallFWD, self.exitFallFWD),
State('fallBCK', self.enterFallBCK, self.exitFallBCK),
State('jump', self.enterJump, self.exitJump),
State('leap', self.enterLeap, self.exitLeap),
State('laugh', self.enterLaugh, self.exitLaugh),
State('happy', self.enterHappyJump, self.exitHappyJump),
State('shrug', self.enterShrug, self.exitShrug),
State('hdance', self.enterHDance, self.exitHDance),
State('wave', self.enterWave, self.exitWave),
State('scientistEmcee', self.enterScientistEmcee, self.exitScientistEmcee),
State('scientistWork', self.enterScientistWork, self.exitScientistWork),
State('scientistGame', self.enterScientistGame, self.exitScientistGame),
State('scientistJealous', self.enterScientistJealous, self.exitScientistJealous),
State('cringe', self.enterCringe, self.exitCringe),
State('conked', self.enterConked, self.exitConked),
State('win', self.enterWin, self.exitWin),
State('walkBack', self.enterWalkBack, self.exitWalkBack),
State('deadNeutral', self.enterDeadNeutral, self.exitDeadNeutral),
State('deadWalk', self.enterDeadWalk, self.exitDeadWalk),
State('squish', self.enterSquish, self.exitSquish),
State('Happy', self.enterHappy, self.exitHappy),
State('Sad', self.enterSad, self.exitSad)], 'off', 'off')
animStateList = self.animFSM.getStates()
self.animFSM.enterInitialState()
if not hasattr(base, 'localAvatar') or not base.localAvatar == self:
Avatar.Avatar.initializeBodyCollisions(self, self.avatarType, 3, 1)
return
def enterHappy(self, ts = 0, callback = None, extraArgs = []):
self.playingAnim = None
self.standWalkRunReverse = (('neutral', 1.0),
('walk', 1.0),
('run', 1.0),
('walk', -1.0))
self.setSpeed(self.forwardSpeed, self.rotateSpeed)
return
def exitHappy(self):
self.standWalkRunReverse = None
self.stop()
return
def enterSad(self, ts = 0, callback = None, extraArgs = []):
self.playingAnim = 'sad'
self.standWalkRunReverse = (('dneutral', 1.0),
('dwalk', 1.2),
('dwalk', 1.2),
('dwalk', -1.0))
self.setSpeed(0, 0)
def exitSad(self):
#.........这里部分代码省略.........
示例2: Char
# 需要导入模块: from direct.fsm.ClassicFSM import ClassicFSM [as 别名]
# 或者: from direct.fsm.ClassicFSM.ClassicFSM import getStates [as 别名]
class Char(Avatar.Avatar):
def __init__(self):
try:
self.Char_initialized
return
except:
self.Char_initialized = 1
Avatar.Avatar.__init__(self)
self.avatarType = CIGlobals.CChar
self.avatarName = None
self.currentAnim = None
self.charType = ''
self.eyes = loader.loadTexture('phase_3/maps/eyes1.jpg', 'phase_3/maps/eyes1_a.rgb')
self.closedEyes = loader.loadTexture('phase_3/maps/mickey_eyes_closed.jpg', 'phase_3/maps/mickey_eyes_closed_a.rgb')
self.animFSM = ClassicFSM('Char', [State('off', self.enterOff, self.exitOff),
State('neutral', self.enterNeutral, self.exitNeutral),
State('walk', self.enterWalk, self.exitWalk),
State('run', self.enterRun, self.exitRun)], 'off', 'off')
animStateList = self.animFSM.getStates()
self.animFSM.enterInitialState()
Avatar.Avatar.initializeBodyCollisions(self, self.avatarType, 3.5, 1)
return
def stopAnimations(self):
if hasattr(self, 'animFSM'):
if not self.animFSM.isInternalStateInFlux():
self.animFSM.request('off')
else:
notify.warning('animFSM in flux, state=%s, not requesting off' % self.animFSM.getCurrentState().getName())
else:
notify.warning('animFSM has been deleted')
def disable(self):
self.stopBlink()
self.stopAnimations()
Avatar.Avatar.disable(self)
def delete(self):
try:
self.Char_deleted
except:
self.Char_deleted = 1
del self.animFSM
Avatar.Avatar.delete(self)
def setChat(self, chatString):
if self.charType == CIGlobals.Mickey:
self.dial = base.audio3d.loadSfx('phase_3/audio/dial/mickey.wav')
elif self.charType == CIGlobals.Minnie:
self.dial = base.audio3d.loadSfx('phase_3/audio/dial/minnie.wav')
elif self.charType == CIGlobals.Goofy:
self.dial = base.audio3d.loadSfx('phase_6/audio/dial/goofy.wav')
base.audio3d.attachSoundToObject(self.dial, self)
self.dial.play()
Avatar.Avatar.setChat(self, chatString)
def setName(self, nameString, charName = None):
self.avatarName = nameString
Avatar.Avatar.setName(self, nameString, avatarType=self.avatarType, charName=charName)
def generateChar(self, charType):
self.charType = charType
if charType == CIGlobals.Mickey or charType == CIGlobals.Minnie:
self.loadModel('phase_3/models/char/' + charType.lower() + '-' + str(CIGlobals.ModelDetail(self.avatarType)) + '.bam')
self.loadAnims({'neutral': 'phase_3/models/char/' + charType.lower() + '-wait.bam',
'walk': 'phase_3/models/char/' + charType.lower() + '-walk.bam',
'run': 'phase_3/models/char/' + charType.lower() + '-run.bam',
'left-start': 'phase_3.5/models/char/' + charType.lower() + '-left-start.bam',
'left': 'phase_3.5/models/char/' + charType.lower() + '-left.bam',
'right-start': 'phase_3.5/models/char/' + charType.lower() + '-right-start.bam',
'right': 'phase_3.5/models/char/' + charType.lower() + '-right.bam'})
if charType == CIGlobals.Mickey:
self.mickeyEye = self.controlJoint(None, 'modelRoot', 'joint_pupilR')
self.mickeyEye.setY(0.025)
for bundle in self.getPartBundleDict().values():
bundle = bundle['modelRoot'].getBundle()
earNull = bundle.findChild('sphere3')
if not earNull:
earNull = bundle.findChild('*sphere3')
earNull.clearNetTransforms()
for bundle in self.getPartBundleDict().values():
charNodepath = bundle['modelRoot'].partBundleNP
bundle = bundle['modelRoot'].getBundle()
earNull = bundle.findChild('sphere3')
if not earNull:
earNull = bundle.findChild('*sphere3')
ears = charNodepath.find('**/sphere3')
if ears.isEmpty():
ears = charNodepath.find('**/*sphere3')
ears.clearEffect(CharacterJointEffect.getClassType())
earRoot = charNodepath.attachNewNode('earRoot')
earPitch = earRoot.attachNewNode('earPitch')
earPitch.setP(40.0)
ears.reparentTo(earPitch)
earNull.addNetTransform(earRoot.node())
ears.clearMat()
ears.node().setPreserveTransform(ModelNode.PTNone)
#.........这里部分代码省略.........