예제 #1
0
    def spawnPlayer(self, player):
        position = self.getMap().getFFAStartPosition(self.players)
        angle = None
        name = player.getName()
        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = NewPlayerSpaz(color=player.color,
                             highlight=player.highlight,
                             character=player.character,
                             player=player)
        player.setActor(spaz)
        player.gameData['boxes'] = 0

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer(enablePickUp=False)
        if self.settings['Equip Boxing Gloves']:
            spaz.equipBoxingGloves()
        if self.settings['Equip Shield']:
            spaz.equipShields()

        spaz.playBigDeathSound = True
        self.scoreSet.playerGotNewSpaz(player, spaz)

        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
예제 #2
0
    def _updateText(self):

        if self.ready:
            # once we're ready, we've saved the name, so lets ask the system
            # for it so we get appended numbers and stuff
            text = bs.Lstr(value=self._player.getName(full=True))
            text = bs.Lstr(value='${A} (${B})',
                           subs=[('${A}', text),
                                 ('${B}', bs.Lstr(resource='readyText'))])
        else:
            text = bs.Lstr(value=self._getName(full=True))

        canSwitchTeams = len(self.getLobby()._teams) > 1

        # flash as we're coming in
        finColor = bs.getSafeColor(self.getColor()) + (1, )
        if not self._inited:
            bsUtils.animateArray(self._textNode, 'color', 4, {
                150: finColor,
                250: (2, 2, 2, 1),
                350: finColor
            })
        else:
            # blend if we're in teams mode; switch instantly otherwise
            if canSwitchTeams:
                bsUtils.animateArray(self._textNode, 'color', 4, {
                    0: self._textNode.color,
                    100: finColor
                })
            else:
                self._textNode.color = finColor

        self._textNode.text = text
예제 #3
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))
예제 #4
0
	def spawnPlayer(self, player):



		if isinstance(self.getSession(), bs.TeamsSession):
			position = self.getMap().getStartPosition(player.getTeam().getID())
		else:
			# otherwise do free-for-all spawn locations
			position = self.getMap().getFFAStartPosition(self.players)

		angle = None


		#spaz = self.spawnPlayerSpaz(player)

		# lets reconnect this player's controls to this
		# spaz but *without* the ability to attack or pick stuff up
		#spaz.connectControlsToPlayer(enablePunch=False,
		#							 enableBomb=False,
		#							 enablePickUp=False)

		# also lets have them make some noise when they die..
		#spaz.playBigDeathSound = True

		name = player.getName()

		lightColor = bsUtils.getNormalizedColor(player.color)
		displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

		spaz = Player(color=player.color,
							 highlight=player.highlight,
							 character=player.character,
							 player=player)
		player.setActor(spaz)

		# we want a bigger area-of-interest in co-op mode
		# if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0
		# else: spaz.node.areaOfInterestRadius = 5.0

		# if this is co-op and we're on Courtyard or Runaround, add the material that allows us to
		# collide with the player-walls
		# FIXME; need to generalize this
		if isinstance(self.getSession(), bs.CoopSession) and self.getMap().getName() in ['Courtyard', 'Tower D']:
			mat = self.getMap().preloadData['collideWithWallMaterial']
			spaz.node.materials += (mat,)
			spaz.node.rollerMaterials += (mat,)

		spaz.node.name = name
		spaz.node.nameColor = displayColor
		spaz.connectControlsToPlayer( enableJump=True, enablePunch=True, enablePickUp=False, enableBomb=True, enableRun=True, enableFly=False)
		self.scoreSet.playerGotNewSpaz(player,spaz)

		# move to the stand position and add a flash of light
		spaz.handleMessage(bs.StandMessage(position,angle if angle is not None else random.uniform(0, 360)))
		t = bs.getGameTime()
		bs.playSound(self._spawnSound, 1, position=spaz.node.position)
		light = bs.newNode('light', attrs={'color': lightColor})
		spaz.node.connectAttr('position', light, 'position')
		bsUtils.animate(light, 'intensity', {0:0, 250:1, 500:0})
		bs.gameTimer(500, light.delete)
예제 #5
0
    def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None):
        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)
        spaz = AntiGravityPlayerSpaz(color=color,
                                     highlight=highlight,
                                     character=player.character,
                                     player=player)
        player.setActor(spaz)
        if isinstance(self.getSession(),
                      bs.CoopSession) and self.getMap().getName() in [
                          'Courtyard', 'Tower D'
                      ]:
            mat = self.getMap().preloadData['collideWithWallMaterial']
            spaz.node.materials += (mat, )
            spaz.node.rollerMaterials += (mat, )
        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        bs.gameTimer(1000, bs.Call(self.raisePlayer, player))
        return spaz
