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


C++ Mission::GetSuccessXP方法代码示例

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


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

示例1: OnEvent

void Player::OnEvent(IEventSource* pSource, IEvent* pEvent)
{
  string sourceType = (pSource ? pSource->GetType() : "World");
  string eventCode = pEvent->GetCode();
  string eventName = eventCode.substr(eventCode.find('.')+1, eventCode.length());

  DYNLOG_ADDLOG( DYNLOG_FORMAT("Player::OnEvent(): Event [%s] received from source [%s]", eventCode.c_str(), sourceType.c_str()) );

	// check for a Player event
  if ( !sourceType.compare( Player::EVTSYS_ObjectType ) )      // player events
  {
    Player* pPlayer = (Player*)pEvent->GetParam();

    // ensure that we do not handle our own event
    if ( pSource != (IEventSource*)this )
    {
      // handle events
      if ( !eventCode.compare( Player::EVT_LoggedIn ) )
      {
      }
    }
  }
	// check for a mission event
	else if ( !sourceType.compare( Mission::EVTSYS_ObjectType ) )
  {
		Mission* pMission = static_cast<Mission*>(pSource);
    Player* pPlayer = (Player*)pEvent->GetPlayer();
		if ( !eventCode.compare( Mission::EVT_Complete ) )
		{
			DYNLOG_ADDLOG( DYNLOG_FORMAT("Player %s completed mission id %ld (earned %ld XP)", GetName().c_str(), (FCULONG)(pEvent->GetParam()), pMission->GetSuccessXP()) );
			// need to send a message to the client here
      SendMissionComplete((FCULONG) pEvent->GetParam(), pPlayer->GetRouterSocket(), pPlayer->GetClientSocket());
			// Add the xp to the player
			pPlayer->AddXP( pMission->GetSuccessXP() );
		}
	}
  else
  {
    // its not a player event, so it may be related to a mission or something else that happened to us
    bool bHandled = false;

		// check if we have any missions
		if ( m_mapMissions.size() )
		{
			// hand the event off to all the missions we have...
			MissionMap::iterator it = m_mapMissions.begin();
			MissionMap::iterator limit = m_mapMissions.end();

			for ( ; it != limit; it++ )
			{
				it->second->OnEvent(pSource, pEvent);
			}
		}

    // if we didn't handle the event, then log the incident
    if ( !bHandled )
      DYNLOG_ADDLOG( DYNLOG_FORMAT("Player::OnEvent(): Unknown event received [source:%s / event:%s]", sourceType.c_str(), pEvent->GetCode().c_str()) );
  }
}
开发者ID:carribus,项目名称:firecell,代码行数:59,代码来源:Player.cpp


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