[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); |
---|
[10758] | 44 | this->setDamage(2); |
---|
[10649] | 45 | this->lifeSpan = 2.0; |
---|
[10646] | 46 | this->grid = new Billboard(); |
---|
| 47 | this->grid->setSize(.2, .2); |
---|
| 48 | this->grid->setPulseMagnitude(.8); |
---|
| 49 | this->grid->setParent(this); |
---|
| 50 | this->grid->setVisibility(false); |
---|
| 51 | this->grid->setPulse(); |
---|
| 52 | this->grid->setTexture( "textures/plasma.png"); |
---|
[10659] | 53 | /* |
---|
| 54 | this->blink = new Blink(); |
---|
| 55 | this->grid->setParent(this); |
---|
| 56 | this->grid->setVisibility(false); |
---|
| 57 | this->blink->setSize(1.0 ); |
---|
| 58 | this->blink->setPeriod(.4); |
---|
| 59 | this->blink->setColor(10, 250, 150); |
---|
| 60 | this->blink->loadBlinkSequence( "66678998766" ); |
---|
| 61 | this->blink->toList(OM_ENVIRON);*/ |
---|
[10740] | 62 | |
---|
| 63 | this->obbTree = new OBBTree(); |
---|
| 64 | this->obbTree->createBox(Vector(0.0f, 0.0f, 0.0f), Vector(1.0f, 1.0f, 1.0f)); |
---|
| 65 | this->setOBBTree(this->obbTree); |
---|
[10646] | 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * standard deconstructor |
---|
| 71 | * |
---|
| 72 | */ |
---|
| 73 | PlasmaPulse::~PlasmaPulse () |
---|
| 74 | { |
---|
| 75 | this->grid->toList(OM_DEAD); |
---|
[10659] | 76 | // this->blink->toList(OM_DEAD); |
---|
[10646] | 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | void PlasmaPulse::activate() |
---|
| 81 | { |
---|
[10747] | 82 | // this->origList = this->getOMListNumber(); |
---|
[10646] | 83 | this->grid->setVisibility(true); |
---|
[10659] | 84 | // this->blink->setVisibility(true); |
---|
[10646] | 85 | |
---|
| 86 | this->setPhysDamage(10); |
---|
| 87 | this->setElecDamage(0); |
---|
| 88 | this->setHealth(0); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | void PlasmaPulse::deactivate() |
---|
| 93 | { |
---|
| 94 | this->lifeCycle = 0.0; |
---|
| 95 | |
---|
| 96 | this->grid->setVisibility(false); |
---|
[10659] | 97 | // this->blink->setVisibility(false); |
---|
[10646] | 98 | this->lifeCycle = 0.0; |
---|
| 99 | this->toList(OM_NULL); |
---|
[10649] | 100 | // this->removeNode(); |
---|
[10646] | 101 | |
---|
| 102 | PlasmaPulse::fastFactory->kill(this); |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | /** |
---|
| 106 | * signal tick, time dependent things will be handled here |
---|
| 107 | * @param dt time since last tick |
---|
| 108 | */ |
---|
| 109 | void PlasmaPulse::tick (float dt) |
---|
| 110 | { |
---|
| 111 | Vector v = this->velocity * dt; |
---|
| 112 | this->shiftCoor(v); |
---|
| 113 | |
---|
| 114 | if (this->tickLifeCycle(dt)) |
---|
| 115 | this->deactivate(); |
---|
| 116 | |
---|
| 117 | this->grid->tick(dt); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | /** |
---|
| 121 | * the function gets called, when the projectile is destroyed |
---|
| 122 | */ |
---|
| 123 | void PlasmaPulse::destroy (WorldEntity* killer) |
---|
| 124 | { |
---|
| 125 | this->deactivate(); |
---|
| 126 | Projectile::destroy( killer ); |
---|
| 127 | PRINTF(5)("DESTROY PlasmaPulse\n"); |
---|
| 128 | this->lifeCycle = .95; //!< @todo calculate this usefully. |
---|
| 129 | } |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | void PlasmaPulse::draw () const |
---|
| 133 | { |
---|
[10648] | 134 | glPushMatrix(); |
---|
[10746] | 135 | glPushAttrib(GL_ENABLE_BIT); |
---|
[10763] | 136 | // glEnable( GL_ALPHA_TEST); |
---|
| 137 | // glAlphaFunc( GL_GEQUAL, .5); |
---|
[10648] | 138 | this->grid->draw(); |
---|
[10659] | 139 | // this->blink->draw(); |
---|
[10746] | 140 | glPopAttrib(); |
---|
[10648] | 141 | glPopMatrix(); |
---|
| 142 | |
---|
[10646] | 143 | } |
---|