-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgamemanager.h
More file actions
93 lines (74 loc) · 2.34 KB
/
Copy pathgamemanager.h
File metadata and controls
93 lines (74 loc) · 2.34 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
#ifndef MAPLOADER_H
#define MAPLOADER_H
#include <QObject>
#include <QPointer>
#include <QList>
#include <QString>
#include <QTimer>
#include <QTcpServer>
#include <QSoundEffect>
#include "player.h"
class Map;
class QQuickView;
class QQmlComponent;
class NetworkClient;
class GameManager : public QObject
{
Q_OBJECT
Q_PROPERTY(int roundsPlayed READ roundsPlayed() NOTIFY roundsPlayedChanged())
Q_PROPERTY(QString address READ address() CONSTANT)
Q_PROPERTY(QStringList maps READ maps() NOTIFY mapsChanged())
Q_PROPERTY(bool soundEnabled READ soundEnabled WRITE setSoundEnabled NOTIFY soundEnabledChanged)
Q_PROPERTY(int ticksLeft READ ticksLeft NOTIFY tick)
public:
explicit GameManager(QQuickView *parent);
~GameManager();
Q_INVOKABLE void loadMap(const QString &path);
Q_INVOKABLE void addPlayer(NetworkClient *client = 0);
Q_INVOKABLE void removeHumanPlayers();
Q_INVOKABLE void setDebugMode(bool debug) { m_tickTimer.setInterval(debug ? 80 : 250); }
QString address();
QQuickView *view() { return m_view; }
QStringList maps();
Q_INVOKABLE QString version() { return /*QLatin1String(APP_VERSION) + " // build time: " +*/ QLatin1String(__TIME__) + ' ' + QLatin1String(__DATE__); }
bool soundEnabled() { return m_soundEnabled; }
void setSoundEnabled(bool enabled);
int ticksLeft() const { return m_ticksLeft; }
QList<QPointer<Player> > players() const { return m_players; }
public slots:
void explosionAt(const QPoint &position);
void endRound();
void startRound();
void playBombSound();
void stopGame();
void togglePause();
void kick(int index);
void resetScores();
int roundsPlayed() { return m_roundsPlayed; }
signals:
void gameOver();
void clientConnected();
void roundsPlayedChanged();
void mapsChanged();
void tick();
void soundEnabledChanged();
private slots:
void gameTick();
void clientConnect();
void clientDisconnected();
private:
void exportPlayerList();
Map *m_map;
QQuickView *m_view;
QList<QPointer<Player> > m_players;
QTimer m_tickTimer;
QTcpServer m_server;
QString m_currentMap;
int m_roundsPlayed;
bool m_soundEnabled;
QSoundEffect m_backgroundLoop;
QVector<QSoundEffect*> m_explosions;
QSoundEffect m_death;
int m_ticksLeft;
};
#endif // MAPLOADER_H