示例#1
0
    def on_key_press(self, key, modifiers):

        if mapKey(
                key) == pyglet.window.key.ENTER and self.dialog_layer.visible:
            if len(self.current_dialog) > self.current_dialog_counter + 2:
                self.current_dialog_counter += 2
                self.dialog_line1.element.text = self.current_dialog[
                    self.current_dialog_counter]
                if len(self.speaker_boxes) > 0:
                    for box in self.speaker_boxes:
                        self.speaker_boxes[box].visible = False
                    self.speaker_boxes[self.current_dialog_speaker[
                        self.current_dialog_counter]].visible = True

                if len(self.current_dialog) > self.current_dialog_counter:
                    self.dialog_line2.element.text = self.current_dialog[
                        self.current_dialog_counter + 1]

                if len(self.current_dialog) > self.current_dialog_counter + 2 and\
                   self.current_dialog_speaker[self.current_dialog_counter] == self.current_dialog_speaker[self.current_dialog_counter+2]:
                    self.dialog_arrow.visible = True
                else:
                    self.dialog_arrow.visible = False
            else:
                self.dialog_arrow.visible = False
                self.dialog_layer.visible = False
示例#2
0
    def on_key_release(self, key, modifiers):

        key = mapKey(key)

        if key == pyglet.window.key.ESCAPE:
            cocos.director.director.window.pop_handlers()
            if self.game_over == True:
                cocos.director.director.terminate_app = True
            self.end()
示例#3
0
    def on_key_release(self, key, modifiers):

        key = mapKey(key)

        if key == pyglet.window.key.ESCAPE:
            cocos.director.director.window.pop_handlers()
            if self.game_over == True:
                cocos.director.director.terminate_app = True
            self.end()
示例#4
0
    def on_key_press(self, key, modifiers):

        if mapKey(key) == pyglet.window.key.ENTER and self.dialog_layer.visible:
            if len(self.current_dialog) > self.current_dialog_counter + 2:
                self.current_dialog_counter += 2
                self.dialog_line1.element.text = self.current_dialog[self.current_dialog_counter]
                if len(self.speaker_boxes) > 0:
                    for box in self.speaker_boxes:
                        self.speaker_boxes[box].visible = False
                    self.speaker_boxes[self.current_dialog_speaker[self.current_dialog_counter]].visible = True

                if len(self.current_dialog) > self.current_dialog_counter:
                    self.dialog_line2.element.text = self.current_dialog[self.current_dialog_counter+1]

                if len(self.current_dialog) > self.current_dialog_counter + 2 and\
                   self.current_dialog_speaker[self.current_dialog_counter] == self.current_dialog_speaker[self.current_dialog_counter+2]:
                    self.dialog_arrow.visible = True
                else:
                    self.dialog_arrow.visible = False
            else:
                self.dialog_arrow.visible = False
                self.dialog_layer.visible = False
