def __init__(self, incTime=1000):

		lightY = 150

		self.pos = 0

		self._beep1Sound = bs.getSound('raceBeep1')
		self._beep2Sound = bs.getSound('raceBeep2')

		self.lights = []
		for i in range(4):
			l = bs.newNode('image',
						   attrs={'texture':bs.getTexture('nub'),
								  'opacity':1.0,
								  'absoluteScale':True,
								  'position':(-75+i*50, lightY),
								  'scale':(50, 50),
								  'attach':'center'})
			bs.animate(l, 'opacity', {10:0, 1000:1.0})
			self.lights.append(l)

		self.lights[0].color = (0.2, 0, 0)
		self.lights[1].color = (0.2, 0, 0)
		self.lights[2].color = (0.2, 0.05, 0)
		self.lights[3].color = (0.0, 0.3, 0)


		self.cases = {1: self._doLight1, 2: self._doLight2, 3: self._doLight3, 4: self._doLight4}
		self.incTimer = None
		self.incTime = incTime
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)
        self._winSound = bs.getSound("score")
        self._cheerSound = bs.getSound("cheer")
        self._chantSound = bs.getSound("crowdChant")
        self._foghornSound = bs.getSound("foghorn")
        self._swipSound = bs.getSound("swip")
        self._whistleSound = bs.getSound("refWhistle")
        self._puckModel = bs.getModel("puck")
        self._puckTex = bs.getTexture("puckColor")
        self._puckSound = bs.getSound("metalHit")

        self._puckMaterial = bs.Material()
        self._puckMaterial.addActions(actions=(("modifyPartCollision", "friction", 0.1)))
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("pickupMaterial")),
            actions=(("modifyPartCollision", "collide", False)),
        )
        self._puckMaterial.addActions(
            conditions=(("weAreYoungerThan", 100), "and", ("theyHaveMaterial", bs.getSharedObject("objectMaterial"))),
            actions=(("modifyNodeCollision", "collide", False)),
        )
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("footingMaterial")),
            actions=(("impactSound", self._puckSound, 0.2, 5)),
        )
        # keep track of which player last touched the puck
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")),
            actions=(("call", "atConnect", self._handlePuckPlayerCollide),),
        )

        # we want the puck to kill powerups; not get stopped by them
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.Powerup.getFactory().powerupMaterial),
            actions=(
                ("modifyPartCollision", "physical", False),
                ("message", "theirNode", "atConnect", bs.DieMessage()),
            ),
        )

        # dis is kill
        self._puckMaterial.addActions(
            conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")),
            actions=(
                ("modifyPartCollision", "physical", False),
                ("message", "ourNode", "atConnect", PuckTouchedMessage()),
            ),
        )

        self._scoreBoard = bs.ScoreBoard()
        self._killsToWin = self.settings["Kills to Win"]
        self._scoreSound = bs.getSound("score")

        self.pucks = []
	def _create_icon_button(self, swinstance, index):
		width, height = swinstance._width, swinstance._gOnlyHeight
		layout = iconbuttonlayouts[sum([b.icon is not None for b in buttons])]
		bw = width / (max(layout) + (0.4 if gSmallUI else 0.2))
		bwx = bw
		bh = height / (len(layout) + (0.5 if gSmallUI else 0.4))
		# try to keep it squared
		if abs(1 - bw / bh) > 0.1:
			bwx *= (bh / bw - 1) / 2 + 1
			bw = bh = min(bw, bh)

		for i in range(len(layout) + 1):
			if sum(layout[:i]) > index:
				row = i - 1
				pos = index - sum(layout[:i - 1])
				break

		x = self.x(swinstance, index, bwx)
		y = swinstance._height - 95 - (row + 0.8) * (bh - 10)

		button = ButtonWidget(parent=swinstance._rootWidget, autoSelect=True,
		                      position=(x, y), size=(bwx, bh), buttonType='square',
		                      label='')
		button.onActivateCall = lambda: self._cb(swinstance)

		x += (bwx - bw) / 2
		TextWidget(parent=swinstance._rootWidget, text=self.text,
		           position=(x + bw * 0.47, y + bh * 0.22),
		           maxWidth=bw * 0.7, size=(0, 0), hAlign='center', vAlign='center',
		           drawController=button,
		           color=(0.7, 0.9, 0.7, 1.0))

		iw, ih = bw * 0.65, bh * 0.65
		i = ImageWidget(parent=swinstance._rootWidget, position=(x + bw * 0.49 - iw * 0.5, y + 43),
		                size=(iw, ih), texture=bs.getTexture(self.icon),
		                drawController=button)
		if self.iconColor:
			i.color = self.iconColor
		self._buttonInstance = button._instance
		return x, y
Exemplo n.º 4
0
    def __init__(self, map):

        bs.Actor.__init__(self)

        self.controlled = False
        self.sourcePlayer = None

        self.floaterMaterial = bs.Material()
        self.floaterMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('playerMaterial')),
            actions=(('modifyNodeCollision', 'collide', True),
                     ('modifyPartCollision', 'physical', True)))
        self.floaterMaterial.addActions(
            conditions=(('theyDontHaveMaterial',
                         bs.getSharedObject('playerMaterial')), 'and',
                        ('theyHaveMaterial',
                         bs.getSharedObject('objectMaterial')), 'or',
                        ('theyHaveMaterial',
                         bs.getSharedObject('footingMaterial'))),
            actions=(('modifyPartCollision', 'physical', False), ))

        self.pos = map.getDefBoundBox('levelBounds')
        self.px = "random.uniform(self.pos[0],self.pos[3])"
        self.py = "random.uniform(self.pos[1],self.pos[4])"
        self.pz = "random.uniform(self.pos[2],self.pos[5])"
        # self.node = bs.newNode('prop',attrs={'position':(eval(self.px),eval(self.py),eval(self.pz)),'sticky':False,'body':'landMine','model':bs.getModel('landMine'),'colorTexture':bs.getTexture('logo'),'bodyScale':4.0,'reflection': 'powerup','density':99999999999999999,'reflectionScale': [1.0],'modelScale':4.0,'gravityScale':0,'shadowSize':0.1,'isAreaOfInterest':True,'materials':[bs.getSharedObject('footingMaterial'),self.floaterMaterial]})

        self.node = bs.newNode(
            'prop',
            delegate=self,
            owner=None,
            attrs={
                'position': (eval(self.px), eval(self.py), eval(self.pz)),
                'model':
                bs.getModel('landMine'),
                'lightModel':
                bs.getModel('landMine'),
                'body':
                'landMine',
                'bodyScale':
                4,
                'modelScale':
                4,
                'shadowSize':
                0.25,
                'density':
                9999999999999999999,
                'gravityScale':
                0.0,
                'colorTexture':
                bs.getTexture('logo'),
                'reflection':
                'soft',
                'reflectionScale': [0.25],
                'materials':
                [bs.getSharedObject('footingMaterial'), self.floaterMaterial]
            })
        #self.node.position = map.getDefPoints('flag')[0][:3]
        self.node2 = bs.newNode(
            'prop',
            owner=self.node,
            attrs={
                'position': (0, 0, 0),
                'sticky':
                False,
                'body':
                'sphere',
                'model':
                None,
                'colorTexture':
                bs.getTexture('logo'),
                'bodyScale':
                1.0,
                'reflection':
                'powerup',
                'density':
                99999999999999999,
                'reflectionScale': [1.0],
                'modelScale':
                1.0,
                'gravityScale':
                0,
                'shadowSize':
                0.1,
                'isAreaOfInterest':
                True,
                'materials':
                [bs.getSharedObject('objectMaterial'), self.floaterMaterial]
            })
        self.node.connectAttr('position', self.node2, 'position')
        #self.node.velocity = (0,0.1,0)
        # bs.gameTimer(500,bs.WeakCall(self.move))
        # bs.gameTimer(2000,bs.WeakCall(self.drop),True)
        self.move()
