Ejemplo n.º 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);
}
Ejemplo n.º 2
0
Player* PlayerManager::NewPlayer(const string& strID)
{
	Player* play = Player::create();
	play->SetID(strID);

	play->setPosition(Point(Game()->GetConfig()->GetPlayerPosition_X(),Game()->GetConfig()->GetPlayerPosition_Y()));
	play->SetDestPoint(Point(Game()->GetConfig()->GetPlayerPosition_X(),Game()->GetConfig()->GetPlayerPosition_Y()));
	play->SetDirection(right_direction);

	play->Action(CodeMsg::code_player_static,right_direction);

	AddPlayer(play);

	return play;
}
Ejemplo n.º 3
0
void Engine()
{
	int SOs = SO.size(),Es = E.size(),Ps = P.size();
	//przesuniecia//
	Hero.Move();
	for(int i=0;i<Es;i++)E[i].Move();
	for(int i=0;i<Ps;i++)P[i].Move();
	
	//obsługa projectile//
	for(int i=0;i<Ps;i++)if(P[i].BOOM() || P[i].Range() <= 0){/*usuniecie pocisku*/};

	//sprawdzic czy cos umarło//

	
	//obsluga AI//
	for(int i=0;i<Es;i++)E[i].AI();
	
	//obsluga Hero//
	Hero.Action();
}