Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/game_rules.cc @ 7461

Last change on this file since 7461 was 7461, checked in by patrick, 18 years ago

orxonox: the mission goal framework is nearly completed

File size: 1.7 KB
RevLine 
[7017]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
[7020]15#define DEBUG_MODULE_GAME_RULES
[7017]16
17#include "game_rules.h"
18
[7193]19#include "util/loading/load_param.h"
[7461]20#include "util/loading/factory.h"
[7017]21
[7461]22#include "util/mission_goal.h"
[7020]23
[7461]24
25
[7017]26using namespace std;
27
28
[7020]29/**
30 * constructor
31 */
[7035]32GameRules::GameRules(const TiXmlElement* root)
33{
34  this->setClassID(CL_GAME_RULES, "GameRules");
35}
[7017]36
[7020]37/**
38 * decontsructor
39 */
[7017]40GameRules::~GameRules()
41{}
[7020]42
43
44
45void GameRules::loadParams(const TiXmlElement* root)
[7035]46{
47  BaseObject::loadParams(root);
[7461]48
49  LoadParamXML(root, "MissionGoal", this, GameRules, loadMissionGoal)
50      .describe("an XML-Element to load the missions from");
[7035]51}
[7020]52
[7461]53
54
55void GameRules::loadMissionGoal(const TiXmlElement* root)
56{
57  const TiXmlElement* element = root->FirstChildElement();
58  while( element != NULL)
59  {
60    PRINTF(2)("============ MissionGoal\n");
61    PRINTF(2)("Adding Mission Goal:%s\n", element->Value());
62    BaseObject* created = Factory::fabricate(element);
63    if (created != NULL && created->isA(CL_GAME_RULES))
64    {
65      MissionGoal* mg = dynamic_cast<MissionGoal*>(created);
66      this->addMissionGoal(mg);
67      // if there is a valid game rule loaded, break because it is not thought to load multiple game rules
68      break;
69    }
70    else
71    {
72      PRINTF(1)("Could not create a %s\n", element->Value());
73      delete created;
74    }
75    element = element->NextSiblingElement();
76  }
77}
78
Note: See TracBrowser for help on using the repository browser.