当前位置: 首页>>代码示例>>Python>>正文


Python Dialog.hide方法代码示例

本文整理汇总了Python中dialog.Dialog.hide方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.hide方法的具体用法?Python Dialog.hide怎么用?Python Dialog.hide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dialog.Dialog的用法示例。


在下文中一共展示了Dialog.hide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Game

# 需要导入模块: from dialog import Dialog [as 别名]
# 或者: from dialog.Dialog import hide [as 别名]
class Game():
    __game__ = None

    def __init__(self, engine):
        Game.__game__ = self
        self.applicationListener = None #run.py
        self.instance_to_agent = {}
        self.engine = engine #needed for exit function
        self.world= world.World(engine)
        self.agentManager = agents.agent_manager.AgentManager(self.world)
        self.dialog = Dialog(self)
        self.reset()


    @classmethod
    def getGame(cls):
        return Game.__game__

    def reset(self):
        self._state = STATE_START
        self._quest = 0
        self._secState = None

    def setApplicationListener(self, applicationListener):
        self.applicationListener = applicationListener

    """
        This method handles all the events. It should be the only function called from
        outside the Game class except for the callback methods (like onTalkButtonPress).
        Combining the event with the current state it decides how to responde.
    """
    def event(self, ev, *args):
        if ev == EV_START:
            if self._state == STATE_START:
                self.dialog.show("Start", "misc/game/start.txt", self.start)
            else:
                self.setState(STATE_PLAY)
        elif ev == EV_HIT:
            self.agentManager.getActiveAgent().health -= 10
            self.setHealth()
            if self.agentManager.getActiveAgent().health <= 0:
                self.deleteStatus()
                self.dialog.show("Exit", "misc/game/game_over.txt", self.game_over)
        elif ev == EV_ACTION_FINISHED:
            pass
        elif ev == EV_BEE_ARRIVED:
            if self.agentManager.beesAtHome():
                self._secState = STATE_BEE1
        elif ev == EV_QUEST_2:
            self.setState(STATE_PAUSE)
            self.dialog.show("Play", "misc/game/quest2.txt", self.quest2)
        elif ev == EV_BEE_DEAD:
            if self.agentManager.beesDead():
                self._secState = STATE_BEE3
        elif ev == EV_QUEST_3:
            self.setState(STATE_PAUSE)
            self.dialog.show("Play", "misc/game/quest3.txt", self.quest3)
        elif ev == EV_SHRINE:
            self._state = STATE_END
            self._secState = STATE_END
            self.dialog.show("Exit", "misc/game/end.txt", self.end)
        else:
            print "Event not recognized: {}".format(ev)

    """
        The functions in this block are callbacks from the gameStatus popup
    """
    def start(self):
        self.dialog.hide()
        self.dialog.show("Play", "misc/game/quest1.txt", self.quest1)

    def quest1(self):
        self.dialog.hide()
        self._quest = 1
        self.setState(STATE_PLAY)

    def quest2(self):
        self.dialog.hide()
        self._quest = 2
        self.setState(STATE_PLAY)
        self._secState = STATE_BEE2

    def quest3(self):
        self.dialog.hide()
        self._quest = 3
        self.setState(STATE_PLAY)
        self._secState = STATE_WIZARD2

    def game_over(self):
        self.exit()

    def end(self):
        self.deleteStatus()
        self.exit()

    """
        The following functions allow the user to save, load and delete the game status.
    """
    def show_save_dialog(self):
        if self._state == STATE_PLAY:
#.........这里部分代码省略.........
开发者ID:drolando,项目名称:SoftDev,代码行数:103,代码来源:game.py


注:本文中的dialog.Dialog.hide方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。