-
Notifications
You must be signed in to change notification settings - Fork 0
/
towerposition.cpp
144 lines (140 loc) · 2.93 KB
/
towerposition.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "towerposition.h"
#include<QSize>
#include<QPainter>
#include<QPixmap>
const QSize towerposition::m_fixedsize(35,35);
towerposition::towerposition(QPoint pos,QString path):
m_pos(pos),
m_path(path),
m_hastower(false),
m_hastower1(false),
m_hastower2(false),
m_hastower3(false),
m_hasbutton(false),
m_hasbutton2(false),
m_hasupdate1(false),
m_hasupdate2(false)
{
}
bool towerposition::hastower()
{
return m_hastower;
}
void towerposition::sethastower(bool hastower)
{
m_hastower=hastower;
}
QPoint towerposition::getcenterpos()
{
QPoint tmp;
tmp.setX(m_pos.x()+m_fixedsize.width()/2);
tmp.setY(m_pos.y()+m_fixedsize.height()/2);
return tmp;
}
QPoint towerposition::getpos()
{
return m_pos;
}
bool towerposition::containpos(QPoint pos)
{
bool xinhere=(pos.x()>m_pos.x())&&(pos.x()<m_pos.x()+m_fixedsize.width());
bool yinhere=(pos.y()>m_pos.y())&&(pos.y()<m_pos.y()+m_fixedsize.height());
return xinhere&&yinhere;
}
void towerposition::draw(QPainter* painter) const
{
painter->drawPixmap(m_pos.x(),m_pos.y(),m_path);
}
bool towerposition::hasbutton()
{
return m_hasbutton;
}
void towerposition::sethasbutton(bool hasbutton)
{
m_hasbutton=hasbutton;
}
void towerposition::setbutton(selectbutton *button)
{
m_button=button;
}
selectbutton* towerposition::getbutton()
{
return m_button;
}
void towerposition::sethastower1(bool hastower11)
{
this->m_hastower1=hastower11;
sethastower(hastower11);
}
bool towerposition::hastower1()
{
return m_hastower1;
}
void towerposition::sethastower2(bool hastower22)
{
this->m_hastower2=hastower22;
sethastower(hastower22);
}
bool towerposition::hastower2()
{
return m_hastower2;
}
void towerposition::sethastower3(bool hastower33)
{
this->m_hastower3=hastower33;
sethastower(hastower33);
}
bool towerposition::hastower3()
{
return m_hastower3;
}
void towerposition::sethasbutton2(bool hasbutton2)
{
m_hasbutton2=hasbutton2;
}
bool towerposition::hasbutton2()
{
return m_hasbutton2;
}
void towerposition::sethasupdate1(bool hasupdate1)
{
m_hasupdate1=hasupdate1;
}
bool towerposition::hasupdate1()
{
return m_hasupdate1;
}
void towerposition::sethasupdate2(bool hasupdate2)
{
m_hasupdate2=hasupdate2;
}
bool towerposition::hasupdate2()
{
return m_hasupdate2;
}
void towerposition::setbutton2(selectbutton2 *button)
{
m_button2=button;
}
void towerposition::settower(tower *Tower)
{
m_tower=Tower;
}
tower* towerposition::gettower()
{
return this->m_tower;
}
selectbutton2* towerposition::getbutton2()
{
return m_button2;
}
void towerposition::removetower()
{
settower(NULL);
sethastower(false);
sethastower1(false);
sethastower2(false);
sethastower3(false);
sethasupdate1(false);
sethasupdate2(false);
}