ScummVM API documentation
orchestra.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef QDENGINE_MINIGAMES_ORCHESTRA_H
23#define QDENGINE_MINIGAMES_ORCHESTRA_H
24
25#include "common/debug.h"
26
27#include "qdengine/qd_fwd.h"
28#include "qdengine/qdcore/qd_minigame_interface.h"
29
30namespace QDEngine {
31
33public:
36
37 bool init(const qdEngineInterface *engine_interface) {
38 debugC(1, kDebugMinigames, "Orchestra::init()");
39
40 _engine = engine_interface;
41 _scene = engine_interface->current_scene_interface();
42 if (!_scene)
43 return false;
44
45 _clickObj = _scene->object_interface(_scene->minigame_parameter("click_object"));
46 _doneObj = _scene->object_interface(_scene->minigame_parameter("done_object"));
47
48 _needReset = false;
49 _counter = 0;
50
51 return true;
52 }
53
54 bool quant(float dt) {
55 debugC(3, kDebugMinigames, "Orchestra::quant(%f)", dt);
56
57 if (!_needReset) {
58 if (_clickObj->is_state_active("\xe4\xe0")) { // "да"
59 _counter++;
60
61 _clickObj->set_state("\xed\xe5\xf2"); // "нет"
62
63 if (_counter >= 20) {
64 _needReset = 1;
65 _doneObj->set_state("\xe4\xe0"); // "да"
66 }
67 }
68 }
69
70 if (_needReset) {
71 if (_doneObj->is_state_active("\xed\xe5\xf2\x31")) { // "нет1"
72 _needReset = false;
73 _counter = 0;
74 }
75 }
76
77 return true;
78 }
79
80 bool finit() {
81 debugC(1, kDebugMinigames, "Orchestra::finit()");
82
83 if (_scene) {
84 _engine->release_scene_interface(_scene);
85 _scene = 0;
86 }
87
88 return true;
89 }
90
91 bool new_game(const qdEngineInterface *engine_interface) {
92 return true;
93 }
94
95 int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size) {
96 return 0;
97 }
98
99 int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size) {
100 return 0;
101 }
102
103 enum { INTERFACE_VERSION = 99 };
104 int version() const {
105 return INTERFACE_VERSION;
106 }
107
108private:
109 const qdEngineInterface *_engine = nullptr;
110 qdMinigameSceneInterface *_scene = nullptr;
111
112 qdMinigameObjectInterface *_clickObj = nullptr;
113 qdMinigameObjectInterface *_doneObj = nullptr;
114
115 bool _needReset = false;
116 int _counter = 0;
117};
118
119} // namespace QDEngine
120
121#endif // QDENGINE_MINIGAMES_ORCHESTRA_H
Definition: qd_minigame_interface.h:365
Definition: qd_minigame_interface.h:78
virtual bool set_state(const char *state_name)=0
Включает состояние с именем state_name.
virtual bool is_state_active(const char *state_name) const =0
Возвращает true, если состояние с именем state_name включено в данный момент.
Интерфейс к сцене.
Definition: qd_minigame_interface.h:315
virtual qdMinigameObjectInterface * object_interface(const char *object_name, bool test=false)=0
Создаёт интерфейс к объекту с именем object_name.
Definition: orchestra.h:32
bool quant(float dt)
Обсчёт логики игры, параметр - время, которое должно пройти в игре (в секундах).
Definition: orchestra.h:54
bool init(const qdEngineInterface *engine_interface)
Инициализация игры.
Definition: orchestra.h:37
int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size)
Загрузка данных, вызывается при загрузке сцены, на которую повешена миниигра.
Definition: orchestra.h:99
bool finit()
Деинициализация игры.
Definition: orchestra.h:80
int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size)
Сохранение данных, вызывается при сохранении сцены, на которую повешена миниигра.
Definition: orchestra.h:95
bool new_game(const qdEngineInterface *engine_interface)
Инициализация миниигры, вызывается при старте и перезапуске игры.
Definition: orchestra.h:91
void void void void void debugC(int level, uint32 debugChannel, MSVC_PRINTF const char *s,...) GCC_PRINTF(3
Базовый класс для игровых ресурсов.
Definition: console.h:28