- ++cursor;
- if (cursor == battle->NumHeroes()) {
- cursor = 0;
- monsters = true;
- }
- } else {
- if (cursor > 0) {
- if (battle->HeroAt(cursor - 1).AttackAnimation()) {
- battle->HeroAt(cursor - 1).AttackAnimation()->Stop();
- }
- if (battle->HeroAt(cursor - 1).SpellAnimation()) {
- battle->HeroAt(cursor - 1).SpellAnimation()->Stop();
- }
- }
- switch (ac.GetType()) {
- case AttackChoice::SWORD:
- titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet";
- break;
- case AttackChoice::MAGIC:
- titleBarText = ac.GetSpell()->Name();
- break;
- case AttackChoice::DEFEND:
- titleBarText = "Defends.";
- break;
- case AttackChoice::IKARI:
- titleBarText = ac.GetItem()->HasIkari() ? ac.GetItem()->GetIkari()->Name() : "No Ikari?";
- break;
- case AttackChoice::ITEM:
- titleBarText = ac.GetItem()->Name();
- break;
- case AttackChoice::UNDECIDED:
- titleBarText = "WTF???";
- break;
- }
- }
+ if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(1500);
+ if (moveAnimation) moveAnimation->Start(*this);
+ if (targetAnimation) {
+ targetAnimationTimer = GraphicsTimers().StartCountdown(150);
+ } else {
+ targetAnimationTimer.Clear();
+ }
+}
+
+void PerformAttacks::CheckAnimations() {
+ if (targetAnimation && targetAnimationTimer.JustHit()) {
+ targetAnimation->Start(*this);
+ }
+ if (moveAnimation && !moveAnimation->Finished()) return;
+ if (targetAnimation && !targetAnimation->Finished()) return;
+ if (moveAnimation || targetAnimation) {
+ moveAnimation = 0;
+ targetAnimation = 0;
+ for (vector<NumberAnimation>::iterator i(numberAnimation.begin()), end(numberAnimation.end()); i != end; ++i) {
+ i->Start(*this);
+ }
+ } else {
+ for (vector<NumberAnimation>::iterator i(numberAnimation.begin()), end(numberAnimation.end()); i != end; ++i) {
+ i->CheckTimers(*this);
+ }
+ }
+}
+
+bool PerformAttacks::HasAnimationsRunning() const {
+ if (titleBarTimer.Running()) return true;
+ if (moveAnimation && moveAnimation->Running()) return true;
+ if (targetAnimation && targetAnimation->Running()) return true;
+ for (vector<NumberAnimation>::const_iterator i(numberAnimation.begin()), end(numberAnimation.end()); i != end; ++i) {
+ if (i->Running()) return true;
+ }
+ return false;
+}
+
+void PerformAttacks::ResetAnimation() {
+ if (moveAnimation) {
+ moveAnimation->Stop();
+ moveAnimation = 0;
+ }
+ if (targetAnimation) {
+ targetAnimation->Stop();
+ targetAnimation = 0;
+ }
+ titleBarTimer.Clear();
+ numberAnimation.clear();
+ numberPosition.clear();
+}
+
+void PerformAttacks::AdvanceCursor() {
+ ++cursor;
+ while (cursor < int(order.size())) {
+ if (order[cursor].isMonster) {
+ if (battle->MonsterAt(order[cursor].index).Health() > 0) break;
+ } else {
+ if (battle->HeroAt(order[cursor].index).Health() > 0) break;