예제 #6
0
    def spawnPlayer(self, player):

        position = self.getMap().getFFAStartPosition(self.players)
        angle = 20
        name = player.getName()

        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = BrickMan(color=player.color,
                        highlight=player.highlight,
                        character=player.character,
                        player=player)
        player.setActor(spaz)

        spaz.node.name = '建筑师\n'.decode('utf8') + name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(bs.StandMessage(position, angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)

        spaz.connectControlsToPlayer(enablePunch=True,
                                     enableBomb=True,
                                     enablePickUp=False)
        spaz.playBigDeathSound = True
        spaz.initArchitect()
        return spaz
	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, 0.6, 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((1.0, 1.0, 0.4))
		bs.animate(self._scoreText, 'scale', {0: startScale, 200: 0.02})
		self._scoreTextHideTimer = bs.Timer(1000, bs.WeakCall(self._hideScoreText))
    def spawnPlayer(self, player):

        if isinstance(self.getSession(), bs.TeamsSession):
            position = self.getMap().getStartPosition(player.getTeam().getID())
        else:
            # otherwise do free-for-all spawn locations
            position = self.getMap().getFFAStartPosition(self.players)

        angle = None

        # spaz = self.spawnPlayerSpaz(player)

        # lets reconnect this player's controls to this
        # spaz but *without* the ability to attack or pick stuff up
        # spaz.connectControlsToPlayer(enablePunch=False,
        # 							 enableBomb=False,
        # 							 enablePickUp=False)

        # also lets have them make some noise when they die..
        # spaz.playBigDeathSound = True

        name = player.getName()

        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = Player(color=player.color, highlight=player.highlight, character=player.character, player=player)
        player.setActor(spaz)

        # we want a bigger area-of-interest in co-op mode
        # if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0
        # else: spaz.node.areaOfInterestRadius = 5.0

        # if this is co-op and we're on Courtyard or Runaround, add the material that allows us to
        # collide with the player-walls
        # FIXME; need to generalize this
        if isinstance(self.getSession(), bs.CoopSession) and self.getMap().getName() in ["Courtyard", "Tower D"]:
            mat = self.getMap().preloadData["collideWithWallMaterial"]
            spaz.node.materials += (mat,)
            spaz.node.rollerMaterials += (mat,)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer(
            enableJump=True, enablePunch=True, enablePickUp=False, enableBomb=True, enableRun=True, enableFly=False
        )
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(bs.StandMessage(position, angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode("light", attrs={"color": lightColor})
        spaz.node.connectAttr("position", light, "position")
        bsUtils.animate(light, "intensity", {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
예제 #9
0
    def setboxScoreText(self, t, color=(1, 1, 0.4), flash=False):
        """
        Utility func to show a message momentarily over our spaz that follows him around;
        Handy for score updates and things.
        """
        colorFin = bs.getSafeColor(color)[:3]
        if not self.node.exists(): return
        try:
            exists = self._scoreText.exists()
        except Exception:
            exists = False
        if not exists:
            startScale = 0.0
            m = bs.newNode('math',
                           owner=self.node,
                           attrs={
                               'input1': (0, 1.4, 0),
                               'operation': 'add'
                           })
            self.node.connectAttr('position', m, 'input2')
            self._scoreText = bs.newNode('text',
                                         owner=self.node,
                                         attrs={
                                             'text': t,
                                             'inWorld': True,
                                             'shadow': 1.0,
                                             'flatness': 1.0,
                                             'color': colorFin,
                                             'scale': 0.02,
                                             'hAlign': 'center'
                                         })
            m.connectAttr('output', self._scoreText, 'position')
        else:
            self._scoreText.color = colorFin
            startScale = self._scoreText.scale
            self._scoreText.text = t
        if flash:
            combine = bs.newNode("combine",
                                 owner=self._scoreText,
                                 attrs={'size': 3})
            sc = 1.8
            offs = 0.5
            t = 300
            for i in range(3):
                c1 = offs + sc * colorFin[i]
                c2 = colorFin[i]
                bs.animate(combine, 'input' + str(i), {
                    0.5 * t: c2,
                    0.75 * t: c1,
                    1.0 * t: c2
                })
            combine.connectAttr('output', self._scoreText, 'color')

        bs.animate(self._scoreText, 'scale', {0: startScale, 200: 0.02})
예제 #10
0
    def spawnPlayer(self, player):

        position = self.getMap().getFFAStartPosition(self.players)
        angle = 20
        name = player.getName()

        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = grimPlayer(color=player.color,
                          highlight=player.highlight,
                          character=player.character,
                          player=player,
                          gameProtectionTime=self.settings['Protection Time After Catching'],
                          hitPoints=self.settings['Player HP'])
        player.setActor(spaz)
        # For some reason, I can't figure out how to get a list of all spaz.
        # Therefore, I am making the list here so I can get which spaz belongs
        # to the player supplied by HitMessage.
        # self.playerList.append(spaz)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # add landmine
        spaz.bombTypeDefault = 'landMine'  # random.choice(['ice', 'impact', 'landMine', 'normal', 'sticky', 'tnt'])
        spaz.bombType = spaz.bombTypeDefault

        # move to the stand position and add a flash of light
        spaz.handleMessage(bs.StandMessage(position, angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)

        # lets reconnect this player's controls to this
        # spaz but *without* the ability to attack or pick stuff up
        spaz.connectControlsToPlayer(enablePunch=False,
                                     enableBomb=self.settings['Allow Landmine'],
                                     enablePickUp=False)
        # player.assignInputCall('pickUpPress', lambda: None)
        # player.assignInputCall('pickUpRelease', lambda: None)
        # also lets have them make some noise when they die..
        spaz.playBigDeathSound = True

        return spaz
예제 #11
0
    def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None):
        """
        Create and wire up a bs.PlayerSpaz for the provide bs.Player.
        """
        position = self.getMap().getFFAStartPosition(self.players)
        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)
        spaz = PlayerSpaz_Infection(color=color,
                                    highlight=highlight,
                                    character=player.character,
                                    player=player)
        player.setActor(spaz)

        # we want a bigger area-of-interest in co-op mode
        # if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0
        # else: spaz.node.areaOfInterestRadius = 5.0

        # if this is co-op and we're on Courtyard or Runaround, add the material that allows us to
        # collide with the player-walls
        # FIXME; need to generalize this
        if isinstance(self.getSession(),
                      bs.CoopSession) and self.getMap().getName() in [
                          'Courtyard', 'Tower D'
                      ]:
            mat = self.getMap().preloadData['collideWithWallMaterial']
            spaz.node.materials += (mat, )
            spaz.node.rollerMaterials += (mat, )

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        return spaz
예제 #12
0
    def __init__(self,player,position,scale,showLives=True,showDeath=True,
                 nameScale=1.0,nameMaxWidth=115.0,flatness=1.0,shadow=1.0):
        bs.Actor.__init__(self)

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

        self._outlineTex = bs.getTexture('characterIconMask')
        
        icon = player.getIcon()
        self.node = bs.newNode('image',
                               owner=self,
                               attrs={'texture':icon['texture'],
                                      'tintTexture':icon['tintTexture'],
                                      'tintColor':icon['tintColor'],
                                      'vrDepth':400,
                                      'tint2Color':icon['tint2Color'],
                                      'maskTexture':self._outlineTex,
                                      'opacity':1.0,
                                      'absoluteScale':True,
                                      'attach':'bottomCenter'})
        self._nameText = bs.newNode('text',
                                    owner=self.node,
                                    attrs={'text':bs.Lstr(value=player.getName()),
                                           'color':bs.getSafeColor(player.getTeam().color),
                                           'hAlign':'center',
                                           'vAlign':'center',
                                           'vrDepth':410,
                                           'maxWidth':nameMaxWidth,
                                           'shadow':shadow,
                                           'flatness':flatness,
                                           'hAttach':'center',
                                           'vAttach':'bottom'})
        if self._showLives:
            self._livesText = bs.newNode('text',
                                         owner=self.node,
                                         attrs={'text':'x0',
                                                'color':(1,1,0.5),
                                                'hAlign':'left',
                                                'vrDepth':430,
                                                'shadow':1.0,
                                                'flatness':1.0,
                                                'hAttach':'center',
                                                'vAttach':'bottom'})
        self.setPositionAndScale(position,scale)
예제 #13
0
    def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None):
        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)
        position = self.getMap().getFFAStartPosition(self.players)
        spaz = JumpSpaz(color=color,
                        highlight=highlight,
                        character=player.character,
                        player=player)
        player.setActor(spaz)
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
예제 #14
0
    def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None):
        posList = ((0, 5, 0), (9, 11, 0), (0, 12, 0), (-11, 11, 0))
        try:
            pos = posList[player.gameData['lastPoint']]
        except:
            pos = (0, 5, 0)
        position = (pos[0] + random.random() * 2 - 1, pos[1], pos[2])
        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)
        spaz = bs.PlayerSpaz(color=color,
                             highlight=highlight,
                             character=player.character,
                             player=player)
        player.setActor(spaz)
        if isinstance(self.getSession(),
                      bs.CoopSession) and self.getMap().getName() in [
                          'Courtyard', 'Tower D'
                      ]:
            mat = self.getMap().preloadData['collideWithWallMaterial']
            spaz.node.materials += (mat, )
            spaz.node.rollerMaterials += (mat, )
        spaz.node.name = name
        spaz.node.nameColor = displayColor
        if self._raceStarted: spaz.connectControlsToPlayer()
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        if not self._raceStarted: player.gameData['lastPoint'] = 0
        bs.gameTimer(250, bs.Call(self.checkPt, player))
        return spaz
