Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/util/game_rules.cc @ 9365

Last change on this file since 9365 was 9357, checked in by bensch, 18 years ago

orxonox/proxy: removed 'using namespace std;' everywhere

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