]> git.localhorst.tv Git - l2e.git/commitdiff
revised attack animation codes
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 14 Aug 2012 18:22:23 +0000 (20:22 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 14 Aug 2012 18:22:23 +0000 (20:22 +0200)
src/battle/AttackAnimation.cpp
src/battle/AttackAnimation.h

index 7f41be6349d1f60ed02a7244ccdb8d9f8efbb5cb..0aedf18610aa2f8043c0f444d3b21c0c4093962f 100644 (file)
@@ -27,15 +27,11 @@ AttackAnimation::~AttackAnimation() {
 }
 
 
-void AttackAnimation::Wait(int ms) {
-       text.push_back(WAIT);
+void AttackAnimation::StartTimer(int ms) {
+       text.push_back(START_TIMER);
        text.push_back(ms);
 }
 
-void AttackAnimation::WaitForAnimation() {
-       text.push_back(WAIT_ANIMATION);
-}
-
 void AttackAnimation::PlayAttackAnimation() {
        text.push_back(ATTACK_ANIMATION);
 }
@@ -54,6 +50,14 @@ void AttackAnimation::PlayFullscreenAnimation(graphics::Animation *a) {
        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;
@@ -70,10 +74,10 @@ void AttackAnimation::Update() {
 
 bool AttackAnimation::ExecuteCommand() {
        switch (text[cursor].command) {
-               case WAIT:
-                       return ExecuteWait();
-               case WAIT_ANIMATION:
-                       return ExecuteWaitAnimation();
+               case NOOP:
+                       break;
+               case START_TIMER:
+                       return ExecuteStartTimer();
                case ATTACK_ANIMATION:
                        return ExecuteAttackAnimation();
                case SPELL_ANIMATION:
@@ -82,34 +86,19 @@ bool AttackAnimation::ExecuteCommand() {
                        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::ExecuteWait() {
-       if (timer.Started()) {
-               if (timer.Running()) {
-                       return true;
-               } else {
-                       cursor += 2;
-                       return false;
-               }
-       } else {
-               timer = state->GraphicsTimers().StartCountdown(text[cursor + 1].number);
-               return true;
-       }
-}
-
 
-bool AttackAnimation::ExecuteWaitAnimation() {
-       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;
+bool AttackAnimation::ExecuteStartTimer() {
+       timer = state->GraphicsTimers().StartCountdown(text[cursor + 1].number);
+       cursor += 2;
        return false;
 }
 
@@ -137,7 +126,7 @@ bool AttackAnimation::ExecuteTargetAnimation() {
        am.position = Point<int>(100, 100);
        animations.push_back(am);
        cursor += 2;
-       return true;
+       return false;
 }
 
 bool AttackAnimation::ExecuteFullscreenAnimation() {
@@ -147,7 +136,27 @@ bool AttackAnimation::ExecuteFullscreenAnimation() {
        am.position = Point<int>(0, 0);
        animations.push_back(am);
        cursor += 2;
-       return true;
+       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;
 }
 
 
index a8ec014ecc43de3a3c003a75a10711b168d19d2d..7758bb89594989f5828cb10ccdc2d8541742cf3e 100644 (file)
@@ -29,12 +29,13 @@ public:
        ~AttackAnimation();
 
 public:
-       void Wait(int ms);
-       void WaitForAnimation();
+       void StartTimer(int ms);
        void PlayAttackAnimation();
        void PlaySpellAnimation();
        void PlayTargetAnimation(graphics::Animation *);
        void PlayFullscreenAnimation(graphics::Animation *);
+       void WaitForTimer();
+       void WaitForAnimations();
 
 public:
        void Start(BattleState *, app::State *);
@@ -44,22 +45,24 @@ public:
 
 private:
        bool ExecuteCommand();
-
-       bool ExecuteWait();
-       bool ExecuteWaitAnimation();
+       bool ExecuteStartTimer();
        bool ExecuteAttackAnimation();
        bool ExecuteSpellAnimation();
        bool ExecuteTargetAnimation();
        bool ExecuteFullscreenAnimation();
+       bool ExecuteWaitTimer();
+       bool ExecuteWaitAnimations();
 
 private:
        enum Command {
-               WAIT,
-               WAIT_ANIMATION,
+               NOOP,
+               START_TIMER,
                ATTACK_ANIMATION,
                SPELL_ANIMATION,
                TARGET_ANIMATION,
                FULLSCREEN_ANIMATION,
+               WAIT_TIMER,
+               WAIT_ANIMATIONS,
        };
        union Code {
                Code(Command c) : command(c) { }