Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

viewmode correct set in spaceship

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