コード例 #1
0
ファイル: CreditsState.py プロジェクト: vardis/pano
    def exit(self):

        FSMState.exit(self)

        if self.playlist is not None:
            self.game.getMusic().stop()

        self.game.getInput().removeMappings('credits')

        if self.displayRegion is not None:
            base.win.removeDisplayRegion(self.displayRegion)
            self.displayRegion = None

        self.camera = None

        if self.scrollInterval is not None:
            self.scrollInterval.finish()
        self.scrollInterval = None

        self.backgroundOSI.destroy()
        self.backgroundOSI = None

        self.creditsOST = None

        self.scene.removeNode()
        self.scene = None

        self.tex = None
        self.alphaMask = None
コード例 #2
0
ファイル: InventoryState.py プロジェクト: vardis/pano
    def enter(self):
        FSMState.enter(self)
        self.getGame().getInput().pushMappings('inventory')

        self.inventory = self.getGame().getInventory()

        self.inventoryView = self.getGame().getView().getInventoryView()
        self.inventoryView.redraw()
        self.inventoryView.clearText()
        #        self.inventoryView.enableDebugRendering()
        self.inventoryView.show()
コード例 #3
0
ファイル: ExploreState.py プロジェクト: vardis/pano
    def __init__(self, gameRef=None):
        FSMState.__init__(self, gameRef, PanoConstants.STATE_EXPLORE)
        self.log = logging.getLogger('pano.exploreState')
        self.activeNode = None
        self.nodeScript = None  # script that controls the currently active node
        self.activeHotspot = None
        self.sounds = None
        self.drawDebugViz = False
        self.nodeTransition = None

        # if True then we are transitioning to a new node, we use this flag to reject certain operations
        # while it is true
        self.inTransition = False
コード例 #4
0
ファイル: ExploreState.py プロジェクト: vardis/pano
    def enter(self):

        FSMState.enter(self)

        self.drawDebugViz = self.game.getConfig().getBool(
            PanoConstants.CVAR_DEBUG_HOTSPOTS, False)

        self.game.getInput().addMappings('explore')
        self.sounds = self.game.getSoundsFx()

        if self.activeNode is None:
            self.changeDisplayNode(self.game.getInitialNode())
        else:
            self.changeDisplayNode(self.activeNode.name)
コード例 #5
0
    def exit(self):

        FSMState.exit(self)

        self.textParent.hide()

        self.getMessenger().sendMessage(PanoConstants.EVENT_GAME_RESUMED)

        self.getGame().getInput().popMappings()

        self.getGame().getView().panoRenderer.resumeAnimations()
        self.getGame().getView().mousePointer.show()

        if self.wasMusicPlaying:
            self.getGame().getMusic().setPaused(False)
コード例 #6
0
    def enter(self):

        FSMState.enter(self)

        self.getGame().getInput().pushMappings('paused')

        # read config
        config = self.game.getConfig()
        self.msgKey = config.get(PanoConstants.CVAR_PAUSED_STATE_MESSAGE)
        self.fontName = config.get(PanoConstants.CVAR_PAUSED_STATE_FONT)
        self.fgColor = config.getVec4(PanoConstants.CVAR_PAUSED_STATE_FGCOLOR)
        self.scale = config.getFloat(PanoConstants.CVAR_PAUSED_STATE_SCALE)

        # translate message and font
        i18n = self.game.getI18n()

        localizedFont = i18n.getLocalizedFont(self.fontName)
        fontPath = self.game.getResources().getResourceFullPath(
            PanoConstants.RES_TYPE_FONTS, localizedFont)
        # if font is None, then Panda3D will use a default built-in font
        font = loader.loadFont(fontPath)

        self.translatedText = i18n.translate(self.msgKey)

        self.getMessenger().sendMessage(PanoConstants.EVENT_GAME_PAUSED)

        music = self.getGame().getMusic()
        self.wasMusicPlaying = not (music.isPaused() or music.isStopped())
        music.setPaused(True)

        self.getGame().getView().panoRenderer.pauseAnimations()

        self.getGame().getView().mousePointer.hide()

        if self.textParent == None:
            self.textParent = aspect2d.attachNewNode("pausedText")

        if self.textNode == None:
            self.textNode = OnscreenText(text=self.translatedText,
                                         pos=(0.0, 0.0),
                                         scale=self.scale,
                                         fg=self.fgColor,
                                         align=TextNode.ACenter,
                                         font=font,
                                         parent=self.textParent,
                                         mayChange=False)

        self.textParent.show()
