Changeset 2389 for code/branches/pickups2
- Timestamp:
- Dec 10, 2008, 5:25:38 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/PickupSpawner.cc
r2227 r2389 16 16 17 17 this->template_ = 0; 18 this->distance_ = 50; 18 this->distance_ = 20; 19 this->respawntimer_= 0; 19 20 } 20 21 … … 28 29 29 30 XMLPortParam(PickupSpawner, "item", setItemTemplate, getItemTemplate, xmlelement, mode); 30 XMLPortParam(PickupSpawner, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(50.0f); 31 XMLPortParam(PickupSpawner, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(20.0f); 32 XMLPortParam(PickupSpawner, "respawntimer", setRespawnTimer, getRespawnTimer, xmlelement, mode); 33 31 34 } 32 35 … … 54 57 if (this->isActive() && this->template_ && this->template_->getBaseclassIdentifier()) 55 58 { 56 COUT(0) << " activated" << std::endl;59 COUT(0) << "ITEM PICKED UP" << std::endl; 57 60 //if(player->isA(itemtemplate_->getPlayerBaseClass())) 58 61 { … … 63 66 newitem->addTemplate(this->itemtemplate_); 64 67 if (newitem->pickedUp(player)== true) 68 { 69 if(respawntimer_!=0) 70 this->triggerRespawnTimer(); 65 71 this->setActive(false); 72 this->fireEvent(); 73 } 66 74 else 67 75 delete newobject; … … 72 80 } 73 81 } 82 83 void PickupSpawner::triggerRespawnTimer() 84 { 85 86 if(respawntimer_!=0) 87 { 88 ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive)); 89 executor->setDefaultValues(true); 90 RespawnTimer_.setTimer(this->respawntimer_, false, (BaseObject*)this, executor); 91 COUT(0) << "TIMER SET" << std::endl; 92 } 74 93 } 94 void PickupSpawner::changedActivity() 95 { 96 /* 97 COUT(0) << "Visble?" << std::endl; 98 if(isActive()) 99 { 100 setVisible(true); 101 COUT(0) << "Visble!" << std::endl; 102 } 103 if(isActive()==false) 104 { 105 setVisible(false); 106 COUT(0) << "INvisble!" << std::endl; 107 } 108 109 */ 110 SUPER(PickupSpawner, changedActivity); 111 112 for (std::set<WorldEntity*>::iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); ++it) 113 (*it)->setVisible(this->isActive()); 114 } 115 116 117 } 118 119 120 -
code/branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h
r2342 r2389 4 4 #include "OrxonoxPrereqs.h" 5 5 #include "Item.h" 6 6 #include "tools/Timer.h" 7 7 #include "objects/worldentities/PositionableEntity.h" 8 8 #include "objects/Tickable.h" … … 15 15 PickupSpawner(BaseObject* creator); 16 16 virtual ~PickupSpawner(); 17 virtual void changedActivity(); 18 virtual void tick(float dt); 19 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 20 virtual void triggering(Pawn* trigger); // Wenn ein Spieler in die Naehe kommt 21 void triggerRespawnTimer(); 17 22 18 virtual void tick(float dt);19 20 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 21 virtual void triggering(Pawn* trigger); // Wenn ein Spieler in die Naehe kommt23 /*inline void setVisibility(bool visible) 24 { this->setActive(visible); } 25 inline float getVisibility() const 26 { return this->isActive(); }*/ 22 27 23 28 void setItemTemplate(const std::string& itemtemplate); … … 29 34 inline float getDistance() const 30 35 { return this->distance_; } 36 inline void setRespawnTimer (float respawntimer) 37 { this->respawntimer_ = respawntimer; } 38 inline float getRespawnTimer() const 39 { return this->respawntimer_; } 31 40 32 41 private: … … 34 43 Template* template_; 35 44 float distance_; 45 float respawntimer_; 46 Timer<BaseObject> RespawnTimer_; 36 47 }; 37 48 } -
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.cc
r2342 r2389 9 9 bool ShipEquipment::insert(Item* item) 10 10 { 11 if(checkSlot(item)== true)11 if(checkSlot(item)==NULL) 12 12 { 13 13 Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); 14 14 return true; 15 15 } 16 COUT(3) << "swap?" << std::endl; 16 else 17 { 18 COUT(3) << "SWAP?" << endl; 19 if((checkSlot(item)->dropped(player))==true); 20 { 21 Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); 22 COUT(3) << "SWAPPED!" << endl; 23 return true; 24 } 17 25 return false; 26 } 18 27 19 28 return false; … … 48 57 } 49 58 50 boolShipEquipment::checkSlot(Item* item)59 Item* ShipEquipment::checkSlot(Item* item) 51 60 { 52 61 std::multimap<std::string,Item*>::iterator it; … … 55 64 //if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass()) 56 65 if(item->isExactlyA((*it).second->getIdentifier())) 57 return false;66 return (*it).second; 58 67 } 59 return true;68 return NULL; 60 69 }; 70 61 71 } -
code/branches/pickups2/src/orxonox/objects/pickup/ShipEquipment.h
r2342 r2389 30 30 //void print(std::multimap<std::string, Item*> eut); 31 31 void eraseAll(); 32 bool checkSlot(Item* item); 32 //bool checkSlot(Item* item); 33 Item* checkSlot(Item* item); 33 34 // const std::multimap<std::string, Item*>& getEquipment() const { return this->Equipment; } 34 35 inline std::multimap<std::string, Item*>& getEquipment() {return this->Equipment;} -
code/branches/pickups2/src/orxonox/objects/pickup/Turbo.cc
r2324 r2389 39 39 bool Turbo::pickedUp(Pawn* player) 40 40 { 41 41 42 if(player-> isA(this->getPlayerBaseClass())) 42 43 { 43 44 SpaceShip* ship = dynamic_cast <SpaceShip*>(player); 45 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 44 46 if(duration_==0 ) 45 47 { if(addTo(player)) 46 { 48 { 49 COUT(3)<<"ITEM EQUIPPED"<<std::endl; 47 50 this->setSpeedBoost(ship); 51 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 48 52 return true; 49 53 } … … 52 56 { 53 57 this->setSpeedBoost(ship); 58 COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl; 54 59 return true; 55 60 } … … 67 72 ship->setMaxRotation( ship->getMaxRotation()-this->rotacc_); 68 73 ship->setRotAcc( ship->getRotAcc()-this->rotacc_); 69 COUT(3)<<" PickUp Timer expired"<<std::endl;74 COUT(3)<<"BOOST UNSET"<<std::endl; 70 75 } 71 76 … … 88 93 if (this->duration_ == 0) 89 94 { 90 COUT(0) << " dropped" << std::endl;95 COUT(0) << "ITEM DROPPED" << std::endl; 91 96 if(remove(player)==true); 92 97 {
Note: See TracChangeset
for help on using the changeset viewer.