Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9965 in orxonox.OLD for branches/playability/src/world_entities


Ignore:
Timestamp:
Nov 28, 2006, 11:54:34 PM (18 years ago)
Author:
marcscha
Message:

Modifications to ship, HUD,.. see changelog

Location:
branches/playability/src/world_entities
Files:
5 edited

Legend:

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

    r9963 r9965  
    8484 */
    8585SpaceShip::SpaceShip(const std::string& fileName)
    86     : primWeaponMan(this),
    87     secWeaponMan(this),
     86    : secWeaponMan(this),
    8887    supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical),
    8988    playmode(Playable::Full3D)
     
    108107*/
    109108SpaceShip::SpaceShip(const TiXmlElement* root)
    110     : primWeaponMan(this),
    111     secWeaponMan(this),
     109    : secWeaponMan(this),
    112110    supportedPlaymodes(Playable::Full3D || Playable::Horizontal || Playable::Vertical),
    113111    playmode(Playable::Full3D)
     
    140138
    141139
    142   this->primWeaponMan.addWeapon( wpLeft, 1, 0);
    143   this->primWeaponMan.addWeapon( wpRight, 1, 1);
    144   this->secWeaponMan.addWeapon( cannon, 0, 6);
    145 
    146   this->primWeaponMan.changeWeaponConfig(1);
     140  this->weaponMan.addWeapon( wpLeft, 0, 0);
     141  this->weaponMan.addWeapon( wpRight, 0, 1);
     142  this->secWeaponMan.addWeapon( cannon, 0, 0);
     143
     144  this->weaponMan.changeWeaponConfig(0);
    147145
    148146  wpRight->requestAction(WA_ACTIVATE);
    149147  wpLeft->requestAction(WA_ACTIVATE);
    150148  cannon->requestAction(WA_ACTIVATE);
     149
     150  this->curWeaponPrimary    = 0;
     151  this->curWeaponSecondary  = 0;
     152
     153  Playable::weaponConfigChanged();
     154
     155  weaponEnergyRegen = 10;   // 10 einheiten pro Sekunde
     156
    151157  /*
    152158  this->addWeapon(wpLeft, 1, 0);
     
    159165  this->loadModel("models/ships/hoverglider_mainbody.obj");
    160166
    161   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bPrimFire = bSecFire = false;
     167  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    162168
    163169  xMouse = yMouse = 0;
     
    178184  this->mouseDir = this->getAbsDir();
    179185  this->pitchDir = this->getAbsDir();
     186
    180187
    181188  //   GLGuiButton* button = new GLGuiPushButton();
     
    205212  registerEvent(EV_MOUSE_MOTION);
    206213
    207   this->primWeaponMan.setSlotCount(6);
    208 
    209   this->primWeaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0));
    210   this->primWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    211 
    212   this->primWeaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0));
    213   this->primWeaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    214 
    215   this->primWeaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5));
    216   this->primWeaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    217 
    218   this->primWeaponMan.setSlotPosition(3, Vector(-1.5, .5, .5));
    219   this->primWeaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    220 
    221   this->primWeaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5));
    222   this->primWeaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    223 
    224   this->primWeaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5));
    225   this->primWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    226   //
    227   this->primWeaponMan.setSlotPosition(6, Vector(-1, 0.0, 0));
    228   this->primWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     214  this->weaponMan.setSlotCount(6);
     215
     216  this->weaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0));
     217  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     218
     219  this->weaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0));
     220  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     221
     222  this->weaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5));
     223  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
     224
     225  this->weaponMan.setSlotPosition(3, Vector(-1.5, .5, .5));
     226  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
     227
     228  this->weaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5));
     229  this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
     230
     231  this->weaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5));
     232  this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    229233
    230234  this->secWeaponMan.setSlotCount(6);
    231235
    232   this->secWeaponMan.setSlotPosition(0, Vector(2.6, -0.5, 0));
     236  this->secWeaponMan.setSlotPosition(0, Vector(2.6, -2.5, 0));
    233237  this->secWeaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    234238
     
    247251  this->secWeaponMan.setSlotPosition(5, Vector(1.5, -.5, -.5));
    248252  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    249   //
    250   this->secWeaponMan.setSlotPosition(6, Vector(1, 0.0, 0));
    251   this->secWeaponMan.setSlotCapability(6, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
     253
    252254  //
    253255  //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
     
    257259  //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    258260
    259   this->primWeaponMan.getFixedTarget()->setParent(this);
    260   this->primWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
     261  this->weaponMan.getFixedTarget()->setParent(this);
     262  this->weaponMan.getFixedTarget()->setRelCoor(100000,0,0);
    261263
    262264  this->secWeaponMan.getFixedTarget()->setParent(this);
    263265  this->secWeaponMan.getFixedTarget()->setRelCoor(100000,0,0);
    264266
    265   dynamic_cast<Element2D*>(this->primWeaponMan.getFixedTarget())->setVisibility( false);
     267  dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false);
    266268
    267269  this->burstEmitter = new DotEmitter(200, 0.0, .01);
     
    315317void SpaceShip::reset()
    316318{
    317   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     319  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    318320
    319321  xMouse = yMouse = 0;
     
    381383
    382384  // Own Tick Setup, as a different fire routine is used on the weapon manager
    383   this->primWeaponMan.tick(time);
     385  this->weaponMan.tick(time);
    384386  this->secWeaponMan.tick(time);
    385387
    386   if( this->bPrimFire)
    387   {
    388     this->primWeaponMan.fire();
     388  if( this->bFire)
     389  {
     390    this->weaponMan.fire();
    389391  }
    390392  if( this->bSecFire)
    391393  {
    392394    this->secWeaponMan.fire();
    393     this->bSecFire = !this->bSecFire;
    394   }
     395    this->bSecFire = !this->bSecFire;   // FIXME This currently is needed to prevent "echo fires" of a second rocket after its cooldown has passed
     396  }
     397
     398  this->weaponRegen(time);
    395399
    396400  if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == SharedNetworkData::getInstance()->getHostID() )
     
    572576    this->bSecFire = event.bPressed;
    573577  else if( event.type == KeyMapper::PEV_FIRE1)
    574     this->bPrimFire = event.bPressed;
     578    this->bFire = event.bPressed;
    575579  else if( event.type == EV_MOUSE_MOTION)
    576580  {
     
    639643  }
    640644}
     645
     646/**
     647 * Weapon regeneration
     648 * does not use any reactor capacity, as it wouldn't work in a consistent way.
     649 */
     650void SpaceShip::weaponRegen(float time)
     651{
     652  float energy  = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;
     653  Weapon* weapon;
     654  for( int i=0; i < this->weaponMan.getSlotCount(); i++)
     655  {
     656    weapon = this->weaponMan.getWeapon(i);
     657    if( weapon != NULL && weapon->isActive())
     658    {
     659      weapon->increaseEnergy( energy);
     660      weapon->updateWidgets();
     661    }
     662
     663  }
     664  // weaponMan.increaseAmmunition( weapon, energy);
     665 
     666}
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r9963 r9965  
    4848    virtual void process(const Event &event);
    4949
     50    inline WeaponManager getWeaponManagerSecondary() { return this->secWeaponMan; };
     51
    5052    //Functions for GUI
    5153    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
     
    6870    void regen(float time);  //!< handler for shield and electronic regeneration
    6971
    70     WeaponManager         primWeaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
     72    void weaponRegen(float time);   //!< weapon energy regeneration
     73
     74    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
    7175    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
    7276    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
    7377    Playable::Playmode    playmode;           //!< The current playmode.
    74     bool                  bPrimFire;
    7578    bool                  bSecFire;
    7679
     
    98101    int         weaponEnergyUsed;
    99102    float       weaponEnergyShare;
     103    float       weaponEnergyRegen;
    100104    int         weaponSpecialSlot;  //!< number of special weapon slots
    101105    int         weaponSpecialUsed;
    102106
    103     int         reactorOutput;      //!< reactor output
    104     int         reactorCapacity;    //!< reactor capacity
    105 
     107    float       reactorOutput;      //!< reactor output
     108    float       reactorCapacity;    //!< reactor capacity
    106109
    107110    int         curWeaponPrimary;   //!< current primary weapon config
  • branches/playability/src/world_entities/weapons/weapon.h

    r9869 r9965  
    169169    bool check() const;
    170170    void debug() const;
     171
     172    void updateWidgets();
    171173
    172174  protected:
     
    200202    inline void enterState(WeaponState state);
    201203
    202     void updateWidgets();
     204   
    203205
    204206  private:
  • branches/playability/src/world_entities/weapons/weapon_manager.cc

    r9961 r9965  
    317317
    318318/**
    319  * @brief does the same as the funtion inclreaseAmmunition, added four your convenience
     319 * @brief does the same as the funtion increaseAmmunition, added four your convenience
    320320 * @param weapon, the Weapon to read the ammo-info about.
    321321 * @param ammo how much ammo to add.
    322322 */
    323 float WeaponManager::inclreaseAmmunition(const Weapon* weapon, float ammo)
     323float WeaponManager::increaseAmmunition(const Weapon* weapon, float ammo)
    324324{
    325325  assert (weapon != NULL);
  • branches/playability/src/world_entities/weapons/weapon_manager.h

    r9869 r9965  
    9191
    9292    float increaseAmmunition(const ClassID& projectileType, float ammo);
    93     float inclreaseAmmunition(const Weapon* weapon, float ammo);
     93    float increaseAmmunition(const Weapon* weapon, float ammo);
    9494
    9595    /** @returns a fixed target namely the Crosshair's 3D position */
Note: See TracChangeset for help on using the changeset viewer.