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; }
39 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)
40 : background(background)
41 , monstersLayout(&monstersLayout)
42 , heroesLayout(&heroesLayout)
43 , heroTagFrame(heroTagFrame)
44 , activeHeroTagFrame(activeHeroTagFrame)
45 , healthGauge(healthGauge)
46 , manaGauge(manaGauge)
47 , ikariGauge(ikariGauge)
48 , attackTypeMenu(attackIcons)
53 void AddMonster(const Monster &);
54 void AddHero(const Hero &);
57 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
58 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
59 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
60 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
62 virtual void Resize(int width, int height);
64 virtual void HandleInput(const app::Input &);
65 virtual void UpdateWorld(float deltaT);
66 virtual void Render(SDL_Surface *);
69 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
70 MoveMenu &GetMoveMenu() { return moveMenu; }
72 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
73 void NextHero() { ++activeHero; }
74 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
75 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
76 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
79 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
80 return geometry::Vector<int>(
81 (screen->w - background->w) / 2,
82 (screen->h - background->h) / 2);
84 int BackgroundWidth() const { return background->w; }
85 int BackgroundHeight() const { return background->h; }
87 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
88 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
89 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
90 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
93 SDL_Surface *background;
94 const PartyLayout *monstersLayout;
95 const PartyLayout *heroesLayout;
96 const graphics::Frame *heroTagFrame;
97 const graphics::Frame *activeHeroTagFrame;
98 const graphics::Gauge *healthGauge;
99 const graphics::Gauge *manaGauge;
100 const graphics::Gauge *ikariGauge;
101 AttackTypeMenu attackTypeMenu;
103 std::vector<geometry::Point<int> > monsterPositions;
104 std::vector<geometry::Point<int> > heroesPositions;
105 std::vector<Monster> monsters;
106 std::vector<Hero> heroes;
107 std::vector<HeroTag> heroTags;
108 std::vector<AttackChoice> attackChoices;
115 #endif /* BATTLE_BATTLESTATE_H_ */