Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/util/game_rules.cc @ 10651

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

merged network back to trunk

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