00001 #ifndef HEADER_CUBE_H 00002 #define HEADER_CUBE_H 00003 00004 class Shape; 00005 class Anim; 00006 class Rules; 00007 class DialogStack; 00008 00009 #include "V2.h" 00010 #include "Goal.h" 00011 #include "NoCopy.h" 00012 #include "Dir.h" 00013 00014 #include <vector> 00015 00016 /** 00017 * A object in game. 00018 */ 00019 class Cube : public NoCopy { 00020 public: 00021 typedef std::vector<Cube*> t_models; 00022 enum eWeight { 00023 NONE, 00024 LIGHT, 00025 HEAVY, 00026 FIXED 00027 }; 00028 enum eAction { 00029 ACTION_NO, 00030 ACTION_FALL, 00031 ACTION_MOVE 00032 }; 00033 private: 00034 int m_index; 00035 bool m_busy; 00036 V2 m_loc; 00037 bool m_alive; 00038 bool m_out; 00039 eWeight m_weight; 00040 eWeight m_power; 00041 bool m_lookLeft; 00042 bool m_lost; 00043 00044 Shape *m_shape; 00045 Anim *m_anim; 00046 Rules *m_rules; 00047 Goal m_goal; 00048 Dir::eDir m_outDir; 00049 int m_outCapacity; 00050 const DialogStack *m_dialogs; 00051 public: 00052 Cube(const V2 &location, 00053 eWeight weight, eWeight power, bool alive, 00054 Shape *shape); 00055 ~Cube(); 00056 void setGoal(const Goal &goal) { m_goal = goal; } 00057 void setIndex(int model_index) { m_index = model_index; } 00058 int getIndex() const { return m_index; } 00059 bool isBusy() const { return m_busy; } 00060 void setBusy(bool busy) { m_busy = busy; } 00061 00062 void change_die(); 00063 void change_goOut(); 00064 void change_remove(); 00065 void change_turnSide(); 00066 void change_setLocation(V2 loc) { m_loc = loc; } 00067 00068 V2 getLocation() const { return m_loc; } 00069 bool isAlive() const { return m_alive; } 00070 bool isLeft() const { return m_lookLeft; } 00071 bool isOut() const { return m_out; } 00072 bool isLost() const { return m_lost; } 00073 bool isSatisfy() const { return m_goal.isSatisfy(this); } 00074 bool isWrong() const { return m_goal.isWrong(this); } 00075 bool isWall() const { return m_weight >= Cube::FIXED; } 00076 bool shouldGoOut() const { return m_goal.shouldGoOut(); } 00077 00078 eWeight getWeight() const { return m_weight; } 00079 eWeight getPower() const { return m_power; } 00080 const Shape *shape() const { return m_shape; } 00081 Dir::eDir getLastMoveDir() const; 00082 00083 bool isOutDir(Dir::eDir dir) const { return m_outDir == dir; } 00084 void setOutDir(Dir::eDir outDir); 00085 void decOutCapacity(); 00086 00087 bool isTalking() const; 00088 void takeDialogs(const DialogStack *dialogs) { m_dialogs = dialogs; } 00089 00090 bool isDisintegrated(); 00091 bool isInvisible(); 00092 Anim *anim() { return m_anim; } 00093 const Anim *const_anim() const { return m_anim; } 00094 Rules *rules() { return m_rules; } 00095 const Rules *const_rules() const { return m_rules; } 00096 00097 virtual std::string toString() const; 00098 }; 00099 00100 #endif