Beispiel #1
0
/************************************************************************
*  处理鼠标右击事件
************************************************************************/
void Controller::HandleRightClick(Point& destPoint)
{
	Player* myPlayer = GetMyPlayer();//GetPlayerManager()->GetPlayer(m_strMyPlayerID);

	// 把所有的怪物的被选中状态置为未选择状态
	Game()->GetMonsterManager()->UnSelectAllMonster();

	// 判断鼠标右击区域是否存在一个怪物,如果存在就返回该怪物的指针,否则返回空
	Monster* pMonster = Game()->GetMonsterManager()->GetMonster(destPoint);

	if (pMonster != 0)
	{
		m_pCurrentSelectedMonster = pMonster;
		// 设置该怪物为被选中状态
		pMonster->SetSelected(true);			
		// 在怪物血条栏上显示怪物的血量
		MonsterLogic::GetInstance()->HandleMonsterBloodChange(pMonster,0);							
	}
	else
	{
		// 清空怪物血条栏上怪物的血量
		Game()->GetSceneManager()->SetMonsterBloodProgress(0);
	}

	// 获取玩家当前的朝向
	int dir = Game()->GetPathManager()->GetDirection(myPlayer->getPosition(),destPoint);

	// 设置玩家的目的地点(玩家要移动到鼠标右键点击的区域)
	myPlayer->SetDestPoint(destPoint);

	// 玩家跑动
	myPlayer->Action(CodeMsg::code_player_run,dir);

	GetNetworkModule()->SendPlayerState(myPlayer);
}
void MonsterManager::UnSelectAll()
{
	map<UINT,Monster*>::iterator itBegin = m_objMap.begin();
	map<UINT,Monster*>::iterator itEnd = m_objMap.end();
	while (itBegin != itEnd) {
		Monster* pMon = itBegin->second;
		pMon->SetSelected(FALSE);
		++itBegin;
	}
}