2010-04-05 23:38:59 +02:00
|
|
|
#ifndef _MODEL_H
|
|
|
|
#define _MODEL_H
|
|
|
|
|
|
|
|
#include "ModelBase.h"
|
|
|
|
#include "AsteroidsEnums.h"
|
|
|
|
|
|
|
|
namespace asteroids {
|
|
|
|
|
|
|
|
class Model : public Engine::ModelBase {
|
|
|
|
public:
|
2010-04-14 22:01:45 +02:00
|
|
|
virtual ~Model() {};
|
2010-04-05 23:38:59 +02:00
|
|
|
virtual void Process();
|
|
|
|
int DoLoadLevel (const char* filename);
|
|
|
|
int DoSaveLevel (const char* filename);
|
2010-04-18 11:41:29 +02:00
|
|
|
bool OnLevelComplete();
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
void SetGameState (const GameState &state) {
|
|
|
|
mLastGameState = mGameState;
|
|
|
|
mGameState = state;
|
|
|
|
};
|
|
|
|
GameState GetGameState () { return mGameState; };
|
|
|
|
|
|
|
|
int GetPlayerLives () { return mPlayerLives; };
|
|
|
|
|
|
|
|
float GetWorldWidth ();
|
|
|
|
float GetWorldHeight ();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/** \brief Initializes the system */
|
|
|
|
virtual int OnInit (int argc, char* argv[]);
|
2010-04-14 22:01:45 +02:00
|
|
|
virtual void OnDestroy() {
|
|
|
|
Engine::ModelBase::OnDestroy();
|
|
|
|
mAsteroids.clear();
|
2010-04-18 11:41:29 +02:00
|
|
|
delete mLevelCompleteEventHandler;
|
2010-04-14 22:01:45 +02:00
|
|
|
};
|
2010-04-05 23:38:59 +02:00
|
|
|
virtual void OnRegisterCommands ();
|
|
|
|
|
|
|
|
virtual void OnCreateEntity (const int type, const unsigned int id);
|
|
|
|
virtual void OnKillEntity (const Engine::EntityBase *entity);
|
|
|
|
|
|
|
|
private:
|
2010-04-18 11:41:29 +02:00
|
|
|
unsigned int InitLevelList ();
|
|
|
|
|
2010-04-05 23:38:59 +02:00
|
|
|
/** \brief Keeps a list of all asteroids */
|
|
|
|
std::vector<unsigned int> mAsteroids;
|
|
|
|
|
|
|
|
GameState mGameState;
|
|
|
|
GameState mLastGameState;
|
|
|
|
|
|
|
|
int mPlayerLives;
|
2010-04-18 11:41:29 +02:00
|
|
|
std::vector<std::string> mLevelList;
|
|
|
|
unsigned int mCurrentLevelIndex;
|
|
|
|
|
|
|
|
/* event handler class definitions */
|
|
|
|
class LevelCompleteEventHandler : public Engine::EventListenerBase {
|
|
|
|
public:
|
|
|
|
explicit LevelCompleteEventHandler (Model *view) : mModel (view) {};
|
|
|
|
virtual bool HandleEvent (const Engine::EventBasePtr &event) const {
|
|
|
|
return mModel->OnLevelComplete();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
LevelCompleteEventHandler() {};
|
|
|
|
Model *mModel;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* event handler member variables */
|
|
|
|
LevelCompleteEventHandler *mLevelCompleteEventHandler;
|
2010-04-05 23:38:59 +02:00
|
|
|
|
|
|
|
friend class View;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _MODEL_H
|