#include "GObjectPlacer.h"

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

//#include "GEnemy.h"
#include "GPlayer.h"

GObjectPlacer::GObjectPlacer(){
}
GObjectPlacer::~GObjectPlacer(){
}

void GObjectPlacer::placePlayer(){
	std::map<int, int> mapDoneCenter;

	// ランダムに設定
	//getSetting()->randomPlayers( false );

	for( int i = 0; i < GEnum::PLAYER_MAX_NUM; i ++ ) {

		int nCenterIndex = -1;
		do {
			nCenterIndex = HPLMath::nextInt(0, playerPointList.size());
			if( mapDoneCenter.find( nCenterIndex ) != mapDoneCenter.end() ) {
				// 既に登録済み
				// 繰り返し
				nCenterIndex = -1;
			}
		} while( nCenterIndex < 0 );

		HPLVector center = this->playerPointList[ nCenterIndex ];

		// 登録
		mapDoneCenter[ nCenterIndex] = i;

		GPlayer* player = &getStaticData()->m_ObjectManager.m_aryPlayerList[i];

		player->getTrigger()->setTrigger(TriggerType::ON_THE_GROUND, false);
		player->setCenter(center);

		player->setVelocityAngle(0,-1);


		int faceDirection = 
			HPLMath::nextInt(0,2) == 0 ? FaceDirection::LEFT : FaceDirection::RIGHT;

		////
		// 向き設定
		player->setFaceDirection(faceDirection);

	}		

}

void GObjectPlacer::placeEnemy(HPLShootingObject* obj, HPLVector center, int nParam){
/*	GEnemy* enemy = getSetting()->getObjectManager()->getEnemyManager()->create(obj->getType(),
		center);
	enemy->setTarget(getSetting()->getObjectManager()->getPlayer());
*/
}

void GObjectPlacer::placeNeutral(HPLShootingObject* obj, HPLVector center,
		int scene, int mapIndex, std::vector<int>& vecParams){
/*	GNeutral* neutral = getSetting()->getObjectManager()->getNeutralManager()->create(obj->getType(),
		center);
	neutral->setTarget(getSetting()->getObjectManager()->getPlayer());
	neutral->setScene(scene);
	neutral->setMapIndex(mapIndex);*/
}	

void GObjectPlacer::placeEffect(HPLShootingObject* obj, HPLVector center){
}

void GObjectPlacer::placeItem(HPLShootingObject* obj, HPLVector center){
/*	GItem* item = getSetting()->getObjectManager()->getItemManager()->create(
		obj->getType(),
		center);
	item->setTarget(getSetting()->getObjectManager()->getPlayer());
*/
}
