- Timestamp:
- Nov 1, 2008, 9:14:14 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/objects/pickup
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/pickup/ShipEquipment.h
r2089 r2094 11 11 12 12 13 namespace orxonox{ 13 namespace orxonox 14 { 15 class _OrxonoxExport ShipEquipment 16 { 17 public: 18 void AddItem(Shipitem toAddItem); 19 void RemoveItem(Shipitem toRemoveItem); 20 bool CheckifValid(Shipitem toBeChecked); 21 int 14 22 15 class _OrxonoxExport ShipEquipment{ 16 public: 17 void AddItem(Shipitem toAddItem); 18 void RemoveItem(Shipitem toRemoveItem); 19 bool CheckifValid(Shipitem toBeChecked); 20 int 21 private: 22 std::multimap<std::string, Item*> Equipment; 23 }; 23 private: 24 std::multimap<std::string, Item*> Equipment; 25 }; 24 26 } 25 27 -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
r2089 r2094 1 const int maxweapons_ =2; //Weaponslots (provisorisch) 2 const int maxslots_= 50; //Inventoryslots (provisorisch) 1 namespace orxonox 2 { 3 const int maxweapons_ =2; //Weaponslots (provisorisch) 4 const int maxslots_= 50; //Inventoryslots (provisorisch) 3 5 4 6 5 bool CheckifSpace(){ 6 if((Usable.size()+Trunk.size())>=maxslots_) 7 return false; 8 return true; 7 bool ShipEquipment::CheckifSpace() 8 { 9 if((Usable.size()+Trunk.size())>=maxslots_) 10 return false; 11 return true; 12 } 9 13 14 /* Checks if the Ship can pick an Item up. Permanents will give a "false" back unless the Ship doesnt carry a Item for that Slot (2 Weaponslots) yet.Others will be picked up unless there is no Space in the Trunk.*/ 10 15 16 bool ShipEquipment::CheckifValid(Shipitem* toBeChecked) 17 { 18 switch(toBeChecked.CheckType()) 19 { 20 case Powerups: 21 activatePowerUp(); //gibts noch nicht 22 return true; 23 case Permanent: 24 switch (toBeChecked.CheckSubType()) 25 { 26 case Weapon: 27 int weaponcheck=0; 28 multimap<string, ShipItem*>::iterator it; 29 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 30 if((*it).second->CheckSubType()==Weapon) 31 weaponcheck++; 32 }; 33 if (weaponcheck>=maxweapons_){ 34 weaponcheck=0; 35 return false; 36 } 37 break; 38 case Thrusters: 39 multimap<string, ShipItem*>::iterator it; 40 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 41 if((*it).second->CheckSubType()==Thrusters) 42 return false; 43 } 44 break; 45 case Shields: 46 multimap<string, ShipItem*>::iterator it; 47 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 48 if((*it).second->CheckSubType()==Shields) 49 return false; 50 } 51 break; 52 case Armor: 53 multimap<string, ShipItem*>::iterator it; 54 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 55 if((*it).second->CheckSubType()==Armor) 56 return false; 57 } 58 break; 59 default:; 60 } 61 case Useable: 62 return CheckifSpace(); 63 case default:; 64 } 65 return true; 66 } 67 68 /*Adds the Item to the Ship*/ 69 void ShipEquipment::AddItem(Shipitem* toAddItem) 70 { 71 if(CheckifValid(toAddItem)==true) 72 { 73 switch(toAddItem.CheckType()) 74 { 75 case Permanent: 76 Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) ); 77 break; 78 case Usable: 79 Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) ); 80 break; 81 case Trunk: 82 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) ); 83 break; 84 } 85 } 86 else if(toAddItem.CheckType()==Permanent) 87 { 88 if(CheckifSpace()==true) 89 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) ); 90 } 91 } 11 92 } 12 13 /* Checks if the Ship can pick an Item up. Permanents will give a "false" back unless the Ship doesnt carry a Item for that Slot (2 Weaponslots) yet.Others will be picked up unless there is no Space in the Trunk.*/14 15 bool CheckifValid(Shipitem* toBeChecked){16 17 switch(toBeChecked.CheckType())18 {19 case Powerups:20 activatePowerUp(); //gibts noch nicht21 return true;22 case Permanent:23 switch (toBeChecked.CheckSubType())24 {25 case Weapon:26 int weaponcheck=0;27 multimap<string, ShipItem*>::iterator it;28 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){29 if((*it).second->CheckSubType()==Weapon)30 weaponcheck++;31 };32 if (weaponcheck>=maxweapons_){33 weaponcheck=0;34 return false;35 }36 case Thrusters:37 multimap<string, ShipItem*>::iterator it;38 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){39 if((*it).second->CheckSubType()==Thrusters)40 return false;41 }42 case Shields:43 multimap<string, ShipItem*>::iterator it;44 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){45 if((*it).second->CheckSubType()==Shields)46 return false;47 }48 case Armor:49 multimap<string, ShipItem*>::iterator it;50 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){51 if((*it).second->CheckSubType()==Armor)52 return false;53 }54 }55 case Useable:56 return CheckifSpace();57 }58 return true;59 }60 /*Adds the Item to the Ship*/61 void AddItem(Shipitem* toAddItem){62 if(CheckifValid(toAddItem)==true){63 switch(toAddItem.CheckType()){64 case Permanent:65 Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );66 break;67 case Usable:68 Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );69 break;70 case Trunk:71 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );72 break;73 }74 75 }76 else if(toAddItem.CheckType()==Permanent){77 if(CheckifSpace()==true)78 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );79 80 }81 82 } -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h
r2089 r2094 12 12 13 13 14 /* 15 14 /* std::map<std::itemtype, Item*> EQClasses; 15 EQClasses["jacke"] = 0; 16 16 Item* item = itemMap_["jacke"]; 17 17 18 18 if (itemMap_["jacke"]) 19 19 if (itemMap_.find("jacke") != itemMap_.end()) */ 20 namespace orxonox{ 20 namespace orxonox 21 { 22 class _OrxonoxExport ShipEquipment 23 { 24 public: 25 void AddItem(Shipitem* toAddItem); 26 void RemoveItem(Shipitem* toRemoveItem); 27 bool CheckifValid(Shipitem* toBeChecked); 28 bool CheckifSpace(); 21 29 22 class _OrxonoxExport ShipEquipment{ 23 public: 24 void AddItem(Shipitem* toAddItem); 25 void RemoveItem(Shipitem* toRemoveItem); 26 bool CheckifValid(Shipitem* toBeChecked); 27 bool CheckifSpace(); 28 private: 29 multimap<std::string, ShipItem*> Equipment; 30 multimap<std::string, ShipItem*> Usable; 31 multimap<std::string, ShipItem*> Trunk; 32 }; 33 34 30 private: 31 multimap<std::string, ShipItem*> Equipment; 32 multimap<std::string, ShipItem*> Usable; 33 multimap<std::string, ShipItem*> Trunk; 34 }; 35 35 } 36 36 -
code/trunk/src/orxonox/objects/pickup/ShipItem.h
r2089 r2094 8 8 9 9 10 namespace orxonox{ 11 class _OrxonoxExport ShipItem{ 10 namespace orxonox 11 { 12 class _OrxonoxExport ShipItem 13 { 14 enum itemType //Diffrent Types of Items 15 { 16 Useable, 17 Powerups, 18 Permanent 19 }; 12 20 13 enum itemType{ //Diffrent Types of Items 21 public: 22 itemType CheckType(); 23 virtual 14 24 15 Useable, 16 Powerups, 17 Permanent 18 }; 19 20 public: 21 itemType CheckType(); 22 virtual 23 24 private: 25 itemType type; 26 string itemname; 27 }; 25 private: 26 itemType type; 27 string itemname; 28 }; 28 29 29 30 30 /* Useables are Items the Player can choose when to activate and then show an instant action/effect 31 * or for a certain duration */ 32 class _OrxonoxExport Useable : public ShipItem{ 31 /* Useables are Items the Player can choose when to activate and then show an instant action/effect 32 * or for a certain duration */ 33 class _OrxonoxExport Useable : public ShipItem 34 { 35 enum subItemTypeUseable //Diffrent Types of Items of the Type Useable 36 { 37 Rockets, 38 Repairkits, 39 Triggers, //trigger events usable by the player (Quests f.exp.) 40 Boosters, 41 Shields, 42 Appearance, 43 }; 33 44 45 public: 46 //subItemTypeUseable CheckSubType(); 34 47 35 enum subItemTypeUseable{ //Diffrent Types of Items of the Type Useable 36 Rockets, 37 Repairkits, 38 Triggers, //trigger events usable by the player (Quests f.exp.) 39 Boosters, 40 Shields, 41 Appearance, 42 }; 48 private: 49 subItemTypeUseable subtype_usable; 50 }; 43 51 44 public: 45 //subItemTypeUseable CheckSubType(); 52 /* Permanents are Items, that effect the Player or his Ship from the instance he picks them up 53 until he drops them again */ 54 class _OrxonoxExport Permanent : public ShipItem 55 { 56 enum subItemTypePermanent //Diffrent Types of Items of the Type Permanent 57 { 58 Weapon, 59 Thrusters, 60 Shields, 61 Armor 62 }; 46 63 47 private: 48 subItemTypeUseable subtype_usable; 49 }; 64 public: 65 subItemTypePermanent CheckSubType(); 50 66 51 /* Permanents are Items, that effect the Player or his Ship from the instance he picks them up 52 until he drops them again */53 class _OrxonoxExport Permanent : public ShipItem{ 67 private: 68 subItemTypePermanent subtype_permanent; 69 }; 54 70 55 enum subItemTypePermanent{ //Diffrent Types of Items of the Type Permanent 56 Weapon, 57 Thrusters, 58 Shields, 59 Armor 60 }; 61 public: 62 subItemTypePermanent CheckSubType(); 71 // Powerups effect the Player right after he picks them up for a certain Duration /or permanently. 72 class _OrxonoxExport Powerups : public ShipItem 73 { 74 enum subItem TypePowerups //Diffrent Types of Items of the Type Powerups 75 { 76 Weapon, 77 Boosters, 78 Shields, 79 Repairkits, 80 Appearance, 81 Trigger 82 }; 63 83 64 private: 65 subItemTypePermanent subtype_permanent; 66 }; 84 public: 85 //subItemTypePowerups CheckSubType(); 67 86 68 // Powerups effect the Player right after he picks them up for a certain Duration /or permanently. 69 class _OrxonoxExport Powerups : public ShipItem{ 70 71 enum subItem TypePowerups{ //Diffrent Types of Items of the Type Powerups 72 Weapon, 73 Boosters, 74 Shields, 75 Repairkits, 76 Appearance, 77 Trigger 78 }; 79 public: 80 //subItemTypePowerups CheckSubType(); 81 82 private: 83 subItemTypePowerups subtype_powerups; 84 }; 85 87 private: 88 subItemTypePowerups subtype_powerups; 89 }; 86 90 } 87 91 88 89 90 91 92 93 94 95 96 97 92 #endif -
code/trunk/src/orxonox/objects/pickup/Usable.h
r2089 r2094 1 /*enum 1 /*enum subItemType{ Subtypes (thrusters etc)*/ 2 2 3 namespace orxonox {4 class _OrxonoxExport Usable: public ShipItem{5 6 public: 7 subtypeusable CheckSubType(); 8 private: 9 subtypeusable subtype; 10 11 3 namespace orxonox 4 { 5 class _OrxonoxExport Usable: public ShipItem 6 { 7 public: 8 subtypeusable CheckSubType(); 9 private: 10 subtypeusable subtype; 11 }; 12 12 }
Note: See TracChangeset
for help on using the changeset viewer.