Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2007, 5:33:43 PM (17 years ago)
Author:
snellen
Message:

merged adm, hud, vs-enhancements : beni's responsible for this commit. blame him!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/space_ship.cc

    r10618 r10698  
    2222#include "util/loading/resource_manager.h"
    2323
     24#include "world_entities/weapons/weapon_manager.h"
     25
    2426#include "weapons/test_gun.h"
    2527#include "weapons/light_blaster.h"
    2628#include "weapons/medium_blaster.h"
    2729#include "weapons/heavy_blaster.h"
     30#include "weapons/rf_cannon.h"
     31#include "weapons/nadion_laser.h"
     32#include "weapons/disruptor.h"
    2833#include "weapons/swarm_launcher.h"
    2934#include "weapons/spike_thrower.h"
     
    6166#include "tools/cameraman.h"
    6267
     68#include "tools/mount_point.h"
     69#include "weapons/weapon_slot.h"
    6370
    6471#include "util/loading/load_param.h"
     
    6673
    6774#include "track/track.h"
    68 
    69 
    70 // #include "lib/gui/gl_gui/glgui_bar.h"
    71 // #include "lib/gui/gl_gui/glgui_pushbutton.h"
    72 
     75#include "track/action_box.h"
    7376
    7477
     
    156159  //weapons:
    157160
    158   Weapon* wpRight1 = new LightBlaster ();
    159   wpRight1->setName( "LightBlaster");
    160   Weapon* wpLeft1 = new LightBlaster ();
    161   wpLeft1->setName( "LightBlaster");
    162 
    163   Weapon* wpRight2 = new MediumBlaster ();
    164   wpRight2->setName( "MediumBlaster");
    165   Weapon* wpLeft2 = new MediumBlaster ();
    166   wpLeft2->setName( "MediumBlaster");
    167 
    168   Weapon* wpRight3 = new HeavyBlaster (1);
    169   wpRight3->setName( "HeavyBlaster");
    170   Weapon* wpLeft3 = new HeavyBlaster (0);
    171   wpLeft3->setName( "HeavyBlaster");
    172 
    173   Weapon* cannon = new SwarmLauncher();
    174   cannon->setName( "SwarmLauncher");
    175 /*
    176   Weapon* spike = new SpikeThrower();
    177   spike->setName( "SpikeThrower" );
    178 
    179 
    180   Weapon* acid0 = new AcidLauncher();
    181   acid0->setName( "AcidSplasher" );
    182 
    183   Weapon* acid1 = new AcidLauncher();
    184   acid1->setName( "AcidSplasher" );*/
    185 
    186 
    187   this->weaponMan.addWeapon( wpLeft1, 0, 0);
    188   this->weaponMan.addWeapon( wpRight1, 0, 1);
    189 
    190   this->weaponMan.addWeapon( wpLeft2, 1, 2);
    191   this->weaponMan.addWeapon( wpRight2, 1, 3);
    192 
    193   this->weaponMan.addWeapon( wpLeft3, 2, 4);
    194   this->weaponMan.addWeapon( wpRight3, 2, 5);
    195 
    196   this->weaponMan.addWeapon( wpLeft1, 3, 0);
    197   this->weaponMan.addWeapon( wpRight1, 3, 1);
    198 
    199   this->weaponMan.addWeapon( wpLeft2, 3, 2);
    200   this->weaponMan.addWeapon( wpRight2, 3, 3);
    201 
    202   this->weaponMan.addWeapon( wpLeft3, 3, 4);
    203   this->weaponMan.addWeapon( wpRight3, 3, 5);
    204 
    205 
    206 //   this->weaponMan.addWeapon( acid0, 3, 0);
    207 //   this->weaponMan.addWeapon( acid1, 3, 1);
    208 
    209 
    210   this->secWeaponMan.addWeapon( cannon, 0, 2);
    211 //   this->secWeaponMan.addWeapon( spike, 1, 3);
    212 //   this->secWeaponMan.addWeapon( acid0, 2, 2);
    213 //   this->secWeaponMan.addWeapon( acid1, 2, 3);
    214 
    215 
    216   this->weaponMan.changeWeaponConfig(3);
     161  this->weaponMan.setParentEntity( this);
     162  this->secWeaponMan.setParentEntity( this);
     163
     164  this->weaponMan.setSlotCount(8);
     165  this->secWeaponMan.setSlotCount(6);
     166
     167  this->weaponMan.createWeaponSlot(0, 3.270, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     168  this->weaponMan.createWeaponSlot(1, 3.270, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     169  this->weaponMan.createWeaponSlot(2, 4.385, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     170  this->weaponMan.createWeaponSlot(3, 4.385, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     171  this->weaponMan.createWeaponSlot(4, 1.635, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     172  this->weaponMan.createWeaponSlot(5, 1.536, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     173  this->weaponMan.createWeaponSlot(6, 1.536, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     174  this->weaponMan.createWeaponSlot(7, 1.536, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     175
     176
     177  this->weaponMan.addWeaponToSlot(0, 0, "RFCannon");
     178  this->weaponMan.addWeaponToSlot(0, 1, "RFCannon");
     179  this->weaponMan.addWeaponToSlot(0, 2, "RFCannon");
     180  this->weaponMan.addWeaponToSlot(0, 3, "RFCannon");
     181  this->weaponMan.addWeaponToSlot(1, 0, "RFCannon");
     182  this->weaponMan.addWeaponToSlot(1, 1, "RFCannon");
     183  this->weaponMan.addWeaponToSlot(1, 2, "RFCannon");
     184  this->weaponMan.addWeaponToSlot(1, 3, "RFCannon");
     185
     186  this->weaponMan.addWeaponToSlot(0, 4, "NadionLaser");
     187  this->weaponMan.addWeaponToSlot(0, 5, "NadionLaser");
     188  this->weaponMan.addWeaponToSlot(2, 4, "NadionLaser");
     189  this->weaponMan.addWeaponToSlot(2, 5, "NadionLaser");
     190
     191  this->weaponMan.addWeaponToSlot(0, 6, "Disruptor");
     192  this->weaponMan.addWeaponToSlot(0, 7, "Disruptor");
     193  this->weaponMan.addWeaponToSlot(3, 6, "Disruptor");
     194  this->weaponMan.addWeaponToSlot(3, 7, "Disruptor");
     195
     196
     197  this->secWeaponMan.createWeaponSlot(0, 1.5, 3, 0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     198  this->secWeaponMan.createWeaponSlot(1, 2.6, 0, 3.0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     199  this->secWeaponMan.createWeaponSlot(2, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     200  this->secWeaponMan.createWeaponSlot(3, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     201  this->secWeaponMan.createWeaponSlot(4, 1.5, 0, .5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     202  this->secWeaponMan.createWeaponSlot(5, 1.5, 0, -.5, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     203
     204  this->secWeaponMan.addWeaponToSlot(0, 2, "SwarmLauncher");
     205
     206
     207  this->weaponMan.changeWeaponConfig(0);
    217208  this->secWeaponMan.changeWeaponConfig(0);
    218209
    219210
    220 //   curWeaponPrimary    = 3;
    221 //   curWeaponSecondary  = 0;
    222 
    223211  Playable::weaponConfigChanged();
    224212
    225   reactorOutput     = 10;
    226 
    227   weaponEnergyRegen = 10;       // 10 einheiten pro Sekunde
    228   engineSpeedBase   = 15;
    229   shieldRegen       = 2;
    230 
    231   shieldEnergyShare = 0.3;
    232   weaponEnergyShare = 0.3;
    233   engineEnergyShare = 0.4;
    234 
    235   shieldCur         = 100;
    236   shieldMax         = 100;
    237   shieldTH          = .2 * shieldMax;   // shield power must be 20% before shield kicks in again
    238 
    239   this->setHealth( 100);
    240   this->setHealthMax( 100);
    241 
    242   electronicCur = 50;
    243   electronicMax = 50;
    244   electronicRegen   = 3;
    245   electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship
    246 
    247 
    248  this->loadModel("models/spaceships/human_spaceship_fighter.obj", .25);
     213  this->bInit = false;
     214
     215  loadEnergyShare(.3,.3,.4);
     216  loadShield(80, 100, .2, 2);
     217  loadHealth(100, 100);
     218  loadElectronic(40, 50, .7, 3.0);
     219  loadReactor(10);
     220  loadWeapon(10);
     221  loadEngine(15);
     222
     223//   this->loadModel("models/spaceships/fighter_redesign9.obj");
    249224  //this->setVisibiliy(false);
    250225
    251226  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    252227
    253   this->setHealthMax(shieldMax);
    254   this->setHealth(shieldCur);
     228//   this->setHealthMax(shieldMax);
     229//   this->setHealth(shieldCur);
    255230
    256231  this->travelNode = new PNode();
     
    260235  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    261236
    262   // widget handling
    263   /*
    264   this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    265   this->electronicWidget->setDisplayedName(std::string(this->getClassName()) + " Electronics:");
    266   this->electronicWidget->setSize2D(30,400);
    267   this->electronicWidget->setAbsCoor2D(150,200);
    268   this->electronicWidget->shiftDir2D(270);
    269   this->updateElectronicWidget();
    270   this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    271   this->shieldWidget->setDisplayedName(std::string(this->getClassName()) + " Shield:");
    272   this->shieldWidget->setSize2D(30,400);
    273   this->shieldWidget->setAbsCoor2D(200,200);
    274   this->shieldWidget->shiftDir2D(270);
    275   this->updateShieldWidget();
    276   if (this->hasPlayer())
    277   {
    278     State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
    279     State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
    280   }
    281   */
    282   this->electronicWidget = NULL;
    283   this->shieldWidget = NULL;
     237
     238//   this->electronicWidget = NULL;
     239//   this->shieldWidget = NULL;
    284240
    285241  //add events to the eventlist
     
    298254  registerEvent(EV_MOUSE_MOTION);
    299255
    300   this->weaponMan.setParentEntity( this);
    301   this->secWeaponMan.setParentEntity( this);
    302 
    303   this->weaponMan.setSlotCount(8);
    304 
    305   this->weaponMan.setSlotPosition(0, Vector(0.0, 0, -3.0));
    306   this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    307 
    308   this->weaponMan.setSlotPosition(1, Vector(0.0, 0, 3.0));
    309   this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    310 
    311   this->weaponMan.setSlotPosition(2, Vector(1.0, 0, -1.5));
    312   this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    313 
    314   this->weaponMan.setSlotPosition(3, Vector(1.0, 0, 1.5));
    315   this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    316 
    317   this->weaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
    318   this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    319 
    320   this->weaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
    321   this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    322 
    323   this->weaponMan.setSlotPosition(6, Vector(0.5, 0, 2.5));
    324   this->weaponMan.setSlotDirection(6, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    325 
    326   this->weaponMan.setSlotPosition(7, Vector(0.5, 0, -2.5));
    327   this->weaponMan.setSlotDirection(7, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    328 
    329   this->secWeaponMan.setSlotPosition(0, Vector(1.5, 0, 0));
    330   this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    331 
    332   this->secWeaponMan.setSlotPosition(1, Vector(2.6, 0, 3.0));
    333   this->secWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    334 
    335   this->secWeaponMan.setSlotPosition(2, Vector(1.5, 0, -.5));
    336   this->secWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    337 
    338   this->secWeaponMan.setSlotPosition(3, Vector(1.5, 0, .5));
    339   this->secWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    340 
    341   this->secWeaponMan.setSlotPosition(4, Vector(1.5, 0, .5));
    342   this->secWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    343 
    344   this->secWeaponMan.setSlotPosition(5, Vector(1.5, 0, -.5));
    345   this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    346 
    347256
    348257  this->weaponMan.getFixedTarget()->setParent(this);
     
    384293  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
    385294
    386   /// FIXME
    387 //   this->trail = new Trail( 5, 10, .2, this);
    388 //   this->trail->setTexture( "textures/engine.png");
    389 //
    390 //   this->trailL = new Trail( 5, 10, .2, this);
    391 //   this->trailL->setTexture( "textures/engine.png");
    392 //
    393 //   this->trailR = new Trail( 5, 10, .2, this);
    394 //   this->trailR->setTexture( "textures/engine.png");
    395 
    396295
    397296  this->toList(OM_GROUP_00);
    398297
    399   //FIXME Just testaddition to show the wobblegrid
    400 /*
    401   this->test  = new Wobblegrid(5);
    402   test->setTexture("textures/blub.png");
    403 
    404   test->setAbsCoor( this->getAbsCoor() + Vector(0, 2, 0));
    405   test->setParent( this);
    406 */
    407 
     298
     299  dynamic_cast<WorldEntity*>(this)->createHealthWidget();
     300  dynamic_cast<WorldEntity*>(this)->createShieldWidget();
     301  dynamic_cast<WorldEntity*>(this)->createElectronicWidget();
     302
     303  if ( this->hasPlayer() ){
     304    State::getPlayer()->hud().setShieldWidget(this->getShieldWidget());
     305    State::getPlayer()->hud().setEnergyWidget(this->getElectronicWidget());
     306  }
    408307}
    409308
     
    415314void SpaceShip::loadParams(const TiXmlElement* root)
    416315{
     316  if(!root)
     317    return;
     318
    417319  Playable::loadParams(root);
    418320
     
    422324  LoadParam(root, "actionWidthPercentage", this, SpaceShip, setActionWidthPercentage);
    423325
    424   State::getCamera()->setViewMode(Camera::ViewTop);
     326  State::getCamera()->setViewMode(Camera::ViewNormal);
     327  State::getCameraTargetNode()->setParent(this);
     328  State::getCamera()->setParent(this);
     329
     330  LoadParam(root, "loadReactor", this, SpaceShip, loadReactor)
     331  .describe("set reactor output");
     332  LoadParam(root, "loadShield", this, WorldEntity, loadShield)
     333  .describe("set shield parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate");
     334  LoadParam(root, "loadHealth", this, WorldEntity, loadHealth)
     335  .describe("set armor/health parameters: current strenght , max strenght");
     336  LoadParam(root, "loadElectronic", this, WorldEntity, loadElectronic)
     337  .describe("set electronics parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate");
     338  LoadParam(root, "loadEngine", this, SpaceShip, loadEngine)
     339  .describe("set base speed");
     340  LoadParam(root, "loadEnergyShare", this, SpaceShip, loadEnergyShare)
     341  .describe("set energy partitioning: shield, weapons, engine (sum should be 1)");
     342  LoadParam(root, "loadWeapon", this, SpaceShip, loadWeapon)
     343  .describe("set weapon regeneration");
     344
     345/*
     346  LOAD_PARAM_START_CYCLE(root, element);
     347  {
     348    LoadParamXML_CYCLE(element, "weaponMan", this->weaponMan, WeaponManager, loadWeapons)
     349    .describe("loads Weapons");
     350  }
     351  LOAD_PARAM_END_CYCLE(element);
     352
     353  LOAD_PARAM_START_CYCLE(root, element);
     354  {
     355    LoadParamXML_CYCLE(element, "secWeaponMan", this->secWeaponMan, WeaponManager, loadWeapons)
     356    .describe("loads Weapons");
     357  }
     358  LOAD_PARAM_END_CYCLE(element);*/
    425359}
    426360
     
    435369  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    436370
    437   //xMouse = yMouse = 0;
    438 
    439   this->setHealth(80);
     371  this->resetHealth();
     372  this->resetShield();
     373  this->resetElectronic();
    440374  this->velocity = Vector(0.0, 0.0, 0.0);
    441375}
     
    448382  State::getPlayer()->hud().setRadarCenterNode(this->travelNode);
    449383  State::getPlayer()->hud().setOverlayActive(true);
    450   //dynamic_cast <OrxGui::GLGuiEnergyWidgetVertical*> (State::getPlayer()->hud().getArmorWidget())->setDisplayedName("Armor");
    451   //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    452   //this->attachCamera();
    453  // this->setPlaymode(Playable::Horizontal);
    454384}
    455385
     
    461391  State::getCamera()->setEventHandling(true);
    462392  State::getPlayer()->hud().setRadarCenterNode(NULL);
    463   //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    464   //this->detachCamera();
    465393}
    466394
     
    473401  if(this->hasPlayer())
    474402    Playable::postSpawn();
    475 
    476   //setCollision(new CollisionCluster(1.0, Vector(0,0,0)));
    477403}
    478404
     
    525451void SpaceShip::tick (float time)
    526452{
     453
     454//   if( !this->bInit)
     455//   {
     456//     // now get slots from the mount points
     457//     std::map<int, MountPoint*>::iterator it = this->mountPointMap.begin();
     458//     for( ;it != this->mountPointMap.end(); it++)
     459//     {
     460//       WeaponSlot* ws = dynamic_cast<WeaponSlot*>((*it).second->getMount());
     461//       if( ws != NULL && ws->isA(WeaponSlot::staticClassID()))
     462//       {
     463//         int slot = ws->getWeaponSlot();
     464// //         int side = ws->getWeaponSide(); //FIXME / REMOVE: is not used// HACK needed for some weapons (left/right)
     465//         this->getWeaponManager().setSlotPosition(slot, (*it).second->getCenter());
     466//         this->getWeaponManager().setSlotDirection(slot, ws->getRelDir());
     467// //         PRINTF(0)("setting slot %i\n", slot);
     468// //         (*it).second->getCenter().debug();
     469//       }
     470//     }
     471//   this->bInit = true;
     472//   }
     473
    527474  // Playable::tick(time);
    528475
     
    636583  if (!(State::getCamera()->getEventHandling()))
    637584  {
     585    //PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
    638586    if( event.type == KeyMapper::PEV_VIEW0)
    639587    {
     
    750698  PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage);
    751699
    752   if( this->shieldActive) {
    753     if( this->shieldCur > pDamage) {
    754       this->shieldCur = this->shieldCur - pDamage;
    755     }
    756     else { // shield <= pDamage
    757       this->shieldCur -=pDamage;
    758       this->shieldActive = false; //shield collapses
    759       pDamage += this->shieldCur;
    760       if( !this->shieldActive) {
    761         this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
    762         this->electronicCur -= eDamage;
    763       }
    764     }
    765   }
    766   else {
    767     this->armorCur = this->armorCur - pDamage;
    768     this->electronicCur = this->electronicCur - eDamage;
    769   }
    770   if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     700  static float tmp = this->decreaseShield(pDamage);
     701  if( tmp > 0)
     702  if ( this->decreaseHealth(tmp / 2) > 0)
    771703    this->destroy(this);
    772704
    773   updateElectronicWidget();
    774   updateShieldWidget();
    775 
    776   this->setHealth( this->armorCur);
    777 }
    778 
    779 
    780 void SpaceShip::regen(float time){
    781   float tmp;
    782   if (this->armorCur != this->armorMax || this->armorRegen != 0){
    783     tmp = this->armorCur + this->armorRegen * time;
    784     if ( tmp > electronicMax)
    785       this->armorCur = this->armorMax;
    786     else
    787       this->armorCur = tmp;
    788   }
    789   if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){
    790     tmp =  this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time;
    791     if( tmp > shieldMax)
    792       this->shieldCur = this->shieldMax;
    793     else
    794       this->shieldCur = tmp;
    795     this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH);
    796 
    797     updateShieldWidget();
    798   }
    799 
    800   this->setHealth( this->shieldCur);      // FIXME currently just to test share system
    801 
    802   if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){
    803     tmp = this->electronicCur + this->electronicRegen * time;
    804     if ( tmp > electronicMax)
    805       this->electronicCur = this->electronicMax;
    806     else
    807       this->electronicCur = tmp;
    808 
    809     updateElectronicWidget();
    810   }
    811 
    812 }
     705}
     706
    813707
    814708
     
    819713void SpaceShip::weaponRegen(float time)
    820714{
    821   float energy  = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;
     715  float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time ;
    822716  Weapon* weapon;
    823   for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)
    824   {
     717  int weaponCount = 0;
     718  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) {
    825719    weapon = this->weaponMan.getWeapon(i);
    826     if( weapon != NULL && weapon->isActive())
    827     {
     720    if( weapon != NULL && weapon->isActive()) {
     721      weaponCount++;
     722    }
     723  }
     724
     725  if (weaponCount == 0)
     726    return;
     727  energy *= ( this->weaponMan.getSlotCount() / (float)weaponCount );
     728
     729  for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) {
     730    weapon = this->weaponMan.getWeapon(i);
     731    if( weapon != NULL && weapon->isActive()) {
    828732      weapon->increaseEnergy( energy);
    829733    }
    830 
    831734  }
    832735  // weaponMan.increaseAmmunition( weapon, energy);
     
    834737
    835738
    836 void SpaceShip::enterPlaymode(Playable::Playmode playmode)
    837 {
     739void SpaceShip::enterPlaymode(Playable::Playmode playmode){
    838740  switch(playmode)
    839741  {
     
    895797      }
    896798      break;
     799
     800
     801    case Playable::Vertical:
     802    {
     803        this->travelNode->setAbsCoor(this->getAbsCoor());
     804        this->travelNode->updateNode(0.01f);
     805
     806        this->isTravelDistanceInit = false;
     807
     808        if(this->entityTrack)
     809           this->travelNode->setParent(this->entityTrack->getTrackNode());
     810
     811        this->setParent(this->travelNode);
     812        this->setRelCoor(0,0,0);
     813
     814        State::getCameraNode()->setParentSoft(this->travelNode);
     815        //State::getCameraNode()->setParentSoft(this);
     816        //State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
     817        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     818        //State::getCameraTargetNode()->setParentSoft(this);
     819        //State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     820        //this->setCameraMode(Camera::ViewNormal);
     821        State::getCamera()->setEventHandling(false);
     822
     823        PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera());
     824        State::getCamera()->setViewMode(Camera::ViewNormal);
     825        State::getCameraTargetNode()->setParent(this);
     826        State::getCamera()->setParent(this);
     827
     828
     829        registerEvent(KeyMapper::PEV_VIEW0);
     830        registerEvent(KeyMapper::PEV_VIEW1);
     831        registerEvent(KeyMapper::PEV_VIEW2);
     832        registerEvent(KeyMapper::PEV_VIEW3);
     833        registerEvent(KeyMapper::PEV_VIEW4);
     834        registerEvent(KeyMapper::PEV_VIEW5);
     835
     836        State::getCamera()->setParentMode(PNODE_ALL);
     837
     838      break;
     839    }
    897840
    898841    default:
     
    10581001    }
    10591002    case Playable::Vertical:
     1003    {
     1004      if ( !entityTrack || !entityTrack->getActionBox() )
     1005      {
     1006        break;
     1007      }
     1008      ActionBox * box = entityTrack->getActionBox();
     1009
     1010      this->travelVelocity = Vector(0, 0, 0);
     1011      float ssss = 50;
     1012      if ( this->bForward )
     1013      {
     1014        this->travelVelocity += Vector( 0, ssss, 0 );
     1015      }
     1016      if ( this->bBackward )
     1017      {
     1018        this->travelVelocity += Vector( 0, -ssss, 0 );
     1019      }
     1020      if ( this->bLeft )
     1021      {
     1022        this->travelVelocity += Vector( 0, 0, -ssss );
     1023      }
     1024      if ( this->bRight )
     1025      {
     1026        this->travelVelocity += Vector( 0, 0, ssss );
     1027      }
     1028
     1029      Vector ds = this->travelVelocity*dt;
     1030      Vector newPos = this->getRelCoor() + ds;
     1031      if ( newPos.y < -(box->getHeight_2()) || newPos.y > box->getHeight_2() )
     1032      {
     1033        this->travelVelocity.y = 0;
     1034      }
     1035      if ( newPos.z > box->getWidth_2() || newPos.z < -(box->getWidth_2()) )
     1036      {
     1037        this->travelVelocity.z = 0;
     1038      }
     1039    }
    10601040      break;
    10611041    default:
     
    10991079}
    11001080
    1101 void SpaceShip::updateElectronicWidget()
    1102 {
    1103   if (this->electronicWidget != NULL)
    1104   { //if it exists already: update it
    1105      this->electronicWidget->setMaximum(this->electronicMax);
    1106      this->electronicWidget->setValue(this->electronicCur);
    1107   }
    1108   else
    1109   { //create the widget
    1110     this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1111     this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
    1112     //this->electronicWidget->setDisplayedName("Electronics:");
    1113     //this->electronicWidget->setSize2D(100,20);
    1114     //this->electronicWidget->setAbsCoor2D(150,200);
    1115     this->updateElectronicWidget();
    1116     if (this->hasPlayer())
    1117       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
    1118   }
    1119 }
    1120 
    1121 void SpaceShip::updateShieldWidget()
    1122 {
    1123   if (this->shieldWidget != NULL)
    1124   {
    1125     this->shieldWidget->setMaximum(this->shieldMax);
    1126     this->shieldWidget->setValue(this->shieldCur);;
    1127   }
    1128   else
    1129   {
    1130     this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
    1131     this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
    1132     //this->shieldWidget->setDisplayedName("Shield:");
    1133     //his->shieldWidget->setSize2D(100,20);
    1134     //this->shieldWidget->setAbsCoor2D(200,200);
    1135     this->updateShieldWidget();
    1136     if (this->hasPlayer())
    1137       State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
    1138   }
    1139 }
     1081// void SpaceShip::updateElectronicWidget()
     1082// {
     1083//   if (this->electronicWidget != NULL)
     1084//   { //if it exists already: update it
     1085//      this->electronicWidget->setMaximum(this->electronicMax);
     1086//      this->electronicWidget->setValue(this->electronicCur);
     1087//   }
     1088//   else
     1089//   { //create the widget
     1090//     this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1091//     this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1092//     //this->electronicWidget->setDisplayedName("Electronics:");
     1093//     //this->electronicWidget->setSize2D(100,20);
     1094//     //this->electronicWidget->setAbsCoor2D(150,200);
     1095//     this->updateElectronicWidget();
     1096//     if (this->hasPlayer())
     1097//       State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);
     1098//   }
     1099// }
     1100//
     1101// void SpaceShip::updateShieldWidget()
     1102// {
     1103//   if (this->shieldWidget != NULL)
     1104//   {
     1105//     this->shieldWidget->setMaximum(this->shieldMax);
     1106//     this->shieldWidget->setValue(this->shieldCur);;
     1107//   }
     1108//   else
     1109//   {
     1110//     this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();
     1111//     this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));
     1112//     //this->shieldWidget->setDisplayedName("Shield:");
     1113//     //his->shieldWidget->setSize2D(100,20);
     1114//     //this->shieldWidget->setAbsCoor2D(200,200);
     1115//     this->updateShieldWidget();
     1116//     if (this->hasPlayer())
     1117//       State::getPlayer()->hud().setShiledWidget(this->shieldWidget);
     1118//   }
     1119// }
     1120
    11401121
    11411122void SpaceShip::setCameraDistance(float dist)
     
    11761157
    11771158  State::getPlayer()->hud().setOverlayPercentage(100-int(100*this->actionWidthPercentage));
    1178   PRINTF(0)("TravelDistance has been updated\n");
     1159//   PRINTF(0)("TravelDistance has been updated\n");
    11791160  this->isTravelDistanceInit = true;
    11801161}
     
    11891170    this->isTravelDistanceInit = false;
    11901171};
     1172
     1173
Note: See TracChangeset for help on using the changeset viewer.