示例#1
0
def character_move(
    character_id: str, target_scene: list
) -> (str, list, list, int):
    """
    通用角色移动控制
    Keyword arguments:
    character_id -- 角色id
    target_scene -- 寻路目标场景(在地图系统下的绝对坐标)
    Return arguments:
    str:null -- 未找到路径
    str:end -- 当前位置已是路径终点
    list -- 路径
    list -- 本次移动到的位置
    int -- 本次移动花费的时间
    """
    now_position = cache_contorl.character_data[character_id].position
    scene_hierarchy = map_handle.judge_scene_affiliation(
        now_position, target_scene
    )
    if scene_hierarchy == "common":
        map_path = map_handle.get_common_map_for_scene_path(
            now_position, target_scene
        )
        now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            map_path, now_position
        )
        target_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            map_path, target_scene
        )
        return identical_map_move(
            character_id, map_path, now_map_scene_id, target_map_scene_id
        )
    return difference_map_move(character_id, target_scene)
示例#2
0
 def down_map(self):
     """ 将当前地图切换为下级地图 """
     py_cmd.clr_cmd()
     character_position = cache.character_data[0].position
     down_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
         self.now_map, character_position)
     self.now_map.append(down_map_scene_id)
示例#3
0
def see_map_flow():
    """
    地图查看流程
    """
    while True:
        py_cmd.clr_cmd()
        input_s = []
        map_cmd = see_map_panel.see_map_panel()
        start_id_1 = len(map_cmd)
        input_s = input_s + map_cmd
        move_path_cmd_data = see_map_panel.see_move_path_panel()
        move_path_cmd = move_path_cmd_data["input_s"]
        move_path_list = move_path_cmd_data["scene_path_list"]
        show_scene_name_list_cmd = see_map_panel.show_scene_name_list_panel()
        see_map_cmd = see_map_panel.back_scene_panel(start_id_1)
        input_s += see_map_cmd + move_path_cmd + [show_scene_name_list_cmd]
        yrn = flow_handle.askfor_all(input_s)
        back_button = str(start_id_1)
        now_position = cache_contorl.character_data["character"][0].position
        now_position_map = map_handle.get_map_for_path(now_position)
        up_map_button = "Null"
        down_map_button = "Null"
        if now_position_map != [] and cache_contorl.now_map != []:
            up_map_button = str(int(start_id_1) + 1)
        if now_position_map != cache_contorl.now_map:
            if up_map_button == "Null":
                down_map_button = str(int(start_id_1) + 1)
            else:
                down_map_button = str(int(start_id_1) + 2)
        now_map = cache_contorl.now_map.copy()
        if yrn in map_cmd:
            now_target_path = map_handle.get_scene_path_for_map_scene_id(
                now_map, yrn)
            character_move.own_charcter_move(now_target_path)
            break
        elif yrn == back_button:
            cache_contorl.now_map = []
            cache_contorl.now_flow_id = "in_scene"
            break
        elif yrn in move_path_cmd:
            move_list_id = move_path_cmd.index(yrn)
            move_id = move_path_list[move_list_id]
            now_target_path = map_handle.get_scene_path_for_map_scene_id(
                now_map, move_id)
            character_move.own_charcter_move(now_target_path)
            break
        elif up_map_button != "Null" and yrn == up_map_button:
            up_map_path = map_handle.get_map_for_path(now_map)
            cache_contorl.now_map = up_map_path
        elif down_map_button != "Null" and yrn == down_map_button:
            character_position = cache_contorl.character_data["character"][
                0].position
            down_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                cache_contorl.now_map, character_position)
            now_map.append(down_map_scene_id)
            cache_contorl.now_map = now_map
        elif yrn == show_scene_name_list_cmd:
            panel_state_handle.panel_state_change(show_scene_name_list_cmd)
