def onBegin(self):

        bs.CoopGameActivity.onBegin(self)
        playerCount = len(self.players)
        self._dingSound = bs.getSound('dingSmall')
        self._dingSoundHigh = bs.getSound('dingSmallHigh')

        hard = False if self._preset in [
            'trainingEasy', 'rookieEasy', 'proEasy', 'uberEasy'] else True

        if self._preset in ['training', 'trainingEasy']:
            import bsUtils
            bsUtils.ControlsHelpOverlay(
                delay=3000, lifespan=10000, bright=True).autoRetain()

            self._haveTnt = False
            self._excludePowerups = ['curse', 'landMines']
            self._waves = [

                {'baseAngle': 195,
                 'entries': ([
                     {'type': bs.BomberBotLame, 'spacing': 5},
                 ] * playerCount)},

                {'baseAngle': 130,
                 'entries': ([
                     {'type': bs.ToughGuyBotLame, 'spacing': 5},
                 ] * playerCount)},

                {'baseAngle': 195,
                 'entries': ([
                     {'type': bs.BomberBotLame, 'spacing': 10},
                 ] * (playerCount+1))},

                {'baseAngle': 130,
                 'entries': ([
                     {'type': bs.ToughGuyBotLame, 'spacing': 10},
                 ] * (playerCount+1))},

                {'baseAngle': 130,
                 'entries': ([
                     {'type': bs.ToughGuyBotLame,
                      'spacing': 5} if playerCount > 1 else None,
                     {'type': bs.ToughGuyBotLame, 'spacing': 5},
                     {'type': None, 'spacing': 30},
                     {'type': bs.BomberBotLame,
                      'spacing': 5} if playerCount > 3 else None,
                     {'type': bs.BomberBotLame, 'spacing': 5},
                     {'type': None, 'spacing': 30},
                     {'type': bs.ToughGuyBotLame, 'spacing': 5},
                     {'type': bs.ToughGuyBotLame,
                      'spacing': 5} if playerCount > 2 else None,
                 ])},

                {'baseAngle': 195,
                 'entries': ([
                     {'type': bs.SkeletonBot, 'spacing': 90},
                     {'type': bs.SkeletonBot,
                      'spacing': 90} if playerCount > 1 else None
                 ])},
            ]

        elif self._preset in ['rookie', 'rookieEasy']:
            self._haveTnt = False
            self._excludePowerups = ['curse']
            self._waves = [

                {'entries': [
                    {'type': bs.NinjaBot,
                     'point': 'LeftUpperMore'} if playerCount > 2 else None,
                    {'type': bs.NinjaBot, 'point': 'LeftUpper'},
                ]},

                {'entries': [
                    {'type': bs.BomberBotStaticLame, 'point': 'TurretTopRight'},
                    {'type': bs.ToughGuyBotLame, 'point': 'RightUpper'},
                    {'type': bs.ToughGuyBotLame, 'point': 'RightLower'} \
                    if playerCount > 1 else None,
                    {'type': bs.BomberBotStaticLame,
                     'point': 'TurretBottomRight'} if playerCount > 2 else None,
                ]},

                {'entries': [
                    {'type': bs.BomberBotStaticLame,
                     'point': 'TurretBottomLeft'},
                    {'type': bs.CallingBot,
                     'point': 'Left'},
                ]},
                {'entries': [
                    {'type': bs.ToughGuyBotLame, 'point': 'TopRight'},
                    {'type': bs.ToughGuyBot,
                     'point': 'TopHalfRight'} if playerCount > 1 else None,
                    {'type': bs.ToughGuyBotLame, 'point': 'TopLeft'},
                    {'type': bs.ToughGuyBotLame,
                     'point': 'TopHalfLeft'} if playerCount > 2 else None,
                    {'type': bs.ToughGuyBot, 'point': 'Top'},
                    {'type': bs.BomberBotStaticLame,
                     'point': 'TurretTopMiddle'},
                ]},

                {'entries': [
                    {'type': bs.ChickBotStatic, 'point': 'TurretBottomLeft'},
                    {'type': bs.ChickBotStatic, 'point': 'TurretBottomRight'},
                    {'type': bs.ChickBot, 'point': 'Bottom'},
                    {'type': bs.ChickBot,
                     'point': 'BottomHalfRight'} if playerCount > 1 else None,
                    {'type': bs.ChickBot,
                     'point': 'BottomHalfLeft'} if playerCount > 2 else None,
                ]},

                {'entries': [
                    {'type': bs.BomberBotStaticLame, 'point': 'TurretTopLeft'},
                    {'type': bs.BomberBotStaticLame, 'point': 'TurretTopRight'},
                    {'type': bs.NinjaBot, 'point': 'Bottom'},
                    {'type': bs.NinjaBot,
                     'point': 'BottomHalfLeft'} if playerCount > 1 else None,
                    {'type': bs.NinjaBot,
                     'point': 'BottomHalfRight'} if playerCount > 2 else None,
                ]},
            ]

        elif self._preset in ['pro', 'proEasy']:
            self._excludePowerups = ['curse']
            self._haveTnt = True
            self._waves = [

                {'baseAngle': -50,
                 'entries': ([
                     {'type': bs.ToughGuyBot,
                      'spacing': 12} if playerCount > 3 else None,
                     {'type': bs.ToughGuyBot, 'spacing': 12},
                     {'type': bs.BomberTNTBot, 'spacing': 1},
                     {'type': bs.BomberTNTBot, 'spacing': 6},
                     {'type': bs.BomberBot,
                         'spacing': 6} if self._preset == 'pro' else None,
                     {'type': bs.BomberBot,
                      'spacing': 6} if playerCount > 1 else None,
                     {'type': bs.ToughGuyBot, 'spacing': 12},
                     {'type': bs.ToughGuyBot,
                      'spacing': 12} if playerCount > 2 else None,
                 ])},

                {'baseAngle': 180,
                 'entries': ([
                     {'type': bs.ToughGuyBot,
                      'spacing': 6} if playerCount > 3 else None,
                     {'type': bs.ToughGuyBot,
                         'spacing': 6} if self._preset == 'pro' else None,
                     {'type': bs.ToughGuyBot, 'spacing': 6},
                     {'type': bs.SkeletonBot, 'spacing': 45},
                     {'type': bs.NinjaBot,
                      'spacing': 45} if playerCount > 1 else None,
                     {'type': bs.SkeletonBot, 'spacing': 6},
                     {'type': bs.ToughGuyBot,
                         'spacing': 6} if self._preset == 'pro' else None,
                     {'type': bs.ToughGuyBot,
                      'spacing': 6} if playerCount > 2 else None,
                 ])},

                {'baseAngle': 0,
                 'entries': ([
                     {'type': bs.NinjaBot, 'spacing': 30},
                     {'type': bs.BomberTNTBot, 'spacing': 30},
                     {'type': bs.BomberTNTBot, 'spacing': 30},
                     {'type': bs.ChickBot, 'spacing': 30},
                     {'type': bs.BomberTNTBot,
                         'spacing': 30} if self._preset == 'pro' else None,
                     {'type': bs.ChickBot,
                      'spacing': 30} if playerCount > 1 else None,
                     {'type': bs.ChickBot,
                      'spacing': 30} if playerCount > 3 else None,
                     {'type': bs.NinjaBot, 'spacing': 30},
                 ])},

                {'baseAngle': 90,
                 'entries': ([
                     {'type': bs.MelBot, 'spacing': 50},
                     {'type': bs.MelBot,
                      'spacing': 50} if self._preset == 'pro' else None,
                     {'type': bs.MelBot, 'spacing': 50},
                     {'type': bs.MelBot,
                      'spacing': 50} if playerCount > 1 else None,
                     {'type': bs.MelBot,
                      'spacing': 50} if playerCount > 3 else None,
                 ])},

                {'baseAngle': 0,
                 'entries': ([
                     {'type': bs.ChickBot, 'spacing': 72},
                     {'type': bs.ChickBot, 'spacing': 72},
                     {'type': bs.ChickBot,
                         'spacing': 72} if self._preset == 'pro' else None,
                     {'type': bs.ChickBot, 'spacing': 72},
                     {'type': bs.ChickBot, 'spacing': 72},
                     {'type': bs.ChickBot,
                      'spacing': 36} if playerCount > 2 else None,
                 ])},

                {'baseAngle': 30,
                 'entries': ([
                     {'type': bs.NinjaBotProShielded, 'spacing': 50},
                     {'type': bs.NinjaBotProShielded, 'spacing': 50},
                     {'type': bs.NinjaBotProShielded,
                         'spacing': 50} if self._preset == 'pro' else None,
                     {'type': bs.NinjaBotProShielded,
                         'spacing': 50} if playerCount > 1 else None,
                     {'type': bs.NinjaBotProShielded,
                         'spacing': 50} if playerCount > 2 else None,
                 ])},
            ]

        elif self._preset in ['uber', 'uberEasy']:

            # show controls help in kiosk mode
            if bs.getEnvironment()['kioskMode']:
                import bsUtils
                bsUtils.ControlsHelpOverlay(
                    delay=3000, lifespan=10000, bright=True).autoRetain()

            self._haveTnt = True
            self._excludePowerups = []
            self._waves = [

                {'entries': [
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopMiddleLeft'} if hard else None,
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopMiddleRight'},
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopLeft'} if playerCount > 2 else None,
                    {'type': bot.SantaBot, 'point': 'TopRight'},
                    {'type': 'delay', 'duration': 4000},
                    {'type': bot.SantaBot, 'point': 'TopLeft'},
                ]},

                {'entries': [
                    {'type': bs.SkeletonBot, 'point': 'Left'},
                    {'type': bs.SkeletonBot, 'point': 'Right'},
                    {'type': bs.NinjaBot, 'point': 'Right'},
                    {'type': bs.NinjaBot,
                     'point': 'RightUpperMore'} if playerCount > 2 else None,
                    {'type': bs.BomberBotProStatic, 'point': 'TurretTopLeft'},
                    {'type': bs.BomberBotProStatic, 'point': 'TurretTopRight'},
                ]},

                {'entries': [
                    {'type': bs.ChickBotPro, 'point': 'TopRight'},
                    {'type': bs.ChickBotPro,
                     'point': 'RightUpperMore'} if playerCount > 1 else None,
                    {'type': bs.ChickBotPro, 'point': 'RightUpper'},
                    {'type': bs.ChickBotPro,
                     'point': 'RightLower'} if hard else None,
                    {'type': bs.ChickBotPro,
                     'point': 'RightLowerMore'} if playerCount > 2 else None,
                    {'type': bs.ChickBotPro, 'point': 'BottomRight'},
                ]},

                {'entries': [
                    {'type': bs.NinjaBotProShielded, 'point': 'BottomRight'},
                    {'type': bs.NinjaBotProShielded,
                     'point': 'Bottom'} if playerCount > 2 else None,
                    {'type': bs.NinjaBotProShielded, 'point': 'BottomLeft'},
                    {'type': bs.NinjaBotProShielded,
                     'point': 'Top'} if hard else None,
                    {'type': bs.BomberBotProStatic, 'point': 'TurretTopMiddle'},
                ]},

                {'entries': [
                    {'type': bs.PirateBot, 'point': 'LeftUpper'},
                    {'type': 'delay', 'duration': 1000},
                    {'type': bs.ToughGuyBotProShielded, 'point': 'LeftLower'},
                    {'type': bs.ToughGuyBotProShielded,
                     'point': 'LeftLowerMore'},
                    {'type': 'delay', 'duration': 4000},
                    {'type': bs.PirateBot, 'point': 'RightUpper'},
                    {'type': 'delay', 'duration': 1000},
                    {'type': bs.ToughGuyBotProShielded, 'point': 'RightLower'},
                    {'type': bs.ToughGuyBotProShielded,
                     'point': 'RightUpperMore'},
                    {'type': 'delay', 'duration': 4000},
                    {'type': bs.PirateBot, 'point': 'Left'},
                    {'type': 'delay', 'duration': 5000},
                    {'type': bs.PirateBot, 'point': 'Right'},
                ]},

                {'entries': [
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopLeft'},
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopRight'},
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretBottomLeft'},
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretBottomRight'},
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopMiddleLeft'} if hard else None,
                    {'type': bs.BomberBotProStatic,
                     'point': 'TurretTopMiddleRight'} if hard else None,
                ]},
            ]
        # we generate these on the fly in endless..
        elif self._preset in ['endless', 'endlessTournament']:
            self._haveTnt = True
            self._excludePowerups = []

        else:
            raise Exception("Invalid preset: "+str(self._preset))

        # FIXME - should migrate to use setupStandardPowerupDrops()

        # spit out a few powerups and start dropping more shortly
        self._dropPowerups(
            standardPoints=True, powerupType='curse'
            if self._preset
            in ['uber', 'uberEasy']
            else(
                'landMines'
                if self._preset in ['rookie', 'rookieEasy'] else None))
        bs.gameTimer(4000, self._startPowerupDrops)
        # our TNT spawner (if applicable)
        if self._haveTnt:
            self._tntSpawner = bs.TNTSpawner(position=self._tntSpawnPosition)

        self.setupLowLifeWarningSound()

        self._updateScores()
        self._bots = bs.BotSet()

        bs.gameTimer(4000, self._startUpdatingWaves)
