Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 23, 2006, 11:44:35 AM (18 years ago)
Author:
nicolasc
Message:

some getAttr for GUI, damage and shield handlers

Location:
branches/playability/src/world_entities/space_ships
Files:
2 edited

Legend:

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

    r9869 r9950  
    521521
    522522
    523 
    524 
     523int SpaceShip::getShieldCur () { return this->shieldCur; }
     524int SpaceShip::getShieldMax () { return this->shieldMax; }
     525
     526int SpaceShip::getArmorCur () { return this->armorCur; }
     527int SpaceShip::getArmorMax () { return this->armorMax; }
     528
     529int SpaceShip::getElectronicCur () { return this->electronicCur; }
     530int SpaceShip::getElectronicMax () { return this->electronicMax; }
     531
     532void SpaceShip::damage(int pDamage, int eDamage){
     533if( this->shieldActive) {
     534    if( this->shieldCur > pDamage) {
     535      this->shieldCur = this->shieldCur - pDamage;
     536    }
     537    else { // shield <= pDamage
     538      this->shieldCur = 0;
     539      this->shieldActive = false; //shield collaptses
     540      pDamage = pDamage - this->shieldCur;
     541      if( !this->shieldActive) {
     542        this->armorCur = this->armorCur -  pDamage / 2; // remaining damages hits armor at half rate
     543        this->electronicCur = this->electronicCur - eDamage;
     544      }
     545    }
     546  }
     547  else {
     548    this->armorCur = this->armorCur - pDamage;
     549    this->electronicCur = this->electronicCur - eDamage;
     550  }
     551  if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     552}
     553
     554void SpaceShip::shield(){
     555  int time = 1; // FIXME implement tick time calculation
     556  if( this->shieldCur + this->shieldRegen * time > shieldMax)
     557    this->shield = this->shieldMax;
     558  else
     559    this-shieldCur = this->shieldCur + this->shieldRegen * time;
     560
     561  if( this->shieldCur > shieldTH)
     562    this->shieldActive = true;
     563}
     564
  • branches/playability/src/world_entities/space_ships/space_ship.h

    r9949 r9950  
    4747    virtual void process(const Event &event);
    4848
     49    //Functions for GUI
     50    virtual int getShieldCur();     //!< returns current shield value
     51    virtual int getShieldMax();     //!< returns maximum shield value
     52
     53    virtual int getArmorCur();      //!< returns current armor value
     54    virtual int getArmorMax();      //!< returns current armor value
     55
     56    virtual int getElectronicCur(); //!< returns current electronic value
     57    virtual int getElectronicMax(); //!< returns current electronic value
     58
     59    //damage handler
     60    virtual void damage(int pDamage, int eDamage);  //!< pDamage physical damage, eDamage electronic damage
     61
    4962  private:
    5063    void init();
     
    5265    void calculateVelocity(float time);
    5366
     67    void shield();  //!< shield handeler
    5468
    55         int                                     shield;                         //!< current shield
    56         int                                     shieldMax;                      //!< maximum shield
    57         float                           shieldEnergyShare;      //!< percentage of reactor output
     69    //ship atributes
     70    int         shieldCur;          //!< current shield
     71    int         shieldMax;          //!< maximum shield
     72    float       shieldEnergyShare;  //!< percentage of reactor output
     73    int         shieldRegen;        //!< shield regeneration rate
     74    int         shieldTH;           //!< shield threshhold for reactivation
     75    bool        shieldActive;       //!< wheather the shield is working
    5876
    59         int                                     armor;                          //!< current armor
    60         int                                     armorMax;                       //!< maximum armor
     77    int         armorCur;           //!< current armor
     78    int         armorMax;           //!< maximum armor
    6179
    62         int                                     electronic;                     //!< current electronic
    63         int                                     electronicMax;          //!< maximum electronic
     80    int         electronicCur;      //!< current electronic
     81    int         electronicMax;      //!< maximum electronic
    6482
    65         int                                     engineSpeed;            //!< speed output
    66         int                                     enginePowerConsume; //!< energy needed
    67         float                           engineEnergyShare;      //!< percentage of reactor output
     83    int         engineSpeedCur;     //!< speed output
     84    int         enginePowerConsume; //!< energy needed
     85    float       engineEnergyShare;  //!< percentage of reactor output
    6886
    69         int                                     weaponEnergySlot;       //!< number of energy weapon slots
    70         int                                     weaponEnergyUsed;
    71         float                           weaponEnergyShare;
    72         int                                     weaponSpecialSlot;      //!< number of special weapon slots
    73         int                                     weaponSpecialUsed;
     87    int         weaponEnergySlot;   //!< number of energy weapon slots
     88    int         weaponEnergyUsed;
     89    float       weaponEnergyShare;
     90    int         weaponSpecialSlot;  //!< number of special weapon slots
     91    int         weaponSpecialUsed;
    7492
    75         int                                     reactorOutput;          //!< reactor output
    76         int                                     reactorCapacity;        //!< reactor capacity
     93    int         reactorOutput;      //!< reactor output
     94    int         reactorCapacity;    //!< reactor capacity
    7795
    7896    bool                  bUp;                //!< up button pressed.
Note: See TracChangeset for help on using the changeset viewer.