Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 23, 2012, 5:56:57 PM (13 years ago)
Author:
decapitb
Message:

safety checkin

Location:
code/branches/captureTheFlag
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/captureTheFlag

  • code/branches/captureTheFlag/src/modules/pickup/items/FlagPickup.cc

    r9220 r9232  
    3939
    4040#include "pickup/PickupIdentifier.h"
    41 #include "worldentities/pawns/Pawn.h"
    4241
    4342namespace orxonox
    4443{
    45 
    46     /*static*/ const std::string FlagPickup::flagTypeBlue_s = "blue";
    47     /*static*/ const std::string FlagPickup::flagTypeRed_s = "red";
    48     /*static*/ const std::string FlagPickup::flagTypeNeutral_s = "neutral";
    4944
    5045    CreateFactory(FlagPickup);
     
    7671    void FlagPickup::initialize(void)
    7772    {
    78         this->flagType_ = pickupFlagType::0;
     73        this->flagType_ = 0;
    7974
    8075        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     
    8782    void FlagPickup::initializeIdentifier(void)
    8883    {
    89         std::string val1 = this->getFlagType();
     84        std::stringstream stream;
     85        int type = this->getFlagType();
     86        stream << type;
     87                std::string val = stream.str();
     88               
    9089        std::string type1 = "flagType";
    91         this->pickupIdentifier_->addParameter(type1, val1);
     90        this->pickupIdentifier_->addParameter(type1, val);
    9291    }
    9392
     
    113112        Returns the falg type as a string.
    114113    */
    115     const std::string& FlagPickup::getFlagType(void) const
     114    const int FlagPickup::getFlagType(void) const
    116115    {
    117         switch(this->getFlagTypeDirect())
    118         {
    119             case pickupFlagType::blue:
    120                 return FlagPickup::flagTypeBlue_s;
    121             case pickupFlagType::red:
    122                 return FlagPickup::flagTypeRed_s;
    123             case pickupFlagType::neutral:
    124                 return FlagPickup::flagTypeNeutral_s;
    125             default:
    126                 orxout(internal_error, context::pickups) << "Invalid flagType in FlagPickup." << endl;
    127                 return BLANKSTRING;
    128         }
    129     }
     116                return this->flagType_;
     117        }
    130118
    131119    /**
     
    135123        The type as a string.
    136124    */
    137     void FlagPickup::setFlagType(std::string type)
     125    void FlagPickup::setFlagType(int type)
    138126    {
    139         if(type == FlagPickup::flagTypeRed_s)
    140             this->setFlagTypeDirect(pickupFlagType::2);
    141         else if(type == FlagPickup::flagTypeBlue_s)
    142             this->setFlagTypeDirect(pickupFlagType::1);
    143         else if(type == FlagPickup::flagTypeNeutral_s)
    144             this->setFlagTypeDirect(pickupFlagType::0);
    145         else
     127        if(type<3){
     128                this->flagType_ = type;
     129        }
     130       
     131        else{
    146132            orxout(internal_error, context::pickups) << "Invalid flagType '" << type << "' in FlagPickup." << endl;
     133        }
    147134    }
    148135
     
    163150           if(this->isUsed())
    164151           {
    165                int team = getTeam(pawn->getPlayer);
    166 
    167                if(this->flagType_ == team){
    168                    if(pawn->hasFlag_){
    169                            teamScore_ = TeamScore_ + 1000;
    170                            pawn->hasFlag_ = false;
    171                    }
    172                this->Pickupable::destroy();
    173                }else{
    174                    pawn->hasFlag_ = true;
    175                }
     152                 this->bPickedUp_ = true;
     153                 this->pickedUpBy_ = pawn;
    176154           }
    177155       }
    178 
    179 
    180156
    181157       /**
     
    196172       }
    197173
    198     int FlagPickup::getTeam(PlayerInfo* player)
    199     {
    200         std::map<PlayerInfo*, int>::const_iterator it_player = this->teamnumbers_.find(player);
    201         if (it_player != this->teamnumbers_.end())
    202             return it_player->second;
    203         else
    204             return -1;
    205     }
    206174
    207 }
    208175
    209176        void FlagPickup::tick(float dt)
     
    213180               Pawn* pawn = this->carrierToPawnHelper();
    214181
    215                    if(pawn->isAlive() && pawn->hasFlag_){
     182                   if(pawn->isAlive() && pawn->hasFlag()){
    216183               this->Pickupable::destroy();
    217184                   }
    218185
    219186           }
     187}
Note: See TracChangeset for help on using the changeset viewer.