]> git.localhorst.tv Git - l2e.git/blob - src/battle/BattleState.h
moved attack type into its own class
[l2e.git] / src / battle / BattleState.h
1 /*
2  * BattleState.h
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_BATTLESTATE_H_
9 #define BATTLE_BATTLESTATE_H_
10
11 #include "AttackTypeMenu.h"
12 #include "Hero.h"
13 #include "HeroTag.h"
14 #include "Monster.h"
15 #include "MoveMenu.h"
16 #include "../app/State.h"
17 #include "../geometry/Point.h"
18 #include "../geometry/Vector.h"
19
20 #include <vector>
21 #include <SDL.h>
22
23 namespace app { class Input; }
24 namespace graphics { class Sprite; }
25
26 namespace battle {
27
28 class PartyLayout;
29
30 // TODO: maybe split battle state into substates for each menu?
31 class BattleState
32 : public app::State {
33
34 public:
35         BattleState(SDL_Surface *background, const PartyLayout &monstersLayout, const PartyLayout &heroesLayout, const graphics::Sprite *attackIcons, const graphics::Sprite *moveIcons)
36         : background(background)
37         , monstersLayout(&monstersLayout)
38         , heroesLayout(&heroesLayout)
39         , attackTypeMenu(attackIcons)
40         , moveMenu(moveIcons)
41         , activeHero(-1) { }
42
43 public:
44         void AddMonster(const Monster &);
45         void AddHero(const Hero &);
46
47 public:
48         virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
49         virtual void ExitState();
50
51         virtual void Resize(int width, int height);
52
53         virtual void HandleInput(const app::Input &);
54         virtual void UpdateWorld(float deltaT);
55         virtual void Render(SDL_Surface *);
56
57 public:
58         AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
59         MoveMenu &GetMoveMenu() { return moveMenu; }
60
61         bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
62         void NextHero() { ++activeHero; }
63
64 public:
65         geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
66                 return geometry::Vector<int>(
67                                 (screen->w - background->w) / 2,
68                                 (screen->h - background->h) / 2);
69         }
70         int BackgroundWidth() const { return background->w; }
71         int BackgroundHeight() const { return background->h; }
72
73         void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
74         void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
75         void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
76         void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
77         void RenderAttackTypeMenu(SDL_Surface *screen, const geometry::Vector<int> &offset);
78
79 private:
80         SDL_Surface *background;
81         const PartyLayout *monstersLayout;
82         const PartyLayout *heroesLayout;
83         AttackTypeMenu attackTypeMenu;
84         MoveMenu moveMenu;
85         std::vector<geometry::Point<int> > monsterPositions;
86         std::vector<geometry::Point<int> > heroesPositions;
87         std::vector<Monster> monsters;
88         std::vector<Hero> heroes;
89         std::vector<HeroTag> heroTags;
90         int activeHero;
91
92 };
93
94 }
95
96 #endif /* BATTLE_BATTLESTATE_H_ */