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; }
38 BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons, const graphics::Frame *heroTagFrame, const graphics::Frame *activeHeroTagFrame)
39 : background(background)
40 , monstersLayout(&monstersLayout)
41 , heroesLayout(&heroesLayout)
42 , heroTagFrame(heroTagFrame)
43 , activeHeroTagFrame(activeHeroTagFrame)
44 , attackTypeMenu(attackIcons)
49 void AddMonster(const Monster &);
50 void AddHero(const Hero &);
53 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
54 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
55 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
56 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
58 virtual void Resize(int width, int height);
60 virtual void HandleInput(const app::Input &);
61 virtual void UpdateWorld(float deltaT);
62 virtual void Render(SDL_Surface *);
65 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
66 MoveMenu &GetMoveMenu() { return moveMenu; }
68 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
69 void NextHero() { ++activeHero; }
70 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
71 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
72 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
75 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
76 return geometry::Vector<int>(
77 (screen->w - background->w) / 2,
78 (screen->h - background->h) / 2);
80 int BackgroundWidth() const { return background->w; }
81 int BackgroundHeight() const { return background->h; }
83 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
84 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
85 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
86 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
89 SDL_Surface *background;
90 const PartyLayout *monstersLayout;
91 const PartyLayout *heroesLayout;
92 const graphics::Frame *heroTagFrame;
93 const graphics::Frame *activeHeroTagFrame;
94 AttackTypeMenu attackTypeMenu;
96 std::vector<geometry::Point<int> > monsterPositions;
97 std::vector<geometry::Point<int> > heroesPositions;
98 std::vector<Monster> monsters;
99 std::vector<Hero> heroes;
100 std::vector<HeroTag> heroTags;
101 std::vector<AttackChoice> attackChoices;
108 #endif /* BATTLE_BATTLESTATE_H_ */