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