Exemplo n.º 5
0
    def handleMessage(self, msg):
        self._handleMessageSanityCheck()

        if isinstance(msg, PowerupAcceptMessage):
            factory = self.getFactory()
            if self.powerupType == 'health':
                bs.playSound(factory.healthPowerupSound,
                             3,
                             position=self.node.position)
            bs.playSound(factory.powerupSound, 3, position=self.node.position)
            self._powersGiven = True
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, _TouchedMessage):
            if not self._powersGiven:
                node = bs.getCollisionInfo("opposingNode")
                if node is not None and node.exists():
                    if self.powerupType == "sloMo":
                        bs.getSharedObject(
                            'globals').slowMotion = bs.getSharedObject(
                                'globals').slowMotion == False
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bsUtils.PopupText(
                            "SloMo",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "TNT":
                        p = node.positionForward
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25),
                                velocity=(0, -6, 0),
                                bombType='tnt').autoRetain()
                        bsUtils.PopupText(
                            "TNT",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "strongICE":
                        p = node.positionForward
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25),
                                velocity=(0, -6, 0),
                                bombType='ice').autoRetain()
                        bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25),
                                velocity=(0, -6, 0),
                                bombType='ice').autoRetain()
                        bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25),
                                velocity=(0, -6, 0),
                                bombType='ice').autoRetain()
                        bsUtils.PopupText(
                            "ICY",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "speedBoots":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.hockey = True
                        bsUtils.PopupText(
                            "Speed away",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "invisible":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.name = ' '
                        node.style = 'agent'
                        node.headModel = None
                        node.torsoModel = None
                        node.pelvisModel = None
                        node.upperArmModel = None
                        node.foreArmModel = None
                        node.handModel = None
                        node.upperLegModel = None
                        node.lowerLegModel = None
                        node.toesModel = None
                        bsUtils.PopupText(
                            "Invisible",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "character":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        testingEvent = 0

                        event = random.randint(
                            1, 6) if testingEvent == 0 else testingEvent
                        print 'Patron And Oore282 <3: ' + str(event)

                        if event in [1]:
                            node.colorTexture = bs.getTexture('frostyColor')
                            node.colorMaskTexture = bs.getTexture(
                                'frostyColorMask')
                            node.headModel = bs.getModel('frostyHead')
                            node.upperArmModel = bs.getModel('kronkUpperArm')
                            node.torsoModel = bs.getModel('frostyTorso')
                            node.pelvisModel = bs.getModel('frostyPelvis')
                            node.foreArmModel = bs.getModel('frostyForeArm')
                            node.handModel = bs.getModel('frostyHand')
                            node.upperLegModel = bs.getModel('frostyUpperLeg')
                            node.lowerLegModel = bs.getModel('frostyLowerLeg')
                            node.toesModel = bs.getModel('frostyToes')
                            node.style = 'frosty'
                            bsUtils.PopupText(
                                "Frosty The Snowman",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                        elif event in [2]:
                            node.colorTexture = bs.getTexture('santaColor')
                            node.colorMaskTexture = bs.getTexture(
                                'santaColorMask')
                            node.headModel = bs.getModel('santaHead')
                            node.upperArmModel = bs.getModel('santaUpperArm')
                            node.torsoModel = bs.getModel('santaTorso')
                            node.pelvisModel = bs.getModel('kronkPelvis')
                            node.foreArmModel = bs.getModel('santaForeArm')
                            node.handModel = bs.getModel('santaHand')
                            node.upperLegModel = bs.getModel('santaUpperLeg')
                            node.lowerLegModel = bs.getModel('santaLowerLeg')
                            node.toesModel = bs.getModel('santaToes')
                            node.style = 'santa'
                            bsUtils.PopupText(
                                "SANTA",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                        elif event in [3]:
                            node.colorTexture = bs.getTexture('wizardColor')
                            node.colorMaskTexture = bs.getTexture(
                                'wizardColorMask')
                            node.headModel = bs.getModel('wizardHead')
                            node.upperArmModel = bs.getModel('wizardUpperArm')
                            node.torsoModel = bs.getModel('wizardTorso')
                            node.pelvisModel = bs.getModel('wizardPelvis')
                            node.foreArmModel = bs.getModel('wizardForeArm')
                            node.handModel = bs.getModel('wizardHand')
                            node.upperLegModel = bs.getModel('wizardUpperLeg')
                            node.lowerLegModel = bs.getModel('wizardLowerLeg')
                            node.toesModel = bs.getModel('wizardToes')
                            node.style = 'wizard'
                            bsUtils.PopupText(
                                "EVIL SCEPTER WIZARD MAN",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                        elif event in [4]:
                            node.colorTexture = bs.getTexture('pixieColor')
                            node.colorMaskTexture = bs.getTexture(
                                'pixieColorMask')
                            node.headModel = bs.getModel('pixieHead')
                            node.upperArmModel = bs.getModel('pixieUpperArm')
                            node.torsoModel = bs.getModel('pixieTorso')
                            node.pelvisModel = bs.getModel('pixiePelvis')
                            node.foreArmModel = bs.getModel('pixieForeArm')
                            node.handModel = bs.getModel('pixieHand')
                            node.upperLegModel = bs.getModel('pixieUpperLeg')
                            node.lowerLegModel = bs.getModel('pixieLowerLeg')
                            node.toesModel = bs.getModel('pixieToes')
                            node.style = 'pixie'
                            bsUtils.PopupText(
                                "PIXIEL-ATED",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                        elif event in [5]:
                            node.colorTexture = bs.getTexture('cyborgColor')
                            node.colorMaskTexture = bs.getTexture(
                                'cyborgColorMask')
                            node.headModel = bs.getModel('cyborgHead')
                            node.upperArmModel = bs.getModel('cyborgUpperArm')
                            node.torsoModel = bs.getModel('cyborgTorso')
                            node.pelvisModel = bs.getModel('cyborgPelvis')
                            node.foreArmModel = bs.getModel('cyborgForeArm')
                            node.handModel = bs.getModel('cyborgHand')
                            node.upperLegModel = bs.getModel('cyborgUpperLeg')
                            node.lowerLegModel = bs.getModel('cyborgLowerLeg')
                            node.toesModel = bs.getModel('cyborgToes')
                            node.style = 'cyborg'
                            bsUtils.PopupText(
                                "The Robo",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                        elif event in [6]:
                            node.colorTexture = bs.getTexture('ninjaColor')
                            node.colorMaskTexture = bs.getTexture(
                                'ninjaColorMask')
                            node.headModel = bs.getModel('ninjaHead')
                            node.upperArmModel = bs.getModel('ninjaUpperArm')
                            node.torsoModel = bs.getModel('ninjaTorso')
                            node.pelvisModel = bs.getModel('ninjaPelvis')
                            node.foreArmModel = bs.getModel('ninjaForeArm')
                            node.handModel = bs.getModel('ninjaHand')
                            node.upperLegModel = bs.getModel('ninjaUpperLeg')
                            node.lowerLegModel = bs.getModel('ninjaLowerLeg')
                            node.toesModel = bs.getModel('ninjaToes')
                            node.style = 'ninja'
                            node.nameColor = (0, 0, 0)
                            node.color = (0, 0, 0)
                            node.highlight = (0, 0, 0)
                            bsUtils.PopupText(
                                "PC||Modder",
                                color=(1, 2, 1),
                                scale=1.5,
                                position=self.node.position).autoRetain()
                    elif self.powerupType == "spazColor":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.color = ((0 + random.random() * 6.5),
                                      (0 + random.random() * 6.5),
                                      (0 + random.random() * 6.5))
                        node.highlight = ((0 + random.random() * 6.5),
                                          (0 + random.random() * 6.5),
                                          (0 + random.random() * 6.5))
                        node.nameColor = ((0 + random.random() * 1.5),
                                          (0 + random.random() * 1.5),
                                          (0 + random.random() * 1.5))
                        node.name += random.choice([
                            '\nTHE BOSS', '\nNOOB', '\nPRO', '\nKill Me',
                            '\nNooby'
                        ])
                        bsUtils.PopupText(
                            "PC||Modder",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "troll":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.handleMessage(bs.FreezeMessage())
                        node.handleMessage(bs.FreezeMessage())
                        node.handleMessage(
                            bs.PowerupMessage(powerupType='curse'))
                        bsUtils.PopupText(
                            "TRoLL",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    elif self.powerupType == "champ":
                        self._powersGiven = True
                        self.handleMessage(bs.DieMessage())
                        node.handleMessage(
                            bs.PowerupMessage(powerupType='punch'))
                        node.handleMessage(
                            bs.PowerupMessage(powerupType='shield'))
                        bsUtils.PopupText(
                            "Champ",
                            color=(1, 2, 1),
                            scale=1.5,
                            position=self.node.position).autoRetain()
                    else:
                        node.handleMessage(
                            PowerupMessage(self.powerupType,
                                           sourceNode=self.node))

        elif isinstance(msg, bs.DieMessage):
            if self.node.exists():
                if (msg.immediate):
                    self.node.delete()
                else:
                    curve = bs.animate(self.node, "modelScale", {0: 1, 100: 0})
                    bs.gameTimer(100, self.node.delete)
                    bs.gameTimer(100, self.nodeLight.delete)

        elif isinstance(msg, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())

        elif isinstance(msg, bs.HitMessage):
            # dont die on punches (thats annoying)
            if msg.hitType != 'punch':
                self.handleMessage(bs.DieMessage())
        else:
            bs.Actor.handleMessage(self, msg)
Exemplo n.º 6
0
    def __init__(self):
        """
        Instantiate a PowerupFactory.
        You shouldn't need to do this; call bs.Powerup.getFactory()
        to get a shared instance.
        """

        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texSloMo = bs.getTexture("achievementFlawlessVictory")
        self.texTNT = bs.getTexture("achievementTNT")
        self.texStrongICE = bs.getTexture("menuButton")
        self.texSpeedBoots = bs.getTexture("achievementGotTheMoves")
        self.texChamp = bs.getTexture("achievementBoxer")
        self.texTroll = bs.getTexture("achievementOffYouGo")
        self.texSpazColor = bs.getTexture("crossOutMask")
        self.texCharacter = bs.getTexture("wizardIcon")
        self.texInvisible = bs.getTexture("ouyaOButton")

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
Exemplo n.º 7
0
    def __init__(self,
                 player,
                 position,
                 scale,
                 showLives=True,
                 showDeath=True,
                 nameScale=1.0,
                 nameMaxWidth=115.0,
                 flatness=1.0,
                 shadow=1.0):
        bs.Actor.__init__(self)

        self._player = player
        self._showLives = showLives
        self._showDeath = showDeath
        self._nameScale = nameScale

        self._outlineTex = bs.getTexture('characterIconMask')

        icon = player.getIcon()
        self.node = bs.newNode('image',
                               owner=self,
                               attrs={
                                   'texture': icon['texture'],
                                   'tintTexture': icon['tintTexture'],
                                   'tintColor': icon['tintColor'],
                                   'vrDepth': 400,
                                   'tint2Color': icon['tint2Color'],
                                   'maskTexture': self._outlineTex,
                                   'opacity': 1.0,
                                   'absoluteScale': True,
                                   'attach': 'bottomCenter'
                               })
        self._nameText = bs.newNode('text',
                                    owner=self.node,
                                    attrs={
                                        'text':
                                        player.getName(),
                                        'color':
                                        bs.getSafeColor(
                                            player.getTeam().color),
                                        'hAlign':
                                        'center',
                                        'vAlign':
                                        'center',
                                        'vrDepth':
                                        410,
                                        'maxWidth':
                                        nameMaxWidth,
                                        'shadow':
                                        shadow,
                                        'flatness':
                                        flatness,
                                        'hAttach':
                                        'center',
                                        'vAttach':
                                        'bottom'
                                    })
        if self._showLives:
            self._livesText = bs.newNode('text',
                                         owner=self.node,
                                         attrs={
                                             'text': 'x0',
                                             'color': (1, 1, 0.5),
                                             'hAlign': 'left',
                                             'vrDepth': 430,
                                             'shadow': 1.0,
                                             'flatness': 1.0,
                                             'hAttach': 'center',
                                             'vAttach': 'bottom'
                                         })
        self.setPositionAndScale(position, scale)
Exemplo n.º 8
0
    def __init__(self):
        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texSuperStar = bs.getTexture("levelIcon")  #for superStar powerup
        self.texSpeed = bs.getTexture("powerupSpeed")  #for speed powerup
        self.texIceCube = bs.getTexture("tipTopBGColor")  #for iceCube powerup
        self.texSurprise = bs.getTexture(
            "powerupHealth")  #for surprise powerup
        self.texMartyrdom = bs.getTexture(
            "achievementCrossHair")  #for martyrdom
        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")
        self.superStarSound = bs.getSound("ooh")  #for superstar
        self.speedSound = bs.getSound("shieldUp")  #for speed
        self.surpriseSound = bs.getSound("hiss")  #for surprise
        self.iceCubeSound = bs.getSound("freeze")  #for iceCube
        self.martyrdomSound = bs.getSound("activateBeep")  #for martyrdom drop
        self.martyrdomPickSound = bs.getSound(
            "gunCocking")  #for martyrdom pick
        self.blockSound = bs.getSound('block')  #for blocking

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
Exemplo n.º 9
0
    def createDisplay(self,
                      x,
                      y,
                      delay,
                      outDelay=None,
                      color=None,
                      style='postGame'):

        if style == 'postGame':
            inGameColors = False
            inMainMenu = False
            hAttach = vAttach = attach = 'center'
        elif style == 'inGame':
            inGameColors = True
            inMainMenu = False
            hAttach = 'left'
            vAttach = 'top'
            attach = 'topLeft'
        elif style == 'news':
            inGameColors = True
            inMainMenu = True
            hAttach = 'center'
            vAttach = 'top'
            attach = 'topCenter'
        else:
            raise Exception('invalid style "' + style + '"')

        # attempt to determine what campaign we're in
        # (so we know whether to show "hard mode only")
        if inMainMenu:
            hmo = False
        else:
            try:
                hmo = (self._hardModeOnly
                       and bs.getSession()._campaignInfo['campaign'] == 'Easy')
            except Exception:
                bs.printException("unable to determine campaign")
                hmo = False

        activity = bs.getActivity()
        if inGameColors:
            objs = []
            outDelayFin = (delay + outDelay) if outDelay is not None else None
            if color is not None:
                c1 = (2.0 * color[0], 2.0 * color[1], 2.0 * color[2], color[3])
                c2 = color
            else:
                c1 = (1.5, 1.5, 2, 1.0)
                c2 = (0.8, 0.8, 1.0, 1.0)

            if hmo:
                c1 = (c1[0], c1[1], c1[2], c1[3] * 0.6)
                c2 = (c2[0], c2[1], c2[2], c2[3] * 0.2)

            objs.append(
                bsUtils.Image(self.getIconTexture(False),
                              hostOnly=True,
                              color=c1,
                              position=(x - 25, y + 5),
                              attach=attach,
                              transition='fadeIn',
                              transitionDelay=delay,
                              vrDepth=4,
                              transitionOutDelay=outDelayFin,
                              scale=(40, 40)).autoRetain())
            txt = self.getDisplayString()
            txtS = 0.85
            txtMaxW = 300
            objs.append(
                bsUtils.Text(txt,
                             hostOnly=True,
                             maxWidth=txtMaxW,
                             position=(x, y + 2),
                             transition='fadeIn',
                             scale=txtS,
                             flatness=0.6,
                             shadow=0.5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             color=c2,
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())
            txt2S = 0.62
            txt2MaxW = 400
            objs.append(
                bsUtils.Text(self.getDescriptionFull()
                             if inMainMenu else self.getDescription(),
                             hostOnly=True,
                             maxWidth=txt2MaxW,
                             position=(x, y - 14),
                             transition='fadeIn',
                             vrDepth=-5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             scale=txt2S,
                             flatness=1.0,
                             shadow=0.5,
                             color=c2,
                             transitionDelay=delay + 100,
                             transitionOutDelay=outDelayFin).autoRetain())

            if hmo:
                t = bsUtils.Text(bs.Lstr(resource='difficultyHardOnlyText'),
                                 hostOnly=True,
                                 maxWidth=txt2MaxW * 0.7,
                                 position=(x + 60, y + 5),
                                 transition='fadeIn',
                                 vrDepth=-5,
                                 hAttach=hAttach,
                                 vAttach=vAttach,
                                 hAlign='center',
                                 vAlign='center',
                                 scale=txtS * 0.8,
                                 flatness=1.0,
                                 shadow=0.5,
                                 color=(1, 1, 0.6, 1),
                                 transitionDelay=delay + 100,
                                 transitionOutDelay=outDelayFin).autoRetain()
                t.node.rotate = 10
                objs.append(t)

            # ticket-award
            awardX = -100
            objs.append(
                bsUtils.Text(bs.getSpecialChar('ticket'),
                             hostOnly=True,
                             position=(x + awardX + 33, y + 7),
                             transition='fadeIn',
                             scale=1.5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             hAlign='center',
                             vAlign='center',
                             color=(1, 1, 1, 0.2 if hmo else 0.4),
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())
            objs.append(
                bsUtils.Text('+' + str(self.getAwardTicketValue()),
                             hostOnly=True,
                             position=(x + awardX + 28, y + 16),
                             transition='fadeIn',
                             scale=0.7,
                             flatness=1,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             hAlign='center',
                             vAlign='center',
                             color=(c2),
                             transitionDelay=delay + 50,
                             transitionOutDelay=outDelayFin).autoRetain())

        else:
            complete = self.isComplete()
            objs = []
            cIcon = self.getIconColor(complete)
            if hmo and not complete:
                cIcon = (cIcon[0], cIcon[1], cIcon[2], cIcon[3] * 0.3)
            objs.append(
                bsUtils.Image(self.getIconTexture(complete),
                              hostOnly=True,
                              color=cIcon,
                              position=(x - 25, y + 5),
                              attach=attach,
                              vrDepth=4,
                              transition='inRight',
                              transitionDelay=delay,
                              transitionOutDelay=None,
                              scale=(40, 40)).autoRetain())
            if complete:
                objs.append(
                    bsUtils.Image(
                        bs.getTexture('achievementOutline'),
                        hostOnly=True,
                        modelTransparent=bs.getModel('achievementOutline'),
                        color=(2, 1.4, 0.4, 1),
                        vrDepth=8,
                        position=(x - 25, y + 5),
                        attach=attach,
                        transition='inRight',
                        transitionDelay=delay,
                        transitionOutDelay=None,
                        scale=(40, 40)).autoRetain())
            else:

                if not complete:
                    awardX = -100
                    objs.append(
                        bsUtils.Text(bs.getSpecialChar('ticket'),
                                     hostOnly=True,
                                     position=(x + awardX + 33, y + 7),
                                     transition='inRight',
                                     scale=1.5,
                                     hAttach=hAttach,
                                     vAttach=vAttach,
                                     hAlign='center',
                                     vAlign='center',
                                     color=(1, 1, 1, 0.4) if complete else
                                     (1, 1, 1, (0.1 if hmo else 0.2)),
                                     transitionDelay=delay + 50,
                                     transitionOutDelay=None).autoRetain())
                    objs.append(
                        bsUtils.Text('+' + str(self.getAwardTicketValue()),
                                     hostOnly=True,
                                     position=(x + awardX + 28, y + 16),
                                     transition='inRight',
                                     scale=0.7,
                                     flatness=1,
                                     hAttach=hAttach,
                                     vAttach=vAttach,
                                     hAlign='center',
                                     vAlign='center',
                                     color=((0.8, 0.93, 0.8,
                                             1.0) if complete else
                                            (0.6, 0.6, 0.6,
                                             (0.2 if hmo else 0.4))),
                                     transitionDelay=delay + 50,
                                     transitionOutDelay=None).autoRetain())
                    # show 'hard-mode-only' only over incomplete achievements
                    # when that's the case..
                    if hmo:
                        t = bsUtils.Text(
                            bs.Lstr(resource='difficultyHardOnlyText'),
                            hostOnly=True,
                            maxWidth=300 * 0.7,
                            position=(x + 60, y + 5),
                            transition='fadeIn',
                            vrDepth=-5,
                            hAttach=hAttach,
                            vAttach=vAttach,
                            hAlign='center',
                            vAlign='center',
                            scale=0.85 * 0.8,
                            flatness=1.0,
                            shadow=0.5,
                            color=(1, 1, 0.6, 1),
                            transitionDelay=delay + 50,
                            transitionOutDelay=None).autoRetain()
                        t.node.rotate = 10
                        objs.append(t)

            objs.append(
                bsUtils.Text(self.getDisplayString(),
                             hostOnly=True,
                             maxWidth=300,
                             position=(x, y + 2),
                             transition='inRight',
                             scale=0.85,
                             flatness=0.6,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             color=((0.8, 0.93, 0.8, 1.0) if complete else
                                    (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))),
                             transitionDelay=delay + 50,
                             transitionOutDelay=None).autoRetain())
            objs.append(
                bsUtils.Text(self.getDescriptionComplete()
                             if complete else self.getDescription(),
                             hostOnly=True,
                             maxWidth=400,
                             position=(x, y - 14),
                             transition='inRight',
                             vrDepth=-5,
                             hAttach=hAttach,
                             vAttach=vAttach,
                             scale=0.62,
                             flatness=1.0,
                             color=((0.6, 0.6, 0.6, 1.0) if complete else
                                    (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))),
                             transitionDelay=delay + 100,
                             transitionOutDelay=None).autoRetain())
        return objs
Exemplo n.º 10
0
    def showCompletionBanner(self, sound=True):

        global gLastAchievementDisplayTime
        gLastAchievementDisplayTime = bs.getRealTime()

        # just piggy-back onto any current activity...
        # (should we use the session instead?..)
        activity = bs.getActivity(exceptionOnNone=False)

        # if this gets called while this achievement is occupying a slot
        # already, ignore it.. (probably should never happen in real
        # life but whatevs..)
        if self._completionBannerSlot is not None:
            return

        if activity is None:
            print 'showCompletionBanner() called with no current activity!'
            return

        if sound:
            bs.playSound(bs.getSound('achievement'), hostOnly=True)
        else:
            bs.gameTimer(
                500, bs.Call(bs.playSound, bs.getSound('ding'), hostOnly=True))

        yOffs = 0
        inTime = 300
        outTime = 3500

        baseVRDepth = 200

        # find the first free slot
        i = 0
        while True:
            if not i in gCompletionBannerSlots:
                #print 'ADDING SLOT',i,'FOR',self
                gCompletionBannerSlots.add(i)
                self._completionBannerSlot = i
                # remove us from that slot when we close..
                # use a real-timer in the UI context so the removal runs even
                # if our activity/session dies
                with bs.Context('UI'):
                    bs.realTimer(inTime + outTime, self._removeBannerSlot)
                break
            i += 1

        yOffs = 110 * self._completionBannerSlot

        objs = []
        obj = bsUtils.Image(bs.getTexture('shadow'),
                            position=(-30, 30 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            transition='inBottom',
                            vrDepth=baseVRDepth - 100,
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(0.0, 0.1, 0, 1),
                            scale=(1000, 300)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True
        obj = bsUtils.Image(bs.getTexture('light'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(1.8, 1.8, 1.0, 0.0),
                            scale=(40, 300)).autoRetain()
        objs.append(obj)

        obj.node.hostOnly = True
        obj.node.premultiplied = True
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 2})
        bsUtils.animate(
            c, 'input0', {
                inTime: 0,
                inTime + 400: 30,
                inTime + 500: 40,
                inTime + 600: 30,
                inTime + 2000: 0
            })
        bsUtils.animate(
            c, 'input1', {
                inTime: 0,
                inTime + 400: 200,
                inTime + 500: 500,
                inTime + 600: 200,
                inTime + 2000: 0
            })
        c.connectAttr('output', obj.node, 'scale')
        bsUtils.animate(obj.node, 'rotate', {0: 0.0, 350: 360.0}, loop=True)
        obj = bsUtils.Image(self.getIconTexture(True),
                            position=(-180, 60 + yOffs),
                            attach='bottomCenter',
                            front=True,
                            vrDepth=baseVRDepth - 10,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # flash
        color = self.getIconColor(True)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')

        obj = bsUtils.Image(bs.getTexture('achievementOutline'),
                            modelTransparent=bs.getModel('achievementOutline'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        obj.node.hostOnly = True

        # flash
        color = (2, 1.4, 0.4, 1)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')
        objs.append(obj)

        obj = bsUtils.Text(bs.Lstr(value='${A}:',
                                   subs=[('${A}',
                                          bs.Lstr(resource='achievementText'))
                                         ]),
                           position=(-120, 91 + yOffs),
                           front=True,
                           vAttach='bottom',
                           vrDepth=baseVRDepth - 10,
                           transition='inBottom',
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           color=(1, 1, 1, 0.8),
                           scale=0.65).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(self.getDisplayString(),
                           position=(-120, 50 + yOffs),
                           front=True,
                           vAttach='bottom',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(1, 0.8, 0, 1.0),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(bs.getSpecialChar('ticket'),
                           position=(-120 - 170 + 5, 75 + yOffs - 20),
                           front=True,
                           vAttach='bottom',
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0.5, 0.5, 0.5, 1),
                           scale=3.0).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text('+' + str(self.getAwardTicketValue()),
                           position=(-120 - 180 + 5, 80 + yOffs - 20),
                           vAttach='bottom',
                           front=True,
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           shadow=1.0,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0, 1, 0, 1),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # add the 'x 2' if we've got pro
        if bsUtils._havePro():
            obj = bsUtils.Text('x 2',
                               position=(-120 - 180 + 45, 80 + yOffs - 50),
                               vAttach='bottom',
                               front=True,
                               hAlign='center',
                               vAlign='center',
                               transition='inBottom',
                               vrDepth=baseVRDepth,
                               flatness=0.5,
                               shadow=1.0,
                               transitionDelay=inTime,
                               transitionOutDelay=outTime,
                               flash=True,
                               color=(0.4, 0, 1, 1),
                               scale=0.9).autoRetain()
            objs.append(obj)
            obj.node.hostOnly = True

        obj = bsUtils.Text(self.getDescriptionComplete(),
                           position=(-120, 30 + yOffs),
                           front=True,
                           vAttach='bottom',
                           transition='inBottom',
                           vrDepth=baseVRDepth - 10,
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           color=(1.0, 0.7, 0.5, 1.0),
                           scale=0.8).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        for obj in objs:
            bs.gameTimer(outTime + 1000,
                         bs.WeakCall(obj.handleMessage, bs.DieMessage()))
Exemplo n.º 11
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        self._scoreBoard = bs.ScoreBoard()
        
        self._cheerSound = bs.getSound("cheer")
        self._chantSound = bs.getSound("crowdChant")
        self._scoreSound = bs.getSound("score")
        self._swipSound = bs.getSound("swip")
        self._whistleSound = bs.getSound("refWhistle")
        self._ballModel = bs.getModel("shield")
        self._ballTex = bs.getTexture("eggTex1")
        self._ballSound = bs.getSound("impactMedium2")
        self._flagKaleTex = bs.getTexture("star")
        self._kaleSound = bs.getSound("metalHit")
        self._nightModel = bs.getModel("shield")
        self._nightTex = bs.getTexture("black")

        self._kaleMaterial = bs.Material()
        #add friction to flags for standing our position (as far as)
        self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')),
                                         actions=( ("modifyPartCollision","friction",9999.5)))
        self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('pickupMaterial')),
                                      actions=( ("modifyPartCollision","collide",False) ) )
        self._kaleMaterial.addActions(conditions=( ("weAreYoungerThan",100),'and',
                                                   ("theyHaveMaterial",bs.getSharedObject('objectMaterial')) ),
                                      actions=( ("modifyNodeCollision","collide",False) ) )
        #dont collide with bombs #FIXME "standing"
        self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.Bomb.getFactory().blastMaterial),
                                      actions=(("modifyPartCollision","collide",False),
                                               ("modifyPartCollision","physical",False)))
        self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.Bomb.getFactory().bombMaterial),
                                      actions=(("modifyPartCollision","collide",False),
                                               ("modifyPartCollision","physical",False)))
        self._kaleMaterial.addActions(
            conditions=('theyHaveMaterial',bs.getSharedObject('objectMaterial')),
            actions=(('impactSound',self._kaleSound,2,5)))
        #we dont wanna hit the night so
        self._nightMaterial = bs.Material()
        self._nightMaterial.addActions(
            conditions=(('theyHaveMaterial',bs.getSharedObject('pickupMaterial')),'or',
                        ('theyHaveMaterial',bs.getSharedObject('attackMaterial'))),
            actions=(('modifyPartCollision','collide',False)))

        # we also dont want anything moving it
        self._nightMaterial.addActions(
            conditions=(('theyHaveMaterial',bs.getSharedObject('objectMaterial')),'or',
                        ('theyDontHaveMaterial',bs.getSharedObject('footingMaterial'))),
            actions=(('modifyPartCollision','collide',False),
                     ('modifyPartCollision','physical',False)))


        self._ballMaterial = bs.Material()
        self._ballMaterial.addActions(actions=( ("modifyPartCollision","friction",0.75)))
        self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('pickupMaterial')),
                                      actions=( ("modifyPartCollision","collide",False) ) )
        self._ballMaterial.addActions(conditions=( ("weAreYoungerThan",100),'and',
                                                 ("theyHaveMaterial",bs.getSharedObject('objectMaterial')) ),
                                      actions=( ("modifyNodeCollision","collide",False) ) )
        self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')),
                                      actions=(("impactSound",self._ballSound,2,0.8)))
        # keep track of which player last touched the ball
        self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                      actions=(("call","atConnect",self._handleBallPlayerCollide),))
        # we want the ball to kill powerups; not get stopped by them
        self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.Powerup.getFactory().powerupMaterial),
                                      actions=(("modifyPartCollision","physical",False),
                                               ("message","theirNode","atConnect",bs.DieMessage())))

        self._scoreRegionMaterial = bs.Material()
        self._scoreRegionMaterial.addActions(conditions=("theyHaveMaterial",self._ballMaterial),
                                             actions=(("modifyPartCollision","collide",True),
                                                      ("modifyPartCollision","physical",False),
                                                      ("call","atConnect",self._handleScore)))
    def __init__(self):
        """
        Instantiate a PowerupFactory.
        You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance.
        """

        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")

        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texHiJump = bs.getTexture("buttonJump")
        self.texInvisibility = bs.getTexture("bonesIcon")
        self.texStar = bs.getTexture("achievementSuperPunch")
        self.textbomb = bs.getTexture("achievementOnslaught")
        self.texweedbomb = bs.getTexture("achievementOffYouGo")
        self.texgluebomb = bs.getTexture("eggTex2")

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
Exemplo n.º 13
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()
        self._teamFinishPts = 100

        # throw a timer up on-screen
        self._timeText = bs.NodeActor(
            bs.newNode(
                'text',
                attrs={'vAttach': 'top', 'hAttach': 'center',
                       'hAlign': 'center', 'color': (1, 1, 0.5, 1),
                       'flatness': 0.5, 'shadow': 0.5, 'position': (0, -50),
                       'scale': 1.4, 'text': ''}))
        self._timer = bs.OnScreenTimer()

        if self.settings['Mine Spawning'] != 0:
            self._raceMines = [
                {'point': p, 'mine': None}
                for p in self.getMap().getDefPoints('raceMine')]
            if len(self._raceMines) > 0:
                self._raceMineTimer = bs.Timer(
                    self.settings['Mine Spawning'],
                    self._updateRaceMine, repeat=True)

        self._scoreBoardTimer = bs.Timer(
            250, self._updateScoreBoard, repeat=True)
        self._playerOrderUpdateTimer = bs.Timer(
            250, self._updatePlayerOrder, repeat=True)

        if self._isSlowMotion:
            tScale = 0.4
            lightY = 50
        else:
            tScale = 1.0
            lightY = 150
        lStart = int(7100*tScale)
        inc = int(1250*tScale)

        bs.gameTimer(lStart, self._doLight1)
        bs.gameTimer(lStart+inc, self._doLight2)
        bs.gameTimer(lStart+2*inc, self._doLight3)
        bs.gameTimer(lStart+3*inc, self._startRace)

        self._startLights = []
        for i in range(4):
            l = bs.newNode('image',
                           attrs={'texture': bs.getTexture('nub'),
                                  'opacity': 1.0,
                                  'absoluteScale': True,
                                  'position': (-75+i*50, lightY),
                                  'scale': (50, 50),
                                  'attach': 'center'})
            bs.animate(
                l, 'opacity',
                {4000 * tScale: 0, 5000 * tScale: 1.0, 12000 * tScale: 1.0,
                 12500 * tScale: 0.0})
            bs.gameTimer(int(13000*tScale), l.delete)
            self._startLights.append(l)

        self._startLights[0].color = (0.2, 0, 0)
        self._startLights[1].color = (0.2, 0, 0)
        self._startLights[2].color = (0.2, 0.05, 0)
        self._startLights[3].color = (0.0, 0.3, 0)
Exemplo n.º 14
0
    def __init__(self,
                 position=(0, 1, 0),
                 velocity=(0, 0, 0),
                 bombType='normal',
                 blastRadius=2,
                 sourcePlayer=None,
                 owner=None):
        if not sourcePlayer.isAlive(): return
        bs.Actor.__init__(self)
        factory = self.getFactory()
        if not bombType in ('ice', 'impact', 'landMine', 'normal', 'sticky',
                            'tnt'):
            raise Exception("invalid bomb type: " + bombType)
        self.bombType = bombType
        self._exploded = False
        self.blastRadius = blastRadius
        self._explodeCallbacks = []
        self.sourcePlayer = sourcePlayer
        self.hitType = 'explosion'
        self.hitSubType = self.bombType
        if owner is None: owner = bs.Node(None)
        self.owner = owner
        materials = (factory.bombMaterial,
                     bs.getSharedObject('objectMaterial'))
        materials = materials + (factory.impactBlastMaterial, )
        players = self.getActivity().players
        i = 0
        # This gives each player a unique orb color, made possible by the powerup textures within the game.
        while players[i] != sourcePlayer:
            i += 1
        color = ("powerupIceBombs", "powerupPunch", "powerupStickyBombs",
                 "powerupBomb", "powerupCurse", "powerupHealth",
                 "powerupShield", "powerupLandMines")[i]
        if isinstance(
                self.getActivity().getSession(), bs.TeamsSession
        ):  # unless we're on teams, so we'll overide the color to be the team's color
            if sourcePlayer in self.getActivity().teams[0].players:
                color = "powerupIceBombs"  # for blue
            else:
                color = "powerupPunch"  # for red
        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'position': position,
                                   'velocity': velocity,
                                   'body': 'sphere',
                                   'model': bs.getModel("shield"),
                                   'shadowSize': 0.3,
                                   'density': 1,
                                   'bodyScale': 3,
                                   'colorTexture': bs.getTexture(color),
                                   'reflection': 'soft',
                                   'reflectionScale': [1.5],
                                   'materials': materials
                               })
        self.armTimer = bs.Timer(200,
                                 bs.WeakCall(self.handleMessage, ArmMessage()))
        self.node.addDeathAction(
            bs.WeakCall(self.handleMessage, _BombDiedMessage()))

        bsUtils.animate(self.node, "modelScale", {0: 0, 200: 1.3, 260: 1})
