}
-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);
}
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;
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:
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;
}
am.position = Point<int>(100, 100);
animations.push_back(am);
cursor += 2;
- return true;
+ return false;
}
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;
}
~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 *);
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) { }