Esempio n. 1
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()
Esempio n. 2
0
    def __init__(self, position, team):
        bsHockey.Puck.__init__(self, position)
        self.team = team

        self.tickrate = 100
        self._timeout = 5000 / self.tickrate
        self._count = self._timeout
        self._tickTimer = bs.Timer(self.tickrate,
                                   call=bs.WeakCall(self._tick),
                                   repeat=True)
        self._counter = bs.newNode('text',
                                   owner=self.node,
                                   attrs={
                                       'inWorld': True,
                                       'color': (1, 1, 1, 0.7),
                                       'scale': 0.015,
                                       'shadow': 0.5,
                                       'flatness': 1.0,
                                       'hAlign': 'center'
                                   })
        self.age = 0
        self.scored = False
        self.lastHoldingPlayer = None
        self.light = None
        self.movedSinceSpawn = False
Esempio n. 3
0
 def checkVal(val):
     self._powersGiven = True
     if val and spaz.isAlive():
         m = bs.newNode('math',
                        owner=spaz,
                        attrs={
                            'input1': (0, 1.3, 0),
                            'operation': 'add'
                        })
         spaz.node.connectAttr('torsoPosition', m,
                               'input2')
         activatedText = bsUtils.PopupText(
             "ACTIVATED",
             color=(1, 1, 1),
             scale=0.7,
             offset=(0, -1, 0)).autoRetain()
         m.connectAttr('output', activatedText.node,
                       'position')
         bs.playSound(
             bs.Powerup.getFactory().martyrdomPickSound,
             position=spaz.node.position)
         spaz.isDropped = True
         spaz.dropss = bs.Timer(1,
                                bs.Call(checkDead),
                                repeat=True)
    def __init__(self, pos=(0, 1, 0), sourcePlayer=None):

        bs.Actor.__init__(self)

        factory = self.getFactory()

        self.targetSound = factory.targetSound
        self.popSound = factory.popSound

        if sourcePlayer is None:
            self.sourcePlayers = [bs.Player(None)]
        else:
            self.sourcePlayers = [sourcePlayer]

        self.node = bs.newNode(
            'prop',
            delegate=self,
            attrs={
                'body': 'sphere',
                'position': pos,
                'velocity': (0, 0, 1),  # Не менять на (0, 0, 0)!
                'model': factory.botModel,
                'colorTexture': factory.botTexture,
                'reflection': u'powerup',
                'reflectionScale': (10, 10, 0),
                'shadowSize': 0.5,
                'extraAcceleration': (0, 20, 0),
                'materials': [bs.getSharedObject("objectMaterial")]
            })
        bs.gameTimer(30000, bs.WeakCall(self.handleMessage, bs.DieMessage()))
        self._updTimer = bs.Timer(500, bs.WeakCall(self._update), repeat=True)
Esempio n. 5
0
 def startMoving(
     self
 ):  #here we overload the default startMoving, which normally calls _update.
     #self._botUpdateTimer = bs.Timer(50,bs.WeakCall(self._update),repeat=True)
     self._botUpdateTimer = bs.Timer(50,
                                     bs.WeakCall(self.zUpdate),
                                     repeat=True)
Esempio n. 6
0
    def announceCompletion(self, sound=True):

        # even though there are technically achievements when we're not signed in,
        # lets not show them (otherwise we tend to get confusing 'controller connected'
        # achievements popping up while waiting to log in which can be confusing..
        if bsInternal._getAccountState() != 'SIGNED_IN':
            return

        # if we're being freshly complete, display/report it and whatnot
        if not [self, sound] in gAchievementsToDisplay:
            gAchievementsToDisplay.append([self, sound])

        # if there's no achievement display timer going, kick one off
        # (if one's already running it will pick this up before it dies)
        global gAchievementDisplayTimer
        global gLastAchievementDisplayTime
        # need to check last time too; its possible our timer wasn't able to clear itself if an
        # activity died and took it down with it..
        if ((gAchievementDisplayTimer is None
             or bs.getRealTime() - gLastAchievementDisplayTime > 2000)
                and bs.getActivity(exceptionOnNone=False) is not None):
            gAchievementDisplayTimer = bs.Timer(1000,
                                                _displayNextAchievement,
                                                repeat=True,
                                                timeType='net')
            _displayNextAchievement()  # show the first immediately
