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 
29 namespace QDEngine {
30 
31 MinigameInterface *createMinigameTriangleGame();
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();
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 char *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  };
73  typedef Std::vector<Node> Nodes;
74 
75 public:
78  void quant(float dt);
79 
80 private:
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  AnimationState _animationState = NO_ANIMATION;
95  int animatedNodes_[2] = { 0 };
96  float _animationTime = 0.0;
97  float _animationTimer = 0.0;
98 
100  void releaseNodeBack(Node &node);
102  void updateNode(Node &node, int position, int flip = 0, bool quick = false);
104  void highlight(int idx, bool hl);
105 
107  void swapNodes(int pos1, int pos2, bool quick);
109  void beginSwapNodes(int pos1, int pos2);
111  bool animate(float dt);
113  void endSwapNodes(int pos1, int pos2);
114 
116  int rowByNum(int num) const;
118  int rowBegin(int row) const;
120  int orientation(int num) const;
122  bool compatible(int num1, int num2) const;
124  int getRotate(int num1, int num2) const;
126  int destination(int num1, int num2) const;
128  mgVect3f slotCoord(int pos, int angle = 0) const;
129 };
130 
131 } // namespace QDEngine
132 
133 #endif // QDENGINE_MINIGAMES_ADV_M_TRIANGLES_H
Definition: common.h:34
Definition: MinigameInterface.h:27
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: m_triangles.h:33
Definition: ObjectContainer.h:27