Esempio n. 1
0
    def __init__(self, vPos, player, lobby):

        import bsInternal

        self._deekSound = bs.getSound('deek')
        self._clickSound = bs.getSound('click01')
        self._punchSound = bs.getSound('punch01')
        self._swishSound = bs.getSound('punchSwish')
        self._errorSound = bs.getSound('error')
        self._maskTexture = bs.getTexture('characterIconMask')
        self._vPos = vPos
        self._lobby = weakref.ref(lobby)
        self._player = player
        self._inited = False
        self._dead = False

        # load available profiles either from the local config or from the remote device..
        self.reloadProfiles()

        # note: this is just our local index out of available teams; *not* the team ID!
        self._selectedTeamIndex = self.getLobby().nextAddTeam

        # store a persistent random character index; we'll use this for the '_random' profile
        # lets use their inputDevice id to seed it.. this will give a persistent character
        # for them between games and will distribute characters nicely if everyone is random
        try:
            inputDeviceID = self._player.getInputDevice().getID()
        except Exception, e:
            print 'ERROR: exception getting inputDeviceID for lobby-chooser creation:', e
            inputDeviceID = 0
            import traceback
            traceback.print_stack()
Esempio n. 2
0
    def __init__(self, data):
        self._width = 350
        self._height = 200
        self._rootWidget = bs.containerWidget(
            size=(self._width, self._height),
            color=(0.45, 0.63, 0.15),
            transition='inScale',
            scale=1.8 if bsUI.gSmallUI else 1.35 if bsUI.gMedUI else 1.0)
        self._data = copy.deepcopy(data)
        bs.playSound(bs.getSound('cashRegister'))
        bs.playSound(bs.getSound('swish'))

        self._cancelButton = bs.buttonWidget(parent=self._rootWidget,
                                             scale=0.5,
                                             position=(40, self._height - 40),
                                             size=(50, 50),
                                             label='',
                                             onActivateCall=self.close,
                                             autoSelect=True,
                                             color=(0.45, 0.63, 0.15),
                                             icon=bs.getTexture('crossOut'),
                                             iconScale=1.2)
        bs.containerWidget(edit=self._rootWidget,
                           cancelButton=self._cancelButton)

        t = bs.textWidget(parent=self._rootWidget,
                          position=(self._width * 0.5, self._height * 0.5),
                          size=(0, 0),
                          color=(1.0, 3.0, 1.0),
                          scale=2.0,
                          hAlign="center",
                          vAlign="center",
                          text=data['code'],
                          maxWidth=self._width * 0.85)