Esempio n. 7
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)
Esempio n. 8
0
 def onPlayerJoin(self, player):
     bs.TeamGameActivity.onPlayerJoin(self, player)
     player.gameData['mines'] = []
     if self.hasStarted:
         call = bs.WeakCall(self._spawnMine, player)
         self.mineTimers.append(
             bs.Timer(int(self.mineDelay * 1000), call, repeat=True))
Esempio n. 9
0
 def giveBallz(self, spaz):
     spaz.punchCallback = self.throwBall
     spaz.lastBallTime = bs.getGameTime()
     if self._powerExpire:
         weakSpaz = weakref.ref(spaz)
         spaz.snoExpireTimer = bs.Timer(
             self._powerLife, bs.WeakCall(self.takeBallz, weakSpaz))
Esempio n. 10
0
    def _handleHitOwnFlag(self,team,val):

        # keep track of when each player is touching their own flag so we can award points when returned
        srcNode = bs.getCollisionInfo('sourceNode')
        try: player = srcNode.getDelegate().getPlayer()
        except Exception: player = None
        if player is not None and player.exists():
            if val: player.gameData['touchingOwnFlag'] += 1
            else: player.gameData['touchingOwnFlag'] -= 1

        # if return-time is zero, just kill it immediately.. otherwise keep track of touches and count down
        if float(self.settings['Flag Touch Return Time']) <= 0.0:
            if not team.gameData['homeFlagAtBase'] and team.gameData['flag']._heldCount == 0:
                # use a node message to kill the flag instead of just killing our team's.
                # (avoids redundantly killing new flags if multiple body parts generate callbacks in one step)
                node = bs.getCollisionInfo("opposingNode")
                if node is not None and node.exists():
                    self._awardPlayersTouchingOwnFlag(team)
                    node.handleMessage(bs.DieMessage())
        # takes a non-zero amount of time to return
        else:
            if val:
                team.gameData['flagReturnTouches'] += 1
                if team.gameData['flagReturnTouches'] == 1:
                    team.gameData['touchReturnTimer'] = bs.Timer(100,call=bs.Call(self._touchReturnUpdate,team),repeat=True)
                    team.gameData['touchReturnTimerTicking'] = None
            else:
                team.gameData['flagReturnTouches'] -= 1
                if team.gameData['flagReturnTouches'] == 0:
                    team.gameData['touchReturnTimer'] = None
                    team.gameData['touchReturnTimerTicking'] = None
            if team.gameData['flagReturnTouches'] < 0:
                bs.printError('CTF: flagReturnTouches < 0; this shouldn\'t happen.')
Esempio n. 11
0
 def setScoreText(self,text):
     """
     Utility func to show a message over the flag; handy for scores.
     """
     if not self.node.exists(): return
     try: exists = self._scoreText.exists()
     except Exception: exists = False
     if not exists:
         startScale = 0.0
         math = bs.newNode('math',owner=self.node,attrs={'input1':(0,1.4,0),'operation':'add'})
         self.node.connectAttr('position',math,'input2')
         self._scoreText = bs.newNode('text',
                                       owner=self.node,
                                       attrs={'text':text,
                                              'inWorld':True,
                                              'scale':0.02,
                                              'shadow':0.5,
                                              'flatness':1.0,
                                              'hAlign':'center'})
         math.connectAttr('output',self._scoreText,'position')
     else:
         startScale = self._scoreText.scale
         self._scoreText.text = text
     self._scoreText.color = bs.getSafeColor(self.node.color)
     bs.animate(self._scoreText,'scale',{0:startScale,200:0.02})
     self._scoreTextHideTimer = bs.Timer(1000,bs.WeakCall(self._hideScoreText))
