本文整理汇总了Python中direct.gui.DirectGui.DirectWaitBar.update方法的典型用法代码示例。如果您正苦于以下问题:Python DirectWaitBar.update方法的具体用法?Python DirectWaitBar.update怎么用?Python DirectWaitBar.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectGui.DirectWaitBar
的用法示例。
在下文中一共展示了DirectWaitBar.update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProgressBar
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class ProgressBar(object):
'''
'''
def __init__(self):
'''
'''
self.__wait_bar = DirectWaitBar( text = "Carregando...",
value = 0,
pos = (0, 0, -.95),
text_scale = 0.05,
text_pos = (0, 0.025),
frameSize = (-1.3, 1.3, 0, 0.08) )
self.hide()
def finish(self):
self.__wait_bar['barColor'] = (0, 1, 0, 1)
self.__wait_bar.setBarColor()
self.__wait_bar.finish()
self.hide()
def hide(self):
self.__wait_bar.hide()
def show(self):
self.__wait_bar.show()
def update(self, value):
if value < 25:
self.__wait_bar['barColor'] = (1, 0, 0, 1)
elif value > 25 and value < 75:
self.__wait_bar['barColor'] = (1, 1, 0, 1)
elif value > 75:
self.__wait_bar['barColor'] = (0, 1, 0, 1)
self.__wait_bar.setBarColor()
self.__wait_bar.update(value)
示例2: DistributedCogBattle
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class DistributedCogBattle(DistributedObject):
notify = directNotify.newCategory('DistributedCogBattle')
DNCData = {0: [[(-50, 98.73, 0.4), (351.31, 0.0, 0.0), 1.25],
[(-41.07, 97.2, 0.4), (350.34, 0.0, 0.0), 1.25],
[(-152.73, -0.58, 0.4), (90.0, 0, 0), 1.25],
[(-152.73, 8.81, 0.4), (85.3, 0, 0), 1.25],
[(34.34, -157.19, 2.95), (150.75, 0, 0), 1.25],
[(26.21, -152.66, 2.95), (147.09, 0, 0), 1.25]],
1: [],
2: [],
5: []}
def __init__(self, cr):
try:
self.DistributedCogBattle_initialized
return
except:
self.DistributedCogBattle_initialized = 1
DistributedObject.__init__(self, cr)
self.hoodIndex = None
self.totalCogs = None
self.cogsRemaining = None
self.cogProgressBar = None
self.DNCSigns = []
self.introMessageSeq = None
self.victorySeq = None
self.turretManager = None
return
def setTurretManager(self, tmgr):
self.turretManager = tmgr
def getTurretManager(self):
return self.turretManager
def victory(self):
self.cr.playGame.getPlace().fsm.request('stop')
base.localAvatar.b_setAnimState('win')
self.victorySeq = Sequence(Wait(7.0), Func(self.finishVictory))
self.victorySeq.start()
def finishVictory(self):
hoodId = self.cr.playGame.hood.hoodId
if hoodId == CIGlobals.BattleTTC:
hoodId = CIGlobals.ToontownCentral
zoneId = CIGlobals.ToontownCentralId
else:
zoneId = CogBattleGlobals.HoodIndex2HoodId[self.getHoodIndex()]
requestStatus = {'zoneId': zoneId,
'hoodId': hoodId,
'where': 'playground',
'avId': base.localAvatar.doId,
'loader': 'safeZoneLoader',
'shardId': None,
'how': 'teleportIn'}
self.cr.playGame.getPlace().fsm.request('teleportOut', [requestStatus])
return
def setTotalCogs(self, num):
self.totalCogs = num
def getTotalCogs(self):
return self.totalCogs
def setCogsRemaining(self, num):
self.cogsRemaining = num
if self.cogProgressBar:
self.__updateProgressBar()
def getCogsRemaining(self):
return self.cogsRemaining
def setHoodIndex(self, index):
self.hoodIndex = index
def getHoodIndex(self):
return self.hoodIndex
def startPlacePoll(self):
taskMgr.add(self.__placePoll, 'DistributedCogBattle-placePoll')
def __placePoll(self, task):
if self.cr.playGame.getPlace() != None:
self.sendUpdate('arrived', [])
self.constructArea()
self.createInterface()
self.__doIntroMessages()
return task.done
else:
return task.cont
return
def stopPlacePoll(self):
taskMgr.remove('DistributedCogBattle-placePoll')
def createInterface(self):
self.cogProgressBar = DirectWaitBar(pos=(0, 0, -0.9), relief=DGG.RAISED, scale=0.6, frameColor=(1, 0.5, 0.3, 0.75), barColor=(1, 0.25, 0.25, 0.5), value=0, range=self.getTotalCogs(), text='', text_scale=0.08)
self.__updateProgressBar()
#.........这里部分代码省略.........
示例3: ExperimentChallengeGUI
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class ExperimentChallengeGUI(NodePath):
def __init__(self, description, needed, icon):
NodePath.__init__(self, 'objective-%s' % id(self))
self.needed = needed
self.visible = False
self.fadeInTrack = None
self.fadeOutTrack = None
gui = loader.loadModel('phase_5/models/cogdominium/tt_m_gui_csa_flyThru')
self.background = gui.find('**/*background').copyTo(self)
self.background.setScale(2.5)
gui.removeNode()
self.icon = icon.copyTo(self.background)
self.icon.setScale(0.08)
self.icon.setPos(-0.167, 0, -0.002)
text = TextNode('challenge')
text.setText('Challenge')
text.setFont(ToontownGlobals.getSignFont())
text.setTextColor(0.95, 0.95, 0, 1)
self.objText = self.background.attachNewNode(text)
self.objText.setScale(0.03)
self.objText.setPos(-0.04, 0.0, 0.02)
text = TextNode('description')
text.setText(description)
text.setFont(ToontownGlobals.getSignFont())
text.setTextColor(0.95, 0.95, 0, 1)
text.setAlign(TextNode.ACenter)
self.objText = self.background.attachNewNode(text)
self.objText.setScale(0.015)
self.objText.setPos(0.048, 0.0, -0.009)
self.progressBar = DirectWaitBar(guiId='ChallengeProgressBar', parent=self.background, frameSize=(-0.11, 0.11, -0.007, 0.007), pos=(0.048, 0, -0.0338), text='')
self.progressBar['range'] = needed
self.progressText = DirectLabel(guiId='ChallengeProgressText', parent=self.progressBar, relief=None, pos=(0, 0, -0.0048), text='', textMayChange=1, text_scale=0.014, text_fg=(0.03, 0.83, 0, 1), text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont())
self.updateProgress(0)
self.reparentTo(base.a2dBottomLeft)
self.stash()
def updateProgress(self, count):
self.progressBar.update(count)
self.progressText['text'] = '%s/%s' % (count, self.needed)
def fadeIn(self):
if self.fadeOutTrack:
self.fadeOutTrack.finish()
self.fadeOutTrack = None
self.visible = True
self.fadeInTrack = Sequence(Func(self.unstash),
Func(self.setTransparency, 1),
LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0)),
Func(self.clearColorScale),
Func(self.clearTransparency))
self.fadeInTrack.start()
def fadeOut(self):
if self.fadeInTrack:
self.fadeInTrack.finish()
self.fadeInTrack = None
self.visible = False
self.fadeOutTrack = Sequence(Func(self.setTransparency, 1),
LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1)),
Func(self.clearColorScale),
Func(self.clearTransparency),
Func(self.stash))
self.fadeOutTrack.start()
def fadeOutDestroy(self):
self.visible = False
Sequence(Func(self.setTransparency, 1),
LerpColorScaleInterval(self, 1, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1)),
Func(self.clearColorScale),
Func(self.clearTransparency),
Func(self.stash),
Func(self.destroy)).start()
def destroy(self):
self.removeNode()
开发者ID:ToontownModder101,项目名称:Toontown-Offline-Squirting-Flower-Modded-,代码行数:89,代码来源:ExperimentChallengeGUI.py
示例4: __init__
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class CIProgressScreen:
def __init__(self):
self.bgm = loader.loadModel('phase_3/models/gui/progress-background.bam')
self.bgm.find('**/logo').stash()
self.bg = self.bgm.find('**/bg')
self.logo = loader.loadTexture('phase_3/maps/CogInvasion_Logo.png')
self.logoImg = OnscreenImage(image=self.logo, scale=(0.5, 0, 0.3), pos=(0, 0, 0), parent=hidden)
self.logoImg.setTransparency(True)
self.bg_img = OnscreenImage(image=self.bg, parent=hidden)
self.bg_img.setSx(1.35)
self.bg_img.hide()
self.progress_bar = DirectWaitBar(value=0, pos=(0, 0, -0.85), parent=hidden, text_pos=(0, 0, 0.2))
self.progress_bar.setSx(1.064)
self.progress_bar.setSz(0.38)
self.loading_lbl = DirectLabel(text='', relief=None, scale=0.08, pos=(-1.0725, 0, -0.79), text_align=TextNode.ALeft, sortOrder=100, text_fg=(0.343, 0.343, 0.343, 1.0), text_font=CIGlobals.getMinnieFont(), parent=hidden, text_shadow=(0, 0, 0, 1))
return
def begin(self, hood, range, wantGui):
render.hide()
self.renderFrames()
base.setBackgroundColor(0, 0, 0)
if hood == 'localAvatarEnterGame':
self.loading_lbl['text'] = 'Entering...'
elif hood == 'init':
self.loading_lbl['text'] = 'Loading...'
else:
self.loading_lbl['text'] = 'Heading to %s...' % hood
self.progress_bar['barColor'] = (0.343, 0.343, 0.343, 1.0)
self.progress_bar['range'] = range
self.bgm.reparentTo(aspect2d)
self.bg.reparentTo(render2d)
self.bg_img.reparentTo(hidden)
self.loading_lbl.reparentTo(aspect2d)
self.logoImg.reparentTo(aspect2d)
self.progress_bar.reparentTo(aspect2d)
self.__count = 0
self.__expectedCount = range
self.progress_bar.update(self.__count)
def renderFramesTask(self, task):
self.renderFrames()
return task.cont
def end(self):
base.setBackgroundColor(CIGlobals.DefaultBackgroundColor)
taskMgr.remove('renderFrames')
render.show()
self.progress_bar.finish()
self.bg_img.reparentTo(hidden)
self.logoImg.reparentTo(hidden)
self.bg.reparentTo(hidden)
self.bgm.reparentTo(hidden)
self.loading_lbl.reparentTo(hidden)
self.progress_bar.reparentTo(hidden)
self.renderFrames()
def destroy(self):
self.bg.removeNode()
del self.bg
self.bgm.removeNode()
del self.bgm
self.bg_img.destroy()
self.loading_lbl.destroy()
self.progress_bar.destroy()
self.bgm.destroy()
del self.bg_img
del self.loading_lbl
del self.progress_bar
del self.bgm
def renderFrames(self):
base.graphicsEngine.renderFrame()
base.graphicsEngine.renderFrame()
def tick(self):
self.__count += 1
self.progress_bar.update(self.__count)
示例5: Enemy
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class Enemy(DirectObject):
def __init__(self, _main):
self.main = _main
self.strenght = self.main.enemyStrength
self.id = id(self)
self.model = loader.loadModel("Enemy")
self.model.setP(-90)
self.model.setH(180)
self.model.hide()
cs = CollisionSphere(0, 0, 0, 0.5)
cnode = CollisionNode('colEnemy' + str(self.id))
cnode.addSolid(cs)
self.colNP = self.model.attachNewNode(cnode)
#self.colNP.show()
# Game state
self.health = 100 + (100 * self.strenght)
self.damageDone = 0.1 + (0.1 * self.strenght)
self.lastShot = 0.0
self.attackRate = 10.0
self.statusHealth = DirectWaitBar(
text = "",
value = self.health,
range = self.health,
frameSize = (0.12, 0.8, -0.12, 0.0),
pos = (-0.5, 0, -0.5),
barColor = (1, 0, 0, 1))
self.statusHealth.reparentTo(self.model)
self.statusHealth.setDepthWrite(False)
self.statusHealth.setBin('fixed', 0)
self.statusHealth.setBillboardAxis()
def start(self, startPos, enemyParent):
self.model.show()
self.model.reparentTo(enemyParent)
self.model.setPos(startPos.x,
startPos.y,
0)
self.accept("into-" + "colEnemy" + str(self.id), self.hit)
self.accept("inRange-" + "colEnemy" + str(self.id), self.startAttack)
self.statusHealth.update(self.health)
def stop(self):
self.model.remove_node()
self.ignore("into-" + "colEnemy" + str(self.id))
self.ignore("inRange-" + "colEnemy" + str(self.id))
def hit(self, _dmg):
if self.health == 0:
base.messenger.send("killEnemy", [self.id])
else:
self.health -= _dmg
self.statusHealth.update(self.health)
def makeAi(self):
# Make some ai character for each
self.aiChar = AICharacter("Enemy" + str(self.id), self.model, -100, 0.05 + (0.05 * self.strenght), 6 + (1 * self.strenght))
self.main.AiWorld.addAiChar(self.aiChar)
self.AIbehaviors = self.aiChar.getAiBehaviors()
self.AIbehaviors.pursue(self.main.player.model)
return self.aiChar
def startAttack(self, _inRange=False):
if _inRange:
self.isAttacking = True
self.simpleAttack()
#taskMgr.remove("StartAttack")
#elif _inRange:
# pass
# taskMgr.add(self.attack, "StartAttack")
def attack(self, task):
dt = globalClock.getDt()
self.lastShot += dt
if self.lastShot >= self.attackRate:
self.lastShot -= self.attackRate
base.messenger.send("doDamageToPlayer", [self.damageDone])
return task.again
def simpleAttack(self):
base.messenger.send("doDamageToPlayer", [self.damageDone])
示例6: __init__
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
class BRWater:
notify = directNotify.newCategory('BRWater')
def __init__(self, playground):
self.playground = playground
self.fsm = ClassicFSM('BRWater', [State('off', self.enterOff, self.exitOff),
State('freezeUp', self.enterFreezeUp, self.exitFreezeUp),
State('coolDown', self.enterCoolDown, self.exitCoolDown),
State('frozen', self.enterFrozen, self.exitFrozen)], 'off', 'off')
self.fsm.enterInitialState()
self.freezeUpSfx = base.loadSfx('phase_8/audio/sfx/freeze_up.mp3')
self.frozenSfxArray = [base.loadSfx('phase_8/audio/sfx/frozen_1.mp3'), base.loadSfx('phase_8/audio/sfx/frozen_2.mp3'), base.loadSfx('phase_8/audio/sfx/frozen_3.mp3')]
self.coolSfxArray = [base.loadSfx('phase_8/audio/sfx/cool_down_1.mp3'), base.loadSfx('phase_8/audio/sfx/cool_down_2.mp3')]
self.freezeUpSfx.setVolume(12)
for sfx in self.frozenSfxArray:
sfx.setVolume(12)
for sfx in self.coolSfxArray:
sfx.setVolume(12)
def attachSound(self, sound):
base.localAvatar.audio3d.attachSoundToObject(sound, base.localAvatar)
def enterOff(self):
self.playground.startWaterWatch()
def exitOff(self):
self.playground.stopWaterWatch()
def loadIceCube(self):
self.iceCube = loader.loadModel('phase_8/models/props/icecube.bam')
for node in self.iceCube.findAllMatches('**/billboard*'):
node.removeNode()
for node in self.iceCube.findAllMatches('**/drop_shadow*'):
node.removeNode()
for node in self.iceCube.findAllMatches('**/prop_mailboxcollisions*'):
node.removeNode()
self.iceCube.reparentTo(base.localAvatar)
self.iceCube.setScale(1.2, 1.0, base.localAvatar.getHeight() / 1.7)
self.iceCube.setTransparency(1)
self.iceCube.setColorScale(0.76, 0.76, 1.0, 0.0)
def unloadIceCube(self):
self.iceCube.removeNode()
del self.iceCube
def enterFreezeUp(self):
length = 1.0
base.playSfx(self.freezeUpSfx)
self.fucsIval = Sequence(LerpColorScaleInterval(base.localAvatar.getGeomNode(), duration=length, colorScale=VBase4(0.5, 0.5, 1.0, 1.0), startColorScale=base.localAvatar.getGeomNode().getColorScale(), blendType='easeOut'), Func(self.fsm.request, 'frozen'))
self.fucsIval.start()
self.playground.startWaterWatch(0)
def exitFreezeUp(self):
self.fucsIval.pause()
del self.fucsIval
self.playground.stopWaterWatch()
def enterFrozen(self):
self.loadIceCube()
base.cr.playGame.getPlace().fsm.request('stop', [0])
base.localAvatar.stop()
base.playSfx(choice(self.frozenSfxArray))
self.iccsIval = LerpColorScaleInterval(self.iceCube, duration=0.5, colorScale=VBase4(0.76, 0.76, 1.0, 1.0), startColorScale=self.iceCube.getColorScale(), blendType='easeInOut')
self.iccsIval.start()
props = WindowProperties()
props.setCursorHidden(True)
base.win.requestProperties(props)
self.frame = DirectFrame(pos=(0, 0, 0.7))
self.powerBar = DirectWaitBar(frameColor=(1, 1, 1, 1), range=100, value=0, scale=(0.4, 0.5, 0.25), parent=self.frame, barColor=(0.55, 0.7, 1.0, 1.0))
self.label = OnscreenText(text='SHAKE MOUSE', shadow=(0, 0, 0, 1), fg=(0.55, 0.7, 1.0, 1.0), pos=(0, -0.1, 0), parent=self.frame)
taskMgr.add(self.__watchMouseMovement, 'BRWater-watchMouseMovement')
taskMgr.add(self.__lowerPowerBar, 'BRWater-lowerPowerBar')
mw = base.mouseWatcherNode
if mw.hasMouse():
self.lastMouseX = mw.getMouseX()
def __lowerPowerBar(self, task):
if self.powerBar['value'] <= 0:
self.powerBar.update(0)
decrement = 1
self.powerBar.update(self.powerBar['value'] - decrement)
task.delayTime = 0.1
return task.again
def __watchMouseMovement(self, task):
if self.powerBar['value'] >= self.powerBar['range']:
self.fsm.request('coolDown', [1])
return task.done
mw = base.mouseWatcherNode
if mw.hasMouse():
if not self.lastMouseX or self.lastMouseX != mw.getMouseX():
value = 3 * self.lastMouseX - mw.getMouseX()
self.lastMouseX = mw.getMouseX()
self.powerBar.update(self.powerBar['value'] + abs(value))
return task.cont
#.........这里部分代码省略.........
示例7: DistributedPieTurretManager
# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import update [as 别名]
#.........这里部分代码省略.........
if turret != None:
self.myTurret = turret
self.turretGag = None
self.makeGui()
return Task.done
else:
return Task.cont
def setGag(self, upgradeId):
self.turretGag = upgradeId
def d_requestPlace(self, posHpr):
self.sendUpdate("requestPlace", [posHpr])
def turretPlaced(self, turretId):
turret = self.cr.doId2do.get(turretId)
turret.b_setGag(self.turretGag)
self.turretGag = None
base.taskMgr.add(self.__pollTurret, "DPTM.pollTurret", extraArgs=[turretId], appendTask=True)
return
def yourTurretIsDead(self):
base.taskMgr.remove("DPTM.pollTurret")
self.destroyGui()
self.myTurret = None
if base.localAvatar.getPUInventory()[0] > 0:
self.createTurretButton()
return
def makeGui(self):
self.destroyGui()
self.guiFrame = DirectFrame(parent=base.a2dBottomRight, pos=(-0.55, 0, 0.15))
self.guiBg = OnscreenImage(image="phase_4/maps/turret_gui_bg.png", scale=(0.15, 0, 0.075), parent=self.guiFrame)
self.guiBg.setTransparency(True)
self.guiLabel = DirectLabel(
text="Turret",
text_fg=(1, 0, 0, 1),
relief=None,
text_scale=0.05,
text_font=loader.loadFont("phase_3/models/fonts/ImpressBT.ttf"),
pos=(0, 0, 0.025),
parent=self.guiFrame,
)
self.guiBar = DirectWaitBar(
range=self.myTurret.getMaxHealth(),
value=self.myTurret.getHealth(),
scale=0.125,
parent=self.guiFrame,
pos=(0, 0, -0.01),
)
return
def createTurretButton(self):
self.makeTurretBtn = DirectButton(
relief=None,
geom=CIGlobals.getDefaultBtnGeom(),
text="Turret",
text_scale=0.055,
command=self.handleMakeTurretBtn,
pos=(-0.47, 0, 0.1),
geom_scale=(0.5, 1.0, 1.0),
text_pos=(0, -0.01),
parent=base.a2dBottomRight,
)
return
def handleMakeTurretBtn(self):
self.makeTurretBtn.destroy()
del self.makeTurretBtn
x, y, z = base.localAvatar.getPos()
h, p, r = base.localAvatar.getHpr()
self.d_requestPlace([x, y, z, h, p, r])
base.localAvatar.sendUpdate("usedPU", [0])
def __pollMyBattle(self, task):
if base.localAvatar.getMyBattle():
base.localAvatar.getMyBattle().setTurretManager(self)
if base.localAvatar.getPUInventory()[0] > 0:
self.createTurretButton()
return Task.done
return Task.cont
def destroyGui(self):
if self.guiBar:
self.guiBar.destroy()
self.guiBar = None
if self.guiLabel:
self.guiLabel.destroy()
self.guiLabel = None
if self.guiBg:
self.guiBg.destroy()
self.guiBg = None
if self.guiFrame:
self.guiFrame.destroy()
self.guiFrame = None
return
def updateTurretGui(self):
if self.guiBar:
self.guiBar.update(self.myTurret.getHealth())