[10179] | 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 |
---|
| 12 | main-programmer: Marc Schaerrer |
---|
| 13 | co-programmer: Benjamin Grauer |
---|
| 14 | |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
---|
| 19 | |
---|
| 20 | #include "acid_splash.h" |
---|
| 21 | |
---|
| 22 | #include "state.h" |
---|
| 23 | |
---|
| 24 | //#include "space_ships/space_ship.h" |
---|
| 25 | |
---|
| 26 | #include <cassert> |
---|
| 27 | #include "debug.h" |
---|
| 28 | |
---|
| 29 | //#include "static_model.h" |
---|
| 30 | |
---|
| 31 | #include "effects/wobblegrid.h" |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | #include "class_id_DEPRECATED.h" |
---|
| 35 | ObjectListDefinition(AcidSplash); |
---|
| 36 | CREATE_FAST_FACTORY_STATIC(AcidSplash); |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * standard constructor |
---|
| 40 | */ |
---|
| 41 | AcidSplash::AcidSplash () : Projectile() |
---|
| 42 | { |
---|
| 43 | this->registerObject(this, AcidSplash::_objectList); |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | //this->loadModel("models/projectiles/laser.obj"); |
---|
| 47 | |
---|
| 48 | this->setMinEnergy(1); |
---|
| 49 | this->setHealthMax(0); |
---|
| 50 | this->lifeSpan = 3.0; |
---|
| 51 | this->angle = 0; |
---|
| 52 | |
---|
| 53 | this->grid = new Wobblegrid( 5); |
---|
| 54 | this->grid->setTexture( "maps/acid3.png"); |
---|
| 55 | this->grid->setParent( this); |
---|
| 56 | |
---|
| 57 | this->grid->toList(this->getOMListNumber()); |
---|
| 58 | this->toList(OM_ENVIRON); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | /** |
---|
| 63 | * standard deconstructor |
---|
| 64 | * |
---|
| 65 | */ |
---|
| 66 | AcidSplash::~AcidSplash () |
---|
| 67 | { |
---|
| 68 | // delete this->emitter; |
---|
| 69 | //delete this->grid; |
---|
| 70 | |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | void AcidSplash::activate() |
---|
| 75 | { |
---|
| 76 | this->unhide(); |
---|
| 77 | this->grid->setVisibiliy(true); |
---|
| 78 | |
---|
| 79 | this->setPhysDamage(10); |
---|
| 80 | this->setElecDamage(0); |
---|
| 81 | this->setHealth(0); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | |
---|
| 85 | void AcidSplash::deactivate() |
---|
| 86 | { |
---|
| 87 | this->lifeCycle = 0.0; |
---|
| 88 | |
---|
| 89 | this->hide(); |
---|
| 90 | this->grid->setVisibiliy(false); |
---|
| 91 | this->toList(OM_DEAD); |
---|
| 92 | this->removeNode(); |
---|
| 93 | |
---|
| 94 | AcidSplash::fastFactory->kill(this); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | void AcidSplash::collidesWith(WorldEntity* entity, const Vector& location) |
---|
| 99 | { |
---|
| 100 | |
---|
| 101 | if (this->hitEntity != entity) |
---|
| 102 | this->destroy( entity ); |
---|
| 103 | this->hitEntity = entity; |
---|
| 104 | //dynamic_cast<SpaceShip*>(entity)->damage(this->getPhysDamage(),this->getElecDamage()); |
---|
| 105 | //this->destroy(this); |
---|
| 106 | this->deactivate(); |
---|
| 107 | |
---|
| 108 | return; |
---|
| 109 | |
---|
| 110 | //dynamic_cast<SpaceShip*>(entity)->damage( this->getPhysDamage(), this->getElecDamage()); |
---|
| 111 | //entity->destroy(this); |
---|
| 112 | //this->deactivate(); |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | /** |
---|
| 116 | * signal tick, time dependent things will be handled here |
---|
| 117 | * @param dt time since last tick |
---|
| 118 | */ |
---|
| 119 | void AcidSplash::tick (float dt) |
---|
| 120 | { |
---|
| 121 | //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); |
---|
| 122 | Vector v = this->velocity * dt; |
---|
| 123 | this->shiftCoor(v); |
---|
| 124 | |
---|
| 125 | if (this->tickLifeCycle(dt)) |
---|
| 126 | this->deactivate(); |
---|
| 127 | |
---|
| 128 | this->angle += this->rotationSpeed * dt; |
---|
| 129 | |
---|
| 130 | this->grid->tick(dt); |
---|
| 131 | |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | /** |
---|
| 135 | * the function gets called, when the projectile is destroyed |
---|
| 136 | */ |
---|
| 137 | void AcidSplash::destroy (WorldEntity* killer) |
---|
| 138 | { |
---|
| 139 | this->deactivate(); |
---|
| 140 | Projectile::destroy( killer ); |
---|
| 141 | PRINTF(5)("DESTROY AcidSplash\n"); |
---|
| 142 | this->lifeCycle = .95; //!< @todo calculate this usefully. |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | |
---|
| 146 | void AcidSplash::draw () const |
---|
| 147 | { |
---|
| 148 | this->grid->draw(); |
---|
| 149 | } |
---|