@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,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"atomId": "tray_container.aicomponent",
|
|
4
|
+
"bundleType": "aicomponent",
|
|
5
|
+
"category": "ui",
|
|
6
|
+
"mode": "fixed",
|
|
7
|
+
"label": {
|
|
8
|
+
"zh": "底部篮子/托盘容器",
|
|
9
|
+
"en": "Bottom tray container (slot-based)"
|
|
10
|
+
},
|
|
11
|
+
"tags": ["ui", "tray", "basket", "container", "slot", "collect", "match-3", "pick-and-match", "threejs", "html-overlay", "3d"],
|
|
12
|
+
"bindingRoles": ["trayContainer"],
|
|
13
|
+
"renderModes": ["phaser-sprite", "html-overlay", "threejs-mesh"],
|
|
14
|
+
"engineVariants": {
|
|
15
|
+
"phaser": {
|
|
16
|
+
"imports": ["phaser.aicomponent"],
|
|
17
|
+
"scaffoldFiles": {
|
|
18
|
+
"src/game/ui/TrayRenderer.ts": { "source": "ref/TrayRenderer.ts", "mode": "full", "weight": 10 }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"threejs": {
|
|
22
|
+
"imports": ["threejs.aicomponent"],
|
|
23
|
+
"scaffoldFiles": {
|
|
24
|
+
"src/game/ui/TrayRendererHtmlOverlay.ts": { "source": "ref/TrayRendererHtmlOverlay.ts", "mode": "full", "weight": 10 },
|
|
25
|
+
"src/game/ui/TrayRenderer3D.ts": { "source": "ref/TrayRenderer3D.ts", "mode": "full", "weight": 10 }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"imports": [
|
|
30
|
+
{ "slot": "engine", "pinAtomId": "phaser.aicomponent", "edgeKind": "requires", "bindAs": "engine" }
|
|
31
|
+
],
|
|
32
|
+
"binding": {
|
|
33
|
+
"role": "trayContainer",
|
|
34
|
+
"target": "src/game/ui/TrayRenderer.ts",
|
|
35
|
+
"type": "code-module-reference"
|
|
36
|
+
},
|
|
37
|
+
"exports": [
|
|
38
|
+
{ "name": "TrayRenderer", "kind": "class", "location": "src/game/ui/TrayRenderer.ts" },
|
|
39
|
+
{ "name": "TrayRendererHtmlOverlay", "kind": "class", "location": "src/game/ui/TrayRendererHtmlOverlay.ts" },
|
|
40
|
+
{ "name": "TrayRenderer3D", "kind": "class", "location": "src/game/ui/TrayRenderer3D.ts" }
|
|
41
|
+
],
|
|
42
|
+
"neutralDescriptor": {
|
|
43
|
+
"geometry": "N-slot container for collected items with grouping insert, match elimination animation, overflow shake feedback",
|
|
44
|
+
"layers": ["ui-layout", "animation", "item-management"],
|
|
45
|
+
"replaceable": ["capacity", "slot size", "animation durations", "render mode (phaser/html/3d)"]
|
|
46
|
+
},
|
|
47
|
+
"usageHints": [
|
|
48
|
+
"支持三种渲染模式:phaser-sprite(Phaser 场景内)、html-overlay(CSS DOM 覆盖层)、threejs-mesh(3D 场景内)",
|
|
49
|
+
"html-overlay 推荐用于 Three.js 项目的 UI 层——不占用 WebGL 管线,CSS transition 动画流畅",
|
|
50
|
+
"threejs-mesh 用于需要完全沉浸式 3D 体验的项目——物品在场景内以 Mesh 呈现",
|
|
51
|
+
"三种模式接口一致:setup/getSlotPos/addItem/rearrangeItems/removeMatchedItems/shake/destroy",
|
|
52
|
+
"TrayRenderer3D.update(dt) 需要在 onUpdate 中每帧调用以驱动动画"
|
|
53
|
+
],
|
|
54
|
+
"files": {
|
|
55
|
+
"skill": "SKILL.md",
|
|
56
|
+
"ref": ["ref/TrayRenderer.ts", "ref/TrayRendererHtmlOverlay.ts", "ref/TrayRenderer3D.ts"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as Phaser from "phaser";
|
|
2
|
+
import type { TrayItem } from "../logic/types";
|
|
3
|
+
import { colorToTextureKey } from "../logic/types";
|
|
4
|
+
import { GameConfig } from "../GameConfig";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 底部篮子(Tray)渲染器
|
|
8
|
+
* 显示已收集的汽车,支持插入/消除动画
|
|
9
|
+
*/
|
|
10
|
+
export class TrayRenderer {
|
|
11
|
+
private scene: Phaser.Scene;
|
|
12
|
+
private container!: Phaser.GameObjects.Container;
|
|
13
|
+
private bgGraphics!: Phaser.GameObjects.Graphics;
|
|
14
|
+
private sprites: Map<string, Phaser.GameObjects.Image> = new Map();
|
|
15
|
+
|
|
16
|
+
// 布局参数
|
|
17
|
+
private trayX = 0;
|
|
18
|
+
private trayY = 0;
|
|
19
|
+
private trayWidth = 0;
|
|
20
|
+
private trayHeight = 0;
|
|
21
|
+
private slotWidth = 0;
|
|
22
|
+
private capacity = 7;
|
|
23
|
+
|
|
24
|
+
constructor(scene: Phaser.Scene) {
|
|
25
|
+
this.scene = scene;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setup(
|
|
29
|
+
areaRect: { x: number; y: number; width: number; height: number },
|
|
30
|
+
capacity: number,
|
|
31
|
+
): void {
|
|
32
|
+
this.capacity = capacity;
|
|
33
|
+
this.trayX = areaRect.x;
|
|
34
|
+
this.trayY = areaRect.y;
|
|
35
|
+
this.trayWidth = areaRect.width;
|
|
36
|
+
this.trayHeight = areaRect.height;
|
|
37
|
+
this.slotWidth = this.trayWidth / capacity;
|
|
38
|
+
|
|
39
|
+
this.container = this.scene.add.container(0, 0);
|
|
40
|
+
|
|
41
|
+
this.bgGraphics = this.scene.add.graphics();
|
|
42
|
+
this.drawBackground();
|
|
43
|
+
this.container.add(this.bgGraphics);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private drawBackground(): void {
|
|
47
|
+
const g = this.bgGraphics;
|
|
48
|
+
g.clear();
|
|
49
|
+
|
|
50
|
+
g.fillStyle(0x16213e, 0.9);
|
|
51
|
+
g.fillRoundedRect(this.trayX, this.trayY, this.trayWidth, this.trayHeight, 12);
|
|
52
|
+
|
|
53
|
+
g.lineStyle(1, 0x3d3d5c, 0.5);
|
|
54
|
+
for (let i = 1; i < this.capacity; i++) {
|
|
55
|
+
const x = this.trayX + i * this.slotWidth;
|
|
56
|
+
g.beginPath();
|
|
57
|
+
g.moveTo(x, this.trayY + 8);
|
|
58
|
+
g.lineTo(x, this.trayY + this.trayHeight - 8);
|
|
59
|
+
g.strokePath();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getSlotWorldPos(index: number): { x: number; y: number } {
|
|
64
|
+
return {
|
|
65
|
+
x: this.trayX + index * this.slotWidth + this.slotWidth / 2,
|
|
66
|
+
y: this.trayY + this.trayHeight / 2,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
addItemSprite(item: TrayItem, index: number): Phaser.GameObjects.Image {
|
|
71
|
+
const pos = this.getSlotWorldPos(index);
|
|
72
|
+
const textureKey = colorToTextureKey(item.color);
|
|
73
|
+
const targetSize = Math.min(this.slotWidth * 0.7, this.trayHeight * 0.7);
|
|
74
|
+
|
|
75
|
+
const sprite = this.scene.add.image(pos.x, pos.y, textureKey);
|
|
76
|
+
sprite.setOrigin(0.5);
|
|
77
|
+
const scale = Math.min(targetSize / sprite.width, targetSize / sprite.height);
|
|
78
|
+
sprite.setScale(scale);
|
|
79
|
+
|
|
80
|
+
this.container.add(sprite);
|
|
81
|
+
this.sprites.set(item.id, sprite);
|
|
82
|
+
|
|
83
|
+
return sprite;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
rearrangeItems(tray: TrayItem[], animate: boolean = true): void {
|
|
87
|
+
for (let i = 0; i < tray.length; i++) {
|
|
88
|
+
const item = tray[i];
|
|
89
|
+
const sprite = this.sprites.get(item.id);
|
|
90
|
+
if (!sprite) continue;
|
|
91
|
+
|
|
92
|
+
const pos = this.getSlotWorldPos(i);
|
|
93
|
+
if (animate) {
|
|
94
|
+
this.scene.tweens.add({
|
|
95
|
+
targets: sprite,
|
|
96
|
+
x: pos.x,
|
|
97
|
+
y: pos.y,
|
|
98
|
+
duration: 200,
|
|
99
|
+
ease: "Power2",
|
|
100
|
+
});
|
|
101
|
+
} else {
|
|
102
|
+
sprite.setPosition(pos.x, pos.y);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
removeMatchedItems(matchedIds: string[], onComplete: () => void): void {
|
|
108
|
+
let completed = 0;
|
|
109
|
+
const total = matchedIds.length;
|
|
110
|
+
|
|
111
|
+
for (const id of matchedIds) {
|
|
112
|
+
const sprite = this.sprites.get(id);
|
|
113
|
+
if (!sprite) {
|
|
114
|
+
completed++;
|
|
115
|
+
if (completed >= total) onComplete();
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this.scene.tweens.add({
|
|
120
|
+
targets: sprite,
|
|
121
|
+
scaleX: sprite.scaleX * 1.3,
|
|
122
|
+
scaleY: sprite.scaleY * 1.3,
|
|
123
|
+
alpha: 0,
|
|
124
|
+
duration: GameConfig.MATCH_DURATION,
|
|
125
|
+
ease: "Power2",
|
|
126
|
+
onComplete: () => {
|
|
127
|
+
sprite.destroy();
|
|
128
|
+
this.sprites.delete(id);
|
|
129
|
+
completed++;
|
|
130
|
+
if (completed >= total) onComplete();
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
shake(): void {
|
|
137
|
+
const originalX = this.container.x;
|
|
138
|
+
this.scene.tweens.add({
|
|
139
|
+
targets: this.container,
|
|
140
|
+
x: originalX + 8,
|
|
141
|
+
duration: 50,
|
|
142
|
+
yoyo: true,
|
|
143
|
+
repeat: 5,
|
|
144
|
+
ease: "Sine.inOut",
|
|
145
|
+
onComplete: () => {
|
|
146
|
+
this.container.x = originalX;
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
destroy(): void {
|
|
152
|
+
this.container?.destroy();
|
|
153
|
+
this.sprites.clear();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
|
|
3
|
+
export interface TrayItem3D {
|
|
4
|
+
id: string;
|
|
5
|
+
color: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TrayConfig3D {
|
|
9
|
+
capacity: number;
|
|
10
|
+
cellSize: number; // 棋盘格子大小(用于计算篮子尺寸)
|
|
11
|
+
matchDuration?: number; // 消除动画时长 ms,默认 300
|
|
12
|
+
rearrangeDuration?: number; // 重排动画时长 ms,默认 200
|
|
13
|
+
shakeIntensity?: number; // 抖动强度,默认 0.1
|
|
14
|
+
colorToHex: (color: string) => number; // 颜色标识 → Three.js hex 颜色
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Three.js 场景内 Mesh 模式的篮子/托盘渲染器。
|
|
19
|
+
* 在 3D 场景中用 Mesh 排列表示收集的物品。
|
|
20
|
+
* 适用于需要完全沉浸式 3D 体验的项目。
|
|
21
|
+
*/
|
|
22
|
+
export class TrayRenderer3D {
|
|
23
|
+
private scene: THREE.Scene;
|
|
24
|
+
private config: Required<TrayConfig3D>;
|
|
25
|
+
private group!: THREE.Group;
|
|
26
|
+
private bgMesh!: THREE.Mesh;
|
|
27
|
+
private items: Map<string, THREE.Mesh> = new Map();
|
|
28
|
+
private slotPositions: THREE.Vector3[] = [];
|
|
29
|
+
|
|
30
|
+
// 动画状态
|
|
31
|
+
private animations: Array<{
|
|
32
|
+
mesh: THREE.Mesh;
|
|
33
|
+
startPos: THREE.Vector3;
|
|
34
|
+
endPos: THREE.Vector3;
|
|
35
|
+
startScale: number;
|
|
36
|
+
endScale: number;
|
|
37
|
+
startOpacity: number;
|
|
38
|
+
endOpacity: number;
|
|
39
|
+
elapsed: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
onComplete?: () => void;
|
|
42
|
+
}> = [];
|
|
43
|
+
|
|
44
|
+
// 震动状态
|
|
45
|
+
private shakeElapsed = 0;
|
|
46
|
+
private shakeDuration = 0;
|
|
47
|
+
private baseGroupX = 0;
|
|
48
|
+
|
|
49
|
+
constructor(scene: THREE.Scene, config: TrayConfig3D) {
|
|
50
|
+
this.scene = scene;
|
|
51
|
+
this.config = {
|
|
52
|
+
capacity: config.capacity,
|
|
53
|
+
cellSize: config.cellSize,
|
|
54
|
+
matchDuration: config.matchDuration ?? 300,
|
|
55
|
+
rearrangeDuration: config.rearrangeDuration ?? 200,
|
|
56
|
+
shakeIntensity: config.shakeIntensity ?? 0.1,
|
|
57
|
+
colorToHex: config.colorToHex,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 初始化篮子:创建背景和槽位
|
|
63
|
+
* @param position 篮子中心的世界坐标
|
|
64
|
+
*/
|
|
65
|
+
setup(position: THREE.Vector3): void {
|
|
66
|
+
this.group = new THREE.Group();
|
|
67
|
+
this.group.position.copy(position);
|
|
68
|
+
this.baseGroupX = position.x;
|
|
69
|
+
|
|
70
|
+
const slotSize = this.config.cellSize * 0.6;
|
|
71
|
+
const gap = slotSize * 0.2;
|
|
72
|
+
const totalWidth = this.config.capacity * slotSize + (this.config.capacity - 1) * gap;
|
|
73
|
+
const height = slotSize * 1.2;
|
|
74
|
+
|
|
75
|
+
// 创建背景板
|
|
76
|
+
const bgGeo = new THREE.BoxGeometry(totalWidth + slotSize * 0.4, 0.1, height);
|
|
77
|
+
const bgMat = new THREE.MeshStandardMaterial({
|
|
78
|
+
color: 0x16213e,
|
|
79
|
+
transparent: true,
|
|
80
|
+
opacity: 0.9,
|
|
81
|
+
roughness: 0.8,
|
|
82
|
+
});
|
|
83
|
+
this.bgMesh = new THREE.Mesh(bgGeo, bgMat);
|
|
84
|
+
this.bgMesh.position.y = -0.05;
|
|
85
|
+
this.bgMesh.receiveShadow = true;
|
|
86
|
+
this.group.add(this.bgMesh);
|
|
87
|
+
|
|
88
|
+
// 计算每个槽位的局部位置
|
|
89
|
+
const startX = -(totalWidth / 2) + slotSize / 2;
|
|
90
|
+
for (let i = 0; i < this.config.capacity; i++) {
|
|
91
|
+
const x = startX + i * (slotSize + gap);
|
|
92
|
+
this.slotPositions.push(new THREE.Vector3(x, slotSize * 0.3, 0));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.scene.add(this.group);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 获取指定槽位的世界坐标
|
|
100
|
+
*/
|
|
101
|
+
getSlotWorldPos(index: number): THREE.Vector3 {
|
|
102
|
+
if (index < 0 || index >= this.slotPositions.length) {
|
|
103
|
+
return this.group.position.clone();
|
|
104
|
+
}
|
|
105
|
+
const local = this.slotPositions[index];
|
|
106
|
+
return local.clone().applyMatrix4(this.group.matrixWorld);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 添加物品到指定槽位
|
|
111
|
+
*/
|
|
112
|
+
addItem(item: TrayItem3D, index: number): THREE.Mesh {
|
|
113
|
+
const slotSize = this.config.cellSize * 0.6;
|
|
114
|
+
const itemSize = slotSize * 0.7;
|
|
115
|
+
|
|
116
|
+
// 创建物品 Mesh(球体表示)
|
|
117
|
+
const geo = new THREE.SphereGeometry(itemSize / 2, 16, 12);
|
|
118
|
+
const mat = new THREE.MeshStandardMaterial({
|
|
119
|
+
color: this.config.colorToHex(item.color),
|
|
120
|
+
transparent: true,
|
|
121
|
+
opacity: 1,
|
|
122
|
+
roughness: 0.4,
|
|
123
|
+
metalness: 0.1,
|
|
124
|
+
});
|
|
125
|
+
const mesh = new THREE.Mesh(geo, mat);
|
|
126
|
+
mesh.castShadow = true;
|
|
127
|
+
|
|
128
|
+
// 设置到目标槽位
|
|
129
|
+
const targetPos = this.slotPositions[index] || new THREE.Vector3();
|
|
130
|
+
mesh.position.copy(targetPos);
|
|
131
|
+
mesh.scale.setScalar(0); // 初始缩放为 0(弹入动画)
|
|
132
|
+
|
|
133
|
+
this.group.add(mesh);
|
|
134
|
+
this.items.set(item.id, mesh);
|
|
135
|
+
|
|
136
|
+
// 弹入动画
|
|
137
|
+
this.animations.push({
|
|
138
|
+
mesh,
|
|
139
|
+
startPos: targetPos.clone(),
|
|
140
|
+
endPos: targetPos.clone(),
|
|
141
|
+
startScale: 0,
|
|
142
|
+
endScale: 1,
|
|
143
|
+
startOpacity: 1,
|
|
144
|
+
endOpacity: 1,
|
|
145
|
+
elapsed: 0,
|
|
146
|
+
duration: this.config.rearrangeDuration / 1000,
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return mesh;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 重新排列所有物品到正确位置
|
|
154
|
+
*/
|
|
155
|
+
rearrangeItems(tray: TrayItem3D[]): void {
|
|
156
|
+
for (let i = 0; i < tray.length; i++) {
|
|
157
|
+
const mesh = this.items.get(tray[i].id);
|
|
158
|
+
if (!mesh) continue;
|
|
159
|
+
|
|
160
|
+
const targetPos = this.slotPositions[i];
|
|
161
|
+
if (!targetPos) continue;
|
|
162
|
+
|
|
163
|
+
// 如果位置已经正确,跳过
|
|
164
|
+
if (mesh.position.distanceTo(targetPos) < 0.001) continue;
|
|
165
|
+
|
|
166
|
+
this.animations.push({
|
|
167
|
+
mesh,
|
|
168
|
+
startPos: mesh.position.clone(),
|
|
169
|
+
endPos: targetPos.clone(),
|
|
170
|
+
startScale: 1,
|
|
171
|
+
endScale: 1,
|
|
172
|
+
startOpacity: 1,
|
|
173
|
+
endOpacity: 1,
|
|
174
|
+
elapsed: 0,
|
|
175
|
+
duration: this.config.rearrangeDuration / 1000,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 消除匹配的物品(放大 + 淡出)
|
|
182
|
+
*/
|
|
183
|
+
removeMatchedItems(matchedIds: string[], onComplete: () => void): void {
|
|
184
|
+
let completed = 0;
|
|
185
|
+
const total = matchedIds.length;
|
|
186
|
+
|
|
187
|
+
for (const id of matchedIds) {
|
|
188
|
+
const mesh = this.items.get(id);
|
|
189
|
+
if (!mesh) {
|
|
190
|
+
completed++;
|
|
191
|
+
if (completed >= total) onComplete();
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.animations.push({
|
|
196
|
+
mesh,
|
|
197
|
+
startPos: mesh.position.clone(),
|
|
198
|
+
endPos: mesh.position.clone(),
|
|
199
|
+
startScale: 1,
|
|
200
|
+
endScale: 1.5,
|
|
201
|
+
startOpacity: 1,
|
|
202
|
+
endOpacity: 0,
|
|
203
|
+
elapsed: 0,
|
|
204
|
+
duration: this.config.matchDuration / 1000,
|
|
205
|
+
onComplete: () => {
|
|
206
|
+
this.group.remove(mesh);
|
|
207
|
+
mesh.geometry.dispose();
|
|
208
|
+
(mesh.material as THREE.Material).dispose();
|
|
209
|
+
this.items.delete(id);
|
|
210
|
+
completed++;
|
|
211
|
+
if (completed >= total) onComplete();
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 满溢抖动
|
|
219
|
+
*/
|
|
220
|
+
shake(): void {
|
|
221
|
+
this.shakeElapsed = 0;
|
|
222
|
+
this.shakeDuration = 0.3; // 300ms
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 每帧更新(处理动画和震动)
|
|
227
|
+
* @param dt 帧间隔时间(秒)
|
|
228
|
+
*/
|
|
229
|
+
update(dt: number): void {
|
|
230
|
+
// 更新物品动画
|
|
231
|
+
for (let i = this.animations.length - 1; i >= 0; i--) {
|
|
232
|
+
const anim = this.animations[i];
|
|
233
|
+
anim.elapsed += dt;
|
|
234
|
+
const t = Math.min(anim.elapsed / anim.duration, 1);
|
|
235
|
+
// easeOutBack for scale, easeOut for position
|
|
236
|
+
const easeT = 1 - Math.pow(1 - t, 3);
|
|
237
|
+
|
|
238
|
+
anim.mesh.position.lerpVectors(anim.startPos, anim.endPos, easeT);
|
|
239
|
+
const scale = anim.startScale + (anim.endScale - anim.startScale) * easeT;
|
|
240
|
+
anim.mesh.scale.setScalar(scale);
|
|
241
|
+
|
|
242
|
+
const mat = anim.mesh.material as THREE.MeshStandardMaterial;
|
|
243
|
+
if (mat.transparent) {
|
|
244
|
+
mat.opacity = anim.startOpacity + (anim.endOpacity - anim.startOpacity) * easeT;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (t >= 1) {
|
|
248
|
+
anim.onComplete?.();
|
|
249
|
+
this.animations.splice(i, 1);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// 更新震动
|
|
254
|
+
if (this.shakeElapsed < this.shakeDuration) {
|
|
255
|
+
this.shakeElapsed += dt;
|
|
256
|
+
const progress = this.shakeElapsed / this.shakeDuration;
|
|
257
|
+
const decay = 1 - progress;
|
|
258
|
+
const offset = Math.sin(progress * Math.PI * 6) * this.config.shakeIntensity * decay;
|
|
259
|
+
this.group.position.x = this.baseGroupX + offset;
|
|
260
|
+
} else if (this.group.position.x !== this.baseGroupX) {
|
|
261
|
+
this.group.position.x = this.baseGroupX;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 销毁所有资源
|
|
267
|
+
*/
|
|
268
|
+
destroy(): void {
|
|
269
|
+
this.items.forEach((mesh) => {
|
|
270
|
+
mesh.geometry.dispose();
|
|
271
|
+
(mesh.material as THREE.Material).dispose();
|
|
272
|
+
});
|
|
273
|
+
this.items.clear();
|
|
274
|
+
this.animations = [];
|
|
275
|
+
if (this.bgMesh) {
|
|
276
|
+
this.bgMesh.geometry.dispose();
|
|
277
|
+
(this.bgMesh.material as THREE.Material).dispose();
|
|
278
|
+
}
|
|
279
|
+
this.scene.remove(this.group);
|
|
280
|
+
}
|
|
281
|
+
}
|