-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplantyard.cpp
63 lines (57 loc) · 1.72 KB
/
plantyard.cpp
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
#include "plantyard.h"
PlantYard::PlantYard(SunLight* mySun, Field* myField, QWidget *parent) :
QWidget(parent),f(myField),sun(mySun)
{
layout = new QHBoxLayout;
addCard("peashooter",100,30);
addCard("sunflower",50,15);
addCard("wallNut",50,200);
//addCard("snowPea",175,100);
//addCard("splitPea",125,100);
addCard("jalapeno",125,200);
addCard("kernelPult",100,100);
addCard("melonPult",300,100);
addCard("threepeater",325,100);
// addCard("cherryBomb",150,200);
addCard("cobCannon",500,100);
// addCard("spikeweed",100,100);
// addCard("potatoMine",25,75);
// addCard("tallNut",125,250);
// addCard("squash",50,200);
addCard("repeater",200,200);
addCard("gatlingPea",250,200);
addCard("torchwood",175,75);
setLayout(layout);
}
void PlantYard::restart()
{
emit restartAllCards();
update();
}
void PlantYard::pause()
{
emit pauseAllCards();
}
void PlantYard::restore()
{
emit restoreAllCards();
}
void PlantYard::clear()
{
delete(layout);
layout = new QHBoxLayout;
setLayout(layout);
emit destroyAllCards();
}
void PlantYard::addCard(QString name,int cost, int time)
{
// qDebug()<<"come to PlantYard::addCard with name "<<name;
PlantCard* card = new PlantCard(name,cost,time,sun);
connect(sun,SIGNAL(updateSun(int)),card,SLOT(sunUpdate(int)));
connect(card,SIGNAL(tryPlanting(Plant*,PlantCard*)),f,SLOT(addPlant(Plant*,PlantCard*)));
connect(this,SIGNAL(restartAllCards()),card,SLOT(restart()));
connect(this,SIGNAL(pauseAllCards()),card,SLOT(pause()));
connect(this,SIGNAL(restoreAllCards()),card,SLOT(restore()));
connect(this,SIGNAL(destroyAllCards()),card,SLOT(destroyMe()));
layout->addWidget(card);
}