namespace battle {
+class AttackAnimation;
+
class Hero {
public:
bool HasRing() const { return ring; }
bool HasJewel() const { return jewel; }
+ class AttackAnimation *MeleeAnimation() { return meleeAnimation; }
+ const class AttackAnimation *MeleeAnimation() const { return meleeAnimation; }
graphics::Animation *AttackAnimation() { return attackAnimation; }
const graphics::Animation *AttackAnimation() const { return attackAnimation; }
graphics::Animation *SpellAnimation() { return spellAnimation; }
void AddSpell(const common::Spell *s) { spells.push_back(s); }
+ void SetMeleeAnimation(class AttackAnimation *a) { meleeAnimation = a; }
void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
const common::Item *ring;
const common::Item *jewel;
+ class AttackAnimation *meleeAnimation;
graphics::Animation *attackAnimation;
graphics::Animation *spellAnimation;
#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) {
#include "app/Application.h"
#include "app/Input.h"
+#include "battle/AttackAnimation.h"
#include "battle/BattleState.h"
#include "battle/Hero.h"
#include "battle/Monster.h"
#include "graphics/Frame.h"
#include "graphics/Gauge.h"
#include "graphics/Menu.h"
+#include "graphics/SimpleAnimation.h"
#include "graphics/Sprite.h"
#include "sdl/InitImage.h"
#include "sdl/InitScreen.h"
using app::Application;
using app::Input;
+using battle::AttackAnimation;
using battle::BattleState;
using battle::Hero;
using battle::Monster;
using graphics::Frame;
using graphics::Gauge;
using graphics::Menu;
+using graphics::SimpleAnimation;
using graphics::Sprite;
using sdl::InitImage;
using sdl::InitScreen;
maxim.SetMana(20);
maxim.SetIP(0);
ComplexAnimation maximAttackAnimation(&maximSprite, 30);
- maximAttackAnimation.AddFrames(2, 0, Vector<int>(), 2);
- maximAttackAnimation.AddFrames(2, 0, Vector<int>(4, 0), 2);
- maximAttackAnimation.AddFrame(2, 1, Vector<int>(4, 0));
- maximAttackAnimation.AddFrames(2, 1, Vector<int>(-2, 0), 2);
- maximAttackAnimation.AddFrame(2, 1, Vector<int>(-8, 0));
- maximAttackAnimation.AddFrames(2, 2, Vector<int>(-8, 0), 2);
- maximAttackAnimation.AddFrame(2, 2, Vector<int>(-4, 0));
+ maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, 0));
+ maximAttackAnimation.AddFrame(1, 0, Vector<int>(2, -1));
+ maximAttackAnimation.AddFrames(2, 0, Vector<int>(2, -2), 2);
+ maximAttackAnimation.AddFrame(2, 0, Vector<int>(4, -2));
+ maximAttackAnimation.AddFrame(2, 0, Vector<int>(3, -1));
+ maximAttackAnimation.AddFrames(2, 1, Vector<int>(3, -1), 2);
+ maximAttackAnimation.AddFrame(2, 1);
+ maximAttackAnimation.AddFrames(2, 2, Vector<int>(), 2);
maxim.SetAttackAnimation(&maximAttackAnimation);
ComplexAnimation maximSpellAnimation(&maximSprite, 150);
maximSpellAnimation.AddFrames(3, 0, Vector<int>(), 2);
maximSpellAnimation.AddFrame(3, 1);
maxim.SetSpellAnimation(&maximSpellAnimation);
+ SDL_Surface *maximMeleeImg(IMG_Load("test-data/melee-maxim.png"));
+ Sprite maximMeleeSprite(maximMeleeImg, 96, 96);
+ SimpleAnimation maximMeleeAnimation(&maximMeleeSprite, 30, 4);
+ AttackAnimation maximMeleeScript;
+ maximMeleeScript.PlayAttackAnimation();
+ maximMeleeScript.StartTimer(150);
+ maximMeleeScript.WaitForTimer();
+ maximMeleeScript.PlayTargetAnimation(&maximMeleeAnimation);
+ maximMeleeScript.WaitForAnimations();
+ maxim.SetMeleeAnimation(&maximMeleeScript);
SDL_Surface *selanImg(IMG_Load("test-data/selan.png"));
Sprite selanSprite(selanImg, 64, 64);
firestorm.GetTargetingMode().TargetAllEnemies();
firestorm.SetPhysical();
zircoSword.SetIkari(&firestorm);
- maxim.SetWeapon(&zircoSword);
+// maxim.SetWeapon(&zircoSword);
Item zirconArmor;
zirconArmor.SetName("Zircon armor");
zirconArmor.SetMenuIcon(&armorIcon);