Changeset 2662 for code/trunk/src/orxonox/objects/pickup
- Timestamp:
- Feb 14, 2009, 10:17:35 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 8 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/pickup/CMakeLists.txt
r2131 r2662 1 1 SET( SRC_FILES 2 ShipEquipmentClasses.cc 3 ShipItem.cc 2 PickupSpawner.cc 3 BaseItem.cc 4 Turbo.cc 5 ShipEquipment.cc 4 6 ) 5 7 -
code/trunk/src/orxonox/objects/pickup/ShipEquipment.h
r2094 r2662 1 2 1 #ifndef _ShipEquipment_H__ 3 2 #define _ShipEquipment_H__ 4 3 #include <string> 5 #include <multimap> 4 #include <map> 5 6 /* 7 multimap<std::string, BaseItem*> equipment_; 8 equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/ 6 9 7 10 8 /* 9 multimap<std::string, Item*> equipment_;10 equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/ 11 /* std::map<std::itemtype, BaseItem*> EQClasses; 12 EQClasses["jacke"] = 0; 13 BaseItem* item = itemMap_["jacke"]; 11 14 12 15 if (itemMap_["jacke"]) 16 if (itemMap_.find("jacke") != itemMap_.end()) */ 13 17 namespace orxonox 14 18 { 19 class BaseItem; 20 /** 21 @brief 22 ShipEquipment is the inventory of a player. It's part of the Pawn class. 23 24 */ 15 25 class _OrxonoxExport ShipEquipment 16 26 { 17 27 public: 18 void AddItem(Shipitem toAddItem); 19 void RemoveItem(Shipitem toRemoveItem); 20 bool CheckifValid(Shipitem toBeChecked); 21 int 22 28 inline int getSpace() 29 { 30 return Usable.size()+Trunk.size(); 31 }; 32 bool insert(BaseItem* item); 33 bool erase (BaseItem* item); 34 //void print(std::multimap<std::string, BaseItem*> eut); 35 void eraseAll(); 36 //bool checkSlot(BaseItem* item); 37 BaseItem* checkSlot(BaseItem* item); 38 // const std::multimap<std::string, BaseItem*>& getEquipment() const { return this->Equipment; } 39 inline std::multimap<std::string, BaseItem*>& getEquipment() {return this->Equipment;} 40 inline std::multimap<std::string, BaseItem*>& getUsable() {return this->Usable;} 41 inline std::multimap<std::string, BaseItem*>& getTrunk() {return this->Trunk;} 42 inline Pawn* getPlayer() {return this->player ;} 43 inline void setPlayer(Pawn* setplayer) 44 {this->player = setplayer;} 23 45 private: 24 std::multimap<std::string, Item*> Equipment; 46 Pawn* player;//!< Is a pointer to the belonging player 47 std::multimap<std::string, BaseItem*> Equipment;//!< the Equipment for permanent Items 48 std::multimap<std::string, BaseItem*> Usable;//!< Where Usables are stored 49 std::multimap<std::string, BaseItem*> Trunk;//!< Every other Item is stored here 25 50 }; 26 51 } … … 39 64 40 65 41 42 43 44 45 66 #endif -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
r2094 r2662 57 57 } 58 58 break; 59 default:;60 59 } 61 60 case Useable: 62 61 return CheckifSpace(); 63 case default:;64 62 } 65 63 return true; … … 67 65 68 66 /*Adds the Item to the Ship*/ 69 void ShipEquipment::AddItem(Ship item* toAddItem)67 void ShipEquipment::AddItem(ShipItem* toAddItem) 70 68 { 71 69 if(CheckifValid(toAddItem)==true) … … 90 88 } 91 89 } 90 91 /*Adds the Item to the Ship*/ 92 void ShipEquipment::AddItem(Shipitem* toAddItem) 93 { 94 if(CheckifValid(toAddItem)==true) 95 { 96 switch(toAddItem.CheckType()){ 97 case Permanent: 98 Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 99 break; 100 case Usable: 101 Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 102 break; 103 case Trunk: 104 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 105 break; 106 } 107 } 108 else if(toAddItem.CheckType()==Permanent) 109 { 110 if(CheckifSpace()==true) 111 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 112 } 113 } 114 115 void ShipEquipment::SwitchItem(Permanent* toSwitchItem) 116 { 117 multimap<string, ShipItem*>::iterator it; 118 string equippedname; 119 equippedname=GetNameofPermanent(toSwitchItem.CheckSubType()); 120 it=Equipment.find(equippedname); 121 Trunk.insert (find(equippedname)); 122 Equipment.erase (it); 123 Equipment.insert(pair<std::string, ShipItem*>(toSwitchItem.itemname,toSwitchItem) 124 } 125 126 string ShipEquipment::GetNameofPermanent (subItemTypePermanent NametoGet) 127 { 128 multimap<string, ShipItem*>::iterator it; 129 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 130 if((*it).second->CheckSubType()==NametoGet){ 131 return (*it).first.itemname; 132 } 133 } 134 return 0; 135 } 92 136 } -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h
r2094 r2662 8 8 9 9 /* 10 multimap<std::string, Item*> equipment_;11 equipment_.insert(pair<std::string, Item*>("Weapon", newItem()));*/10 multimap<std::string, BaseItem*> equipment_; 11 equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/ 12 12 13 13 14 /* std::map<std::itemtype, Item*> EQClasses;14 /* std::map<std::itemtype, BaseItem*> EQClasses; 15 15 EQClasses["jacke"] = 0; 16 Item* item = itemMap_["jacke"];16 BaseItem* item = itemMap_["jacke"]; 17 17 18 18 if (itemMap_["jacke"]) … … 23 23 { 24 24 public: 25 void AddItem(Shipitem* toAddItem);25 /*void AddItem(Shipitem* toAddItem); 26 26 void RemoveItem(Shipitem* toRemoveItem); 27 27 bool CheckifValid(Shipitem* toBeChecked); 28 28 bool CheckifSpace(); 29 void SwitchItem(Permanent* toSwitchItem); 30 string GetNameofPermanent (subItemTypePermanent NametoGet);*/ //holt den Namen des getragenen Items im jeweiligen Slot. 29 31 30 32 private: 31 multimap<std::string, ShipItem*> Equipment;32 multimap<std::string, ShipItem*> Usable;33 multimap<std::string, ShipItem*> Trunk;33 multimap<std::string, BaseItem*> Equipment; 34 multimap<std::string, BaseItem*> Usable; 35 multimap<std::string, BaseItem*> Trunk; 34 36 }; 35 37 } -
code/trunk/src/orxonox/objects/pickup/ShipItem.cc
r2089 r2662 5 5 itemtype ShipItem::CheckType() 6 6 { 7 return this .type;7 return this->type; 8 8 } 9 9 10 10 subItemTypePermanent CheckSubType() 11 11 { 12 return this .subtype_permanent;12 return this->subtype_permanent; 13 13 } 14 15 subItemTypePowerups CheckSubType() 16 { 17 return this->subtype_powerups; 18 } 19 subItemTypeUsable CheckSubType() 20 { 21 return this->subtype_usables; 22 } 23 14 24 } -
code/trunk/src/orxonox/objects/pickup/ShipItem.h
r2094 r2662 21 21 public: 22 22 itemType CheckType(); 23 virtual23 //virtual ChecksubType(); 24 24 25 25 private: … … 27 27 string itemname; 28 28 }; 29 30 29 31 30 /* Useables are Items the Player can choose when to activate and then show an instant action/effect … … 37 36 Rockets, 38 37 Repairkits, 39 Triggers, 38 Triggers, //trigger events usable by the player (Quests f.exp.) 40 39 Boosters, 41 40 Shields, -
code/trunk/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.