//@STATE=作成中
//@DESCRIPTION ---------------------------------------------------------------
//	履歴：
//	$Log: AbstractEnemy.cpp,v $
//	Revision 1.1  2001/10/28 21:40:35  fujiwara
//	DLLに分割
//	
//@DESCRIPTION_END -----------------------------------------------------------
//@AUTHOR=S.F.
///////////////////////////////////////////////////////////////////////////////
#pragma warning( disable : 4786 )	//STLの警告外し

// System Includes //

// メモリーリーク検出用
#include "sfdebug.h"

#include <string>
#include <vector>
#include <memory>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <map>
#include "stdio.h"
#include "math.h"

// Project Includes //

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

#include "exception.h"
#include "singleton.h"
#include "system.h"
#include "console.h"
#include "input.h"
#include "sound.h"

#include "Obj.h"
#include "Obj2D.h"
#include "Obj3D.h"
#include "Obj3DL.h"
#include "ObjRectangle.h"
#include "ObjQuadrangle.h"

#include "Background.h"
#include "Scene.h"
#include "main.h"

#include "character.h"
#include "Hit.h"
#include "MyShip.h"
#include "Game.h"
#include "Enemys.h"
#include "AbstractCharacter.h"
#include "AbstractEnemy.h"


using namespace sf::application;
using namespace sf::application::enemy;

sf::system::console::sprite::PSprite AbstractEnemy::mspSpriteLight;

const sf::system::console::sprite::Info AbstractEnemy::msSpriteInfoLight = 
{
	"media\\enlight.png",0.0f,0.0f,0.0f,0.0f,0xff000000,console::sprite::SPRITE2D
};
//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////

AbstractEnemy::AbstractEnemy()
{

}

AbstractEnemy::~AbstractEnemy()
{

}

void AbstractEnemy::initLight(void)
{
	// Light部分
	mObjLight.index(0);
	mObjLight.sprite(mspSpriteLight.get());
	mObjLight.color(0x80ffff00);
	mObjLight.drawMode(sf::system::console::DRAW_ADD);
	mObjLight.visibility(true);
	mLightDirection = (int)(-16.0f * sf::system::instance()->deltaTime());
	mLightCount = 0xff;
}

void AbstractEnemy::moveLight(void)
{
	int temp;

	// ライト？
	mLightCount += mLightDirection;

	if(mLightCount <= 0 || mLightCount >= 255){
		mLightDirection = -mLightDirection;
		mLightCount += mLightDirection; 
	}

	temp = 0x80000000 + (mLightCount << 16) ;
	mObjLight.color(temp);
}

void AbstractEnemy::loadLight(void)
{
	using namespace sf::system::console::sprite;
	if(!mspSpriteLight.get()){
		sf::system::console::sprite::PSprite ptemp(sf::system::instance()->console()->createSprite(&msSpriteInfoLight)); 
		mspSpriteLight = ptemp;
	}
}