[6113] | 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" |
---|
[6233] | 21 | #include "list.h" |
---|
[6113] | 22 | |
---|
| 23 | #include "primitive_model.h" |
---|
| 24 | |
---|
| 25 | #include "factory.h" |
---|
| 26 | #include "load_param.h" |
---|
| 27 | |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP); |
---|
| 31 | |
---|
| 32 | WeaponPowerUp::WeaponPowerUp () : PowerUp(1.0, 1.0, 0.0) |
---|
| 33 | { |
---|
| 34 | this->init(); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) : PowerUp(1.0, 1.0, 0.0) |
---|
| 38 | { |
---|
| 39 | this->init(); |
---|
| 40 | this->loadParams(root); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | WeaponPowerUp::~WeaponPowerUp () |
---|
| 45 | { |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | void WeaponPowerUp::init() |
---|
| 50 | { |
---|
| 51 | weaponXML = NULL; |
---|
| 52 | weapon = NULL; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | void 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 | |
---|
| 71 | Weapon* WeaponPowerUp::getWeapon() |
---|
| 72 | { |
---|
| 73 | return this->weapon; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void 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 | |
---|
| 83 | void WeaponPowerUp::setWeaponClass(const char* name) |
---|
| 84 | { |
---|
| 85 | this->weapon = dynamic_cast<Weapon*>(Factory::fabricate(name)); |
---|
| 86 | } |
---|