Changeset 10670 in orxonox.OLD for branches/vs-enhencements/src/world_entities/world_entity.cc
- Timestamp:
- Jun 5, 2007, 2:48:15 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.