⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bonus.h

📁 吃豆子游戏源码
💻 H
字号:
/**
 *	File	:	Bonus.h
 *  Author	:	Kevin Lynx
 *	Date	:	2007/8/1
 */
#ifndef _BONUS_H_
#define _BONUS_H_

#include <list>
#include "Sprite.h"
#include "Singleton.h"

using std::list;

class Player;

const float BONUS_EXIST_TIME = 60.0f;

/**
 * Bonus 
 *
 * Implements a bonus that can help player 
 */
class Bonus : public Sprite
{
public:
	/** 
	 * Constructor
	 *
	 */
	Bonus( int bonusType );

	/**
	 * Destructor
	 *
	 */
	~Bonus();

	/**
	 * init
	 *
	 */
	bool	init( ISceneManager *smgr, IAnimatedMesh *mesh, const vector3df &pos );

	/**
	 * collision with a box
	 *
	 * @param box the bounding box for a sprite ( player )
	 * @return true if collision check ok
	 */
	bool	collision( const aabbox3df &box );

	/**
	 * getExpPosition
	 *
	 * only used to create an exploding effect
	 */
	const vector3df getExpPosition();

	bool	disappear();

	/// inherited from base class
	void	update( float dt );

public:
	int		mBonusType;
	float	mExistTime;
};

/**
 * bonus manager
 *
 * manage all the bonus , bonus will be created when 
 * a monster is dead .
 */
class BonusManager : public Singleton<BonusManager>
{
public:
	/**
	 * some types
	 *
	 */
	typedef list<Bonus*> tBonuses;
	
public:
	/**
	 * Constructor
	 *
	 */
	BonusManager( IrrlichtDevice *device );

	/**
	 * Destructor
	 *
	 */
	~BonusManager();

	/**
	 * init
	 *
	 */
	bool	init();

	/**
	 * reset
	 *
	 * it just delete all bonus
	 */
	void	reset();
	/**
	 * release
	 *
	 * it will destroy all the bonus
	 */
	void	release();

	/**
	 * update 
	 *
	 */
	void	update( float dt );

	/**
	 * createBonus
	 *
	 */
	void    createBonus( const vector3df &pos );

	/**
	 * checkPlayer
	 *
	 * collision check between player and bonus
	 * if the player got the bonus, here will set 
	 * player properties directly
	 */
	bool	checkPlayer( Player *player );

private:
	IrrlichtDevice *mDevice;
	tBonuses    mBonuses;
};

#endif //end _BONUS_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -