Changeset 7163 for code/trunk/src/modules/pickup/items/InvisiblePickup.cc
- Timestamp:
- Aug 11, 2010, 8:55:13 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
- Property svn:eol-style set to native
r6755 r7163 34 34 #include "InvisiblePickup.h" 35 35 36 #include <sstream> 37 #include <OgreEntity.h> 38 #include <OgreAnimationState.h> 39 40 #include "util/StringUtils.h" 36 41 #include "core/CoreIncludes.h" 37 42 #include "core/XMLPort.h" 38 #include "util/StringUtils.h"39 43 40 44 #include "worldentities/pawns/Pawn.h" 41 45 #include "pickup/PickupIdentifier.h" 42 46 43 #include <sstream>44 45 47 namespace orxonox 46 48 { 47 49 48 50 CreateFactory(InvisiblePickup); 49 51 50 52 /** 51 53 @brief … … 56 58 RegisterObject(InvisiblePickup); 57 59 //! Defines who is allowed to pick up the pickup. 58 this->initialize(); 59 } 60 60 this->initialize(); 61 } 62 61 63 /** 62 64 @brief … … 64 66 */ 65 67 InvisiblePickup::~InvisiblePickup() 66 { 67 } 68 69 68 { 69 } 70 71 70 72 void InvisiblePickup::initializeIdentifier(void) 71 73 { … … 76 78 this->pickupIdentifier_->addParameter(type1, val1); 77 79 } 78 80 79 81 /** 80 82 @brief … … 93 95 void InvisiblePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) 94 96 { 95 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 97 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 96 98 XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode); 97 99 98 100 this->initializeIdentifier(); 99 101 } 100 102 101 103 /** 102 104 @brief … … 106 108 { 107 109 SUPER(InvisiblePickup, changedUsed); 108 110 109 111 //! If the pickup is not picked up nothing must be done. 110 112 if(!this->isPickedUp()) 111 113 return; 112 114 113 115 if (this->isUsed()) 114 116 { … … 121 123 this->startPickupTimer(this->getDuration()); 122 124 } 125 123 126 this->setInvisible(true); 127 124 128 } 125 129 else 126 130 { 127 131 this->setInvisible(false); 128 132 129 133 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration()) 130 134 { 131 this-> destroy();135 this->Pickupable::destroy(); 132 136 } 133 137 else … … 136 140 } 137 141 } 138 139 } 140 142 143 } 144 141 145 /** 142 146 @brief … … 149 153 PickupCarrier* carrier = this->getCarrier(); 150 154 Pawn* pawn = dynamic_cast<Pawn*>(carrier); 151 155 152 156 if(pawn == NULL) 153 157 { … … 156 160 return pawn; 157 161 } 158 162 159 163 /** 160 164 @brief … … 167 171 if(item == NULL) 168 172 item = new InvisiblePickup(this); 169 173 170 174 SUPER(InvisiblePickup, clone, item); 171 175 172 176 InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item); 173 177 pickup->setDuration(this->getDuration()); 174 178 pickup->initializeIdentifier(); 175 179 } 176 180 177 181 /** 178 182 @brief … … 186 190 if(pawn == NULL) 187 191 return false; 188 192 189 193 pawn->setVisible(!invisibility); 194 pawn->setRadarVisibility(!invisibility); 195 196 // Test to change Material at runtime! 197 198 // Ogre::MaterialPtr mat = this->mesh_.getEntity()->getSubEntity(0)->getMaterial(); 199 // mat->setDiffuse(0.4, 0.3, 0.1, 0.1); 200 // mat->setAmbient(0.3, 0.7, 0.8); 201 // mat->setSpecular(0.5, 0.5, 0.5, 0.1); 202 // Ogre::SceneBlendType sbt = Ogre::SBT_ADD; 203 // 204 // mat->setSceneBlending(sbt); 205 190 206 return true; 191 207 } 192 208 193 209 /** 194 210 @brief … … 209 225 } 210 226 } 211 227 212 228 void InvisiblePickup::pickupTimerCallback(void) 213 229 {
Note: See TracChangeset
for help on using the changeset viewer.