#include <game.h>
Collaboration diagram for Game:
Public Member Functions | |
void | Start () |
void | UnloadDatas () |
bool | IsGameFinished () |
bool | IsGameLaunched () const |
void | MessageLoading () |
void | MessageEndOfGame () |
int | AskQuestion (Question &question, bool draw=true) |
void | Pause () |
bool | GetEndOfGameStatus () |
void | SetEndOfGameStatus (bool status) |
Static Public Member Functions | |
static Game * | GetInstance () |
Private Member Functions | |
int | NbrRemainingTeams () |
Game () | |
Private Attributes | |
bool | isGameLaunched |
bool | endOfGameStatus |
Static Private Attributes | |
static Game * | singleton = NULL |
Definition at line 29 of file game.h.
Game::Game | ( | ) | [private] |
Definition at line 60 of file game.cpp.
00061 { 00062 isGameLaunched = false; 00063 endOfGameStatus = false; 00064 }
Here is the caller graph for this function:
int Game::AskQuestion | ( | Question & | question, | |
bool | draw = true | |||
) |
Definition at line 117 of file game.cpp.
00118 { 00119 Time * global_time = Time::GetInstance(); 00120 global_time->Pause(); 00121 00122 if (draw) 00123 GameLoop::GetInstance()->Draw (); 00124 00125 int answer = question.Ask (); 00126 00127 global_time->Continue(); 00128 return answer; 00129 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool Game::GetEndOfGameStatus | ( | ) |
Game * Game::GetInstance | ( | ) | [static] |
bool Game::IsGameFinished | ( | ) |
Definition at line 66 of file game.cpp.
00067 { 00068 return (NbrRemainingTeams() <= 1); 00069 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool Game::IsGameLaunched | ( | ) | const |
void Game::MessageEndOfGame | ( | ) |
Definition at line 89 of file game.cpp.
00090 { 00091 std::vector<TeamResults*>* results_list = TeamResults::createAllResults(); 00092 const char *winner_name = NULL; 00093 00094 FOR_EACH_TEAM(team) 00095 { 00096 // Determine winner 00097 if (0 < (**team).NbAliveCharacter()) 00098 { 00099 winner_name = (**team).GetName().c_str(); 00100 break; 00101 } 00102 } 00103 00104 // Print out results 00105 if (winner_name) 00106 jukebox.Play("share","victory"); 00107 00108 //question.Set (txt, true, 0); 00109 //AskQuestion(); 00110 Mouse::GetInstance()->SetPointer(Mouse::POINTER_STANDARD); 00111 ResultsMenu menu(results_list, winner_name); 00112 menu.Run(); 00113 00114 TeamResults::deleteAllResults(results_list); 00115 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Game::MessageLoading | ( | ) |
int Game::NbrRemainingTeams | ( | ) | [private] |
Definition at line 71 of file game.cpp.
00072 { 00073 uint nbr = 0; 00074 00075 FOR_EACH_TEAM(team){ 00076 if( (**team).NbAliveCharacter() > 0 ) 00077 nbr++; 00078 } 00079 00080 return nbr; 00081 }
Here is the caller graph for this function:
void Game::Pause | ( | ) |
Definition at line 214 of file game.cpp.
00215 { 00216 Question question; 00217 if(!network.IsLocal()) 00218 return; 00219 00220 jukebox.Pause(); 00221 00222 //Pause screen 00223 question.Set ("", false, 0, "interface/pause_screen"); 00224 question.add_choice(Config::GetInstance()->GetKeyboard()->GetKeyAssociatedToAction(Action::ACTION_PAUSE), 00225 1 00226 ); 00227 AskQuestion(question, false); 00228 jukebox.Resume(); 00229 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Game::SetEndOfGameStatus | ( | bool | status | ) |
Definition at line 239 of file game.cpp.
00239 { 00240 endOfGameStatus = status; 00241 }
Here is the caller graph for this function:
void Game::Start | ( | ) |
Definition at line 131 of file game.cpp.
00132 { 00133 bool err=true; 00134 bool end; 00135 std::string err_msg; 00136 00137 try 00138 { 00139 GameLoop::GetInstance()->Init (); 00140 00141 do 00142 { 00143 isGameLaunched = true; 00144 GameLoop::GetInstance()->fps.Reset(); 00145 00146 GameLoop::GetInstance()->Run(); 00147 00148 MSG_DEBUG( "game", "End of game_loop.Run()" ); 00149 isGameLaunched = false; 00150 00151 if (!IsGameFinished()) 00152 { 00153 Question question; 00154 const char *msg = _("Do you really want to quit? (Y/N)"); 00155 question.Set (msg, true, 0, "interface/quit_screen"); 00156 00157 { 00158 /* Tiny fix by Zygmunt Krynicki <zyga@zyga.dyndns.org> */ 00159 /* Let's find out what the user would like to press ... */ 00160 char *key_x_ptr = strchr (msg, '/'); 00161 char key_x; 00162 if (key_x_ptr && key_x_ptr > msg) /* it's there and it's not the first char */ 00163 key_x = tolower(key_x_ptr[-1]); 00164 else 00165 abort(); 00166 if (!isalpha(key_x)) /* sanity check */ 00167 abort(); 00168 00169 question.add_choice(SDLK_a + (int)key_x - 'a', 1); 00170 } 00171 00172 jukebox.Pause(); 00173 end = (AskQuestion(question) == 1); 00174 jukebox.Resume(); 00175 if(!end) 00176 world.ToRedrawOnScreen(Rectanglei(Point2i(0,0),AppWormux::GetInstance()->video.window.GetSize())); 00177 } else { 00178 end = true; 00179 } 00180 } while (!end); 00181 err = false; 00182 } 00183 catch (const std::exception &e) 00184 { 00185 err_msg = e.what(); 00186 } 00187 00188 if (!err) 00189 if (IsGameFinished()) 00190 MessageEndOfGame(); 00191 00192 UnloadDatas(); 00193 Mouse::GetInstance()->SetPointer(Mouse::POINTER_STANDARD); 00194 00195 if (err) 00196 { 00197 Question question; 00198 std::string txt = Format(_("Error:\n%s"), err_msg.c_str()); 00199 std::cout << std::endl << txt << std::endl; 00200 question.Set (txt, true, 0); 00201 AskQuestion (question, false); 00202 } 00203 }
Here is the call graph for this function:
Here is the caller graph for this function:
void Game::UnloadDatas | ( | ) |
Definition at line 205 of file game.cpp.
00206 { 00207 world.FreeMem(); 00208 lst_objects.FreeMem(); 00209 ParticleEngine::Stop(); 00210 teams_list.UnloadGamingData(); 00211 jukebox.StopAll(); 00212 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool Game::endOfGameStatus [private] |
bool Game::isGameLaunched [private] |
Game * Game::singleton = NULL [static, private] |