Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2005, 4:16:51 PM (20 years ago)
Author:
patrick
Message:

network: merged the trunk into the network with the command svn merge -r5824:HEAD ../trunk network, changes changed… bla bla..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/world_entities/weapons/bomb.cc

    r5769 r5968  
    1717#include "glincl.h"
    1818#include "state.h"
     19#include "model.h"
     20#include "primitive_model.h"
     21
     22#include "fast_factory.h"
    1923#include "list.h"
    20 #include "model.h"
    21 #include "vector.h"
    22 #include "fast_factory.h"
    2324
     25#include "object_manager.h"
    2426
    2527#include "particle_engine.h"
     
    5961Bomb::~Bomb ()
    6062{
     63  delete this->detonationSphere;
     64  delete this->detonationMaterial;
    6165
    6266}
     
    7175  this->setClassID(CL_BOMB, "Bomb");
    7276
     77
     78  this->detonationSphere = new PrimitiveModel(PRIM_SPHERE);
     79  this->detonationMaterial = new Material();
     80  this->detonationMaterial->setDiffuse(1, 0, 0);
     81  //   this->detonationMaterial->setTransparency(.1);
    7382  /**
    7483   * @todo: Write CL_PROTO_WORLD_ENTITY INTO THE src/defs/class_id.h (your own definition)
     
    101110void Bomb::tick(float time)
    102111{
    103   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    104   Vector v = this->velocity * (time);
    105   this->shiftCoor(v);
    106 
    107112  this->lifeCycle += time/this->lifeSpan;
    108113  if( this->lifeCycle >= 1.0)
     
    114119      this->deactivate();
    115120    }
     121  else if (this->lifeCycle > 0.9f)
     122    this->detonate ((this->lifeCycle-.89) *1000.0);
     123  else
     124  {
     125    Vector v = this->velocity * (time);
     126    this->shiftCoor(v);
     127  }
    116128}
    117129
     
    133145  glMultMatrixf((float*)matrix);
    134146
    135   if (model)
    136     model->draw();
     147  if (this->lifeCycle < .9)
     148  {
     149    if (model)
     150      model->draw();
     151  }
     152  else
     153  {
     154    glScalef((this->lifeCycle-.89) *1000.0,
     155              (this->lifeCycle-.89) *1000.0,
     156              (this->lifeCycle-.89) *1000.0);
     157    this->detonationMaterial->select();
     158    this->detonationSphere->draw();
     159  }
    137160  glPopMatrix();
    138161}
     
    145168void Bomb::collidesWith (WorldEntity* entity, const Vector& location)
    146169{
    147         this->detonate();
     170  if (this->lifeCycle < .9f && entity->isA(CL_NPC))
     171    this->lifeCycle = 0.9f;
    148172}
    149173
     
    157181{
    158182  State::getWorldEntityList()->remove(this);
     183  this->lifeCycle = 0.0f;
    159184  Bomb::fastFactory->kill(this);
    160185}
    161186
    162 void Bomb::detonate()
     187void Bomb::detonate(float size)
    163188{
    164   tIterator<WorldEntity>* it = State::getWorldEntityList()->getIterator();
    165   WorldEntity* lm = it->firstElement();
    166 
    167   while(lm != NULL)
     189  std::list<WorldEntity*>* detonationList = ObjectManager::distanceFromObject(*this, size, CL_NPC);
     190  if (detonationList != NULL)
    168191  {
    169 
    170     lm = it->nextElement();
     192    while( !detonationList->empty() )
     193    {
     194      detonationList->front()->collidesWith(this, Vector(0,0,0));
     195      detonationList->pop_front();
     196    }
     197    delete detonationList;
    171198  }
    172199}
Note: See TracChangeset for help on using the changeset viewer.