YAPOG  0.0.1
Yet Another Pokemon Online Game
BeginWildBattlePhase.cpp
Go to the documentation of this file.
4 
8 #include "Battle/Battle.hpp"
9 #include "Game.hpp"
10 
11 namespace ycl
12 {
14  const sf::Color BeginWildBattlePhase::DEFAULT_COLOR = sf::Color ();
15  const float BeginWildBattlePhase::GROUND_SPEED = 500.f;
17 
19  (Battle& battle, BattleInterface& battleInterface)
20  : BeginBattlePhase (battle, battleInterface)
21  , nextState_ (FISRT_STATE)
22  {
23  }
24 
26  {
27  }
28 
30  {
32  [&] (const yap::IBattleEntity& sender,
34  {
37 
40  };
41 
43  [&] (const yap::BaseWidget& sender, const yap::EmptyEventArgs& args)
44  {
45  if (nextState_ == "WaitUser")
46  {
48  AddText (battle_.GetPlayerTeam ().GetName () + "! GO !");
49 
50  nextState_ = "PlayerBack";
52  }
53  };
54  }
55 
57  {
59 
60  // Begin battle little phases booleans init.
62 
63  // Player's side init
65  yap::Vector2 (
67  ));
68 
70 
71  // Opponent's side init.
73  yap::Vector2 (
74  (-1) * battle_.GetOpponentGround ().GetSize ().x,
76 
78 
81  const yap::String& opponentName = battle_.GetOpponent ().GetName ();
82 
83  // Battle dialog box init.
88  AddText ("Un " + opponentName + " sauvage apparait !");
89 
90  // Opponent's side.
97 
102 
104  }
105 
107  {
109 
110  if (nextState_ == FISRT_STATE)
111  {
112  if (battle_.GetPlayerGround ().GetPosition ().x >
114  {
116  yap::Vector2 (
117  (-1) * (GROUND_SPEED * dt.GetValue ()),
118  0));
119 
121  }
122  else
123  {
126 
128  }
129 
132  {
134  yap::Vector2 (
135  (GROUND_SPEED * dt.GetValue ()),
136  0));
137 
139  }
140  else
141  {
144 
146  }
147 
152  {
153  nextState_ = "OpponentInfo";
154  }
155  }
156 
157  if (nextState_ == "OpponentInfo")
158  {
160 
163  {
165  ((GROUND_SPEED * 2) * dt.GetValue ()),
166  0));
167  }
168  else
169  {
172 
174  nextState_ = "WaitUser";
175  }
176  }
177 
178  if (nextState_ == "PlayerBack")
179  {
181  (-1) * battle_.GetPlayerTrainerBack ().GetSize ().x)
182  {
184  yap::Vector2 ((-1) * ((GROUND_SPEED * 2) * dt.GetValue ()), 0));
185  }
186  else
187  nextState_ = "SwitchPhase";
188  }
189 
190  if (nextState_ == "SwitchPhase")
192  }
193 
195  {
197  }
198 
200  {
201  }
202 
203  void BeginWildBattlePhase::HandleShow (bool isVisible)
204  {
205  }
206 
207  void BeginWildBattlePhase::HandleChangeColor (const sf::Color& color)
208  {
209  }
210 
212  {
214  yap::Vector2 (
216  battle_.GetPlayerGround ().GetSize ().x / 2 -
219  battle_.GetPlayerGround ().GetSize ().y / 2 -
221  ));
222  }
223 
225  {
227  yap::Vector2 (
229  battle_.GetOpponentGround ().GetSize ().x / 2 -
232  battle_.GetOpponent ().GetBattleSprite ().GetSize ().y / 2));
233  }
234 }