Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2009, 4:34:48 PM (15 years ago)
Author:
mockm
Message:

new revision of gametype UnderAttack: Ship is now moving

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.cc

    r2826 r2952  
    9393        if (!this->gtinfo_.bStarted_)
    9494            this->checkStart();
    95         else
     95        else if (!this->gtinfo_.bEnded_)
    9696            this->spawnDeadPlayersIfRequested();
    9797
     
    111111    {
    112112        this->gtinfo_.bEnded_ = true;
     113
     114        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     115        {
     116            if (it->first->getControllableEntity())
     117            {
     118                ControllableEntity* oldentity = it->first->getControllableEntity();
     119       
     120                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(oldentity->getCreator());
     121                if (oldentity->getCamera())
     122                {
     123                    entity->setPosition(oldentity->getCamera()->getWorldPosition());
     124                    entity->setOrientation(oldentity->getCamera()->getWorldOrientation());
     125                }
     126                else
     127                {
     128                    entity->setPosition(oldentity->getWorldPosition());
     129                    entity->setOrientation(oldentity->getWorldOrientation());
     130                }
     131
     132                it->first->stopControl(oldentity, true);
     133                it->first->startControl(entity);
     134            }
     135            else
     136                this->spawnPlayerAsDefaultPawn(it->first);
     137        }
    113138    }
    114139
     
    254279                if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
    255280                {
    256                     SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
    257                     if (spawn)
    258                     {
    259                         // force spawn at spawnpoint with default pawn
    260                         ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
    261                         spawn->spawn(entity);
    262                         it->first->startControl(entity);
    263                         it->second.state_ = PlayerState::Dead;
    264                     }
    265                     else
    266                     {
    267                         COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
    268                         abort();
    269                     }
     281                    this->spawnPlayerAsDefaultPawn(it->first);
     282                    it->second.state_ = PlayerState::Dead;
    270283                }
    271284            }
     
    345358    }
    346359
     360    void Gametype::spawnPlayerAsDefaultPawn(PlayerInfo* player)
     361    {
     362        SpawnPoint* spawn = this->getBestSpawnPoint(player);
     363        if (spawn)
     364        {
     365            // force spawn at spawnpoint with default pawn
     366            ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
     367            spawn->spawn(entity);
     368            player->startControl(entity);
     369        }
     370        else
     371        {
     372            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
     373            abort();
     374        }
     375    }
     376
    347377    void Gametype::addBots(unsigned int amount)
    348378    {
Note: See TracChangeset for help on using the changeset viewer.