//@STATE=嶌惉拞
//@DESCRIPTION ---------------------------------------------------------------
// MyBullets.h: MyBullets 僋儔僗偺僀儞僞乕僼僃僀僗
//	棜楌丗
// $Log: MyBullets.h,v $
// Revision 1.1  2001/10/28 21:40:36  fujiwara
// DLL偵暘妱
//
// Revision 1.6  2001/07/09 20:30:09  fujiwara
// 椺奜張棟偺慻傒崬傒
//
// Revision 1.5  2001/07/01 01:03:44  fujiwara
// const 偺尒捈偟
// 攝抲僄僨傿僞偼搑拞宱夁
//
// Revision 1.4  2001/06/10 21:17:01  fujiwara
// 僞乕僎僢僩捛壛乮抧忋梡乯
//
// Revision 1.3  2001/05/13 20:04:24  fujiwara
// 儊儌儕乕儕乕僋偑敪惗偟偨偺偱庢傝彍偔丅
// 帺抏偺僒僂儞僪僥僗僩
//
// Revision 1.2  2001/05/12 00:49:34  fujiwara
// 俠倁俽傪摫擖偟丄儘僌昞帵傪捛壛
//
//@DESCRIPTION_END -----------------------------------------------------------
//@AUTHOR=S.F.
///////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MYBULLETS_H__A11104A5_01DB_4B55_B2D4_04853C553E9C__INCLUDED_)
#define AFX_MYBULLETS_H__A11104A5_01DB_4B55_B2D4_04853C553E9C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

namespace sf {
	namespace application {
		namespace player {
			namespace bullet {

// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
// 帺抏掕媊 
// 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅

const	int MAX_BULLETS = 8;
const	int MAX_TYPE = 1;

class Bullets : public Characters {
	DECLARE_SINGLETON(Bullets)
	Bullets();
public:
	~Bullets();
	// Type 掕媊 //
	// 僆僽僕僃僋僩惗惉儊僜僢僪傊偺億僀儞僞 
	typedef Character * const (*CreateFuncPtr)(float,float,float,sf::application::scene::Game * const,int);
	// 僥僋僗僠儍儘乕僟傊偺億僀儞僞
	typedef void (*LoaderFuncPtr)(void);
	enum TYPE {
		NORMAL = 0
	};
	// OPERATIONS 
	void initialize();
	// 僉儍儔僋僞乕堏摦
	void move(void);

	const bool create(const TYPE id,const float x,const float y,const float z,sf::application::scene::Game * const pGame);
	const bool hitCheck(Character * const pDest);
	const bool hitCheck(Characters * const pDest);
	const void clear(int index){mpBullets[index] = NULL ; mCount-- ;};
private:
	Character *mpBullets[MAX_BULLETS];
	int mCount;
	int mMax;
	static const LoaderFuncPtr mpLoaders[MAX_TYPE];
	static const int INIT_BULLETS;
	static const CreateFuncPtr mpFunctions[MAX_TYPE];
};// Bullets()

	// 
	const float Z_OFFSET = 0.2f;
	
	// 僲乕儅儖抏 亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅亅
	class Normal : public sf::application::AbstractCharacter {
	public:
		// LIFECYCLE //
		Normal(){};
		~Normal(){ sf::application::player::bullet::Bullets::instance()->clear(index());};
		// OPERATORS //
		// OPERATIONS //
		void initialize();
		// 僉儍儔僋僞乕堏摦
		void move(void);

		// 拞怱嵗昗

		void hit(Character * const pDest)
		{	
			if(mState == MOVE){
				if(pDest->life() > life()){
					mHitRect.isChecking(false);
					mbHit = true;
					mState = BOUND;
					mObj.sprite(mpSpriteB.get());
					mAnimCount = 0.0f;
					sf::system::instance()->sound()->play(mSoundIDB,1,false,false);
				} else {
					mHitRect.isChecking(false);
					mbHit = true;
					mState = DEAD;
				}
			}
		};

		static Character * const create(float x,float y ,float z,sf::application::scene::Game * const pGame,int index);
		static void load(void);
		
		// ACCESS //
		sf::application::hit::Interface * const hitObj(void){ return &mHitRect;};
		// INQUIRY //
	private:
		enum STATE {
			MOVE,
			BOUND,
			DEAD
		} mState;

		hit::HitRect mHitRect;
		bool mbHit;
//		float mSpeed;
		float mBeforeY;
		float mAnimCount;

		sf::system::console::ObjRectangle mObj;
		static int mSoundID;
		static int mSoundIDB;
		static std::auto_ptr<sf::system::console::sprite::Sprite> mpSprite;
		static std::auto_ptr<sf::system::console::sprite::Sprite> mpSpriteB;

		static const console::sprite::Info mSpriteInfo;
		static const console::sprite::Info mSpriteBInfo;
		static const float mTextureWidth;
		static const float mTextureHeight;
	};// Normal 

};
		}	
	}
}

#endif // !defined(AFX_MYBULLETS_H__A11104A5_01DB_4B55_B2D4_04853C553E9C__INCLUDED_)
