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


C++ PlayerPointer::GetNewGUID方法代码示例

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


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

示例1: SendMoveForTime

void TaxiPath::SendMoveForTime(PlayerPointer riding, PlayerPointer to, uint32 time)
{
	if (!time)
		return;

	float length;
	uint32 mapid = riding->GetMapId();
	if( mapid == m_map1 )
		length = m_length1;
	else
		length = m_length2;

	float traveled_len = (time/(length * TAXI_TRAVEL_SPEED))*length;
	uint32 len = 0;
	float x = 0,y = 0,z = 0;

	if (!m_pathNodes.size())
		return;

	std::map<uint32, TaxiPathNode*>::iterator itr;
	itr = m_pathNodes.begin();

	float nx;
	float ny;
	float nz;
	bool set = false;
	uint32 nodecounter = 1;

	while (itr != m_pathNodes.end())
	{
		if( itr->second->mapid != mapid )
		{
			itr++;
			nodecounter++;
			continue;
		}

		if(!set)
		{
			nx = itr->second->x;
			ny = itr->second->y;
			nz = itr->second->z;
			set = true;
			continue;
		}

		len = (uint32)sqrt((itr->second->x - nx)*(itr->second->x - nx) +
			(itr->second->y - ny)*(itr->second->y - ny) + 
			(itr->second->z - nz)*(itr->second->z - nz));

		if (len >= traveled_len)
		{
			x = (itr->second->x - nx)*(traveled_len/len) + nx;
			y = (itr->second->y - ny)*(traveled_len/len) + ny;
			z = (itr->second->z - nz)*(traveled_len/len) + nz;
			break;
		}
		else
		{
			traveled_len -= len;
		}

		nx = itr->second->x;
		ny = itr->second->y;
		nz = itr->second->z;
		itr++;
	}

	if (itr == m_pathNodes.end())
		return;

	WorldPacket * data = new WorldPacket(SMSG_MONSTER_MOVE, 2000);
	size_t pos;

	*data << riding->GetNewGUID();
	*data << uint8(0);
	*data << riding->GetPositionX( ) << riding->GetPositionY( ) << riding->GetPositionZ( );
	*data << getMSTime();
	*data << uint8( 0 );
	*data << uint32( MONSTER_MOVE_FLAG_FLY );
	*data << uint32( uint32((length * TAXI_TRAVEL_SPEED) - time));
	*data << uint32( nodecounter );
	pos = data->wpos();
	*data << nx << ny << nz;

	while (itr != m_pathNodes.end())
	{
		TaxiPathNode *pn = itr->second;
		if( pn->mapid != mapid )
			break;

		*data << pn->x << pn->y << pn->z;
		++itr;
		++nodecounter;
	}
	
	*(uint32*)&(data->contents()[pos]) = nodecounter;
	to->delayedPackets.add(data);
/*	if (!time)
		return;
//.........这里部分代码省略.........
开发者ID:Vanj-crew,项目名称:HearthStone-Emu,代码行数:101,代码来源:TaxiMgr.cpp


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