[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 <cassert> |
---|
| 25 | #include "debug.h" |
---|
| 26 | |
---|
[10740] | 27 | #include "obb_tree.h" |
---|
| 28 | |
---|
[10179] | 29 | #include "effects/wobblegrid.h" |
---|
| 30 | |
---|
| 31 | |
---|
[10366] | 32 | |
---|
[10179] | 33 | ObjectListDefinition(AcidSplash); |
---|
| 34 | CREATE_FAST_FACTORY_STATIC(AcidSplash); |
---|
| 35 | |
---|
| 36 | /** |
---|
| 37 | * standard constructor |
---|
| 38 | */ |
---|
| 39 | AcidSplash::AcidSplash () : Projectile() |
---|
| 40 | { |
---|
| 41 | this->registerObject(this, AcidSplash::_objectList); |
---|
| 42 | |
---|
[10701] | 43 | // moved to baseObject |
---|
| 44 | // srand(time(0)); //initialize Random Nomber Generator |
---|
[10298] | 45 | |
---|
[10179] | 46 | this->setMinEnergy(1); |
---|
| 47 | this->setHealthMax(0); |
---|
| 48 | this->lifeSpan = 3.0; |
---|
| 49 | this->angle = 0; |
---|
| 50 | |
---|
| 51 | this->grid = new Wobblegrid( 5); |
---|
| 52 | this->grid->setParent( this); |
---|
[10511] | 53 | this->grid->setVisibility(false); |
---|
[10179] | 54 | |
---|
[10333] | 55 | |
---|
[10345] | 56 | int rnd = int(rand() % 3); |
---|
[10333] | 57 | |
---|
| 58 | switch (rnd){ |
---|
| 59 | case 0: |
---|
[10420] | 60 | this->grid->setTexture( "textures/acid2.png"); |
---|
[10333] | 61 | break; |
---|
| 62 | case 1: |
---|
[10420] | 63 | this->grid->setTexture( "textures/acid3.png"); |
---|
[10333] | 64 | break; |
---|
| 65 | case 2: |
---|
[10420] | 66 | this->grid->setTexture( "textures/blub.png"); |
---|
[10333] | 67 | break; |
---|
| 68 | default: |
---|
[10420] | 69 | this->grid->setTexture( "textures/acid2.png"); |
---|
[10333] | 70 | } |
---|
[10298] | 71 | |
---|
[10345] | 72 | this->grid->toList(OM_ENVIRON); |
---|
[10740] | 73 | |
---|
| 74 | this->obbTree = new OBBTree(); |
---|
| 75 | this->obbTree->createBox(Vector(0.0f, 0.0f, 0.0f), Vector(1.0f, 1.0f, 1.0f)); |
---|
| 76 | this->setOBBTree(this->obbTree); |
---|
[10179] | 77 | } |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * standard deconstructor |
---|
| 82 | * |
---|
| 83 | */ |
---|
| 84 | AcidSplash::~AcidSplash () |
---|
| 85 | { |
---|
[10328] | 86 | this->grid->toList(OM_DEAD); |
---|
[10179] | 87 | } |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | void AcidSplash::activate() |
---|
| 91 | { |
---|
[10747] | 92 | // this->origList = this->getOMListNumber(); |
---|
| 93 | // this->toList(OM_ENVIRON); |
---|
[10345] | 94 | // this->unhide(); |
---|
[10511] | 95 | this->grid->setVisibility(true); |
---|
[10179] | 96 | |
---|
| 97 | this->setPhysDamage(10); |
---|
| 98 | this->setElecDamage(0); |
---|
| 99 | this->setHealth(0); |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | void AcidSplash::deactivate() |
---|
| 104 | { |
---|
| 105 | this->lifeCycle = 0.0; |
---|
| 106 | |
---|
[10345] | 107 | // this->hide(); |
---|
[10511] | 108 | this->grid->setVisibility(false); |
---|
[10345] | 109 | this->lifeCycle = 0.0; |
---|
| 110 | this->toList(OM_NULL); |
---|
| 111 | //this->toList(OM_DEAD); |
---|
[10698] | 112 | // this->removeNode(); |
---|
| 113 | |
---|
[10179] | 114 | AcidSplash::fastFactory->kill(this); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * signal tick, time dependent things will be handled here |
---|
| 120 | * @param dt time since last tick |
---|
| 121 | */ |
---|
| 122 | void AcidSplash::tick (float dt) |
---|
| 123 | { |
---|
| 124 | Vector v = this->velocity * dt; |
---|
| 125 | this->shiftCoor(v); |
---|
| 126 | |
---|
| 127 | if (this->tickLifeCycle(dt)) |
---|
| 128 | this->deactivate(); |
---|
| 129 | |
---|
| 130 | this->angle += this->rotationSpeed * dt; |
---|
| 131 | |
---|
| 132 | this->grid->tick(dt); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | /** |
---|
| 136 | * the function gets called, when the projectile is destroyed |
---|
| 137 | */ |
---|
| 138 | void AcidSplash::destroy (WorldEntity* killer) |
---|
| 139 | { |
---|
| 140 | this->deactivate(); |
---|
| 141 | Projectile::destroy( killer ); |
---|
| 142 | PRINTF(5)("DESTROY AcidSplash\n"); |
---|
| 143 | this->lifeCycle = .95; //!< @todo calculate this usefully. |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | void AcidSplash::draw () const |
---|
| 148 | { |
---|
| 149 | this->grid->draw(); |
---|
| 150 | } |
---|