Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/projectiles/plasma_pulse.cc @ 10737

Last change on this file since 10737 was 10737, checked in by nicolasc, 17 years ago

collision fix

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