Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/power_ups/weapon_power_up.cc @ 6243

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

orxonox/trunk: merged the power-ups to the tunk again

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 () : PowerUp(1.0, 1.0, 0.0)
33{
34  this->init();
35}
36
37WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0)
38{
39  this->init();
40  this->loadParams(root);
41}
42
43
44WeaponPowerUp::~WeaponPowerUp ()
45{
46}
47
48
49void WeaponPowerUp::init()
50{
51  weaponXML = NULL;
52  weapon = NULL;
53}
54
55
56void WeaponPowerUp::loadParams(const TiXmlElement* root)
57{
58  static_cast<PowerUp*>(this)->loadParams(root);
59  const TiXmlElement* elem = root->FirstChildElement("weapon");
60  if(elem != NULL && (elem = elem->FirstChildElement()) != NULL)
61  {
62    this->weaponXML = elem;
63    respawn();
64  }
65  else
66  {
67    LoadParam(root, "weaponID", this, WeaponPowerUp, setWeaponClass);
68  }
69}
70
71Weapon* WeaponPowerUp::getWeapon()
72{
73  return this->weapon;
74}
75
76void WeaponPowerUp::respawn()
77{
78  this->weapon = dynamic_cast<Weapon*>((weaponXML == NULL)
79      ? Factory::fabricate(static_cast<ClassID>(this->weapon->getClassID()))
80      : Factory::fabricate(weaponXML));
81}
82
83void WeaponPowerUp::setWeaponClass(const char* name)
84{
85  this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name));
86}
Note: See TracBrowser for help on using the repository browser.