-
Notifications
You must be signed in to change notification settings - Fork 1
/
gametools.h
143 lines (105 loc) · 3.37 KB
/
gametools.h
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
138
139
140
141
142
143
#ifndef GAMETOOLS_H
#define GAMETOOLS_H
#include <QString>
#include <QPoint>
#include <QPainter>
class GameScene;
class ToolSet;
struct PlaceInfo;
struct BonusInfo;
struct PlayerInfo;
struct LevelPackInfo;
#define ALL_TOOLS 100
class GameTool : public QObject
{
Q_OBJECT
friend class ToolSet;
public:
enum ToolAction { ToolOutOfRange, ToolInactive, ToolActive };
enum ToolType { ManualTool, AutoTool, ConstTool };
GameTool(int x, int y, int score);
GameTool(int x, int y, int score, const QString &resource);
virtual ~GameTool();
virtual ToolType type() const { return ManualTool; }
void setBase(ToolSet *set) { myToolset = set; }
void setCurrent();
inline const QPixmap& pixmap() const { return myPixmap; }
inline void setPixmap(const QPixmap &pm) { myPixmap = pm; }
inline BonusInfo* info() const { return bonusInfo; }
inline int score() const { return myScore; }
inline const QPoint& pos() const { return myPos; }
inline bool inProgress() const { return myProgress; }
inline bool isActive() const { return myActive; }
inline void setActive(bool act = true) { myActive = act; }
virtual QString hint() const;
// internal
virtual void advanceAndPaint(QPainter &p, int currentScore);
void animateActivation();
// defined for manual tools
virtual bool checkItemClick(int /*row*/, int /*col*/) { return false; }
virtual ToolAction checkItemState(int /*row*/, int /*col*/) { return ToolOutOfRange; }
// defined for auto tools
virtual bool checkToolClick() { return false; }
protected:
QPixmap myPixmap;
QPoint myPos;
int myScore;
ToolSet *myToolset;
int myProgress;
bool myActive;
BonusInfo *bonusInfo;
static int stage;
};
class ToolSet
{
public:
ToolSet();
~ToolSet();
inline GameTool* current() { return currentTool; }
inline GameTool* tool(int idx) { return tools.at(idx); }
int bonusClock() const;
int bonusScore() const;
int bonusTimer() const;
int bonusMag() const;
void readProfile(LevelPackInfo *lpi);
void writeProfile(LevelPackInfo *lpi);
void initGraphics();
void addScore(int score);
void nextToolActivated();
//int activeToolIndex(int score);
inline int nextToolIndex() const { return next_tool; }
void updateTools(QPainter &p);
inline int toolRow() const { return myOverRow; }
inline int toolCol() const { return myOverCol; }
bool checkMouseHover(const QPoint &pos);
bool checkMouseActions(const QPoint &pos);
bool checkItemClick(int row, int col);
GameTool::ToolAction checkItemState(int row, int col);
void checkMouseMoved(int row, int col);
void progressCurrent();
bool isPuzzle() const { return puzzle; }
protected:
QList<GameTool*> tools;
int toolScore;
GameTool *currentTool;
int myOverRow, myOverCol;
int next_tool;
int diff;
bool puzzle;
class HammerTool *hammerTool;
class BigHammerTool *bigHammerTool;
class SmallHammerTool *smallHammerTool;
class BombTool *bombTool;
class ThunderTool *thunderTool;
class ClockTool *clockTool;
class RandomKillTool *randomKillTool;
class MixerTool *mixerTool;
class UnblockTool *unblockTool;
class TwinTool *twinTool;
class MagBonus *magBonus;
class TimerBonus *timerBonus;
class ScoreBonus *scoreBonus;
class ClockBonus *clockBonus;
};
extern ToolSet * toolset;
#endif // GAMETOOLS_H