Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/acid_splash.cc @ 10735

Last change on this file since 10735 was 10698, checked in by snellen, 18 years ago

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

File size: 3.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: Marc Schaerrer
13   co-programmer: Benjamin Grauer
14
15*/
16
17
18#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
19
20#include "acid_splash.h"
21
22#include "state.h"
23
24//#include "space_ships/space_ship.h"
25
26#include <cassert>
27#include "debug.h"
28
29//#include "static_model.h"
30
31#include "effects/wobblegrid.h"
32
33
34
35ObjectListDefinition(AcidSplash);
36CREATE_FAST_FACTORY_STATIC(AcidSplash);
37
38/**
39 *  standard constructor
40*/
41AcidSplash::AcidSplash () : Projectile()
42{
43  this->registerObject(this, AcidSplash::_objectList);
44
45  srand(time(0));   //initialize Random Nomber Generator
46
47  //this->loadModel("models/projectiles/laser.obj");
48
49  this->setMinEnergy(1);
50  this->setHealthMax(0);
51  this->lifeSpan = 3.0;
52  this->angle     = 0;
53
54  this->grid = new Wobblegrid( 5);
55  this->grid->setParent( this);
56  this->grid->setVisibility(false);
57
58
59  int rnd = int(rand() % 3);
60
61  switch (rnd){
62    case 0:
63      this->grid->setTexture( "textures/acid2.png");
64      break;
65    case 1:
66      this->grid->setTexture( "textures/acid3.png");
67      break;
68    case 2:
69      this->grid->setTexture( "textures/blub.png");
70      break;
71    default:
72      this->grid->setTexture( "textures/acid2.png");
73  }
74//   if (rand()/2 == 0) //!<Randomized Textrures
75//     this->grid->setTexture( "textures/acid3.png");
76//   else
77//     this->grid->setTexture( "textures/blub.png");
78
79  this->grid->toList(OM_ENVIRON); 
80}
81
82
83/**
84 *  standard deconstructor
85 *
86 */
87AcidSplash::~AcidSplash ()
88{
89  // delete this->emitter;
90  //delete this->grid;
91  this->grid->toList(OM_DEAD);
92 
93}
94
95
96void AcidSplash::activate()
97{
98  this->origList = this->getOMListNumber();
99  this->toList(OM_ENVIRON);
100 // this->unhide();
101  this->grid->setVisibility(true);
102
103  this->setPhysDamage(10);
104  this->setElecDamage(0);
105  this->setHealth(0);
106}
107
108
109void AcidSplash::deactivate()
110{
111  this->lifeCycle = 0.0;
112
113 // this->hide();
114  this->grid->setVisibility(false);
115  this->lifeCycle = 0.0;
116  this->toList(OM_NULL);
117  //this->toList(OM_DEAD);
118//   this->removeNode();
119
120  AcidSplash::fastFactory->kill(this);
121}
122
123/*
124void AcidSplash::collidesWith(WorldEntity* entity, const Vector& location)
125{
126
127  if (this->hitEntity != entity)
128    this->destroy( entity );
129  this->hitEntity = entity;
130  //dynamic_cast<SpaceShip*>(entity)->damage(this->getPhysDamage(),this->getElecDamage());
131  //this->destroy(this);
132  this->deactivate();
133 
134//   return;
135
136  //dynamic_cast<SpaceShip*>(entity)->damage( this->getPhysDamage(), this->getElecDamage());
137  //entity->destroy(this);
138  //this->deactivate();
139}
140*/
141/**
142 *  signal tick, time dependent things will be handled here
143 * @param dt time since last tick
144*/
145void AcidSplash::tick (float dt)
146{
147  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
148  Vector v = this->velocity * dt;
149  this->shiftCoor(v);
150
151  if (this->tickLifeCycle(dt))
152    this->deactivate();
153
154  this->angle += this->rotationSpeed * dt;
155
156  this->grid->tick(dt);
157
158  for( ObjectList<Playable>::const_iterator eIterator = Playable::objectList().begin(); eIterator !=Playable::objectList().end(); eIterator++)
159  {
160    if( ((*eIterator)->getOMListNumber() != (this->origList -1))  && ((*eIterator)->getAbsCoor() - this->getAbsCoor()).len() <= 8)
161    {
162      (*eIterator)->hit (this->getDamage(),this);
163      this->deactivate();
164    }
165  }
166
167}
168
169/**
170 *  the function gets called, when the projectile is destroyed
171*/
172void AcidSplash::destroy (WorldEntity* killer)
173{
174  this->deactivate();
175  Projectile::destroy( killer );
176  PRINTF(5)("DESTROY AcidSplash\n");
177  this->lifeCycle = .95; //!< @todo calculate this usefully.
178}
179
180
181void AcidSplash::draw () const
182{
183  this->grid->draw();
184}
Note: See TracBrowser for help on using the repository browser.