예제 #15
0
    def spawnPlayer(self, player):
        position = self.getMap().getFFAStartPosition(self.players)
        angle = 20
        name = player.getName()

        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = HunterSpaz(color=player.color,
                          highlight=player.highlight,
                          character=player.character,
                          player=player,
                          force_fly=False,
                          allowAim=self.settings[JungleHunterLanguage.aimHelp])
        player.setActor(spaz)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(bs.StandMessage(position, angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)

        # lets reconnect this player's controls to this
        # spaz but *without* the ability to attack or pick stuff up
        spaz.connectControlsToPlayer(enablePunch=False,
                                     enableBomb=True,
                                     enablePickUp=False)
        spaz.initArcher()
        spaz.playBigDeathSound = True

        return spaz
예제 #16
0
    def spawnPlayerSpaz(self, player):
        position = self.init_position
        if self.teamsOrFFA() == 'teams':
            position = self.team_init_positions[player.getTeam().getID() % 2]

        angle = None

        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)
        spaz = AbyssPlayerSpaz(color=color,
                               highlight=highlight,
                               character=player.character,
                               player=player)
        player.setActor(spaz)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer(enablePunch=False,
                                     enableBomb=True,
                                     enablePickUp=False)
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        spaz.playBigDeathSound = True
        return spaz