Esempio n. 12
0
    def __init__(self,
                 challengeID,
                 challengeActivity=None,
                 position=(0, 0),
                 delegate=None,
                 scale=None,
                 offset=(0, 0),
                 onCloseCall=None):

        self._challengeID = challengeID

        self._onCloseCall = onCloseCall
        if scale is None:
            scale = 2.3 if bsUI.gSmallUI else 1.65 if bsUI.gMedUI else 1.23
        self._delegate = delegate
        self._transitioningOut = False

        self._challengeActivity = challengeActivity

        self._width = 340
        self._height = 290

        self._canForfeit = False
        self._forfeitButton = None

        challenge = bsUI._getCachedChallenge(self._challengeID)
        # this stuff shouldn't change..
        if challenge is None:
            self._canForfeit = False
            self._prizeTickets = 0
            self._prizeTrophy = None
            self._level = 0
            self._waitTickets = 0
        else:
            self._canForfeit = challenge['canForfeit']
            self._prizeTrophy = challenge['prizeTrophy']
            self._prizeTickets = challenge['prizeTickets']
            self._level = challenge['level']
            t = time.time()
            self._waitTickets = max(
                1,
                int(challenge['waitTickets'] *
                    (1.0 - (t - challenge['waitStart']) /
                     (challenge['waitEnd'] - challenge['waitStart']))))

        self._bgColor = (0.5, 0.4, 0.6)

        # creates our _rootWidget
        bsUI.PopupWindow.__init__(self,
                                  position=position,
                                  size=(self._width, self._height),
                                  scale=scale,
                                  bgColor=self._bgColor,
                                  offset=offset)
        self._state = None
        self._updateTimer = bs.Timer(1000,
                                     bs.WeakCall(self._update),
                                     repeat=True,
                                     timeType='real')
        self._update()
    def handleMessage(self, m):

        # respawn dead players
        if isinstance(m, bs.PlayerSpazDeathMessage):
            bs.TeamGameActivity.handleMessage(self, m)  # augment standard
            self._aPlayerHasBeenKilled = True
            player = m.spaz.getPlayer()
            if not player.exists():
                return
            self.scoreSet.playerLostSpaz(player)
            # respawn them shortly
            respawnTime = 2000+len(self.initialPlayerInfo)*1000
            player.gameData['respawnTimer'] = bs.Timer(
                respawnTime, bs.Call(self.spawnPlayerIfExists, player))
            player.gameData['respawnIcon'] = bs.RespawnIcon(player, respawnTime)

        # whenever our evil bunny dies, respawn him and spew some eggs
        elif isinstance(m, bs.SpazBotDeathMessage):
            self._spawnEvilBunny()
            pt = m.badGuy.node.position
            for i in range(6):
                s = 0.4
                self._eggs.append(Egg(position=(pt[0]+random.uniform(-s, s),
                                                pt[1]+random.uniform(-s, s),
                                                pt[2]+random.uniform(-s, s))))
        else:
            # default handler:
            bs.TeamGameActivity.handleMessage(self, m)
