[10646] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004-2006 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific |
---|
[10747] | 12 | main-programmer: Nicolas Schlumberger |
---|
| 13 | co-programmer: |
---|
[10646] | 14 | |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
---|
| 19 | |
---|
| 20 | #include "plasma_pulse.h" |
---|
| 21 | |
---|
| 22 | #include "state.h" |
---|
[10737] | 23 | #include "world_entities/npcs/actionbox_enemy.h" |
---|
[10646] | 24 | |
---|
| 25 | #include <cassert> |
---|
| 26 | #include "debug.h" |
---|
| 27 | |
---|
[10740] | 28 | #include "obb_tree.h" |
---|
[10646] | 29 | |
---|
[10740] | 30 | |
---|
[10646] | 31 | ObjectListDefinition(PlasmaPulse); |
---|
| 32 | CREATE_FAST_FACTORY_STATIC(PlasmaPulse); |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * standard constructor |
---|
| 36 | */ |
---|
| 37 | PlasmaPulse::PlasmaPulse () : Projectile() |
---|
| 38 | { |
---|
| 39 | this->registerObject(this, PlasmaPulse::_objectList); |
---|
| 40 | |
---|
| 41 | |
---|
[10747] | 42 | this->setMinEnergy(2); |
---|
[10646] | 43 | this->setHealthMax(0); |
---|
[10649] | 44 | this->lifeSpan = 2.0; |
---|
[10646] | 45 | this->grid = new Billboard(); |
---|
| 46 | this->grid->setSize(.2, .2); |
---|
| 47 | this->grid->setPulseMagnitude(.8); |
---|
| 48 | this->grid->setParent(this); |
---|
| 49 | this->grid->setVisibility(false); |
---|
| 50 | this->grid->setPulse(); |
---|
| 51 | this->grid->setTexture( "textures/plasma.png"); |
---|
[10659] | 52 | /* |
---|
| 53 | this->blink = new Blink(); |
---|
| 54 | this->grid->setParent(this); |
---|
| 55 | this->grid->setVisibility(false); |
---|
| 56 | this->blink->setSize(1.0 ); |
---|
| 57 | this->blink->setPeriod(.4); |
---|
| 58 | this->blink->setColor(10, 250, 150); |
---|
| 59 | this->blink->loadBlinkSequence( "66678998766" ); |
---|
| 60 | this->blink->toList(OM_ENVIRON);*/ |
---|
[10740] | 61 | |
---|
| 62 | this->obbTree = new OBBTree(); |
---|
| 63 | this->obbTree->createBox(Vector(0.0f, 0.0f, 0.0f), Vector(1.0f, 1.0f, 1.0f)); |
---|
| 64 | this->setOBBTree(this->obbTree); |
---|
[10646] | 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * standard deconstructor |
---|
| 70 | * |
---|
| 71 | */ |
---|
| 72 | PlasmaPulse::~PlasmaPulse () |
---|
| 73 | { |
---|
| 74 | this->grid->toList(OM_DEAD); |
---|
[10659] | 75 | // this->blink->toList(OM_DEAD); |
---|
[10646] | 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | void PlasmaPulse::activate() |
---|
| 80 | { |
---|
[10747] | 81 | // this->origList = this->getOMListNumber(); |
---|
[10646] | 82 | this->grid->setVisibility(true); |
---|
[10659] | 83 | // this->blink->setVisibility(true); |
---|
[10646] | 84 | |
---|
| 85 | this->setPhysDamage(10); |
---|
| 86 | this->setElecDamage(0); |
---|
| 87 | this->setHealth(0); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | void PlasmaPulse::deactivate() |
---|
| 92 | { |
---|
| 93 | this->lifeCycle = 0.0; |
---|
| 94 | |
---|
| 95 | this->grid->setVisibility(false); |
---|
[10659] | 96 | // this->blink->setVisibility(false); |
---|
[10646] | 97 | this->lifeCycle = 0.0; |
---|
| 98 | this->toList(OM_NULL); |
---|
[10649] | 99 | // this->removeNode(); |
---|
[10646] | 100 | |
---|
| 101 | PlasmaPulse::fastFactory->kill(this); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * signal tick, time dependent things will be handled here |
---|
| 106 | * @param dt time since last tick |
---|
| 107 | */ |
---|
| 108 | void PlasmaPulse::tick (float dt) |
---|
| 109 | { |
---|
| 110 | Vector v = this->velocity * dt; |
---|
| 111 | this->shiftCoor(v); |
---|
| 112 | |
---|
| 113 | if (this->tickLifeCycle(dt)) |
---|
| 114 | this->deactivate(); |
---|
| 115 | |
---|
| 116 | this->grid->tick(dt); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /** |
---|
| 120 | * the function gets called, when the projectile is destroyed |
---|
| 121 | */ |
---|
| 122 | void PlasmaPulse::destroy (WorldEntity* killer) |
---|
| 123 | { |
---|
| 124 | this->deactivate(); |
---|
| 125 | Projectile::destroy( killer ); |
---|
| 126 | PRINTF(5)("DESTROY PlasmaPulse\n"); |
---|
| 127 | this->lifeCycle = .95; //!< @todo calculate this usefully. |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | void PlasmaPulse::draw () const |
---|
| 132 | { |
---|
[10648] | 133 | glPushMatrix(); |
---|
[10746] | 134 | glPushAttrib(GL_ENABLE_BIT); |
---|
[10648] | 135 | glEnable( GL_ALPHA_TEST); |
---|
| 136 | glAlphaFunc( GL_GEQUAL, .5); |
---|
| 137 | this->grid->draw(); |
---|
[10659] | 138 | // this->blink->draw(); |
---|
[10746] | 139 | glPopAttrib(); |
---|
[10648] | 140 | glPopMatrix(); |
---|
| 141 | |
---|
[10646] | 142 | } |
---|