Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10766 was 10763, checked in by nicolasc, 18 years ago

moved loadShield (XML), some minor cleanup

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