def __init__(self, avatar): self.data = avatar.getData() self.localAvatar = avatar.getAvatar() self.gag = None self.setupToon() self.walkSound = SoundBank.getSound('toon_walk') self.runSound = SoundBank.getSound('toon_run') self.laffMeter = LaffMeter(self) self.laffMeter.setPos(-1.18, 0, -0.84) self.laffMeter.start() self.localAvatar.setPythonTag('Avatar', self) self.gagMgr = GagManager() render.setPythonTag('GagManager', self.gagMgr) from doomsday.shop.GagCannon import GagCannon from doomsday.shop.GagBarrel import GagBarrel gagCannon = GagCannon().generate() gagCannon.reparentTo(render) gagCannon.setPos(43.36, -0.82, 4.03) gagCannon.setH(89.47) #gagCannon2 = GagCannon().generate() #gagCannon2.reparentTo(render) #gagCannon2.setPos(-60.18, -9.06, 1.23) #gagCannon2.setH(93.90) barrel = GagBarrel('Wedding Cake').generate() barrel.setPos(43.36, 6.71, 4.03) barrel.setH(89.47) barrel = GagBarrel('Wedding Cake').generate() barrel.setPos(-57.20, -5.61, 1.23) barrel.setH(91.19) return
def gagRelease(self, task): gagRange = NodePath('Gag Range') gagRange.reparentTo(self.localAvatar.find('**/joint_nameTag')) gagRange.setPos(0, 75, 0) gagRange.setHpr(90, -90, 90) if self.gag == None: gagRange.removeNode() base.taskMgr.doMethodLater(0.1, self.enableThrowing, 'Enable Gag Throw') return else: if self.height > 1: grav = 0.7 + self.height / 10 else: grav = 0.7 if self.height > 5.2: base.taskMgr.add(self.enableThrowing, 'Enable Gag Throw') return self.gag.reparentTo(render) self.gag.setHpr(gagRange.getHpr(render)) self.gagMgr.getGagByName(self.currentGag).addCollision(self.gag) handJoint = self.localAvatar.find('**/def_joint_right_hold') startPos = Vec3(handJoint.getPos(render).getX(), handJoint.getPos(render).getY(), handJoint.getPos(render).getZ() + 0.8) self.projectile = ProjectileInterval(self.gag, startPos=startPos, endPos=gagRange.getPos(render), duration=1, gravityMult=grav) self.projectile.start() SoundBank.getSound('pie_throw').play() base.taskMgr.doMethodLater(0.8, self.enableThrowing, 'Enable Gag Throw') base.taskMgr.doMethodLater(2, self.destroyGag, 'Destroy Gag', extraArgs = [self.gag, self.projectile], appendTask = True) base.accept('delete-up', self.null) base.accept('p-up', self.null) self.throwingPie = False return Task.done
def closeDoors(self, avatar, task): self.firstPositions.pop(avatar.getPythonTag("Cog").getName()) SoundBank.getSound('door_close').play() self.rightDoor.hprInterval(0.5, Vec3(0, 0, 0), startHpr = (95, 0, 0), blendType = 'easeInOut') self.rightDoor.hide() self.rightDoorHole.hide() self.toonhall.colorScaleInterval(2, Vec4(0.2509803921568627, 0.2509803921568627, 0.2509803921568627, 1), startColorScale=Vec4(1, 1, 1, 1), blendType='easeInOut') return Task.done
def openDoors(self, avatar, task): if not avatar.getPythonTag('Cog').isDefeated: self.rightDoorHole.show() self.rightDoor.show() SoundBank.getSound('door_open').play() self.rightDoor.hprInterval(1, Vec3(95, 0, 0), startHpr=(0, 0, 0), blendType='easeInOut') base.taskMgr.doMethodLater(0.2, self.moveAvatarThroughDoor, 'Move Avatar Through Door', extraArgs = [avatar], appendTask = True) else: self.firstPositions.pop(avatar.getPythonTag("Cog").getName()) return Task.done
def openDoors(self, avatar, task): if not avatar.getPythonTag("Cog").isDefeated: self.rightDoorHole.show() self.rightDoor.show() SoundBank.getSound("door_open").play() self.rightDoor.hprInterval(1, Vec3(95, 0, 0), startHpr=(0, 0, 0), blendType="easeInOut") base.taskMgr.doMethodLater( 0.2, self.moveAvatarThroughDoor, "Move Avatar Through Door", extraArgs=[avatar], appendTask=True ) else: self.firstPositions.pop(avatar.getPythonTag("Cog").getName()) return Task.done
def execute(self): ent = self.cls.getEntity() if not ent.isEmpty(): SoundBank.getSound('drop_pickup').play() if(ent.getName() == "ent_jellybean"): jbAmt = ent.getPythonTag("Amount") toon = render.find('**/Toon').getPythonTag('Avatar') toon.setJellybeans(toon.getJellybeans() + jbAmt) elif(ent.getName() == "ent_clothes"): pass ent.removeNode() else: return
def execute(self): ent = self.cls.getEntity() if not ent.isEmpty(): SoundBank.getSound('drop_pickup').play() if (ent.getName() == "ent_jellybean"): jbAmt = ent.getPythonTag("Amount") toon = render.find('**/Toon').getPythonTag('Avatar') toon.setJellybeans(toon.getJellybeans() + jbAmt) elif (ent.getName() == "ent_clothes"): pass ent.removeNode() else: return
def handleAttackCollision(self, entry): intoNode = entry.getIntoNodePath() fromNode = entry.getFromNodePath() if(intoNode.getName() == 'coll_toon'): if(fromNode.getName() == 'coll_attack'): stats = fromNode.getParent().getPythonTag("Stats") avatar = intoNode.getParent().getPythonTag('Avatar') if(avatar.isHit() == False): avatar.setHit(True) avatar.setHealth(avatar.getHealth() - stats.getDamage()) if(fromNode.getParent().hasPythonTag("HitSound")): SoundBank.getSound(fromNode.getParent().getPythonTag("HitSound")).play() fromNode.getParent().removeNode()
def closeDoors(self, avatar, task): self.firstPositions.pop(avatar.getPythonTag("Cog").getName()) SoundBank.getSound("door_close").play() self.rightDoor.hprInterval(0.5, Vec3(0, 0, 0), startHpr=(95, 0, 0), blendType="easeInOut") self.rightDoor.hide() self.rightDoorHole.hide() self.toonhall.colorScaleInterval( 2, Vec4(0.2509803921568627, 0.2509803921568627, 0.2509803921568627, 1), startColorScale=Vec4(1, 1, 1, 1), blendType="easeInOut", ) return Task.done
def handleAttackCollision(self, entry): intoNode = entry.getIntoNodePath() fromNode = entry.getFromNodePath() if (intoNode.getName() == 'coll_toon'): if (fromNode.getName() == 'coll_attack'): stats = fromNode.getParent().getPythonTag("Stats") avatar = intoNode.getParent().getPythonTag('Avatar') if (avatar.isHit() == False): avatar.setHit(True) avatar.setHealth(avatar.getHealth() - stats.getDamage()) if (fromNode.getParent().hasPythonTag("HitSound")): SoundBank.getSound(fromNode.getParent().getPythonTag( "HitSound")).play() fromNode.getParent().removeNode()
def __init__(self, toonhall, door): self.toonhall = toonhall self.door = door self.rightDoorHole = self.door.find('**/doorFrameHoleRight') self.rightDoor = self.toonhall.find('**/rightDoor') self.sfx = SoundBank.getSound('toonhall_warning') base.taskMgr.doMethodLater(0.8, self.detectNearbyCogs, 'Detect Nearby Cogs')
def __init__(self, toonhall, door): self.toonhall = toonhall self.door = door self.rightDoorHole = self.door.find("**/doorFrameHoleRight") self.rightDoor = self.toonhall.find("**/rightDoor") self.sfx = SoundBank.getSound("toonhall_warning") base.taskMgr.doMethodLater(0.8, self.detectNearbyCogs, "Detect Nearby Cogs")
def flyIn(self): phase_4 = "phase_4/models/props" cog = self.cog.getCog() collisions = render.getPythonTag('WorldCollisions') collisions.addCogCollision(self.cog) self.propeller = Actor( loader.loadModel(phase_4 + "/propeller-mod.bam"), {'chan': loader.loadModel(phase_4 + "/propeller-chan.bam")}) self.propeller.reparentTo(cog.find('**/joint_head')) propSound = SoundBank.getSound('propeller') propSound.setLoop(True) propSound.setVolume(0.8) propSound.play() pos = cog.getPos() cog.setPos(pos.getX(), pos.getY(), pos.getZ() + 20) cog.pose('landing', 1) cog.colorScaleInterval(4.8, Vec4(1, 1, 1, 1), startColorScale=Vec4(0.2509803921568627, 0.2509803921568627, 0.2509803921568627, 0.25), blendType='easeInOut').start() path = cog.posInterval(5, pos, startPos=cog.getPos()) path.start() self.propeller.loop('chan', fromFrame=0, toFrame=3) base.taskMgr.add(self.handleCogDead, 'Handle Cog Death') base.taskMgr.doMethodLater(4, self.playInSound, 'Play In Sound', extraArgs=[propSound], appendTask=True) base.taskMgr.doMethodLater(5, self.landCog, 'Land Cog')
def __init__(self, gag = None, supply = def_supply, health = 20, fireSpeed = 2, searchTime = 4): self.gag = None self.maxSupply = supply self.supply = 0 self.maxHp = health self.hp = health self.fireSpeed = fireSpeed self.searchTime = searchTime self.maxDistance = 100 self.target = None self.cannon = None self.gagMgr = None self.firing = False self.gagProp = None self.fireSound = SoundBank.getSound('cannon_fire') self.adjustSound = SoundBank.getSound('cannon_adjust') self.whizzSound = SoundBank.getSound('cannon_whizz')
def releaseProj(task): if(cog.getHealth() > 0): attackRange = ent.find('**/joint_nameTag').attachNewNode("Attack Range") attackRange.setPos(0, 50, -5) self.projectile.setBillboardPointEye() wc = render.getPythonTag('WorldCollisions') wc.addAttackCollision(self.projectile) self.projectile.reparentTo(render) projTrack = ProjectileInterval(self.projectile, endPos = Point3(attackRange.getPos(render)), startPos = (handJoint.getPos(render)), gravityMult = 0.7, duration = 1) projTrack.start() if(self.throwSound != None): SoundBank.getSound(self.throwSound).play() ent.play('neutral') Sequence( Wait(2), Func(destroy, range) ) return Task.done
def __init__(self): self.trans = Transitions(loader) self.scene = render.getPythonTag('SceneManager').createScene('Make-A-Toon') self.setupEnvironment() self.randomizeData() self.setupHUD() self.bgm = SoundBank.getSound('make_a_toon') self.bgm.setLoop(True) self.bgm.play()
def __init__(self): self.trans = Transitions(loader) self.scene = render.getPythonTag('SceneManager').createScene( 'Make-A-Toon') self.setupEnvironment() self.randomizeData() self.setupHUD() self.bgm = SoundBank.getSound('make_a_toon') self.bgm.setLoop(True) self.bgm.play()
def releaseProj(task): if (cog.getHealth() > 0): attackRange = ent.find( '**/joint_nameTag').attachNewNode("Attack Range") attackRange.setPos(0, 50, -5) self.projectile.setBillboardPointEye() wc = render.getPythonTag('WorldCollisions') wc.addAttackCollision(self.projectile) self.projectile.reparentTo(render) projTrack = ProjectileInterval( self.projectile, endPos=Point3(attackRange.getPos(render)), startPos=(handJoint.getPos(render)), gravityMult=0.7, duration=1) projTrack.start() if (self.throwSound != None): SoundBank.getSound(self.throwSound).play() ent.play('neutral') Sequence(Wait(2), Func(destroy, range)) return Task.done
def handleInCollisions(self, entry): cogCollNames = ['coll_body', 'coll_crit'] intoNode = entry.getIntoNodePath() fromNode = entry.getFromNodePath() if (self.called): return self.called = True splatColor = Vec4(0.7, 0.7, 0.8, 1.0) splatScale = 0.7 if (intoNode.getName() in cogCollNames): cog = intoNode.getParent().getPythonTag('Cog') gag = fromNode.getParent().getPythonTag('Stats') splatColor = gag.getSplatColor() splatScale = gag.getSplatScale() if not cog.wasHit(): cog.setHit(True) if (cog.getLevel() > 1): exp = int( math.ceil(float(cog.getLevel()) / 2.0) * gag.getLevel()) else: exp = int(gag.getLevel()) render.getPythonTag("LevelManager").addEXP(exp) dmg = gag.getDamageCurve()[0] if (intoNode.getName() == cogCollNames[1]): dmg = (dmg * 2) * 0.4 cog.setHealth(cog.getHealth() - int(dmg)) if (cog.getHealth() <= 0): maxHp = float((cog.getLevel() + 1) * (cog.getLevel() + 2)) if (cog.getHealth() <= (-1 * (maxHp * 0.2))): h = cog.getCog().getHpr(fromNode.getParent()).getX() if (h > 0 and h < 90 or h < 270 and h > 0): cog.getCog().play('slip-backward') else: cog.getCog().play('slip-forward') else: cog.getCog().play('pie-small') SoundBank.getSound('pie_coll').play() Splat(fromNode.getParent().getPos(), splatColor, splatScale).generate() fromNode.getParent().removeNode()
def __init__(self, gag=None, supply=def_supply, health=20, fireSpeed=2, searchTime=4): self.gag = None self.maxSupply = supply self.supply = 0 self.maxHp = health self.hp = health self.fireSpeed = fireSpeed self.searchTime = searchTime self.maxDistance = 100 self.target = None self.cannon = None self.gagMgr = None self.firing = False self.gagProp = None self.fireSound = SoundBank.getSound('cannon_fire') self.adjustSound = SoundBank.getSound('cannon_adjust') self.whizzSound = SoundBank.getSound('cannon_whizz')
def handleInCollisions(self, entry): cogCollNames = ['coll_body', 'coll_crit'] intoNode = entry.getIntoNodePath() fromNode = entry.getFromNodePath() if(self.called): return self.called = True splatColor = Vec4(0.7, 0.7, 0.8, 1.0) splatScale = 0.7 if(intoNode.getName() in cogCollNames): cog = intoNode.getParent().getPythonTag('Cog') gag = fromNode.getParent().getPythonTag('Stats') splatColor = gag.getSplatColor() splatScale = gag.getSplatScale() if not cog.wasHit(): cog.setHit(True) if(cog.getLevel() > 1): exp = int(math.ceil(float(cog.getLevel()) / 2.0) * gag.getLevel()) else: exp = int(gag.getLevel()) render.getPythonTag("LevelManager").addEXP(exp) dmg = gag.getDamageCurve()[0] if(intoNode.getName() == cogCollNames[1]): dmg = (dmg * 2) * 0.4 cog.setHealth(cog.getHealth() - int(dmg)) if(cog.getHealth() <= 0): maxHp = float((cog.getLevel() + 1) * (cog.getLevel() + 2)) if(cog.getHealth() <= (-1 * (maxHp * 0.2))): h = cog.getCog().getHpr(fromNode.getParent()).getX() if(h > 0 and h < 90 or h < 270 and h > 0): cog.getCog().play('slip-backward') else: cog.getCog().play('slip-forward') else: cog.getCog().play('pie-small') SoundBank.getSound('pie_coll').play() Splat(fromNode.getParent().getPos(), splatColor, splatScale).generate() fromNode.getParent().removeNode()
def startWave(self): if (self.bgm != None): self.bgm.stop() if (self.currentWave == -1): wave = 0 render.find('**/TTC').getPythonTag('Class').doFade() else: if ((self.currentWave + 1) != len(self.waves)): wave = (self.currentWave + 1) else: wave = 0 self.currentWave = wave waveObj = self.waves[wave] if (wave == 0): Sequence(Wait(3.4), Func(waveObj.spawnCogs)).start() else: waveObj.spawnCogs() self.bgm = SoundBank.getSound(random.choice(self.bgms)) self.bgm.setLoop(True) self.bgm.play()
def flyIn(self): phase_4 = "phase_4/models/props" cog = self.cog.getCog() collisions = render.getPythonTag('WorldCollisions') collisions.addCogCollision(self.cog) self.propeller = Actor(loader.loadModel(phase_4 + "/propeller-mod.bam"), {'chan' : loader.loadModel(phase_4 + "/propeller-chan.bam")}) self.propeller.reparentTo(cog.find('**/joint_head')) propSound = SoundBank.getSound('propeller') propSound.setLoop(True) propSound.setVolume(0.8) propSound.play() pos = cog.getPos() cog.setPos(pos.getX(), pos.getY(), pos.getZ() + 20) cog.pose('landing', 1) cog.colorScaleInterval(4.8, Vec4(1, 1, 1, 1), startColorScale=Vec4(0.2509803921568627, 0.2509803921568627, 0.2509803921568627, 0.25), blendType='easeInOut').start() path = cog.posInterval(5, pos, startPos = cog.getPos()) path.start() self.propeller.loop('chan', fromFrame=0, toFrame=3) base.taskMgr.add(self.handleCogDead, 'Handle Cog Death') base.taskMgr.doMethodLater(4, self.playInSound, 'Play In Sound', extraArgs = [propSound], appendTask = True) base.taskMgr.doMethodLater(5, self.landCog, 'Land Cog')
def startWave(self): if(self.bgm != None): self.bgm.stop() if(self.currentWave == -1): wave = 0 render.find('**/TTC').getPythonTag('Class').doFade() else: if((self.currentWave + 1) != len(self.waves)): wave = (self.currentWave + 1) else: wave = 0 self.currentWave = wave waveObj = self.waves[wave] if(wave == 0): Sequence( Wait(3.4), Func(waveObj.spawnCogs) ).start() else: waveObj.spawnCogs() self.bgm = SoundBank.getSound(random.choice(self.bgms)) self.bgm.setLoop(True) self.bgm.play()
def playSound(sound): SoundBank.getSound(sound).play()
def playInSound(self, sound, task): if not self.cancelStep: sound.stop() SoundBank.getSound('propeller_in').play() return Task.done