コード例 #1
0
	/* ------------------------------------------------
	// 请求目标骑宠属性
	------------------------------------------------ */
	INT Mount::TargetMountAttrRequest(LuaPlus::LuaState* state)
	{
		tObject* pObj = CObjectManager::GetMe()->GetMainTarget();

		if (pObj && g_theKernel.IsKindOf(pObj->GetClass(), GETCLASS(CObject_PlayerOther)))
		{
			CObject_PlayerOther* pOtherPlayer = (CObject_PlayerOther*)pObj;
			if (0 < pOtherPlayer->GetCharacterData()->Get_MountID())
			{
				// 发送 请求目标骑宠属性消息
				CGManipulatePet Msg;

				Msg.SetObjID(pOtherPlayer->GetServerID());
				Msg.SetCharObjID(CObjectManager::GetMe()->GetMySelf()->GetServerID());
				Msg.SetManipulateType(MANIPULATE_ASKOTHERPETINFO);

				CNetManager::GetMe()->SendPacket(&Msg);
			}
		}

		return 0;
	}
コード例 #2
0
VOID CGameInterface::Object_ShowContexMenu(INT idObj,BOOL showMyself)
{
	CObject* pObject = (CObject*)CObjectManager::GetMe()->FindServerObject(idObj);
	if(!pObject) return;

	CHAR szObjId[32]; _snprintf(szObjId, 32, "%d", pObject->GetID());

	//得到鼠标位置
	POINT ptMouse = CInputSystem::GetMe()->MouseGetPos();

	CHAR szXPos[32]; _snprintf(szXPos, 32, "%d", ptMouse.x);
	CHAR szYPos[32]; _snprintf(szYPos, 32, "%d", ptMouse.y);
	
	std::vector< STRING > vParam;
	//根据不同物体产生不同右键事件
	if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerMySelf)))
	{
		if(showMyself)
		{
			// 如果自己已经在队伍中了
			if( CUIDataPool::GetMe()->IsInTeam())
			{
				vParam.push_back("player_in_team");
				vParam.push_back(szObjId);
				vParam.push_back(szXPos);
				vParam.push_back(szYPos);
				CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
				return;
			}

			// 自己没有组队
			vParam.push_back("player");
			vParam.push_back(szObjId);
			vParam.push_back(szXPos);
			vParam.push_back(szYPos);
			CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
		}
	}
	else if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerOther)))
	{
		CObject_PlayerOther* pOtherObject = (CObject_PlayerOther*)pObject;

		// 自己有队伍, 点击的其他玩家也有队伍
		if((pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( CUIDataPool::GetMe()->IsInTeam()))
		{
			vParam.push_back("other_team_member");
			vParam.push_back(szObjId);
			vParam.push_back(szXPos);
			vParam.push_back(szYPos);
			CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
			return;

		}

		//点击其他玩家没有队伍
		if((!pOtherObject->GetCharacterData()->Get_HaveTeamFlag()))
		{
			vParam.push_back("other_not_team_member");
			vParam.push_back(szObjId);
			vParam.push_back(szXPos);
			vParam.push_back(szYPos);
			CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
			return;

		}

		
		// 自己没队伍, 点击其他玩家有队伍
		if((pOtherObject->GetCharacterData()->Get_HaveTeamFlag())&&( !CUIDataPool::GetMe()->IsInTeam()))
		{
			vParam.push_back("other_team_member_me_not_teamer");
			vParam.push_back(szObjId);
			vParam.push_back(szXPos);
			vParam.push_back(szYPos);
			CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
			return;

		}


		vParam.push_back("other_player");
		vParam.push_back(szObjId);
		vParam.push_back(szXPos);
		vParam.push_back(szYPos);
		CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
	}
	else if(g_theKernel.IsKindOf(pObject->GetClass(), GETCLASS(CObject_PlayerNPC)))
	{
		PET_GUID_t pg = CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_CurrentPetGUID();

		//自己的宠物
		if(!(pg.IsNull()) && CDataPool::GetMe()->Pet_GetPet(pg) && CDataPool::GetMe()->Pet_GetPet(pg)->m_idServer == pObject->GetServerID())
		{
			vParam.push_back("my_pet");
			vParam.push_back(szObjId);
			vParam.push_back(szXPos);
			vParam.push_back(szYPos);
			CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
			return;
		}

		CObject_PlayerNPC* pNpcObject = (CObject_PlayerNPC*)pObject;
		//其他宠物
		if(pNpcObject->GetNpcType() == NPC_TYPE_PET)
		{
			if(INVALID_ID != pNpcObject->GetCharacterData()->Get_OwnerID())
			{
				//有归属的宠物才显示菜单
				vParam.push_back("other_pet");
				vParam.push_back(szObjId);
				vParam.push_back(szXPos);
				vParam.push_back(szYPos);
				CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
			}
			return;
		}

		vParam.push_back("npc");
		vParam.push_back(szObjId);
		vParam.push_back(szXPos);
		vParam.push_back(szYPos);
		CEventSystem::GetMe()->PushEvent(GE_SHOW_CONTEXMENU, vParam);
	}
	else return;

}
コード例 #3
0
uint GCNewPlayer_MoveHandler :: Execute( GCNewPlayer_Move* pPacket, Player* pPlayer ) 
{
//__ENTER_FUNCTION
	//AxTrace(0, 2, "GCNewPlayerHandler");
//	return PACKET_EXE_CONTINUE ;

	//当前流程是主流程
	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();

		//检查位置是否合法
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewPlayer_MoveHandler");
		}

		//创建玩家
		CObject_PlayerOther* pOther = (CObject_PlayerOther*)(pObjectManager->FindServerObject( (INT)pPacket->getObjID() ));
		fVector3 fvGame;
		CGameProcedure::s_pGfxSystem->Axis_Trans(
			CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
			CRenderSystem::AX_GAME, fvGame);

		if ( pOther == NULL )
		{
			pOther = pObjectManager->NewPlayerOther( (INT)pPacket->getObjID() );

			SObjectInit initPlayerOther;
			initPlayerOther.m_fvPos	= fvGame;

			pOther->Initial( &initPlayerOther );
		}
		else
		{
			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition(mapPos);
			pOther->Enable( OSF_VISIABLE );
			pOther->Disalbe( OSF_OUT_VISUAL_FIELD );
		}

		////激活鼠标查询
		//if(pOther->GetRenderInterface())
		//{
		//	pOther->Enable(OSF_RAY_QUERY);
		//}

		//更新装备信息
		pOther->GetCharacterData()->Set_EquipVer(pPacket->getEquipVer());
		//跟新移动速度
		pOther->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());

		// move to command
		{
			WORLD_POS posTarget;
			posTarget.m_fX	= pPacket->getTargetPos().m_fX;
			posTarget.m_fZ	= pPacket->getTargetPos().m_fZ;

			SCommand_Object cmdTemp;
			cmdTemp.m_wID			= OC_MOVE;
			cmdTemp.m_auParam[0]	= 0;
			cmdTemp.m_anParam[1]	= pPacket->getHandleID();
			cmdTemp.m_anParam[2]	= 1;
			cmdTemp.m_apParam[3]	= &posTarget;
			pOther->PushCommand(&cmdTemp );
		}

		//放入Ask队列
		CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pOther->GetID(), CObject_Character::CT_PLAYEROTHER);

		// tempcode{
		// 此版不做服务器繁忙客户端延后发消息的处理
