namespace battle {
+SelectTarget::SelectTarget(
+ Battle *battle,
+ SelectAttackType *parent,
+ TargetSelection *selection,
+ const graphics::Sprite *cursorIcon)
+: battle(battle)
+, parent(parent)
+, selection(selection)
+, cursorIcon(cursorIcon)
+, flipFlop(true) {
+
+}
+
+
void SelectTarget::OnEnterState(SDL_Surface *screen) {
OnResize(screen->w, screen->h);
}
void SelectTarget::OnResize(int width, int height) {
- Vector<int> offset(battle->ScreenOffset());
+ Vector<int> offset(parent->ScreenOffset());
cursorOffset = Vector<int>(cursorIcon->Width() / -2, cursorIcon->Height()) + offset;
// offset the indicator by 1/8th to the right and top
indicatorOffset = cursorOffset + Vector<int>(cursorIcon->Width() / 8, cursorIcon->Height() / -8);
monsterPositions.clear();
- monsterPositions.reserve(battle->MaxMonsters());
- for (int i(0), end(battle->MaxMonsters()); i < end; ++i) {
+ monsterPositions.reserve(battle->NumMonsters());
+ for (int i(0), end(battle->NumMonsters()); i < end; ++i) {
monsterPositions.push_back(battle->MonsterAt(i).Position());
}
heroPositions.clear();
heroPositions.reserve(battle->NumHeroes());
for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
- heroPositions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset());
+ heroPositions.push_back(parent->HeroTagPositionAt(i) + parent->HeroTagAt(i).HeroOffset());
}
}