Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2008, 4:39:13 AM (15 years ago)
Author:
landauf
Message:

added spawn- and destroy-effects to Pawn

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2369 r2414  
    3737#include "objects/gametypes/Gametype.h"
    3838#include "objects/weaponSystem/WeaponSystem.h"
     39#include "objects/worldentities/ParticleSpawner.h"
     40#include "objects/worldentities/ExplosionChunk.h"
    3941
    4042namespace orxonox
     
    5658        this->lastHitOriginator_ = 0;
    5759        this->weaponSystem_ = 0;
     60
     61        this->spawnparticleduration_ = 3.0f;
    5862
    5963        /*
     
    8791        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    8892        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     93        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
     94        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     95        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
    8996    }
    9097
     
    133140    }
    134141
    135     void Pawn::spawn()
     142    void Pawn::spawneffect()
    136143    {
    137144        // play spawn effect
     145        if (this->spawnparticlesource_ != "")
     146        {
     147            ParticleSpawner* effect = new ParticleSpawner(this);
     148            effect->setPosition(this->getPosition());
     149            effect->setOrientation(this->getOrientation());
     150            effect->setDestroyAfterLife(true);
     151            effect->setSource(this->spawnparticlesource_);
     152            effect->setLifetime(this->spawnparticleduration_);
     153        }
    138154    }
    139155
     
    151167            this->getPlayer()->stopControl(this);
    152168
     169        this->deatheffect();
     170    }
     171
     172    void Pawn::deatheffect()
     173    {
    153174        // play death effect
     175        {
     176            ParticleSpawner* effect = new ParticleSpawner(this);
     177            effect->setPosition(this->getPosition());
     178            effect->setOrientation(this->getOrientation());
     179            effect->setDestroyAfterLife(true);
     180            effect->setSource("Orxonox/explosion2");
     181            effect->setLifetime(4.0f);
     182        }
     183        {
     184            ParticleSpawner* effect = new ParticleSpawner(this);
     185            effect->setPosition(this->getPosition());
     186            effect->setOrientation(this->getOrientation());
     187            effect->setDestroyAfterLife(true);
     188            effect->setSource("Orxonox/smoke6");
     189            effect->setLifetime(4.0f);
     190        }
     191        {
     192            ParticleSpawner* effect = new ParticleSpawner(this);
     193            effect->setPosition(this->getPosition());
     194            effect->setOrientation(this->getOrientation());
     195            effect->setDestroyAfterLife(true);
     196            effect->setSource("Orxonox/sparks");
     197            effect->setLifetime(4.0f);
     198        }
     199        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
     200        {
     201            ExplosionChunk* chunk = new ExplosionChunk(this);
     202            chunk->setPosition(this->getPosition());
     203
     204        }
    154205    }
    155206
     
    163214    {
    164215        this->setHealth(this->initialHealth_);
    165         this->spawn();
     216        this->spawneffect();
    166217    }
    167218
Note: See TracChangeset for help on using the changeset viewer.