1 #ifndef BATTLE_BATTLESTATE_H_
2 #define BATTLE_BATTLESTATE_H_
16 #include "AttackTypeMenu.h"
23 #include "Resources.h"
24 #include "SmallHeroTag.h"
25 #include "../app/State.h"
26 #include "../common/GameConfig.h"
27 #include "../common/Stats.h"
28 #include "../graphics/Animation.h"
29 #include "../graphics/Menu.h"
41 BattleState(common::GameConfig *game, SDL_Surface *background, const PartyLayout *monstersLayout)
43 , background(background)
44 , res(game->battleResources)
45 , battle(game->heroesLayout, monstersLayout)
46 , attackTypeMenu(res->attackIcons)
47 , moveMenu(res->moveIcons)
48 , ranAway(false), alreadyPushed(false)
49 { assert(background && game); }
52 void AddMonster(const Monster &);
53 void AddHero(const Hero &);
54 void SetCapsule(const Capsule &);
57 virtual void HandleEvents(const app::Input &);
58 virtual void UpdateWorld(Uint32 deltaT);
59 virtual void Render(SDL_Surface *);
62 Battle &GetBattle() { return battle; }
63 const Battle &GetBattle() const { return battle; }
64 const Resources &Res() const { return *res; }
65 AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
66 MoveMenu &GetMoveMenu() { return moveMenu; }
68 graphics::Menu<const common::Item *> &ItemMenu() { return itemMenu; }
69 const graphics::Menu<const common::Item *> &ItemMenu() const { return itemMenu; }
71 Hero &HeroAt(int index) { return battle.HeroAt(index); }
72 const Hero &HeroAt(int index) const { return battle.HeroAt(index); }
73 Monster &MonsterAt(int index) { return battle.MonsterAt(index); }
74 const Monster &MonsterAt(int index) const { return battle.MonsterAt(index); }
76 const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; }
77 const math::Vector<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
79 int NumHeroes() const { return battle.NumHeroes(); }
80 int MaxHeroes() const { return battle.MaxHeroes(); }
81 int NumMonsters() const { return battle.NumMonsters(); }
82 int MaxMonsters() const { return battle.MaxMonsters(); }
84 void SetRunaway() { ranAway = true; }
87 const math::Vector<int> &ScreenOffset() const { return offset; }
88 int Width() const { return background->w; }
89 int Height() const { return background->h; }
90 math::Vector<int> Size() const { return math::Vector<int>(Width(), Height()); }
92 void RenderBackground(SDL_Surface *screen);
93 void RenderMonsters(SDL_Surface *screen);
94 void RenderHeroes(SDL_Surface *screen);
95 void RenderCapsule(SDL_Surface *screen);
96 void RenderHeroTags(SDL_Surface *screen);
97 void RenderSmallHeroTags(SDL_Surface *screen);
100 virtual void OnEnterState(SDL_Surface *screen);
101 virtual void OnExitState(SDL_Surface *screen);
102 virtual void OnResumeState(SDL_Surface *screen);
103 virtual void OnPauseState(SDL_Surface *screen);
105 virtual void OnResize(int width, int height);
108 void LoadInventory();
111 common::GameConfig *game;
112 SDL_Surface *background;
113 const Resources *res;
115 AttackTypeMenu attackTypeMenu;
117 graphics::Menu<const common::Item *> itemMenu;
119 SmallHeroTag smallHeroTags[4];
120 math::Vector<int> heroTagPositions[4];
121 math::Vector<int> smallHeroTagPositions[4];
123 math::Vector<int> offset;