コード例 #7
0
    def __init__(self, gameRef=None):
        FSMState.__init__(self, gameRef, PanoConstants.STATE_PAUSED)
        self.log = logging.getLogger('pano.pausedState')

        self.msgKey = "Game Paused"
        self.translatedText = ""
        self.fontName = None
        self.fgColor = None
        self.scale = 1.0

        self.mousePointerTask = None
        self.musicTask = None
        self.wasMusicPlaying = False

        self.textParent = None
        self.textNode = None
コード例 #8
0
ファイル: ExploreState.py プロジェクト: vardis/pano
    def exit(self):
        FSMState.exit(self)

        if self.nodeTransition is not None:
            self.nodeTransition.finish()
            self.inTransition = False

        if self.nodeScript is not None:
            self.nodeScript.exit()

        self.game.getInput().removeMappings('explore')
        self.game.getView().getCameraController().disable()
        self.game.getView().clearScene()
        self.game.getView().getMousePointer().hide()
        self.game.getView().getTalkBox().hide()

        self.game.getMusic().stop()
コード例 #9
0
ファイル: CreditsState.py プロジェクト: vardis/pano
    def __init__(self, gameRef=None):
        FSMState.__init__(self, gameRef, PanoConstants.STATE_CREDITS)

        self.log = logging.getLogger('pano.creditsState')
        self.alphaMask = None
        self.tex = None

        # scene root
        self.scene = None

        # parent node of self.creditsOST
        self.textParent = None

        # filename of the background image
        self.background = None

        # OnscreenImage used for background rendering
        self.backgroundOSI = None

        # name of the font definition to use
        self.fontName = None

        self.fontColor = None

        # scroll speed in pixels / s
        self.scrollSpeed = 1.0

        # the duration of credits
        self.scrollTime = 0.0

        self.credits = None

        # OnscreenText object for rendering the credits
        self.creditsOST = None

        # positional interval used to scroll the texts
        self.scrollInterval = None

        self.camera = None
        self.camNP = None

        self.displayRegion = None

        self.playlist = None
