22 #ifndef QDENGINE_MINIGAMES_3MICE2_RASKR_ALL_H 23 #define QDENGINE_MINIGAMES_3MICE2_RASKR_ALL_H 25 #include "common/debug.h" 27 #include "qdengine/qd_fwd.h" 28 #include "qdengine/qdcore/qd_minigame_interface.h" 32 const int zoneCountInit1[] = {
33 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
34 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 64, 89, 90, 91,
35 92, 93, 94, 96, 97, 98, 99, 129, 130, 132, 134, 135, 136, 138, 139, 140, 141,
36 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 153, 154, 155, 156, 157, 158,
37 159, 160, 161, 162, 163, 164, 166, 167, 170, 172, 173, 174, 178, 179, 180, 182,
38 184, 185, 186, 187, 190, 192, 196, 197, 198, 199, 204, 205, 211, 212, 213, 214,
39 216, 217, 218, 219, 220, 221, 222, 223, 225, 226, 227, 229, 230, 231, 232, 234,
40 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 254, 255, 260, 261, 263,
41 265, 267, 268, 271, 272, 273, 274, 280, 283, 284, 287, 288, 289, 290, 292, 294,
45 const int colorRegions1[] = {
46 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,
47 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 89, 308, 309, 311, 0,
49 90, 91, 92, 190, 207, 0,
51 96, 97, 98, 99, 103, 0,
54 134, 135, 136, 137, 0,
55 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 0,
56 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 0,
59 172, 173, 174, 175, 0,
60 178, 179, 180, 182, 184, 185, 186, 187, 229, 230, 231, 232, 233, 0,
63 197, 198, 199, 200, 0,
65 211, 212, 213, 214, 215, 0,
66 216, 217, 218, 219, 220, 221, 222, 223, 224, 0,
67 225, 226, 227, 228, 0,
69 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 0,
75 271, 272, 273, 274, 275, 0,
78 284, 287, 288, 289, 290, 307, 0,
85 const int zoneCountInit2[] = {
86 1, 2, 3, 4, 5, 6, 8, 16, 17, 18, 37, 46, 48, 49, 50, 51, 52, 53, 54, 55,
87 56, 57, 58, 59, 60, 61, 66, 69, 70, 71, 72, 73, 74, 75, 76, 78, 80, 81,
88 82, 83, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
89 101, 102, 106, 107, 108, 109, 111, 113, 114, 115, 116, 117, 118, 119, 121,
90 124, 126, 128, 130, 131, 132, 143, 146, 154, 156, 157, 191, 192, 193, 194,
94 int colorRegions2[] = {
95 1, 2, 3, 4, 5, 55, 56, 57, 58, 59, 60, 93, 94, 95, 96, 97, 98, 99, 100, 101, 134, 0,
101 48, 49, 50, 51, 52, 53, 54, 102, 103, 0,
104 69, 70, 71, 72, 73, 74, 75, 76, 81, 152, 0,
106 80, 85, 86, 87, 88, 89, 90, 91, 92, 141, 0,
108 106, 107, 108, 109, 110, 0,
110 113, 114, 115, 116, 117, 118, 119, 120, 0,
115 130, 131, 132, 133, 0,
121 191, 192, 193, 194, 195, 196, 0,
126 const int zoneCountInit3[] = {
127 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
128 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 189, 190, -1
131 const int colorRegions3[] = {
132 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,
133 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0,
138 const int zoneCountInit4[] = {
142 const int colorRegions4[] = {
154 debugC(1, kDebugMinigames,
"3mice2RaskrAll::init()");
156 _engine = engine_interface;
157 _scene = engine_interface->current_scene_interface();
161 const int *zoneCountInit =
nullptr;
162 int zoneCountDelta = 0;
166 _colorRegions = colorRegions1;
167 _colorRegionsSize =
ARRAYSIZE(colorRegions1);
170 zoneCountInit = zoneCountInit1;
172 }
else if (_gameNum == 2) {
174 _colorRegions = colorRegions2;
175 _colorRegionsSize =
ARRAYSIZE(colorRegions2);
178 zoneCountInit = zoneCountInit2;
180 }
else if (_gameNum == 3) {
182 _colorRegions = colorRegions3;
183 _colorRegionsSize =
ARRAYSIZE(colorRegions3);
186 zoneCountInit = zoneCountInit3;
188 }
else if (_gameNum == 4) {
190 _colorRegions = colorRegions4;
191 _colorRegionsSize =
ARRAYSIZE(colorRegions4);
194 zoneCountInit = zoneCountInit4;
197 error(
"qd3mice2RaskrAllMiniGame::init(): Unsupported gameNumber: %d", _gameNum);
200 for (
int i = 1; i <= _numZones; i++) {
202 _zoneCount[i] =
true;
205 for (
int i = 0; zoneCountInit[i] + zoneCountDelta != 0; i++)
206 _zoneCount[zoneCountInit[i] + zoneCountDelta] =
false;
214 for (
int i = 1; i <= _numZones; i++)
215 _zones[i]->set_shadow(0xFEFEFF, 0);
217 _objColorSel->
set_state(
"!\xEC\xE0\xF1\xEA\xE0");
228 debugC(3, kDebugMinigames,
"3mice2RaskrAll::quant(%f)", dt);
232 if (_timePassed > 0.5) {
244 const char *name = mouseObj->
name();
246 if (strstr(name,
"@color@")) {
250 for (
int i = 8; name[i] !=
'#'; i++)
255 if (strstr(name,
"zone@")) {
256 int num = getObjNum(name);
259 for (
int i = 0; i < _colorRegionsSize; i++) {
260 if (_colorRegions[i] == 0) {
265 if (_colorRegions[i] == num)
269 debugC(2, kDebugMinigames,
"zone: %d", num);
271 if (start < _colorRegionsSize) {
272 for (
int i = start; _colorRegions[i] != 0; i++)
279 _scene->release_object_interface(mouseObj);
285 debugC(1, kDebugMinigames,
"3mice2RaskrAll::finit()");
288 _engine->release_scene_interface(_scene);
307 enum { INTERFACE_VERSION = 112 };
308 int version()
const {
309 return INTERFACE_VERSION;
313 bool checkSolution() {
316 for (
int i = 1; i <= _numZones; i++) {
317 if (_zones[i]->shadow_color() != 0)
322 debugC(2, kDebugMinigames,
"Solution count: %d zone234: %06x", count, _zones[234]->shadow_color());
324 return count > _neededColors;
327 int getObjNum(
const char *name) {
328 const char *from = strstr(name,
"@");
329 const char *to = strstr(name,
"#");
347 bool _zoneCount[312] = {
false };
350 float _timePassed = 0;
354 const int *_colorRegions =
nullptr;
355 int _colorRegionsSize = 0;
356 int _neededColors = 0;
361 #endif // QDENGINE_MINIGAMES_3MICE2_RASKR_ALL_H #define ARRAYSIZE(x)
Definition: util.h:91
virtual bool set_shadow(int shadow_color, int shadow_alpha)=0
Устанавливает затенение.
bool init(const qdEngineInterface *engine_interface)
Инициализация игры.
Definition: 3mice2_raskr_all.h:153
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: 3mice2_raskr_all.h:148
bool quant(float dt)
Обсчёт логики игры, параметр - время, которое должно пройти в игре (в секундах).
Definition: 3mice2_raskr_all.h:227
size_t strlcpy(char *dst, const char *src, size_t size)
virtual const char * name() const =0
Имя объекта.
int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size)
Сохранение данных, вызывается при сохранении сцены, на которую повешена миниигра. ...
Definition: 3mice2_raskr_all.h:299
Definition: qd_minigame_interface.h:78
Definition: qd_minigame_interface.h:365
virtual int shadow_color() const =0
Возвращает цвет затенения.
int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size)
Загрузка данных, вызывается при загрузке сцены, на которую повешена миниигра.
Definition: 3mice2_raskr_all.h:303
virtual bool is_state_active(const char *state_name) const =0
Возвращает true, если состояние с именем state_name включено в данный момент.
Базовый класс для игровых ресурсов.
Definition: console.h:28
virtual qdMinigameObjectInterface * mouse_click_object_interface() const =0
Создаёт интерфейс к объекту, по которому кликнули мышью.
Интерфейс к динамическому объекту.
Definition: qd_minigame_interface.h:230
Интерфейс к сцене.
Definition: qd_minigame_interface.h:315
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
virtual bool set_state(const char *state_name)=0
Включает состояние с именем state_name.
virtual qdMinigameObjectInterface * object_interface(const char *object_name)=0
Создаёт интерфейс к объекту с именем object_name.
bool new_game(const qdEngineInterface *engine_interface)
Инициализация миниигры, вызывается при старте и перезапуске игры.
Definition: 3mice2_raskr_all.h:295
void void void void void debugC(int level, uint32 debugChannels, MSVC_PRINTF const char *s,...) GCC_PRINTF(3
bool finit()
Деинициализация игры.
Definition: 3mice2_raskr_all.h:284
virtual int shadow_alpha() const =0
Возвращает прозрачность затенения, значения - [0, 255], если равно -1, то затенения нет...