示例#5
0
    def on_key_release(self,key,modifiers):

        key = mapKey(key)

        if self.menu_level == 0:

            if key == pyglet.window.key.LEFT:
                # SFX['move-select'].play()
                self.next_command(-1)

            if key == pyglet.window.key.RIGHT:
                # SFX['move-select'].play()
                self.next_command(1)

            if key == pyglet.window.key.ENTER:
                l = 1
                action = self.commands[self.active][self.n_command].element.text.lower()

                if action == 'skills':
                    l = len(self.heros[self.active].skills)

                if action =='items':
                    l = len(INVENTORY)

                if l <= 0:
                    # SFX['error'].play()
                    return

                # SFX['select'].play()
                self.setMenuLevel(1)

            if key == pyglet.window.key.ESCAPE:
                # SFX['error'].play()
                pass

        elif self.menu_level == 1:

            if key == pyglet.window.key.UP:
                # SFX['move-select'].play()
                self.next_slot(-1)

            if key == pyglet.window.key.DOWN:
                # SFX['move-select'].play()
                self.next_slot(1)

            if key == pyglet.window.key.ENTER:
                
                action = self.sub_list[self.active][self.n_slot].element.text.lower()

                if self.n_command == 1:

                    if self.heros[self.active].mp[0] < MAGIC[action]:
                        # SFX['error'].play()
                        return

                # SFX['select'].play()
                self.action = self.sub_list[self.active][self.n_slot].element.text.lower()

                self.choice_arrow.kill()
                if self.action in FRIEND_SKILL:
                    self.choice_arrow = Sprite('img/GUI/arrow_friend.png')
                else:
                    self.choice_arrow = Sprite('img/GUI/arrow_enemy.png')
                self.add(self.choice_arrow,z=6)

                self.setMenuLevel(2)

            if key == pyglet.window.key.ESCAPE:
                # SFX['escape'].play()
                memo = self.n_command
                self.setMenuLevel(0)
                self.n_command = memo

        elif self.menu_level == 2:

            if key == pyglet.window.key.LEFT:
                # SFX['move-select'].play()
                self.next_choice(-1)

            if key == pyglet.window.key.RIGHT:
                # SFX['move-select'].play()
                self.next_choice(1)

            if key == pyglet.window.key.ENTER:
                # SFX['select'].play()
                if self.action in FRIEND_SKILL:
                    self.target = self.heros[self.n_choice]
                else:
                    self.target = self.enemies[self.n_choice]
                self.run_action()

            if key == pyglet.window.key.ESCAPE:
                # SFX['escape'].play()
                if self.n_command == 0:
                    self.setMenuLevel(0)
                else:
                    self.setMenuLevel(1)
示例#6
0
    def on_key_release(self,key,modifiers):

        key = mapKey(key)

        if self.menu_level == 0:

            if key == pyglet.window.key.LEFT:
                SFX['move-select'].play()
                self.next_command(-1)

            if key == pyglet.window.key.RIGHT:
                SFX['move-select'].play()
                self.next_command(1)

            if key == pyglet.window.key.ENTER:
                l = 1
                action = self.commands[self.active][self.n_command].element.text.lower()

                if action == 'skills':
                    l = len(self.heros[self.active].skills)

                if action =='items':
                    l = len(INVENTORY)

                if l <= 0:
                    SFX['error'].play()
                    return

                SFX['select'].play()
                self.setMenuLevel(1)

            if key == pyglet.window.key.ESCAPE:
                SFX['error'].play()

        elif self.menu_level == 1:

            if key == pyglet.window.key.UP:
                SFX['move-select'].play()
                self.next_slot(-1)

            if key == pyglet.window.key.DOWN:
                SFX['move-select'].play()
                self.next_slot(1)

            if key == pyglet.window.key.ENTER:
                
                action = self.sub_list[self.active][self.n_slot].element.text.lower()

                if self.n_command == 1:

                    if self.heros[self.active].mp[0] < MAGIC[action]:
                        SFX['error'].play()
                        return

                SFX['select'].play()
                self.action = self.sub_list[self.active][self.n_slot].element.text.lower()

                self.choice_arrow.kill()
                if self.action in FRIEND_SKILL:
                    self.choice_arrow = Sprite('img/GUI/arrow_friend.png')
                else:
                    self.choice_arrow = Sprite('img/GUI/arrow_enemy.png')
                self.add(self.choice_arrow,z=6)

                self.setMenuLevel(2)

            if key == pyglet.window.key.ESCAPE:
                SFX['escape'].play()
                memo = self.n_command
                self.setMenuLevel(0)
                self.n_command = memo

        elif self.menu_level == 2:

            if key == pyglet.window.key.LEFT:
                SFX['move-select'].play()
                self.next_choice(-1)

            if key == pyglet.window.key.RIGHT:
                SFX['move-select'].play()
                self.next_choice(1)

            if key == pyglet.window.key.ENTER:
                SFX['select'].play()
                if self.action in FRIEND_SKILL:
                    self.target = self.heros[self.n_choice]
                else:
                    self.target = self.enemies[self.n_choice]
                self.run_action()

            if key == pyglet.window.key.ESCAPE:
                SFX['escape'].play()
                if self.n_command == 0:
                    self.setMenuLevel(0)
                else:
                    self.setMenuLevel(1)