Changeset 2500 for code/branches/presentation/src/orxonox/objects/pickup
- Timestamp:
- Dec 17, 2008, 8:00:43 AM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 2 added
- 8 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/pickups2 (added) merged: 2110,2136,2202,2227,2289-2290,2293-2294,2324,2342,2389,2397
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/pickup/CMakeLists.txt
r2131 r2500 1 1 SET( SRC_FILES 2 ShipEquipmentClasses.cc 3 ShipItem.cc 2 PickupSpawner.cc 3 Item.cc 4 Turbo.cc 5 ShipEquipment.cc 4 6 ) 5 7 -
code/branches/presentation/src/orxonox/objects/pickup/PickupSpawner.cc
- Property svn:eol-style set to native
r2498 r2500 1 1 #include "PickupSpawner.h" 2 #include " Item.h"2 #include "BaseItem.h" 3 3 #include "objects/worldentities/pawns/Pawn.h" 4 4 #include "objects/worldentities/triggers/DistanceTrigger.h" … … 11 11 CreateFactory(PickupSpawner); 12 12 13 PickupSpawner::PickupSpawner(BaseObject* creator) : PositionableEntity(creator)13 PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator) 14 14 { 15 15 RegisterObject(PickupSpawner); … … 31 31 XMLPortParam(PickupSpawner, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(20.0f); 32 32 XMLPortParam(PickupSpawner, "respawntimer", setRespawnTimer, getRespawnTimer, xmlelement, mode); 33 33 34 34 } 35 35 … … 58 58 { 59 59 COUT(0) << "ITEM PICKED UP" << std::endl; 60 //if(player->isA(itemtemplate_->getPlayerBaseClass())) 60 //if(player->isA(itemtemplate_->getPlayerBaseClass())) 61 61 { 62 62 BaseObject* newobject = this->template_->getBaseclassIdentifier()->fabricate(this); 63 Item* newitem = dynamic_cast<Item*>(newobject);63 BaseItem* newitem = dynamic_cast<BaseItem*>(newobject); 64 64 if (newitem) 65 65 { … … 71 71 this->setActive(false); 72 72 this->fireEvent(); 73 } 73 } 74 74 else 75 75 delete newobject; … … 82 82 83 83 void PickupSpawner::triggerRespawnTimer() 84 { 85 84 { 85 86 86 if(respawntimer_!=0) 87 87 { … … 90 90 RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor); 91 91 COUT(0) << "TIMER SET" << std::endl; 92 } 92 } 93 93 } 94 94 void PickupSpawner::changedActivity() … … 106 106 COUT(0) << "INvisble!" << std::endl; 107 107 } 108 108 109 109 */ 110 110 SUPER(PickupSpawner, changedActivity); -
code/branches/presentation/src/orxonox/objects/pickup/PickupSpawner.h
- Property svn:eol-style set to native
r2498 r2500 3 3 4 4 #include "OrxonoxPrereqs.h" 5 #include " Item.h"5 #include "BaseItem.h" 6 6 #include "tools/Timer.h" 7 #include "objects/worldentities/ PositionableEntity.h"7 #include "objects/worldentities/StaticEntity.h" 8 8 #include "objects/Tickable.h" 9 9 10 10 namespace orxonox 11 11 { 12 class _OrxonoxExport PickupSpawner : public PositionableEntity, public Tickable12 class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable 13 13 { 14 14 public: -
code/branches/presentation/src/orxonox/objects/pickup/ShipEquipment.cc
- Property svn:eol-style set to native
r2498 r2500 1 #include " Item.h"1 #include "BaseItem.h" 2 2 #include "ShipEquipment.h" 3 3 #include "objects/worldentities/pawns/Pawn.h" … … 9 9 @brief 10 10 Insert a permanent Item to the Equipment. Is usually called by the addTo function in Items. 11 11 12 12 @param item 13 13 pointer to the item which is to be inserted. … … 16 16 if new item has sucessfully been added it will return true, in any other case the return value is false. 17 17 */ 18 bool ShipEquipment::insert( Item* item)18 bool ShipEquipment::insert(BaseItem* item) 19 19 { 20 20 if(checkSlot(item)==NULL) 21 21 { 22 Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) );22 Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) ); 23 23 return true; 24 24 } … … 26 26 { 27 27 COUT(3) << "SWAP?" << endl; 28 //Abfrage- irgendne ifschleife... 28 //Abfrage- irgendne ifschleife... 29 29 if((checkSlot(item)->dropped(player))==true); 30 30 { 31 Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) );31 Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) ); 32 32 COUT(3) << "SWAPPED!" << endl; 33 33 return true; … … 42 42 @brief 43 43 Erases a permanent Item in the Equipment. Is usually called by the remove/dropped function in Items. 44 44 45 45 @param item 46 46 pointer to the item which is to be erased. … … 49 49 if new item has sucessfully been erased it will return true, in any other case the return value is false. 50 50 */ 51 bool ShipEquipment::erase ( Item* item)51 bool ShipEquipment::erase (BaseItem* item) 52 52 { 53 std::multimap<std::string, Item*>::iterator it = Equipment.find(item->getName());53 std::multimap<std::string,BaseItem*>::iterator it = Equipment.find(item->getName()); 54 54 if(it != Equipment.end()) 55 55 { … … 59 59 return false; 60 60 }; 61 /*void print(std::multimap<std::string, Item*> eut)61 /*void print(std::multimap<std::string, BaseItem*> eut) 62 62 { 63 std::multimap<std::string, Item*>::iterator it;63 std::multimap<std::string,BaseItem*>::iterator it; 64 64 COUT(3) << "Liste:" << endl; 65 65 for ( it=eut.begin() ; it != eut.end(); ++it ) … … 75 75 { 76 76 //print(Equipment); 77 for (std::multimap<std::string, Item*>::iterator it = Equipment.begin(); it != Equipment.end(); )77 for (std::multimap<std::string,BaseItem*>::iterator it = Equipment.begin(); it != Equipment.end(); ) 78 78 { 79 79 … … 83 83 } 84 84 85 Item* ShipEquipment::checkSlot(Item* item)85 BaseItem* ShipEquipment::checkSlot(BaseItem* item) 86 86 { 87 std::multimap<std::string, Item*>::iterator it;87 std::multimap<std::string,BaseItem*>::iterator it; 88 88 for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ ) 89 89 { … … 94 94 return NULL; 95 95 }; 96 96 97 97 } -
code/branches/presentation/src/orxonox/objects/pickup/ShipEquipment.h
r2094 r2500 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/branches/presentation/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
r2094 r2500 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/branches/presentation/src/orxonox/objects/pickup/ShipEquipmentClasses.h
r2094 r2500 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/branches/presentation/src/orxonox/objects/pickup/ShipItem.cc
r2089 r2500 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/branches/presentation/src/orxonox/objects/pickup/ShipItem.h
r2094 r2500 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/branches/presentation/src/orxonox/objects/pickup/Turbo.cc
- Property svn:eol-style set to native
r2498 r2500 8 8 namespace orxonox 9 9 { 10 10 11 11 12 12 CreateFactory(Turbo); 13 13 14 Turbo::Turbo(BaseObject* creator) : Item(creator)14 Turbo::Turbo(BaseObject* creator) : BaseItem(creator) 15 15 { 16 16 RegisterObject(Turbo); … … 33 33 XMLPortParam(Turbo, "duration", setDuration, getDuration, xmlelement, mode); 34 34 XMLPortParam(Turbo, "accboost", setAccBoost, getAccBoost, xmlelement, mode); 35 XMLPortParam(Turbo, "rotacc", setRotAcc, getRotAcc, xmlelement, mode); 36 35 XMLPortParam(Turbo, "rotacc", setRotAcc, getRotAcc, xmlelement, mode); 37 36 } 38 37 39 38 bool Turbo::pickedUp(Pawn* player) 40 39 { 41 40 42 41 if(player-> isA(this->getPlayerBaseClass())) 43 42 { 44 43 SpaceShip* ship = dynamic_cast <SpaceShip*>(player); 45 44 if(duration_==0 ) 46 { 45 { 47 46 if(addTo(player)) 48 { 47 { 49 48 COUT(3)<<"ITEM EQUIPPED"<<std::endl; 50 49 this->setSpeedBoost(ship); … … 63 62 64 63 } 65 66 64 65 67 66 void Turbo::unsetSpeedBoost(SpaceShip* ship) 68 67 { 68 /* 69 69 ship->setMaxSpeed( ship->getMaxSpeed() - this->boost_); 70 70 ship->setTransAcc( ship->getTransAcc()/this->accboost_); … … 73 73 COUT(3)<<"BOOST UNSET"<<std::endl; 74 74 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 75 */ 76 ship->setPermanentBoost(false); 75 77 } 76 78 77 79 void Turbo::setSpeedBoost(SpaceShip* ship) 78 80 { 81 /* 79 82 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 80 83 ship->setMaxSpeed( ship->getMaxSpeed() + this->boost_); … … 82 85 ship->setMaxRotation( ship->getMaxRotation()+this->rotacc_); 83 86 ship->setRotAcc( ship->getRotAcc()+this->rotacc_); 87 */ 88 ship->setPermanentBoost(true); 89 ship->setBoost(true); 90 84 91 if( this->duration_ != 0) 85 92 { … … 88 95 turbotimer_.setTimer(this->duration_, false, this, executor); 89 96 } 90 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl;97 // COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 91 98 } 92 99 bool Turbo::dropped(Pawn* player) … … 99 106 SpaceShip* ship = dynamic_cast <SpaceShip*>(player); 100 107 this->unsetSpeedBoost(ship); 101 } 108 } 102 109 } 103 110 return true; 104 111 } 105 112 106 113 } 107 114 /*<Template baseclass="Turbo" name=turboitem> … … 115 122 </PickupSpawner>*/ 116 123 117 118 119 120 124 125 126 127 -
code/branches/presentation/src/orxonox/objects/pickup/Turbo.h
- Property svn:eol-style set to native
r2498 r2500 3 3 4 4 #include "tools/Timer.h" 5 #include " Item.h"5 #include "BaseItem.h" 6 6 #include "OrxonoxPrereqs.h" 7 7 #include "util/Math.h" … … 9 9 namespace orxonox 10 10 { 11 class _OrxonoxExport Turbo : public Item11 class _OrxonoxExport Turbo : public BaseItem 12 12 { 13 13 14 14 public: 15 15 Turbo(BaseObject* creator); … … 39 39 { return this->rotacc_; } 40 40 41 41 42 42 inline void setAccBoost(float accboost) 43 43 { this->accboost_ = accboost; } -
code/branches/presentation/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed
/code/branches/pickups2/src/orxonox/objects/pickup/Usable.h (added) merged: 2136
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.