Changeset 10670 in orxonox.OLD for branches/vs-enhencements
- Timestamp:
- Jun 5, 2007, 2:48:15 PM (18 years ago)
- Location:
- branches/vs-enhencements/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/lib/graphics/importer/bsp/bsp_manager.cc
r10618 r10670 173 173 // erase alreadyVisible 174 174 for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false; 175 float tmp = 0;175 // float tmp = 0; 176 176 //this->opal.clear(); 177 177 //this->trasparent.clear(); … … 186 186 187 187 this->viewDir= State::getCamera()->getAbsDirX(); 188 float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);188 // float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z); 189 189 190 190 BspTreeNode* ActLeaf = this->getLeaf(this->bspFile->root, &ship); … … 254 254 255 255 for(int i = 0; i < this->bspFile->numLeafs ; ++i ) { 256 leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ;256 // leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ; 257 257 leaf& curLeaf = (this->bspFile->leaves)[i] ; 258 258 int& cluster = curLeaf.cluster; -
branches/vs-enhencements/src/util/hud.cc
r10659 r10670 138 138 } 139 139 140 void Hud::setShi ledWidget(OrxGui::GLGuiWidget* widget)140 void Hud::setShieldWidget(OrxGui::GLGuiWidget* widget) 141 141 { 142 142 /* -
branches/vs-enhencements/src/util/hud.h
r10368 r10670 39 39 void setBackGround(); 40 40 void setEnergyWidget(OrxGui::GLGuiWidget* widget); 41 void setShi ledWidget(OrxGui::GLGuiWidget* widget);41 void setShieldWidget(OrxGui::GLGuiWidget* widget); 42 42 void setArmorWidget(OrxGui::GLGuiWidget* widget); 43 43 inline OrxGui::GLGuiWidget* getEnergyWidget() {return this->energyWidget;}; -
branches/vs-enhencements/src/world_entities/playable.h
r10368 r10670 32 32 typedef enum { 33 33 Vertical = 1, //!< Vertical (seen from left or right/move in x-z) 34 Horizontal = 2, //!< Horizontal (see tfrom the top/move in x-y)34 Horizontal = 2, //!< Horizontal (seen from the top/move in x-y) 35 35 FromBehind = 4, //!< Seen from behind (move in z-y) 36 36 Full3D = 8, //!< Full featured 3D-mode. (move in all directions x-y-z) -
branches/vs-enhencements/src/world_entities/projectiles/swarm_projectile.cc
r10649 r10670 204 204 /** old guiding function*/ 205 205 206 float projectileVelocity = this->getVelocity().len();206 static float projectileVelocity = this->getVelocity().len(); 207 207 if (target != NULL){ 208 Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized();208 static Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized(); 209 209 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 210 210 } -
branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc
r10669 r10670 161 161 this->secWeaponMan.setSlotCount(6); 162 162 163 this->weaponMan.createWeaponSlot(0, 3. 006, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);164 this->weaponMan.createWeaponSlot(1, 3. 006, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);165 this->weaponMan.createWeaponSlot(2, 4. 03, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);166 this->weaponMan.createWeaponSlot(3, 4. 03, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);167 this->weaponMan.createWeaponSlot(4, 1. 431, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);168 this->weaponMan.createWeaponSlot(5, 1. 431, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);169 this->weaponMan.createWeaponSlot(6, 1. 431, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);170 this->weaponMan.createWeaponSlot(7, 1. 431, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);163 this->weaponMan.createWeaponSlot(0, 3.270, 1.028, .155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 164 this->weaponMan.createWeaponSlot(1, 3.270, 1.028, -.155, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 165 this->weaponMan.createWeaponSlot(2, 4.385, .063, .876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 166 this->weaponMan.createWeaponSlot(3, 4.385, -.063, -.876, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 167 this->weaponMan.createWeaponSlot(4, 1.635, -.612, 2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 168 this->weaponMan.createWeaponSlot(5, 1.536, -.612, -2.691, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 169 this->weaponMan.createWeaponSlot(6, 1.536, -.612, 3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 170 this->weaponMan.createWeaponSlot(7, 1.536, -.612, -3.254, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 171 171 172 172 … … 212 212 213 213 214 setEnergyShare(.3,.3,.4);215 setShield(100, 100, .2, 2);216 setArmor(100, 100);217 setElectronic(50, 50, .7, 3.0);214 // loadEnergyShare(.3,.3,.4); 215 // loadShield(80, 100, .2, 2); 216 // loadHealth(100, 100, 0); 217 // loadElectronic(40, 50, .7, 3.0); 218 218 219 219 // this->loadModel("models/spaceships/fighter_redesign9.obj"); … … 232 232 233 233 234 this->electronicWidget = NULL;235 this->shieldWidget = NULL;234 // this->electronicWidget = NULL; 235 // this->shieldWidget = NULL; 236 236 237 237 //add events to the eventlist … … 290 290 291 291 292 this->toList(OM_GROUP_00); 292 // this->toList(OM_GROUP_00); 293 294 if ( this->hasPlayer() ){ 295 State::getPlayer()->hud().setShieldWidget(this->getShieldWidget()); 296 State::getPlayer()->hud().setEnergyWidget(this->getElectronicWidget()); 297 } 293 298 } 294 299 … … 313 318 LoadParam(root, "setReactor", this, SpaceShip, setReactor) 314 319 .describe("set reactor output"); 315 LoadParam(root, " setShield", this, SpaceShip, setShield)320 LoadParam(root, "loadShield", this, WorldEntity, loadShield) 316 321 .describe("set shield parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 317 LoadParam(root, " setArmor", this, SpaceShip, setArmor)322 LoadParam(root, "loadHealth", this, WorldEntity, loadHealth) 318 323 .describe("set armor/health parameters: current strenght , max strenght"); 319 LoadParam(root, " setElectronic", this, SpaceShip, setElectronic)324 LoadParam(root, "loadElectronic", this, WorldEntity, loadElectronic) 320 325 .describe("set electronics parameters: current strenght , max strenght, threshhold value (0..1), regeneration rate"); 321 326 LoadParam(root, "setEngine", this, SpaceShip, setEngine) 322 327 .describe("set base speed"); 323 LoadParam(root, " setEnergyShare", this, SpaceShip, setEnergyShare)328 LoadParam(root, "loadEnergyShare", this, SpaceShip, loadEnergyShare) 324 329 .describe("set energy partitioning: shield, weapons, engine (sum should be 1)"); 325 330 LoadParam(root, "setWeapon", this, SpaceShip, setWeapon) … … 352 357 bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false; 353 358 354 355 // this->armorCur = this->armorMax; 356 this->setHealth(this->getHealthMax()); 357 this->shieldCur = this->shieldMax; 358 this->shieldActive = true; 359 this->electronicCur = this->electronicMax; 360 // this->updateHealth(); 359 this->resetHealth(); 360 this->resetShield(); 361 this->resetElectronic(); 361 362 this->velocity = Vector(0.0, 0.0, 0.0); 362 363 } … … 664 665 PRINTF(5)("ship hit for (%f,%f) \n",pDamage,eDamage); 665 666 666 if( this->shieldActive) { 667 if( this->shieldCur > pDamage) { 668 this->shieldCur = this->shieldCur - pDamage; 669 } 670 else { // shield <= pDamage 671 this->shieldCur -=pDamage; 672 this->shieldActive = false; //shield collapses 673 pDamage += this->shieldCur; 674 if( !this->shieldActive) { 675 this->decreaseHealth( pDamage / 2); // remaining damages hits armor at half rate 676 this->electronicCur -= eDamage; 677 } 678 } 679 } 680 else { 681 this->decreaseHealth(pDamage); 682 this->electronicCur = this->electronicCur - eDamage; 683 } 684 if( this->getHealth() <= 0) { /* FIXME implement shipcrash*/ } 667 static float tmp = this->decreaseShield(pDamage); 668 if( tmp > 0) 669 if ( this->decreaseHealth(tmp / 2) ) 685 670 this->destroy(this); 686 671 687 updateElectronicWidget(); 688 updateShieldWidget(); 689 690 // this->setHealth( this->armorCur); 691 } 692 693 694 void SpaceShip::regen(float time){ 695 static float tmp, armorCur, armorMax; 696 if (armorCur != armorMax || this->armorRegen != 0){ 697 tmp = armorCur + armorRegen * time; 698 if ( tmp > armorMax) 699 armorCur = armorMax; 700 else 701 armorCur = tmp; 702 } 703 if (this->shieldCur != this->shieldMax || this->shieldRegen != 0){ 704 tmp = this->shieldCur + (this->shieldRegen + this->reactorOutput * this->shieldEnergyShare) * time; 705 if( tmp > shieldMax) 706 this->shieldCur = this->shieldMax; 707 else 708 this->shieldCur = tmp; 709 this->shieldActive = ( this->shieldActive || this->shieldCur > shieldTH); 710 711 updateShieldWidget(); 712 } 713 714 this->setHealth( this->shieldCur); // FIXME currently just to test share system 715 716 if (this->electronicCur != this->electronicMax || this->electronicRegen != 0){ 717 tmp = this->electronicCur + this->electronicRegen * time; 718 if ( tmp > electronicMax) 719 this->electronicCur = this->electronicMax; 720 else 721 this->electronicCur = tmp; 722 723 updateElectronicWidget(); 724 } 725 726 } 672 } 673 727 674 728 675 … … 733 680 void SpaceShip::weaponRegen(float time) 734 681 { 735 float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time;682 float energy = ( this->reactorOutput * this->weaponEnergyShare + this->weaponEnergyRegen) * time ; 736 683 Weapon* weapon; 737 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++)738 {684 int weaponCount = 0; 685 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) { 739 686 weapon = this->weaponMan.getWeapon(i); 740 if( weapon != NULL && weapon->isActive()) 741 { 687 if( weapon != NULL && weapon->isActive()) { 688 weaponCount++; 689 } 690 } 691 692 if (weaponCount == 0) 693 return; 694 energy *= ( this->weaponMan.getSlotCount() / (float)weaponCount ); 695 696 for( unsigned int i=0; i < this->weaponMan.getSlotCount(); i++) { 697 weapon = this->weaponMan.getWeapon(i); 698 if( weapon != NULL && weapon->isActive()) { 742 699 weapon->increaseEnergy( energy); 743 700 } 744 745 701 } 746 702 // weaponMan.increaseAmmunition( weapon, energy); … … 748 704 749 705 750 void SpaceShip::enterPlaymode(Playable::Playmode playmode) 751 { 706 void SpaceShip::enterPlaymode(Playable::Playmode playmode){ 752 707 switch(playmode) 753 708 { … … 810 765 break; 811 766 812 767 813 768 case Playable::Vertical: 814 769 { … … 832 787 //this->setCameraMode(Camera::ViewNormal); 833 788 State::getCamera()->setEventHandling(false); 834 789 835 790 PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera()); 836 791 State::getCamera()->setViewMode(Camera::ViewNormal); … … 838 793 State::getCamera()->setParent(this); 839 794 840 841 795 842 796 registerEvent(KeyMapper::PEV_VIEW0); 843 797 registerEvent(KeyMapper::PEV_VIEW1); … … 848 802 849 803 State::getCamera()->setParentMode(PNODE_ALL); 850 804 851 805 break; 852 806 } 853 807 854 808 default: 855 809 PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName()); … … 1020 974 } 1021 975 ActionBox * box = entityTrack->getActionBox(); 1022 976 1023 977 this->travelVelocity = Vector(0, 0, 0); 1024 978 float ssss = 50; … … 1039 993 this->travelVelocity += Vector( 0, 0, ssss ); 1040 994 } 1041 995 1042 996 Vector ds = this->travelVelocity*dt; 1043 997 Vector newPos = this->getRelCoor() + ds; … … 1092 1046 } 1093 1047 1094 void SpaceShip::updateElectronicWidget()1095 {1096 if (this->electronicWidget != NULL)1097 { //if it exists already: update it1098 this->electronicWidget->setMaximum(this->electronicMax);1099 this->electronicWidget->setValue(this->electronicCur);1100 }1101 else1102 { //create the widget1103 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical();1104 this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));1105 //this->electronicWidget->setDisplayedName("Electronics:");1106 //this->electronicWidget->setSize2D(100,20);1107 //this->electronicWidget->setAbsCoor2D(150,200);1108 this->updateElectronicWidget();1109 if (this->hasPlayer())1110 State::getPlayer()->hud().setEnergyWidget(this->electronicWidget);1111 }1112 }1113 1114 void SpaceShip::updateShieldWidget()1115 {1116 if (this->shieldWidget != NULL)1117 {1118 this->shieldWidget->setMaximum(this->shieldMax);1119 this->shieldWidget->setValue(this->shieldCur);;1120 }1121 else1122 {1123 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical();1124 this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1));1125 //this->shieldWidget->setDisplayedName("Shield:");1126 //his->shieldWidget->setSize2D(100,20);1127 //this->shieldWidget->setAbsCoor2D(200,200);1128 this->updateShieldWidget();1129 if (this->hasPlayer())1130 State::getPlayer()->hud().setShiledWidget(this->shieldWidget);1131 }1132 }1048 // void SpaceShip::updateElectronicWidget() 1049 // { 1050 // if (this->electronicWidget != NULL) 1051 // { //if it exists already: update it 1052 // this->electronicWidget->setMaximum(this->electronicMax); 1053 // this->electronicWidget->setValue(this->electronicCur); 1054 // } 1055 // else 1056 // { //create the widget 1057 // this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1058 // this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1059 // //this->electronicWidget->setDisplayedName("Electronics:"); 1060 // //this->electronicWidget->setSize2D(100,20); 1061 // //this->electronicWidget->setAbsCoor2D(150,200); 1062 // this->updateElectronicWidget(); 1063 // if (this->hasPlayer()) 1064 // State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1065 // } 1066 // } 1067 // 1068 // void SpaceShip::updateShieldWidget() 1069 // { 1070 // if (this->shieldWidget != NULL) 1071 // { 1072 // this->shieldWidget->setMaximum(this->shieldMax); 1073 // this->shieldWidget->setValue(this->shieldCur);; 1074 // } 1075 // else 1076 // { 1077 // this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1078 // this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1079 // //this->shieldWidget->setDisplayedName("Shield:"); 1080 // //his->shieldWidget->setSize2D(100,20); 1081 // //this->shieldWidget->setAbsCoor2D(200,200); 1082 // this->updateShieldWidget(); 1083 // if (this->hasPlayer()) 1084 // State::getPlayer()->hud().setShiledWidget(this->shieldWidget); 1085 // } 1086 // } 1133 1087 1134 1088 void SpaceShip::setCameraDistance(float dist) … … 1183 1137 }; 1184 1138 1185 // void SpaceShip::addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName){ 1186 // if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); } 1187 // if (wm == 1) { this->weaponMan.addWeapon( Weapon::createWeapon( weaponName ), config, slot); } 1188 // else return; 1189 // } 1190 1139 -
branches/vs-enhencements/src/world_entities/space_ships/space_ship.h
r10669 r10670 12 12 #include "playable.h" 13 13 #include "extendable.h" 14 #include "world_entity.h" 14 15 15 16 // Forward Declaration … … 64 65 65 66 //!< functions for XML loading 66 inline void setReactor(float output) {this->reactorOutput = output; }; 67 inline void setShield(float cur, float max, float th, float regen) 68 { this->shieldCur = cur; this->shieldMax = max; this->shieldTH = th; this->shieldRegen = regen;}; 69 inline void setArmor(float cur, float max) { this->setHealth(cur); this->setHealthMax(max); }; 70 inline void setElectronic(float cur, float max, float th, float regen) 71 { this->electronicCur = cur; this->electronicMax = max; this->electronicTH = th; this->electronicRegen = regen; }; 72 inline void setEngine( float speedBase) {this->engineSpeedBase = speedBase; }; 73 inline void setEnergyShare(float shield, float weapon, float engine) 67 void setReactor(float output) {this->reactorOutput = output; }; 68 void setEngine( float speedBase) {this->engineSpeedBase = speedBase; }; 69 void loadEnergyShare(float shield, float weapon, float engine) 74 70 { float tmp = shield + weapon + engine; if (unlikely (tmp > 1)) { tmp = 1/tmp; } 75 // dirty safety hack, prevents total share being bigger than 1!!71 // HACK dirty safety hack, prevents total share being bigger than 1!! 76 72 this->shieldEnergyShare = shield * tmp; 77 73 this->weaponEnergyShare = weapon * tmp; … … 79 75 inline void setWeapon(float regen) { this->weaponEnergyRegen = regen; }; 80 76 81 //!< Resynchonizes armor with health in WE!!82 // inline void updateHealth() { this->setHealth(this->armorCur); this->setHealthMax(this->armorMax); };83 84 77 void addWeaponToSlot(int wm, int config, int slot, const std::string& weaponName); 85 86 //Functions for GUI87 inline float getShieldCur() { return this->shieldCur; }; //!< returns current shield value88 inline float getShieldMax() { return this->shieldMax; }; //!< returns maximum shield value89 90 inline float getArmorCur() { return this->getHealth(); }; //!< returns current armor value91 inline float getArmorMax() { return this->getHealthMax(); }; //!< returns current armor value92 93 inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value94 inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value95 78 96 79 inline PNode* getTravelNode() { return this->travelNode; }; … … 121 104 //void calculateVelocity(float time); 122 105 123 void regen(float time); //!< handler for shield and electronic regeneration106 // void regen(float time); //!< handler for shield and electronic regeneration 124 107 125 108 void weaponRegen(float time); //!< weapon energy regeneration 126 109 127 inline bool systemFailure() { return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };128 129 void updateElectronicWidget();130 void updateShieldWidget();110 // inline bool systemFailure() { return (this->getElectronic() < float(rand())/float(RAND_MAX) * this->getElectronicTH()); }; 111 112 // void updateElectronicWidget(); 113 // void updateShieldWidget(); 131 114 132 115 //WeaponManager weaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping … … 136 119 137 120 //ship atributes 138 float shieldCur; //!< current shield 139 float shieldMax; //!< maximum shield 140 float shieldEnergyShare; //!< percentage of reactor output 141 float shieldRegen; //!< shield regeneration rate per second 142 float shieldTH; //!< shield threshhold for reactivation 143 bool shieldActive; //!< wheather the shield is working 144 OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 121 // float shieldCur; //!< current shield 122 // float shieldMax; //!< maximum shield 123 // float shieldRegen; //!< shield regeneration rate per second 124 // float shieldTH; //!< shield threshhold for reactivation 125 // bool shieldActive; //!< wheather the shield is working 126 // OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 145 127 146 128 // float armorCur; //!< current armor 147 129 // float armorMax; //!< maximum armor 148 float armorRegen; //!< armor regeneration per tick (usable on bioships?)130 // float armorRegen; //!< armor regeneration per tick (usable on bioships?) 149 131 //note that the armor widget is set on the health- widget in world- entity (see in player.cc) 150 132 151 float electronicCur; //!< current electronic152 float electronicMax; //!< maximum electronic153 float electronicRegen; //!< electronic regenration rate per tick154 float electronicTH; //!< Threshhold for electronic failure155 OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar133 // float electronicCur; //!< current electronic 134 // float electronicMax; //!< maximum electronic 135 // float electronicRegen; //!< electronic regenration rate per tick 136 // float electronicTH; //!< Threshhold for electronic failure 137 // OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar 156 138 157 139 float engineSpeedCur; //!< speed output for movement = speed base + energy share part … … 159 141 int enginePowerConsume; //!< energy needed 160 142 float engineEnergyShare; //!< percentage of reactor output 143 float shieldEnergyShare; //!< percentage of reactor output 161 144 162 145 int weaponEnergySlot; //!< number of energy weapon slots -
branches/vs-enhencements/src/world_entities/world_entity.cc
r10618 r10670 75 75 this->aabbNode = NULL; 76 76 this->healthWidget = NULL; 77 this->electronicWidget = NULL; 78 this->shieldWidget = NULL; 77 79 this->healthMax = 1.0f; 78 80 this->health = 1.0f; … … 776 778 this->updateHealthWidget(); 777 779 return 0.0; 778 779 } 780 } 781 780 782 781 783 /** … … 792 794 this->updateHealthWidget(); 793 795 } 796 797 798 799 /** 800 * @param shiled the Shieldstength to add. 801 * @returns the shield left (this->shieldMax - shiled + this->shield) 802 */ 803 float WorldEntity::increaseShield(float shiled) 804 { 805 this->shield += shield; 806 if (this->shield > this->shieldTH * this->shieldMax) { this->bShieldActive = true; } 807 if (this->shield > this->shieldMax) 808 { 809 float retShield = this->shieldMax - this->shield; 810 this->shield = this->shieldMax; 811 this->updateShieldWidget(); 812 return retShield; 813 } 814 this->updateShieldWidget(); 815 return 0.0; 816 } 817 818 /** 819 * @param shield the Shieldstrength to be removed 820 * @returns 0.0 or the rest, if the shield drops belew 0.0 821 */ 822 float WorldEntity::decreaseShield(float shield) 823 { 824 this->shield -= shield; 825 826 if (this->shield <= 0) 827 { 828 float retShield = -this->shield; 829 this->updateShieldWidget(); 830 this->bShieldActive = false; 831 return retShield; 832 } 833 this->updateShieldWidget(); 834 return 0.0; 835 } 836 837 794 838 795 839 /** … … 813 857 } 814 858 859 860 void WorldEntity::createShieldWidget() 861 { 862 if (this->shieldWidget == NULL) 863 { 864 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 865 this->updateHealthWidget(); 866 } 867 else 868 PRINTF(3)("Allready created the ShieldWidget for %s::%s\n", this->getClassCName(), this->getCName()); 869 } 870 871 void WorldEntity::createElectronicWidget() 872 { 873 if (this->electronicWidget == NULL) 874 { 875 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 876 this->updateElectronicWidget(); 877 } 878 else 879 PRINTF(3)("Allready created the ElectronicWidget for %s::%s\n", this->getClassCName(), this->getCName()); 880 } 881 882 815 883 void WorldEntity::increaseHealthMax(float increaseHealth) 816 884 { … … 822 890 OrxGui::GLGuiWidget* WorldEntity::getHealthWidget() 823 891 { 824 this->createHealthWidget(); 892 if ( this->healthWidget == NULL) 893 this->createHealthWidget(); 825 894 return this->healthWidget; 826 895 } 896 897 898 OrxGui::GLGuiWidget* WorldEntity::getShieldWidget() 899 { 900 if ( this->shieldWidget == NULL) 901 this->createShieldWidget(); 902 return this->shieldWidget; 903 } 904 905 906 OrxGui::GLGuiWidget* WorldEntity::getElectronicWidget() 907 { 908 if ( this->electronicWidget == NULL) 909 this->createElectronicWidget(); 910 return this->electronicWidget; 911 } 912 913 827 914 828 915 /** … … 830 917 * (creates the widget if needed) 831 918 */ 832 void WorldEntity::setHealthWidgetVisibilit (bool visibility)919 void WorldEntity::setHealthWidgetVisibility(bool visibility) 833 920 { 834 921 if (visibility) … … 890 977 } 891 978 } 979 980 /** 981 * @brief updates the Electronic Widget 982 */ 983 //!< xferred from spaceship 984 void WorldEntity::updateElectronicWidget(){ 985 if (this->electronicWidget != NULL) 986 { //if it exists already: update it 987 this->electronicWidget->setMaximum(this->electronicMax); 988 this->electronicWidget->setValue(this->electronic); 989 } 990 else 991 { //create the widget 992 this->electronicWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 993 this->electronicWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 994 //this->electronicWidget->setDisplayedName("Electronics:"); 995 //this->electronicWidget->setSize2D(100,20); 996 //this->electronicWidget->setAbsCoor2D(150,200); 997 this->updateElectronicWidget(); 998 // if ( dynamic_cast<SpaceShip*>(this)->hasPlayer() ) 999 // State::getPlayer()->hud().setEnergyWidget(this->electronicWidget); 1000 } 1001 } 1002 1003 /** 1004 * @brief updates the ShieldWidget 1005 */ 1006 //!< xferred from spaceship 1007 void WorldEntity::updateShieldWidget() 1008 { 1009 if (this->shieldWidget != NULL) 1010 { 1011 this->shieldWidget->setMaximum(this->shieldMax); 1012 this->shieldWidget->setValue(this->shield);; 1013 } 1014 else 1015 { 1016 this->shieldWidget = new OrxGui::GLGuiEnergyWidgetVertical(); 1017 this->shieldWidget->getBarWidget()->setChangedValueColor(Color(1,0,0,1)); 1018 //this->shieldWidget->setDisplayedName("Shield:"); 1019 //his->shieldWidget->setSize2D(100,20); 1020 //this->shieldWidget->setAbsCoor2D(200,200); 1021 this->updateShieldWidget(); 1022 // if (dynamic_cast<SpaceShip*>(this)->hasPlayer()) 1023 // State::getPlayer()->hud().setShieldWidget(this->shieldWidget); 1024 } 1025 } 1026 892 1027 893 1028 … … 985 1120 } 986 1121 1122 1123 void WorldEntity::regen(float time){ 1124 static float tmp; 1125 increaseHealth(time * this->healthRegen); 1126 increaseShield(time * this->shieldRegen); 1127 // updateHealthWidget(); 1128 // updateShieldWidget(); 1129 1130 //this->setHealth( this->shieldCur); // FIXME currently just to test share system 1131 1132 if (this->electronic != this->electronicMax || this->electronicRegen != 0){ 1133 tmp = this->electronic + this->electronicRegen * time; 1134 if ( tmp > electronicMax) 1135 this->electronic = this->electronicMax; 1136 else 1137 this->electronic = tmp; 1138 1139 updateElectronicWidget(); 1140 } 1141 1142 } -
branches/vs-enhencements/src/world_entities/world_entity.h
r10669 r10670 161 161 void increaseHealthMax(float increaseHealth); 162 162 OrxGui::GLGuiWidget* getHealthWidget(); 163 OrxGui::GLGuiWidget* getShieldWidget(); 164 OrxGui::GLGuiWidget* getElectronicWidget(); 163 165 bool hasHealthWidget() const { return this->healthWidget != NULL; }; 164 166 167 float getShield() const { return this->shield; }; 168 float getShieldMax() const { return this->shieldMax; }; 169 float increaseShield(float shield); 170 float decreaseShield(float shield); 171 bool getShieldActive() { return this->bShieldActive; }; 172 173 float getElectronic() const { return this->electronic; }; 174 float getElectronicMax() const { return this->electronicMax; }; 175 float increaseElectronic(float electronic); 176 float decreaseElectronic(float electronic); 177 178 bool systemFailure() { return (this->electronic < float(rand())/float(RAND_MAX) * this->electronicTH); }; 179 180 void resetElectronic() { this->electronic = this->electronicMax; }; 181 void resetShield() { this->shield = this->shieldMax; this->bShieldActive = true; }; 182 void resetHealth() { this->health = this->healthMax; }; 183 184 185 void regen(float time); 186 187 void loadShield(float cur, float max, float th, float regen) 188 { this->setShield(cur); this->setShieldMax(max); this->setShieldTH(th); this->setShieldRegen(regen); }; 189 void loadHealth(float cur, float max, float regen = 0) { this->setHealth(cur); this->setHealthMax(max); this->setHealthRegen(regen); }; 190 void loadElectronic(float cur, float max, float th, float regen) 191 { this->setElectronic(cur); this->setElectronicMax(max); this->setElectronicTH(th); this->setElectronicRegen(regen); }; 192 /* 193 OrxGui::GLGuiEnergyWidgetVertical* getHealthWidget() { return this->healthWidget; }; 194 OrxGui::GLGuiEnergyWidgetVertical* getShieldWidget() { return this->shieldWidget; }; 195 OrxGui::GLGuiEnergyWidgetVertical* getEnergyWidget() { return this->electronicWidget; };*/ 196 197 165 198 virtual void varChangeHandler( std::list<int> & id ); 199 200 166 201 167 202 … … 181 216 void pauseTrack(bool stop); 182 217 218 // void updateHealthWidget(); 219 // void updateElectronicWidget(); 220 // void updateShieldWidget(); 183 221 184 222 protected: 185 void setHealth(float health) { this->health = health; this->updateHealthWidget();};186 void setHealthWidgetVisibilit (bool visibility);223 inline void setHealth(float health) { this->health = health; this->updateHealthWidget();}; 224 void setHealthWidgetVisibility(bool visibility); 187 225 void setHealthMax(float healthMax); 188 226 void createHealthWidget(); 227 void createShieldWidget(); 228 void createElectronicWidget(); 229 void setHealthRegen(float regen) { this->healthRegen = regen; }; 189 230 // CharacterAttributes* charAttr; //!< the character attributes of a world_entity 231 232 void setShield(float shield) { this->shield = shield; }; 233 void setShieldMax(float shield) { this->shieldMax = shield; }; 234 void setShieldTH(float th) { this->shieldTH = th; }; 235 void setShieldRegen(float regen) { this->shieldRegen = regen; }; 236 void setShieldActive(bool active) { this->bShieldActive = active; }; 237 238 void setElectronic(float electronic) { this->electronic = electronic; }; 239 void setElectronicMax(float electronic) { this->electronicMax = electronic; }; 240 void setElectronicTH(float th) { this->electronicTH = th; }; 241 void setElectronicRegen(float regen) { this->electronicRegen = regen; }; 190 242 191 243 inline void drawDebugTrack(int flag) { this->bDrawTrack = (bool)flag; } 192 244 inline bool isDrawTrack() const { return this->bDrawTrack; } 193 245 194 195 246 private: 196 247 void updateHealthWidget(); 248 void updateElectronicWidget(); 249 void updateShieldWidget(); 197 250 void addTrack(const TiXmlElement* root); 198 251 … … 206 259 207 260 private: 208 /// TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC 261 //!< TODO maybe we will move the following three entries and the corresponding functions to Playable AND NPC 262 //!< started transfering shield/electronic/health from spaceship to WE! (nico, 4.Jun.07) 209 263 float damage; //!< the damage dealt to other objects by colliding. 210 264 float health; //!< The Energy of this Entity, if the Entity has any energy at all. 211 265 float healthMax; //!< The Maximal energy this entity can take. 266 float healthRegen; //!< Regeneration Rate of Health, mesured in units per second 212 267 OrxGui::GLGuiEnergyWidgetVertical* healthWidget; //!< The Slider (if wanted). 268 269 float shield; //!< current shield 270 float shieldMax; //!< maximum shield 271 float shieldRegen; //!< shield regeneration rate per second 272 float shieldTH; //!< shield threshhold for reactivation 273 bool bShieldActive; //!< wheather the shield is working 274 OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar 275 276 float electronic; //!< current electronic 277 float electronicMax; //!< maximum electronic 278 float electronicRegen; //!< electronic regenration rate per tick 279 float electronicTH; //!< Threshhold for electronic failure 280 OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar 281 213 282 214 283 std::vector<Model*> models; //!< The model that should be loaded for this entity.
Note: See TracChangeset
for help on using the changeset viewer.