Esempio n. 3
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        if self.settings['Epic Mode']: self._isSlowMotion = True

        # print messages when players die since it matters here..
        self.announcePlayerDeaths = True
        
        self._scoreBoard = bs.ScoreBoard()
        self._swipSound = bs.getSound("swip")
        self._tickSound = bs.getSound('tick')
        
        self._scoreToWin = self.settings['Capsules to Collect']
        
        self._capsuleModel = bs.getModel('bomb')
        self._capsuleTex = bs.getTexture('bombColor')
        self._capsuleLuckyTex = bs.getTexture('bombStickyColor')
        
        self._collectSound = bs.getSound('powerup01')
        self._luckyCollectSound = bs.getSound('cashRegister2')
        
        self._capsuleMaterial = bs.Material()
        self._capsuleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                     actions=(("call","atConnect",self._onCapsulePlayerCollide),))
        self._capsules = []
        
        self._flagRegionMaterial = bs.Material()
        self._flagRegionMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')),
                                            actions=(("modifyPartCollision","collide",True),
                                                     ("modifyPartCollision","physical",False),
                                                     ("call","atConnect",bs.Call(self._handlePlayerFlagRegionCollide,1)),
                                                     ("call","atDisconnect",bs.Call(self._handlePlayerFlagRegionCollide,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.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)
	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
Esempio n. 6
0
    def onTransitionIn(self):
        bs.TeamGameActivity.onTransitionIn(
            self, music='Epic Race' if self.settings['Epic Mode'] else 'Race')

        self._nubTex = bs.getTexture('nub')
        self._beep1Sound = bs.getSound('raceBeep1')
        self._beep2Sound = bs.getSound('raceBeep2')
Esempio n. 7
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")
        # Add for Bunnybot:
        self.eggModel = bs.getModel('egg')
        self.texEgg = bs.getTexture('eggTex1')
        # Add for snoBalls:
        self.texSno = bs.getTexture(
            "bunnyColor")  # Bunny is most uniform plain white color.
        self.snoModel = bs.getModel(
            "frostyPelvis")  # Frosty pelvis is very nice and round...
        # Add for randomDoor:
        self.texDoor = bs.getTexture("cyborgColor")
        self.doorModel = bs.getModel("frostyPelvis")

        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)
Esempio n. 8
0
def _preload3():

    for m in ["bomb","bombSticky","impactBomb"]: bs.getModel(m)
    for t in ["bombColor","bombColorIce","bombStickyColor",
              "impactBombColor","impactBombColorLit"]: bs.getTexture(t)
    for s in ["freeze","fuse01","activateBeep","warnBeep"]: bs.getSound(s)

    spazFactory = bs.Spaz.getFactory()

    # go through and load our existing spazzes
    # (spread these out quite a bit)
    def _load(spaz):
        spazFactory._preload(spaz)
        # icons also..
        bs.getTexture(bsSpaz.appearances[spaz].iconTexture)
        bs.getTexture(bsSpaz.appearances[spaz].iconMaskTexture)

    # FIXME - need to come up with a standin texture mechanism or something
    # ..preloading won't scale too much farther..
    t = 50
    # for spaz in bsSpaz.appearances:
    #     bs.gameTimer(t,bs.Call(_load,spaz))
    #     t += 100

    bs.gameTimer(200,_preload4)
def adminKick(self, popupWindow, choice):
    def getIndex():
        for i in bsInternal._getGameRoster():
            if i["clientID"] == self._popupPartyMemberClientID:
                return bsInternal._getGameRoster().index(i)

    if choice == "kick":
        if self._popupPartyMemberIsHost:
            bs.playSound(bs.getSound('error'))
            bs.screenMessage(bs.Lstr(resource='internal.cantKickHostError'),
                             color=(1, 0, 0))
        else:
            print self._popupPartyMemberClientID
            result = bsInternal._disconnectClient(
                self._popupPartyMemberClientID)
            if not result:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='getTicketsWindow.unavailableText'),
                    color=(1, 0, 0))
    else:
        f = open(bs.getEnvironment()['userScriptsDirectory'] + "/ban.txt", 'a')
        for i in bsInternal._getGameRoster():
            cid = i['clientID']
            if cid == self._popupPartyMemberClientID:
                bsInternal._chatMessage("/kick " + str(cid))
                f.write(i['players'][0]['nameFull'] + '  -  ' +
                        eval(bsInternal._getGameRoster()[getIndex()]
                             ["specString"])["n"] + '\n')
        bs.textWidget(edit=self._textField, text='')
Esempio n. 10
0
    def __init__(self,settings={}):

        try: self._preset = settings['preset']
        except Exception: self._preset = 'training'

        if self._preset in ['training','trainingEasy','pro','proEasy','endless','endlessTournament']: settings['map'] = 'Doom Shroom'
        else: settings['map'] = 'Courtyard'

        bs.CoopGameActivity.__init__(self,settings)

        # show messages when players die since it matters here..
        self.announcePlayerDeaths = True
        
        self._newWaveSound = bs.getSound('scoreHit01')
        self._winSound = bs.getSound("score")
        self._cashRegisterSound = bs.getSound('cashRegister')
        self._aPlayerHasBeenHurt = False
        self._playerHasDroppedBomb = False

        # fixme - should use standard map defs..
        if settings['map'] == 'Doom Shroom':
            self._spawnCenter = (0,3,-5)
            self._tntSpawnPosition = (0,3,-5)
            self._powerupCenter = (0,5,-3.6)
            self._powerupSpread = (6,4)
        elif settings['map'] == 'Courtyard':
            self._spawnCenter = (0,3,-2)
            self._tntSpawnPosition = (0,3,2.1)
            self._powerupCenter = (0,5,-1.6)
            self._powerupSpread = (4.6,2.7)
        else: raise Exception("Unsupported map: "+str(settings['map']))