예제 #17
0
    def spawnPlayerSpaz(self, player, position=(0, 0, 0), angle=None):
        """
        Create and wire up a bs.PlayerSpaz for the provide bs.Player.
        """
        position = self.getMap().getFFAStartPosition(self.players)
        name = player.getName()
        color = player.color
        highlight = player.highlight

        lightColor = bsUtils.getNormalizedColor(color)
        displayColor = bs.getSafeColor(color, targetIntensity=0.75)

        bt = random.choice([
            'Jumper', 'Hopper', 'Bomber', 'Stronger', 'Flash', 'Frozenman',
            'Shieldman'
        ])
        if bt == 'Jumper':
            bt = PlayerSpazTeleporter
            name += '\nJUMPER'
        elif bt == 'Hopper':
            bt = PlayerSpazJumper
            name += '\nHOPPER'
        elif bt == 'Bomber':
            bt = PlayerSpazBomber
            name += '\nBOMBER'
        elif bt == 'Stronger':
            extra = 'strong'
            bt = PlayerSpazNormal
            name += '\nHULK'
        elif bt == 'Flash':
            extra = 'speed'
            bt = PlayerSpazNormal
            name += '\nFLASH'
        elif bt == 'Frozenman':
            bt = PlayerSpazFrozenman
            name += '\nICEMAN'
        elif bt == 'Shieldman':
            extra = 'shield'
            bt = PlayerSpazNormal
            name += '\nSHIELDMAN'

        s = spaz = bt(color=color,
                      highlight=highlight,
                      character=player.character,
                      player=player)
        if bt == PlayerSpazFrozenman: spaz.bombType = 'ice'
        if bt == PlayerSpazNormal and extra == 'speed': spaz.equipSpeed()
        if bt == PlayerSpazNormal and extra == 'shield': spaz.equipShields()
        if bt == PlayerSpazNormal and extra == 'strong': s._punchPowerScale = 5
        player.setActor(spaz)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer()

        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        return spaz
