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 "Resources.h"
18 #include "../app/State.h"
19 #include "../geometry/Point.h"
20 #include "../geometry/Vector.h"
21 #include "../graphics/Menu.h"
26 namespace app { class Input; }
42 BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const Resources *res)
43 : background(background)
44 , monstersLayout(&monstersLayout)
45 , heroesLayout(&heroesLayout)
47 , attackTypeMenu(res->attackIcons)
48 , moveMenu(res->moveIcons)
52 void AddMonster(const Monster &);
53 void AddHero(const Hero &);
56 virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
57 virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
58 virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
59 virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
61 virtual void Resize(int width, int height);
63 virtual void HandleInput(const app::Input &);
64 virtual void UpdateWorld(float deltaT);
65 virtual void Render(SDL_Surface *);
68 const Resources &Res() const { return *res; }
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 BeforeFirstHero() const { return activeHero < 0; }
75 void PreviousHero() { --activeHero; }
76 Hero &ActiveHero() { return heroes[activeHero]; }
77 const Hero &ActiveHero() const { return heroes[activeHero]; }
78 bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
79 void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
80 bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
81 graphics::Menu</* Spell */ void *> &GetSpellMenu() { return spellMenus[activeHero]; }
82 const graphics::Menu</* Spell */ void *> &GetSpellMenu() const { return spellMenus[activeHero]; }
83 graphics::Menu</* Ikari or Item */ void *> &GetIkariMenu() { return ikariMenus[activeHero]; }
84 const graphics::Menu</* Ikari or Item */ void *> &GetIkariMenu() const { return ikariMenus[activeHero]; }
85 graphics::Menu</* Item */ void *> &GetItemMenu() { return itemMenu; }
86 const graphics::Menu</* Item */ void *> &GetItemMenu() const { return itemMenu; }
89 geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
90 return geometry::Vector<int>(
91 (screen->w - background->w) / 2,
92 (screen->h - background->h) / 2);
94 int BackgroundWidth() const { return background->w; }
95 int BackgroundHeight() const { return background->h; }
97 void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
98 void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
99 void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
100 void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
103 SDL_Surface *background;
104 const PartyLayout *monstersLayout;
105 const PartyLayout *heroesLayout;
106 const Resources *res;
107 AttackTypeMenu attackTypeMenu;
109 std::vector<geometry::Point<int> > monsterPositions;
110 std::vector<geometry::Point<int> > heroesPositions;
111 std::vector<Monster> monsters;
112 std::vector<Hero> heroes;
113 std::vector<graphics::Menu</* Spell */ void *> > spellMenus;
114 graphics::Menu</* Item */ void *> itemMenu;
115 std::vector<graphics::Menu</* Ikari or Item */ void *> > ikariMenus;
116 std::vector<HeroTag> heroTags;
117 std::vector<AttackChoice> attackChoices;
124 #endif /* BATTLE_BATTLESTATE_H_ */