MActionPipe.h
00001 #ifndef MACTIONPIPE_H 00002 #define MACTIONPIPE_H 00003 00004 00005 #include <list> 00006 using namespace std; 00007 class MObject; 00008 class MAction; 00009 class MActParam; 00010 00011 00012 enum PIPE_STATE { 00013 PIPE_STATE_STOPPED, 00014 PIPE_STATE_PENDING, 00015 PIPE_STATE_RUNNING 00016 }; 00017 00018 00019 class MActionPipe { 00020 protected: 00021 int m_nID; 00022 PIPE_STATE m_nState; 00023 MObject* m_pActor; 00024 00025 list<MAction*> m_ActionList; 00026 00027 public: 00028 MActionPipe(); 00029 virtual ~MActionPipe(); 00030 00031 int GetID() { return m_nID; } 00032 void SetID(int nID) { m_nID = nID; } 00033 PIPE_STATE GetState() { return m_nState; } 00034 void SetState(PIPE_STATE nState) { m_nState = nState; } 00035 MObject* GetActor() { return m_pActor; } 00036 void SetActor(MObject* pActor) { m_pActor = pActor; } 00037 00038 void AddAction(MAction* pAction); 00039 void DelAction(int nID); 00040 int GetActionCount() { return (int)m_ActionList.size(); } 00041 void ClearAction(); 00042 list<MAction*>::iterator GetActionBeginItor() { return m_ActionList.begin(); } 00043 list<MAction*>::iterator GetActionEndItor() { return m_ActionList.end(); } 00044 00045 virtual void Start() { SetState(PIPE_STATE_RUNNING); } 00046 virtual void Pause() { SetState(PIPE_STATE_PENDING); } 00047 virtual void Stop() { SetState(PIPE_STATE_STOPPED); } 00048 00049 virtual bool CheckTurn(int nTime) = 0; 00050 virtual bool Run(int nTime, MObject* pActor, MActParam* pParam); 00051 }; 00052 00053 00054 enum PIPE_ID { 00055 PIPE_ID_ACTIVE, 00056 PIPE_ID_DEFENSE, 00057 PIPE_ID_SKILL, 00058 PIPE_ID_BUFF 00059 }; 00060 00061 00062 class MActivePipe : public MActionPipe { 00063 protected: 00064 int m_nPrimaryInterval; 00065 int m_nLastPrimaryRunTime; 00066 00067 int m_nSecondaryInterval; 00068 int m_nLastSecondaryRunTime; 00069 00070 protected: 00071 int GetPrimaryInterval() { return m_nPrimaryInterval; } 00072 void SetPrimaryInterval(int nInterval) { m_nPrimaryInterval = nInterval; } 00073 int GetLastPrimaryRunTime() { return m_nLastPrimaryRunTime; } 00074 void SetLastPrimaryRunTime(int nTime) { m_nLastPrimaryRunTime = nTime; } 00075 00076 int GetSecondaryInterval() { return m_nSecondaryInterval; } 00077 void SetSecondaryInterval(int nInterval){ m_nSecondaryInterval = nInterval; } 00078 int GetLastSecondaryRunTime() { return m_nLastSecondaryRunTime; } 00079 void SetLastSecondaryRunTime(int nTime) { m_nLastSecondaryRunTime = nTime; } 00080 00081 public: 00082 MActivePipe(); 00083 virtual ~MActivePipe(); 00084 00085 virtual bool CheckTurn(int nTime); 00086 virtual bool Run(int nTime, MObject* pActor, MActParam* pParam); 00087 00088 void GiveDelayPenalty(int nTime, int nDelay); 00089 }; 00090 00091 class MDefensePipe : public MActionPipe { 00092 public: 00093 MDefensePipe(); 00094 virtual ~MDefensePipe(); 00095 00096 virtual bool CheckTurn(int nTime); 00097 }; 00098 00099 class MSkillPipe : public MActionPipe { 00100 protected: 00101 int m_nInterval; 00102 int m_nLastRunTime; 00103 00104 protected: 00105 enum SKILLSTATE { 00106 SKILLSTATE_IDLE, 00107 SKILLSTATE_ENTER, 00108 SKILLSTATE_EXCUTE, 00109 SKILLSTATE_EXIT 00110 }; 00111 00112 protected: 00113 00114 MSkillPipe::SKILLSTATE m_nSkillState; 00115 MSkillPipe::SKILLSTATE m_nNextSkillState; 00116 int m_nEnterDelay; 00117 int m_nExitDelay; 00118 int m_nTimeStamp; 00119 00120 bool CheckStateReady(MSkillPipe::SKILLSTATE nState) { 00121 if ((m_nSkillState == nState) || (m_nNextSkillState != nState)) return false; 00122 return true; 00123 } 00124 void SetNextSkillState(MSkillPipe::SKILLSTATE nState) { m_nNextSkillState = nState; } 00125 // void UnifySkillState() { m_nSkillState = m_nNextSkillState; } 00126 /* 00127 // vector<int> m_nStateTracer; 00128 bool CheckStateReady(MSkillPipe::SKILLSTATE nState) { 00129 if (m_nStateTracer.size() <= 0) return false; 00130 if (m_nStateTracer[0] == nState) return true; 00131 else return false; 00132 } 00133 void SetSkillState(MSkillPipe::SKILLSTATE nState) { 00134 m_nSkillState = nState; 00135 m_nStateTracer.push_back((int)nState); 00136 } 00137 void ClearStateTracer() { m_nStateTracer.clear(); }*/ 00138 int GetTimeStamp() { return m_nTimeStamp; } 00139 void SetTimeStamp(int nTime) { m_nTimeStamp = nTime; } 00140 int GetEnterDelay() { return m_nEnterDelay; } 00141 void SetEnterDelay(int nDelay) { m_nEnterDelay = nDelay; } 00142 int GetExitDelay() { return m_nExitDelay; } 00143 void SetExitDelay(int nDelay) { m_nExitDelay = nDelay; } 00144 00145 protected: 00146 virtual bool OnEnter(int nTime, MObject* pActor, MActParam* pParam); // On Enter State 00147 virtual bool OnExcute(int nTime, MObject* pActor, MActParam* pParam); // On Excute 00148 virtual bool OnExit(int nTime, MObject* pActor, MActParam* pParam); // On Exit State 00149 00150 public: 00151 MSkillPipe(); 00152 virtual ~MSkillPipe(); 00153 00154 int GetInterval() { return m_nInterval; } 00155 void SetInterval(int nInterval) { m_nInterval = nInterval; } 00156 int GetLastRunTime() { return m_nLastRunTime; } 00157 void SetLastRunTime(int nTime) { m_nLastRunTime = nTime; } 00158 00159 virtual void Start() { MActionPipe::Start(); SetNextSkillState(MSkillPipe::SKILLSTATE_ENTER); } 00160 virtual void Stop() { MActionPipe::Stop(); SetNextSkillState(MSkillPipe::SKILLSTATE_IDLE); } 00161 00162 virtual bool CheckTurn(int nTime); 00163 virtual bool Run(int nTime, MObject* pActor, MActParam* pParam); 00164 }; 00165 00166 class MBuffPipe : public MActionPipe { 00167 public: 00168 MBuffPipe(); 00169 virtual ~MBuffPipe(); 00170 00171 }; 00172 00173 00174 #endif
MAIET entertainment