Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2952


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

new revision of gametype UnderAttack: Ship is now moving

Location:
code/branches/gametypes/src/orxonox/objects
Files:
5 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    {
  • code/branches/gametypes/src/orxonox/objects/gametypes/Gametype.h

    r2826 r2952  
    132132            virtual void checkStart();
    133133            virtual void spawnPlayer(PlayerInfo* player);
     134            virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player);
    134135            virtual void spawnPlayersIfRequested();
    135136            virtual void spawnDeadPlayersIfRequested();
  • code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.cc

    r2935 r2952  
    3535#include "objects/worldentities/TeamSpawnPoint.h"
    3636
     37#include "network/Host.h"
    3738namespace orxonox
    3839{
     
    5051    }
    5152
     53    void UnderAttack::setConfigValues()
     54    {
     55        SetConfigValue(gameTime_, 30);
     56    }
     57
    5258    void UnderAttack::addDestroyer(Destroyer* destroyer)
    5359    {
     
    6066        if (pawn == this->destroyer_)
    6167        {
    62 
    63             COUT(0) << "Ship destroyed! Team 0 has won!" << std::endl;
    64             // Todo: end game
     68            this->end(); //end gametype
     69            std::string message = "Ship destroyed! Team 0 has won!";
     70            COUT(0) << message << std::endl;
     71            Host::Broadcast(message);
    6572        }
    6673    }
     
    129136            {
    130137                gameEnded_ = true;
    131                 COUT(0) << "Time is up! Team 1 has won!" << std::endl;
     138                this->end();
     139                std::string message = "Time is up! Team 1 has won!";
     140                COUT(0) << message << std::endl;
     141                Host::Broadcast(message);
    132142            }
    133143        }
  • code/branches/gametypes/src/orxonox/objects/gametypes/UnderAttack.h

    r2933 r2952  
    4444            UnderAttack(BaseObject* creator);
    4545            virtual ~UnderAttack() {}
     46
     47            void setConfigValues();
     48
    4649            void tick (float dt);
    4750            void addDestroyer(Destroyer* destroyer);
  • code/branches/gametypes/src/orxonox/objects/worldentities/SpawnPoint.cc

    r2662 r2952  
    9595    void SpawnPoint::spawn(ControllableEntity* entity)
    9696    {
    97         entity->setPosition(this->getPosition());
    98         entity->setOrientation(this->getOrientation());
     97        entity->setPosition(this->getWorldPosition());
     98        entity->setOrientation(this->getWorldOrientation());
    9999    }
    100100}
Note: See TracChangeset for help on using the changeset viewer.