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 | |
---|
28 | using namespace std; |
---|
29 | |
---|
30 | CREATE_FACTORY(WeaponPowerUp, CL_WEAPON_POWER_UP); |
---|
31 | |
---|
32 | WeaponPowerUp::WeaponPowerUp () |
---|
33 | { |
---|
34 | this->init(); |
---|
35 | } |
---|
36 | |
---|
37 | WeaponPowerUp::WeaponPowerUp(const TiXmlElement* root) |
---|
38 | { |
---|
39 | this->init(); |
---|
40 | this->loadParams(root); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | WeaponPowerUp::~WeaponPowerUp () |
---|
45 | { |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | void WeaponPowerUp::init() |
---|
50 | { |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | void 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 | |
---|
69 | Weapon* WeaponPowerUp::getWeapon() |
---|
70 | { |
---|
71 | return this->weapon; |
---|
72 | } |
---|
73 | |
---|
74 | void 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 | |
---|
81 | void WeaponPowerUp::setWeaponClass(const char* name) |
---|
82 | { |
---|
83 | this->weapon = dynamic_cast<Weapon*>(Factory::getFirst()->fabricate(name, name)); |
---|
84 | } |
---|