Exemplo n.º 15
0
 def path():
     p = bs.newNode('prop',
                    attrs={
                        'position': (6, 2.0, 2),
                        'velocity': (2.0, 0.8, 0),
                        'sticky':
                        False,
                        'body':
                        'landMine',
                        'model':
                        bs.getModel('landMine'),
                        'colorTexture':
                        bs.getTexture('achievementWall'),
                        'bodyScale':
                        1.0,
                        'reflection':
                        'powerup',
                        'density':
                        9999999999999999,
                        'reflectionScale': [1.0],
                        'modelScale':
                        1.0,
                        'gravityScale':
                        0,
                        'shadowSize':
                        0.0,
                        'materials': [
                            bs.getSharedObject('objectMaterial'),
                            bs.getSharedObject('footingMaterial')
                        ]
                    })
     bs.gameTimer(4000, p.delete)
     p = bs.newNode('prop',
                    attrs={
                        'position': (6, 2.0, -2),
                        'velocity': (2.0, 0.8, 0),
                        'sticky':
                        False,
                        'body':
                        'landMine',
                        'model':
                        bs.getModel('landMine'),
                        'colorTexture':
                        bs.getTexture('achievementWall'),
                        'bodyScale':
                        1.0,
                        'reflection':
                        'powerup',
                        'density':
                        9999999999999999,
                        'reflectionScale': [1.0],
                        'modelScale':
                        1.0,
                        'gravityScale':
                        0,
                        'shadowSize':
                        0.0,
                        'materials': [
                            bs.getSharedObject('objectMaterial'),
                            bs.getSharedObject('footingMaterial')
                        ]
                    })
     bs.gameTimer(4000, p.delete)
