Exemplo n.º 1
0
    def onTransitionIn(self):

        bs.CoopGameActivity.onTransitionIn(self, music='Football')

        self._scoreBoard = bs.ScoreBoard()
        self._flagSpawnPos = self.getMap().getFlagPosition(None)

        self._spawnFlag()

        # set up the two score regions
        self.scoreRegions = []
        defs = self.getMap().defs
        self.scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': defs.boxes['goal1'][0:3],
                               'scale': defs.boxes['goal1'][6:9],
                               'type': 'box',
                               'materials': [self._scoreRegionMaterial]
                           })))

        self.scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': defs.boxes['goal2'][0:3],
                               'scale': defs.boxes['goal2'][6:9],
                               'type': 'box',
                               'materials': [self._scoreRegionMaterial]
                           })))
        bs.playSound(self._chantSound)
Exemplo n.º 2
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)

        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops(enableTNT=False)

        self._ballSpawnPos = self.getMap().getFlagPosition(None)
        self._spawnBall()
        #for night mode we need night actor. And same goodies for nigh mode
        if self.settings['Night Mode']: self._nightSpawny(),self._flagKaleFlash()

        # set up the two score regions
        defs = self.getMap().defs
        self._scoreRegions = []
        self._scoreRegions.append(bs.NodeActor(bs.newNode("region",
                                                          attrs={'position':(13.75, 0.85744967453, 0.1095578275),
                                                                 'type':"box",
                                                                'scale': (1.05,1.1,3.8),
                                                                 'materials':[self._scoreRegionMaterial]})))
        
        self._scoreRegions.append(bs.NodeActor(bs.newNode("region",
                                                          attrs={'position':(-13.55, 0.85744967453, 0.1095578275),
                                                                 'type':"box",
                                                                 'scale': (1.05,1.1,3.8),
                                                                 'materials':[self._scoreRegionMaterial]})))
        self._updateScoreBoard()

        bs.playSound(self._chantSound)
Exemplo n.º 3
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)

        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()

        self._flagSpawnPos = self.getMap().getFlagPosition(None)
        self._spawnFlag()

        # set up the two score regions
        self._scoreRegions = []

        defs = self.getMap().defs
        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': defs.boxes['goal1'][0:3],
                               'scale': defs.boxes['goal1'][6:9],
                               'type': 'box',
                               'materials': (self.scoreRegionMaterial, )
                           })))

        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': defs.boxes['goal2'][0:3],
                               'scale': defs.boxes['goal2'][6:9],
                               'type': 'box',
                               'materials': (self.scoreRegionMaterial, )
                           })))
        self._updateScoreBoard()

        bs.playSound(self._chantSound)
Exemplo n.º 4
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)

        self._excludePowerups = ['speed']
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()

        self._puckSpawnPos = self.getMap().getFlagPosition(None)
        self._spawnPuck()

        # set up the two score regions
        defs = self.getMap().defs
        self._scoreRegions = []
        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode("region",
                           attrs={
                               'position': defs.boxes["goal1"][0:3],
                               'scale': defs.boxes["goal1"][6:9],
                               'type': "box",
                               'materials': [self._scoreRegionMaterial]
                           })))

        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode("region",
                           attrs={
                               'position': defs.boxes["goal2"][0:3],
                               'scale': defs.boxes["goal2"][6:9],
                               'type': "box",
                               'materials': [self._scoreRegionMaterial]
                           })))
        self._updateScoreBoard()

        bs.playSound(self._chantSound)
Exemplo n.º 5
0
    def _touchReturnUpdate(self, team):

        # count down only while its away from base and not being held
        if (team.gameData['homeFlagAtBase']
                or team.gameData['flag']._heldCount > 0):
            team.gameData['touchReturnTimerTicking'] = None
            return  # no need to return when its at home
        else:
            if team.gameData['touchReturnTimerTicking'] is None:
                team.gameData['touchReturnTimerTicking'] = bs.NodeActor(
                    bs.newNode('sound',
                               attrs={
                                   'sound': self._tickingSound,
                                   'positional': False,
                                   'loop': True
                               }))
        flag = team.gameData['flag']
        flag._touchReturnTime -= 0.1
        if flag._counter.exists():
            flag._counter.text = "%.1f" % flag._touchReturnTime
            flag._counter.color = (1, 1, 0, 1)
            flag._counter.scale = 0.02

        if flag._touchReturnTime <= 0.0:
            self._awardPlayersTouchingOwnFlag(team)
            flag.handleMessage(bs.DieMessage())
