示例#1
0
    def showCompletionBanner(self, sound=True):

        global gLastAchievementDisplayTime
        gLastAchievementDisplayTime = bs.getRealTime()

        # just piggy-back onto any current activity...
        # (should we use the session instead?..)
        activity = bs.getActivity(exceptionOnNone=False)

        # if this gets called while this achievement is occupying a slot already, ignore it..
        # (probably should never happen in real life but whatevs..)
        if self._completionBannerSlot is not None:
            return

        if activity is None:
            print 'showCompletionBanner() called with no current activity!'
            return

        if sound: bs.playSound(bs.getSound('achievement'), hostOnly=True)
        else:
            bs.gameTimer(
                500, bs.Call(bs.playSound, bs.getSound('ding'), hostOnly=True))

        yOffs = 0
        inTime = 300
        outTime = 3500

        baseVRDepth = 200

        # find the first free slot
        i = 0
        while True:
            if not i in gCompletionBannerSlots:
                #print 'ADDING SLOT',i,'FOR',self
                gCompletionBannerSlots.add(i)
                self._completionBannerSlot = i
                # remove us from that slot when we close..
                # use a real-timer in the UI context so the removal runs even if our activity/session dies
                with bs.Context('UI'):
                    bs.realTimer(inTime + outTime, self._removeBannerSlot)
                break
            i += 1

        yOffs = 110 * self._completionBannerSlot

        objs = []
        obj = bsUtils.Image(bs.getTexture('shadow'),
                            position=(-30, 30 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            transition='inBottom',
                            vrDepth=baseVRDepth - 100,
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(0.0, 0.1, 0, 1),
                            scale=(1000, 300)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True
        obj = bsUtils.Image(bs.getTexture('light'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            color=(1.8, 1.8, 1.0, 0.0),
                            scale=(40, 300)).autoRetain()
        objs.append(obj)

        obj.node.hostOnly = True
        obj.node.premultiplied = True
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 2})
        bsUtils.animate(
            c, 'input0', {
                inTime: 0,
                inTime + 400: 30,
                inTime + 500: 40,
                inTime + 600: 30,
                inTime + 2000: 0
            })
        bsUtils.animate(
            c, 'input1', {
                inTime: 0,
                inTime + 400: 200,
                inTime + 500: 500,
                inTime + 600: 200,
                inTime + 2000: 0
            })
        c.connectAttr('output', obj.node, 'scale')
        bsUtils.animate(obj.node, 'rotate', {0: 0.0, 350: 360.0}, loop=True)
        obj = bsUtils.Image(self.getIconTexture(True),
                            position=(-180, 60 + yOffs),
                            attach='bottomCenter',
                            front=True,
                            vrDepth=baseVRDepth - 10,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # flash
        color = self.getIconColor(True)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')

        obj = bsUtils.Image(bs.getTexture('achievementOutline'),
                            modelTransparent=bs.getModel('achievementOutline'),
                            position=(-180, 60 + yOffs),
                            front=True,
                            attach='bottomCenter',
                            vrDepth=baseVRDepth,
                            transition='inBottom',
                            transitionDelay=inTime,
                            transitionOutDelay=outTime,
                            scale=(100, 100)).autoRetain()
        obj.node.hostOnly = True

        # flash
        color = (2, 1.4, 0.4, 1)
        c = bs.newNode('combine', owner=obj.node, attrs={'size': 3})
        keys = {
            inTime: 1.0 * color[0],
            inTime + 400: 1.5 * color[0],
            inTime + 500: 6.0 * color[0],
            inTime + 600: 1.5 * color[0],
            inTime + 2000: 1.0 * color[0]
        }
        bsUtils.animate(c, 'input0', keys)
        keys = {
            inTime: 1.0 * color[1],
            inTime + 400: 1.5 * color[1],
            inTime + 500: 6.0 * color[1],
            inTime + 600: 1.5 * color[1],
            inTime + 2000: 1.0 * color[1]
        }
        bsUtils.animate(c, 'input1', keys)
        keys = {
            inTime: 1.0 * color[2],
            inTime + 400: 1.5 * color[2],
            inTime + 500: 6.0 * color[2],
            inTime + 600: 1.5 * color[2],
            inTime + 2000: 1.0 * color[2]
        }
        bsUtils.animate(c, 'input2', keys)
        c.connectAttr('output', obj.node, 'color')
        objs.append(obj)

        obj = bsUtils.Text(bs.Lstr(value='${A}:',
                                   subs=[('${A}',
                                          bs.Lstr(resource='achievementText'))
                                         ]),
                           position=(-120, 91 + yOffs),
                           front=True,
                           vAttach='bottom',
                           vrDepth=baseVRDepth - 10,
                           transition='inBottom',
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           color=(1, 1, 1, 0.8),
                           scale=0.65).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(self.getDisplayString(),
                           position=(-120, 50 + yOffs),
                           front=True,
                           vAttach='bottom',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(1, 0.8, 0, 1.0),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text(bs.getSpecialChar('ticket'),
                           position=(-120 - 170 + 5, 75 + yOffs - 20),
                           front=True,
                           vAttach='bottom',
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0.5, 0.5, 0.5, 1),
                           scale=3.0).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        obj = bsUtils.Text('+' + str(self.getAwardTicketValue()),
                           position=(-120 - 180 + 5, 80 + yOffs - 20),
                           vAttach='bottom',
                           front=True,
                           hAlign='center',
                           vAlign='center',
                           transition='inBottom',
                           vrDepth=baseVRDepth,
                           flatness=0.5,
                           shadow=1.0,
                           transitionDelay=inTime,
                           transitionOutDelay=outTime,
                           flash=True,
                           color=(0, 1, 0, 1),
                           scale=1.5).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        # add the 'x 2' if we've got pro
        if bsUtils._havePro():
            obj = bsUtils.Text('x 2',
                               position=(-120 - 180 + 45, 80 + yOffs - 50),
                               vAttach='bottom',
                               front=True,
                               hAlign='center',
                               vAlign='center',
                               transition='inBottom',
                               vrDepth=baseVRDepth,
                               flatness=0.5,
                               shadow=1.0,
                               transitionDelay=inTime,
                               transitionOutDelay=outTime,
                               flash=True,
                               color=(0.4, 0, 1, 1),
                               scale=0.9).autoRetain()
            objs.append(obj)
            obj.node.hostOnly = True

        obj = bsUtils.Text(
            self.getDescriptionComplete(),
            # self.getDescriptionCompleteLocalized(),
            position=(-120, 30 + yOffs),
            front=True,
            vAttach='bottom',
            transition='inBottom',
            vrDepth=baseVRDepth - 10,
            flatness=0.5,
            transitionDelay=inTime,
            transitionOutDelay=outTime,
            color=(1.0, 0.7, 0.5, 1.0),
            scale=0.8).autoRetain()
        objs.append(obj)
        obj.node.hostOnly = True

        for obj in objs:
            bs.gameTimer(outTime + 1000,
                         bs.WeakCall(obj.handleMessage, bs.DieMessage()))
示例#2
0
def _getAchMult(includeProBonus=False):
    val = bsInternal._getAccountMiscReadVal('achAwardMult', 5)
    if includeProBonus and bsUtils._havePro(): val *= 2
    return val