Exemplo n.º 16
0
    def __init__(self):
        Map.__init__(self)

        platform = bs.newNode('prop',
                              delegate=self,
                              attrs={
                                  'position': (-8.00, 0.9515026107, -2.0),
                                  'velocity': (0, 0, 0),
                                  'sticky':
                                  False,
                                  'body':
                                  'crate',
                                  'model':
                                  bs.getModel('tnt'),
                                  'density':
                                  0.00000,
                                  'colorTexture':
                                  bs.getTexture('menuBG'),
                                  'bodyScale':
                                  6.0,
                                  'reflection':
                                  'powerup',
                                  'damping':
                                  9999999999999,
                                  'reflectionScale': [0],
                                  'modelScale':
                                  6.0,
                                  'shadowSize':
                                  0.0,
                                  'materials':
                                  [bs.getSharedObject('footingMaterial')]
                              })
        platform = bs.newNode('prop',
                              delegate=self,
                              attrs={
                                  'position': (-8.00, 0.9515026107, 2.0),
                                  'velocity': (0, 0, 0),
                                  'sticky':
                                  False,
                                  'body':
                                  'crate',
                                  'model':
                                  bs.getModel('tnt'),
                                  'density':
                                  0.00000,
                                  'colorTexture':
                                  bs.getTexture('menuBG'),
                                  'bodyScale':
                                  6.0,
                                  'reflection':
                                  'powerup',
                                  'damping':
                                  9999999999999,
                                  'reflectionScale': [0],
                                  'modelScale':
                                  6.0,
                                  'shadowSize':
                                  0.0,
                                  'materials':
                                  [bs.getSharedObject('footingMaterial')]
                              })
        self.node = bs.newNode('terrain',
                               delegate=self,
                               attrs={
                                   'model':
                                   self.preloadData['model'],
                                   'collideModel':
                                   self.preloadData['collideModel'],
                                   'colorTexture':
                                   self.preloadData['tex'],
                                   'materials':
                                   [bs.getSharedObject('footingMaterial')]
                               })
        bs.newNode('terrain',
                   attrs={
                       'model': self.preloadData['vrFillModel'],
                       'lighting': False,
                       'vrOnly': True,
                       'background': True,
                       'colorTexture': self.preloadData['tex']
                   })

        def credittext():
            #bySoby
            text = bs.newNode('text',
                              attrs={
                                  'text': 'Mod By SobyDamn',
                                  'scale': 1.0,
                                  'maxWidth': 0,
                                  'position': (0, 0),
                                  'shadow': 1.0,
                                  'flatness': 0.50,
                                  'hAlign': 'center',
                                  'vAttach': 'bottom'
                              })
            bs.animate(text, 'opacity', {
                0: 0.0,
                500: 1.0,
                10500: 1.0,
                11000: 0.0
            })
            bs.gameTimer(11500, text.delete)

        bs.gameTimer(2000, bs.Call(credittext))

        def path():
            p = bs.newNode('prop',
                           attrs={
                               'position': (-5.750, 4.3515026107, -2.0),
                               'velocity': (2.0, 1.0, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('achievementWall'),
                               'bodyScale':
                               1.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [1.0],
                               'modelScale':
                               1.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(3000, p.delete)
            p = bs.newNode('prop',
                           attrs={
                               'position': (-5.750, 4.3515026107, 2.0),
                               'velocity': (2.0, 1.0, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('achievementWall'),
                               'bodyScale':
                               1.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [1.0],
                               'modelScale':
                               1.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(3000, p.delete)

        bs.gameTimer(600, bs.Call(path), repeat=True)

        def platform():
            p = bs.newNode('prop',
                           attrs={
                               'position': (0, 2, -2),
                               'velocity': (0, 0, 1),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('achievementWall'),
                               'bodyScale':
                               5.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [1.0],
                               'modelScale':
                               5.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(7000, p.delete)
            p = bs.newNode('prop',
                           attrs={
                               'position': (0, 1, 2),
                               'velocity': (2.0, 0.1, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('eggTex2'),
                               'bodyScale':
                               4.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [0.0],
                               'modelScale':
                               4.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(4000, p.delete)
            p = bs.newNode('prop',
                           attrs={
                               'position': (0, 1, -1.5),
                               'velocity': (2.0, 0.1, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('eggTex2'),
                               'bodyScale':
                               4.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [0.0],
                               'modelScale':
                               4.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(4000, p.delete)

        bs.gameTimer(200, bs.Call(platform))
        bs.gameTimer(5000, bs.Call(platform), repeat=True)

        def path():
            p = bs.newNode('prop',
                           attrs={
                               'position': (6, 2.0, 2),
                               'velocity': (2.0, 0.8, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('achievementWall'),
                               'bodyScale':
                               1.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [1.0],
                               'modelScale':
                               1.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(4000, p.delete)
            p = bs.newNode('prop',
                           attrs={
                               'position': (6, 2.0, -2),
                               'velocity': (2.0, 0.8, 0),
                               'sticky':
                               False,
                               'body':
                               'landMine',
                               'model':
                               bs.getModel('landMine'),
                               'colorTexture':
                               bs.getTexture('achievementWall'),
                               'bodyScale':
                               1.0,
                               'reflection':
                               'powerup',
                               'density':
                               9999999999999999,
                               'reflectionScale': [1.0],
                               'modelScale':
                               1.0,
                               'gravityScale':
                               0,
                               'shadowSize':
                               0.0,
                               'materials': [
                                   bs.getSharedObject('objectMaterial'),
                                   bs.getSharedObject('footingMaterial')
                               ]
                           })
            bs.gameTimer(4000, p.delete)

        bs.gameTimer(600, bs.Call(path), repeat=True)
        g = bs.getSharedObject('globals')
        g.tint = (1.3, 1.2, 1.0)
        g.ambientColor = (1.3, 1.2, 1.0)
        g.vignetteOuter = (0.57, 0.57, 0.57)
        g.vignetteInner = (0.9, 0.9, 0.9)
        g.vrCameraOffset = (0, -0.8, -1.1)
        g.vrNearClip = 0.5
Exemplo n.º 17
0
    def __init__(self):
        """
        Instantiate a PowerupFactory.
        You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance.
        """

        self._lastPowerupType = None

        self.model = bs.getModel("powerup")
        self.modelSimple = bs.getModel("powerupSimple")
        self.texSpeed = bs.getTexture("achievementGotTheMoves")
        self.texBomb = bs.getTexture("powerupBomb")
        self.texPunch = bs.getTexture("powerupPunch")
        self.texIceBombs = bs.getTexture("powerupIceBombs")
        self.texStickyBombs = bs.getTexture("powerupStickyBombs")
        self.texAtomBombs = bs.getTexture('eggTex')
        self.texShield = bs.getTexture("powerupShield")
        self.texImpactBombs = bs.getTexture("powerupImpactBombs")
        self.texHealth = bs.getTexture("powerupHealth")
        self.texLandMines = bs.getTexture("powerupLandMines")
        self.texCurse = bs.getTexture("powerupCurse")
        self.texIvincible = bs.getTexture("achievementFlawlessVictory")
        self.texLuckyBlock = bs.getTexture("achievementEmpty")
        self.shockWaveTex = bs.getTexture("medalGold")
        self.texEgg = bs.getTexture('eggTex2')
        self.texSno = bs.getTexture(
            "bunnyColor")  #Bunny is most uniform plain white color.
        self.snoModel = bs.getModel("frostyPelvis")
        self.texSlow = bs.getTexture('coin')
        self.texNight = bs.getTexture('empty')
        self.inv = bs.getTexture('rock')

        self.healthPowerupSound = bs.getSound("healthPowerup")
        self.powerupSound = bs.getSound("powerup01")
        self.powerdownSound = bs.getSound("powerdown01")
        self.dropSound = bs.getSound("boxDrop")

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('pickupMaterial')),
            actions=(("modifyPartCollision", "collide", False)))

        self.powerupMaterial.addActions(
            conditions=("theyHaveMaterial",
                        bs.getSharedObject('footingMaterial')),
            actions=(("impactSound", self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)
Exemplo n.º 18
0
 def getIconTexture(self, complete):
     return bs.getTexture(
         self._iconName if complete else 'achievementEmpty')
Exemplo n.º 19
0
    def __init__(self):
        """
        Instantiate a PowerupFactory.
        You shouldn't need to do this; call bs.Powerup.getFactory()
        to get a shared instance.
        """
        self._lastPowerupType = None

        self.model = bs.getModel('powerup')
        self.modelSimple = bs.getModel('powerupSimple')
        self.snoModel = bs.getModel('frostyPelvis')

        self.texBomb = bs.getTexture('powerupBomb')
        self.texPunch = bs.getTexture('powerupPunch')
        self.texIceBombs = bs.getTexture('powerupIceBombs')
        self.texStickyBombs = bs.getTexture('powerupStickyBombs')
        self.texShield = bs.getTexture('powerupShield')
        self.texImpactBombs = bs.getTexture('powerupImpactBombs')
        self.texHealth = bs.getTexture('powerupHealth')
        self.texLandMines = bs.getTexture('powerupLandMines')
        self.texCurse = bs.getTexture('powerupCurse')
        self.texLuckyBlock = bs.getTexture('powerupLuckyBlock')
        self.texExtraAccelerator = bs.getTexture('powerupExtraAccelerator')
        self.texStickyForce = bs.getTexture('powerupStickyForce')
        self.texDirt = bs.getTexture('powerupDirt')
        self.texSpeed = bs.getTexture('powerupSpeed')
        self.texLego = bs.getTexture('powerupLego')
        self.texCannon = bs.getTexture('powerupCannon')
        self.textoxic = bs.getTexture('powerupToxic')
        self.texPoison = bs.getTexture('powerupPoison')
        self.texSlipper = bs.getTexture('powerupSlipper')
        self.texArtillery = bs.getTexture('powerupArtillery')
        self.texHealthBomb = bs.getTexture('powerupHealthBomb')
        self.texBanana = bs.getTexture('powerupBanana')
        self.shockWaveTex = bs.getTexture('powerupShockwave')
        self.texMolotov = bs.getTexture('powerupMolotov')
        self.texPetard = bs.getTexture('powerupPetard')
        self.texHolyBomb = bs.getTexture('powerupHolyBomb')
        self.texPortalBomb = bs.getTexture('powerupPortalBomb')
        self.texElonMuskMine = bs.getTexture('powerupElonMine')
        self.texAirstrike = bs.getTexture('powerupAirstrike')
        self.texColorBomb = bs.getTexture('powerupPaintBomb')
        self.texHighJump = bs.getTexture('powerupJump')
        self.texBot = bs.getTexture('neoSpazIcon')
        self.texSno = bs.getTexture('bunnyColor')
        self.texBlessing = bs.getTexture('powerupBlessing')
        self.texRailgun = bs.getTexture('powerupRailgun')

        self.healthPowerupSound = bs.getSound('healthPowerup')
        self.powerupSound = bs.getSound('powerup01')
        self.powerdownSound = bs.getSound('powerdown01')
        self.dropSound = bs.getSound('boxDrop')

        # material for powerups
        self.powerupMaterial = bs.Material()

        # material for anyone wanting to accept powerups
        self.powerupAcceptMaterial = bs.Material()

        # pass a powerup-touched message to applicable stuff
        self.powerupMaterial.addActions(
            conditions=(('theyHaveMaterial', self.powerupAcceptMaterial)),
            actions=(('modifyPartCollision', 'collide',
                      True), ('modifyPartCollision', 'physical', False),
                     ('message', 'ourNode', 'atConnect', _TouchedMessage())))

        # we dont wanna be picked up
        self.powerupMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('pickupMaterial')),
            actions=(('modifyPartCollision', 'collide', False)))

        self.powerupMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('footingMaterial')),
            actions=(('impactSound', self.dropSound, 0.5, 0.1)))

        self._powerupDist = []
        for p, freq in getDefaultPowerupDistribution():
            for i in range(int(freq)):
                self._powerupDist.append(p)