From: Daniel Karbach Date: Tue, 14 Aug 2012 18:22:23 +0000 (+0200) Subject: revised attack animation codes X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=e52f2d15302057cbcc4a2dcca1ae9b25dc12dbcd;p=l2e.git revised attack animation codes --- diff --git a/src/battle/AttackAnimation.cpp b/src/battle/AttackAnimation.cpp index 7f41be6..0aedf18 100644 --- a/src/battle/AttackAnimation.cpp +++ b/src/battle/AttackAnimation.cpp @@ -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::const_iterator i(animations.begin()), end(animations.end()); i != end; ++i) { - if (i->animation->Running()) return true; - } - for (vector::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(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(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::const_iterator i(animations.begin()), end(animations.end()); i != end; ++i) { + if (i->animation->Running()) return true; + } + for (vector::const_iterator i(foreignAnimations.begin()), end(foreignAnimations.end()); i != end; ++i) { + if ((*i)->Running()) return true; + } + ++cursor; + return false; } diff --git a/src/battle/AttackAnimation.h b/src/battle/AttackAnimation.h index a8ec014..7758bb8 100644 --- a/src/battle/AttackAnimation.h +++ b/src/battle/AttackAnimation.h @@ -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) { }