예제 #1
0
void MapLoader::load_level() {
  Logger::info("Cargando nivel");

  xmlpp::Node *visible_layer = (*level_)->get_first_child("visible-object-layer");
  const xmlpp::Node::NodeList &rectangles = visible_layer->get_children("rectangle");
  for (std::list<xmlpp::Node *>::const_iterator it = rectangles.begin();
       it != rectangles.end(); ++it) {
    // Lo agrega al engine
    add_floor(*it);
  }

  xmlpp::Node *control_layer = (*level_)->get_first_child("control-object-layer");
  const xmlpp::Node::NodeList &startpoints = control_layer->get_children("startpoint");
  clean_start_points();
  for (std::list<xmlpp::Node *>::const_iterator it = startpoints.begin();
       it != startpoints.end(); ++it) {
    // LO AGREGA EN EL MAP LOADER!!! SE NECESITA LIMPIAR ESTO!!!
    add_startpoint(*it);
  }

  const xmlpp::Node::NodeList &spawnpoints = control_layer->get_children("spawnpoint");
  for (std::list<xmlpp::Node *>::const_iterator it = spawnpoints.begin();
       it != spawnpoints.end(); ++it) {
    // Lo agrega al engine
    add_spawnpoint(*it);
  }

  const xmlpp::Node::NodeList &goals = control_layer->get_children("goal");
  for (std::list<xmlpp::Node *>::const_iterator it = goals.begin();
       it != goals.end(); ++it) {
    // Lo agrega al engine
    add_goal(*it);
  }
}
예제 #2
0
Level* LevelLoader::load_level(const std::string& level_file_name) {
  parser_.parse_file(level_file_name);
  xmlpp::Node* level_node = parser_.get_document()->get_root_node();
  level_ = new Level(
    level_node->eval_to_string("@title"),
    static_cast<int>(level_node->eval_to_number("@width")),
    static_cast<int>(level_node->eval_to_number("@height")),
    static_cast<int>(level_node->eval_to_number("@players_size")));

  xmlpp::Node *visible_layer = (level_node)->get_first_child("visible-object-layer");
  const xmlpp::Node::NodeList &rectangles = visible_layer->get_children("rectangle");
  for (std::list<xmlpp::Node *>::const_iterator it = rectangles.begin();
       it != rectangles.end(); ++it) {
    add_floor(*it);
  }

  xmlpp::Node *control_layer = (level_node)->get_first_child("control-object-layer");
  const xmlpp::Node::NodeList &startpoints = control_layer->get_children("startpoint");
  for (std::list<xmlpp::Node *>::const_iterator it = startpoints.begin();
       it != startpoints.end(); ++it) {
    add_startpoint(*it);
  }

  const xmlpp::Node::NodeList &spawnpoints = control_layer->get_children("spawnpoint");
  for (std::list<xmlpp::Node *>::const_iterator it = spawnpoints.begin();
       it != spawnpoints.end(); ++it) {
    add_spawnpoint(*it);
  }

  const xmlpp::Node::NodeList &goals = control_layer->get_children("goal");
  for (std::list<xmlpp::Node *>::const_iterator it = goals.begin();
       it != goals.end(); ++it) {
    add_goal(*it);
  }

  return level_;
}
예제 #3
0
int main() {
    fp = fopen("log.txt", "w");
    log_time();
    fprintf(fp, "Start Programm\n");

    int target_floor, target_room;
    int view_flag = 1;
    building *building_list = (building *) malloc(sizeof(building));
    log_time();
    fprintf(fp, "init building_list\n");
    init(building_list);
    add_floor(building_list, FALSE);
    add_room(building_list, FALSE);
    add_room(building_list, FALSE);
    add_room(building_list, FALSE);

    while (1) {
        fflush(fp);
        if (view_flag)
            view_building(building_list, TRUE);
        else {
            view_room(building_list, target_floor, target_room);
        }
        switch (input_cmd()) {
            case 1: { // [1] 건물 확장
                switch (input_extend_cmd()) {
                    case 1: { // [1] 층 확장
                        add_floor(building_list, TRUE);
                        break;
                    }
                    case 2: { // [2] 방 확장
                        add_room(building_list, TRUE);
                        break;
                    }
                }
                break;
            }
            case 2: { // [2] View 변환
                if (view_flag) {
                    printf("특정 방 내부 보여주기 로 View가 변환되었습니다.\n");
                    printf("층과 호수를 입력하세요\n");
                    if (tts_flag) {
                        system("pico2wave -w test.wav \"Translated the view into the specific room viewing.\"");
                        system("aplay -q test.wav");
                        system("pico2wave -w test.wav \"Input floor number and room number\"");
                        system("aplay -q test.wav");
                    }
                    scanf("%d %d", &target_floor, &target_room);
                    view_flag = 0;
                } else {
                    printf("전체 방 보여주기 로 View가 변환되었습니다.\n");
                    if (tts_flag) {
                        system("pico2wave -w test.wav \"Translated the view into the total room viewing.\"");
                        system("aplay -q test.wav");
                    }
                    view_flag = 1;
                }
                break;
            }
            case 3: { // [3] 방 별 칸 변환
                change_space(building_list);
                break;
            }
            case 4: { // [4] 칸 별 사람 이름 변환
                change_name(building_list);
                break;
            }
            case 5: {
                search_name(building_list);
                break;
            }
            case 6: { // [6] TTS ON/OFF
                if (tts_flag) {
                    printf("TTS를 사용하지않습니다.\n");
                    tts_flag = 0;
                } else {
                    printf("TTS를 사용합니다.\n");
                    system("pico2wave -w test.wav \"From now, Use text to speach.\"");
                    system("aplay -q test.wav");
                    tts_flag = 1;
                }
                break;
            }
            case 7: { // [5] 종료
                printf("\n프로그램을 종료합니다.\n");
                if (tts_flag) {
                    system("pico2wave -w test.wav \"Exit Program.\"");
                    system("aplay -q test.wav");
                }
                return 0;
                break;
            }
        }
    }
    return 0;
}