| 1 |
#ifndef HEADER_CUBE_H |
| 2 |
#define HEADER_CUBE_H |
| 3 |
|
| 4 |
class Shape; |
| 5 |
class Anim; |
| 6 |
class Rules; |
| 7 |
class DialogStack; |
| 8 |
|
| 9 |
#include "V2.h" |
| 10 |
#include "Goal.h" |
| 11 |
#include "NoCopy.h" |
| 12 |
#include "Dir.h" |
| 13 |
|
| 14 |
#include <vector> |
| 15 |
|
| 16 |
/** |
| 17 |
* A object in game. |
| 18 |
*/ |
| 19 |
class Cube : public NoCopy { |
| 20 |
public: |
| 21 |
typedef std::vector<Cube*> t_models; |
| 22 |
enum eWeight { |
| 23 |
NONE, |
| 24 |
LIGHT, |
| 25 |
HEAVY, |
| 26 |
FIXED |
| 27 |
}; |
| 28 |
enum eAction { |
| 29 |
ACTION_NO, |
| 30 |
ACTION_FALL, |
| 31 |
ACTION_MOVE |
| 32 |
}; |
| 33 |
private: |
| 34 |
int m_index; |
| 35 |
bool m_busy; |
| 36 |
V2 m_loc; |
| 37 |
bool m_alive; |
| 38 |
bool m_out; |
| 39 |
eWeight m_weight; |
| 40 |
eWeight m_power; |
| 41 |
bool m_lookLeft; |
| 42 |
bool m_lost; |
| 43 |
|
| 44 |
Shape *m_shape; |
| 45 |
Anim *m_anim; |
| 46 |
Rules *m_rules; |
| 47 |
Goal m_goal; |
| 48 |
Dir::eDir m_outDir; |
| 49 |
int m_outCapacity; |
| 50 |
const DialogStack *m_dialogs; |
| 51 |
public: |
| 52 |
Cube(const V2 &location, |
| 53 |
eWeight weight, eWeight power, bool alive, |
| 54 |
Shape *shape); |
| 55 |
~Cube(); |
| 56 |
void setGoal(const Goal &goal) { m_goal = goal; } |
| 57 |
void setIndex(int model_index) { m_index = model_index; } |
| 58 |
int getIndex() const { return m_index; } |
| 59 |
bool isBusy() const { return m_busy; } |
| 60 |
void setBusy(bool busy) { m_busy = busy; } |
| 61 |
|
| 62 |
void change_die(); |
| 63 |
void change_goingOut(); |
| 64 |
void change_goOut(); |
| 65 |
void change_remove(); |
| 66 |
void change_turnSide(); |
| 67 |
void change_setLocation(const V2 &loc) { m_loc = loc; } |
| 68 |
|
| 69 |
V2 getLocation() const { return m_loc; } |
| 70 |
bool isAlive() const { return m_alive; } |
| 71 |
bool isLeft() const { return m_lookLeft; } |
| 72 |
bool isOut() const { return m_out; } |
| 73 |
bool isLost() const { return m_lost; } |
| 74 |
bool isSatisfy() const { return m_goal.isSatisfy(this); } |
| 75 |
bool isWrong() const { return m_goal.isWrong(this); } |
| 76 |
bool isWall() const { return m_weight >= Cube::FIXED; } |
| 77 |
bool shouldGoOut() const { return m_goal.shouldGoOut(); } |
| 78 |
bool isBorder() const { return m_index == -1; } |
| 79 |
|
| 80 |
eWeight getWeight() const { return m_weight; } |
| 81 |
eWeight getPower() const { return m_power; } |
| 82 |
const Shape *shape() const { return m_shape; } |
| 83 |
Dir::eDir getLastMoveDir() const; |
| 84 |
|
| 85 |
bool isOutDir(Dir::eDir dir) const { return m_outDir == dir; } |
| 86 |
Dir::eDir getOutDir() { return m_outDir; } |
| 87 |
int getOutCapacity() { return m_outCapacity; } |
| 88 |
void setOutDir(Dir::eDir outDir, |
| 89 |
int capacity=2, eWeight weight=Cube::FIXED); |
| 90 |
void decOutCapacity(); |
| 91 |
void setExtraParams(); |
| 92 |
|
| 93 |
bool isTalking() const; |
| 94 |
void takeDialogs(const DialogStack *dialogs) { m_dialogs = dialogs; } |
| 95 |
|
| 96 |
bool isDisintegrated(); |
| 97 |
bool isInvisible(); |
| 98 |
Anim *anim() { return m_anim; } |
| 99 |
const Anim *const_anim() const { return m_anim; } |
| 100 |
Rules *rules() { return m_rules; } |
| 101 |
const Rules *const_rules() const { return m_rules; } |
| 102 |
|
| 103 |
virtual std::string toString() const; |
| 104 |
}; |
| 105 |
|
| 106 |
#endif |