[9972] | 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 | |
---|
[9998] | 50 | this->setStateDuration(WS_SHOOTING, 0.05); // 20 Schuss pro Sekunde |
---|
[9972] | 51 | this->setStateDuration(WS_RELOADING, 0); |
---|
| 52 | this->setStateDuration(WS_ACTIVATING, .5); |
---|
| 53 | this->setStateDuration(WS_DEACTIVATING, 1); |
---|
| 54 | |
---|
[9998] | 55 | this->setEnergyMax(500); |
---|
| 56 | this->increaseEnergy(500); |
---|
[9972] | 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); |
---|
[9978] | 64 | //this->setProjectileTypeC("RailProjectile"); // FIXME temp project type until the blaste class exist |
---|
[10044] | 65 | this->setProjectileTypeC("LBolt"); // Working; FIXME: add textures |
---|
[9972] | 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 | |
---|
[9975] | 90 | // set the owner |
---|
| 91 | pj->setOwner(this->getOwner()); |
---|
| 92 | |
---|
[9972] | 93 | pj->setParent(PNode::getNullParent()); |
---|
| 94 | |
---|
[10044] | 95 | // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); |
---|
[10046] | 96 | pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*180); |
---|
[9972] | 97 | |
---|
| 98 | pj->setAbsCoor(this->getEmissionPoint()); |
---|
| 99 | pj->setAbsDir(this->getAbsDir()); |
---|
[10109] | 100 | pj->toList(OM_GROUP_01_PROJ); |
---|
[9972] | 101 | pj->activate(); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * this activates the weapon |
---|
| 106 | */ |
---|
| 107 | void LightBlaster::activate() |
---|
| 108 | { |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | /** |
---|
| 112 | * this deactivates the weapon |
---|
| 113 | */ |
---|
| 114 | void LightBlaster::deactivate() |
---|
| 115 | { |
---|
[9975] | 116 | } |
---|
| 117 | |
---|
| 118 | void LightBlaster::draw() const |
---|
| 119 | { |
---|
| 120 | } |
---|