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, const graphics::Sprite *heroTagSprites)
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 , heroTagSprites(heroTagSprites)
49 , attackTypeMenu(attackIcons)
54 void AddMonster(const Monster &);
55 void AddHero(const Hero &);
58 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
59 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
60 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
61 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
63 virtual void Resize(int width, int height);
65 virtual void HandleInput(const app::Input &);
66 virtual void UpdateWorld(float deltaT);
67 virtual void Render(SDL_Surface *);
70 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
71 MoveMenu &GetMoveMenu() { return moveMenu; }
73 bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
74 void NextHero() { ++activeHero; }
75 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
76 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
77 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
80 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
81 return geometry::Vector<int>(
82 (screen->w - background->w) / 2,
83 (screen->h - background->h) / 2);
85 int BackgroundWidth() const { return background->w; }
86 int BackgroundHeight() const { return background->h; }
88 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
89 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
90 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
91 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
94 SDL_Surface *background;
95 const PartyLayout *monstersLayout;
96 const PartyLayout *heroesLayout;
97 const graphics::Frame *heroTagFrame;
98 const graphics::Frame *activeHeroTagFrame;
99 const graphics::Gauge *healthGauge;
100 const graphics::Gauge *manaGauge;
101 const graphics::Gauge *ikariGauge;
102 const graphics::Sprite *heroTagSprites;
103 AttackTypeMenu attackTypeMenu;
105 std::vector<geometry::Point<int> > monsterPositions;
106 std::vector<geometry::Point<int> > heroesPositions;
107 std::vector<Monster> monsters;
108 std::vector<Hero> heroes;
109 std::vector<HeroTag> heroTags;
110 std::vector<AttackChoice> attackChoices;
117 #endif /* BATTLE_BATTLESTATE_H_ */