Esempio n. 11
0
 def __init__(self, settings):
     self._raceStarted = False
     bs.TeamGameActivity.__init__(self, settings)
     self._scoreBoard = bs.ScoreBoard()
     if self.settings['Epic Mode']: self._isSlowMotion = True
     self._scoreSound = bs.getSound("score")
     self._swipSound = bs.getSound("swip")
     self._lastTeamTime = None
     self._frontRaceRegion = None
Esempio n. 12
0
def _preload4():
    for t in ['bar', 'meter', 'null', 'flagColor', 'achievementOutline']:
        bs.getTexture(t)
    for m in ['frameInset', 'meterTransparent', 'achievementOutline']:
        bs.getModel(m)
    for s in ['metalHit', 'metalSkid', 'refWhistle', 'achievement']:
        bs.getSound(s)
    bs.Flag.getFactory()
    bs.Powerup.getFactory()
    def onTransitionIn(self):

        bs.CoopGameActivity.onTransitionIn(self)

        # show special landmine tip on rookie preset
        if self._preset in ['rookie', 'rookieEasy']:
            # show once per session only (then we revert to regular tips)
            if not hasattr(bs.getSession(), '_gShowedOnslaughtLandMineTip'):
                bs.getSession()._gShowedOnslaughtLandMineTip = True
                self.tips = [
                    {'tip': "Land-mines are a good way to stop speedy enemies.",
                     'icon': bs.getTexture('powerupLandMines'),
                     'sound': bs.getSound('ding')}]

        # show special tnt tip on pro preset
        if self._preset in ['pro', 'proEasy']:
            # show once per session only (then we revert to regular tips)
            if not hasattr(bs.getSession(), '_gShowedOnslaughtTntTip'):
                bs.getSession()._gShowedOnslaughtTntTip = True
                self.tips = [{
                    'tip':
                    "Take out a group of enemies by\nsetting"
                    " off a bomb near a TNT box.",
                    'icon': bs.getTexture('tnt'),
                    'sound': bs.getSound('ding')}]

        # show special curse tip on uber preset
        if self._preset in ['uber', 'uberEasy']:
            # show once per session only (then we revert to regular tips)
            if not hasattr(bs.getSession(), '_gShowedOnslaughtCurseTip'):
                bs.getSession()._gShowedOnslaughtCurseTip = True
                self.tips = [{
                    'tip':
                    "Curse boxes turn you into a ticking time bomb.\n"
                    "The only cure is to quickly grab a health-pack.",
                    'icon': bs.getTexture('powerupCurse'),
                    'sound': bs.getSound('ding')}]

        self._spawnInfoText = bs.NodeActor(
            bs.newNode(
                "text",
                attrs={'position': (15, -130),
                       'hAttach': "left", 'vAttach': "top", 'scale': 0.55,
                       'color': (0.3, 0.8, 0.3, 1.0),
                       'text': ''}))
        bs.playMusic('Onslaught')

        self._scoreBoard = bs.ScoreBoard(
            label=bs.Lstr(resource='scoreText'),
            scoreSplit=0.5)
        self._gameOver = False
        self._wave = 0
        self._canEndWave = True
        # we use this in place of a regular int to make it harder to hack scores
        self._score = bs.SecureInt(0)
        self._timeBonus = 0
