//打开一个玩家的摊位
VOID CGameInterface::Stall_OpenStallSale(INT nObjId)
{
	CObject *pChar = (CObject*) CObjectManager::GetMe()->FindServerObject(nObjId);
	if(pChar)
	{
		//先判定距离是不是合法
		const fVector3 pMePos = CObjectManager::GetMe()->GetMySelf()->GetPosition();
		const fVector3 pOtherPos = (pChar)->GetPosition();

		FLOAT fDistance = 
			TDU_GetDist(fVector2(pMePos.x, pMePos.z),
						fVector2(pOtherPos.x, pOtherPos.z));

		AxTrace(0,0,"%f", fDistance);

		if( EXCHANGE_MAX_DISTANCE < fDistance )
		{
			CEventSystem::GetMe()->PushEvent(GE_NEW_DEBUGMESSAGE,"距离太远,不能打开这个摊位");
			return ;
		}

		//发送打开摊位的消息
		CGStallOpen OpenStallMsg;
		OpenStallMsg.SetObjID(nObjId);
		CNetManager::GetMe()->SendPacket(&OpenStallMsg);

		//同时发送请求StallMessage的消息
		//CGBBSApply BbsMsg;
		//BbsMsg.SetObjID(nObjId);
		//CNetManager::GetMe()->SendPacket(&BbsMsg);
	}

}
Esempio n. 2
0
FLOAT TDU_GetYAngle(const fVector2& fvPos1, const fVector2& fvPos2)	
{
	DOUBLE dDistance = (DOUBLE)TDU_GetDist(fvPos1, fvPos2 );
	if(dDistance <= 0.0f) return 0.0f;

	DOUBLE fACos = (fvPos2.y - fvPos1.y ) / dDistance;
	if( fACos >  1.0) fACos = 0.0;
	if( fACos < -1.0) fACos = TDU_PI;

	if( fACos >-TDU_MINFLOAT && fACos <TDU_MINFLOAT)
	{
		if(fvPos2.x > fvPos1.x )	return  (FLOAT)TDU_PI/2.0f;
		else						return -(FLOAT)TDU_PI/2.0f;
	}

	fACos = ::acos(fACos);
 
	// [0~180]
	if(fvPos2.x >= fvPos1.x)
		return (FLOAT)fACos;
	//(180, 360)
	else
		return (FLOAT)(2*TDU_PI - fACos);
}