Ejemplo n.º 1
0
 def getDifficulty(self):
     if self.difficultyOverride is not None:
         return self.difficultyOverride
     if hasattr(toonbase, 'minigameDifficulty'):
         return float(toonbase.minigameDifficulty)
     return MinigameGlobals.getDifficulty(self.getSafezoneId())
     return
Ejemplo n.º 2
0
 def getDifficulty(self):
     if self.difficultyOverride is not None:
         return self.difficultyOverride
     else:
         if hasattr(self.air, 'minigameDifficulty'):
             return float(self.air.minigameDifficulty)
         return MinigameGlobals.getDifficulty(self.getSafezoneId())
 def getDifficulty(self):
     if self.difficultyOverride is not None:
         return self.difficultyOverride
     
     if hasattr(self.air, 'minigameDifficulty'):
         return float(self.air.minigameDifficulty)
     
     return MinigameGlobals.getDifficulty(self.getSafezoneId())
Ejemplo n.º 4
0
            def printPeriodTable(name, numSuitList, fasterSuits,
                                 tTransFunc=None):
                str = '%s = {\n' % name
                # cycle through the safezones and calculate the
                # corresponding suit speeds
                for zone in MinigameGlobals.SafeZones:
                    str += '%s%s : {' % (' '*4, zone)

                    difficulty = MinigameGlobals.getDifficulty(zone)
                    minSpeed = lerp(self.MinSuitSpeedRange[0],
                                    self.MinSuitSpeedRange[1],
                                    difficulty)
                    maxSpeed = lerp(self.MaxSuitSpeedRange[0],
                                    self.MaxSuitSpeedRange[1],
                                    difficulty)
                    # all the 'slower' suits will be slower than this speed,
                    # all the 'faster' suits will be faster.
                    midSpeed = (minSpeed + maxSpeed) / 2.

                    # cycle through the suit counts (how many suits
                    # will be in play)
                    for numSuits in numSuitList:
                        # there must be an even number of suits
                        assert not numSuits % 2
                        speeds = []
                        for i in xrange(numSuits/2):
                            if fasterSuits:
                                i += numSuits/2
                            t = i / float(numSuits-1)
                            # map t into 0..1
                            if fasterSuits:
                                t -= .5
                            t *= 2.
                            # apply any time transformation function
                            if tTransFunc != None:
                                t = tTransFunc(t)

                            if fasterSuits:
                                speed = lerp(midSpeed, maxSpeed, t)
                            else:
                                speed = lerp(minSpeed, midSpeed, t)
                            speeds.append(speed)

                        # calculate the corresponding suit periods
                        def calcUpdatePeriod(speed):
                            # result in tics
                            # SUIT_TIC_FREQ: tics/sec
                            # CELL_WIDTH: feet
                            # speed: feet/sec
                            # tics = ((tics/sec) * feet) / (feet/sec)
                            return int((float(MazeGameGlobals.SUIT_TIC_FREQ) * \
                                        float(MazeData.CELL_WIDTH)) / speed)

                        periods = map(calcUpdatePeriod, speeds)

                        filler = ""
                        if numSuits < 10:
                            filler = " "

                        str += '%s%s : %s,\n%s%s' % (numSuits, filler, periods,
                                                     ' '*4, ' '*8)
                    str += '},\n'
                str += '%s}' % (' '*4)
                print str
 def getDifficulty(self):
     if self.difficultyOverride is not None:
         return self.difficultyOverride
     if hasattr(base, "minigameDifficulty"):
         return float(base.minigameDifficulty)
     return MinigameGlobals.getDifficulty(self.getSafezoneId())