#include "GEnemyManager.h"

#ifdef _DXLIB
#include "GStaticDataDX.h"
#else
#include "GStaticData.h"
#endif

using namespace std;
using namespace GEnum;

void GEnemyManager::process(bool isMove, bool bIsAI){ 

	this->m_vecAdds.clear();

	for( list<GPlayer*>::iterator it = this->getList()->begin();
		it != this->getList()->end(); )
	{
		GPlayer* lpEnemy = *it;

		if( isMove ) {
			getStaticData()->m_CommonWork.defaultPlayerProcess( lpEnemy, true );
		}

		if( lpEnemy->getStoredDamage() >= MAX_ENEMY_PLAYER_HP ) {
			// ダメージが一定量/
			// TODO 一定時刻経過
			// →死亡
			lpEnemy->setAlive( false );
			
		}
		if( lpEnemy->isAlive() ) {
			// 描画
#ifdef _DXLIB
			lpEnemy->draw();
#else
			lpEnemy->draw( staticData->getImageManager() );
#endif

			it ++;
		} else {
			// 死亡

			// TODO エフェクト
			it = this->getList()->erase( it );
			delete lpEnemy;
		}
	}

	for( list<GPlayer*>::iterator it = this->m_vecAdds.begin();
		it != this->m_vecAdds.end();
		it ++ )
	{
		getList()->push_back( *it);
	}
}

GPlayer* GEnemyManager::create(int t, HPLVector center,
							   int nForceID) {
	GPlayer* lpPlayer = new GPlayer();
	lpPlayer->setup();
	lpPlayer->changeType( t );
	lpPlayer->setCenter( center );
	lpPlayer->m_nForceID = nForceID;

	this->getList()->push_back( lpPlayer );

	return lpPlayer;
}

void GEnemyManager::algorithm(GPlayer* lpEnemy) {
}
bool GEnemyManager::checkHitToShot(GPlayer* lpEnemy) {
	return false;
}

bool GEnemyManager::checkHitToPlayer(GPlayer* lpEnemy, GPlayer* lpTarget) {
	return false;
}

bool GEnemyManager::checkHitToEnemy(GPlayer* lpEnemy) {
	return false;
}
