Changeset 2324 for code/branches/pickups2/src/orxonox/objects/pickup
- Timestamp:
- Dec 3, 2008, 4:07:49 PM (16 years ago)
- Location:
- code/branches/pickups2/src/orxonox/objects/pickup
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickups2/src/orxonox/objects/pickup/Item.cc
r2293 r2324 8 8 #include "util/String.h" 9 9 #include "objects/worldentities/pawns/Pawn.h" 10 10 11 11 12 namespace orxonox … … 30 31 bool Item::addTo (Pawn* player) 31 32 { 33 34 return player->getPickUp().insert(this); 32 35 /*if(checkSlot(player)==true) 33 36 player->pickUp.Equipment.insert ( std::pair<std::string, Item*>(this->getName(),this) ); 34 37 else 35 38 COUT(3) << "swap?" << std::endl;*/ 36 return player->getPickUp().insert(this);37 39 } 38 40 bool Item::remove(Pawn* player) … … 51 53 bool Item::checkSlot(Pawn* player) 52 54 { 53 /*std::multimap<std::string,Item*>::iterator it;54 for ( it=player-> pickUp.Equipment.begin() ; it != player->pickUp.Equipment.end(); it++ )55 std::multimap<std::string,Item*>::iterator it; 56 for ( it=player->getPickUp().getEquipment().begin() ; it != player->getPickUp().getEquipment().end(); it++ ) 55 57 { 56 58 if((*it).second->playerBaseClass_==this->playerBaseClass_) 57 59 return false; 58 60 } 59 return true; */60 return player->getPickUp().checkSlot(this);61 return true; 62 //return player->getPickUp().checkSlot(player); 61 63 } 62 64 void Item::setPlayerBaseClassName(const std::string& name) -
code/branches/pickups2/src/orxonox/objects/pickup/Item.h
r2293 r2324 4 4 #include "core/BaseObject.h" 5 5 #include "OrxonoxPrereqs.h" 6 #include "ShipEquipment.h"7 6 8 7 namespace orxonox 9 8 { 9 class ShipEquipment; 10 10 11 class _OrxonoxExport Item : public BaseObject 11 12 { -
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.cc
r2294 r2324 1 1 #include "Item.h" 2 2 #include "ShipEquipment.h" 3 #include "objects/worldentities/pawns/Pawn.h" 3 4 4 5 5 6 namespace orxonox 6 7 { 8 7 9 bool ShipEquipment::insert(Item* item) 8 10 { 9 if(checkSlot(player)==true) 11 if(checkSlot(item)==true) 12 { 10 13 Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); 11 else 14 return true; 15 } 12 16 COUT(3) << "swap?" << std::endl; 17 return false; 13 18 19 return false; 14 20 }; 15 21 bool ShipEquipment::erase (Item* item) 16 22 { 17 if(Equipment.find(item->getName())!= Equipment.end()) 23 std::multimap<std::string,Item*>::iterator it = Equipment.find(item->getName()); 24 if(it != Equipment.end()) 18 25 { 19 std::multimap<std::string,Item*>::iterator it; 20 it=Equipment.find(item->getName()); 26 //it->second->dropped(this->getPlayer()); 21 27 Equipment.erase (it); 22 28 return true; … … 25 31 return false; 26 32 }; 27 bool ShipEquipment::checkSlot(Item* item) const 33 34 void ShipEquipment::eraseAll() 35 { 36 37 for (std::multimap<std::string,Item*>::iterator it = Equipment.begin(); it != Equipment.end(); ) 38 { 39 40 (it++)->second->dropped(this->getPlayer()); 41 } 42 } 43 44 bool ShipEquipment::checkSlot(Item* item) 28 45 { 29 46 std::multimap<std::string,Item*>::iterator it; 30 for ( it= Equipment.begin() ; it != Equipment.end(); it++ )47 for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ ) 31 48 { 32 if((*it).second-> playerBaseClass_==item->playerBaseClass_)49 if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass()) 33 50 return false; 34 51 } -
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.h
r2294 r2324 3 3 #include <string> 4 4 #include <map> 5 #include "Item.h"6 5 7 6 /* … … 18 17 namespace orxonox 19 18 { 19 class Item; 20 20 21 class _OrxonoxExport ShipEquipment 21 22 { … … 27 28 bool insert(Item* item); 28 29 bool erase (Item* item); 29 const bool checkSlot(Item* item) const; 30 void eraseAll(); 31 bool checkSlot(Item* item); 30 32 // const std::multimap<std::string, Item*>& getEquipment() const { return this->Equipment; } 33 inline std::multimap<std::string, Item*>& getEquipment() {return this->Equipment;} 34 inline std::multimap<std::string, Item*>& getUsable() {return this->Usable;} 35 inline std::multimap<std::string, Item*>& getTrunk() {return this->Trunk;} 36 inline Pawn* getPlayer() {return this->player ;} 37 inline void setPlayer(Pawn* setplayer) 38 {this->player = setplayer;} 31 39 32 40 private: 41 Pawn* player; 33 42 std::multimap<std::string, Item*> Equipment; 34 43 std::multimap<std::string, Item*> Usable; -
code/branches/pickups2/src/orxonox/objects/pickup/Turbo.cc
r2289 r2324 42 42 { 43 43 SpaceShip* ship = dynamic_cast <SpaceShip*>(player); 44 this->setSpeedBoost(ship); 45 if(duration_==0) 46 addTo(player); 47 return true; 44 if(duration_==0 ) 45 { if(addTo(player)) 46 { 47 this->setSpeedBoost(ship); 48 return true; 49 } 50 } 51 else 52 { 53 this->setSpeedBoost(ship); 54 return true; 55 } 56 return false; 48 57 } 49 58 return false; … … 79 88 if (this->duration_ == 0) 80 89 { 90 COUT(0) << "dropped" << std::endl; 81 91 if(remove(player)==true); 82 92 {
Note: See TracChangeset
for help on using the changeset viewer.