#pragma once

#include	"Common.h"

#define	PLAYERSTATE_ALIVE				0
#define	PLAYERSTATE_DEAD				1

// vorward declarations of classes
class	CLevel;
class	CAliens;

// weapon class to handle ONE bullet
class	CWeapon
{
public:
	// konstructor / destructor
	CWeapon();
	~CWeapon();

	void	Reset();
	void	Destroy();

	// bullet sprite and particle effect id's
	int		m_iBulletSprID		= 0;
	int		m_iExplosionPfxID	= 0;
	
	// active flag
	int		m_iActive			= 0;

	// live time of bullet
	float	m_fLife				= 0.0f;
};

// player class handle player related things
class CPlayer
{
public:
	// constructor / destructor
	CPlayer();
	~CPlayer();

	void	SetReferences(CLevel* pLevel, CAliens* pAliens);

	// returns if game over or not
	int		IsGameOver()														{ return m_iGameOver; }

	// returns current score
	int		GetScore()															{ return m_iScore; }

	// returns current lives
	int		GetLives()															{ return m_iLives; }

	void	ResetPlayer(int iNewGame = 0);
	void	ResetBullets();
	void	HidePlayer();
	void	ShowPlayer();
	void	UpdatePlayer();
	void	MovePlayer();
	void	CheckPlayerWithScenery();
	void	CheckPlayerWithAliens();
	void	CheckBulletsWithAliens();
	void	FireBullets();
	void	UpdateBullets();
	void	KillPlayer();
	void	DestroyAllBullets();
	void	DestroyPlayer();

private:
	// player data (score, lives, gameover flag ...
	int		m_iScore				= 0;
	int		m_iLives				= 3;
	int		m_iDelay				= 0;
	int		m_iGameOver				= 0;

	// ship sprite and engine / explosion particles
	int		m_iParticleImgID		= IMGID_PARTICLES;
	int		m_iShipSprID			= 0;
	int		m_iEnginePfxID			= 0;
	int		m_iExplosionPfxID		= 0;

	// delay between shots
	float	m_fShootDelay			= 0.0f;

	// player state
	int		m_iState				= 0;

	// handle 10 bullets
	CWeapon	m_Bullets[10]			= {};


	// references
	CLevel*		m_refScenery;
	CAliens*	m_refAliens;
};

