def __init__(self, node): self.fish = Actor.Actor('phase_4/models/props/SZ_fish-mod', { 'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim' }, copy=0) self.fish.hide() self.fish.reparentTo(node) self.splashSfxList = ( loader.loadSfx('phase_4/audio/sfx/TT_splash1.ogg'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.ogg')) self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) self.exitRipples.setPosHprScale(-0.3, 0.0, 1.24, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) randomSplash = random.choice(self.splashSfxList) self.track = Sequence( Wait(5 + 10 * random.random()), Parallel( Func(self.fish.show), self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence( Wait(1.13), Func(self.splash.play), SoundInterval(randomSplash, volume=0.3, node=self.fish), Func(self.fish.hide))))
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.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 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 loadModels(self): self.playArea = loader.loadModel('phase_13/models/parties/partyTugOfWar') self.playArea.reparentTo(self.root) self.sign.reparentTo(self.playArea.find('**/TugOfWar_sign_locator')) self.dockPositions = [ [], []] for i in range(4): self.dockPositions[0].append(Point3(-(PartyGlobals.TugOfWarInitialToonPositionsXOffset) - PartyGlobals.TugOfWarToonPositionXSeparation * i, 0.0, PartyGlobals.TugOfWarToonPositionZ)) for i in range(4): self.dockPositions[1].append(Point3(PartyGlobals.TugOfWarInitialToonPositionsXOffset + PartyGlobals.TugOfWarToonPositionXSeparation * i, 0.0, PartyGlobals.TugOfWarToonPositionZ)) self.hopOffPositions = [ [], []] for i in range(1, 5): self.hopOffPositions[PartyGlobals.TeamActivityTeams.LeftTeam].append(self.playArea.find('**/leftTeamHopOff%d_locator' % i).getPos()) self.hopOffPositions[PartyGlobals.TeamActivityTeams.RightTeam].append(self.playArea.find('**/rightTeamHopOff%d_locator' % i).getPos()) for i in range(1, 5): pos = self.playArea.find('**/fallenToon%d_locator' % i).getPos() self.fallenPositions.append(pos) self.joinCollision = [] self.joinCollisionNodePaths = [] for i in range(len(PartyGlobals.TeamActivityTeams)): collShape = CollisionTube(PartyGlobals.TugOfWarJoinCollisionEndPoints[0], PartyGlobals.TugOfWarJoinCollisionEndPoints[1], PartyGlobals.TugOfWarJoinCollisionRadius) collShape.setTangible(True) self.joinCollision.append(CollisionNode('TugOfWarJoinCollision%d' % i)) self.joinCollision[i].addSolid(collShape) tubeNp = self.playArea.attachNewNode(self.joinCollision[i]) tubeNp.node().setCollideMask(ToontownGlobals.WallBitmask) self.joinCollisionNodePaths.append(tubeNp) self.joinCollisionNodePaths[i].setPos(PartyGlobals.TugOfWarJoinCollisionPositions[i]) self._DistributedPartyTugOfWarActivity__enableCollisions() ropeModel = loader.loadModel('phase_4/models/minigames/tug_of_war_rope') self.ropeTexture = ropeModel.findTexture('*') ropeModel.removeNode() for i in range(PartyGlobals.TugOfWarMaximumPlayersPerTeam * 2 - 1): rope = Rope(self.uniqueName('TugRope%d' % i)) if rope.showRope: rope.ropeNode.setRenderMode(RopeNode.RMBillboard) rope.ropeNode.setThickness(0.20000000000000001) rope.setTexture(self.ropeTexture) rope.ropeNode.setUvMode(RopeNode.UVDistance) rope.ropeNode.setUvDirection(1) rope.setTransparency(1) rope.setColor(0.89000000000000001, 0.89000000000000001, 0.59999999999999998, 1.0) rope.reparentTo(self.root) rope.stash() self.tugRopes.append(rope) self.splash = Splash.Splash(self.root) self.splash.setScale(2.0, 4.0, 1.0) pos = self.fallenPositions[0] self.splash.setPos(pos[0], pos[1], PartyGlobals.TugOfWarSplashZOffset) self.splash.hide()
def __init__(self, node): AnimatedProp.AnimatedProp.__init__(self, node) parent = node.getParent() self.fish = Actor.Actor(node, copy=0) self.fish.reparentTo(parent) self.fish.setTransform(node.getTransform()) node.clearMat() self.fish.loadAnims({"jump": "phase_4/models/props/SZ_fish-jump", "swim": "phase_4/models/props/SZ_fish-swim"}) self.splashSfxList = ( loader.loadSfx("phase_4/audio/sfx/TT_splash1.ogg"), loader.loadSfx("phase_4/audio/sfx/TT_splash2.ogg"), ) self.node = self.fish self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin("fixed", 25, 1) self.exitRipples.setPosHprScale(-0.3, 0.0, 1.24, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) randomSplash = random.choice(self.splashSfxList) self.track = Sequence( Func(self.randomizePosition), Func(self.node.unstash), Parallel( self.fish.actorInterval("jump"), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.14), Func(self.splash.play)), ), Wait(1), Func(self.node.stash), Wait(10 * random.random()), name=self.uniqueName("Fish"), )
def playSplashEffect(self, x, y, z): if self.splash == None: self.splash = Splash.Splash(render) self.splash.setPos(x, y, z) self.splash.setScale(2) self.splash.play() place = base.cr.playGame.getPlace() if place and hasattr(place.loader, 'submergeSound'): base.playSfx(place.loader.submergeSound, node=self)
def __init__(self, node): AnimatedProp.AnimatedProp.__init__(self, node) parent = node.getParent() self.fish = Actor.Actor(node, copy=0) self.fish.reparentTo(parent) self.fish.setTransform(node.getTransform()) node.clearMat() self.fish.loadAnims({'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim'}) self.splashSfxList = (loader.loadSfx('phase_4/audio/sfx/TT_splash1.mp3'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.mp3')) self.node = self.fish self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) self.exitRipples.setPosHprScale(-0.3, 0.0, 1.24, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) randomSplash = random.choice(self.splashSfxList) self.track = Sequence(FunctionInterval(self.randomizePosition), Func(self.node.unstash), Parallel(self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.14), Func(self.splash.play), SoundInterval(randomSplash, volume=0.8, node=self.node))), Wait(1), Func(self.node.stash), Wait(4 + 10 * random.random()), name=self.uniqueName('Fish'))
class FishAnimatedProp: def __init__(self, node): self.fish = Actor.Actor('phase_4/models/props/SZ_fish-mod', {'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim'}, copy=0) self.fish.hide() self.fish.reparentTo(node) self.splashSfxList = (loader.loadSfx('phase_4/audio/sfx/TT_splash1.ogg'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.ogg')) self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) self.exitRipples.setPosHprScale(-0.3, 0.0, 1.24, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.7, 0.7, 0.7) randomSplash = random.choice(self.splashSfxList) self.track = Sequence(Wait(5 + 10 * random.random()), Parallel(Func(self.fish.show), self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.13), Func(self.splash.play), SoundInterval(randomSplash, volume = 0.3, node = self.fish), Func(self.fish.hide)))) def delete(self): self.exitRipples.destroy() del self.exitRipples self.splash.destroy() del self.splash del self.track self.fish.removeNode() del self.fish del self.geom def enter(self): self.track.loop() def exit(self): self.track.finish() self.splash.stop() self.exitRipples.stop()
def load(self): self.notify.debug('load') DistributedMinigame.load(self) self.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.room = loader.loadModel('phase_4/models/minigames/tug_of_war_dock') self.room.reparentTo(hidden) ropeModel = loader.loadModel('phase_4/models/minigames/tug_of_war_rope') self.ropeTexture = ropeModel.findTexture('*') ropeModel.removeNode() self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') self.dropShadow = loader.loadModel('phase_3/models/props/drop_shadow') self.correctSound = base.loadSfx('phase_4/audio/sfx/MG_pos_buzzer.ogg') self.sndHitWater = base.loadSfx('phase_4/audio/sfx/MG_cannon_splash.ogg') self.whistleSound = base.loadSfx('phase_4/audio/sfx/AA_sound_whistle.ogg') self.music = base.loadMusic(self.bgm) self.roundText = DirectLabel(text=' ', text_fg=(0, 1, 0, 1), frameColor=(1, 1, 1, 0), text_font=ToontownGlobals.getSignFont(), pos=(0.014, 0, -.84), scale=0.2) self.powerMeter = MinigamePowerMeter.MinigamePowerMeter(17) self.powerMeter.reparentTo(aspect2d) self.powerMeter.setPos(0, 0, 0.4) self.powerMeter.setPower(8) self.powerMeter.setTarget(8) self.arrows = [None] * 2 for x in range(len(self.arrows)): self.arrows[x] = loader.loadModel('phase_3/models/props/arrow') self.arrows[x].reparentTo(self.powerMeter) self.arrows[x].hide() self.arrows[x].setScale(0.2 - 0.4 * x, 0.2, 0.2) self.arrows[x].setPos(0.12 - 0.24 * x, 0, -.26) self.disableArrow(self.arrows[x]) self.splash = Splash.Splash(render) self.suitSplash = Splash.Splash(render) self.ripples = Ripples.Ripples(render) self.suitRipples = Ripples.Ripples(render) return
class FishAnimatedProp(AnimatedProp.AnimatedProp): def __init__(self, node): AnimatedProp.AnimatedProp.__init__(self, node) parent = node.getParent() self.fish = Actor.Actor(node, copy = 0) self.fish.reparentTo(parent) self.fish.setTransform(node.getTransform()) node.clearMat() self.fish.loadAnims({ 'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim' }) self.splashSfxList = (loader.loadSfx('phase_4/audio/sfx/TT_splash1.mp3'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.mp3')) self.node = self.fish self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) self.exitRipples.setPosHprScale(-0.29999999999999999, 0.0, 1.24, 0.0, 0.0, 0.0, 0.69999999999999996, 0.69999999999999996, 0.69999999999999996) self.splash = Splash(self.geom, wantParticles = 0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.69999999999999996, 0.69999999999999996, 0.69999999999999996) randomSplash = random.choice(self.splashSfxList) self.track = Sequence(FunctionInterval(self.randomizePosition), Func(self.node.unstash), Parallel(self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence(Wait(1.1399999999999999), Func(self.splash.play), SoundInterval(randomSplash, volume = 0.80000000000000004, node = self.node))), Wait(1), Func(self.node.stash), Wait(4 + 10 * random.random()), name = self.uniqueName('Fish')) def delete(self): self.exitRipples.destroy() del self.exitRipples self.splash.destroy() del self.splash del self.track self.fish.removeNode() del self.fish del self.node del self.geom def randomizePosition(self): x = 5 * (random.random() - 0.5) y = 5 * (random.random() - 0.5) h = 360 * random.random() self.geom.setPos(x, y, 0) self.geom.setHpr(h, 0, 0) def enter(self): AnimatedProp.AnimatedProp.enter(self) self.track.loop() def exit(self): AnimatedProp.AnimatedProp.exit(self) self.track.finish() self.splash.stop() self.exitRipples.stop()
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)
def __init__(self, node): # To access fish in game: # fish = base.cr.playGame.hood.loader.animPropDict.values()[0] AnimatedProp.AnimatedProp.__init__(self, node) parent = node.getParent() self.fish = Actor.Actor(node, copy=0) self.fish.reparentTo(parent) # Move the transform from the original character node, # self.node, to the new Actor node, self.fish. self.fish.setTransform(node.getTransform()) node.clearMat() self.fish.loadAnims({ 'jump': "phase_4/models/props/SZ_fish-jump", 'swim': "phase_4/models/props/SZ_fish-swim" }) self.splashSfxList = ( loader.loadSfx("phase_4/audio/sfx/TT_splash1.mp3"), loader.loadSfx("phase_4/audio/sfx/TT_splash2.mp3"), ) # Now forget about the old self.node; we're now the Actor. self.node = self.fish # Except that we still want a handle to the model node so we # can randomly position the fish around. self.geom = self.fish.getGeomNode() # Ripples to display when fish exits the water self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) # Put it a little higher to help transparency sort order self.exitRipples.setPosHprScale(-0.3, 0.0, 1.24, 0.00, 0.00, 0.00, 0.7, 0.7, 0.7) # Splash and ripples to display when fish re-enters the water self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.00, 0.00, 0.00, 0.7, 0.7, 0.7) randomSplash = random.choice(self.splashSfxList) # Track to play back the whole think self.track = Sequence( FunctionInterval(self.randomizePosition), Func(self.node.unstash), Parallel( self.fish.actorInterval('jump'), # Ripples when exiting water Sequence( Wait(0.25), Func(self.exitRipples.play, 0.75), ), # Splash when re-entering water Sequence( Wait(1.14), Func(self.splash.play), SoundInterval(randomSplash, volume=0.8, node=self.node), )), Wait(1), Func(self.node.stash), # Wait inbetween Wait(4 + 10 * random.random()), name=self.uniqueName("Fish"))
def __healDive(heal, hasInteractivePropHealBonus): splash = Splash.Splash(render) splash.reparentTo(render) npcId = 0 if 'npcId' in heal: npcId = heal['npcId'] toon = NPCToons.createLocalNPC(npcId) if toon == None: return else: toon = heal['toon'] targets = heal['target'] ineffective = heal['sidestep'] level = heal['level'] if npcId != 0: track = Sequence(MovieNPCSOS.teleportIn(heal, toon)) else: track = Sequence(__runToHealSpot(heal)) delay = 7.0 first = 1 targetTrack = Sequence() for target in targets: targetToon = target['toon'] hp = target['hp'] reactIval = Func(__healToon, targetToon, hp, ineffective, hasInteractivePropHealBonus) if first == 1: targetTrack.append(Wait(delay)) first = 0 targetTrack.append(reactIval) thisBattle = heal['battle'] toonsInBattle = thisBattle.toons glass = globalPropPool.getProp('glass') glass.setScale(4.0) glass.setHpr(0.0, 90.0, 0.0) ladder = globalPropPool.getProp('ladder') placeNode = NodePath('lookNode') diveProps = [glass, ladder] ladderScale = toon.getBodyScale() / 0.66 scaleUpPoint = Point3(0.5, 0.5, 0.45) * ladderScale basePos = toon.getPos() glassOffset = Point3(0, 1.1, 0.2) glassToonOffset = Point3(0, 1.2, 0.2) splashOffset = Point3(0, 1.0, 0.4) ladderOffset = Point3(0, 4, 0) ladderToonSep = Point3(0, 1, 0) * ladderScale diveOffset = Point3(0, 0, 10) divePos = add3(add3(ladderOffset, diveOffset), ladderToonSep) ladder.setH(toon.getH()) glassPos = render.getRelativePoint(toon, glassOffset) glassToonPos = render.getRelativePoint(toon, glassToonOffset) ladderPos = render.getRelativePoint(toon, ladderOffset) climbladderPos = render.getRelativePoint(toon, add3(ladderOffset, ladderToonSep)) divePos = render.getRelativePoint(toon, divePos) topDivePos = render.getRelativePoint(toon, diveOffset) lookBase = render.getRelativePoint(toon, ladderOffset) lookTop = render.getRelativePoint(toon, add3(ladderOffset, diveOffset)) LookGlass = render.getRelativePoint(toon, glassOffset) splash.setPos(splashOffset) walkToLadderTime = 1.0 climbTime = 5.0 diveTime = 1.0 ladderGrowTime = 1.5 splash.setPos(glassPos) toonNode = toon.getGeomNode() placeNode.reparentTo(render) placeNode.setScale(5.0) placeNode.setPos(toon.getPos(render)) placeNode.setHpr(toon.getHpr(render)) toonscale = toonNode.getScale() toonFacing = toon.getHpr() propTrack = Sequence( Func(MovieUtil.showProp, glass, render, glassPos), Func(MovieUtil.showProp, ladder, render, ladderPos), Func(toonsLook, toonsInBattle, placeNode, Point3(0, 0, 0)), Func(placeNode.setPos, lookBase), LerpScaleInterval(ladder, ladderGrowTime, scaleUpPoint, startScale=MovieUtil.PNT3_NEARZERO), Func(placeNode.setPos, lookTop), Wait(2.1), MovieCamera.toonGroupHighShot(None, 0), Wait(2.1), Func(placeNode.setPos, LookGlass), Wait(0.4), MovieCamera.allGroupLowShot(None, 0), Wait(1.8), LerpScaleInterval(ladder, ladderGrowTime, MovieUtil.PNT3_NEARZERO, startScale=scaleUpPoint), Func(MovieUtil.removeProps, diveProps)) mtrack = Parallel( propTrack, __getSoundTrack(level, 0.6, duration=9.0, node=toon), Sequence( Parallel( Sequence( ActorInterval(toon, 'walk', loop=0, duration=walkToLadderTime), ActorInterval(toon, 'neutral', loop=0, duration=0.1)), LerpPosInterval(toon, walkToLadderTime, climbladderPos), Wait(ladderGrowTime)), Parallel( ActorInterval(toon, 'climb', loop=0, endFrame=116), Sequence( Wait(4.6), Func(toonNode.setTransparency, 1), LerpColorScaleInterval(toonNode, 0.25, VBase4(1, 1.0, 1, 0.0), blendType='easeInOut'), LerpScaleInterval(toonNode, 0.01, 0.1, startScale=toonscale), LerpHprInterval(toon, 0.01, toonFacing), LerpPosInterval(toon, 0.0, glassToonPos), Func(toonNode.clearTransparency), Func(toonNode.clearColorScale), Parallel( ActorInterval(toon, 'swim', loop=1, startTime=0.0, endTime=1.0), Wait(1.0))), Sequence(Wait(4.6), Func(splash.play), Wait(1.0), Func(splash.destroy))), Wait(0.5), Parallel( ActorInterval(toon, 'jump', loop=0, startTime=0.2), LerpScaleInterval(toonNode, 0.5, toonscale, startScale=0.1), Func(stopLook, toonsInBattle))), targetTrack) track.append(mtrack) if npcId != 0: track.append(MovieNPCSOS.teleportOut(heal, toon)) else: track.append(__returnToBase(heal)) for target in targets: targetToon = target['toon'] track.append(Func(targetToon.clearChat)) return track
def loadModels(self): # load the tug of war play area self.playArea = loader.loadModel( "phase_13/models/parties/partyTugOfWar") # reparent to the party ground root self.playArea.reparentTo(self.root) # place the activity sign self.sign.reparentTo(self.playArea.find("**/TugOfWar_sign_locator")) # define initial positions, with index 0 being closest to the other team self.dockPositions = [ [], # left team positions [], # right team positions ] for i in range(4): self.dockPositions[0].append( Point3( -PartyGlobals.TugOfWarInitialToonPositionsXOffset - PartyGlobals.TugOfWarToonPositionXSeparation * i, 0.0, PartyGlobals.TugOfWarToonPositionZ, )) for i in range(4): self.dockPositions[1].append( Point3( PartyGlobals.TugOfWarInitialToonPositionsXOffset + PartyGlobals.TugOfWarToonPositionXSeparation * i, 0.0, PartyGlobals.TugOfWarToonPositionZ, )) self.hopOffPositions = [ [], # left team positions [], # right team positions ] for i in range(1, 5): self.hopOffPositions[ PartyGlobals.TeamActivityTeams.LeftTeam].append( self.playArea.find("**/leftTeamHopOff%d_locator" % i).getPos()) self.hopOffPositions[ PartyGlobals.TeamActivityTeams.RightTeam].append( self.playArea.find("**/rightTeamHopOff%d_locator" % i).getPos()) # load positions for when toons fall into the water for i in range(1, 5): pos = self.playArea.find("**/fallenToon%d_locator" % i).getPos() self.fallenPositions.append(pos) # load collision that allows toons to play the game # create one for each dock that lets toons join a particular team self.joinCollision = [] self.joinCollisionNodePaths = [] for i in range(len(PartyGlobals.TeamActivityTeams)): collShape = CollisionTube( PartyGlobals.TugOfWarJoinCollisionEndPoints[0], PartyGlobals.TugOfWarJoinCollisionEndPoints[1], PartyGlobals.TugOfWarJoinCollisionRadius) collShape.setTangible(True) self.joinCollision.append( CollisionNode("TugOfWarJoinCollision%d" % i)) self.joinCollision[i].addSolid(collShape) tubeNp = self.playArea.attachNewNode(self.joinCollision[i]) tubeNp.node().setCollideMask(ToontownGlobals.WallBitmask) self.joinCollisionNodePaths.append(tubeNp) self.joinCollisionNodePaths[i].setPos( PartyGlobals.TugOfWarJoinCollisionPositions[i]) self.__enableCollisions() # Get the rope texture by extracting it from its model. ropeModel = loader.loadModel( "phase_4/models/minigames/tug_of_war_rope") self.ropeTexture = ropeModel.findTexture("*") ropeModel.removeNode() # create as many ropes as we will ever need for i in range(PartyGlobals.TugOfWarMaximumPlayersPerTeam * 2 - 1): rope = Rope(self.uniqueName("TugRope%d" % i)) if rope.showRope: rope.ropeNode.setRenderMode(RopeNode.RMBillboard) rope.ropeNode.setThickness(0.2) rope.setTexture(self.ropeTexture) rope.ropeNode.setUvMode(RopeNode.UVDistance) rope.ropeNode.setUvDirection(1) rope.setTransparency(1) rope.setColor(0.89, 0.89, 0.6, 1.0) rope.reparentTo(self.root) rope.stash() self.tugRopes.append(rope) # Splash object for when toon hits the water self.splash = Splash.Splash(self.root) self.splash.setScale(2.0, 4.0, 1.0) pos = self.fallenPositions[0] self.splash.setPos(pos[0], pos[1], PartyGlobals.TugOfWarSplashZOffset) self.splash.hide()
def __healDive(heal, hasInteractivePropHealBonus): """ __healJuggle(heal) """ # Determine if this is an NPC heal #print("heal Dive Anim") # Splash object for when toon hits the water splash = Splash.Splash(render) #remember to destroy splash.reparentTo(render) #import pdb; pdb.set_trace() npcId = 0 if ('npcId' in heal): npcId = heal['npcId'] toon = NPCToons.createLocalNPC(npcId) if (toon == None): return None else: toon = heal['toon'] targets = heal['target'] ineffective = heal['sidestep'] level = heal['level'] #print("toonScale %s" % (toon.getBodyScale())) # Make a 'sandwich' around the track specific interval if (npcId != 0): track = Sequence(MovieNPCSOS.teleportIn(heal, toon)) else: track = Sequence(__runToHealSpot(heal)) delay = 7.0 first = 1 targetTrack = Sequence() for target in targets: targetToon = target['toon'] #hp = min(targetToon.hp + target['hp'], targetToon.maxHp) hp = target['hp'] reactIval = Func(__healToon, targetToon, hp, ineffective, hasInteractivePropHealBonus) if (first == 1): targetTrack.append(Wait(delay)) first = 0 targetTrack.append(reactIval) thisBattle = heal['battle'] toonsInBattle = thisBattle.toons glass = globalPropPool.getProp('glass') glass.setScale(4.0) glass.setHpr(0.0, 90.0, 0.0) ladder = globalPropPool.getProp('ladder') #MovieUtil.copyProp(cube) #placeNode = MovieUtil.copyProp(glass) placeNode = NodePath("lookNode") diveProps = [glass, ladder] #, placeNode] ladderScale = (toon.getBodyScale() / 0.66) scaleUpPoint = Point3(.50, .5, .45) * ladderScale basePos = toon.getPos() glassOffset = Point3(0, 1.1, 0.2) glassToonOffset = Point3(0, 1.2, 0.2) splashOffset = Point3(0, 1.0, 0.4) ladderOffset = Point3(0, 4, 0) ladderToonSep = Point3(0, 1, 0) * ladderScale diveOffset = Point3(0, 0, 10) divePos = add3(add3(ladderOffset, diveOffset), ladderToonSep) ladder.setH(toon.getH()) glassPos = render.getRelativePoint( toon, glassOffset) #add3(basePos, glassOffset) glassToonPos = render.getRelativePoint(toon, glassToonOffset) ladderPos = render.getRelativePoint(toon, ladderOffset) climbladderPos = render.getRelativePoint( toon, add3(ladderOffset, ladderToonSep)) #add3(basePos, ladderOffset) divePos = render.getRelativePoint(toon, divePos) topDivePos = render.getRelativePoint(toon, diveOffset) lookBase = render.getRelativePoint(toon, ladderOffset) lookTop = render.getRelativePoint(toon, add3(ladderOffset, diveOffset)) LookGlass = render.getRelativePoint(toon, glassOffset) splash.setPos(splashOffset) walkToLadderTime = 1.0 climbTime = 5.0 diveTime = 1.0 ladderGrowTime = 1.5 splash.setPos(glassPos) toonNode = toon.getGeomNode() #nameTagNode = NodePath(toon.nametag.getNametag3d()) #nameTagNode = NodePath(toon.getHeadParts()[0]) #placeNode = NodePath("lookNode") placeNode.reparentTo(render) placeNode.setScale(5.0) #placeNode.attachNewNode("lookNode") placeNode.setPos(toon.getPos(render)) placeNode.setHpr(toon.getHpr(render)) toonscale = toonNode.getScale() toonFacing = toon.getHpr() #for someToon in toonsInBattle: # someToon.startStareAt(nameTagNode, Point3(0,0,3)) #toonsLook(toonsInBattle, placeNode, Point3(0,0,3)) propTrack = Sequence( #Func(MovieUtil.showProps, cubes, hips), Func(MovieUtil.showProp, glass, render, glassPos), Func(MovieUtil.showProp, ladder, render, ladderPos), Func(toonsLook, toonsInBattle, placeNode, Point3(0, 0, 0)), Func(placeNode.setPos, lookBase), LerpScaleInterval(ladder, ladderGrowTime, scaleUpPoint, startScale=MovieUtil.PNT3_NEARZERO), Func(placeNode.setPos, lookTop), Wait(2.1), MovieCamera.toonGroupHighShot(None, 0), Wait(2.1), Func(placeNode.setPos, LookGlass), Wait(0.4), MovieCamera.allGroupLowShot(None, 0), Wait(1.8), LerpScaleInterval(ladder, ladderGrowTime, MovieUtil.PNT3_NEARZERO, startScale=scaleUpPoint), Func(MovieUtil.removeProps, diveProps), #Func(MovieUtil.removeProps, placeNode), ) mtrack = Parallel( propTrack, __getSoundTrack(level, 0.6, duration=9.0, node=toon), Sequence( Parallel( Sequence( ActorInterval(toon, 'walk', loop=0, duration=walkToLadderTime), ActorInterval(toon, 'neutral', loop=0, duration=0.1), ), LerpPosInterval(toon, walkToLadderTime, climbladderPos), Wait(ladderGrowTime), ), Parallel( ActorInterval(toon, 'climb', loop=0, endFrame=116), Sequence( Wait(4.6), #LerpScaleInterval(toon, diveTime*0.1, 0.1), #Func(toon.doToonAlphaColorScale, VBase4(1, 0.0, 1, 0.0), 0.5), Func(toonNode.setTransparency, 1), LerpColorScaleInterval(toonNode, 0.25, VBase4(1, 1.0, 1, 0.0), blendType='easeInOut'), LerpScaleInterval(toonNode, 0.01, 0.1, startScale=toonscale), LerpHprInterval(toon, 0.01, toonFacing), LerpPosInterval(toon, 0.0, glassToonPos), Func(toonNode.clearTransparency), Func(toonNode.clearColorScale), Parallel( ActorInterval(toon, 'swim', loop=1, startTime=0.0, endTime=1.00), Wait(1.0), ), # ), Sequence( Wait(4.6), Func(splash.play), Wait(1.0), Func(splash.destroy), ), ), #ActorInterval(toon, 'walk', loop = 1, duration=walkToLadderTime), #ActorInterval(toon, 'swim', loop = 1, duration=climbTime), #ActorInterval(toon, 'swim', loop = 1, duration=diveTime*1.0), #LerpScaleInterval(toon, diveTime*0.1, 0.1), Wait(0.5), Parallel( #LerpHprInterval(toon, 0.1, Point3(0,0,0)), ActorInterval(toon, 'jump', loop=0, startTime=0.2), LerpScaleInterval(toonNode, 0.5, toonscale, startScale=0.1), Func(stopLook, toonsInBattle), )), targetTrack) track.append(mtrack) if (npcId != 0): track.append(MovieNPCSOS.teleportOut(heal, toon)) else: track.append(__returnToBase(heal)) for target in targets: targetToon = target['toon'] track.append(Func(targetToon.clearChat)) return track
class FishAnimatedProp(AnimatedProp.AnimatedProp): def __init__(self, node): AnimatedProp.AnimatedProp.__init__(self, node) parent = node.getParent() self.fish = Actor.Actor(node, copy=0) self.fish.reparentTo(parent) self.fish.setTransform(node.getTransform()) node.clearMat() self.fish.loadAnims({ 'jump': 'phase_4/models/props/SZ_fish-jump', 'swim': 'phase_4/models/props/SZ_fish-swim' }) self.splashSfxList = ( loader.loadSfx('phase_4/audio/sfx/TT_splash1.mp3'), loader.loadSfx('phase_4/audio/sfx/TT_splash2.mp3')) self.node = self.fish self.geom = self.fish.getGeomNode() self.exitRipples = Ripples(self.geom) self.exitRipples.setBin('fixed', 25, 1) self.exitRipples.setPosHprScale(-0.29999999999999999, 0.0, 1.24, 0.0, 0.0, 0.0, 0.69999999999999996, 0.69999999999999996, 0.69999999999999996) self.splash = Splash(self.geom, wantParticles=0) self.splash.setPosHprScale(-1, 0.0, 1.23, 0.0, 0.0, 0.0, 0.69999999999999996, 0.69999999999999996, 0.69999999999999996) randomSplash = random.choice(self.splashSfxList) self.track = Sequence(FunctionInterval(self.randomizePosition), Func(self.node.unstash), Parallel( self.fish.actorInterval('jump'), Sequence(Wait(0.25), Func(self.exitRipples.play, 0.75)), Sequence( Wait(1.1399999999999999), Func(self.splash.play), SoundInterval(randomSplash, volume=0.80000000000000004, node=self.node))), Wait(1), Func(self.node.stash), Wait(4 + 10 * random.random()), name=self.uniqueName('Fish')) def delete(self): self.exitRipples.destroy() del self.exitRipples self.splash.destroy() del self.splash del self.track self.fish.removeNode() del self.fish del self.node del self.geom def randomizePosition(self): x = 5 * (random.random() - 0.5) y = 5 * (random.random() - 0.5) h = 360 * random.random() self.geom.setPos(x, y, 0) self.geom.setHpr(h, 0, 0) def enter(self): AnimatedProp.AnimatedProp.enter(self) self.track.loop() def exit(self): AnimatedProp.AnimatedProp.exit(self) self.track.finish() self.splash.stop() self.exitRipples.stop()