else if(this->m_cButton[this->m_iCurrentLevel].m_bPushed) {
if(this->m_iCurrentLevel==this->m_iCarTop){
this->m_iCarFor=DOWN;
this->Told("顶开");
} else {
this->m_iCarFor=UP;
this->Told("上开");
}
this->m_bCarAtLevel=TRUE;
this->m_bCarGateOpen=TRUE;
this->m_iCarTime=WAITSECOND;
// Internal Person want to go Out
this->CarOut();
}
else if (this->m_iCarCapacity>MAXCARPERSON-1) {
//Car Full, NonStop
this->m_iCarTime=RUNNINGSECOND;
this->Told("满员");
}
else if (theLevel[this->m_iCurrentLevel].m_bUpButtonPressed==TRUE){
// Level Same Request, Open Door
this->m_bCarAtLevel=TRUE;
this->m_bCarGateOpen=TRUE;
this->m_iCarTime=WAITSECOND;
this->m_iCarFor=UP;
this->Told("开上");
}
else if (this->m_cButton[this->m_iCurrentLevel].m_bPushed){
if(this->m_iCurrentLevel==0){
this->m_iCarFor=UP;
this->Told("底开");
} else {
this->m_iCarFor=DOWN;
this->Told("下开");
}
this->m_bCarAtLevel=TRUE;
this->m_bCarGateOpen=TRUE;
this->m_iCarTime=WAITSECOND;
// Internal Person want to go Out
this->CarOut();
}
else if (this->m_iCarCapacity>MAXCARPERSON-1) {
//Car Full, NonStop
this->m_iCarTime=RUNNINGSECOND;
this->Told("满员");
}
else if (theLevel[this->m_iCurrentLevel].m_bDownButtonPressed==TRUE){
// Level Same Request, Open Door
this->m_bCarAtLevel=TRUE;
this->m_bCarGateOpen=TRUE;
this->m_iCarFor=DOWN;
this->m_iCarTime=WAITSECOND;
this->Told("开下");
}
else if (this->CarBelowButton()) {
// Internal Down Request, Keep Going
this->m_iCarTime=RUNNINGSECOND;
this->Told("不停");
}
这是电梯类
class CLiftCar : public CObject
{
DECLARE_DYNCREATE(CLiftCar)
CLiftCar(); // protected constructor used by dynamic creation
// Attributes
public:
int m_iCarIndex; // the car number
int m_iCurrentLevel; // Which Level the car is
BOOL m_bCarGateOpen; // Car Gate is Open?
BOOL m_bCarAtLevel; // Car is just on a level?
int m_iCarFor; // Car Direction? UP,DOWN,NONE
int m_iCarTime; // Car Tick
int m_iSleepLevel; // Not Availabale
int m_iCarInfoDispX; // Debug Information
int m_iCarInfoDispY;
int m_iCarTop; // The Top Level of the Car
int m_iCarBottom; // The Bottom Level of the Car
int m_iCarCapacity; // How many psn in the car
int m_iCarHold[MAXCARPERSON]; // Who is in the car
struct CarPanel{ // Car Internal Panel
BOOL m_bPushed; // Someone Push for Out
BOOL m_bNonStop; // Car will not stop here
CRect m_rPosition; // For USer Click
} m_cButton[MAXLEVEL]; // Each Level has One Panel
private:
void Told(CString str); // Debug Tool
// Operations
public:
void InitCar(void); // As the Name
void CarOut(void); // "You'v got your Level, Out!!"
void UpCarIn(void); // "Going Up, Please Come In"
void DownCarIn(void); // "Going Down, Please Come In"
BOOL CarBelowButton(void); // Any Internal Below Button Pressed
BOOL CarAboveButton(void); // Any Internal Above Button Pressed
int CarJudge(void); // How to move for a idle Car
void CarWork(void); // MainLoop
void DrawDoor(void); // As the Name
void EraseDoor(void); // As the Name
void DrawCarIndicator(void); // Draw Car Status
void CarButtonInit(int lvl);
void CarButtonPress(int lvl, BOOL Press); // Press Car Button of the Lvl
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLiftCar)
//}}AFX_VIRTUAL
// Implementation
protected:
virtual ~CLiftCar();
// Generated message map functions
//{{AFX_MSG(CLiftCar)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG