| 1 |
#ifndef HEADER_UNIT_H |
| 2 |
#define HEADER_UNIT_H |
| 3 |
|
| 4 |
class Cube; |
| 5 |
class InputProvider; |
| 6 |
|
| 7 |
#include "KeyControl.h" |
| 8 |
#include "ControlSym.h" |
| 9 |
#include "Dir.h" |
| 10 |
#include "V2.h" |
| 11 |
|
| 12 |
#include "SDL.h" |
| 13 |
#include <string> |
| 14 |
|
| 15 |
/** |
| 16 |
* Unit to drive. |
| 17 |
*/ |
| 18 |
class Unit { |
| 19 |
private: |
| 20 |
KeyControl m_buttons; |
| 21 |
ControlSym m_symbols; |
| 22 |
Cube *m_model; |
| 23 |
bool m_startActive; |
| 24 |
private: |
| 25 |
char goLeft(); |
| 26 |
char goRight(); |
| 27 |
char goUp(); |
| 28 |
char goDown(); |
| 29 |
public: |
| 30 |
Unit(const KeyControl &buttons, const ControlSym &symbols, |
| 31 |
bool startActive=false); |
| 32 |
void takeModel(Cube *model) { m_model = model; } |
| 33 |
bool startActive() { return m_startActive; } |
| 34 |
|
| 35 |
bool canDrive() const; |
| 36 |
bool willMove() const; |
| 37 |
char drive(const InputProvider *input); |
| 38 |
char driveBorrowed(const InputProvider *input, |
| 39 |
const KeyControl &buttons); |
| 40 |
void activate(); |
| 41 |
|
| 42 |
char mySymbol(SDLKey key) const; |
| 43 |
char mySymbolBorrowed(SDLKey key, const KeyControl &buttons) const; |
| 44 |
char myOrder(Dir::eDir dir) const; |
| 45 |
char driveOrder(char move); |
| 46 |
|
| 47 |
bool isMoving() const; |
| 48 |
bool isMovingDown() const; |
| 49 |
bool isTurning() const; |
| 50 |
bool isPushing() const; |
| 51 |
bool isDrivenBy(char symbol) const; |
| 52 |
bool equalsModel(const Cube *other) const; |
| 53 |
V2 getLoc() const; |
| 54 |
int getW() const; |
| 55 |
int getH() const; |
| 56 |
bool isFreePlace(const V2 &loc) const; |
| 57 |
|
| 58 |
int countAnimPhases(const std::string &anim) const; |
| 59 |
bool isPowerful() const; |
| 60 |
}; |
| 61 |
|
| 62 |
#endif |