@playcraft/skills 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. package/README.md +333 -0
  2. package/dist/src/index.d.ts +3 -0
  3. package/dist/src/index.d.ts.map +1 -0
  4. package/dist/src/index.js +2 -0
  5. package/dist/src/index.js.map +1 -0
  6. package/dist/src/skills.loader.d.ts +31 -0
  7. package/dist/src/skills.loader.d.ts.map +1 -0
  8. package/dist/src/skills.loader.js +200 -0
  9. package/dist/src/skills.loader.js.map +1 -0
  10. package/dist/src/skills.types.d.ts +44 -0
  11. package/dist/src/skills.types.d.ts.map +1 -0
  12. package/dist/src/skills.types.js +9 -0
  13. package/dist/src/skills.types.js.map +1 -0
  14. package/package.json +35 -0
  15. package/skills/2048_core.aigameplay/SKILL.md +123 -0
  16. package/skills/2048_core.aigameplay/manifest.json +159 -0
  17. package/skills/2048_core.aigameplay/ref/pgs-schema.json +194 -0
  18. package/skills/2048_core.aigameplay/ref/reducer.template.ts +189 -0
  19. package/skills/SKILL.md +46 -0
  20. package/skills/ad_compliance_rules.aiconfig/SKILL.md +85 -0
  21. package/skills/ad_compliance_rules.aiconfig/manifest.json +60 -0
  22. package/skills/agent_remix_orchestrator.aicomponent/SKILL.md +257 -0
  23. package/skills/agent_remix_orchestrator.aicomponent/manifest.json +12 -0
  24. package/skills/app_metadata.aiconfig/SKILL.md +53 -0
  25. package/skills/app_metadata.aiconfig/manifest.json +32 -0
  26. package/skills/appear_sfx.aiaudio/SKILL.md +59 -0
  27. package/skills/appear_sfx.aiaudio/manifest.json +45 -0
  28. package/skills/appear_sfx.aiaudio/ref/appear.mp3 +0 -0
  29. package/skills/arrow_move_error_sfx.aiaudio/SKILL.md +59 -0
  30. package/skills/arrow_move_error_sfx.aiaudio/manifest.json +45 -0
  31. package/skills/arrow_move_error_sfx.aiaudio/ref/arrow_move_error.mp3 +0 -0
  32. package/skills/arrow_path_data_format.aicomponent/SKILL.md +152 -0
  33. package/skills/arrow_path_data_format.aicomponent/manifest.json +57 -0
  34. package/skills/arrow_path_data_format.aicomponent/ref/LevelParser.ts +188 -0
  35. package/skills/arrow_path_data_format.aicomponent/ref/LevelTypes.ts +131 -0
  36. package/skills/arrow_pick_match_rules.aigameplay/SKILL.md +117 -0
  37. package/skills/arrow_pick_match_rules.aigameplay/manifest.json +105 -0
  38. package/skills/arrow_pick_match_rules.aigameplay/ref/pgs-schema.json +180 -0
  39. package/skills/asset_pipeline_scripts.aicomponent/SKILL.md +117 -0
  40. package/skills/asset_pipeline_scripts.aicomponent/manifest.json +17 -0
  41. package/skills/asset_pipeline_scripts.aicomponent/ref/gen-sprite.sh +105 -0
  42. package/skills/ball_sort.aigameplay/SKILL.md +109 -0
  43. package/skills/ball_sort.aigameplay/manifest.json +155 -0
  44. package/skills/ball_sort.aigameplay/ref/pgs-schema.json +192 -0
  45. package/skills/ball_sort.aigameplay/ref/reducer.template.ts +156 -0
  46. package/skills/basketball_shot.aigameplay/SKILL.md +94 -0
  47. package/skills/basketball_shot.aigameplay/manifest.json +150 -0
  48. package/skills/basketball_shot.aigameplay/ref/pgs-schema.json +229 -0
  49. package/skills/basketball_shot.aigameplay/ref/reducer.template.ts +189 -0
  50. package/skills/bg_music.aiaudio/SKILL.md +61 -0
  51. package/skills/bg_music.aiaudio/manifest.json +48 -0
  52. package/skills/bg_music.aiaudio/ref/bg.mp3 +0 -0
  53. package/skills/big_watermelon.aigameplay/SKILL.md +94 -0
  54. package/skills/big_watermelon.aigameplay/manifest.json +155 -0
  55. package/skills/big_watermelon.aigameplay/ref/pgs-schema.json +191 -0
  56. package/skills/big_watermelon.aigameplay/ref/reducer.template.ts +202 -0
  57. package/skills/block_puzzle.aigameplay/SKILL.md +121 -0
  58. package/skills/block_puzzle.aigameplay/manifest.json +154 -0
  59. package/skills/block_puzzle.aigameplay/ref/pgs-schema.json +170 -0
  60. package/skills/block_puzzle.aigameplay/ref/reducer.template.ts +182 -0
  61. package/skills/board_entity_sprite.aiimage/SKILL.md +255 -0
  62. package/skills/board_entity_sprite.aiimage/manifest.json +153 -0
  63. package/skills/board_entity_sprite.aiimage/ref/ProceduralCar.ts +357 -0
  64. package/skills/board_entity_sprite.aiimage/ref/car.png +0 -0
  65. package/skills/board_entity_sprite.aiimage/ref/car.webp +0 -0
  66. package/skills/bottom_ui_bar.aicomponent/SKILL.md +50 -0
  67. package/skills/bottom_ui_bar.aicomponent/manifest.json +31 -0
  68. package/skills/bottom_ui_bar.aicomponent/ref/GameBottomUI.ts +27 -0
  69. package/skills/bubble_shooter.aigameplay/SKILL.md +129 -0
  70. package/skills/bubble_shooter.aigameplay/manifest.json +181 -0
  71. package/skills/bubble_shooter.aigameplay/ref/pgs-schema.json +226 -0
  72. package/skills/bubble_shooter.aigameplay/ref/reducer.template.ts +228 -0
  73. package/skills/button_click_sfx.aiaudio/SKILL.md +59 -0
  74. package/skills/button_click_sfx.aiaudio/manifest.json +45 -0
  75. package/skills/button_click_sfx.aiaudio/ref/button_click.mp3 +0 -0
  76. package/skills/calm_piano.aiaudio/SKILL.md +68 -0
  77. package/skills/calm_piano.aiaudio/manifest.json +50 -0
  78. package/skills/camera_controller_3d.aicomponent/SKILL.md +100 -0
  79. package/skills/camera_controller_3d.aicomponent/manifest.json +52 -0
  80. package/skills/camera_controller_3d.aicomponent/ref/CameraController.ts +199 -0
  81. package/skills/camera_controller_3d.aicomponent/ref/OrbitControlsAdapter.ts +152 -0
  82. package/skills/candy_tile.aiimage/SKILL.md +62 -0
  83. package/skills/candy_tile.aiimage/manifest.json +49 -0
  84. package/skills/car_parking.aigameplay/SKILL.md +105 -0
  85. package/skills/car_parking.aigameplay/manifest.json +164 -0
  86. package/skills/car_parking.aigameplay/ref/pgs-schema.json +163 -0
  87. package/skills/car_parking.aigameplay/ref/reducer.template.ts +166 -0
  88. package/skills/castle.aiimage/SKILL.md +64 -0
  89. package/skills/castle.aiimage/manifest.json +48 -0
  90. package/skills/cheerful_ukulele.aiaudio/SKILL.md +72 -0
  91. package/skills/cheerful_ukulele.aiaudio/manifest.json +50 -0
  92. package/skills/click_sfx.aiaudio/SKILL.md +59 -0
  93. package/skills/click_sfx.aiaudio/manifest.json +45 -0
  94. package/skills/click_sfx.aiaudio/ref/click.mp3 +0 -0
  95. package/skills/combo_display.aicomponent/SKILL.md +45 -0
  96. package/skills/combo_display.aicomponent/manifest.json +31 -0
  97. package/skills/combo_display.aicomponent/ref/ComboManager.ts +362 -0
  98. package/skills/combo_display.aicomponent/ref/ComboSmallUI.ts +232 -0
  99. package/skills/combo_praise_text.aicomponent/SKILL.md +56 -0
  100. package/skills/combo_praise_text.aicomponent/manifest.json +34 -0
  101. package/skills/combo_praise_text.aicomponent/ref/ComboManager.ts +362 -0
  102. package/skills/countdown_timer.aicomponent/SKILL.md +44 -0
  103. package/skills/countdown_timer.aicomponent/manifest.json +35 -0
  104. package/skills/countdown_timer.aicomponent/ref/CountdownDisplay.ts +213 -0
  105. package/skills/cta_platform_config.aiconfig/SKILL.md +72 -0
  106. package/skills/cta_platform_config.aiconfig/manifest.json +56 -0
  107. package/skills/debug_overlay.aicomponent/SKILL.md +75 -0
  108. package/skills/debug_overlay.aicomponent/manifest.json +17 -0
  109. package/skills/debug_overlay.aicomponent/ref/DebugOverlay.ts +144 -0
  110. package/skills/desert.aiimage/SKILL.md +63 -0
  111. package/skills/desert.aiimage/manifest.json +49 -0
  112. package/skills/difficulty_curve_designer.aiconfig/SKILL.md +68 -0
  113. package/skills/difficulty_curve_designer.aiconfig/manifest.json +36 -0
  114. package/skills/digit_renderer.aicomponent/SKILL.md +43 -0
  115. package/skills/digit_renderer.aicomponent/manifest.json +25 -0
  116. package/skills/digit_renderer.aicomponent/ref/DigitRenderer.ts +237 -0
  117. package/skills/download_button.aicomponent/SKILL.md +44 -0
  118. package/skills/download_button.aicomponent/manifest.json +25 -0
  119. package/skills/download_button.aicomponent/ref/DownloadButton.ts +137 -0
  120. package/skills/draw_line_puzzle.aigameplay/SKILL.md +84 -0
  121. package/skills/draw_line_puzzle.aigameplay/manifest.json +152 -0
  122. package/skills/draw_line_puzzle.aigameplay/ref/pgs-schema.json +189 -0
  123. package/skills/draw_line_puzzle.aigameplay/ref/reducer.template.ts +194 -0
  124. package/skills/easy_to_hard.aiconfig/SKILL.md +52 -0
  125. package/skills/easy_to_hard.aiconfig/manifest.json +33 -0
  126. package/skills/eight_ball_pool.aigameplay/SKILL.md +104 -0
  127. package/skills/eight_ball_pool.aigameplay/manifest.json +152 -0
  128. package/skills/eight_ball_pool.aigameplay/ref/pgs-schema.json +205 -0
  129. package/skills/eight_ball_pool.aigameplay/ref/reducer.template.ts +198 -0
  130. package/skills/energetic_electronic.aiaudio/SKILL.md +69 -0
  131. package/skills/energetic_electronic.aiaudio/manifest.json +51 -0
  132. package/skills/fail_sfx.aiaudio/SKILL.md +59 -0
  133. package/skills/fail_sfx.aiaudio/manifest.json +44 -0
  134. package/skills/fail_sfx.aiaudio/ref/fail.mp3 +0 -0
  135. package/skills/figer_icon.aiimage/SKILL.md +58 -0
  136. package/skills/figer_icon.aiimage/manifest.json +48 -0
  137. package/skills/figer_icon.aiimage/ref/figer.png +0 -0
  138. package/skills/figer_icon.aiimage/ref/figer.webp +0 -0
  139. package/skills/forest.aiimage/SKILL.md +74 -0
  140. package/skills/forest.aiimage/manifest.json +48 -0
  141. package/skills/fruit_tile.aiimage/SKILL.md +68 -0
  142. package/skills/fruit_tile.aiimage/manifest.json +48 -0
  143. package/skills/game_over_panel.aicomponent/SKILL.md +47 -0
  144. package/skills/game_over_panel.aicomponent/manifest.json +61 -0
  145. package/skills/game_over_panel.aicomponent/ref/GameOverPanel.ts +74 -0
  146. package/skills/game_scene.aicomponent/SKILL.md +57 -0
  147. package/skills/game_scene.aicomponent/manifest.json +36 -0
  148. package/skills/game_scene.aicomponent/ref/Game.ts +748 -0
  149. package/skills/gameplay_balance_check.aivalidator/SKILL.md +69 -0
  150. package/skills/gameplay_balance_check.aivalidator/manifest.json +21 -0
  151. package/skills/gameplay_unit_test.aivalidator/SKILL.md +89 -0
  152. package/skills/gameplay_unit_test.aivalidator/manifest.json +17 -0
  153. package/skills/gameplay_unit_test.aivalidator/ref/gameplay.test.ts +202 -0
  154. package/skills/gameplay_unit_test.aivalidator/ref/vitest.config.ts +13 -0
  155. package/skills/grid_board_layout.aicomponent/SKILL.md +85 -0
  156. package/skills/grid_board_layout.aicomponent/manifest.json +69 -0
  157. package/skills/grid_board_layout.aicomponent/ref/BoardLayout.ts +416 -0
  158. package/skills/grid_board_layout.aicomponent/ref/BoardLayout3D.ts +125 -0
  159. package/skills/grid_board_layout.aicomponent/ref/BoardLayoutMath.ts +85 -0
  160. package/skills/grid_board_layout.aicomponent/ref/BoardRenderer3D.ts +298 -0
  161. package/skills/heart_lives.aicomponent/SKILL.md +42 -0
  162. package/skills/heart_lives.aicomponent/manifest.json +25 -0
  163. package/skills/heart_lives.aicomponent/ref/HeartDisplay.ts +96 -0
  164. package/skills/idle-breathe.aicomponent/SKILL.md +27 -0
  165. package/skills/idle-breathe.aicomponent/manifest.json +20 -0
  166. package/skills/idle-breathe.aicomponent/ref/phaser.js +25 -0
  167. package/skills/idle-breathe.aicomponent/ref/playcanvas.js +29 -0
  168. package/skills/jewel_tile.aiimage/SKILL.md +63 -0
  169. package/skills/jewel_tile.aiimage/manifest.json +49 -0
  170. package/skills/knife_hit.aigameplay/SKILL.md +103 -0
  171. package/skills/knife_hit.aigameplay/manifest.json +151 -0
  172. package/skills/knife_hit.aigameplay/ref/pgs-schema.json +202 -0
  173. package/skills/knife_hit.aigameplay/ref/reducer.template.ts +196 -0
  174. package/skills/left_right_parkour.aigameplay/SKILL.md +120 -0
  175. package/skills/left_right_parkour.aigameplay/manifest.json +165 -0
  176. package/skills/left_right_parkour.aigameplay/ref/pgs-schema.json +200 -0
  177. package/skills/left_right_parkour.aigameplay/ref/reducer.template.ts +194 -0
  178. package/skills/level_data_pack.aiconfig/SKILL.md +64 -0
  179. package/skills/level_data_pack.aiconfig/manifest.json +37 -0
  180. package/skills/level_data_validator.aivalidator/SKILL.md +85 -0
  181. package/skills/level_data_validator.aivalidator/manifest.json +17 -0
  182. package/skills/level_data_validator.aivalidator/ref/LevelValidator.ts +113 -0
  183. package/skills/level_lifecycle.aicomponent/SKILL.md +81 -0
  184. package/skills/level_lifecycle.aicomponent/manifest.json +87 -0
  185. package/skills/level_lifecycle.aicomponent/ref/LevelLifecycle.ts +235 -0
  186. package/skills/level_solvability_validator.aivalidator/SKILL.md +74 -0
  187. package/skills/level_solvability_validator.aivalidator/manifest.json +23 -0
  188. package/skills/level_solvability_validator.aivalidator/ref/LevelValidator.ts +186 -0
  189. package/skills/level_state.aicomponent/SKILL.md +55 -0
  190. package/skills/level_state.aicomponent/manifest.json +34 -0
  191. package/skills/level_state.aicomponent/ref/LevelDataManager.ts +26 -0
  192. package/skills/level_state.aicomponent/ref/LevelManager.ts +26 -0
  193. package/skills/loading_screen.aicomponent/SKILL.md +57 -0
  194. package/skills/loading_screen.aicomponent/manifest.json +43 -0
  195. package/skills/loading_screen.aicomponent/ref/LoadingUI.ts +339 -0
  196. package/skills/lose_result_panel.aiimage/SKILL.md +58 -0
  197. package/skills/lose_result_panel.aiimage/manifest.json +47 -0
  198. package/skills/lose_result_panel.aiimage/ref/lose.png +0 -0
  199. package/skills/lose_result_panel.aiimage/ref/lose.webp +0 -0
  200. package/skills/lose_sfx.aiaudio/SKILL.md +59 -0
  201. package/skills/lose_sfx.aiaudio/manifest.json +45 -0
  202. package/skills/lose_sfx.aiaudio/ref/lose.mp3 +0 -0
  203. package/skills/match-pop.aicomponent/SKILL.md +29 -0
  204. package/skills/match-pop.aicomponent/manifest.json +19 -0
  205. package/skills/match-pop.aicomponent/ref/phaser.js +30 -0
  206. package/skills/match-pop.aicomponent/ref/playcanvas.js +22 -0
  207. package/skills/match3_core.aigameplay/SKILL.md +125 -0
  208. package/skills/match3_core.aigameplay/manifest.json +107 -0
  209. package/skills/match3_core.aigameplay/ref/pgs-schema.json +154 -0
  210. package/skills/match3_core.aigameplay/ref/reducer.template.ts +191 -0
  211. package/skills/match_engine.aicomponent/SKILL.md +84 -0
  212. package/skills/match_engine.aicomponent/manifest.json +23 -0
  213. package/skills/match_engine.aicomponent/ref/MatchEngine.ts +75 -0
  214. package/skills/memory_match.aigameplay/SKILL.md +111 -0
  215. package/skills/memory_match.aigameplay/manifest.json +164 -0
  216. package/skills/memory_match.aigameplay/ref/pgs-schema.json +190 -0
  217. package/skills/memory_match.aigameplay/ref/reducer.template.ts +162 -0
  218. package/skills/merge_core.aigameplay/SKILL.md +112 -0
  219. package/skills/merge_core.aigameplay/manifest.json +154 -0
  220. package/skills/merge_core.aigameplay/ref/pgs-schema.json +202 -0
  221. package/skills/merge_core.aigameplay/ref/reducer.template.ts +179 -0
  222. package/skills/mistake_sfx.aiaudio/SKILL.md +59 -0
  223. package/skills/mistake_sfx.aiaudio/manifest.json +45 -0
  224. package/skills/mistake_sfx.aiaudio/ref/mistake.mp3 +0 -0
  225. package/skills/nomove_hint_overlay.aiimage/SKILL.md +58 -0
  226. package/skills/nomove_hint_overlay.aiimage/manifest.json +48 -0
  227. package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.png +0 -0
  228. package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.webp +0 -0
  229. package/skills/normal_dot.aiimage/SKILL.md +58 -0
  230. package/skills/normal_dot.aiimage/manifest.json +46 -0
  231. package/skills/normal_dot.aiimage/ref/normal_dot.png +0 -0
  232. package/skills/normal_dot.aiimage/ref/normal_dot.webp +0 -0
  233. package/skills/ocean.aiimage/SKILL.md +71 -0
  234. package/skills/ocean.aiimage/manifest.json +49 -0
  235. package/skills/particle-confetti.aicomponent/SKILL.md +32 -0
  236. package/skills/particle-confetti.aicomponent/manifest.json +21 -0
  237. package/skills/particle-confetti.aicomponent/ref/html5-spritesheet.js +17 -0
  238. package/skills/particle-confetti.aicomponent/ref/phaser.js +38 -0
  239. package/skills/particle-explosion.aicomponent/SKILL.md +37 -0
  240. package/skills/particle-explosion.aicomponent/manifest.json +24 -0
  241. package/skills/particle-explosion.aicomponent/ref/html5-spritesheet.js +40 -0
  242. package/skills/particle-explosion.aicomponent/ref/phaser.js +46 -0
  243. package/skills/particle-explosion.aicomponent/ref/playcanvas.js +33 -0
  244. package/skills/particle-trail.aicomponent/SKILL.md +25 -0
  245. package/skills/particle-trail.aicomponent/manifest.json +22 -0
  246. package/skills/particle-trail.aicomponent/ref/phaser.js +31 -0
  247. package/skills/path_animation.aicomponent/SKILL.md +82 -0
  248. package/skills/path_animation.aicomponent/manifest.json +77 -0
  249. package/skills/path_animation.aicomponent/ref/AnimationManager.ts +694 -0
  250. package/skills/path_animation.aicomponent/ref/AnimationManager3D.ts +317 -0
  251. package/skills/path_elimination_rules.aigameplay/SKILL.md +88 -0
  252. package/skills/path_elimination_rules.aigameplay/manifest.json +119 -0
  253. package/skills/path_elimination_rules.aigameplay/ref/pgs-schema.json +227 -0
  254. package/skills/path_input_handler.aicomponent/SKILL.md +87 -0
  255. package/skills/path_input_handler.aicomponent/manifest.json +97 -0
  256. package/skills/path_input_handler.aicomponent/ref/InputHandler.ts +714 -0
  257. package/skills/path_input_handler.aicomponent/ref/InputHandler3D.ts +204 -0
  258. package/skills/path_renderer.aicomponent/SKILL.md +101 -0
  259. package/skills/path_renderer.aicomponent/manifest.json +69 -0
  260. package/skills/path_renderer.aicomponent/ref/PathRenderer.ts +509 -0
  261. package/skills/path_renderer.aicomponent/ref/PathRenderer3D.ts +176 -0
  262. package/skills/path_renderer.aicomponent/ref/PathRenderers.ts +640 -0
  263. package/skills/phaser.aicomponent/SKILL.md +315 -0
  264. package/skills/phaser.aicomponent/manifest.json +156 -0
  265. package/skills/phaser.aicomponent/ref/BootScene.ts +29 -0
  266. package/skills/phaser.aicomponent/ref/GameConfig.ts +29 -0
  267. package/skills/phaser.aicomponent/ref/GameScene.ts +88 -0
  268. package/skills/phaser.aicomponent/ref/PreloaderScene.ts +78 -0
  269. package/skills/phaser.aicomponent/ref/SceneKeys.ts +7 -0
  270. package/skills/phaser.aicomponent/ref/SoundUtils.ts +21 -0
  271. package/skills/phaser.aicomponent/ref/UiLayout.ts +74 -0
  272. package/skills/phaser.aicomponent/ref/globals.d.ts +52 -0
  273. package/skills/phaser.aicomponent/ref/index.css +40 -0
  274. package/skills/phaser.aicomponent/ref/index.html +14 -0
  275. package/skills/phaser.aicomponent/ref/index.ts +48 -0
  276. package/skills/phaser.aicomponent/ref/main.ts +16 -0
  277. package/skills/phaser.aicomponent/ref/package.json +22 -0
  278. package/skills/phaser.aicomponent/ref/tsconfig.json +25 -0
  279. package/skills/phaser.aicomponent/ref/webpack.config.js +57 -0
  280. package/skills/phaser_scene_lifecycle.aicomponent/SKILL.md +63 -0
  281. package/skills/phaser_scene_lifecycle.aicomponent/manifest.json +33 -0
  282. package/skills/pick_and_match_rules.aigameplay/SKILL.md +113 -0
  283. package/skills/pick_and_match_rules.aigameplay/manifest.json +121 -0
  284. package/skills/pick_and_match_rules.aigameplay/ref/pgs-schema.json +354 -0
  285. package/skills/pin_pull.aigameplay/SKILL.md +110 -0
  286. package/skills/pin_pull.aigameplay/manifest.json +164 -0
  287. package/skills/pin_pull.aigameplay/ref/pgs-schema.json +201 -0
  288. package/skills/pin_pull.aigameplay/ref/reducer.template.ts +216 -0
  289. package/skills/playable_app_logo.aiimage/SKILL.md +58 -0
  290. package/skills/playable_app_logo.aiimage/manifest.json +47 -0
  291. package/skills/playable_app_logo.aiimage/ref/logo.png +0 -0
  292. package/skills/playable_app_logo.aiimage/ref/logo.webp +0 -0
  293. package/skills/playable_end_screen_layout.aicomponent/SKILL.md +75 -0
  294. package/skills/playable_end_screen_layout.aicomponent/manifest.json +24 -0
  295. package/skills/playable_guidance_layer.aicomponent/SKILL.md +89 -0
  296. package/skills/playable_guidance_layer.aicomponent/manifest.json +24 -0
  297. package/skills/playable_hud_layout.aicomponent/SKILL.md +96 -0
  298. package/skills/playable_hud_layout.aicomponent/manifest.json +24 -0
  299. package/skills/playable_scripts_build.aicomponent/SKILL.md +69 -0
  300. package/skills/playable_scripts_build.aicomponent/manifest.json +53 -0
  301. package/skills/playable_scripts_build.aicomponent/ref/builds.config.js +257 -0
  302. package/skills/playcraft-3d-flip-sprite/SKILL.md +336 -0
  303. package/skills/playcraft-3d-flip-sprite/renderer/flatten_glb.mjs +62 -0
  304. package/skills/playcraft-3d-flip-sprite/renderer/render.mjs +325 -0
  305. package/skills/playcraft-3d-flip-sprite/renderer/render_single.mjs +138 -0
  306. package/skills/playcraft-asset-management/SKILL.md +73 -0
  307. package/skills/playcraft-audio-generation/SKILL.md +126 -0
  308. package/skills/playcraft-build/SKILL.md +44 -0
  309. package/skills/playcraft-code-editor/SKILL.md +71 -0
  310. package/skills/playcraft-create-remix/SKILL.md +62 -0
  311. package/skills/playcraft-deploy/SKILL.md +59 -0
  312. package/skills/playcraft-image-generation/SKILL.md +148 -0
  313. package/skills/playcraft-image-processing/SKILL.md +216 -0
  314. package/skills/playcraft-platform-intro/SKILL.md +41 -0
  315. package/skills/playcraft-prefab/SKILL.md +98 -0
  316. package/skills/playcraft-project-management/SKILL.md +57 -0
  317. package/skills/playcraft-remix-workflow/SKILL.md +119 -0
  318. package/skills/playcraft-remix-workflow/references/xplatform.schema.json5 +31 -0
  319. package/skills/playcraft-save/SKILL.md +46 -0
  320. package/skills/playcraft-skill-recommender/SKILL.md +152 -0
  321. package/skills/playcraft-sprite-generation/SKILL.md +534 -0
  322. package/skills/playcraft-sprite-remix/SKILL.md +155 -0
  323. package/skills/playcraft-sprite-sheet/SKILL.md +97 -0
  324. package/skills/playtest_report.aivalidator/SKILL.md +103 -0
  325. package/skills/playtest_report.aivalidator/manifest.json +21 -0
  326. package/skills/preloader_scene.aicomponent/SKILL.md +58 -0
  327. package/skills/preloader_scene.aicomponent/manifest.json +43 -0
  328. package/skills/preloader_scene.aicomponent/ref/Preloader.ts +339 -0
  329. package/skills/progress_bar.aicomponent/SKILL.md +38 -0
  330. package/skills/progress_bar.aicomponent/manifest.json +25 -0
  331. package/skills/progress_bar.aicomponent/ref/ProgressDisplay.ts +140 -0
  332. package/skills/references/xplatform.schema.json5 +31 -0
  333. package/skills/responsive_2d_layout.aicomponent/SKILL.md +161 -0
  334. package/skills/responsive_2d_layout.aicomponent/manifest.json +43 -0
  335. package/skills/responsive_2d_layout.aicomponent/ref/UiLayout.ts +56 -0
  336. package/skills/run_context_state.aicomponent/SKILL.md +54 -0
  337. package/skills/run_context_state.aicomponent/manifest.json +40 -0
  338. package/skills/run_context_state.aicomponent/ref/RunContextRuntime.ts +30 -0
  339. package/skills/score-fly.aicomponent/SKILL.md +31 -0
  340. package/skills/score-fly.aicomponent/manifest.json +21 -0
  341. package/skills/score-fly.aicomponent/ref/phaser.js +26 -0
  342. package/skills/score-fly.aicomponent/ref/playcanvas.js +28 -0
  343. package/skills/score_goal.aiconfig/SKILL.md +46 -0
  344. package/skills/score_goal.aiconfig/manifest.json +33 -0
  345. package/skills/screen-flash.aicomponent/SKILL.md +30 -0
  346. package/skills/screen-flash.aicomponent/manifest.json +20 -0
  347. package/skills/screen-flash.aicomponent/ref/phaser.js +48 -0
  348. package/skills/screen-shake.aicomponent/SKILL.md +30 -0
  349. package/skills/screen-shake.aicomponent/manifest.json +19 -0
  350. package/skills/screen-shake.aicomponent/ref/phaser.js +23 -0
  351. package/skills/screen-shake.aicomponent/ref/playcanvas.js +44 -0
  352. package/skills/screw_puzzle.aigameplay/SKILL.md +116 -0
  353. package/skills/screw_puzzle.aigameplay/manifest.json +164 -0
  354. package/skills/screw_puzzle.aigameplay/ref/pgs-schema.json +235 -0
  355. package/skills/screw_puzzle.aigameplay/ref/reducer.template.ts +213 -0
  356. package/skills/settings_state.aicomponent/SKILL.md +61 -0
  357. package/skills/settings_state.aicomponent/manifest.json +33 -0
  358. package/skills/settings_state.aicomponent/ref/SettingsManager.ts +130 -0
  359. package/skills/slide_out_to_tray_animation.aicomponent/SKILL.md +64 -0
  360. package/skills/slide_out_to_tray_animation.aicomponent/manifest.json +58 -0
  361. package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager.ts +164 -0
  362. package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager3D.ts +198 -0
  363. package/skills/slide_out_to_tray_animation.aicomponent/ref/BezierUtils.ts +59 -0
  364. package/skills/slot_machine.aigameplay/SKILL.md +119 -0
  365. package/skills/slot_machine.aigameplay/manifest.json +166 -0
  366. package/skills/slot_machine.aigameplay/ref/pgs-schema.json +212 -0
  367. package/skills/slot_machine.aigameplay/ref/reducer.template.ts +212 -0
  368. package/skills/sniper_shot.aigameplay/SKILL.md +84 -0
  369. package/skills/sniper_shot.aigameplay/manifest.json +153 -0
  370. package/skills/sniper_shot.aigameplay/ref/pgs-schema.json +211 -0
  371. package/skills/sniper_shot.aigameplay/ref/reducer.template.ts +211 -0
  372. package/skills/solitaire.aigameplay/SKILL.md +101 -0
  373. package/skills/solitaire.aigameplay/manifest.json +151 -0
  374. package/skills/solitaire.aigameplay/ref/pgs-schema.json +200 -0
  375. package/skills/solitaire.aigameplay/ref/reducer.template.ts +176 -0
  376. package/skills/sound-effects/SKILL.md +46 -0
  377. package/skills/sound_utils.aicomponent/SKILL.md +52 -0
  378. package/skills/sound_utils.aicomponent/manifest.json +30 -0
  379. package/skills/sound_utils.aicomponent/ref/SoundUtils.ts +29 -0
  380. package/skills/sprite-animation-2d.aicomponent/SKILL.md +45 -0
  381. package/skills/sprite-animation-2d.aicomponent/manifest.json +28 -0
  382. package/skills/sprite-animation-2d.aicomponent/ref/html5.js +83 -0
  383. package/skills/sprite-animation-2d.aicomponent/ref/phaser.js +38 -0
  384. package/skills/sprite-animation-2d.aicomponent/ref/playcanvas.js +67 -0
  385. package/skills/sprite_entity_renderer.aicomponent/SKILL.md +148 -0
  386. package/skills/sprite_entity_renderer.aicomponent/manifest.json +17 -0
  387. package/skills/sprite_entity_renderer.aicomponent/ref/SpriteEntityRenderer.ts +126 -0
  388. package/skills/success_sfx.aiaudio/SKILL.md +59 -0
  389. package/skills/success_sfx.aiaudio/manifest.json +45 -0
  390. package/skills/success_sfx.aiaudio/ref/success.mp3 +0 -0
  391. package/skills/tap_blast.aigameplay/SKILL.md +116 -0
  392. package/skills/tap_blast.aigameplay/manifest.json +153 -0
  393. package/skills/tap_blast.aigameplay/ref/pgs-schema.json +208 -0
  394. package/skills/tap_blast.aigameplay/ref/reducer.template.ts +202 -0
  395. package/skills/theme_state.aicomponent/SKILL.md +53 -0
  396. package/skills/theme_state.aicomponent/manifest.json +33 -0
  397. package/skills/theme_state.aicomponent/ref/ThemeManager.ts +174 -0
  398. package/skills/theme_switcher_build.aicomponent/SKILL.md +62 -0
  399. package/skills/theme_switcher_build.aicomponent/manifest.json +38 -0
  400. package/skills/theme_switcher_build.aicomponent/ref/theme-index.ts +8 -0
  401. package/skills/theme_variant.aiconfig/SKILL.md +78 -0
  402. package/skills/theme_variant.aiconfig/manifest.json +39 -0
  403. package/skills/theme_variant.aiconfig/ref/ExampleTheme/index.ts +16 -0
  404. package/skills/theme_variant.aiconfig/ref/ExampleTheme/levelEasy.json +141 -0
  405. package/skills/threejs.aicomponent/SKILL.md +422 -0
  406. package/skills/threejs.aicomponent/manifest.json +166 -0
  407. package/skills/threejs.aicomponent/ref/AssetLoader.ts +158 -0
  408. package/skills/threejs.aicomponent/ref/BaseScene.ts +88 -0
  409. package/skills/threejs.aicomponent/ref/GameConfig.ts +47 -0
  410. package/skills/threejs.aicomponent/ref/MainScene.ts +170 -0
  411. package/skills/threejs.aicomponent/ref/PreloaderScene.ts +93 -0
  412. package/skills/threejs.aicomponent/ref/SceneKeys.ts +6 -0
  413. package/skills/threejs.aicomponent/ref/SceneManager.ts +69 -0
  414. package/skills/threejs.aicomponent/ref/ViewportManager.ts +62 -0
  415. package/skills/threejs.aicomponent/ref/globals.d.ts +74 -0
  416. package/skills/threejs.aicomponent/ref/index.css +80 -0
  417. package/skills/threejs.aicomponent/ref/index.html +20 -0
  418. package/skills/threejs.aicomponent/ref/index.ts +117 -0
  419. package/skills/threejs.aicomponent/ref/main.ts +10 -0
  420. package/skills/threejs.aicomponent/ref/package.json +23 -0
  421. package/skills/threejs.aicomponent/ref/tsconfig.json +24 -0
  422. package/skills/threejs.aicomponent/ref/webpack.config.js +61 -0
  423. package/skills/time_clear_goal.aiconfig/SKILL.md +46 -0
  424. package/skills/time_clear_goal.aiconfig/manifest.json +32 -0
  425. package/skills/time_icon.aiimage/SKILL.md +58 -0
  426. package/skills/time_icon.aiimage/manifest.json +47 -0
  427. package/skills/time_icon.aiimage/ref/time.png +0 -0
  428. package/skills/time_icon.aiimage/ref/time.webp +0 -0
  429. package/skills/top_ui_bar.aicomponent/SKILL.md +45 -0
  430. package/skills/top_ui_bar.aicomponent/manifest.json +27 -0
  431. package/skills/top_ui_bar.aicomponent/ref/GameTopUI.ts +229 -0
  432. package/skills/tower_defence.aigameplay/SKILL.md +117 -0
  433. package/skills/tower_defence.aigameplay/manifest.json +175 -0
  434. package/skills/tower_defence.aigameplay/ref/pgs-schema.json +247 -0
  435. package/skills/tower_defence.aigameplay/ref/reducer.template.ts +239 -0
  436. package/skills/tray_container.aicomponent/SKILL.md +143 -0
  437. package/skills/tray_container.aicomponent/manifest.json +58 -0
  438. package/skills/tray_container.aicomponent/ref/TrayRenderer.ts +155 -0
  439. package/skills/tray_container.aicomponent/ref/TrayRenderer3D.ts +281 -0
  440. package/skills/tray_container.aicomponent/ref/TrayRendererHtmlOverlay.ts +228 -0
  441. package/skills/tutorial_overlay.aicomponent/SKILL.md +46 -0
  442. package/skills/tutorial_overlay.aicomponent/manifest.json +34 -0
  443. package/skills/tutorial_overlay.aicomponent/ref/TutorialManager.ts +367 -0
  444. package/skills/tween-animation-2d.aicomponent/SKILL.md +35 -0
  445. package/skills/tween-animation-2d.aicomponent/manifest.json +28 -0
  446. package/skills/tween-animation-2d.aicomponent/ref/phaser.js +49 -0
  447. package/skills/tween-animation-2d.aicomponent/ref/playcanvas.js +36 -0
  448. package/skills/typescript_module_patterns.aicomponent/SKILL.md +209 -0
  449. package/skills/typescript_module_patterns.aicomponent/manifest.json +28 -0
  450. package/skills/typescript_module_patterns.aicomponent/ref/globals.d.ts +31 -0
  451. package/skills/ui-transition.aicomponent/SKILL.md +33 -0
  452. package/skills/ui-transition.aicomponent/manifest.json +19 -0
  453. package/skills/ui-transition.aicomponent/ref/phaser.js +45 -0
  454. package/skills/ux_flow_spec.aiconfig/SKILL.md +82 -0
  455. package/skills/ux_flow_spec.aiconfig/manifest.json +39 -0
  456. package/skills/wave_difficulty.aiconfig/SKILL.md +46 -0
  457. package/skills/wave_difficulty.aiconfig/manifest.json +33 -0
  458. package/skills/webpack_build.aicomponent/SKILL.md +204 -0
  459. package/skills/webpack_build.aicomponent/manifest.json +29 -0
  460. package/skills/webpack_build.aicomponent/ref/package.json +16 -0
  461. package/skills/webpack_build.aicomponent/ref/webpack.config.js +53 -0
  462. package/skills/win_anim_sfx.aiaudio/SKILL.md +59 -0
  463. package/skills/win_anim_sfx.aiaudio/manifest.json +46 -0
  464. package/skills/win_anim_sfx.aiaudio/ref/win_anim.mp3 +0 -0
  465. package/skills/win_dot.aiimage/SKILL.md +58 -0
  466. package/skills/win_dot.aiimage/manifest.json +47 -0
  467. package/skills/win_dot.aiimage/ref/win_dot.png +0 -0
  468. package/skills/win_dot.aiimage/ref/win_dot.webp +0 -0
  469. package/skills/win_result_panel.aiimage/SKILL.md +58 -0
  470. package/skills/win_result_panel.aiimage/manifest.json +47 -0
  471. package/skills/win_result_panel.aiimage/ref/win.png +0 -0
  472. package/skills/win_result_panel.aiimage/ref/win.webp +0 -0
  473. package/skills/word_connect.aigameplay/SKILL.md +86 -0
  474. package/skills/word_connect.aigameplay/manifest.json +154 -0
  475. package/skills/word_connect.aigameplay/ref/pgs-schema.json +212 -0
  476. package/skills/word_connect.aigameplay/ref/reducer.template.ts +186 -0
  477. package/src/index.ts +10 -0
  478. package/src/skills.loader.ts +225 -0
  479. package/src/skills.types.ts +42 -0
