Ejemplo n.º 1
0
    def update(self, delta_time):
        super().update(delta_time)

        # Update the transition screen shake
        if self.transition:
            self.transition_delay = approach(self.transition_delay, 0,
                                             0.06 * delta_time)

            # Check if the next scene should be loaded
            if self.transition_delay == 0:
                self.transition_delay = 50
                self.transition = False

                # Checks if it is the last scene
                if Cutscene.current_cutscene == 19:
                    self.director.change_scene(scenes.Menu(True))
                    Config.level = 1
                    Cutscene.current_cutscene = 1
                    ScreenNarrator.current_narrator = 0
                    ScreenDialog.current_dialog = 0

                # Checks wheter next scene is a combat or another cutscene
                elif Cutscene.current_cutscene in (2, 5, 6, 9, 12, 15, 18):
                    Cutscene.current_cutscene += 1
                    self.director.change_scene(scenes.Stage())
                else:
                    Cutscene.current_cutscene += 1
                    self.director.change_scene(scenes.Cutscene())
        else:
            # Update the current screen
            self.current_screen.update(delta_time, self)
Ejemplo n.º 2
0
def cast_summon(caster, name=None, hostile=False):
    def summon_monster(name):
        print(name)
        x, y = 0, 0
        i = 0
        while i < 100:
            angle = rl.random_int(0, 359)
            distance = rl.random_int(2, 4)
            x = int(caster.x + .5 + math.cos(math.pi * angle / 180) * distance)
            y = int(caster.y + .5 + math.sin(math.pi * angle / 180) * distance)
            print(x, y)
            if not level.is_blocked(x, y) and caster.can_see_tile(x, y):
                break
            i += 1
        if i == 100:
            if caster is player:
                ui.message('You fail to cast the summon spell.', rl.BLUE)
        monster = monsters.make_monster(name, x, y)
        if not hostile:
            monster.master = caster
        level.objects.append(monster)
        if caster is player or player.can_see(caster) or player.can_see(monster):
            ui.message(util.capitalize(caster.get_name('summon{s}')) + ' ' + monster.get_name(determiner='a') + '.', rl.BLUE)
    if name is None:
        if caster is player:
            options = ['rat', 'bat', 'orc', 'troll', 'ghost', 'eye', 'fire_elemental', 'octopus', 'necromancer', 'wizard']
            def callback(index):
                game.pop_scene()
                summon_monster(options[index])
            game.push_scene(scenes.Menu('What monster do you want to summon?', options, callback))
            return
        else:
            name = monsters.random_choice(monsters.get_monster_chances())
    summon_monster(name)
Ejemplo n.º 3
0
def choose_level(caster):
    global dungeon_level
    options = ['Level %d' % i for i in range(1, 9)]

    def callback(index):
        game.pop_scene()
        game.dungeon_level = index
        game.next_level()

    game.push_scene(scenes.Menu('Choose level', options, callback))
Ejemplo n.º 4
0
def any_spell(caster):
    actions = [
        powers.LIGHTNING, powers.FEAR, powers.FIREBALL, powers.CONFUSE,
        powers.FREEZE, powers.TELEPORT, powers.DIG, powers.SUMMON
    ]
    options = [action.name for action in actions]

    def callback(index):
        game.pop_scene()
        actions[index].effect(player)

    game.push_scene(scenes.Menu('Which spell?', options, callback))
Ejemplo n.º 5
0
def see_ending(caster):
    options = [
        'rat', 'bat', 'orc', 'troll', 'ghost', 'eye', 'fire_elemental',
        'octopus', 'necromancer', 'wizard', 'original-body', 'ghoul'
    ]

    def callback(index):
        game.pop_scene()
        player.pop_controller()
        builtins.player = monsters.make_monster(options[index], 0, 0)
        player.push_controller(controllers.Player())
        game.push_scene(scenes.Ending())

    game.push_scene(scenes.Menu('Choose character', options, callback))
Ejemplo n.º 6
0
 def exec_quit(self):
     self.director.change_scene(scenes.Menu())
     if self.undo:
         scenes.Cutscene.current_cutscene -= 1
         scenes.ScreenDialog.current_dialog -= 1