Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r8327 r8706  
    151151                //Give new pig boost
    152152                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    153                 if (spaceship && spaceship->getEngine())
    154                 {
    155                     spaceship->getEngine()->setSpeedFactor(5);
    156                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    157                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    158                     executor->setDefaultValue(0, ptr);
    159                     new Timer(10, false, executor, true);
    160                 }
     153                grantPigBoost(spaceship);
    161154            }
    162155
     
    252245                //Give new pig boost
    253246                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    254                 if (spaceship && spaceship->getEngine())
    255                 {
    256                     spaceship->getEngine()->setSpeedFactor(5);
    257                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    258                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    259                     executor->setDefaultValue(0, ptr);
    260                     new Timer(10, false, executor, true);
    261                 }
    262 
     247                grantPigBoost(spaceship);
    263248            }
    264249            // killer vs piggy
     
    321306    }
    322307
     308    void Dynamicmatch::grantPigBoost(orxonox::SpaceShip* spaceship)
     309    {
     310        // Give pig boost
     311        if (spaceship)
     312        {
     313            spaceship->setSpeedFactor(5);
     314            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
     315            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
     316            executor->setDefaultValue(0, ptr);
     317            new Timer(10, false, executor, true);
     318        }
     319    }
     320
    323321    void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring
    324322    {
     
    597595    }
    598596
    599     void Dynamicmatch::resetSpeedFactor(WeakPtr<Engine>* ptr)// helper function
     597    void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
    600598    {
    601599        if (*ptr)
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.h

    r7163 r8706  
    7373            virtual void furtherInstructions();*/
    7474            virtual void rewardPig();
    75             void resetSpeedFactor(WeakPtr<Engine>* ptr);
     75            void grantPigBoost(SpaceShip* spaceship); // Added this, since it's used twice on different occasions.
     76            void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
    7677            void tick (float dt);// used to end the game
    7778            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r8327 r8706  
    121121        }
    122122
    123         if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
    124             this->gtinfo_->startCountdown_ -= dt;
    125 
    126         if (!this->gtinfo_->bStarted_)
     123        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
     124            this->gtinfo_->countdownStartCountdown(dt);
     125
     126        if (!this->gtinfo_->hasStarted())
     127        {
     128            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     129            {
     130                // Inform the GametypeInfo that the player is ready to spawn.
     131                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
     132                    this->gtinfo_->playerReadyToSpawn(it->first);
     133            }
     134                   
    127135            this->checkStart();
    128         else if (!this->gtinfo_->bEnded_)
     136        }
     137        else if (!this->gtinfo_->hasEnded())
    129138            this->spawnDeadPlayersIfRequested();
    130139
     
    136145        this->addBots(this->numberOfBots_);
    137146
    138         this->gtinfo_->bStarted_ = true;
     147        this->gtinfo_->start();
    139148
    140149        this->spawnPlayersIfRequested();
     
    143152    void Gametype::end()
    144153    {
    145         this->gtinfo_->bEnded_ = true;
     154        this->gtinfo_->end();
    146155
    147156        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    173182    {
    174183        this->players_[player].state_ = PlayerState::Joined;
     184        this->gtinfo_->playerEntered(player);
    175185    }
    176186
     
    270280                }
    271281
     282                if(victim->getPlayer()->isHumanPlayer())
     283                    this->gtinfo_->pawnKilled(victim->getPlayer());
     284
    272285                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
    273286                if (victim->getCamera())
     
    306319    SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
    307320    {
     321        // If there is at least one SpawnPoint.
    308322        if (this->spawnpoints_.size() > 0)
    309323        {
     324            // Fallback spawn point if there is no active one, choose a random one.
    310325            SpawnPoint* fallbackSpawnPoint = NULL;
    311326            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    312327            unsigned int index = 0;
    313             std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
     328            std::vector<SpawnPoint*> activeSpawnPoints;
    314329            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
    315330            {
     
    317332                    fallbackSpawnPoint = (*it);
    318333
    319                 if (!(*it)->isActive())
    320                     activeSpawnPoints.erase(*it);
     334                if (*it != NULL && (*it)->isActive())
     335                    activeSpawnPoints.push_back(*it);
    321336
    322337                ++index;
    323338            }
    324339
    325             randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    326             index = 0;
    327             for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it)
    328             {
    329                 if (index == randomspawn)
    330                     return (*it);
    331 
    332                 ++index;
    333             }
    334 
     340            if(activeSpawnPoints.size() > 0)
     341            {
     342                randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size())));
     343                return activeSpawnPoints[randomspawn];
     344            }
     345
     346            COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
    335347            return fallbackSpawnPoint;
    336348        }
     
    346358                it->second.state_ = PlayerState::Dead;
    347359
    348                 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
     360                if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
    349361                {
    350362                    this->spawnPlayerAsDefaultPawn(it->first);
     
    357369    void Gametype::checkStart()
    358370    {
    359         if (!this->gtinfo_->bStarted_)
    360         {
    361             if (this->gtinfo_->bStartCountdownRunning_)
    362             {
    363                 if (this->gtinfo_->startCountdown_ <= 0)
    364                 {
    365                     this->gtinfo_->bStartCountdownRunning_ = false;
    366                     this->gtinfo_->startCountdown_ = 0;
     371        if (!this->gtinfo_->hasStarted())
     372        {
     373            if (this->gtinfo_->isStartCountdownRunning())
     374            {
     375                if (this->gtinfo_->getStartCountdown() <= 0.0f)
     376                {
     377                    this->gtinfo_->stopStartCountdown();
     378                    this->gtinfo_->setStartCountdown(0.0f);;
    367379                    this->start();
    368380                }
     
    389401                        // If in developer's mode, there is no start countdown.
    390402                        if(Core::getInstance().inDevMode())
    391                             this->gtinfo_->startCountdown_ = 0;
     403                            this->start();
    392404                        else
    393                             this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    394                         this->gtinfo_->bStartCountdownRunning_ = true;
     405                            this->gtinfo_->setStartCountdown(this->initialStartCountdown_);
     406                        this->gtinfo_->startStartCountdown();
    395407                    }
    396408                }
     
    402414    {
    403415        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     416        {
    404417            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    405418                this->spawnPlayer(it->first);
     419        }
    406420    }
    407421
     
    422436            player->startControl(spawnpoint->spawn());
    423437            this->players_[player].state_ = PlayerState::Alive;
     438
     439            if(player->isHumanPlayer())
     440                this->gtinfo_->playerSpawned(player);
     441           
    424442            this->playerPostSpawn(player);
    425443        }
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r8178 r8706  
    7878
    7979            inline bool hasStarted() const
    80                 { return this->gtinfo_->bStarted_; }
     80                { return this->gtinfo_->hasStarted(); }
    8181            inline bool hasEnded() const
    82                 { return this->gtinfo_->bEnded_; }
     82                { return this->gtinfo_->hasEnded(); }
    8383
    8484            virtual void start();
     
    114114
    115115            inline bool isStartCountdownRunning() const
    116                 { return this->gtinfo_->bStartCountdownRunning_; }
     116                { return this->gtinfo_->isStartCountdownRunning(); }
    117117            inline float getStartCountdown() const
    118                 { return this->gtinfo_->startCountdown_; }
     118                { return this->gtinfo_->getStartCountdown(); }
    119119
    120120            inline void setHUDTemplate(const std::string& name)
    121                 { this->gtinfo_->hudtemplate_ = name; }
     121                { this->gtinfo_->setHUDTemplate(name); }
    122122            inline const std::string& getHUDTemplate() const
    123                 { return this->gtinfo_->hudtemplate_; }
     123                { return this->gtinfo_->getHUDTemplate(); }
    124124
    125125            void addBots(unsigned int amount);
  • code/trunk/src/orxonox/gametypes/LastTeamStanding.cc

    r8351 r8706  
    5555        this->setHUDTemplate("lastTeamStandingHUD");
    5656    }
    57    
     57
    5858    LastTeamStanding::~LastTeamStanding()
    5959    {
    60     }   
     60    }
    6161
    6262    void LastTeamStanding::playerEntered(PlayerInfo* player)
     
    6969        else
    7070            playerLives_[player]=getMinLives();//new players only get minimum of lives */
    71        
     71
    7272        this->timeToAct_[player] = timeRemaining;
    7373        this->playerDelayTime_[player] = respawnDelay;
    7474        this->inGame_[player] = true;
    7575        unsigned int team = getTeam(player);
    76         if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     76        if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    7777            return;
    7878        if(this->eachTeamsPlayers[team]==0) //if a player is the first in his group, a new team is alive
     
    9191            this->inGame_.erase(player);
    9292            unsigned int team = getTeam(player);
    93             if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     93            if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    9494                return valid_player;
    9595            this->eachTeamsPlayers[team]--;       // a player left the team
     
    107107        bool allow = TeamDeathmatch::allowPawnDeath(victim, originator);
    108108        if(!allow) {return allow;}
    109        
     109
    110110        playerLives_[victim->getPlayer()] = playerLives_[victim->getPlayer()] - 1; //player lost a live
    111111        this->inGame_[victim->getPlayer()] = false; //if player dies, he isn't allowed to respawn immediately
     
    113113        {
    114114            unsigned int team = getTeam(victim->getPlayer());
    115             if(team < 0|| team > teams_) // make sure getTeam returns a regular value
     115            if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    116116                return allow;
    117117            this->eachTeamsPlayers[team]--;
     
    140140                const std::string& message = ""; // resets Camper-Warning-message
    141141                this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    142             }   
     142            }
    143143        }
    144144        return allow;
     
    163163            return;
    164164        TeamDeathmatch::playerStartsControllingPawn(player,pawn);
    165        
     165
    166166        this->timeToAct_[player] = timeRemaining + 3.0f + respawnDelay;//reset timer
    167167        this->playerDelayTime_[player] = respawnDelay;
    168        
     168
    169169        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
    170170        if (it != this->players_.end())
     
    174174            const std::string& message = ""; // resets Camper-Warning-message
    175175            this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    176         } 
     176        }
    177177    }
    178178
     
    187187            }
    188188            for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
    189             {   
     189            {
    190190                if (playerGetLives(it->first) <= 0)//Players without lives shouldn't be affected by time.
    191                     continue;     
     191                    continue;
    192192                it->second -= dt;//Decreases punishment time.
    193                 if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 
     193                if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
    194194                {
    195195                    playerDelayTime_[it->first] -= dt;
     
    309309            return 0;
    310310    }
    311    
     311
    312312    void LastTeamStanding::setConfigValues()
    313313    {
Note: See TracChangeset for help on using the changeset viewer.