Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8331 in orxonox.OLD for branches/network/src/util


Ignore:
Timestamp:
Jun 12, 2006, 10:49:23 PM (18 years ago)
Author:
rennerc
Message:

players can change teams while playing

Location:
branches/network/src/util
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/util/game_rules.h

    r7488 r8331  
    2020
    2121
    22 class GameRules : public BaseObject
     22class GameRules : virtual public BaseObject
    2323{
    2424
  • branches/network/src/util/multiplayer_team_deathmatch.cc

    r8147 r8331  
    6565  this->currentGameState = GAMESTATE_PRE_GAME;
    6666  this->gameStateTimer = 10.0f;
     67  this->bShowTeamChange = false;
    6768 
    6869  this->box = NULL;
     
    7778  if( root != NULL)
    7879    this->loadParams(root);
     80 
     81  subscribeEvent( ES_GAME, SDLK_o );
    7982}
    8083
     
    8689  if( this->deathScreen)
    8790    delete this->deathScreen;
     91 
     92  unsubscribeEvent( ES_GAME, SDLK_o );
    8893}
    8994
     
    150155    return;
    151156 
    152   if ( currentGameState == GAMESTATE_PRE_GAME )
     157  if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME )
    153158  {
    154159    if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    155          && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
    156160         && box == NULL
     161         &&  (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM
     162         || bShowTeamChange )
     163         
    157164       )
    158165    {
     
    180187      buttonTeam1->connect(SIGNAL(buttonTeam1, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonTeam1));
    181188     
     189      if ( bShowTeamChange )
     190      {
     191        OrxGui::GLGuiPushButton * buttonCancel = new OrxGui::GLGuiPushButton("Cancel");
     192        box->pack( buttonCancel );
     193        buttonCancel->connect(SIGNAL(buttonCancel, released), this, SLOT(MultiplayerTeamDeathmatch, onButtonCancel));
     194      }
     195     
    182196      OrxGui::GLGuiPushButton * buttonExit = new OrxGui::GLGuiPushButton("Exit");
    183197      box->pack( buttonExit );
     
    191205       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )
    192206       && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM
     207       && !bShowTeamChange
    193208     )
    194209  {
     
    479494{
    480495  State::getCurrentStoryEntity()->stop();
     496  this->bShowTeamChange = false;
    481497}
    482498
     
    484500{
    485501  NetworkGameManager::getInstance()->prefereTeam( TEAM_RANDOM );
     502  this->bShowTeamChange = false;
    486503}
    487504
     
    489506{
    490507  NetworkGameManager::getInstance()->prefereTeam( 0 );
     508  this->bShowTeamChange = false;
    491509}
    492510
     
    494512{
    495513  NetworkGameManager::getInstance()->prefereTeam( 1 );
     514  this->bShowTeamChange = false;
    496515}
    497516
     
    499518{
    500519  NetworkGameManager::getInstance()->prefereTeam( TEAM_SPECTATOR );
     520  this->bShowTeamChange = false;
    501521}
    502522
     
    507527}
    508528
    509 
    510 
    511 
    512 
    513 
     529  /**
     530   * function that processes events from the handler
     531   * @param event: the event
     532   * @todo replace SDLK_o with something from KeyMapper
     533   */
     534void MultiplayerTeamDeathmatch::process( const Event & event )
     535{
     536  if ( event.type == SDLK_o )
     537  {
     538    if ( event.bPressed )
     539      this->bShowTeamChange = true;
     540  }
     541}
     542
     543void MultiplayerTeamDeathmatch::onButtonCancel( )
     544{
     545  this->bShowTeamChange = false;
     546}
     547
     548
     549
     550
     551
     552
  • branches/network/src/util/multiplayer_team_deathmatch.h

    r8147 r8331  
    2727
    2828
    29 class MultiplayerTeamDeathmatch : public NetworkGameRules
     29class MultiplayerTeamDeathmatch : public NetworkGameRules, public EventListener
    3030{
    3131
     
    5555   
    5656    int getRandomTeam();
     57   
     58    virtual void process(const Event &event);
    5759
    5860  protected:
     
    7476    float              gameStateTimer;             //!< if less than 0 -> change game state
    7577
     78    bool               bShowTeamChange;            //!< if true -> show team change dialog
     79
    7680    OrxGui::GLGuiBox* box;
    7781
     
    8791    void onButtonTeam0();
    8892    void onButtonTeam1();
     93    void onButtonCancel();
    8994    void onButtonExit();
    9095};
Note: See TracChangeset for help on using the changeset viewer.