-
Notifications
You must be signed in to change notification settings - Fork 2
/
model.h
76 lines (67 loc) · 1.87 KB
/
model.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef MODEL_H
#define MODEL_H
#include <QList>
#include <QPair>
#include <QSet>
#include <QMutex>
#include <QObject>
#include <QVariant>
#include <QTime>
#include <QColor>
#include "vector.h"
#include "player.h"
#include "bullet.h"
#include "obstacles.h"
class Model: public QObject
{
Q_OBJECT
public:
int mapWidth, mapLength;
Model();
//static Model * getInstance();
void addUpdatedPlayer(Player);
void setUpdatedPlayers(QString json);
QList<Player> getUpdatedPlayers();
QList<Player> getAllPlayers();
void addUpdatedBullet(Bullet);
void setUpdatedBullets(QString json);
QList<Bullet> getUpdatedBullets();
void addUpdatedObstacles(Obstacles);
void setUpdatedObstacles(QString json);
QList<Obstacles> getUpdatedObstacles();
void setName(QString n);
QString & getName();
void setColor(QColor c);
QColor getColor();
void updateKeys(QString name, bool state);
void updateMouse(float x, float y, float z);
void shot(float x, float y, float z);
QList<QString> getClearedActors();
void setMap(QString json);
int getMapWidth();
int getMapLength();
const Player * getSelf();
void updatePlayer(QVariant data);
void updateBullet(QVariant data);
void updateObstacle(QVariant data);
void setToClear(QString json);
const Player * getBestPlayer();
bool freeWay(const Actor * self, const Actor * target) const;
private:
// static Model * instance;
QMap<QString, Player*> players;
QMap<QString, Bullet*> bullets;
QMap<QString, Obstacles*> obstacles;
QString name;
QColor color;
int life, id;
QSet<QString> toClear;
mutable QMutex mutex;
QTime mouseTimeout;
void update();
signals:
void keyChanged(QString name, bool state);
void mouseChanged(float x, float y, float z);
void shotEvent(float x, float y, float z);
};
#endif // MODEL_H