示例#4
0
def difference_map_move(character_id: str,
                        target_scene: list) -> (str, list, list, int):
    """
    角色跨地图层级移动
    Keyword arguments:
    character_id -- 角色id
    target_scene -- 寻路目标场景(在地图系统下的绝对坐标)
    Return arguments:
    str:null -- 未找到路径
    str:end -- 当前位置已是路径终点
    list -- 路径
    list -- 本次移动到的位置
    int -- 本次移动花费的时间
    """
    character_data = cache.character_data[character_id]
    now_position = character_data.position
    is_affiliation = map_handle.judge_scene_affiliation(
        now_position, target_scene)
    now_true_position = map_handle.get_scene_path_for_true(now_position)
    now_true_map = map_handle.get_map_for_path(now_true_position)
    if is_affiliation == "subordinate":
        now_true_affiliation = map_handle.judge_scene_is_affiliation(
            now_true_position, target_scene)
        if now_true_affiliation == "subordinate":
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                now_true_map, now_true_position)
            return identical_map_move(character_id, now_true_map,
                                      now_map_scene_id, "0")
        now_map = map_handle.get_map_for_path(target_scene)
        now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            now_map, now_position)
        return identical_map_move(character_id, now_map, now_map_scene_id, "0")
    relation_map_list = map_handle.get_relation_map_list_for_scene_path(
        now_true_position)
    now_scene_real_map = relation_map_list[-1]
    now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
        now_scene_real_map, now_true_position)
    common_map = map_handle.get_common_map_for_scene_path(
        now_true_position, target_scene)
    if now_scene_real_map != common_map:
        if now_map_scene_id == "0":
            now_true_position = now_scene_real_map.copy()
            relation_map_list = map_handle.get_relation_map_list_for_scene_path(
                now_true_position)
            now_scene_real_map = relation_map_list[-1]
    target_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
        common_map, target_scene)
    if now_scene_real_map == common_map:
        now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            common_map, now_true_position)
    else:
        now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            now_scene_real_map, now_true_position)
        target_map_scene_id = "0"
        common_map = now_scene_real_map
    return identical_map_move(character_id, common_map, now_map_scene_id,
                              target_map_scene_id)
示例#5
0
def see_move_path_panel() -> dict:
    """
    当前场景可直接通往的移动路径绘制面板
    """
    input_s = []
    now_scene = cache_contorl.character_data[0].position
    now_map = cache_contorl.now_map
    now_map_str = map_handle.get_map_system_path_str_for_list(now_map)
    map_data = cache_contorl.map_data[now_map_str]
    move_path_info = text_loading.get_text_data(constant.FilePath.MESSAGE_PATH,
                                                "27")
    era_print.normal_print("\n")
    era_print.line_feed_print(move_path_info)
    path_edge = map_data["PathEdge"]
    map_scene_id = map_handle.get_map_scene_id_for_scene_path(
        now_map, now_scene)
    scene_path = path_edge[map_scene_id].copy()
    if map_scene_id in scene_path:
        del scene_path[map_scene_id]
    scene_path_list = list(scene_path.keys())
    if len(scene_path_list) > 0:
        scene_cmd = []
        for scene in scene_path_list:
            now_map_str = map_handle.get_map_system_path_str_for_list(now_map)
            load_scene_data = map_handle.get_scene_data_for_map(
                now_map_str, scene)
            scene_name = load_scene_data["SceneName"]
            scene_cmd.append(scene_name)
        yrn = cmd_button_queue.option_str(
            cmd_list=None,
            cmd_list_data=scene_cmd,
            cmd_column=4,
            askfor=False,
            cmd_size="center",
        )
        input_s = input_s + yrn
    else:
        error_move_text = text_loading.get_text_data(
            constant.FilePath.MESSAGE_PATH, "28")
        era_print.normal_print(error_move_text)
    era_print.restart_line_print()
    return {"input_s": input_s, "scene_path_list": scene_path_list}
示例#6
0
 def draw(self):
     """ 绘制面板 """
     self.return_list = []
     map_path_str = map_handle.get_map_system_path_str_for_list(
         self.now_map)
     map_data: game_type.Map = cache.map_data[map_path_str]
     path_edge = map_data.path_edge
     scene_id_list = list(path_edge.keys())
     if len(scene_id_list):
         character_data: game_type.Character = cache.character_data[0]
         character_scene_id = map_handle.get_map_scene_id_for_scene_path(
             self.now_map, character_data.position)
         scene_path = path_edge[character_scene_id].copy()
         if character_scene_id in scene_path:
             del scene_path[character_scene_id]
         scene_path_list = list(scene_path.keys())
         draw_list = []
         for scene_id in scene_id_list:
             load_scene_data = map_handle.get_scene_data_for_map(
                 map_path_str, scene_id)
             now_scene_path = map_handle.get_map_system_path_for_str(
                 load_scene_data.scene_path)
             now_id_text = f"{scene_id}:{load_scene_data.scene_name}"
             now_draw = draw.LeftButton(now_id_text,
                                        now_id_text,
                                        self.width,
                                        cmd_func=self.move_now,
                                        args=(now_scene_path, ))
             self.return_list.append(now_draw.return_text)
             draw_list.append(now_draw)
         draw_group = value_handle.list_of_groups(draw_list, 4)
         now_width_index = 0
         for now_draw_list in draw_group:
             if len(now_draw_list) > now_width_index:
                 now_width_index = len(now_draw_list)
         now_width = self.width / now_width_index
         for now_draw_list in draw_group:
             for now_draw in now_draw_list:
                 now_draw.width = now_width
                 now_draw.draw()
             line_feed.draw()
     self.end_index = len(scene_id_list) - 1
