def onBeginstats(self, customContinueMessage=None): bs.Activity.onBegin(self) import mystats start_new_thread(mystats.update, (self.scoreSet, )) # start_new_thread(mystats.update,(self.scoreSet,)) # pop up a 'press any button to continue' statement after our # min-view-time show a 'press any button to continue..' # thing after a bit.. if bs.getEnvironment()['interfaceType'] == 'large': # FIXME - need a better way to determine whether we've probably # got a keyboard s = bs.Lstr(resource='pressAnyKeyButtonText') else: s = bs.Lstr(resource='pressAnyButtonText') bsUtils.Text(customContinueMessage if customContinueMessage else s, vAttach='bottom', hAlign='center', flash=True, vrDepth=50, position=(0, 10), scale=0.8, color=(0.5, 0.7, 0.5, 0.5), transition='inBottomSlow', transitionDelay=self._minViewTime).autoRetain()
def ranklists(self,text,pos): #if fighterRank1 pos 0 100 # so -30 for every value rankText = bsUtils.Text(text, position=pos, hAlign='left', vAlign='center', maxWidth=300,scale=1.0, color=(0.9, 0.9, 0.9, 1),shadow=1.0,flatness=1.0, transition='inLeft', transitionDelay=500).autoRetain()
def _changePhrase(self): global gLastNewsFetchTime if time.time()-gLastNewsFetchTime > 100.0: self._fetchNews() self._text = None else: if self._text is not None: if len(self._phrases) == 0: for p in self._usedPhrases: self._phrases.insert(0,p) val = self._phrases.pop() if val == '__ACH__': vr = bs.getEnvironment()['vrMode'] bsUtils.Text( bs.Lstr(resource='nextAchievementsText'), color=(1,1,1,1) if vr else (0.95,0.9,1,0.4), hostOnly=True, maxWidth=200, position=(-300, -35), hAlign='right', transition='fadeIn', scale=0.9 if vr else 0.7, flatness=1.0 if vr else 0.6, shadow=1.0 if vr else 0.5, hAttach="center", vAttach="top", transitionDelay=1000, transitionOutDelay=self._messageDuration)\ .autoRetain() import bsAchievement achs = [a for a in bsAchievement.gAchievements if not a.isComplete()] if len(achs) > 0: a = achs.pop(random.randrange(min(4,len(achs)))) a.createDisplay(-180, -35, 1000, outDelay=self._messageDuration, style='news') if len(achs) > 0: a = achs.pop(random.randrange(min(8,len(achs)))) a.createDisplay(180, -35, 1250, outDelay=self._messageDuration, style='news') else: s = self._messageSpacing keys = {s:0, s+1000:1.0, s+self._messageDuration-1000:1.0, s+self._messageDuration:0.0} bs.animate(self._text.node, "opacity", dict([[k,v] for k,v in keys.items()])) self._text.node.text = val
def _startPart2(self): if self._part != 1: return self._part = 2 self._image = bsUtils.Image(self._tex2, transition='fadeIn', scale=(400, 400), transitionDelay=0) t = bsUtils._translate('tips', 'If you are short on controllers, ' 'install the \'${REMOTE_APP_NAME}\' app\n' 'on your mobile devices to use them ' 'as controllers.') t = t.replace('${REMOTE_APP_NAME}',bsUtils._getRemoteAppName()) self._text = bsUtils.Text(t, maxWidth=900, hAlign='center', vAlign='center', position=(0,270), color=(1,1,1,1), transition='fadeIn')
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()))
def createDisplay(self, x, y, delay, outDelay=None, color=None, style='postGame'): if style == 'postGame': inGameColors = False inMainMenu = False hAttach = vAttach = attach = 'center' elif style == 'inGame': inGameColors = True inMainMenu = False hAttach = 'left' vAttach = 'top' attach = 'topLeft' elif style == 'news': inGameColors = True inMainMenu = True hAttach = 'center' vAttach = 'top' attach = 'topCenter' else: raise Exception('invalid style "' + style + '"') # attempt to determine what campaign we're in # (so we know whether to show "hard mode only") if inMainMenu: hmo = False else: try: hmo = (self._hardModeOnly and bs.getSession()._campaignInfo['campaign'] == 'Easy') except Exception: bs.printException("unable to determine campaign") hmo = False activity = bs.getActivity() if inGameColors: objs = [] outDelayFin = (delay + outDelay) if outDelay is not None else None if color is not None: c1 = (2.0 * color[0], 2.0 * color[1], 2.0 * color[2], color[3]) c2 = color else: c1 = (1.5, 1.5, 2, 1.0) c2 = (0.8, 0.8, 1.0, 1.0) if hmo: c1 = (c1[0], c1[1], c1[2], c1[3] * 0.6) c2 = (c2[0], c2[1], c2[2], c2[3] * 0.2) objs.append( bsUtils.Image(self.getIconTexture(False), hostOnly=True, color=c1, position=(x - 25, y + 5), attach=attach, transition='fadeIn', transitionDelay=delay, vrDepth=4, transitionOutDelay=outDelayFin, scale=(40, 40)).autoRetain()) txt = self.getDisplayString() txtS = 0.85 txtMaxW = 300 objs.append( bsUtils.Text(txt, hostOnly=True, maxWidth=txtMaxW, position=(x, y + 2), transition='fadeIn', scale=txtS, flatness=0.6, shadow=0.5, hAttach=hAttach, vAttach=vAttach, color=c2, transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) # txt2 = self.getDescriptionLocalized() txt2S = 0.62 txt2MaxW = 400 objs.append( bsUtils.Text(self.getDescriptionFull() if inMainMenu else self.getDescription(), hostOnly=True, maxWidth=txt2MaxW, position=(x, y - 14), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, scale=txt2S, flatness=1.0, shadow=0.5, color=c2, transitionDelay=delay + 100, transitionOutDelay=outDelayFin).autoRetain()) if hmo: t = bsUtils.Text(bs.Lstr(resource='difficultyHardOnlyText'), hostOnly=True, maxWidth=txt2MaxW * 0.7, position=(x + 60, y + 5), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', scale=txtS * 0.8, flatness=1.0, shadow=0.5, color=(1, 1, 0.6, 1), transitionDelay=delay + 100, transitionOutDelay=outDelayFin).autoRetain() t.node.rotate = 10 objs.append(t) # ticket-award awardX = -100 objs.append( bsUtils.Text(bs.getSpecialChar('ticket'), hostOnly=True, position=(x + awardX + 33, y + 7), transition='fadeIn', scale=1.5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(1, 1, 1, 0.2 if hmo else 0.4), transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) objs.append( bsUtils.Text('+' + str(self.getAwardTicketValue()), hostOnly=True, position=(x + awardX + 28, y + 16), transition='fadeIn', scale=0.7, flatness=1, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(c2), transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) else: complete = self.isComplete() objs = [] cIcon = self.getIconColor(complete) if hmo and not complete: cIcon = (cIcon[0], cIcon[1], cIcon[2], cIcon[3] * 0.3) objs.append( bsUtils.Image(self.getIconTexture(complete), hostOnly=True, color=cIcon, position=(x - 25, y + 5), attach=attach, vrDepth=4, transition='inRight', transitionDelay=delay, transitionOutDelay=None, scale=(40, 40)).autoRetain()) if complete: objs.append( bsUtils.Image( bs.getTexture('achievementOutline'), hostOnly=True, modelTransparent=bs.getModel('achievementOutline'), color=(2, 1.4, 0.4, 1), vrDepth=8, position=(x - 25, y + 5), attach=attach, transition='inRight', transitionDelay=delay, transitionOutDelay=None, scale=(40, 40)).autoRetain()) else: if not complete: awardX = -100 objs.append( bsUtils.Text(bs.getSpecialChar('ticket'), hostOnly=True, position=(x + awardX + 33, y + 7), transition='inRight', scale=1.5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(1, 1, 1, 0.4) if complete else (1, 1, 1, (0.1 if hmo else 0.2)), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) objs.append( bsUtils.Text('+' + str(self.getAwardTicketValue()), hostOnly=True, position=(x + awardX + 28, y + 16), transition='inRight', scale=0.7, flatness=1, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=((0.8, 0.93, 0.8, 1.0) if complete else (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) # show 'hard-mode-only' only over incomplete achievements # when that's the case.. if hmo: t = bsUtils.Text( bs.Lstr(resource='difficultyHardOnlyText'), hostOnly=True, maxWidth=300 * 0.7, position=(x + 60, y + 5), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', scale=0.85 * 0.8, flatness=1.0, shadow=0.5, color=(1, 1, 0.6, 1), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain() t.node.rotate = 10 objs.append(t) objs.append( bsUtils.Text(self.getDisplayString(), hostOnly=True, maxWidth=300, position=(x, y + 2), transition='inRight', scale=0.85, flatness=0.6, hAttach=hAttach, vAttach=vAttach, color=((0.8, 0.93, 0.8, 1.0) if complete else (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) objs.append( bsUtils.Text(self.getDescriptionComplete() if complete else self.getDescription(), hostOnly=True, maxWidth=400, position=(x, y - 14), transition='inRight', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, scale=0.62, flatness=1.0, color=((0.6, 0.6, 0.6, 1.0) if complete else (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))), transitionDelay=delay + 100, transitionOutDelay=None).autoRetain()) return objs
def onTransitionIn(self, music=None): """ Method override; optionally can be passed a 'music' string which is the suggested type of music to play during the game. Note that in some cases music may be overridden by the map or other factors, which is why you should pass it in here instead of simply playing it yourself. """ bs.Activity.onTransitionIn(self) colo = (random.uniform(0.5, 3), random.uniform(0.5, 3), random.uniform(0.5, 3)) if some.show_texts: m = [ ("Scripts Made By: Logic\nHosting Provider: {}").format(some.host), ("Asking For Adminship Can Get You Kicked"), (u"Mail Your Suggestions/Contributions On \n [email protected]" ), (u"All Chats, Name & ID's Are Being Logged..."), ("This Party Has An Abusive Filter\nWith Over 600 Filtered Words"), ("Stats Get Reset Every Monday!\nPoints Are Not Affected"), (u"Join RAGE On Discord To Get Server Address!\nLink: https://bit.ly/awesomelogic" ), (u"For The Best Gaming Experience,\nNight Mode Will Automatically Turn On At 8PM Till 7AM" ), ("Swipe From Punch To Jump To Perform A Backflip\nLong Press Bomb Button To Toggle It!" ), ("Thanks For Playing!\nHave Fun And Play Ethically!") ] else: m = [''] self.myName = bsUtils.Text( random.choice(m), vAttach='bottom', hAlign='center', shadow=1.0, position=(0, 140) if self.getName() == "Elimination" else (0, 100) if self.getName() == "BombSpot" else (0, 50), color=colo, maxWidth=350) po = self.myName.node.position obj = bsUtils.Text(bs.getSpecialChar('logoFlat'), position=(po[0] + 325, po[1] + 0), vAttach='bottom', color=colo, hAlign='center', vAlign='center', scale=1.5 if some.show_texts else 0).autoRetain() obj1 = bsUtils.Text(bs.getSpecialChar('logoFlat'), position=(po[0] - 325, po[1] + 0), vAttach='bottom', color=colo, hAlign='center', vAlign='center', scale=1.5 if some.show_texts else 0).autoRetain() def animate(): self.myName.node.text = random.choice(m) def animate3(): bs.animate(self.myName.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.animate(obj.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.animate(obj1.node, 'opacity', {0: 1, 1000: 0, 2000: 1}) bs.gameTimer(1000, animate) animate3() bs.animate(obj.node, 'rotate', {0: 0.0, 3000: 360.0}, loop=True) bs.animate(obj1.node, 'rotate', {0: 0.0, 3000: 360.0}, loop=True) bs.animate(self.myName.node, 'scale', { 0: 1.25, 1000: 1.30, 2000: 1.25 }, loop=True) bs.gameTimer(9000, animate3, repeat=True) self.version = bs.NodeActor( bs.newNode( 'text', attrs={ 'vAttach': 'bottom', 'vAlign': 'bottom', 'hAttach': 'left', 'hAlign': 'left', 'flatness': 1.0, 'opacity': 1.0, 'shadow': 0.5, 'color': (0.5, 0.5, 0.5, 0.7), 'scale': 0.7, 'position': (10, 10), 'text': bsUtils._gServerConfig.get('partyName', '') + ('\n' + 'Scripts Available At: https://github.com/Awesome-Logic/' ) #if some.is_logic else '' })) self.version2 = bs.NodeActor( bs.newNode('text', attrs={ 'vAttach': 'bottom', 'vAlign': 'bottom', 'hAttach': 'right', 'hAlign': 'right', 'flatness': 1.0, 'opacity': 1.0, 'shadow': 0.5, 'color': (0.5, 0.5, 0.5, 0.7), 'scale': 0.7, 'position': (-10, 10), 'text': 'Scripts By: Logic\nHosting By: {}'.format(some.host) })) txt = '\n'.join(open(some.flyfile).read().split('\n')) animateText = bsUtils.Text(txt, position=(0, 285), hAlign='center', vAlign='top', flatness=1.0, maxWidth=180, color=colo, transition='inLeft', scale=3.0, transitionOutDelay=8000, shadow=1.0, transitionDelay=5000).autoRetain() # make our map self._map = self._mapType() # give our map a chance to override the music # (for happy-thoughts and other such themed maps) overrideMusic = self._mapType.getMusicType() if overrideMusic is not None: music = overrideMusic if music is not None: bs.playMusic(music)