Ejemplo n.º 1
0
bool	Ground_Attack_Handler::CanAttack(Unit* u)
{
	double	xD;
	double	yD;
	double	xA;
	double	yA;
	double	dist;

	if ((u->GetModel()->GetType() == TYPE_AIR && (this->_unit->GetModel()->GetTargetType() != TARGET_ALL ||
	    this->_unit->GetModel()->GetTargetType() != TARGET_AIR)) ||
	    (u->GetModel()->GetType() == TYPE_GROUND && (this->_unit->GetModel()->GetTargetType() != TARGET_ALL ||
	    this->_unit->GetModel()->GetTargetType() != TARGET_GROUND)))
		return false;
	u->GetPositionXY(&xD, &yD);
	this->_unit->GetPositionXY(&xA, &yA);
	dist = IDdistance(xD, yD, xA, yA);
	dist -= u->GetModel()->GetSize();
	dist -= this->_unit->GetModel()->GetSize();
	dist -= this->_unit->GetModel()->GetArange();
	return (dist <= 0);
}
Ejemplo n.º 2
0
bool	Ground_Attack_Handler::CanAttack(Unit* u)
{
	double	xD;
	double	yD;
	double	xA;
	double	yA;
	double	dist;

	if (Game::GetInstance()->currentTick < this->_lastAttack + this->_unit->GetModel()->GetAspd())
		return false;
	if (u->GetPlayer() == this->_unit->GetPlayer())
//	if (u->GetPlayer() == this->_unit->GetPlayer() ||
//   u->GetPlayer()->GetTeam() == this->_unit->GetPlayer()->GetTeam())
		return false;
	if (this->_unit->GetModel()->GetTargetType() == TARGET_AIR)
		return false;
	u->GetPositionXY(&xD, &yD);
	this->_unit->GetPositionXY(&xA, &yA);
	dist = IDdistance(xD, yD, xA, yA) -
	       u->GetModel()->GetSize() -
	       this->_unit->GetModel()->GetSize() -
	       this->_unit->GetModel()->GetArange();
	return (dist <= 0);
}