示例#7
0
 def draw(self):
     """ 绘制对象 """
     move_menu_panel_data = {
         0: MapSceneNameDraw(self.now_map, self.width),
         1: GlobalSceneNamePanel(self.now_map, self.width),
         2: SocialSceneNamePanel(self.now_map, self.width),
         3: CollectionSceneNamePanel(self.now_map, self.width),
     }
     move_menu_panel = MoveMenuPanel(self.width)
     while 1:
         line_feed.draw()
         if cache.now_panel_id != constant.Panel.SEE_MAP:
             break
         map_path_str = map_handle.get_map_system_path_str_for_list(
             self.now_map)
         map_data: game_type.Map = cache.map_data[map_path_str]
         map_name = attr_text.get_map_path_text(self.now_map)
         title_draw = draw.TitleLineDraw(_("移动:") + map_name, self.width)
         title_draw.draw()
         now_draw_list: game_type.MapDraw = map_data.map_draw
         character_data: game_type.Character = cache.character_data[0]
         character_scene_id = map_handle.get_map_scene_id_for_scene_path(
             self.now_map, character_data.position)
         return_list = []
         index = 0
         for now_draw_line in now_draw_list.draw_text:
             fix_width = int((self.width - now_draw_line.width) / 2)
             fix_text = " " * fix_width
             fix_draw = draw.NormalDraw()
             fix_draw.text = fix_text
             fix_draw.width = fix_width
             fix_draw.draw()
             for draw_text in now_draw_line.draw_list:
                 if draw_text.is_button and draw_text.text != character_scene_id:
                     scene_path = map_handle.get_scene_path_for_map_scene_id(
                         self.now_map, draw_text.text)
                     now_draw = draw.Button(draw_text.text,
                                            draw_text.text,
                                            cmd_func=self.move_now,
                                            args=(scene_path, ))
                     now_draw.width = self.width
                     now_draw.draw()
                     return_list.append(now_draw.return_text)
                 else:
                     now_draw = draw.NormalDraw()
                     now_draw.text = draw_text.text
                     now_draw.width = self.width
                     if draw_text.is_button and draw_text.text == character_scene_id:
                         now_draw.style = "nowmap"
                     now_draw.draw()
             line_feed.draw()
         path_edge = map_data.path_edge
         scene_path = path_edge[character_scene_id].copy()
         if character_scene_id in scene_path:
             del scene_path[character_scene_id]
         scene_path_list = list(scene_path.keys())
         if len(scene_path_list):
             line = draw.LineDraw(".", self.width)
             line.draw()
             message_draw = draw.NormalDraw()
             message_draw.text = _("你可以从这里前往:\n")
             message_draw.width = self.width
             message_draw.draw()
             draw_list = []
             for scene in scene_path_list:
                 load_scene_data = map_handle.get_scene_data_for_map(
                     map_path_str, scene)
                 now_scene_path = map_handle.get_map_system_path_for_str(
                     load_scene_data.scene_path)
                 now_draw = draw.CenterButton(
                     f"[{load_scene_data.scene_name}]",
                     load_scene_data.scene_name,
                     self.width / 4,
                     cmd_func=self.move_now,
                     args=(now_scene_path, ),
                 )
                 return_list.append(now_draw.return_text)
                 draw_list.append(now_draw)
             draw_group = value_handle.list_of_groups(draw_list, 4)
             for now_draw_list in draw_group:
                 for now_draw in now_draw_list:
                     now_draw.draw()
                 line_feed.draw()
         scene_id_list = list(path_edge.keys())
         now_index = len(scene_id_list)
         index = now_index
         move_menu_panel.update()
         move_menu_panel.draw()
         return_list.extend(move_menu_panel.return_list)
         if move_menu_panel.now_type in move_menu_panel_data:
             now_move_menu = move_menu_panel_data[move_menu_panel.now_type]
             now_move_menu.update(self.now_map, index)
             now_move_menu.draw()
             now_index = now_move_menu.end_index + 1
             return_list.extend(now_move_menu.return_list)
         line = draw.LineDraw("=", self.width)
         line.draw()
         if self.now_map != []:
             now_id = text_handle.id_index(now_index)
             now_text = now_id + _("查看上级地图")
             up_button = draw.CenterButton(now_text,
                                           str(now_index),
                                           self.width / 3,
                                           cmd_func=self.up_map)
             up_button.draw()
             return_list.append(up_button.return_text)
             now_index += 1
         else:
             now_draw = draw.NormalDraw()
             now_draw.text = " " * int(self.width / 3)
             now_draw.width = self.width / 3
             now_draw.draw()
         back_id = text_handle.id_index(now_index)
         now_text = back_id + _("返回")
         back_button = draw.CenterButton(now_text, str(now_index),
                                         self.width / 3)
         back_button.draw()
         return_list.append(back_button.return_text)
         now_index += 1
         character_map = map_handle.get_map_for_path(
             character_data.position)
         if character_map != self.now_map:
             now_id = text_handle.id_index(now_index)
             now_text = now_id + _("查看下级地图")
             down_button = draw.CenterButton(now_text,
                                             str(now_index),
                                             self.width / 3,
                                             cmd_func=self.down_map)
             down_button.draw()
             return_list.append(down_button.return_text)
         line_feed.draw()
         yrn = flow_handle.askfor_all(return_list)
         py_cmd.clr_cmd()
         if yrn == back_button.return_text:
             cache.now_panel_id = constant.Panel.IN_SCENE
             break
