-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapseg.h
50 lines (36 loc) · 1.34 KB
/
mapseg.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
#ifndef MAPSEG_H
#define MAPSEG_H
#include "baseblock.h"
#include <QObject>
enum MapBlock { nothing, wall, steel, sand, water, grass, boss };
class Mapseg : public Baseblock {
Q_OBJECT
private:
MapBlock _seg_kind = nothing; // 地块类型
int _life = 0; // 地块生命
unsigned _penetration = 0; // 导弹可穿透等级 0 可直接穿透,
bool _pass = true; // 坦克可通行? false 不可穿透,
private:
void init_kind(MapBlock kind); // 根据种类初始化地块
public:
//--- 构造器和析构器
Mapseg(const QPoint &pos, MapBlock segkind = nothing);
Mapseg(const int &x = 0, const int &y = 0, MapBlock segkind = nothing)
: Mapseg(QPoint{x, y}, segkind) {}
// 删除拷贝构造器 和 拷贝运算
Mapseg(const Mapseg &) = delete;
Mapseg &operator=(const Mapseg &) = delete;
virtual ~Mapseg() override = default;
// 接口函数
MapBlock get_kind() const { return _seg_kind; }
bool is_pass() const { return _pass; }
int penetration() const { return _penetration; }
virtual void display(QPainter &_painter) const override;
void update_seg();
int life() const { return _life; }
void set_life(int l) { _life = l; }
void set_disappear(bool a) { _disappear = a; }
// using Baseblock::is_disappear;
// bool is_disappear() const { return _disappear; }
};
#endif // MAPSEG_H