Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/powerups/src/world_entities/power_ups/weapon_power_up.cc @ 5986

Last change on this file since 5986 was 5986, checked in by manuel, 18 years ago

2 bugs resolved

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: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "weapon_power_up.h"
19#include "factory.h"
20#include "state.h"
21#include "list.h"
22
23#include "primitive_model.h"
24
25#include "factory.h"
26#include "load_param.h"
27
28using namespace std;
29
30CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP);
31
32WeaponPowerUp::WeaponPowerUp ()
33{
34  this->init();
35}
36
37WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root)
38{
39  this->init();
40  this->loadParams(root);
41}
42
43
44WeaponPowerUp::~WeaponPowerUp ()
45{
46}
47
48
49void WeaponPowerUp::init()
50{
51}
52
53
54void WeaponPowerUp::loadParams(const TiXmlElement* root)
55{
56  static_cast<PowerUp*>(this)->loadParams(root);
57  const TiXmlElement* elem = root->FirstChildElement("weapon");
58  if(elem != NULL && (elem = elem->getFirstChildElement()) != NULL)
59  {
60    this->weaponXML = elem;
61    createWeapon();
62  }
63  else
64  {
65    LoadParam(root, "weaponID", this, WeaponPowerUp, setWeaponClass);
66  }
67}
68
69Weapon* WeaponPowerUp::getWeapon()
70{
71  return this->weapon;
72}
73
74void WeaponPowerUp::createWeapon()
75{
76  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
77      ? Factory::getFirst()->fabricate(static_cast<ClassID>(this->weapon->getClassID()))
78      : Factory::getFirst()->fabricate(weaponXML));
79}
80
81void WeaponPowerUp::setWeaponClass(const char* name)
82{
83  this->weapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(name, name));
84}
Note: See TracBrowser for help on using the repository browser.