Exemplo n.º 6
0
            def _gotNews(self, news):
                
                # run this stuff in the context of our activity since we need
                # to make nodes and stuff.. should fix the serverGet call so it 
                activity = self._activity()
                if activity is None or activity.isFinalized(): return
                with bs.Context(activity):
                
                    self._phrases = []
                    # show upcoming achievements in non-vr versions
                    # (currently too hard to read in vr)
                    self._usedPhrases = (
                        ['__ACH__'] if not bs.getEnvironment()['vrMode']
                        else []) + [s for s in news.split('<br>\n') if s != '']
                    self._phraseChangeTimer = bs.Timer(
                        self._messageDuration+self._messageSpacing,
                        bs.WeakCall(self._changePhrase), repeat=True)

                    sc = 1.2 if (bs.getEnvironment()['interfaceType'] == 'small'
                                 or bs.getEnvironment()['vrMode']) else 0.8

                    self._text = bs.NodeActor(bs.newNode('text', attrs={
                        'vAttach':'top',
                        'hAttach':'center',
                        'hAlign':'center',
                        'vrDepth':-20,
                        'shadow':1.0 if bs.getEnvironment()['vrMode'] else 0.4,
                        'flatness':0.8,
                        'vAlign':'top',
                        'color':((1, 1, 1, 1) if bs.getEnvironment()['vrMode']
                                 else (0.7, 0.65, 0.75, 1.0)),
                        'scale':sc,
                        'maxWidth':900.0/sc,
                        'position':(0,-10)}))
                    self._changePhrase()
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)
        if self.settings['Epic Mode']: self._isSlowMotion = True
        self.info = bs.NodeActor(
            bs.newNode('text',
                       attrs={
                           'vAttach': 'bottom',
                           'hAlign': 'center',
                           'vrDepth': 0,
                           'color': (0, .2, 0),
                           'shadow': 1.0,
                           'flatness': 1.0,
                           'position': (0, 0),
                           'scale': 0.8,
                           'text': "Modified by Mr.Smoothy",
                       }))
        self.possession = True
        self.heldLast = None
        self.fouled = False
        self.firstFoul = False
        self.jb = True
        self._bots = bs.BotSet()
        self.hoop = Hoop((0, 5, -8), (1, 1, 1))
        self.threePointLine = ThreePointLine().autoRetain()
        self._scoredis = bs.ScoreBoard()
        self.referee = Referee

        bs.gameTimer(
            10,
            bs.Call(self._bots.spawnBot,
                    self.referee,
                    pos=(-6, 3, -6),
                    spawnTime=1))
Exemplo n.º 8
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self._bots = bs.BotSet()

        pt1 = (6.972673935, 4.380775486, -9.424407061)
        pt2 = (-6.972673935, 4.380775486, -9.424407061)
        pt3 = (6.972673935, 4.380775486, 3.424407061)
        pt4 = (-6.972673935, 4.380775486, 3.424407061)

        for i in range(self.settings['Bombers']):
            bs.gameTimer(
                1000,
                bs.Call(self._bots.spawnBot,
                        bs.BomberBotStatic,
                        pos=random.choice([pt1, pt2, pt3, pt4]),
                        spawnTime=3000))

        self._scoreRegions = []
        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': (0.3, 4.044276501, -2.9),
                               'scale': (11.7, 15, 9.5),
                               'type': 'box',
                               'materials': (self.safeRegionMaterial, )
                           })))
        self._timer = bs.OnScreenTimer()
        bs.gameTimer(4000, self._timer.start)
        self._updateTimer = bs.Timer(1000, self._onSpazBotDied, repeat=True)
Exemplo n.º 9
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.winners = []
        self.setupStandardTimeLimit(self.settings['Time Limit'])

        # set up the score region
        self._scoreRegions = []

        defs = self.getMap().defs
        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode('region',
                           attrs={
                               'position': defs.boxes['goal1'][0:3],
                               'scale': defs.boxes['goal1'][6:9],
                               'type': 'box',
                               'materials': (self.scoreRegionMaterial, )
                           })))

        self._updateScoreBoard()
        self.updateBoxes()
        #Preload the play area with mines
        while len(self.mines) < self.settings['Start Mines']:
            x = random.uniform(-11.3, 11.3)
            y = random.uniform(-5.2, 5.7)
            pos = [x, 0.32, y]
            self._makeMine(pos)
        bs.playSound(self._chantSound)
        #Set up the timer for mine spawning
        bs.gameTimer(int(1000 / self.settings['Mines per Second']),
                     bs.WeakCall(self.mineUpdate),
                     repeat=True)
        bs.gameTimer(1000, self._update, repeat=True)
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()
        self.zombieQ = 1  # queue of zombies to spawn. this will increment/decrement
        if self._soloMode:
            self._vsText = bs.NodeActor(
                bs.newNode("text",
                           attrs={
                               'position': (0, 105),
                               'hAttach': "center",
                               'hAlign': 'center',
                               'maxWidth': 200,
                               'shadow': 0.5,
                               'vrDepth': 390,
                               'scale': 0.6,
                               'vAttach': "bottom",
                               'color': (0.8, 0.8, 0.3, 1.0),
                               'text': bs.Lstr(resource='vsText')
                           }))

        # if balance-team-lives is on, add lives to the smaller team until total lives match
        if (isinstance(self.getSession(), bs.TeamsSession)
                and self.settings['Balance Total Lives']
                and len(self.teams[0].players) > 0
                and len(self.teams[1].players) > 0):
            if self._getTotalTeamLives(
                    self.teams[0]) < self._getTotalTeamLives(self.teams[1]):
                lesserTeam = self.teams[0]
                greaterTeam = self.teams[1]
            else:
                lesserTeam = self.teams[1]
                greaterTeam = self.teams[0]
            addIndex = 0
            while self._getTotalTeamLives(
                    lesserTeam) < self._getTotalTeamLives(greaterTeam):
                lesserTeam.players[addIndex].gameData['lives'] += 1
                addIndex = (addIndex + 1) % len(lesserTeam.players)
        #Let's add a couple of bots
        # this wrangles our bots
        self._bots = zBotSet()

        #Set colors and character for ToughGuyBot to be zombie
        setattr(bs.ToughGuyBot, 'color', (0.4, 0.1, 0.05))
        setattr(bs.ToughGuyBot, 'highlight', (0.2, 0.4, 0.3))
        setattr(bs.ToughGuyBot, 'character', 'Kronk2')
        # start some timers to spawn bots
        thePt = self.getMap().getFFAStartPosition(self.players)
        #bs.gameTimer(1000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=thePt,spawnTime=3000))

        self._updateIcons()
        self._updateScoreBoard

        # we could check game-over conditions at explicit trigger points,
        # but lets just do the simple thing and poll it...
        bs.gameTimer(1000, self._update, repeat=True)
