4 * Created on: Aug 5, 2012
8 #ifndef BATTLE_BATTLESTATE_H_
9 #define BATTLE_BATTLESTATE_H_
11 #include "AttackChoice.h"
12 #include "AttackTypeMenu.h"
17 #include "../app/State.h"
18 #include "../geometry/Point.h"
19 #include "../geometry/Vector.h"
24 namespace app { class Input; }
25 namespace graphics { class Sprite; }
31 // TODO: maybe split battle state into substates for each menu?
36 BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons)
37 : background(background)
38 , monstersLayout(&monstersLayout)
39 , heroesLayout(&heroesLayout)
40 , attackTypeMenu(attackIcons)
45 void AddMonster(const Monster &);
46 void AddHero(const Hero &);
49 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
50 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
51 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
52 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
54 virtual void Resize(int width, int height);
56 virtual void HandleInput(const app::Input &);
57 virtual void UpdateWorld(float deltaT);
58 virtual void Render(SDL_Surface *);
61 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
62 MoveMenu &GetMoveMenu() { return moveMenu; }
64 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
65 void NextHero() { ++activeHero; }
66 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
67 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
68 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
71 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
72 return geometry::Vector<int>(
73 (screen->w - background->w) / 2,
74 (screen->h - background->h) / 2);
76 int BackgroundWidth() const { return background->w; }
77 int BackgroundHeight() const { return background->h; }
79 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
80 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
81 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
82 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
85 SDL_Surface *background;
86 const PartyLayout *monstersLayout;
87 const PartyLayout *heroesLayout;
88 AttackTypeMenu attackTypeMenu;
90 std::vector<geometry::Point<int> > monsterPositions;
91 std::vector<geometry::Point<int> > heroesPositions;
92 std::vector<Monster> monsters;
93 std::vector<Hero> heroes;
94 std::vector<HeroTag> heroTags;
95 std::vector<AttackChoice> attackChoices;
102 #endif /* BATTLE_BATTLESTATE_H_ */