-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap_Level_2.h
More file actions
65 lines (59 loc) · 2.17 KB
/
Copy pathMap_Level_2.h
File metadata and controls
65 lines (59 loc) · 2.17 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
#ifndef MAP_LEVEL_2_H
#define MAP_LEVEL_2_H
#include<QWidget>
#include<QPainter>
#include <QCoreApplication>
#include <QGraphicsScene>
#include <QGraphicsItem>
#include <QGraphicsPixmapItem>
#include <QGraphicsRectItem>
#include <QTimer>
#include <QObject>
#include "Level_Map_Impl.h" // 引入实现类
#include "Steve.h"//引入人物类
#include "Zombie.h"//引入僵尸类
#include "Creeper.h"//引入爬行者类
#include "SpawnerBlock.h"//引入刷怪笼类
class Map_Level_2: public QObject, public Level_Map_Impl // 继承 QObject 和 Level_Map_Impl
{
Q_OBJECT
public:
Map_Level_2();
~Map_Level_2();
// 更新视野范围函数
void updateVisibility();
bool isRoad(int x, int y) const override;
bool isLadder(int x, int y) const override;
bool isTransmit(int x, int y) const override;
bool isTransmitBack(int x, int y) const override;
bool isInteractive(int x, int y) const override;
void setTrigger(int x, int y) override;
void removeTrigger(int x, int y) override;
bool Trigger_Arrow();
QGraphicsScene* getScene() const override { return level_2_Scene; }
int getBlockType(int x, int y) const { return map_2[y][x]; } // 获取指定位置的方块类型
bool isBox(int x, int y) const;
bool isTrigger(int x, int y) const override;
bool isBoxOpened(int x, int y) const;
void changeBoxState(int x, int y);
int getBoxId(int x, int y) const; // 获取箱子ID
void handlePlayerInteraction();
bool isCraftingTable(int x, int y) const; // 检测指定位置是否为工作台
void updateBlock(int x, int y, int newBlockType); // 添加更新地图块的方法,用于TNT爆炸
public:
QGraphicsScene* level_2_Scene;
Steve m_Steve;
QTimer* m_ZombieTimer;
QTimer* m_CreeperTimer;
private:
QGraphicsItem* m_Arrow;
QString filePath;
vector<vector<int>> map_2;
Zombie m_Zombie;
Creeper m_Creeper;
// 视野遮罩相关
QGraphicsPathItem* m_visionMask; // 视野遮罩
bool m_isInUpperArea; // 是否在上方区域(Y<250)
QTimer* m_visibilityTimer; // 更新视野的定时器
};
#endif // MAP_LEVEL_2_H