方块放置逻辑流程图.svg 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <svg width="1200" height="1600" xmlns="http://www.w3.org/2000/svg">
  2. <defs>
  3. <style>
  4. .title { font-family: Arial, sans-serif; font-size: 20px; font-weight: bold; fill: #2c3e50; }
  5. .subtitle { font-family: Arial, sans-serif; font-size: 14px; font-weight: bold; fill: #34495e; }
  6. .text { font-family: Arial, sans-serif; font-size: 12px; fill: #2c3e50; }
  7. .small-text { font-family: Arial, sans-serif; font-size: 10px; fill: #7f8c8d; }
  8. .start-end { fill: #e74c3c; stroke: #c0392b; stroke-width: 2; }
  9. .process { fill: #3498db; stroke: #2980b9; stroke-width: 2; }
  10. .decision { fill: #f39c12; stroke: #e67e22; stroke-width: 2; }
  11. .success { fill: #27ae60; stroke: #229954; stroke-width: 2; }
  12. .error { fill: #e74c3c; stroke: #c0392b; stroke-width: 2; }
  13. .arrow { stroke: #2c3e50; stroke-width: 2; fill: none; marker-end: url(#arrowhead); }
  14. .yes-arrow { stroke: #27ae60; stroke-width: 2; fill: none; marker-end: url(#arrowhead); }
  15. .no-arrow { stroke: #e74c3c; stroke-width: 2; fill: none; marker-end: url(#arrowhead); }
  16. </style>
  17. <marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
  18. <polygon points="0 0, 10 3.5, 0 7" fill="#2c3e50" />
  19. </marker>
  20. </defs>
  21. <!-- 标题 -->
  22. <text x="600" y="30" text-anchor="middle" class="title">方块放置逻辑流程图</text>
  23. <text x="600" y="50" text-anchor="middle" class="small-text">Block Placement Logic Flowchart</text>
  24. <!-- 开始 -->
  25. <ellipse cx="600" cy="90" rx="60" ry="25" class="start-end"/>
  26. <text x="600" y="95" text-anchor="middle" class="text">开始拖拽方块</text>
  27. <!-- 箭头1 -->
  28. <line x1="600" y1="115" x2="600" y2="140" class="arrow"/>
  29. <!-- 设置拖拽事件 -->
  30. <rect x="520" y="140" width="160" height="40" rx="5" class="process"/>
  31. <text x="600" y="155" text-anchor="middle" class="text">setupBlockDragEvents</text>
  32. <text x="600" y="170" text-anchor="middle" class="small-text">设置触摸事件监听</text>
  33. <!-- 箭头2 -->
  34. <line x1="600" y1="180" x2="600" y2="205" class="arrow"/>
  35. <!-- 拖拽开始 -->
  36. <rect x="520" y="205" width="160" height="40" rx="5" class="process"/>
  37. <text x="600" y="220" text-anchor="middle" class="text">onTouchStart</text>
  38. <text x="600" y="235" text-anchor="middle" class="small-text">记录初始位置,禁用碰撞</text>
  39. <!-- 箭头3 -->
  40. <line x1="600" y1="245" x2="600" y2="270" class="arrow"/>
  41. <!-- 拖拽移动 -->
  42. <rect x="520" y="270" width="160" height="40" rx="5" class="process"/>
  43. <text x="600" y="285" text-anchor="middle" class="text">onTouchMove</text>
  44. <text x="600" y="300" text-anchor="middle" class="small-text">更新方块位置,显示调试信息</text>
  45. <!-- 箭头4 -->
  46. <line x1="600" y1="310" x2="600" y2="335" class="arrow"/>
  47. <!-- 拖拽结束 -->
  48. <rect x="520" y="335" width="160" height="40" rx="5" class="process"/>
  49. <text x="600" y="350" text-anchor="middle" class="text">onTouchEnd</text>
  50. <text x="600" y="365" text-anchor="middle" class="small-text">调用handleBlockDrop</text>
  51. <!-- 箭头5 -->
  52. <line x1="600" y1="375" x2="600" y2="400" class="arrow"/>
  53. <!-- 处理方块放置 -->
  54. <rect x="520" y="400" width="160" height="40" rx="5" class="process"/>
  55. <text x="600" y="415" text-anchor="middle" class="text">handleBlockDrop</text>
  56. <text x="600" y="430" text-anchor="middle" class="small-text">核心放置逻辑处理</text>
  57. <!-- 箭头6 -->
  58. <line x1="600" y1="440" x2="600" y2="480" class="arrow"/>
  59. <!-- 判断是否在kuang区域 -->
  60. <polygon points="600,480 680,510 600,540 520,510" class="decision"/>
  61. <text x="600" y="505" text-anchor="middle" class="text">是否在kuang</text>
  62. <text x="600" y="520" text-anchor="middle" class="text">区域内?</text>
  63. <!-- kuang区域处理分支 -->
  64. <line x1="680" y1="510" x2="780" y2="510" class="yes-arrow"/>
  65. <text x="730" y="505" text-anchor="middle" class="small-text">是</text>
  66. <!-- 检查标签 -->
  67. <polygon points="780,480 860,510 780,540 700,510" class="decision"/>
  68. <text x="780" y="505" text-anchor="middle" class="text">BlockTag</text>
  69. <text x="780" y="520" text-anchor="middle" class="text">hasTag?</text>
  70. <!-- 有标签 -->
  71. <line x1="860" y1="510" x2="960" y2="510" class="yes-arrow"/>
  72. <text x="910" y="505" text-anchor="middle" class="small-text">有标签</text>
  73. <rect x="880" y="490" width="160" height="40" rx="5" class="success"/>
  74. <text x="960" y="505" text-anchor="middle" class="text">放回kuang区域</text>
  75. <text x="960" y="520" text-anchor="middle" class="small-text">移除标签,恢复原位置</text>
  76. <!-- 无标签 -->
  77. <line x1="780" y1="540" x2="780" y2="580" class="no-arrow"/>
  78. <text x="790" y="565" text-anchor="middle" class="small-text">无标签</text>
  79. <rect x="700" y="580" width="160" height="40" rx="5" class="error"/>
  80. <text x="780" y="595" text-anchor="middle" class="text">拒绝放置</text>
  81. <text x="780" y="610" text-anchor="middle" class="small-text">恢复到原位置</text>
  82. <!-- 网格区域处理分支 -->
  83. <line x1="520" y1="510" x2="420" y2="510" class="no-arrow"/>
  84. <text x="470" y="505" text-anchor="middle" class="small-text">否</text>
  85. <!-- 尝试放置到网格 -->
  86. <rect x="340" y="490" width="160" height="40" rx="5" class="process"/>
  87. <text x="420" y="505" text-anchor="middle" class="text">tryPlaceBlockToGrid</text>
  88. <text x="420" y="520" text-anchor="middle" class="small-text">BlockManager处理</text>
  89. <!-- 箭头到网格检查 -->
  90. <line x1="420" y1="530" x2="420" y2="570" class="arrow"/>
  91. <!-- 检查网格初始化 -->
  92. <polygon points="420,570 500,600 420,630 340,600" class="decision"/>
  93. <text x="420" y="595" text-anchor="middle" class="text">网格是否</text>
  94. <text x="420" y="610" text-anchor="middle" class="text">初始化?</text>
  95. <!-- 网格未初始化 -->
  96. <line x1="340" y1="600" x2="240" y2="600" class="no-arrow"/>
  97. <text x="290" y="595" text-anchor="middle" class="small-text">否</text>
  98. <rect x="160" y="580" width="160" height="40" rx="5" class="error"/>
  99. <text x="240" y="595" text-anchor="middle" class="text">放置失败</text>
  100. <text x="240" y="610" text-anchor="middle" class="small-text">网格未初始化</text>
  101. <!-- 网格已初始化 -->
  102. <line x1="420" y1="630" x2="420" y2="670" class="yes-arrow"/>
  103. <text x="430" y="655" text-anchor="middle" class="small-text">是</text>
  104. <!-- 查找B1节点 -->
  105. <rect x="340" y="670" width="160" height="40" rx="5" class="process"/>
  106. <text x="420" y="685" text-anchor="middle" class="text">查找B1节点</text>
  107. <text x="420" y="700" text-anchor="middle" class="small-text">获取方块基准位置</text>
  108. <!-- 箭头 -->
  109. <line x1="420" y1="710" x2="420" y2="750" class="arrow"/>
  110. <!-- 坐标转换 -->
  111. <rect x="340" y="750" width="160" height="40" rx="5" class="process"/>
  112. <text x="420" y="765" text-anchor="middle" class="text">坐标转换</text>
  113. <text x="420" y="780" text-anchor="middle" class="small-text">世界坐标→网格本地坐标</text>
  114. <!-- 箭头 -->
  115. <line x1="420" y1="790" x2="420" y2="830" class="arrow"/>
  116. <!-- 边界检查 -->
  117. <polygon points="420,830 500,860 420,890 340,860" class="decision"/>
  118. <text x="420" y="855" text-anchor="middle" class="text">是否在网格</text>
  119. <text x="420" y="870" text-anchor="middle" class="text">边界内?</text>
  120. <!-- 超出边界 -->
  121. <line x1="340" y1="860" x2="240" y2="860" class="no-arrow"/>
  122. <text x="290" y="855" text-anchor="middle" class="small-text">否</text>
  123. <rect x="160" y="840" width="160" height="40" rx="5" class="error"/>
  124. <text x="240" y="855" text-anchor="middle" class="text">超出边界</text>
  125. <text x="240" y="870" text-anchor="middle" class="small-text">放置失败</text>
  126. <!-- 在边界内 -->
  127. <line x1="420" y1="890" x2="420" y2="930" class="yes-arrow"/>
  128. <text x="430" y="915" text-anchor="middle" class="small-text">是</text>
  129. <!-- 查找最近网格 -->
  130. <rect x="340" y="930" width="160" height="40" rx="5" class="process"/>
  131. <text x="420" y="945" text-anchor="middle" class="text">findNearestGridNode</text>
  132. <text x="420" y="960" text-anchor="middle" class="small-text">找到最近的网格节点</text>
  133. <!-- 箭头 -->
  134. <line x1="420" y1="970" x2="420" y2="1010" class="arrow"/>
  135. <!-- 尝试放置到特定网格 -->
  136. <rect x="340" y="1010" width="160" height="50" rx="5" class="process"/>
  137. <text x="420" y="1025" text-anchor="middle" class="text">tryPlaceBlockTo</text>
  138. <text x="420" y="1040" text-anchor="middle" class="text">SpecificGrid</text>
  139. <text x="420" y="1055" text-anchor="middle" class="small-text">精确网格放置</text>
  140. <!-- 箭头 -->
  141. <line x1="420" y1="1060" x2="420" y2="1100" class="arrow"/>
  142. <!-- 检查是否可以放置 -->
  143. <polygon points="420,1100 500,1130 420,1160 340,1130" class="decision"/>
  144. <text x="420" y="1125" text-anchor="middle" class="text">canPlaceBlockAt</text>
  145. <text x="420" y="1140" text-anchor="middle" class="text">检查?</text>
  146. <!-- 不能放置 -->
  147. <line x1="340" y1="1130" x2="240" y2="1130" class="no-arrow"/>
  148. <text x="290" y="1125" text-anchor="middle" class="small-text">否</text>
  149. <rect x="160" y="1110" width="160" height="40" rx="5" class="error"/>
  150. <text x="240" y="1125" text-anchor="middle" class="text">网格被占用</text>
  151. <text x="240" y="1140" text-anchor="middle" class="small-text">或形状不匹配</text>
  152. <!-- 可以放置 -->
  153. <line x1="420" y1="1160" x2="420" y2="1200" class="yes-arrow"/>
  154. <text x="430" y="1185" text-anchor="middle" class="small-text">是</text>
  155. <!-- 成功放置处理 -->
  156. <rect x="340" y="1200" width="160" height="50" rx="5" class="process"/>
  157. <text x="420" y="1215" text-anchor="middle" class="text">handleSuccessful</text>
  158. <text x="420" y="1230" text-anchor="middle" class="text">Placement</text>
  159. <text x="420" y="1245" text-anchor="middle" class="small-text">成功放置后处理</text>
  160. <!-- 箭头 -->
  161. <line x1="420" y1="1250" x2="420" y2="1290" class="arrow"/>
  162. <!-- 标记占用位置 -->
  163. <rect x="340" y="1290" width="160" height="40" rx="5" class="process"/>
  164. <text x="420" y="1305" text-anchor="middle" class="text">markOccupiedPositions</text>
  165. <text x="420" y="1320" text-anchor="middle" class="small-text">更新网格占用状态</text>
  166. <!-- 箭头 -->
  167. <line x1="420" y1="1330" x2="420" y2="1370" class="arrow"/>
  168. <!-- 尝试合并 -->
  169. <rect x="340" y="1370" width="160" height="40" rx="5" class="process"/>
  170. <text x="420" y="1385" text-anchor="middle" class="text">tryMergeOnOverlap</text>
  171. <text x="420" y="1400" text-anchor="middle" class="small-text">检查是否可以合并</text>
  172. <!-- 箭头 -->
  173. <line x1="420" y1="1410" x2="420" y2="1450" class="arrow"/>
  174. <!-- 添加锁定提示 -->
  175. <rect x="340" y="1450" width="160" height="40" rx="5" class="process"/>
  176. <text x="420" y="1465" text-anchor="middle" class="text">addLockedVisualHint</text>
  177. <text x="420" y="1480" text-anchor="middle" class="small-text">添加视觉锁定效果</text>
  178. <!-- 箭头 -->
  179. <line x1="420" y1="1490" x2="420" y2="1530" class="arrow"/>
  180. <!-- 移除标签 -->
  181. <rect x="340" y="1530" width="160" height="40" rx="5" class="process"/>
  182. <text x="420" y="1545" text-anchor="middle" class="text">BlockTag.removeTag</text>
  183. <text x="420" y="1560" text-anchor="middle" class="small-text">移除方块标签</text>
  184. <!-- 所有错误路径汇聚到恢复位置 -->
  185. <line x1="240" y1="620" x2="240" y2="1400" class="arrow"/>
  186. <line x1="240" y1="880" x2="240" y2="1400" class="arrow"/>
  187. <line x1="240" y1="1150" x2="240" y2="1400" class="arrow"/>
  188. <line x1="780" y1="620" x2="780" y2="1400" class="arrow"/>
  189. <!-- 恢复原位置 -->
  190. <rect x="160" y="1400" width="160" height="40" rx="5" class="error"/>
  191. <text x="240" y="1415" text-anchor="middle" class="text">恢复原位置</text>
  192. <text x="240" y="1430" text-anchor="middle" class="small-text">放置失败,恢复到拖拽前位置</text>
  193. <!-- 成功结束 -->
  194. <line x1="420" y1="1570" x2="600" y2="1570" class="arrow"/>
  195. <line x1="960" y1="530" x2="960" y2="1570" class="arrow"/>
  196. <line x1="960" y1="1570" x2="600" y2="1570" class="arrow"/>
  197. <ellipse cx="600" cy="1570" rx="60" ry="25" class="success"/>
  198. <text x="600" y="1575" text-anchor="middle" class="text">放置完成</text>
  199. <!-- 图例 -->
  200. <rect x="50" y="50" width="200" height="180" fill="none" stroke="#bdc3c7" stroke-width="1"/>
  201. <text x="150" y="70" text-anchor="middle" class="subtitle">图例</text>
  202. <ellipse cx="80" cy="90" rx="25" ry="12" class="start-end"/>
  203. <text x="130" y="95" class="small-text">开始/结束</text>
  204. <rect x="55" y="105" width="50" height="20" class="process"/>
  205. <text x="130" y="118" class="small-text">处理过程</text>
  206. <polygon points="80,130 95,140 80,150 65,140" class="decision"/>
  207. <text x="130" y="143" class="small-text">判断条件</text>
  208. <rect x="55" y="155" width="50" height="20" class="success"/>
  209. <text x="130" y="168" class="small-text">成功操作</text>
  210. <rect x="55" y="180" width="50" height="20" class="error"/>
  211. <text x="130" y="193" class="small-text">错误/失败</text>
  212. <line x1="55" y1="205" x2="105" y2="205" class="yes-arrow"/>
  213. <text x="130" y="208" class="small-text">是/成功</text>
  214. <line x1="55" y1="220" x2="105" y2="220" class="no-arrow"/>
  215. <text x="130" y="223" class="small-text">否/失败</text>
  216. </svg>