Changeset 2289 for code/branches/pickups2/src
- Timestamp:
- Nov 26, 2008, 7:48:26 PM (16 years ago)
- Location:
- code/branches/pickups2/src/orxonox/objects
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickups2/src/orxonox/objects/pickup/Item.cc
r2227 r2289 29 29 void Item::addTo (Pawn* player) 30 30 { 31 //player->Equipment.insert ( std::pair<std::string, Item*>(this->itemname,this) ); 31 if(checkSlot(player)==true) 32 player->pickUp.Equipment.insert ( std::pair<std::string, Item*>(this->getName(),this) ); 33 else 34 COUT(3) << "swap?" << std::endl; 32 35 } 33 36 bool Item::remove(Pawn* player) 37 { 38 if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end()) 39 { 40 std::multimap<std::string,Item*>::iterator it; 41 it=player->pickUp.Equipment.find(this->getName()); 42 player->pickUp.Equipment.erase (it); 43 return true; 44 } 45 else 46 return false; 47 } 48 bool Item::checkSlot(Pawn* player) 49 { 50 std::multimap<std::string,Item*>::iterator it; 51 for ( it=player->pickUp.Equipment.begin() ; it != player->pickUp.Equipment.end(); it++ ) 52 { 53 if((*it).second->playerBaseClass_==this->playerBaseClass_) 54 return false; 55 } 56 return true; 57 } 34 58 void Item::setPlayerBaseClassName(const std::string& name) 35 59 { -
code/branches/pickups2/src/orxonox/objects/pickup/Item.h
r2227 r2289 12 12 Item( BaseObject* creator); 13 13 virtual ~Item(); 14 14 bool checkSlot(Pawn* player); 15 15 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 16 16 17 17 virtual bool pickedUp(Pawn* player) { return true; } 18 18 virtual bool dropped(Pawn* player) { return true; } //erst bei festen Items 19 bool remove(Pawn* player); 19 20 void addTo(Pawn* player); 20 21 … … 28 29 const std::string& getPlayerBaseClassName() const; 29 30 30 Identifier* playerBaseClass_; //class(...)31 Identifier* playerBaseClass_; 31 32 }; 32 33 } -
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.h
r2094 r2289 3 3 #define _ShipEquipment_H__ 4 4 #include <string> 5 #include <multimap> 5 #include <map> 6 #include "Item.h" 6 7 7 8 … … 11 12 12 13 14 /* std::map<std::itemtype, Item*> EQClasses; 15 EQClasses["jacke"] = 0; 16 Item* item = itemMap_["jacke"]; 17 18 if (itemMap_["jacke"]) 19 if (itemMap_.find("jacke") != itemMap_.end()) */ 13 20 namespace orxonox 14 21 { … … 16 23 { 17 24 public: 18 void AddItem(Shipitem toAddItem); 19 void RemoveItem(Shipitem toRemoveItem); 20 bool CheckifValid(Shipitem toBeChecked); 21 int 25 inline int getSpace() 26 { 27 return Usable.size()+Trunk.size(); 28 }; 29 30 // const std::multimap<std::string, Item*>& getEquipment() const { return this->Equipment; } 22 31 23 32 private: 24 33 std::multimap<std::string, Item*> Equipment; 34 std::multimap<std::string, Item*> Usable; 35 std::multimap<std::string, Item*> Trunk; 25 36 }; 26 37 } … … 39 50 40 51 41 42 43 44 45 52 #endif -
code/branches/pickups2/src/orxonox/objects/pickup/Turbo.cc
r2227 r2289 19 19 this->duration_ = 0; 20 20 this->accboost_ = 1; 21 this->rotacc_= 0; 21 22 } 22 23 … … 32 33 XMLPortParam(Turbo, "duration", setDuration, getDuration, xmlelement, mode); 33 34 XMLPortParam(Turbo, "accboost", setAccBoost, getAccBoost, xmlelement, mode); 35 XMLPortParam(Turbo, "rotacc", setRotAcc, getRotAcc, xmlelement, mode); 36 34 37 } 35 38 … … 53 56 ship->setMaxSpeed( ship->getMaxSpeed() - this->boost_); 54 57 ship->setTransAcc( ship->getTransAcc()/this->accboost_); 58 ship->setMaxRotation( ship->getMaxRotation()-this->rotacc_); 59 ship->setRotAcc( ship->getRotAcc()-this->rotacc_); 55 60 COUT(3)<<"PickUp Timer expired"<<std::endl; 56 61 } … … 60 65 ship->setMaxSpeed( ship->getMaxSpeed() + this->boost_); 61 66 ship->setTransAcc( ship->getTransAcc()*this->accboost_); 67 ship->setMaxRotation( ship->getMaxRotation()+this->rotacc_); 68 ship->setRotAcc( ship->getRotAcc()+this->rotacc_); 62 69 if( this->duration_ != 0) 63 70 { … … 72 79 if (this->duration_ == 0) 73 80 { 74 //player->Equipment.erase ( std::pair<std::string, Item*>(this->itemname,this) ); 81 if(remove(player)==true); 82 { 75 83 SpaceShip* ship = dynamic_cast <SpaceShip*>(player); 76 84 this->unsetSpeedBoost(ship); 85 } 77 86 } 78 87 return true; -
code/branches/pickups2/src/orxonox/objects/pickup/Turbo.h
r2227 r2289 5 5 #include "Item.h" 6 6 #include "OrxonoxPrereqs.h" 7 #include "util/Math.h" 7 8 8 9 namespace orxonox … … 33 34 { return this->duration_; } 34 35 36 inline void setRotAcc(Degree rotacc) 37 { this->rotacc_ = rotacc; } 38 inline Degree getRotAcc() const 39 { return this->rotacc_; } 40 35 41 36 42 inline void setAccBoost(float accboost) … … 44 50 float duration_; 45 51 float accboost_; 52 Degree rotacc_; 46 53 }; 47 54 } -
code/branches/pickups2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2289 31 31 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "objects/pickup/ShipEquipment.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 35 … … 75 75 76 76 virtual void fire(); 77 77 ShipEquipment pickUp; 78 78 virtual void postSpawn(); 79 79 … … 83 83 84 84 bool bAlive_; 85 85 86 86 87 float health_; -
code/branches/pickups2/src/orxonox/objects/worldentities/pawns/SpaceShip.h
r2087 r2289 74 74 inline float getMaxSecondarySpeed() const 75 75 { return this->maxSecondarySpeed_; } 76 inline floatgetMaxRotation() const77 { return this->maxRotation_ .valueDegrees(); }76 inline const Degree& getMaxRotation() const 77 { return this->maxRotation_; } 78 78 inline float getTransAcc() const 79 79 { return this->translationAcceleration_; } 80 inline floatgetRotAcc() const81 { return this->rotationAcceleration_ .valueDegrees(); }80 inline const Degree& getRotAcc() const 81 { return this->rotationAcceleration_; } 82 82 inline float getTransDamp() const 83 83 { return this->translationDamping_; } … … 90 90 float translationAcceleration_; 91 91 float translationDamping_; 92 93 92 Degree maxRotation_; 94 93 Degree rotationAcceleration_;
Note: See TracChangeset
for help on using the changeset viewer.