/*
* file EnnemyUnit.cpp
* EnnemyUnit
* 
* 27/01/2006
* Copyright Piquier Production
* 
*/

#include "EnnemyUnit.h"
#include "MemoryManager/debugNew.h"

EnnemyUnit::EnnemyUnit(Unit * u, EnnemyState s){
	unit = u;
	state = s;
	lastPosition = u->getPosition();
	hiddenElapsedTime = 0;
}

EnnemyUnit::~EnnemyUnit(void) {}


Unit * EnnemyUnit::getUnit() {
	return unit;
}

void EnnemyUnit::notifyAttack(Point2D position) {
	unit->notifyAttack(position);
}

void EnnemyUnit::decreaseHealthPoint(int decreasePoint) {
	unit->decreaseHealthPoint(decreasePoint);
	if(unit->isDead()){
		setState(EnnemyUnit::DEAD);
	}
}

void EnnemyUnit::decreaseMountHealthPoint(int decreasePoint) {
	unit->decreaseMountHealthPoint(decreasePoint);
}

Point2D EnnemyUnit::getPosition() {
	return unit->getPosition();
}

float EnnemyUnit::getAltitude() {
	return unit->getAltitude();
}

float EnnemyUnit::getRadius(){
	return unit->getRadius();
}

unitEnumeration::Armor EnnemyUnit::getArmorType() {
	return unit->getArmorType();
}

int EnnemyUnit::getHealthPoint() {
	return unit->getHealthPoint();
}

unitEnumeration::UnitType EnnemyUnit::getType() {
	return unit->getType();
}

void EnnemyUnit::setState(EnnemyState s) {
	state = s;
}

void EnnemyUnit::kill() {
	state = EnnemyUnit::DEAD;
	unit->kill();
}

bool EnnemyUnit::isAlive() {
	return unit->isAlive();
}

bool EnnemyUnit::isMounted() {
	return unit->isMounted();
}

bool EnnemyUnit::isMoving() {
	return unit->isMoving();
}

bool EnnemyUnit::isCharging() {
	return unit->isCharging();
}

bool EnnemyUnit::isInCombatPosture() {
	return unit->isInCombatPosture();
}

bool EnnemyUnit::isFleeing() {
	return unit->isFleeing();
}

bool EnnemyUnit::isWaiting() {
	return unit->isWaiting();
}

void EnnemyUnit::mountDie(){
	unit->dismount();
}

EnnemyUnit::EnnemyState EnnemyUnit::getState(){
	return state;
}

Mount * EnnemyUnit::getMount() {
	return unit->getMount();
}

Point2D EnnemyUnit::getDangerPosition(){
	return unit->getPosition();
}
float EnnemyUnit::getDangerRadius(){
	// le rayon de danger minimum d'une unité est de 3 cases
	float ret = 3;
	if(unit->getWeapon()->maxRange > ret){
		ret = unit->getWeapon()->maxRange;
	}
	return ret;
}

float EnnemyUnit::getDangerLevel(){
	return unit->getWeapon()->damage;
}

bool EnnemyUnit::isVisible(){
	return this->state == VISIBLE;
}

void EnnemyUnit::updateDistance(Point2D &pt) {
	distance = (this->getPosition() - pt).getLength();
}

float EnnemyUnit::getDistance() {
	return distance;
}

