#include "../../common/Spell.h"
#include "../../geometry/operators.h"
#include "../../geometry/Point.h"
+#include "../../graphics/Animation.h"
#include "../../graphics/Font.h"
#include "../../graphics/Frame.h"
using app::Input;
using geometry::Point;
using geometry::Vector;
+using graphics::Animation;
namespace battle {
if (titleBarText) {
titleBarText = 0;
++cursor;
- while (cursor < (int)battle->Monsters().size() && !battle->MonsterPositionOccupied(cursor)) {
+ while (cursor < battle->MaxMonsters() && !battle->MonsterPositionOccupied(cursor)) {
++cursor;
}
- if (cursor >= (int)battle->Monsters().size()) {
+ if (cursor >= battle->MaxMonsters()) {
battle->ClearAllAttacks();
ctrl->PopState();
}
} else {
+ if (cursor == 0) {
+ battle->HeroAnimationAt(battle->NumHeroes() - 1).Stop();
+ }
titleBarText = battle->MonsterAt(cursor).Name();
}
} else {
+ const AttackChoice &ac(battle->AttackChoiceAt(cursor));
if (titleBarText) {
titleBarText = 0;
+
+ switch (ac.GetType()) {
+ case AttackChoice::SWORD:
+ battle->HeroAnimationAt(cursor) = Animation(
+ battle->HeroAt(cursor).Sprite(),
+ battle->HeroAt(cursor).AttackFrameTime(),
+ battle->HeroAt(cursor).AttackFrames(), 2);
+ break;
+ case AttackChoice::MAGIC:
+ battle->HeroAnimationAt(cursor) = Animation(
+ battle->HeroAt(cursor).Sprite(),
+ battle->HeroAt(cursor).SpellFrameTime(),
+ battle->HeroAt(cursor).SpellFrames(), 3);
+ break;
+ case AttackChoice::DEFEND:
+ break;
+ case AttackChoice::IKARI:
+ if (ac.GetItem()->HasIkari()) {
+ if (ac.GetItem()->GetIkari()->IsMagical()) {
+ battle->HeroAnimationAt(cursor) = Animation(
+ battle->HeroAt(cursor).Sprite(),
+ battle->HeroAt(cursor).SpellFrameTime(),
+ battle->HeroAt(cursor).SpellFrames(), 3);
+ } else {
+ battle->HeroAnimationAt(cursor) = Animation(
+ battle->HeroAt(cursor).Sprite(),
+ battle->HeroAt(cursor).AttackFrameTime(),
+ battle->HeroAt(cursor).AttackFrames(), 2);
+ }
+ }
+ break;
+ case AttackChoice::ITEM:
+ break;
+ case AttackChoice::UNDECIDED:
+ break;
+ }
+ battle->HeroAnimationAt(cursor).Start(*this);
+
++cursor;
- if (cursor == (int)battle->Heroes().size()) {
+ if (cursor == battle->NumHeroes()) {
cursor = 0;
monsters = true;
}
} else {
- const AttackChoice &ac(battle->AttackChoiceAt(cursor));
+ if (cursor > 0) {
+ battle->HeroAnimationAt(cursor - 1).Stop();
+ }
switch (ac.GetType()) {
case AttackChoice::SWORD:
titleBarText = battle->HeroAt(cursor).HasWeapon() ? battle->HeroAt(cursor).Weapon()->Name() : "Gauntlet";
battle->RenderBackground(screen, offset);
battle->RenderMonsters(screen, offset);
battle->RenderHeroes(screen, offset);
- // render small tags
+ battle->RenderSmallHeroTags(screen, offset);
RenderTitleBar(screen, offset);
}