ScummVM API documentation
m_triangles.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_ADV_M_TRIANGLES_H
23#define QDENGINE_MINIGAMES_ADV_M_TRIANGLES_H
24
25#include "qdengine/minigames/adv/common.h"
26#include "qdengine/minigames/adv/MinigameInterface.h"
27#include "qdengine/minigames/adv/ObjectContainer.h"
28
29namespace QDEngine {
30
31MinigameInterface *createMinigameTriangle(MinigameManager *runtime);
32
34 enum GameType {
35 TRIANGLE,
36 RECTANGLE,
37 HEXAGON
38 };
39
40 enum AnimationState {
41 NO_ANIMATION,
42 FIRST_PHASE,
43 SECOND_PHASE,
44 FIRD_PHASE
45 };
46
47 struct Node {
48 Node(int number = -1, int rot = -1);
49
50 void release(MinigameManager *runtime);
51 void debugInfo() const;
52
53 const QDObject &obj() const {
54 return _isBack ? _back : _face[_flip];
55 }
56
57 bool hit(const mgVect2f &pos) const;
58
59 int _number; // правильная позиция (номер слота)
60 int _rotation; // текущий угол поворота (правильный угол = 0)
61 int _flip;
62 QDObjects _face; // набор возможных углов переворота для лицевой стороны
63 QDObject _back; // обратная сторона
64 QDObject _border; // рамка
65 bool _isBack; // повернут лицом (true) или рубашкой (false)
66 bool _highlight;
67 bool _animated;
68
69 static const Common::String getFaceStateName(int angle, bool selected, bool animated, bool instantaneous);
70 static const char *getBackStateName(bool selected, bool animated, bool instantaneous);
71 static const char *getBorderStateName(bool selected);
72 };
74
75public:
78 void quant(float dt);
79
80private:
81 GameType _gameType = TRIANGLE;
82 Coords _positions;
83 int _selectDepth = 0;
84
85 int _fieldLines = 0;
86 int _fieldWidth = 0;
87 int _fieldSize = 0;
88 Nodes _nodes;
89 ObjectContainer _selectBorders[2];
90 ObjectContainer _backSides[6];
91 int _selected = 0;
92 int _hovered = 0;
93
94 bool _quickReselect = false;
95
96 AnimationState _animationState = NO_ANIMATION;
97 int _animatedNodes[2] = { 0 };
98 float _animationTime = 0.0;
99 float _animationTimer = 0.0;
100
102 void releaseNodeBack(Node &node);
104 void updateNode(Node &node, int position, int flip = 0, bool quick = false);
106 void highlight(int idx, bool hl);
107
109 void swapNodes(int pos1, int pos2, bool quick);
111 void beginSwapNodes(int pos1, int pos2);
113 bool animate(float dt);
115 void endSwapNodes(int pos1, int pos2);
116
118 int rowByNum(int num) const;
120 int rowBegin(int row) const;
122 int orientation(int num) const;
124 bool compatible(int num1, int num2) const;
126 int getRotate(int num1, int num2) const;
128 int destination(int num1, int num2) const;
130 mgVect3f slotCoord(int pos, int angle = 0) const;
131
132 MinigameManager *_runtime;
133};
134
135} // namespace QDEngine
136
137#endif // QDENGINE_MINIGAMES_ADV_M_TRIANGLES_H
Definition: str.h:59
Definition: MinigameInterface.h:27
Definition: RunTime.h:94
Definition: m_triangles.h:33
Definition: ObjectContainer.h:27
Definition: common.h:34
Базовый класс для игровых ресурсов.
Definition: console.h:28