Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8782 in orxonox.OLD


Ignore:
Timestamp:
Jun 26, 2006, 1:35:46 PM (18 years ago)
Author:
rennerc
Message:

MultiplayerTeamDeathmatch: added functions to handle kills/respawns

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

Legend:

Unmodified
Added
Removed
  • branches/network/src/util/multiplayer_team_deathmatch.cc

    r8774 r8782  
    717717}
    718718
    719 
    720 
    721 
     719/**
     720 * this function is called when a player kills another one or himself
     721 * @param killedUserId
     722 * @param userId
     723 */
     724void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId )
     725{
     726  assert( PlayerStats::getStats( killedUserId ) );
     727  assert( PlayerStats::getStats( userId ) );
     728 
     729  PlayerStats & killedStats = *PlayerStats::getStats( killedUserId );
     730  PlayerStats & stats = *PlayerStats::getStats( userId );
     731 
     732  if ( killedUserId != userId )
     733    stats.setScore( stats.getScore() + 1 );
     734  else
     735    stats.setScore( stats.getScore() - 1 );
     736 
     737  killedStats.getPlayable()->toList( OM_DEAD );
     738 
     739  if ( killedUserId == SharedNetworkData::getInstance()->getHostID() )
     740  {
     741    this->bLocalPlayerDead = true;
     742    this->showStats();
     743  }
     744 
     745  //TODO respawn killed palyer
     746 
     747}
     748
     749/**
     750 * this function is called on player respawn
     751 * @param userId
     752 */
     753void MultiplayerTeamDeathmatch::onRespawn( int userId )
     754{
     755  if ( userId == SharedNetworkData::getInstance()->getHostID() )
     756  {
     757    this->bLocalPlayerDead = false;
     758    this->hideStats();
     759  }
     760}
     761
  • branches/network/src/util/multiplayer_team_deathmatch.h

    r8772 r8782  
    5858    virtual void process(const Event &event);
    5959   
     60    void onKill( int killedUserId, int userId );
     61    void onRespawn( int userId );
     62   
    6063    virtual void handleChatMessage( int userId, const std::string & message, int messageType );
    6164
Note: See TracChangeset for help on using the changeset viewer.