]> git.localhorst.tv Git - l2e.git/blob - src/battle/BattleState.h
added hero tag labels
[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 "AttackChoice.h"
12 #include "AttackTypeMenu.h"
13 #include "Hero.h"
14 #include "HeroTag.h"
15 #include "Monster.h"
16 #include "MoveMenu.h"
17 #include "../app/State.h"
18 #include "../geometry/Point.h"
19 #include "../geometry/Vector.h"
20
21 #include <vector>
22 #include <SDL.h>
23
24 namespace app { class Input; }
25 namespace graphics {
26         class Frame;
27         class Gauge;
28         class Sprite;
29 }
30
31 namespace battle {
32
33 class PartyLayout;
34
35 class BattleState
36 : public app::State {
37
38 public:
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)
50         , moveMenu(moveIcons)
51         , activeHero(-1) { }
52
53 public:
54         void AddMonster(const Monster &);
55         void AddHero(const Hero &);
56
57 public:
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);
62
63         virtual void Resize(int width, int height);
64
65         virtual void HandleInput(const app::Input &);
66         virtual void UpdateWorld(float deltaT);
67         virtual void Render(SDL_Surface *);
68
69 public:
70         AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
71         MoveMenu &GetMoveMenu() { return moveMenu; }
72
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(); }
78
79 public:
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);
84         }
85         int BackgroundWidth() const { return background->w; }
86         int BackgroundHeight() const { return background->h; }
87
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);
92
93 private:
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;
104         MoveMenu moveMenu;
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;
111         int activeHero;
112
113 };
114
115 }
116
117 #endif /* BATTLE_BATTLESTATE_H_ */