class Chapter4B(ChapterBase): def __init__(self, rootParent): ChapterBase.__init__(self, "chapter4/office.png", rootParent) self.overlay = Overlay(rootParent) self.overlay.newspaper["image"] = "chapter4/newspaperB.png" self.startPos = (0.5, 0, -0.3) base.messenger.send("animateChar", ["idle", "l", 3, True]) self.accept("continue", self.readNewspaper) base.messenger.send("showText", [FINAL.copy()]) self.alica = Character(rootParent, (0.3, 0, -0.3), "alica", "alica") self.alica.animate("idle", "r", 3) self.accept("mike", self.talkMike) def destroy(self): self.overlay.destroy() self.alica.destroy() ChapterBase.destroy(self) def readNewspaper(self): self.overlay.newspaper.hide() self.accept("alica", self.talkAlica) def talkAlica(self): self.accept("continue", base.messenger.send, extraArgs=["switchToChapter", ["chapterEndB"]]) base.messenger.send("showText", [FINAL_ALICA.copy()]) def talkMike(self): base.messenger.send("showNote", ["Ms Alica is here, I should talk with her."])
class ChapterEndB(DirectObject): def __init__(self, rootParent): self.screen = EndScreen(rootParent) self.screen.lblEnding["text"] = "You've found ending 2/2" self.startPos = (0.1, 0, -.3) base.messenger.send("animateChar", ["idle", "l", 3, True]) self.alica = Character(rootParent, (-0.1, 0, -.3), "alica", "alica") self.alica.animate("idle", "r", 3) self.accept("alica", self.talkAlica) self.accept("mike", self.talkMike) def destroy(self): self.alica.destroy() self.screen.destroy() def talkAlica(self): base.messenger.send("showNote", ["Thanks for playing!"]) def talkMike(self): base.messenger.send("showNote", ["Good job!"])
class GameScreenHandler(DirectObject, GameScreen): def __init__(self): GameScreen.__init__(self) self.btnContinue.hide() self.mainChar = Character(self.frmContent.getCanvas(), (0,0,0), "mainChar", "mike") self.mainChar.animate("idle", "l", 3) self.mainChar.btn.reparentTo(self.frmContent.getCanvas(), 100) self.chapter = None self.inventory = Inventory(self.frmInventory) self.accept("quitGame", self.askQuit) self.accept("toggleAudio", self.toggleAudio) self.accept("switchToChapter", self.switchToChapter) self.accept("showText", self.showText) self.accept("showNote", self.showNote) self.accept("addInventory", self.addInventory) self.accept("getInventory", self.getInventory) self.accept("moveChar", self.mainChar.moveTo) self.accept("stopChar", self.mainChar.stop) self.accept("animateChar", self.mainChar.animate) if base.AppHasAudioFocus: self.btnAudioToggle["text"] = "Audio On" else: self.btnAudioToggle["text"] = "Audio Off" self.chapter = levelTree["chapter1"](self.frmContent.getCanvas()) self.mainChar.btn.setPos(self.chapter.startPos) LerpColorInterval(self.frmFadeOverlay, 2.0, (0,0,0,0)).start() def askQuit(self): self.yesNoDialog = YesNoDialog( text="Realy Quit?", command=self.quitGame) def quitGame(self, yes): self.yesNoDialog.destroy() if yes: self.ignoreAll() self.mainChar.stop() self.mainChar.destroy() self.chapter.destroy() base.messenger.send("exit") def toggleAudio(self): if base.AppHasAudioFocus: base.disableAllAudio() self.btnAudioToggle["text"] = "Audio Off" else: base.enableAllAudio() self.btnAudioToggle["text"] = "Audio On" def setChapter(self, chapterName): if self.chapter is not None: del self.chapter self.chapter = None self.chapter = levelTree[chapterName](self.frmContent.getCanvas()) def switchToChapter(self, chapterName): switchTo = Sequence( LerpColorInterval(self.frmFadeOverlay, 2.0, (0,0,0,1), (0,0,0,0)), Func(self.chapter.destroy), Func(self.setChapter, chapterName), Func(self.setStarPos), LerpColorInterval(self.frmFadeOverlay, 2.0, (0,0,0,0)), ) switchTo.start() def setStarPos(self): self.mainChar.setStart(self.chapter.startPos) def showNote(self, text): self.lblStory["text"] = text base.messenger.send("continue") def showText(self, textQueue): self.btnContinue.show() self.textQueue = textQueue self.accept("story_continue", self.nextText) self.nextText() def nextText(self): if len(self.textQueue) <= 0: base.messenger.send("continue") self.ignore("story_continue") self.lblStory["text"] = "" self.btnContinue.hide() return text = self.textQueue[0] self.lblStory["text"] = text del self.textQueue[0] def addInventory(self, itemKey, itemImage): self.inventory.addItem(itemKey, itemImage) def getInventory(self): base.messenger.send("inventoryRequest", [self.inventory.inventoryList])
class Chapter3(ChapterBase): def __init__(self, rootParent): ChapterBase.__init__(self, "chapter3/hotel.png", rootParent) self.startPos = (-0.7, 0, -0.3) self.talkedBadGuy1 = False self.talkedBadGuy2 = False self.hasFakeIDs = False self.shownFakeID = False base.messenger.send("animateChar", ["idle", "r", 3, True]) self.overlay = Overlay(rootParent) self.alica = Character(rootParent, (0.5, 0, -0.3), "alica", "alica") self.alica.animate("lie", "l", 3) self.badGuy1 = Character(rootParent, (-0.2, 0, -0.3), "badGuy1", "badGuy1") self.badGuy1.animate("idle", "l", 3) self.badGuy2 = Character(rootParent, (0.4, 0, -0.3), "badGuy2", "badGuy2") self.badGuy2.animate("idle", "l", 3) self.accept("badGuy1", self.talkBadGuy1) self.accept("badGuy2", self.talkBadGuy2) self.accept("alica", self.talkAlica) self.accept("mike", self.talkMike) self.accept("inventory_fakeID", self.showFakeID) self.accept("inventoryRequest", self.inventoryCheck) base.messenger.send("getInventory") def destroy(self): self.overlay.destroy() self.alica.destroy() self.badGuy1.destroy() self.badGuy2.destroy() ChapterBase.destroy(self) def inventoryCheck(self, inventory): for i in inventory: if i.key == "fakeID": self.hasFakeIDs = True def talkMike(self): if not self.talkedBadGuy1: base.messenger.send("showNote", ["Let's talk with that guy in front of me."]) elif not self.shownFakeID: base.messenger.send( "showNote", ["Now's the time to select the Fake IDs from my inventory"]) elif not self.talkedBadGuy2: base.messenger.send("showNote", [ "That guy is letting me pass, I should speakk with that other one in the next room" ]) else: base.messenger.send("showNote", ["C'mon, Alica is there waiting for me!"]) def talkBadGuy1(self): if not self.talkedBadGuy1: self.talkedBadGuy1 = True base.messenger.send("moveChar", [(-0.4, 0, -0.3)]) if self.hasFakeIDs: base.messenger.send("showText", [STORY_BADGUY1_GOOD.copy()]) else: self.accept("continue", base.messenger.send, extraArgs=["switchToChapter", ["chapter4A"]]) base.messenger.send("showText", [STORY_BADGUY1_FAILED.copy()]) elif not self.shownFakeID: base.messenger.send("showNote", [ "Why are you still around, you disturb our ascertainment. Go get lost!" ]) else: base.messenger.send( "showNote", ["You already got me, just go on, my buddy won't be so easy."]) def showFakeID(self): if not self.talkedBadGuy1: base.messenger.send("showNote", [ "It's not the right time for it yet. I should talk to that guy in front of me first." ]) elif not self.shownFakeID: self.shownFakeID = True base.messenger.send("showText", [STORY_BADGUY1_2.copy()]) else: base.messenger.send("showNote", [ "The guys already saw them and should play along nice... for now." ]) def talkBadGuy2(self): if not self.talkedBadGuy1 or not self.shownFakeID: base.messenger.send("showNote", [ "Shady Guy: Where do you think you're going. You may not pass yet." ]) elif not self.talkedBadGuy2: self.talkedBadGuy2 = True base.messenger.send("moveChar", [(0.2, 0, -0.3)]) base.messenger.send("showText", [STORY_BADGUY2.copy()]) else: base.messenger.send("showNote", ["He remains silent."]) def talkAlica(self): if not self.talkedBadGuy1 or not self.shownFakeID: base.messenger.send("showNote", [ "Shady Guy: Where do you think you're going. You may not pass yet." ]) elif not self.talkedBadGuy2: base.messenger.send( "showNote", ["Other Shady Guy: This is none of ya busines. Go get lost!"]) else: self.accept("continue", base.messenger.send, extraArgs=["switchToChapter", ["chapter4B"]]) base.messenger.send("moveChar", [(0.35, 0, -0.3)]) base.messenger.send("showText", [STORY_ALICA.copy()])