示例#8
0
def difference_map_move(
    character_id: str, target_scene: list
) -> (str, list, list, int):
    """
    角色跨地图层级移动
    Keyword arguments:
    character_id -- 角色id
    target_scene -- 寻路目标场景(在地图系统下的绝对坐标)
    Return arguments:
    str:null -- 未找到路径
    str:end -- 当前位置已是路径终点
    list -- 路径
    list -- 本次移动到的位置
    int -- 本次移动花费的时间
    """
    now_position = cache_contorl.character_data[character_id].position
    is_affiliation = map_handle.judge_scene_is_affiliation(
        now_position, target_scene
    )
    now_true_position = map_handle.get_scene_path_for_true(now_position)
    map_door_data = map_handle.get_map_door_data_for_scene_path(
        map_handle.get_map_system_path_str_for_list(now_true_position)
    )
    door_scene = "0"
    now_true_map = map_handle.get_map_for_path(now_true_position)
    now_true_map_map_system_str = map_handle.get_map_system_path_str_for_list(
        now_true_map
    )
    if is_affiliation == "subordinate":
        now_true_affiliation = map_handle.judge_scene_is_affiliation(
            now_true_position, target_scene
        )
        if now_true_affiliation == "subordinate":
            if map_door_data != {}:
                door_scene = map_door_data[now_true_map_map_system_str]["Door"]
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                now_true_map, now_position
            )
            return identical_map_move(
                character_id, now_true_map, now_map_scene_id, door_scene
            )
        now_map = map_handle.get_map_for_path(target_scene)
        now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            now_map, now_position
        )
        return identical_map_move(
            character_id, now_map, now_map_scene_id, door_scene
        )
    else:
        if now_true_map == []:
            now_target_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                [], target_scene
            )
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                [], now_true_position
            )
            return identical_map_move(
                character_id, [], now_map_scene_id, now_target_map_scene_id
            )
        relation_map_list = map_handle.get_relation_map_list_for_scene_path(
            now_true_position
        )
        now_scene_real_map = relation_map_list[-1]
        common_map = map_handle.get_common_map_for_scene_path(
            now_true_position, target_scene
        )
        real_map_in_map = map_handle.get_map_for_path(now_scene_real_map)
        target_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
            common_map, target_scene
        )
        if now_scene_real_map == common_map:
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                common_map, now_true_position
            )
        elif real_map_in_map == common_map:
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                common_map, now_scene_real_map
            )
        else:
            now_map_scene_id = map_handle.get_map_scene_id_for_scene_path(
                now_true_map, now_true_position
            )
            target_map_scene_id = "0"
            common_map = now_scene_real_map
        return identical_map_move(
            character_id, common_map, now_map_scene_id, target_map_scene_id
        )