Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8956


Ignore:
Timestamp:
Nov 30, 2011, 5:12:00 PM (13 years ago)
Author:
jo
Message:

implementing first player control parameter.

Location:
code/branches/gamecontent
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gamecontent/data/levels/lastTeamStanding.oxw

    r8891 r8956  
    1717 name         = "Last Team Standing"
    1818 description  = "testmap for gametype last team standing"
    19  gametype     =  "LastTeamStanding"
     19 gametype     =  "TeamGametype"
    2020>
    2121  <templates>
  • code/branches/gamecontent/src/orxonox/gametypes/Gametype.cc

    r8930 r8956  
    133133                    this->gtinfo_->playerReadyToSpawn(it->first);
    134134            }
    135                    
     135
    136136            this->checkStart();
    137137        }
     
    440440            if(player->isHumanPlayer())
    441441                this->gtinfo_->playerSpawned(player);
    442            
     442
    443443            this->playerPostSpawn(player);
    444444        }
  • code/branches/gamecontent/src/orxonox/gametypes/Gametype.h

    r8930 r8956  
    126126            void killBots(unsigned int amount = 0);
    127127
    128             inline unsigned int getNumberOfPlayers() const
    129                 { return this->players_.size(); }
    130 
    131128            virtual void addTime(float t);
    132129            virtual void removeTime(float t);
     
    151148
    152149            //inline bool getForceSpawn()
    153             //  { return this->bForceSpawn_; }       
     150            //  { return this->bForceSpawn_; }
    154151
    155152            virtual void resetTimer();
  • code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.cc

    r8951 r8956  
    4646        RegisterObject(TeamGametype);
    4747
    48         this->teams_ = 2;
     48        this->teams_ = 2; //most team gametypes use two different teams
    4949        this->allowFriendlyFire_ = false;
    5050        //this->playersPerTeam_ = 0;
    51         this->maxPlayers_ = 0;
     51        this->maxPlayers_ = 2; //TEST
    5252        this->setConfigValues();
    5353    }
     
    7878        if(player == NULL) return;
    7979        this->findAndSetTeam(player);
    80         if( getNumberOfPlayers() < maxPlayers_ || maxPlayers_  ==  0)
     80        if( this->players_.size() <= maxPlayers_ || maxPlayers_  ==  0)
     81        {
    8182            this->allowedInGame_[player]= true;
     83        }
    8284        else
     85        {
    8386            this->allowedInGame_[player]= false;
     87            orxout() << "not allowed in game: players = " << this->players_.size() << " > maximum: " << maxPlayers_ << endl;
     88        }
    8489    }
    8590
     
    110115    {
    111116        bool valid_player = Gametype::playerLeft(player);
     117        if( (this->players_.size() >= maxPlayers_) && (allowedInGame_[player] == true) ) // if there's a "waiting list"
     118        {
     119            for (std::map<PlayerInfo*, bool>::iterator it = this->allowedInGame_.begin(); it != this->allowedInGame_.end(); ++it)
     120            {
     121                 if(it->second == false) // waiting player found
     122                 {it->second = true; break;} // allow player to enter
     123                        }
     124                }
    112125
    113126        if (valid_player)
     127        {   // clean up the maps
    114128            this->teamnumbers_.erase(player);
     129            this->allowedInGame_.erase(player);
     130        }
     131
    115132
    116133        return valid_player;
     
    121138        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)\
    122139        {
    123             if(true)//check if dead player is allowed to enter -> if maximum nr of players is exceeded & player was not in game before: disallow
    124                 //continue;
     140            if(allowedInGame_[it->first] == false)//check if dead player is allowed to enter
     141            {
     142                                continue;
     143            }
    125144            if (it->second.state_ == PlayerState::Dead)
    126145            {
     
    135154
    136155    bool TeamGametype::allowPawnHit(Pawn* victim, Pawn* originator)
    137     {// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed 
     156    {// hit allowed: if victim & originator are foes or if originator doesnot exist or if friendlyfire is allowed
    138157        return (!this->pawnsAreInTheSameTeam(victim, originator) || !originator || this->allowFriendlyFire_);
    139158    }
     
    262281        if(pawn == NULL)
    263282            return;
    264        
     283
    265284        int teamnumber = pawn->getTeam();
    266285
     
    292311    void TeamGametype::colourPawn(Pawn* pawn, int teamNr)
    293312    {// catch no-colouring-case and wrong input
    294         if(teamNr < 0 || pawn == NULL) return; 
     313        if(teamNr < 0 || pawn == NULL) return;
    295314        pawn->setRadarObjectColour(this->teamcolours_[teamNr]);
    296315
  • code/branches/gamecontent/src/orxonox/gametypes/TeamGametype.h

    r8942 r8956  
    6767            bool pawnsAreInTheSameTeam(Pawn* pawn1, Pawn* pawn2);
    6868
    69             bool allowFriendlyFire_; //<! friendlyfire is per default switched off: friendlyFire_ = false;
     69            bool allowFriendlyFire_; //!< friendlyfire is per default switched off: friendlyFire_ = false;
    7070            std::map<PlayerInfo*, int> teamnumbers_;
    7171            std::vector<ColourValue> teamcolours_;
    72             unsigned int teams_; //<! Number  of teams. Value 0 : no teams!
    73             //unsigned int playersPerTeam_; //<! Defines Maximum for players per team. Value 0: no maximum!
    74             unsigned int maxPlayers_;  //<! Defines Maximum for number of players. Value 0 : no maximum!
     72            unsigned int teams_; //!< Number  of teams. Value 0 : no teams!
     73            //unsigned int playersPerTeam_; //!< Defines Maximum for players per team. Value 0: no maximum!
     74            unsigned int maxPlayers_; //!< Defines Maximum for number of players. Value 0 : no maximum!
    7575            std::map<PlayerInfo*, bool> allowedInGame_; //!< Only those players are allowed to spawn which are listed here as 'true'.
    7676            void setTeamColour(PlayerInfo* player, Pawn* pawn);
Note: See TracChangeset for help on using the changeset viewer.