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; }
40 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, const graphics::Gauge *healthGauge, const graphics::Gauge *manaGauge, const graphics::Gauge *ikariGauge, const graphics::Sprite *heroTagSprites, const graphics::Font *heroTagFont)
41 : background(background)
42 , monstersLayout(&monstersLayout)
43 , heroesLayout(&heroesLayout)
44 , heroTagFrame(heroTagFrame)
45 , activeHeroTagFrame(activeHeroTagFrame)
46 , healthGauge(healthGauge)
47 , manaGauge(manaGauge)
48 , ikariGauge(ikariGauge)
49 , heroTagSprites(heroTagSprites)
50 , heroTagFont(heroTagFont)
51 , attackTypeMenu(attackIcons)
56 void AddMonster(const Monster &);
57 void AddHero(const Hero &);
60 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
61 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
62 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
63 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
65 virtual void Resize(int width, int height);
67 virtual void HandleInput(const app::Input &);
68 virtual void UpdateWorld(float deltaT);
69 virtual void Render(SDL_Surface *);
72 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
73 MoveMenu &GetMoveMenu() { return moveMenu; }
75 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
76 void NextHero() { ++activeHero; }
77 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
78 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
79 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
82 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
83 return geometry::Vector<int>(
84 (screen->w - background->w) / 2,
85 (screen->h - background->h) / 2);
87 int BackgroundWidth() const { return background->w; }
88 int BackgroundHeight() const { return background->h; }
90 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
91 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
92 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
93 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
96 SDL_Surface *background;
97 const PartyLayout *monstersLayout;
98 const PartyLayout *heroesLayout;
99 const graphics::Frame *heroTagFrame;
100 const graphics::Frame *activeHeroTagFrame;
101 const graphics::Gauge *healthGauge;
102 const graphics::Gauge *manaGauge;
103 const graphics::Gauge *ikariGauge;
104 const graphics::Sprite *heroTagSprites;
105 const graphics::Font *heroTagFont;
106 AttackTypeMenu attackTypeMenu;
108 std::vector<geometry::Point<int> > monsterPositions;
109 std::vector<geometry::Point<int> > heroesPositions;
110 std::vector<Monster> monsters;
111 std::vector<Hero> heroes;
112 std::vector<HeroTag> heroTags;
113 std::vector<AttackChoice> attackChoices;
120 #endif /* BATTLE_BATTLESTATE_H_ */