Esempio n. 14
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self._updateScoreBoard()

        self._targets = []

        # number of targets is based on player count
        numTargets = min(5,len(self.initialPlayerInfo)+2)
        for i in range(numTargets):
            bs.gameTimer(5000+i*1000,self._spawnTarget)
        
        
        # this wrangles our bots
        self._bots = bs.BotSet()

        # start some timers to spawn bots
        bs.gameTimer(1000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(3,3,-2),spawnTime=3000))
        #bs.gameTimer(2000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(-3,3,-2),spawnTime=3000))
        #bs.gameTimer(3000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(5,3,-2),spawnTime=3000))
        #bs.gameTimer(4000,bs.Call(self._bots.spawnBot,bs.NinjaBot,pos=(-5,3,-2),spawnTime=3000))

        # add a few extras for multiplayer
        if len(self.initialPlayerInfo) > 2:
            bs.gameTimer(5000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(0,3,-5),spawnTime=3000))
        if len(self.initialPlayerInfo) > 3:
            bs.gameTimer(6000,bs.Call(self._bots.spawnBot,bs.ToughGuyBot,pos=(0,3,1),spawnTime=3000))

        # note: if spawns were spread out more we'd probably want to set some sort of flag on the
        # last spawn to ensure we don't inadvertantly allow a 'win' before every bot is spawned.
        # (ie: if bot 1, 2, and 3 got killed but 4 hadn't spawned yet, the game might end because
        # it sees no remaining bots.
        self._updateTimer = bs.Timer(1000,self._update,repeat=True)

        self._countdown = bs.OnScreenCountdown(150,endCall=self.endGame)
        bs.gameTimer(4000,self._countdown.start)
    def __init__(self, position=(0, 1, 0), maxBalls=5):

        bs.Actor.__init__(self)

        self.balls = []

        self.maxBalls = maxBalls

        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'extraAcceleration': (0, 18, 0),
                                   'position':
                                   position,
                                   'model':
                                   bs.getModel('tnt'),
                                   'lightModel':
                                   bs.getModel('tnt'),
                                   'body':
                                   'crate',
                                   'shadowSize':
                                   0.5,
                                   'colorTexture':
                                   bs.getTexture('achievementFlawlessVictory'),
                                   'reflection':
                                   'soft',
                                   'reflectionScale': [1],
                                   'materials':
                                   [bs.getSharedObject('objectMaterial')]
                               })
        self.timer = bs.Timer(5000, bs.Call(self.spawnBall), repeat=True)
Esempio n. 16
0
 def spawn_hold_node(self):
     if self.node is None or not self.node.exists(): return
     self.delete_hold_node()
     t = self.node.position
     t = (t[0], t[1] + 1, t[2])
     self.hold_node = bs.newNode('prop',
                                 owner=self.node,
                                 delegate=self,
                                 attrs={
                                     'position': t,
                                     'body': 'box',
                                     'bodyScale': 0.000001,
                                     'model': None,
                                     'modelScale': 0.000001,
                                     'colorTexture': None,
                                     'maxSpeed': 0,
                                     'sticky': True,
                                     'stickToOwner': True,
                                     'owner': self.node,
                                     'materials': []
                                 })
     self._c = c = bs.newNode('combine',
                              owner=self.hold_node,
                              attrs={'size': 3})
     self._c_move = [0, 0, 0]
     c.input0, c.input1, c.input2 = t
     self._c.connectAttr('output', self.hold_node, 'position')
     self._fly_timer = bs.Timer(100,
                                bs.WeakCall(self.move_hold_node, 'all'),
                                repeat=True)
 def __init__(self,position = (0,0.5,0),owner = None,prefix = 'ADMIN',prefixColor = (1,1,1),prefixAnim = {0:(1,1,1),500:(0.5,0.5,0.5)},prefixAnimate = True,particles = True):
     self.position = position
     self.owner = owner        
     ###
     
     def a():
         self.emit()
         ##
     if particles:
         self.timer = bs.Timer(10,bs.Call(a),repeat = True)
         
     #prefix
     m = bs.newNode('math', owner=self.owner, attrs={'input1': (0, 1.35, 0), 'operation': 'add'})
     self.owner.connectAttr('position', m, 'input2')
     
     self._Text = bs.newNode('text',
                                   owner=self.owner,
                                   attrs={'text':prefix, #prefix text
                                          'inWorld':True,
                                          'shadow':1.2,
                                          'flatness':1.0,
                                          'color':prefixColor,
                                          'scale':0.0,
                                          'hAlign':'center'})
                                          
     m.connectAttr('output', self._Text, 'position')
     
     bs.animate(self._Text, 'scale', {0: 0.0, 1000: 0.01}) #smooth prefix spawn
     
     #animate prefix
     if prefixAnimate:
         bsUtils.animateArray(self._Text, 'color',3, prefixAnim,True) #animate prefix color
