-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStation.h
59 lines (47 loc) · 1.3 KB
/
Station.h
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
#pragma once
#include <QPoint>
#include <QPainter>
#include <QJsonObject>
#include <time.h>
#include "config.h"
#include "Object.h"
#include "Utils.h"
class Station : public Object {
enum Shape { CIRCLE, TRIANGLE, SQUARE, STAR, PENTAGON, RHOMBUS, CROSS, DIAMOND };
private:
static bool _uniqueStations[5];
QPoint _position;
unsigned int _currentPass;
Shape _shape;
int _index;
QTimer* _deathTimer;
int _deathTimerRemainingTime;
public:
Station(QPoint pos, int index, int shape = -1);
Station(const Station& s);
~Station();
// Metodi virtuali reimplementati
void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget);
QRectF boundingRect() const;
void advance() { }
// Savegame functions
void read(const QJsonObject& json);
void write(QJsonObject& json) const;
// Getters
QPoint position() { return _position; }
QPoint centerPos() {return QPoint(_position.x() + STATION_SIZE / 2,
_position.y() + STATION_SIZE / 2);}
int stationShape() { return int(_shape); }
int index() { return _index; }
int passengers() { return _currentPass; }
// Utility
bool pointerOnStation(QPoint pointerPos);
void addPassenger();
void removePassengers() { _currentPass = 0; }
int uniqueShape();
void resetUniqueStations();
void pauseDeathTimer();
void resumeDeathTimer();
};