1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
#ifndef PLAYER_STATUS_H
#define PLAYER_STATUS_H
#include <string>
#include "Tools.h"
#include "SDLTools.h"
//----------------------------------------------------------------------------
class PlayerStatus
{
//------------------------------------------------------------------------
PlayerStatus();
~PlayerStatus();
public:
//------------------------------------------------------------------------
inline static PlayerStatus* getInstance()
{
if (sm_instance == NULL)
sm_instance = new PlayerStatus();
return sm_instance;
}
//------------------------------------------------------------------------
inline static void destroy()
{
if (sm_instance)
ZAP_POINTER(sm_instance);
}
//------------------------------------------------------------------------
inline void addScore(const unsigned points)
{
m_score += 1.0*points;
}
//------------------------------------------------------------------------
inline void addScore(const double points)
{
m_score += points;
}
//------------------------------------------------------------------------
inline void decScore(const unsigned points)
{
m_score -= 1.0*points;
}
//------------------------------------------------------------------------
inline void decScore(const double points)
{
m_score -= points;
}
//------------------------------------------------------------------------
inline unsigned getScore() const
{
return (unsigned)rint(m_score);
}
//------------------------------------------------------------------------
inline void incLifes()
{
++m_lifes;
}
//------------------------------------------------------------------------
inline void decLifes()
{
--m_lifes;
}
//------------------------------------------------------------------------
inline unsigned getLifes() const
{
return m_lifes;
}
//------------------------------------------------------------------------
inline void setInitialBonus(unsigned bonus)
{
m_bonus = bonus;
}
//------------------------------------------------------------------------
inline void decBonus(unsigned decrement)
{
if (m_bonus > decrement)
{
m_bonus -= decrement;
}
else
{
m_bonus = 0;
}
}
//------------------------------------------------------------------------
inline unsigned getBonus() const
{
return m_bonus;
}
//------------------------------------------------------------------------
inline void clearMessage()
{
m_message.clear();
}
//------------------------------------------------------------------------
inline void setMessage(const std::string &message)
{
m_message = message;
}
//------------------------------------------------------------------------
inline const std::string &getMessage() const
{
return m_message;
}
private:
//------------------------------------------------------------------------
double m_score;
unsigned m_lifes;
unsigned m_bonus;
std::string m_message;
//------------------------------------------------------------------------
static PlayerStatus* sm_instance;
};
#endif // PLAYER_STATUS_H
|