예제 #18
0
    def __init__(self, scoreboard, team, doCover, scale, label, flashLength):

        self._scoreboard = weakref.ref(scoreboard)

        self._doCover = doCover
        self._scale = scale

        self._flashLength = flashLength

        self._width = 140.0 * self._scale
        self._height = 32.0 * self._scale
        self._barWidth = 2.0 * self._scale
        self._barHeight = 32.0 * self._scale

        self._barTex = self._backingTex = bs.getTexture('bar')
        self._coverTex = bs.getTexture('uiAtlas')
        self._model = bs.getModel('meterTransparent')

        safeTeamColor = bs.getSafeColor(team.color, targetIntensity=1.0)

        vr = bs.getEnvironment()['vrMode']

        #if self._doCover: self._backingColor = [0.05+c*0.17 for c in team.color]
        if self._doCover:
            if vr:
                self._backingColor = [0.1 + c * 0.1 for c in safeTeamColor]
                #if vr: self._backingColor = [0,0,0]
            else:
                self._backingColor = [0.05 + c * 0.17 for c in safeTeamColor]
        else:
            self._backingColor = [0.05 + c * 0.1 for c in safeTeamColor]

        self._backing = bs.NodeActor(
            bs.newNode('image',
                       attrs={
                           'scale': (self._width, self._height),
                           'opacity':
                           (0.8 if vr else 0.8) if self._doCover else 0.5,
                           'color': self._backingColor,
                           'vrDepth': -3,
                           'attach': 'topLeft',
                           'texture': self._backingTex
                       }))

        #safeTeamColor = tuple([0.5 + 0.7*c for c in team.color])
        #print 'GOT',safeTeamColor,safeTeamColor2
        # if self._doCover: self._barColor = safeTeamColor
        # else: self._barColor = [0.3+c*0.6 for c in safeTeamColor]
        self._barColor = safeTeamColor

        self._bar = bs.NodeActor(
            bs.newNode('image',
                       attrs={
                           'opacity': 0.7,
                           'color': self._barColor,
                           'attach': 'topLeft',
                           'texture': self._barTex
                       }))

        self._barScale = bs.newNode('combine',
                                    owner=self._bar.node,
                                    attrs={
                                        'size': 2,
                                        'input0': self._barWidth,
                                        'input1': self._barHeight
                                    })

        self._barScale.connectAttr('output', self._bar.node, 'scale')

        self._barPosition = bs.newNode('combine',
                                       owner=self._bar.node,
                                       attrs={
                                           'size': 2,
                                           'input0': 0,
                                           'input1': 0
                                       })

        self._barPosition.connectAttr('output', self._bar.node, 'position')

        #self._coverColor = [0.2 + c*1.0 for c in team.color]
        self._coverColor = safeTeamColor

        if self._doCover:
            self._cover = bs.NodeActor(
                bs.newNode('image',
                           attrs={
                               'scale':
                               (self._width * 1.15, self._height * 1.6),
                               'opacity': 1.0,
                               'color': self._coverColor,
                               'vrDepth': 2,
                               'attach': 'topLeft',
                               'texture': self._coverTex,
                               'modelTransparent': self._model
                           }))

        c = safeTeamColor
        #c = [0.2 + 1.0*c for c in team.color] + [1.0]
        self._scoreText = bs.NodeActor(
            bs.newNode('text',
                       attrs={
                           'hAttach': 'left',
                           'vAttach': 'top',
                           'hAlign': 'right',
                           'vAlign': 'center',
                           'maxWidth': 130.0 * (1.0 - scoreboard._scoreSplit),
                           'vrDepth': 2,
                           'scale': self._scale * 0.9,
                           'text': '',
                           'shadow': 1.0 if vr else 0.5,
                           'flatness':
                           (1.0 if vr else 0.5) if self._doCover else 1.0,
                           'color': c
                       }))

        c = safeTeamColor

        if label is not None:
            teamNameLabel = label
        else:
            teamNameLabel = team.name
            # we do our own clipping here; should probably try to tap into some existing functionality
            if type(teamNameLabel) is bs.Lstr:
                if teamNameLabel.isFlatValue():
                    v = teamNameLabel.evaluate()
                    if len(v) > 10:
                        teamNameLabel = v[:10] + '...'
            else:
                if len(teamNameLabel) > 10:
                    teamNameLabel = teamNameLabel[:10] + '...'
                teamNameLabel = bs.Lstr(value=teamNameLabel)

        self._nameText = bs.NodeActor(
            bs.newNode('text',
                       attrs={
                           'hAttach': 'left',
                           'vAttach': 'top',
                           'hAlign': 'left',
                           'vAlign': 'center',
                           'vrDepth': 2,
                           'scale': self._scale * 0.9,
                           'shadow': 1.0 if vr else 0.5,
                           'flatness':
                           (1.0 if vr else 0.5) if self._doCover else 1.0,
                           'maxWidth': 130 * scoreboard._scoreSplit,
                           'text': teamNameLabel,
                           'color': c + (1.0, )
                       }))

        self._score = None