Exemplo n.º 12
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        #self.setupStandardPowerupDrops() #No standard powerups.  We'll drop 'em from the sky.

        if self._soloMode:
            self._vsText = bs.NodeActor(
                bs.newNode("text",
                           attrs={
                               'position': (0, 105),
                               'hAttach': "center",
                               'hAlign': 'center',
                               'maxWidth': 200,
                               'shadow': 0.5,
                               'vrDepth': 390,
                               'scale': 0.6,
                               'vAttach': "bottom",
                               'color': (0.8, 0.8, 0.3, 1.0),
                               'text': bs.Lstr(resource='vsText')
                           }))

        # if balance-team-lives is on, add lives to the smaller team until total lives match
        if (isinstance(self.getSession(), bs.TeamsSession)
                and self.settings['Balance Total Lives']
                and len(self.teams[0].players) > 0
                and len(self.teams[1].players) > 0):
            if self._getTotalTeamLives(
                    self.teams[0]) < self._getTotalTeamLives(self.teams[1]):
                lesserTeam = self.teams[0]
                greaterTeam = self.teams[1]
            else:
                lesserTeam = self.teams[1]
                greaterTeam = self.teams[0]
            addIndex = 0
            while self._getTotalTeamLives(
                    lesserTeam) < self._getTotalTeamLives(greaterTeam):
                lesserTeam.players[addIndex].gameData['lives'] += 1
                addIndex = (addIndex + 1) % len(lesserTeam.players)

        self._updateIcons()
        for pName in self.scoreSet._players:
            spz = self.scoreSet._players[pName].getSpaz()
            if not spz is None:
                bs.gameTimer(1500, bs.WeakCall(spz.curse))  #Curse you all!

        #bsPowerup.Powerup(position=self.getMap().powerupSpawnPoints[0], powerupType='health',expire=False).autoRetain()
        #bsPowerup.Powerup(position=self.getMap().powerupSpawnPoints[1], powerupType='curse',expire=False).autoRetain()
        #bsPowerup.Powerup(position=self.getMap().powerupSpawnPoints[3], powerupType='health',expire=False).autoRetain()
        #bsPowerup.Powerup(position=self.getMap().powerupSpawnPoints[2], powerupType='curse',expire=False).autoRetain()
        self.boxMult = 4.0
        self.totBoxes = []
        self.boxSpawn()
        # we could check game-over conditions at explicit trigger points,
        # but lets just do the simple thing and poll it...
        bs.gameTimer(1000, self._update, repeat=True)
