#include <game_mode.h>
Collaboration diagram for GameMode:
Definition at line 31 of file game_mode.h.
GameMode::GameMode | ( | ) | [private] |
Definition at line 41 of file game_mode.cpp.
00042 { 00043 max_characters = 6; 00044 max_teams = 4; 00045 duration_turn = 60; 00046 duration_exchange_player = 2; 00047 duration_before_death_mode = 20 * 60; 00048 damage_per_turn_during_death_mode = 5; 00049 gravity = 9.81; 00050 safe_fall = 10; 00051 damage_per_fall_unit = 7; 00052 duration_move_player = 3; 00053 allow_character_selection = BEFORE_FIRST_ACTION_AND_END_TURN; 00054 character.init_energy = 100; /* overvriten whenreading XML */ 00055 character.max_energy = 100; /* overvriten whenreading XML */ 00056 character.mass = 100; 00057 character.air_resist_factor = 1.0; 00058 character.jump_strength = 8; 00059 character.jump_angle = -60; 00060 character.super_jump_strength = 11; 00061 character.super_jump_angle = -80; 00062 character.back_jump_strength = 9; 00063 character.back_jump_angle = -100; 00064 }
Here is the caller graph for this function:
bool GameMode::AllowCharacterSelection | ( | ) | const |
Definition at line 202 of file game_mode.cpp.
00203 { 00204 switch (allow_character_selection) 00205 { 00206 case GameMode::ALWAYS: break; 00207 00208 case GameMode::BEFORE_FIRST_ACTION: 00209 case GameMode::BEFORE_FIRST_ACTION_AND_END_TURN: 00210 return (GameLoop::GetInstance()->ReadState() == GameLoop::PLAYING) && !GameLoop::GetInstance()->character_already_chosen; 00211 00212 case GameMode::CHANGE_ON_END_TURN: 00213 case GameMode::NEVER: 00214 return false; 00215 } 00216 00217 return true; 00218 }
Here is the call graph for this function:
GameMode * GameMode::GetInstance | ( | ) | [static] |
bool GameMode::Load | ( | const std::string & | mode | ) |
Definition at line 166 of file game_mode.cpp.
00167 { 00168 if (mode == m_current) return true; 00169 m_current = mode; 00170 00171 std::string fullname; 00172 try 00173 { 00174 XmlReader doc; 00175 std::string filename = 00176 PATH_SEPARATOR 00177 + std::string("game_mode") 00178 + std::string(PATH_SEPARATOR) 00179 + mode 00180 + std::string(".xml"); 00181 00182 Config * config = Config::GetInstance(); 00183 fullname = config->GetPersonalDir() + filename; 00184 00185 if(!IsFileExist(fullname)) 00186 fullname = config->GetDataDir() + filename; 00187 if(!doc.Load(fullname)) 00188 return false; 00189 if(!LoadXml(doc.GetRoot())) 00190 return false; 00191 } 00192 catch (const xmlpp::exception &e) 00193 { 00194 std::cerr << Format(_("Error while loading game mode %s (file %s):"), 00195 mode.c_str(), fullname.c_str()) 00196 << std::endl << e.what() << std::endl; 00197 return false; 00198 } 00199 return true; 00200 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool GameMode::LoadXml | ( | xmlpp::Element * | xml | ) | [protected] |
Definition at line 67 of file game_mode.cpp.
00068 { 00069 std::string txt; 00070 if (XmlReader::ReadString(xml, "allow_character_selection", txt)) 00071 { 00072 if (txt == "always") 00073 allow_character_selection = ALWAYS; 00074 else if (txt == "never") 00075 allow_character_selection = NEVER; 00076 else if (txt == "change_on_end_turn") 00077 allow_character_selection = CHANGE_ON_END_TURN; 00078 else if (txt == "before_first_action_and_end_turn") 00079 allow_character_selection = BEFORE_FIRST_ACTION_AND_END_TURN; 00080 else if (txt == "before_first_action") 00081 allow_character_selection = BEFORE_FIRST_ACTION; 00082 } 00083 00084 XmlReader::ReadUint(xml, "duration_turn", duration_turn); 00085 XmlReader::ReadUint(xml, "duration_move_player", duration_move_player); 00086 XmlReader::ReadUint(xml, "duration_exchange_player", duration_exchange_player); 00087 XmlReader::ReadUint(xml, "duration_before_death_mode", duration_before_death_mode); 00088 XmlReader::ReadUint(xml, "damage_per_turn_during_death_mode", damage_per_turn_during_death_mode); 00089 XmlReader::ReadUint(xml, "max_teams", max_teams); 00090 XmlReader::ReadUint(xml, "max_characters", max_characters); 00091 XmlReader::ReadDouble(xml, "gravity", gravity); 00092 XmlReader::ReadDouble(xml, "safe_fall", safe_fall); 00093 XmlReader::ReadDouble(xml, "damage_per_fall_unit", damage_per_fall_unit); 00094 00095 // Character options 00096 xmlpp::Element *character_xml = XmlReader::GetMarker(xml, "character"); 00097 if (character_xml != NULL) 00098 { 00099 xmlpp::Element *item = XmlReader::GetMarker(character_xml, "energy"); 00100 if (item != NULL) { 00101 XmlReader::ReadUintAttr(item, "initial", character.init_energy); 00102 XmlReader::ReadUintAttr(item, "maximum", character.max_energy); 00103 if (character.init_energy==0) character.init_energy = 1; 00104 if (character.max_energy==0) character.max_energy = 1; 00105 } 00106 XmlReader::ReadUint(character_xml, "mass", character.mass); 00107 XmlReader::ReadDouble(character_xml, "air_resist_factor", character.air_resist_factor); 00108 item = XmlReader::GetMarker(character_xml, "jump"); 00109 if (item != NULL) { 00110 int angle_deg; 00111 XmlReader::ReadUintAttr(item, "strength", character.jump_strength); 00112 XmlReader::ReadIntAttr(item, "angle", angle_deg); 00113 character.jump_angle = static_cast<double>(angle_deg) * M_PI / 180; 00114 } 00115 00116 item = XmlReader::GetMarker(character_xml, "super_jump"); 00117 if (item != NULL) { 00118 int angle_deg; 00119 XmlReader::ReadUintAttr(item, "strength", character.super_jump_strength); 00120 XmlReader::ReadIntAttr(item, "angle", angle_deg); 00121 character.super_jump_angle = static_cast<double>(angle_deg) * M_PI / 180; 00122 } 00123 item = XmlReader::GetMarker(character_xml, "back_jump"); 00124 if (item != NULL) { 00125 int angle_deg; 00126 XmlReader::ReadUintAttr(item, "strength", character.back_jump_strength); 00127 XmlReader::ReadIntAttr(item, "angle", angle_deg); 00128 character.back_jump_angle = static_cast<double>(angle_deg) * M_PI / 180; 00129 } 00130 xmlpp::Element *explosion = XmlReader::GetMarker(character_xml, "death_explosion"); 00131 if (explosion != NULL) 00132 death_explosion_cfg.LoadXml(explosion); 00133 } 00134 00135 // Barrel explosion 00136 xmlpp::Element *barrel_xml = XmlReader::GetMarker(xml, "barrel"); 00137 if(barrel_xml != NULL) { 00138 xmlpp::Element *barrel_explosion = XmlReader::GetMarker(barrel_xml, "explosion"); 00139 if (barrel_explosion != NULL) 00140 barrel_explosion_cfg.LoadXml(barrel_explosion); 00141 } 00142 00143 // Bonus box explosion 00144 xmlpp::Element *bonus_box_xml = XmlReader::GetMarker(xml, "bonus_box"); 00145 if(bonus_box_xml != NULL) { 00146 xmlpp::Element *bonus_box_explosion = XmlReader::GetMarker(bonus_box_xml, "explosion"); 00147 if (bonus_box_explosion != NULL) 00148 bonus_box_explosion_cfg.LoadXml(bonus_box_explosion); 00149 } 00150 00151 //=== Weapons === 00152 xmlpp::Element *armes = XmlReader::GetMarker(xml, "weapons"); 00153 if (armes != NULL) 00154 { 00155 std::list<Weapon*> l_weapons_list = Config::GetInstance()->GetWeaponsList()->GetList() ; 00156 std::list<Weapon*>::iterator 00157 itw = l_weapons_list.begin(), 00158 end = l_weapons_list.end(); 00159 00160 for (; itw != end ; ++itw) (*itw)->LoadXml(armes); 00161 } 00162 00163 return true; 00164 }
Here is the call graph for this function:
Here is the caller graph for this function:
Definition at line 62 of file game_mode.h.
const int GameMode::ALWAYS = 0 [static] |
Definition at line 64 of file game_mode.h.
Definition at line 45 of file game_mode.h.
const int GameMode::BEFORE_FIRST_ACTION = 1 [static] |
Definition at line 65 of file game_mode.h.
const int GameMode::BEFORE_FIRST_ACTION_AND_END_TURN = 2 [static] |
Definition at line 66 of file game_mode.h.
Definition at line 46 of file game_mode.h.
const int GameMode::CHANGE_ON_END_TURN = 3 [static] |
Definition at line 67 of file game_mode.h.
Definition at line 43 of file game_mode.h.
Definition at line 40 of file game_mode.h.
Definition at line 44 of file game_mode.h.
Definition at line 39 of file game_mode.h.
Definition at line 38 of file game_mode.h.
Definition at line 37 of file game_mode.h.
Definition at line 36 of file game_mode.h.
double GameMode::gravity |
Definition at line 41 of file game_mode.h.
std::string GameMode::m_current [private] |
Definition at line 71 of file game_mode.h.
Definition at line 34 of file game_mode.h.
Definition at line 35 of file game_mode.h.
const int GameMode::NEVER = 4 [static] |
Definition at line 68 of file game_mode.h.
double GameMode::safe_fall |
Definition at line 42 of file game_mode.h.
GameMode * GameMode::singleton = NULL [static, private] |
Definition at line 72 of file game_mode.h.