예제 #19
0
def bsScoreBoardinit(self, scoreboard, team, doCover, scale, label,
                     flashLength):

    self._scoreboard = weakref.ref(scoreboard)
    self._doCover = False
    self._scale = scale
    self._flashLength = flashLength
    self._width = 140.0 * self._scale
    self._height = 32.0 * self._scale
    self._barWidth = 2.0 * self._scale
    self._barHeight = 32.0 * self._scale
    self._barTex = self._backingTex = bs.getTexture('bar')
    self._coverTex = bs.getTexture('uiAtlas')
    self._model = bs.getModel('meterTransparent')

    safeTeamColor = bs.getSafeColor(team.color, targetIntensity=1.0)

    vr = bs.getEnvironment()['vrMode']

    if self._doCover:
        if vr:
            self._backingColor = [0.1 + c * 0.1 for c in safeTeamColor]
        else:
            self._backingColor = [0.05 + c * 0.17 for c in safeTeamColor]
    else:
        self._backingColor = [0.05 + c * 0.1 for c in safeTeamColor]

    self._backing = bs.NodeActor(
        bs.newNode('image',
                   attrs={
                       'scale': (self._width, self._height),
                       'opacity':
                       (0.8 if vr else 0.8) if self._doCover else 0.5,
                       'color': self._backingColor,
                       'vrDepth': -3,
                       'attach': 'topLeft',
                       'texture': self._backingTex
                   }))

    self._barColor = safeTeamColor
    self._bar = bs.NodeActor(
        bs.newNode('image',
                   attrs={
                       'opacity': 0.7,
                       'color': self._barColor,
                       'attach': 'topLeft',
                       'texture': self._barTex
                   }))

    self._barScale = bs.newNode('combine',
                                owner=self._bar.node,
                                attrs={
                                    'size': 2,
                                    'input0': self._barWidth,
                                    'input1': self._barHeight
                                })

    self._barScale.connectAttr('output', self._bar.node, 'scale')

    self._barPosition = bs.newNode('combine',
                                   owner=self._bar.node,
                                   attrs={
                                       'size': 2,
                                       'input0': 0,
                                       'input1': 0
                                   })

    self._barPosition.connectAttr('output', self._bar.node, 'position')

    self._coverColor = safeTeamColor

    if self._doCover:
        self._cover = bs.NodeActor(
            bs.newNode('image',
                       attrs={
                           'scale': (self._width * 1.15, self._height * 1.6),
                           'opacity': 1.0,
                           'color': self._coverColor,
                           'vrDepth': 2,
                           'attach': 'topLeft',
                           'texture': self._coverTex,
                           'modelTransparent': self._model
                       }))

    c = safeTeamColor
    self._scoreText = bs.NodeActor(
        bs.newNode('text',
                   attrs={
                       'hAttach': 'left',
                       'vAttach': 'top',
                       'hAlign': 'right',
                       'vAlign': 'center',
                       'maxWidth': 130.0 * (1.0 - scoreboard._scoreSplit),
                       'vrDepth': 2,
                       'scale': self._scale * 0.9,
                       'text': '',
                       'shadow': 1.0 if vr else 0.5,
                       'flatness':
                       (1.0 if vr else 0.5) if self._doCover else 1.0,
                       'color': c
                   }))

    c = safeTeamColor

    if label is not None:
        teamNameLabel = label
    else:
        teamNameLabel = team.name

        # we do our own clipping here; should probably try to tap into some
        # existing functionality
        if type(teamNameLabel) is bs.Lstr:

            # hmmm; if the team-name is a non-translatable value lets go
            # ahead and clip it otherwise we leave it as-is so
            # translation can occur..
            if teamNameLabel.isFlatValue():
                v = teamNameLabel.evaluate()
                # in python < 3.5 some unicode chars can have length 2,
                # so we need to convert to raw int vals for safer trimming
                vChars = bs.uniToInts(v)
                if len(vChars) > 10:
                    teamNameLabel = bs.Lstr(value=bs.uniFromInts(vChars[:10]) +
                                            '...')
        else:
            # in python < 3.5 some unicode chars can have length 2,
            # so we need to convert to raw int vals for safe trimming
            teamNameLabelChars = bs.uniToInts(teamNameLabel)
            if len(teamNameLabelChars) > 10:
                teamNameLabel = bs.uniFromInts(teamNameLabelChars[:10]) + '...'
            teamNameLabel = bs.Lstr(value=teamNameLabel)

    self._nameText = bs.NodeActor(
        bs.newNode('text',
                   attrs={
                       'hAttach': 'left',
                       'vAttach': 'top',
                       'hAlign': 'left',
                       'vAlign': 'center',
                       'vrDepth': 2,
                       'scale': self._scale * 0.9,
                       'shadow': 1.0 if vr else 0.5,
                       'flatness':
                       (1.0 if vr else 0.5) if self._doCover else 1.0,
                       'maxWidth': 130 * scoreboard._scoreSplit,
                       'text': teamNameLabel,
                       'color': c + (1.0, )
                   }))

    self._score = None