Esempio n. 14
0
 def __init__(self, settings):
     bs.TeamGameActivity.__init__(self, settings)
     self._scoreBoard = bs.ScoreBoard()
     if self.settings['Epic Mode']: self._isSlowMotion = True
     self._alarmSound = bs.getSound("alarm")
     self._tickingSound = bs.getSound("ticking")
     self._lastScoreTime = 0
     self._scoreSound = bs.getSound("score")
     self._swipSound = bs.getSound("swip")
     self._allBasesMaterial = bs.Material()
 def continueFoulShots(self, baller):
     if self.basketball.node.exists(): self.basketball.node.delete()
     self.firstFoul = False
     baller.actor.node.handleMessage('stand', 0, 3.2, -3, 0)
     self.respawnBall(None)
     bs.playSound(bs.getSound('announceOne'))
     baller.actor.onPickUpPress()
     baller.actor.onPickUpRelease()
     bs.playSound(bs.getSound('bear1'))
     baller.actor.setScoreText("5 seconds to shoot")
     bs.gameTimer(6000, bs.Call(self.continuePlay, baller))
Esempio n. 16
0
def _preload2():
    # FIXME - could integrate these loads with the classes that use them
    # so they don't have to redundantly call the load
    # (even if the actual result is cached)
    for m in ["powerup", "powerupSimple"]: bs.getModel(m)
    for t in ["powerupBomb", "powerupSpeed", "powerupPunch",
              "powerupIceBombs", "powerupStickyBombs", "powerupShield",
              "powerupImpactBombs", "powerupHealth"]: bs.getTexture(t)
    for s in ["powerup01", "boxDrop", "boxingBell", "scoreHit01",
              "scoreHit02", "dripity", "spawn", "gong"]: bs.getSound(s)
    bs.Bomb.getFactory()
    bs.gameTimer(100,_preload3)
Esempio n. 17
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        if self.settings['Epic Mode']: self._isSlowMotion = True
        self._scoreBoard = bs.ScoreBoard()
        self._scoreSound = bs.getSound('score')
        self._swipSound = bs.getSound('swip')

        self._extraFlagMaterial = bs.Material()

        # we want flags to tell us they've been hit but not react physically
        self._extraFlagMaterial.addActions(conditions=('theyHaveMaterial',bs.getSharedObject('playerMaterial')),
                                           actions=(('modifyPartCollision','collide',True),
                                                    ('call','atConnect',self._handleFlagPlayerCollide)))
Esempio n. 18
0
 def handleShot(self, ball):
     if ball.node.position[0] > -1.5 and ball.node.position[0] < 1.5:
         if ball.node.position[1] > 4 and ball.node.position[1] < 5:
             if ball.node.position[2] > -9 and ball.node.position[2] < -8:
                 if self.isTendingGoal(ball):
                     ball.node.delete()
                     self.respawnBall(not self.possession)
                     bs.playSound(bs.getSound('bearDeath'))
                     ball.heldLast.actor.shatter()
                     return
                 bs.playSound(
                     bs.getSound('bear' + str(random.randint(1, 4))))
                 for node in self.hoop._nodes:
                     node.delete()
                 self.hoop = None
                 if not self.fouled:
                     if self.possession:
                         pts = self.checkThreePoint(ball)
                         self.teams[0].gameData['score'] += pts
                         ball.heldLast.actor.setScoreText(
                             str(pts) + " Points")
                         self.hoop = Hoop((0, 5, -8), (0, 0, 1))
                         for player in self.teams[0].players:
                             player.actor.node.handleMessage(
                                 'stand', -6.5, 3.2,
                                 (random.random() * 5) - 4.5, 0)
                     else:
                         pts = self.checkThreePoint(ball)
                         self.teams[1].gameData['score'] += pts
                         ball.heldLast.actor.setScoreText(
                             str(pts) + " Points")
                         self.hoop = Hoop((0, 5, -8), (1, 0, 0))
                         for player in self.teams[1].players:
                             player.actor.node.handleMessage(
                                 'stand', 6.5, 3.2,
                                 (random.random() * 5) - 4.5, 0)
                     self.updateScore()
                     ball.node.delete()
                     self.respawnBall(not self.possession)
                 else:
                     if self.possession:
                         self.hoop = Hoop((0, 5, -8), (0, 0, 1))
                         self.teams[0].gameData['score'] += 1
                     else:
                         self.hoop = Hoop((0, 5, -8), (1, 0, 0))
                         self.teams[1].gameData['score'] += 1
                     ball.heldLast.actor.setScoreText("1 Point")
                     self.updateScore()
                     ball.node.delete()
