Exemple #1
0
    def setup(self):
        self.dnaStore = toonbase.tcr.playGame.dnaStore
        self.randomGenerator = random.Random()
        self.randomGenerator.seed(self.zoneId)
        self.interior = loader.loadModel(
            'phase_3.5/models/modules/toon_interior_tutorial')
        self.interior.reparentTo(render)
        dnaStore = DNAStorage()
        node = loader.loadDNAFile(self.cr.playGame.hood.dnaStore,
                                  'phase_3.5/dna/tutorial_street.dna')
        self.street = render.attachNewNode(node)
        self.street.flattenMedium()
        self.street.setPosHpr(-12, 42, -0.5, 180, 0, 0)
        self.street.find('**/tb2:toon_landmark_TT_A1_DNARoot').stash()
        self.street.find(
            '**/tb1:toon_landmark_hqTT_DNARoot/**/door_flat_0').stash()
        self.street.findAllMatches('**/+CollisionNode').stash()
        self.skyFile = 'phase_3.5/models/props/TT_sky'
        self.sky = loader.loadModel(self.skyFile)
        self.sky.setScale(0.80000000000000004)
        self.sky.reparentTo(render)
        self.sky.setDepthTest(0)
        self.sky.setDepthWrite(0)
        self.sky.setBin('background', 100)
        self.sky.find('**/Sky').reparentTo(self.sky, -1)
        hoodId = ZoneUtil.getHoodId(self.zoneId)
        self.colors = ToonInteriorColors.colors[hoodId]
        self.replaceRandomInModel(self.interior)
        doorModelName = 'door_double_round_ul'
        if doorModelName[-1:] == 'r':
            doorModelName = doorModelName[:-1] + 'l'
        else:
            doorModelName = doorModelName[:-1] + 'r'
        door = self.dnaStore.findNode(doorModelName)
        door_origin = render.find('**/door_origin;+s')
        doorNP = door.copyTo(door_origin)
        door_origin.setScale(0.80000000000000004, 0.80000000000000004,
                             0.80000000000000004)
        door_origin.setPos(door_origin, 0, -0.025000000000000001, 0)
        color = self.randomGenerator.choice(self.colors['TI_door'])
        DNADoor.DNADoor.setupDoor(doorNP, self.interior, door_origin,
                                  self.dnaStore, str(self.block), color)
        doorFrame = doorNP.find('door_*_flat')
        doorFrame.wrtReparentTo(self.interior)
        doorFrame.setColor(color)
        del self.colors
        del self.dnaStore
        del self.randomGenerator
        self.interior.flattenMedium()
        npcOrigin = self.interior.find('**/npc_origin_' +
                                       ` self.npc.posIndex `)
        if not npcOrigin.isEmpty():
            self.npc.reparentTo(npcOrigin)
            self.npc.clearMat()

        self.createSuit()
        self.mickeyMovie = QuestParser.NPCMoviePlayer('tutorial_mickey',
                                                      toonbase.localToon,
                                                      self.npc)
        self.acceptOnce('enterTutorialInterior', self.mickeyMovie.play)
    def setMovie(self, mode, npcId, avId, timestamp):
        timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
        self.npcId = npcId
        self.isLocalToon = avId == toonbase.localToon.doId
        if mode == NPCToons.BLOCKER_MOVIE_CLEAR:
            return None
        elif mode == NPCToons.BLOCKER_MOVIE_START:
            self.movie = QuestParser.NPCMoviePlayer('tutorial_blocker',
                                                    toonbase.localToon, self)
            self.movie.play()
        elif mode == NPCToons.BLOCKER_MOVIE_TIMEOUT:
            return None

        return None
 def setMovie(self, mode, npcId, avId, quests, timestamp):
     timeStamp = ClockDelta.globalClockDelta.localElapsedTime(timestamp)
     isLocalToon = avId == toonbase.localToon.doId
     self.notify.info('setMovie: %s %s %s %s %s %s' % (mode, npcId, avId, quests, timeStamp, isLocalToon))
     if mode == NPCToons.QUEST_MOVIE_CLEAR:
         self.notify.info('setMovie: movie cleared')
         return
     if mode == NPCToons.QUEST_MOVIE_TIMEOUT:
         self.notify.info('setMovie: movie timeout')
         self.ignore(self.uniqueName('doneChatPage'))
         self.ignore('chooseQuest')
         if self.curQuestMovie:
             self.curQuestMovie.timeout()
             self.curQuestMovie.cleanup()
             self.curQuestMovie = None
         if self.questChoiceGui:
             self.questChoiceGui.destroy()
             self.questChoiceGui = None
         if isLocalToon:
             self.freeAvatar()
         self.setPageNumber(0, -1)
         self.clearChat()
         self.startLookAround()
         self.detectAvatars()
         return
     av = toonbase.tcr.doId2do.get(avId)
     if av is None:
         self.notify.warning('Avatar %d not found in doId' % avId)
         return
     if mode == NPCToons.QUEST_MOVIE_REJECT:
         rejectString = Quests.chooseQuestDialogReject()
         rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
         self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
         if isLocalToon:
             toonbase.localToon.posCamera(0, 0)
             toonbase.tcr.playGame.getPlace().setState('walk')
         return
     if mode == NPCToons.QUEST_MOVIE_TIER_NOT_DONE:
         rejectString = Quests.chooseQuestDialogTierNotDone()
         rejectString = Quests.fillInQuestNames(rejectString, avName=av.name)
         self.setChatAbsolute(rejectString, CFSpeech | CFTimeout)
         if isLocalToon:
             toonbase.localToon.posCamera(0, 0)
             toonbase.tcr.playGame.getPlace().setState('walk')
         return
     self.setupAvatars(av)
     fullString = ''
     toNpcId = None
     if mode == NPCToons.QUEST_MOVIE_COMPLETE:
         questId, rewardId, toNpcId = quests
         scriptId = 'quest_complete_' + str(questId)
         if QuestParser.questDefined(scriptId):
             self.curQuestMovie = QuestParser.NPCMoviePlayer(scriptId, av, self)
             self.curQuestMovie.play()
             return
         if isLocalToon:
             self.setupCamera(mode)
         greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING)
         if greetingString:
             fullString += greetingString + '\x07'
         fullString += Quests.chooseQuestDialog(questId, Quests.COMPLETE) + '\x07'
         if rewardId:
             fullString += Quests.getReward(rewardId).getString()
         leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING)
         if leavingString:
             fullString += '\x07' + leavingString
     else:
         if mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE_CANCEL:
             fullString = Localizer.QuestMovieQuestChoiceCancel
         else:
             if mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE_CANCEL:
                 fullString = Localizer.QuestMovieTrackChoiceCancel
             else:
                 if mode == NPCToons.QUEST_MOVIE_INCOMPLETE:
                     questId, completeStatus, toNpcId = quests
                     scriptId = 'quest_incomplete_' + str(questId)
                     if QuestParser.questDefined(scriptId):
                         self.curQuestMovie = QuestParser.NPCMoviePlayer(scriptId, av, self)
                         self.curQuestMovie.play()
                         return
                     if isLocalToon:
                         self.setupCamera(mode)
                     greetingString = Quests.chooseQuestDialog(questId, Quests.GREETING)
                     if greetingString:
                         fullString += greetingString + '\x07'
                     fullString += Quests.chooseQuestDialog(questId, completeStatus)
                     leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING)
                     if leavingString:
                         fullString += '\x07' + leavingString
                 else:
                     if mode == NPCToons.QUEST_MOVIE_ASSIGN:
                         questId, rewardId, toNpcId = quests
                         scriptId = 'quest_assign_' + str(questId)
                         if QuestParser.questDefined(scriptId):
                             self.curQuestMovie = QuestParser.NPCMoviePlayer(scriptId, av, self)
                             self.curQuestMovie.play()
                             return
                         if isLocalToon:
                             self.setupCamera(mode)
                         fullString += Quests.chooseQuestDialog(questId, Quests.QUEST)
                         leavingString = Quests.chooseQuestDialog(questId, Quests.LEAVING)
                         if leavingString:
                             fullString += '\x07' + leavingString
                     else:
                         if mode == NPCToons.QUEST_MOVIE_QUEST_CHOICE:
                             if isLocalToon:
                                 self.setupCamera(mode)
                             self.notify.debug('QUEST_MOVIE_QUEST_CHOICE: %s' % quests)
                             self.setChatAbsolute(Localizer.QuestMovieQuestChoice, CFSpeech)
                             if isLocalToon:
                                 self.acceptOnce('chooseQuest', self.sendChooseQuest)
                                 self.questChoiceGui = QuestChoiceGui.QuestChoiceGui()
                                 self.questChoiceGui.setQuests(quests, npcId, ChoiceTimeout)
                             return
                         else:
                             if mode == NPCToons.QUEST_MOVIE_TRACK_CHOICE:
                                 if isLocalToon:
                                     self.setupCamera(mode)
                                 tracks = quests
                                 self.notify.debug('QUEST_MOVIE_TRACK_CHOICE: %s' % tracks)
                                 self.setChatAbsolute(Localizer.QuestMovieTrackChoice, CFSpeech)
                                 if isLocalToon:
                                     self.acceptOnce('chooseTrack', self.sendChooseTrack)
                                     self.trackChoiceGui = TrackChoiceGui.TrackChoiceGui(tracks, ChoiceTimeout)
                                 return
     fullString = Quests.fillInQuestNames(fullString, avName=av.name, fromNpcId=npcId, toNpcId=toNpcId)
     self.acceptOnce(self.uniqueName('doneChatPage'), self.finishMovie, extraArgs=[av, isLocalToon])
     self.setPageChat(avId, 0, fullString, 1)
     return