예제 #20
0
    def spawnPlayer(self, player):
        """This next line is the default spawn line. But we need to spawn our special guy"""
        #self.spawnPlayerSpaz(player,self._getSpawnPoint(player))
        #position = self._getSpawnPoint(player)
        #if isinstance(self.getSession(), bs.TeamsSession):
        #    position = self.getMap().getStartPosition(player.getTeam().getID())
        #else:
        #	# otherwise do free-for-all spawn locations
        position = self.getMap().getFFAStartPosition(self.players)

        angle = 20

        #spaz = self.spawnPlayerSpaz(player)

        # lets reconnect this player's controls to this
        # spaz but *without* the ability to attack or pick stuff up
        #spaz.connectControlsToPlayer(enablePunch=False,
        #							 enableBomb=False,
        #							 enablePickUp=False)

        # also lets have them make some noise when they die..
        #spaz.playBigDeathSound = True

        name = player.getName()

        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)

        spaz = PlayerSpaz_Zom(color=player.color,
                              highlight=player.highlight,
                              character=player.character,
                              player=player)
        player.setActor(spaz)
        #For some reason, I can't figure out how to get a list of all spaz.
        #Therefore, I am making the list here so I can get which spaz belongs
        #to the player supplied by HitMessage.
        self.spazList.append(spaz)
        # we want a bigger area-of-interest in co-op mode
        # if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0
        # else: spaz.node.areaOfInterestRadius = 5.0

        # if this is co-op and we're on Courtyard or Runaround, add the material that allows us to
        # collide with the player-walls
        # FIXME; need to generalize this
        if isinstance(self.getSession(),
                      bs.CoopSession) and self.getMap().getName() in [
                          'Courtyard', 'Tower D'
                      ]:
            mat = self.getMap().preloadData['collideWithWallMaterial']
            spaz.node.materials += (mat, )
            spaz.node.rollerMaterials += (mat, )

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer(
            enablePickUp=False
        )  #Unfortunately, I can't figure out how to prevent picking up other player but allow other pickup.
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        #Start code to spawn special guy:
        #End of code to spawn special guy
        if not self._soloMode:
            bs.gameTimer(300, bs.Call(self._printLives, player))

        # if we have any icons, update their state
        for icon in player.gameData['icons']:
            icon.handlePlayerSpawned()
예제 #21
0
    def doHitAtPosition(self, pos, player):
        activity = self.getActivity()

        # ignore hits if the game is over or if we've already been hit
        if activity.hasEnded() or self._hit or not self._nodes: return 0

        diff = (bs.Vector(*pos) - self._position)
        diff[
            1] = 0.0  # disregard y difference (our target point probably isnt exactly on the ground anyway)
        dist = diff.length()

        bullsEye = False
        points = 0
        if dist <= self._r3 + self._rFudge:
            # inform our activity that we were hit
            self._hit = True
            self.getActivity().handleMessage(self.TargetHitMessage())
            keys = {0: (1, 0, 0), 49: (1, 0, 0), 50: (1, 1, 1), 100: (0, 1, 0)}
            cDull = (0.3, 0.3, 0.3)
            if dist <= self._r1 + self._rFudge:
                bullsEye = True
                self._nodes[1].color = cDull
                self._nodes[2].color = cDull
                bs.animateArray(self._nodes[0], 'color', 3, keys, loop=True)
                popupScale = 1.8
                popupColor = (1, 1, 0, 1)
                streak = player.gameData['streak']
                points = 10 + min(20, streak * 2)
                bs.playSound(bs.getSound('bellHigh'))
                if streak > 0:
                    bs.playSound(
                        bs.getSound(
                            'orchestraHit4' if streak > 3 else
                            'orchestraHit3' if streak > 2 else
                            'orchestraHit2' if streak > 1 else 'orchestraHit'))
            elif dist <= self._r2 + self._rFudge:
                self._nodes[0].color = cDull
                self._nodes[2].color = cDull
                bs.animateArray(self._nodes[1], 'color', 3, keys, loop=True)
                popupScale = 1.25
                popupColor = (1, 0.5, 0.2, 1)
                points = 4
                bs.playSound(bs.getSound('bellMed'))
            else:
                self._nodes[0].color = cDull
                self._nodes[1].color = cDull
                bs.animateArray(self._nodes[2], 'color', 3, keys, loop=True)
                popupScale = 1.0
                popupColor = (0.8, 0.3, 0.3, 1)
                points = 2
                bs.playSound(bs.getSound('bellLow'))

            # award points/etc.. (technically should probably leave this up to the activity)
            popupStr = "+" + str(points)

            # if there's more than 1 player in the game, include their names and colors
            # so they know who got the hit
            if len(activity.players) > 1:
                popupColor = bs.getSafeColor(player.color,
                                             targetIntensity=0.75)
                popupStr += ' ' + player.getName()
            bs.PopupText(popupStr,
                         position=self._position,
                         color=popupColor,
                         scale=popupScale).autoRetain()

            # give this player's team points and update the score-board
            player.getTeam().gameData['score'].add(points)
            activity._updateScoreBoard()

            # also give this individual player points (only applies in teams mode)
            activity.scoreSet.playerScored(player,
                                           points,
                                           showPoints=False,
                                           screenMessage=False)

            bs.animateArray(self._nodes[0], 'size', 1, {
                800: self._nodes[0].size,
                1000: [0.0]
            })
            bs.animateArray(self._nodes[1], 'size', 1, {
                850: self._nodes[1].size,
                1050: [0.0]
            })
            bs.animateArray(self._nodes[2], 'size', 1, {
                900: self._nodes[2].size,
                1100: [0.0]
            })
            bs.gameTimer(1100, bs.Call(self.handleMessage, bs.DieMessage()))

        return bullsEye