Esempio n. 19
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.scoreRegionMaterial = bs.Material()

        self.scoreRegionMaterial.addActions(
            conditions=("theyHaveMaterial", bs.Bomb.getFactory().bombMaterial),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("call", "atConnect", self._handleScore)))
    def handleMessage(self, m):
        super(self.__class__, self).handleMessage(m)

        if isinstance(m, bs.DieMessage):
            self.node.delete()
        elif isinstance(m, bs.OutOfBoundsMessage):
            self.handleMessage(bs.DieMessage())
        elif isinstance(m, bs.DroppedMessage):
            bs.gameTimer(
                200, bs.WeakCall(self.handleMessage, doorStartUseMessage()))
        elif isinstance(m, doorStartUseMessage):
            self.canUse = True
        elif isinstance(m, doorHitSpazMessage):
            if not self.canUse:
                return
            if self._used:
                return
            oppoNode = bs.getCollisionInfo("opposingNode")
            if oppoNode is not None and oppoNode.exists():
                activity = self._activity()
                pos = self.getFactory().getRandomPosition(activity)
                oppoNode.handleMessage(bs.StandMessage(pos))
                bs.Blast(position=pos, blastRadius=1.0,
                         blastType='smoke').autoRetain()
                bs.playSound(bs.getSound('shieldDown'))

            self._disappear()
 def giveFoulShots(self, baller):
     for p in self.players:
         p.actor.disconnectControlsFromPlayer()
         if p in self.teams[0].players and p != baller:
             p.actor.node.handleMessage('stand', -6.5, 3.2,
                                        (random.random() * 5) - 4.5, 0)
         if p in self.teams[1].players and p != baller:
             p.actor.node.handleMessage('stand', 6.5, 3.2,
                                        (random.random() * 5) - 4.5, 0)
     self.spawnPlayerSpaz(baller, fouled=True)
     s = self.settings
     baller.actor.connectControlsToPlayer(enableBomb=False,
                                          enableRun=s["Enable Running"],
                                          enableJump=s["Enable Jumping"],
                                          enablePunch=False)
     self.firstFoul = True
     self.basketball.node.delete()
     self.respawnBall(None)
     sound = bs.getSound('announceTwo')
     bs.gameTimer(1000, bs.Call(bs.playSound, sound))
     baller.actor.node.handleMessage('stand', 0, 3.2, -3, 0)
     baller.actor.onPickUpPress()
     baller.actor.onPickUpRelease()
     baller.actor.setScoreText("5 seconds to shoot")
     bs.gameTimer(6000, bs.Call(self.continueFoulShots, baller))
    def __init__(self):

        self.texColor = bs.getTexture("cyborgColor")
        self.doorModel = bs.getModel("frostyPelvis")
        self.ballMaterial = bs.Material()
        self.impactSound = bs.getSound('impactMedium')
        self.ballMaterial.addActions(
            conditions=((('weAreYoungerThan', 5), 'or', ('theyAreYoungerThan',
                                                         100)), 'and',
                        ('theyHaveMaterial',
                         bs.getSharedObject('objectMaterial'))),
            actions=(('modifyNodeCollision', 'collide', False)))
        self.ballMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('pickupMaterial')),
            actions=(('modifyPartCollision', 'useNodeCollide', False)))
        self.ballMaterial.addActions(actions=('modifyPartCollision',
                                              'friction', 0.3))
        self.ballMaterial.addActions(
            conditions=('theyHaveMaterial',
                        bs.getSharedObject('playerMaterial')),
            actions=(('modifyPartCollision', 'physical',
                      False), ('message', 'ourNode', 'atConnect',
                               doorHitSpazMessage())))

        self.defaultBallTimeout = 300
        self._autoDisappear = True
        self.positionSpan = None
