def showHpString(self, text, duration=0.85, scale=0.7):
     if self.HpTextEnabled and not self.ghostMode:
         if text != '':
             if self.hpText:
                 self.hideHpText()
             self.HpTextGenerator.setFont(OTPGlobals.getSignFont())
             self.HpTextGenerator.setText(text)
             self.HpTextGenerator.clearShadow()
             self.HpTextGenerator.setAlign(TextNode.ACenter)
             r = a = 1.0
             g = b = 0.0
             self.HpTextGenerator.setTextColor(r, g, b, a)
             self.hpTextNode = self.HpTextGenerator.generate()
             self.hpText = self.attachNewNode(self.hpTextNode)
             self.hpText.setScale(scale)
             self.hpText.setBillboardAxis()
             self.hpText.setPos(0, 0, self.height / 2)
             seq = Sequence(
                 self.hpText.posInterval(1.0,
                                         Point3(0, 0, self.height + 1.5),
                                         blendType='easeOut'),
                 Wait(duration),
                 self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)),
                 Func(self.hideHpText))
             seq.start()
Ejemplo n.º 2
0
 def showScoreText(self, number, scale=1.25):
     if not number == 0:
         if self.scoreText:
             self.hideScoreText()
         self.ScoreTextGenerator.setFont(OTPGlobals.getSignFont())
         if number < 0:
             self.ScoreTextGenerator.setText(str(number))
         else:
             self.ScoreTextGenerator.setText('+' + str(number))
         self.ScoreTextGenerator.clearShadow()
         self.ScoreTextGenerator.setAlign(TextNode.ACenter)
         if number < 0:
             r, g, b, a = (0.9, 0, 0, 1)
         else:
             r, g, b, a = (0.9, 0.9, 0, 1)
         self.scoreTextNode = self.ScoreTextGenerator.generate()
         self.scoreText = self.toon.attachNewNode(self.scoreTextNode)
         self.scoreText.setScale(scale)
         self.scoreText.setBillboardPointEye()
         self.scoreText.setBin('fixed', 100)
         self.scoreText.setPos(0, 0, self.toon.height / 2)
         self.scoreText.setTransparency(1)
         self.scoreText.setColor(r, g, b, a)
         self.scoreText.setDepthTest(0)
         self.scoreText.setDepthWrite(0)
         seq = Sequence(
             self.scoreText.posInterval(0.5,
                                        Point3(0, 0, self.toon.height + 2),
                                        blendType='easeOut'),
             self.scoreText.colorInterval(0.25, Vec4(r, g, b, 0)),
             Func(self.hideScoreText))
         seq.start()
 def showHpText(self, number, bonus=0, scale=1):
     if self.HpTextEnabled and not self.ghostMode:
         if number != 0:
             if self.hpText:
                 self.hideHpText()
             self.HpTextGenerator.setFont(OTPGlobals.getSignFont())
             if number < 0:
                 self.HpTextGenerator.setText(str(number))
             else:
                 self.HpTextGenerator.setText('+' + str(number))
             self.HpTextGenerator.clearShadow()
             self.HpTextGenerator.setAlign(TextNode.ACenter)
             if bonus == 1:
                 r = 1.0
                 g = 1.0
                 b = 0
                 a = 1
             elif bonus == 2:
                 r = 1.0
                 g = 0.5
                 b = 0
                 a = 1
             elif number < 0:
                 r = 0.9
                 g = 0
                 b = 0
                 a = 1
             else:
                 r = 0
                 g = 0.9
                 b = 0
                 a = 1
             self.HpTextGenerator.setTextColor(r, g, b, a)
             self.hpTextNode = self.HpTextGenerator.generate()
             self.hpText = self.attachNewNode(self.hpTextNode)
             self.hpText.setScale(scale)
             self.hpText.setBillboardPointEye()
             self.hpText.setBin('fixed', 100)
             self.hpText.setPos(0, 0, self.height / 2)
             seq = Sequence(
                 self.hpText.posInterval(1.0,
                                         Point3(0, 0, self.height + 1.5),
                                         blendType='easeOut'), Wait(0.85),
                 self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)),
                 Func(self.hideHpText))
             seq.start()
    def showHpText(self, number, bonus=0, scale=1, attackTrack=-1):
        if self.HpTextEnabled and not self.ghostMode:
            if number != 0:
                if self.hpText:
                    self.hideHpText()

                self.HpTextGenerator.setFont(OTPGlobals.getSignFont())

                if number < 0:
                    self.HpTextGenerator.setText(str(number))

                    if config.GetBool(
                            'silly-surge-text',
                            True) and random.randrange(0, 100) < config.GetInt(
                                'silly-surge-chance', 10):
                        self.sillySurgeText = True
                        absNumber = int(abs(number) / 10)

                        if len(TTLocalizer.SillySurgeTerms) > absNumber:
                            self.HpTextGenerator.setText(
                                str(number) + '\n' +
                                TTLocalizer.SillySurgeTerms[absNumber])
                        else:
                            self.HpTextGenerator.setText(
                                str(number) + '\n' +
                                random.choice(TTLocalizer.SillySurgeTerms))

                    if self.interactivePropTrackBonus > -1 and self.interactivePropTrackBonus == attackTrack:
                        self.sillySurgeText = True

                        if attackTrack in TTLocalizer.InteractivePropTrackBonusTerms:
                            self.HpTextGenerator.setText(
                                str(number) + '\n' + TTLocalizer.
                                InteractivePropTrackBonusTerms[attackTrack])
                else:
                    self.HpTextGenerator.setText('+' + str(number))

                self.HpTextGenerator.clearShadow()
                self.HpTextGenerator.setAlign(TextNode.ACenter)

                if bonus == 1:
                    color = [1, 1, 0, 1]
                elif bonus == 2:
                    color = [1, 0.5, 0, 1]
                elif number < 0:
                    color = [0.9, 0, 0, 1]

                    if self.interactivePropTrackBonus > -1 and self.interactivePropTrackBonus == attackTrack:
                        color = [0, 0, 1, 1]
                else:
                    color = [0, 0.9, 0, 1]

                self.HpTextGenerator.setTextColor(*color)
                self.hpTextNode = self.HpTextGenerator.generate()
                self.hpText = self.attachNewNode(self.hpTextNode)
                self.hpText.setScale(scale)
                self.hpText.setBillboardPointEye()
                self.hpText.setBin('fixed', 100)

                if self.sillySurgeText:
                    self.nametag3d.setDepthTest(0)
                    self.nametag3d.setBin('fixed', 99)

                self.hpText.setPos(0, 0, self.height / 2)
                color[3] = 0
                Sequence(
                    self.hpText.posInterval(1.0,
                                            Point3(0, 0, self.height + 1.5),
                                            blendType='easeOut'), Wait(0.85),
                    self.hpText.colorInterval(0.1, Vec4(*color), 0.1),
                    Func(self.hideHpText)).start()