예제 #1
0
void TentacleLogicCmp::checkPlayerInRange()
{
	int nbr = 0;
	TentacleGearCmp* tmp = _start;
	PositionComponent* player = _boss->getPlayer()->GET_CMP(PositionComponent);
	PositionComponent* me = this->getEntity()->GET_CMP(PositionComponent);
	int xP = player->getX();
	int yP = player->getY();
	int xMe = me->getX();
	int yMe = me->getY();
	while (tmp != NULL)
	{
		tmp = tmp->getNext();
		nbr++;
	}
	if (pow((pow((xP - xMe), 2) + pow((yP - yMe), 2)), 0.5) <= 64 * nbr)
		setInRange(true);
	else
	{
		_inRange = false;
		_hasBeenReset = false;
	}


	getBoss()->getPlayer();
}
예제 #2
0
bool TentacleLogicCmp::isGoodSide(int were)
{
	PositionComponent* player = _boss->getPlayer()->GET_CMP(PositionComponent);
	PositionComponent* me = this->getEntity()->GET_CMP(PositionComponent);
	int xP = player->getX();
	int yP = player->getY();
	int xMe = me->getX();
	int yMe = me->getY();

	if (were == 0)
	{
		//left
		if (xP < xMe)
			return true;
	}
	else if (were == 1)
	{
		//right
		if (xP > xMe)
			return true;

	}
	else if (were == 2)
	{
		//top
		if (yP > yMe)
			return true;

	}
	else if (were == 3)
	{
		//bot
		if (yP < yMe)
			return true;
	}
	return false;
}