Esempio n. 23
0
    def onBegin(self):

        bs.CoopGameActivity.onBegin(self)

        # spit out a few powerups and start dropping more shortly
        self._dropPowerups(standardPoints=True)
        bs.gameTimer(2000,bs.WeakCall(self._startPowerupDrops))
        bs.gameTimer(1,bs.WeakCall(self._startBotUpdates))
        self.setupLowLifeWarningSound()
        self._updateScores()
        self._bots = bs.BotSet()
        self._dingSound = bs.getSound('dingSmall')
        self._dingSoundHigh = bs.getSound('dingSmallHigh')

        # our TNT spawner (if applicable)
        self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition,respawnTime=10000)
    def handleMessage(self, m):
        if isinstance(m, bs.DieMessage):
            if self.node is not None and self.node.exists():
                bs.playSound(bs.getSound('shatter'),
                             position=self.node.position)
                bs.emitBGDynamics(position=self.node.position,
                                  velocity=(0, 4, 0),
                                  count=14,
                                  scale=0.8,
                                  chunkType='spark',
                                  spread=1.5)
            self.node.delete()
            self.bodyNode.delete()

        elif isinstance(m, bs.OutOfBoundsMessage):
            self.node.delete()
            self.bodyNode.delete()

        elif isinstance(m, bs.HitMessage):
            self.node.handleMessage("impulse", m.pos[0], m.pos[1], m.pos[2],
                                    m.velocity[0], m.velocity[1],
                                    m.velocity[2], 1.0 * m.magnitude,
                                    1.0 * m.velocityMagnitude, m.radius, 0,
                                    m.forceDirection[0], m.forceDirection[1],
                                    m.forceDirection[2])

        else:
            bs.Actor.handleMessage(self, m)
Esempio n. 25
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()
        if len(self.teams) > 0:
            self._scoreToWin = self.settings['Capsules to Collect'] * max(1,max(len(t.players) for t in self.teams))
        else: self._scoreToWin = self.settings['Capsules to Collect']
        self._updateScoreBoard()
        self._dingSound = bs.getSound('dingSmall')
        if isinstance(bs.getActivity().getSession(),bs.FreeForAllSession):
            self._flagNumber = random.randint(0,1)
            self._flagPos = self.getMap().getFlagPosition(self._flagNumber)
        else: self._flagPos = self.getMap().getFlagPosition(None)
        bs.gameTimer(1000,self._tick,repeat=True)
        self._flagState = self.FLAG_NEW
        self.projectFlagStand(self._flagPos)

        self._flag = bs.Flag(position=self._flagPos,
                             touchable=False,
                             color=(1,1,1))
        self._flagLight = bs.newNode('light',
                                     attrs={'position':self._flagPos,
                                            'intensity':0.2,
                                            'heightAttenuated':False,
                                            'radius':0.4,
                                            'color':(0.2,0.2,0.2)})

        # flag region
        bs.newNode('region',
                   attrs={'position':self._flagPos,
                          'scale': (1.8,1.8,1.8),
                          'type': 'sphere',
                          'materials':[self._flagRegionMaterial,bs.getSharedObject('regionMaterial')]})
        self._updateFlagState()
Esempio n. 26
0
 def givePowers(self):
     for player in self.players:
         if not player.actor is None:
             if player.actor.isAlive():
                 #This teleport the player
                 if player.actor.landMineCount == 1:
                     pos = self.getMap().getFFAStartPosition(self.players)
                     player.actor.handleMessage(bs.StandMessage(pos))
                     bs.Blast(position=pos,
                              blastRadius=1.0,
                              blastType='smoke').autoRetain()
                     bs.playSound(bs.getSound('shieldDown'))
                     player.actor.landMineCount = 0
                 #The player will be fly with the explosions
                 elif player.actor.landMineCount == 2:
                     pos = player.actor.node.position
                     bs.Blast(position=(pos[0], pos[1] - 0.5, pos[2]),
                              blastRadius=1.0,
                              blastType='smoke').autoRetain()
                     player.actor.handleMessage(bs.PowerupMessage('health'))
                     player.actor.landMineCount = 0
                 elif player.actor.landMineCount == 3:
                     mPlayer = player.actor
                     self.freezeAll(mPlayer)
                     player.actor.landMineCount = 0