//		CGCharAskBaseAttrib msgAskBaseAttrib;
//		msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
//		CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );

		//AxTrace(0, 0, "[%d]Ask %d", m_hmObject.size(), pPacket->getObjID());
		// }

		pOther->PushDebugString("GCNewPlayer");
		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
//__ENTER_FUNCTION
//	AxTrace(0, 2, "GCNewPlayerHandler");
//
//	//当前流程是主流程
//	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
//	{
//		CObjectManager* pObjectManager = CObjectManager::GetMe();
//
//		//创建玩家
//		CObject_PlayerOther* pOther = pObjectManager->CreatePlayerOther(
//											(INT)pPacket->getObjID(),
//											(INT)pPacket->getRace(),
//											pPacket->getEquipVer(),
//											fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ),
//											true);
//
//		if(!pOther) return PACKET_EXE_CONTINUE;
//
//		//设置新的位置
//		pOther->SetMapPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ));
//		pOther->RegisterToZone();
//		//IDLE装态
//		pOther->SetMotionStatus(CMS_STATUS_IDLE);
//		pOther->PushDebugString("GCNewPlayer");
//		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
//	}
//
//	return PACKET_EXE_CONTINUE ;
//
//__LEAVE_FUNCTION
//
//	return PACKET_EXE_ERROR ;
}
コード例 #4
0
uint GCNewPlayerHandler :: Execute( GCNewPlayer* pPacket, Player* pPlayer ) 
{
//__ENTER_FUNCTION

	//当前流程是主流程
	if(CGameProcedure::GetActiveProcedure() == (CGameProcedure*)CGameProcedure::s_pProcMain)
	{
		CObjectManager* pObjectManager = CObjectManager::GetMe();
		//检查位置是否合法
		if(!CWorldManager::GetMe()->GetActiveScene()->IsValidPosition(fVector2(pPacket->getWorldPos().m_fX, pPacket->getWorldPos().m_fZ)))
		{
			TDThrow("ERROR POSITION @ GCNewPlayerHandler");
		}

		//创建玩家
		CObject_PlayerOther* pOther = (CObject_PlayerOther*)(pObjectManager->FindServerObject( (INT)pPacket->getObjID()));
		fVector3 fvGame;
		CGameProcedure::s_pGfxSystem->Axis_Trans(
			CRenderSystem::AX_PLAN, fVector3(pPacket->getWorldPos().m_fX, 0.0f, pPacket->getWorldPos().m_fZ),
			CRenderSystem::AX_GAME, fvGame);

		FLOAT fFaceDir = pPacket->getDir();

		if ( pOther == NULL )
		{
			pOther = pObjectManager->NewPlayerOther( (INT)pPacket->getObjID() );

			SObjectInit initPlayerOther;
			initPlayerOther.m_fvPos	= fvGame;
			initPlayerOther.m_fvRot = fVector3( 0.f, fFaceDir, 0.f );
			pOther->Initial( &initPlayerOther );

			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition( mapPos );
		}
		else
		{
			fVector2 mapPos(fvGame.x, fvGame.z);
			pOther->SetMapPosition( mapPos );
			pOther->SetFaceDir( fFaceDir );
			pOther->Enable( OSF_VISIABLE );
			pOther->Disalbe( OSF_OUT_VISUAL_FIELD );
		}

		//更新装备信息
		pOther->GetCharacterData()->Set_EquipVer(pPacket->getEquipVer());

		pOther->GetCharacterData()->Set_MoveSpeed(pPacket->getMoveSpeed());

		////激活鼠标查询
		//if(pOther->GetRenderInterface())
		//{
		//	pOther->Enable(OSF_RAY_QUERY);
		//}

		SCommand_Object cmdTemp;
		cmdTemp.m_wID			= OC_IDLE;
		cmdTemp.m_afParam[0]	= fvGame.x;
		cmdTemp.m_afParam[1]	= fvGame.z;
		cmdTemp.m_abParam[2]	= FALSE;
		pOther->PushCommand(&cmdTemp );

		//放入Ask队列
		CObjectManager::GetMe()->GetLoadQueue()->TryAddLoadTask(pOther->GetID(), CObject_Character::CT_PLAYEROTHER);

		// tempcode{
		// 此版不做服务器繁忙客户端延后发消息的处理
//		CGCharAskBaseAttrib msgAskBaseAttrib;
//		msgAskBaseAttrib.setTargetID( (INT)pPacket->getObjID() );
//		CNetManager::GetMe()->SendPacket( &msgAskBaseAttrib );

		//AxTrace(0, 0, "[%d]Ask %d", m_hmObject.size(), pPacket->getObjID());
		// }

		//如果是自己,退出死亡效果
		if(pOther == (CObject_PlayerOther*)pObjectManager->GetMySelf())
		{
			CGameProcedure::s_pGfxSystem->Scene_SetPostFilter_Death(FALSE);
		}

		pOther->PushDebugString("GCNewPlayer");
		pOther->SetMsgTime(CGameProcedure::s_pTimeSystem->GetTimeNow());
	}

	return PACKET_EXE_CONTINUE ;

//__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}