1 | #include "medium_blaster.h" |
---|
2 | #include "world_entities/projectiles/projectile.h" |
---|
3 | |
---|
4 | #include "world_entity.h" |
---|
5 | #include "static_model.h" |
---|
6 | #include "weapon_manager.h" |
---|
7 | #include "util/loading/factory.h" |
---|
8 | |
---|
9 | #include "animation3d.h" |
---|
10 | |
---|
11 | #include "loading/fast_factory.h" |
---|
12 | |
---|
13 | CREATE_FACTORY(MediumBlaster); |
---|
14 | /** |
---|
15 | * Standard constructor |
---|
16 | */ |
---|
17 | MediumBlaster::MediumBlaster () |
---|
18 | : Weapon() |
---|
19 | { |
---|
20 | this->init(); |
---|
21 | } |
---|
22 | |
---|
23 | MediumBlaster::MediumBlaster (const TiXmlElement* root = NULL) |
---|
24 | : Weapon() |
---|
25 | { |
---|
26 | this->init(); |
---|
27 | if (root != NULL) |
---|
28 | this->loadParams(root); |
---|
29 | } |
---|
30 | |
---|
31 | /** |
---|
32 | * Default destructor |
---|
33 | */ |
---|
34 | MediumBlaster::~MediumBlaster() |
---|
35 | { |
---|
36 | // model will be deleted from WorldEntity-destructor |
---|
37 | } |
---|
38 | |
---|
39 | void MediumBlaster::loadParams(const TiXmlElement* root) |
---|
40 | { |
---|
41 | Weapon::loadParams(root); |
---|
42 | } |
---|
43 | |
---|
44 | void MediumBlaster::init() |
---|
45 | { |
---|
46 | //this->registerObject(this, MediumBlaster::_objectList); |
---|
47 | |
---|
48 | // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); |
---|
49 | |
---|
50 | this->loadModel("models/guns/plasmadriver_#.obj", 1.0); |
---|
51 | |
---|
52 | |
---|
53 | this->setStateDuration(WS_SHOOTING, 0.2); // 5 Schuss pro Sekunde |
---|
54 | |
---|
55 | this->setStateDuration(WS_RELOADING, 0); |
---|
56 | this->setStateDuration(WS_ACTIVATING, .5); |
---|
57 | this->setStateDuration(WS_DEACTIVATING, 1); |
---|
58 | |
---|
59 | this->setEnergyMax(500); |
---|
60 | this->increaseEnergy(500); |
---|
61 | //this->minCharge = 2; |
---|
62 | |
---|
63 | this->setActionSound(WA_SHOOT, "sound/laser.wav"); |
---|
64 | this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav"); |
---|
65 | this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav"); |
---|
66 | |
---|
67 | this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); |
---|
68 | this->setProjectileTypeC("MBolt"); // FIXME temp project type until the blaste class exist |
---|
69 | this->prepareProjectiles(20); |
---|
70 | |
---|
71 | Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); |
---|
72 | Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); |
---|
73 | |
---|
74 | animation2->setInfinity(ANIM_INF_CONSTANT); |
---|
75 | animation3->setInfinity(ANIM_INF_CONSTANT); |
---|
76 | |
---|
77 | this->setEmissionPoint(3.8, 1.2, 0); |
---|
78 | |
---|
79 | animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
80 | animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
---|
81 | |
---|
82 | animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
---|
83 | animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | void MediumBlaster::fire() |
---|
88 | { |
---|
89 | Projectile* pj = this->getProjectile(); |
---|
90 | if (pj == NULL) |
---|
91 | return; |
---|
92 | |
---|
93 | // set the owner |
---|
94 | pj->setOwner(this->getOwner()); |
---|
95 | |
---|
96 | pj->setParent(PNode::getNullParent()); |
---|
97 | |
---|
98 | pj->setVelocity(this->getParent()->getVelocity() + this->getAbsDir().apply(Vector(1,0,0))*160); |
---|
99 | |
---|
100 | pj->setAbsCoor(this->getEmissionPoint()); |
---|
101 | pj->setAbsDir(this->getAbsDir()); |
---|
102 | pj->toList(OM_GROUP_01_PROJ); |
---|
103 | pj->activate(); |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * this activates the weapon |
---|
108 | */ |
---|
109 | void MediumBlaster::activate() |
---|
110 | { |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * this deactivates the weapon |
---|
115 | */ |
---|
116 | void MediumBlaster::deactivate() |
---|
117 | { |
---|
118 | } |
---|
119 | |
---|
120 | void MediumBlaster::draw() const |
---|
121 | { |
---|
122 | } |
---|