コード例 #10
0
ファイル: CreditsState.py プロジェクト: vardis/pano
    def enter(self):

        FSMState.enter(self)

        self.game.getView().fadeOut(1.0)

        self._configure()

        globalClock.setMode(ClockObject.MSlave)

        # create alpha mask that fades the top and bottom
        img = PNMImage(8, 8)
        img.addAlpha()
        img.fill(1)
        img.alphaFill(1)
        for x in range(img.getXSize()):
            for y in range(img.getYSize()):
                img.setAlpha(
                    x, y, -.2 + 2.5 * math.sin(math.pi * y / img.getYSize()))
        self.alphaMask = img

        # create texture for applying the alpha mask
        self.tex = Texture()
        self.tex.load(self.alphaMask)
        self.tex.setWrapU(Texture.WMClamp)
        self.tex.setWrapV(Texture.WMClamp)

        # create scenegraph
        self.scene = NodePath('credits_scene_root')
        self.scene.setDepthTest(False)
        self.scene.setDepthWrite(False)

        self.textParent = self.scene.attachNewNode('text_parent')

        ts = TextureStage('')
        self.textParent.setTexGen(ts, TexGenAttrib.MWorldPosition)
        self.textParent.setTexScale(ts, .5, .5)
        self.textParent.setTexOffset(ts, .5, .5)
        self.textParent.setTexture(ts, self.tex)

        # background
        self.backgroundOSI = OnscreenImage(
            self.game.getResources().getResourceFullPath(
                PanoConstants.RES_TYPE_TEXTURES, self.background),
            parent=render2d)

        #  create credits text
        i18n = self.game.getI18n()
        localizedFont = i18n.getLocalizedFont(self.fontName)
        fontPath = self.game.getResources().getResourceFullPath(
            PanoConstants.RES_TYPE_FONTS, localizedFont)
        fontRes = loader.loadFont(fontPath)

        self.creditsOST = TextNode('creditsTextNode')
        crNP = self.textParent.attachNewNode(self.creditsOST)
        crNP.setScale(self.fontScale *
                      PandaUtil.getFontPixelPerfectScale(fontRes))
        self.creditsOST.setFont(fontRes)
        self.creditsOST.setEncoding(TextEncoder.EUtf8)
        self.creditsOST.setText(self.credits)
        self.creditsOST.setTextColor(
            Vec4(self.fontColor[0], self.fontColor[1], self.fontColor[2],
                 self.fontColor[3]))
        self.creditsOST.setAlign(TextNode.ACenter)
        crNP.setP(-90)
        crNP.flattenLight()

        b3 = self.textParent.getTightBounds()
        dims = b3[1] - b3[0]

        pixels = PandaUtil.unitsToPixelsY(dims[1] + 2.0 - 1.05)
        self.scrollTime = pixels / self.scrollSpeed
        self.log.debug('time to scroll: %f' % self.scrollTime)
        self.scrollInterval = LerpPosInterval(self.textParent, self.scrollTime,
                                              Point3(0, dims[1] + 2, 0),
                                              Point3(0, -1.05, 0))

        # render scene through an orthographic camera
        self.camera = Camera('credits_camera')
        lens = OrthographicLens()
        lens.setFilmSize(2, 2)
        lens.setNearFar(-1000, 1000)
        self.camera.setLens(lens)

        self.camNP = NodePath(self.camera)
        self.camNP.reparentTo(self.scene)
        self.camNP.setP(-90)

        self.displayRegion = self.game.getView().getWindow().makeDisplayRegion(
        )
        self.displayRegion.setClearColor(Vec4(0, 0, 0, 1))
        self.displayRegion.setCamera(self.camNP)
        self.displayRegion.setSort(20)

        self.game.getInput().addMappings('credits')

        self.game.getView().fadeIn(.5)

        self.scrollInterval.start()

        globalClock.setMode(ClockObject.MNormal)

        if self.playlist is not None:
            self.game.getMusic().setPlaylist(
                self.game.getResources().loadPlaylist(self.playlist))
            self.game.getMusic().play()
コード例 #11
0
ファイル: InventoryState.py プロジェクト: vardis/pano
 def exit(self):
     FSMState.exit(self)
     self.getGame().getInput().popMappings()
     self.inventoryView.hide()
コード例 #12
0
ファイル: InventoryState.py プロジェクト: vardis/pano
 def __init__(self, gameRef=None):
     FSMState.__init__(self, gameRef, PanoConstants.STATE_INVENTORY)
     self.log = logging.getLogger('pano.inventoryState')
     self.startSlot = None
     self.inventory = None
     self.inventoryView = None
コード例 #13
0
 def __init__(self, game, name, node):
     FSMState.__init__(self, game, name)
     self.log = logging.getLogger('pano.baseNodeScript')
     self.node = node
コード例 #14
0
ファイル: ConsoleState.py プロジェクト: vardis/pano
 def exit(self):
     FSMState.exit(self)
     self.log.debug('exited console state')
     self.getGame().getInput().popMappings()
コード例 #15
0
ファイル: ConsoleState.py プロジェクト: vardis/pano
 def enter(self):
     FSMState.enter(self)
     self.log.debug('entered console state')
     self.getGame().getInput().pushMappings('console')
コード例 #16
0
ファイル: ConsoleState.py プロジェクト: vardis/pano
 def __init__(self, gameRef):
     FSMState.__init__(self, gameRef, PanoConstants.STATE_CONSOLE)        
     self.log = logging.getLogger('pano.consoleState')