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)
Пример #2
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)
Пример #3
0
    def handleMessage(self, m):
        """ handle high-level game messages """

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

            player = m.spaz.getPlayer()

            self.scoreSet.playerLostSpaz(player)

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

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

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

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

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

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