forked from ssine/airport-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckpoint.cpp
More file actions
105 lines (91 loc) · 2.29 KB
/
Copy pathcheckpoint.cpp
File metadata and controls
105 lines (91 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "stdafx.h"
#include <vector>
#include "globalvar.h"
#include "queue.h"
#include "checkpoint.h"
#include "function.h"
#include "view.h"
#include <iostream>
using namespace std;
int CheckPoint::num = 0;
float CPInterval = 0.15;
float CPBaseX = -0.70, CPBaseY = -0.15;
float CPWidth = 0.135, CPHeight = 0.35;
void CheckPoint::start() {
if(state != offDuty) {
state = onDuty;
}
}
void CheckPoint::toPause()
{
if (state != offDuty && state != closed)
state = pause;
}
void CheckPoint::toPause(time_t pauseTime)
{
if (state != offDuty && state != closed)
{
state = pause;
nextPopTime += pauseTime;
pauseEndTime = getTime() + pauseTime*2;
}
}
bool CheckPoint::isFull() {
return getNum() >= MaxCustCheck;
}
int CheckPoint::getState() {
return state;
}
void CheckPoint::refreshNum() {
if (state == pause&&getTime() > pauseEndTime)
{
state = onDuty;
} else if(state == onDuty || state == closed) {
if(!isempty()&&getTime()>nextPopTime) {
popPassenger();
for(int i = front; i != rear; i = (i+1)%500)
q[i].routeId--;
}
}
}
void CheckPoint::refreshPopTime() {
if(getTime()>nextPopTime)
{
//popPassenger();
if(!isempty())
nextPopTime=getTime()+getFirstPassenger().checkTime*10;
}
}
void CheckPoint::shut()
{
state=closed;
}
void CheckPoint::addPassenger(Passenger p) {
p.routeId = MaxCustNum+1+id*(MaxCustCheck+1) + getNum();
if(p.routeId > MaxCustNum+(id+1)*(MaxCustCheck+1)) {
p.routeId = MaxCustNum+(id+1)*(MaxCustCheck+1);
}
Queue::addPassenger(p);
}
CheckPoint::CheckPoint() {
id = num++;
width = CPWidth; height = CPHeight;
texId = ::texId[_checkPoint];
pos.x = CPBaseX + id*CPInterval;
pos.y = CPBaseY;
}
void CheckPoint::draw() {
this->Glyph::draw();
switch(state) {
case closed:
drawObject(CPblock, Point(pos.x+0.05, pos.y+height), 0.07, 0.12);
break;
case pause:
drawObject(CPpause, Point(pos.x+0.05, pos.y+height), 0.07, 0.12);
break;
}
for(int i = 0; i < this->getNum(); i++) {
if(i == 0) (*this)[i].draw(true);
else (*this)[i].draw(false);
}
}