Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 22, 2012, 5:05:14 PM (12 years ago)
Author:
purgham
Message:

Made SpaceRace-Mode usable for more then 1 Spaceship

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Racingbot/src/modules/gametypes/RaceCheckPoint.cc

    r9348 r9412  
    4343    CreateFactory(RaceCheckPoint);
    4444
    45     RaceCheckPoint::RaceCheckPoint(BaseObject* creator): DistanceMultiTrigger(creator), RadarViewable(creator, static_cast<WorldEntity*>(this))
     45    RaceCheckPoint::RaceCheckPoint(BaseObject* creator) :
     46        DistanceMultiTrigger(creator), RadarViewable(creator,
     47                static_cast<WorldEntity*> (this))
    4648    {
    47         RegisterObject(RaceCheckPoint);
    48 
    49         this->setDistance(100);
     49        RegisterObject(RaceCheckPoint)
     50;        this->setDistance(100);
    5051        this->setBeaconMode("off");
    5152        this->setBroadcast(false);
     
    6061        this->bIsLast_ = false;
    6162        this->timeLimit_ = 0;
    62         this->player_ = NULL;
     63        //this->players_ = vector<PlayerInfo*>();
    6364    }
    6465
     66    RaceCheckPoint::~RaceCheckPoint()
     67    {
    6568
    66    RaceCheckPoint::~RaceCheckPoint()
    67    {
    68    }
     69    }
    6970
    7071    void RaceCheckPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    8687            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(originator);
    8788            if (entity)
    88                 this->player_ = entity->getPlayer();
     89            this->players_.push_back(entity->getPlayer());
    8990        }
    9091    }
     
    9596        if (this->timeLimit_ != 0)
    9697        {
    97             std::string message =  "You have " + multi_cast<std::string>(this->timeLimit_)
    98                         + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
     98            std::string message = "You have " + multi_cast<std::string>(this->timeLimit_)
     99            + " seconds to reach the check point " + multi_cast<std::string>(this->checkpointIndex_ + 1);
    99100            this->getGametype()->getGametypeInfo()->sendAnnounceMessage(message);
    100101            ChatManager::message(message);
     
    107108
    108109        if (checkpoints.x > -1)
    109             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
     110        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.x + 0.5));
    110111        if (checkpoints.y > -1)
    111             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
     112        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.y + 0.5));
    112113        if (checkpoints.z > -1)
    113             this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     114        this->nextCheckpoints_.insert(static_cast<int>(checkpoints.z + 0.5));
     115    }
     116
     117    PlayerInfo* RaceCheckPoint::getPlayer(unsigned int clientID) const
     118    {
     119        if (players_.size() > 0)
     120        {
     121            for (int i = 0; i < players_.size(); i++)
     122            {
     123                if (this->players_[i]->getClientID() == clientID)
     124                {
     125                    return players_[i];
     126                }
     127            }
     128        }
     129        return NULL;
     130    }
     131
     132    bool RaceCheckPoint::playerWasHere(PlayerInfo* player) const
     133    {
     134        if (players_.size() > 0)
     135        {
     136            for (int i = 0; i < players_.size(); i++)
     137            {
     138                if (this->players_[i] == player)
     139                {
     140                    return true;
     141                }
     142            }
     143        }
     144        return false;
    114145    }
    115146
Note: See TracChangeset for help on using the changeset viewer.