Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8691 was 8362, checked in by bensch, 18 years ago

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

File size: 2.0 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#include "debug.h"
25
26
27using namespace std;
28
29
30/**
31 * constructor
32 */
33GameRules::GameRules(const TiXmlElement* root)
34{
35  this->setClassID(CL_GAME_RULES, "GameRules");
36}
37
38/**
39 * decontsructor
40 */
41GameRules::~GameRules()
42{}
43
44
45
46void GameRules::loadParams(const TiXmlElement* root)
47{
48  BaseObject::loadParams(root);
49
50  PRINTF(0)("GameRules::loadParams(...) hit me\n");
51  LoadParamXML(root, "MissionGoal", this, GameRules, loadMissionGoal)
52      .describe("an XML-Element to load the missions from");
53}
54
55
56
57void GameRules::loadMissionGoal(const TiXmlElement* root)
58{
59  PRINTF(0)("Trying to load MissionGoals\n");
60  const TiXmlElement* element = root->FirstChildElement();
61  while( element != NULL)
62  {
63    PRINTF(4)("============ MissionGoal\n");
64    PRINTF(4)("Adding Mission Goal:%s\n", element->Value());
65    BaseObject* created = Factory::fabricate(element);
66    if (created != NULL /*&& created->isA(CL_GAME_RULES)*/)
67    {
68      MissionGoal* mg = dynamic_cast<MissionGoal*>(created);
69      this->addMissionGoal(mg);
70      // if there is a valid game rule loaded, break because it is not thought to load multiple game rules
71      break;
72    }
73    else
74    {
75      PRINTF(1)("Could not create a %s\n", element->Value());
76      delete created;
77    }
78    element = element->NextSiblingElement();
79  }
80}
81
82/**
83 * adding a kill event to the kill list
84 * @param kill the kill object containing all infos
85 */
86void GameRules::registerKill(const Kill& kill)
87{
88  PRINTF(0)("Received Event: Kill\n");
89  this->killList.push_back(kill);
90}
91
Note: See TracBrowser for help on using the repository browser.