Exemplo n.º 13
0
 def __init__(self,settings):
     bs.TeamGameActivity.__init__(self,settings)
     if self.settings['Epic Mode']: self._isSlowMotion = True
     self.info = bs.NodeActor(bs.newNode('text',
                                                attrs={'vAttach': 'bottom',
                                                       'hAlign': 'center',
                                                       'vrDepth': 0,
                                                       'color': (0,.2,0),
                                                       'shadow': 1.0,
                                                       'flatness': 1.0,
                                                       'position': (0,0),
                                                       'scale': 0.8,
                                                       'text': "Created by MattZ45986 on Github",
                                                       }))
     self.roundNum = 0
     self.simon = False
     self.time = 5000
     self._r1 = 2
     n1 = bs.newNode('locator',attrs={'shape':'circle','position':(-4,0,-6),
                                      'color':(1,0,0),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n2 = bs.newNode('locator',attrs={'shape':'circle','position':(0,0,-6),
                                      'color':(0,1,0),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n3 = bs.newNode('locator',attrs={'shape':'circle','position':(4,0,-6),
                                      'color':(0,0,1),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n4 = bs.newNode('locator',attrs={'shape':'circle','position':(-4,0,-2),
                                      'color':(1,1,0),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n5 = bs.newNode('locator',attrs={'shape':'circle','position':(0,0,-2),
                                      'color':(0,1,1),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n6 = bs.newNode('locator',attrs={'shape':'circle','position':(4,0,-2),
                                      'color':(1,0,1),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n7 = bs.newNode('locator',attrs={'shape':'circle','position':(-4,0,2),
                                      'color':(.5,.5,.5),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n8 = bs.newNode('locator',attrs={'shape':'circle','position':(0,0,2),
                                      'color':(.5,.325,0),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     n9 = bs.newNode('locator',attrs={'shape':'circle','position':(4,0,2),
                                      'color':(1,1,1),'opacity':0.5,
                                      'drawBeauty':True,'additive':True})
     bs.animateArray(n1,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n2,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n3,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n4,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n5,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n6,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n7,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n8,'size',1,{0:[0.0],200:[self._r1*2.0]})
     bs.animateArray(n9,'size',1,{0:[0.0],200:[self._r1*2.0]})
     self.options = ["red", "green", "blue", "yellow", "teal", "purple", "gray", "orange", "white", "top", "bottom", "middle row", "left", "right", "center column", "outside"]
Exemplo n.º 14
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()

        if self._soloMode:
            self._vsText = bs.NodeActor(
                bs.newNode("text",
                           attrs={
                               'position': (0, 105),
                               'hAttach': "center",
                               'hAlign': 'center',
                               'maxWidth': 200,
                               'shadow': 0.5,
                               'vrDepth': 390,
                               'scale': 0.6,
                               'vAttach': "bottom",
                               'color': (0.8, 0.8, 0.3, 1.0),
                               'text': bs.Lstr(resource='vsText')
                           }))

        # if balance-team-lives is on, add lives to the smaller team until total lives match
        if (isinstance(self.getSession(), bs.TeamsSession)
                and self.settings['Balance Total Lives']
                and len(self.teams[0].players) > 0
                and len(self.teams[1].players) > 0):
            if self._getTotalTeamLives(
                    self.teams[0]) < self._getTotalTeamLives(self.teams[1]):
                lesserTeam = self.teams[0]
                greaterTeam = self.teams[1]
            else:
                lesserTeam = self.teams[1]
                greaterTeam = self.teams[0]
            addIndex = 0
            while self._getTotalTeamLives(
                    lesserTeam) < self._getTotalTeamLives(greaterTeam):
                lesserTeam.players[addIndex].gameData['lives'] += 1
                addIndex = (addIndex + 1) % len(lesserTeam.players)

        self._updateIcons()

        self._bots.finalCelebrate()
        activity = bs.getActivity()
        try:
            myFactory = activity._sharedSpazFactory
        except Exception:
            myFactory = activity._sharedSpazFactory = bsSpaz.SpazFactory()

        # we could check game-over conditions at explicit trigger points,
        # but lets just do the simple thing and poll it...
        self.minLife = 1000  #A clone's life must be at least this long for death to count.
        for player in self.players:
            self.spawnDummy(player, SpazClone)
        bs.gameTimer(1000, self._update, repeat=True)
Exemplo n.º 15
0
    def handleMessage(self, m):
        """ handle high-level game messages """

        # respawn dead players
        if isinstance(m, bs.PlayerSpazDeathMessage):

            player = m.spaz.getPlayer()

            self.scoreSet.playerLostSpaz(player)

            respawnTime = 2000 + len(self.initialPlayerInfo) * 1000

            # respawn them shortly
            player.gameData['respawnTimer'] = bs.Timer(
                respawnTime, bs.Call(self.spawnPlayerIfExists, player))
            player.gameData['respawnIcon'] = bs.RespawnIcon(
                player, respawnTime)

            # augment standard behavior
            bs.CoopGameActivity.handleMessage(self, m)

        elif isinstance(m, bs.SpazBotDeathMessage):
            # every time a bad guy dies, spawn a new one
            bs.gameTimer(3000, bs.Call(self._spawnBot, (type(m.badGuy))))

        elif isinstance(m, bs.SpazBotPunchedMessage):
            if self._preset in ['rookie', 'rookieEasy']:
                if m.damage >= 500:
                    self._awardAchievement('Super Punch')
            elif self._preset in ['pro', 'proEasy']:
                if m.damage >= 1000:
                    self._awardAchievement('Super Mega Punch')

        # respawn dead flags
        elif isinstance(m, bs.FlagDeathMessage):
            m.flag.respawnTimer = bs.Timer(3000, self._spawnFlag)
            self._flagRespawnLight = bs.NodeActor(
                bs.newNode('light',
                           attrs={
                               'position': self._flagSpawnPos,
                               'heightAttenuated': False,
                               'radius': 0.15,
                               'color': (1.0, 1.0, 0.3)
                           }))
            bs.animate(self._flagRespawnLight.node,
                       "intensity", {
                           0: 0,
                           250: 0.15,
                           500: 0
                       },
                       loop=True)
            bs.gameTimer(3000, self._flagRespawnLight.node.delete)
        else:
            bs.CoopGameActivity.handleMessage(self, m)
Exemplo n.º 16
0
    def _makeWord(self, word, x, y, scale=1.0, delay=0,
                  vrDepthOffset=0, shadow=True):
        wordShadowObj = bs.NodeActor(bs.newNode('text', attrs={
            'position':(x,y),
            'big':True,
            'color':(0.95, 1.55, 0.6+random.random()/2 if random.random()>0.6 else 0.6, 0.65),
            'tiltTranslate':0.11,
            'tiltTranslate':0.09,
            'opacityScalesShadow':False,
            'shadow':0.2,
            'vrDepth':-130,
            'vAlign':'center',
            'projectScale':0.97*scale,
            'scale':1.0,
            'text':word}))
        self._wordActors.append(wordShadowObj)
        if not bs.getEnvironment()['vrMode']:
            if not shadow: c = bs.newNode("combine", owner=wordObj.node, attrs={'size':2})
            else: c = None
            if shadow: c2 = bs.newNode("combine", owner=wordShadowObj.node, attrs={'size':2})
            else: c2 = None
            if not shadow: c.connectAttr('output',wordObj.node,'position')
            if shadow: c2.connectAttr('output',wordShadowObj.node,'position')
            keys = {}
            keys2 = {}
            timeV = 0
            for i in range(10):
                val = x + random.uniform(0, 1)
                val2 = x + random.uniform(-1,0)
                keys[timeV*self._ts] = val
                keys2[timeV*self._ts] = val2
                timeV += 720
            if c is not None: bs.animate(c, "input0", keys, loop=True)
            if c2 is not None: bs.animate(c2, "input0", keys2, loop=True)

            keys = {}
            keys2 = {}
            timeV = 0
            for i in range(10):
                val = y+random.uniform(0, 1)
                val2 = y+random.uniform(-1,0)
                keys[timeV*self._ts] = val
                keys2[timeV*self._ts] = val2
                timeV += 1000
            if c is not None: bs.animate(c,"input1",keys,loop=True)
            if c2 is not None: bs.animate(c2,"input1",keys2,loop=True)

        if not shadow:
            bs.animate(wordObj.node, "projectScale",
                       {delay:scale * 0, delay+210:scale})
        else:
            bs.animate(wordShadowObj.node, "projectScale",
                       {delay:scale *0, delay+210:scale})
 def __init__(self,settings):
     bs.TeamGameActivity.__init__(self,settings)
     self.info = bs.NodeActor(bs.newNode('text',
                                                attrs={'vAttach': 'bottom',
                                                       'hAlign': 'center',
                                                       'vrDepth': 0,
                                                       'color': (0,.2,0),
                                                       'shadow': 1.0,
                                                       'flatness': 1.0,
                                                       'position': (0,0),
                                                       'scale': 0.8,
                                                       'text': "Created by MattZ45986 on Github",
                                                       }))
Exemplo n.º 18
0
    def handleMessage(self, m):

        if isinstance(m, bs.FlagPickedUpMessage):
            try:
                player = m.node.getDelegate().getPlayer()
                if player.exists(): m.flag.lastHoldingPlayer = player
            except Exception:
                bs.printException(
                    'exception in Football FlagPickedUpMessage; this shoudln\'t happen'
                )
            m.flag.heldCount += 1

        elif isinstance(m, bs.FlagDroppedMessage):
            m.flag.heldCount -= 1

        # respawn dead players if they're still in the game
        elif isinstance(m, bs.PlayerSpazDeathMessage):
            bs.TeamGameActivity.handleMessage(self,
                                              m)  # augment standard behavior
            self.respawnPlayer(m.spaz.getPlayer())
            # jasonhu5
            player = m.spaz.getPlayer()
            killer = m.killerPlayer
            self._handleKillScore(player, killer)
            #

        # respawn dead flags
        elif isinstance(m, bs.FlagDeathMessage):
            if not self.hasEnded():
                self._flagRespawnTimer = bs.Timer(3000, self._spawnFlag)
                self._flagRespawnLight = bs.NodeActor(
                    bs.newNode('light',
                               attrs={
                                   'position': self._flagSpawnPos,
                                   'heightAttenuated': False,
                                   'radius': 0.15,
                                   'color': (1.0, 1.0, 0.3)
                               }))
                bs.animate(self._flagRespawnLight.node,
                           "intensity", {
                               0: 0,
                               250: 0.15,
                               500: 0
                           },
                           loop=True)
                bs.gameTimer(3000, self._flagRespawnLight.node.delete)

        else:
            bs.TeamGameActivity.handleMessage(self,
                                              m)  # augment standard behavior
Exemplo n.º 19
0
    def _makeLogo(self, x, y, scale, delay, customTexture=None, jitterScale=1.0,
                  rotate=0, vrDepthOffset=0):
        # temp easter googness
        if customTexture is None:
            customTexture = self._getCustomLogoTexName()
        self._customLogoTexName = customTexture
        logo = bs.NodeActor(bs.newNode('image', attrs={
            'texture': bs.getTexture(customTexture if customTexture is not None
                                     else 'logo'),
            'modelOpaque':(None if customTexture is not None
                           else bs.getModel('logo')),
            'modelTransparent':(None if customTexture is not None
                                else bs.getModel('logoTransparent')),
            'vrDepth':-10+vrDepthOffset,
            'rotate':rotate,
            'attach':"center",
            'tiltTranslate':0.21,
            'absoluteScale':True}))
        self._logoNode = logo.node
        self._wordActors.append(logo)
        # add a bit of stop-motion-y jitter to the logo
        # (unless we're in VR mode in which case its best to leave things still)
        if not bs.getEnvironment()['vrMode']:
            c = bs.newNode("combine", owner=logo.node, attrs={'size':2})
            c.connectAttr('output', logo.node, 'position')
            keys = {}
            timeV = 0
            # gen some random keys for that stop-motion-y look
            for i in range(10):
                keys[timeV] = x+(random.random()-0.5)*0.7*jitterScale
                timeV += random.random() * 100
            bs.animate(c,"input0",keys,loop=True)
            keys = {}
            timeV = 0
            for i in range(10):
                keys[timeV*self._ts] = y+(random.random()-0.5)*0.7*jitterScale
                timeV += random.random() * 100
            bs.animate(c,"input1",keys,loop=True)
        else:
            logo.node.position = (x,y)

        c = bs.newNode("combine",owner=logo.node,attrs={"size":2})

        keys = {delay:0,delay+100:700*scale,delay+200:600*scale}
        bs.animate(c,"input0",keys)
        bs.animate(c,"input1",keys)
        c.connectAttr("output",logo.node,"scale")
Exemplo n.º 20
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self.setupStandardPowerupDrops()

        if self._soloMode:
            self._vsText = bs.NodeActor(
                bs.newNode(
                    "text",
                    attrs={
                        'position': (0, 105),
                        'hAttach': "center",
                        'hAlign': 'center',
                        'maxWidth': 200,
                        'shadow': 0.5,
                        'vrDepth': 390,
                        'scale': 0.6,
                        'vAttach': "bottom",
                        'color': (0.8, 0.8, 0.3, 1.0),
                        'text': bs.Lstr(resource='vsText')
                    }))

        # if balance-team-lives is on, add lives to the smaller team until
        # total lives match
        if (isinstance(self.getSession(), bs.TeamsSession)
                and self.settings['Balance Total Lives']
                and len(self.teams[0].players) > 0
                and len(self.teams[1].players) > 0):
            if self._getTotalTeamLives(
                    self.teams[0]) < self._getTotalTeamLives(self.teams[1]):
                lesserTeam = self.teams[0]
                greaterTeam = self.teams[1]
            else:
                lesserTeam = self.teams[1]
                greaterTeam = self.teams[0]
            addIndex = 0
            while self._getTotalTeamLives(
                    lesserTeam) < self._getTotalTeamLives(greaterTeam):
                lesserTeam.players[addIndex].gameData['lives'] += 1
                addIndex = (addIndex + 1) % len(lesserTeam.players)

        self._updateIcons()

        # we could check game-over conditions at explicit trigger points,
        # but lets just do the simple thing and poll it...
        bs.gameTimer(1000, self._update, repeat=True)
Exemplo n.º 21
0
    def _setChosenOnePlayer(self,player):
        try:
            for p in self.players: p.gameData['chosenLight'] = None
            bs.playSound(self._swipSound)
            if player is None or not player.exists():
                self._flag = bs.Flag(color=(1,0.9,0.2),
                                     position=self._flagSpawnPos,
                                     touchable=False)
                self._chosenOnePlayer = None

                l = bs.newNode('light',
                               owner=self._flag.node,
                               attrs={'position': self._flagSpawnPos,
                                      'intensity':0.6,
                                      'heightAttenuated':False,
                                      'volumeIntensityScale':0.1,
                                      'radius':0.1,
                                      'color': (1.2,1.2,0.4)})

                self._flashFlagSpawn()
            else:
                if player.actor is not None:
                    self._flag = None
                    self._chosenOnePlayer = player

                    if player.actor.node.exists():
                        if self.settings['Chosen One Gets Shield']: player.actor.handleMessage(bs.PowerupMessage('shield'))
                        if self.settings['Chosen One Gets Gloves']: player.actor.handleMessage(bs.PowerupMessage('punch'))
                        # use a color that's partway between their team color and white
                        color = [0.3+c*0.7 for c in bs.getNormalizedColor(player.getTeam().color)]
                        l = player.gameData['chosenLight'] = bs.NodeActor(bs.newNode('light',
                                                                                     attrs={"intensity":0.6,
                                                                                            "heightAttenuated":False,
                                                                                            "volumeIntensityScale":0.1,
                                                                                            "radius":0.13,
                                                                                            "color": color}))

                        bs.animate(l.node,'intensity',{0:1.0, 200:0.4, 400:1.0},loop=True)
                        player.actor.node.connectAttr('position',l.node,'position')
        except Exception,e:
            import traceback
            print 'EXC in _setChosenOnePlayer'
            traceback.print_exc(e)
            traceback,print_stack()
Exemplo n.º 22
0
 def __init__(self, settings):
     bs.TeamGameActivity.__init__(self, settings)
     self.called = False
     if self.settings['Epic Mode']: self._isSlowMotion = True
     self.info = bs.NodeActor(
         bs.newNode('text',
                    attrs={
                        'vAttach': 'bottom',
                        'hAlign': 'center',
                        'vrDepth': 0,
                        'color': (0, .2, 0),
                        'shadow': 1.0,
                        'flatness': 1.0,
                        'position': (0, 0),
                        'scale': 0.8,
                        'text': "Created by MattZ45986 on Github",
                    }))
     self._scoredis = bs.ScoreBoard()
     self.timer = bs.OnScreenCountdown(30, self.endGame)
Exemplo n.º 23
0
    def __init__(self, settings):
        bs.TeamGameActivity.__init__(self, settings)

        if self.settings['Epic Mode']: self._isSlowMotion = True

        # print messages when players die (since its meaningful in this game)
        self.announcePlayerDeaths = True
        self.fix_y = -5.614479365
        self.start_z = 0
        self.init_position = (0, self.start_z, self.fix_y)
        self.team_init_positions = [(-5, self.start_z, self.fix_y),
                                    (5, self.start_z, self.fix_y)]
        self.cur_speed = 2.5
        # TODO: The variable below should be set in settings
        self.peace_time = self.settings[AbyssLang.peaceTime]
        self.npc_density = self.settings[AbyssLang.npcDensity]

        self._lastPlayerDeathTime = None

        self._gameCredit = bs.NodeActor(
            bs.newNode('text',
                       attrs={
                           'vAttach':
                           'bottom',
                           'hAlign':
                           'center',
                           'vrDepth':
                           0,
                           'color': (0, 0, 0.8),
                           'shadow':
                           1.0 if True else 0.5,
                           'flatness':
                           1.0 if True else 0.5,
                           'position': (0, 0),
                           'scale':
                           0.8,
                           'text':
                           ' | '.join([
                               AbyssLang.author, AbyssLang.github,
                               AbyssLang.blog
                           ]),
                       }))
Exemplo n.º 24
0
 def __init__(self, position=(0, 1, 0)):
     bs.Actor.__init__(self)
     self.info = bs.NodeActor(
         bs.newNode('text',
                    attrs={
                        'vAttach': 'bottom',
                        'hAlign': 'center',
                        'vrDepth': 0,
                        'color': (0, .2, 0),
                        'shadow': 1.0,
                        'flatness': 1.0,
                        'position': (0, 0),
                        'scale': 0.8,
                        'text': "Created by MattZ45986 on Github",
                    }))
     activity = self.getActivity()
     self._spawnPos = (position[0], position[1] + 1.0, position[2])
     self.lastPlayersToTouch = {}
     self.node = bs.newNode(
         "prop",
         attrs={
             'model':
             bs.getModel('puck'),
             'colorTexture':
             bs.getTexture('puckColor'),
             'body':
             'puck',
             'reflection':
             'soft',
             'reflectionScale': [0.2],
             'shadowSize':
             1.0,
             'gravityScale':
             2.5,
             'isAreaOfInterest':
             True,
             'position':
             self._spawnPos,
             'materials':
             [bs.getSharedObject('objectMaterial'), activity._puckMaterial]
         },
         delegate=self)
Exemplo n.º 25
0
    def __init__(self,settings):
        bs.TeamGameActivity.__init__(self,settings)
        if self.settings['Epic Mode']: self._isSlowMotion = True

        self.info = bs.NodeActor(bs.newNode('text',
                                                   attrs={'vAttach': 'bottom',
                                                          'hAlign': 'center',
                                                          'vrDepth': 0,
                                                          'color': (0,.2,0),
                                                          'shadow': 1.0,
                                                          'flatness': 1.0,
                                                          'position': (0,0),
                                                          'scale': 0.8,
                                                          'text': "Created by MattZ45986 on Github",
                                                          }))
        self.announcePlayerDeaths = True
        
        try: self._soloMode = settings['Solo Mode']
        except Exception: self._soloMode = False
        self._scoreBoard = bs.ScoreBoard()
Exemplo n.º 26
0
 def startNextWave(self,num):
     self.killed = 0
     self.time = bs.getGameTime()
     for i in range(len(self.waves[self.num])):
         bs.gameTimer(i*100,bs.Call(self._bots.spawnBot,self.waves[self.num][i],pos=self.getRandomPos() if not self.waves[self.num][i] == bs.EricBot else (9, 5 ,-5),spawnTime=1000))
         
     self.showZoomMessage(bs.Lstr(value='${A} ${B}',subs=[('${A}',bs.Lstr(resource='waveText')),('${B}',str(self.num))]),
                          scale=1.0,duration=1000,trail=True)
                          
     self._waveText = bs.NodeActor(bs.newNode('text',
                                              attrs={'vAttach':'top',
                                                     'hAttach':'center',
                                                     'hAlign':'center',
                                                     'vrDepth':-10,
                                                     'color':(1,1,1,1) if True else (0.7,0.7,0.7,1.0),
                                                     'shadow':1.0 if True else 0.7,
                                                     'flatness':1.0 if True else 0.5,
                                                     'position':(0,-40),
                                                     'scale':1.3 if True else 1.1,
                                                     'text':bs.Lstr(value='${A} ${B}',subs=[('${A}',bs.Lstr(resource='waveText')),('${B}',str(self.num))])}))
Exemplo n.º 27
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['Kills to Win Per Player'] * max(
                1, max(len(t.players) for t in self.teams))
        else:
            self._scoreToWin = self.settings['Kills to Win Per Player']
        self._updateScoreBoard()
        self._dingSound = bs.getSound('dingSmall')
        if self.settings['Night Mode']: self._nightSpawny()
        #self.cameraFlash(duration=10)

        _scaleFoot = (29.0, 0.02, 11.8)
        _scaleRamp = (14.0, 0.1, 4.33)
        _posFoot = (0.0, 0.0, 0.0)
        _posRamp = (0.3196701116, 5.0, -4.292515158)
        _typeFoot = ('box')
        _typeRamp = ('box')

        Mapinfo = self.getMap()
        if Mapinfo.getName() == ('Football Stadium'):
            self._mapScale = _scaleFoot
        if Mapinfo.getName() == ('Football Stadium'): self._mapPos = _posFoot
        if Mapinfo.getName() == ('Football Stadium'): self._mapType = _typeFoot
        if Mapinfo.getName() == ('Rampage'): self._mapScale = _scaleRamp
        if Mapinfo.getName() == ('Rampage'): self._mapPos = _posRamp
        if Mapinfo.getName() == ('Rampage'): self._mapType = _typeRamp

        self._scoreRegions = []
        self._scoreRegions.append(
            bs.NodeActor(
                bs.newNode("region",
                           attrs={
                               'position': self._mapPos,
                               'type': self._mapType,
                               'scale': self._mapScale,
                               'materials': [self._scoreRegionMaterial]
                           })))
Exemplo n.º 28
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.allPowerups = []
        self.allTNTs = []
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        self._customPowerupRespawn = False
        self._keepPowerupsAliveWhenFighting = False
        self.setupStandardPowerupDrops()

        self._vsText = bs.NodeActor(
            bs.newNode("text",
                       attrs={
                           'position': (0, 105),
                           'hAttach': "center",
                           'hAlign': 'center',
                           'maxWidth': 200,
                           'shadow': 0.5,
                           'vrDepth': 390,
                           'scale': 0.6,
                           'vAttach': "bottom",
                           'color': (0.8, 0.8, 0.3, 1.0),
                           'text': bs.Lstr(resource='vsText')
                       }))
        if isinstance(self.getSession(), bs.FreeForAllSession):
            self.gameData['spawnOrder'] = []

        self._addPlayersToSpawnQueue()

        self._addIcons()

        self._spawnTimer1 = None
        self._spawnTimer2 = None

        self._spawnPlayers()

        self._scoreToWin = None
        if isinstance(self.getSession(), bs.FreeForAllSession):
            self._scoreToWin = self.settings['Kills to Win Per Player']
        else:
            self._scoreToWin = self.settings['Kills to Win Per Team']
        self._showScoreBoard()
Exemplo n.º 29
0
 def tick(self):
     self.check4Players()
     self._time = bs.NodeActor(
         bs.newNode('text',
                    attrs={
                        'vAttach': 'top',
                        'hAttach': 'center',
                        'text':
                        'Kill timer: ' + str(self._timeRemaining) + 's',
                        'opacity': 0.8,
                        'maxWidth': 100,
                        'hAlign': 'center',
                        'vAlign': 'center',
                        'shadow': 1.0,
                        'flatness': 1.0,
                        'color': (1, 1, 1),
                        'scale': 1.5,
                        'position': (0, -50)
                    }))
     self._timeRemaining -= 1
     bs.playSound(self._tickSound)
Exemplo n.º 30
0
    def onTransitionIn(self):

        bs.CoopGameActivity.onTransitionIn(self, music='Marching')

        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

        self._scoreRegion = bs.NodeActor(
            bs.newNode('region',
                       attrs={
                           'position':
                           self.getMap().defs.boxes['scoreRegion'][0:3],
                           'scale':
                           self.getMap().defs.boxes['scoreRegion'][6:9],
                           'type': 'box',
                           'materials': [self._scoreRegionMaterial]
                       }))