#include "PerformAttacks.h"
+#include "../AttackAnimation.h"
#include "../BattleState.h"
#include "../Hero.h"
#include "../Monster.h"
void PerformAttacks::HandleEvents(const Input &input) {
+ if (attackAnimation) attackAnimation->Update();
CheckNumberAnimation();
if (HasAnimationsRunning()) return;
ResetAnimation();
switch (ac.GetType()) {
case AttackChoice::SWORD:
- titleBarText = hero.HasWeapon() ? hero.Weapon()->Name() : "Melee attack!";
- moveAnimation = hero.AttackAnimation();
+ if (hero.HasWeapon()) {
+ titleBarText = hero.Weapon()->Name();
+ moveAnimation = hero.AttackAnimation();
+ } else {
+ titleBarText = "Melee attack!";
+ if (hero.MeleeAnimation()) {
+ moveAnimation = 0;
+ attackAnimation = hero.MeleeAnimation();
+ } else {
+ moveAnimation = hero.AttackAnimation();
+ attackAnimation = 0;
+ }
+ }
numberAnimation.push_back(NumberAnimation(15, battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
if (ac.Selection().TargetsEnemies()) {
numberPosition.push_back(
if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(1500);
if (moveAnimation) moveAnimation->Start(*this);
+ if (attackAnimation) attackAnimation->Start(battle, this);
}
void PerformAttacks::CheckNumberAnimation() {
if (moveAnimation && moveAnimation->Running()) return;
- if (!moveAnimation || moveAnimation->JustFinished()) {
+ if (attackAnimation && !attackAnimation->Finished()) return;
+ if (moveAnimation || attackAnimation) {
+ moveAnimation = 0;
+ attackAnimation = 0;
for (vector<NumberAnimation>::iterator i(numberAnimation.begin()), end(numberAnimation.end()); i != end; ++i) {
i->Start(*this);
}
void PerformAttacks::ResetAnimation() {
if (moveAnimation) moveAnimation->Stop();
+ if (attackAnimation) attackAnimation = 0;
titleBarTimer.Clear();
numberAnimation.clear();
numberPosition.clear();
battle->RenderSmallHeroTags(screen, offset);
RenderTitleBar(screen, offset);
RenderNumbers(screen, offset);
+ if (attackAnimation) attackAnimation->Render(screen, offset);
}
void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {