-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgarden.h
73 lines (67 loc) · 1.84 KB
/
garden.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
#ifndef GARDEN_H
#define GARDEN_H
#include <QtGui/QtGui>
#include "plant.h"
#include "zombie.h"
#include "sunlight.h"
#include "scene.h"
#include "timer.h"
class Pea;
class Sun;
QT_BEGIN_NAMESPACE
class QMouseEvent;
QT_END_NAMESPACE
class Garden : public QWidget
{
Q_OBJECT
public:
explicit Garden(SunLight *sun, QWidget *parent = 0);
Scene* scene;
// QGraphicsScene* scene;
QGraphicsView* view;
signals:
void addPlantAt(Plant* plant, int row, int col);
void removePlantAt(int row, int col);
void sendHit(Zombie* z, int strength, int property);
void sendEatTo(Plant* pp, int num);
void destroyPlant(Plant* plant);
void emitSun(int);
void explodeAt(int row, int col);
void restartScene();
void pauseScene();
void restoreScene();
void clearLine(int row);
public slots:
void restart();
void pause();
void restore();
void addPlant(Plant* plant, int row, int col);
void removePlant(Plant* plant);
void prepareToPlant(Plant* plant);
void prepareToRemove(void);
void addZombieAt(Zombie* zombie, int row, int col);
void addPea(int row, int col, int strength, int property, int targetCol=1000);
void deleteZombie(Zombie* z);
void destroyPea(Pea* p);
void deletePlant(Plant* p);
void produceSun(Plant* p);
void destroySun(Sun* s);
void emitCob();
/*
void collectSun(Plant* p);// to be changed
*/
protected:
virtual void mousePressEvent(QMouseEvent *event);
Plant* newPlant;
bool prepare;
bool prepare2Remove;
bool prepare4Cob;
SunLight* sun;
const QPoint targetPoint(const QPointF &position) const;
const QPoint scenePos(const QPointF &position) const;
const QPointF actualPos(int row, int col) const;
const QPoint plantPos(const QPointF &position) const;
Timer* timer;
bool paused;
};
#endif // GARDEN_H