Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2128


Ignore:
Timestamp:
Nov 4, 2008, 12:13:51 PM (15 years ago)
Author:
dsommer
Message:

getnameofpermanents und switch

Location:
code/branches/pickups
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickups/src/orxonox/objects/pickup/ShipEquipmentClasses.cc

    r2055 r2128  
    6363                switch(toAddItem.CheckType()){
    6464                        case Permanent:
    65                                 Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
     65                                Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
    6666                                break;
    6767                        case Usable:
    68                                 Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
     68                                Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
    6969                                break;
    7070                        case Trunk:
    71                                 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
     71                                Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
    7272                                break;
    7373                }
     
    7676        else if(toAddItem.CheckType()==Permanent){
    7777                if(CheckifSpace()==true)
    78                         Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
     78                        Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
    7979       
    8080        }
    8181               
    8282}
     83
     84void SwitchItem(Permanent* toSwitchItem){
     85        multimap<string, ShipItem*>::iterator it;
     86        string equippedname;
     87        equippedname=GetNameofPermanent(toSwitchItem.CheckSubType());
     88        it=Equipment.find(equippedname);
     89        Trunk.insert (find(equippedname));
     90        Equipment.erase (it);
     91        Equipment.insert(pair<std::string, ShipItem*>(toSwitchItem.itemname,toSwitchItem)
     92                       
     93}
     94
     95string GetNameofPermanent (subItemTypePermanent NametoGet){
     96                multimap<string, ShipItem*>::iterator it;
     97                for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
     98                        if((*it).second->CheckSubType()==NametoGet){
     99                        return (*it).first.itemname;
     100                        }
     101               
     102                }
     103                return 0;
     104}
  • code/branches/pickups/src/orxonox/objects/pickup/ShipEquipmentClasses.h

    r2083 r2128  
    2626                bool CheckifValid(Shipitem* toBeChecked);
    2727                bool CheckifSpace();
     28                void SwitchItem(Permanent* toSwitchItem);
     29                string GetNameofPermanent (subItemTypePermanent NametoGet); //holt den Namen des getragenen Items im jeweiligen Slot.
    2830        private:
    2931                multimap<std::string, ShipItem*> Equipment;
  • code/branches/pickups/src/orxonox/objects/pickup/ShipItem.cc

    r2083 r2128  
    1212        return this.subtype_permanent;
    1313    }
     14
     15    subItemTypePowerups CheckSubType()
     16    {
     17        return this.subtype_powerups;
     18    }
     19    subItemTypeUsable CheckSubType()
     20    {
     21        return this.subtype_usables;
     22    }
     23
    1424}
  • code/branches/pickups/src/orxonox/objects/pickup/ShipItem.h

    r2083 r2128  
    2020        public:
    2121                itemType CheckType();
    22                 virtual
     22                //virtual ChecksubType();
    2323
    2424        private:
Note: See TracChangeset for help on using the changeset viewer.