ScummVM API documentation
mazechasepuzzle.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 NANCY_ACTION_MAZECHASEPUZZLE_H
23 #define NANCY_ACTION_MAZECHASEPUZZLE_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 namespace Action {
29 
30 // Implements a puzzle introduced in nancy5 where the player controls
31 // one piece being chased by several other pieces on a grid. Movement
32 // is performed via buttons, and both player and enemy navigate one
33 // tile at a time. Has some similarities to CollisionPuzzle, but was
34 // different enough to warrant its own class.
36 public:
38  virtual ~MazeChasePuzzle() {}
39 
40  void init() override;
41  void registerGraphics() override;
42  void updateGraphics() override;
43 
44  void readData(Common::SeekableReadStream &stream) override;
45  void execute() override;
46  void handleInput(NancyInput &input) override;
47 
48 protected:
49  enum WallType { kWallLeft = 1, kWallUp = 2, kWallRight = 3, kWallDown = 4, kWallLeftRight = 6, kWallUpDown = 6 };
50 
51  class Piece : public RenderObject {
52  public:
53  Piece(uint z) : RenderObject(z) {}
54  virtual ~Piece() {}
55 
56  Common::Point _gridPos;
57  Common::Point _lastPos;
58 
59  protected:
60  bool isViewportRelative() const override { return true; }
61  };
62 
63  Common::String getRecordTypeName() const override { return "MazeChasePuzzle"; };
64  bool isViewportRelative() const override { return true; }
65 
66  Common::Rect getScreenPosition(Common::Point gridPos);
67  void drawGrid();
68  void enemyMovement(uint enemyID);
69  bool canMove(uint pieceID, WallType direction);
70  void reset();
71 
72  Common::Path _imageName;
73 
74  Common::Point _exitPos = Common::Point(-1, -1);
75 
77  Common::Array<Common::Point> _startLocations;
78 
79  Common::Rect _playerSrc;
80  Common::Rect _enemySrc;
81  Common::Rect _verticalWallSrc;
82  Common::Rect _horizontalWallSrc;
83  Common::Rect _lightSrc;
84 
85  Common::Rect _upButtonSrc;
86  Common::Rect _rightButtonSrc;
87  Common::Rect _downButtonSrc;
88  Common::Rect _leftButtonSrc;
89  Common::Rect _resetButtonSrc;
90 
91  Common::Point _gridPos;
92 
93  Common::Rect _lightDest;
94 
95  Common::Rect _upButtonDest;
96  Common::Rect _rightButtonDest;
97  Common::Rect _downButtonDest;
98  Common::Rect _leftButtonDest;
99  Common::Rect _resetButtonDest;
100 
101  uint16 _lineWidth = 0;
102  uint16 _framesPerMove = 0;
103 
104  SoundDescription _failSound;
105  SoundDescription _moveSound;
106 
107  SceneChangeWithFlag _solveScene;
108  uint16 _solveSoundDelay = 0;
109  SoundDescription _solveSound;
110 
111  SceneChangeWithFlag _exitScene;
112  Common::Rect _exitHotspot;
113 
115  Common::Array<Piece> _pieces;
116 
117  int _currentAnimFrame = -1;
118 
119  uint32 _solveSoundPlayTime = 0;
120  bool _solved = false;
121  bool _reset = false;
122 };
123 
124 } // End of namespace Action
125 } // End of namespace Nancy
126 
127 #endif // NANCY_ACTION_MAZECHASEPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: array.h:52
Definition: mazechasepuzzle.h:35
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: commontypes.h:171
Definition: actionrecord.h:149
Definition: renderobject.h:36
Definition: rect.h:45
Definition: mazechasepuzzle.h:51
Definition: commontypes.h:254
Definition: actionmanager.h:32