@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.
- package/README.md +333 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/skills.loader.d.ts +31 -0
- package/dist/src/skills.loader.d.ts.map +1 -0
- package/dist/src/skills.loader.js +200 -0
- package/dist/src/skills.loader.js.map +1 -0
- package/dist/src/skills.types.d.ts +44 -0
- package/dist/src/skills.types.d.ts.map +1 -0
- package/dist/src/skills.types.js +9 -0
- package/dist/src/skills.types.js.map +1 -0
- package/package.json +35 -0
- package/skills/2048_core.aigameplay/SKILL.md +123 -0
- package/skills/2048_core.aigameplay/manifest.json +159 -0
- package/skills/2048_core.aigameplay/ref/pgs-schema.json +194 -0
- package/skills/2048_core.aigameplay/ref/reducer.template.ts +189 -0
- package/skills/SKILL.md +46 -0
- package/skills/ad_compliance_rules.aiconfig/SKILL.md +85 -0
- package/skills/ad_compliance_rules.aiconfig/manifest.json +60 -0
- package/skills/agent_remix_orchestrator.aicomponent/SKILL.md +257 -0
- package/skills/agent_remix_orchestrator.aicomponent/manifest.json +12 -0
- package/skills/app_metadata.aiconfig/SKILL.md +53 -0
- package/skills/app_metadata.aiconfig/manifest.json +32 -0
- package/skills/appear_sfx.aiaudio/SKILL.md +59 -0
- package/skills/appear_sfx.aiaudio/manifest.json +45 -0
- package/skills/appear_sfx.aiaudio/ref/appear.mp3 +0 -0
- package/skills/arrow_move_error_sfx.aiaudio/SKILL.md +59 -0
- package/skills/arrow_move_error_sfx.aiaudio/manifest.json +45 -0
- package/skills/arrow_move_error_sfx.aiaudio/ref/arrow_move_error.mp3 +0 -0
- package/skills/arrow_path_data_format.aicomponent/SKILL.md +152 -0
- package/skills/arrow_path_data_format.aicomponent/manifest.json +57 -0
- package/skills/arrow_path_data_format.aicomponent/ref/LevelParser.ts +188 -0
- package/skills/arrow_path_data_format.aicomponent/ref/LevelTypes.ts +131 -0
- package/skills/arrow_pick_match_rules.aigameplay/SKILL.md +117 -0
- package/skills/arrow_pick_match_rules.aigameplay/manifest.json +105 -0
- package/skills/arrow_pick_match_rules.aigameplay/ref/pgs-schema.json +180 -0
- package/skills/asset_pipeline_scripts.aicomponent/SKILL.md +117 -0
- package/skills/asset_pipeline_scripts.aicomponent/manifest.json +17 -0
- package/skills/asset_pipeline_scripts.aicomponent/ref/gen-sprite.sh +105 -0
- package/skills/ball_sort.aigameplay/SKILL.md +109 -0
- package/skills/ball_sort.aigameplay/manifest.json +155 -0
- package/skills/ball_sort.aigameplay/ref/pgs-schema.json +192 -0
- package/skills/ball_sort.aigameplay/ref/reducer.template.ts +156 -0
- package/skills/basketball_shot.aigameplay/SKILL.md +94 -0
- package/skills/basketball_shot.aigameplay/manifest.json +150 -0
- package/skills/basketball_shot.aigameplay/ref/pgs-schema.json +229 -0
- package/skills/basketball_shot.aigameplay/ref/reducer.template.ts +189 -0
- package/skills/bg_music.aiaudio/SKILL.md +61 -0
- package/skills/bg_music.aiaudio/manifest.json +48 -0
- package/skills/bg_music.aiaudio/ref/bg.mp3 +0 -0
- package/skills/big_watermelon.aigameplay/SKILL.md +94 -0
- package/skills/big_watermelon.aigameplay/manifest.json +155 -0
- package/skills/big_watermelon.aigameplay/ref/pgs-schema.json +191 -0
- package/skills/big_watermelon.aigameplay/ref/reducer.template.ts +202 -0
- package/skills/block_puzzle.aigameplay/SKILL.md +121 -0
- package/skills/block_puzzle.aigameplay/manifest.json +154 -0
- package/skills/block_puzzle.aigameplay/ref/pgs-schema.json +170 -0
- package/skills/block_puzzle.aigameplay/ref/reducer.template.ts +182 -0
- package/skills/board_entity_sprite.aiimage/SKILL.md +255 -0
- package/skills/board_entity_sprite.aiimage/manifest.json +153 -0
- package/skills/board_entity_sprite.aiimage/ref/ProceduralCar.ts +357 -0
- package/skills/board_entity_sprite.aiimage/ref/car.png +0 -0
- package/skills/board_entity_sprite.aiimage/ref/car.webp +0 -0
- package/skills/bottom_ui_bar.aicomponent/SKILL.md +50 -0
- package/skills/bottom_ui_bar.aicomponent/manifest.json +31 -0
- package/skills/bottom_ui_bar.aicomponent/ref/GameBottomUI.ts +27 -0
- package/skills/bubble_shooter.aigameplay/SKILL.md +129 -0
- package/skills/bubble_shooter.aigameplay/manifest.json +181 -0
- package/skills/bubble_shooter.aigameplay/ref/pgs-schema.json +226 -0
- package/skills/bubble_shooter.aigameplay/ref/reducer.template.ts +228 -0
- package/skills/button_click_sfx.aiaudio/SKILL.md +59 -0
- package/skills/button_click_sfx.aiaudio/manifest.json +45 -0
- package/skills/button_click_sfx.aiaudio/ref/button_click.mp3 +0 -0
- package/skills/calm_piano.aiaudio/SKILL.md +68 -0
- package/skills/calm_piano.aiaudio/manifest.json +50 -0
- package/skills/camera_controller_3d.aicomponent/SKILL.md +100 -0
- package/skills/camera_controller_3d.aicomponent/manifest.json +52 -0
- package/skills/camera_controller_3d.aicomponent/ref/CameraController.ts +199 -0
- package/skills/camera_controller_3d.aicomponent/ref/OrbitControlsAdapter.ts +152 -0
- package/skills/candy_tile.aiimage/SKILL.md +62 -0
- package/skills/candy_tile.aiimage/manifest.json +49 -0
- package/skills/car_parking.aigameplay/SKILL.md +105 -0
- package/skills/car_parking.aigameplay/manifest.json +164 -0
- package/skills/car_parking.aigameplay/ref/pgs-schema.json +163 -0
- package/skills/car_parking.aigameplay/ref/reducer.template.ts +166 -0
- package/skills/castle.aiimage/SKILL.md +64 -0
- package/skills/castle.aiimage/manifest.json +48 -0
- package/skills/cheerful_ukulele.aiaudio/SKILL.md +72 -0
- package/skills/cheerful_ukulele.aiaudio/manifest.json +50 -0
- package/skills/click_sfx.aiaudio/SKILL.md +59 -0
- package/skills/click_sfx.aiaudio/manifest.json +45 -0
- package/skills/click_sfx.aiaudio/ref/click.mp3 +0 -0
- package/skills/combo_display.aicomponent/SKILL.md +45 -0
- package/skills/combo_display.aicomponent/manifest.json +31 -0
- package/skills/combo_display.aicomponent/ref/ComboManager.ts +362 -0
- package/skills/combo_display.aicomponent/ref/ComboSmallUI.ts +232 -0
- package/skills/combo_praise_text.aicomponent/SKILL.md +56 -0
- package/skills/combo_praise_text.aicomponent/manifest.json +34 -0
- package/skills/combo_praise_text.aicomponent/ref/ComboManager.ts +362 -0
- package/skills/countdown_timer.aicomponent/SKILL.md +44 -0
- package/skills/countdown_timer.aicomponent/manifest.json +35 -0
- package/skills/countdown_timer.aicomponent/ref/CountdownDisplay.ts +213 -0
- package/skills/cta_platform_config.aiconfig/SKILL.md +72 -0
- package/skills/cta_platform_config.aiconfig/manifest.json +56 -0
- package/skills/debug_overlay.aicomponent/SKILL.md +75 -0
- package/skills/debug_overlay.aicomponent/manifest.json +17 -0
- package/skills/debug_overlay.aicomponent/ref/DebugOverlay.ts +144 -0
- package/skills/desert.aiimage/SKILL.md +63 -0
- package/skills/desert.aiimage/manifest.json +49 -0
- package/skills/difficulty_curve_designer.aiconfig/SKILL.md +68 -0
- package/skills/difficulty_curve_designer.aiconfig/manifest.json +36 -0
- package/skills/digit_renderer.aicomponent/SKILL.md +43 -0
- package/skills/digit_renderer.aicomponent/manifest.json +25 -0
- package/skills/digit_renderer.aicomponent/ref/DigitRenderer.ts +237 -0
- package/skills/download_button.aicomponent/SKILL.md +44 -0
- package/skills/download_button.aicomponent/manifest.json +25 -0
- package/skills/download_button.aicomponent/ref/DownloadButton.ts +137 -0
- package/skills/draw_line_puzzle.aigameplay/SKILL.md +84 -0
- package/skills/draw_line_puzzle.aigameplay/manifest.json +152 -0
- package/skills/draw_line_puzzle.aigameplay/ref/pgs-schema.json +189 -0
- package/skills/draw_line_puzzle.aigameplay/ref/reducer.template.ts +194 -0
- package/skills/easy_to_hard.aiconfig/SKILL.md +52 -0
- package/skills/easy_to_hard.aiconfig/manifest.json +33 -0
- package/skills/eight_ball_pool.aigameplay/SKILL.md +104 -0
- package/skills/eight_ball_pool.aigameplay/manifest.json +152 -0
- package/skills/eight_ball_pool.aigameplay/ref/pgs-schema.json +205 -0
- package/skills/eight_ball_pool.aigameplay/ref/reducer.template.ts +198 -0
- package/skills/energetic_electronic.aiaudio/SKILL.md +69 -0
- package/skills/energetic_electronic.aiaudio/manifest.json +51 -0
- package/skills/fail_sfx.aiaudio/SKILL.md +59 -0
- package/skills/fail_sfx.aiaudio/manifest.json +44 -0
- package/skills/fail_sfx.aiaudio/ref/fail.mp3 +0 -0
- package/skills/figer_icon.aiimage/SKILL.md +58 -0
- package/skills/figer_icon.aiimage/manifest.json +48 -0
- package/skills/figer_icon.aiimage/ref/figer.png +0 -0
- package/skills/figer_icon.aiimage/ref/figer.webp +0 -0
- package/skills/forest.aiimage/SKILL.md +74 -0
- package/skills/forest.aiimage/manifest.json +48 -0
- package/skills/fruit_tile.aiimage/SKILL.md +68 -0
- package/skills/fruit_tile.aiimage/manifest.json +48 -0
- package/skills/game_over_panel.aicomponent/SKILL.md +47 -0
- package/skills/game_over_panel.aicomponent/manifest.json +61 -0
- package/skills/game_over_panel.aicomponent/ref/GameOverPanel.ts +74 -0
- package/skills/game_scene.aicomponent/SKILL.md +57 -0
- package/skills/game_scene.aicomponent/manifest.json +36 -0
- package/skills/game_scene.aicomponent/ref/Game.ts +748 -0
- package/skills/gameplay_balance_check.aivalidator/SKILL.md +69 -0
- package/skills/gameplay_balance_check.aivalidator/manifest.json +21 -0
- package/skills/gameplay_unit_test.aivalidator/SKILL.md +89 -0
- package/skills/gameplay_unit_test.aivalidator/manifest.json +17 -0
- package/skills/gameplay_unit_test.aivalidator/ref/gameplay.test.ts +202 -0
- package/skills/gameplay_unit_test.aivalidator/ref/vitest.config.ts +13 -0
- package/skills/grid_board_layout.aicomponent/SKILL.md +85 -0
- package/skills/grid_board_layout.aicomponent/manifest.json +69 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayout.ts +416 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayout3D.ts +125 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardLayoutMath.ts +85 -0
- package/skills/grid_board_layout.aicomponent/ref/BoardRenderer3D.ts +298 -0
- package/skills/heart_lives.aicomponent/SKILL.md +42 -0
- package/skills/heart_lives.aicomponent/manifest.json +25 -0
- package/skills/heart_lives.aicomponent/ref/HeartDisplay.ts +96 -0
- package/skills/idle-breathe.aicomponent/SKILL.md +27 -0
- package/skills/idle-breathe.aicomponent/manifest.json +20 -0
- package/skills/idle-breathe.aicomponent/ref/phaser.js +25 -0
- package/skills/idle-breathe.aicomponent/ref/playcanvas.js +29 -0
- package/skills/jewel_tile.aiimage/SKILL.md +63 -0
- package/skills/jewel_tile.aiimage/manifest.json +49 -0
- package/skills/knife_hit.aigameplay/SKILL.md +103 -0
- package/skills/knife_hit.aigameplay/manifest.json +151 -0
- package/skills/knife_hit.aigameplay/ref/pgs-schema.json +202 -0
- package/skills/knife_hit.aigameplay/ref/reducer.template.ts +196 -0
- package/skills/left_right_parkour.aigameplay/SKILL.md +120 -0
- package/skills/left_right_parkour.aigameplay/manifest.json +165 -0
- package/skills/left_right_parkour.aigameplay/ref/pgs-schema.json +200 -0
- package/skills/left_right_parkour.aigameplay/ref/reducer.template.ts +194 -0
- package/skills/level_data_pack.aiconfig/SKILL.md +64 -0
- package/skills/level_data_pack.aiconfig/manifest.json +37 -0
- package/skills/level_data_validator.aivalidator/SKILL.md +85 -0
- package/skills/level_data_validator.aivalidator/manifest.json +17 -0
- package/skills/level_data_validator.aivalidator/ref/LevelValidator.ts +113 -0
- package/skills/level_lifecycle.aicomponent/SKILL.md +81 -0
- package/skills/level_lifecycle.aicomponent/manifest.json +87 -0
- package/skills/level_lifecycle.aicomponent/ref/LevelLifecycle.ts +235 -0
- package/skills/level_solvability_validator.aivalidator/SKILL.md +74 -0
- package/skills/level_solvability_validator.aivalidator/manifest.json +23 -0
- package/skills/level_solvability_validator.aivalidator/ref/LevelValidator.ts +186 -0
- package/skills/level_state.aicomponent/SKILL.md +55 -0
- package/skills/level_state.aicomponent/manifest.json +34 -0
- package/skills/level_state.aicomponent/ref/LevelDataManager.ts +26 -0
- package/skills/level_state.aicomponent/ref/LevelManager.ts +26 -0
- package/skills/loading_screen.aicomponent/SKILL.md +57 -0
- package/skills/loading_screen.aicomponent/manifest.json +43 -0
- package/skills/loading_screen.aicomponent/ref/LoadingUI.ts +339 -0
- package/skills/lose_result_panel.aiimage/SKILL.md +58 -0
- package/skills/lose_result_panel.aiimage/manifest.json +47 -0
- package/skills/lose_result_panel.aiimage/ref/lose.png +0 -0
- package/skills/lose_result_panel.aiimage/ref/lose.webp +0 -0
- package/skills/lose_sfx.aiaudio/SKILL.md +59 -0
- package/skills/lose_sfx.aiaudio/manifest.json +45 -0
- package/skills/lose_sfx.aiaudio/ref/lose.mp3 +0 -0
- package/skills/match-pop.aicomponent/SKILL.md +29 -0
- package/skills/match-pop.aicomponent/manifest.json +19 -0
- package/skills/match-pop.aicomponent/ref/phaser.js +30 -0
- package/skills/match-pop.aicomponent/ref/playcanvas.js +22 -0
- package/skills/match3_core.aigameplay/SKILL.md +125 -0
- package/skills/match3_core.aigameplay/manifest.json +107 -0
- package/skills/match3_core.aigameplay/ref/pgs-schema.json +154 -0
- package/skills/match3_core.aigameplay/ref/reducer.template.ts +191 -0
- package/skills/match_engine.aicomponent/SKILL.md +84 -0
- package/skills/match_engine.aicomponent/manifest.json +23 -0
- package/skills/match_engine.aicomponent/ref/MatchEngine.ts +75 -0
- package/skills/memory_match.aigameplay/SKILL.md +111 -0
- package/skills/memory_match.aigameplay/manifest.json +164 -0
- package/skills/memory_match.aigameplay/ref/pgs-schema.json +190 -0
- package/skills/memory_match.aigameplay/ref/reducer.template.ts +162 -0
- package/skills/merge_core.aigameplay/SKILL.md +112 -0
- package/skills/merge_core.aigameplay/manifest.json +154 -0
- package/skills/merge_core.aigameplay/ref/pgs-schema.json +202 -0
- package/skills/merge_core.aigameplay/ref/reducer.template.ts +179 -0
- package/skills/mistake_sfx.aiaudio/SKILL.md +59 -0
- package/skills/mistake_sfx.aiaudio/manifest.json +45 -0
- package/skills/mistake_sfx.aiaudio/ref/mistake.mp3 +0 -0
- package/skills/nomove_hint_overlay.aiimage/SKILL.md +58 -0
- package/skills/nomove_hint_overlay.aiimage/manifest.json +48 -0
- package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.png +0 -0
- package/skills/nomove_hint_overlay.aiimage/ref/nomove_hint.webp +0 -0
- package/skills/normal_dot.aiimage/SKILL.md +58 -0
- package/skills/normal_dot.aiimage/manifest.json +46 -0
- package/skills/normal_dot.aiimage/ref/normal_dot.png +0 -0
- package/skills/normal_dot.aiimage/ref/normal_dot.webp +0 -0
- package/skills/ocean.aiimage/SKILL.md +71 -0
- package/skills/ocean.aiimage/manifest.json +49 -0
- package/skills/particle-confetti.aicomponent/SKILL.md +32 -0
- package/skills/particle-confetti.aicomponent/manifest.json +21 -0
- package/skills/particle-confetti.aicomponent/ref/html5-spritesheet.js +17 -0
- package/skills/particle-confetti.aicomponent/ref/phaser.js +38 -0
- package/skills/particle-explosion.aicomponent/SKILL.md +37 -0
- package/skills/particle-explosion.aicomponent/manifest.json +24 -0
- package/skills/particle-explosion.aicomponent/ref/html5-spritesheet.js +40 -0
- package/skills/particle-explosion.aicomponent/ref/phaser.js +46 -0
- package/skills/particle-explosion.aicomponent/ref/playcanvas.js +33 -0
- package/skills/particle-trail.aicomponent/SKILL.md +25 -0
- package/skills/particle-trail.aicomponent/manifest.json +22 -0
- package/skills/particle-trail.aicomponent/ref/phaser.js +31 -0
- package/skills/path_animation.aicomponent/SKILL.md +82 -0
- package/skills/path_animation.aicomponent/manifest.json +77 -0
- package/skills/path_animation.aicomponent/ref/AnimationManager.ts +694 -0
- package/skills/path_animation.aicomponent/ref/AnimationManager3D.ts +317 -0
- package/skills/path_elimination_rules.aigameplay/SKILL.md +88 -0
- package/skills/path_elimination_rules.aigameplay/manifest.json +119 -0
- package/skills/path_elimination_rules.aigameplay/ref/pgs-schema.json +227 -0
- package/skills/path_input_handler.aicomponent/SKILL.md +87 -0
- package/skills/path_input_handler.aicomponent/manifest.json +97 -0
- package/skills/path_input_handler.aicomponent/ref/InputHandler.ts +714 -0
- package/skills/path_input_handler.aicomponent/ref/InputHandler3D.ts +204 -0
- package/skills/path_renderer.aicomponent/SKILL.md +101 -0
- package/skills/path_renderer.aicomponent/manifest.json +69 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderer.ts +509 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderer3D.ts +176 -0
- package/skills/path_renderer.aicomponent/ref/PathRenderers.ts +640 -0
- package/skills/phaser.aicomponent/SKILL.md +315 -0
- package/skills/phaser.aicomponent/manifest.json +156 -0
- package/skills/phaser.aicomponent/ref/BootScene.ts +29 -0
- package/skills/phaser.aicomponent/ref/GameConfig.ts +29 -0
- package/skills/phaser.aicomponent/ref/GameScene.ts +88 -0
- package/skills/phaser.aicomponent/ref/PreloaderScene.ts +78 -0
- package/skills/phaser.aicomponent/ref/SceneKeys.ts +7 -0
- package/skills/phaser.aicomponent/ref/SoundUtils.ts +21 -0
- package/skills/phaser.aicomponent/ref/UiLayout.ts +74 -0
- package/skills/phaser.aicomponent/ref/globals.d.ts +52 -0
- package/skills/phaser.aicomponent/ref/index.css +40 -0
- package/skills/phaser.aicomponent/ref/index.html +14 -0
- package/skills/phaser.aicomponent/ref/index.ts +48 -0
- package/skills/phaser.aicomponent/ref/main.ts +16 -0
- package/skills/phaser.aicomponent/ref/package.json +22 -0
- package/skills/phaser.aicomponent/ref/tsconfig.json +25 -0
- package/skills/phaser.aicomponent/ref/webpack.config.js +57 -0
- package/skills/phaser_scene_lifecycle.aicomponent/SKILL.md +63 -0
- package/skills/phaser_scene_lifecycle.aicomponent/manifest.json +33 -0
- package/skills/pick_and_match_rules.aigameplay/SKILL.md +113 -0
- package/skills/pick_and_match_rules.aigameplay/manifest.json +121 -0
- package/skills/pick_and_match_rules.aigameplay/ref/pgs-schema.json +354 -0
- package/skills/pin_pull.aigameplay/SKILL.md +110 -0
- package/skills/pin_pull.aigameplay/manifest.json +164 -0
- package/skills/pin_pull.aigameplay/ref/pgs-schema.json +201 -0
- package/skills/pin_pull.aigameplay/ref/reducer.template.ts +216 -0
- package/skills/playable_app_logo.aiimage/SKILL.md +58 -0
- package/skills/playable_app_logo.aiimage/manifest.json +47 -0
- package/skills/playable_app_logo.aiimage/ref/logo.png +0 -0
- package/skills/playable_app_logo.aiimage/ref/logo.webp +0 -0
- package/skills/playable_end_screen_layout.aicomponent/SKILL.md +75 -0
- package/skills/playable_end_screen_layout.aicomponent/manifest.json +24 -0
- package/skills/playable_guidance_layer.aicomponent/SKILL.md +89 -0
- package/skills/playable_guidance_layer.aicomponent/manifest.json +24 -0
- package/skills/playable_hud_layout.aicomponent/SKILL.md +96 -0
- package/skills/playable_hud_layout.aicomponent/manifest.json +24 -0
- package/skills/playable_scripts_build.aicomponent/SKILL.md +69 -0
- package/skills/playable_scripts_build.aicomponent/manifest.json +53 -0
- package/skills/playable_scripts_build.aicomponent/ref/builds.config.js +257 -0
- package/skills/playcraft-3d-flip-sprite/SKILL.md +336 -0
- package/skills/playcraft-3d-flip-sprite/renderer/flatten_glb.mjs +62 -0
- package/skills/playcraft-3d-flip-sprite/renderer/render.mjs +325 -0
- package/skills/playcraft-3d-flip-sprite/renderer/render_single.mjs +138 -0
- package/skills/playcraft-asset-management/SKILL.md +73 -0
- package/skills/playcraft-audio-generation/SKILL.md +126 -0
- package/skills/playcraft-build/SKILL.md +44 -0
- package/skills/playcraft-code-editor/SKILL.md +71 -0
- package/skills/playcraft-create-remix/SKILL.md +62 -0
- package/skills/playcraft-deploy/SKILL.md +59 -0
- package/skills/playcraft-image-generation/SKILL.md +148 -0
- package/skills/playcraft-image-processing/SKILL.md +216 -0
- package/skills/playcraft-platform-intro/SKILL.md +41 -0
- package/skills/playcraft-prefab/SKILL.md +98 -0
- package/skills/playcraft-project-management/SKILL.md +57 -0
- package/skills/playcraft-remix-workflow/SKILL.md +119 -0
- package/skills/playcraft-remix-workflow/references/xplatform.schema.json5 +31 -0
- package/skills/playcraft-save/SKILL.md +46 -0
- package/skills/playcraft-skill-recommender/SKILL.md +152 -0
- package/skills/playcraft-sprite-generation/SKILL.md +534 -0
- package/skills/playcraft-sprite-remix/SKILL.md +155 -0
- package/skills/playcraft-sprite-sheet/SKILL.md +97 -0
- package/skills/playtest_report.aivalidator/SKILL.md +103 -0
- package/skills/playtest_report.aivalidator/manifest.json +21 -0
- package/skills/preloader_scene.aicomponent/SKILL.md +58 -0
- package/skills/preloader_scene.aicomponent/manifest.json +43 -0
- package/skills/preloader_scene.aicomponent/ref/Preloader.ts +339 -0
- package/skills/progress_bar.aicomponent/SKILL.md +38 -0
- package/skills/progress_bar.aicomponent/manifest.json +25 -0
- package/skills/progress_bar.aicomponent/ref/ProgressDisplay.ts +140 -0
- package/skills/references/xplatform.schema.json5 +31 -0
- package/skills/responsive_2d_layout.aicomponent/SKILL.md +161 -0
- package/skills/responsive_2d_layout.aicomponent/manifest.json +43 -0
- package/skills/responsive_2d_layout.aicomponent/ref/UiLayout.ts +56 -0
- package/skills/run_context_state.aicomponent/SKILL.md +54 -0
- package/skills/run_context_state.aicomponent/manifest.json +40 -0
- package/skills/run_context_state.aicomponent/ref/RunContextRuntime.ts +30 -0
- package/skills/score-fly.aicomponent/SKILL.md +31 -0
- package/skills/score-fly.aicomponent/manifest.json +21 -0
- package/skills/score-fly.aicomponent/ref/phaser.js +26 -0
- package/skills/score-fly.aicomponent/ref/playcanvas.js +28 -0
- package/skills/score_goal.aiconfig/SKILL.md +46 -0
- package/skills/score_goal.aiconfig/manifest.json +33 -0
- package/skills/screen-flash.aicomponent/SKILL.md +30 -0
- package/skills/screen-flash.aicomponent/manifest.json +20 -0
- package/skills/screen-flash.aicomponent/ref/phaser.js +48 -0
- package/skills/screen-shake.aicomponent/SKILL.md +30 -0
- package/skills/screen-shake.aicomponent/manifest.json +19 -0
- package/skills/screen-shake.aicomponent/ref/phaser.js +23 -0
- package/skills/screen-shake.aicomponent/ref/playcanvas.js +44 -0
- package/skills/screw_puzzle.aigameplay/SKILL.md +116 -0
- package/skills/screw_puzzle.aigameplay/manifest.json +164 -0
- package/skills/screw_puzzle.aigameplay/ref/pgs-schema.json +235 -0
- package/skills/screw_puzzle.aigameplay/ref/reducer.template.ts +213 -0
- package/skills/settings_state.aicomponent/SKILL.md +61 -0
- package/skills/settings_state.aicomponent/manifest.json +33 -0
- package/skills/settings_state.aicomponent/ref/SettingsManager.ts +130 -0
- package/skills/slide_out_to_tray_animation.aicomponent/SKILL.md +64 -0
- package/skills/slide_out_to_tray_animation.aicomponent/manifest.json +58 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager.ts +164 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/AnimationManager3D.ts +198 -0
- package/skills/slide_out_to_tray_animation.aicomponent/ref/BezierUtils.ts +59 -0
- package/skills/slot_machine.aigameplay/SKILL.md +119 -0
- package/skills/slot_machine.aigameplay/manifest.json +166 -0
- package/skills/slot_machine.aigameplay/ref/pgs-schema.json +212 -0
- package/skills/slot_machine.aigameplay/ref/reducer.template.ts +212 -0
- package/skills/sniper_shot.aigameplay/SKILL.md +84 -0
- package/skills/sniper_shot.aigameplay/manifest.json +153 -0
- package/skills/sniper_shot.aigameplay/ref/pgs-schema.json +211 -0
- package/skills/sniper_shot.aigameplay/ref/reducer.template.ts +211 -0
- package/skills/solitaire.aigameplay/SKILL.md +101 -0
- package/skills/solitaire.aigameplay/manifest.json +151 -0
- package/skills/solitaire.aigameplay/ref/pgs-schema.json +200 -0
- package/skills/solitaire.aigameplay/ref/reducer.template.ts +176 -0
- package/skills/sound-effects/SKILL.md +46 -0
- package/skills/sound_utils.aicomponent/SKILL.md +52 -0
- package/skills/sound_utils.aicomponent/manifest.json +30 -0
- package/skills/sound_utils.aicomponent/ref/SoundUtils.ts +29 -0
- package/skills/sprite-animation-2d.aicomponent/SKILL.md +45 -0
- package/skills/sprite-animation-2d.aicomponent/manifest.json +28 -0
- package/skills/sprite-animation-2d.aicomponent/ref/html5.js +83 -0
- package/skills/sprite-animation-2d.aicomponent/ref/phaser.js +38 -0
- package/skills/sprite-animation-2d.aicomponent/ref/playcanvas.js +67 -0
- package/skills/sprite_entity_renderer.aicomponent/SKILL.md +148 -0
- package/skills/sprite_entity_renderer.aicomponent/manifest.json +17 -0
- package/skills/sprite_entity_renderer.aicomponent/ref/SpriteEntityRenderer.ts +126 -0
- package/skills/success_sfx.aiaudio/SKILL.md +59 -0
- package/skills/success_sfx.aiaudio/manifest.json +45 -0
- package/skills/success_sfx.aiaudio/ref/success.mp3 +0 -0
- package/skills/tap_blast.aigameplay/SKILL.md +116 -0
- package/skills/tap_blast.aigameplay/manifest.json +153 -0
- package/skills/tap_blast.aigameplay/ref/pgs-schema.json +208 -0
- package/skills/tap_blast.aigameplay/ref/reducer.template.ts +202 -0
- package/skills/theme_state.aicomponent/SKILL.md +53 -0
- package/skills/theme_state.aicomponent/manifest.json +33 -0
- package/skills/theme_state.aicomponent/ref/ThemeManager.ts +174 -0
- package/skills/theme_switcher_build.aicomponent/SKILL.md +62 -0
- package/skills/theme_switcher_build.aicomponent/manifest.json +38 -0
- package/skills/theme_switcher_build.aicomponent/ref/theme-index.ts +8 -0
- package/skills/theme_variant.aiconfig/SKILL.md +78 -0
- package/skills/theme_variant.aiconfig/manifest.json +39 -0
- package/skills/theme_variant.aiconfig/ref/ExampleTheme/index.ts +16 -0
- package/skills/theme_variant.aiconfig/ref/ExampleTheme/levelEasy.json +141 -0
- package/skills/threejs.aicomponent/SKILL.md +422 -0
- package/skills/threejs.aicomponent/manifest.json +166 -0
- package/skills/threejs.aicomponent/ref/AssetLoader.ts +158 -0
- package/skills/threejs.aicomponent/ref/BaseScene.ts +88 -0
- package/skills/threejs.aicomponent/ref/GameConfig.ts +47 -0
- package/skills/threejs.aicomponent/ref/MainScene.ts +170 -0
- package/skills/threejs.aicomponent/ref/PreloaderScene.ts +93 -0
- package/skills/threejs.aicomponent/ref/SceneKeys.ts +6 -0
- package/skills/threejs.aicomponent/ref/SceneManager.ts +69 -0
- package/skills/threejs.aicomponent/ref/ViewportManager.ts +62 -0
- package/skills/threejs.aicomponent/ref/globals.d.ts +74 -0
- package/skills/threejs.aicomponent/ref/index.css +80 -0
- package/skills/threejs.aicomponent/ref/index.html +20 -0
- package/skills/threejs.aicomponent/ref/index.ts +117 -0
- package/skills/threejs.aicomponent/ref/main.ts +10 -0
- package/skills/threejs.aicomponent/ref/package.json +23 -0
- package/skills/threejs.aicomponent/ref/tsconfig.json +24 -0
- package/skills/threejs.aicomponent/ref/webpack.config.js +61 -0
- package/skills/time_clear_goal.aiconfig/SKILL.md +46 -0
- package/skills/time_clear_goal.aiconfig/manifest.json +32 -0
- package/skills/time_icon.aiimage/SKILL.md +58 -0
- package/skills/time_icon.aiimage/manifest.json +47 -0
- package/skills/time_icon.aiimage/ref/time.png +0 -0
- package/skills/time_icon.aiimage/ref/time.webp +0 -0
- package/skills/top_ui_bar.aicomponent/SKILL.md +45 -0
- package/skills/top_ui_bar.aicomponent/manifest.json +27 -0
- package/skills/top_ui_bar.aicomponent/ref/GameTopUI.ts +229 -0
- package/skills/tower_defence.aigameplay/SKILL.md +117 -0
- package/skills/tower_defence.aigameplay/manifest.json +175 -0
- package/skills/tower_defence.aigameplay/ref/pgs-schema.json +247 -0
- package/skills/tower_defence.aigameplay/ref/reducer.template.ts +239 -0
- package/skills/tray_container.aicomponent/SKILL.md +143 -0
- package/skills/tray_container.aicomponent/manifest.json +58 -0
- package/skills/tray_container.aicomponent/ref/TrayRenderer.ts +155 -0
- package/skills/tray_container.aicomponent/ref/TrayRenderer3D.ts +281 -0
- package/skills/tray_container.aicomponent/ref/TrayRendererHtmlOverlay.ts +228 -0
- package/skills/tutorial_overlay.aicomponent/SKILL.md +46 -0
- package/skills/tutorial_overlay.aicomponent/manifest.json +34 -0
- package/skills/tutorial_overlay.aicomponent/ref/TutorialManager.ts +367 -0
- package/skills/tween-animation-2d.aicomponent/SKILL.md +35 -0
- package/skills/tween-animation-2d.aicomponent/manifest.json +28 -0
- package/skills/tween-animation-2d.aicomponent/ref/phaser.js +49 -0
- package/skills/tween-animation-2d.aicomponent/ref/playcanvas.js +36 -0
- package/skills/typescript_module_patterns.aicomponent/SKILL.md +209 -0
- package/skills/typescript_module_patterns.aicomponent/manifest.json +28 -0
- package/skills/typescript_module_patterns.aicomponent/ref/globals.d.ts +31 -0
- package/skills/ui-transition.aicomponent/SKILL.md +33 -0
- package/skills/ui-transition.aicomponent/manifest.json +19 -0
- package/skills/ui-transition.aicomponent/ref/phaser.js +45 -0
- package/skills/ux_flow_spec.aiconfig/SKILL.md +82 -0
- package/skills/ux_flow_spec.aiconfig/manifest.json +39 -0
- package/skills/wave_difficulty.aiconfig/SKILL.md +46 -0
- package/skills/wave_difficulty.aiconfig/manifest.json +33 -0
- package/skills/webpack_build.aicomponent/SKILL.md +204 -0
- package/skills/webpack_build.aicomponent/manifest.json +29 -0
- package/skills/webpack_build.aicomponent/ref/package.json +16 -0
- package/skills/webpack_build.aicomponent/ref/webpack.config.js +53 -0
- package/skills/win_anim_sfx.aiaudio/SKILL.md +59 -0
- package/skills/win_anim_sfx.aiaudio/manifest.json +46 -0
- package/skills/win_anim_sfx.aiaudio/ref/win_anim.mp3 +0 -0
- package/skills/win_dot.aiimage/SKILL.md +58 -0
- package/skills/win_dot.aiimage/manifest.json +47 -0
- package/skills/win_dot.aiimage/ref/win_dot.png +0 -0
- package/skills/win_dot.aiimage/ref/win_dot.webp +0 -0
- package/skills/win_result_panel.aiimage/SKILL.md +58 -0
- package/skills/win_result_panel.aiimage/manifest.json +47 -0
- package/skills/win_result_panel.aiimage/ref/win.png +0 -0
- package/skills/win_result_panel.aiimage/ref/win.webp +0 -0
- package/skills/word_connect.aigameplay/SKILL.md +86 -0
- package/skills/word_connect.aigameplay/manifest.json +154 -0
- package/skills/word_connect.aigameplay/ref/pgs-schema.json +212 -0
- package/skills/word_connect.aigameplay/ref/reducer.template.ts +186 -0
- package/src/index.ts +10 -0
- package/src/skills.loader.ts +225 -0
- package/src/skills.types.ts +42 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import * as Phaser from "phaser";
|
|
2
|
+
import { GAME_TOP_UI_BAR_HEIGHT } from "./GameTopUI";
|
|
3
|
+
import { ThemeManager } from "./ThemeManager";
|
|
4
|
+
import type { ParsedLevel } from "../../levels/LevelTypes";
|
|
5
|
+
import {
|
|
6
|
+
BOARD_MARGIN_RATIO,
|
|
7
|
+
BOARD_PAN_MARGIN_RATIO,
|
|
8
|
+
BOARD_SCALE_FACTOR,
|
|
9
|
+
CELL_SPACING_MULTIPLIER,
|
|
10
|
+
GameConfig,
|
|
11
|
+
} from "../../GameConfig";
|
|
12
|
+
import { GAME_CANVAS_BACKGROUND_COLOR } from "../../DebugConfig";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 描述 BoardLayout 从 Game 场景中所需内容的最小接口。
|
|
16
|
+
*/
|
|
17
|
+
export interface BoardLayoutGameRef extends Phaser.Scene {
|
|
18
|
+
level: ParsedLevel | null;
|
|
19
|
+
cellSize: number;
|
|
20
|
+
cellWidth: number;
|
|
21
|
+
cellHeight: number;
|
|
22
|
+
visualSize: number;
|
|
23
|
+
boardWidth: number;
|
|
24
|
+
boardHeight: number;
|
|
25
|
+
boardContainer: Phaser.GameObjects.Container;
|
|
26
|
+
boardGraphics: Phaser.GameObjects.Graphics;
|
|
27
|
+
hintOverlayGraphics: Phaser.GameObjects.Graphics | undefined;
|
|
28
|
+
levelBackgroundImage: Phaser.GameObjects.Image | null;
|
|
29
|
+
zoom: number;
|
|
30
|
+
minZoom: number;
|
|
31
|
+
boardOffsetX: number;
|
|
32
|
+
boardOffsetY: number;
|
|
33
|
+
removedPaths: Set<number>;
|
|
34
|
+
topUI: any; // GameTopUI | null
|
|
35
|
+
backgroundRect: Phaser.GameObjects.Rectangle | undefined;
|
|
36
|
+
|
|
37
|
+
// BoardLayout 需要的 Game 方法
|
|
38
|
+
renderGridPaths(level: ParsedLevel, clampedProgress: number): void;
|
|
39
|
+
renderHintOverlay(): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class BoardLayout {
|
|
43
|
+
private scene: BoardLayoutGameRef;
|
|
44
|
+
|
|
45
|
+
constructor(scene: BoardLayoutGameRef) {
|
|
46
|
+
this.scene = scene;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ── 构建棋盘 ──
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 根据关卡数据和屏幕尺寸构建棋盘布局。
|
|
53
|
+
* 计算格子大小、棋盘尺寸,并渲染路径。
|
|
54
|
+
* @param level 关卡数据
|
|
55
|
+
* @param drawProgress 绘制进度(0~1)
|
|
56
|
+
*/
|
|
57
|
+
buildBoard(level: ParsedLevel, drawProgress: number = 1): void {
|
|
58
|
+
const s = this.scene;
|
|
59
|
+
const { width, height } = s.scale;
|
|
60
|
+
const isLandscape = width > height;
|
|
61
|
+
|
|
62
|
+
const marginRatio = BOARD_MARGIN_RATIO;
|
|
63
|
+
const usableWidth = width * (1 - 2 * marginRatio);
|
|
64
|
+
|
|
65
|
+
// 计算可用高度:减去顶部和底部UI高度
|
|
66
|
+
const BASE_HEIGHT = 1334;
|
|
67
|
+
const scaleY = height / BASE_HEIGHT;
|
|
68
|
+
|
|
69
|
+
let topUiHeight: number;
|
|
70
|
+
let bottomUiHeight: number;
|
|
71
|
+
if (isLandscape) {
|
|
72
|
+
// 横屏模式:使用较小的固定像素高度
|
|
73
|
+
topUiHeight = 55;
|
|
74
|
+
bottomUiHeight = 45;
|
|
75
|
+
} else {
|
|
76
|
+
// 竖屏模式:使用缩放逻辑
|
|
77
|
+
topUiHeight = GAME_TOP_UI_BAR_HEIGHT * scaleY;
|
|
78
|
+
bottomUiHeight = GameConfig.GAME_BOTTOM_UI_BAR_HEIGHT * scaleY;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const availableHeight = height - topUiHeight - bottomUiHeight;
|
|
82
|
+
const usableHeight = availableHeight * (1 - 2 * marginRatio);
|
|
83
|
+
|
|
84
|
+
// 应用棋盘缩放系数
|
|
85
|
+
const scaleFactor = BOARD_SCALE_FACTOR;
|
|
86
|
+
const scaledUsableWidth = usableWidth * scaleFactor;
|
|
87
|
+
const scaledUsableHeight = usableHeight * scaleFactor;
|
|
88
|
+
|
|
89
|
+
// 计算原始格子大小(用于箭头和线条渲染)
|
|
90
|
+
let baseSize: number;
|
|
91
|
+
if (isLandscape) {
|
|
92
|
+
const maxBaseSizeFromHeight = Math.floor(
|
|
93
|
+
scaledUsableHeight / (CELL_SPACING_MULTIPLIER * level.rows),
|
|
94
|
+
);
|
|
95
|
+
const maxBaseSizeFromWidth = Math.floor(
|
|
96
|
+
scaledUsableWidth / (CELL_SPACING_MULTIPLIER * level.cols),
|
|
97
|
+
);
|
|
98
|
+
baseSize = Math.max(
|
|
99
|
+
4,
|
|
100
|
+
Math.min(maxBaseSizeFromHeight, maxBaseSizeFromWidth),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const maxCellFromHeight = Math.floor(scaledUsableHeight / level.rows);
|
|
104
|
+
const maxCellFromWidth = Math.floor(scaledUsableWidth / level.cols);
|
|
105
|
+
const squareCellSize = Math.min(maxCellFromHeight, maxCellFromWidth);
|
|
106
|
+
s.cellWidth = squareCellSize;
|
|
107
|
+
s.cellHeight = squareCellSize;
|
|
108
|
+
|
|
109
|
+
s.visualSize = Math.floor(squareCellSize / CELL_SPACING_MULTIPLIER);
|
|
110
|
+
s.cellSize = Math.floor(baseSize * CELL_SPACING_MULTIPLIER);
|
|
111
|
+
|
|
112
|
+
s.boardWidth = s.cellWidth * level.cols;
|
|
113
|
+
s.boardHeight = s.cellHeight * level.rows;
|
|
114
|
+
} else {
|
|
115
|
+
// 竖屏:正方形格子
|
|
116
|
+
baseSize = Math.max(
|
|
117
|
+
4,
|
|
118
|
+
Math.floor(
|
|
119
|
+
Math.min(
|
|
120
|
+
scaledUsableWidth / level.cols,
|
|
121
|
+
scaledUsableHeight / level.rows,
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
s.visualSize = baseSize;
|
|
127
|
+
s.cellSize = Math.floor(baseSize * CELL_SPACING_MULTIPLIER);
|
|
128
|
+
s.cellWidth = s.cellSize;
|
|
129
|
+
s.cellHeight = s.cellSize;
|
|
130
|
+
|
|
131
|
+
s.boardWidth = s.cellSize * level.cols;
|
|
132
|
+
s.boardHeight = s.cellSize * level.rows;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.positionBoardContainer();
|
|
136
|
+
|
|
137
|
+
s.boardGraphics.clear();
|
|
138
|
+
s.hintOverlayGraphics?.clear();
|
|
139
|
+
|
|
140
|
+
// 处理背景图片
|
|
141
|
+
this.handleLevelBackground(level);
|
|
142
|
+
|
|
143
|
+
const clampedProgress = Phaser.Math.Clamp(drawProgress, 0, 1);
|
|
144
|
+
|
|
145
|
+
s.renderGridPaths(level, clampedProgress);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ── 处理关卡背景 ──
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 处理关卡背景图片的加载和显示。
|
|
152
|
+
* 如果关卡有背景图配置,则加载并显示;否则清除已有背景。
|
|
153
|
+
* @param level 关卡数据
|
|
154
|
+
*/
|
|
155
|
+
handleLevelBackground(level: ParsedLevel): void {
|
|
156
|
+
const s = this.scene;
|
|
157
|
+
// 清除之前的背景图片
|
|
158
|
+
if (s.levelBackgroundImage) {
|
|
159
|
+
s.levelBackgroundImage.destroy();
|
|
160
|
+
s.levelBackgroundImage = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 如果关卡有背景图配置,加载并显示
|
|
164
|
+
if (level.background && level.background.imageKey) {
|
|
165
|
+
const { imageKey, dataUrl, opacity = 0.5 } = level.background;
|
|
166
|
+
|
|
167
|
+
console.log(`[Game] 处理背景图片: ${imageKey}`);
|
|
168
|
+
|
|
169
|
+
if (!s.textures.exists(imageKey)) {
|
|
170
|
+
if (dataUrl) {
|
|
171
|
+
console.log(`[Game] 从 data URL 创建背景纹理: ${imageKey}`);
|
|
172
|
+
this.createTextureFromDataUrl(imageKey, dataUrl);
|
|
173
|
+
return; // 异步纹理创建,完成后会创建图片
|
|
174
|
+
} else {
|
|
175
|
+
console.warn(`[Game] 未找到背景纹理且无 data URL: ${imageKey}`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
s.levelBackgroundImage = s.add.image(
|
|
181
|
+
s.boardWidth / 2,
|
|
182
|
+
s.boardHeight / 2,
|
|
183
|
+
imageKey,
|
|
184
|
+
);
|
|
185
|
+
s.levelBackgroundImage.setOrigin(0.5, 0.5);
|
|
186
|
+
s.levelBackgroundImage.setAlpha(opacity);
|
|
187
|
+
s.levelBackgroundImage.setDepth(3000);
|
|
188
|
+
|
|
189
|
+
s.boardContainer.addAt(s.levelBackgroundImage, 0);
|
|
190
|
+
|
|
191
|
+
this.resizeLevelBackgroundImage();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ── 从 DataUrl 创建纹理 ──
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* 从 data URL 异步创建纹理。
|
|
199
|
+
* @param textureKey 纹理键名
|
|
200
|
+
* @param dataUrl 图片的 data URL
|
|
201
|
+
*/
|
|
202
|
+
private createTextureFromDataUrl(textureKey: string, dataUrl: string): void {
|
|
203
|
+
const s = this.scene;
|
|
204
|
+
const img = new Image();
|
|
205
|
+
img.onload = () => {
|
|
206
|
+
if (!s.scene || !s.textures) {
|
|
207
|
+
console.warn(`[Game] 纹理创建前场景已被销毁: ${textureKey}`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (s.textures.exists(textureKey)) {
|
|
212
|
+
s.textures.remove(textureKey);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const texture = s.textures.createCanvas(
|
|
216
|
+
textureKey,
|
|
217
|
+
img.width,
|
|
218
|
+
img.height,
|
|
219
|
+
);
|
|
220
|
+
if (!texture) {
|
|
221
|
+
console.error(`[Game] 创建 canvas 纹理失败: ${textureKey}`);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const context = texture.getContext();
|
|
225
|
+
if (!context) {
|
|
226
|
+
console.error(`[Game] 获取纹理 canvas 上下文失败: ${textureKey}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
context.drawImage(img, 0, 0);
|
|
230
|
+
texture.refresh();
|
|
231
|
+
console.log(`[Game] 从 data URL 创建纹理成功: ${textureKey}`);
|
|
232
|
+
|
|
233
|
+
this.loadBackgroundImageAfterTextureCreation(textureKey);
|
|
234
|
+
};
|
|
235
|
+
img.onerror = () => {
|
|
236
|
+
console.error(`[Game] 从 data URL 加载图片失败: ${textureKey}`);
|
|
237
|
+
};
|
|
238
|
+
img.src = dataUrl;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// ── 纹理创建后加载背景图片 ──
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* 纹理异步创建完成后,加载并显示背景图片。
|
|
245
|
+
* @param textureKey 纹理键名
|
|
246
|
+
*/
|
|
247
|
+
private loadBackgroundImageAfterTextureCreation(textureKey: string): void {
|
|
248
|
+
const s = this.scene;
|
|
249
|
+
if (
|
|
250
|
+
s.level &&
|
|
251
|
+
s.level.background &&
|
|
252
|
+
s.level.background.imageKey === textureKey
|
|
253
|
+
) {
|
|
254
|
+
const { opacity = 0.5 } = s.level.background;
|
|
255
|
+
|
|
256
|
+
if (s.levelBackgroundImage) {
|
|
257
|
+
s.levelBackgroundImage.destroy();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
s.levelBackgroundImage = s.add.image(
|
|
261
|
+
s.boardWidth / 2,
|
|
262
|
+
s.boardHeight / 2,
|
|
263
|
+
textureKey,
|
|
264
|
+
);
|
|
265
|
+
s.levelBackgroundImage.setOrigin(0.5, 0.5);
|
|
266
|
+
s.levelBackgroundImage.setAlpha(opacity);
|
|
267
|
+
s.levelBackgroundImage.setDepth(3000);
|
|
268
|
+
|
|
269
|
+
s.boardContainer.addAt(s.levelBackgroundImage, 0);
|
|
270
|
+
|
|
271
|
+
this.resizeLevelBackgroundImage();
|
|
272
|
+
|
|
273
|
+
console.log(`[Game] 纹理创建后背景图片加载成功: ${textureKey}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ── 调整关卡背景图片尺寸 ──
|
|
278
|
+
|
|
279
|
+
/** 根据棋盘尺寸调整背景图片的缩放和位置。 */
|
|
280
|
+
resizeLevelBackgroundImage(): void {
|
|
281
|
+
const s = this.scene;
|
|
282
|
+
if (!s.levelBackgroundImage) return;
|
|
283
|
+
|
|
284
|
+
const scaleX = s.boardWidth / s.levelBackgroundImage.width;
|
|
285
|
+
const scaleY = s.boardHeight / s.levelBackgroundImage.height;
|
|
286
|
+
|
|
287
|
+
s.levelBackgroundImage.setScale(scaleX, scaleY);
|
|
288
|
+
s.levelBackgroundImage.setPosition(s.boardWidth / 2, s.boardHeight / 2);
|
|
289
|
+
s.levelBackgroundImage.setOrigin(0.5, 0.5);
|
|
290
|
+
|
|
291
|
+
if (
|
|
292
|
+
s.boardContainer &&
|
|
293
|
+
s.levelBackgroundImage.parentContainer !== s.boardContainer
|
|
294
|
+
) {
|
|
295
|
+
s.boardContainer.addAt(s.levelBackgroundImage, 0);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ── 重新布局棋盘 ──
|
|
300
|
+
|
|
301
|
+
/** 重新布局整个棋盘,包括背景颜色、棋盘构建和提示覆盖层。 */
|
|
302
|
+
relayoutBoard(): void {
|
|
303
|
+
const s = this.scene;
|
|
304
|
+
if (!s.level) return;
|
|
305
|
+
|
|
306
|
+
// 重置背景颜色和相机大小
|
|
307
|
+
const themeManager = ThemeManager.instance;
|
|
308
|
+
const bgColor = themeManager.getBackgroundColorNumber();
|
|
309
|
+
const finalBgColor =
|
|
310
|
+
GAME_CANVAS_BACKGROUND_COLOR >= 0
|
|
311
|
+
? GAME_CANVAS_BACKGROUND_COLOR
|
|
312
|
+
: bgColor;
|
|
313
|
+
s.cameras.main.setBackgroundColor(finalBgColor);
|
|
314
|
+
|
|
315
|
+
// 更新背景矩形
|
|
316
|
+
const { width, height } = s.scale;
|
|
317
|
+
if (s.backgroundRect) {
|
|
318
|
+
s.backgroundRect.setPosition(width / 2, height / 2);
|
|
319
|
+
s.backgroundRect.setSize(width, height);
|
|
320
|
+
s.backgroundRect.setFillStyle(finalBgColor);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
this.buildBoard(s.level);
|
|
324
|
+
s.renderHintOverlay();
|
|
325
|
+
|
|
326
|
+
// 更新进度百分比
|
|
327
|
+
if (s.topUI) {
|
|
328
|
+
const totalPaths = s.level.paths.length;
|
|
329
|
+
s.topUI.updateProgress(s.removedPaths.size, totalPaths);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ── 定位棋盘容器 ──
|
|
334
|
+
|
|
335
|
+
/** 根据缩放和偏移量定位棋盘容器,并约束拖拽范围。 */
|
|
336
|
+
positionBoardContainer(): void {
|
|
337
|
+
const s = this.scene;
|
|
338
|
+
if (!s.boardContainer) return;
|
|
339
|
+
const width = s.scale.width;
|
|
340
|
+
const height = s.scale.height;
|
|
341
|
+
const isLandscape = width > height;
|
|
342
|
+
const scaledWidth = s.boardWidth * s.zoom;
|
|
343
|
+
const scaledHeight = s.boardHeight * s.zoom;
|
|
344
|
+
|
|
345
|
+
s.boardContainer.setScale(s.zoom);
|
|
346
|
+
|
|
347
|
+
// 计算顶部和底部UI高度(必须与 buildBoard 一致)
|
|
348
|
+
const BASE_HEIGHT = 1334;
|
|
349
|
+
const scaleY = height / BASE_HEIGHT;
|
|
350
|
+
|
|
351
|
+
let topOffset: number;
|
|
352
|
+
let bottomOffset: number;
|
|
353
|
+
|
|
354
|
+
if (isLandscape) {
|
|
355
|
+
topOffset = 55;
|
|
356
|
+
bottomOffset = 45;
|
|
357
|
+
} else {
|
|
358
|
+
topOffset = GAME_TOP_UI_BAR_HEIGHT * scaleY;
|
|
359
|
+
bottomOffset = GameConfig.GAME_BOTTOM_UI_BAR_HEIGHT * scaleY;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const availableHeight = height - topOffset - bottomOffset;
|
|
363
|
+
|
|
364
|
+
const baseX = (width - scaledWidth) / 2;
|
|
365
|
+
// Ensure the board never overlaps the top UI bar
|
|
366
|
+
const rawBaseY = topOffset + (availableHeight - scaledHeight) / 2;
|
|
367
|
+
const baseY = Math.max(topOffset, rawBaseY);
|
|
368
|
+
let x = baseX + s.boardOffsetX;
|
|
369
|
+
let y = baseY + s.boardOffsetY;
|
|
370
|
+
|
|
371
|
+
// 约束拖拽范围
|
|
372
|
+
const marginX = width * BOARD_PAN_MARGIN_RATIO;
|
|
373
|
+
const marginY = availableHeight * BOARD_PAN_MARGIN_RATIO;
|
|
374
|
+
|
|
375
|
+
// 水平方向
|
|
376
|
+
if (scaledWidth + 2 * marginX <= width) {
|
|
377
|
+
x = baseX;
|
|
378
|
+
s.boardOffsetX = 0;
|
|
379
|
+
} else {
|
|
380
|
+
const minX = width - marginX - scaledWidth;
|
|
381
|
+
const maxX = marginX;
|
|
382
|
+
if (minX > maxX) {
|
|
383
|
+
x = baseX;
|
|
384
|
+
s.boardOffsetX = 0;
|
|
385
|
+
} else if (x < minX) {
|
|
386
|
+
x = minX;
|
|
387
|
+
s.boardOffsetX = x - baseX;
|
|
388
|
+
} else if (x > maxX) {
|
|
389
|
+
x = maxX;
|
|
390
|
+
s.boardOffsetX = x - baseX;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// 垂直方向
|
|
395
|
+
if (scaledHeight + 2 * marginY <= availableHeight) {
|
|
396
|
+
y = baseY;
|
|
397
|
+
s.boardOffsetY = 0;
|
|
398
|
+
} else {
|
|
399
|
+
const minY = height - marginY - scaledHeight;
|
|
400
|
+
const maxY = topOffset + marginY;
|
|
401
|
+
if (minY > maxY) {
|
|
402
|
+
y = baseY;
|
|
403
|
+
s.boardOffsetY = 0;
|
|
404
|
+
} else if (y < minY) {
|
|
405
|
+
y = minY;
|
|
406
|
+
s.boardOffsetY = y - baseY;
|
|
407
|
+
} else if (y > maxY) {
|
|
408
|
+
y = maxY;
|
|
409
|
+
s.boardOffsetY = y - baseY;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
s.boardContainer.x = x;
|
|
414
|
+
s.boardContainer.y = y;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { computeBoardLayout, type BoardLayoutParams, type BoardLayoutResult } from "./BoardLayoutMath";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Three.js 3D 棋盘布局器
|
|
6
|
+
* 在 XZ 平面上布局棋盘,Y=0 为地面。
|
|
7
|
+
*
|
|
8
|
+
* 坐标约定:
|
|
9
|
+
* - X 向右(col 增大方向)
|
|
10
|
+
* - Z 向下(row 增大方向)— 俯视时等价于屏幕"向下"
|
|
11
|
+
* - Y 向上(物品高度)
|
|
12
|
+
*/
|
|
13
|
+
export interface BoardLayout3DResult {
|
|
14
|
+
cellSize: number; // 格子世界单位大小
|
|
15
|
+
boardWidth: number; // 棋盘总宽度(世界单位)
|
|
16
|
+
boardHeight: number; // 棋盘总高度/深度(世界单位)
|
|
17
|
+
originX: number; // 棋盘左上角 X 世界坐标
|
|
18
|
+
originZ: number; // 棋盘左上角 Z 世界坐标
|
|
19
|
+
rows: number;
|
|
20
|
+
cols: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class BoardLayout3D {
|
|
24
|
+
private layout!: BoardLayout3DResult;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 计算棋盘布局
|
|
28
|
+
* @param rows 行数
|
|
29
|
+
* @param cols 列数
|
|
30
|
+
* @param cellSize 格子大小(世界单位),默认 1.0
|
|
31
|
+
*/
|
|
32
|
+
computeLayout(rows: number, cols: number, cellSize: number = 1.0): BoardLayout3DResult {
|
|
33
|
+
const boardWidth = cols * cellSize;
|
|
34
|
+
const boardHeight = rows * cellSize;
|
|
35
|
+
|
|
36
|
+
// 以原点为棋盘中心
|
|
37
|
+
const originX = -boardWidth / 2;
|
|
38
|
+
const originZ = -boardHeight / 2;
|
|
39
|
+
|
|
40
|
+
this.layout = {
|
|
41
|
+
cellSize,
|
|
42
|
+
boardWidth,
|
|
43
|
+
boardHeight,
|
|
44
|
+
originX,
|
|
45
|
+
originZ,
|
|
46
|
+
rows,
|
|
47
|
+
cols,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return this.layout;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 获取格子中心的世界坐标
|
|
55
|
+
* @param col 列号(0-indexed)
|
|
56
|
+
* @param row 行号(0-indexed)
|
|
57
|
+
* @returns 世界坐标 { x, y, z }
|
|
58
|
+
*/
|
|
59
|
+
getCellWorldPos(col: number, row: number): THREE.Vector3 {
|
|
60
|
+
const { cellSize, originX, originZ } = this.layout;
|
|
61
|
+
return new THREE.Vector3(
|
|
62
|
+
originX + col * cellSize + cellSize / 2,
|
|
63
|
+
0,
|
|
64
|
+
originZ + row * cellSize + cellSize / 2
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 获取棋盘中心世界坐标
|
|
70
|
+
*/
|
|
71
|
+
getBoardCenter(): THREE.Vector3 {
|
|
72
|
+
return new THREE.Vector3(0, 0, 0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 世界坐标 → 格子坐标
|
|
77
|
+
* @returns { col, row } 或 null(如果超出棋盘范围)
|
|
78
|
+
*/
|
|
79
|
+
worldToCell(worldX: number, worldZ: number): { col: number; row: number } | null {
|
|
80
|
+
const { cellSize, originX, originZ, rows, cols } = this.layout;
|
|
81
|
+
const col = Math.floor((worldX - originX) / cellSize);
|
|
82
|
+
const row = Math.floor((worldZ - originZ) / cellSize);
|
|
83
|
+
|
|
84
|
+
if (col < 0 || col >= cols || row < 0 || row >= rows) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return { col, row };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 计算格子索引(row-major)
|
|
92
|
+
*/
|
|
93
|
+
cellToIndex(col: number, row: number): number {
|
|
94
|
+
return row * this.layout.cols + col;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 获取棋盘边界(用于确定哪些格子在边缘)
|
|
99
|
+
*/
|
|
100
|
+
isOnEdge(col: number, row: number): boolean {
|
|
101
|
+
const { rows, cols } = this.layout;
|
|
102
|
+
return col === 0 || col === cols - 1 || row === 0 || row === rows - 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 计算从某格子到棋盘边缘的步数(沿指定方向)
|
|
107
|
+
*/
|
|
108
|
+
stepsToEdge(col: number, row: number, dx: number, dz: number): number {
|
|
109
|
+
const { rows, cols } = this.layout;
|
|
110
|
+
let steps = 0;
|
|
111
|
+
let c = col + dx;
|
|
112
|
+
let r = row + dz;
|
|
113
|
+
while (c >= 0 && c < cols && r >= 0 && r < rows) {
|
|
114
|
+
steps++;
|
|
115
|
+
c += dx;
|
|
116
|
+
r += dz;
|
|
117
|
+
}
|
|
118
|
+
return steps + 1; // +1 for exiting the board
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** 获取当前布局结果 */
|
|
122
|
+
getLayout(): BoardLayout3DResult {
|
|
123
|
+
return this.layout;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 棋盘布局纯数学核心(引擎无关)
|
|
3
|
+
* 给定棋盘行列数和可用空间,计算格子大小和偏移。
|
|
4
|
+
* Phaser 版和 Three.js 版都可以引用此模块。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface BoardLayoutParams {
|
|
8
|
+
rows: number;
|
|
9
|
+
cols: number;
|
|
10
|
+
availableWidth: number;
|
|
11
|
+
availableHeight: number;
|
|
12
|
+
marginRatio?: number; // 边距比例,默认 0.07
|
|
13
|
+
spacingMultiplier?: number; // 格子间距放大系数,默认 1.15
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BoardLayoutResult {
|
|
17
|
+
cellSize: number; // 基础格子大小
|
|
18
|
+
cellWidth: number; // 实际格子宽度(含间距)
|
|
19
|
+
cellHeight: number; // 实际格子高度(含间距)
|
|
20
|
+
boardWidth: number; // 棋盘总宽度
|
|
21
|
+
boardHeight: number; // 棋盘总高度
|
|
22
|
+
offsetX: number; // 棋盘左上角 X 偏移(居中)
|
|
23
|
+
offsetY: number; // 棋盘左上角 Y 偏移(居中)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 计算棋盘布局(纯数学,零引擎依赖)
|
|
28
|
+
*/
|
|
29
|
+
export function computeBoardLayout(params: BoardLayoutParams): BoardLayoutResult {
|
|
30
|
+
const {
|
|
31
|
+
rows,
|
|
32
|
+
cols,
|
|
33
|
+
availableWidth,
|
|
34
|
+
availableHeight,
|
|
35
|
+
marginRatio = 0.07,
|
|
36
|
+
spacingMultiplier = 1.15,
|
|
37
|
+
} = params;
|
|
38
|
+
|
|
39
|
+
const usableWidth = availableWidth * (1 - 2 * marginRatio);
|
|
40
|
+
const usableHeight = availableHeight * (1 - 2 * marginRatio);
|
|
41
|
+
|
|
42
|
+
// 计算基础格子大小(取宽高中更受限的方向)
|
|
43
|
+
const baseSize = Math.max(
|
|
44
|
+
4,
|
|
45
|
+
Math.floor(Math.min(usableWidth / cols, usableHeight / rows))
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
// 应用间距系数
|
|
49
|
+
const cellWidth = Math.floor(baseSize * spacingMultiplier);
|
|
50
|
+
const cellHeight = cellWidth; // 正方形格子
|
|
51
|
+
|
|
52
|
+
const boardWidth = cellWidth * cols;
|
|
53
|
+
const boardHeight = cellHeight * rows;
|
|
54
|
+
|
|
55
|
+
// 居中偏移
|
|
56
|
+
const offsetX = (availableWidth - boardWidth) / 2;
|
|
57
|
+
const offsetY = (availableHeight - boardHeight) / 2;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
cellSize: baseSize,
|
|
61
|
+
cellWidth,
|
|
62
|
+
cellHeight,
|
|
63
|
+
boardWidth,
|
|
64
|
+
boardHeight,
|
|
65
|
+
offsetX,
|
|
66
|
+
offsetY,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 计算格子中心坐标(基于偏移和格子大小)
|
|
72
|
+
*/
|
|
73
|
+
export function getCellCenter(
|
|
74
|
+
col: number,
|
|
75
|
+
row: number,
|
|
76
|
+
cellWidth: number,
|
|
77
|
+
cellHeight: number,
|
|
78
|
+
offsetX: number,
|
|
79
|
+
offsetY: number
|
|
80
|
+
): { x: number; y: number } {
|
|
81
|
+
return {
|
|
82
|
+
x: offsetX + col * cellWidth + cellWidth / 2,
|
|
83
|
+
y: offsetY + row * cellHeight + cellHeight / 2,
|
|
84
|
+
};
|
|
85
|
+
}
|