Changeset 9232 for code/branches/captureTheFlag/src/modules
- Timestamp:
- May 23, 2012, 5:56:57 PM (13 years ago)
- Location:
- code/branches/captureTheFlag
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/captureTheFlag
- Property svn:mergeinfo changed
/code/branches/waypoints (added) merged: 9032,9043,9054,9093,9105,9159,9177,9219
- Property svn:mergeinfo changed
-
code/branches/captureTheFlag/src/modules/overlays/hud/HUDNavigation.cc
r9016 r9232 36 36 #include <OgreTextAreaOverlayElement.h> 37 37 #include <OgrePanelOverlayElement.h> 38 #include <OgreEntity.h> 38 39 39 40 #include "util/Math.h" … … 45 46 #include "Radar.h" 46 47 #include "graphics/Camera.h" 48 #include "graphics/Model.h" 49 #include "worldentities/MovableEntity.h" 47 50 #include "controllers/HumanController.h" 48 51 #include "worldentities/pawns/Pawn.h" … … 80 83 this->setNavMarkerSize ( 0.05f ); 81 84 this->setDetectionLimit( 10000.0f ); 85 86 //Ogre::Entity* ent = this->getScene()->getSceneManager()->createEntity("Arrow3D", "Arrow3D.mesh"); 87 88 Model* arrow = new Model(this); 89 this->arrowEntity = new MovableEntity(this); 90 arrow->setMeshSource("Arrow3D.mesh"); 91 arrow->setSyncMode(0); 92 this->arrowEntity->attach(arrow); 93 this->arrowEntity->scale(1); 94 this->arrowEntity->setVisible(true); 95 this->arrowEntity->setPosition(0, +30, -100); 96 this->arrowEntity->setSyncMode(0); 97 this->arrowEntity->attachToNode(this->overlay3d_); 98 //this->add3DMesh(arrowEntity); 99 100 //this->overlay3d_->setPosition(0, 0, 0); 101 //this->overlay3d_->setVisible(false, true); 102 this->overlay_->setZOrder(0); 103 this->overlay_->show(); 104 hideArrow3D(); 82 105 } 83 106 … … 178 201 unsigned int markerCount_ = 0; 179 202 bool closeEnough_ = false; //only display objects that are close enough to be relevant for the player 203 204 //for the first element of sortedObjectList_ / the closest waypoint show the Arrow3D 205 //set the direction of the arrow to the closest waypoint 206 if(!sortedObjectList_.empty()) 207 { 208 showArrow3D(); 209 sortedList::iterator firstIt = sortedObjectList_.begin(); 210 211 Ogre::Vector3 pos1 = camTransform * firstIt->first->getRVWorldPosition(); 212 orxout(user_info, context::events()) << pos1 << endl; 213 this->arrowEntity->setDirection(1-pos1.x, 1 - pos1.y, 1 - pos1.z); 214 215 //this->arrowEntity->rotate(quat); 216 //this->overlay3d_->setDirection(pos1); 217 } 218 else{hideArrow3D();} 219 180 220 181 221 // for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it) … … 382 422 this->background_->addChild ( text ); 383 423 384 sortedObjectList_.push_front ( std::make_pair ( object, ( unsigned int ) 0 ) ); 424 Ogre::Vector3 temp = object->getWorldEntity()->getPosition(); 425 unsigned int distance = sqrt(temp.x*temp.x+temp.y*temp.y+temp.z*temp.z); 426 427 428 429 sortedObjectList_.push_front ( std::make_pair ( object, distance ) ); 385 430 386 431 … … 445 490 } 446 491 } 447 448 } 492 void HUDNavigation::showArrow3D() 493 { this->overlay3d_->setVisible(true, true);} 494 void HUDNavigation::hideArrow3D() 495 { this->overlay3d_->setVisible(false, true);} 496 497 498 } -
code/branches/captureTheFlag/src/modules/overlays/hud/HUDNavigation.h
r9016 r9232 42 42 #include "overlays/OrxonoxOverlay.h" 43 43 44 44 45 namespace orxonox 45 46 { … … 51 52 52 53 void setConfigValues(); 54 55 53 56 54 57 virtual void XMLPort ( Element& xmlelement, XMLPort::Mode mode ); … … 80 83 81 84 }; 85 86 void showArrow3D(); 87 void hideArrow3D(); 88 89 orxonox::MovableEntity* arrowEntity; 82 90 83 91 bool showObject( RadarViewable* rv ); -
code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.cc
r9220 r9232 39 39 40 40 #include "pickup/PickupIdentifier.h" 41 #include "worldentities/pawns/Pawn.h"42 41 43 42 namespace orxonox 44 43 { 45 46 /*static*/ const std::string FlagPickup::flagTypeBlue_s = "blue";47 /*static*/ const std::string FlagPickup::flagTypeRed_s = "red";48 /*static*/ const std::string FlagPickup::flagTypeNeutral_s = "neutral";49 44 50 45 CreateFactory(FlagPickup); … … 76 71 void FlagPickup::initialize(void) 77 72 { 78 this->flagType_ = pickupFlagType::0;73 this->flagType_ = 0; 79 74 80 75 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); … … 87 82 void FlagPickup::initializeIdentifier(void) 88 83 { 89 std::string val1 = this->getFlagType(); 84 std::stringstream stream; 85 int type = this->getFlagType(); 86 stream << type; 87 std::string val = stream.str(); 88 90 89 std::string type1 = "flagType"; 91 this->pickupIdentifier_->addParameter(type1, val 1);90 this->pickupIdentifier_->addParameter(type1, val); 92 91 } 93 92 … … 113 112 Returns the falg type as a string. 114 113 */ 115 const std::string&FlagPickup::getFlagType(void) const114 const int FlagPickup::getFlagType(void) const 116 115 { 117 switch(this->getFlagTypeDirect()) 118 { 119 case pickupFlagType::blue: 120 return FlagPickup::flagTypeBlue_s; 121 case pickupFlagType::red: 122 return FlagPickup::flagTypeRed_s; 123 case pickupFlagType::neutral: 124 return FlagPickup::flagTypeNeutral_s; 125 default: 126 orxout(internal_error, context::pickups) << "Invalid flagType in FlagPickup." << endl; 127 return BLANKSTRING; 128 } 129 } 116 return this->flagType_; 117 } 130 118 131 119 /** … … 135 123 The type as a string. 136 124 */ 137 void FlagPickup::setFlagType( std::stringtype)125 void FlagPickup::setFlagType(int type) 138 126 { 139 if(type == FlagPickup::flagTypeRed_s) 140 this->setFlagTypeDirect(pickupFlagType::2); 141 else if(type == FlagPickup::flagTypeBlue_s) 142 this->setFlagTypeDirect(pickupFlagType::1); 143 else if(type == FlagPickup::flagTypeNeutral_s) 144 this->setFlagTypeDirect(pickupFlagType::0); 145 else 127 if(type<3){ 128 this->flagType_ = type; 129 } 130 131 else{ 146 132 orxout(internal_error, context::pickups) << "Invalid flagType '" << type << "' in FlagPickup." << endl; 133 } 147 134 } 148 135 … … 163 150 if(this->isUsed()) 164 151 { 165 int team = getTeam(pawn->getPlayer); 166 167 if(this->flagType_ == team){ 168 if(pawn->hasFlag_){ 169 teamScore_ = TeamScore_ + 1000; 170 pawn->hasFlag_ = false; 171 } 172 this->Pickupable::destroy(); 173 }else{ 174 pawn->hasFlag_ = true; 175 } 152 this->bPickedUp_ = true; 153 this->pickedUpBy_ = pawn; 176 154 } 177 155 } 178 179 180 156 181 157 /** … … 196 172 } 197 173 198 int FlagPickup::getTeam(PlayerInfo* player)199 {200 std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);201 if (it_player != this->teamnumbers_.end())202 return it_player->second;203 else204 return -1;205 }206 174 207 }208 175 209 176 void FlagPickup::tick(float dt) … … 213 180 Pawn* pawn = this->carrierToPawnHelper(); 214 181 215 if(pawn->isAlive() && pawn->hasFlag _){182 if(pawn->isAlive() && pawn->hasFlag()){ 216 183 this->Pickupable::destroy(); 217 184 } 218 185 219 186 } 187 } -
code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.h
r9220 r9232 37 37 38 38 #include "pickup/PickupPrereqs.h" 39 #include "worldentities/pawns/Pawn.h" 39 40 40 41 #include <string> … … 42 43 #include "pickup/Pickup.h" 43 44 #include "tools/Timer.h" 45 #include "tools/interfaces/Tickable.h" 44 46 45 47 … … 47 49 /* 48 50 @ingroup PickupItems 49 */ 50 namespace pickupFlagType 51 { 52 enum Value 53 { 54 blue, //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is the flag of the blue team. 55 red, //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is the flag of the red team. 56 neutral //!< Means that the @ref orxonox::FlagPickup "FlagPickup" is a neutral flag. 57 }; 58 } 59 60 /** 51 61 52 62 53 @author … … 76 67 virtual void tick(float dt); 77 68 78 const std::string& getFlagType(void) const; //!< Get the flag type of this pickup. 79 80 int teamScore_; 81 69 const int getFlagType(void) const; //!< Get the flag type of this pickup. 70 71 inline bool isPickedUp() const 72 { return this->bPickedUp_; } 73 inline Pawn* pickedUpBy() const 74 { return this->pickedUpBy_; } 75 76 inline void setPickedUp(bool pickedUp) 77 { this->bPickedUp_ = pickedUp; } 78 79 inline void ignorePickedUp() 80 { this->Pickupable::destroy(); } 81 82 82 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 83 83 … … 89 89 @param type The type of this pickup as an enum. 90 90 */ 91 inline void setFlagTypeDirect( pickupFlagType::Valuetype)91 inline void setFlagTypeDirect(int type) 92 92 { this->flagType_ = type; } 93 void setFlagType( std::stringtype); //!< Set the type of the FlagPickup.93 void setFlagType(int type); //!< Set the type of the FlagPickup. 94 94 95 95 private: 96 96 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 97 int getTeam(PlayerInfo* player);98 97 void initialize(void); //!< Initializes the member variables. 99 100 pickupFlagType::Value flagType_; //!< The type of the FlagPickup. 101 102 103 //! Strings for the flag types. 104 static const std::string flagTypeBlue_s; 105 static const std::string flagTypeRed_s; 106 static const std::string flagTypeNeutral_s; 107 98 Pawn* pickedUpBy_; 99 int flagType_; 100 101 bool bPickedUp_; 102 108 103 }; 109 104 }
Note: See TracChangeset
for help on using the changeset viewer.