Esempio n. 27
0
 def a():
     self.zone.delete()
     self.zone = None
     self.zoneLimit.delete()
     self.zoneLimit = None
     bs.playSound(bs.getSound('shieldDown'))
     bs.gameTimer(1000, self.spawnZone)
Esempio n. 28
0
 def __init__(self, settings):
     bs.TeamGameActivity.__init__(self, settings)
     self._scoreBoard = bs.ScoreBoard()
     if self.settings['Epic Mode']:
         self._isSlowMotion = True
     self._lastScoreTime = 0
     self._scoreSound = bs.getSound("score")
Esempio n. 29
0
    def onPlayerLeave(self, player):
        bs.TeamGameActivity.onPlayerLeave(self, player)

        # a player leaving disqualifies the team if 'Entire Team Must Finish'
        # is on (otherwise in teams mode everyone could just leave except the
        # leading player to win)
        if isinstance(self.getSession(), bs.TeamsSession
                      ) and self.settings.get('Entire Team Must Finish'):
            # FIXME translate this
            bs.screenMessage(bs.Lstr(
                translate=('statements',
                           '${TEAM} is disqualified because ${PLAYER} left'),
                subs=[('${TEAM}', player.getTeam().name),
                      ('${PLAYER}', player.getName(full=True))]),
                             color=(1, 1, 0))
            player.getTeam().gameData['finished'] = True
            player.getTeam().gameData['time'] = None
            player.getTeam().gameData['lap'] = 0
            bs.playSound(bs.getSound("boo"))
            for player in player.getTeam().players:
                player.gameData['lap'] = 0
                player.gameData['finished'] = True
                try:
                    player.actor.handleMessage(bs.DieMessage())
                except Exception:
                    pass

        # delay by one tick so team/player lists will be updated
        bs.gameTimer(1, self._checkEndGame)
