Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the christmas branche to the trunk
merged with command:
svn merge -r6165:HEAD christmas_branche/ ../trunk/
no conflicts

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