Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/world_entities/projectiles/acid_splash.cc @ 10648

Last change on this file since 10648 was 10420, checked in by patrick, 18 years ago

maps ⇒ textures

File size: 3.8 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
57
58  int rnd = int(rand() % 3);
59
60  switch (rnd){
61    case 0:
62      this->grid->setTexture( "textures/acid2.png");
63      break;
64    case 1:
65      this->grid->setTexture( "textures/acid3.png");
66      break;
67    case 2:
68      this->grid->setTexture( "textures/blub.png");
69      break;
70    default:
71      this->grid->setTexture( "textures/acid2.png");
72  }
73//   if (rand()/2 == 0) //!<Randomized Textrures
74//     this->grid->setTexture( "textures/acid3.png");
75//   else
76//     this->grid->setTexture( "textures/blub.png");
77
78  this->grid->toList(OM_ENVIRON); 
79}
80
81
82/**
83 *  standard deconstructor
84 *
85 */
86AcidSplash::~AcidSplash ()
87{
88  // delete this->emitter;
89  //delete this->grid;
90  this->grid->toList(OM_DEAD);
91 
92}
93
94
95void AcidSplash::activate()
96{
97  this->origList = this->getOMListNumber();
98  this->toList(OM_ENVIRON);
99 // this->unhide();
100  this->grid->setVisibiliy(true);
101
102  this->setPhysDamage(10);
103  this->setElecDamage(0);
104  this->setHealth(0);
105}
106
107
108void AcidSplash::deactivate()
109{
110  this->lifeCycle = 0.0;
111
112 // this->hide();
113  this->grid->setVisibiliy(false);
114  this->lifeCycle = 0.0;
115  this->toList(OM_NULL);
116  //this->toList(OM_DEAD);
117  this->removeNode();
118 
119  AcidSplash::fastFactory->kill(this);
120}
121
122/*
123void AcidSplash::collidesWith(WorldEntity* entity, const Vector& location)
124{
125
126  if (this->hitEntity != entity)
127    this->destroy( entity );
128  this->hitEntity = entity;
129  //dynamic_cast<SpaceShip*>(entity)->damage(this->getPhysDamage(),this->getElecDamage());
130  //this->destroy(this);
131  this->deactivate();
132 
133//   return;
134
135  //dynamic_cast<SpaceShip*>(entity)->damage( this->getPhysDamage(), this->getElecDamage());
136  //entity->destroy(this);
137  //this->deactivate();
138}
139*/
140/**
141 *  signal tick, time dependent things will be handled here
142 * @param dt time since last tick
143*/
144void AcidSplash::tick (float dt)
145{
146  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
147  Vector v = this->velocity * dt;
148  this->shiftCoor(v);
149
150  if (this->tickLifeCycle(dt))
151    this->deactivate();
152
153  this->angle += this->rotationSpeed * dt;
154
155  this->grid->tick(dt);
156
157  for( ObjectList<Playable>::const_iterator eIterator = Playable::objectList().begin(); eIterator !=Playable::objectList().end(); eIterator++)
158  {
159    if( ((*eIterator)->getOMListNumber() != (this->origList -1))  && ((*eIterator)->getAbsCoor() - this->getAbsCoor()).len() <= 8)
160    {
161      (*eIterator)->hit (this->getDamage(),this);
162      this->deactivate();
163    }
164  }
165
166}
167
168/**
169 *  the function gets called, when the projectile is destroyed
170*/
171void AcidSplash::destroy (WorldEntity* killer)
172{
173  this->deactivate();
174  Projectile::destroy( killer );
175  PRINTF(5)("DESTROY AcidSplash\n");
176  this->lifeCycle = .95; //!< @todo calculate this usefully.
177}
178
179
180void AcidSplash::draw () const
181{
182  this->grid->draw();
183}
Note: See TracBrowser for help on using the repository browser.