Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/projectiles/acid_splash.cc @ 10759

Last change on this file since 10759 was 10747, checked in by nicolasc, 18 years ago

cleaned out origList

File size: 2.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 <cassert>
25#include "debug.h"
26
27#include "obb_tree.h"
28
29#include "effects/wobblegrid.h"
30
31
32
33ObjectListDefinition(AcidSplash);
34CREATE_FAST_FACTORY_STATIC(AcidSplash);
35
36/**
37 *  standard constructor
38*/
39AcidSplash::AcidSplash () : Projectile()
40{
41  this->registerObject(this, AcidSplash::_objectList);
42
43// moved to baseObject
44//   srand(time(0));   //initialize Random Nomber Generator
45
46  this->setMinEnergy(1);
47  this->setHealthMax(0);
48  this->lifeSpan = 3.0;
49  this->angle     = 0;
50
51  this->grid = new Wobblegrid( 5);
52  this->grid->setParent( this);
53  this->grid->setVisibility(false);
54
55
56  int rnd = int(rand() % 3);
57
58  switch (rnd){
59    case 0:
60      this->grid->setTexture( "textures/acid2.png");
61      break;
62    case 1:
63      this->grid->setTexture( "textures/acid3.png");
64      break;
65    case 2:
66      this->grid->setTexture( "textures/blub.png");
67      break;
68    default:
69      this->grid->setTexture( "textures/acid2.png");
70  }
71
72  this->grid->toList(OM_ENVIRON); 
73 
74  this->obbTree = new OBBTree();
75  this->obbTree->createBox(Vector(0.0f, 0.0f, 0.0f), Vector(1.0f, 1.0f, 1.0f));
76  this->setOBBTree(this->obbTree);
77}
78
79
80/**
81 *  standard deconstructor
82 *
83 */
84AcidSplash::~AcidSplash ()
85{
86  this->grid->toList(OM_DEAD);
87}
88
89
90void AcidSplash::activate()
91{
92//   this->origList = this->getOMListNumber();
93//   this->toList(OM_ENVIRON);
94 // this->unhide();
95  this->grid->setVisibility(true);
96
97  this->setPhysDamage(10);
98  this->setElecDamage(0);
99  this->setHealth(0);
100}
101
102
103void AcidSplash::deactivate()
104{
105  this->lifeCycle = 0.0;
106
107 // this->hide();
108  this->grid->setVisibility(false);
109  this->lifeCycle = 0.0;
110  this->toList(OM_NULL);
111  //this->toList(OM_DEAD);
112//   this->removeNode();
113
114  AcidSplash::fastFactory->kill(this);
115}
116
117
118/**
119 *  signal tick, time dependent things will be handled here
120 * @param dt time since last tick
121*/
122void AcidSplash::tick (float dt)
123{
124  Vector v = this->velocity * dt;
125  this->shiftCoor(v);
126
127  if (this->tickLifeCycle(dt))
128    this->deactivate();
129
130  this->angle += this->rotationSpeed * dt;
131
132  this->grid->tick(dt);
133}
134
135/**
136 *  the function gets called, when the projectile is destroyed
137*/
138void AcidSplash::destroy (WorldEntity* killer)
139{
140  this->deactivate();
141  Projectile::destroy( killer );
142  PRINTF(5)("DESTROY AcidSplash\n");
143  this->lifeCycle = .95; //!< @todo calculate this usefully.
144}
145
146
147void AcidSplash::draw () const
148{
149  this->grid->draw();
150}
Note: See TracBrowser for help on using the repository browser.