Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 20, 2007, 10:29:13 PM (17 years ago)
Author:
rennerc
Message:

die player die

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/space_ships/space_ship.cc

    r10742 r10749  
    7474#include "track/track.h"
    7575#include "track/action_box.h"
     76
     77#include "event_handler.h"
     78
     79#include "story_entity.h"
    7680
    7781
     
    421425void SpaceShip::tick (float time)
    422426{
     427  if ( deadBox != NULL )
     428  {
     429    OrxGui::GLGuiHandler::getInstance()->tick( time );
     430  }
    423431 // printf("SSGROUP: %d\n", this->getOMListNumber());
    424432
     
    597605}
    598606
    599 void SpaceShip::destroy( WorldEntity* killer )
    600 {
    601   if(this->hasPlayer())
    602     Playable::destroy( killer);
    603 
    604   PRINTF(5)("spaceship destroy\n");
    605 
    606   EmitterNode* node  = NULL;
    607   DotEmitter* emitter = NULL;
    608   SpriteParticles*  explosionParticles  = NULL;
    609 
    610   explosionParticles = new SpriteParticles(200);
    611   explosionParticles->setName("SpaceShipExplosionParticles");
    612   explosionParticles->setLifeSpan(.2, .3);
    613   explosionParticles->setRadius(0.0, 10.0);
    614   explosionParticles->setRadius(.5, 6.0);
    615   explosionParticles->setRadius(1.0, 3.0);
    616   explosionParticles->setColor(0.0, 1,1,1,.9);
    617   explosionParticles->setColor(0.1,  1,1,0,.9);
    618   explosionParticles->setColor(0.5, .8,.4,0,.5);
    619   explosionParticles->setColor(1.0, .2,.2,.2,.5);
    620 
    621 
    622   emitter = new DotEmitter( 2000, 70, 360);
    623   //emitter->setSpread( 0, M_2_PI);
    624   emitter->setEmissionRate( 200.0);
    625   //emitter->setEmissionVelocity( 200.0);
    626   //emitter->setSystem( explosionParticles);
    627   //emitter->setAbsCoor( this->getAbsCoor());
    628 
    629   node  = new EmitterNode( .1f);
    630   node->setupParticle( emitter, explosionParticles);
    631   node->setAbsDir( this->getAbsDir());
    632   node->setVelocity( this->getVelocity() * .9f);
    633   node->setAbsCoor( this->getAbsCoor());
    634   if( !node->start())
    635     PRINTF(0)("Explosion node not correctly started!");
    636 /*
    637   PNode* node          = new PNode();
    638   node->setAbsCoor(this->getAbsCoor());
    639   Explosion* explosion = new Explosion();
    640   explosion->explode( node, Vector(5,5,5));
    641 */
    642 /*
    643   if( this->hasPlayer())
    644   {
    645         this->setAbsCoor(Vector(-10000,10000,10000));
    646         this->hide();
    647   }
    648   else
    649   {*/
    650     this->setAbsCoor( this->getAbsCoor() + Vector(100,0,0) + Vector(1,0,0) * VECTOR_RAND(150).dot(Vector(1,0,0)));
    651   //}
    652 
    653 }
    654 
    655607void SpaceShip::respawn( )
    656608{
    657609  Playable::respawn();
    658610}
    659 
    660 
    661 void SpaceShip::damage(float pDamage, float eDamage){
    662   PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage);
    663 
    664   static float tmp = this->decreaseShield(pDamage);
    665   if( tmp > 0)
    666   if ( this->decreaseHealth(tmp / 2) > 0)
    667     this->destroy(this);
    668 
    669 }
    670 
    671611
    672612
     
    1036976  this->weaponMan.previousWeaponConfig();
    1037977  Playable::weaponConfigChanged();
    1038 }
    1039 
    1040 void SpaceShip::hit( float damage, WorldEntity* killer)
    1041 {
    1042   this->damage(killer->getDamage(),0);
    1043978}
    1044979
     
    11351070};
    11361071
    1137 
     1072void SpaceShip::hit( float damage, WorldEntity * killer )
     1073{
     1074  PRINTF(0)("SS HIT: %f\n", this->getHealth() );
     1075  Playable::hit( damage, killer );
     1076  PRINTF(0)("SS HIT: %f\n", this->getHealth() ); 
     1077}
     1078
     1079void SpaceShip::destroy( WorldEntity * killer )
     1080{
     1081  Playable::destroy( killer );
     1082  this->showDeadScreen();
     1083  myList = this->getOMListNumber();
     1084  toList( OM_DEAD );
     1085}
     1086
     1087void SpaceShip::onButtonContinue( )
     1088{
     1089  OrxGui::GLGuiHandler::getInstance()->deactivateCursor( true );
     1090  EventHandler::getInstance()->popState();
     1091  WorldEntity::reset();
     1092  toList( myList );
     1093  deadBox->hideAll();
     1094}
     1095
     1096void SpaceShip::onButtonExit( )
     1097{
     1098  State::getCurrentStoryEntity()->setNextStoryID( 0 );
     1099  State::getCurrentStoryEntity()->stop();
     1100}
     1101
     1102void SpaceShip::showDeadScreen( )
     1103{
     1104  EventHandler::getInstance()->pushState( ES_MENU );
     1105
     1106  OrxGui::GLGuiHandler::getInstance()->activateCursor();
     1107 
     1108  if ( deadBox )
     1109    delete deadBox;
     1110  deadBox = new OrxGui::GLGuiBox();
     1111  deadBox->setAbsCoor2D( 100, 100 );
     1112
     1113  OrxGui::GLGuiText* text = new OrxGui::GLGuiText();
     1114  text->setText( "Game Over! - You died!" );
     1115  OrxGui::GLGuiPushButton* exitButton = new OrxGui::GLGuiPushButton( "exit" );
     1116  exitButton->released.connect(this, &SpaceShip::onButtonExit);
     1117  OrxGui::GLGuiPushButton* continueButton = new OrxGui::GLGuiPushButton( "continue" );
     1118  continueButton->released.connect(this, &SpaceShip::onButtonContinue);
     1119
     1120  deadBox->pack( text );
     1121  deadBox->pack( continueButton );
     1122  deadBox->pack( exitButton );
     1123
     1124  deadBox->showAll();
     1125}
     1126
     1127
     1128
Note: See TracChangeset for help on using the changeset viewer.