Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

some getAttr for GUI, damage and shield handlers

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.