def loseCogSuits(self, toons, battleNode, camLoc, arrayOfObjs = False): seq = Sequence() if not toons: return seq self.notify.debug('battleNode=%s camLoc=%s' % (battleNode, camLoc)) seq.append(Func(camera.setPosHpr, battleNode, *camLoc)) suitsOff = Parallel() if arrayOfObjs: toonArray = toons else: toonArray = [] for toonId in toons: toon = base.cr.doId2do.get(toonId) if toon: toonArray.append(toon) for toon in toonArray: dustCloud = DustCloud.DustCloud() dustCloud.setPos(0, 2, 3) dustCloud.setScale(0.5) dustCloud.setDepthWrite(0) dustCloud.setBin('fixed', 0) dustCloud.createTrack() suitsOff.append(Sequence(Func(dustCloud.reparentTo, toon), Parallel(dustCloud.track, Sequence(Wait(0.3), Func(toon.takeOffSuit), Func(toon.sadEyes), Func(toon.blinkEyes), Func(toon.play, 'slip-backward'), Wait(0.7))), Func(dustCloud.detachNode), Func(dustCloud.destroy))) seq.append(suitsOff) return seq
def load(self): self.notify.debug('load') DistributedPartyActivity.load(self) base.cr.playGame.hood.loader.loadClouds() base.cr.playGame.hood.loader.setCloudSwitch(1) self.shadow = loader.loadModel('phase_3/models/props/drop_shadow') self.shadowNode = hidden.attachNewNode('dropShadow') self.shadow.copyTo(self.shadowNode) self.shadowNode.setColor(0, 0, 0, 0.5) self.shadowNode.setBin('fixed', 0, 1) self.splash = Splash.Splash(render) self.dustCloud = DustCloud.DustCloud(render) self.dustCloud.setBillboardPointEye() self.sndHitGround = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndHitWater = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_splash.ogg') self.sndHitHouse = base.loader.loadSfx( 'phase_5/audio/sfx/AA_drop_sandbag.ogg') self.sndBounce1 = base.loader.loadSfx('phase_13/audio/sfx/bounce1.ogg') self.sndBounce2 = base.loader.loadSfx('phase_13/audio/sfx/bounce2.ogg') self.sndBounce3 = base.loader.loadSfx('phase_13/audio/sfx/bounce3.ogg') self.onstage() self.sign.reparentTo(hidden) self.sign.setPos(-6.0, 10.0, 0.0) self.accept(FireworksStartedEvent, self.__handleFireworksStarted) self.accept(FireworksFinishedEvent, self.__handleFireworksFinished)
def wearCogSuits(self, toons, battleNode, camLoc, arrayOfObjs = False, waiter = False): seq = Sequence() if not toons: return seq self.notify.debug('battleNode=%s camLoc=%s' % (battleNode, camLoc)) if camLoc: seq.append(Func(camera.setPosHpr, battleNode, *camLoc)) suitsOff = Parallel() if arrayOfObjs: toonArray = toons else: toonArray = [] for toonId in toons: toon = base.cr.doId2do.get(toonId) if toon: toonArray.append(toon) for toon in toonArray: dustCloud = DustCloud.DustCloud() dustCloud.setPos(0, 2, 3) dustCloud.setScale(0.5) dustCloud.setDepthWrite(0) dustCloud.setBin('fixed', 0) dustCloud.createTrack() makeWaiter = Sequence() if waiter: makeWaiter = Func(toon.makeWaiter) suitsOff.append(Sequence(Func(dustCloud.reparentTo, toon), Parallel(dustCloud.track, Sequence(Wait(0.3), Func(self.putToonInCogSuit, toon), makeWaiter, Wait(0.7))), Func(dustCloud.detachNode))) seq.append(suitsOff) return seq
def getDustCloudIval(): dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1) dustCloud.setBillboardAxis(2.0) dustCloud.setZ(4) dustCloud.setScale(0.6) dustCloud.createTrack() return Sequence(Func(dustCloud.reparentTo, self), dustCloud.track, Func(dustCloud.destroy), name='dustCloadIval')
def load(self): self.notify.debug('load') DistributedMinigame.load(self) self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') self.ground = loader.loadModel('phase_4/models/minigames/toon_cannon_gameground') self.tower = loader.loadModel('phase_4/models/minigames/toon_cannon_water_tower') self.cannon = loader.loadModel('phase_4/models/minigames/toon_cannon') self.dropShadow = loader.loadModel('phase_3/models/props/drop_shadow') self.hill = loader.loadModel('phase_4/models/minigames/cannon_hill') self.sky.setScale(WORLD_SCALE) self.ground.setScale(GROUND_SCALE) self.cannon.setScale(CANNON_SCALE) self.dropShadow.setColor(0, 0, 0, 0.5) self.ground.setColor(0.85, 0.85, 0.85, 1.0) self.hill.setScale(1, 1, CANNON_Z / 20.0) self.dropShadow.setBin('fixed', 0, 1) self.splash = Splash.Splash(render) self.dustCloud = DustCloud.DustCloud(render) purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') self.jarImage = purchaseModels.find('**/Jar') self.jarImage.reparentTo(hidden) self.rewardPanel = DirectLabel(parent=hidden, relief=None, pos=(-0.173, 0.0, -0.55), scale=0.65, text='', text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -.13), text_font=ToontownGlobals.getSignFont(), image=self.jarImage) self.rewardPanelTitle = DirectLabel(parent=self.rewardPanel, relief=None, pos=(0, 0, 0.06), scale=0.08, text=TTLocalizer.CannonGameReward, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1)) self.music = base.loadMusic('phase_4/audio/bgm/MG_cannon_game.ogg') self.sndCannonMove = base.loadSfx('phase_4/audio/sfx/MG_cannon_adjust.ogg') self.sndCannonFire = base.loadSfx('phase_4/audio/sfx/MG_cannon_fire_alt.ogg') self.sndHitGround = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndHitTower = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_tower.ogg') self.sndHitWater = base.loadSfx('phase_4/audio/sfx/MG_cannon_splash.ogg') self.sndWhizz = base.loadSfx('phase_4/audio/sfx/MG_cannon_whizz.ogg') self.sndWin = base.loadSfx('phase_4/audio/sfx/MG_win.ogg') self.sndRewardTick = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg') guiModel = 'phase_4/models/gui/cannon_game_gui' cannonGui = loader.loadModel(guiModel) self.aimPad = DirectFrame(image=cannonGui.find('**/CannonFire_PAD'), relief=None, pos=(0.7, 0, -0.553333), scale=0.8) cannonGui.removeNode() self.aimPad.hide() self.fireButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Fire_Btn_UP'), (guiModel, '**/Fire_Btn_DN'), (guiModel, '**/Fire_Btn_RLVR')), relief=None, pos=(0.0115741, 0, 0.00505051), scale=1.0, command=self.__firePressed) self.upButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0115741, 0, 0.221717)) self.downButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0136112, 0, -0.210101), image_hpr=(0, 0, 180)) self.leftButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(-0.199352, 0, -0.000505269), image_hpr=(0, 0, -90)) self.rightButton = DirectButton(parent=self.aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.219167, 0, -0.00101024), image_hpr=(0, 0, 90)) self.aimPad.setColor(1, 1, 1, 0.9) def bindButton(button, upHandler, downHandler): button.bind(DGG.B1PRESS, lambda x, handler = upHandler: handler()) button.bind(DGG.B1RELEASE, lambda x, handler = downHandler: handler()) bindButton(self.upButton, self.__upPressed, self.__upReleased) bindButton(self.downButton, self.__downPressed, self.__downReleased) bindButton(self.leftButton, self.__leftPressed, self.__leftReleased) bindButton(self.rightButton, self.__rightPressed, self.__rightReleased) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.DEBUG_TOWER_RANGE = 0 self.DEBUG_CANNON_FAR_LEFT = 0 self.DEBUG_TOWER_NEAR = 1 self.DEBUG_TOWER_FAR_LEFT = 1 return
def load(self): self.cannon = loader.loadModel('phase_4/models/minigames/toon_cannon') self.shadow = loader.loadModel('phase_3/models/props/drop_shadow') self.shadowNode = hidden.attachNewNode('dropShadow') self.shadow.copyTo(self.shadowNode) self.smoke = loader.loadModel('phase_4/models/props/test_clouds') self.smoke.setBillboardPointEye() self.cannon.setScale(CANNON_SCALE) self.shadowNode.setColor(0, 0, 0, 0.5) self.shadowNode.setBin('fixed', 0, 1) self.splash = Splash.Splash(render) self.dustCloud = DustCloud.DustCloud(render) self.dustCloud.setBillboardPointEye() self.sndCannonMove = base.loadSfx('phase_4/audio/sfx/MG_cannon_adjust.mp3') self.sndCannonFire = base.loadSfx('phase_4/audio/sfx/MG_cannon_fire_alt.mp3') self.sndHitGround = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.mp3') self.sndHitTower = base.loadSfx('phase_4/audio/sfx/MG_cannon_hit_tower.mp3') self.sndHitWater = base.loadSfx('phase_4/audio/sfx/MG_cannon_splash.mp3') self.sndWhizz = base.loadSfx('phase_4/audio/sfx/MG_cannon_whizz.mp3') self.sndWin = base.loadSfx('phase_4/audio/sfx/MG_win.mp3') self.sndHitHouse = base.loadSfx('phase_5/audio/sfx/AA_drop_sandbag.mp3') self.collSphere = CollisionSphere(0, 0, 0, self.getSphereRadius()) self.collSphere.setTangible(1) self.collNode = CollisionNode(self.uniqueName('CannonSphere')) self.collNode.setCollideMask(ToontownGlobals.WallBitmask) self.collNode.addSolid(self.collSphere) self.collNodePath = self.nodePath.attachNewNode(self.collNode) self.loadCannonBumper()
def loseCogSuits(self, toons, battleNode, camLoc, arrayOfObjs = False): seq = Sequence() if not toons: return seq self.notify.debug('battleNode=%s camLoc=%s' % (battleNode, camLoc)) seq.append(base.camera.posHprInterval(1, Point3(camLoc[0], camLoc[1], camLoc[2]), Point3(camLoc[3], camLoc[4], camLoc[5]), other = battleNode, blendType = 'easeInOut')) suitsOff = Parallel() if arrayOfObjs: toonArray = toons else: toonArray = [] for toonId in toons: toon = base.cr.doId2do.get(toonId) if toon: toonArray.append(toon) for toon in toonArray: dustCloud = DustCloud.DustCloud() dustCloud.setPos(0, 2, 3) dustCloud.setScale(0.5) dustCloud.setDepthWrite(0) dustCloud.setBin('fixed', 0) dustCloud.createTrack() suitsOff.append(Sequence(Func(dustCloud.reparentTo, toon), Parallel(dustCloud.track, Sequence(Wait(0.3), Func(toon.takeOffSuit), Func(toon.sadEyes), Func(toon.blinkEyes), Func(toon.play, 'slip-backward'), Wait(0.7))), Func(dustCloud.detachNode), Func(toon.normalEyes), Func(dustCloud.destroy))) snd = loader.loadSfx('phase_5/audio/sfx/tt_s_ara_cfg_propellerBreaks.ogg') seq.append(Func(snd.play)) seq.append(suitsOff) return seq
def delete(self): # When the bank collectable is deleted, and has not been grabbed, do a # poof effect: if not self.grabbed: dustCloud = DustCloud.DustCloud(fBillboard=0) dustCloud.setBillboardAxis(2.0) dustCloud.setZ(4) dustCloud.setScale(0.4) dustCloud.createTrack() dustCloud.reparentTo(render) dustCloud.setPos(self.nodePath.getPos()) Sequence(dustCloud.track, Func(dustCloud.destroy)).start() if self.flyTrack is not None: self.flyTrack.finish() self.flyTrack = None if self.floatTrack is not None: self.floatTrack.finish() self.floatTrack = None if self.rotateTrack is not None: self.rotateTrack.finish() self.rotateTrack = None if self.nodePath is not None: self.nodePath.removeNode() self.nodePath = None DistributedObject.delete(self)
def getDustCloudIval(toon): dustCloud = DustCloud.DustCloud(fBillboard=0) dustCloud.setBillboardAxis(2.0) dustCloud.setZ(3) dustCloud.setScale(0.4) dustCloud.createTrack() toon.laffMeter.color = toon.style.getBlackColor() return Sequence(Wait(0.5), Func(dustCloud.reparentTo, toon), dustCloud.track, Func(dustCloud.detachNode), Func(toon.laffMeter.adjustFace, toon.hp, toon.maxHp))
def getDustCloudIval(): cleanupDustCloudIval() dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1) dustCloud.setBillboardAxis(2.0) dustCloud.setZ(3) dustCloud.setScale(0.4) dustCloud.createTrack() self.dustCloudIval = Sequence(Func(dustCloud.reparentTo, render), Func(dustCloud.setPos, getDustCloudPos()), dustCloud.track, Func(dustCloud.detachNode), Func(dustCloud.destroy), name='dustCloadIval') self.dustCloudIval.start()
def disable(self): self.ignoreAll() dustCloud = DustCloud.DustCloud(fBillboard=0, wantSound=1) dustCloud.setBillboardAxis(2.0) dustCloud.setScale(0.6) dustCloud.createTrack() Sequence(Func(dustCloud.reparentTo, render), Func(dustCloud.setPos, self.getPos()), dustCloud.track, Func(dustCloud.detachNode), Func(dustCloud.destroy)).start() DistributedFurnitureItem.disable(self)
def getDustCloudIval(toon): dustCloud = DustCloud.DustCloud(fBillboard=0) dustCloud.setBillboardAxis(2.0) dustCloud.setZ(3) dustCloud.setScale(0.4) dustCloud.createTrack() if getattr(toon, 'laffMeter', None): toon.laffMeter.color = toon.style.getWhiteColor() seq = Sequence(Wait(0.5), Func(dustCloud.reparentTo, toon), dustCloud.track, Func(dustCloud.destroy)) if getattr(toon, 'laffMeter', None): seq.append(Func(toon.laffMeter.adjustFace, toon.hp, toon.maxHp)) return seq
def load(self): self.cannon = loader.loadModel('phase_4/models/minigames/toon_cannon') self.collSphere = CollisionSphere(0, 0, 0, self.getSphereRadius()) self.dustCloud = DustCloud.DustCloud(render) self.dustCloud.setBillboardPointEye() self.collSphere.setTangible(1) self.collNode = CollisionNode(self.uniqueName('CannonSphere')) self.collNode.setCollideMask(ToontownGlobals.WallBitmask) self.collNode.addSolid(self.collSphere) self.collNodePath = self.nodePath.attachNewNode(self.collNode) self.cannon.reparentTo(self.nodePath) self.kartColNode = CollisionNode(self.uniqueName('KartColNode')) self.kartNode = self.nodePath.attachNewNode(self.kartColNode) self.sndCannonMove = base.loader.loadSfx('phase_4/audio/sfx/MG_cannon_adjust.ogg') self.sndCannonFire = base.loader.loadSfx('phase_4/audio/sfx/MG_cannon_fire_alt.ogg') self.sndHitGround = base.loader.loadSfx('phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndHitChair = base.loader.loadSfx('phase_11/audio/sfx/LB_toon_jury.ogg') self.cannon.hide() self.flashingLabel = None
def createPropeller(self): self.propellerSmoke = DustCloud.DustCloud(self.toon, wantSound=False) self.propellerSmoke.setBillboardPointEye() self.propellerSmoke.setBin('fixed', 5002) self.backpack = CogdoUtil.loadFlyingModel('propellerPack') self.backpack.setScale(1.3) self.backpack.setHpr(180.0, 0.0, 0.0) self.backpackInstances = [] self.backpackTextureCard = CogdoUtil.loadFlyingModel( 'propellerPack_card') parts = self.toon.getTorsoParts() for part in parts: backpackInstance = part.attachNewNode('backpackInstance') animal = self.toon.style.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animal] backpackHeight = ToontownGlobals.torsoHeightDict[ self.toon.style.torso] * bodyScale - 0.5 backpackInstance.setPos(0.0, -0.325, backpackHeight) self.backpackInstances.append(backpackInstance) self.backpack.instanceTo(backpackInstance) self.propInstances = [] self.propeller = CogdoUtil.loadFlyingModel('toonPropeller') for part in self.backpackInstances: propInstance = part.attachNewNode('propInstance') propInstance.setPos(0.0, -0.275, 0.0) propInstance.setHpr(0.0, 20.0, 0.0) propInstance.setScale(1.0, 1.0, 1.25) self.propInstances.append(propInstance) self.propeller.instanceTo(propInstance) self.blades = [] self.activeBlades = [] index = 1 blade = self.propeller.find('**/propeller%d' % index) while not blade.isEmpty(): self.blades.append(blade) index += 1 blade = self.propeller.find('**/propeller%d' % index) for blade in self.blades: self.activeBlades.append(blade)
def load(self): self.notify.debug("load") DistributedPartyActivity.load(self) # Show clouds. base.cr.playGame.hood.loader.loadClouds() base.cr.playGame.hood.loader.setCloudSwitch(1) # The shadow is used while the local toon is flying around self.shadow = loader.loadModel("phase_3/models/props/drop_shadow") self.shadowNode = hidden.attachNewNode("dropShadow") self.shadow.copyTo(self.shadowNode) self.shadowNode.setColor(0, 0, 0, 0.5) # put the shadow in the 'fixed' bin, so that it will be drawn correctly # in front of the translucent water. # NOTE: if we put trees or other opaque/transparent objects in the scene, # put the shadow in the fixed bin only when it's over the water. self.shadowNode.setBin('fixed', 0, 1) # undo with shadow.clearBin() # Splash object for when toon hits the water self.splash = Splash.Splash(render) # Dust cloud object for when toon hits ground self.dustCloud = DustCloud.DustCloud(render) self.dustCloud.setBillboardPointEye() # Collision Sounds self.sndHitGround = base.loader.loadSfx( "phase_4/audio/sfx/MG_cannon_hit_dirt.mp3") self.sndHitWater = base.loader.loadSfx( "phase_4/audio/sfx/MG_cannon_splash.mp3") self.sndHitHouse = base.loader.loadSfx( "phase_5/audio/sfx/AA_drop_sandbag.mp3") self.sndBounce1 = base.loader.loadSfx("phase_13/audio/sfx/bounce1.mp3") self.sndBounce2 = base.loader.loadSfx("phase_13/audio/sfx/bounce2.mp3") self.sndBounce3 = base.loader.loadSfx("phase_13/audio/sfx/bounce3.mp3") self.onstage() self.sign.reparentTo(hidden) self.sign.setPos(-6.0, 10.0, 0.0) self.accept(FireworksStartedEvent, self.__handleFireworksStarted) self.accept(FireworksFinishedEvent, self.__handleFireworksFinished)