]> git.localhorst.tv Git - l2e.git/blob - src/battle/BattleState.h
added gauges for health, mana, and ikari displays
[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)
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         , attackTypeMenu(attackIcons)
49         , moveMenu(moveIcons)
50         , activeHero(-1) { }
51
52 public:
53         void AddMonster(const Monster &);
54         void AddHero(const Hero &);
55
56 public:
57         virtual void EnterState(app::Application &ctrl, SDL_Surface *screen);
58         virtual void ExitState(app::Application &ctrl, SDL_Surface *screen);
59         virtual void ResumeState(app::Application &ctrl, SDL_Surface *screen);
60         virtual void PauseState(app::Application &ctrl, SDL_Surface *screen);
61
62         virtual void Resize(int width, int height);
63
64         virtual void HandleInput(const app::Input &);
65         virtual void UpdateWorld(float deltaT);
66         virtual void Render(SDL_Surface *);
67
68 public:
69         AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
70         MoveMenu &GetMoveMenu() { return moveMenu; }
71
72         bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
73         void NextHero() { ++activeHero; }
74         bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
75         void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
76         bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
77
78 public:
79         geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
80                 return geometry::Vector<int>(
81                                 (screen->w - background->w) / 2,
82                                 (screen->h - background->h) / 2);
83         }
84         int BackgroundWidth() const { return background->w; }
85         int BackgroundHeight() const { return background->h; }
86
87         void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
88         void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
89         void RenderHeroes(SDL_Surface *screen, const geometry::Vector<int> &offset);
90         void RenderHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
91
92 private:
93         SDL_Surface *background;
94         const PartyLayout *monstersLayout;
95         const PartyLayout *heroesLayout;
96         const graphics::Frame *heroTagFrame;
97         const graphics::Frame *activeHeroTagFrame;
98         const graphics::Gauge *healthGauge;
99         const graphics::Gauge *manaGauge;
100         const graphics::Gauge *ikariGauge;
101         AttackTypeMenu attackTypeMenu;
102         MoveMenu moveMenu;
103         std::vector<geometry::Point<int> > monsterPositions;
104         std::vector<geometry::Point<int> > heroesPositions;
105         std::vector<Monster> monsters;
106         std::vector<Hero> heroes;
107         std::vector<HeroTag> heroTags;
108         std::vector<AttackChoice> attackChoices;
109         int activeHero;
110
111 };
112
113 }
114
115 #endif /* BATTLE_BATTLESTATE_H_ */