]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/AttackAnimation.cpp
alternate approach to battle animation
[l2e.git] / src / battle / AttackAnimation.cpp
diff --git a/src/battle/AttackAnimation.cpp b/src/battle/AttackAnimation.cpp
deleted file mode 100644 (file)
index 07148db..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * AttackAnimation.cpp
- *
- *  Created on: Aug 13, 2012
- *      Author: holy
- */
-
-#include "AttackAnimation.h"
-
-#include "BattleState.h"
-#include "../app/State.h"
-#include "../graphics/Animation.h"
-
-using geometry::Point;
-using graphics::Animation;
-using std::vector;
-
-namespace battle {
-
-AttackAnimation::~AttackAnimation() {
-       for (vector<AnimationMemo>::const_iterator i(animations.begin()), end(animations.end()); i != end; ++i) {
-               i->animation->Stop();
-       }
-       for (vector<Animation *>::const_iterator i(foreignAnimations.begin()), end(foreignAnimations.end()); i != end; ++i) {
-               (*i)->Stop();
-       }
-}
-
-
-void AttackAnimation::StartTimer(int ms) {
-       text.push_back(START_TIMER);
-       text.push_back(ms);
-}
-
-void AttackAnimation::PlayAttackAnimation() {
-       text.push_back(ATTACK_ANIMATION);
-}
-
-void AttackAnimation::PlaySpellAnimation() {
-       text.push_back(SPELL_ANIMATION);
-}
-
-void AttackAnimation::PlayTargetAnimation(graphics::Animation *a) {
-       text.push_back(TARGET_ANIMATION);
-       text.push_back(a);
-}
-
-void AttackAnimation::PlayFullscreenAnimation(graphics::Animation *a) {
-       text.push_back(FULLSCREEN_ANIMATION);
-       text.push_back(a);
-}
-
-void AttackAnimation::WaitForTimer() {
-       text.push_back(WAIT_TIMER);
-}
-
-void AttackAnimation::WaitForAnimations() {
-       text.push_back(WAIT_ANIMATIONS);
-}
-
-
-void AttackAnimation::Start(BattleState *b, app::State *s) {
-       battle = b;
-       state = s;
-       cursor = 0;
-       Update();
-}
-
-void AttackAnimation::Update() {
-       while (!Finished()) {
-               if (ExecuteCommand()) break;
-       }
-}
-
-bool AttackAnimation::ExecuteCommand() {
-       switch (text[cursor].command) {
-               case NOOP:
-                       break;
-               case START_TIMER:
-                       return ExecuteStartTimer();
-               case ATTACK_ANIMATION:
-                       return ExecuteAttackAnimation();
-               case SPELL_ANIMATION:
-                       return ExecuteSpellAnimation();
-               case TARGET_ANIMATION:
-                       return ExecuteTargetAnimation();
-               case FULLSCREEN_ANIMATION:
-                       return ExecuteFullscreenAnimation();
-               case WAIT_TIMER:
-                       return ExecuteWaitTimer();
-               case WAIT_ANIMATIONS:
-                       return ExecuteWaitAnimations();
-       }
-       ++cursor; // skip unknown command (which should never happen anyway)
-       return false;
-}
-
-
-bool AttackAnimation::ExecuteStartTimer() {
-       timer = state->GraphicsTimers().StartCountdown(text[cursor + 1].number);
-       cursor += 2;
-       return false;
-}
-
-bool AttackAnimation::ExecuteAttackAnimation() {
-       // TODO: get real hero/monster
-       foreignAnimations.push_back(battle->HeroAt(0).AttackAnimation());
-       battle->HeroAt(0).AttackAnimation()->Start(*state);
-       ++cursor;
-       return false;
-}
-
-bool AttackAnimation::ExecuteSpellAnimation() {
-       // TODO: get real hero/monster
-       foreignAnimations.push_back(battle->HeroAt(0).SpellAnimation());
-       battle->HeroAt(0).SpellAnimation()->Start(*state);
-       ++cursor;
-       return false;
-}
-
-bool AttackAnimation::ExecuteTargetAnimation() {
-        // TODO: get real positions
-       AnimationMemo am;
-       am.animation = (Animation *) text[cursor + 1].ptr;
-       am.animation->Start(*state);
-       am.position = Point<int>(100, 100);
-       animations.push_back(am);
-       cursor += 2;
-       return false;
-}
-
-bool AttackAnimation::ExecuteFullscreenAnimation() {
-       AnimationMemo am;
-       am.animation = (Animation *) text[cursor + 1].ptr;
-       am.animation->Start(*state);
-       am.position = Point<int>(0, 0);
-       animations.push_back(am);
-       cursor += 2;
-       return false;
-}
-
-bool AttackAnimation::ExecuteWaitTimer() {
-       if (timer.Running()) {
-               return true;
-       } else {
-               ++cursor;
-               return false;
-       }
-}
-
-bool AttackAnimation::ExecuteWaitAnimations() {
-       for (vector<AnimationMemo>::const_iterator i(animations.begin()), end(animations.end()); i != end; ++i) {
-               if (i->animation->Running()) return true;
-       }
-       for (vector<Animation *>::const_iterator i(foreignAnimations.begin()), end(foreignAnimations.end()); i != end; ++i) {
-               if ((*i)->Running()) return true;
-       }
-       ++cursor;
-       return false;
-}
-
-
-bool AttackAnimation::Running() const {
-       return cursor >= 0 && !Finished();
-}
-
-bool AttackAnimation::Finished() const {
-       return cursor >= int(text.size());
-}
-
-void AttackAnimation::Render(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
-       for (vector<AnimationMemo>::const_iterator i(animations.begin()), end(animations.end()); i != end; ++i) {
-               if (i->animation->Running()) {
-                       i->animation->Draw(screen, i->position + offset);
-               }
-       }
-}
-
-}