@@ -0,0 +1,509 @@
1
+ import * as Phaser from "phaser";
2
+ import type { ParsedLevel, LevelPath } from "../../levels/LevelTypes";
3
+ import { ARROW_SIZE_RATIO, PATH_LINE_WIDTH_RATIO } from "../../GameConfig";
4
+ import {
5
+ ENABLE_ERROR_PATH_HIGHLIGHT,
6
+ PATH_CORNER_STYLE,
7
+ } from "../../DebugConfig";
8
+ import {
9
+ type PathTrackCell,
10
+ type PathRenderer as IPathRenderer,
11
+ SquarePathRenderer,
12
+ RoundedCornerPathRenderer,
13
+ fillRoundedTriangle,
14
+ } from "../../utils/PathRenderers";
15
+
16
+ /**
17
+ * 描述 PathRenderer 从 Game 场景中所需内容的最小接口。
18
+ * 避免模块级别的循环导入。
19
+ */
20
+ export interface PathRendererGameRef extends Phaser.Scene {
21
+ level: ParsedLevel | null;
22
+ boardGraphics: Phaser.GameObjects.Graphics;
23
+ hintOverlayGraphics?: Phaser.GameObjects.Graphics;
24
+ cellSize: number;
25
+ cellWidth: number;
26
+ cellHeight: number;
27
+ visualSize: number;
28
+ removedPaths: Set<number>;
29
+ blockedPaths: Set<number>;
30
+ animatingPaths: Set<number>;
31
+ pathCornerStyle: "rounded" | "square";
32
+ tutorialManager: {
33
+ hintTargetIndex: number | null;
34
+ hintPulseScale: number;
35
+ };
36
+ }
37
+
38
+ /**
39
+ * 路径渲染器。
40
+ * 负责渲染网格路径、箭头头部、Hint覆盖层等所有与路径视觉相关的内容。
41
+ */
42
+ export class PathRendererManager {
43
+ private scene: PathRendererGameRef;
44
+
45
+ /** 路径轨迹缓存 */
46
+ private pathTracks: PathTrackCell[][] = [];
47
+
48
+ /** 缓存的箭头出现顺序(基于距离排序) */
49
+ private introPathOrder: number[] = [];
50
+
51
+ /** 每条路径的箭头颜色 */
52
+ private arrowBaseColor = 0x000000;
53
+ private pathArrowColors: number[] = [];
54
+
55
+ constructor(scene: PathRendererGameRef) {
56
+ this.scene = scene;
57
+ }
58
+
59
+ // ── 路径轨迹构建 ──
60
+
61
+ /**
62
+ * 根据路径数据构建离散格子轨迹。
63
+ * @param path 路径数据
64
+ * @returns 轨迹格子数组
65
+ */
66
+ buildPathTrack(path: LevelPath): PathTrackCell[] {
67
+ const track: PathTrackCell[] = [];
68
+ const pushCell = (cx: number, cy: number) => {
69
+ const last = track[track.length - 1];
70
+ if (last && last.x === cx && last.y === cy) return;
71
+ track.push({ x: cx, y: cy });
72
+ };
73
+
74
+ if (path.points.length > 0) {
75
+ for (let i = 0; i < path.points.length - 1; i++) {
76
+ const a = path.points[i]!;
77
+ const b = path.points[i + 1]!;
78
+ if (a.x === b.x) {
79
+ const stepY = b.y > a.y ? 1 : -1;
80
+ for (let y = a.y; y !== b.y + stepY; y += stepY) {
81
+ pushCell(a.x, y);
82
+ }
83
+ } else if (a.y === b.y) {
84
+ const stepX = b.x > a.x ? 1 : -1;
85
+ for (let x = a.x; x !== b.x + stepX; x += stepX) {
86
+ pushCell(x, a.y);
87
+ }
88
+ } else {
89
+ pushCell(a.x, a.y);
90
+ pushCell(b.x, b.y);
91
+ }
92
+ }
93
+ }
94
+ return track;
95
+ }
96
+
97
+ /**
98
+ * 获取路径渲染器(圆角或方角)。
99
+ * @param _lineWidth 线宽(当前未使用)
100
+ * @returns 路径渲染器实例
101
+ */
102
+ getPathRendererForLineWidth(_lineWidth: number): IPathRenderer {
103
+ return this.scene.pathCornerStyle === "rounded"
104
+ ? RoundedCornerPathRenderer
105
+ : SquarePathRenderer;
106
+ }
107
+
108
+ // ── 基础绘图工具 ──
109
+
110
+ /**
111
+ * 计算指定格子的中心坐标。
112
+ * @param col 列号
113
+ * @param row 行号
114
+ * @returns 中心坐标
115
+ */
116
+ cellCenter(col: number, row: number): { x: number; y: number } {
117
+ const s = this.scene;
118
+ const x = col * s.cellWidth + s.cellWidth / 2;
119
+ const y = row * s.cellHeight + s.cellHeight / 2;
120
+ return { x, y };
121
+ }
122
+
123
+ /**
124
+ * 绘制轴对齐的线段矩形(用于路径体渲染)。
125
+ * 支持亚像素抗锯齿模式(小格子时启用)。
126
+ */
127
+ fillAxisAlignedSegmentRect(
128
+ g: Phaser.GameObjects.Graphics,
129
+ x1: number,
130
+ y1: number,
131
+ x2: number,
132
+ y2: number,
133
+ lineWidth: number,
134
+ ) {
135
+ const useSubpixelAA = this.scene.cellSize < 18;
136
+ const w = Math.max(1, useSubpixelAA ? lineWidth : Math.round(lineWidth));
137
+ const half = w / 2;
138
+
139
+ if (useSubpixelAA) {
140
+ if (Math.abs(x1 - x2) < 0.0001 && Math.abs(y1 - y2) < 0.0001) {
141
+ g.fillRect(x1 - half, y1 - half, w, w);
142
+ return;
143
+ }
144
+
145
+ if (Math.abs(x1 - x2) < 0.0001) {
146
+ const left = x1 - half;
147
+ const top = Math.min(y1, y2);
148
+ const height = Math.abs(y2 - y1);
149
+ g.fillRect(left, top, w, height);
150
+ return;
151
+ }
152
+
153
+ if (Math.abs(y1 - y2) < 0.0001) {
154
+ const left = Math.min(x1, x2);
155
+ const top = y1 - half;
156
+ const width = Math.abs(x2 - x1);
157
+ g.fillRect(left, top, width, w);
158
+ }
159
+ return;
160
+ }
161
+
162
+ if (Math.abs(x1 - x2) < 0.0001) {
163
+ const left = Math.floor(x1 - half);
164
+ const right = Math.ceil(x1 + half);
165
+ const top = Math.floor(Math.min(y1, y2) - half);
166
+ const bottom = Math.ceil(Math.max(y1, y2) + half);
167
+ g.fillRect(
168
+ left,
169
+ top,
170
+ Math.max(1, right - left),
171
+ Math.max(1, bottom - top),
172
+ );
173
+ return;
174
+ }
175
+
176
+ if (Math.abs(y1 - y2) < 0.0001) {
177
+ const left = Math.floor(Math.min(x1, x2) - half);
178
+ const right = Math.ceil(Math.max(x1, x2) + half);
179
+ const top = Math.floor(y1 - half);
180
+ const bottom = Math.ceil(y1 + half);
181
+ g.fillRect(
182
+ left,
183
+ top,
184
+ Math.max(1, right - left),
185
+ Math.max(1, bottom - top),
186
+ );
187
+ }
188
+ }
189
+
190
+ // ── 箭头绘制 ──
191
+
192
+ /**
193
+ * 绘制圆角三角形箭头头部。
194
+ * @param g 目标 Graphics 对象
195
+ * @param cx 中心X坐标
196
+ * @param cy 中心Y坐标
197
+ * @param angle 旋转角度(弧度,0 = 朝上)
198
+ * @param color 填充颜色
199
+ * @param scale 额外缩放因子(默认1)
200
+ */
201
+ drawArrowHead(
202
+ g: Phaser.GameObjects.Graphics,
203
+ cx: number,
204
+ cy: number,
205
+ angle: number,
206
+ color: number,
207
+ scale: number = 1,
208
+ ): void {
209
+ const s = this.scene;
210
+ const arrowWidth = s.visualSize * ARROW_SIZE_RATIO * scale;
211
+ const arrowHeight = s.visualSize * ARROW_SIZE_RATIO * scale;
212
+
213
+ const cos = Math.cos(angle);
214
+ const sin = Math.sin(angle);
215
+
216
+ const localPoints = [
217
+ { x: 0, y: -arrowHeight / 2 },
218
+ { x: -arrowWidth / 2, y: arrowHeight / 2 },
219
+ { x: arrowWidth / 2, y: arrowHeight / 2 },
220
+ ];
221
+
222
+ const worldPoints = localPoints.map((p) => ({
223
+ x: cx + p.x * cos - p.y * sin,
224
+ y: cy + p.x * sin + p.y * cos,
225
+ }));
226
+
227
+ const [p0, p1, p2] = worldPoints;
228
+ if (!p0 || !p1 || !p2) {
229
+ return;
230
+ }
231
+
232
+ g.fillStyle(color, 1);
233
+ if (s.pathCornerStyle === "square") {
234
+ g.beginPath();
235
+ g.moveTo(p0.x, p0.y);
236
+ g.lineTo(p1.x, p1.y);
237
+ g.lineTo(p2.x, p2.y);
238
+ g.closePath();
239
+ g.fillPath();
240
+ } else {
241
+ const cornerRadius = Math.min(arrowWidth, arrowHeight) * 0.15;
242
+ fillRoundedTriangle(g, p0, p1, p2, cornerRadius);
243
+ }
244
+ }
245
+
246
+ // ── 方向工具 ──
247
+
248
+ /**
249
+ * 将方向字符串转换为单位增量 { dx, dy }。
250
+ */
251
+ static directionToDelta(direction: string): { dx: number; dy: number } {
252
+ switch (direction) {
253
+ case "left":
254
+ return { dx: -1, dy: 0 };
255
+ case "right":
256
+ return { dx: 1, dy: 0 };
257
+ case "up":
258
+ return { dx: 0, dy: -1 };
259
+ case "down":
260
+ return { dx: 0, dy: 1 };
261
+ default:
262
+ return { dx: 0, dy: 0 };
263
+ }
264
+ }
265
+
266
+ /**
267
+ * 将方向字符串转换为角度(弧度,0 = 朝上)。
268
+ */
269
+ static directionToAngle(direction: string): number {
270
+ switch (direction) {
271
+ case "up":
272
+ return 0;
273
+ case "right":
274
+ return Math.PI / 2;
275
+ case "down":
276
+ return Math.PI;
277
+ case "left":
278
+ return -Math.PI / 2;
279
+ default:
280
+ return 0;
281
+ }
282
+ }
283
+
284
+ /**
285
+ * 实例方法包装:将方向字符串转换为单位增量。
286
+ * 供其他模块通过接口调用。
287
+ */
288
+ directionToDelta(direction: string): { dx: number; dy: number } {
289
+ return PathRendererManager.directionToDelta(direction);
290
+ }
291
+
292
+ // ── 主题颜色 ──
293
+
294
+ /**
295
+ * 根据当前主题初始化每条路径的基础颜色,用于静态绘制和动画。
296
+ * @param level 关卡数据
297
+ * @param arrowBaseColor 主题箭头基础颜色
298
+ */
299
+ setupThemeColors(level: ParsedLevel, arrowBaseColor: number): void {
300
+ this.arrowBaseColor = arrowBaseColor;
301
+ const pathCount = level.paths.length;
302
+ this.pathArrowColors = new Array(pathCount);
303
+ for (let i = 0; i < pathCount; i++) {
304
+ this.pathArrowColors[i] = this.arrowBaseColor;
305
+ }
306
+ }
307
+
308
+ /**
309
+ * 获取指定路径的基础颜色。
310
+ * @param pathIndex 路径索引
311
+ * @returns 颜色值
312
+ */
313
+ getPathBaseColor(pathIndex: number): number {
314
+ const pathColor = this.scene.level?.paths[pathIndex]?.color;
315
+ if (typeof pathColor === "string") {
316
+ return this.parseColorToNumber(pathColor, this.arrowBaseColor);
317
+ }
318
+ return this.pathArrowColors[pathIndex] ?? this.arrowBaseColor;
319
+ }
320
+
321
+ /**
322
+ * 解析颜色字符串为数字。
323
+ * @param spec 颜色字符串(支持 #RRGGBB 或 0xRRGGBB 格式)
324
+ * @param fallback 默认值
325
+ */
326
+ private parseColorToNumber(
327
+ spec: string | undefined,
328
+ fallback: number = 0x000000,
329
+ ): number {
330
+ if (!spec) return fallback;
331
+ const s = spec.trim();
332
+ if (/^#?[0-9a-fA-F]{6}$/.test(s)) {
333
+ const hex = s.startsWith("#") ? s.slice(1) : s;
334
+ return parseInt(hex, 16);
335
+ }
336
+ if (/^0x[0-9a-fA-F]{6}$/.test(s)) {
337
+ return parseInt(s, 16);
338
+ }
339
+ return fallback;
340
+ }
341
+
342
+ // ── 初始化路径轨迹缓存 ──
343
+
344
+ /**
345
+ * 为关卡所有路径构建轨迹缓存。在 buildBoard 时调用。
346
+ * @param level 关卡数据
347
+ */
348
+ initPathTracks(level: ParsedLevel): void {
349
+ this.pathTracks = level.paths.map((p) => this.buildPathTrack(p));
350
+ }
351
+
352
+ // ── 网格路径渲染 ──
353
+
354
+ /**
355
+ * 渲染关卡中的所有路径(带 intro 错开动画)。
356
+ * @param level 关卡数据
357
+ * @param clampedProgress 入场动画进度(0-1)
358
+ */
359
+ renderGridPaths(level: ParsedLevel, clampedProgress: number): void {
360
+ const s = this.scene;
361
+ const pathCount = level.paths.length;
362
+ const staggerRatio = 0.33;
363
+ const animDuration = 1 - staggerRatio;
364
+
365
+ // 如果是新关卡或顺序为空,计算从随机角落开始的出现顺序
366
+ if (this.introPathOrder.length !== pathCount) {
367
+ const corners = [
368
+ { x: 0, y: 0 },
369
+ { x: level.cols - 1, y: 0 },
370
+ { x: 0, y: level.rows - 1 },
371
+ { x: level.cols - 1, y: level.rows - 1 },
372
+ ];
373
+ const corner = corners[Math.floor(Math.random() * corners.length)]!;
374
+
375
+ const pathDistances = level.paths.map((path, idx) => {
376
+ const dx = path.head.x - corner.x;
377
+ const dy = path.head.y - corner.y;
378
+ return { index: idx, dist: Math.sqrt(dx * dx + dy * dy) };
379
+ });
380
+
381
+ pathDistances.sort((a, b) => a.dist - b.dist);
382
+ this.introPathOrder = pathDistances.map((p) => p.index);
383
+ }
384
+
385
+ const orderMap = new Map<number, number>();
386
+ this.introPathOrder.forEach((pathIdx, order) => {
387
+ orderMap.set(pathIdx, order);
388
+ });
389
+
390
+ const staggerStep = pathCount > 1 ? staggerRatio / (pathCount - 1) : 0;
391
+
392
+ level.paths.forEach((path: LevelPath, index: number) => {
393
+ if (s.removedPaths.has(index)) return;
394
+ if (s.animatingPaths.has(index)) return;
395
+
396
+ const order = orderMap.get(index) ?? index;
397
+ const pathStartTime = order * staggerStep;
398
+ const localProgress = Phaser.Math.Clamp(
399
+ (clampedProgress - pathStartTime) / animDuration,
400
+ 0,
401
+ 1,
402
+ );
403
+
404
+ if (localProgress <= 0) return;
405
+
406
+ const baseColor = this.getPathBaseColor(index);
407
+ const color =
408
+ ENABLE_ERROR_PATH_HIGHLIGHT && s.blockedPaths.has(index)
409
+ ? 0xff0000
410
+ : baseColor;
411
+ const headCell = path.head;
412
+ const track = this.pathTracks[index] ?? [];
413
+ const trackLength = track.length;
414
+ if (trackLength === 0) return;
415
+
416
+ const visibleCells =
417
+ localProgress >= 1
418
+ ? trackLength
419
+ : Math.max(1, Math.floor(trackLength * localProgress));
420
+ const maxCellIndex = Math.min(visibleCells - 1, trackLength - 1);
421
+
422
+ const bodyColor = color;
423
+
424
+ if (trackLength > 1) {
425
+ const lineWidth = s.visualSize * PATH_LINE_WIDTH_RATIO;
426
+ s.boardGraphics.fillStyle(bodyColor, 1);
427
+
428
+ this.getPathRendererForLineWidth(lineWidth).render({
429
+ g: s.boardGraphics,
430
+ track,
431
+ startSegmentIndex: 0,
432
+ endSegmentIndexExclusive: maxCellIndex,
433
+ cellSize: s.cellSize,
434
+ lineWidth,
435
+ headCell,
436
+ cellCenter: (col, row) => this.cellCenter(col, row),
437
+ fillAxisAlignedSegmentRect: (g, x1, y1, x2, y2, w) =>
438
+ this.fillAxisAlignedSegmentRect(g, x1, y1, x2, y2, w),
439
+ });
440
+ }
441
+
442
+ if (visibleCells < trackLength) return;
443
+
444
+ const { x: hx, y: hy } = this.cellCenter(headCell.x, headCell.y);
445
+ const angle = PathRendererManager.directionToAngle(path.direction);
446
+ this.drawArrowHead(s.boardGraphics, hx, hy, angle, color);
447
+ });
448
+ }
449
+
450
+ // ── Hint 覆盖层渲染 ──
451
+
452
+ /**
453
+ * 渲染 Hint 高亮覆盖层(带脉冲缩放效果)。
454
+ */
455
+ renderHintOverlay(): void {
456
+ const s = this.scene;
457
+ const g = s.hintOverlayGraphics;
458
+ if (!g) return;
459
+ g.clear();
460
+ if (!s.level) return;
461
+
462
+ const pathIndex = s.tutorialManager.hintTargetIndex;
463
+ if (pathIndex === null) return;
464
+ if (s.removedPaths.has(pathIndex)) return;
465
+ if (s.animatingPaths.has(pathIndex)) return;
466
+
467
+ const path = s.level.paths[pathIndex];
468
+ if (!path) return;
469
+
470
+ const track = this.pathTracks[pathIndex] ?? this.buildPathTrack(path);
471
+ const trackLength = track.length;
472
+ if (trackLength <= 0) return;
473
+
474
+ const baseColor = this.getPathBaseColor(pathIndex);
475
+ const color =
476
+ ENABLE_ERROR_PATH_HIGHLIGHT && s.blockedPaths.has(pathIndex)
477
+ ? 0xff0000
478
+ : baseColor;
479
+
480
+ if (trackLength > 1) {
481
+ const lineWidth =
482
+ s.visualSize * PATH_LINE_WIDTH_RATIO * s.tutorialManager.hintPulseScale;
483
+ g.fillStyle(color, 1);
484
+ this.getPathRendererForLineWidth(lineWidth).render({
485
+ g,
486
+ track,
487
+ startSegmentIndex: 0,
488
+ endSegmentIndexExclusive: trackLength - 1,
489
+ cellSize: s.cellSize,
490
+ lineWidth,
491
+ headCell: path.head,
492
+ cellCenter: (col, row) => this.cellCenter(col, row),
493
+ fillAxisAlignedSegmentRect: (g2, x1, y1, x2, y2, w) =>
494
+ this.fillAxisAlignedSegmentRect(g2, x1, y1, x2, y2, w),
495
+ });
496
+ }
497
+
498
+ const { x: hx, y: hy } = this.cellCenter(path.head.x, path.head.y);
499
+ const angle = PathRendererManager.directionToAngle(path.direction);
500
+ this.drawArrowHead(
501
+ g,
502
+ hx,
503
+ hy,
504
+ angle,
505
+ color,
506
+ s.tutorialManager.hintPulseScale,
507
+ );
508
+ }
509
+ }
@@ -0,0 +1,176 @@
1
+ import * as THREE from "three";
2
+ import type { BoardLayout3D } from "./BoardLayout3D";
3
+
4
+ export interface PathData {
5
+ points: Array<{ x: number; y: number }>; // GridPoints (x=col, y=row)
6
+ direction: "up" | "down" | "left" | "right";
7
+ color: string;
8
+ }
9
+
10
+ export type PathState = "normal" | "highlight" | "blocked" | "animating";
11
+
12
+ /**
13
+ * Three.js mesh-per-cell 路径渲染器。
14
+ * 路径覆盖的每个 cell 放置一个 3D 模型,全部朝路径方向旋转。
15
+ */
16
+ export class PathRenderer3D {
17
+ private scene: THREE.Scene;
18
+ private boardLayout: BoardLayout3D;
19
+ private pathMeshes: Map<number, THREE.Mesh[]> = new Map(); // pathIndex → mesh[]
20
+ private baseMaterial!: THREE.MeshStandardMaterial;
21
+ private baseGeometry!: THREE.BufferGeometry;
22
+
23
+ // 方向 → Y 轴旋转角度(模型默认朝 +Z)
24
+ private static DIRECTION_ANGLES: Record<string, number> = {
25
+ up: Math.PI,
26
+ down: 0,
27
+ left: -Math.PI / 2,
28
+ right: Math.PI / 2,
29
+ };
30
+
31
+ constructor(scene: THREE.Scene, boardLayout: BoardLayout3D) {
32
+ this.scene = scene;
33
+ this.boardLayout = boardLayout;
34
+ }
35
+
36
+ /**
37
+ * 设置共享几何体(所有车复用同一个 geometry)
38
+ * @param geometry 车模型的几何体(已归一化到单位大小)
39
+ */
40
+ setSharedGeometry(geometry: THREE.BufferGeometry): void {
41
+ this.baseGeometry = geometry;
42
+ }
43
+
44
+ /**
45
+ * 如果没有加载外部模型,使用内置的简单几何体(BoxGeometry 作为占位)
46
+ */
47
+ useDefaultGeometry(): void {
48
+ // 使用圆角盒子近似汽车形状
49
+ this.baseGeometry = new THREE.BoxGeometry(0.6, 0.3, 0.9);
50
+ }
51
+
52
+ /**
53
+ * 渲染所有路径
54
+ * @param paths 路径数据数组
55
+ * @param colorToHex 颜色字符串 → hex 数字
56
+ */
57
+ renderPaths(paths: PathData[], colorToHex: (color: string) => number): void {
58
+ this.clearAll();
59
+
60
+ const cellSize = this.boardLayout.getLayout().cellSize;
61
+ const meshScale = cellSize * 0.75;
62
+
63
+ for (let pathIdx = 0; pathIdx < paths.length; pathIdx++) {
64
+ const path = paths[pathIdx];
65
+ const meshes: THREE.Mesh[] = [];
66
+ const angle = PathRenderer3D.DIRECTION_ANGLES[path.direction] ?? 0;
67
+ const color = colorToHex(path.color);
68
+
69
+ for (let cellIdx = 0; cellIdx < path.points.length; cellIdx++) {
70
+ const pt = path.points[cellIdx];
71
+ const worldPos = this.boardLayout.getCellWorldPos(pt.x, pt.y);
72
+
73
+ // 每个 cell 一个独立材质(用于状态变色)
74
+ const mat = new THREE.MeshStandardMaterial({
75
+ color,
76
+ roughness: 0.5,
77
+ metalness: 0.1,
78
+ });
79
+
80
+ const mesh = new THREE.Mesh(this.baseGeometry, mat);
81
+ mesh.position.copy(worldPos);
82
+ mesh.position.y = meshScale * 0.2; // 略微抬起
83
+ mesh.rotation.y = angle;
84
+ mesh.scale.setScalar(meshScale);
85
+ mesh.castShadow = true;
86
+ mesh.receiveShadow = true;
87
+
88
+ // 存储索引信息,用于 Raycaster hitTest
89
+ mesh.userData = { pathIndex: pathIdx, cellIndex: cellIdx };
90
+
91
+ this.scene.add(mesh);
92
+ meshes.push(mesh);
93
+ }
94
+
95
+ this.pathMeshes.set(pathIdx, meshes);
96
+ }
97
+ }
98
+
99
+ /**
100
+ * 设置路径状态(高亮/阻挡/正常)
101
+ */
102
+ setPathState(pathIndex: number, state: PathState): void {
103
+ const meshes = this.pathMeshes.get(pathIndex);
104
+ if (!meshes) return;
105
+
106
+ for (const mesh of meshes) {
107
+ const mat = mesh.material as THREE.MeshStandardMaterial;
108
+ switch (state) {
109
+ case "highlight":
110
+ mat.emissive.setHex(0x333333);
111
+ break;
112
+ case "blocked":
113
+ mat.emissive.setHex(0x660000);
114
+ break;
115
+ case "normal":
116
+ default:
117
+ mat.emissive.setHex(0x000000);
118
+ break;
119
+ }
120
+ }
121
+ }
122
+
123
+ /**
124
+ * 获取某条路径的所有 Mesh(用于动画)
125
+ */
126
+ getPathMeshes(pathIndex: number): THREE.Mesh[] {
127
+ return this.pathMeshes.get(pathIndex) || [];
128
+ }
129
+
130
+ /**
131
+ * 获取所有可选中的 Mesh 列表(用于 Raycaster)
132
+ */
133
+ getAllSelectableMeshes(): THREE.Mesh[] {
134
+ const all: THREE.Mesh[] = [];
135
+ this.pathMeshes.forEach((meshes) => all.push(...meshes));
136
+ return all;
137
+ }
138
+
139
+ /**
140
+ * 移除某条路径的所有 Mesh
141
+ */
142
+ removePath(pathIndex: number): void {
143
+ const meshes = this.pathMeshes.get(pathIndex);
144
+ if (!meshes) return;
145
+
146
+ for (const mesh of meshes) {
147
+ this.scene.remove(mesh);
148
+ mesh.geometry.dispose();
149
+ (mesh.material as THREE.Material).dispose();
150
+ }
151
+ this.pathMeshes.delete(pathIndex);
152
+ }
153
+
154
+ /**
155
+ * 清除所有路径渲染
156
+ */
157
+ clearAll(): void {
158
+ this.pathMeshes.forEach((meshes, idx) => {
159
+ for (const mesh of meshes) {
160
+ this.scene.remove(mesh);
161
+ (mesh.material as THREE.Material).dispose();
162
+ }
163
+ });
164
+ this.pathMeshes.clear();
165
+ }
166
+
167
+ /**
168
+ * 销毁(释放共享资源)
169
+ */
170
+ destroy(): void {
171
+ this.clearAll();
172
+ if (this.baseGeometry) {
173
+ this.baseGeometry.dispose();
174
+ }
175
+ }
176
+ }