00001
00002
00009
00010
00011
#include "xml_niveau.h"
00012
#include "affichage.h"
00013
#include "texture_manager.h"
00014
00015 CXMLNiveau::CXMLNiveau ()
00016 {
00017
00018 }
00019
00020
00021
00022 CXMLNiveau::~CXMLNiveau ()
00023 {
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 }
00048
00049
00050 CTypeBonusArme*
CXMLNiveau::GetTypeBonusArme (
unsigned int uiNiveau)
const
00051
{
00052
return m_Niveaux[uiNiveau].m_TypeBonusArme[
RandInt (0, m_Niveaux[uiNiveau].m_TypeBonusArme.size ())];
00053 }
00054
00055
00056 CTypeBonusBouclier*
CXMLNiveau::GetTypeBonusBouclier (
unsigned int uiNiveau)
const
00057
{
00058
return m_Niveaux[uiNiveau].m_TypeBonusBouclier[
RandInt (0, m_Niveaux[uiNiveau].m_TypeBonusBouclier.size ())];
00059 }
00060
00061
00062 CTypeEnnemi*
CXMLNiveau::GetTypeEnnemi (
unsigned int uiNiveau)
const
00063
{
00064
return m_Niveaux[uiNiveau].m_TypeEnnemi[
RandInt (0, m_Niveaux[uiNiveau].m_TypeEnnemi.size ())];
00065 }
00066
00067
00068 unsigned int CXMLNiveau::GetEnnemiNombre (
unsigned int uiNiveau)
const
00069
{
00070
return m_Niveaux[uiNiveau].m_uiEnnemiNombre;
00071 }
00072
00073
00074 unsigned int CXMLNiveau::GetNiveauNombre ()
const
00075
{
00076
return m_Niveaux.size ();
00077 }
00078
00079
00080 float CXMLNiveau::GetBonusArmeFrequence (
unsigned int uiNiveau)
const
00081
{
00082
return m_Niveaux[uiNiveau].m_fBonusArmeFrequence;
00083 }
00084
00085
00086 float CXMLNiveau::GetBonusBouclierFrequence (
unsigned int uiNiveau)
const
00087
{
00088
return m_Niveaux[uiNiveau].m_fBonusBouclierFrequence;
00089 }
00090
00091
00092 float CXMLNiveau::GetEnnemiFrequence (
unsigned int uiNiveau)
const
00093
{
00094
return m_Niveaux[uiNiveau].m_fEnnemiFrequence;
00095 }
00096
00097
00098 bool CXMLNiveau::Charger (
const char* szFilename)
00099 {
00100
00101 xmlDoc* pDocument = xmlParseFile (szFilename);
00102
00103
00104
if (!Validation (pDocument))
00105 {
00106 xmlFreeDoc (pDocument);
00107
return false;
00108 }
00109
00110
00111 xmlNode* pJeu = xmlDocGetRootElement (pDocument);
00112
if ((!xmlStrcmp (pJeu->name, (
const xmlChar *)
"jeu")))
00113 Jeu (pJeu);
00114
00115
00116 xmlFreeDoc (pDocument);
00117
00118
return true;
00119 }
00120
00121
00122
bool CXMLNiveau::Validation (xmlDoc* pDocument)
00123 {
00124
00125 xmlValidCtxt Contexte;
00126 Contexte.userData = (
void *) stderr;
00127 Contexte.error = (xmlValidityErrorFunc) fprintf;
00128 Contexte.warning = (xmlValidityWarningFunc) fprintf;
00129
00130
return xmlValidateDocument (&Contexte, pDocument) == 1;
00131 }
00132
00133
00134
void CXMLNiveau::Jeu (xmlNode* pNode)
00135 {
00136
00137 xmlNode* pChild = pNode->children;
00138
if (pChild)
00139 {
00140
do
00141 {
00142
if (pChild->type == XML_ELEMENT_NODE)
00143 {
00144
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"bonus-armes")))
00145 BonusArmes (pChild);
00146
else if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"bonus-boucliers")))
00147 BonusBoucliers (pChild);
00148
else if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"ennemis")))
00149 Ennemis (pChild);
00150
else if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"niveaux")))
00151 Niveaux (pChild);
00152 }
00153 }
00154
while ((pChild = pChild->next) != 0);
00155 }
00156 }
00157
00158
00159
void CXMLNiveau::BonusArmes (xmlNode* pNode)
00160 {
00161
00162 xmlNode* pChild = pNode->children;
00163
do
00164 {
00165
if (pChild->type == XML_ELEMENT_NODE)
00166
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"bonus-arme")))
00167 m_TypeBonusArme.insert (BonusArme (pChild));
00168 }
00169
while ((pChild = pChild->next) != 0);
00170 }
00171
00172
00173 std::pair<unsigned int, CTypeBonusArme*> CXMLNiveau::BonusArme (xmlNode* pNode)
00174 {
00175
CTypeBonusArme *pTypeBonusArme =
new CTypeBonusArme;
00176
unsigned int uiIndex = 0;
00177
CVecteur Vitesse, Acceleration;
00178
00179
00180 xmlAttribute* pAttribute = ((xmlElement*)pNode)->attributes;
00181
if (pAttribute)
00182 {
00183
do
00184 {
00185
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00186 {
00187
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"index")))
00188 uiIndex = atoi ((
const char*) xmlGetProp (pNode, pAttribute->name));
00189
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"taille")))
00190 pTypeBonusArme->
SetTaille ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00191
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-x")))
00192 Acceleration (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00193
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-y")))
00194 Acceleration (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00195
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-x")))
00196 Vitesse (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00197
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-y")))
00198 Vitesse (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00199
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"texture")))
00200 pTypeBonusArme->
SetTexture (CTextureManager::Instance ()->Texture2D ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00201
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"son")))
00202 pTypeBonusArme->
SetSon ((
const char*) xmlGetProp (pNode, pAttribute->name));
00203 }
00204 }
00205
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00206 }
00207
00208 pTypeBonusArme->
SetAcceleration (Acceleration);
00209 pTypeBonusArme->
SetVitesse (Vitesse);
00210
00211
00212 xmlNode* pChild = pNode->children;
00213
if (pChild)
00214 {
00215
do
00216 {
00217
if (pChild->type == XML_ELEMENT_NODE)
00218
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"arme")))
00219 pTypeBonusArme->
SetArme (Arme (pChild));
00220 }
00221
while ((pChild = pChild->next) != 0);
00222 }
00223
00224
return std::make_pair<unsigned int, CTypeBonusArme*> (uiIndex, pTypeBonusArme);
00225 }
00226
00227
00228
CVecteur CXMLNiveau::Ancrage (xmlNode* pNode)
00229 {
00230
CVecteur Ancrage;
00231
00232
00233 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00234
if (pAttribute)
00235 {
00236
do
00237 {
00238
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00239 {
00240
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"x")))
00241 Ancrage (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00242
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"y")))
00243 Ancrage (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00244 }
00245 }
00246
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00247 }
00248
return Ancrage;
00249 }
00250
00251
00252
void CXMLNiveau::BonusBoucliers (xmlNode* pNode)
00253 {
00254
00255 xmlNode* pChild = pNode->children;
00256
if (pChild)
00257 {
00258
do
00259 {
00260
if (pChild->type == XML_ELEMENT_NODE)
00261
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"bonus-bouclier")))
00262 m_TypeBonusBouclier.insert (BonusBouclier (pChild));
00263 }
00264
while ((pChild = pChild->next) != 0);
00265 }
00266 }
00267
00268
00269 std::pair<unsigned int, CTypeBonusBouclier*> CXMLNiveau::BonusBouclier (xmlNode* pNode)
00270 {
00271
CTypeBonusBouclier *pTypeBonusBouclier =
new CTypeBonusBouclier;
00272
unsigned int uiIndex = 0;
00273
CVecteur Vitesse, Acceleration;
00274
00275
00276 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00277
if (pAttribute)
00278 {
00279
do
00280 {
00281
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00282 {
00283
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"index")))
00284 uiIndex = atoi ((
const char*) xmlGetProp (pNode, pAttribute->name));
00285
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"taille")))
00286 pTypeBonusBouclier->
SetTaille ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00287
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-x")))
00288 Acceleration (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00289
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-y")))
00290 Acceleration (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00291
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-x")))
00292 Vitesse (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00293
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-y")))
00294 Vitesse (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00295
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"texture")))
00296 pTypeBonusBouclier->
SetTexture (CTextureManager::Instance ()->Texture2D ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00297
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"bouclier")))
00298 pTypeBonusBouclier->
SetBonusBouclier (atoi ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00299
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"son")))
00300 pTypeBonusBouclier->
SetSon ((
const char*) xmlGetProp (pNode, pAttribute->name));
00301 }
00302 }
00303
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00304 }
00305
00306 pTypeBonusBouclier->
SetAcceleration (Acceleration);
00307 pTypeBonusBouclier->
SetVitesse (Vitesse);
00308
00309
return std::make_pair<unsigned int, CTypeBonusBouclier*> (uiIndex, pTypeBonusBouclier);
00310 }
00311
00312
00313
void CXMLNiveau::Ennemis (xmlNode* pNode)
00314 {
00315
00316 xmlNode* pChild = pNode->children;
00317
if (pChild)
00318 {
00319
do
00320 {
00321
if (pChild->type == XML_ELEMENT_NODE)
00322
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"ennemi")))
00323 m_TypeEnnemi.insert (Ennemi (pChild));
00324 }
00325
while ((pChild = pChild->next) != 0);
00326 }
00327 }
00328
00329
00330 std::pair<unsigned int, CTypeEnnemi*> CXMLNiveau::Ennemi (xmlNode* pNode)
00331 {
00332
CTypeEnnemi *pTypeEnnemi =
new CTypeEnnemi;
00333
unsigned int uiIndex = 0;
00334
CVecteur Vitesse, Acceleration;
00335
00336
00337 xmlAttribute* pAttribute = ((xmlElement*)pNode)->attributes;
00338
if (pAttribute)
00339 {
00340
do
00341 {
00342
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00343 {
00344
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"index")))
00345 uiIndex = atoi ((
const char*) xmlGetProp (pNode, pAttribute->name));
00346
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"taille")))
00347 pTypeEnnemi->
SetTaille ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00348
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"dommage")))
00349 pTypeEnnemi->
SetDommage (atoi ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00350
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"bouclier")))
00351 pTypeEnnemi->
SetBouclier (atoi ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00352
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"point")))
00353 pTypeEnnemi->
SetPoint (atoi ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00354
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-x")))
00355 Acceleration (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00356
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-y")))
00357 Acceleration (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00358
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-x")))
00359 Vitesse (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00360
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-y")))
00361 Vitesse (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00362
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"texture")))
00363 pTypeEnnemi->
SetTexture (CTextureManager::Instance ()->Texture2D ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00364
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"son")))
00365 pTypeEnnemi->
SetSon ((
const char*) xmlGetProp (pNode, pAttribute->name));
00366 }
00367 }
00368
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00369 }
00370
00371 pTypeEnnemi->
SetAcceleration (Acceleration);
00372 pTypeEnnemi->
SetVitesse (Vitesse);
00373
00374
00375 xmlNode* pChild = pNode->children;
00376
if (pChild)
00377 {
00378
do
00379 {
00380
if (pChild->type == XML_ELEMENT_NODE)
00381
if ((!xmlStrcmp (pChild->name, (
const xmlChar*)
"arme")))
00382 pTypeEnnemi->
SetTypeArme (Arme (pChild));
00383 }
00384
while ((pChild = pChild->next) != 0);
00385 }
00386
00387
return std::make_pair<unsigned int, CTypeEnnemi*> (uiIndex, pTypeEnnemi);
00388 }
00389
00390
00391
CTypeArme* CXMLNiveau::Arme (xmlNode* pNode)
00392 {
00393
CTypeArme *pTypeArme =
new CTypeArme;
00394
00395
CVecteur Acceleration;
00396
CVecteur Vitesse;
00397
CCouleur Couleur;
00398
00399
00400 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00401
if (pAttribute)
00402 {
00403
do
00404 {
00405
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00406 {
00407
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"dommage")))
00408 pTypeArme->
SetDommage (atoi ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00409
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"cadence")))
00410 pTypeArme->
SetCadence ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00411
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"taille")))
00412 pTypeArme->
SetTaille ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00413
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"precision")))
00414 pTypeArme->
SetPrecision ((
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00415
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-x")))
00416 Acceleration (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00417
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"acceleration-y")))
00418 Acceleration (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00419
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-x")))
00420 Vitesse (gtl::X) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00421
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vitesse-y")))
00422 Vitesse (gtl::Y) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00423
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"texture")))
00424 pTypeArme->
SetTexture (CTextureManager::Instance ()->Texture2D ((
const char*) xmlGetProp (pNode, pAttribute->name)));
00425
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"son")))
00426 pTypeArme->
SetSon ((
const char*) xmlGetProp (pNode, pAttribute->name));
00427
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"fumee")))
00428 pTypeArme->
SetFumee (!xmlStrcmp (xmlGetProp (pNode, pAttribute->name), (
const xmlChar *)
"oui"));
00429
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"rouge")))
00430 Couleur (gtl::R) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00431
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"vert")))
00432 Couleur (gtl::G) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00433
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"bleu")))
00434 Couleur (gtl::B) = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00435 }
00436 }
00437
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00438 }
00439
00440 pTypeArme->
SetAcceleration (Acceleration);
00441 pTypeArme->
SetVitesse (Vitesse);
00442 pTypeArme->
SetCouleur (Couleur);
00443
00444
00445 xmlNode* pChild = pNode->children;
00446
if (pChild)
00447 {
00448
do
00449 {
00450
if (pChild->type == XML_ELEMENT_NODE)
00451
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"ancrage")))
00452 pTypeArme->
AddAncrage (Ancrage (pChild));
00453 }
00454
while ((pChild = pChild->next) != 0);
00455 }
00456
00457
return pTypeArme;
00458 }
00459
00460
00461
void CXMLNiveau::Niveaux (xmlNode* pNode)
00462 {
00463
00464 xmlNode* pChild = pNode->children;
00465
if (pChild)
00466 {
00467
do
00468 {
00469
if (pChild->type == XML_ELEMENT_NODE)
00470
if (!xmlStrcmp (pChild->name, (
const xmlChar *)
"niveau"))
00471 m_Niveaux.push_back (Niveau (pChild));
00472 }
00473
while ((pChild = pChild->next) != 0);
00474 }
00475 }
00476
00477
00478
SNiveau CXMLNiveau::Niveau (xmlNode* pNode)
00479 {
00480
SNiveau Niveau;
00481
00482
00483 xmlNode* pChild = pNode->children;
00484
if (pChild)
00485 {
00486
do
00487 {
00488
if (pChild->type == XML_ELEMENT_NODE)
00489 {
00490
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-armes")))
00491 IndexArmes (pChild, Niveau);
00492
else if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-boucliers")))
00493 IndexBoucliers (pChild, Niveau);
00494
else if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-ennemis")))
00495 IndexEnnemis (pChild, Niveau);
00496 }
00497 }
00498
while ((pChild = pChild->next) != 0);
00499 }
00500
00501
return Niveau;
00502 }
00503
00504
00505
void CXMLNiveau::IndexArmes (xmlNode* pNode,
SNiveau & Niveau)
00506 {
00507
00508 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00509
if (pAttribute)
00510 {
00511
do
00512 {
00513
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00514
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"frequence")))
00515 Niveau.
m_fBonusArmeFrequence = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00516 }
00517
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00518 }
00519
00520
00521 xmlNode* pChild = pNode->children;
00522
if (pChild)
00523 {
00524
do
00525 {
00526
if (pChild->type == XML_ELEMENT_NODE)
00527
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-arme")))
00528 Niveau.
m_TypeBonusArme.push_back (GetTypeBonusArmeParIndex (IndexAttribute (pChild)));
00529 }
00530
while ((pChild = pChild->next) != 0);
00531 }
00532 }
00533
00534
00535
void CXMLNiveau::IndexBoucliers (xmlNode* pNode,
SNiveau & Niveau)
00536 {
00537
00538 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00539
if (pAttribute)
00540 {
00541
do
00542 {
00543
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00544
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"frequence")))
00545 Niveau.
m_fBonusBouclierFrequence = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00546 }
00547
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00548 }
00549
00550
00551 xmlNode* pChild = pNode->children;
00552
if (pChild)
00553 {
00554
do
00555 {
00556
if (pChild->type == XML_ELEMENT_NODE)
00557
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-bouclier")))
00558 Niveau.
m_TypeBonusBouclier.push_back (GetTypeBonusBouclierParIndex (IndexAttribute (pChild)));
00559 }
00560
while ((pChild = pChild->next) != 0);
00561 }
00562 }
00563
00564
00565
void CXMLNiveau::IndexEnnemis (xmlNode* pNode,
SNiveau & Niveau)
00566 {
00567
00568 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00569
if (pAttribute)
00570 {
00571
do
00572 {
00573
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00574 {
00575
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"nombre")))
00576 Niveau.
m_uiEnnemiNombre = atoi ((
const char*) xmlGetProp (pNode, pAttribute->name));
00577
else if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"frequence")))
00578 Niveau.
m_fEnnemiFrequence = (
float) atof ((
const char*) xmlGetProp (pNode, pAttribute->name));
00579 }
00580 }
00581
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00582 }
00583
00584
00585 xmlNode* pChild = pNode->children;
00586
if (pChild)
00587 {
00588
do
00589 {
00590
if (pChild->type == XML_ELEMENT_NODE)
00591
if ((!xmlStrcmp (pChild->name, (
const xmlChar *)
"index-ennemi")))
00592 Niveau.
m_TypeEnnemi.push_back (GetTypeEnnemiParIndex (IndexAttribute (pChild)));
00593 }
00594
while ((pChild = pChild->next) != 0);
00595 }
00596 }
00597
00598
00599
int CXMLNiveau::IndexAttribute (xmlNode* pNode)
00600 {
00601
00602 xmlAttribute* pAttribute = ((xmlElement*) pNode)->attributes;
00603
if (pAttribute)
00604 {
00605
do
00606 {
00607
if (pAttribute->type == XML_ATTRIBUTE_NODE)
00608
if ((!xmlStrcmp (pAttribute->name, (
const xmlChar *)
"index")))
00609
return atoi ((
const char*) xmlGetProp (pNode, pAttribute->name));
00610 }
00611
while ((pAttribute = (xmlAttribute*) pAttribute->next) != 0);
00612 }
00613
return -1;
00614 }
00615
00616
00617
unsigned int CXMLNiveau::CompterChildren (xmlNode* pNode)
00618 {
00619
unsigned int uiNombreChildren = 0;
00620
00621
00622 xmlNode* pChild = pNode->children;
00623
if (pChild)
00624 {
00625
do
00626 {
00627
if (pChild->type == XML_ELEMENT_NODE)
00628 uiNombreChildren++;
00629 }
00630
while ((pChild = pChild->next) != 0);
00631 }
00632
return uiNombreChildren;
00633 }
00634
00635
00636 CTypeBonusArme* CXMLNiveau::GetTypeBonusArmeParIndex (
unsigned int uiIndex)
const
00637
{
00638
return m_TypeBonusArme.find (uiIndex)->second;
00639 }
00640
00641
00642 CTypeBonusBouclier* CXMLNiveau::GetTypeBonusBouclierParIndex (
unsigned int uiIndex)
const
00643
{
00644
return m_TypeBonusBouclier.find (uiIndex)->second;
00645 }
00646
00647
00648 CTypeEnnemi* CXMLNiveau::GetTypeEnnemiParIndex (
unsigned int uiIndex)
const
00649
{
00650
return m_TypeEnnemi.find (uiIndex)->second;
00651 }