YAPOG  0.0.1
Yet Another Pokemon Online Game
Battle.cpp
Go to the documentation of this file.
6 
11 #include "Battle/PokemonFighter.hpp"
12 #include "Battle/PokemonFighterTeam.hpp"
13 #include "Game.hpp"
14 #include "Battle/Battle.hpp"
15 
16 namespace ycl
17 {
18  const bool Battle::DEFAULT_VISIBLE_STATE = true;
19  const sf::Color Battle::DEFAULT_COLOR = sf::Color ();
21  = yap::Vector2 (0.75f, 0.75f);
22 
23  Battle::Battle (BattleInterface& battleInterface)
24  : yap::Battle ()
25  , isVisible_ (DEFAULT_VISIBLE_STATE)
26  , color_ (DEFAULT_COLOR)
27  , battleInterface_ (battleInterface)
28  , background_ (nullptr)
29  , playerGround_ (nullptr)
30  , opponentGround_ (nullptr)
31  , playerTrainerBack_ (nullptr)
32  , playerGroundPosition_ ()
33  , opponentGroundPosition_ ()
34  , opponentInfoPosition_ ()
35  , pokemonInfoPosition_ ()
36  , playerTeam_ (nullptr)
37  , opponent_ (nullptr)
38  {
39  }
40 
42  {
43  delete background_;
44  delete playerGround_;
45  delete opponentGround_;
46  delete playerTrainerBack_;
47  }
48 
50  {
53  Create<yap::Texture> ("Texture", yap::ID (42)));
54 
56  Create<yap::Texture> ("Texture", yap::ID (43)));
57 
59  Create<yap::Texture> ("Texture", yap::ID (43)));
60 
62  Create<yap::Texture> ("Texture", yap::ID (44)));
63 
67 
70  ((playerGround_->GetSize ().y) / 2));
71 
74  (opponentGround_->GetSize ().x),
75  Game::SCREEN_SIZE.y / 3 -
76  (opponentGround_->GetSize ().y) / 2);
77 
79  opponentGroundPosition_.x -
81  opponentGroundPosition_.y -
83 
86  playerGround_->GetSize ().x,
89 
90  // Hide some sprites
91  playerTeam_->GetBattleSprite ().Show (false);
92  }
93 
96  { return *background_; }
97 
99  { return *playerGround_; }
100 
102  { return *opponentGround_; }
103 
105  { return *playerTrainerBack_; }
106 
108  { return playerGroundPosition_; }
109 
111  { return opponentGroundPosition_; }
112 
114  { return opponentInfoPosition_; }
115 
117  { return pokemonInfoPosition_; }
118 
120  { return *playerTeam_; }
121 
123  { return *opponent_; }
124 
127  {
128  playerTeam_ = playerTeam;
129  }
130 
132  {
133  opponent_ = opponent;
134  }
136  {
137  if (!IsVisible ())
138  return;
139 
140  HandleDraw (context);
141  }
142 
143  bool Battle::IsVisible () const
144  {
145  return isVisible_;
146  }
147 
148  void Battle::Show (bool isVisible)
149  {
150  isVisible_ = isVisible;
151 
152  HandleShow (isVisible);
153  }
154 
155  void Battle::ChangeColor (const sf::Color& color)
156  {
157  color_ = color;
158 
159  HandleChangeColor (color);
160  }
161 
163  {
164  background_->Update (dt);
165  playerGround_->Update (dt);
167  opponentGround_->Update (dt);
168  }
169 
171  {
172  background_->Draw (context);
173  playerGround_->Draw (context);
174  playerTrainerBack_->Draw (context);
175  opponentGround_->Draw (context);
176  GetPlayerTeam ().Draw (context);
177  GetOpponent ().Draw (context);
178  }
179 
180  void Battle::HandleShow (bool isVisible)
181  {
182  }
183 
184  void Battle::HandleChangeColor (const sf::Color& color)
185  {
186  }
187 
188 } // namespace ycl