| 1 | #include "light_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(LightBlaster); |
|---|
| 14 | /** |
|---|
| 15 | * Standard constructor |
|---|
| 16 | */ |
|---|
| 17 | LightBlaster::LightBlaster () |
|---|
| 18 | : Weapon() |
|---|
| 19 | { |
|---|
| 20 | this->init(); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | LightBlaster::LightBlaster (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 | LightBlaster::~LightBlaster() |
|---|
| 35 | { |
|---|
| 36 | // model will be deleted from WorldEntity-destructor |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | void LightBlaster::loadParams(const TiXmlElement* root) |
|---|
| 40 | { |
|---|
| 41 | Weapon::loadParams(root); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | void LightBlaster::init() |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | this->loadModel("models/guns/plasmadriver_#.obj", 1.0); |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | this->setStateDuration(WS_SHOOTING, 0.05); // 20 Schuss pro Sekunde |
|---|
| 51 | this->setStateDuration(WS_RELOADING, 0); |
|---|
| 52 | this->setStateDuration(WS_ACTIVATING, .5); |
|---|
| 53 | this->setStateDuration(WS_DEACTIVATING, 1); |
|---|
| 54 | |
|---|
| 55 | this->setEnergyMax(500); |
|---|
| 56 | this->increaseEnergy(500); |
|---|
| 57 | //this->minCharge = 2; |
|---|
| 58 | |
|---|
| 59 | this->setActionSound(WA_SHOOT, "sound/laser.wav"); |
|---|
| 60 | this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav"); |
|---|
| 61 | this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav"); |
|---|
| 62 | |
|---|
| 63 | this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); |
|---|
| 64 | //this->setProjectileTypeC("RailProjectile"); // FIXME temp project type until the blaste class exist |
|---|
| 65 | this->setProjectileTypeC("Bolt"); // Working; FIXME: add textures |
|---|
| 66 | this->prepareProjectiles(100); |
|---|
| 67 | |
|---|
| 68 | Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); |
|---|
| 69 | Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); |
|---|
| 70 | |
|---|
| 71 | animation2->setInfinity(ANIM_INF_CONSTANT); |
|---|
| 72 | animation3->setInfinity(ANIM_INF_CONSTANT); |
|---|
| 73 | |
|---|
| 74 | this->setEmissionPoint(3.8, 1.2, 0); |
|---|
| 75 | |
|---|
| 76 | animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
|---|
| 77 | animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
|---|
| 78 | |
|---|
| 79 | animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
|---|
| 80 | animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | void LightBlaster::fire() |
|---|
| 85 | { |
|---|
| 86 | Projectile* pj = this->getProjectile(); |
|---|
| 87 | if (pj == NULL) |
|---|
| 88 | return; |
|---|
| 89 | |
|---|
| 90 | // set the owner |
|---|
| 91 | pj->setOwner(this->getOwner()); |
|---|
| 92 | |
|---|
| 93 | pj->setParent(PNode::getNullParent()); |
|---|
| 94 | |
|---|
| 95 | pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); |
|---|
| 96 | |
|---|
| 97 | pj->setAbsCoor(this->getEmissionPoint()); |
|---|
| 98 | pj->setAbsDir(this->getAbsDir()); |
|---|
| 99 | pj->activate(); |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | /** |
|---|
| 103 | * this activates the weapon |
|---|
| 104 | */ |
|---|
| 105 | void LightBlaster::activate() |
|---|
| 106 | { |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | /** |
|---|
| 110 | * this deactivates the weapon |
|---|
| 111 | */ |
|---|
| 112 | void LightBlaster::deactivate() |
|---|
| 113 | { |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | void LightBlaster::draw() const |
|---|
| 117 | { |
|---|
| 118 | } |
|---|