[9972] | 1 | #include "heavy_blaster.h" |
---|
[9975] | 2 | #include "world_entities/projectiles/projectile.h" |
---|
[9972] | 3 | |
---|
[9975] | 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(HeavyBlaster); |
---|
| 14 | /** |
---|
| 15 | * Standard constructor |
---|
| 16 | */ |
---|
| 17 | HeavyBlaster::HeavyBlaster () |
---|
| 18 | : Weapon() |
---|
| 19 | { |
---|
| 20 | this->init(); |
---|
| 21 | } |
---|
| 22 | |
---|
[9972] | 23 | HeavyBlaster::HeavyBlaster (const TiXmlElement* root = NULL) |
---|
| 24 | : Weapon() |
---|
[9975] | 25 | { |
---|
[9972] | 26 | this->init(); |
---|
| 27 | if (root != NULL) |
---|
| 28 | this->loadParams(root); |
---|
[9975] | 29 | } |
---|
[9972] | 30 | |
---|
| 31 | /** |
---|
| 32 | * Default destructor |
---|
| 33 | */ |
---|
| 34 | HeavyBlaster::~HeavyBlaster() |
---|
[9975] | 35 | { |
---|
[9972] | 36 | // model will be deleted from WorldEntity-destructor |
---|
[9975] | 37 | } |
---|
[9972] | 38 | |
---|
[9975] | 39 | void HeavyBlaster::loadParams(const TiXmlElement* root) |
---|
| 40 | { |
---|
| 41 | Weapon::loadParams(root); |
---|
| 42 | } |
---|
[9972] | 43 | |
---|
[9975] | 44 | void HeavyBlaster::init() |
---|
| 45 | { |
---|
| 46 | //this->registerObject(this, HeavyBlaster::_objectList); |
---|
| 47 | |
---|
| 48 | // this->model = (Model*)ResourceManager::getInstance()->load("models/guns/test_gun.obj", OBJ, RP_CAMPAIGN); |
---|
| 49 | |
---|
[10133] | 50 | this->loadModel("models/guns/fragcannon.obj", .4); |
---|
[9975] | 51 | |
---|
| 52 | |
---|
[9998] | 53 | this->setStateDuration(WS_SHOOTING, 0.5); // 2 Schuss pro Sekunde |
---|
[9975] | 54 | this->setStateDuration(WS_RELOADING, 0); |
---|
| 55 | this->setStateDuration(WS_ACTIVATING, .5); |
---|
| 56 | this->setStateDuration(WS_DEACTIVATING, 1); |
---|
| 57 | |
---|
[9998] | 58 | this->setEnergyMax(500); |
---|
| 59 | this->increaseEnergy(500); |
---|
[9975] | 60 | //this->minCharge = 2; |
---|
| 61 | |
---|
| 62 | this->setActionSound(WA_SHOOT, "sound/laser.wav"); |
---|
| 63 | this->setActionSound(WA_ACTIVATE, "sound/voices/lasers.wav"); |
---|
| 64 | this->setActionSound(WA_RELOAD, "sound/spawn/alien_generator.wav"); |
---|
| 65 | |
---|
| 66 | this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL | WTYPE_LIGHT); |
---|
[9979] | 67 | this->setProjectileTypeC("HBolt"); // FIXME temp project type until the blaste class exist |
---|
[9998] | 68 | this->prepareProjectiles(5); |
---|
[9975] | 69 | |
---|
[10136] | 70 | this->setBarrels(3); |
---|
| 71 | this->setSegs(2); |
---|
| 72 | |
---|
[10133] | 73 | this->objComp1 = new PNode; |
---|
| 74 | this->objComp2 = new PNode; |
---|
| 75 | this->objComp3 = new PNode; |
---|
| 76 | this->objComp4 = new PNode; |
---|
| 77 | this->objComp5 = new PNode; |
---|
| 78 | this->objComp6 = new PNode; |
---|
| 79 | |
---|
[10136] | 80 | Animation3D* animB0Shoot = this->getAnimation(WS_SHOOTING0, this->objComp1); |
---|
| 81 | // Animation3D* animB1Shoot = this->getAnimation(WS_SHOOTING1, this->objComp2); |
---|
| 82 | // Animation3D* animB2Shoot = this->getAnimation(WS_SHOOTING2, this->objComp3); |
---|
| 83 | // Animation3D* animT0Shoot = this->getAnimation(WS_SHOOTING3, this->objComp4); |
---|
| 84 | // Animation3D* animT1Shoot = this->getAnimation(WS_SHOOTING4, this->objComp5); |
---|
| 85 | // Animation3D* animT2Shoot = this->getAnimation(WS_SHOOTING5, this->objComp6); |
---|
[10133] | 86 | |
---|
| 87 | animB0Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
[10136] | 88 | // animB1Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
| 89 | // animB2Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
| 90 | // animT0Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
| 91 | // animT1Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
| 92 | // animT2Shoot->setInfinity(ANIM_INF_CONSTANT); |
---|
[10133] | 93 | |
---|
[10136] | 94 | animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 95 | animB0Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
| 96 | animB0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 97 | /* |
---|
| 98 | animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 99 | animT0Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
| 100 | animT0Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL);*/ |
---|
| 101 | /* |
---|
| 102 | animB1Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 103 | animB1Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
[10133] | 104 | animB1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); |
---|
| 105 | |
---|
[10136] | 106 | animT1Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 107 | animT1Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
[10133] | 108 | animT1Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); |
---|
| 109 | |
---|
[10136] | 110 | animB2Shoot->addKeyFrame(Vector(0.1, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 111 | animB2Shoot->addKeyFrame(Vector(-0.1, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
[10133] | 112 | animB2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL); |
---|
| 113 | |
---|
[10136] | 114 | animT2Shoot->addKeyFrame(Vector(0.04, 0.0, 0.0), Quaternion(), 0.1, ANIM_LINEAR, ANIM_NULL); |
---|
| 115 | animT2Shoot->addKeyFrame(Vector(-0.04, 0.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
| 116 | animT2Shoot->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.0, ANIM_LINEAR, ANIM_NULL);*/ |
---|
[10133] | 117 | |
---|
[9975] | 118 | Animation3D* animation2 = this->getAnimation(WS_ACTIVATING, this); |
---|
| 119 | Animation3D* animation3 = this->getAnimation(WS_DEACTIVATING, this); |
---|
| 120 | |
---|
| 121 | animation2->setInfinity(ANIM_INF_CONSTANT); |
---|
| 122 | animation3->setInfinity(ANIM_INF_CONSTANT); |
---|
| 123 | |
---|
| 124 | this->setEmissionPoint(3.8, 1.2, 0); |
---|
| 125 | |
---|
| 126 | animation2->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
| 127 | animation2->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
---|
| 128 | |
---|
| 129 | animation3->addKeyFrame(Vector(0.0, 0.0, 0.0), Quaternion(), 0.5, ANIM_LINEAR, ANIM_NULL); |
---|
| 130 | animation3->addKeyFrame(Vector(0.0, -1.0, 0.0), Quaternion(), 0.3, ANIM_LINEAR, ANIM_NULL); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | void HeavyBlaster::fire() |
---|
| 135 | { |
---|
| 136 | Projectile* pj = this->getProjectile(); |
---|
| 137 | if (pj == NULL) |
---|
| 138 | return; |
---|
| 139 | |
---|
| 140 | // set the owner |
---|
| 141 | pj->setOwner(this->getOwner()); |
---|
| 142 | |
---|
| 143 | pj->setParent(PNode::getNullParent()); |
---|
| 144 | |
---|
[10044] | 145 | // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*250 + VECTOR_RAND(5)); |
---|
[10046] | 146 | // pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); |
---|
[10044] | 147 | pj->setVelocity(this->getAbsDir().apply(Vector(1,0,0))*130 + VECTOR_RAND(1)); |
---|
[9975] | 148 | |
---|
| 149 | pj->setAbsCoor(this->getEmissionPoint()); |
---|
| 150 | pj->setAbsDir(this->getAbsDir()); |
---|
[10109] | 151 | pj->toList(OM_GROUP_01_PROJ); |
---|
[9975] | 152 | pj->activate(); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | /** |
---|
| 156 | * this activates the weapon |
---|
| 157 | */ |
---|
| 158 | void HeavyBlaster::activate() |
---|
| 159 | { |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | /** |
---|
| 163 | * this deactivates the weapon |
---|
| 164 | */ |
---|
| 165 | void HeavyBlaster::deactivate() |
---|
| 166 | { |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | void HeavyBlaster::draw() const |
---|
| 170 | { |
---|
[10133] | 171 | glMatrixMode(GL_MODELVIEW); |
---|
| 172 | glPushMatrix(); |
---|
| 173 | glTranslatef (this->getAbsCoor ().x, |
---|
| 174 | this->getAbsCoor ().y, |
---|
| 175 | this->getAbsCoor ().z); |
---|
| 176 | |
---|
| 177 | static_cast<StaticModel*>(this->getModel())->draw(6); |
---|
| 178 | |
---|
| 179 | glPushMatrix(); |
---|
[10136] | 180 | glTranslatef (this->objComp1->getAbsCoor().x, this->objComp1->getAbsCoor().y, this->objComp1->getAbsCoor().z); |
---|
| 181 | static_cast<StaticModel*>(this->getModel())->draw(1); |
---|
| 182 | static_cast<StaticModel*>(this->getModel())->draw(2); |
---|
| 183 | static_cast<StaticModel*>(this->getModel())->draw(0); |
---|
| 184 | |
---|
| 185 | glPushMatrix(); |
---|
| 186 | glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z); |
---|
| 187 | static_cast<StaticModel*>(this->getModel())->draw(4); |
---|
| 188 | static_cast<StaticModel*>(this->getModel())->draw(5); |
---|
| 189 | static_cast<StaticModel*>(this->getModel())->draw(3); |
---|
| 190 | glPopMatrix(); |
---|
[10133] | 191 | glPopMatrix(); |
---|
| 192 | /* |
---|
| 193 | glPushMatrix(); |
---|
| 194 | glTranslatef (this->objComp2->getAbsCoor().x, this->objComp2->getAbsCoor().y, this->objComp2->getAbsCoor().z); |
---|
| 195 | static_cast<StaticModel*>(this->getModel())->draw(2); |
---|
| 196 | glPopMatrix(); |
---|
| 197 | |
---|
| 198 | glPushMatrix(); |
---|
| 199 | glTranslatef (this->objComp3->getAbsCoor().x, this->objComp3->getAbsCoor().y, this->objComp3->getAbsCoor().z); |
---|
| 200 | static_cast<StaticModel*>(this->getModel())->draw(0); |
---|
| 201 | glPopMatrix();*/ |
---|
[10136] | 202 | |
---|
| 203 | // glPushMatrix(); |
---|
| 204 | // glTranslatef (this->objComp4->getAbsCoor().x, this->objComp4->getAbsCoor().y, this->objComp4->getAbsCoor().z); |
---|
| 205 | // static_cast<StaticModel*>(this->getModel())->draw(4); |
---|
| 206 | // static_cast<StaticModel*>(this->getModel())->draw(5); |
---|
| 207 | // static_cast<StaticModel*>(this->getModel())->draw(3); |
---|
| 208 | // glPopMatrix(); |
---|
[10133] | 209 | /* |
---|
| 210 | glPushMatrix(); |
---|
| 211 | glTranslatef (this->objComp5->getAbsCoor().x, this->objComp5->getAbsCoor().y, this->objComp5->getAbsCoor().z); |
---|
| 212 | static_cast<StaticModel*>(this->getModel())->draw(5); |
---|
| 213 | glPopMatrix(); |
---|
| 214 | |
---|
| 215 | glPushMatrix(); |
---|
| 216 | glTranslatef (this->objComp6->getAbsCoor().x, this->objComp6->getAbsCoor().y, this->objComp6->getAbsCoor().z); |
---|
| 217 | static_cast<StaticModel*>(this->getModel())->draw(3); |
---|
| 218 | glPopMatrix();*/ |
---|
| 219 | |
---|
| 220 | glPopMatrix(); |
---|
[9975] | 221 | } |
---|