Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/plasma_pulse.cc @ 10699

Last change on this file since 10699 was 10698, checked in by snellen, 17 years ago

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

File size: 3.1 KB
Line 
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, Nicolas Schlumberger
14
15*/
16
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
19
20#include "plasma_pulse.h"
21
22#include "state.h"
23
24#include <cassert>
25#include "debug.h"
26
27
28ObjectListDefinition(PlasmaPulse);
29CREATE_FAST_FACTORY_STATIC(PlasmaPulse);
30
31/**
32 *  standard constructor
33*/
34PlasmaPulse::PlasmaPulse () : Projectile()
35{
36  this->registerObject(this, PlasmaPulse::_objectList);
37
38
39  this->setMinEnergy(1);
40  this->setHealthMax(0);
41  this->lifeSpan = 2.0;
42
43  this->grid = new Billboard();
44  this->grid->setSize(.2, .2);
45  this->grid->setPulseMagnitude(.8);
46  this->grid->setParent(this);
47  this->grid->setVisibility(false);
48  this->grid->setPulse();
49  this->grid->setTexture( "textures/plasma.png");
50  this->grid->toList(OM_ENVIRON);
51/*
52  this->blink = new Blink();
53  this->grid->setParent(this);
54  this->grid->setVisibility(false);
55  this->blink->setSize(1.0 );
56  this->blink->setPeriod(.4);
57  this->blink->setColor(10, 250, 150);
58  this->blink->loadBlinkSequence( "66678998766" );
59  this->blink->toList(OM_ENVIRON);*/
60}
61
62
63/**
64 *  standard deconstructor
65 *
66 */
67PlasmaPulse::~PlasmaPulse ()
68{
69  this->grid->toList(OM_DEAD);
70//   this->blink->toList(OM_DEAD);
71}
72
73
74void PlasmaPulse::activate()
75{
76  this->origList = this->getOMListNumber();
77  this->toList(OM_ENVIRON);
78  this->grid->setVisibility(true);
79//   this->blink->setVisibility(true);
80
81  this->setPhysDamage(10);
82  this->setElecDamage(0);
83  this->setHealth(0);
84}
85
86
87void PlasmaPulse::deactivate()
88{
89  this->lifeCycle = 0.0;
90
91  this->grid->setVisibility(false);
92//   this->blink->setVisibility(false);
93  this->lifeCycle = 0.0;
94  this->toList(OM_NULL);
95//   this->removeNode();
96
97  PlasmaPulse::fastFactory->kill(this);
98}
99
100/**
101 *  signal tick, time dependent things will be handled here
102 * @param dt time since last tick
103*/
104void PlasmaPulse::tick (float dt)
105{
106  Vector v = this->velocity * dt;
107  this->shiftCoor(v);
108
109  if (this->tickLifeCycle(dt))
110    this->deactivate();
111
112  this->grid->tick(dt);
113
114  for( ObjectList<Playable>::const_iterator eIterator = Playable::objectList().begin(); eIterator !=Playable::objectList().end(); eIterator++)
115  {
116    if( ((*eIterator)->getOMListNumber() != (this->origList -1))  && ((*eIterator)->getAbsCoor() - this->getAbsCoor()).len() <= 3)
117    {
118      (*eIterator)->hit (this->getDamage(),this);
119      this->deactivate();
120    }
121  }
122
123}
124
125/**
126 *  the function gets called, when the projectile is destroyed
127*/
128void PlasmaPulse::destroy (WorldEntity* killer)
129{
130  this->deactivate();
131  Projectile::destroy( killer );
132  PRINTF(5)("DESTROY PlasmaPulse\n");
133  this->lifeCycle = .95; //!< @todo calculate this usefully.
134}
135
136
137void PlasmaPulse::draw () const
138{
139  glPushMatrix();
140    glEnable( GL_ALPHA_TEST);
141    glAlphaFunc( GL_GEQUAL, .5);
142    this->grid->draw();
143//     this->blink->draw();
144  glPopMatrix();
145
146}
Note: See TracBrowser for help on using the repository browser.