本文整理汇总了C++中unit::get_modification_advances方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::get_modification_advances方法的具体用法?C++ unit::get_modification_advances怎么用?C++ unit::get_modification_advances使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::get_modification_advances方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: number_of_possible_advances
int number_of_possible_advances(const unit &u)
{
return u.advances_to().size() + u.get_modification_advances().size();
}
示例2: animate_unit_advancement
bool animate_unit_advancement(unit& u, size_t choice)
{
const events::command_disabler cmd_disabler;
if (u.advances() == false) {
return false;
}
const std::vector<std::string>& options = u.advances_to();
std::vector<config> mod_options = u.get_modification_advances();
if (choice >= options.size() + mod_options.size()) {
return false;
}
// When the unit advances, it fades to white, and then switches
// to the new unit, then fades back to the normal colour
game_display* disp = resources::screen;
rect_of_hexes& draw_area = disp->draw_area();
bool force_scroll = preferences::scroll_to_action();
bool animate = force_scroll || point_in_rect_of_hexes(u.get_location().x, u.get_location().y, draw_area);
if (!resources::screen->video().update_locked() && animate) {
unit_animator animator;
bool with_bars = true;
animator.add_animation(&u, "levelout", u.get_location(), map_location(), 0, with_bars);
animator.start_animations();
animator.wait_for_end();
}
if(choice < options.size()) {
// chosen_unit is not a reference, since the unit may disappear at any moment.
std::string chosen_unit = options[choice];
::advance_unit(u, chosen_unit);
} else {
unit* amla_unit = &u;
const config &mod_option = mod_options[choice - options.size()];
game_events::fire("advance", u.get_location());
amla_unit->get_experience(increase_xp::attack_ublock(*amla_unit), -amla_unit->max_experience()); // subtract xp required
// ALMA may want to change status, but add_modification in modify_according_to_hero cannot change state,
// so it need call amla_unit->add_modification instead of amla_unit->modify_according_to_hero.
amla_unit->add_modification(mod_option);
game_events::fire("post_advance", u.get_location());
}
resources::screen->invalidate_unit();
if (!resources::screen->video().update_locked()) {
if (force_scroll || point_in_rect_of_hexes(u.get_location().x, u.get_location().y, draw_area)) {
unit_animator animator;
animator.add_animation(&u, "levelin", u.get_location(), map_location(), 0, true);
animator.start_animations();
animator.wait_for_end();
animator.set_all_standing();
resources::screen->invalidate(u.get_location());
resources::screen->draw();
}
events::pump();
}
resources::screen->invalidate_all();
if (force_scroll || point_in_rect_of_hexes(u.get_location().x, u.get_location().y, draw_area)) {
resources::screen->draw();
}
return true;
}