示例#2
0
    def onBegin(self):
        bs.CoopGameActivity.onBegin(self)

        # show controls help in kiosk mode
        if bs.getEnvironment()['kioskMode']:
            import bsUtils
            bsUtils.ControlsHelpOverlay(delay=3000,
                                        lifespan=10000,
                                        bright=True).autoRetain()

        if self._preset in ['rookie', 'rookieEasy']:
            self._excludePowerups = ['curse']
            self._haveTnt = False
            tgb = bs.ToughGuyBotLame if self._preset == 'rookieEasy' else bs.ToughGuyBot
            self._botTypesInitial = [tgb] * len(self.initialPlayerInfo)
            bb = bs.BomberBotLame if self._preset == 'rookieEasy' else bs.BomberBot
            self._botTypes7 = [bb] * (1 if len(self.initialPlayerInfo) < 3 else
                                      2)
            cb = bs.BomberBot if self._preset == 'rookieEasy' else bs.ChickBot
            self._botTypes14 = [cb] * (1 if len(self.initialPlayerInfo) < 3
                                       else 2)
        elif self._preset == 'tournament':
            self._excludePowerups = []
            self._haveTnt = True
            self._botTypesInitial = [bs.ToughGuyBot] * (
                1 if len(self.initialPlayerInfo) < 2 else 2)
            self._botTypes7 = [bs.ChickBot] * (
                1 if len(self.initialPlayerInfo) < 3 else 2)
            self._botTypes14 = [bs.NinjaBot] * (
                1 if len(self.initialPlayerInfo) < 4 else 2)
        elif self._preset in ['pro', 'proEasy', 'tournamentPro']:
            self._excludePowerups = ['curse']
            self._haveTnt = True
            self._botTypesInitial = [bs.NinjaBot] * len(self.initialPlayerInfo)
            tgb = bs.ToughGuyBot if self._preset == 'pro' else bs.ToughGuyBotLame
            self._botTypes7 = [
                tgb
            ] + [bs.BomberBot] * (1 if len(self.initialPlayerInfo) < 3 else 2)
            cb = bs.ChickBotPro if self._preset == 'pro' else bs.ChickBot
            self._botTypes14 = [cb] * (1 if len(self.initialPlayerInfo) < 3
                                       else 2)
        elif self._preset in ['uber', 'uberEasy']:
            self._excludePowerups = []
            self._haveTnt = True
            tgb = bs.ToughGuyBotPro if self._preset == 'uber' else bs.ToughGuyBot
            cb = bs.ChickBotPro if self._preset == 'uber' else bs.ChickBot
            self._botTypesInitial = [bs.MelBot
                                     ] + [tgb] * len(self.initialPlayerInfo)
            self._botTypes7 = [cb] * (1 if len(self.initialPlayerInfo) < 3 else
                                      2)
            self._botTypes14 = [bs.PirateBot] * (
                1 if len(self.initialPlayerInfo) < 3 else 2)
        else:
            raise Exception()

        self.setupLowLifeWarningSound()

        self._dropPowerups(standardPoints=True)
        bs.gameTimer(4000, self._startPowerupDrops)

        # make a bogus team for our bots
        # badTeamName = self.getTeamNameLocalized('Bad Guys')
        badTeamName = self.getTeamDisplayString('Bad Guys')
        self._botTeam = bs.Team(1, badTeamName, (0.5, 0.4, 0.4))

        for team in [self.teams[0], self._botTeam]:
            team.gameData['score'] = 0

        self.updateScores()

        # time
        self._startTime = bs.getGameTime()
        self._timeText = bs.NodeActor(
            bs.newNode('text',
                       attrs={
                           'vAttach': 'top',
                           'hAttach': 'center',
                           'hAlign': 'center',
                           'color': (1, 1, 0.5, 1),
                           'flatness': 0.5,
                           'shadow': 0.5,
                           'position': (0, -50),
                           'scale': 1.3,
                           'text': ''
                       }))

        self._timeTextInput = bs.NodeActor(
            bs.newNode('timeDisplay', attrs={'showSubSeconds': True}))
        bs.getSharedObject('globals').connectAttr('gameTime',
                                                  self._timeTextInput.node,
                                                  'time2')
        self._timeTextInput.node.connectAttr('output', self._timeText.node,
                                             'text')

        # self._updateTime()

        # update fast enough so it looks continuous
        # self._timeTextTimer = bs.Timer(43,self._updateTime,repeat=True)

        # our TNT spawner (if applicable)
        if self._haveTnt:
            self._tntSpawner = bs.TNTSpawner(position=(0, 1, -1))

        self._bots = bs.BotSet()
        self._botSpawnTimer = bs.Timer(1000, self._updateBots, repeat=True)

        for b in self._botTypesInitial:
            self._spawnBot(b)