virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
+ // TODO: turn this mess into a well stuctured interface
public:
const Resources &Res() const { return *res; }
AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
const AttackChoice &ActiveHeroAttackChoice() const { return AttackChoiceAt(activeHero); }
AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
+ AttackChoice &MonsterAttackChoiceAt(int index) { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
+ const AttackChoice &MonsterAttackChoiceAt(int index) const { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
bool AttackSelectionDone() const { return activeHero >= numHeroes; }
int NumHeroes() const { return numHeroes; }
titleBarText = monster.Name();
moveAnimation = monster.AttackAnimation();
targetAnimation = monster.MeleeAnimation();
- // TODO: add number animations
+ AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection());
} else {
Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
targetAnimation = hero.MeleeAnimation();
}
moveAnimation = hero.AttackAnimation();
-
- if (ac.Selection().TargetsEnemies()) {
- for (int i(0); i < battle->MaxMonsters(); ++i) {
- if (ac.Selection().IsSelected(i)) {
- numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
- numberPosition.push_back(
- battle->MonsterPositions()[i]);
- }
- }
- } else {
- for (int i(0); i < battle->NumHeroes(); ++i) {
- if (ac.Selection().IsSelected(i)) {
- numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
- numberPosition.push_back(
- battle->HeroesPositions()[i]);
- }
- }
- }
+ AddNumberAnimations(ac.Selection());
break;
case AttackChoice::MAGIC:
titleBarText = ac.GetSpell()->Name();
}
}
+void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) {
+ if (ts.TargetsEnemies()) {
+ for (int i(0); i < battle->MaxMonsters(); ++i) {
+ if (ts.IsBad(i)) {
+ numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
+ numberPosition.push_back(
+ battle->MonsterPositions()[i]);
+ } else if (ts.IsGood(i)) {
+ numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
+ numberPosition.push_back(
+ battle->MonsterPositions()[i]);
+ }
+ }
+ } else {
+ for (int i(0); i < battle->NumHeroes(); ++i) {
+ if (ts.IsBad(i)) {
+ numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
+ numberPosition.push_back(
+ battle->HeroesPositions()[i]);
+ } else if (ts.IsGood(i)) {
+ numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
+ numberPosition.push_back(
+ battle->HeroesPositions()[i]);
+ }
+ }
+ }
+}
+
void PerformAttacks::CheckAnimations() {
if (targetAnimation && targetAnimationTimer.JustHit()) {
targetAnimation->Start(*this);