1 #include "animationfactory.h"
4 #include "namedsprite.h"
5 #include "pointconverter.h"
6 #include "graphicalapi.h"
8 AnimationFactory::AnimationFactory(GraphicalAPI
* api
)
10 m_group
= AnimationGroupPtr(new AnimationGroup
);
13 AnimationGroupPtr
AnimationFactory::group() const {
17 void AnimationFactory::setGroup(const AnimationGroupPtr
& group
) {
21 void AnimationFactory::addPreAnimation(const Animate::Scheme
& scheme
, Animate::AnimationType type
) {
22 m_group
->addPreAnimation(m_api
->animate(scheme
, type
));
25 void AnimationFactory::addPostAnimation(const Animate::Scheme
& scheme
, Animate::AnimationType type
) {
26 m_group
->addPostAnimation(m_api
->animate(scheme
, type
));
29 AnimationFactory::operator AnimationGroupPtr() const {
37 move::move(const NamedSprite
& sprite
, const Point
& to
, int type
)
42 AnimationPtr
move::run(const PointConverter
* converter
, AnimationType type
) const {
45 MovementAnimation
* mov
;
46 if (m_type
& LShaped
) {
47 mov
= new KnightMovementAnimation(m_sprite
.sprite(), converter
->toReal(m_to
), m_type
& Rotating
);
50 mov
= new MovementAnimation(m_sprite
.sprite(), converter
->toReal(m_to
), m_type
& Rotating
);
52 return AnimationPtr(mov
);
56 return AnimationPtr(new InstantAnimation(m_sprite
.sprite(), converter
->toReal(m_to
)));
60 appear::appear(const NamedSprite
& sprite
)
61 : m_sprite(sprite
) { }
63 AnimationPtr
appear::run(const PointConverter
*, AnimationType type
) const {
66 return AnimationPtr(new FadeAnimation(m_sprite
.sprite(), 0, 255));
69 return AnimationPtr(new DropAnimation(m_sprite
.sprite()));
73 disappear::disappear(const NamedSprite
& sprite
)
74 : m_sprite(sprite
) { }
76 AnimationPtr
disappear::run(const PointConverter
*, AnimationType type
) const {
79 return AnimationPtr(new FadeAnimation(m_sprite
.sprite(), 255, 0));
82 return AnimationPtr(new CaptureAnimation(m_sprite
.sprite()));
86 destroy::destroy(const NamedSprite
& sprite
)
87 : m_sprite(sprite
) { }
89 AnimationPtr
destroy::run(const PointConverter
*, AnimationType type
) const {
92 return AnimationPtr(new ExplodeAnimation(m_sprite
.sprite(), Random::instance()));
95 return AnimationPtr(new CaptureAnimation(m_sprite
.sprite()));
99 morph::morph(const NamedSprite
& sprite
, const NamedSprite
& new_sprite
)
101 , m_new_sprite(new_sprite
) { }
103 AnimationPtr
morph::run(const PointConverter
*, AnimationType type
) const {
106 return AnimationPtr(new CrossFadingAnimation(m_sprite
.sprite(), m_new_sprite
.sprite()));
109 return AnimationPtr(new PromotionAnimation(m_sprite
.sprite(), m_new_sprite
.sprite()));