Esempio n. 30
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.texBlast = bs.getTexture("tnt")
        self.texMix = bs.getTexture("eggTex1")

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

        self.powerupMaterial = bs.Material()

        self.powerupAcceptMaterial = bs.Material()

        self.powerupMaterial.addActions(
            conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)),
            actions=(("modifyPartCollision", "collide",
                      True), ("modifyPartCollision", "physical", False),
                     ("message", "ourNode", "atConnect", _TouchedMessage())))

        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)
 def onBegin(self):
     bs.TeamGameActivity.onBegin(self)
     self.setupStandardTimeLimit(self.settings['Time Limit'])
     if len(self.teams) > 0:
         self._scoreToWin = self.settings['KOs to Win Per Player'] * max(1,max(len(t.players) for t in self.teams))
     else: self._scoreToWin = self.settings['KOs to Win Per Player']
     self._updateScoreBoard()
     self._dingSound = bs.getSound('dingSmall')
	def setAutoUpdate(self, val):
		# FIXME: properly disable checkbox
		if not self.checkUpdates.value:
			bs.playSound(bs.getSound("error"))
			self.autoUpdates.value = False
			return
		config["auto-update-old-mods"] = bool(val)
		bs.writeConfig()
    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 __init__(self, mod, onok, swish=True, back=False):
		self._back = back
		self.mod = mod
		self.onok = bs.WeakCall(onok)
		if swish:
			bs.playSound(bs.getSound('swish'))

		self._rootWidget = ConfirmWindow("Are you sure you want to delete " + mod.filename + "?",
														self.ok).getRootWidget()
	def __init__(self):
		global quittoapply
		if quittoapply is not None:
			quittoapply.delete()
			quittoapply = None
		bs.playSound(bs.getSound('swish'))
		text = "Quit BS to reload mods?"
		if bs.getEnvironment()["platform"] == "android":
			text += "\n(On Android you have to kill the activity)"
		self._rootWidget = quittoapply = ConfirmWindow(text, self._doFadeAndQuit).getRootWidget()
	def _reload_module(self):
		bs.screenMessage("reloading " + self._filename)
		self._prepare_reload()
		self._import_module()
		#self._module = import_module(self._filename[:-3], package=IMPORT_FOLDER.split("/")[-2])
		with open(IMPORT_FOLDER + self._filename, "r") as f:
			self._module_md5 = md5(f.read()).hexdigest()
		self._did_print_error = False
		if self._is_available() and self._type == "game":
			self._game = self._module.bsGetGames()[0]
		else:
			self._game = None
		bs.playSound(bs.getSound('swish'))
	def _cb_select_tab(self, index, refresh=True):
		bs.playSound(bs.getSound('click01'))
		self._selectedTab = self.tabs[index]
		label = self._selectedTab["label"]

		for i, tab in enumerate(self.tabs):
			button = tab["button"]
			if i == index:
				button.set(color=(0.5, 0.4, 0.93), textColor=(0.85, 0.75, 0.95)) # lit
			else:
				button.set(color=(0.52, 0.48, 0.63), textColor=(0.65, 0.6, 0.7)) # unlit
		if refresh:
			self._refresh(refreshTabs=False)
	def __init__(self, mod, onok, swish=True, back=False):
		self._back = back
		self.mod = mod
		self.onok = bs.WeakCall(onok)
		if swish:
			bs.playSound(bs.getSound('swish'))
		text = "Do you want to update %s?" if mod.isInstalled() else "Do you want to install %s?"
		text = text %(mod.filename)
		if mod.changelog and mod.isInstalled():
			text += "\n\nChangelog:"
			for change in mod.changelog:
				text += "\n"+change
		height = 100 * (1 + len(mod.changelog) * 0.3) if mod.isInstalled() else 100
		width = 360 * (1 + len(mod.changelog) * 0.15) if mod.isInstalled() else 360
		self._rootWidget = ConfirmWindow(text, self.ok, height=height, width=width).getRootWidget()
	def __init__(self, settings):
		bs.TeamGameActivity.__init__(self, settings)
		self._scoreBoard = bs.ScoreBoard()
		self._swipSound = bs.getSound("swip")
		self._tickSound = bs.getSound('tick')
		self._countDownSounds = {10:bs.getSound('announceTen'),
								 9:bs.getSound('announceNine'),
								 8:bs.getSound('announceEight'),
								 7:bs.getSound('announceSeven'),
								 6:bs.getSound('announceSix'),
								 5:bs.getSound('announceFive'),
								 4:bs.getSound('announceFour'),
								 3:bs.getSound('announceThree'),
								 2:bs.getSound('announceTwo'),
								 1:bs.getSound('announceOne')}
	def __init__(self, settings):
		bs.TeamGameActivity.__init__(self, settings)
		if self.settings['Epic Mode']:
			self._isSlowMotion = True
		self._scoreBoard = bs.ScoreBoard()
		self._swipSound = bs.getSound("swip")
		self._countDownSounds = {10:bs.getSound('announceTen'),
								 9:bs.getSound('announceNine'),
								 8:bs.getSound('announceEight'),
								 7:bs.getSound('announceSeven'),
								 6:bs.getSound('announceSix'),
								 5:bs.getSound('announceFive'),
								 4:bs.getSound('announceFour'),
								 3:bs.getSound('announceThree'),
								 2:bs.getSound('announceTwo'),
								 1:bs.getSound('announceOne')}
		self.maxTailLength = self.settings['Mines to win'] * self.tailIncrease
		self.isFinished = False
		self.hasStarted = False
	def _cb_info(self, withSound=False):
		if withSound:
			bs.playSound(bs.getSound('swish'))
		ModInfoWindow(self._selectedMod, self, originWidget=self.modInfoButton)
 def __init__(self,settings):
     bs.TeamGameActivity.__init__(self,settings)
     self._winSound = bs.getSound("score")