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, const graphics::Frame *selectFrame)
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 , selectFrame(selectFrame)
52 , attackTypeMenu(attackIcons)
57 void AddMonster(const Monster &);
58 void AddHero(const Hero &);
61 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
62 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
63 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
64 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
66 virtual void Resize(int width, int height);
68 virtual void HandleInput(const app::Input &);
69 virtual void UpdateWorld(float deltaT);
70 virtual void Render(SDL_Surface *);
73 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
74 MoveMenu &GetMoveMenu() { return moveMenu; }
75 const graphics::Frame &GetSelectFrame() const { return *selectFrame; }
77 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
78 void NextHero() { ++activeHero; }
79 bool BeforeFirstHero() const { return activeHero < 0; }
80 void PreviousHero() { --activeHero; }
81 Hero &ActiveHero() { return heroes[activeHero]; }
82 const Hero &ActiveHero() const { return heroes[activeHero]; }
83 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
84 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
85 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
88 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
89 return geometry::Vector<int>(
90 (screen->w - background->w) / 2,
91 (screen->h - background->h) / 2);
93 int BackgroundWidth() const { return background->w; }
94 int BackgroundHeight() const { return background->h; }
96 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
97 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
98 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
99 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
102 SDL_Surface *background;
103 const PartyLayout *monstersLayout;
104 const PartyLayout *heroesLayout;
105 const graphics::Frame *heroTagFrame;
106 const graphics::Frame *activeHeroTagFrame;
107 const graphics::Gauge *healthGauge;
108 const graphics::Gauge *manaGauge;
109 const graphics::Gauge *ikariGauge;
110 const graphics::Sprite *heroTagSprites;
111 const graphics::Font *heroTagFont;
112 const graphics::Frame *selectFrame;
113 AttackTypeMenu attackTypeMenu;
115 std::vector<geometry::Point<int> > monsterPositions;
116 std::vector<geometry::Point<int> > heroesPositions;
117 std::vector<Monster> monsters;
118 std::vector<Hero> heroes;
119 std::vector<HeroTag> heroTags;
120 std::vector<AttackChoice> attackChoices;
127 #endif /* BATTLE_BATTLESTATE_H_ */