Esempio n. 18
0
 def _startBotUpdates(self):
     self._botUpdateInterval = 3300 - 300*(len(self.players))
     self._updateBots()
     self._updateBots()
     if len(self.players) > 2: self._updateBots()
     if len(self.players) > 3: self._updateBots()
     self._botUpdateTimer = bs.Timer(int(self._botUpdateInterval),bs.WeakCall(self._updateBots))
Esempio n. 19
0
    def onBegin(self):

        bs.TeamGameActivity.onBegin(self)
        # drop a wave every few seconds.. and every so often drop the time between waves
        # ..lets have things increase faster if we have fewer players
        #self._meteorTime = 3000
        t = 7500 if len(self.players) > 2 else 4000
        if self.settings['Epic Mode']: t /= 4
        #bs.gameTimer(t,self._decrementMeteorTime,repeat=True)

        # kick off the first wave in a few seconds
        t = 3000
        if self.settings['Epic Mode']: t /= 4
        #bs.gameTimer(t,self._setMeteorTimer)
        # this wrangles our bots
        self._bots = bs.BotSet()

        for i in range(self.settings['Max Bots']):
         bPos = (-7.3+15.3*random.random(),10,-5.5+2.1*random.random())
         bs.gameTimer(4000,bs.Call(self._bots.spawnBot,self._getRandomBotType(),pos=bPos,spawnTime=0))

        self._updateTimer = bs.Timer(1000,self._onSpazBotDied,repeat=True)
        
        self._timer = bs.OnScreenTimer()
        bs.gameTimer(4000,self._timer.start)
Esempio n. 20
0
	def onBegin(self):
		bs.TeamGameActivity.onBegin(self)
		self.setupStandardTimeLimit(self.settings['Time Limit'])
		self.setupStandardPowerupDrops(enableTNT=True)
		self._boxSpawnPos = self.getMap().getFlagPosition(None)
		self._spawnBox()
		self._updateTimer = bs.Timer(1000, call=self._tick, repeat=True)
		self._updateBoxState()
Esempio n. 21
0
 def __init__(self,activity):
     self._valid = True
     self._messageDuration = 10000
     self._messageSpacing = 2000
     self._text = None
     self._activity = weakref.ref(activity)
     self._fetchTimer = bs.Timer(1000,bs.WeakCall(self._tryFetchingNews),repeat=True)
     self._tryFetchingNews()
Esempio n. 22
0
 def flash(self, countdown, extraFlash):
     self._flashTimer = bs.Timer(100,
                                 bs.WeakCall(self._doFlash),
                                 repeat=True)
     if countdown: self._flashCounter = 10
     else: self._flashCounter = int(20.0 * self._flashLength)
     if extraFlash: self._flashCounter *= 4
     self._setFlashColors(True)
Esempio n. 23
0
 def flex(actor=None):
     def work(node=None):
         if node is not None and node.exists(): node.handleMessage('celebrate', 1000)
     if actor is not None and actor.exists():
         if not hasattr(actor, '_flex') or (hasattr(actor, '_flex') and actor._flex is None):
             actor._flex = bs.Timer(1000, bs.Call(work, actor.node), repeat=True)
             work(node=actor.node)
         else: actor._flex = None
Esempio n. 24
0
 def onBegin(self):
     bs.TeamGameActivity.onBegin(self)
     self.setupStandardTimeLimit(self.settings['Time Limit'])
     self.setupStandardPowerupDrops(enableTNT=False)
     self._pow = None
     self._tntDropTimer = bs.Timer(1000 * 30, bs.WeakCall(self._dropPowBox), repeat=True)
     self._updateIcons()
     bs.gameTimer(1000, self._update, repeat=True)
Esempio n. 25
0
    def _update(self):

        # if we're down to 1 or fewer living teams, start a timer to end the game
        # (allows the dust to settle and draws to occur if deaths are close enough)
        if (len([
                team for team in self.teams
                if team.gameData['score'] < self.settings['Score to Win']
        ]) < 2) or len(self.winners) > 2:
            self._roundEndTimer = bs.Timer(500, self.endGame)
