Jelajahi Sumber

1、新加物品必须完成状态和终点校验

liyanbo 4 bulan lalu
induk
melakukan
4728e1c834
1 mengubah file dengan 7 tambahan dan 4 penghapusan
  1. 7 4
      src/components/blockly/MapGame.vue

+ 7 - 4
src/components/blockly/MapGame.vue

@@ -1290,6 +1290,7 @@ window.pickupItem = async function()  {
         // 保留点但移除img属性
         const updatedPoint = { ...gameState.mapData.walkablePoints[pointIndex] };
         delete updatedPoint.img;
+        updatedPoint.status = updatedPoint.must === true;
         gameState.mapData.walkablePoints.splice(pointIndex, 1, updatedPoint);
         // 更新映射
         walkablePointsMap.set(`${x},${y}`, updatedPoint);
@@ -1409,7 +1410,7 @@ window.pause = async function(seconds) {
 
         // 保留点但移除img属性并设置完成状态图标
         const updatedPoint = { ...gameState.mapData.walkablePoints[pointIndex] };
-        updatedPoint.img = updatedPoint.endImg; // 设置完成状态图标
+        updatedPoint.img = updatedPoint.endImg;
         updatedPoint.status = true;
         gameState.mapData.walkablePoints.splice(pointIndex, 1, updatedPoint);
 
@@ -1709,14 +1710,16 @@ window.isFinish = async function() {
 
   if (gameState.player.position.x === endPoint.value.x && gameState.player.position.y === endPoint.value.y) {
 
-    // 统计所有类型为TASK的任务点总数
+    // 统计所有类型为TASK的任务点总数||必须完成拾取物品的人物总数
     const totalTasks = gameState.mapData.walkablePoints.filter(
-        p => p.type === BLOCKLY_MAP_TYPE_DICT.TASK
+        p => p.type === BLOCKLY_MAP_TYPE_DICT.TASK ||
+            p.type === BLOCKLY_MAP_TYPE_DICT.ITEM && p.must === true
     ).length;
 
-    // 统计其中status为true的完成任务数
+    // 统计其中status为true的完成任务数||完成拾取物品的人物总数
     const completedTasks = gameState.mapData.walkablePoints.filter(
         p => p.type === BLOCKLY_MAP_TYPE_DICT.TASK && p.status === true
+                || p.type === BLOCKLY_MAP_TYPE_DICT.ITEM && p.must === true && p.status === true
     ).length;
 
     //blockly总星星数量