当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerState::getStatus方法代码示例

本文整理汇总了C++中PlayerState::getStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerState::getStatus方法的具体用法?C++ PlayerState::getStatus怎么用?C++ PlayerState::getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerState的用法示例。


在下文中一共展示了PlayerState::getStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawPlayerStats

// drawPlayerStats
//---------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------
void RankView::drawPlayerStats(Surface &dest)
{
    char statBuf[256];

    ObjectiveInterface::updatePlayerObjectiveCounts();

    std::vector<const PlayerState*> states;
    for(size_t i = 0; i < PlayerInterface::getMaxPlayers(); ++i) {
        PlayerState* state = PlayerInterface::getPlayerState(i);
        if(state->getStatus() != _player_state_active)
            continue;
        states.push_back(state);
    }

    switch(gameconfig->gametype) {
    case _gametype_objective:
        std::sort(states.begin(), states.end(), StatesSortByObjectives());
        break;
    case _gametype_timelimit:
    case _gametype_fraglimit:
        std::sort(states.begin(), states.end(), StatesSortByFrags());
        break;
    }

    unsigned int CHAR_YPIX = Surface::getFontHeight();
    unsigned int entryHeight = std::max(CHAR_YPIX, UNIT_FLAGS_SURFACE.getHeight()) + 2;
    iXY offset(2, 40);
    iXY flagOffset(162, 40 + (int(CHAR_YPIX - UNIT_FLAGS_SURFACE.getHeight()))/2);

    for(std::vector<const PlayerState*>::iterator i = states.begin();
            i != states.end(); ++i) {
        const PlayerState* state = *i;

        snprintf(statBuf, sizeof(statBuf),
                 "%-20s%10i%7i%6i%10i", state->getName().substr(0,20).c_str(),
                 state->getKills(), state->getLosses(), state->getTotal(),
                 state->getObjectivesHeld());
        dest.bltString(offset.x, offset.y, statBuf, state->getColor());
        UNIT_FLAGS_SURFACE.setFrame(state->getFlag());
        UNIT_FLAGS_SURFACE.blt( dest, flagOffset.x, flagOffset.y );

        offset.y += entryHeight;
        flagOffset.y += entryHeight;
    }

} // end RankView::drawPlayerStats
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:50,代码来源:RankView.cpp

示例2: netMessagePingRequest

void GameManager::netMessagePingRequest(const NetMessage* message)
{
    const SystemPingRequest *ping_request
        = (const SystemPingRequest*) message;

    if(ping_request->getClientPlayerIndex() >= PlayerInterface::getMaxPlayers())
    {
        LOGGER.warning("Invalid pingRequest message");
        return;
    }

    PlayerState * player;
    player = PlayerInterface::getPlayer( ping_request->getClientPlayerIndex() );

    SystemPingAcknowledge ping_ack;

    if ( player->getStatus() == _player_state_active
         && ping_request->getClientPlayerIndex() != MIN_PLAYER_ID
       )
    {
        SERVER->sendMessage(player->getID(), &ping_ack, sizeof(SystemPingAcknowledge));
    }
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:23,代码来源:GameManager.cpp

示例3: drawPlayerStats

// drawPlayerStats
//---------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------
void RankView::drawPlayerStats( unsigned int flagHeight)
{
    char statBuf[256];

	states.clear();
	for(size_t i = 0; i < PlayerInterface::getMaxPlayers(); ++i)
	{
        PlayerState* state = PlayerInterface::getPlayer(i);
        if(state->getStatus() != _player_state_active)
        {
			continue;
		}
        states.push_back(state);
    }

    switch(gameconfig->gametype)
	{
        case _gametype_objective:
            std::sort(states.begin(), states.end(), StatesSortByObjectives());
            break;
        case _gametype_timelimit:
        case _gametype_fraglimit:
            std::sort(states.begin(), states.end(), StatesSortByFrags());
            break;
    }

    unsigned int CHAR_YPIX = Surface::getFontHeight();
    unsigned int entryHeight = std::max(CHAR_YPIX, flagHeight) + 2;
    iXY offset( 6*8, 40);
    iXY flagOffset(26, 40 + (int(CHAR_YPIX - flagHeight))/2);
    Surface * flag = 0;

    for(std::vector<const PlayerState*>::iterator i = states.begin();
            i != states.end(); ++i) {
        const PlayerState* state = *i;

        snprintf(statBuf, sizeof(statBuf),
                "%-20s%5i%7i%7i%10i", state->getName().substr(0,20).c_str(),
                state->getKills(), state->getLosses(), state->getTotal(),
                state->getObjectivesHeld());
        drawStringShadowed(offset.x, offset.y, statBuf, Color::white, Color::gray64);
        
        flag = ResourceManager::getFlag(state->getFlag());
        drawImage( *flag, flagOffset.x, flagOffset.y );
		if ( state->getID() != PlayerInterface::getLocalPlayerIndex() )
		{
			bool meWithHim = PlayerInterface::isSingleAllied(PlayerInterface::getLocalPlayerIndex(), state->getID());
			bool himWithMe = PlayerInterface::isSingleAllied(state->getID(), PlayerInterface::getLocalPlayerIndex());
			if ( meWithHim && himWithMe )
			{
				drawImage( allyImage, 4, flagOffset.y );
			}
			else if ( meWithHim )
			{
				drawImage( allyRequestImage, 4, flagOffset.y );
			}
			else if ( himWithMe )
			{
				drawImage( allyOtherImage, 4, flagOffset.y );
			}
			else
			{
				drawImage( noAllyImage, 4, flagOffset.y );
			}
		}
		
        offset.y += entryHeight;
        flagOffset.y += entryHeight;        
    }

} // end RankView::drawPlayerStats
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:75,代码来源:RankView.cpp


注:本文中的PlayerState::getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。