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
Line 
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
15#define DEBUG_MODULE_GAME_RULES
16
17#include "game_rules.h"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
21
22#include "util/mission_goal.h"
23
24
25
26using namespace std;
27
28
29/**
30 * constructor
31 */
32GameRules::GameRules(const TiXmlElement* root)
33{
34  this->setClassID(CL_GAME_RULES, "GameRules");
35}
36
37/**
38 * decontsructor
39 */
40GameRules::~GameRules()
41{}
42
43
44
45void GameRules::loadParams(const TiXmlElement* root)
46{
47  BaseObject::loadParams(root);
48
49  LoadParamXML(root, "MissionGoal", this, GameRules, loadMissionGoal)
50      .describe("an XML-Element to load the missions from");
51}
52
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.