Esempio n. 26
0
    def handleMessage(self, m):

        if isinstance(m, bs.PlayerScoredMessage):
            self._score.add(m.score)
            self._updateScores()

        # respawn dead players
        elif isinstance(m, bs.PlayerSpazDeathMessage):
            self._aPlayerHasBeenKilled = True
            player = m.spaz.getPlayer()
            if player is None:
                bs.printError('FIXME: getPlayer() should no'
                              ' longer ever be returning None')
                return
            if not player.exists():
                return

            self.scoreSet.playerLostSpaz(player)

            # respawn them shortly
            respawnTime = 2000 + len(self.initialPlayerInfo) * 1000

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

        elif isinstance(m, bs.SpazBotDeathMessage):
            if m.how == 'goal':
                return
            pts, importance = m.badGuy.getDeathPoints(m.how)
            if m.killerPlayer is not None:
                try:
                    target = m.badGuy.node.position
                except Exception:
                    target = None
                try:
                    if m.killerPlayer is not None and m.killerPlayer.exists():
                        self.scoreSet.playerScored(m.killerPlayer,
                                                   pts,
                                                   target=target,
                                                   kill=True,
                                                   screenMessage=False,
                                                   importance=importance)
                        bs.playSound(self._dingSound if importance == 1 else
                                     self._dingSoundHigh,
                                     volume=0.6)
                except Exception as e:
                    print 'EXC in Runaround handling SpazBotDeathMessage:', e
            # normally we pull scores from the score-set, but if there's no
            # player lets be explicit..
            else:
                self._score.add(pts)
            self._updateScores()

        else:
            self.__superHandleMessage(m)
Esempio n. 27
0
 def onBegin(self):
     bs.TeamGameActivity.onBegin(self)
     self.setupStandardTimeLimit(self.settings['Time Limit'])
     self.setupStandardPowerupDrops()
     self._flagSpawnPos = self.getMap().getFlagPosition(None)
     self._spawnFlag()
     self._updateTimer = bs.Timer(1000, call=self._tick, repeat=True)
     self._updateFlagState()
     self.projectFlagStand(self._flagSpawnPos)
    def __init__(self, position=(0, 1, 0), team=None):

        bs.Actor.__init__(self)
        self.errorSound = bs.getSound('error')
        self.position = position
        self._team = team

        # Where do we place block?
        self.loc = bs.newNode('shield',
                              attrs={
                                  'position': position,
                                  'radius': 0.01,
                                  'color': (-8, -2, -2)
                              })

        # Block.
        self.body = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'modelScale':
                                   1,
                                   'bodyScale':
                                   1,
                                   'model':
                                   bs.getModel('tnt'),
                                   'colorTexture':
                                   bs.getTexture('powerupCurse'),
                                   'materials': [
                                       bs.getSharedObject('footingMaterial'),
                                       bs.getSharedObject('objectMaterial')
                                   ]
                               })
        self.loc.connectAttr('position', self.body, 'position')
        self.hp = 8000
        self.frozen = False  # On freeze block don't spawn enemies.
        self.position = position  # For spawn bots.
        if self._team is None:
            self._bots = bs.BotSet()
            self._botSpawnCooldown = 5000
            self.spawner = bs.Timer(self._botSpawnCooldown,
                                    self._spawnBot,
                                    repeat=True)
        self._scoreText = bs.newNode('text',
                                     owner=self.body,
                                     attrs={
                                         'text': 'HP: ' + str(self.hp),
                                         'inWorld': True,
                                         'shadow': 1.0,
                                         'flatness': 1.0,
                                         'color': (0, 1, 0),
                                         'scale': 0.01,
                                         'hAlign': 'center',
                                         'position': self.position
                                     })
        bs.gameTimer(1000, self._scoreText.delete)
