fysxasteroids/asteroids/Model.h

84 lines
2.1 KiB
C
Raw Normal View History

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:
virtual ~Model() {};
2010-04-05 23:38:59 +02:00
virtual void Process();
int DoLoadLevel (const char* filename);
int DoSaveLevel (const char* filename);
bool OnLevelComplete();
2010-06-10 23:30:29 +02:00
bool OnGameOver();
/** \brief Resets values from a previous game */
void OnNewGame ();
2010-04-05 23:38:59 +02:00
virtual void SetGameState (const unsigned int &state);
2010-04-05 23:38:59 +02:00
int GetPlayerLives () { return mPlayerLives; };
2010-05-02 22:39:49 +02:00
unsigned int GetPoints () { return mPoints; };
2010-06-10 23:30:29 +02:00
std::string GetPlayerName() { return mPlayerName; };
void SetPlayerName(const std::string &name) {
Engine::LogDebug("new player name: %s", name.c_str());
mPlayerName = name;
};
2010-04-05 23:38:59 +02:00
float GetWorldWidth ();
float GetWorldHeight ();
2010-06-10 23:30:29 +02:00
struct HighscoreEntry {
HighscoreEntry(): name ("unknown"), points (0) { };
HighscoreEntry (const char *e_name, const unsigned int e_points):
name (e_name), points (e_points) { };
std::string name;
unsigned int points;
};
/* Highscore */
void LoadHighscoreList ();
void SaveHighscoreList ();
unsigned int AddHighscoreEntry(const std::string &name, const unsigned int points);
bool HighscoreCmp (HighscoreEntry a, HighscoreEntry b);
std::list<HighscoreEntry> mHighscoreList;
unsigned int mNewestHighscoreEntryIndex;
2010-04-05 23:38:59 +02:00
protected:
/** \brief Initializes the system */
virtual int OnInit (int argc, char* argv[]);
virtual void OnDestroy() {
Engine::ModelBase::OnDestroy();
mAsteroids.clear();
2010-05-02 22:39:49 +02:00
mLevelList.clear();
2010-06-10 23:30:29 +02:00
SaveHighscoreList();
};
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:
unsigned int InitLevelList ();
2010-04-05 23:38:59 +02:00
/** \brief Keeps a list of all asteroids */
std::vector<unsigned int> mAsteroids;
int mPlayerLives;
2010-05-02 22:39:49 +02:00
unsigned int mPoints;
unsigned int mCurrentLevelIndex;
2010-06-10 23:30:29 +02:00
std::string mPlayerName;
std::vector<std::string> mLevelList;
virtual bool OnReceiveEvent (const Engine::EventBasePtr &event);
2010-04-05 23:38:59 +02:00
friend class View;
};
}
#endif // _MODEL_H