Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

moved loadHealth to WE

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