Esempio n. 29
0
    def __init__(
            self, position=(0, 1, 0),
            color=(1, 1, 1),
            materials=[],
            touchable=True, droppedTimeout=None):
        """
        Instantiate a flag.

        If 'touchable' is False, the flag will only touch terrain;
        useful for things like king-of-the-hill where players should
        not be moving the flag around.

        'materials is a list of extra bs.Materials to apply to the flag.

        If 'droppedTimeout' is provided (in seconds), the flag will die
        after remaining untouched for that long once it has been moved
        from its initial position.
        """
        bs.Actor.__init__(self)

        self._initialPosition = None
        self._hasMoved = False

        factory = self.getFactory()

        if type(materials) is not list:
            # in case they passed a tuple or whatnot..
            materials = list(materials)
        if not touchable:
            materials = [factory.noHitMaterial]+materials

        self.node = bs.newNode(
            "flag",
            attrs={'position': (position[0],
                                position[1] + 0.75, position[2]),
                   'colorTexture': factory.flagTexture, 'color': color,
                   'materials':
                   [bs.getSharedObject('objectMaterial'),
                    factory.flagMaterial] + materials},
            delegate=self)

        self._droppedTimeout = droppedTimeout
        if self._droppedTimeout is not None:
            self._count = self._droppedTimeout
            self._tickTimer = bs.Timer(
                1000, call=bs.WeakCall(self._tick),
                repeat=True)
            self._counter = bs.newNode(
                'text', owner=self.node,
                attrs={'inWorld': True, 'color': (1, 1, 1, 0.7),
                       'scale': 0.015, 'shadow': 0.5, 'flatness': 1.0,
                       'hAlign': 'center'})
        else:
            self._counter = None

        self._heldCount = 0
Esempio n. 30
0
    def onBegin(self):
        bs.TeamGameActivity.onBegin(self)
        self.dropShield()
        self._shieldDropper = bs.Timer(8001,
                                       bs.WeakCall(self.dropShield),
                                       repeat=True)
        self.setupStandardTimeLimit(self.settings['Time Limit'])
        bsGlobals = bs.getSharedObject('globals')
        if self.settings['Obstacles']:
            count = self.settings['Obstacles count']
            map = bs.getActivity()._map.getName()
            for i in range(count):
                if map == 'Football Stadium':
                    radius = (random.uniform(-10, 1),
                              6,
                              random.uniform(-4.5, 4.5)) \
                              if i > count/2 else (random.uniform(10, 1), 6, random.uniform(-4.5, 4.5))
                else:
                    radius = (random.uniform(-10,1),
                              6,
                              random.uniform(-8,8)) \
                              if i > count/2 else (random.uniform(10, 1), 6, random.uniform(-8, 8))

                Boxes(position=radius,
                      graphics=self.settings['Graphics'],
                      randomColor=self.settings['Random obstacles color'],
                      mirror=self.settings['Obstacles mirror shots'],
                      form=self.settings['Obstacles form']).autoRetain()

        if self.settings['Graphics'] == 2:
            bsGlobals.tint = (bsGlobals.tint[0] - 0.6, bsGlobals.tint[1] - 0.6,
                              bsGlobals.tint[2] - 0.6)
            light = bs.newNode('light', attrs={
                'position': (9, 10, 0) if map == 'Football Stadium' else (6, 7, -2) \
                    if not map == 'Rampage' else (6, 11, -2) if not map == 'The Pad' else (6, 8.5, -2),
                'color': (0.4, 0.4, 0.45),
                'radius': 1,
                'intensity': 6,
                'volumeIntensityScale': 10.0})

            light2 = bs.newNode('light', attrs={
                'position': (-9, 10, 0) if map == 'Football Stadium' else (-6, 7, -2) \
                    if not map == 'Rampage' else (-6, 11, -2) if not map == 'The Pad' else (-6, 8.5, -2),
                'color': (0.4, 0.4, 0.45),
                'radius': 1,
                'intensity': 6,
                'volumeIntensityScale': 10.0})

        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')