|
|
@@ -252,6 +252,7 @@ const CONFIG = {
|
|
|
USE_ITEM_SUCCESS: '使用物品成功',
|
|
|
USE_SPECIAL_ITEM: '需要特殊物品才能使用',
|
|
|
NO_USE_ITEM: '当前位置不需要使用物品',
|
|
|
+ ERROR_ERROR: '错了错了',
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -1280,7 +1281,7 @@ window.pickupItem = async function() {
|
|
|
// 处理携带物品逻辑
|
|
|
if (tileMap && tileMap.img) {
|
|
|
|
|
|
- // 从地图上移除图标(但保留点的可通行性)
|
|
|
+ // 从地图上移除图标
|
|
|
const pointIndex = gameState.mapData.walkablePoints.findIndex(
|
|
|
p => p.x === x && p.y === y
|
|
|
);
|
|
|
@@ -1344,7 +1345,7 @@ window.useItem = async function() {
|
|
|
// 从携带物品中移除已使用的物品
|
|
|
gameState.player.carriedItems.splice(itemIndex, 1);
|
|
|
|
|
|
- // 从地图上移除图标(但保留点的可通行性)
|
|
|
+ // 从地图上移除图标
|
|
|
const pointIndex = gameState.mapData.walkablePoints.findIndex(
|
|
|
p => p.x === x && p.y === y
|
|
|
);
|
|
|
@@ -1387,6 +1388,41 @@ window.pause = async function(seconds) {
|
|
|
// 使用更细粒度的时间间隔,确保能快速响应重置操作
|
|
|
const interval = 100; // 100毫秒检查一次
|
|
|
const totalIterations = seconds * 10; // 总迭代次数
|
|
|
+
|
|
|
+
|
|
|
+ // 取人物当前位置
|
|
|
+ let x = playerPosition.value.x;
|
|
|
+ let y = playerPosition.value.y;
|
|
|
+ let tileMap = walkablePointsMap.get(`${x},${y}`);
|
|
|
+
|
|
|
+ // 根据当前方格类型执行相应操作(与声音播放同时进行)
|
|
|
+ if (tileMap) {
|
|
|
+
|
|
|
+ // 判断当前位置是否有特殊需求
|
|
|
+ if (tileMap && tileMap.type === BLOCKLY_MAP_TYPE_DICT.TASK) {
|
|
|
+
|
|
|
+ // 从地图上移除图标
|
|
|
+ const pointIndex = gameState.mapData.walkablePoints.findIndex(
|
|
|
+ p => p.x === x && p.y === y
|
|
|
+ );
|
|
|
+ if (pointIndex !== -1) {
|
|
|
+
|
|
|
+ // 保留点但移除img属性并设置完成状态图标
|
|
|
+ const updatedPoint = { ...gameState.mapData.walkablePoints[pointIndex] };
|
|
|
+ updatedPoint.img = updatedPoint.endImg; // 设置完成状态图标
|
|
|
+ updatedPoint.status = true;
|
|
|
+ gameState.mapData.walkablePoints.splice(pointIndex, 1, updatedPoint);
|
|
|
+
|
|
|
+ // 更新映射
|
|
|
+ walkablePointsMap.set(`${x},${y}`, updatedPoint);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用物品成功
|
|
|
+ showGameMessage(tileMap.finishedTip || CONFIG.TIPS.USE_ITEM_SUCCESS, 'success');
|
|
|
+ } else {
|
|
|
+ showGameMessage(CONFIG.TIPS.ERROR_ERROR, 'info');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
for (let i = 0; i < totalIterations; i++) {
|
|
|
// 检查是否应该停止执行
|
|
|
@@ -1617,7 +1653,7 @@ window.playSound = async function() {
|
|
|
// 判断当前位置是否有特殊需求
|
|
|
if (tileMap && tileMap.type === BLOCKLY_MAP_TYPE_DICT.TASK) {
|
|
|
|
|
|
- // 从地图上移除图标(但保留点的可通行性)
|
|
|
+ // 从地图上移除图标
|
|
|
const pointIndex = gameState.mapData.walkablePoints.findIndex(
|
|
|
p => p.x === x && p.y === y
|
|
|
);
|
|
|
@@ -1640,7 +1676,7 @@ window.playSound = async function() {
|
|
|
await new Promise(resolve => setTimeout(resolve, CONFIG.DELAY.PALY_MP3_TIMES));
|
|
|
return
|
|
|
} else {
|
|
|
- showGameMessage(CONFIG.TIPS.NO_USE_ITEM, 'info');
|
|
|
+ showGameMessage(CONFIG.TIPS.ERROR_ERROR, 'info');
|
|
|
}
|
|
|
}
|
|
|
|