예제 #22
0
    def spawnPlayerZombie(self, player):
        position = self.getMap().getFFAStartPosition(self.players)
        angle = 20
        name = player.getName()
        lightColor = bsUtils.getNormalizedColor(player.color)
        displayColor = bs.getSafeColor(player.color, targetIntensity=0.75)
        spaz = PlayerZombie(color=player.color,
                            highlight=player.highlight,
                            character='Kronk2',
                            player=player)
        player.setActor(spaz)
        #For some reason, I can't figure out how to get a list of all spaz.
        #Therefore, I am making the list here so I can get which spaz belongs
        #to the player supplied by HitMessage.
        self.spazList.append(spaz)
        # we want a bigger area-of-interest in co-op mode
        # if isinstance(self.getSession(),bs.CoopSession): spaz.node.areaOfInterestRadius = 5.0
        # else: spaz.node.areaOfInterestRadius = 5.0

        # if this is co-op and we're on Courtyard or Runaround, add the material that allows us to
        # collide with the player-walls
        # FIXME; need to generalize this
        if isinstance(self.getSession(),
                      bs.CoopSession) and self.getMap().getName() in [
                          'Courtyard', 'Tower D'
                      ]:
            mat = self.getMap().preloadData['collideWithWallMaterial']
            spaz.node.materials += (mat, )
            spaz.node.rollerMaterials += (mat, )
        #Need to prevent picking up powerups:
        pam = bs.Powerup.getFactory().powerupAcceptMaterial
        for attr in ['materials', 'rollerMaterials', 'extrasMaterials']:
            materials = getattr(spaz.node, attr)
            if pam in materials:
                setattr(spaz.node, attr,
                        tuple(m for m in materials if m != pam))
        #spaz.node.materials.remove(pam)
        #spaz.node.rollerMaterials.remove(pam)
        #spaz.node.extrasMaterials.remove(pam)

        spaz.node.name = name
        spaz.node.nameColor = displayColor
        spaz.connectControlsToPlayer(
            enablePunch=True, enableBomb=False, enablePickUp=False
        )  #Unfortunately, I can't figure out how to prevent picking up other player but allow other pickup.
        self.scoreSet.playerGotNewSpaz(player, spaz)

        # move to the stand position and add a flash of light
        spaz.handleMessage(
            bs.StandMessage(
                position,
                angle if angle is not None else random.uniform(0, 360)))
        t = bs.getGameTime()
        bs.playSound(self._spawnSound, 1, position=spaz.node.position)
        light = bs.newNode('light', attrs={'color': lightColor})
        spaz.node.connectAttr('position', light, 'position')
        bsUtils.animate(light, 'intensity', {0: 0, 250: 1, 500: 0})
        bs.gameTimer(500, light.delete)
        #Start code to spawn special guy:
        #End of code to spawn special guy
        if not self._soloMode:
            bs.gameTimer(300, bs.Call(self._printLives, player))

        # if we have any icons, update their state
        for icon in player.gameData['icons']:
            icon.handlePlayerSpawned()