new animations : pre_movement_anim and post_movement_anim...

...for drake take-off and landing
This commit is contained in:
Jérémy Rosen 2009-09-02 21:38:07 +00:00
parent 717eca7428
commit 98ff6e4888
3 changed files with 44 additions and 1 deletions

View file

@ -60,6 +60,9 @@ Version 1.7.4:
* Fix regression about broken undo after a multi-turn ("goto") move
* Fix regression about pathfinding poorly using the teleport ability
* Added extra wiki comment and updated the extractor
* Animations
* Movement have the number of steps done in value and the number of step left in value_second.
* new animations pre_movement_anim and post_movement_anim to allow take-off and landing animation
Version 1.7.3:
* AI:

View file

@ -363,6 +363,16 @@ void unit_animation::fill_initial_animations( std::vector<unit_animation> & anim
tmp_anim.event_ = utils::split("levelout");
animations.push_back(tmp_anim);
tmp_anim = *itor;
tmp_anim.unit_anim_.override(0,1,"","",0,"");
tmp_anim.event_ = utils::split("pre_movement");
animations.push_back(tmp_anim);
tmp_anim = *itor;
tmp_anim.unit_anim_.override(0,1,"","",0,"");
tmp_anim.event_ = utils::split("post_movement");
animations.push_back(tmp_anim);
tmp_anim = *itor;
tmp_anim.unit_anim_.override(0,5100,"","",0,"0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,",lexical_cast<std::string>(display::LAYER_UNIT_MOVE_DEFAULT-display::LAYER_UNIT_FIRST));
tmp_anim.event_ = utils::split("movement");
@ -548,6 +558,14 @@ void unit_animation::add_anims( std::vector<unit_animation> & animations, const
animations.back().sub_anims_["_poison_sound"].add_frame(1,frame_builder().sound("poison.ogg"),true);
}
expanded_cfg = unit_animation::prepare_animation(cfg,"pre_movement_anim");
foreach (config &anim, expanded_cfg.child_range("pre_movement_anim"))
{
anim["apply_to"] = "pre_movement";
if (anim["layer"].empty()) anim["layer"] = move_layer;
animations.push_back(unit_animation(anim));
}
expanded_cfg = unit_animation::prepare_animation(cfg,"movement_anim");
foreach (config &anim, expanded_cfg.child_range("movement_anim"))
{
@ -559,6 +577,14 @@ void unit_animation::add_anims( std::vector<unit_animation> & animations, const
animations.push_back(unit_animation(anim));
}
expanded_cfg = unit_animation::prepare_animation(cfg,"post_movement_anim");
foreach (config &anim, expanded_cfg.child_range("post_movement_anim"))
{
anim["apply_to"] = "post_movement";
if (anim["layer"].empty()) anim["layer"] = move_layer;
animations.push_back(unit_animation(anim));
}
expanded_cfg = unit_animation::prepare_animation(cfg,"defend");
foreach (config &anim, expanded_cfg.child_range("defend"))
{

View file

@ -159,6 +159,15 @@ void move_unit(const std::vector<map_location>& path, unit& u, const std::vector
// don't forget to change the previous draw(false) to true
disp->draw(true);
// extra immobile mvt anim for take-off
temp_unit.set_location(path[0]);
disp->place_temporary_unit(temp_unit);
temp_unit.set_facing(path[0].get_relative_dir(path[1]));
unit_animator animator;
animator.add_animation(&temp_unit,"pre_movement",path[0],path[1]);
animator.start_animations();
animator.wait_for_end();
for(size_t i = 0; i+1 < path.size(); ++i) {
invisible = teams[temp_unit.side()-1].is_enemy(int(disp->viewing_team()+1)) &&
@ -190,9 +199,14 @@ void move_unit(const std::vector<map_location>& path, unit& u, const std::vector
}
}
}
temp_unit.set_location(path[path.size() - 1]);
temp_unit.set_facing(path[path.size()-2].get_relative_dir(path[path.size()-1]));
animator.clear();
animator.add_animation(&temp_unit,"post_movement",path[path.size()-2],path[path.size()-1]);
animator.start_animations();
animator.wait_for_end();
disp->remove_temporary_unit();
u.set_location(path[path.size() - 1]);
u.set_facing(path[path.size()-2].get_relative_dir(path[path.size()-1]));
u.set_standing();
u.set_hidden(was_hidden);