chore: freeze v1.1.3 filing submission build (60 levels, full-screen safe layout)
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"cocos-mayi-coco-cc2403": {
|
||||||
|
"serverUrl": "http://127.0.0.1:22301/mcp/project/cc2403ad1b1e051ad7e48b42/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 2,
|
||||||
|
"skillId": "cocos-mcp-workflow",
|
||||||
|
"skillName": "funplay-cocos-mcp-workflow",
|
||||||
|
"templateVersion": 4,
|
||||||
|
"templateHash": "80d0dda747fe5ed422d851db7b550af6802bfe61289f915a4ff1b95b2c059f5a",
|
||||||
|
"installedHash": "80d0dda747fe5ed422d851db7b550af6802bfe61289f915a4ff1b95b2c059f5a",
|
||||||
|
"files": {
|
||||||
|
"SKILL.md": {
|
||||||
|
"templateHash": "80d0dda747fe5ed422d851db7b550af6802bfe61289f915a4ff1b95b2c059f5a",
|
||||||
|
"installedHash": "80d0dda747fe5ed422d851db7b550af6802bfe61289f915a4ff1b95b2c059f5a"
|
||||||
|
},
|
||||||
|
"references/project-readiness.md": {
|
||||||
|
"templateHash": "e5fb0ffc4320f6b108cc0f852124b7dd3f6f0acadd9c5d552a3f58f8ddf3b141",
|
||||||
|
"installedHash": "e5fb0ffc4320f6b108cc0f852124b7dd3f6f0acadd9c5d552a3f58f8ddf3b141"
|
||||||
|
},
|
||||||
|
"references/project-identity-and-input.md": {
|
||||||
|
"templateHash": "5d2e1490645031a8fe16fb43526f3749002b723c45b656f1ea4925c1ec5d6daa",
|
||||||
|
"installedHash": "5d2e1490645031a8fe16fb43526f3749002b723c45b656f1ea4925c1ec5d6daa"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extensionVersion": "0.7.6",
|
||||||
|
"updatedAt": "2026-11-23T08:36:02.340Z"
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
---
|
||||||
|
name: funplay-cocos-mcp-workflow
|
||||||
|
description: "Edit, inspect, validate, preview, and debug Cocos Creator projects through Funplay Cocos MCP. Use when working with scenes, nodes, prefabs, assets, TypeScript, logs, screenshots, preview behavior, runtime state, or MCP connectivity."
|
||||||
|
---
|
||||||
|
|
||||||
|
# Funplay Cocos MCP Workflow
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
## Operating Loop
|
||||||
|
|
||||||
|
1. Establish context.
|
||||||
|
- Before writes, independently match the intended project to initialize.funplay.context; do not adopt whichever server answered. For old endpoints, reconnects, or frame-paced gestures, read [project identity and input](references/project-identity-and-input.md).
|
||||||
|
- Read `cocos://project/context` or call `get_editor_state` before assuming the project, active scene, MCP URL, selection, visible windows, or tool profile.
|
||||||
|
- Inspect the active scene with `get_scene_info` and `get_hierarchy`; use `get_selection`, `list_scenes`, `list_assets`, or `list_prefabs` when identity or ownership is unclear.
|
||||||
|
- Treat user-provided node and asset names as hints. Resolve the real hierarchy path, node UUID, asset UUID, or `db://assets/...` URL before editing.
|
||||||
|
- Call `get_tool_catalog` when a required tool may be hidden by the `core`, `full`, or custom exposure profile.
|
||||||
|
2. Choose the edit surface.
|
||||||
|
- Edit TypeScript and ordinary project files with repository tools or the MCP file tools, then refresh the affected asset and run diagnostics.
|
||||||
|
- Edit live scene nodes with focused scene/component tools or `execute_javascript` using `context="scene"`; save the scene when the change must persist.
|
||||||
|
- Use `execute_javascript` with `context="editor"` for asset-db, Editor messages, project orchestration, and filesystem work that belongs in the editor process.
|
||||||
|
- Inspect prefab ownership and references before mutation. Prefer focused prefab tools, or edit a verified linked instance and apply it back through the editor workflow.
|
||||||
|
- Preserve an existing UI or gameplay prefab hierarchy and change only the necessary nodes, components, and serialized fields; do not rebuild the entire prefab unless explicitly requested.
|
||||||
|
3. Execute the smallest coherent change.
|
||||||
|
- Prefer one guarded `execute_javascript` operation for tightly related editor work, but use focused tools when they provide clearer validation or safer arguments.
|
||||||
|
- Keep JavaScript safety checks enabled unless the code and its paths were reviewed explicitly.
|
||||||
|
- Null-check every scene, node, component, asset, and filesystem lookup. Return concise structured before/after values, including stable UUIDs or asset URLs where useful.
|
||||||
|
- Save or refresh only the assets and scenes intentionally changed.
|
||||||
|
- Do not guess alternate paths, silently create replacement objects, or run self-healing fallback loops after a missing reference or unsupported editor message.
|
||||||
|
4. Read back and validate.
|
||||||
|
- Re-inspect the exact node, component, prefab instance, or asset after mutation; a successful command response alone is not proof of the final editor state.
|
||||||
|
- Run `run_script_diagnostics` or `get_script_diagnostic_context` after TypeScript changes, then use `validate_scene` and project logs before claiming success.
|
||||||
|
- For visual or runtime work, run the appropriate browser, Game View, or simulator preview and verify with runtime state, input, logs, and screenshots.
|
||||||
|
- State exactly what was verified and what still requires a native build, device, network, store, or manual check.
|
||||||
|
|
||||||
|
## Scene, Prefab, and Asset Safety
|
||||||
|
|
||||||
|
- Do not treat Cocos `.scene`, `.prefab`, or `.meta` files as ordinary text. Prefer scene-process, prefab, and asset-db operations that preserve UUID references and editor import state.
|
||||||
|
- If `edit_prefab_json` is used, target a verified prefab path and the smallest exact JSON path or literal replacement, then run `validate_prefab_references` and inspect the result.
|
||||||
|
- Before structural prefab work, call `inspect_prefab`; for scene instances, call `inspect_prefab_instance` and choose deliberately between apply and revert.
|
||||||
|
- Replacing a prefab at the same path can keep the asset UUID while changing internal object IDs and breaking serialized references, animation tracks, nested prefab links, and scene overrides.
|
||||||
|
- Inspect dependencies with `inspect_asset_dependencies` and validate them with `validate_asset_dependencies` before and after sensitive asset changes.
|
||||||
|
- Never copy a `.meta` file when duplicating an asset. Use `duplicate_prefab` or asset-db operations so the new asset receives its own UUID.
|
||||||
|
|
||||||
|
## Tool Exposure and Execution Contexts
|
||||||
|
|
||||||
|
- The default `core` profile exposes the main inspection, diagnostics, logs, screenshots, scene, asset, and unified JavaScript workflow.
|
||||||
|
- The `full` profile adds focused mutation tools for nodes, components, prefabs, UI, runtime control, input simulation, files, and project preview.
|
||||||
|
- If a named tool is unavailable under a custom profile, adapt to the exposed catalog and report the missing capability instead of pretending it ran.
|
||||||
|
- In scene context, use the Cocos runtime and scene APIs for live hierarchy and component work. In editor context, use `Editor` APIs and messages for asset-db and extension orchestration.
|
||||||
|
- Use `execute_scene_script` and `execute_editor_script` only as compatibility entrypoints; prefer `execute_javascript` with an explicit context for new workflows.
|
||||||
|
|
||||||
|
## Readiness and Preview Evidence
|
||||||
|
|
||||||
|
- For imports, scripts, preview startup, calibrated input, or persistence checks, read [project readiness](references/project-readiness.md). Do not load this conditional reference for an unrelated inspection.
|
||||||
|
- `check_asset_ready` checks stable AssetDB identity, not script compilation or runtime loading. Discover its exposure before use.
|
||||||
|
- `get_runtime_state` describes the editor Game View and toolbar, not browser/simulator runtime or edit-scene counters.
|
||||||
|
- Read `get_recent_logs` or `search_project_logs` for relevant errors. Do not clear persistent logs without explicit confirmation.
|
||||||
|
|
||||||
|
## Failure Handling
|
||||||
|
|
||||||
|
- If MCP is unreachable, limit claims to safe filesystem inspection or code edits; do not claim scene, prefab, editor, preview, or runtime verification.
|
||||||
|
- If a node lookup is ambiguous, return the matching paths and UUIDs and choose only after identifying the user-visible or prefab-owned target.
|
||||||
|
- If editor readback and serialized text disagree, trust editor and asset-db readback first and investigate whether the wrong asset, scene instance, or stale import was inspected.
|
||||||
|
- Fix diagnostics or new error logs caused by the change before visual or runtime validation.
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Project identity and frame-paced input
|
||||||
|
|
||||||
|
## Before editing through MCP
|
||||||
|
|
||||||
|
Generated connections use /mcp/project/<project-id>/ on the existing project port. Independently compare initialize.funplay.context.project_path and project_id to the user's intended project. Context metadata identifies an extension/Editor lifetime, not authentication or permission to edit another project.
|
||||||
|
|
||||||
|
Legacy / and /mcp addresses still support initialization and exposed read-only tools. Mutating tools require expected_context from that verified initialization, either as a tool argument or params._meta.expected_context. A project-scoped URL binds the project; an explicit expected_context also pins the extension/Editor instance. Missing, wrong-project, conflicting or stale pins execute nothing. Never automatically fetch a token from an arbitrary responding server just to bypass a rejection.
|
||||||
|
|
||||||
|
Prefer reconfiguration from MCP Server's existing connection/Skills notice, then reconnect or restart the client. Existing user edits remain protected. Unreadable client files need review; unrelated entries and historical shared entries are not silently deleted. A reload can invalidate the instance pin and calibrated screenshots even while the port remains the same. Read fresh identity and capture again; never replay a mutation solely to get a cleaner reply.
|
||||||
|
|
||||||
|
## Frame-paced mouse drag (Full profile)
|
||||||
|
|
||||||
|
Use this only when a drag test is requested and the originating input tool is exposed. Keep legacy timing for existing steps/stepDelayMs callers. For a new frame-paced gesture, capture the exact target, use coordinateSpace=image-pixels with its captureId, and choose a unique requestKey. Set timing=frame-paced and supply startX/startY/endX/endY from that PNG. durationMs is 50..10000 (default 600); pressHoldMs and endHoldMs are 0..2000 (default 100). Each edge still gets separate renderer frames at zero hold. Do not mix legacy step timing with these fields.
|
||||||
|
|
||||||
|
The tool waits up to waitMs (default 1200), then may return a running receipt. Read it through the SAME tool with action=status and jobId or requestKey; cancel through action=cancel without coordinates. A retained identical start recovers its original receipt and never dispatches the gesture again. Changed arguments conflict. Only the latest 32 receipts are retained; these are not durable transactions across eviction/reload. A missing receipt requires inspection of the resulting state, not an automatic retry with a new key. The preview wrapper and direct mouse-drag tool have separate ownership; do not change custom exposure lists to access another tool's receipts.
|
||||||
|
|
||||||
|
Frame-paced input observes the captured Electron renderer's requestAnimationFrame callbacks. Native Game View pause/stop state is checked separately; renderer progression does not prove that native game Update advanced or a game accepted the gesture. Receipts deliberately report nativeGameUpdateVerified=false and businessOutcomeVerified=false. Compare authored state, actual preview/game state and fresh screenshots independently. This is mouse input, not touch injection or proof of physical-device provenance.
|
||||||
|
|
||||||
|
Focus loss, stale geometry, stalled frames, cancellation, preview pause/stop and extension shutdown interrupt the job. Only its own mouse release is attempted, without business callbacks or a legacy fallback. Cleanup failure leaves the target window locked; explicitly cancel that job to retry cleanup. Status reads never send input. No background/focus policy, preview pause state, project input setting or dependency is automatically changed.
|
||||||
|
|
||||||
|
Sources: [MCP transport](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports), [Electron input](https://www.electronjs.org/docs/latest/api/web-contents#contentssendinputeventinputevent) and [Creator Director](https://docs.cocos.com/creator/3.8/api/en/class/Director).
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Project, import, and preview readiness
|
||||||
|
|
||||||
|
## Asset and script changes
|
||||||
|
|
||||||
|
- Resolve the exact AssetDB UUID or db:// URL. Refresh only the changed source assets; do not guess an extension or silently substitute another asset.
|
||||||
|
- Import is asynchronous. If exposed, use `check_asset_ready` with the exact target after refresh/import and before assigning the asset or attaching its script. A stable imported UUID/URL identity is not proof that the importer queue is empty, TypeScript compiled, or the preview loaded those bytes.
|
||||||
|
- `check_asset_ready` is a Full-profile read-only tool. Discover exposure with `get_tool_catalog`; do not change a custom allowlist without authorization. If unavailable, query exact asset info and report the narrower evidence instead of claiming full readiness.
|
||||||
|
- After TypeScript edits, run `run_script_diagnostics` and inspect import/preview errors. Its no-emit compiler result is separate from Creator's compilation and preview loading.
|
||||||
|
- A zero-wait readiness query is one observation, not stable readiness. Busy, missing, importing, timeout, unavailable, and unknown results are not success. Wait within a bounded budget or report the unresolved state; never repeat a mutation to obtain a cleaner response.
|
||||||
|
- Check APIs against the actual Creator version and loaded project components, not only a package.json declaration. Preserve existing dependencies and project conventions.
|
||||||
|
|
||||||
|
## Preview evidence
|
||||||
|
|
||||||
|
- Query `get_preview_mode` before choosing browser, editor Game View, or simulator. Browser `localUrl` is same-host; `networkUrl` is Creator's LAN address.
|
||||||
|
- `get_runtime_state`, pause, and resume address the editor Game View and its native toolbar. They do not inspect external browser/simulator runtime state. Edit-scene director counters and time scale are not Game View state.
|
||||||
|
- A listening MCP server, opened window, non-empty screenshot, current scene drawing, and correct business behavior are different claims. Verify only the layers relevant to the user's request and identify missing evidence.
|
||||||
|
- Use `capture_scene_screenshot` for editor Scene composition and Game/preview capture for game output. For real pointer testing, bind `simulate_mouse_click` or drag to the returned `captureId` with `coordinateSpace="image-pixels"`; use coordinates from that exact image.
|
||||||
|
- Recapture after a resize, zoom, reload, scene change, or stale-capture rejection. Do not scale coordinates from an unrelated/resized reference image yourself. Button event emission tests handlers but does not prove hit testing, clipping, focus, or occlusion.
|
||||||
|
- If an input reports an unknown outcome, inspect the resulting state before deciding on another action. Do not automatically resend it. Restore only temporary state owned by this task; preserve user changes.
|
||||||
|
|
||||||
|
## Persistence
|
||||||
|
|
||||||
|
- Prefer scene-process, prefab, and AssetDB tools for .scene/.prefab/.meta changes. A successful native message alone does not prove saved content or preserved UUID links.
|
||||||
|
- Reinspect the exact object and relevant serialized references, save only the requested changes, and reopen when persistence matters. Keep incomplete checks explicit.
|
||||||
|
|
||||||
|
Sources: [Creator messages](https://docs.cocos.com/creator/3.8/manual/en/editor/extension/messages.html) and [asset workflow](https://docs.cocos.com/creator/3.8/manual/en/asset/asset-workflow.html).
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 2,
|
||||||
|
"skillId": "cocos-ui-composition",
|
||||||
|
"skillName": "funplay-cocos-ui-composition",
|
||||||
|
"templateVersion": 5,
|
||||||
|
"templateHash": "509e34ddc0bd9b96f6003884855ef39f57f078c87e0d29c7259ed03873bcb30f",
|
||||||
|
"installedHash": "509e34ddc0bd9b96f6003884855ef39f57f078c87e0d29c7259ed03873bcb30f",
|
||||||
|
"files": {
|
||||||
|
"SKILL.md": {
|
||||||
|
"templateHash": "509e34ddc0bd9b96f6003884855ef39f57f078c87e0d29c7259ed03873bcb30f",
|
||||||
|
"installedHash": "509e34ddc0bd9b96f6003884855ef39f57f078c87e0d29c7259ed03873bcb30f"
|
||||||
|
},
|
||||||
|
"references/layout-and-adaptation.md": {
|
||||||
|
"templateHash": "04eab714246a80077e87a9be525a1be3bfb1b365a9d167bb1f55a9068bb87257",
|
||||||
|
"installedHash": "04eab714246a80077e87a9be525a1be3bfb1b365a9d167bb1f55a9068bb87257"
|
||||||
|
},
|
||||||
|
"references/sprites-and-importers.md": {
|
||||||
|
"templateHash": "466062877f01b84895294f36c65176b968cd247c10f55c7eaf253509229863c3",
|
||||||
|
"installedHash": "466062877f01b84895294f36c65176b968cd247c10f55c7eaf253509229863c3"
|
||||||
|
},
|
||||||
|
"references/text-and-localization.md": {
|
||||||
|
"templateHash": "519c280dcc5bc868e87b142298fa6bc95e19e613497627f6ef6461e7805ccbb4",
|
||||||
|
"installedHash": "519c280dcc5bc868e87b142298fa6bc95e19e613497627f6ef6461e7805ccbb4"
|
||||||
|
},
|
||||||
|
"references/input-and-validation.md": {
|
||||||
|
"templateHash": "ebf57c3620b7a812ad3e102e4be4f9d87883312eb3c68bde2825c066174361cc",
|
||||||
|
"installedHash": "ebf57c3620b7a812ad3e102e4be4f9d87883312eb3c68bde2825c066174361cc"
|
||||||
|
},
|
||||||
|
"references/image-to-prefab.md": {
|
||||||
|
"templateHash": "650004f2f1e3bfcd33ef6ea346d03ced76a1b25287afbe9f0d5502fb0b87204f",
|
||||||
|
"installedHash": "650004f2f1e3bfcd33ef6ea346d03ced76a1b25287afbe9f0d5502fb0b87204f"
|
||||||
|
},
|
||||||
|
"references/project-identity-and-input.md": {
|
||||||
|
"templateHash": "5d2e1490645031a8fe16fb43526f3749002b723c45b656f1ea4925c1ec5d6daa",
|
||||||
|
"installedHash": "5d2e1490645031a8fe16fb43526f3749002b723c45b656f1ea4925c1ec5d6daa"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extensionVersion": "0.7.6",
|
||||||
|
"updatedAt": "2026-11-23T08:36:02.348Z"
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
name: funplay-cocos-ui-composition
|
||||||
|
description: "Build and revise responsive Cocos Creator UI, and turn full-page design images into editable prefabs with reusable sprites, layout adaptation, and visual fidelity checks. Use for Canvas layout, prefabs, scrolling, text, input, and UI validation."
|
||||||
|
---
|
||||||
|
|
||||||
|
# Funplay Cocos UI Composition
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
For MCP writes, reconnects, or interactive drag tests, read [project identity and input](references/project-identity-and-input.md). Renderer frames are not native Game View engine updates or gameplay acceptance.
|
||||||
|
|
||||||
|
## UI Workflow
|
||||||
|
|
||||||
|
1. Inspect the active scene, Canvas, design resolution, target viewports, `UITransform`, `Widget`, `Layout`, existing `SafeArea` policy, prefab ownership and serialized references.
|
||||||
|
2. Preserve the user's design requirements and established project baseline. A full-page reference may define a new screen's baseline; clarify cropped or conflicting references instead of imposing a fixed resolution.
|
||||||
|
3. Preserve existing roots, node/component identities, event bindings, animation targets and nested prefabs. Change only what the request requires; do not rebuild the entire prefab unless explicitly requested.
|
||||||
|
4. Choose one owner for each position/size property. Avoid conflicting Widget, Layout, animation and manual writes. Use supported Cocos scene/prefab/AssetDB workflows for authored assets.
|
||||||
|
5. Read back exact dimensions, anchors, constraints, SpriteFrame/font references and event bindings. Save/reopen when persistence matters; use preview input and screenshots for visual or interaction claims.
|
||||||
|
|
||||||
|
## Design Fidelity
|
||||||
|
|
||||||
|
- Preserve authored spacing and the project's adaptation. Do not proactively add SafeArea containers, adaptation scripts or extra insets. New adaptation requires an explicit request or a demonstrated overlap confirmed with the user.
|
||||||
|
- Keep complete UI pages in saved prefabs when that fits the project; runtime hierarchy creation is not a substitute for requested authored UI.
|
||||||
|
- A tool response, hierarchy, edit-scene performance counter and screenshot prove different things. Report unverified runtime, device, glyph or business behavior explicitly.
|
||||||
|
|
||||||
|
## Read Only the Relevant References
|
||||||
|
|
||||||
|
- For a complete design image or screenshot to editable UI, including asset splitting, shared controls, and fidelity acceptance, start with [image to prefab](references/image-to-prefab.md).
|
||||||
|
- For resolution, orientation, SafeArea, Widget/Layout, scrolling or masks: [layout and adaptation](references/layout-and-adaptation.md).
|
||||||
|
- For SpriteFrames, nine-slice, atlas or importer edits: [sprites and importers](references/sprites-and-importers.md).
|
||||||
|
- For fonts, text overflow, glyph coverage or requested localization: [text and localization](references/text-and-localization.md).
|
||||||
|
- For event bindings, real input, animation, screenshots or performance evidence: [input and validation](references/input-and-validation.md).
|
||||||
|
|
||||||
|
These references are conditional; do not load every file for a focused edit.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# From a full UI image to an editable Cocos prefab
|
||||||
|
|
||||||
|
Use this workflow for a new page or a set of switchable pages drawn in a user design. Work with the project's reusable artwork and the user's own designs and assets. For a third-party inspiration reference, create original visuals for the new UI.
|
||||||
|
|
||||||
|
## When image generation helps
|
||||||
|
|
||||||
|
Image generation is optional. Cocos MCP handles asset import, prefab composition, and preview verification. Any image generation or editing comes from a tool available in the AI client or the project's art pipeline.
|
||||||
|
|
||||||
|
- For a layered design, reuse its exported assets. For a flattened image, reuse clean cuts from visible regions and build text, dividers, and simple surfaces with native UI components. The reference can be analyzed by an image-capable client or described in a supplied component map.
|
||||||
|
- If a complex background or icon is missing, or a UI element hides part of the background, use an available image generation or editing tool to produce just the missing asset. Specify its intended dimensions, silhouette, style, and transparency or bleed. Inspect the output at its intended size and mark generated artwork as an approximation until it passes the visual comparison.
|
||||||
|
- With no generation tool, proceed with reusable assets and the layout that can be verified. If missing artwork blocks fidelity acceptance, request the corresponding clean background, transparent sprite, or layered design. Record any placeholder and the affected regions in the review.
|
||||||
|
|
||||||
|
## Lock the design and map the parts
|
||||||
|
|
||||||
|
- Keep each reference at its original pixel dimensions. Identify the game viewport, the selected page/tab, the locale, visible counter values, list scroll position, and relevant control states. Keep the reference and state record for comparison after implementation. If supplied pages disagree on a shared control, resolve the intended variant and record each deliberate departure from the references.
|
||||||
|
- Use the existing Canvas policy in an established project. On a new page without a baseline, use the intended full viewport as the design basis. Map part bounds in top-left reference pixels, node paths, stacking order, anchors, and fixed or flexible edges. Distinguish visible artwork bounds from the control's layout box and hit area.
|
||||||
|
- Record the chosen source for each part. Inspect cutouts, including their alpha edges and original padding, against the background they will actually use.
|
||||||
|
|
||||||
|
## Build the saved UI
|
||||||
|
|
||||||
|
- Keep the full reference image outside the rendered hierarchy. Import only the separately reusable art and use real SpriteFrames. Separate the background, title, button surfaces, icons, labels, badges, progress track/fill, and state overlays so each can move or change independently. Give text, dynamic values, and localization native text components. Reserve graphical lettering for artwork meant to stay fixed.
|
||||||
|
- Share a navigation prefab or shell across related pages. Keep each tab's icon and caption separate from the normal and selected backgrounds and divider lines. Derive the highlight, tab widths, divider positions, label placement, and hit areas from the selected state and available width. Use nine-slice for stretchable surfaces with fixed corners. Keep icon proportions and intentional blank margins.
|
||||||
|
- Author repeated lists as reusable rows in a ScrollView with a clipped viewport and Layout-managed content. Give each row separate art, text, and button bindings. Bind callbacks inside standalone prefab boundaries and use the project's normal events or controller bindings to connect them to a shell.
|
||||||
|
- Save the UI under the existing Canvas with UI_2D layers. Use native prefab serialization, verify exact imported references, and confirm that assets survive reload or fresh instantiation. Consult [sprites and importers](sprites-and-importers.md) for trim/insets and [text and localization](text-and-localization.md) for font behavior. If an icon appears too large, check the imported trim and padding first. If a label clips, apply the font and overflow policy before setting the final box, then inspect the glyph baseline in preview.
|
||||||
|
- Adapt regions independently. Use anchors for pinned controls, let the list viewport consume the remaining space, and crop flexible background art while preserving its aspect ratio. Keep a single owner for each driven dimension. Use [layout and adaptation](layout-and-adaptation.md) for the project's resize and safe-area policy.
|
||||||
|
|
||||||
|
## Verify fidelity in the actual preview
|
||||||
|
|
||||||
|
1. Capture the saved scene or prefab instance in the target Cocos preview. For fidelity, use a raw PNG of the same game viewport size and state as the reference. Check visible landmarks, the crop and the canvas size. Equal PNG dimensions alone can still conceal a cropped or zoomed capture.
|
||||||
|
2. Compare at the same pixel coordinates. Review the whole page, then zoom into the mapped regions for icon silhouettes, alignment, text baselines, borders, shadow/alpha edges, and clipping. Use a side-by-side view and, when available, a same-scale overlay, wipe, or difference heatmap. Avoid shifting or stretching individual regions during comparison.
|
||||||
|
3. Check node geometry and rendered appearance separately. Use runtime bounds projected into capture pixels for geometry. Use the visible pixels for glyphs, strokes, and artwork. Region color error, structural similarity, and tolerant edge overlap can help locate differences. Choose tolerances for the project before accepting results, and review each required region so a large matching background cannot hide a small control defect.
|
||||||
|
4. Fix the source of each difference and recapture under the same conditions. A flat 1 px stroke may require a filled border or different pixel alignment. A matching node box can still contain the wrong sprite or state. Preserve the original design, captures, per-region results, and any approved variations for review.
|
||||||
|
5. Check adaptation at the requested narrow and wide viewports with real pointer input. Exercise the in-scope page changes, button states, value updates, list scrolling and clipping using [input and validation](input-and-validation.md). Report the fidelity result for the baseline size and the adaptation/input results for the tested sizes. State any remaining mismatches or untested conditions.
|
||||||
|
|
||||||
|
For example, a shared bottom bar can have separate mapped regions for five icon silhouettes, the selected surface, a thin divider, and the full bar. At the reference size, check these independently. On a wider viewport, check that the highlight and lines follow the slots and that the same tabs respond to clicks. This catches trim and resize problems even when the page looks close in a thumbnail.
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Input, animation, and visual verification
|
||||||
|
|
||||||
|
- Verify Button/Toggle/Slider/EditBox target nodes, serialized component/handler/custom data, disabled state, hit area and focus behavior. Bind once; don't make duplicate listeners to compensate for an unresolved reference.
|
||||||
|
- Emitting Button click events checks callbacks, not real pointer dispatch. For hit testing use the actual Game View/preview and calibrated screenshot coordinates; verify the resulting state or screenshot rather than treating event delivery as the business outcome.
|
||||||
|
- Screenshot `captureId` identifies one image and its observed geometry. Use `coordinateSpace="image-pixels"` with coordinates in that exact PNG. Calibration maps to Electron content coordinates and rejects stale or changed targets. It does not identify a Button or prove absence of occlusion.
|
||||||
|
- Keep UIOpacity, active state, Button interactability and BlockInputEvents consistent. A transparent modal may still block input; a visible scrim may not block anything. Check sibling order, masks and hidden states in preview.
|
||||||
|
- Animate a Visual/Container child when Widget or Layout owns the root. Cancel/reconcile prior tweens, and verify deterministic position, scale, opacity, active state and close/reopen behavior. Use an explicit UI clock only if menus must animate during gameplay pause.
|
||||||
|
- Test only requested interactions. An input with unknown delivery/outcome must be followed by readback, not automatic replay. Restore temporary preview state only if still owned by this task.
|
||||||
|
- Use `validate_scene`, exact component/reference readback and screenshots as complementary evidence. A complete hierarchy or non-empty image does not prove correct layout, visible text, hit testing or business behavior.
|
||||||
|
- `get_performance_snapshot` reports edit-scene node/component/UI/depth/memory counters, not browser/Game View draw calls or GPU performance. Use actual runtime/platform measurements before making performance claims.
|
||||||
|
- Choose representative aspect ratios and locales for the target project. Record which checks passed, failed, were incomplete or require a device; avoid claiming universal validation from one screenshot.
|
||||||
|
|
||||||
|
Sources: [UI system](https://docs.cocos.com/creator/3.8/manual/en/2d-object/ui-system/) and [node hierarchy](https://docs.cocos.com/creator/3.8/manual/en/concepts/scene/node-tree.html).
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Layout and design fidelity
|
||||||
|
|
||||||
|
## Resolution and safe area
|
||||||
|
|
||||||
|
- User requirements and explicit design specifications take priority. Preserve an established project's design resolution and Fit Width/Fit Height policy unless a change is requested. For a new screen without a baseline, a full-page design image may define the baseline; a crop, conflicting images, or unclear intended dimensions need clarification. Do not impose a fixed phone resolution.
|
||||||
|
- Keep authored spacing and full-bleed composition. Inspect existing SafeArea components and runtime adaptation before changing them. Do not proactively add SafeArea containers, adaptation scripts, extra margins, or a second inset; new adaptation needs an explicit request or a demonstrated overlap confirmed with the user.
|
||||||
|
- If safe-area adaptation is requested, distinguish full-bleed art from critical controls and apply it once. Cocos SafeArea uses sys.getSafeAreaRect and Widget; preserve the project's existing ownership of position/size.
|
||||||
|
- Separate Canvas adaptation from gameplay camera composition. Correct Widget constraints do not prove that the world camera shows the desired area.
|
||||||
|
|
||||||
|
## Property ownership
|
||||||
|
|
||||||
|
- UITransform owns contentSize and anchor point. Keep ordinary layout scale at one; change dimensions or constraints rather than stretching transforms to approximate a design.
|
||||||
|
- Widget owns selected edges/centers and may overwrite position or size. Choose ONCE, ON_WINDOW_RESIZE, or ALWAYS from actual behavior; do not animate a property continuously rewritten by Widget.
|
||||||
|
- Layout drives children or container according to ResizeMode. Putting Layout and Widget on the same node can create competing ownership. Read back driven sizes after layout settles; call updateLayout only when same-frame measurement is required.
|
||||||
|
- Verify grid cell/constraint policy, padding, spacing, axis and growth direction. Keep nested layout chains shallow and batch repeated content changes.
|
||||||
|
- Responsive region patterns are options, not permission to reorganize existing prefabs. Reposition only the regions needed by the requested aspect-ratio change; retain roots, identities, references and animation tracks.
|
||||||
|
|
||||||
|
## Scrolling and clipping
|
||||||
|
|
||||||
|
- Use a ScrollView root, masked view and content node. Verify the actual content reference, enabled axes, inertia/brake/bounce, child-button cancellation and nested scrolling.
|
||||||
|
- Respect Mask renderer constraints and clipping boundaries. Do not add Sprite/Label renderers to a Mask node where its renderer is owned by the mask implementation.
|
||||||
|
- Pool large repeated lists. Test first/last items, resize, overflow and dynamic content in preview; dimensions alone do not prove visibility or input.
|
||||||
|
|
||||||
|
Sources: [Widget](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/editor/widget.html), [Layout](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/editor/layout.html), [SafeArea](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/editor/safearea.html), [multi-resolution adaptation](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/engine/multi-resolution.html).
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Project identity and frame-paced input
|
||||||
|
|
||||||
|
## Before editing through MCP
|
||||||
|
|
||||||
|
Generated connections use /mcp/project/<project-id>/ on the existing project port. Independently compare initialize.funplay.context.project_path and project_id to the user's intended project. Context metadata identifies an extension/Editor lifetime, not authentication or permission to edit another project.
|
||||||
|
|
||||||
|
Legacy / and /mcp addresses still support initialization and exposed read-only tools. Mutating tools require expected_context from that verified initialization, either as a tool argument or params._meta.expected_context. A project-scoped URL binds the project; an explicit expected_context also pins the extension/Editor instance. Missing, wrong-project, conflicting or stale pins execute nothing. Never automatically fetch a token from an arbitrary responding server just to bypass a rejection.
|
||||||
|
|
||||||
|
Prefer reconfiguration from MCP Server's existing connection/Skills notice, then reconnect or restart the client. Existing user edits remain protected. Unreadable client files need review; unrelated entries and historical shared entries are not silently deleted. A reload can invalidate the instance pin and calibrated screenshots even while the port remains the same. Read fresh identity and capture again; never replay a mutation solely to get a cleaner reply.
|
||||||
|
|
||||||
|
## Frame-paced mouse drag (Full profile)
|
||||||
|
|
||||||
|
Use this only when a drag test is requested and the originating input tool is exposed. Keep legacy timing for existing steps/stepDelayMs callers. For a new frame-paced gesture, capture the exact target, use coordinateSpace=image-pixels with its captureId, and choose a unique requestKey. Set timing=frame-paced and supply startX/startY/endX/endY from that PNG. durationMs is 50..10000 (default 600); pressHoldMs and endHoldMs are 0..2000 (default 100). Each edge still gets separate renderer frames at zero hold. Do not mix legacy step timing with these fields.
|
||||||
|
|
||||||
|
The tool waits up to waitMs (default 1200), then may return a running receipt. Read it through the SAME tool with action=status and jobId or requestKey; cancel through action=cancel without coordinates. A retained identical start recovers its original receipt and never dispatches the gesture again. Changed arguments conflict. Only the latest 32 receipts are retained; these are not durable transactions across eviction/reload. A missing receipt requires inspection of the resulting state, not an automatic retry with a new key. The preview wrapper and direct mouse-drag tool have separate ownership; do not change custom exposure lists to access another tool's receipts.
|
||||||
|
|
||||||
|
Frame-paced input observes the captured Electron renderer's requestAnimationFrame callbacks. Native Game View pause/stop state is checked separately; renderer progression does not prove that native game Update advanced or a game accepted the gesture. Receipts deliberately report nativeGameUpdateVerified=false and businessOutcomeVerified=false. Compare authored state, actual preview/game state and fresh screenshots independently. This is mouse input, not touch injection or proof of physical-device provenance.
|
||||||
|
|
||||||
|
Focus loss, stale geometry, stalled frames, cancellation, preview pause/stop and extension shutdown interrupt the job. Only its own mouse release is attempted, without business callbacks or a legacy fallback. Cleanup failure leaves the target window locked; explicitly cancel that job to retry cleanup. Status reads never send input. No background/focus policy, preview pause state, project input setting or dependency is automatically changed.
|
||||||
|
|
||||||
|
Sources: [MCP transport](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports), [Electron input](https://www.electronjs.org/docs/latest/api/web-contents#contentssendinputeventinputevent) and [Creator Director](https://docs.cocos.com/creator/3.8/api/en/class/Director).
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# SpriteFrames, nine-slice, and importer edits
|
||||||
|
|
||||||
|
- Resolve the source image, its .meta ownership and exact SpriteFrame subasset UUID before assignment or importer edits. Texture, ImageAsset and SpriteFrame are different asset types; never fabricate a subasset UUID.
|
||||||
|
- Inspect source dimensions, rect/trim/rotation, cap insets, Sprite type, sizeMode and UITransform dimensions. Set CUSTOM sizeMode before assigning a SpriteFrame when authored dimensions must remain fixed, then read back the final size after assignment.
|
||||||
|
- For sliced borders, retain source-coordinate insets and surviving SpriteFrame identities. Check that left+right and top+bottom fit the source rect and that corners/borders remain intact at the intended sizes. Do not derive importer coordinates from a downscaled screenshot.
|
||||||
|
- Use focused importer/AssetDB operations when available. If a narrowly scoped .meta edit is necessary, preserve unrelated importer settings, UUIDs, submeta mappings and atlas references, refresh the exact source, and verify imported state. Do not recreate metadata or copy a .meta file to duplicate an asset.
|
||||||
|
- Changing atlas membership, trimming or slicing can affect animation tracks, nested prefabs and material/batching behavior. Inspect incoming references before a structural change and report unsupported identity preservation rather than rebuilding references by name.
|
||||||
|
- After import, `check_asset_ready` verifies only the imported AssetDB identity; inspect the actual SpriteFrame and saved component binding separately. Save/reopen when persistence is required and visually inspect corners at the target size.
|
||||||
|
- Group compatible materials/textures only while preserving intended render order. Editor node/component counts are not a runtime draw-call or GPU measurement.
|
||||||
|
|
||||||
|
Sources: [Sprite](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/editor/sprite.html) and [image assets](https://docs.cocos.com/creator/3.8/manual/en/asset/image.html).
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# Fonts, text sizing, and requested localization
|
||||||
|
|
||||||
|
- Preserve the project's font system: system font, imported TTF/OTF, bitmap font, RichText, or a project-specific localization component. Resolve font assets and their actual component bindings; do not replace the font strategy merely to silence a warning.
|
||||||
|
- Verify fontSize, lineHeight, alignment, wrapping, contentSize, cacheMode and overflow at the intended viewport. CLAMP clips, SHRINK changes readable size and can cost CPU on dynamic text, and RESIZE_HEIGHT transfers height ownership to the label. Choose from project policy rather than applying SHRINK everywhere.
|
||||||
|
- Check CJK, punctuation, digits, icons and other required glyphs in representative strings. Include line breaks, long translations and dynamic/code-composed strings when localization is requested. A successful string assignment does not establish glyph coverage or readability.
|
||||||
|
- Bitmap-font atlas glyphs, character-cache capacity, fallback behavior and persisted font assets need separate checks. If coverage cannot be measured, report unknown rather than assuming all characters render.
|
||||||
|
- For requested localization, identify the existing locale IDs and mapping, text keys, authored labels, runtime formatting and fallback policy. Change only requested languages/scope and preserve existing services; do not install an unrelated localization package by default.
|
||||||
|
- Read back persisted font/text/localization references and representative outputs. Report covered, missing and unverified strings separately; inspecting authored labels does not prove coverage of runtime-generated text.
|
||||||
|
- Capture representative languages and aspect ratios and inspect missing glyphs, clipping, wrapping and layout growth. Native/device performance and input-method behavior require corresponding platform evidence.
|
||||||
|
|
||||||
|
Sources: [Label](https://docs.cocos.com/creator/3.8/manual/en/ui-system/components/editor/label.html) and [font assets](https://docs.cocos.com/creator/3.8/manual/en/asset/font.html).
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"image": {
|
||||||
|
"type": "sprite-frame"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
#///////////////////////////
|
||||||
|
# Cocos Creator 3D Project
|
||||||
|
#///////////////////////////
|
||||||
|
library/
|
||||||
|
temp/
|
||||||
|
local/
|
||||||
|
build/
|
||||||
|
profiles/
|
||||||
|
native
|
||||||
|
#//////////////////////////
|
||||||
|
# NPM
|
||||||
|
#//////////////////////////
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
#//////////////////////////
|
||||||
|
# VSCode
|
||||||
|
#//////////////////////////
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
#//////////////////////////
|
||||||
|
# WebStorm
|
||||||
|
#//////////////////////////
|
||||||
|
.idea/
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "c2e3f73e-fabe-45a8-a514-235234562e04",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {
|
||||||
|
"isBundle": true,
|
||||||
|
"bundleConfigID": "default",
|
||||||
|
"bundleName": "resources",
|
||||||
|
"priority": 8
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "dd535c06-a1d1-4ef6-903b-8b96dfaa15df",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "57ab131f-ec21-4073-b56c-0e5e35a86c4e",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "57ab131f-ec21-4073-b56c-0e5e35a86c4e@6c48a",
|
||||||
|
"displayName": "art_ch1_sunflower",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "57ab131f-ec21-4073-b56c-0e5e35a86c4e",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "57ab131f-ec21-4073-b56c-0e5e35a86c4e@f9941",
|
||||||
|
"displayName": "art_ch1_sunflower",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "57ab131f-ec21-4073-b56c-0e5e35a86c4e@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "57ab131f-ec21-4073-b56c-0e5e35a86c4e@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "2ab53249-ddac-4016-abc9-f977d99e8ca6",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "2ab53249-ddac-4016-abc9-f977d99e8ca6@6c48a",
|
||||||
|
"displayName": "art_ch2_kingfisher",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "2ab53249-ddac-4016-abc9-f977d99e8ca6",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "2ab53249-ddac-4016-abc9-f977d99e8ca6@f9941",
|
||||||
|
"displayName": "art_ch2_kingfisher",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "2ab53249-ddac-4016-abc9-f977d99e8ca6@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "2ab53249-ddac-4016-abc9-f977d99e8ca6@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 37 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "95409ff0-ed92-4c39-856f-b3ce7f058b93",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "95409ff0-ed92-4c39-856f-b3ce7f058b93@6c48a",
|
||||||
|
"displayName": "art_ch3_orange_cat",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "95409ff0-ed92-4c39-856f-b3ce7f058b93",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "95409ff0-ed92-4c39-856f-b3ce7f058b93@f9941",
|
||||||
|
"displayName": "art_ch3_orange_cat",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "95409ff0-ed92-4c39-856f-b3ce7f058b93@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "95409ff0-ed92-4c39-856f-b3ce7f058b93@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "0217754b-d7df-493a-9237-052a0c4a3bde",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "0217754b-d7df-493a-9237-052a0c4a3bde@6c48a",
|
||||||
|
"displayName": "art_ch4_jiangnan_bridge",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "0217754b-d7df-493a-9237-052a0c4a3bde",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "0217754b-d7df-493a-9237-052a0c4a3bde@f9941",
|
||||||
|
"displayName": "art_ch4_jiangnan_bridge",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "0217754b-d7df-493a-9237-052a0c4a3bde@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "0217754b-d7df-493a-9237-052a0c4a3bde@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "c43588b2-d583-493e-90de-6f55b8bce335",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "c43588b2-d583-493e-90de-6f55b8bce335@6c48a",
|
||||||
|
"displayName": "art_ch5_red_cottage",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "c43588b2-d583-493e-90de-6f55b8bce335",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "c43588b2-d583-493e-90de-6f55b8bce335@f9941",
|
||||||
|
"displayName": "art_ch5_red_cottage",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "c43588b2-d583-493e-90de-6f55b8bce335@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "c43588b2-d583-493e-90de-6f55b8bce335@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 69 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "8a7b838d-ca41-4326-b212-c8304c43afcd",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "8a7b838d-ca41-4326-b212-c8304c43afcd@6c48a",
|
||||||
|
"displayName": "art_ch6_strawberry_cake",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "8a7b838d-ca41-4326-b212-c8304c43afcd",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "8a7b838d-ca41-4326-b212-c8304c43afcd@f9941",
|
||||||
|
"displayName": "art_ch6_strawberry_cake",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 512,
|
||||||
|
"height": 512,
|
||||||
|
"rawWidth": 512,
|
||||||
|
"rawHeight": 512,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
-256,
|
||||||
|
0,
|
||||||
|
-256,
|
||||||
|
256,
|
||||||
|
0,
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
512,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
512,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-256,
|
||||||
|
-256,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
256,
|
||||||
|
256,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "8a7b838d-ca41-4326-b212-c8304c43afcd@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "8a7b838d-ca41-4326-b212-c8304c43afcd@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "6ca8872f-1e7b-4115-a835-27feb0726cc8",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 171 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "d42d3c48-3373-4781-93bd-e10ed3f15ce9",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "d42d3c48-3373-4781-93bd-e10ed3f15ce9@6c48a",
|
||||||
|
"displayName": "bg_lobby_atelier",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "d42d3c48-3373-4781-93bd-e10ed3f15ce9",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "d42d3c48-3373-4781-93bd-e10ed3f15ce9@f9941",
|
||||||
|
"displayName": "bg_lobby_atelier",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 750,
|
||||||
|
"height": 1334,
|
||||||
|
"rawWidth": 750,
|
||||||
|
"rawHeight": 1334,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-375,
|
||||||
|
-667,
|
||||||
|
0,
|
||||||
|
375,
|
||||||
|
-667,
|
||||||
|
0,
|
||||||
|
-375,
|
||||||
|
667,
|
||||||
|
0,
|
||||||
|
375,
|
||||||
|
667,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
1334,
|
||||||
|
750,
|
||||||
|
1334,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
750,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-375,
|
||||||
|
-667,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
375,
|
||||||
|
667,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "d42d3c48-3373-4781-93bd-e10ed3f15ce9@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "d42d3c48-3373-4781-93bd-e10ed3f15ce9@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 223 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81",
|
||||||
|
"files": [
|
||||||
|
".jpg",
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81@6c48a",
|
||||||
|
"displayName": "bg_play_atelier",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81@f9941",
|
||||||
|
"displayName": "bg_play_atelier",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 750,
|
||||||
|
"height": 1334,
|
||||||
|
"rawWidth": 750,
|
||||||
|
"rawHeight": 1334,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-375,
|
||||||
|
-667,
|
||||||
|
0,
|
||||||
|
375,
|
||||||
|
-667,
|
||||||
|
0,
|
||||||
|
-375,
|
||||||
|
667,
|
||||||
|
0,
|
||||||
|
375,
|
||||||
|
667,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
1334,
|
||||||
|
750,
|
||||||
|
1334,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
750,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-375,
|
||||||
|
-667,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
375,
|
||||||
|
667,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": false,
|
||||||
|
"redirect": "a7dd8f7e-3f7b-424b-90e7-bf1ef2842a81@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090@6c48a",
|
||||||
|
"displayName": "btn_dock_demo",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090@f9941",
|
||||||
|
"displayName": "btn_dock_demo",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0.5,
|
||||||
|
"offsetY": 0.5,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 141,
|
||||||
|
"height": 143,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 144,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-70.5,
|
||||||
|
-71.5,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
-71.5,
|
||||||
|
0,
|
||||||
|
-70.5,
|
||||||
|
71.5,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
71.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
144,
|
||||||
|
143,
|
||||||
|
144,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
143,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.013888888888888888,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.013888888888888888,
|
||||||
|
1,
|
||||||
|
0.9930555555555556,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-70.5,
|
||||||
|
-71.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
70.5,
|
||||||
|
71.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "c0f88bf0-b5ac-4c0a-a6b8-a5479ac13090@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "c6bef064-5d4c-47e0-85e0-c627492f8406",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "c6bef064-5d4c-47e0-85e0-c627492f8406@6c48a",
|
||||||
|
"displayName": "btn_dock_hint",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "c6bef064-5d4c-47e0-85e0-c627492f8406",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "c6bef064-5d4c-47e0-85e0-c627492f8406@f9941",
|
||||||
|
"displayName": "btn_dock_hint",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 1,
|
||||||
|
"trimX": 1,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 142,
|
||||||
|
"height": 142,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 144,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-71,
|
||||||
|
-71,
|
||||||
|
0,
|
||||||
|
71,
|
||||||
|
-71,
|
||||||
|
0,
|
||||||
|
-71,
|
||||||
|
71,
|
||||||
|
0,
|
||||||
|
71,
|
||||||
|
71,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
1,
|
||||||
|
144,
|
||||||
|
143,
|
||||||
|
144,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
143,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.006944444444444444,
|
||||||
|
0.013888888888888888,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.013888888888888888,
|
||||||
|
0.006944444444444444,
|
||||||
|
1,
|
||||||
|
0.9930555555555556,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-71,
|
||||||
|
-71,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
71,
|
||||||
|
71,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "c6bef064-5d4c-47e0-85e0-c627492f8406@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "c6bef064-5d4c-47e0-85e0-c627492f8406@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "33908762-7602-48f2-a8e1-5857aa630410",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "33908762-7602-48f2-a8e1-5857aa630410@6c48a",
|
||||||
|
"displayName": "btn_dock_restart",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "33908762-7602-48f2-a8e1-5857aa630410",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "33908762-7602-48f2-a8e1-5857aa630410@f9941",
|
||||||
|
"displayName": "btn_dock_restart",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0.5,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 1,
|
||||||
|
"width": 141,
|
||||||
|
"height": 142,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 144,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-70.5,
|
||||||
|
-71,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
-71,
|
||||||
|
0,
|
||||||
|
-70.5,
|
||||||
|
71,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
71,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
143,
|
||||||
|
143,
|
||||||
|
143,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
143,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.013888888888888888,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.013888888888888888,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.9930555555555556
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-70.5,
|
||||||
|
-71,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
70.5,
|
||||||
|
71,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "33908762-7602-48f2-a8e1-5857aa630410@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "33908762-7602-48f2-a8e1-5857aa630410@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 9.9 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "b59db9b8-ade3-497b-8bf5-659d34e0a923",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "b59db9b8-ade3-497b-8bf5-659d34e0a923@6c48a",
|
||||||
|
"displayName": "btn_dock_undo",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "b59db9b8-ade3-497b-8bf5-659d34e0a923",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "b59db9b8-ade3-497b-8bf5-659d34e0a923@f9941",
|
||||||
|
"displayName": "btn_dock_undo",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0.5,
|
||||||
|
"offsetY": 0.5,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 141,
|
||||||
|
"height": 143,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 144,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-70.5,
|
||||||
|
-71.5,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
-71.5,
|
||||||
|
0,
|
||||||
|
-70.5,
|
||||||
|
71.5,
|
||||||
|
0,
|
||||||
|
70.5,
|
||||||
|
71.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
144,
|
||||||
|
143,
|
||||||
|
144,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
143,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.013888888888888888,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.9930555555555556,
|
||||||
|
0.006944444444444444,
|
||||||
|
0.013888888888888888,
|
||||||
|
1,
|
||||||
|
0.9930555555555556,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-70.5,
|
||||||
|
-71.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
70.5,
|
||||||
|
71.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "b59db9b8-ade3-497b-8bf5-659d34e0a923@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "b59db9b8-ade3-497b-8bf5-659d34e0a923@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "31550c7a-7818-4446-8f3b-8cf827d91f71",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "31550c7a-7818-4446-8f3b-8cf827d91f71@6c48a",
|
||||||
|
"displayName": "ui_floral_node",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "31550c7a-7818-4446-8f3b-8cf827d91f71",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "31550c7a-7818-4446-8f3b-8cf827d91f71@f9941",
|
||||||
|
"displayName": "ui_floral_node",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 144,
|
||||||
|
"height": 147,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 147,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-72,
|
||||||
|
-73.5,
|
||||||
|
0,
|
||||||
|
72,
|
||||||
|
-73.5,
|
||||||
|
0,
|
||||||
|
-72,
|
||||||
|
73.5,
|
||||||
|
0,
|
||||||
|
72,
|
||||||
|
73.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
147,
|
||||||
|
144,
|
||||||
|
147,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
144,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-72,
|
||||||
|
-73.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
72,
|
||||||
|
73.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "31550c7a-7818-4446-8f3b-8cf827d91f71@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "31550c7a-7818-4446-8f3b-8cf827d91f71@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "806fea18-614c-4d99-8437-a81fb017ecf4",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "806fea18-614c-4d99-8437-a81fb017ecf4@6c48a",
|
||||||
|
"displayName": "ui_gold_btn",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "806fea18-614c-4d99-8437-a81fb017ecf4",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "806fea18-614c-4d99-8437-a81fb017ecf4@f9941",
|
||||||
|
"displayName": "ui_gold_btn",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 1,
|
||||||
|
"offsetY": 1,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 438,
|
||||||
|
"height": 190,
|
||||||
|
"rawWidth": 440,
|
||||||
|
"rawHeight": 192,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-219,
|
||||||
|
-95,
|
||||||
|
0,
|
||||||
|
219,
|
||||||
|
-95,
|
||||||
|
0,
|
||||||
|
-219,
|
||||||
|
95,
|
||||||
|
0,
|
||||||
|
219,
|
||||||
|
95,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
192,
|
||||||
|
440,
|
||||||
|
192,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
440,
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.004545454545454545,
|
||||||
|
0.010416666666666666,
|
||||||
|
1,
|
||||||
|
0.010416666666666666,
|
||||||
|
0.004545454545454545,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-219,
|
||||||
|
-95,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
219,
|
||||||
|
95,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "806fea18-614c-4d99-8437-a81fb017ecf4@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "806fea18-614c-4d99-8437-a81fb017ecf4@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 85 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "5e053d7f-5472-4a75-809d-24681e8402d2",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "5e053d7f-5472-4a75-809d-24681e8402d2@6c48a",
|
||||||
|
"displayName": "ui_linen_modal",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "5e053d7f-5472-4a75-809d-24681e8402d2",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "5e053d7f-5472-4a75-809d-24681e8402d2@f9941",
|
||||||
|
"displayName": "ui_linen_modal",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 1.5,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 3,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 517,
|
||||||
|
"height": 518,
|
||||||
|
"rawWidth": 520,
|
||||||
|
"rawHeight": 518,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-258.5,
|
||||||
|
-259,
|
||||||
|
0,
|
||||||
|
258.5,
|
||||||
|
-259,
|
||||||
|
0,
|
||||||
|
-258.5,
|
||||||
|
259,
|
||||||
|
0,
|
||||||
|
258.5,
|
||||||
|
259,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
3,
|
||||||
|
518,
|
||||||
|
520,
|
||||||
|
518,
|
||||||
|
3,
|
||||||
|
0,
|
||||||
|
520,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.0057692307692307696,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0.0057692307692307696,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-258.5,
|
||||||
|
-259,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
258.5,
|
||||||
|
259,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "5e053d7f-5472-4a75-809d-24681e8402d2@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "5e053d7f-5472-4a75-809d-24681e8402d2@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "1cb62d1b-404b-4949-9d85-edf088befd3f",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "1cb62d1b-404b-4949-9d85-edf088befd3f@6c48a",
|
||||||
|
"displayName": "ui_silk_ribbon",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "1cb62d1b-404b-4949-9d85-edf088befd3f",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "1cb62d1b-404b-4949-9d85-edf088befd3f@f9941",
|
||||||
|
"displayName": "ui_silk_ribbon",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": -0.5,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 515,
|
||||||
|
"height": 171,
|
||||||
|
"rawWidth": 520,
|
||||||
|
"rawHeight": 171,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-257.5,
|
||||||
|
-85.5,
|
||||||
|
0,
|
||||||
|
257.5,
|
||||||
|
-85.5,
|
||||||
|
0,
|
||||||
|
-257.5,
|
||||||
|
85.5,
|
||||||
|
0,
|
||||||
|
257.5,
|
||||||
|
85.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
171,
|
||||||
|
517,
|
||||||
|
171,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
517,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.0038461538461538464,
|
||||||
|
0,
|
||||||
|
0.9942307692307693,
|
||||||
|
0,
|
||||||
|
0.0038461538461538464,
|
||||||
|
1,
|
||||||
|
0.9942307692307693,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-257.5,
|
||||||
|
-85.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
257.5,
|
||||||
|
85.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "1cb62d1b-404b-4949-9d85-edf088befd3f@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "1cb62d1b-404b-4949-9d85-edf088befd3f@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 7.5 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869@6c48a",
|
||||||
|
"displayName": "ui_wax_seal",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869@f9941",
|
||||||
|
"displayName": "ui_wax_seal",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 0,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 144,
|
||||||
|
"height": 139,
|
||||||
|
"rawWidth": 144,
|
||||||
|
"rawHeight": 139,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-72,
|
||||||
|
-69.5,
|
||||||
|
0,
|
||||||
|
72,
|
||||||
|
-69.5,
|
||||||
|
0,
|
||||||
|
-72,
|
||||||
|
69.5,
|
||||||
|
0,
|
||||||
|
72,
|
||||||
|
69.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
0,
|
||||||
|
139,
|
||||||
|
144,
|
||||||
|
139,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
144,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-72,
|
||||||
|
-69.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
72,
|
||||||
|
69.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "e0bcfc7e-d9b8-4ebc-92f7-681d292ca869@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 23 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "530cdc4b-db34-4a9b-a773-02cf5878899c",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "530cdc4b-db34-4a9b-a773-02cf5878899c@6c48a",
|
||||||
|
"displayName": "ui_wood_dock",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "530cdc4b-db34-4a9b-a773-02cf5878899c",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "530cdc4b-db34-4a9b-a773-02cf5878899c@f9941",
|
||||||
|
"displayName": "ui_wood_dock",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 1,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 722,
|
||||||
|
"height": 100,
|
||||||
|
"rawWidth": 724,
|
||||||
|
"rawHeight": 100,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-361,
|
||||||
|
-50,
|
||||||
|
0,
|
||||||
|
361,
|
||||||
|
-50,
|
||||||
|
0,
|
||||||
|
-361,
|
||||||
|
50,
|
||||||
|
0,
|
||||||
|
361,
|
||||||
|
50,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
1,
|
||||||
|
100,
|
||||||
|
723,
|
||||||
|
100,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
723,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.0013812154696132596,
|
||||||
|
0,
|
||||||
|
0.9986187845303868,
|
||||||
|
0,
|
||||||
|
0.0013812154696132596,
|
||||||
|
1,
|
||||||
|
0.9986187845303868,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-361,
|
||||||
|
-50,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
361,
|
||||||
|
50,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "530cdc4b-db34-4a9b-a773-02cf5878899c@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "530cdc4b-db34-4a9b-a773-02cf5878899c@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "79f6c331-78a6-4028-a3b6-cd86df09b222",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "79f6c331-78a6-4028-a3b6-cd86df09b222@6c48a",
|
||||||
|
"displayName": "ui_wood_plaque",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "79f6c331-78a6-4028-a3b6-cd86df09b222",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "79f6c331-78a6-4028-a3b6-cd86df09b222@f9941",
|
||||||
|
"displayName": "ui_wood_plaque",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0.5,
|
||||||
|
"offsetY": 1.5,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 477,
|
||||||
|
"height": 128,
|
||||||
|
"rawWidth": 480,
|
||||||
|
"rawHeight": 131,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-238.5,
|
||||||
|
-64,
|
||||||
|
0,
|
||||||
|
238.5,
|
||||||
|
-64,
|
||||||
|
0,
|
||||||
|
-238.5,
|
||||||
|
64,
|
||||||
|
0,
|
||||||
|
238.5,
|
||||||
|
64,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
131,
|
||||||
|
479,
|
||||||
|
131,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
479,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.004166666666666667,
|
||||||
|
0.022900763358778626,
|
||||||
|
0.9979166666666667,
|
||||||
|
0.022900763358778626,
|
||||||
|
0.004166666666666667,
|
||||||
|
1,
|
||||||
|
0.9979166666666667,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-238.5,
|
||||||
|
-64,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
238.5,
|
||||||
|
64,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "79f6c331-78a6-4028-a3b6-cd86df09b222@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "79f6c331-78a6-4028-a3b6-cd86df09b222@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 6.3 KiB |
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.0.27",
|
||||||
|
"importer": "image",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "6f7a7ada-d524-4185-86b4-94f490312b8a",
|
||||||
|
"files": [
|
||||||
|
".json",
|
||||||
|
".png"
|
||||||
|
],
|
||||||
|
"subMetas": {
|
||||||
|
"6c48a": {
|
||||||
|
"importer": "texture",
|
||||||
|
"uuid": "6f7a7ada-d524-4185-86b4-94f490312b8a@6c48a",
|
||||||
|
"displayName": "ui_wood_round",
|
||||||
|
"id": "6c48a",
|
||||||
|
"name": "texture",
|
||||||
|
"userData": {
|
||||||
|
"wrapModeS": "clamp-to-edge",
|
||||||
|
"wrapModeT": "clamp-to-edge",
|
||||||
|
"imageUuidOrDatabaseUri": "6f7a7ada-d524-4185-86b4-94f490312b8a",
|
||||||
|
"isUuid": true,
|
||||||
|
"visible": false,
|
||||||
|
"minfilter": "linear",
|
||||||
|
"magfilter": "linear",
|
||||||
|
"mipfilter": "none",
|
||||||
|
"anisotropy": 0
|
||||||
|
},
|
||||||
|
"ver": "1.0.22",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
},
|
||||||
|
"f9941": {
|
||||||
|
"importer": "sprite-frame",
|
||||||
|
"uuid": "6f7a7ada-d524-4185-86b4-94f490312b8a@f9941",
|
||||||
|
"displayName": "ui_wood_round",
|
||||||
|
"id": "f9941",
|
||||||
|
"name": "spriteFrame",
|
||||||
|
"userData": {
|
||||||
|
"trimThreshold": 1,
|
||||||
|
"rotated": false,
|
||||||
|
"offsetX": 0.5,
|
||||||
|
"offsetY": 0,
|
||||||
|
"trimX": 2,
|
||||||
|
"trimY": 0,
|
||||||
|
"width": 113,
|
||||||
|
"height": 117,
|
||||||
|
"rawWidth": 116,
|
||||||
|
"rawHeight": 117,
|
||||||
|
"borderTop": 0,
|
||||||
|
"borderBottom": 0,
|
||||||
|
"borderLeft": 0,
|
||||||
|
"borderRight": 0,
|
||||||
|
"packable": true,
|
||||||
|
"pixelsToUnit": 100,
|
||||||
|
"pivotX": 0.5,
|
||||||
|
"pivotY": 0.5,
|
||||||
|
"meshType": 0,
|
||||||
|
"vertices": {
|
||||||
|
"rawPosition": [
|
||||||
|
-56.5,
|
||||||
|
-58.5,
|
||||||
|
0,
|
||||||
|
56.5,
|
||||||
|
-58.5,
|
||||||
|
0,
|
||||||
|
-56.5,
|
||||||
|
58.5,
|
||||||
|
0,
|
||||||
|
56.5,
|
||||||
|
58.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"indexes": [
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
2,
|
||||||
|
1,
|
||||||
|
3
|
||||||
|
],
|
||||||
|
"uv": [
|
||||||
|
2,
|
||||||
|
117,
|
||||||
|
115,
|
||||||
|
117,
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
115,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"nuv": [
|
||||||
|
0.017241379310344827,
|
||||||
|
0,
|
||||||
|
0.9913793103448276,
|
||||||
|
0,
|
||||||
|
0.017241379310344827,
|
||||||
|
1,
|
||||||
|
0.9913793103448276,
|
||||||
|
1
|
||||||
|
],
|
||||||
|
"minPos": [
|
||||||
|
-56.5,
|
||||||
|
-58.5,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"maxPos": [
|
||||||
|
56.5,
|
||||||
|
58.5,
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"isUuid": true,
|
||||||
|
"imageUuidOrDatabaseUri": "6f7a7ada-d524-4185-86b4-94f490312b8a@6c48a",
|
||||||
|
"atlasUuid": "",
|
||||||
|
"trimType": "auto"
|
||||||
|
},
|
||||||
|
"ver": "1.0.12",
|
||||||
|
"imported": true,
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"userData": {
|
||||||
|
"type": "sprite-frame",
|
||||||
|
"fixAlphaTransparencyArtifacts": false,
|
||||||
|
"hasAlpha": true,
|
||||||
|
"redirect": "6f7a7ada-d524-4185-86b4-94f490312b8a@6c48a"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "3d4fab07-747a-4776-91a8-eee8245e1574",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,392 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"__type__": "cc.SceneAsset",
|
||||||
|
"_name": "Main",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_native": "",
|
||||||
|
"scene": {
|
||||||
|
"__id__": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Scene",
|
||||||
|
"_name": "Main",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_parent": null,
|
||||||
|
"_children": [
|
||||||
|
{
|
||||||
|
"__id__": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [],
|
||||||
|
"_prefab": null,
|
||||||
|
"autoReleaseAssets": false,
|
||||||
|
"_globals": {
|
||||||
|
"__id__": 9
|
||||||
|
},
|
||||||
|
"_id": "55fb76c3-ffcc-432b-a0ce-8cd655b3a0a9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "Canvas",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 1
|
||||||
|
},
|
||||||
|
"_children": [
|
||||||
|
{
|
||||||
|
"__id__": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 7
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__id__": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": null,
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 375,
|
||||||
|
"y": 667,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1,
|
||||||
|
"y": 1,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_layer": 33554432,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": "beI88Z2HpFELqR4T5EMHpg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Node",
|
||||||
|
"_name": "Camera",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"_parent": {
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
"_children": [],
|
||||||
|
"_active": true,
|
||||||
|
"_components": [
|
||||||
|
{
|
||||||
|
"__id__": 4
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"_prefab": null,
|
||||||
|
"_lpos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 1000
|
||||||
|
},
|
||||||
|
"_lrot": {
|
||||||
|
"__type__": "cc.Quat",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_lscale": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1,
|
||||||
|
"y": 1,
|
||||||
|
"z": 1
|
||||||
|
},
|
||||||
|
"_layer": 1073741824,
|
||||||
|
"_euler": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_id": "ebFwiq8gBFaYpqYbdoDODe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Camera",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 3
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": null,
|
||||||
|
"_projection": 0,
|
||||||
|
"_priority": 0,
|
||||||
|
"_fov": 45,
|
||||||
|
"_fovAxis": 0,
|
||||||
|
"_orthoHeight": 667,
|
||||||
|
"_near": 1,
|
||||||
|
"_far": 2000,
|
||||||
|
"_color": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 244,
|
||||||
|
"g": 236,
|
||||||
|
"b": 217,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_depth": 1,
|
||||||
|
"_stencil": 0,
|
||||||
|
"_clearFlags": 7,
|
||||||
|
"_rect": {
|
||||||
|
"__type__": "cc.Rect",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"width": 1,
|
||||||
|
"height": 1
|
||||||
|
},
|
||||||
|
"_aperture": 19,
|
||||||
|
"_shutter": 7,
|
||||||
|
"_iso": 0,
|
||||||
|
"_screenScale": 1,
|
||||||
|
"_visibility": 1108344832,
|
||||||
|
"_targetTexture": null,
|
||||||
|
"_id": "63WIch3o5BEYRlXzTT0oWc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.UITransform",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": null,
|
||||||
|
"_contentSize": {
|
||||||
|
"__type__": "cc.Size",
|
||||||
|
"width": 750,
|
||||||
|
"height": 1334
|
||||||
|
},
|
||||||
|
"_anchorPoint": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 0.5,
|
||||||
|
"y": 0.5
|
||||||
|
},
|
||||||
|
"_id": "d6rUX5yfhMlKoWX2bSbawx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Canvas",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": null,
|
||||||
|
"_cameraComponent": {
|
||||||
|
"__id__": 4
|
||||||
|
},
|
||||||
|
"_alignCanvasWithScreen": true,
|
||||||
|
"_id": "12O/ljcVlEqLmVm3U2gEOQ"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.Widget",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": null,
|
||||||
|
"_alignFlags": 45,
|
||||||
|
"_target": null,
|
||||||
|
"_left": 0,
|
||||||
|
"_right": 0,
|
||||||
|
"_top": 0,
|
||||||
|
"_bottom": 0,
|
||||||
|
"_horizontalCenter": 0,
|
||||||
|
"_verticalCenter": 0,
|
||||||
|
"_isAbsLeft": true,
|
||||||
|
"_isAbsRight": true,
|
||||||
|
"_isAbsTop": true,
|
||||||
|
"_isAbsBottom": true,
|
||||||
|
"_isAbsHorizontalCenter": true,
|
||||||
|
"_isAbsVerticalCenter": true,
|
||||||
|
"_originalWidth": 0,
|
||||||
|
"_originalHeight": 0,
|
||||||
|
"_alignMode": 2,
|
||||||
|
"_lockFlags": 0,
|
||||||
|
"_id": "c5V1EV8IpMtrIvY1OE9t2u"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "2ffbdpQgxlKjoT48h/eEfEo",
|
||||||
|
"_name": "",
|
||||||
|
"_objFlags": 0,
|
||||||
|
"node": {
|
||||||
|
"__id__": 2
|
||||||
|
},
|
||||||
|
"_enabled": true,
|
||||||
|
"__prefab": null,
|
||||||
|
"_id": "81MainControllerNode01"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.SceneGlobals",
|
||||||
|
"ambient": {
|
||||||
|
"__id__": 10
|
||||||
|
},
|
||||||
|
"shadows": {
|
||||||
|
"__id__": 11
|
||||||
|
},
|
||||||
|
"_skybox": {
|
||||||
|
"__id__": 12
|
||||||
|
},
|
||||||
|
"fog": {
|
||||||
|
"__id__": 13
|
||||||
|
},
|
||||||
|
"octree": {
|
||||||
|
"__id__": 14
|
||||||
|
},
|
||||||
|
"skin": {
|
||||||
|
"__id__": 15
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.AmbientInfo",
|
||||||
|
"_skyColorHDR": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 0.520833125
|
||||||
|
},
|
||||||
|
"_skyColor": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 0.520833125
|
||||||
|
},
|
||||||
|
"_skyIllumHDR": 20000,
|
||||||
|
"_skyIllum": 20000,
|
||||||
|
"_groundAlbedoHDR": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 0
|
||||||
|
},
|
||||||
|
"_groundAlbedo": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"z": 0,
|
||||||
|
"w": 0
|
||||||
|
},
|
||||||
|
"_skyColorLDR": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0.2,
|
||||||
|
"y": 0.5,
|
||||||
|
"z": 0.8,
|
||||||
|
"w": 1
|
||||||
|
},
|
||||||
|
"_skyIllumLDR": 20000,
|
||||||
|
"_groundAlbedoLDR": {
|
||||||
|
"__type__": "cc.Vec4",
|
||||||
|
"x": 0.2,
|
||||||
|
"y": 0.2,
|
||||||
|
"z": 0.2,
|
||||||
|
"w": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.ShadowsInfo",
|
||||||
|
"_enabled": false,
|
||||||
|
"_type": 0,
|
||||||
|
"_normal": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 0,
|
||||||
|
"y": 1,
|
||||||
|
"z": 0
|
||||||
|
},
|
||||||
|
"_distance": 0,
|
||||||
|
"_shadowColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 76,
|
||||||
|
"g": 76,
|
||||||
|
"b": 76,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_maxReceived": 4,
|
||||||
|
"_size": {
|
||||||
|
"__type__": "cc.Vec2",
|
||||||
|
"x": 512,
|
||||||
|
"y": 512
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.SkyboxInfo",
|
||||||
|
"_envLightingType": 0,
|
||||||
|
"_envmapHDR": null,
|
||||||
|
"_envmap": null,
|
||||||
|
"_envmapLDR": null,
|
||||||
|
"_diffuseMapHDR": null,
|
||||||
|
"_diffuseMapLDR": null,
|
||||||
|
"_enabled": false,
|
||||||
|
"_useHDR": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.FogInfo",
|
||||||
|
"_type": 0,
|
||||||
|
"_fogColor": {
|
||||||
|
"__type__": "cc.Color",
|
||||||
|
"r": 200,
|
||||||
|
"g": 200,
|
||||||
|
"b": 200,
|
||||||
|
"a": 255
|
||||||
|
},
|
||||||
|
"_enabled": false,
|
||||||
|
"_fogDensity": 0.3,
|
||||||
|
"_fogStart": 0.5,
|
||||||
|
"_fogEnd": 300,
|
||||||
|
"_fogAtten": 5,
|
||||||
|
"_fogTop": 1.5,
|
||||||
|
"_fogRange": 1.2,
|
||||||
|
"_accurate": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.OctreeInfo",
|
||||||
|
"_enabled": false,
|
||||||
|
"_minPos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": -1024,
|
||||||
|
"y": -1024,
|
||||||
|
"z": -1024
|
||||||
|
},
|
||||||
|
"_maxPos": {
|
||||||
|
"__type__": "cc.Vec3",
|
||||||
|
"x": 1024,
|
||||||
|
"y": 1024,
|
||||||
|
"z": 1024
|
||||||
|
},
|
||||||
|
"_depth": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"__type__": "cc.SkinInfo",
|
||||||
|
"_enabled": false,
|
||||||
|
"_scale": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.1.50",
|
||||||
|
"importer": "scene",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "55fb76c3-ffcc-432b-a0ce-8cd655b3a0a9",
|
||||||
|
"files": [
|
||||||
|
".json"
|
||||||
|
],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "1c6f0478-9347-43d7-8468-05a020ebd860",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import { Component, Game, game, Node, view, _decorator } from 'cc';
|
||||||
|
import { AtelierService } from './core/AtelierService';
|
||||||
|
import { SoundService } from './core/SoundService';
|
||||||
|
import { StorageService } from './core/StorageService';
|
||||||
|
import { EmbroideryRenderer } from './render/EmbroideryRenderer';
|
||||||
|
import { LobbyView } from './ui/LobbyView';
|
||||||
|
import { PlayView } from './ui/PlayView';
|
||||||
|
import { applyResponsivePolicy, computeScreenMetrics, ScreenMetrics } from './ui/ScreenAdapter';
|
||||||
|
import { createLabel, createPanel, createUINode } from './ui/UiBuilder';
|
||||||
|
|
||||||
|
const { ccclass } = _decorator;
|
||||||
|
|
||||||
|
@ccclass('MainController')
|
||||||
|
export class MainController extends Component {
|
||||||
|
private storage!: StorageService;
|
||||||
|
private sound!: SoundService;
|
||||||
|
private atelier!: AtelierService;
|
||||||
|
private renderer!: EmbroideryRenderer;
|
||||||
|
private lobbyView!: LobbyView;
|
||||||
|
private playView!: PlayView;
|
||||||
|
private mockCapsuleNode: Node | null = null;
|
||||||
|
|
||||||
|
protected onLoad(): void {
|
||||||
|
applyResponsivePolicy();
|
||||||
|
this.storage = new StorageService();
|
||||||
|
this.sound = new SoundService(this.storage);
|
||||||
|
this.atelier = new AtelierService(
|
||||||
|
() => this.storage.readAtelierRaw(),
|
||||||
|
raw => this.storage.saveAtelierRaw(raw),
|
||||||
|
);
|
||||||
|
this.atelier.syncFromLegacyRecords(lv => this.storage.getRecord(lv));
|
||||||
|
this.renderer = new EmbroideryRenderer(1.5);
|
||||||
|
|
||||||
|
const lobbyNode = createUINode('LobbyView', 750, 1334, this.node);
|
||||||
|
this.lobbyView = lobbyNode.addComponent(LobbyView);
|
||||||
|
this.lobbyView.init(this.storage, this.sound, this.atelier, this.renderer, index => this.enterLevel(index));
|
||||||
|
|
||||||
|
const playNode = createUINode('PlayView', 750, 1334, this.node);
|
||||||
|
this.playView = playNode.addComponent(PlayView);
|
||||||
|
this.playView.init(
|
||||||
|
this.storage,
|
||||||
|
this.sound,
|
||||||
|
this.atelier,
|
||||||
|
this.renderer,
|
||||||
|
() => this.showLobby(),
|
||||||
|
(tab, chapterIndex, focusLevelIndex) => {
|
||||||
|
this.showLobby();
|
||||||
|
this.lobbyView.openAtelier(tab, chapterIndex, focusLevelIndex);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
game.on(Game.EVENT_HIDE, this.onAppHide, this);
|
||||||
|
game.on(Game.EVENT_SHOW, this.onAppShow, this);
|
||||||
|
view.on('canvas-resize', this.onCanvasResize, this);
|
||||||
|
this.applyLayoutMetrics();
|
||||||
|
this.showLobby();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onDestroy(): void {
|
||||||
|
game.off(Game.EVENT_HIDE, this.onAppHide, this);
|
||||||
|
game.off(Game.EVENT_SHOW, this.onAppShow, this);
|
||||||
|
view.off('canvas-resize', this.onCanvasResize, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onCanvasResize(): void {
|
||||||
|
applyResponsivePolicy();
|
||||||
|
this.applyLayoutMetrics();
|
||||||
|
}
|
||||||
|
|
||||||
|
private applyLayoutMetrics(): void {
|
||||||
|
const metrics = computeScreenMetrics();
|
||||||
|
this.lobbyView?.applyScreenMetrics(metrics);
|
||||||
|
this.playView?.applyScreenMetrics(metrics);
|
||||||
|
this.syncMockWeChatCapsule(metrics);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 仅在浏览器 URL 带 ?wxsim=iphone15 或 ?wxsim=iphonese 时绘制模拟微信胶囊,方便真机前目视验收 */
|
||||||
|
private syncMockWeChatCapsule(m: ScreenMetrics): void {
|
||||||
|
if (!m.mockCapsule) {
|
||||||
|
if (this.mockCapsuleNode) this.mockCapsuleNode.active = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { top, height, width, right } = m.mockCapsule;
|
||||||
|
if (!this.mockCapsuleNode) {
|
||||||
|
const cap = createPanel('MockWeChatCapsule', width, height, {
|
||||||
|
fill: '#00000088', stroke: '#ffffff88', strokeWidth: 2, radius: height / 2,
|
||||||
|
}, this.node);
|
||||||
|
createLabel('CapGlyph', '••• | ◎', width - 14, height - 8, {
|
||||||
|
size: 22, color: '#ffffff', bold: true,
|
||||||
|
}, cap.node);
|
||||||
|
this.mockCapsuleNode = cap.node;
|
||||||
|
}
|
||||||
|
this.mockCapsuleNode.active = true;
|
||||||
|
this.mockCapsuleNode.setPosition(
|
||||||
|
m.visibleW / 2 - right - width / 2,
|
||||||
|
m.visibleH / 2 - top - height / 2,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onAppHide(): void {
|
||||||
|
this.playView?.cancelDrag(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onAppShow(): void {
|
||||||
|
this.atelier?.settleIdle(Date.now());
|
||||||
|
this.applyLayoutMetrics();
|
||||||
|
if (this.lobbyView?.node.active) this.lobbyView.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private showLobby(): void {
|
||||||
|
this.atelier?.settleIdle(Date.now());
|
||||||
|
this.playView.node.active = false;
|
||||||
|
this.lobbyView.node.active = true;
|
||||||
|
this.lobbyView.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private enterLevel(index: number): void {
|
||||||
|
this.lobbyView.node.active = false;
|
||||||
|
this.playView.node.active = true;
|
||||||
|
this.playView.loadLevel(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "2ffbda50-8319-4a8e-84f8-f21fde11f128",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "796c0e40-4f92-4b2b-8bba-238c9c8d88ae",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,601 @@
|
|||||||
|
import { CHAPTERS, LEVELS, recordKey } from './LevelData';
|
||||||
|
import { LevelDef } from './Types';
|
||||||
|
|
||||||
|
export type PosterFrameId = 'celadon' | 'walnut' | 'rouge' | 'gilded';
|
||||||
|
export type PosterQuoteId = 'craft' | 'breeze' | 'meeting' | 'blossom';
|
||||||
|
|
||||||
|
export interface ChapterLetterDef {
|
||||||
|
chapter: number;
|
||||||
|
senderZh: string;
|
||||||
|
senderEn: string;
|
||||||
|
titleZh: string;
|
||||||
|
titleEn: string;
|
||||||
|
requestZh: string;
|
||||||
|
requestEn: string;
|
||||||
|
replyTitleZh: string;
|
||||||
|
replyTitleEn: string;
|
||||||
|
replyZh: string;
|
||||||
|
replyEn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PosterFrameDef {
|
||||||
|
id: PosterFrameId;
|
||||||
|
nameZh: string;
|
||||||
|
nameEn: string;
|
||||||
|
cost: number;
|
||||||
|
bgTop: string;
|
||||||
|
bgBottom: string;
|
||||||
|
border: string;
|
||||||
|
accent: string;
|
||||||
|
cardBg: string;
|
||||||
|
cardStroke: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PosterQuoteDef {
|
||||||
|
id: PosterQuoteId;
|
||||||
|
zh: string;
|
||||||
|
en: string;
|
||||||
|
cost: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GalleryItem {
|
||||||
|
levelIndex: number;
|
||||||
|
levelId: string;
|
||||||
|
stars: number;
|
||||||
|
length: number;
|
||||||
|
frameId: PosterFrameId;
|
||||||
|
quoteId: PosterQuoteId;
|
||||||
|
savedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AntDiaryDef {
|
||||||
|
id: string;
|
||||||
|
titleZh: string;
|
||||||
|
titleEn: string;
|
||||||
|
moodZh: string;
|
||||||
|
moodEn: string;
|
||||||
|
bodyZh: string;
|
||||||
|
bodyEn: string;
|
||||||
|
accentColor: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AtelierSaveData {
|
||||||
|
yarnThreads: number;
|
||||||
|
pendingThreads: number;
|
||||||
|
lastTickAt: number;
|
||||||
|
unlockedFrames: PosterFrameId[];
|
||||||
|
unlockedQuotes: PosterQuoteId[];
|
||||||
|
activeFrame: PosterFrameId;
|
||||||
|
activeQuote: PosterQuoteId;
|
||||||
|
unlockedDiaries: string[];
|
||||||
|
gallery: GalleryItem[];
|
||||||
|
welcomed: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IDLE_MINUTES_PER_THREAD = 10;
|
||||||
|
export const IDLE_MAX_THREADS = 48; // 8 小时封顶,不清零,零焦虑
|
||||||
|
|
||||||
|
export const POSTER_FRAMES: PosterFrameDef[] = [
|
||||||
|
{
|
||||||
|
id: 'celadon',
|
||||||
|
nameZh: '青瓷松绿',
|
||||||
|
nameEn: 'Celadon Linen',
|
||||||
|
cost: 0,
|
||||||
|
bgTop: '#627052',
|
||||||
|
bgBottom: '#4e5c41',
|
||||||
|
border: 'rgba(246, 232, 198, 0.34)',
|
||||||
|
accent: '#efe0bd',
|
||||||
|
cardBg: '#f8f1df',
|
||||||
|
cardStroke: '#d7c297',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'walnut',
|
||||||
|
nameZh: '温润胡桃',
|
||||||
|
nameEn: 'Warm Walnut',
|
||||||
|
cost: 20,
|
||||||
|
bgTop: '#5b3f28',
|
||||||
|
bgBottom: '#422c1b',
|
||||||
|
border: 'rgba(242, 206, 132, 0.42)',
|
||||||
|
accent: '#f6d899',
|
||||||
|
cardBg: '#faf2e1',
|
||||||
|
cardStroke: '#cca35e',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'rouge',
|
||||||
|
nameZh: '山茶胭脂',
|
||||||
|
nameEn: 'Camellia Rouge',
|
||||||
|
cost: 40,
|
||||||
|
bgTop: '#7d4547',
|
||||||
|
bgBottom: '#5e3134',
|
||||||
|
border: 'rgba(255, 226, 204, 0.38)',
|
||||||
|
accent: '#fde3cc',
|
||||||
|
cardBg: '#fdf4ea',
|
||||||
|
cardStroke: '#d8a69d',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'gilded',
|
||||||
|
nameZh: '宋韵描金',
|
||||||
|
nameEn: 'Gilded Song',
|
||||||
|
cost: 70,
|
||||||
|
bgTop: '#314449',
|
||||||
|
bgBottom: '#213035',
|
||||||
|
border: 'rgba(248, 211, 118, 0.56)',
|
||||||
|
accent: '#f9d87d',
|
||||||
|
cardBg: '#fbf5e4',
|
||||||
|
cardStroke: '#d9b059',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const POSTER_QUOTES: PosterQuoteDef[] = [
|
||||||
|
{ id: 'craft', zh: '一针一线 · 慢享手作好时光', en: 'Stitch by stitch · Slow cozy craft', cost: 0 },
|
||||||
|
{ id: 'breeze', zh: '愿此间清风,伴君岁岁安好', en: 'May gentle breeze keep every season bright', cost: 15 },
|
||||||
|
{ id: 'meeting', zh: '拾光入绣,见画如晤', en: 'Woven sunlight, warm as meeting again', cost: 30 },
|
||||||
|
{ id: 'blossom', zh: '繁花入梦,针脚生香', en: 'Blossoms in dreams, fragrance in thread', cost: 45 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const CHAPTER_LETTERS: ChapterLetterDef[] = [
|
||||||
|
{
|
||||||
|
chapter: 0,
|
||||||
|
senderZh: '窗台养花的林阿婆',
|
||||||
|
senderEn: 'Grandma Lin',
|
||||||
|
titleZh: '给阳台的向日葵',
|
||||||
|
titleEn: 'Sunflowers for the Window',
|
||||||
|
requestZh: '小绣娘安好:今秋连绵阴雨,阳台的向日葵垂了头。想请你和工坊的小蚂蚁,替我绣一束永不低头的暖黄繁花,挂在茶几旁添点晴色。',
|
||||||
|
requestEn: 'Dear stitcher, autumn rain bowed my balcony sunflowers. Could you and your little ants stitch a sunny bouquet that never fades?',
|
||||||
|
replyTitleZh: '林阿婆的回信',
|
||||||
|
replyTitleEn: 'Reply from Grandma Lin',
|
||||||
|
replyZh: '绣画挂上墙的那一刻,整间茶室都亮堂起来!老邻居们来喝茶,都夸这针脚细密又暖心,连小蚂蚁搬线的模样都讨人喜欢。',
|
||||||
|
replyEn: 'The moment we hung your embroidery, the whole tea room brightened! Every neighbor admired the neat golden stitches.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chapter: 1,
|
||||||
|
senderZh: '观鸟手账画师 · 苏禾',
|
||||||
|
senderEn: 'Suhe the Birdwatcher',
|
||||||
|
titleZh: '林间一抹翠羽',
|
||||||
|
titleEn: 'A Flash of Kingfisher Blue',
|
||||||
|
requestZh: '上月在溪畔偶遇一只俯冲的蓝翠鸟,快门慢了半拍没留住。听闻蚂蚁织画馆善绣灵禽,能否替我把那抹湖蓝留在手帕上?',
|
||||||
|
requestEn: 'I spotted a kingfisher diving by the creek last month, too fast for my camera. Could you capture that flash of lake-blue in silk?',
|
||||||
|
replyTitleZh: '苏禾的回信',
|
||||||
|
replyTitleEn: 'Reply from Suhe',
|
||||||
|
replyZh: '太灵动了!这抹翠羽蓝竟和我记忆里一模一样,我已经夹进观鸟手账扉页,以后每次翻开都能听见溪水声。',
|
||||||
|
replyEn: 'So vivid! That exact feather blue now rests on the opening page of my field journal.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chapter: 2,
|
||||||
|
senderZh: '爱猫的插画生 · 小柚',
|
||||||
|
senderEn: 'Youyou the Cat Lover',
|
||||||
|
titleZh: '午后打盹的橘团子',
|
||||||
|
titleEn: 'Napping Ginger Cat',
|
||||||
|
requestZh: '我家橘猫团子最爱蜷在暖气片旁呼噜噜睡大觉。想订一幅软绵绵的萌宠手绣,寄给远方念书的姐姐解解馋。',
|
||||||
|
requestEn: 'My ginger cat loves curling up in afternoon sunbeams. I want to mail a cozy embroidered portrait to my sister studying abroad.',
|
||||||
|
replyTitleZh: '小柚的回信',
|
||||||
|
replyTitleEn: 'Reply from Youyou',
|
||||||
|
replyZh: '姐姐收到当天就拍了合照!她说摸着绒绒的橘色绣线,就像真的撸到了团子软乎乎的小肚皮。',
|
||||||
|
replyEn: 'My sister hugged it the day it arrived—she says the plush orange threads feel just like petting our cat!',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chapter: 3,
|
||||||
|
senderZh: '远行建筑师 · 沈砚',
|
||||||
|
senderEn: 'Shen Yan the Traveler',
|
||||||
|
titleZh: '梦里的江南石桥',
|
||||||
|
titleEn: 'Jiangnan Stone Bridge',
|
||||||
|
requestZh: '在北方奔波三年,夜里总想起故乡青瓦白墙与弯弯石桥。烦请以青绿丝线入画,替我绣一方可随身携带的烟雨江南。',
|
||||||
|
requestEn: 'After three years up north, I still dream of home—white walls and an arched stone bridge. Stitch a pocket of Jiangnan for me?',
|
||||||
|
replyTitleZh: '沈砚的回信',
|
||||||
|
replyTitleEn: 'Reply from Shen Yan',
|
||||||
|
replyZh: '桥影流水层次分明,真有水墨晕染之韵。出差的行囊里多了这幅绣片,走到哪儿都像带着故乡的风。',
|
||||||
|
replyEn: 'The layered greens and arching bridge feel like ink painting in silk. Wherever I travel now, home comes along.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chapter: 4,
|
||||||
|
senderZh: '刚搬新家的温宁',
|
||||||
|
senderEn: 'Wenning’s New Home',
|
||||||
|
titleZh: '红顶小屋乔迁礼',
|
||||||
|
titleEn: 'Red-Roof Cottage Gift',
|
||||||
|
requestZh: '终于攒够钱买下了带小院的新家!玄关还空着一面暖白墙,想请你们绣一栋亮着暖灯的红顶童话屋,当作家里的第一件藏品。',
|
||||||
|
requestEn: 'We finally moved into a little house with a yard! Could you stitch a warm red-roof cottage as our very first entryway piece?',
|
||||||
|
replyTitleZh: '温宁的回信',
|
||||||
|
replyTitleEn: 'Reply from Wenning',
|
||||||
|
replyZh: '昨晚装框挂在玄关,回家推开门第一眼就看见窗格里的暖光,疲惫一下子散了一半,谢谢你们的一针一线!',
|
||||||
|
replyEn: 'Framed by the front door—seeing those warm stitched windows every evening melts the day’s fatigue right away.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
chapter: 5,
|
||||||
|
senderZh: '巷口甜品店主 · 夏茉',
|
||||||
|
senderEn: 'Xiamo the Pastry Chef',
|
||||||
|
titleZh: '周年纪念草莓蛋糕',
|
||||||
|
titleEn: 'Anniversary Shortcake',
|
||||||
|
requestZh: '小店开张满一周年啦!想请蚂蚁工坊把招牌草莓奶油蛋糕绣成精致桌旗,放在收银台边见证每一个甜甜的午后。',
|
||||||
|
requestEn: 'Our little bakery turns one this week! Would your ant atelier stitch our signature strawberry shortcake for the counter?',
|
||||||
|
replyTitleZh: '夏茉的回信',
|
||||||
|
replyTitleEn: 'Reply from Xiamo',
|
||||||
|
replyZh: '客人们进门先对着这幅草莓蛋糕拍照!奶油的蓬松和草莓红太逼真了,下次你来小店,红茶和蛋糕一律免单!',
|
||||||
|
replyEn: 'Every customer snaps a photo of the stitched cake first! Tea and shortcake are on the house whenever you visit!',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ANT_DIARIES: AntDiaryDef[] = [
|
||||||
|
{
|
||||||
|
id: 'dawn-thread',
|
||||||
|
titleZh: '第一缕晨光',
|
||||||
|
titleEn: 'First Morning Thread',
|
||||||
|
moodZh: '搬线中',
|
||||||
|
moodEn: 'Carrying',
|
||||||
|
bodyZh: '今天刚开门,领头小蚁就挑了一根最亮的金丝线,在阳光晒暖的亚麻布上试走了三圈。',
|
||||||
|
bodyEn: 'At sunrise, our lead ant picked the brightest gold thread and marched three cheerful laps across warm linen.',
|
||||||
|
accentColor: '#d99a2e',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tea-steam',
|
||||||
|
titleZh: '抹茶雾气里的打盹',
|
||||||
|
titleEn: 'Nap by Matcha Steam',
|
||||||
|
moodZh: '打盹中',
|
||||||
|
moodEn: 'Napping',
|
||||||
|
bodyZh: '午后茶杯飘来淡淡茶香,两只小工蚁靠着线轴眯了十分钟,触角还一翘一翘地数针脚。',
|
||||||
|
bodyEn: 'Warm tea steam drifted across the desk. Two helper ants napped against a spool, antennae twitching in rhythm.',
|
||||||
|
accentColor: '#6f9454',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'spool-parade',
|
||||||
|
titleZh: '圆滚滚的线球体操',
|
||||||
|
titleEn: 'Yarn Ball Parade',
|
||||||
|
moodZh: '列队中',
|
||||||
|
moodEn: 'Parading',
|
||||||
|
bodyZh: '三只小蚂蚁排成一字长蛇把玫瑰粉毛线球推回木槽,走过的地方留下了一串歪歪扭扭的小脚印。',
|
||||||
|
bodyEn: 'Three ants formed a tidy parade rolling a rose yarn ball back into the tray, leaving tiny proud footprints.',
|
||||||
|
accentColor: '#cc6c86',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'brass-scissors',
|
||||||
|
titleZh: '鹤嘴剪上的倒影',
|
||||||
|
titleEn: 'Mirror on Brass Scissors',
|
||||||
|
moodZh: '臭美中',
|
||||||
|
moodEn: 'Admiring',
|
||||||
|
bodyZh: '最小的那只蚂蚁爬上黄铜鹤嘴剪照了半天镜子,认真理了理两根金尖触角才肯继续开工。',
|
||||||
|
bodyEn: 'The smallest ant checked its reflection on the brass crane scissors and tidied both antennae before working.',
|
||||||
|
accentColor: '#b98b3f',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'chamomile-petal',
|
||||||
|
titleZh: '一片洋甘菊花瓣',
|
||||||
|
titleEn: 'A Chamomile Petal',
|
||||||
|
moodZh: '拾荒中',
|
||||||
|
moodEn: 'Gathering',
|
||||||
|
bodyZh: '风吹落了一片洋甘菊花瓣在绣绷边缘,小蚂蚁们合力把它做成午休小凉伞。',
|
||||||
|
bodyEn: 'A breeze dropped a chamomile petal by the hoop; the ants turned it into a cozy sunshade for break time.',
|
||||||
|
accentColor: '#d6a444',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'indigo-dye',
|
||||||
|
titleZh: '沾到天青色的脚丫',
|
||||||
|
titleEn: 'Sky-Blue Paws',
|
||||||
|
moodZh: '染线中',
|
||||||
|
moodEn: 'Dyeing',
|
||||||
|
bodyZh: '调色染缸刚开盖,贪玩的小蚁踩了一点天青色,在废布角上歪歪斜斜印出一朵小蓝花。',
|
||||||
|
bodyEn: 'One curious ant stepped into sky-blue dye and accidentally stamped a tiny blue blossom on scrap linen.',
|
||||||
|
accentColor: '#578ea9',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'rainy-hoop',
|
||||||
|
titleZh: '雨声与八音盒',
|
||||||
|
titleEn: 'Raindrops & Music Box',
|
||||||
|
moodZh: '听雨中',
|
||||||
|
moodEn: 'Listening',
|
||||||
|
bodyZh: '窗外下起淅沥小雨,工坊里叮咚的八音盒配着穿针沙沙声,连打结的毛线都顺滑起来。',
|
||||||
|
bodyEn: 'Soft rain tapped outside while the music box chimed—even the tangled skeins untied themselves smoothly.',
|
||||||
|
accentColor: '#6f8799',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'button-bridge',
|
||||||
|
titleZh: '木纽扣小桥',
|
||||||
|
titleEn: 'Wooden Button Bridge',
|
||||||
|
moodZh: '搭桥中',
|
||||||
|
moodEn: 'Building',
|
||||||
|
bodyZh: '小蚂蚁把四眼木纽扣当成转盘练习绕线,今天一次都没打结,集体奖励半颗松仁碎!',
|
||||||
|
bodyEn: 'They practiced looping thread around a wooden button with zero tangles—everyone earned a pine-nut crumb!',
|
||||||
|
accentColor: '#9c6b43',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'lavender-sachet',
|
||||||
|
titleZh: '薰衣草香囊边角料',
|
||||||
|
titleEn: 'Lavender Sachet Scraps',
|
||||||
|
moodZh: '理线中',
|
||||||
|
moodEn: 'Sorting',
|
||||||
|
bodyZh: '收拾针线盒时翻出一小截薰衣草紫线头,工坊今天一整天都香喷喷的。',
|
||||||
|
bodyEn: 'Found a snip of lavender silk while tidying the sewing box—the whole workshop smelled dreamy all afternoon.',
|
||||||
|
accentColor: '#8c74b0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'sunset-gold',
|
||||||
|
titleZh: '落日洒在樱桃木上',
|
||||||
|
titleEn: 'Sunset on Cherry Wood',
|
||||||
|
moodZh: '收工中',
|
||||||
|
moodEn: 'Wrapping up',
|
||||||
|
bodyZh: '傍晚的斜阳把绣绷照得像一块蜜糖饼,小蚂蚁们把剪齐的线头码得整整齐齐等你回来。',
|
||||||
|
bodyEn: 'Evening light turned the hoop honey-gold. The ants stacked every trimmed thread neatly waiting for you.',
|
||||||
|
accentColor: '#d67a3e',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'wax-seal-stamp',
|
||||||
|
titleZh: '山茶红火漆的秘密',
|
||||||
|
titleEn: 'Secret of the Wax Seal',
|
||||||
|
moodZh: '寄信中',
|
||||||
|
moodEn: 'Mailing',
|
||||||
|
bodyZh: '每逢绣成新作品,工坊都要盖一枚山茶红火漆。小蚂蚁悄悄说:热乎乎的蜡香最好闻了。',
|
||||||
|
bodyEn: 'Every finished piece earns a camellia wax seal. The ants whisper that warm sealing wax is their favorite scent.',
|
||||||
|
accentColor: '#c4524c',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'starry-atelier',
|
||||||
|
titleZh: '星光下的守夜蚁',
|
||||||
|
titleEn: 'Starlight Night Watch',
|
||||||
|
moodZh: '值班中',
|
||||||
|
moodEn: 'Guarding',
|
||||||
|
bodyZh: '夜深了,一盏小暖灯亮在绣绷旁。别担心线头会丢,工坊小队会乖乖替你攒到明天。',
|
||||||
|
bodyEn: 'A tiny warm lamp glows beside the hoop tonight. Rest easy—the ant crew will keep every thread safe until tomorrow.',
|
||||||
|
accentColor: '#b3893c',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function createDefaultSave(nowMs: number): AtelierSaveData {
|
||||||
|
return {
|
||||||
|
yarnThreads: 16,
|
||||||
|
pendingThreads: 4,
|
||||||
|
lastTickAt: nowMs,
|
||||||
|
unlockedFrames: ['celadon'],
|
||||||
|
unlockedQuotes: ['craft'],
|
||||||
|
activeFrame: 'celadon',
|
||||||
|
activeQuote: 'craft',
|
||||||
|
unlockedDiaries: [ANT_DIARIES[0].id],
|
||||||
|
gallery: [],
|
||||||
|
welcomed: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AtelierService {
|
||||||
|
private data: AtelierSaveData;
|
||||||
|
private readonly persist: (raw: string) => void;
|
||||||
|
|
||||||
|
constructor(loadRaw: () => string | null, saveRaw: (raw: string) => void) {
|
||||||
|
this.persist = saveRaw;
|
||||||
|
this.data = this.parse(loadRaw(), Date.now());
|
||||||
|
this.settleIdle(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
private parse(raw: string | null, nowMs: number): AtelierSaveData {
|
||||||
|
const base = createDefaultSave(nowMs);
|
||||||
|
if (!raw) return base;
|
||||||
|
try {
|
||||||
|
const p = JSON.parse(raw);
|
||||||
|
if (!p || typeof p !== 'object') return base;
|
||||||
|
const validFrames = new Set(POSTER_FRAMES.map(f => f.id));
|
||||||
|
const validQuotes = new Set(POSTER_QUOTES.map(q => q.id));
|
||||||
|
const validDiaries = new Set(ANT_DIARIES.map(d => d.id));
|
||||||
|
|
||||||
|
const unlockedFrames: PosterFrameId[] = Array.isArray(p.unlockedFrames)
|
||||||
|
? p.unlockedFrames.filter((id: any) => validFrames.has(id))
|
||||||
|
: ['celadon'];
|
||||||
|
if (!unlockedFrames.includes('celadon')) unlockedFrames.unshift('celadon');
|
||||||
|
|
||||||
|
const unlockedQuotes: PosterQuoteId[] = Array.isArray(p.unlockedQuotes)
|
||||||
|
? p.unlockedQuotes.filter((id: any) => validQuotes.has(id))
|
||||||
|
: ['craft'];
|
||||||
|
if (!unlockedQuotes.includes('craft')) unlockedQuotes.unshift('craft');
|
||||||
|
|
||||||
|
const unlockedDiaries: string[] = Array.isArray(p.unlockedDiaries)
|
||||||
|
? p.unlockedDiaries.filter((id: any) => validDiaries.has(id))
|
||||||
|
: [ANT_DIARIES[0].id];
|
||||||
|
if (!unlockedDiaries.length) unlockedDiaries.push(ANT_DIARIES[0].id);
|
||||||
|
|
||||||
|
const gallery: GalleryItem[] = Array.isArray(p.gallery)
|
||||||
|
? p.gallery
|
||||||
|
.filter((g: any) => g && Number.isInteger(g.levelIndex) && g.levelIndex >= 0 && g.levelIndex < LEVELS.length)
|
||||||
|
.slice(0, 60)
|
||||||
|
.map((g: any) => ({
|
||||||
|
levelIndex: g.levelIndex,
|
||||||
|
levelId: String(g.levelId ?? LEVELS[g.levelIndex].id),
|
||||||
|
stars: Math.min(3, Math.max(1, Math.round(Number(g.stars) || 1))),
|
||||||
|
length: Math.max(1, Number(g.length) || 100),
|
||||||
|
frameId: validFrames.has(g.frameId) ? g.frameId : 'celadon',
|
||||||
|
quoteId: validQuotes.has(g.quoteId) ? g.quoteId : 'craft',
|
||||||
|
savedAt: Number(g.savedAt) || nowMs,
|
||||||
|
}))
|
||||||
|
: [];
|
||||||
|
|
||||||
|
return {
|
||||||
|
yarnThreads: Math.max(0, Math.floor(Number(p.yarnThreads) || 0)),
|
||||||
|
pendingThreads: Math.min(IDLE_MAX_THREADS, Math.max(0, Math.floor(Number(p.pendingThreads) || 0))),
|
||||||
|
lastTickAt: Number.isFinite(Number(p.lastTickAt)) ? Number(p.lastTickAt) : nowMs,
|
||||||
|
unlockedFrames,
|
||||||
|
unlockedQuotes,
|
||||||
|
activeFrame: validFrames.has(p.activeFrame) && unlockedFrames.includes(p.activeFrame) ? p.activeFrame : 'celadon',
|
||||||
|
activeQuote: validQuotes.has(p.activeQuote) && unlockedQuotes.includes(p.activeQuote) ? p.activeQuote : 'craft',
|
||||||
|
unlockedDiaries,
|
||||||
|
gallery,
|
||||||
|
welcomed: true,
|
||||||
|
};
|
||||||
|
} catch {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private save(): void {
|
||||||
|
this.persist(JSON.stringify(this.data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public getState(): AtelierSaveData {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 按墙钟时间结算离线线头(最多累积 8 小时 = 48 束,永不清零、幂等防溢出) */
|
||||||
|
public settleIdle(nowMs = Date.now()): number {
|
||||||
|
if (nowMs <= this.data.lastTickAt) return 0;
|
||||||
|
const elapsedMin = Math.floor((nowMs - this.data.lastTickAt) / 60000);
|
||||||
|
const gained = Math.floor(elapsedMin / IDLE_MINUTES_PER_THREAD);
|
||||||
|
if (gained <= 0) return 0;
|
||||||
|
|
||||||
|
const room = Math.max(0, IDLE_MAX_THREADS - this.data.pendingThreads);
|
||||||
|
const added = Math.min(room, gained);
|
||||||
|
this.data.pendingThreads += added;
|
||||||
|
// 只推进整周期,保留余数分钟,绝不吞时间
|
||||||
|
this.data.lastTickAt =
|
||||||
|
this.data.pendingThreads >= IDLE_MAX_THREADS
|
||||||
|
? nowMs
|
||||||
|
: this.data.lastTickAt + gained * IDLE_MINUTES_PER_THREAD * 60000;
|
||||||
|
this.save();
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNextThreadMinutes(nowMs = Date.now()): number {
|
||||||
|
if (this.data.pendingThreads >= IDLE_MAX_THREADS) return 0;
|
||||||
|
const elapsedMin = Math.max(0, (nowMs - this.data.lastTickAt) / 60000);
|
||||||
|
return Math.max(1, Math.ceil(IDLE_MINUTES_PER_THREAD - (elapsedMin % IDLE_MINUTES_PER_THREAD)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 收下工坊待领线头,每满 3 束(或首次领取)有机会带回一篇新的蚂蚁日记 */
|
||||||
|
public collectPending(nowMs = Date.now()): { threads: number; newDiary: AntDiaryDef | null } {
|
||||||
|
this.settleIdle(nowMs);
|
||||||
|
const threads = this.data.pendingThreads;
|
||||||
|
if (threads <= 0) return { threads: 0, newDiary: null };
|
||||||
|
|
||||||
|
this.data.yarnThreads += threads;
|
||||||
|
this.data.pendingThreads = 0;
|
||||||
|
this.data.lastTickAt = nowMs;
|
||||||
|
|
||||||
|
let newDiary: AntDiaryDef | null = null;
|
||||||
|
const locked = ANT_DIARIES.filter(d => !this.data.unlockedDiaries.includes(d.id));
|
||||||
|
if (locked.length > 0 && (threads >= 2 || this.data.unlockedDiaries.length < 3)) {
|
||||||
|
const idx = (Math.floor(nowMs / 60000) + this.data.yarnThreads) % locked.length;
|
||||||
|
newDiary = locked[idx];
|
||||||
|
this.data.unlockedDiaries.push(newDiary.id);
|
||||||
|
}
|
||||||
|
this.save();
|
||||||
|
return { threads, newDiary };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 通关奖励:首次/提升星级送少量线头,同时把作品沉淀进轻量展柜(不存大图) */
|
||||||
|
public recordCompletedArtwork(levelIndex: number, level: LevelDef, stars: number, length: number, improved: boolean): number {
|
||||||
|
const bonus = improved ? stars + 2 : 1;
|
||||||
|
this.data.yarnThreads += bonus;
|
||||||
|
|
||||||
|
const existing = this.data.gallery.find(item => item.levelIndex === levelIndex);
|
||||||
|
if (existing) {
|
||||||
|
if (stars > existing.stars || (stars === existing.stars && length < existing.length)) {
|
||||||
|
existing.stars = stars;
|
||||||
|
existing.length = length;
|
||||||
|
}
|
||||||
|
existing.frameId = this.data.activeFrame;
|
||||||
|
existing.quoteId = this.data.activeQuote;
|
||||||
|
existing.savedAt = Date.now();
|
||||||
|
} else {
|
||||||
|
this.data.gallery.unshift({
|
||||||
|
levelIndex,
|
||||||
|
levelId: recordKey(level),
|
||||||
|
stars,
|
||||||
|
length,
|
||||||
|
frameId: this.data.activeFrame,
|
||||||
|
quoteId: this.data.activeQuote,
|
||||||
|
savedAt: Date.now(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.data.gallery.sort((a, b) => a.levelIndex - b.levelIndex);
|
||||||
|
this.save();
|
||||||
|
return bonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将旧存档中已通关但未进展柜的作品同步补齐,保证老玩家打开展柜即有藏品 */
|
||||||
|
public syncFromLegacyRecords(getRecord: (lv: LevelDef) => { stars: number; length: number } | undefined): void {
|
||||||
|
let changed = false;
|
||||||
|
for (let i = 0; i < LEVELS.length; i++) {
|
||||||
|
const rec = getRecord(LEVELS[i]);
|
||||||
|
if (!rec || rec.stars <= 0) continue;
|
||||||
|
const hit = this.data.gallery.find(g => g.levelIndex === i);
|
||||||
|
if (!hit) {
|
||||||
|
this.data.gallery.push({
|
||||||
|
levelIndex: i,
|
||||||
|
levelId: recordKey(LEVELS[i]),
|
||||||
|
stars: rec.stars,
|
||||||
|
length: rec.length,
|
||||||
|
frameId: this.data.activeFrame,
|
||||||
|
quoteId: this.data.activeQuote,
|
||||||
|
savedAt: Date.now(),
|
||||||
|
});
|
||||||
|
changed = true;
|
||||||
|
} else if (rec.stars > hit.stars) {
|
||||||
|
hit.stars = rec.stars;
|
||||||
|
hit.length = rec.length;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) {
|
||||||
|
this.data.gallery.sort((a, b) => a.levelIndex - b.levelIndex);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getFrameDef(id: PosterFrameId = this.data.activeFrame): PosterFrameDef {
|
||||||
|
return POSTER_FRAMES.find(f => f.id === id) ?? POSTER_FRAMES[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getQuoteDef(id: PosterQuoteId = this.data.activeQuote): PosterQuoteDef {
|
||||||
|
return POSTER_QUOTES.find(q => q.id === id) ?? POSTER_QUOTES[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public selectOrUnlockFrame(id: PosterFrameId): { ok: boolean; unlockedNow: boolean; need?: number } {
|
||||||
|
const def = this.getFrameDef(id);
|
||||||
|
if (this.data.unlockedFrames.includes(id)) {
|
||||||
|
this.data.activeFrame = id;
|
||||||
|
this.save();
|
||||||
|
return { ok: true, unlockedNow: false };
|
||||||
|
}
|
||||||
|
if (this.data.yarnThreads < def.cost) {
|
||||||
|
return { ok: false, unlockedNow: false, need: def.cost - this.data.yarnThreads };
|
||||||
|
}
|
||||||
|
this.data.yarnThreads -= def.cost;
|
||||||
|
this.data.unlockedFrames.push(id);
|
||||||
|
this.data.activeFrame = id;
|
||||||
|
this.save();
|
||||||
|
return { ok: true, unlockedNow: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
public selectOrUnlockQuote(id: PosterQuoteId): { ok: boolean; unlockedNow: boolean; need?: number } {
|
||||||
|
const def = this.getQuoteDef(id);
|
||||||
|
if (this.data.unlockedQuotes.includes(id)) {
|
||||||
|
this.data.activeQuote = id;
|
||||||
|
this.save();
|
||||||
|
return { ok: true, unlockedNow: false };
|
||||||
|
}
|
||||||
|
if (this.data.yarnThreads < def.cost) {
|
||||||
|
return { ok: false, unlockedNow: false, need: def.cost - this.data.yarnThreads };
|
||||||
|
}
|
||||||
|
this.data.yarnThreads -= def.cost;
|
||||||
|
this.data.unlockedQuotes.push(id);
|
||||||
|
this.data.activeQuote = id;
|
||||||
|
this.save();
|
||||||
|
return { ok: true, unlockedNow: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
public isChapterReplyUnlocked(
|
||||||
|
chapterIndex: number,
|
||||||
|
getRecord: (lv: LevelDef) => { stars: number; length: number } | undefined,
|
||||||
|
): boolean {
|
||||||
|
const ch = CHAPTERS[chapterIndex];
|
||||||
|
if (!ch) return false;
|
||||||
|
// 第一章完成第 1 关向日葵即拆阅林阿婆回信,让首局立刻闭环「委托 → 织画 → 入柜 → 回信」
|
||||||
|
if (chapterIndex === 0) {
|
||||||
|
return Boolean(getRecord(LEVELS[0])?.stars);
|
||||||
|
}
|
||||||
|
const slice = LEVELS.slice(ch.startIndex, ch.startIndex + ch.count);
|
||||||
|
const chStars = slice.reduce((sum, lv) => sum + (getRecord(lv)?.stars ?? 0), 0);
|
||||||
|
const bossCleared = Boolean(getRecord(slice[slice.length - 1])?.stars);
|
||||||
|
return bossCleared || chStars >= 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLetter(chapterIndex: number): ChapterLetterDef {
|
||||||
|
return CHAPTER_LETTERS[chapterIndex] ?? CHAPTER_LETTERS[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getUnlockedDiaries(): AntDiaryDef[] {
|
||||||
|
return ANT_DIARIES.filter(d => this.data.unlockedDiaries.includes(d.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "f77d2130-97db-4b99-badc-688e99c8480e",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "970b0916-4b65-4081-8775-a00e35b1257e",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,730 @@
|
|||||||
|
import { HOOP_CENTER, NEST, RIM_LIMIT, YARN_COLORS } from './LevelData';
|
||||||
|
import {
|
||||||
|
BallDef,
|
||||||
|
BlockReason,
|
||||||
|
ButtonAnchorDef,
|
||||||
|
ButtonEvent,
|
||||||
|
DeliveryEvent,
|
||||||
|
DyeEvent,
|
||||||
|
DyeVatDef,
|
||||||
|
GateDef,
|
||||||
|
GateEvent,
|
||||||
|
HintState,
|
||||||
|
LevelDef,
|
||||||
|
PickEvent,
|
||||||
|
Point2D,
|
||||||
|
PondDef,
|
||||||
|
RouteEvent,
|
||||||
|
RouteState,
|
||||||
|
SectionDef,
|
||||||
|
SpoolDef,
|
||||||
|
SpoolEvent,
|
||||||
|
TargetColor,
|
||||||
|
YarnColor,
|
||||||
|
} from './Types';
|
||||||
|
|
||||||
|
export const ANT_SPEED = 0.264;
|
||||||
|
export const STITCH_TIME = 710;
|
||||||
|
|
||||||
|
export function isPickEvent(event: RouteEvent): event is PickEvent {
|
||||||
|
return event.kind === 'pick';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isDeliveryEvent(event: RouteEvent): event is DeliveryEvent {
|
||||||
|
return event.kind === 'delivery';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isSpoolEvent(event: RouteEvent): event is SpoolEvent {
|
||||||
|
return event.kind === 'spool';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isButtonEvent(event: RouteEvent): event is ButtonEvent {
|
||||||
|
return event.kind === 'button';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isDyeEvent(event: RouteEvent): event is DyeEvent {
|
||||||
|
return event.kind === 'dye';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isGateEvent(event: RouteEvent): event is GateEvent {
|
||||||
|
return event.kind === 'gate';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function distance(a: Point2D, b: Point2D): number {
|
||||||
|
return Math.hypot(a.x - b.x, a.y - b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function interpolate(a: Point2D, b: Point2D, t: number): Point2D {
|
||||||
|
return { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function closestFraction(start: Point2D, end: Point2D, point: Point2D, scaleX = 1, scaleY = 1): number {
|
||||||
|
const dx = (end.x - start.x) / scaleX;
|
||||||
|
const dy = (end.y - start.y) / scaleY;
|
||||||
|
const fx = (point.x - start.x) / scaleX;
|
||||||
|
const fy = (point.y - start.y) / scaleY;
|
||||||
|
const length = dx * dx + dy * dy;
|
||||||
|
return length ? Math.max(0, Math.min(1, (fx * dx + fy * dy) / length)) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function intersectsPond(start: Point2D, end: Point2D, pond: PondDef): boolean {
|
||||||
|
const t = closestFraction(start, end, pond, pond.rx, pond.ry);
|
||||||
|
const point = interpolate(start, end, t);
|
||||||
|
return Math.hypot((point.x - pond.x) / pond.rx, (point.y - pond.y) / pond.ry) < 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hitSpan(from: Point2D, to: Point2D, center: Point2D, rx: number, ry: number): { enter: number; leave: number } | null {
|
||||||
|
const x = (from.x - center.x) / rx;
|
||||||
|
const y = (from.y - center.y) / ry;
|
||||||
|
const dx = (to.x - from.x) / rx;
|
||||||
|
const dy = (to.y - from.y) / ry;
|
||||||
|
const a = dx * dx + dy * dy;
|
||||||
|
if (a < 1e-8) {
|
||||||
|
return x * x + y * y <= 1 ? { enter: 0, leave: 1 } : null;
|
||||||
|
}
|
||||||
|
const b = x * dx + y * dy;
|
||||||
|
const d = b * b - a * (x * x + y * y - 1);
|
||||||
|
if (d < 0) return null;
|
||||||
|
const root = Math.sqrt(d);
|
||||||
|
const enter = Math.max(0, (-b - root) / a);
|
||||||
|
const leave = Math.min(1, (-b + root) / a);
|
||||||
|
return enter <= leave ? { enter, leave } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function orient(a: Point2D, b: Point2D, c: Point2D): number {
|
||||||
|
return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function segmentsIntersect(a: Point2D, b: Point2D, c: Point2D, d: Point2D): boolean {
|
||||||
|
const minAx = Math.min(a.x, b.x) - 1;
|
||||||
|
const maxAx = Math.max(a.x, b.x) + 1;
|
||||||
|
const minAy = Math.min(a.y, b.y) - 1;
|
||||||
|
const maxAy = Math.max(a.y, b.y) + 1;
|
||||||
|
const minCx = Math.min(c.x, d.x) - 1;
|
||||||
|
const maxCx = Math.max(c.x, d.x) + 1;
|
||||||
|
const minCy = Math.min(c.y, d.y) - 1;
|
||||||
|
const maxCy = Math.max(c.y, d.y) + 1;
|
||||||
|
if (maxAx < minCx || maxCx < minAx || maxAy < minCy || maxCy < minAy) return false;
|
||||||
|
const o1 = orient(a, b, c);
|
||||||
|
const o2 = orient(a, b, d);
|
||||||
|
const o3 = orient(c, d, a);
|
||||||
|
const o4 = orient(c, d, b);
|
||||||
|
return (o1 * o2 < 0) && (o3 * o4 < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function segmentCost(level: LevelDef, from: Point2D, to: Point2D, segLen: number): number {
|
||||||
|
if (!level.roughZones.length || segLen <= 0) return segLen;
|
||||||
|
let extraFactor = 0;
|
||||||
|
for (const zone of level.roughZones) {
|
||||||
|
const span = hitSpan(from, to, zone, zone.rx, zone.ry);
|
||||||
|
if (span && span.leave > span.enter) {
|
||||||
|
const overlap = span.leave - span.enter;
|
||||||
|
const zoneExtra = Math.max(0, (zone.factor ?? 1.8) - 1) * overlap;
|
||||||
|
if (zoneExtra > extraFactor) extraFactor = zoneExtra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return segLen * (1 + extraFactor);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createEmptyRoute(showTip = false, nest: Point2D = NEST): RouteState {
|
||||||
|
return {
|
||||||
|
nest: { ...nest },
|
||||||
|
points: [{ ...nest }],
|
||||||
|
cum: [0],
|
||||||
|
costCum: [0],
|
||||||
|
len: 0,
|
||||||
|
cost: 0,
|
||||||
|
picks: [],
|
||||||
|
deliveries: [],
|
||||||
|
spools: [],
|
||||||
|
buttons: [],
|
||||||
|
dyes: [],
|
||||||
|
gates: [],
|
||||||
|
events: [],
|
||||||
|
color: null,
|
||||||
|
blocked: null,
|
||||||
|
showTip,
|
||||||
|
startedAt: 0,
|
||||||
|
carry: [],
|
||||||
|
ant: { ...nest, angle: -Math.PI / 2, carry: [], walk: true },
|
||||||
|
finished: false,
|
||||||
|
arrivedAt: 0,
|
||||||
|
segment: 1,
|
||||||
|
nextEvent: 0,
|
||||||
|
duration: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function totalLength(lines: RouteState[]): number {
|
||||||
|
return lines.reduce((sum, line) => sum + line.cost, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function collectedSpoolBonus(lines: RouteState[], drawing?: RouteState | null): number {
|
||||||
|
let bonus = 0;
|
||||||
|
for (const line of lines) {
|
||||||
|
for (const sp of line.spools) bonus += sp.spool.bonus;
|
||||||
|
}
|
||||||
|
if (drawing) {
|
||||||
|
for (const sp of drawing.spools) bonus += sp.spool.bonus;
|
||||||
|
}
|
||||||
|
return bonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function effectiveBudget(level: LevelDef, lines: RouteState[], drawing?: RouteState | null): number | undefined {
|
||||||
|
if (!level.budget) return undefined;
|
||||||
|
return level.budget + collectedSpoolBonus(lines, drawing);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isPondBridged(pond: PondDef, lines: RouteState[]): boolean {
|
||||||
|
if (!pond.bridgeSectionId) return false;
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.deliveries.some(d => d.target.id === pond.bridgeSectionId)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isTargetLocked(
|
||||||
|
level: LevelDef,
|
||||||
|
targetId: string,
|
||||||
|
lines: RouteState[],
|
||||||
|
drawing?: RouteState | null,
|
||||||
|
): boolean {
|
||||||
|
const reqId = level.locks?.[targetId];
|
||||||
|
if (!reqId) return false;
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.deliveries.some(d => d.target.id === reqId)) return false;
|
||||||
|
}
|
||||||
|
if (drawing && drawing.deliveries.some(d => d.target.id === reqId)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dyeUsedCount(dyeId: number, lines: RouteState[], drawing?: RouteState | null): number {
|
||||||
|
let count = 0;
|
||||||
|
for (const line of lines) {
|
||||||
|
for (const ev of line.dyes) if (ev.dye.id === dyeId) count++;
|
||||||
|
}
|
||||||
|
if (drawing) {
|
||||||
|
for (const ev of drawing.dyes) if (ev.dye.id === dyeId) count++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dyeRemainingUses(dye: DyeVatDef, lines: RouteState[], drawing?: RouteState | null): number {
|
||||||
|
if (dye.uses === undefined) return Infinity;
|
||||||
|
return Math.max(0, dye.uses - dyeUsedCount(dye.id, lines, drawing));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function availableTargets(level: LevelDef, lines: RouteState[], color?: YarnColor | null): SectionDef[] {
|
||||||
|
const used = new Set<string>();
|
||||||
|
for (const line of lines) {
|
||||||
|
for (const d of line.deliveries) used.add(d.target.id);
|
||||||
|
}
|
||||||
|
return level.targets.filter(target => (!color || target.color === color) && !used.has(target.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function threadedButtonIds(lines: RouteState[], drawing?: RouteState | null): Set<number> {
|
||||||
|
const ids = new Set<number>();
|
||||||
|
for (const line of lines) for (const b of line.buttons) ids.add(b.button.id);
|
||||||
|
if (drawing) for (const b of drawing.buttons) ids.add(b.button.id);
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function passedGateIds(lines: RouteState[], drawing?: RouteState | null): Set<number> {
|
||||||
|
const ids = new Set<number>();
|
||||||
|
for (const line of lines) for (const g of line.gates) ids.add(g.gate.id);
|
||||||
|
if (drawing) for (const g of drawing.gates) ids.add(g.gate.id);
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function dispatchWarning(level: LevelDef, lines: RouteState[]): string {
|
||||||
|
if (!level.maxDispatches) return '';
|
||||||
|
const remaining = level.maxDispatches - lines.length;
|
||||||
|
const targets = availableTargets(level, lines);
|
||||||
|
const hasOverrideDye = level.dyes.some(d => d.override && dyeRemainingUses(d, lines) > 0);
|
||||||
|
const trips = hasOverrideDye
|
||||||
|
? Math.ceil(targets.length / 2)
|
||||||
|
: YARN_COLORS.reduce(
|
||||||
|
(sum, color) => sum + Math.ceil(targets.filter(t => t.color === color).length / 2),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
if (trips > remaining) {
|
||||||
|
return `剩 ${remaining} 笔、${targets.length} 个针位,撤销一笔把球串起来。`;
|
||||||
|
}
|
||||||
|
const missingButtons = level.buttons.filter(b => !threadedButtonIds(lines).has(b.id)).length;
|
||||||
|
const missingGates = level.gates.filter(g => !passedGateIds(lines).has(g.id)).length;
|
||||||
|
if (remaining === 0 && (missingButtons > 0 || missingGates > 0)) {
|
||||||
|
return missingButtons > 0
|
||||||
|
? `还有 ${missingButtons} 颗纽扣未穿过,请撤销重画。`
|
||||||
|
: `还有 ${missingGates} 处穿针眼未穿过,请撤销重画。`;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function scoreForLength(level: LevelDef, used: number): number {
|
||||||
|
return used <= level.threeStar ? 3 : used <= level.twoStar ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function rollbackToLength(route: RouteState, newLen: number, newCost: number): void {
|
||||||
|
route.len = newLen;
|
||||||
|
route.cost = newCost;
|
||||||
|
route.picks = route.picks.filter(e => e.at <= newLen);
|
||||||
|
route.deliveries = route.deliveries.filter(e => e.at <= newLen);
|
||||||
|
route.spools = route.spools.filter(e => e.at <= newLen);
|
||||||
|
route.buttons = route.buttons.filter(e => e.at <= newLen);
|
||||||
|
route.dyes = route.dyes.filter(e => e.at <= newLen);
|
||||||
|
route.gates = route.gates.filter(e => e.at <= newLen);
|
||||||
|
route.events = route.events.filter(e => e.at <= newLen);
|
||||||
|
|
||||||
|
// 根据保留的事件重算当前毛线颜色(支持白球染色后回退还原成白色)
|
||||||
|
let color: YarnColor | null = null;
|
||||||
|
for (const ev of route.events) {
|
||||||
|
if (isPickEvent(ev) && color === null) {
|
||||||
|
color = ev.ball.color;
|
||||||
|
} else if (isDyeEvent(ev) && color !== null) {
|
||||||
|
color = ev.dye.color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
route.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function tryBacktrack(route: RouteState, point: Point2D): boolean {
|
||||||
|
let retracted = false;
|
||||||
|
while (route.points.length >= 2) {
|
||||||
|
const tip = route.points[route.points.length - 1];
|
||||||
|
const prev = route.points[route.points.length - 2];
|
||||||
|
const segLen = distance(prev, tip);
|
||||||
|
const dPrev = distance(point, prev);
|
||||||
|
const dTip = distance(point, tip);
|
||||||
|
if (dPrev + 1.5 < dTip && dPrev <= Math.max(segLen * 1.1, 14)) {
|
||||||
|
route.points.pop();
|
||||||
|
route.cum.pop();
|
||||||
|
route.costCum.pop();
|
||||||
|
rollbackToLength(route, route.cum[route.cum.length - 1], route.costCum[route.costCum.length - 1]);
|
||||||
|
retracted = true;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlanCallbacks {
|
||||||
|
onPick?: (count: number) => void;
|
||||||
|
onMark?: (count: number) => void;
|
||||||
|
onLocked?: () => void;
|
||||||
|
onSpool?: (bonus: number) => void;
|
||||||
|
onButton?: () => void;
|
||||||
|
onDye?: (color: TargetColor) => void;
|
||||||
|
onGate?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type HitCandidate =
|
||||||
|
| { kind: 'pick'; ball: BallDef; span: { enter: number; leave: number } }
|
||||||
|
| { kind: 'delivery'; target: SectionDef; span: { enter: number; leave: number } }
|
||||||
|
| { kind: 'spool'; spool: SpoolDef; span: { enter: number; leave: number } }
|
||||||
|
| { kind: 'button'; button: ButtonAnchorDef; span: { enter: number; leave: number } }
|
||||||
|
| { kind: 'dye'; dye: DyeVatDef; span: { enter: number; leave: number } }
|
||||||
|
| { kind: 'gate'; gate: GateDef; span: { enter: number; leave: number } };
|
||||||
|
|
||||||
|
export function planStops(
|
||||||
|
level: LevelDef,
|
||||||
|
lines: RouteState[],
|
||||||
|
route: RouteState,
|
||||||
|
from: Point2D,
|
||||||
|
to: Point2D,
|
||||||
|
startLength: number,
|
||||||
|
length: number,
|
||||||
|
cb?: PlanCallbacks,
|
||||||
|
): void {
|
||||||
|
const takenBalls = new Set<number>();
|
||||||
|
for (const line of lines) for (const p of line.picks) takenBalls.add(p.ball.id);
|
||||||
|
for (const p of route.picks) takenBalls.add(p.ball.id);
|
||||||
|
|
||||||
|
const takenSpools = new Set<number>();
|
||||||
|
for (const line of lines) for (const s of line.spools) takenSpools.add(s.spool.id);
|
||||||
|
for (const s of route.spools) takenSpools.add(s.spool.id);
|
||||||
|
|
||||||
|
const takenButtons = threadedButtonIds(lines, route);
|
||||||
|
const takenGates = passedGateIds(lines, route);
|
||||||
|
|
||||||
|
const candidates: HitCandidate[] = [];
|
||||||
|
|
||||||
|
for (const ball of level.balls) {
|
||||||
|
if (takenBalls.has(ball.id)) continue;
|
||||||
|
const span = hitSpan(from, to, ball, 28, 28);
|
||||||
|
if (span) candidates.push({ kind: 'pick', ball, span });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const spool of level.spools) {
|
||||||
|
if (takenSpools.has(spool.id)) continue;
|
||||||
|
const span = hitSpan(from, to, spool, 26, 26);
|
||||||
|
if (span) candidates.push({ kind: 'spool', spool, span });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const button of level.buttons) {
|
||||||
|
if (takenButtons.has(button.id)) continue;
|
||||||
|
const span = hitSpan(from, to, button, 26, 26);
|
||||||
|
if (span) candidates.push({ kind: 'button', button, span });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const dye of level.dyes) {
|
||||||
|
const span = hitSpan(from, to, dye, 28, 28);
|
||||||
|
if (span) candidates.push({ kind: 'dye', dye, span });
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const gate of level.gates) {
|
||||||
|
if (takenGates.has(gate.id)) continue;
|
||||||
|
const r = gate.radius ?? 25;
|
||||||
|
const span = hitSpan(from, to, gate, r, r);
|
||||||
|
if (span) candidates.push({ kind: 'gate', gate, span });
|
||||||
|
}
|
||||||
|
|
||||||
|
const marked = new Set(route.deliveries.map(stop => stop.target.id));
|
||||||
|
const targetHits: { target: SectionDef; span: { enter: number; leave: number } }[] = [];
|
||||||
|
for (const target of availableTargets(level, lines)) {
|
||||||
|
if (marked.has(target.id)) continue;
|
||||||
|
const span = hitSpan(from, to, target, target.rx, target.ry);
|
||||||
|
if (span) {
|
||||||
|
targetHits.push({ target, span });
|
||||||
|
candidates.push({ kind: 'delivery', target, span });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
candidates.sort((a, b) => a.span.enter - b.span.enter);
|
||||||
|
|
||||||
|
const markDelivery = (target: SectionDef, t: number) => {
|
||||||
|
if (!route.color || route.color === 'white') return;
|
||||||
|
if (target.color !== route.color || marked.has(target.id) || route.deliveries.length === route.picks.length) return;
|
||||||
|
if (isTargetLocked(level, target.id, lines, route)) {
|
||||||
|
cb?.onLocked?.();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const stop: DeliveryEvent = { kind: 'delivery', target, at: startLength + length * t, origin: interpolate(from, to, t) };
|
||||||
|
marked.add(target.id);
|
||||||
|
route.deliveries.push(stop);
|
||||||
|
route.events.push(stop);
|
||||||
|
cb?.onMark?.(route.deliveries.length);
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const entry of candidates) {
|
||||||
|
const enter = entry.span.enter;
|
||||||
|
if (entry.kind === 'delivery') {
|
||||||
|
markDelivery(entry.target, enter);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (entry.kind === 'spool') {
|
||||||
|
if (takenSpools.has(entry.spool.id)) continue;
|
||||||
|
takenSpools.add(entry.spool.id);
|
||||||
|
const ev: SpoolEvent = { kind: 'spool', spool: entry.spool, at: startLength + length * enter };
|
||||||
|
route.spools.push(ev);
|
||||||
|
route.events.push(ev);
|
||||||
|
cb?.onSpool?.(entry.spool.bonus);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (entry.kind === 'button') {
|
||||||
|
if (takenButtons.has(entry.button.id)) continue;
|
||||||
|
takenButtons.add(entry.button.id);
|
||||||
|
const ev: ButtonEvent = { kind: 'button', button: entry.button, at: startLength + length * enter };
|
||||||
|
route.buttons.push(ev);
|
||||||
|
route.events.push(ev);
|
||||||
|
cb?.onButton?.();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (entry.kind === 'gate') {
|
||||||
|
if (takenGates.has(entry.gate.id)) continue;
|
||||||
|
takenGates.add(entry.gate.id);
|
||||||
|
const ev: GateEvent = { kind: 'gate', gate: entry.gate, at: startLength + length * enter };
|
||||||
|
route.gates.push(ev);
|
||||||
|
route.events.push(ev);
|
||||||
|
cb?.onGate?.();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (entry.kind === 'dye') {
|
||||||
|
if (dyeRemainingUses(entry.dye, lines, route) <= 0) continue;
|
||||||
|
// 染缸:手上有球且未全部落针时染色;普通染缸只染白球,覆色染缸可强行改色
|
||||||
|
const canDye =
|
||||||
|
route.picks.length > 0 &&
|
||||||
|
route.deliveries.length < route.picks.length &&
|
||||||
|
route.color !== entry.dye.color &&
|
||||||
|
(route.color === 'white' || Boolean(entry.dye.override));
|
||||||
|
if (canDye) {
|
||||||
|
route.color = entry.dye.color;
|
||||||
|
const ev: DyeEvent = { kind: 'dye', dye: entry.dye, at: startLength + length * enter };
|
||||||
|
route.dyes.push(ev);
|
||||||
|
route.events.push(ev);
|
||||||
|
cb?.onDye?.(entry.dye.color);
|
||||||
|
for (const hit of targetHits) {
|
||||||
|
if (hit.span.enter <= enter && enter <= hit.span.leave) markDelivery(hit.target, enter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// pick
|
||||||
|
const ball = entry.ball;
|
||||||
|
if (route.picks.length >= 2) continue;
|
||||||
|
if (route.color && route.color !== ball.color) continue;
|
||||||
|
if (!route.color) route.color = ball.color;
|
||||||
|
const pick: PickEvent = { kind: 'pick', ball, at: startLength + length * enter };
|
||||||
|
route.picks.push(pick);
|
||||||
|
route.events.push(pick);
|
||||||
|
cb?.onPick?.(route.picks.length);
|
||||||
|
for (const hit of targetHits) {
|
||||||
|
if (hit.span.enter <= enter && enter <= hit.span.leave) markDelivery(hit.target, enter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkSegmentBlock(
|
||||||
|
level: LevelDef,
|
||||||
|
lines: RouteState[],
|
||||||
|
route: RouteState,
|
||||||
|
from: Point2D,
|
||||||
|
to: Point2D,
|
||||||
|
segLen: number,
|
||||||
|
): BlockReason | null {
|
||||||
|
if (level.ponds.some(pond => !isPondBridged(pond, lines) && intersectsPond(from, to, pond))) return 'pond';
|
||||||
|
if (
|
||||||
|
Math.hypot(from.x - HOOP_CENTER.x, from.y - HOOP_CENTER.y) > RIM_LIMIT ||
|
||||||
|
Math.hypot(to.x - HOOP_CENTER.x, to.y - HOOP_CENTER.y) > RIM_LIMIT
|
||||||
|
) {
|
||||||
|
return 'rim';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实体毛线球阻挡:不可穿过异色或已满载时的未拾毛线球
|
||||||
|
if (level.solidBalls) {
|
||||||
|
const takenBalls = new Set<number>();
|
||||||
|
for (const line of lines) for (const p of line.picks) takenBalls.add(p.ball.id);
|
||||||
|
for (const p of route.picks) takenBalls.add(p.ball.id);
|
||||||
|
for (const ball of level.balls) {
|
||||||
|
if (takenBalls.has(ball.id)) continue;
|
||||||
|
const cannotPick = route.picks.length >= 2 || (route.color !== null && route.color !== ball.color);
|
||||||
|
if (cannotPick && hitSpan(from, to, ball, 22, 22)) return 'ball';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单向穿针眼校验:碰到未穿过的针眼时,行进方向必须与箭头夹角 < ~80°
|
||||||
|
if (level.gates.length > 0 && segLen > 0.5) {
|
||||||
|
const dirX = (to.x - from.x) / segLen;
|
||||||
|
const dirY = (to.y - from.y) / segLen;
|
||||||
|
const passed = passedGateIds(lines, route);
|
||||||
|
for (const gate of level.gates) {
|
||||||
|
if (passed.has(gate.id)) continue;
|
||||||
|
const r = gate.radius ?? 25;
|
||||||
|
if (hitSpan(from, to, gate, r, r)) {
|
||||||
|
const dot = dirX * Math.cos(gate.angle) + dirY * Math.sin(gate.angle);
|
||||||
|
if (dot < 0.15) return 'gate';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不可交叉校验:禁止压过任何已提交毛线的线段(共享蚁巢出口 24px 内豁免)
|
||||||
|
if (level.noCross && lines.length > 0) {
|
||||||
|
const nearAnyNest = level.nests.some(n => distance(from, n) < 24 && distance(to, n) < 24);
|
||||||
|
if (!nearAnyNest) {
|
||||||
|
for (const prevLine of lines) {
|
||||||
|
const pts = prevLine.points;
|
||||||
|
for (let i = 1; i < pts.length; i++) {
|
||||||
|
const a = pts[i - 1];
|
||||||
|
const b = pts[i];
|
||||||
|
if (level.nests.some(n => distance(a, n) < 24 && distance(b, n) < 24)) continue;
|
||||||
|
if (segmentsIntersect(from, to, a, b)) return 'cross';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const budget = effectiveBudget(level, lines, route);
|
||||||
|
if (budget !== undefined) {
|
||||||
|
const costAdd = segmentCost(level, from, to, segLen);
|
||||||
|
if (totalLength(lines) + route.cost + costAdd > budget) return 'budget';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function trimRouteTail(route: RouteState): void {
|
||||||
|
const lastEvent = route.events[route.events.length - 1];
|
||||||
|
if (!lastEvent || lastEvent.at >= route.len - 0.5) return;
|
||||||
|
const cutAt = lastEvent.at;
|
||||||
|
let seg = 1;
|
||||||
|
while (seg < route.cum.length - 1 && route.cum[seg] < cutAt) seg++;
|
||||||
|
const prevLen = route.cum[seg - 1];
|
||||||
|
const nextLen = route.cum[seg];
|
||||||
|
const t = nextLen > prevLen ? Math.max(0, Math.min(1, (cutAt - prevLen) / (nextLen - prevLen))) : 0;
|
||||||
|
const endPoint = interpolate(route.points[seg - 1], route.points[seg], t);
|
||||||
|
const prevCost = route.costCum[seg - 1];
|
||||||
|
const nextCost = route.costCum[seg];
|
||||||
|
const endCost = prevCost + (nextCost - prevCost) * t;
|
||||||
|
route.points = [...route.points.slice(0, seg), endPoint];
|
||||||
|
route.cum = [...route.cum.slice(0, seg), cutAt];
|
||||||
|
route.costCum = [...route.costCum.slice(0, seg), endCost];
|
||||||
|
route.len = cutAt;
|
||||||
|
route.cost = endCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function prepareRouteForRun(route: RouteState, startedAt: number): void {
|
||||||
|
route.blocked = null;
|
||||||
|
route.startedAt = startedAt;
|
||||||
|
route.carry = [];
|
||||||
|
route.ant = { ...route.nest, angle: -Math.PI / 2, carry: route.carry, walk: true };
|
||||||
|
route.finished = false;
|
||||||
|
route.arrivedAt = 0;
|
||||||
|
route.segment = 1;
|
||||||
|
route.nextEvent = 0;
|
||||||
|
|
||||||
|
let stopTime = 0;
|
||||||
|
for (const event of route.events) {
|
||||||
|
event.ms = event.at / ANT_SPEED + stopTime;
|
||||||
|
event.hold = isPickEvent(event) ? 135 : isDeliveryEvent(event) ? 160 : 75;
|
||||||
|
stopTime += event.hold;
|
||||||
|
}
|
||||||
|
route.duration = route.len / ANT_SPEED + stopTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findNextHint(level: LevelDef, lines: RouteState[], tier: 1 | 2 | 3 = 1): HintState {
|
||||||
|
const takenBalls = new Set<number>();
|
||||||
|
for (const line of lines) for (const p of line.picks) takenBalls.add(p.ball.id);
|
||||||
|
const remainingBalls = level.balls.filter(b => !takenBalls.has(b.id));
|
||||||
|
const remTargets = availableTargets(level, lines);
|
||||||
|
|
||||||
|
let chosen = level.demo[Math.min(lines.length, level.demo.length - 1)];
|
||||||
|
let firstBall: BallDef | null = null;
|
||||||
|
let firstBallIndex = 1;
|
||||||
|
for (const path of level.demo) {
|
||||||
|
let hit: BallDef | undefined;
|
||||||
|
let hitIdx = 1;
|
||||||
|
for (let i = 1; i < path.length; i++) {
|
||||||
|
const [x, y] = path[i];
|
||||||
|
hit = remainingBalls.find(ball => Math.hypot(x - ball.x, y - ball.y) < 34);
|
||||||
|
if (hit) {
|
||||||
|
hitIdx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const prev = { x: path[i - 1][0], y: path[i - 1][1] };
|
||||||
|
const cur = { x, y };
|
||||||
|
hit = remainingBalls.find(ball => hitSpan(prev, cur, ball, 28, 28) !== null);
|
||||||
|
if (hit) {
|
||||||
|
hitIdx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hit) {
|
||||||
|
chosen = path;
|
||||||
|
firstBall = hit;
|
||||||
|
firstBallIndex = hitIdx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const fullPts = (chosen ?? level.demo[0] ?? []).map(([x, y]) => ({ x, y }));
|
||||||
|
|
||||||
|
let firstTarget: SectionDef | null = null;
|
||||||
|
for (let i = 1; i < fullPts.length; i++) {
|
||||||
|
const pt = fullPts[i];
|
||||||
|
const hit = remTargets.find(t => Math.hypot((pt.x - t.x) / t.rx, (pt.y - t.y) / t.ry) <= 1.05);
|
||||||
|
if (hit) {
|
||||||
|
firstTarget = hit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let points = fullPts;
|
||||||
|
if (tier === 1) {
|
||||||
|
// 1 级提示:沿真实 demo 折线截取到第一颗球,保留绕开水洼的中间拐点(避免直线穿水洼)
|
||||||
|
points = fullPts.length >= 2 ? fullPts.slice(0, Math.min(fullPts.length, firstBallIndex + 1)) : fullPts;
|
||||||
|
} else if (tier === 2 && fullPts.length >= 2) {
|
||||||
|
// 2 级提示:截取该笔折线的前半程(按长度 52%)
|
||||||
|
let total = 0;
|
||||||
|
for (let i = 1; i < fullPts.length; i++) total += distance(fullPts[i - 1], fullPts[i]);
|
||||||
|
const halfLen = total * 0.52;
|
||||||
|
const sliced: Point2D[] = [fullPts[0]];
|
||||||
|
let acc = 0;
|
||||||
|
for (let i = 1; i < fullPts.length; i++) {
|
||||||
|
const seg = distance(fullPts[i - 1], fullPts[i]);
|
||||||
|
if (acc + seg >= halfLen) {
|
||||||
|
const t = seg > 0 ? (halfLen - acc) / seg : 0;
|
||||||
|
sliced.push(interpolate(fullPts[i - 1], fullPts[i], Math.max(0, Math.min(1, t))));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sliced.push(fullPts[i]);
|
||||||
|
acc += seg;
|
||||||
|
}
|
||||||
|
points = sliced;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { tier, points, ball: firstBall, target: firstTarget };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 自动化验关器:用真实引擎规则跑完整关 demo,返回是否通关、总耗线与失败原因 */
|
||||||
|
export function validateLevelDemo(level: LevelDef): { ok: boolean; cost: number; error?: string } {
|
||||||
|
const lines: RouteState[] = [];
|
||||||
|
for (let d = 0; d < level.demo.length; d++) {
|
||||||
|
const raw = level.demo[d];
|
||||||
|
if (!raw || raw.length < 2) {
|
||||||
|
return { ok: false, cost: 0, error: `demo[${d}] 点数不足` };
|
||||||
|
}
|
||||||
|
const startPt: Point2D = { x: raw[0][0], y: raw[0][1] };
|
||||||
|
const matchedNest = level.nests.find(n => distance(n, startPt) < 4);
|
||||||
|
if (!matchedNest) {
|
||||||
|
return { ok: false, cost: 0, error: `demo[${d}] 起点 (${startPt.x},${startPt.y}) 不在任何蚁巢上` };
|
||||||
|
}
|
||||||
|
const route = createEmptyRoute(false, matchedNest);
|
||||||
|
for (let i = 1; i < raw.length; i++) {
|
||||||
|
const fromPt = { x: raw[i - 1][0], y: raw[i - 1][1] };
|
||||||
|
const toPt = { x: raw[i][0], y: raw[i][1] };
|
||||||
|
const dist = distance(fromPt, toPt);
|
||||||
|
const steps = Math.max(1, Math.ceil(dist / 6));
|
||||||
|
for (let s = 1; s <= steps; s++) {
|
||||||
|
const pt = interpolate(fromPt, toPt, s / steps);
|
||||||
|
const prev = route.points[route.points.length - 1];
|
||||||
|
const segLen = distance(prev, pt);
|
||||||
|
if (segLen < 1.5) continue;
|
||||||
|
const blocked = checkSegmentBlock(level, lines, route, prev, pt, segLen);
|
||||||
|
if (blocked) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
cost: totalLength(lines) + route.cost,
|
||||||
|
error: `demo[${d}] 第 ${i} 段在 (${pt.x.toFixed(1)},${pt.y.toFixed(1)}) 触发阻挡: ${blocked}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const costAdd = segmentCost(level, prev, pt, segLen);
|
||||||
|
route.points.push(pt);
|
||||||
|
const startLen = route.len;
|
||||||
|
route.len += segLen;
|
||||||
|
route.cost += costAdd;
|
||||||
|
route.cum.push(route.len);
|
||||||
|
route.costCum.push(route.cost);
|
||||||
|
planStops(level, lines, route, prev, pt, startLen, segLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!route.picks.length || route.picks.length !== route.deliveries.length) {
|
||||||
|
return {
|
||||||
|
ok: false,
|
||||||
|
cost: totalLength(lines) + route.cost,
|
||||||
|
error: `demo[${d}] 未完成配对: picks=${route.picks.length}, deliveries=${route.deliveries.length}, color=${route.color}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
prepareRouteForRun(route, 0);
|
||||||
|
lines.push(route);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level.maxDispatches && lines.length > level.maxDispatches) {
|
||||||
|
return { ok: false, cost: totalLength(lines), error: `出发笔数 ${lines.length} 超过限笔 ${level.maxDispatches}` };
|
||||||
|
}
|
||||||
|
const remTargets = availableTargets(level, lines);
|
||||||
|
if (remTargets.length > 0) {
|
||||||
|
return { ok: false, cost: totalLength(lines), error: `尚有未绣针位: ${remTargets.map(t => t.id).join(',')}` };
|
||||||
|
}
|
||||||
|
const doneButtons = threadedButtonIds(lines);
|
||||||
|
if (level.buttons.some(b => !doneButtons.has(b.id))) {
|
||||||
|
return { ok: false, cost: totalLength(lines), error: `尚有纽扣未穿过` };
|
||||||
|
}
|
||||||
|
const doneGates = passedGateIds(lines);
|
||||||
|
if (level.gates.some(g => !doneGates.has(g.id))) {
|
||||||
|
return { ok: false, cost: totalLength(lines), error: `尚有单向针眼未穿过` };
|
||||||
|
}
|
||||||
|
const finalCost = totalLength(lines);
|
||||||
|
const maxBudget = effectiveBudget(level, lines);
|
||||||
|
if (maxBudget !== undefined && finalCost > maxBudget) {
|
||||||
|
return { ok: false, cost: finalCost, error: `总耗线 ${finalCost.toFixed(1)} 超出限额 ${maxBudget}` };
|
||||||
|
}
|
||||||
|
return { ok: true, cost: finalCost };
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "797ea493-d04e-49a8-b775-3d88ea5e9afb",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
import { StorageService } from './StorageService';
|
||||||
|
|
||||||
|
declare const wx: any;
|
||||||
|
|
||||||
|
interface ToneOptions {
|
||||||
|
type?: OscillatorType;
|
||||||
|
volume?: number;
|
||||||
|
slideTo?: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SoundService {
|
||||||
|
private ctx: any = null;
|
||||||
|
private enabled: boolean;
|
||||||
|
private bgmEnabled: boolean;
|
||||||
|
private bgmTimer: any = null;
|
||||||
|
private bgmStep = 0;
|
||||||
|
private lastBlockAt = 0;
|
||||||
|
|
||||||
|
// 舒缓手作五声八音盒旋律(C 大调五声:C5 D5 E5 G5 A5 C6)
|
||||||
|
private readonly bgmNotes = [523.25, 659.25, 783.99, 659.25, 587.33, 659.25, 880.0, 783.99, 523.25, 587.33, 659.25, 440.0];
|
||||||
|
|
||||||
|
constructor(private readonly storage: StorageService) {
|
||||||
|
this.enabled = storage.readSoundEnabled();
|
||||||
|
this.bgmEnabled = storage.readBgmEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public isEnabled(): boolean {
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isBgmEnabled(): boolean {
|
||||||
|
return this.bgmEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggle(): boolean {
|
||||||
|
this.enabled = !this.enabled;
|
||||||
|
this.storage.saveSoundEnabled(this.enabled);
|
||||||
|
if (this.enabled) {
|
||||||
|
this.unlock();
|
||||||
|
this.playTone(620, 0.06, 0.02, { volume: 0.055 });
|
||||||
|
}
|
||||||
|
return this.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public toggleBgm(): boolean {
|
||||||
|
this.bgmEnabled = !this.bgmEnabled;
|
||||||
|
this.storage.saveBgmEnabled(this.bgmEnabled);
|
||||||
|
if (this.bgmEnabled) {
|
||||||
|
this.unlock();
|
||||||
|
this.startBgmLoop();
|
||||||
|
} else {
|
||||||
|
this.stopBgmLoop();
|
||||||
|
}
|
||||||
|
return this.bgmEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private startBgmLoop(): void {
|
||||||
|
if (!this.bgmEnabled || this.bgmTimer !== null) return;
|
||||||
|
if (typeof setInterval !== 'function') return;
|
||||||
|
this.bgmTimer = setInterval(() => {
|
||||||
|
if (!this.bgmEnabled || !this.ctx || this.ctx.state !== 'running') return;
|
||||||
|
const freq = this.bgmNotes[this.bgmStep % this.bgmNotes.length];
|
||||||
|
this.bgmStep++;
|
||||||
|
this.playRawTone(freq, 0.42, 0, { type: 'sine', volume: 0.018 });
|
||||||
|
if (this.bgmStep % 4 === 1) {
|
||||||
|
this.playRawTone(freq * 0.5, 0.72, 0.02, { type: 'triangle', volume: 0.011 });
|
||||||
|
}
|
||||||
|
}, 920);
|
||||||
|
}
|
||||||
|
|
||||||
|
public stopBgmLoop(): void {
|
||||||
|
if (this.bgmTimer !== null && typeof clearInterval === 'function') {
|
||||||
|
clearInterval(this.bgmTimer);
|
||||||
|
this.bgmTimer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public unlock(): void {
|
||||||
|
if (!this.enabled && !this.bgmEnabled) return;
|
||||||
|
if (!this.ctx) {
|
||||||
|
if (typeof wx !== 'undefined' && typeof wx.createWebAudioContext === 'function') {
|
||||||
|
this.ctx = wx.createWebAudioContext();
|
||||||
|
} else if (typeof window !== 'undefined') {
|
||||||
|
const AudioCtx = (window as any).AudioContext || (window as any).webkitAudioContext;
|
||||||
|
if (AudioCtx) this.ctx = new AudioCtx();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.ctx && this.ctx.state === 'suspended' && typeof this.ctx.resume === 'function') {
|
||||||
|
try {
|
||||||
|
const res = this.ctx.resume();
|
||||||
|
if (res && typeof res.catch === 'function') res.catch(() => {});
|
||||||
|
} catch {
|
||||||
|
// Ignore autoplay restrictions until next gesture.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.bgmEnabled) this.startBgmLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private playRawTone(freq: number, duration: number, delay = 0, opts: ToneOptions = {}): void {
|
||||||
|
if (!this.ctx || this.ctx.state !== 'running') return;
|
||||||
|
const { type = 'triangle', volume = 0.065, slideTo = null } = opts;
|
||||||
|
try {
|
||||||
|
const osc = this.ctx.createOscillator();
|
||||||
|
const gain = this.ctx.createGain();
|
||||||
|
const start = this.ctx.currentTime + delay;
|
||||||
|
osc.type = type;
|
||||||
|
osc.frequency.setValueAtTime(freq, start);
|
||||||
|
if (slideTo) osc.frequency.exponentialRampToValueAtTime(slideTo, start + duration);
|
||||||
|
gain.gain.setValueAtTime(0.0008, start);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(volume, start + 0.012);
|
||||||
|
gain.gain.exponentialRampToValueAtTime(0.0008, start + duration + 0.035);
|
||||||
|
osc.connect(gain);
|
||||||
|
gain.connect(this.ctx.destination);
|
||||||
|
osc.start(start);
|
||||||
|
osc.stop(start + duration + 0.04);
|
||||||
|
} catch {
|
||||||
|
// Ignore transient WebAudio errors.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private playTone(freq: number, duration: number, delay = 0, opts: ToneOptions = {}): void {
|
||||||
|
if (!this.enabled) return;
|
||||||
|
this.playRawTone(freq, duration, delay, opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public pick(count: number): void {
|
||||||
|
this.playTone(count > 1 ? 659 : 523, 0.065, 0, { volume: 0.06 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public mark(count: number): void {
|
||||||
|
this.playTone(count > 1 ? 880 : 740, 0.06, 0, { volume: 0.055 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public pickup(): void {
|
||||||
|
this.playTone(494, 0.06, 0, { volume: 0.05 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public deliver(): void {
|
||||||
|
this.playTone(659, 0.085, 0, { volume: 0.065 });
|
||||||
|
this.playTone(988, 0.09, 0.09, { volume: 0.06 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public block(): void {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - this.lastBlockAt < 320) return;
|
||||||
|
this.lastBlockAt = now;
|
||||||
|
this.playTone(230, 0.09, 0, { type: 'sine', volume: 0.055, slideTo: 145 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public undo(): void {
|
||||||
|
this.playTone(440, 0.06, 0, { volume: 0.045, slideTo: 330 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public bonus(): void {
|
||||||
|
this.playTone(698, 0.07, 0, { volume: 0.055, slideTo: 932 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public dye(): void {
|
||||||
|
this.playTone(587, 0.08, 0, { type: 'sine', volume: 0.06, slideTo: 880 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public button(): void {
|
||||||
|
this.playTone(784, 0.055, 0, { volume: 0.05 });
|
||||||
|
}
|
||||||
|
|
||||||
|
public win(): void {
|
||||||
|
[523, 659, 784, 1046].forEach((freq, i) => this.playTone(freq, 0.14, i * 0.085, { volume: 0.065 }));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "b7281e35-228d-4d00-b1c6-118316441f21",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
import { sys } from 'cc';
|
||||||
|
import { LevelDef, RecordMap } from './Types';
|
||||||
|
import { recordKey } from './LevelData';
|
||||||
|
|
||||||
|
const RECORDS_KEY = 'ant-embroidery-best-v1';
|
||||||
|
const SOUND_KEY = 'ant-embroidery-sound-v1';
|
||||||
|
const BGM_KEY = 'ant-embroidery-bgm-v1';
|
||||||
|
const LOUPE_KEY = 'ant-embroidery-loupe-v1';
|
||||||
|
const LANG_KEY = 'ant-embroidery-lang-v1';
|
||||||
|
const TUTORIAL_KEY = 'ant-embroidery-tut-v1';
|
||||||
|
const ATELIER_KEY = 'ant-embroidery-atelier-v1';
|
||||||
|
|
||||||
|
export type AppLang = 'zh' | 'en';
|
||||||
|
|
||||||
|
declare const wx: any;
|
||||||
|
|
||||||
|
function getRaw(key: string): string | null {
|
||||||
|
try {
|
||||||
|
if (typeof wx !== 'undefined' && typeof wx.getStorageSync === 'function') {
|
||||||
|
const val = wx.getStorageSync(key);
|
||||||
|
return val === '' || val === undefined || val === null ? null : String(val);
|
||||||
|
}
|
||||||
|
return sys.localStorage.getItem(key);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setRaw(key: string, value: string): void {
|
||||||
|
try {
|
||||||
|
if (typeof wx !== 'undefined' && typeof wx.setStorageSync === 'function') {
|
||||||
|
wx.setStorageSync(key, value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sys.localStorage.setItem(key, value);
|
||||||
|
} catch {
|
||||||
|
// Ignore storage errors on restricted environments.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class StorageService {
|
||||||
|
private records: RecordMap = {};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.records = this.loadRecords();
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadRecords(): RecordMap {
|
||||||
|
try {
|
||||||
|
const raw = getRaw(RECORDS_KEY);
|
||||||
|
const parsed = raw ? JSON.parse(raw) : {};
|
||||||
|
const valid: RecordMap = {};
|
||||||
|
if (parsed && typeof parsed === 'object') {
|
||||||
|
for (const k of Object.keys(parsed)) {
|
||||||
|
const rec = parsed[k];
|
||||||
|
if (
|
||||||
|
Number.isInteger(rec?.stars) && rec.stars >= 1 && rec.stars <= 3 &&
|
||||||
|
Number.isFinite(rec?.length) && rec.length > 0
|
||||||
|
) {
|
||||||
|
valid[k] = { stars: rec.stars, length: rec.length };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRecord(level: LevelDef) {
|
||||||
|
return this.records[recordKey(level)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveRecord(level: LevelDef, stars: number, length: number): boolean {
|
||||||
|
const key = recordKey(level);
|
||||||
|
const prev = this.records[key];
|
||||||
|
if (prev && (stars < prev.stars || (stars === prev.stars && length >= prev.length))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.records[key] = { stars, length };
|
||||||
|
setRaw(RECORDS_KEY, JSON.stringify(this.records));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public readSoundEnabled(): boolean {
|
||||||
|
const raw = getRaw(SOUND_KEY);
|
||||||
|
return raw === null ? true : raw === '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveSoundEnabled(enabled: boolean): void {
|
||||||
|
setRaw(SOUND_KEY, enabled ? '1' : '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
public readBgmEnabled(): boolean {
|
||||||
|
const raw = getRaw(BGM_KEY);
|
||||||
|
return raw === null ? true : raw === '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveBgmEnabled(enabled: boolean): void {
|
||||||
|
setRaw(BGM_KEY, enabled ? '1' : '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
public readLoupeEnabled(): boolean {
|
||||||
|
const raw = getRaw(LOUPE_KEY);
|
||||||
|
return raw === null ? true : raw === '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveLoupeEnabled(enabled: boolean): void {
|
||||||
|
setRaw(LOUPE_KEY, enabled ? '1' : '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
public readLanguage(): AppLang {
|
||||||
|
const raw = getRaw(LANG_KEY);
|
||||||
|
return raw === 'en' ? 'en' : 'zh';
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveLanguage(lang: AppLang): void {
|
||||||
|
setRaw(LANG_KEY, lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
public hasSeenTutorial(): boolean {
|
||||||
|
return getRaw(TUTORIAL_KEY) === '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
public markTutorialSeen(): void {
|
||||||
|
setRaw(TUTORIAL_KEY, '1');
|
||||||
|
}
|
||||||
|
|
||||||
|
public readAtelierRaw(): string | null {
|
||||||
|
return getRaw(ATELIER_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public saveAtelierRaw(raw: string): void {
|
||||||
|
setRaw(ATELIER_KEY, raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "e984a08f-a1e2-4210-af6d-dc00d166892a",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
export type TargetColor =
|
||||||
|
| 'gold'
|
||||||
|
| 'green'
|
||||||
|
| 'rose'
|
||||||
|
| 'sky'
|
||||||
|
| 'coral'
|
||||||
|
| 'lavender'
|
||||||
|
| 'cream'
|
||||||
|
| 'cocoa';
|
||||||
|
export type YarnColor = TargetColor | 'white';
|
||||||
|
export type MotifId = 'sunflower' | 'lotus' | 'sakura' | 'garden' | 'custom';
|
||||||
|
export type BlockReason = 'pond' | 'rim' | 'budget' | 'cross' | 'gate' | 'ball';
|
||||||
|
|
||||||
|
export interface Point2D {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SectionDef {
|
||||||
|
id: string;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
rx: number;
|
||||||
|
ry: number;
|
||||||
|
color: TargetColor;
|
||||||
|
petals?: number[];
|
||||||
|
side?: number;
|
||||||
|
lotus?: 'bloom' | 'bud' | 'pad-left' | 'pad-right';
|
||||||
|
sakura?: 'left' | 'top' | 'right' | 'bird' | 'leaf';
|
||||||
|
garden?: 'gold-floret' | 'rose-peony' | 'leaf-l' | 'leaf-r';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BallDef {
|
||||||
|
id: number;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
color: YarnColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PondDef {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
rx: number;
|
||||||
|
ry: number;
|
||||||
|
/** 若指定了针位 ID,当该针位绣好后此水洼被绣片搭桥覆盖、可通行 */
|
||||||
|
bridgeSectionId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SpoolDef {
|
||||||
|
id: number;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
bonus: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ButtonAnchorDef {
|
||||||
|
id: number;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DyeVatDef {
|
||||||
|
id: number;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
color: TargetColor;
|
||||||
|
/** 可用次数(不填表示无限;填 1 表示单次干涸染缸) */
|
||||||
|
uses?: number;
|
||||||
|
/** 是否对已染色毛线强制覆色 */
|
||||||
|
override?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GateDef {
|
||||||
|
id: number;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
/** 允许穿过的方向角(弧度,0 为向右,-PI/2 为向上) */
|
||||||
|
angle: number;
|
||||||
|
radius?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoughZoneDef {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
rx: number;
|
||||||
|
ry: number;
|
||||||
|
factor?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChapterDef {
|
||||||
|
id: string;
|
||||||
|
index: number;
|
||||||
|
name: string;
|
||||||
|
subtitle: string;
|
||||||
|
motif: MotifId;
|
||||||
|
startIndex: number;
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LevelDef {
|
||||||
|
id: string;
|
||||||
|
recordId?: string;
|
||||||
|
chapter: number;
|
||||||
|
name: string;
|
||||||
|
difficulty: string;
|
||||||
|
lesson: string;
|
||||||
|
goal: string;
|
||||||
|
ruleTag: string;
|
||||||
|
motif: MotifId;
|
||||||
|
/** 可选高精刺绣贴图资源名(位于 assets/resources/artworks/<name>) */
|
||||||
|
artworkImage?: string;
|
||||||
|
budget?: number;
|
||||||
|
maxDispatches?: number;
|
||||||
|
noCross?: boolean;
|
||||||
|
/** 不可穿过不同色未拾毛线球(形成物理堵路) */
|
||||||
|
solidBalls?: boolean;
|
||||||
|
/** 机关顺序锁:key 为被锁针位 ID,value 为必须先绣完的前置针位 ID */
|
||||||
|
locks?: Record<string, string>;
|
||||||
|
nests: Point2D[];
|
||||||
|
targets: SectionDef[];
|
||||||
|
balls: BallDef[];
|
||||||
|
ponds: PondDef[];
|
||||||
|
spools: SpoolDef[];
|
||||||
|
buttons: ButtonAnchorDef[];
|
||||||
|
dyes: DyeVatDef[];
|
||||||
|
gates: GateDef[];
|
||||||
|
roughZones: RoughZoneDef[];
|
||||||
|
threeStar: number;
|
||||||
|
twoStar: number;
|
||||||
|
/** 每笔演示折线(首点必须是某个蚁巢坐标) */
|
||||||
|
demo: [number, number][][];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PickEvent {
|
||||||
|
kind: 'pick';
|
||||||
|
ball: BallDef;
|
||||||
|
at: number;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
pickedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeliveryEvent {
|
||||||
|
kind: 'delivery';
|
||||||
|
target: SectionDef;
|
||||||
|
at: number;
|
||||||
|
origin: Point2D;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
arrivedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SpoolEvent {
|
||||||
|
kind: 'spool';
|
||||||
|
spool: SpoolDef;
|
||||||
|
at: number;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
collectedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ButtonEvent {
|
||||||
|
kind: 'button';
|
||||||
|
button: ButtonAnchorDef;
|
||||||
|
at: number;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
threadedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DyeEvent {
|
||||||
|
kind: 'dye';
|
||||||
|
dye: DyeVatDef;
|
||||||
|
at: number;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
dyedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GateEvent {
|
||||||
|
kind: 'gate';
|
||||||
|
gate: GateDef;
|
||||||
|
at: number;
|
||||||
|
ms?: number;
|
||||||
|
hold?: number;
|
||||||
|
passedAt?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RouteEvent = PickEvent | DeliveryEvent | SpoolEvent | ButtonEvent | DyeEvent | GateEvent;
|
||||||
|
|
||||||
|
export interface CarryBall extends BallDef {
|
||||||
|
pickedAt: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AntState {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
angle: number;
|
||||||
|
carry: CarryBall[];
|
||||||
|
walk: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RouteState {
|
||||||
|
nest: Point2D;
|
||||||
|
points: Point2D[];
|
||||||
|
cum: number[];
|
||||||
|
costCum: number[];
|
||||||
|
len: number;
|
||||||
|
cost: number;
|
||||||
|
picks: PickEvent[];
|
||||||
|
deliveries: DeliveryEvent[];
|
||||||
|
spools: SpoolEvent[];
|
||||||
|
buttons: ButtonEvent[];
|
||||||
|
dyes: DyeEvent[];
|
||||||
|
gates: GateEvent[];
|
||||||
|
events: RouteEvent[];
|
||||||
|
color: YarnColor | null;
|
||||||
|
blocked: BlockReason | null;
|
||||||
|
showTip: boolean;
|
||||||
|
fingerTip?: Point2D | null;
|
||||||
|
loupeEnabled?: boolean;
|
||||||
|
startedAt: number;
|
||||||
|
carry: CarryBall[];
|
||||||
|
ant: AntState;
|
||||||
|
finished: boolean;
|
||||||
|
arrivedAt: number;
|
||||||
|
traveled?: number;
|
||||||
|
segment: number;
|
||||||
|
nextEvent: number;
|
||||||
|
duration: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HintState {
|
||||||
|
tier: 1 | 2 | 3;
|
||||||
|
points: Point2D[];
|
||||||
|
ball: BallDef | null;
|
||||||
|
target: SectionDef | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GameState {
|
||||||
|
time: number;
|
||||||
|
lines: RouteState[];
|
||||||
|
drawing: RouteState | null;
|
||||||
|
complete: boolean;
|
||||||
|
completedAt: number;
|
||||||
|
demo: boolean;
|
||||||
|
assisted: boolean;
|
||||||
|
/** 用过 2/3 级路线提示或看过演示时,通关存档星级封顶为 2 星 */
|
||||||
|
hintCapped: boolean;
|
||||||
|
/** 本关是否看过演示(重来/重绣不清空,仅换关时重置) */
|
||||||
|
demoWatched: boolean;
|
||||||
|
hint: HintState | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RecordEntry {
|
||||||
|
stars: number;
|
||||||
|
length: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RecordMap = Record<string, RecordEntry>;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "c8ca71e2-d2c9-4c45-b475-7592d4b13fdd",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "b3fa63e3-0773-4f1e-af5b-c35b2ea80490",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "e3874383-1a6b-495c-ab42-36d52333b3fd",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a1efed9a-a10c-4c78-8ec3-82de9d522bcf",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,815 @@
|
|||||||
|
import { Component, Graphics, Label, Node, Sprite, SpriteFrame, _decorator } from 'cc';
|
||||||
|
import {
|
||||||
|
ANT_DIARIES,
|
||||||
|
AtelierService,
|
||||||
|
IDLE_MAX_THREADS,
|
||||||
|
POSTER_FRAMES,
|
||||||
|
POSTER_QUOTES,
|
||||||
|
PosterFrameId,
|
||||||
|
} from '../core/AtelierService';
|
||||||
|
import { CHAPTERS, CHAPTER_UNLOCK_STARS, formatLength, LEVELS } from '../core/LevelData';
|
||||||
|
import { SoundService } from '../core/SoundService';
|
||||||
|
import { StorageService } from '../core/StorageService';
|
||||||
|
import { EmbroideryRenderer } from '../render/EmbroideryRenderer';
|
||||||
|
import {
|
||||||
|
createArtSprite,
|
||||||
|
createButton,
|
||||||
|
createLabel,
|
||||||
|
createPanel,
|
||||||
|
createUINode,
|
||||||
|
drawPadlockIcon,
|
||||||
|
drawRoundedBox,
|
||||||
|
hex,
|
||||||
|
stretchToParent,
|
||||||
|
StyledButton,
|
||||||
|
} from './UiBuilder';
|
||||||
|
|
||||||
|
const { ccclass } = _decorator;
|
||||||
|
|
||||||
|
export type AtelierTab = 'workshop' | 'gallery' | 'letters';
|
||||||
|
|
||||||
|
const CHAPTER_SHORT_ZH = ['繁花', '灵禽', '萌宠', '山水', '筑影', '甜物'];
|
||||||
|
const CHAPTER_SHORT_EN = ['Flora', 'Birds', 'Pets', 'Hills', 'Villas', 'Sweets'];
|
||||||
|
|
||||||
|
@ccclass('AtelierModal')
|
||||||
|
export class AtelierModal extends Component {
|
||||||
|
private storage!: StorageService;
|
||||||
|
private sound!: SoundService;
|
||||||
|
private atelier!: AtelierService;
|
||||||
|
private renderer!: EmbroideryRenderer;
|
||||||
|
private getThumbnail!: (levelIndex: number) => SpriteFrame;
|
||||||
|
private onChanged?: () => void;
|
||||||
|
|
||||||
|
private activeTab: AtelierTab = 'workshop';
|
||||||
|
private tabBtns: Record<AtelierTab, StyledButton> = {} as any;
|
||||||
|
private tabGroups: Record<AtelierTab, Node> = {} as any;
|
||||||
|
private closeBtn!: StyledButton;
|
||||||
|
|
||||||
|
// Tab 1: 蚂蚁工坊
|
||||||
|
private wsThreadsLabel!: Label;
|
||||||
|
private wsPendingLabel!: Label;
|
||||||
|
private wsStageSprite!: Sprite;
|
||||||
|
private wsCollectBtn!: StyledButton;
|
||||||
|
private wsDiaryHeaderLabel!: Label;
|
||||||
|
private wsDiaryMoodLabel!: Label;
|
||||||
|
private wsDiaryMoodBg!: Graphics;
|
||||||
|
private wsDiaryBodyLabel!: Label;
|
||||||
|
private wsToastLabel!: Label;
|
||||||
|
private diaryIndex = 0;
|
||||||
|
private workshopTimeMs = 0;
|
||||||
|
|
||||||
|
// Tab 2: 绣品展柜
|
||||||
|
private galEmptyNode!: Node;
|
||||||
|
private galContentNode!: Node;
|
||||||
|
private galPreviewCardBg!: Graphics;
|
||||||
|
private galPreviewSprite!: Sprite;
|
||||||
|
private galPreviewTitle!: Label;
|
||||||
|
private galPreviewMeta!: Label;
|
||||||
|
private galCounterLabel!: Label;
|
||||||
|
private galThreadsLabel!: Label;
|
||||||
|
private galFrameBtns: { id: PosterFrameId; btn: StyledButton }[] = [];
|
||||||
|
private galQuoteBtn!: StyledButton;
|
||||||
|
private galQuotePreview!: Label;
|
||||||
|
private galExportBtn!: StyledButton;
|
||||||
|
private galToastLabel!: Label;
|
||||||
|
private galleryCursor = 0;
|
||||||
|
|
||||||
|
// Tab 3: 委托信箱
|
||||||
|
private letterChapter = 0;
|
||||||
|
private letterTabs: { btn: StyledButton; lockNode: Node }[] = [];
|
||||||
|
private letterReqHeader!: Label;
|
||||||
|
private letterReqBody!: Label;
|
||||||
|
private letterReplyBg!: Graphics;
|
||||||
|
private letterReplyLockNode!: Node;
|
||||||
|
private letterReplyHeader!: Label;
|
||||||
|
private letterReplyBody!: Label;
|
||||||
|
|
||||||
|
public init(
|
||||||
|
storage: StorageService,
|
||||||
|
sound: SoundService,
|
||||||
|
atelier: AtelierService,
|
||||||
|
renderer: EmbroideryRenderer,
|
||||||
|
getThumbnail: (levelIndex: number) => SpriteFrame,
|
||||||
|
onChanged?: () => void,
|
||||||
|
): void {
|
||||||
|
this.storage = storage;
|
||||||
|
this.sound = sound;
|
||||||
|
this.atelier = atelier;
|
||||||
|
this.renderer = renderer;
|
||||||
|
this.getThumbnail = getThumbnail;
|
||||||
|
this.onChanged = onChanged;
|
||||||
|
this.buildUI();
|
||||||
|
this.node.active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isEn(): boolean {
|
||||||
|
return this.storage.readLanguage() === 'en';
|
||||||
|
}
|
||||||
|
|
||||||
|
private getTotalStars(): number {
|
||||||
|
return LEVELS.reduce((sum, entry) => sum + (this.storage.getRecord(entry)?.stars ?? 0), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private isChapterUnlocked(idx: number): boolean {
|
||||||
|
if (idx <= 0) return true;
|
||||||
|
return this.getTotalStars() >= (CHAPTER_UNLOCK_STARS[idx] ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public open(tab: AtelierTab, chapterIndex = 0, focusLevelIndex?: number): void {
|
||||||
|
this.atelier.settleIdle(Date.now());
|
||||||
|
this.atelier.syncFromLegacyRecords(lv => this.storage.getRecord(lv));
|
||||||
|
this.activeTab = tab;
|
||||||
|
this.letterChapter = this.isChapterUnlocked(chapterIndex) ? chapterIndex : 0;
|
||||||
|
const diaries = this.atelier.getUnlockedDiaries();
|
||||||
|
this.diaryIndex = Math.max(0, diaries.length - 1);
|
||||||
|
const gallery = this.atelier.getState().gallery;
|
||||||
|
if (focusLevelIndex !== undefined) {
|
||||||
|
const idx = gallery.findIndex(item => item.levelIndex === focusLevelIndex);
|
||||||
|
if (idx >= 0) this.galleryCursor = idx;
|
||||||
|
}
|
||||||
|
if (this.galleryCursor >= gallery.length) {
|
||||||
|
this.galleryCursor = Math.max(0, gallery.length - 1);
|
||||||
|
}
|
||||||
|
this.wsToastLabel.string = '';
|
||||||
|
this.galToastLabel.string = '';
|
||||||
|
this.node.active = true;
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
public close(): void {
|
||||||
|
this.node.active = false;
|
||||||
|
this.onChanged?.();
|
||||||
|
}
|
||||||
|
|
||||||
|
public refreshCurrentTab(): void {
|
||||||
|
if (!this.node.active) return;
|
||||||
|
this.refreshUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildUI(): void {
|
||||||
|
const scrim = createPanel('AtelierScrim', 3200, 3200, { fill: '#18120cc4', radius: 0 }, this.node);
|
||||||
|
|
||||||
|
const frame = createArtSprite('AtelierLinenFrame', 'ui/ui_linen_modal', 688, 790, scrim.node);
|
||||||
|
frame.node.setPosition(0, 6, 0);
|
||||||
|
|
||||||
|
// 顶部三页签切换栏(位于雕花拱顶下方留白区,避免与木雕花叶重叠)
|
||||||
|
const tabsBar = createUINode('AtelierTabs', 536, 40, frame.node);
|
||||||
|
tabsBar.setPosition(0, 146, 0);
|
||||||
|
const tabDefs: { id: AtelierTab; zh: string; x: number }[] = [
|
||||||
|
{ id: 'workshop', zh: '蚂蚁工坊', x: -178 },
|
||||||
|
{ id: 'gallery', zh: '绣品展柜', x: 0 },
|
||||||
|
{ id: 'letters', zh: '委托信箱', x: 178 },
|
||||||
|
];
|
||||||
|
for (const def of tabDefs) {
|
||||||
|
const btn = createButton({
|
||||||
|
name: `Tab_${def.id}`,
|
||||||
|
text: def.zh,
|
||||||
|
w: 168,
|
||||||
|
h: 38,
|
||||||
|
radius: 19,
|
||||||
|
fill: '#ead9b8',
|
||||||
|
stroke: '#c8ab77',
|
||||||
|
depth: 3,
|
||||||
|
depthColor: '#b5945e',
|
||||||
|
textColor: '#4e371e',
|
||||||
|
fontSize: 18,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
this.activeTab = def.id;
|
||||||
|
this.wsToastLabel.string = '';
|
||||||
|
this.galToastLabel.string = '';
|
||||||
|
this.refreshUI();
|
||||||
|
},
|
||||||
|
}, tabsBar);
|
||||||
|
btn.node.setPosition(def.x, 0, 0);
|
||||||
|
this.tabBtns[def.id] = btn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 三个子页容器(上移留足底部提示与返回按钮的舒适间距)
|
||||||
|
this.tabGroups.workshop = createUINode('WorkshopGroup', 540, 360, frame.node);
|
||||||
|
this.tabGroups.workshop.setPosition(0, -40, 0);
|
||||||
|
this.buildWorkshopTab(this.tabGroups.workshop);
|
||||||
|
|
||||||
|
this.tabGroups.gallery = createUINode('GalleryGroup', 540, 360, frame.node);
|
||||||
|
this.tabGroups.gallery.setPosition(0, -40, 0);
|
||||||
|
this.buildGalleryTab(this.tabGroups.gallery);
|
||||||
|
|
||||||
|
this.tabGroups.letters = createUINode('LettersGroup', 540, 360, frame.node);
|
||||||
|
this.tabGroups.letters.setPosition(0, -40, 0);
|
||||||
|
this.buildLettersTab(this.tabGroups.letters);
|
||||||
|
|
||||||
|
this.closeBtn = createButton({
|
||||||
|
name: 'AtelierCloseBtn',
|
||||||
|
text: '返 回',
|
||||||
|
w: 220,
|
||||||
|
h: 48,
|
||||||
|
radius: 22,
|
||||||
|
fill: '#4d6f49',
|
||||||
|
stroke: '#8ab084',
|
||||||
|
depth: 4,
|
||||||
|
depthColor: '#2e472b',
|
||||||
|
textColor: '#fff9e8',
|
||||||
|
fontSize: 21,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
this.close();
|
||||||
|
},
|
||||||
|
}, frame.node);
|
||||||
|
this.closeBtn.node.setPosition(0, -296, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildWorkshopTab(parent: Node): void {
|
||||||
|
// 顶部状态条:当前持有线头 + 待领线头
|
||||||
|
const leftStat = createPanel('OwnedThreadsPill', 236, 34, {
|
||||||
|
fill: '#4b311c', stroke: '#d6ae63', strokeWidth: 1.6, radius: 17,
|
||||||
|
}, parent);
|
||||||
|
leftStat.node.setPosition(-128, 146, 0);
|
||||||
|
this.wsThreadsLabel = createLabel('Text', '柔丝线头:15 束', 220, 28, {
|
||||||
|
size: 16, color: '#fff4d6', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, leftStat.node);
|
||||||
|
|
||||||
|
const rightStat = createPanel('PendingThreadsPill', 246, 34, {
|
||||||
|
fill: '#3c5938', stroke: '#9cc286', strokeWidth: 1.6, radius: 17,
|
||||||
|
}, parent);
|
||||||
|
rightStat.node.setPosition(124, 146, 0);
|
||||||
|
this.wsPendingLabel = createLabel('Text', '待领:+4 束(最多8h)', 232, 28, {
|
||||||
|
size: 15, color: '#e9f9d8', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, rightStat.node);
|
||||||
|
|
||||||
|
// 实时动态小蚂蚁工作舞台
|
||||||
|
const stageNode = createUINode('AntWorkshopStage', 492, 152, parent);
|
||||||
|
stageNode.setPosition(0, 48, 0);
|
||||||
|
this.wsStageSprite = stageNode.addComponent(Sprite);
|
||||||
|
this.wsStageSprite.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||||
|
this.wsStageSprite.spriteFrame = this.renderer.getWorkshopSpriteFrame();
|
||||||
|
|
||||||
|
// 收下线头按钮
|
||||||
|
this.wsCollectBtn = createButton({
|
||||||
|
name: 'CollectThreadsBtn',
|
||||||
|
text: '收下线头 (+4 束)',
|
||||||
|
w: 292,
|
||||||
|
h: 44,
|
||||||
|
radius: 22,
|
||||||
|
fill: '#df9c34',
|
||||||
|
stroke: '#fae09e',
|
||||||
|
depth: 4,
|
||||||
|
depthColor: '#996012',
|
||||||
|
textColor: '#3f2207',
|
||||||
|
fontSize: 19,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
const res = this.atelier.collectPending(Date.now());
|
||||||
|
if (res.threads > 0) {
|
||||||
|
this.sound.bonus();
|
||||||
|
const diaries = this.atelier.getUnlockedDiaries();
|
||||||
|
if (res.newDiary) {
|
||||||
|
this.diaryIndex = Math.max(0, diaries.length - 1);
|
||||||
|
const title = this.isEn() ? res.newDiary.titleEn : res.newDiary.titleZh;
|
||||||
|
this.wsToastLabel.string = this.isEn()
|
||||||
|
? `Collected +${res.threads} threads & new diary: ${title}!`
|
||||||
|
: `收下 +${res.threads} 束线头!小蚂蚁带回新日记《${title}》`;
|
||||||
|
} else {
|
||||||
|
this.wsToastLabel.string = this.isEn()
|
||||||
|
? `Collected +${res.threads} threads! Use them in the Gallery.`
|
||||||
|
: `已收下 +${res.threads} 束线头,可去「绣品展柜」换装裱与落款!`;
|
||||||
|
}
|
||||||
|
this.refreshUI();
|
||||||
|
this.onChanged?.();
|
||||||
|
} else {
|
||||||
|
const mins = this.atelier.getNextThreadMinutes(Date.now());
|
||||||
|
this.wsToastLabel.string = this.isEn()
|
||||||
|
? `Ants are spinning... next thread in ~${mins} min.`
|
||||||
|
: `小蚂蚁正在勤快理线,约 ${mins} 分钟后产出新线头~`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, parent);
|
||||||
|
this.wsCollectBtn.node.setPosition(0, -56, 0);
|
||||||
|
|
||||||
|
// 底部:蚂蚁日记明信片
|
||||||
|
const diaryCard = createPanel('AntDiaryCard', 504, 102, {
|
||||||
|
fill: '#f7edd7', stroke: '#d2b682', strokeWidth: 1.8, radius: 16, stitchColor: '#d7be9099', stitchInset: 6,
|
||||||
|
}, parent);
|
||||||
|
diaryCard.node.setPosition(0, -138, 0);
|
||||||
|
|
||||||
|
this.wsDiaryHeaderLabel = createLabel('DiaryHeader', '蚂蚁日记 1/12 · 第一缕晨光', 310, 26, {
|
||||||
|
size: 16, color: '#472f18', bold: true, align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, diaryCard.node);
|
||||||
|
this.wsDiaryHeaderLabel.node.setPosition(-74, 28, 0);
|
||||||
|
|
||||||
|
const moodPill = createPanel('DiaryMood', 78, 24, {
|
||||||
|
fill: '#c87e2d', radius: 12,
|
||||||
|
}, diaryCard.node);
|
||||||
|
moodPill.node.setPosition(116, 28, 0);
|
||||||
|
this.wsDiaryMoodBg = moodPill.graphics;
|
||||||
|
this.wsDiaryMoodLabel = createLabel('Text', '搬线中', 70, 22, {
|
||||||
|
size: 13, color: '#fff9ec', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, moodPill.node);
|
||||||
|
|
||||||
|
const prevDiary = createButton({
|
||||||
|
name: 'PrevDiaryBtn',
|
||||||
|
text: '‹',
|
||||||
|
w: 30,
|
||||||
|
h: 28,
|
||||||
|
radius: 14,
|
||||||
|
fill: '#e7d5b0',
|
||||||
|
stroke: '#c6a76e',
|
||||||
|
textColor: '#4c341a',
|
||||||
|
fontSize: 20,
|
||||||
|
onClick: () => {
|
||||||
|
const list = this.atelier.getUnlockedDiaries();
|
||||||
|
if (list.length <= 1) return;
|
||||||
|
this.diaryIndex = (this.diaryIndex - 1 + list.length) % list.length;
|
||||||
|
this.refreshWorkshop();
|
||||||
|
},
|
||||||
|
}, diaryCard.node);
|
||||||
|
prevDiary.node.setPosition(186, 28, 0);
|
||||||
|
|
||||||
|
const nextDiary = createButton({
|
||||||
|
name: 'NextDiaryBtn',
|
||||||
|
text: '›',
|
||||||
|
w: 30,
|
||||||
|
h: 28,
|
||||||
|
radius: 14,
|
||||||
|
fill: '#e7d5b0',
|
||||||
|
stroke: '#c6a76e',
|
||||||
|
textColor: '#4c341a',
|
||||||
|
fontSize: 20,
|
||||||
|
onClick: () => {
|
||||||
|
const list = this.atelier.getUnlockedDiaries();
|
||||||
|
if (list.length <= 1) return;
|
||||||
|
this.diaryIndex = (this.diaryIndex + 1) % list.length;
|
||||||
|
this.refreshWorkshop();
|
||||||
|
},
|
||||||
|
}, diaryCard.node);
|
||||||
|
nextDiary.node.setPosition(222, 28, 0);
|
||||||
|
|
||||||
|
this.wsDiaryBodyLabel = createLabel('DiaryBody', '', 462, 54, {
|
||||||
|
size: 15, color: '#5d472b', align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, diaryCard.node);
|
||||||
|
this.wsDiaryBodyLabel.node.setPosition(0, -14, 0);
|
||||||
|
|
||||||
|
this.wsToastLabel = createLabel('WorkshopToast', '', 504, 24, {
|
||||||
|
size: 14, color: '#7a4f1b', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, parent);
|
||||||
|
this.wsToastLabel.node.setPosition(0, -200, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildGalleryTab(parent: Node): void {
|
||||||
|
// 空展柜状态
|
||||||
|
this.galEmptyNode = createPanel('GalleryEmpty', 488, 220, {
|
||||||
|
fill: '#f4e8ce', stroke: '#d4b988', strokeWidth: 1.8, radius: 20,
|
||||||
|
}, parent).node;
|
||||||
|
this.galEmptyNode.setPosition(0, 10, 0);
|
||||||
|
createLabel('EmptyText', '绣成任意一幅作品后\n你的手绣藏品会自动陈列于此,并可换装裱导出海报。', 440, 90, {
|
||||||
|
size: 19, color: '#614a2c', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, this.galEmptyNode);
|
||||||
|
|
||||||
|
// 展柜主视图
|
||||||
|
this.galContentNode = createUINode('GalleryContent', 520, 356, parent);
|
||||||
|
|
||||||
|
// 左侧:装裱预览画框
|
||||||
|
const previewCard = createPanel('PosterPreviewCard', 222, 256, {
|
||||||
|
fill: '#627052', stroke: '#efe0bd', strokeWidth: 2.2, radius: 18, shadow: 4,
|
||||||
|
}, this.galContentNode);
|
||||||
|
previewCard.node.setPosition(-136, 30, 0);
|
||||||
|
this.galPreviewCardBg = previewCard.graphics;
|
||||||
|
|
||||||
|
const thumbNode = createUINode('GalleryThumb', 176, 176, previewCard.node);
|
||||||
|
thumbNode.setPosition(0, 22, 0);
|
||||||
|
this.galPreviewSprite = thumbNode.addComponent(Sprite);
|
||||||
|
this.galPreviewSprite.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||||
|
|
||||||
|
this.galPreviewTitle = createLabel('ThumbTitle', '《金色向日葵》', 198, 26, {
|
||||||
|
size: 16, color: '#fff7e0', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, previewCard.node);
|
||||||
|
this.galPreviewTitle.node.setPosition(0, -82, 0);
|
||||||
|
|
||||||
|
this.galPreviewMeta = createLabel('ThumbMeta', '★★★ · 3.4 cm', 198, 22, {
|
||||||
|
size: 14, color: '#f4dc9e', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, previewCard.node);
|
||||||
|
this.galPreviewMeta.node.setPosition(0, -106, 0);
|
||||||
|
|
||||||
|
// 左侧底部翻页
|
||||||
|
const prevGal = createButton({
|
||||||
|
name: 'PrevGalleryBtn',
|
||||||
|
text: '‹',
|
||||||
|
w: 44,
|
||||||
|
h: 34,
|
||||||
|
radius: 17,
|
||||||
|
fill: '#e6d3ad',
|
||||||
|
stroke: '#c6a66c',
|
||||||
|
depth: 2,
|
||||||
|
depthColor: '#ad8d55',
|
||||||
|
textColor: '#483018',
|
||||||
|
fontSize: 24,
|
||||||
|
onClick: () => {
|
||||||
|
const list = this.atelier.getState().gallery;
|
||||||
|
if (list.length <= 1) return;
|
||||||
|
this.galleryCursor = (this.galleryCursor - 1 + list.length) % list.length;
|
||||||
|
this.refreshGallery();
|
||||||
|
},
|
||||||
|
}, this.galContentNode);
|
||||||
|
prevGal.node.setPosition(-208, -124, 0);
|
||||||
|
|
||||||
|
this.galCounterLabel = createLabel('GalCounter', '1 / 1', 90, 28, {
|
||||||
|
size: 16, color: '#4d361d', bold: true,
|
||||||
|
}, this.galContentNode);
|
||||||
|
this.galCounterLabel.node.setPosition(-136, -124, 0);
|
||||||
|
|
||||||
|
const nextGal = createButton({
|
||||||
|
name: 'NextGalleryBtn',
|
||||||
|
text: '›',
|
||||||
|
w: 44,
|
||||||
|
h: 34,
|
||||||
|
radius: 17,
|
||||||
|
fill: '#e6d3ad',
|
||||||
|
stroke: '#c6a66c',
|
||||||
|
depth: 2,
|
||||||
|
depthColor: '#ad8d55',
|
||||||
|
textColor: '#483018',
|
||||||
|
fontSize: 24,
|
||||||
|
onClick: () => {
|
||||||
|
const list = this.atelier.getState().gallery;
|
||||||
|
if (list.length <= 1) return;
|
||||||
|
this.galleryCursor = (this.galleryCursor + 1) % list.length;
|
||||||
|
this.refreshGallery();
|
||||||
|
},
|
||||||
|
}, this.galContentNode);
|
||||||
|
nextGal.node.setPosition(-64, -124, 0);
|
||||||
|
|
||||||
|
// 右侧:定制装裱 + 落款 + 导出按钮
|
||||||
|
const threadPill = createPanel('GalThreadPill', 250, 32, {
|
||||||
|
fill: '#4b311c', stroke: '#d6ae63', strokeWidth: 1.5, radius: 16,
|
||||||
|
}, this.galContentNode);
|
||||||
|
threadPill.node.setPosition(122, 138, 0);
|
||||||
|
this.galThreadsLabel = createLabel('Text', '柔丝线头:15 束', 236, 26, {
|
||||||
|
size: 15, color: '#fff3d4', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, threadPill.node);
|
||||||
|
|
||||||
|
createLabel('FrameHeading', '装裱风格', 248, 22, {
|
||||||
|
size: 15, color: '#584126', bold: true, align: Label.HorizontalAlign.LEFT,
|
||||||
|
}, this.galContentNode).node.setPosition(122, 104, 0);
|
||||||
|
|
||||||
|
this.galFrameBtns = POSTER_FRAMES.map((f, idx) => {
|
||||||
|
const col = idx % 2;
|
||||||
|
const row = Math.floor(idx / 2);
|
||||||
|
const btn = createButton({
|
||||||
|
name: `Frame_${f.id}`,
|
||||||
|
text: f.nameZh,
|
||||||
|
w: 120,
|
||||||
|
h: 38,
|
||||||
|
radius: 14,
|
||||||
|
fill: '#ead8b6',
|
||||||
|
stroke: '#c8ab77',
|
||||||
|
depth: 3,
|
||||||
|
depthColor: '#ad8e59',
|
||||||
|
textColor: '#4a321a',
|
||||||
|
fontSize: 15,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
const res = this.atelier.selectOrUnlockFrame(f.id);
|
||||||
|
if (res.ok) {
|
||||||
|
this.sound.bonus();
|
||||||
|
this.galToastLabel.string = res.unlockedNow
|
||||||
|
? `已用 ${f.cost} 束线头解锁「${f.nameZh}」装裱!`
|
||||||
|
: `已切换为「${f.nameZh}」装裱风格`;
|
||||||
|
this.refreshGallery();
|
||||||
|
} else {
|
||||||
|
this.sound.block();
|
||||||
|
this.galToastLabel.string = `还差 ${res.need} 束线头(去「蚂蚁工坊」收线头或通关获取)`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, this.galContentNode);
|
||||||
|
btn.node.setPosition(58 + col * 128, 66 - row * 46, 0);
|
||||||
|
return { id: f.id, btn };
|
||||||
|
});
|
||||||
|
|
||||||
|
createLabel('QuoteHeading', '藏品落款(点击切换 / 解锁)', 248, 22, {
|
||||||
|
size: 14, color: '#584126', bold: true, align: Label.HorizontalAlign.LEFT,
|
||||||
|
}, this.galContentNode).node.setPosition(122, -16, 0);
|
||||||
|
|
||||||
|
this.galQuoteBtn = createButton({
|
||||||
|
name: 'QuoteCycleBtn',
|
||||||
|
text: '一针一线 · 慢享手作好时光',
|
||||||
|
w: 250,
|
||||||
|
h: 44,
|
||||||
|
radius: 14,
|
||||||
|
fill: '#f5ead2',
|
||||||
|
stroke: '#cca96e',
|
||||||
|
depth: 3,
|
||||||
|
depthColor: '#b3915a',
|
||||||
|
textColor: '#4c3318',
|
||||||
|
fontSize: 14,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
const state = this.atelier.getState();
|
||||||
|
const curIdx = POSTER_QUOTES.findIndex(q => q.id === state.activeQuote);
|
||||||
|
const nextQuote = POSTER_QUOTES[(curIdx + 1) % POSTER_QUOTES.length];
|
||||||
|
const res = this.atelier.selectOrUnlockQuote(nextQuote.id);
|
||||||
|
if (res.ok) {
|
||||||
|
this.sound.bonus();
|
||||||
|
this.galToastLabel.string = res.unlockedNow
|
||||||
|
? `已用 ${nextQuote.cost} 束线头解锁新落款!`
|
||||||
|
: `已切换落款:「${nextQuote.zh}」`;
|
||||||
|
this.refreshGallery();
|
||||||
|
} else {
|
||||||
|
// 线头不够解锁下一条时,轮换已解锁落款并提示
|
||||||
|
const unlocked = state.unlockedQuotes;
|
||||||
|
const nextUnlocked = unlocked[(unlocked.indexOf(state.activeQuote) + 1) % unlocked.length];
|
||||||
|
this.atelier.selectOrUnlockQuote(nextUnlocked);
|
||||||
|
this.galToastLabel.string = `下条落款需 ${nextQuote.cost} 束线头(还差 ${res.need} 束)`;
|
||||||
|
this.refreshGallery();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, this.galContentNode);
|
||||||
|
this.galQuoteBtn.node.setPosition(122, -56, 0);
|
||||||
|
this.galQuotePreview = this.galQuoteBtn.label;
|
||||||
|
|
||||||
|
this.galExportBtn = createButton({
|
||||||
|
name: 'ExportGalleryBtn',
|
||||||
|
text: '导出藏品海报',
|
||||||
|
w: 250,
|
||||||
|
h: 46,
|
||||||
|
radius: 22,
|
||||||
|
fill: '#4d7247',
|
||||||
|
stroke: '#8ab082',
|
||||||
|
depth: 4,
|
||||||
|
depthColor: '#2d4729',
|
||||||
|
textColor: '#fff9e8',
|
||||||
|
fontSize: 19,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
const list = this.atelier.getState().gallery;
|
||||||
|
const item = list[this.galleryCursor];
|
||||||
|
if (!item) return;
|
||||||
|
const lv = LEVELS[item.levelIndex];
|
||||||
|
const chName = CHAPTERS[lv.chapter]?.name ?? '蚂蚁织画';
|
||||||
|
const qDef = this.atelier.getQuoteDef();
|
||||||
|
this.renderer.exportGalleryArtwork(
|
||||||
|
lv,
|
||||||
|
{
|
||||||
|
stars: item.stars,
|
||||||
|
lengthText: formatLength(item.length),
|
||||||
|
chapterName: chName,
|
||||||
|
levelNumber: item.levelIndex + 1,
|
||||||
|
frame: this.atelier.getFrameDef(),
|
||||||
|
quoteText: this.isEn() ? qDef.en : qDef.zh,
|
||||||
|
},
|
||||||
|
msg => {
|
||||||
|
this.galToastLabel.string = msg;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}, this.galContentNode);
|
||||||
|
this.galExportBtn.node.setPosition(122, -118, 0);
|
||||||
|
|
||||||
|
this.galToastLabel = createLabel('GalleryToast', '', 504, 24, {
|
||||||
|
size: 14, color: '#7a4f1b', bold: true, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, parent);
|
||||||
|
this.galToastLabel.node.setPosition(0, -196, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildLettersTab(parent: Node): void {
|
||||||
|
// 顶部 6 章信件切换条
|
||||||
|
const strip = createUINode('LetterChapterStrip', 516, 34, parent);
|
||||||
|
strip.setPosition(0, 142, 0);
|
||||||
|
this.letterTabs = CHAPTERS.map((_, idx) => {
|
||||||
|
const btn = createButton({
|
||||||
|
name: `LetterCh_${idx + 1}`,
|
||||||
|
text: CHAPTER_SHORT_ZH[idx],
|
||||||
|
w: 80,
|
||||||
|
h: 32,
|
||||||
|
radius: 16,
|
||||||
|
fill: '#ead8b6',
|
||||||
|
stroke: '#c8ab77',
|
||||||
|
depth: 2,
|
||||||
|
depthColor: '#b0915c',
|
||||||
|
textColor: '#4c3318',
|
||||||
|
fontSize: 14,
|
||||||
|
onClick: () => {
|
||||||
|
this.sound.unlock();
|
||||||
|
if (!this.isChapterUnlocked(idx)) {
|
||||||
|
this.sound.block();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.letterChapter = idx;
|
||||||
|
this.refreshLetters();
|
||||||
|
},
|
||||||
|
}, strip);
|
||||||
|
btn.node.setPosition((idx - 2.5) * 86, 0, 0);
|
||||||
|
const lockNode = createUINode('Lock', 16, 16, btn.node);
|
||||||
|
lockNode.setPosition(-21, 0, 0);
|
||||||
|
drawPadlockIcon(lockNode.addComponent(Graphics), 0.78, '#b89b6a', '#d7bd8e', '#46311f');
|
||||||
|
lockNode.active = false;
|
||||||
|
return { btn, lockNode };
|
||||||
|
});
|
||||||
|
|
||||||
|
// 上半卡:客人委托来信(舒朗间距)
|
||||||
|
const reqCard = createPanel('RequestLetterCard', 506, 138, {
|
||||||
|
fill: '#f9f0dc', stroke: '#d2b47d', strokeWidth: 1.8, radius: 18, stitchColor: '#d9bf8e99', stitchInset: 7,
|
||||||
|
}, parent);
|
||||||
|
reqCard.node.setPosition(0, 42, 0);
|
||||||
|
|
||||||
|
const waxDot = createPanel('ReqWax', 18, 18, { fill: '#c85450', stroke: '#f4d39c', strokeWidth: 1.5, radius: 9 }, reqCard.node);
|
||||||
|
waxDot.node.setPosition(-224, 42, 0);
|
||||||
|
|
||||||
|
this.letterReqHeader = createLabel('ReqHeader', '', 436, 28, {
|
||||||
|
size: 17, color: '#452c15', bold: true, align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, reqCard.node);
|
||||||
|
this.letterReqHeader.node.setPosition(10, 42, 0);
|
||||||
|
|
||||||
|
this.letterReqBody = createLabel('ReqBody', '', 462, 80, {
|
||||||
|
size: 16, color: '#5c462b', align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, reqCard.node);
|
||||||
|
this.letterReqBody.node.setPosition(0, -14, 0);
|
||||||
|
|
||||||
|
// 下半卡:成画回信(与委托卡保持舒适留白)
|
||||||
|
const replyCard = createPanel('ReplyLetterCard', 506, 138, {
|
||||||
|
fill: '#eaf1e1', stroke: '#9ab785', strokeWidth: 1.8, radius: 18, stitchColor: '#9ab78588', stitchInset: 7,
|
||||||
|
}, parent);
|
||||||
|
replyCard.node.setPosition(0, -118, 0);
|
||||||
|
this.letterReplyBg = replyCard.graphics;
|
||||||
|
|
||||||
|
this.letterReplyLockNode = createUINode('ReplyLock', 28, 28, replyCard.node);
|
||||||
|
this.letterReplyLockNode.setPosition(0, 32, 0);
|
||||||
|
drawPadlockIcon(this.letterReplyLockNode.addComponent(Graphics), 1.35, '#bfa06a', '#e3ca97', '#4a321b');
|
||||||
|
|
||||||
|
this.letterReplyHeader = createLabel('ReplyHeader', '', 450, 28, {
|
||||||
|
size: 17, color: '#33542d', bold: true, align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, replyCard.node);
|
||||||
|
this.letterReplyHeader.node.setPosition(0, 42, 0);
|
||||||
|
|
||||||
|
this.letterReplyBody = createLabel('ReplyBody', '', 462, 80, {
|
||||||
|
size: 16, color: '#43583c', align: Label.HorizontalAlign.LEFT, overflow: Label.Overflow.SHRINK,
|
||||||
|
}, replyCard.node);
|
||||||
|
this.letterReplyBody.node.setPosition(0, -14, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private refreshUI(): void {
|
||||||
|
const en = this.isEn();
|
||||||
|
this.tabBtns.workshop.label.string = en ? 'Ant Craft' : '蚂蚁工坊';
|
||||||
|
this.tabBtns.gallery.label.string = en ? 'Gallery' : '绣品展柜';
|
||||||
|
this.tabBtns.letters.label.string = en ? 'Letters' : '委托信箱';
|
||||||
|
this.closeBtn.label.string = en ? 'Back' : '返 回';
|
||||||
|
|
||||||
|
(['workshop', 'gallery', 'letters'] as AtelierTab[]).forEach(tab => {
|
||||||
|
const active = tab === this.activeTab;
|
||||||
|
this.tabGroups[tab].active = active;
|
||||||
|
this.tabBtns[tab].setStyle(
|
||||||
|
active ? '#c85b56' : '#ead9b8',
|
||||||
|
active ? '#f7d58b' : '#c8ab77',
|
||||||
|
active ? '#fff9eb' : '#4e371e',
|
||||||
|
active ? '#823430' : '#b5945e',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.activeTab === 'workshop') this.refreshWorkshop();
|
||||||
|
else if (this.activeTab === 'gallery') this.refreshGallery();
|
||||||
|
else this.refreshLetters();
|
||||||
|
}
|
||||||
|
|
||||||
|
private refreshWorkshop(): void {
|
||||||
|
const en = this.isEn();
|
||||||
|
const st = this.atelier.getState();
|
||||||
|
this.wsThreadsLabel.string = en ? `Threads: ${st.yarnThreads}` : `柔丝线头:${st.yarnThreads} 束`;
|
||||||
|
this.wsPendingLabel.string = en
|
||||||
|
? `Ready: +${st.pendingThreads}/${IDLE_MAX_THREADS}`
|
||||||
|
: `待领:+${st.pendingThreads} 束(8h封顶)`;
|
||||||
|
|
||||||
|
if (st.pendingThreads > 0) {
|
||||||
|
this.wsCollectBtn.label.string = en
|
||||||
|
? `Collect Threads (+${st.pendingThreads})`
|
||||||
|
: `收下线头 (+${st.pendingThreads} 束)`;
|
||||||
|
this.wsCollectBtn.setStyle('#df9c34', '#fae09e', '#3f2207', '#996012');
|
||||||
|
} else {
|
||||||
|
const mins = this.atelier.getNextThreadMinutes(Date.now());
|
||||||
|
this.wsCollectBtn.label.string = en
|
||||||
|
? `Spinning... +1 in ${mins}m`
|
||||||
|
: `工坊织线中 · ${mins} 分钟后 +1`;
|
||||||
|
this.wsCollectBtn.setStyle('#d9c8a5', '#bca479', '#6c573c', '#a89066');
|
||||||
|
}
|
||||||
|
|
||||||
|
const diaries = this.atelier.getUnlockedDiaries();
|
||||||
|
const idx = Math.min(this.diaryIndex, Math.max(0, diaries.length - 1));
|
||||||
|
const diary = diaries[idx] ?? ANT_DIARIES[0];
|
||||||
|
this.wsDiaryHeaderLabel.string = en
|
||||||
|
? `Diary ${idx + 1}/${ANT_DIARIES.length} · ${diary.titleEn}`
|
||||||
|
: `蚂蚁日记 ${idx + 1}/${ANT_DIARIES.length} · ${diary.titleZh}`;
|
||||||
|
this.wsDiaryMoodLabel.string = en ? diary.moodEn : diary.moodZh;
|
||||||
|
drawRoundedBox(this.wsDiaryMoodBg, 78, 24, { fill: diary.accentColor, radius: 12 });
|
||||||
|
this.wsDiaryBodyLabel.string = en ? diary.bodyEn : diary.bodyZh;
|
||||||
|
|
||||||
|
this.renderer.renderWorkshopFrame(this.workshopTimeMs, st.pendingThreads);
|
||||||
|
}
|
||||||
|
|
||||||
|
private refreshGallery(): void {
|
||||||
|
const en = this.isEn();
|
||||||
|
const st = this.atelier.getState();
|
||||||
|
const hasItems = st.gallery.length > 0;
|
||||||
|
this.galEmptyNode.active = !hasItems;
|
||||||
|
this.galContentNode.active = hasItems;
|
||||||
|
if (!hasItems) return;
|
||||||
|
|
||||||
|
if (this.galleryCursor >= st.gallery.length) this.galleryCursor = st.gallery.length - 1;
|
||||||
|
const item = st.gallery[this.galleryCursor];
|
||||||
|
const lv = LEVELS[item.levelIndex];
|
||||||
|
const frameDef = this.atelier.getFrameDef();
|
||||||
|
const quoteDef = this.atelier.getQuoteDef();
|
||||||
|
|
||||||
|
drawRoundedBox(this.galPreviewCardBg, 222, 256, {
|
||||||
|
fill: frameDef.bgTop,
|
||||||
|
stroke: frameDef.accent,
|
||||||
|
strokeWidth: 2.4,
|
||||||
|
radius: 18,
|
||||||
|
shadow: 4,
|
||||||
|
});
|
||||||
|
this.galPreviewSprite.spriteFrame = this.getThumbnail(item.levelIndex);
|
||||||
|
this.galPreviewTitle.string = en ? lv.name : `《${lv.name}》`;
|
||||||
|
this.galPreviewTitle.color = hex(frameDef.accent);
|
||||||
|
this.galPreviewMeta.string = `${'★'.repeat(item.stars)}${'☆'.repeat(3 - item.stars)} · ${formatLength(item.length)}`;
|
||||||
|
this.galCounterLabel.string = `${this.galleryCursor + 1} / ${st.gallery.length}`;
|
||||||
|
this.galThreadsLabel.string = en ? `Threads: ${st.yarnThreads}` : `柔丝线头:${st.yarnThreads} 束`;
|
||||||
|
|
||||||
|
for (const entry of this.galFrameBtns) {
|
||||||
|
const def = POSTER_FRAMES.find(f => f.id === entry.id)!;
|
||||||
|
const unlocked = st.unlockedFrames.includes(entry.id);
|
||||||
|
const active = st.activeFrame === entry.id;
|
||||||
|
const baseName = en ? def.nameEn : def.nameZh;
|
||||||
|
entry.btn.label.string = unlocked ? baseName : `${baseName}(${def.cost})`;
|
||||||
|
entry.btn.setStyle(
|
||||||
|
active ? '#c85b56' : unlocked ? '#ead8b6' : '#ddd0b7',
|
||||||
|
active ? '#f7d58b' : unlocked ? '#c8ab77' : '#b2a184',
|
||||||
|
active ? '#fff9eb' : unlocked ? '#4a321a' : '#7b684e',
|
||||||
|
active ? '#823430' : '#ad8e59',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.galQuotePreview.string = en ? quoteDef.en : quoteDef.zh;
|
||||||
|
this.galExportBtn.label.string = en ? 'Export Poster' : '导出藏品海报';
|
||||||
|
}
|
||||||
|
|
||||||
|
private refreshLetters(): void {
|
||||||
|
const en = this.isEn();
|
||||||
|
const shortList = en ? CHAPTER_SHORT_EN : CHAPTER_SHORT_ZH;
|
||||||
|
this.letterTabs.forEach((tab, idx) => {
|
||||||
|
const unlocked = this.isChapterUnlocked(idx);
|
||||||
|
const active = idx === this.letterChapter;
|
||||||
|
tab.btn.label.string = shortList[idx];
|
||||||
|
tab.lockNode.active = !unlocked;
|
||||||
|
tab.btn.label.node.setPosition(unlocked ? 0 : 8, 1, 0);
|
||||||
|
tab.btn.setStyle(
|
||||||
|
active ? '#c85b56' : unlocked ? '#ead8b6' : '#d6cab4',
|
||||||
|
active ? '#f7d58b' : unlocked ? '#c8ab77' : '#aea08a',
|
||||||
|
active ? '#fff9eb' : unlocked ? '#4c3318' : '#857763',
|
||||||
|
active ? '#823430' : '#ad8e59',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const letter = this.atelier.getLetter(this.letterChapter);
|
||||||
|
this.letterReqHeader.string = en
|
||||||
|
? `${letter.senderEn} · ${letter.titleEn}`
|
||||||
|
: `委托人:${letter.senderZh} · 《${letter.titleZh}》`;
|
||||||
|
this.letterReqBody.string = en ? letter.requestEn : letter.requestZh;
|
||||||
|
|
||||||
|
const replyUnlocked = this.atelier.isChapterReplyUnlocked(this.letterChapter, lv => this.storage.getRecord(lv));
|
||||||
|
const ch = CHAPTERS[this.letterChapter];
|
||||||
|
const chStars = LEVELS.slice(ch.startIndex, ch.startIndex + ch.count).reduce(
|
||||||
|
(sum, lv) => sum + (this.storage.getRecord(lv)?.stars ?? 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
this.letterReplyLockNode.active = !replyUnlocked;
|
||||||
|
if (replyUnlocked) {
|
||||||
|
drawRoundedBox(this.letterReplyBg, 506, 138, {
|
||||||
|
fill: '#eaf1e1', stroke: '#8fb27a', strokeWidth: 1.8, radius: 18, stitchColor: '#8fb27a88', stitchInset: 7,
|
||||||
|
});
|
||||||
|
this.letterReplyHeader.node.active = true;
|
||||||
|
this.letterReplyHeader.string = en ? `✦ ${letter.replyTitleEn}` : `✦ ${letter.replyTitleZh}`;
|
||||||
|
this.letterReplyBody.color = hex('#3a5433');
|
||||||
|
this.letterReplyBody.horizontalAlign = Label.HorizontalAlign.LEFT;
|
||||||
|
this.letterReplyBody.node.setPosition(0, -14, 0);
|
||||||
|
this.letterReplyBody.string = en ? letter.replyEn : letter.replyZh;
|
||||||
|
} else {
|
||||||
|
drawRoundedBox(this.letterReplyBg, 506, 138, {
|
||||||
|
fill: '#efe5d0', stroke: '#cbb48a', strokeWidth: 1.6, radius: 18, stitchColor: '#cbb48a80', stitchInset: 7,
|
||||||
|
});
|
||||||
|
this.letterReplyHeader.node.active = false;
|
||||||
|
this.letterReplyBody.color = hex('#755f42');
|
||||||
|
this.letterReplyBody.horizontalAlign = Label.HorizontalAlign.CENTER;
|
||||||
|
this.letterReplyBody.node.setPosition(0, -16, 0);
|
||||||
|
this.letterReplyBody.string = this.letterChapter === 0
|
||||||
|
? (en
|
||||||
|
? 'Finish Stage 1 (Golden Sunflower) to read Grandma Lin’s reply!'
|
||||||
|
: '绣完第 1 关《金色向日葵》,即可立刻拆阅林阿婆的暖心回信!')
|
||||||
|
: (en
|
||||||
|
? `Clear Chapter Boss or earn 15 ★ in this chapter to open the reply (${chStars} / 15 ★).`
|
||||||
|
: `通关本章终考关,或本章集满 15 ★ 即可拆阅客人回信\n(当前本章已获 ${chStars} / 15 ★)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected update(dt: number): void {
|
||||||
|
if (!this.node.active || this.activeTab !== 'workshop') return;
|
||||||
|
this.workshopTimeMs += Math.min(50, Math.max(0, dt * 1000));
|
||||||
|
this.renderer.renderWorkshopFrame(this.workshopTimeMs, this.atelier.getState().pendingThreads);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "9dc539ef-2450-466e-a081-e730151809b3",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "80a6df9c-75ae-44b3-b21e-b0f999a50a37",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a0eaa4b4-714c-4e00-9412-68230ed12d7e",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
import { Node, ResolutionPolicy, screen, UITransform, Vec3, view } from 'cc';
|
||||||
|
|
||||||
|
declare const wx: any;
|
||||||
|
|
||||||
|
export const DESIGN_W = 750;
|
||||||
|
export const DESIGN_H = 1334;
|
||||||
|
|
||||||
|
export interface ScreenMetrics {
|
||||||
|
visibleW: number;
|
||||||
|
visibleH: number;
|
||||||
|
/** 顶部安全区高度(含刘海/灵动岛,设计坐标) */
|
||||||
|
topInset: number;
|
||||||
|
/** 微信右上角胶囊下沿距屏幕顶部的安全距离(设计坐标) */
|
||||||
|
capsuleBottom: number;
|
||||||
|
/** 底部安全区高度(含 iPhone Home 手势条,设计坐标) */
|
||||||
|
bottomInset: number;
|
||||||
|
/** 安全区实际可用高度(safeRoot 局部坐标系中 >= 1334,全面屏自动舒展消除上下大空白) */
|
||||||
|
safeHeight: number;
|
||||||
|
/** 安全区半高:safeRoot 内顶安全边 = +safeHalfH,底安全边 = -safeHalfH */
|
||||||
|
safeHalfH: number;
|
||||||
|
/** 超出 1334 基准的额外垂直空间(用于均匀拉宽中间板块间距) */
|
||||||
|
extraH: number;
|
||||||
|
/** 主内容区整体缩放系数(仅超短屏 + 胶囊时自动收拢防裁切) */
|
||||||
|
contentScale: number;
|
||||||
|
/** safeRoot 中心在屏幕中的 Y 偏移 */
|
||||||
|
contentOffsetY: number;
|
||||||
|
/** 背景图全屏铺满(cover)所需缩放系数 */
|
||||||
|
bgCoverScale: number;
|
||||||
|
isWeChat: boolean;
|
||||||
|
/** 浏览器预览调试参数 ?wxsim=iphone15 / ?wxsim=iphonese 时的模拟胶囊信息 */
|
||||||
|
mockCapsule?: { top: number; height: number; width: number; right: number };
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWeChatSimMode(): 'iphone15' | 'iphonese' | null {
|
||||||
|
try {
|
||||||
|
if (typeof window === 'undefined' || !window.location?.search) return null;
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const val = (params.get('wxsim') || '').toLowerCase();
|
||||||
|
if (val === 'iphone15' || val === '15') return 'iphone15';
|
||||||
|
if (val === 'iphonese' || val === 'se') return 'iphonese';
|
||||||
|
} catch {
|
||||||
|
// Ignore non-browser environments.
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自适应分辨率策略:
|
||||||
|
* - 竖屏手机(比例 <= 9:16,如 16:9 / 19.5:9 / 20:9)使用 FIXED_WIDTH,消除全面屏上下黑边;
|
||||||
|
* - 平板 / 折叠屏展开 / 桌面横屏预览(比例 > 9:16)使用 FIXED_HEIGHT,确保上下完整不裁切。
|
||||||
|
*/
|
||||||
|
export function applyResponsivePolicy(): void {
|
||||||
|
const frame = screen.windowSize;
|
||||||
|
if (!frame || frame.width <= 0 || frame.height <= 0) return;
|
||||||
|
const aspect = frame.width / frame.height;
|
||||||
|
const designAspect = DESIGN_W / DESIGN_H;
|
||||||
|
const policy = aspect <= designAspect + 0.005 ? ResolutionPolicy.FIXED_WIDTH : ResolutionPolicy.FIXED_HEIGHT;
|
||||||
|
view.setDesignResolutionSize(DESIGN_W, DESIGN_H, policy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一读取微信小游戏胶囊按钮(getMenuButtonBoundingClientRect)与安全区(getWindowInfo / getSystemInfoSync),
|
||||||
|
* 并换算为 Cocos 设计分辨率坐标系。
|
||||||
|
*/
|
||||||
|
export function computeScreenMetrics(): ScreenMetrics {
|
||||||
|
const vis = view.getVisibleSize();
|
||||||
|
const visibleW = Math.max(DESIGN_W, vis.width || DESIGN_W);
|
||||||
|
const visibleH = Math.max(DESIGN_H, vis.height || DESIGN_H);
|
||||||
|
|
||||||
|
let topInset = 0;
|
||||||
|
let capsuleBottom = 0;
|
||||||
|
let bottomInset = 0;
|
||||||
|
let isWeChat = false;
|
||||||
|
let mockCapsule: ScreenMetrics['mockCapsule'];
|
||||||
|
|
||||||
|
if (typeof wx !== 'undefined') {
|
||||||
|
isWeChat = true;
|
||||||
|
try {
|
||||||
|
const winInfo =
|
||||||
|
typeof wx.getWindowInfo === 'function'
|
||||||
|
? wx.getWindowInfo()
|
||||||
|
: typeof wx.getSystemInfoSync === 'function'
|
||||||
|
? wx.getSystemInfoSync()
|
||||||
|
: null;
|
||||||
|
const winH = Number(winInfo?.windowHeight) || Number(winInfo?.screenHeight) || 0;
|
||||||
|
const scaleY = winH > 0 ? visibleH / winH : visibleW / (Number(winInfo?.windowWidth) || 375);
|
||||||
|
|
||||||
|
const safe = winInfo?.safeArea;
|
||||||
|
if (safe && winH > 0) {
|
||||||
|
topInset = Math.max(0, Number(safe.top) || 0) * scaleY;
|
||||||
|
const rawBottom = winH - (Number(safe.bottom) || winH);
|
||||||
|
bottomInset = Math.max(0, rawBottom) * scaleY;
|
||||||
|
} else if (winInfo?.statusBarHeight) {
|
||||||
|
topInset = Math.max(0, Number(winInfo.statusBarHeight) || 0) * scaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof wx.getMenuButtonBoundingClientRect === 'function') {
|
||||||
|
const menu = wx.getMenuButtonBoundingClientRect();
|
||||||
|
if (menu && Number(menu.bottom) > 0) {
|
||||||
|
// 紧贴胶囊下沿留 10px 轻呼吸距,避免顶部出现大块空白
|
||||||
|
capsuleBottom = Number(menu.bottom) * scaleY + 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (capsuleBottom <= 0) {
|
||||||
|
capsuleBottom = Math.max(topInset + 76, 108);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
capsuleBottom = 112;
|
||||||
|
bottomInset = 32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const sim = getWeChatSimMode();
|
||||||
|
if (sim === 'iphone15') {
|
||||||
|
isWeChat = true;
|
||||||
|
topInset = 98;
|
||||||
|
capsuleBottom = 172;
|
||||||
|
bottomInset = 52;
|
||||||
|
mockCapsule = { top: 98, height: 62, width: 168, right: 20 };
|
||||||
|
} else if (sim === 'iphonese') {
|
||||||
|
isWeChat = true;
|
||||||
|
topInset = 38;
|
||||||
|
capsuleBottom = 112;
|
||||||
|
bottomInset = 0;
|
||||||
|
mockCapsule = { top: 38, height: 64, width: 174, right: 18 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const effectiveTop = Math.max(topInset, capsuleBottom);
|
||||||
|
// 底部手势条只保留必要安全高度(上限 54px),避免底部产生大块空木板
|
||||||
|
const effectiveBottom = Math.min(54, Math.max(0, bottomInset));
|
||||||
|
const availableH = Math.max(640, visibleH - effectiveTop - effectiveBottom);
|
||||||
|
|
||||||
|
const contentScale = availableH < DESIGN_H ? Math.max(0.78, availableH / DESIGN_H) : 1;
|
||||||
|
const safeHeight = availableH >= DESIGN_H ? Math.min(1560, availableH) : DESIGN_H;
|
||||||
|
const safeHalfH = safeHeight / 2;
|
||||||
|
const extraH = Math.max(0, safeHeight - DESIGN_H);
|
||||||
|
|
||||||
|
const safeTopY = visibleH / 2 - effectiveTop;
|
||||||
|
const safeBottomY = -visibleH / 2 + effectiveBottom;
|
||||||
|
const contentOffsetY = (safeTopY + safeBottomY) / 2;
|
||||||
|
|
||||||
|
const bgCoverScale = Math.max(visibleW / DESIGN_W, visibleH / DESIGN_H);
|
||||||
|
|
||||||
|
return {
|
||||||
|
visibleW,
|
||||||
|
visibleH,
|
||||||
|
topInset,
|
||||||
|
capsuleBottom,
|
||||||
|
bottomInset,
|
||||||
|
safeHeight,
|
||||||
|
safeHalfH,
|
||||||
|
extraH,
|
||||||
|
contentScale,
|
||||||
|
contentOffsetY,
|
||||||
|
bgCoverScale,
|
||||||
|
isWeChat,
|
||||||
|
mockCapsule,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将主内容容器精准居中并缩放到安全区(避开微信胶囊 + 刘海 + 底部手势条) */
|
||||||
|
export function applySafeContentTransform(contentRoot: Node, m: ScreenMetrics): void {
|
||||||
|
const ui = contentRoot.getComponent(UITransform);
|
||||||
|
if (ui) ui.setContentSize(DESIGN_W, m.safeHeight);
|
||||||
|
contentRoot.setPosition(0, m.contentOffsetY, 0);
|
||||||
|
contentRoot.setScale(new Vec3(m.contentScale, m.contentScale, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将背景精灵按屏幕比例等比铺满(cover),消除全面屏上下黑边 */
|
||||||
|
export function applyCoverBackground(bgNode: Node, m: ScreenMetrics): void {
|
||||||
|
bgNode.setPosition(0, 0, 0);
|
||||||
|
bgNode.setScale(new Vec3(m.bgCoverScale, m.bgCoverScale, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将遮罩节点铺满全屏(兼容任意长宽比) */
|
||||||
|
export function applyFullScrimSize(scrimNode: Node, m: ScreenMetrics): void {
|
||||||
|
const ui = scrimNode.getComponent(UITransform);
|
||||||
|
if (ui) ui.setContentSize(Math.max(2400, m.visibleW + 40), Math.max(2400, m.visibleH + 40));
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "a8021e06-ffa1-41ce-bd82-0ac950fbd90f",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,853 @@
|
|||||||
|
import { Button, Color, Graphics, ImageAsset, Label, Layers, Node, resources, Sprite, SpriteFrame, Texture2D, UITransform, Widget } from 'cc';
|
||||||
|
|
||||||
|
declare const wx: any;
|
||||||
|
|
||||||
|
export const UI_LAYER = Layers.Enum.UI_2D;
|
||||||
|
|
||||||
|
export function hex(code: string): Color {
|
||||||
|
const c = new Color();
|
||||||
|
Color.fromHEX(c, code);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BoxStyle {
|
||||||
|
fill?: string;
|
||||||
|
stroke?: string;
|
||||||
|
strokeWidth?: number;
|
||||||
|
radius?: number;
|
||||||
|
/** 3D 底部厚边(实体按键/木牌立体感) */
|
||||||
|
depth?: number;
|
||||||
|
depthColor?: string;
|
||||||
|
/** 柔和落影偏移 */
|
||||||
|
shadow?: number;
|
||||||
|
shadowColor?: string;
|
||||||
|
/** 顶部高光细线 */
|
||||||
|
highlight?: string;
|
||||||
|
/** 内侧虚线手缝线装饰 */
|
||||||
|
stitchColor?: string;
|
||||||
|
stitchInset?: number;
|
||||||
|
/** 四角黄铜铆钉装饰 */
|
||||||
|
rivets?: boolean;
|
||||||
|
rivetColor?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createUINode(name: string, w: number, h: number, parent?: Node): Node {
|
||||||
|
const node = new Node(name);
|
||||||
|
node.layer = UI_LAYER;
|
||||||
|
const ui = node.addComponent(UITransform);
|
||||||
|
ui.setContentSize(w, h);
|
||||||
|
if (parent) parent.addChild(node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawDashedRect(g: Graphics, x: number, y: number, w: number, h: number, color: string): void {
|
||||||
|
g.strokeColor = hex(color);
|
||||||
|
g.lineWidth = 1.6;
|
||||||
|
const dash = 7;
|
||||||
|
const gap = 5;
|
||||||
|
const drawEdge = (x1: number, y1: number, x2: number, y2: number) => {
|
||||||
|
const dist = Math.hypot(x2 - x1, y2 - y1);
|
||||||
|
const ux = (x2 - x1) / dist;
|
||||||
|
const uy = (y2 - y1) / dist;
|
||||||
|
let pos = 4;
|
||||||
|
while (pos < dist - 4) {
|
||||||
|
const end = Math.min(dist - 4, pos + dash);
|
||||||
|
g.moveTo(x1 + ux * pos, y1 + uy * pos);
|
||||||
|
g.lineTo(x1 + ux * end, y1 + uy * end);
|
||||||
|
pos = end + gap;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
drawEdge(x, y + h, x + w, y + h);
|
||||||
|
drawEdge(x + w, y + h, x + w, y);
|
||||||
|
drawEdge(x + w, y, x, y);
|
||||||
|
drawEdge(x, y, x, y + h);
|
||||||
|
g.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function drawPadlockIcon(
|
||||||
|
g: Graphics,
|
||||||
|
scale = 1,
|
||||||
|
bodyColor = '#d6b67d',
|
||||||
|
shackleColor = '#ecd2a2',
|
||||||
|
keyholeColor = '#46311f',
|
||||||
|
): void {
|
||||||
|
g.clear();
|
||||||
|
const s = scale;
|
||||||
|
const r = 3.7 * s;
|
||||||
|
const archY = 3.2 * s;
|
||||||
|
|
||||||
|
// 锁梁(U 型圆弧,手动采样保证各端方向一致)
|
||||||
|
g.strokeColor = hex(shackleColor);
|
||||||
|
g.lineWidth = Math.max(1.5, 2.0 * s);
|
||||||
|
g.moveTo(-r, 0.2 * s);
|
||||||
|
g.lineTo(-r, archY);
|
||||||
|
const steps = 12;
|
||||||
|
for (let i = 1; i <= steps; i++) {
|
||||||
|
const t = Math.PI - (Math.PI * i) / steps;
|
||||||
|
g.lineTo(Math.cos(t) * r, archY + Math.sin(t) * r);
|
||||||
|
}
|
||||||
|
g.lineTo(r, 0.2 * s);
|
||||||
|
g.stroke();
|
||||||
|
|
||||||
|
// 锁身(倒角金属块)
|
||||||
|
const bw = 11.4 * s;
|
||||||
|
const bh = 8.6 * s;
|
||||||
|
g.fillColor = hex(bodyColor);
|
||||||
|
g.roundRect(-bw / 2, -6.8 * s, bw, bh, 2.2 * s);
|
||||||
|
g.fill();
|
||||||
|
|
||||||
|
// 锁孔
|
||||||
|
g.fillColor = hex(keyholeColor);
|
||||||
|
g.circle(0, -1.7 * s, 1.45 * s);
|
||||||
|
g.fill();
|
||||||
|
g.rect(-0.68 * s, -4.6 * s, 1.36 * s, 2.7 * s);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function drawEnvelopeIcon(g: Graphics, scale = 1, color = '#fff2cf', sealColor = '#d45a52'): void {
|
||||||
|
g.clear();
|
||||||
|
const s = scale;
|
||||||
|
const w = 22 * s;
|
||||||
|
const h = 15 * s;
|
||||||
|
g.strokeColor = hex(color);
|
||||||
|
g.lineWidth = Math.max(1.6, 2.1 * s);
|
||||||
|
g.roundRect(-w / 2, -h / 2, w, h, 2.4 * s);
|
||||||
|
g.stroke();
|
||||||
|
|
||||||
|
g.moveTo(-w / 2 + 1.5 * s, h / 2 - 1.5 * s);
|
||||||
|
g.lineTo(0, -1.2 * s);
|
||||||
|
g.lineTo(w / 2 - 1.5 * s, h / 2 - 1.5 * s);
|
||||||
|
g.stroke();
|
||||||
|
|
||||||
|
g.fillColor = hex(sealColor);
|
||||||
|
g.circle(0, -1.6 * s, 3.0 * s);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function drawSpoolIcon(g: Graphics, scale = 1, woodColor = '#f4d694', threadColor = '#93be76'): void {
|
||||||
|
g.clear();
|
||||||
|
const s = scale;
|
||||||
|
// 绕线身
|
||||||
|
g.fillColor = hex(threadColor);
|
||||||
|
g.roundRect(-7 * s, -7 * s, 14 * s, 14 * s, 2.5 * s);
|
||||||
|
g.fill();
|
||||||
|
// 几道柔和丝线横纹
|
||||||
|
g.strokeColor = hex('#eef7dc99');
|
||||||
|
g.lineWidth = 1.3 * s;
|
||||||
|
for (const ry of [-3.4, 0, 3.4]) {
|
||||||
|
g.moveTo(-6.2 * s, ry * s);
|
||||||
|
g.lineTo(6.2 * s, ry * s);
|
||||||
|
}
|
||||||
|
g.stroke();
|
||||||
|
// 上下木挡片
|
||||||
|
g.fillColor = hex(woodColor);
|
||||||
|
g.roundRect(-10.5 * s, 6.2 * s, 21 * s, 4.4 * s, 2 * s);
|
||||||
|
g.roundRect(-10.5 * s, -10.6 * s, 21 * s, 4.4 * s, 2 * s);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function drawGalleryFrameIcon(g: Graphics, scale = 1, frameColor = '#fff0c8', accentColor = '#e6b14c'): void {
|
||||||
|
g.clear();
|
||||||
|
const s = scale;
|
||||||
|
const w = 20 * s;
|
||||||
|
const h = 22 * s;
|
||||||
|
g.strokeColor = hex(frameColor);
|
||||||
|
g.lineWidth = Math.max(1.8, 2.2 * s);
|
||||||
|
g.roundRect(-w / 2, -h / 2, w, h, 3 * s);
|
||||||
|
g.stroke();
|
||||||
|
|
||||||
|
// 内绣绷圆环 + 小花点缀
|
||||||
|
g.strokeColor = hex(accentColor);
|
||||||
|
g.lineWidth = 1.6 * s;
|
||||||
|
g.circle(0, 1.5 * s, 5.4 * s);
|
||||||
|
g.stroke();
|
||||||
|
|
||||||
|
g.fillColor = hex(accentColor);
|
||||||
|
g.circle(0, 1.5 * s, 2.2 * s);
|
||||||
|
g.fill();
|
||||||
|
|
||||||
|
g.strokeColor = hex(frameColor);
|
||||||
|
g.lineWidth = 1.5 * s;
|
||||||
|
g.moveTo(-5.5 * s, -6.8 * s);
|
||||||
|
g.lineTo(5.5 * s, -6.8 * s);
|
||||||
|
g.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function drawRoundedBox(g: Graphics, w: number, h: number, style: BoxStyle): void {
|
||||||
|
g.clear();
|
||||||
|
const r = Math.min(style.radius ?? 16, w / 2, h / 2);
|
||||||
|
const x = -w / 2;
|
||||||
|
const y = -h / 2;
|
||||||
|
const depth = style.depth ?? 0;
|
||||||
|
const shadow = style.shadow ?? 0;
|
||||||
|
|
||||||
|
// 1. 柔和地面投影
|
||||||
|
if (shadow > 0) {
|
||||||
|
g.fillColor = hex(style.shadowColor ?? '#1b211438');
|
||||||
|
const sy = y - depth - shadow;
|
||||||
|
if (r > 0) g.roundRect(x + 1, sy, w - 2, h, r);
|
||||||
|
else g.rect(x + 1, sy, w - 2, h);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 实体 3D 底座厚边
|
||||||
|
if (depth > 0) {
|
||||||
|
g.fillColor = hex(style.depthColor ?? '#3b4530');
|
||||||
|
if (r > 0) g.roundRect(x, y - depth, w, h, r);
|
||||||
|
else g.rect(x, y - depth, w, h);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 主面板填充
|
||||||
|
if (style.fill) {
|
||||||
|
g.fillColor = hex(style.fill);
|
||||||
|
if (r > 0) g.roundRect(x, y, w, h, r);
|
||||||
|
else g.rect(x, y, w, h);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 顶部微光高光带(让按钮/木牌有温润手作光泽)
|
||||||
|
if (style.highlight && w > 24 && h > 16) {
|
||||||
|
const inset = Math.max(4, Math.min(r * 0.65, 16));
|
||||||
|
g.strokeColor = hex(style.highlight);
|
||||||
|
g.lineWidth = 2;
|
||||||
|
g.moveTo(x + inset, y + h - 2.5);
|
||||||
|
g.lineTo(x + w - inset, y + h - 2.5);
|
||||||
|
g.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 外描边
|
||||||
|
if (style.stroke) {
|
||||||
|
g.strokeColor = hex(style.stroke);
|
||||||
|
g.lineWidth = style.strokeWidth ?? 2;
|
||||||
|
if (r > 0) g.roundRect(x, y, w, h, r);
|
||||||
|
else g.rect(x, y, w, h);
|
||||||
|
g.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 内侧手缝虚线
|
||||||
|
if (style.stitchColor) {
|
||||||
|
const inset = style.stitchInset ?? 8;
|
||||||
|
if (w > inset * 2 + 16 && h > inset * 2 + 16) {
|
||||||
|
drawDashedRect(g, x + inset, y + inset, w - inset * 2, h - inset * 2, style.stitchColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 四角黄铜铆钉
|
||||||
|
if (style.rivets && w > 48 && h > 40) {
|
||||||
|
const pad = Math.max(12, Math.min(18, r * 0.65));
|
||||||
|
const pts = [
|
||||||
|
[x + pad, y + h - pad],
|
||||||
|
[x + w - pad, y + h - pad],
|
||||||
|
[x + pad, y + pad],
|
||||||
|
[x + w - pad, y + pad],
|
||||||
|
];
|
||||||
|
for (const [rx, ry] of pts) {
|
||||||
|
g.fillColor = hex('#2c1e1255');
|
||||||
|
g.circle(rx, ry - 1.2, 3.6);
|
||||||
|
g.fill();
|
||||||
|
g.fillColor = hex(style.rivetColor ?? '#d9ad62');
|
||||||
|
g.circle(rx, ry, 3.2);
|
||||||
|
g.fill();
|
||||||
|
g.fillColor = hex('#fff2cfcc');
|
||||||
|
g.circle(rx - 0.9, ry + 0.9, 1.1);
|
||||||
|
g.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPanel(name: string, w: number, h: number, style: BoxStyle, parent?: Node): { node: Node; graphics: Graphics } {
|
||||||
|
const node = createUINode(name, w, h, parent);
|
||||||
|
const graphics = node.addComponent(Graphics);
|
||||||
|
drawRoundedBox(graphics, w, h, style);
|
||||||
|
return { node, graphics };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LabelStyle {
|
||||||
|
size?: number;
|
||||||
|
lineHeight?: number;
|
||||||
|
color?: string;
|
||||||
|
bold?: boolean;
|
||||||
|
align?: number;
|
||||||
|
verticalAlign?: number;
|
||||||
|
overflow?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createLabel(name: string, text: string, w: number, h: number, style: LabelStyle = {}, parent?: Node): Label {
|
||||||
|
const node = createUINode(name, w, h, parent);
|
||||||
|
const label = node.addComponent(Label);
|
||||||
|
label.string = text;
|
||||||
|
label.fontSize = style.size ?? 24;
|
||||||
|
label.lineHeight = style.lineHeight ?? Math.round((style.size ?? 24) * 1.25);
|
||||||
|
label.color = hex(style.color ?? '#302e22');
|
||||||
|
label.isBold = Boolean(style.bold);
|
||||||
|
label.horizontalAlign = style.align ?? Label.HorizontalAlign.CENTER;
|
||||||
|
label.verticalAlign = style.verticalAlign ?? Label.VerticalAlign.CENTER;
|
||||||
|
if (style.overflow !== undefined) label.overflow = style.overflow;
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ButtonSpec {
|
||||||
|
name: string;
|
||||||
|
text: string;
|
||||||
|
w: number;
|
||||||
|
h: number;
|
||||||
|
fill: string;
|
||||||
|
stroke?: string;
|
||||||
|
depth?: number;
|
||||||
|
depthColor?: string;
|
||||||
|
shadow?: number;
|
||||||
|
highlight?: string;
|
||||||
|
stitchColor?: string;
|
||||||
|
textColor?: string;
|
||||||
|
fontSize?: number;
|
||||||
|
radius?: number;
|
||||||
|
bold?: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StyledButton {
|
||||||
|
node: Node;
|
||||||
|
button: Button;
|
||||||
|
label: Label;
|
||||||
|
graphics: Graphics;
|
||||||
|
setStyle: (fill: string, stroke: string | undefined, textColor: string, depthColor?: string) => void;
|
||||||
|
setEnabled: (enabled: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createButton(spec: ButtonSpec, parent?: Node): StyledButton {
|
||||||
|
const radius = spec.radius ?? Math.min(22, spec.h / 2);
|
||||||
|
const depth = spec.depth ?? 5;
|
||||||
|
const shadow = spec.shadow ?? 3;
|
||||||
|
const highlight = spec.highlight ?? '#ffffff55';
|
||||||
|
const defaultDepth = spec.depthColor ?? spec.stroke ?? '#3c4530';
|
||||||
|
|
||||||
|
const { node, graphics } = createPanel(
|
||||||
|
spec.name,
|
||||||
|
spec.w,
|
||||||
|
spec.h,
|
||||||
|
{
|
||||||
|
fill: spec.fill,
|
||||||
|
stroke: spec.stroke,
|
||||||
|
strokeWidth: 2,
|
||||||
|
radius,
|
||||||
|
depth,
|
||||||
|
depthColor: defaultDepth,
|
||||||
|
shadow,
|
||||||
|
highlight,
|
||||||
|
stitchColor: spec.stitchColor,
|
||||||
|
stitchInset: 6,
|
||||||
|
},
|
||||||
|
parent,
|
||||||
|
);
|
||||||
|
const label = createLabel(
|
||||||
|
'Label',
|
||||||
|
spec.text,
|
||||||
|
spec.w - 14,
|
||||||
|
spec.h,
|
||||||
|
{
|
||||||
|
size: spec.fontSize ?? 24,
|
||||||
|
color: spec.textColor ?? '#302e22',
|
||||||
|
bold: spec.bold ?? true,
|
||||||
|
overflow: Label.Overflow.SHRINK,
|
||||||
|
},
|
||||||
|
node,
|
||||||
|
);
|
||||||
|
const button = node.addComponent(Button);
|
||||||
|
button.transition = Button.Transition.SCALE;
|
||||||
|
button.zoomScale = 0.93;
|
||||||
|
node.on(Button.EventType.CLICK, () => {
|
||||||
|
if (button.interactable) spec.onClick();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
node,
|
||||||
|
button,
|
||||||
|
label,
|
||||||
|
graphics,
|
||||||
|
setStyle(fill: string, stroke: string | undefined, textColor: string, depthColor?: string) {
|
||||||
|
drawRoundedBox(graphics, spec.w, spec.h, {
|
||||||
|
fill,
|
||||||
|
stroke,
|
||||||
|
strokeWidth: 2,
|
||||||
|
radius,
|
||||||
|
depth,
|
||||||
|
depthColor: depthColor ?? stroke ?? defaultDepth,
|
||||||
|
shadow,
|
||||||
|
highlight,
|
||||||
|
stitchColor: spec.stitchColor,
|
||||||
|
stitchInset: 6,
|
||||||
|
});
|
||||||
|
label.color = hex(textColor);
|
||||||
|
},
|
||||||
|
setEnabled(enabled: boolean) {
|
||||||
|
button.interactable = enabled;
|
||||||
|
const base = label.color.clone();
|
||||||
|
base.a = enabled ? 255 : 115;
|
||||||
|
label.color = base;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockButtonSpec {
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
text: string;
|
||||||
|
w: number;
|
||||||
|
h: number;
|
||||||
|
fill: string;
|
||||||
|
stroke: string;
|
||||||
|
depthColor: string;
|
||||||
|
iconBg: string;
|
||||||
|
iconColor: string;
|
||||||
|
textColor: string;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DockButton extends StyledButton {
|
||||||
|
iconLabel: Label;
|
||||||
|
iconBgGraphics: Graphics;
|
||||||
|
setDockStyle: (fill: string, stroke: string, depthColor: string, iconBg: string, iconColor: string, textColor: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 底部游戏工具栏专用:上图标徽章 + 下短文字 + 3D 实体木/陶按压底座 */
|
||||||
|
export function createDockButton(spec: DockButtonSpec, parent?: Node): DockButton {
|
||||||
|
const radius = 20;
|
||||||
|
const { node, graphics } = createPanel(
|
||||||
|
spec.name,
|
||||||
|
spec.w,
|
||||||
|
spec.h,
|
||||||
|
{
|
||||||
|
fill: spec.fill,
|
||||||
|
stroke: spec.stroke,
|
||||||
|
strokeWidth: 2,
|
||||||
|
radius,
|
||||||
|
depth: 6,
|
||||||
|
depthColor: spec.depthColor,
|
||||||
|
shadow: 4,
|
||||||
|
highlight: '#fffdf466',
|
||||||
|
},
|
||||||
|
parent,
|
||||||
|
);
|
||||||
|
|
||||||
|
const badge = createPanel('IconBadge', 44, 44, { fill: spec.iconBg, radius: 22 }, node);
|
||||||
|
badge.node.setPosition(0, 14, 0);
|
||||||
|
const iconLabel = createLabel('Icon', spec.icon, 44, 44, { size: 25, color: spec.iconColor, bold: true }, badge.node);
|
||||||
|
|
||||||
|
const label = createLabel(
|
||||||
|
'Label',
|
||||||
|
spec.text,
|
||||||
|
spec.w - 10,
|
||||||
|
26,
|
||||||
|
{ size: 18, color: spec.textColor, bold: true, overflow: Label.Overflow.SHRINK },
|
||||||
|
node,
|
||||||
|
);
|
||||||
|
label.node.setPosition(0, -25, 0);
|
||||||
|
|
||||||
|
const button = node.addComponent(Button);
|
||||||
|
button.transition = Button.Transition.SCALE;
|
||||||
|
button.zoomScale = 0.91;
|
||||||
|
node.on(Button.EventType.CLICK, () => {
|
||||||
|
if (button.interactable) spec.onClick();
|
||||||
|
});
|
||||||
|
|
||||||
|
const applyDock = (fill: string, stroke: string, depthColor: string, iconBg: string, iconColor: string, textColor: string) => {
|
||||||
|
drawRoundedBox(graphics, spec.w, spec.h, {
|
||||||
|
fill,
|
||||||
|
stroke,
|
||||||
|
strokeWidth: 2,
|
||||||
|
radius,
|
||||||
|
depth: 6,
|
||||||
|
depthColor,
|
||||||
|
shadow: 4,
|
||||||
|
highlight: '#fffdf466',
|
||||||
|
});
|
||||||
|
drawRoundedBox(badge.graphics, 44, 44, { fill: iconBg, radius: 22 });
|
||||||
|
iconLabel.color = hex(iconColor);
|
||||||
|
label.color = hex(textColor);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
node,
|
||||||
|
button,
|
||||||
|
label,
|
||||||
|
graphics,
|
||||||
|
iconLabel,
|
||||||
|
iconBgGraphics: badge.graphics,
|
||||||
|
setStyle(fill: string, stroke: string | undefined, textColor: string, depthColor?: string) {
|
||||||
|
applyDock(fill, stroke ?? spec.stroke, depthColor ?? stroke ?? spec.depthColor, spec.iconBg, spec.iconColor, textColor);
|
||||||
|
},
|
||||||
|
setDockStyle: applyDock,
|
||||||
|
setEnabled(enabled: boolean) {
|
||||||
|
button.interactable = enabled;
|
||||||
|
const tc = label.color.clone();
|
||||||
|
tc.a = enabled ? 255 : 110;
|
||||||
|
label.color = tc;
|
||||||
|
const ic = iconLabel.color.clone();
|
||||||
|
ic.a = enabled ? 255 : 110;
|
||||||
|
iconLabel.color = ic;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeOffscreenCanvas(w: number, h: number): any {
|
||||||
|
const c = typeof wx !== 'undefined' && typeof wx.createCanvas === 'function'
|
||||||
|
? wx.createCanvas()
|
||||||
|
: document.createElement('canvas');
|
||||||
|
c.width = w;
|
||||||
|
c.height = h;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function canvasToSpriteFrame(canvas: any): SpriteFrame {
|
||||||
|
const img = new ImageAsset(canvas);
|
||||||
|
const tex = new Texture2D();
|
||||||
|
tex.image = img;
|
||||||
|
const sf = new SpriteFrame();
|
||||||
|
sf.texture = tex;
|
||||||
|
return sf;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cachedPlayBg: SpriteFrame | null = null;
|
||||||
|
let cachedLobbyBg: SpriteFrame | null = null;
|
||||||
|
|
||||||
|
/** 生成对局场景全屏「手作刺绣工坊桌面」纹理(苔绿麻布台垫 + 暖光斜照 + 木桌边沿 + 角落小道具) */
|
||||||
|
export function createAtelierTableSpriteFrame(): SpriteFrame {
|
||||||
|
if (cachedPlayBg) return cachedPlayBg;
|
||||||
|
const W = 750;
|
||||||
|
const H = 1334;
|
||||||
|
const canvas = makeOffscreenCanvas(W, H);
|
||||||
|
const ctx: CanvasRenderingContext2D = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// 1. 基底:苔藓绿手作亚麻桌垫渐变(模拟从左上方洒下的自然窗光)
|
||||||
|
const baseGrad = ctx.createRadialGradient(210, 260, 40, W * 0.52, H * 0.48, 860);
|
||||||
|
baseGrad.addColorStop(0, '#728562');
|
||||||
|
baseGrad.addColorStop(0.42, '#5c6e4f');
|
||||||
|
baseGrad.addColorStop(0.82, '#47573d');
|
||||||
|
baseGrad.addColorStop(1, '#36432e');
|
||||||
|
ctx.fillStyle = baseGrad;
|
||||||
|
ctx.fillRect(0, 0, W, H);
|
||||||
|
|
||||||
|
// 2. 亚麻细密织纹
|
||||||
|
ctx.save();
|
||||||
|
ctx.strokeStyle = 'rgba(255, 248, 226, 0.045)';
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
for (let x = 0; x < W; x += 6) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, 0);
|
||||||
|
ctx.lineTo(x, H);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.strokeStyle = 'rgba(20, 28, 16, 0.05)';
|
||||||
|
for (let y = 0; y < H; y += 6) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, y);
|
||||||
|
ctx.lineTo(W, y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 3. 左右极细原木桌沿(带来真实桌面的边界感,但绝不挤占空间)
|
||||||
|
const drawWoodTrim = (x0: number, w: number) => {
|
||||||
|
const g = ctx.createLinearGradient(x0, 0, x0 + w, 0);
|
||||||
|
g.addColorStop(0, '#6e492b');
|
||||||
|
g.addColorStop(0.5, '#8c603c');
|
||||||
|
g.addColorStop(1, '#583920');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fillRect(x0, 0, w, H);
|
||||||
|
};
|
||||||
|
drawWoodTrim(0, 10);
|
||||||
|
drawWoodTrim(W - 10, 10);
|
||||||
|
|
||||||
|
// 4. 内侧细金线压边(刺绣桌垫滚边)
|
||||||
|
ctx.save();
|
||||||
|
ctx.strokeStyle = 'rgba(244, 224, 174, 0.24)';
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.setLineDash([8, 6]);
|
||||||
|
ctx.strokeRect(20, 20, W - 40, H - 40);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 5. 柔和斜射日光斑(氛围层次)
|
||||||
|
ctx.save();
|
||||||
|
const sunGrad = ctx.createLinearGradient(0, 0, 560, 620);
|
||||||
|
sunGrad.addColorStop(0, 'rgba(255, 245, 212, 0.14)');
|
||||||
|
sunGrad.addColorStop(0.5, 'rgba(255, 245, 212, 0.03)');
|
||||||
|
sunGrad.addColorStop(1, 'rgba(255, 245, 212, 0)');
|
||||||
|
ctx.fillStyle = sunGrad;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 0);
|
||||||
|
ctx.lineTo(520, 0);
|
||||||
|
ctx.lineTo(750, 480);
|
||||||
|
ctx.lineTo(750, 720);
|
||||||
|
ctx.lineTo(0, 240);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 6. 绣绷底座大柔影(让中央木绣绷宛如真实搁在桌面上)
|
||||||
|
ctx.save();
|
||||||
|
const hoopShadow = ctx.createRadialGradient(W / 2, 654, 240, W / 2, 668, 368);
|
||||||
|
hoopShadow.addColorStop(0, 'rgba(18, 25, 14, 0.42)');
|
||||||
|
hoopShadow.addColorStop(0.72, 'rgba(18, 25, 14, 0.18)');
|
||||||
|
hoopShadow.addColorStop(1, 'rgba(18, 25, 14, 0)');
|
||||||
|
ctx.fillStyle = hoopShadow;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(W / 2, 658, 368, 0, Math.PI * 2);
|
||||||
|
ctx.fill();
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 7. 桌面四角低调手作装饰(角落暗纹藤叶 + 右下角小木线轴剪影,绝不抢戏)
|
||||||
|
ctx.save();
|
||||||
|
ctx.strokeStyle = 'rgba(240, 224, 182, 0.14)';
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
const drawCornerLeaf = (cx: number, cy: number, sx: number, sy: number) => {
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(cx, cy);
|
||||||
|
ctx.scale(sx, sy);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 48);
|
||||||
|
ctx.quadraticCurveTo(6, 6, 48, 0);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.ellipse(22, 16, 10, 4.5, -0.5, 0, Math.PI * 2);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.ellipse(14, 30, 9, 4, -1.0, 0, Math.PI * 2);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
|
};
|
||||||
|
drawCornerLeaf(32, 232, 1, 1);
|
||||||
|
drawCornerLeaf(W - 32, 232, -1, 1);
|
||||||
|
drawCornerLeaf(32, 1142, 1, -1);
|
||||||
|
drawCornerLeaf(W - 32, 1142, -1, -1);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 8. 底部深暗脚垫渐变(托举底部木质工具盘)
|
||||||
|
const bottomGrad = ctx.createLinearGradient(0, H - 240, 0, H);
|
||||||
|
bottomGrad.addColorStop(0, 'rgba(24, 31, 19, 0)');
|
||||||
|
bottomGrad.addColorStop(1, 'rgba(22, 29, 17, 0.42)');
|
||||||
|
ctx.fillStyle = bottomGrad;
|
||||||
|
ctx.fillRect(0, H - 240, W, 240);
|
||||||
|
|
||||||
|
cachedPlayBg = canvasToSpriteFrame(canvas);
|
||||||
|
return cachedPlayBg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 生成大厅场景全屏「温暖原木手作书案」纹理(暖橡木桌底 + 苔绿亚麻桌旗 + 阳光光晕) */
|
||||||
|
export function createLobbyDeskSpriteFrame(): SpriteFrame {
|
||||||
|
if (cachedLobbyBg) return cachedLobbyBg;
|
||||||
|
const W = 750;
|
||||||
|
const H = 1334;
|
||||||
|
const canvas = makeOffscreenCanvas(W, H);
|
||||||
|
const ctx: CanvasRenderingContext2D = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// 1. 暖杏色手工木案渐变
|
||||||
|
const deskGrad = ctx.createLinearGradient(0, 0, 0, H);
|
||||||
|
deskGrad.addColorStop(0, '#627354');
|
||||||
|
deskGrad.addColorStop(0.24, '#56674a');
|
||||||
|
deskGrad.addColorStop(0.242, '#eadbc0');
|
||||||
|
deskGrad.addColorStop(0.55, '#f2e6cf');
|
||||||
|
deskGrad.addColorStop(1, '#dfd0b1');
|
||||||
|
ctx.fillStyle = deskGrad;
|
||||||
|
ctx.fillRect(0, 0, W, H);
|
||||||
|
|
||||||
|
// 2. 顶部苔绿工坊幕布区域(给游戏标题与今日绣绷展示台营造景深)
|
||||||
|
const topCloth = ctx.createRadialGradient(W * 0.35, 110, 30, W * 0.5, 190, 520);
|
||||||
|
topCloth.addColorStop(0, '#6f825e');
|
||||||
|
topCloth.addColorStop(0.55, '#546548');
|
||||||
|
topCloth.addColorStop(1, '#3f4e36');
|
||||||
|
ctx.fillStyle = topCloth;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 0);
|
||||||
|
ctx.lineTo(W, 0);
|
||||||
|
ctx.lineTo(W, 338);
|
||||||
|
ctx.quadraticCurveTo(W / 2, 372, 0, 338);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
// 3. 顶部幕布金线滚边与波浪收口
|
||||||
|
ctx.save();
|
||||||
|
ctx.strokeStyle = 'rgba(244, 221, 168, 0.55)';
|
||||||
|
ctx.lineWidth = 3;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, 338);
|
||||||
|
ctx.quadraticCurveTo(W / 2, 372, W, 338);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
ctx.strokeStyle = 'rgba(255, 245, 218, 0.25)';
|
||||||
|
ctx.lineWidth = 1.6;
|
||||||
|
ctx.setLineDash([7, 6]);
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(18, 326);
|
||||||
|
ctx.quadraticCurveTo(W / 2, 358, W - 18, 326);
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 4. 下半部分亚麻纸/木纹细肌理
|
||||||
|
ctx.save();
|
||||||
|
ctx.strokeStyle = 'rgba(138, 112, 74, 0.045)';
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
for (let y = 360; y < H; y += 7) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0, y);
|
||||||
|
ctx.lineTo(W, y);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.strokeStyle = 'rgba(255, 250, 238, 0.14)';
|
||||||
|
for (let x = 0; x < W; x += 9) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, 360);
|
||||||
|
ctx.lineTo(x, H);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// 5. 左右原木桌框边条
|
||||||
|
const drawSideWood = (x0: number, w: number) => {
|
||||||
|
const g = ctx.createLinearGradient(x0, 0, x0 + w, 0);
|
||||||
|
g.addColorStop(0, '#7c5534');
|
||||||
|
g.addColorStop(0.5, '#9d7048');
|
||||||
|
g.addColorStop(1, '#684528');
|
||||||
|
ctx.fillStyle = g;
|
||||||
|
ctx.fillRect(x0, 0, w, H);
|
||||||
|
};
|
||||||
|
drawSideWood(0, 8);
|
||||||
|
drawSideWood(W - 8, 8);
|
||||||
|
|
||||||
|
// 6. 顶部柔光粒子光晕(手作温暖感)
|
||||||
|
ctx.save();
|
||||||
|
const glow = ctx.createRadialGradient(140, 80, 10, 140, 80, 260);
|
||||||
|
glow.addColorStop(0, 'rgba(255, 244, 206, 0.18)');
|
||||||
|
glow.addColorStop(1, 'rgba(255, 244, 206, 0)');
|
||||||
|
ctx.fillStyle = glow;
|
||||||
|
ctx.fillRect(0, 0, 420, 340);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
cachedLobbyBg = canvasToSpriteFrame(canvas);
|
||||||
|
return cachedLobbyBg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建全屏纹理背景精灵 */
|
||||||
|
export function createBackdropSprite(name: string, frame: SpriteFrame, parent: Node): Node {
|
||||||
|
const node = createUINode(name, 750, 1334, parent);
|
||||||
|
const sp = node.addComponent(Sprite);
|
||||||
|
sp.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||||
|
sp.spriteFrame = frame;
|
||||||
|
stretchToParent(node);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uiSpriteCache = new Map<string, SpriteFrame>();
|
||||||
|
|
||||||
|
/** 从 assets/resources/<path> 异步加载 Meowa 生成的精绘游戏 UI 精灵(自动兼容 SpriteFrame 与 ImageAsset) */
|
||||||
|
export function loadUiSprite(resourcePath: string, sprite: Sprite): void {
|
||||||
|
const cached = uiSpriteCache.get(resourcePath);
|
||||||
|
if (cached) {
|
||||||
|
if (sprite.isValid) sprite.spriteFrame = cached;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resources.load(`${resourcePath}/spriteFrame`, SpriteFrame, (err, sf) => {
|
||||||
|
if (!err && sf) {
|
||||||
|
uiSpriteCache.set(resourcePath, sf);
|
||||||
|
if (sprite.isValid) sprite.spriteFrame = sf;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resources.load(resourcePath, ImageAsset, (imgErr, img) => {
|
||||||
|
if (imgErr || !img) return;
|
||||||
|
const tex = new Texture2D();
|
||||||
|
tex.image = img;
|
||||||
|
const fallbackSf = new SpriteFrame();
|
||||||
|
fallbackSf.texture = tex;
|
||||||
|
uiSpriteCache.set(resourcePath, fallbackSf);
|
||||||
|
if (sprite.isValid) sprite.spriteFrame = fallbackSf;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建加载 Meowa 美术贴图的精灵节点 */
|
||||||
|
export function createArtSprite(name: string, resourcePath: string, w: number, h: number, parent: Node): { node: Node; sprite: Sprite } {
|
||||||
|
const node = createUINode(name, w, h, parent);
|
||||||
|
const sprite = node.addComponent(Sprite);
|
||||||
|
sprite.sizeMode = Sprite.SizeMode.CUSTOM;
|
||||||
|
loadUiSprite(resourcePath, sprite);
|
||||||
|
return { node, sprite };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtButtonSpec {
|
||||||
|
name: string;
|
||||||
|
resourcePath: string;
|
||||||
|
text?: string;
|
||||||
|
w: number;
|
||||||
|
h: number;
|
||||||
|
textColor?: string;
|
||||||
|
fontSize?: number;
|
||||||
|
textOffsetY?: number;
|
||||||
|
bold?: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtButton {
|
||||||
|
node: Node;
|
||||||
|
button: Button;
|
||||||
|
sprite: Sprite;
|
||||||
|
label?: Label;
|
||||||
|
setEnabled: (enabled: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建基于 Meowa 手绘贴图的实体按压按钮 */
|
||||||
|
export function createArtButton(spec: ArtButtonSpec, parent: Node): ArtButton {
|
||||||
|
const { node, sprite } = createArtSprite(spec.name, spec.resourcePath, spec.w, spec.h, parent);
|
||||||
|
let label: Label | undefined;
|
||||||
|
if (spec.text !== undefined) {
|
||||||
|
label = createLabel(
|
||||||
|
'Label',
|
||||||
|
spec.text,
|
||||||
|
spec.w - 28,
|
||||||
|
spec.h - 8,
|
||||||
|
{
|
||||||
|
size: spec.fontSize ?? 26,
|
||||||
|
color: spec.textColor ?? '#3b240a',
|
||||||
|
bold: spec.bold ?? true,
|
||||||
|
overflow: Label.Overflow.SHRINK,
|
||||||
|
},
|
||||||
|
node,
|
||||||
|
);
|
||||||
|
if (spec.textOffsetY) label.node.setPosition(0, spec.textOffsetY, 0);
|
||||||
|
}
|
||||||
|
const button = node.addComponent(Button);
|
||||||
|
button.transition = Button.Transition.SCALE;
|
||||||
|
button.zoomScale = 0.92;
|
||||||
|
node.on(Button.EventType.CLICK, () => {
|
||||||
|
if (button.interactable) spec.onClick();
|
||||||
|
});
|
||||||
|
const res: ArtButton = {
|
||||||
|
node,
|
||||||
|
button,
|
||||||
|
sprite,
|
||||||
|
label,
|
||||||
|
setEnabled(enabled: boolean) {
|
||||||
|
button.interactable = enabled;
|
||||||
|
sprite.color = enabled ? hex('#ffffff') : hex('#c2b8a8');
|
||||||
|
if (res.label) {
|
||||||
|
const c = res.label.color.clone();
|
||||||
|
c.a = enabled ? 255 : 155;
|
||||||
|
res.label.color = c;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stretchToParent(node: Node): Widget {
|
||||||
|
const widget = node.addComponent(Widget);
|
||||||
|
widget.isAlignTop = true;
|
||||||
|
widget.isAlignBottom = true;
|
||||||
|
widget.isAlignLeft = true;
|
||||||
|
widget.isAlignRight = true;
|
||||||
|
widget.top = 0;
|
||||||
|
widget.bottom = 0;
|
||||||
|
widget.left = 0;
|
||||||
|
widget.right = 0;
|
||||||
|
widget.alignMode = Widget.AlignMode.ON_WINDOW_RESIZE;
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.24",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "88e02ada-30d0-40d3-bed4-28c125a80104",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,624 @@
|
|||||||
|
# 《蚂蚁织画》深度玩法扩展方案(P0 / P1 / P2)
|
||||||
|
|
||||||
|
> **文档类型**:可执行设计与研发方案(Living Document)
|
||||||
|
> **代码基线**:`v1.0.1`(纯单机手作版,Cocos Creator 3.8.8 / TypeScript / 微信小游戏 + H5 竖屏 750×1334)
|
||||||
|
> **关联文档**:`docs/蚂蚁织画-游戏设计与研发文档.md`
|
||||||
|
> **状态**:待评审 · 未实施
|
||||||
|
> **约定**:本方案只描述设计与改动点,不含自动打包构建。所有新增机制默认可通过开关关闭,保证现有 60 关行为零回归。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 0. 结论摘要:深度不够的根因
|
||||||
|
|
||||||
|
实测基线(`node tools/audit-levels.mjs`,60/60 通过):紧度 `61.9%–93.8%` / 均值 `81.9%`,平均机制数 `1.10 → 4.00`,半途换色 4 关、多级因果链 18 关、多蚁巢 29 关、不交叉 40 关。
|
||||||
|
|
||||||
|
| # | 诊断 | 代码证据 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| D1 | **最优解事实上唯一**。三星阈值必须紧贴标准答案 | `audit-levels.mjs` 中 `threeStar < res.cost` 报错、`threeStar - res.cost > max(45, cost*0.05)` 报错 ⇒ `threeStar ∈ [demoCost, demoCost+5%]` |
|
||||||
|
| D2 | 难度靠「压余量 + 加禁令」推进,不是靠决策分叉 | 十大机制中 7 项为通行禁令(pond / rim / cross / gate / ball / rough / budget),仅 locks / bridge / dyes 有顺序耦合 |
|
||||||
|
| D3 | **玩家画的线不改变作品** | `LevelDef.targets` 是预设 `SectionDef`;`route` 只影响 `cost`;`exportArtwork()` 导出预设底图 + 星级;6 幅手绣图仅覆盖各章首关 |
|
||||||
|
| D4 | 无风险、无积累 | 无限撤销 / 重来;星数仅用于 `CHAPTER_UNLOCK_STARS = [0,12,30,54,80,110]` 门控,不反哺玩法 |
|
||||||
|
| D5 | 提示与惩罚倒挂(设计缺陷) | `startDemo()` 设 `assisted=true` 仅阻止演示当局存档;「重绣本关」→ `resetLevel()` 清空 `assisted` 与 `hintCapped` ⇒ 看完整演示后照画可拿 3 星,而只给半程路线的提示 2/3 却封顶 2 星 |
|
||||||
|
|
||||||
|
**总判断**:当前是一个「全信息、单目标、零风险、唯一解」的临摹型谜题。加机制只能提高手稳要求,无法提高思考密度。因此三层的任务分别是:
|
||||||
|
|
||||||
|
- **P0 核心规则层**:把「一个标量最优」变成「多个互相冲突的目标」→ 产生取舍。
|
||||||
|
- **P1 关卡内容层**:把「静态空间拓扑题」变成「随时间演化的时空题」→ 产生推演。
|
||||||
|
- **P2 长线系统层**:把「60 个一次性谜题」变成「玩家可持续产出的作品与内容」→ 产生意义与留存。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 总体设计原则
|
||||||
|
|
||||||
|
1. **治愈感是底线,不是可牺牲项**。所有增加压力的内容(落针无悔、限时、瑕疵)一律走 `PlayMode = 'artisan'` 可选模式,默认 `calm` 保持现状手感;`1:1 跟手`、放大镜、遥控拖线、回撤等已固化手感原则不允许被新机制破坏。
|
||||||
|
2. **纯逻辑引擎继续可离线运行**。`RouteEngine.ts` 不得引入 `cc` 依赖;所有搜索/验算放在 Node 侧工具(`tools/`),运行时零搜索。这是现有 CI 能零构建直跑 TS 的前提,必须保持。
|
||||||
|
3. **向后兼容优先**。旧存档 `ant-embroidery-best-v1` 的 `stars: 0..3` 语义不变 —— 三维星级是「三枚独立判定各贡献 1 星」,总星数仍是 `1..3`,因此 `CHAPTER_UNLOCK_STARS`、大厅集星统计(`LobbyView.ts:822` 附近)、`PlayView.getNextChapterGate()`(`1328`)完全不需要改。
|
||||||
|
4. **每个机制都要能被 CI 验证**。新增机制必须配套一项自动化门禁,否则不进入 `LEVELS`。
|
||||||
|
5. **单机优先**。P0 / P1 全程不联网;P2 的 UGC 与排行榜才引入云端,且需按现有隐私政策补授权说明。
|
||||||
|
|
||||||
|
### 1.1 三层依赖与批次
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
graph LR
|
||||||
|
A[M1 · P0 评分与针法] --> B[M2 · P1 自动求解器]
|
||||||
|
B --> C[M3 · 阈值替换与多解门禁]
|
||||||
|
C --> D[M4 · P1 时序与动态机关]
|
||||||
|
C --> E[M5 · P2 绣品与自创绣谱]
|
||||||
|
D --> F[M6 · P2 绣坊元进程]
|
||||||
|
E --> F
|
||||||
|
```
|
||||||
|
|
||||||
|
**关键解耦决策**:P0 的三维阈值不阻塞求解器。M1 先用 `deriveScoreSpecFromDemo()` 由现有 `demo` 启发式生成 `ScoreSpec`(`source: 'demo'`),M2 求解器落地后由 `solveLevel()` 重算并整体替换(`source: 'solver'`),`ScoreSpec` 接口不变,上层 `evaluateRun()` 无感。这样 P0 可以先行验证手感,不必等搜索算法。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. P0 · 核心规则层:让一关有多种赢法
|
||||||
|
|
||||||
|
### 2.1 三维星级(核心改动)
|
||||||
|
|
||||||
|
#### 2.1.1 设计
|
||||||
|
|
||||||
|
取消「用线越短星越多」的单轴评分,改为三条**独立、互相冲突**的轴,每条达成得 1 星,总星数仍为 `0..3`:
|
||||||
|
|
||||||
|
| 轴 | 徽记 | 达成条件 | 指标来源 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 省线星 | 金线尺 | `metrics.yarn ≤ score.yarn3` | `totalLength(lines)`,沿用现有语义 |
|
||||||
|
| 笔数星 | 蚁巢徽 | `metrics.dispatch ≤ score.dispatch3` | `lines` 按 `dispatchId` 去重计数 |
|
||||||
|
| 针脚星 | 银针徽 | `metrics.stitch ≤ score.stitch3` | 加权折点数 |
|
||||||
|
|
||||||
|
**加权折点数**定义(可从 `RouteState.points` 直接算,无需新采集):
|
||||||
|
|
||||||
|
```
|
||||||
|
stitch = Σ over corners: turnWeight(|Δangle|) × profile.turnFactor
|
||||||
|
turnWeight(a) = 0 if a < 12° // 手指抖动细分点不算折点
|
||||||
|
= 1 if a < 60°
|
||||||
|
= 2 if a < 120°
|
||||||
|
= 3 otherwise // 急转 / 回头
|
||||||
|
```
|
||||||
|
|
||||||
|
`points` 已被 `appendPoint()` 按 `≤14px` 细分,因此必须先做**折线抽稀**(Douglas–Peucker,ε = 10px)再计算转角,否则细分点会淹没信号。抽稀只用于评分,不改动 `route.points` 本身。
|
||||||
|
|
||||||
|
#### 2.1.2 为什么会产生真取舍(必须验证,不能只写在设计里)
|
||||||
|
|
||||||
|
| 玩家选择 | 省线星 | 笔数星 | 针脚星 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 一笔串双球再绕去两个针位 | 最省 | 最优 | 折点最多,常丢 |
|
||||||
|
| 分两笔各走直线 | 较费 | 变多 | 最漂亮 |
|
||||||
|
| 锁/浮桥要求的因果顺序 | 被迫绕路 | 可能被迫多一笔 | 变差 |
|
||||||
|
| 缎面绣(见 2.2) | ×1.42 耗线 | 不变 | 线宽大、更易触发不交叉 |
|
||||||
|
| 锁边绣 | ×1.10 耗线 | 不变 | 折点消耗 ×0.6 |
|
||||||
|
|
||||||
|
三条轴的阈值由求解器分别取 Pareto 前沿上的可达值,确保**不存在同时轻松满足三条轴的支配解**。CI 需新增门禁验证这一点(见 §6 门禁 G10)。
|
||||||
|
|
||||||
|
#### 2.1.3 UI 与反馈
|
||||||
|
|
||||||
|
- `PlayView.updateHud()`(约 `1155–1164` 行):`meterTargetLabel` 的 `★★★` 改为三枚异形徽记,每枚独立点亮/熄灭,实时随拖线变化;量尺上的 `threeStar` 金色刻度保留,仅表示省线轴。
|
||||||
|
- 通关页 `updateHud()`(约 `1299–1314` 行):`resultStarsLabel` 显示三枚徽记 + 总星数;`resultLengthLabel` 追加「省线 / 笔数 / 针脚」三项达成明细。
|
||||||
|
- `saveBtn`(约 `507` 行)与通关存档(`1372` 行)统一改调 `evaluateRun()`,禁止再直接调 `scoreForLength()`。
|
||||||
|
- 设置面板「玩法说明」新增一页三维星级图文卡。
|
||||||
|
|
||||||
|
#### 2.1.4 兼容与迁移
|
||||||
|
|
||||||
|
- `scoreForLength()` **保留**为 deprecated 包装:内部调用 `evaluateRun().stars`,供尚未迁移的调用点与外部工具过渡。
|
||||||
|
- `StorageService.loadRecords()` 的 v1 校验逻辑(`stars ∈ 1..3`、`length > 0`)保持;新字段全部可选。旧记录读出来 `axes` 缺省时,门控与大厅展示按 `stars` 原值工作。
|
||||||
|
- 新存档 key `ant-embroidery-best-v2`;启动时若 v2 为空则一次性从 v1 迁移,迁移后**保留 v1 不删**(可回退)。
|
||||||
|
|
||||||
|
### 2.2 针法系统
|
||||||
|
|
||||||
|
四种针法,玩家在**每笔落笔前**从针线盒选择(不影响 1:1 拖线手感)。针法不只是皮肤,它同时改变耗线、渲染和拓扑判定:
|
||||||
|
|
||||||
|
| 针法 | id | 耗线倍率 | 线宽 | 折点权重 | 特殊规则 |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| 平针 | `running` | 1.00 | 5.2 | 1.00 | 默认,行为与现状完全一致 |
|
||||||
|
| 回针 | `backstitch` | 1.18 | 6.0 | 1.00 | 绣面更饱满,成品覆盖度 +1 |
|
||||||
|
| 缎面 | `satin` | 1.42 | 9.0 | 1.20 | **线宽参与不交叉判定**(见下) |
|
||||||
|
| 锁边 | `blanket` | 1.10 | 5.6 | 0.60 | 曲折路径的最优解,省针脚星 |
|
||||||
|
|
||||||
|
**线宽参与拓扑判定**(让针法真正影响玩法的关键):
|
||||||
|
|
||||||
|
`checkSegmentBlock()` 现有 `segmentsIntersect(from, to, a, b)` 是零宽线段相交。改为:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// RouteEngine.ts
|
||||||
|
export function stitchWidthIntersect(
|
||||||
|
a: Point2D, b: Point2D, c: Point2D, d: Point2D, width: number,
|
||||||
|
): boolean {
|
||||||
|
return segmentsIntersect(a, b, c, d) || segmentDistance(a, b, c, d) < width * 0.5;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
判定使用 `max(当前笔针法线宽, 已提交笔针法线宽)`。`running` 线宽沿用现有 5.2 与容差 `1px`,行为与旧关卡一致。`noCross` 关卡中缎面绣会显著挤压可用通道,形成「想省针脚星但会堵死后续路线」的真实代价。
|
||||||
|
|
||||||
|
**耗线计费**:`segmentCost()` 在 `roughZones` 倍率之后再乘 `profile.costFactor`;`effectiveBudget()` 与 `checkSegmentBlock()` 的预算分支共用同一函数,保证 HUD 显示与判定一致。
|
||||||
|
|
||||||
|
**渲染**:`EmbroideryRenderer.ts` 的 `drawRoute()`(`1327` 行)接收 `style` 参数,替换硬编码的 `7 / 5.4 / 5.2 / 1.25` 线宽组合;`twine()`(`147` 行)按针法改线股数:平针 2 股、回针 3 股、缎面 5 股密排、锁边沿路径加短垂针。`exportArtwork()` 复用同一套绘制,让成品真正因针法而异。
|
||||||
|
|
||||||
|
**解锁节奏**:第 1–10 关仅平针;第 11 关解锁回针、第 21 关缎面、第 31 关锁边,与现有机制首次出现章节对齐,`LevelDef.allowedStitches` 控制。
|
||||||
|
|
||||||
|
### 2.3 匠心模式(可选承诺)
|
||||||
|
|
||||||
|
`PlayMode` 二值,设置面板 / 关卡开始前切换,默认 `calm`:
|
||||||
|
|
||||||
|
| 维度 | `calm`(默认) | `artisan` |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 撤销 / 重来 | 无限,现状 | 每关 2 次「拆线」额度 |
|
||||||
|
| 松手校验 | 现状 | 提交即锁定,笔内不可回拖修改 |
|
||||||
|
| 演示 / 提示 | 现状 | 演示不可用,提示仅 1 级 |
|
||||||
|
| 存档 | 独立记录 | 独立记录,`RecordEntry.mode` 区分 |
|
||||||
|
| 奖励 | 常规 | 灵感点 ×2、限定绣框 / 落款 |
|
||||||
|
|
||||||
|
**不做全局限时**:治愈品类里计时器会直接破坏体验;张力来自「承诺点」而非速度。
|
||||||
|
|
||||||
|
### 2.4 提示 / 演示一致性修复
|
||||||
|
|
||||||
|
| 问题 | 修复 |
|
||||||
|
| --- | --- |
|
||||||
|
| 看完整演示后重绣可拿 3 星 | 新增 `state.demoWatched` 持久化到本关会话,`resetLevel()` **不清空**;`demoWatched = true` 时 `hintCapped = true`(封顶 2 星),仅 `loadLevel()` 换关时清除 |
|
||||||
|
| 信息量与惩罚倒挂 | 演示 = 完整答案 ⇒ 封顶 2 星;提示 3/3 完整单笔 ⇒ 封顶 2 星;提示 1/3 不扣星,规则不变 |
|
||||||
|
| 演示与 `assisted` 语义混用 | `assisted` 只表示「本局由演示代打、不存档」;`demoWatched` 表示「本关看过答案」,两者解耦 |
|
||||||
|
|
||||||
|
改动点:`PlayView.ts` 的 `GameState` 初始化(`101` 行)、`resetLevel()`(`824` 行)、`startDemo()`(`861` 行)、`loadLevel()`(`747` 行)、通关存档分支(`1371` 行)。
|
||||||
|
|
||||||
|
### 2.5 P0 数据模型(`Types.ts` 新增)
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export type StitchStyle = 'running' | 'backstitch' | 'satin' | 'blanket';
|
||||||
|
export type ScoreAxis = 'yarn' | 'dispatch' | 'stitch';
|
||||||
|
export type PlayMode = 'calm' | 'artisan';
|
||||||
|
|
||||||
|
export interface StitchProfile {
|
||||||
|
style: StitchStyle;
|
||||||
|
costFactor: number;
|
||||||
|
width: number;
|
||||||
|
turnFactor: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ScoreSpec {
|
||||||
|
yarn3: number;
|
||||||
|
dispatch3: number;
|
||||||
|
stitch3: number;
|
||||||
|
source: 'demo' | 'solver';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RunMetrics {
|
||||||
|
yarn: number;
|
||||||
|
dispatch: number;
|
||||||
|
stitch: number;
|
||||||
|
flawCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RunScore {
|
||||||
|
axes: Record<ScoreAxis, boolean>;
|
||||||
|
stars: number; // 0..3,语义与 v1 存档一致
|
||||||
|
metrics: RunMetrics;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LevelDef 新增字段
|
||||||
|
// score?: ScoreSpec;
|
||||||
|
// stitch?: StitchStyle; // 默认 'running'
|
||||||
|
// allowedStitches?: StitchStyle[];
|
||||||
|
// mode?: PlayMode; // 默认 'calm'
|
||||||
|
|
||||||
|
// RouteState 新增字段
|
||||||
|
// stitch: StitchStyle;
|
||||||
|
// dispatchId: number; // 协同笔分组用,P0 阶段 = lines.length
|
||||||
|
// lane?: number;
|
||||||
|
// phaseIndex?: number;
|
||||||
|
|
||||||
|
// GameState 新增字段
|
||||||
|
// mode: PlayMode;
|
||||||
|
// demoWatched: boolean;
|
||||||
|
// unpickCharges?: number;
|
||||||
|
// loadout?: Loadout; // P2 预置
|
||||||
|
|
||||||
|
// RecordEntry 新增可选字段
|
||||||
|
// axes?: Record<ScoreAxis, boolean>;
|
||||||
|
// stitch?: StitchStyle;
|
||||||
|
// mode?: PlayMode;
|
||||||
|
// schema?: 2;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.6 P0 引擎接口(`RouteEngine.ts`)
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export function stitchProfile(style: StitchStyle): StitchProfile;
|
||||||
|
export function simplifyPolyline(points: Point2D[], epsilon?: number): Point2D[];
|
||||||
|
export function computeRunMetrics(level: LevelDef, lines: RouteState[]): RunMetrics;
|
||||||
|
export function evaluateRun(level: LevelDef, lines: RouteState[], drawing?: RouteState | null): RunScore;
|
||||||
|
export function deriveScoreSpecFromDemo(level: LevelDef, demoCost: number): ScoreSpec; // M1 临时
|
||||||
|
export function stitchWidthIntersect(a: Point2D, b: Point2D, c: Point2D, d: Point2D, width: number): boolean;
|
||||||
|
/** @deprecated 兼容包装,内部转调 evaluateRun */
|
||||||
|
export function scoreForLength(level: LevelDef, used: number): number;
|
||||||
|
```
|
||||||
|
|
||||||
|
`LevelDef.score` 缺省时由 `LEVELS` 构建阶段(`LevelData.ts` 的 `RAW_LAYOUTS.map`,`1524` 行)调用 `deriveScoreSpecFromDemo()` 补齐,确保老关卡零改动即可运行。
|
||||||
|
|
||||||
|
### 2.7 P0 验收清单
|
||||||
|
|
||||||
|
- [ ] 现有 60 关在 `calm + running` 组合下的 `validateLevelDemo` 结果、耗线、星级与基线**逐关完全一致**(回归门禁 G8)。
|
||||||
|
- [ ] 三枚徽记实时随拖线点亮/熄灭,松手回撤后回退正确。
|
||||||
|
- [ ] 旧 v1 存档导入后星数、章节解锁状态不变。
|
||||||
|
- [ ] `demoWatched` 换关才清除,看演示后重绣最多 2 星。
|
||||||
|
- [ ] 四种针法在 `noCross` 关卡中的带宽判定与 HUD 耗线一致。
|
||||||
|
- [ ] 至少 3 关出现「三轴不可兼得」的实测解(CI 门禁 G10)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. P1 · 关卡内容层:让关卡状态活起来
|
||||||
|
|
||||||
|
### 3.1 自动求解器(P1 地基,优先级最高)
|
||||||
|
|
||||||
|
新增 `tools/solve-level.ts`(Node 24 直跑 TS,复用 `audit-levels.mjs` 的 `registerHooks` 加载方式),产出 `assets/resources/levelmeta/<levelId>.json` 供运行时读取;**运行时绝不执行搜索**。
|
||||||
|
|
||||||
|
#### 3.1.1 问题建模
|
||||||
|
|
||||||
|
连续拖线路径不可穷举,因此离散化为**可视图(visibility graph)**:
|
||||||
|
|
||||||
|
1. **节点集**:所有 `nests` / `balls` / `targets` 中心 / `buttons` / `dyes` / `gates` / `spools`,加上每个 `PondDef` 椭圆的外切绕行点(每椭圆 8 个方位点)、`RIM_LIMIT` 圆上的投影点、粗布区四角外沿点。
|
||||||
|
2. **边集**:两节点直线相连,用与 `checkSegmentBlock()` 相同的逐步细分(≤6px)验证通行性;被 `pond` / `rim` / `gate`(按 angle 与方向点积)/ `solidBalls` 阻断的边丢弃。边权 = `segmentCost()`,含粗布倍率与针法倍率。
|
||||||
|
3. **路径层**:A* 求两点间最短路,得到候选折线骨架;同一对节点保留前 K 条不同骨架(K=3),用于多解计数。
|
||||||
|
|
||||||
|
#### 3.1.2 组合层
|
||||||
|
|
||||||
|
外层 DFS 枚举「一笔的语义」:`(巢, 球序列[1..2 同色], 针位序列[1..2 同色], 染缸事件, 必经纽扣/针门)`,剪枝条件:
|
||||||
|
|
||||||
|
- `maxDispatches` 余量、`effectiveBudget` 余量;
|
||||||
|
- `locks` 前置针位必须已被更早的笔满足(拓扑序剪枝);
|
||||||
|
- `bridgeSectionId` 浮桥状态、`dyeRemainingUses` 次数、`solidBalls` 清路顺序;
|
||||||
|
- `noCross`:已提交骨架参与边阻断(带宽判定见 2.2);
|
||||||
|
- 目标可达性下界:剩余针位按颜色分组的 `ceil(count/2)` ≤ 剩余笔数(复用 `dispatchWarning()` 中的 `minTrips` 逻辑)。
|
||||||
|
|
||||||
|
每个完整方案回灌 `validateLevelDemo()` 的同款步进模拟,确认事件配对与通关条件,再计算三轴 `RunMetrics`。
|
||||||
|
|
||||||
|
#### 3.1.3 输出
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface RunPlan {
|
||||||
|
dispatches: PlannedRoute[]; // 每笔:巢 + 折线点 + 事件序列 + 针法
|
||||||
|
metrics: RunMetrics;
|
||||||
|
signature: string; // 球-针位配对 + 骨架哈希,用于去重
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SolveReport {
|
||||||
|
feasible: boolean;
|
||||||
|
best: RunPlan | null;
|
||||||
|
bestCost: number;
|
||||||
|
solutionCount: number; // Pareto 前沿上互不等价的解数
|
||||||
|
pareto: RunPlan[]; // 三轴非支配解集
|
||||||
|
thresholds: ScoreSpec; // source: 'solver'
|
||||||
|
degraded: boolean;
|
||||||
|
reason?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function solveLevel(level: LevelDef, opts?: SolveOptions): SolveReport;
|
||||||
|
```
|
||||||
|
|
||||||
|
`thresholds` 生成规则:`yarn3 = 省线轴最优 + 5%`,`dispatch3 = 笔数轴最优`,`stitch3 = 针脚轴最优 + 2`。**三轴分别取各自的最优值**,而非同一个解的三项值 —— 这正是逼出取舍的关键。若 `solutionCount < 2`,说明关卡退化,CI 直接报错,要求调整布局。
|
||||||
|
|
||||||
|
#### 3.1.4 复杂度与降级(务实约束)
|
||||||
|
|
||||||
|
| 项 | 上限 |
|
||||||
|
| --- | --- |
|
||||||
|
| 每关搜索节点数 | 200,000 |
|
||||||
|
| 每关耗时(CI) | 2 s |
|
||||||
|
| 骨架候选 K | 3 |
|
||||||
|
| 完整方案枚举 | 5,000 |
|
||||||
|
|
||||||
|
超限或搜索失败时 `degraded = true`,回退「以 `demo` 为 best + 阈值放宽至 demo ±8%」,CI 报告列出 degraded 关卡并**阻止发版**(但允许本地开发继续)。60 关全量求解目标 < 60 s,保持现有 CI「< 1 s 基础审计 + 可选深度审计」的双档:`audit-levels.mjs --quick` 跑原有 7 项,`--full` 追加求解器门禁。
|
||||||
|
|
||||||
|
#### 3.1.5 求解器带来的连锁收益
|
||||||
|
|
||||||
|
- `RAW_LAYOUTS` 中的 `stars` 字段可废弃,阈值不再手工反推(M3 一次性生成并替换);
|
||||||
|
- `findNextHint()` 不再依赖硬编码 `demo` 折线,可改为「给出 Pareto 解中当前最优的下一段」,提示更聪明且天然防剧透;
|
||||||
|
- 每日关 / UGC 绣谱的可解性与阈值校验;
|
||||||
|
- CI 新增多解性、三轴非退化、针法平衡门禁。
|
||||||
|
|
||||||
|
### 3.2 协同笔(双蚁时序)
|
||||||
|
|
||||||
|
**为什么改这个**:现有 `noCross` 只约束「已提交的线」,所有决策都是空间上的;加入时间与顺序后,玩家必须推演「谁先走」而不是只规划「怎么绕」。
|
||||||
|
|
||||||
|
**交互定义**(避免移动端双指同时操作,保持单指拖线手感):
|
||||||
|
|
||||||
|
- 一个 `dispatch` 含 2 条 `lane` 路线,玩家**依次**拖出,但共享一次出发计数;
|
||||||
|
- 两条 lane 之间 `noCross` 双向生效(含针法线宽);
|
||||||
|
- 关卡可声明 `junction`(汇合点)与 `order: [laneA_event, laneB_event]`,例如「lane 1 必须先穿过针门 G,lane 2 才能经过汇合点 J」;
|
||||||
|
- 提交时校验顺序约束,违反则该 dispatch 整体收回并给出「小蚂蚁要排队」提示。
|
||||||
|
|
||||||
|
**数据**:`CoopDispatchDef { id, lanes, junction?, order? }` 加入 `LevelDef`;`RouteState.dispatchId / lane / phaseIndex` 生效;`GameState.lines` 保持扁平,按 `dispatchId` 分组计数(笔数星按组算)。
|
||||||
|
|
||||||
|
**引擎落点**:`checkSegmentBlock()` 的 noCross 分支扩展为「已提交 lines + 同 dispatch 已提交的 lane」;新增 `validateDispatchOrder()`;`dispatchWarning()` 的 `minTrips` 改为按 dispatch 计。
|
||||||
|
|
||||||
|
**渲染**:`prepareRouteForRun()` 按 `phaseIndex` 给 `startedAt` 加偏移;现有 `EmbroideryRenderer` 的蚂蚁编队动画(`drawAnt`、`drawScene`)可直接复用为两只领头蚁错峰出发。
|
||||||
|
|
||||||
|
**关卡范式**:第 4 章起引入「双巢协同」教学关(2 笔各 2 lane),Boss 关做 4 lane + 汇合点排序,与现有「四巢怀表阵」自然衔接。
|
||||||
|
|
||||||
|
### 3.3 动态机关
|
||||||
|
|
||||||
|
| 机制 | 规则 | 新增定义 | 引擎落点 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| **潮位水洼** | 水洼按已提交笔数在「淹没 / 退潮」间切换;UI 显示下一笔的潮位预告 | `TideDef { pondIndex, openOnDispatch: number[] }` | `isPondBridged()` → `isPondPassable(pond, lines)`,同时被 `checkSegmentBlock()` 与 `drawPond()` 调用,保证所见即所判 |
|
||||||
|
| **调色染缸** | 携带 A 色线经过含 B 色染缸,按配方产出 C 色;配方由关卡声明 | `DyeVatDef.recipe?: Record<string, TargetColor>`(键为 `from→vat` 组合) | `planStops()` 的 dye 分支;`override` 与 `recipe` 优先级需明确:先查 `recipe`,未命中再走 `override` / 普通白球规则 |
|
||||||
|
| **拆线回收** | 撤销已提交的一笔,返还 `cost × 0.7` 计入可用预算(不是当前直接 `pop` 的零成本) | `GameState.unpickCharges`(匠心模式 2 次) | `PlayView.undoLastLine()` 改为调 `unpickLine()`;`effectiveBudget()` 增加 `refund` 参数 |
|
||||||
|
| **瑕疵与补针**(feature flag) | 允许异色落针生成混色瑕疵,成品出现斑驳;后续可用补针覆盖但耗线 +N | `FlawDef`、`RouteState.flaws` | `markDelivery()` 接受 `mismatch` 并记录;`availableTargets()` 需区分「已绣但带瑕疵」;此项风险最高,默认关闭,仅匠心模式开放 |
|
||||||
|
|
||||||
|
**设计约束**:动态机关必须**可预告**。潮位、染缸剩余次数在 HUD 有明确下一笔预览,避免变成记忆题或试错题 —— 治愈品类不接受「猜错了重来十遍」。
|
||||||
|
|
||||||
|
### 3.4 每日一绣(程序化关卡)
|
||||||
|
|
||||||
|
**流水线**(全部离线确定性,不联网也能玩):
|
||||||
|
|
||||||
|
```
|
||||||
|
seed = hash(UTC+8 日历日, 版本号)
|
||||||
|
→ 选取 6 个已验证拓扑模板之一 + 参数扰动(球位/水洼/锁链/针门)
|
||||||
|
→ solveLevel() 验证可解 + solutionCount ≥ 2 + 生成三轴阈值
|
||||||
|
→ 不合格则 seed +1 重生成(最多 12 次)
|
||||||
|
→ 仍失败则回退到官方关卡池中按 seed 取一关(保证 100% 有内容)
|
||||||
|
→ 写入 ant-embroidery-daily-v1 { date, seed, best, plays }
|
||||||
|
```
|
||||||
|
|
||||||
|
复用 `EmbroideryRenderer.ts` 已有的 `rng(seed)`(`117` 行)保证跨端一致。**禁止**把未求解的随机布局直接投放;这是 Roadmap V1.1「每日一绣」必须先做求解器的原因。V1.1 接入排行榜时,只上传 `{date, stars, axes, length}`,不上传路径,避免答案泄露。
|
||||||
|
|
||||||
|
### 3.5 P1 验收清单
|
||||||
|
|
||||||
|
- [ ] `solveLevel()` 对 60 关全部 `feasible`,`bestCost ≤ demoCost` 或给出合理解释(证明 demo 不是天花板)。
|
||||||
|
- [ ] `solutionCount ≥ 2` 全关通过;`degraded` 关卡数为 0。
|
||||||
|
- [ ] `--full` 深度审计总耗时 < 60 s,`--quick` 保持 < 1 s。
|
||||||
|
- [ ] 协同笔关卡在真机上单指依次拖线可完成,顺序违约束提示清晰。
|
||||||
|
- [ ] 潮位预告与实际判定逐帧一致(`drawPond` 与 `isPondPassable` 共用同一状态函数)。
|
||||||
|
- [ ] 连续 30 个日期 seed 的每日关 100% 可解且阈值合理。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. P2 · 长线系统层:让玩家留下自己的作品
|
||||||
|
|
||||||
|
### 4.1 绣品定制与展柜
|
||||||
|
|
||||||
|
**问题**:现在 `exportArtwork()` 导出的是「预设底图 + 星级」,玩家的操作对成品零影响,海报缺少炫耀价值。
|
||||||
|
|
||||||
|
| 能力 | 说明 | 落点 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 换线配色 | 按 `TargetColor` 覆盖 8 色线盘,含 3 套预设(宋韵 / 莫兰迪 / 节气限定) | `ArtworkCustomization.palette` 传入 `exportArtwork()`;`ROUTE_COLORS` 改为可注入 |
|
||||||
|
| 针法留痕 | 成品线迹按本局实际针法组合绘制,缎面/锁边在海报上肉眼可辨 | `drawRoute()` 在海报通道复用对局绘制 |
|
||||||
|
| 题字落款 | 12 字内短句 + 日期 + 绣者名,写入海报亚麻奖牌框 | `exportArtwork(opts)` 扩展 |
|
||||||
|
| 绣框与衬底 | 星数 / 套装解锁 6 款木框、3 款布纹 | `frameId` |
|
||||||
|
| 展柜 | 本地保存每次成品的元数据与缩略图,支持回看、按章节/星级筛选、再导出 | `ant-embroidery-gallery-v1`,上限 120 条滚动淘汰 |
|
||||||
|
|
||||||
|
`GalleryEntry`:`{ levelKey, stars, axes, length, stitch, palette, inscription, frameId, createdAt, thumbPath }`。注意微信小游戏本地存储容量限制,缩略图只存 `256×256` 压缩图或按需重绘,不存 `1280×1720` 全图。
|
||||||
|
|
||||||
|
### 4.2 自创绣谱(UGC)
|
||||||
|
|
||||||
|
**`StitchChart`(绣谱)** = `LevelDef` 的可序列化子集:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface StitchChart {
|
||||||
|
v: 1;
|
||||||
|
author?: string;
|
||||||
|
title: string;
|
||||||
|
seed: number;
|
||||||
|
layout: {
|
||||||
|
nests: Point2D[];
|
||||||
|
targets: SectionDef[];
|
||||||
|
balls: BallDef[];
|
||||||
|
ponds: PondDef[];
|
||||||
|
spools: SpoolDef[];
|
||||||
|
buttons: ButtonAnchorDef[];
|
||||||
|
dyes: DyeVatDef[];
|
||||||
|
gates: GateDef[];
|
||||||
|
roughZones: RoughZoneDef[];
|
||||||
|
locks?: Record<string, string>;
|
||||||
|
budget?: number;
|
||||||
|
maxDispatches?: number;
|
||||||
|
noCross?: boolean;
|
||||||
|
solidBalls?: boolean;
|
||||||
|
};
|
||||||
|
score?: ScoreSpec; // 由求解器生成,禁止作者手填
|
||||||
|
checksum: string; // 防篡改 / 防手改阈值
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**编辑器流程**:摆球 → 摆针位(从 motif 模板或自由点位)→ 拖机关 → 「验谱」按钮调 `solveLevel()`:不可解则高亮冲突元素,`solutionCount < 2` 提示「这关只有一种解法,再加点分叉」→ 通过后自动生成 `ScoreSpec` 与 checksum → 试玩 → 保存。
|
||||||
|
|
||||||
|
**分享码**:紧凑二进制 + base64url,目标 ≤ 1.5 KB(微信分享参数长度限制);超长时改为云端 `chartId`(需 V1.1 云服务)。
|
||||||
|
|
||||||
|
**合规边界(重要)**:
|
||||||
|
- V1.0 单机阶段:**仅本地自创 + 导出图片分享**,不上传、不拉取他人绣谱;作者名与题字属用户生成内容,需走 `wx.security.msgSecCheck` 或服务端内容安全检查后才能展示给他人。
|
||||||
|
- 现有隐私政策明确 V1 不采集个人信息;开启 UGC 云端分享时必须同步更新隐私政策与授权弹窗(文档 §5.1 已有此预留)。
|
||||||
|
- 禁止绣谱携带任意脚本/外链,`decodeChart()` 只接受白名单字段,做严格 schema 校验 + 坐标范围钳制到 `HOOP_WIDTH/HEIGHT`。
|
||||||
|
|
||||||
|
### 4.3 绣坊元进程
|
||||||
|
|
||||||
|
**灵感点(`Inspiration`)**:来源 = 首次通关 `+1`、每枚星 `+1`、套装集齐 `+10`、每日一绣 `+2`;匠心模式翻倍。消费于线材 / 工具 / 绣框 / 故事碎片。
|
||||||
|
|
||||||
|
**工具与 Build**:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export interface RulePatch {
|
||||||
|
budgetBonus?: number;
|
||||||
|
extraDispatch?: number;
|
||||||
|
costFactor?: number; // 乘在针法倍率上
|
||||||
|
dyeUsesBonus?: number;
|
||||||
|
stitchTurnFactor?: number;
|
||||||
|
}
|
||||||
|
export interface ToolDef {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
patch: RulePatch;
|
||||||
|
unlockAt: number; // 所需累计灵感点
|
||||||
|
}
|
||||||
|
export interface Loadout { tools: string[]; } // 上限 2 件
|
||||||
|
```
|
||||||
|
|
||||||
|
示例工具:`蚕丝线轴`(`budgetBonus: +60`)、`双巢令`(`extraDispatch: +1`)、`绣花顶针`(`stitchTurnFactor: 0.8`)、`备用染碟`(`dyeUsesBonus: +1`)、`细针`(`costFactor: 0.94`)。玩家带 1–2 件进关,形成 build 选择,且**允许在官方关卡中使用** —— 这让老关卡产生新的解法空间。
|
||||||
|
|
||||||
|
**引擎落点**:`effectiveBudget(level, lines, drawing, loadout?)`、`dispatchWarning()`、`dyeRemainingUses()`、`segmentCost()` 全部接受可选 `Loadout`;`solveLevel()` 校验「带任意合法 Loadout 仍可通关」且阈值不被破坏(CI 门禁 G15)。
|
||||||
|
|
||||||
|
**叙事与收集**:六章各 3 段「绣谱故事」碎片(`StoryFragment`),按通关 / 满星 / 套装解锁,串成「为谁绣这幅画」的主线;节气限定主题(江南梅雪 / 端午香囊 / 中秋玉兔)做成 `SetDef`,集齐后合成一幅整墙挂画。这一层不增加操作难度,但给重复游玩提供意义。
|
||||||
|
|
||||||
|
### 4.4 P2 存储 Key 总表
|
||||||
|
|
||||||
|
| Key | 内容 | 迁移 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `ant-embroidery-best-v2` | 三维星级记录(含 `axes` / `stitch` / `mode`) | 从 v1 一次性导入,v1 保留 |
|
||||||
|
| `ant-embroidery-mode-v1` | `calm` / `artisan` 偏好 | 新增,默认 `calm` |
|
||||||
|
| `ant-embroidery-gallery-v1` | 展柜元数据 | 上限 120 条 |
|
||||||
|
| `ant-embroidery-daily-v1` | 每日一绣日期 / seed / 成绩 | 新增 |
|
||||||
|
| `ant-embroidery-charts-v1` | 本地自创绣谱 | 上限 30 份 |
|
||||||
|
| `ant-embroidery-atelier-v1` | 灵感点 / 已解锁工具 / 故事碎片 / 套装 | 新增 |
|
||||||
|
| `ant-embroidery-custom-v1` | 配色 / 落款 / 绣框偏好 | 新增 |
|
||||||
|
|
||||||
|
### 4.5 P2 验收清单
|
||||||
|
|
||||||
|
- [ ] 同一关用不同针法 + 配色导出的两张海报,像素差异可被肉眼分辨。
|
||||||
|
- [ ] 展柜在微信小游戏存储上限内不触发写入失败,超限时按时间淘汰且给提示。
|
||||||
|
- [ ] 任意构造的恶意绣谱(超范围坐标、非法枚举、手改 `score`)都被 `decodeChart()` 拒绝。
|
||||||
|
- [ ] 带任意合法 Loadout 时,60 关仍 `feasible`,且 `evaluateRun()` 星级判定一致。
|
||||||
|
- [ ] 关闭云端时,UGC 全流程仍可本地闭环(编辑 → 验谱 → 试玩 → 出图)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 全量改动地图
|
||||||
|
|
||||||
|
| 文件 | P0 | P1 | P2 | 风险 |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| `assets/scripts/core/Types.ts` | 三维评分 / 针法 / 模式类型 | 协同笔、潮位、调色、Solve 报告 | Loadout / 绣品 / 绣谱 / 展柜 | 低,纯类型 |
|
||||||
|
| `assets/scripts/core/LevelData.ts` | `RAW_LAYOUTS.map` 补 `deriveScoreSpecFromDemo` | 读取 `levelmeta/*.json`、`stars` 字段废弃 | 程序化模板、节气套装数据 | 中,60 关数据回归 |
|
||||||
|
| `assets/scripts/core/RouteEngine.ts` | `evaluateRun` / `segmentCost` 针法倍率 / 带宽相交 / 折线抽稀 | 顺序校验、潮位通行、调色染缸、拆线返还、Loadout 参数 | — | **高**,核心判定,必须逐关回归 |
|
||||||
|
| `assets/scripts/ui/PlayView.ts` | 三徽记 HUD、针法选择、`demoWatched`、匠心模式 | 协同笔提交、潮位预告、拆线额度 | 定制入口、Loadout 选择 | 中,UI 状态多 |
|
||||||
|
| `assets/scripts/ui/LobbyView.ts` | 设置页新增模式 / 玩法说明 | 每日一绣入口 | 展柜 / 绣坊 / 故事入口 | 低 |
|
||||||
|
| `assets/scripts/ui/UiBuilder.ts` | 徽记、针法按钮组件 | 潮位预告条 | 新弹窗组件 | 低 |
|
||||||
|
| `assets/scripts/render/EmbroideryRenderer.ts` | `drawRoute` / `twine` 按针法 | 双蚁错峰、潮位水洼、瑕疵 | 配色注入、题字、绣框、海报变体 | 中,离屏 Canvas 性能 |
|
||||||
|
| `assets/scripts/core/StorageService.ts` | v2 存档与 v1 迁移 | 每日成绩 | 展柜 / 绣谱 / 绣坊 | 中,数据安全 |
|
||||||
|
| `assets/scripts/MainController.ts` | 模式透传 | — | 新视图路由 | 低 |
|
||||||
|
| `tools/audit-levels.mjs` | 三轴 / 针法平衡门禁 | `--full` 深度审计 | 恶意绣谱抽样校验 | 低 |
|
||||||
|
| `tools/solve-level.ts`(新) | — | 求解器 + 阈值生成 | UGC 验谱复用 | 中,算法复杂度 |
|
||||||
|
| `assets/resources/levelmeta/*.json`(新) | — | 60 份求解报告 | — | 低,构建产物 |
|
||||||
|
|
||||||
|
**关键回归策略**:`RouteEngine.ts` 的每次改动都先跑 `--quick` 的 7 项基线门禁,要求 60 关 `cost` 与 `demo` 通过情况与 `v1.0.1` **逐关字节级一致**(`calm + running` 组合),再开新机制。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 迭代批次与 CI 门禁
|
||||||
|
|
||||||
|
| 批次 | 内容 | 前置 | 主要交付 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| **M1** | P0:三维星级、针法、`demoWatched` 修复、匠心模式 | — | 可玩的 P0,阈值 `source: 'demo'` |
|
||||||
|
| **M2** | P1:`solve-level.ts` 求解器 + `levelmeta` 生成 + `--full` 审计 | M1 的 `ScoreSpec` 接口 | 离线求解器与报告 |
|
||||||
|
| **M3** | 阈值整体替换 `source: 'solver'`;提示改用 Pareto 解;60 关多解性整改 | M2 | 唯一解问题被彻底解决 |
|
||||||
|
| **M4** | P1:协同笔、潮位、调色染缸、拆线回收、每日一绣 | M3 | 时空题型与新关卡 |
|
||||||
|
| **M5** | P2:绣品定制、展柜、自创绣谱(本地闭环) | M2(验谱复用)、M1(针法) | 表达性与 UGC |
|
||||||
|
| **M6** | P2:绣坊元进程、叙事、节气套装、轻社交 | M4、M5 | 长线留存 |
|
||||||
|
|
||||||
|
> 批次按依赖排序,不绑定具体工期;每批独立可发版,未完成的下批不阻塞上批上线。
|
||||||
|
|
||||||
|
### 6.1 全局 CI 门禁清单(现有 7 项 + 新增 10 项)
|
||||||
|
|
||||||
|
| ID | 门禁 | 生效批次 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| G1–G7 | 现有 7 项(引擎通关、布局唯一、锯齿紧度、三星阈值、防倒挂、限笔容错、高阶机制覆盖) | 基线 |
|
||||||
|
| G8 | **基线回归**:`calm + running` 下 60 关 `cost` / 通关结果与 v1.0.1 一致 | M1 |
|
||||||
|
| G9 | **阈值来源**:`ScoreSpec.source === 'solver'`(M3 起),且 `bestCost ≤ yarn3 ≤ bestCost × 1.08` | M3 |
|
||||||
|
| G10 | **三轴非退化**:Pareto 前沿 ≥ 2 个解,且不存在同时满足三轴最优的支配解 | M1 / M3 强化 |
|
||||||
|
| G11 | **多解性**:`solutionCount ≥ 2`(60 关全过) | M3 |
|
||||||
|
| G12 | **针法平衡**:任一针法在 60 关中的三星可达率 ∈ `[20%, 80%]`,且无严格支配针法 | M1 粗验 / M3 精确 |
|
||||||
|
| G13 | **协同笔时序**:声明协同的关卡必须存在合法 `order` 解且可被 `validateDispatchOrder()` 复现 | M4 |
|
||||||
|
| G14 | **每日关**:连续 30 个日期 seed 100% 可解,回退路径可触发且不崩溃 | M4 |
|
||||||
|
| G15 | **Loadout 安全性**:任意合法工具组合下 60 关仍 `feasible` | M6 |
|
||||||
|
| G16 | **存档迁移**:v1 样本导入 v2 后星数与章节解锁状态不变 | M1 |
|
||||||
|
| G17 | **绣谱安全**:恶意样本(越界坐标 / 非法枚举 / 篡改 checksum)100% 被拒 | M5 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. 风险、兼容与回退
|
||||||
|
|
||||||
|
| 风险 | 影响 | 应对 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 三维星级让老玩家星数变化、章节重新上锁 | 高 | 总星数语义保持 `0..3`;门控逻辑零改动;v1 存档一次性迁移且保留原 key |
|
||||||
|
| 针法线宽判定改变旧关卡解 | 高 | `running` 参数与旧判定等价;G8 逐关回归;新针法仅在 `allowedStitches` 声明的关卡可用 |
|
||||||
|
| 求解器复杂度失控 / CI 变慢 | 中 | 离线运行、节点与时间双上限、degraded 降级、双档审计(quick / full) |
|
||||||
|
| 动态机关变成记忆试错 | 中 | 所有状态变化必须 HUD 预告;渲染与判定共用同一状态函数 |
|
||||||
|
| 匠心模式伤害治愈核心用户 | 中 | 默认关闭、独立存档、奖励只给外观与灵感点,不给关卡进度优势 |
|
||||||
|
| UGC 内容合规 | 高 | V1.0 只做本地闭环;云端分享前补内容安全审核与隐私政策更新 |
|
||||||
|
| 小游戏包体与存储膨胀 | 中 | `levelmeta` 用紧凑 JSON;海报不入库只存元数据 + 缩略图;展柜 / 绣谱设上限 |
|
||||||
|
| 范围蔓延 | 中 | 见 §8 明确不做清单;每批独立可发版 |
|
||||||
|
|
||||||
|
**统一回退开关**:`assets/resources/config/features.json` 提供 `threeAxes / stitches / artisan / coop / dynamic / ugc / atelier` 七个布尔位,默认全部 `false`(= v1.0.1 行为)。任何一批出问题,改配置即可回退,无需回滚代码。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. 明确不做(防止范围蔓延)
|
||||||
|
|
||||||
|
- 不做实时 PvP、异步攻防、体力/付费数值;
|
||||||
|
- 不做全局倒计时或失败惩罚(匠心模式的张力来自承诺点,不来自速度);
|
||||||
|
- 不做 3D、物理模拟、开放世界;
|
||||||
|
- 不把求解器放进运行时(包体与帧率风险);
|
||||||
|
- 不在 V1.x 引入强账号体系,云端仅用于 UGC 分享与排行榜;
|
||||||
|
- 不改动已固化的手感原则:1:1 跟手、放大镜避让、空白桌面遥控、≤14px 细分、原路回撤。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 附录 A:关键接口签名汇总
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// RouteEngine.ts(P0 / P1)
|
||||||
|
export function stitchProfile(style: StitchStyle): StitchProfile;
|
||||||
|
export function simplifyPolyline(points: Point2D[], epsilon?: number): Point2D[];
|
||||||
|
export function computeRunMetrics(level: LevelDef, lines: RouteState[]): RunMetrics;
|
||||||
|
export function evaluateRun(level: LevelDef, lines: RouteState[], drawing?: RouteState | null): RunScore;
|
||||||
|
export function deriveScoreSpecFromDemo(level: LevelDef, demoCost: number): ScoreSpec;
|
||||||
|
export function segmentDistance(a: Point2D, b: Point2D, c: Point2D, d: Point2D): number;
|
||||||
|
export function stitchWidthIntersect(a: Point2D, b: Point2D, c: Point2D, d: Point2D, width: number): boolean;
|
||||||
|
export function isPondPassable(pond: PondDef, lines: RouteState[]): boolean;
|
||||||
|
export function validateDispatchOrder(level: LevelDef, lines: RouteState[]): boolean;
|
||||||
|
export function effectiveBudget(level: LevelDef, lines: RouteState[], drawing?: RouteState | null, loadout?: Loadout, refund?: number): number | undefined;
|
||||||
|
export function segmentCost(level: LevelDef, from: Point2D, to: Point2D, segLen: number, stitch?: StitchStyle, loadout?: Loadout): number;
|
||||||
|
|
||||||
|
// tools/solve-level.ts(P1)
|
||||||
|
export function solveLevel(level: LevelDef, opts?: SolveOptions): SolveReport;
|
||||||
|
export function generateDailyLevel(seed: number): { level: LevelDef; report: SolveReport };
|
||||||
|
export function validateChart(chart: StitchChart): { ok: boolean; report?: SolveReport; error?: string };
|
||||||
|
|
||||||
|
// StorageService.ts(P0 / P2)
|
||||||
|
public saveRun(level: LevelDef, score: RunScore, ctx: RunContext): boolean;
|
||||||
|
public migrateFromV1(): number;
|
||||||
|
public saveGallery(entry: GalleryEntry): boolean;
|
||||||
|
public saveChart(chart: StitchChart): boolean;
|
||||||
|
```
|
||||||
|
|
||||||
|
## 附录 B:求解器主循环伪代码
|
||||||
|
|
||||||
|
```
|
||||||
|
function solveLevel(level, opts):
|
||||||
|
G = buildVisibilityGraph(level) // 节点 + 可通行边,复用 checkSegmentBlock
|
||||||
|
frontier = [ emptyState ] // 已用笔数 / 已拾球 / 已绣针位 / 桥状态 / 染缸次数
|
||||||
|
plans = []
|
||||||
|
while frontier not empty and budget not exceeded:
|
||||||
|
state = frontier.pop()
|
||||||
|
if allTargetsDone(state) and buttonsGatesOk(state):
|
||||||
|
plans.push(buildPlan(state)); continue
|
||||||
|
for candidate in enumerateDispatchSemantics(level, state): // 巢 × 球 × 针位 × 染色 × 必经点
|
||||||
|
if not prunable(candidate, state): continue // 锁序 / 限笔 / 预算下界 / noCross
|
||||||
|
routes = []
|
||||||
|
for leg in candidate.legs:
|
||||||
|
path = astar(G, leg.from, leg.to, state.blockedEdges) // 保留前 K 条骨架
|
||||||
|
if path == null: break
|
||||||
|
routes.push(path)
|
||||||
|
simulated = replayWithEngine(level, state, routes) // 复用 validateLevelDemo 步进模拟
|
||||||
|
if simulated.valid: frontier.push(simulated.nextState)
|
||||||
|
pareto = nonDominated(plans, axes = [yarn, dispatch, stitch])
|
||||||
|
thresholds = { yarn3: minYarn*1.05, dispatch3: minDispatch, stitch3: minStitch+2, source:'solver' }
|
||||||
|
return { feasible: plans.length>0, best: argminYarn(plans), solutionCount: distinctSignatures(pareto),
|
||||||
|
pareto, thresholds, degraded: budgetExceeded }
|
||||||
|
```
|
||||||
|
|
||||||
|
## 附录 C:术语
|
||||||
|
|
||||||
|
| 术语 | 含义 |
|
||||||
|
| --- | --- |
|
||||||
|
| 轴 / Axis | 三维星级的一条独立判定(省线 / 笔数 / 针脚) |
|
||||||
|
| 针法 / StitchStyle | 每笔落笔前选择的线迹类型,影响耗线、线宽、折点计量与成品 |
|
||||||
|
| 协同笔 / CoopDispatch | 一个出发计数内包含 2 条 lane、带先后序约束的路线组 |
|
||||||
|
| 绣谱 / StitchChart | 玩家自创关卡的可序列化数据结构 |
|
||||||
|
| 绣坊 / Atelier | 灵感点、工具 Build、故事与套装构成的元进程 |
|
||||||
|
| 灵感点 / Inspiration | 跨关累积的软货币,仅兑换外观与规则工具 |
|
||||||
|
| 静心 / 匠心 | `calm` / `artisan` 两种游玩模式,后者引入承诺点 |
|
||||||
|
| Pareto 前沿 | 三轴互不支配的解集,用于多解计数与阈值生成 |
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
# 《蚂蚁织画》游戏设计与研发文档(持续更新版)
|
||||||
|
|
||||||
|
> **文档状态**:Living Document(随每次功能、美术、关卡与发版迭代同步维护)
|
||||||
|
> **当前版本**:`v1.1.3`(微信小游戏备案提审收口版)
|
||||||
|
> **最后更新**:`2026-11-24`
|
||||||
|
> **引擎与平台**:Cocos Creator `3.8.8`(TypeScript)|目标平台:微信小游戏 / H5 竖屏(`750×1334`)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 一、产品定位与核心体验
|
||||||
|
|
||||||
|
| 维度 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| **游戏名称** | 蚂蚁织画(English: *Ant Stitch*) |
|
||||||
|
| **核心品类** | 手工刺绣题材 · 治愈系空间拓扑连线解谜 |
|
||||||
|
| **目标用户** | 女性向休闲玩家为核心(审美敏感、喜爱手作/治愈画风、乐于保存与分享精美成品绣画) |
|
||||||
|
| **核心记忆点** | **会排着队织画的小蚂蚁**(搬球拉长身体、身后实时“长出”彩色绣线、演示模式纵队行进)+ **六大主题手绣成品藏品海报** |
|
||||||
|
| **视觉基调** | 日系手作绣坊 × 宋韵织绣桌案:青瓷亚麻布垫、樱桃木/胡桃木雕花、古铜金铆钉、亮米白瓷釉按压钮、山茶红火漆焦点印章 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 二、核心玩法与规则设计
|
||||||
|
|
||||||
|
### 2.1 一句话玩法
|
||||||
|
从发光的「**蚁巢**」起手拖线,串起同色毛线球(单蚁最多 2 颗),送进对应颜色的呼吸目标针位;蚂蚁沿线爬行并在身后织出饱满绣线,填满全部针位即绣成整幅作品——**用线越短,星级越高**。
|
||||||
|
|
||||||
|
### 2.2 操控与手感规范(已固化原则)
|
||||||
|
1. **1:1 严格跟手,不缩尾、不偏漂**:
|
||||||
|
- 直拖蚁巢(`96px` 吸附半径)采用 **1:1 真实手指坐标**,取消早期向上偏移,避免线条与起手引导线割裂或顶部蚁巢向下拖撞框。
|
||||||
|
- 松手落笔不做尾部裁切(`prepareRouteForRun()` 保留完整真实轨迹),确保「手拖多长、成线多长」。
|
||||||
|
2. **双防遮挡方案**:
|
||||||
|
- **自动避让圆形放大镜(`镜`,默认开启)**:针尖偏左时浮现右上、偏右时浮现左上,`1.7×` 清晰放大针尖落点。
|
||||||
|
- **空白桌面隐形遥控**:落指在蚁巢 `96px` 外自动切换相对滑动模式(`GAIN = 1.42`),手指完全不挡绣绷画面。
|
||||||
|
3. **精细防穿模与便捷回撤**:
|
||||||
|
- 拖线步长自动细分至 `≤ 14px`,防止快速划屏跳过水洼、粗布区或单向针门。
|
||||||
|
- 沿原路回拖自动触发回撤(`tryBacktrack`),零误操作成本。
|
||||||
|
4. **首进教学与动态起手引导**:
|
||||||
|
- 第 1 关首次进入弹出林阿婆委托浮卡与起手指引(点击「知道了」或直接触屏拖线均立即收起并持久化记录);绣完第 1 关立刻解锁林阿婆回信并可在通关页一键直达展柜/回信。
|
||||||
|
- 前 3 关(第 1–3 关新手教学)落第一笔前自动播放金色虚线起手引导;第 4 关起仅保留蚁巢脉冲光环与「按这里拖线」标牌,不自动剧透起手蚁巢和第一颗球,保留独立思考空间。
|
||||||
|
|
||||||
|
### 2.3 数值语义与星级体系
|
||||||
|
- **全端统一「用线」语义**:彻底废弃「剩线 / 用线」混用;对局右上量尺统一显示 **`用线 X.X / 上限`** + **实时动态星级 `★★★ / ★★☆ / ★☆☆`**。
|
||||||
|
- **进度条星级分界刻度**:量尺槽上直接标出 **3★ 金色刻度线** 与 **2★ 暖橘刻度线**,玩家无需心算减法。
|
||||||
|
- **3 级渐进提示与演示星级封顶(消除倒挂)**:
|
||||||
|
- `提示 1/3`:仅标出起手毛线球与目标方向(**不扣星**)。
|
||||||
|
- `提示 2/3`:显示前半程推荐轨迹(本局最高封顶 **2★**)。
|
||||||
|
- `提示 3/3`:显示该笔完整推荐轨迹(本局最高封顶 **2★**)。
|
||||||
|
- `演示模式`:`demoWatched` 持续生效至换关,观看演示后点「重来 / 重绣本关」仍封顶 **2★**,杜绝看答案白拿三星。
|
||||||
|
|
||||||
|
### 2.4 十大解谜机制体系
|
||||||
|
| # | 机制 | 规则说明 | 首见章节 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 1 | **串双球** | 单只蚂蚁可串联 2 颗同色毛线球,一笔送达两处针位大幅省线 | 第一章 `#2` |
|
||||||
|
| 2 | **不交叉(`noCross`)** | 已铺设毛线与当前线不可相交,形成平面拓扑约束 | 第一章 `#3` |
|
||||||
|
| 3 | **水洼绕行(`ponds`)** | 不可穿过水洼,需绕道或寻找捷径 | 第一章 `#4` |
|
||||||
|
| 4 | **机关顺序锁(`locks`)** | 带铜锁针位需先绣完虚线相连的前置针位方可解锁 | 第一章 `#5` |
|
||||||
|
| 5 | **绣片浮桥(`bridgeSectionId`)** | 绣完指定前置针位后,对应水洼架起通行绣桥 | 第一章 `#6` |
|
||||||
|
| 6 | **粗麻布区(`roughZones`)** | 经过区域耗线倍率 `×2.0`,精确按线段重叠长度计费 | 第一章 `#7` |
|
||||||
|
| 7 | **实体堵球(`solidBalls`)** | 未拾取的异色毛线球形成物理阻挡,须先清路或绕行 | 第一章 `#8` |
|
||||||
|
| 8 | **纽扣锚点(`buttons`)** | 通关前须将场上所有纽扣穿线激活 | 第一章 `#9` |
|
||||||
|
| 9 | **线轴续线 / 单向针门 / 多蚁巢** | 拾线轴扩充上限;针门仅允许顺箭头穿过;支持 2/3/4 巢 | 第二章 `#13–#18` |
|
||||||
|
| 10 | **染缸与「一蚁半途换色」(`dyes`)** | 白球入染缸变色;限次孤缸须双球同染;**覆染缸支持单蚁落 A 色一针后半途改染 B 色落第二针** | 第三章 `#22–#24`,第六章深化 |
|
||||||
|
|
||||||
|
### 2.5 主角「小蚂蚁」视效表现规范
|
||||||
|
- 尺寸 `1.34×` 亮泽栗棕甲壳 + 灵动双眸高光 + 挥舞金尖触角 + 三足交替步态。
|
||||||
|
- 待机时朝向首颗毛线球俏皮轻晃;搬球行进时**身体动态拉长与摆动**。
|
||||||
|
- **身后实时“长线”**:行进前方保留轻柔虚线待织蓝图,蚂蚁身后随位移(`route.traveled`)逐段生长出饱满立体彩色绣线。
|
||||||
|
- **蚂蚁织画小队**:演示模式与串双球出击时,自动派出 2–3 只迷你工蚁背着彩线团紧随领头蚁列队行进。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 三、六大主题章节与 60 关完整目录
|
||||||
|
|
||||||
|
### 3.1 章节进度与难度曲线总览(来自 `node tools/audit-levels.mjs` 实测)
|
||||||
|
|
||||||
|
| 章节 | 关号 | 解锁建议星数 | 手绣样板(首关) | 平均耗线 | 平均机制数 | 平均紧度 | 紧度锯齿序列(%) |
|
||||||
|
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||||
|
| **第一章 · 繁花集** | `1–10` | `0 ★` | 金色向日葵 | `959` | `1.10` | `73.8%` | `-, 61.9, 67.7, 73.7, 70, 73.9, 65.8, 77.7, 83.6, 89.6` |
|
||||||
|
| **第二章 · 灵禽志** | `11–20` | `12 ★` | 枝头蓝翠鸟 | `1048` | `2.10` | `79.2%` | `67.7, 72, 73.8, 75.8, 79.7, 83.7, 71.9, 85.9, 88.9, 92.3` |
|
||||||
|
| **第三章 · 萌宠记** | `21–30` | `26 ★` | 团子橘猫 | `1094` | `2.90` | `81.7%` | `69.3, 73.7, 77.9, 82, 83.7, 85.4, 75.6, 87.5, 90, 91.4` |
|
||||||
|
| **第四章 · 诗意山水** | `31–40` | `44 ★` | 江南小桥 | `1782` | `3.10` | `84.5%` | `73.6, 77.9, 83.8, 85.8, 84, 87.8, 77.6, 89.8, 92, 93.1` |
|
||||||
|
| **第五章 · 雅致筑影** | `41–50` | `64 ★` | 红顶童话屋 | `1826` | `3.40` | `85.2%` | `75.7, 80, 83.9, 85.9, 85.7, 87.8, 77.8, 90.1, 92.1, 93.2` |
|
||||||
|
| **第六章 · 拾光甜物** | `51–60` | `86 ★` | 草莓奶油蛋糕 | `1656` | `4.00` | `86.5%` | `78.1, 81.8, 86.1, 86.2, 88.1, 90.1, 76.7, 90.8, 93.2, 93.8` |
|
||||||
|
|
||||||
|
> - 章节解锁采用**严格集星门控(无跳关)**:未解锁章节丝签以精致金属小锁图标标识,点击弹出当前星数与差额提示,需在已解锁章节集齐星数后开启;对局通关页「下一关」同样受此星数门槛校验。
|
||||||
|
> - 全 60 关每章第 7 关设为「**喘息关**」,章首自动回落难度避免倒挂(`0 处倒挂`)。
|
||||||
|
|
||||||
|
### 3.2 60 关完整清单
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>展开查看全部 60 关名称、难度与核心标签</summary>
|
||||||
|
|
||||||
|
- **第一章 · 繁花集(1–10)**:1.金色向日葵[入门/手绣样板] · 2.双瓣向阳[基础/串双球] · 3.金蕊交错[基础/不交叉初见] · 4.溪畔金葵[普通/绕水省线] · 5.葵叶花锁[普通/机关锁单练] · 6.晨露叶桥[进阶/浮桥单练] · 7.暖阳麻布[休闲/粗布×2.0] · 8.牡丹清径[进阶/实体堵球] · 9.绣球双扣[挑战/纽扣+不交] · 10.铃兰繁花[Boss/章末Boss]
|
||||||
|
- **第二章 · 灵禽志(11–20)**:11.枝头蓝翠鸟[基础/手绣样板] · 12.春燕浮桥[普通/浮桥复现] · 13.火烈鸟轴[普通/线轴单练] · 14.白鸽穿门[进阶/针门单练] · 15.锦羽连锁[进阶/连环锁+不交] · 16.知更浅滩[挑战/粗布+双轴] · 17.双巢金雀[休闲/双蚁巢单练] · 18.夜枭双门[挑战/反向绕背门] · 19.彩蝶锁桥[烧脑/堵球+锁桥] · 20.百鸟朝凤[Boss/章末Boss]
|
||||||
|
- **第三章 · 萌宠记(21–30)**:21.团子橘猫[基础/手绣样板] · 22.垂耳小兔[普通/染缸单练] · 23.笑脸柴犬[进阶/染×1孤缸] · 24.红耳小狐[烧脑/一蚁双色] · 25.抱竹熊猫[挑战/三重连锁] · 26.梅花小鹿[挑战/双巢+粗布] · 27.毛绒柯基[休闲/堵球+孤缸] · 28.蓝眼布偶[烧脑/三巢锁扣] · 29.果园刺猬[烧脑/五重烧脑] · 30.萌宠花园[Boss/章末Boss]
|
||||||
|
- **第四章 · 诗意山水(31–40)**:31.江南小桥[进阶/手绣样板] · 32.远山晓月[进阶/粗布+双扣] · 33.夕阳孤帆[挑战/6球拓扑锁] · 34.翠竹听风[挑战/双桥+线轴] · 35.雪顶樱山[烧脑/堵球+花锁] · 36.星夜灯海[烧脑/双孤缸+针门] · 37.云海热球[休闲/双巢喘息] · 38.秋枫溪谷[大师/7球双门双锁] · 39.极光雪松[大师/8球满载] · 40.千里江山[Boss/三巢Boss]
|
||||||
|
- **第五章 · 雅致筑影(41–50)**:41.红顶童话屋[进阶/手绣样板] · 42.风车磨坊[进阶/针门+绕水] · 43.江南水亭[挑战/侧巢双桥] · 44.樱花鸟居[挑战/覆染+鸟居锁] · 45.浪漫摩天轮[烧脑/堵球+三重锁] · 46.海边白灯塔[烧脑/7球粗布双轴] · 47.森林树屋[休闲/三巢喘息] · 48.复古花窗[大师/四重因果锁] · 49.玻璃花房[大师/三巢星阵] · 50.雪夜钟楼[Boss/半途换色Boss]
|
||||||
|
- **第六章 · 拾光甜物(51–60)**:51.草莓奶油蛋糕[进阶/手绣样板] · 52.樱花马卡龙[挑战/孤缸+双扣] · 53.青花茶壶[烧脑/侧巢半途换色] · 54.焦糖布丁[烧脑/环岛反向门] · 55.复古香水瓶[烧脑/双蚁半途换色] · 56.蜜桃气泡饮[大师/上下双巢7球] · 57.抹茶铜锣烧[休闲/侧巢茶歇] · 58.手工针线篮[大师/7球因果锁] · 59.星月怀表[大师/四巢怀表阵] · 60.下午茶宗师[终极Boss/60关宗师]
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### 3.3 自动化 CI 关卡质量门禁(8 项全绿)
|
||||||
|
运行命令:`node tools/audit-levels.mjs`(耗时 < 1 秒,直接执行真实 `RouteEngine.ts`)
|
||||||
|
1. **引擎全量通关校验**:`60 / 60` 全部通过真实几何、阻挡、锁桥、染缸与限额校验。
|
||||||
|
2. **全局跨章布局唯一性**:`60 / 60` 零重复球位拓扑(0 换皮复用)。
|
||||||
|
3. **锯齿紧度分布校验**:`min 61.9%` · `max 93.8%` · `mean 81.9%` · `sd 8.02`。
|
||||||
|
4. **分级三星阈值合理性校验**:第 1 关完成即三星;基础/普通/休闲留 `9%–11%` 触屏余量、进阶/挑战留 `6%–7%`、烧脑/大师/Boss 保持 `4%–5%` 精准挑战。
|
||||||
|
5. **跨章首关防倒挂校验**:`0 处` 章首难度高于前章 Boss。
|
||||||
|
6. **限笔容错覆盖率**:`39 / 60 (65%) ≥ 60%`。
|
||||||
|
7. **高阶机制覆盖统计**:半途换色 `4 关` · 多级因果链 `18 关` · 多蚁巢 `29 关`(顶/侧/四巢 `14 关`)· 针门 `13 关` · 不交叉 `40 关`。
|
||||||
|
8. **1 级提示安全校验**:全 60 关开局与首笔后,`findNextHint(lv, lines, 1)` 均严格沿真实折线绕水,零穿水洼误导。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 四、界面布局与美术资产规范
|
||||||
|
|
||||||
|
### 4.1 视觉 Token
|
||||||
|
- **青瓷松绿** `#2d443a`(对局台垫底色与宽屏外延衬底)
|
||||||
|
- **温润胡桃木** `#3c2615` / `#5e3b24`(顶部铭牌、任务徽章、用线量尺、底部针线盒托盘)
|
||||||
|
- **古铜暖金** `#d4ab62` / `#ffd866`(铆钉、铜边、三星刻度、已通关实金丝线)
|
||||||
|
- **亮米瓷釉** `#fbf1d9`(底部 4 枚工具按钮高对比瓷面与标签)
|
||||||
|
- **山茶绯红** `#c85450`(火漆印章与当前选关高亮焦点)
|
||||||
|
|
||||||
|
### 4.2 两大核心界面结构
|
||||||
|
1. **大厅界面([LobbyView.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/LobbyView.ts))**
|
||||||
|
- 顶栏:胡桃木雕花招牌「蚂蚁织画」 + 3D 集星进度(`★ X / 180`)+ 齿轮「设置」圆钮(`⚙`)。
|
||||||
|
- 中央画架:纯绣品预览绣绷(不展示毛线球/蚂蚁/机关,按高置信像素投影**严格上下左右居中**,已取消误触点击进关)+ 右上双行火漆印章(`难度 / 基础`)+ 左右切章木圆钮(配 `上一章 / 下一章` 微标)+ 青瓷刺绣绸带(双行居中)。
|
||||||
|
- 下方单排 6 枚主题丝签 + **蛇形金线针迹 10 关一屏地图**(已通关:亮彩绣花+金/绿环+`✓`印章+实金丝线;当前关:`1.16×`聚焦金环+山茶红号牌;未通关:素纱柔暗态+虚针连线)。
|
||||||
|
- 底部:统一「用线」信息签 + Meowa 蜜糖金大钮(`开始织画 · 第 X 关`)。
|
||||||
|
2. **对局界面([PlayView.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/PlayView.ts))**
|
||||||
|
- 顶栏:木质首页圆钮(`⌂`)+ 居中标题樱桃木牌(`04 溪畔金葵`)+ 放大镜(`镜`)与音效(`♪`)双木圆钮。
|
||||||
|
- 任务行:全套统一胡桃木铜边材质(左:彩色毛线点进度 + 笔数/机制标;右:`用线 X.X / 上限` + 实时 `★★★` + 双刻度进度条)。
|
||||||
|
- 舞台:全屏 Meowa 晨光青瓷桌面(四角鹤嘴剪/线轴/洋甘菊)+ 中央主角绣绷 + 顶部轻纱提示条。
|
||||||
|
- 底部托盘:雕花樱桃木针线盒 + 4 枚高对比亮米白瓷釉黄铜工具钮(提示 / 演示 / 撤销 / 重来)。
|
||||||
|
- 通关弹板:弹出时自动收起底部托盘,保留上方完整成品绣绷;下方 Meowa 雕花木拱顶亚麻奖牌框,支持导出 `1280×1720` 竖版博物馆藏品海报(居中成品 + 品牌印章 + 小程序码位 `assets/resources/branding/wx_qr`)。
|
||||||
|
|
||||||
|
### 4.3 已接入美术资源清单(总计 20 件,压缩后仅 `0.88 MB` / `897 KB`,较原 `2.55 MB` 缩减 `65.7%`)
|
||||||
|
|
||||||
|
| 目录 | 文件 | 尺寸 / 体积 | 来源与用途 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `assets/resources/ui/` | `bg_lobby_atelier.jpg` | `750×1334` · 171 KB | Meowa 大厅阳光樱桃木书案背景(基线优化 JPG) |
|
||||||
|
| `assets/resources/ui/` | `bg_play_atelier.jpg` | `750×1334` · 223 KB | Meowa 对局青瓷亚麻桌垫与角落道具(基线优化 JPG) |
|
||||||
|
| `assets/resources/ui/` | `btn_dock_{hint,demo,undo,restart}.png` | `144×144` · 40 KB 共4件 | Meowa 亮米瓷釉黄铜花扣工具按钮(PNG-8 透明索引) |
|
||||||
|
| `assets/resources/ui/` | `ui_wood_plaque.png` / `ui_wood_dock.png` / `ui_wood_round.png` | 49 KB 共3件 | Meowa 樱桃木招牌、底部木槽、圆木钮(PNG-8 透明索引) |
|
||||||
|
| `assets/resources/ui/` | `ui_silk_ribbon.png` / `ui_gold_btn.png` / `ui_wax_seal.png` / `ui_floral_node.png` / `ui_linen_modal.png` | 158 KB 共5件 | Meowa 青瓷绸带、蜜糖金钮、火漆印、花扣、亚麻弹框(PNG-8 透明索引) |
|
||||||
|
| `assets/resources/artworks/` | `art_ch1_sunflower.jpg` … `art_ch6_strawberry_cake.jpg` | `512×512` · 256 KB 共6幅 | 六大章节首关高精手绣成品底图(基线优化 JPG) |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 五、设置系统、数据存储与合规清单
|
||||||
|
|
||||||
|
### 5.1 设置面板能力(主页右上 `⚙` 统一收纳)
|
||||||
|
- **背景音乐开关**:独立控制轻柔五声八音盒循环(`SoundService.toggleBgm`)。
|
||||||
|
- **游戏音效开关**:独立控制拾球、落针、染缸、通关等 WebAudio 合成音效(`SoundService.toggle`)。
|
||||||
|
- **界面语言**:`简体中文` / `English` 即时切换(无悬浮翻译按钮)。
|
||||||
|
- **玩法说明(图文)**:3 步卡片式图文教学,随时回顾。
|
||||||
|
- **隐私政策**:真实可点静态展示页,明确 V1 纯单机不采集个人隐私信息、本地存储用途及 V1.1 联网授权说明(满足软著/小游戏提审备案要求)。
|
||||||
|
- **关于**:`蚂蚁织画 v1.0.0(纯单机手作版)`。
|
||||||
|
|
||||||
|
### 5.2 本地存储 Key 清单([StorageService.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/StorageService.ts))
|
||||||
|
| Key | 类型 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `ant-embroidery-best-v1` | JSON Map | 各关最高星级(1–3)与最佳用线长度 |
|
||||||
|
| `ant-embroidery-sound-v1` | `'1' \| '0'` | 游戏音效开关 |
|
||||||
|
| `ant-embroidery-bgm-v1` | `'1' \| '0'` | 背景音乐开关 |
|
||||||
|
| `ant-embroidery-loupe-v1` | `'1' \| '0'` | 拖动放大镜开关 |
|
||||||
|
| `ant-embroidery-lang-v1` | `'zh' \| 'en'` | 界面语言偏好 |
|
||||||
|
| `ant-embroidery-tut-v1` | `'1'` | 第 1 关首进教学浮卡已读标记 |
|
||||||
|
| `ant-embroidery-atelier-v1` | JSON | 蚂蚁工坊线头、待领离线进度、已解锁装裱/落款、蚂蚁日记与轻量展柜元数据 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 六、代码架构与工程约定
|
||||||
|
|
||||||
|
| 模块文件 | 代码行数 | 核心职责 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| [MainController.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/MainController.ts) | 55 | 应用入口、大厅/对局视图切换、切后台中断拖线保护 |
|
||||||
|
| [Types.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/Types.ts) | 258 | 全量核心数据结构(关卡、8 色毛线、路线、提示、进度) |
|
||||||
|
| [LevelData.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/LevelData.ts) | 1579 | 6 大主题章节与 60 关完整拓扑定义、单位格式化 |
|
||||||
|
| [RouteEngine.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/RouteEngine.ts) | 717 | 纯逻辑规则引擎(阻挡、精确粗布重叠、半途换色、3 级提示、自动化验关) |
|
||||||
|
| [EmbroideryRenderer.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/render/EmbroideryRenderer.ts) | 2551 | 离屏 Canvas 手绣渲染、蚂蚁编队动画、放大镜、行列投影居中、藏品海报导出 |
|
||||||
|
| [LobbyView.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/LobbyView.ts) | 1033 | 大厅画架、蛇形针迹关卡图、章节门控弹窗、设置/玩法/隐私弹窗 |
|
||||||
|
| [PlayView.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/PlayView.ts) | 1350 | 对局 HUD、触控直拖/遥控、演示编队调度、首进引导、通关庆典 |
|
||||||
|
| [UiBuilder.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/UiBuilder.ts) | 744 | 3D 质感面板/按钮构建器、Meowa 精灵异步缓存加载器 |
|
||||||
|
| [SoundService.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/SoundService.ts) | 169 | 零音频素材依赖的 WebAudio 音效与五声八音盒 BGM 合成器 |
|
||||||
|
| [StorageService.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/StorageService.ts) | 135 | 微信小游戏 `wx.getStorageSync` / 浏览器 `localStorage` 双端持久化 |
|
||||||
|
| [AtelierService.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/core/AtelierService.ts) | 600 | 放置蚂蚁工坊离线结算(8h封顶)、12 篇蚂蚁日记、6 章委托信/回信与展柜装裱定制纯逻辑服务 |
|
||||||
|
| [AtelierModal.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/AtelierModal.ts) | 760 | 「我的绣坊」统一三页签弹窗(蚂蚁工坊实时小舞台 / 绣品展柜与海报定制 / 委托信箱) |
|
||||||
|
| [ScreenAdapter.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/ScreenAdapter.ts) | 162 | 微信小游戏全面屏分辨率策略、全高安全区动态锚定(紧贴胶囊下沿与底部手势条,拉宽中间板块间距,消除上下大空白) |
|
||||||
|
| [audit-levels.mjs](file:///Users/1993.x/development/mayi_coco/tools/audit-levels.mjs) | 280 | Node 24 零构建 60 关 8 项 CI 自动化质量审计脚本 |
|
||||||
|
|
||||||
|
> **工程约定**:严禁在未经用户明确指令前执行自动打包构建(`CocosCreator --build`)或自动生成发版压缩包;仅在用户明确要求打包时执行构建。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 七、迭代路线图与更新日志
|
||||||
|
|
||||||
|
### 7.1 后续规划(Roadmap)
|
||||||
|
- **V1.0 上线收口**
|
||||||
|
- [ ] 放入正式微信小程序码图片至 `assets/resources/branding/wx_qr.png`(海报导出将自动替换默认太阳码占位)。
|
||||||
|
- [ ] 按需为其余关卡(如第 2–10 关或各章 Boss 关)补充更多 Meowa 专属手绣成品底图,进一步丰富画廊多样性。
|
||||||
|
- [ ] 微信开发者工具真机体验测试(触控帧率、海报保存相册权限 `wx.saveImageToPhotosAlbum`)。
|
||||||
|
- **V1.1 轻社交与留存**
|
||||||
|
- [ ] 接入微信好友排行榜与官方隐私授权弹窗。
|
||||||
|
- [ ] 增加「我的绣品展柜」回看与一键分享好友炫耀。
|
||||||
|
- [ ] 每日一绣(每日限定图案挑战)。
|
||||||
|
- **V1.2 内容与核心玩法扩展**
|
||||||
|
- [ ] 「拆旧织新」旧绣片分层抽线 + 绣绷线碗特别玩法章节(先完成 V1.1 备案上线,后续正式立项回归)。
|
||||||
|
- [ ] 节气/节日限定主题绣章(如江南梅雪、端午香囊、中秋玉兔)。
|
||||||
|
|
||||||
|
### 7.2 持续更新日志(Changelog)
|
||||||
|
|
||||||
|
| 日期 | 版本 | 更新摘要 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `2026-11-25` | `v1.1.3` | **微信小游戏提审备案收口与全面屏间距精调**:移除「拆旧织新」番外原型(延后至 V1.2 正式版本),恢复委托信箱双卡舒朗排版;升级 [ScreenAdapter.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/ScreenAdapter.ts) 按实际安全区高度(`safeHalfH / extraH`)动态顶底锚定,彻底消除真机全面屏顶部胶囊下方与底部手势条上方的大块空白,并将释放出的纵向空间均匀分配给大厅(绸带→章节签→10 关地图→信息签→主按钮)与对局页(顶栏→任务行→提示条→中央绣绷→底部针线盒),第 1 关信息签文案优化为「入门引导 · 完成即可满星 ★」。 |
|
||||||
|
| `2026-11-24` | `v1.1.2` | **微信小游戏全机型界面适配 + 美术资源瘦身 65.7%**:新增 [ScreenAdapter.ts](file:///Users/1993.x/development/mayi_coco/assets/scripts/ui/ScreenAdapter.ts),竖屏手机切为 `FIXED_WIDTH` 全屏铺满(背景 Cover 缩放 + 3200×3200 全屏弹窗遮罩,彻底消除全面屏上下黑边),平板/横屏自动切 `FIXED_HEIGHT`;实时读取 `wx.getMenuButtonBoundingClientRect()` 与 `safeArea` 自动避让微信右上角胶囊、灵动岛与底部 Home 条;补齐微信相册权限拒绝后的 `wx.showModal` + `wx.openSetting` 恢复重存流程;全量 20 件美术资源压缩(PNG-8 透明索引 + Retina 适度裁齐 + 基线优化 JPG),总包体从 `2.55 MB` 降至 `0.88 MB`。 |
|
||||||
|
| `2026-11-24` | `v1.1.1` | **产品评审 4 项必修收口**:① 修复 1 级提示跳过绕水拐点直线穿水洼 Bug(如第 19 关)并纳入 CI 第 8 项门禁;② 自动起手虚线引导收敛为仅前 3 关新手教学,第 4 关起不再剧透起手蚁巢与球;③ 按难度分级放宽教学/普通关三星手感余量(第 1 关完成即三星),章节星数门槛温和下调为 `[0, 12, 26, 44, 64, 86]` 防卡死第六章;④ 打通第 1 关「林阿婆委托 → 织画 → 入柜 → 立刻拆阅回信」首局闭环,通关页新增直达展柜/读回信入口。 |
|
||||||
|
| `2026-11-24` | `v1.1.0` | **核心轻循环与规则漏洞收口**:修复 `demoWatched` 看演示重绣白拿三星漏洞;上线统一「我的绣坊」三页签系统——① **放置蚂蚁工坊**(离线最多 8h 累积柔丝线头、零焦虑不清零、实时 3 只工蚁小舞台动画、12 篇可收集蚂蚁日记)、② **绣品展柜与海报定制**(元数据轻量存储、4 款装裱风格与 4 句雅致落款线头兑换、支持展柜内直接导出 `1280×1720` 定制海报)、③ **六大章节客人委托信与成画回信**(大厅画架左上信封对称入口 + 底部工坊/展柜双圆钮)。 |
|
||||||
|
| `2026-11-24` | `v1.0.1` | **章节解锁收口与锁图标化**:彻底移除大厅「跳关试玩」及通关页跨章绕过,改为严格集星解锁;大厅未解锁章节丝签、解锁提示弹窗与对局内机关锁徽章统一以矢量金属小锁图标替代「锁」文字。 |
|
||||||
|
| `2026-11-24` | `v1.0.0` | **品牌与产品体验收口**:正式定名「蚂蚁织画」;统一「用线 → 实时星级」量尺与双刻度;新增蚂蚁纵队编队织画与身后实时“长线”效果;新增目标针位呼吸光环;上线主页齿轮「设置」总弹窗(BGM/音效/语言/图文玩法/合规隐私政策/关于)及第 1 关首进教学浮卡;强化大厅已通关/当前/未通关三态对比。 |
|
||||||
|
| `2026-11-24` | `v0.9.5` | **Meowa 手绘界面全面重构**:按 `frontend-design` 规范彻底去网页化,使用 Meowa 产出 2 幅 9:16 阳光刺绣桌面背景 + 12 件透明手绘木雕/瓷釉 UI 组件;大厅重构为「中央纯图案居中绣绷画架 + 蛇形金线针迹 10 关地图」;直拖蚁巢改为 1:1 严格跟手。 |
|
||||||
|
| `2026-11-24` | `v0.9.0` | **60 关认知难度与全局去重**:打通「一蚁半途换色」机制;重做 16 关跨章复用拓扑实现 60/60 全局零重复;CI 新增全局唯一性门禁,60 关 7 项指标全绿。 |
|
||||||
|
| `2026-11-24` | `v0.8.0` | **六大主题章节与藏品海报**:移除十字绣原型;扩充至 6 章 × 10 关 = 60 关与 8 色莫兰迪绣线;生成 6 幅章节手绣样板底图;升级 `1280×1720` 竖版藏品海报导出;移除线尾裁切还原真实拖线长度。 |
|
||||||
@@ -0,0 +1,538 @@
|
|||||||
|
# 《蚂蚁织画》跨品类休闲玩法融合提案
|
||||||
|
|
||||||
|
> **文档类型**:方向评估与融合设计(配套 `docs/蚂蚁织画-深度玩法扩展方案-P0P1P2.md`)
|
||||||
|
> **代码基线**:`v1.0.1` · 纯单机手作版
|
||||||
|
> **状态**:待评审 · 未实施 · 不修改上一份方案的批次计划
|
||||||
|
> **目标**:从成熟休闲品类中提取「循环钩子」,判断哪些能融进现有拖线玩法,哪些会稀释它。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 0. 先说结论
|
||||||
|
|
||||||
|
**融合解决不了「深度不够」。** 上一份方案诊断的根因是「全信息 + 单目标 + 唯一解」,属于核心规则层(P0 三维星级 / P1 求解器与多解)。跨品类融合带来的是**回访理由、可见成长、情感意义、爽感反馈**——这些能让玩家愿意一直回来,但不会让一关变得更需要思考。只做融合而不做 P0/P1,结果会是「包装很丰富、依然在临摹一条线」。
|
||||||
|
|
||||||
|
唯一的例外是 **B 档的三消式连锁** 与 **Roguelike 三选一**:它们额外引入了「要不要凑连锁」「选哪个词条」的决策,能同时贡献深度与留存。
|
||||||
|
|
||||||
|
**第二条核心判断:要融合的是「循环结构」,不是「操作动词」。** 本作的身份是「单指拖一条 1:1 跟手的连续折线」。任何引入第二套操作动词的玩法(三消棋盘、合成棋盘、点按节奏、重力弹射)都会稀释它。因此下面的筛选标准只有两个:
|
||||||
|
|
||||||
|
| 判据 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| **侵入度** | 是否改变核心动词、是否引入第二套操作、是否给 `RouteEngine` 加新判定 |
|
||||||
|
| **收益** | 是否补上「次日回访 / 星数意义 / 情感动机 / 单关爽感 / 可重复内容」中的至少一项 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 可融合接口与不可侵犯项
|
||||||
|
|
||||||
|
现有系统能被外部玩法挂接的四个接口:
|
||||||
|
|
||||||
|
| 接口 | 现状 | 可挂接的玩法 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 星数 | 仅用于 `CHAPTER_UNLOCK_STARS` 门槛 | 家园装修货币、图鉴进度、套装收集 |
|
||||||
|
| 成品绣画 | 预设底图 + 星级,`exportArtwork()` 导出 | 展柜、拼图长卷、赠礼、配色定制 |
|
||||||
|
| 关卡序列 | 60 关静态线性列表 | 每日一绣、无尽绣坊、seed 分享 |
|
||||||
|
| 蚂蚁主角 | 演示编队 + 织线动画,`drawAnt()` 已成型 | 放置工坊、日记明信片、小生命行为 |
|
||||||
|
|
||||||
|
**不可侵犯的四条**(与上一份方案 §1 一致):
|
||||||
|
|
||||||
|
1. 单指 1:1 跟手拖线,不缩尾、不偏漂;
|
||||||
|
2. 无全局倒计时、无失败惩罚、无限撤销(匠心模式除外,且可选);
|
||||||
|
3. 治愈 / 手作 / 收藏的情绪基调;
|
||||||
|
4. `RouteEngine.ts` 保持纯逻辑、可离线运行。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 品类扫描总表
|
||||||
|
|
||||||
|
| 品类 / 参照 | 值得迁移的机制原子 | 融合形态 | 侵入度 | 收益 | 依赖 | 判断 |
|
||||||
|
| --- | --- | --- | --- | --- | --- | --- |
|
||||||
|
| 放置 · 旅行青蛙 / 猫咪公寓 | 离线产出、回来收菜、小生命自主行为、明信片 | 蚂蚁工坊 | 低 | 极高 | 无 | **A · 首选** |
|
||||||
|
| 家园装修 · 梦幻家园 / Project Makeover | 关卡货币 → 装扮空间 → 空间给目标与叙事 | 绣坊装扮 | 低 | 极高 | P2 绣坊 | **A · 首选** |
|
||||||
|
| 图鉴收集 · 宝可梦 / 明信片 | 收集格子的填满欲、稀有度 | 绣谱图鉴 + 完成度 | 低 | 中高 | 展柜 | **A** |
|
||||||
|
| 拼图 / 数字涂色 · Happy Color | 碎片拼整图、完成度百分比、逐格显影 | 六章长卷 + 逐针显影 | 低 | 中高 | 海报导出 | **A** |
|
||||||
|
| 叙事信件 · Florence / 情书 | 每关是故事的一片、物件承载记忆 | 绣坊委托信 | 低 | 中 | 纯内容 | **A** |
|
||||||
|
| 三消 · Candy Crush | 连锁正反馈 cascade、步数经济、特殊块组合 | 连针连锁 + 省笔返线 | 中 | 高 | P0 三维星级 | **B · 首选** |
|
||||||
|
| Roguelike · 杀戮尖塔 | 每局随机三选一、build 成长、种子分享 | 无尽绣坊 | 中高 | 高 | P1 求解器 + P2 Loadout | **B** |
|
||||||
|
| Merge · Merge Dragons | 两物合成高阶物、重复产出的转化器 | 展柜里一次点击合绣片 | 中 | 中 | 展柜 | **B · 轻融合** |
|
||||||
|
| 收纳整理 · A Little to the Left | 归位的秩序快感、无失败无计时 | 针线盒整理日课 | 中低 | 低中 | 无 | **A · 点缀** |
|
||||||
|
| 异步社交 · 动森 / Words with Friends | 互访、共同完成一幅画、半成品接力 | 接龙绣绷 | 中 | 中 | V1.1 云端 | **B · 后置** |
|
||||||
|
| 音游节奏 · Cytus | 节拍反馈 | 仅保留「落针音按线色组成旋律」 | 高 | 低 | SoundService | **C · 只借听感** |
|
||||||
|
| 物理弹射 · 割绳子 | 沿线滑落物件、重力 | — | 极高 | 低 | — | **C · 不做** |
|
||||||
|
| 塔防 / 实时 PvP / 体力 | 对抗、失败压力 | — | 极高 | 低 | — | **C · 不做** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. A 档:零冲突,只加外层循环
|
||||||
|
|
||||||
|
### A1 放置蚂蚁工坊(解决「次日回访」)
|
||||||
|
|
||||||
|
**为什么是首选**:题材天作之合,且完全不碰 `RouteEngine`;旅行青蛙已验证该模型对女性向治愈用户的有效性。它补的是当前最缺的一环——**玩家没有任何理由明天再打开游戏**。
|
||||||
|
|
||||||
|
| 项 | 设计 |
|
||||||
|
| --- | --- |
|
||||||
|
| 数据 | `AtelierIdle { lastSeenAt, ants: AntWorker[], pending: IdleReward[], diary: DiaryEntry[] }` → `ant-embroidery-idle-v1` |
|
||||||
|
| 离线结算 | 按墙钟时间累积「线头」,**上限 8 小时且不清零**;不做「错过就亏」的焦虑设计 |
|
||||||
|
| 小生命行为 | 3–4 只工蚁在绣坊里绕线 / 打盹 / 画小样 / 搬线轴,状态由 seed 决定,复用 `EmbroideryRenderer.drawAnt()`(1740 行)与 `drawScene()`(1853 行) |
|
||||||
|
| 产出 | 灵感点、可选工具、绣坊装饰件;**稀有产出是 `DiaryEntry`**——一张小蚂蚁随手织的插画 + 一句短句,进图鉴 |
|
||||||
|
| 兑换边界 | 只兑外观 / 故事 / 可选工具,**绝不兑通关必需资源**(否则变肝) |
|
||||||
|
| 落点 | 新增 `IdleService`(纯 TS、无 `cc` 依赖、可单测);`MainController.onShow` 结算;`LobbyView` 加工坊入口;`SoundService` 加一声轻提示 |
|
||||||
|
|
||||||
|
**验收**:离线 1h / 8h / 72h 三种情形结算正确且无溢出;杀进程重进结果幂等;产出不影响任一关的 `evaluateRun()` 星级。
|
||||||
|
|
||||||
|
### A2 绣坊装扮(解决「星数没有意义」)
|
||||||
|
|
||||||
|
把上一份方案 P2 §4.3 的「绣坊元进程」升级为**可见的家园系统**,两处合并实现,避免两套货币、两套界面。
|
||||||
|
|
||||||
|
| 项 | 设计 |
|
||||||
|
| --- | --- |
|
||||||
|
| 数据 | `AtelierDecor { slots: Record<DecorSlot, string>, owned: string[], currency: number }` |
|
||||||
|
| 货币 | 「丝线币」= 首次通关 +1 / 每枚星 +1 / 套装集齐 +10 / 每日一绣 +2(与「灵感点」合并为一个,不要两种货币) |
|
||||||
|
| 槽位 | 桌布、绣绷、线架、窗景、灯、茶具、猫窝、挂画(8 槽,每槽 3 选 1) |
|
||||||
|
| 视觉回报 | 装扮**直接改变大厅画架与对局桌面的道具图层**:`bg_lobby_atelier.jpg` / `bg_play_atelier.jpg` 之上叠可替换道具;`EmbroideryRenderer.drawSurround()`(774 行)已有四角道具绘制,挂 decor 图层成本最低 |
|
||||||
|
| 数值 | **纯外观,零属性加成**。规则加成统一走 P2 的 `Loadout`,两者严格分离,避免「氪/肝才能过关」的观感 |
|
||||||
|
| 落点 | `LobbyView` 加「布置绣坊」入口;`StorageService` 新增 key;`UiBuilder` 复用现有木雕 / 瓷釉组件做槽位卡 |
|
||||||
|
|
||||||
|
**验收**:任一装扮组合下 60 关 `cost` 与星级完全不变;装扮变更在大厅与对局两侧同步生效。
|
||||||
|
|
||||||
|
### A3 图鉴 / 长卷 / 委托信(解决「绣完就结束」)
|
||||||
|
|
||||||
|
- **绣谱图鉴**:`CodexEntry { key, rarity, unlockedAt }`,维度 = 8 色线 × 6 章 × 4 针法 × 节气限定;大厅常驻「完成度 xx%」条 —— 借鉴数字涂色的完成度钩子,给长线一个直观终点。落点:展柜 `ant-embroidery-gallery-v1` 升级。
|
||||||
|
- **六章长卷**:每章产出 1 块绣片,集齐合成一张竖版长卷海报;`exportArtwork()` 扩展为多源合成。跨章节的视觉终点,也是套装收集的自然奖励。
|
||||||
|
- **绣坊委托信**:每章首关收到一封委托(奶奶的生日、朋友搬家、孩子的第一场雪),通关/满星解锁回信。纯内容层,零引擎改动,把「绣一幅画」变成「为谁绣一幅画」。
|
||||||
|
- **针线盒整理日课**(可选点缀):关末把用过的线轴/纽扣拖回格子归位,无计时无失败,给一个轻仪式感。借鉴 A Little to the Left 的秩序快感,但**不强制、不评分、不联网**。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. B 档:轻耦合,复用现有事件流
|
||||||
|
|
||||||
|
### B1 三消式连锁正反馈(同时贡献爽感与深度)
|
||||||
|
|
||||||
|
三消真正该偷的不是「三连消」,而是 **cascade:一次决策引发一串正反馈**。
|
||||||
|
|
||||||
|
| 项 | 设计 |
|
||||||
|
| --- | --- |
|
||||||
|
| 触发 | 一笔内连续送达的针位在绣面上相邻或共线。`SectionDef` 已有 `x/y`,关卡加载时自动生成邻接表 `LevelDef.adjacency?: Record<string, string[]>`,无需手填 |
|
||||||
|
| 效果 | ① 返还 `N` 点用线进预算(`effectiveBudget()` 加 `refund`);② 下一片针位提前点亮预览;③ 递进音效按线色音高排列(`SoundService` 现有五声八音盒合成器可直接扩展);④ 连续 2/3 次给「连针」徽记 |
|
||||||
|
| 关键 | **只给正反馈,绝不给失败惩罚**;连锁常要求一笔串更多针位,天然与 P0「笔数星 / 针脚星」形成取舍 |
|
||||||
|
| 落点 | `planStops()` 的 `markDelivery` 回调加 cascade 检测;`PlayView` 播连锁动画;`RouteEngine` 只增一个纯函数 `detectCascade()`,判定仍可离线跑 |
|
||||||
|
|
||||||
|
**这是唯一能不靠 P1 求解器就增加单关决策面的融合项**,建议排在 A 档之后、B2 之前。
|
||||||
|
|
||||||
|
### B2 无尽绣坊(Roguelike 三选一,解决「60 关玩完就没了」)
|
||||||
|
|
||||||
|
| 项 | 设计 |
|
||||||
|
| --- | --- |
|
||||||
|
| 结构 | 连续 5–8 关,seed 决定关卡序列;每关后从 3 个 `ToolDef`(上一份方案 §4.3 已有)中选 1 个,形成 build |
|
||||||
|
| 无失败 | 中途随时可「收工」并带走收获;**没有死亡、没有重开惩罚**,符合治愈定位 |
|
||||||
|
| 成绩 | 最终按三轴(省线 / 笔数 / 针脚)结算,分享「种子码 + 成绩」,异步比拼更省 / 更漂亮,不动官方关卡星数 |
|
||||||
|
| 依赖 | P1 求解器:必须保证带任意合法 Loadout 组合的关卡可解(对应门禁 **G15**);P2 `Loadout` 数据结构 |
|
||||||
|
| 落点 | `generateDailyLevel()` 扩展为 `generateRun(seed, depth)`;`MainController` 加 run 视图状态;`ant-embroidery-run-v1` |
|
||||||
|
|
||||||
|
### B3 绣片合成(Merge 的轻融合)
|
||||||
|
|
||||||
|
通关掉落的「绣片碎片」在展柜里**点一次**即可两片合成高阶绣片,用于装扮槽位或长卷。明确禁止做成独立合成棋盘——那会引入第二套操作动词,把拖线玩法割裂成两个游戏。落点:`GalleryService` 纯数据合并,零渲染新增。
|
||||||
|
|
||||||
|
### B4 接龙绣绷(异步社交,V1.1 后置)
|
||||||
|
|
||||||
|
我绣一半、好友补另一半;或每人认领一幅大绣的一块异步接力。比排行榜更贴合治愈系,但依赖云端与内容审核,排在上一份方案 M6 之后。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. C 档:明确不做
|
||||||
|
|
||||||
|
| 方向 | 不做的理由 | 可保留的部分 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 音游节奏 / 计时 | 与「无时间压力、1:1 跟手」直接冲突 | 落针音按线色组成一小段旋律(听感层,非玩法) |
|
||||||
|
| 物理弹射 / 重力割绳 | 把折线变成受力模拟,破坏跟手手感 | 现有「纽扣锚点」已经是「沿途收集小星星」,无需再加 |
|
||||||
|
| 独立三消 / 合成棋盘 | 引入第二套操作动词,稀释核心身份 | 只取 cascade 与合成作为数据层事件 |
|
||||||
|
| 塔防 / 实时 PvP / 体力 / 强失败惩罚 | 与治愈定位冲突 | — |
|
||||||
|
| 强限时每日任务 | 制造「错过就亏」的焦虑 | 每日一绣保持无期限、可补玩 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 与 P0/P1/P2 的挂接关系
|
||||||
|
|
||||||
|
| 融合项 | 前置 | 挂接的系统 | 是否碰 `RouteEngine` |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| A1 蚂蚁工坊 | 无 | `MainController` / `LobbyView` / `IdleService` | 否 |
|
||||||
|
| A2 绣坊装扮 | P2 §4.3 绣坊(合并实现) | `LobbyView` / `StorageService` / `drawSurround` | 否 |
|
||||||
|
| A3 图鉴长卷委托信 | 展柜(M5) | `exportArtwork` / `LobbyView` | 否 |
|
||||||
|
| B1 连针连锁 | P0 三维星级(M1) | `planStops` / `effectiveBudget` / `SoundService` | 是,仅增纯函数 |
|
||||||
|
| B2 无尽绣坊 | P1 求解器(M2)+ P2 Loadout(M6) | `solve-level.ts` / `MainController` | 否(复用求解器) |
|
||||||
|
| B3 绣片合成 | 展柜(M5) | `GalleryService` | 否 |
|
||||||
|
| B4 接龙绣绷 | V1.1 云端 | 云服务 / 内容安全 | 否 |
|
||||||
|
|
||||||
|
**结论**:A 档三项全部可以**与 M1 并行开发**,互不阻塞;B1 需等 M1 的 `ScoreSpec`,B2 必须等 M2 + G15。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. 推荐的最小可验证融合包
|
||||||
|
|
||||||
|
> **A1 放置蚂蚁工坊 + A2 绣坊装扮 + P0 三维星级**
|
||||||
|
|
||||||
|
理由:三者分别补上「明天为什么回来」「星星有什么用」「这一关要不要想」,且互相不依赖、除 P0 外都不碰核心判定,能在一个版本内形成完整循环:
|
||||||
|
|
||||||
|
```
|
||||||
|
回到绣坊收线头 → 看小蚂蚁的日记 → 用丝线币换一张新桌布
|
||||||
|
→ 顺手再绣一关,这次试着同时拿「省线星」和「针脚星」
|
||||||
|
→ 成品入展柜、完成度 +1%
|
||||||
|
```
|
||||||
|
|
||||||
|
**第二批**加 B1 连针连锁:它给单关补爽感,且让「笔数星」的取舍更有存在感。B2 无尽绣坊等 M2 求解器稳定后再开,作为 60 关之后的内容承接。
|
||||||
|
|
||||||
|
不建议同时上 A1 + A2 + A3 + B1 + B2:五个系统同时铺开会让大厅变成入口堆叠,反而稀释「一幅绣绷 + 一张桌案」的干净气质。每批最多两个新入口。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. 风险与合规
|
||||||
|
|
||||||
|
| 风险 | 应对 |
|
||||||
|
| --- | --- |
|
||||||
|
| **玩法稀释**:入口太多、第二套操作动词 | §5 硬约束;每批最多两个新入口;新品类必须能挂到 §1 四个接口之一 |
|
||||||
|
| **肝度 / 焦虑**:离线收益变负担 | 8h 封顶、不清零、产出只兑外观;每日一绣可补玩、无期限 |
|
||||||
|
| **数值污染**:装扮影响通关 | 装扮零属性,规则加成只走 `Loadout`;CI 增门禁「任一装扮组合下 60 关 cost 不变」 |
|
||||||
|
| **包体膨胀**:装饰图层 | 复用现有 `ui_wood_*` / `ui_silk_ribbon` 等 20 件组件做组合,不新增大图;新增道具按需异步加载 |
|
||||||
|
| **隐私合规**:本地埋点 | 只存聚合计数(次日回访、工坊打开率、装扮变更次数、展柜回看率),不采集个人信息、不上传;与现有隐私政策「V1 纯单机」表述一致。UGC / 社交仍延后到 V1.1 并更新授权弹窗 |
|
||||||
|
| **指标不可得**:单机无后台 | 本地聚合计数在设置页「关于」里可视化,供开发期人工验收;联网上报需另行评审 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. 验收指标(本地可观测)
|
||||||
|
|
||||||
|
| 指标 | 期望 | 观测方式 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 次日回访 | 有工坊后显著提升 | 本地 `lastSeenAt` 差值聚合计数 |
|
||||||
|
| 工坊打开率 / 收菜率 | 打开大厅后进入工坊的比例 | 本地计数 |
|
||||||
|
| 装扮变更次数 | 每个活跃周期 ≥ 1 次 | 本地计数 |
|
||||||
|
| 展柜回看率 / 完成度增长 | 图鉴墙启用后逐周上升 | 本地计数 |
|
||||||
|
| 三轴分散度 | 不再出现「90% 玩家三星全同解」 | `RecordEntry.axes` 分布(P0 后可得) |
|
||||||
|
| 无尽绣坊深度 | run 平均完成关数 ≥ 4 | `ant-embroidery-run-v1` 本地统计 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 附录:融合机制 → 代码落点对照
|
||||||
|
|
||||||
|
| 机制 | 新增 / 修改文件 | 关键位置 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 蚂蚁工坊 | 新增 `assets/scripts/core/IdleService.ts`;改 `MainController.ts`、`LobbyView.ts` | `onShow` 结算;`drawAnt()` 1740 / `drawScene()` 1853 |
|
||||||
|
| 绣坊装扮 | 改 `LobbyView.ts`、`UiBuilder.ts`、`StorageService.ts` | `drawSurround()` 774;两大背景图道具层 |
|
||||||
|
| 图鉴 / 长卷 | 改 `LobbyView.ts`、`EmbroideryRenderer.ts` | `exportArtwork()` 2378;`GalleryEntry` |
|
||||||
|
| 委托信 | 新增内容数据 `assets/resources/story/*.json`;改 `LobbyView.ts` | 章节首关弹窗 |
|
||||||
|
| 连针连锁 | 改 `RouteEngine.ts`、`PlayView.ts`、`SoundService.ts` | `planStops()` 329 的 `markDelivery`;`effectiveBudget()` 173 |
|
||||||
|
| 无尽绣坊 | 改 `tools/solve-level.ts`、`MainController.ts` | `generateDailyLevel()` → `generateRun()`;门禁 G15 |
|
||||||
|
| 绣片合成 | 新增 `GalleryService.ts` | 展柜数据合并 |
|
||||||
|
| 接龙绣绷 | V1.1 云端 | 依赖 `cloud-service` 与内容安全审核 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. 决策复核:新增五条候选(2026-11-24 追加)
|
||||||
|
|
||||||
|
> 承接用户侧「第十三章 · 跨品类融合候选」。本节按「规则 / 咬合点 / 引擎触点 / 成本 / 验证判据」统一规格登记,并附代码级复核。**本提案原有 §0–§9 结论不变**。
|
||||||
|
|
||||||
|
### 10.1 编号映射与待确认项
|
||||||
|
|
||||||
|
已检索范围:项目 `docs/` 全部文档、全部 `*.ts`、历史会话检索(无结果)。以下编号来自另一套方案,不臆测定义:
|
||||||
|
|
||||||
|
| 用户侧编号 | 本项目可对应的位置 | 状态 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| **A 方案 / 网络收益 / 熟线折扣 `0.2 → 0.1`** | 未检索到定义;推测与「串球 / 路线网络收益」相关,对应 `planStops()` 的配对规则 | **待补定义**。§11 词条 1 暂按「粗布区额外倍率减半」占位 |
|
||||||
|
| **C3 展柜** | 本提案 §3 A3「图鉴 / 展柜」、深度方案 §4.1「绣品定制与展柜」 | 可映射 |
|
||||||
|
| **双面绣** | 未检索到定义 | **待补定义**。若指「布背翻面显影」,可挂到 §11 词条 5「翻绷」 |
|
||||||
|
| **铁律 1** | 推测为「1:1 跟手、不引入精度惩罚」,对应深度方案 §1 原则 1 与 §8 不做清单 | **推测,待确认** |
|
||||||
|
| **第十三章** | 本会话两份文档分别为 §0–§8、§0–§9,无第十三章 | 编号差异。本提案以 **§10 / §11** 承接;若那份文档在本地,提供路径后可改挂 |
|
||||||
|
|
||||||
|
### 10.2 五条候选 · 统一规格
|
||||||
|
|
||||||
|
#### 候选 1 · 绣娘行囊(Roguelike 词条构筑)→ 详见 §11
|
||||||
|
|
||||||
|
| 项 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| 规则 | 单局 10 关,每 3 关从 3 张词条选 1 张,累积到局末;词条池 12–16 个;关卡布局固定、只随机关键词;保留无词条的经典模式 |
|
||||||
|
| 咬合点 | 同一关在不同构筑下最优策略不同 → 60 关组合寿命被乘上去;治「一眼看穿」与「通关即结束」 |
|
||||||
|
| 引擎触点 | `segmentCost()` / `planStops()` / `checkSegmentBlock()` / `effectiveBudget()` / `evaluateRun()` 读取 `RunModifier[]` |
|
||||||
|
| 成本 | 引擎一个 `modifiers` 参数 + 分发函数;卡片 UI 复用 `ui_linen_modal` 与木雕钮,**新增美术 ≈ 0** |
|
||||||
|
| 验证判据 | 任一合法词条组合下 60 关 `validateLevelDemo` 全通过;同一关至少 2 种构筑产生不同的最优笔序(求解器判定) |
|
||||||
|
|
||||||
|
#### 候选 2 · 负重耗线(贪吃蛇风险收益,只取结构不取精度惩罚)
|
||||||
|
|
||||||
|
| 项 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| 规则 | 串第 2 颗球后全程耗线 `×1.15`;串第 3 颗 `×1.35`(第 3 颗需「串三球」词条解锁)。**增量按段计费,不回溯重算** |
|
||||||
|
| 咬合点 | 现在串双球是纯收益零代价(`planStops()` 464 行只有上限,无成本)→ 不是决策,只是「能串就串」。加负重后「串几颗、在哪颗下线」成为计算题 |
|
||||||
|
| 引擎触点 | `RouteEngine.ts:115 segmentCost` + **3 处调用点**:`checkSegmentBlock:538`、`validateLevelDemo:675`、`PlayView.appendPoint:951`;另 `dispatchWarning:245` 的 `minTrips` 语义 |
|
||||||
|
| 成本 | 函数签名 + 3 处调用 + 1 个纯函数,**约 15–25 行**(不是 5 行,见 §10.3) |
|
||||||
|
| 验证判据 | 三处调用点计费结果逐段一致;`tryBacktrack` 回撤后 `costCum` 快照无偏移;60 关 `demo` 耗线变化清单 + 阈值重算后 CI 全绿 |
|
||||||
|
|
||||||
|
#### 候选 3 · 连绣绽放(消除连锁,去随机、去掉落)
|
||||||
|
|
||||||
|
| 项 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| 规则 | 同色针位按 motif 邻接(`petals` / 分组)成片绣好 → 触发绽放,返还部分线量;棋盘全公开、无随机,纯规划题 |
|
||||||
|
| 咬合点 | 现在「落针顺序」只有 `locks` 这一条作者写死的限制;连绣给顺序一个**正向回报** |
|
||||||
|
| 引擎触点 | `planStops()` 的 `markDelivery`(395 行)加邻接检测;`LevelDef.adjacency` 可在 `LEVELS` 构建时由 `targets` 坐标自动生成;返还结算进 `RunMetrics.yarn` |
|
||||||
|
| 成本 | 中低;渲染复用绣片绘制 |
|
||||||
|
| 验证判据 | 单关原型:返还开启/关闭两种情况下 `validateLevelDemo` 通关路径一致;60 关 `ScoreSpec.yarn3` 重算后无「过松」关卡 |
|
||||||
|
|
||||||
|
#### 候选 4 · 绣坊装裱(收纳 + 换装 + 经营)
|
||||||
|
|
||||||
|
| 项 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| 规则 | 绣品完成后进入装裱搭配(画框 × 丝线材质 × 印章 × 衬布),按主题契合度评分;装好的作品挂进绣坊墙面自由摆放 |
|
||||||
|
| 咬合点 | 表达断层与长期目标;对女性向核心用户命中率高 |
|
||||||
|
| 引擎触点 | 不碰 `RouteEngine`;`LobbyView` / `UiBuilder` / `exportArtwork()` / `StorageService` |
|
||||||
|
| 成本 | 中;UI + 数值为主,**但画框与衬布需 6–10 张小图 —— 本次讨论中美术成本最高,需先拍板预算** |
|
||||||
|
| 验证判据 | 装裱评分不影响星级与门控;任一装扮组合下 60 关 `cost` 不变 |
|
||||||
|
|
||||||
|
#### 候选 5 · 客人订单叙事
|
||||||
|
|
||||||
|
| 项 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| 规则 | 每关一位客人带一句话需求(「想要一幅送给母亲的向日葵」),通关/满星解锁回信 |
|
||||||
|
| 咬合点 | 不增加机制深度,给 60 关一条情绪曲线;治意义感 |
|
||||||
|
| 引擎触点 | 纯内容数据 `assets/resources/story/*.json` + 章节弹窗;**零引擎改动** |
|
||||||
|
| 成本 | 近乎零;复用现有火漆印章与亚麻弹框 |
|
||||||
|
| 验证判据 | 60 关文本齐备、中英双语、`recordId` 变更后不丢进度 |
|
||||||
|
|
||||||
|
### 10.3 代码级复核:两条被低估的代价
|
||||||
|
|
||||||
|
**① 负重耗线不是 5 行,且会动到全部 60 关阈值。**
|
||||||
|
|
||||||
|
`segmentCost()` 有 **3 个调用点**,且全部发生在 `planStops()` **之前**(`PlayView.appendPoint` 951 行计费、956 行才拾球)。因此:
|
||||||
|
|
||||||
|
- 必须给 `segmentCost()` 增加 `carryCount` 参数,3 处调用点同步传入同一个值,否则会出现「阻断判定按旧系数、实际累加按新系数」的 HUD 与判定不一致;
|
||||||
|
- 必须定义计费时序:**以段起点的 carry 数计费**(拾到球的这一段仍按旧系数,下一段起负重)。理由:`tryBacktrack()` 依赖 `costCum` 快照回撤(267–309 行),若松手时按最终球数回溯重算整条线,`costCum` 会全部失效,回撤手感直接崩;增量计费则零改动。
|
||||||
|
- 现有 `picks.length >= 2` 硬上限在 `planStops:464` 与 `checkSegmentBlock:500`,`EmbroideryRenderer:2056` 的 `followerCount` 也硬编码了「2 颗球 = 2 只工蚁」。**「串第 3 颗 +35%」隐含依赖「串三球」词条**,单独做候选 2 时只有 1→2 两档;加串三球时渲染层的编队数量也要改。
|
||||||
|
- **最关键**:现有关卡的 `demo` 全部按「串双球纯收益」设计,且 CI 把 `threeStar` 锁死在 `demoCost ~ demoCost+5%`、紧度最高 93.8%(预算余量仅 6%)。加 15% 负重会直接改变每一关的 `demo` 耗线,**可能让 `validateLevelDemo` 的 budget 校验失败、锯齿紧度曲线整体位移**。所以这条虽然代码少,但必须捆绑「`ScoreSpec` / `stars` / `TARGET_TIGHTNESS` 重算 + G8 基线回归豁免说明」,不能作为孤立的 5 行补丁上线。
|
||||||
|
|
||||||
|
**② 连绣返还的正确落点是评分轴,不是硬预算。**
|
||||||
|
|
||||||
|
候选 3 的风险判断(可能击穿星级阈值)是对的,但「返还只作用于下一笔」仍不够稳:`effectiveBudget()` 是 `checkSegmentBlock()` 的阻断依据,返还一旦进硬预算,就改变了关卡的可通行路径,60 关 `demo` 可能失效。
|
||||||
|
|
||||||
|
**更稳的裁定**:返还只计入 `RunMetrics.yarn`(软评分),**不进 `effectiveBudget()`(硬预算)**。这样——① 玩家仍能看到量尺回退、省线星点亮,正反馈保留;② 关卡可解路径完全不变;③ 阈值只需在 `ScoreSpec.yarn3` 上重算一次,不必逐关调 `budget`。代价是 HUD 必须诚实标注「返还仅计入用线评分」,否则「多出 20 线却画不出来」会有欺骗感。若坚持返还进硬预算,则需设「每笔 ≤ 40 线、全局 ≤ 120 线」双上限 + 求解器逐关重算,成本明显更高。
|
||||||
|
|
||||||
|
补充:`dispatchWarning()` 与 `audit-levels.mjs` 的 `minTrips` 都用 `ceil(count/2)`,假定「串双球总是最优」。负重后该公式仍只用于**笔数可行性**判断,不会算错,但语义从「限笔有余量 = 有容错」变成「限笔有余量 = 可以为了省线多跑一笔」——反而是好事,G6 覆盖率门禁无需修改。
|
||||||
|
|
||||||
|
### 10.4 命名冲突裁定(必须现在定,否则实现会打架)
|
||||||
|
|
||||||
|
用户侧「针法词条」与深度方案 P0 §2.2 的「针法系统」同名不同物:
|
||||||
|
|
||||||
|
| 名称 | 代码标识 | 含义 | 生效范围 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| 针法 / 线迹 | `StitchStyle` | 平针 / 回针 / 缎面 / 锁边;落笔前选,影响耗线倍率、线宽、折点权重、成品纹理 | 每笔 |
|
||||||
|
| **行囊词条** | `RunModifier` | 单局构筑卡;串三球、粗布免疫、翻绷、白球万能等,改变规则 | 整局 |
|
||||||
|
|
||||||
|
**裁定**:UI 文案可保留「针法卡」,但代码与文档统一改称「**行囊词条 / RunModifier**」,避免与 `StitchStyle` 冲突。§11 按此执行。
|
||||||
|
|
||||||
|
### 10.5 优先级裁定
|
||||||
|
|
||||||
|
| 序 | 条目 | 裁定 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 1 | **负重耗线** | 方向完全同意(性价比最高、直击「串双球是伪决策」)。但**必须与阈值重算打包**,不能当孤立 5 行补丁;先做单关原型量出 60 关耗线位移,再决定 15% 是否偏大 |
|
||||||
|
| 2 | **行囊词条** | 同意作为独立一期,排在 P0 三维星级 / A 档之后;它是唯一能把 60 关寿命乘上去、且几乎不花美术钱的机制。见 §11 |
|
||||||
|
| 3 | **连绣绽放** | 同意先做单关原型;按 §10.3 ② 改为「返还只进评分轴」,可把风险从「最危险」降到「可控」 |
|
||||||
|
| 4 | 绣坊装裱 | 同意先定美术预算再排期;可与 §3 A2「绣坊装扮」合并实现,避免两套装扮系统 |
|
||||||
|
| 5 | 客人订单叙事 | 同意顺手搭车;建议与 §3 A3「委托信」合并为一套内容,不单独立项 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 11. 深挖:绣娘行囊(`RunModifier`)完整规格
|
||||||
|
|
||||||
|
### 11.1 单局结构
|
||||||
|
|
||||||
|
| 项 | 设定 |
|
||||||
|
| --- | --- |
|
||||||
|
| 局长度 | 10 关,从已解锁关卡池按 seed 抽取;关卡布局**永远固定**,只有词条随机 |
|
||||||
|
| 选卡节奏 | 第 3 / 6 / 9 关后各从 3 张里选 1 张(一局 3 张,避免 build 过度膨胀) |
|
||||||
|
| 词条池 | 12–16 个,分三档(见 11.2) |
|
||||||
|
| 无失败 | 中途可随时「收工」并带走收获;没有死亡、没有重开惩罚 |
|
||||||
|
| 成绩 | 三轴(省线 / 笔数 / 针脚)结算,分享「种子码 + 成绩」;不动官方 60 关星数 |
|
||||||
|
| 经典模式 | 官方 60 关**永远无词条**,保住「关卡精心设计」的确定感 |
|
||||||
|
|
||||||
|
### 11.2 词条池(16 个,按风险分档)
|
||||||
|
|
||||||
|
> 表中 `evaluateRun()` / `computeRunMetrics()` / `RunMetrics` 为 P0 新增接口(深度方案 §2.5–§2.6),其余为 `v1.0.1` 现有函数;行号为当前基线代码位置。
|
||||||
|
|
||||||
|
| # | 词条 | 效果 | 引擎触点 | 档 |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| 1 | 熟线折扣 | 粗布区额外倍率减半(A 方案 `0.2→0.1` 占位,待确认) | `segmentCost()` | 数值 |
|
||||||
|
| 2 | 细针 | 全局耗线 `×0.94` | `segmentCost()` | 数值 |
|
||||||
|
| 3 | 粗布免疫 | `roughZones` 恒 1.0 | `segmentCost()` | 数值 |
|
||||||
|
| 4 | 线轴增益 | `spool.bonus ×1.5` | `collectedSpoolBonus()` | 数值 |
|
||||||
|
| 5 | 落针返还 | 每次 delivery 返还 20 线(**进 `RunMetrics.yarn`,不进硬预算**) | `evaluateRun()` | 数值 |
|
||||||
|
| 6 | 省线星放宽 | `ScoreSpec.yarn3 ×1.06` | `evaluateRun()` | 数值 |
|
||||||
|
| 7 | 针脚顺滑 | 加权折点 `×0.8` | `computeRunMetrics()` | 数值 |
|
||||||
|
| 8 | 串三球 | `picks` 上限 2→3 | `planStops:464`、`checkSegmentBlock:500`、渲染 `:2056` | 规则 |
|
||||||
|
| 9 | 翻绷 | 本局 1 次,整笔撤回并返还 80% 用线 | `PlayView.undoLastLine()`、`effectiveBudget()` | 规则 |
|
||||||
|
| 10 | 白球万能 | 白球可直接落任意色一针,绕过染缸 | `markDelivery()` 396 行 | 规则 |
|
||||||
|
| 11 | 染缸续杯 | 所有 `dye.uses +1` | `dyeRemainingUses()` | 规则 |
|
||||||
|
| 12 | 多一笔 | `maxDispatches +1` | `dispatchWarning()`、`validateLevelDemo()` | 规则 |
|
||||||
|
| 13 | 浮桥早搭 | 带 `bridgeSectionId` 的水洼开局即通行 | `isPondBridged()` | **绕过** |
|
||||||
|
| 14 | 锁匠 | 忽略一级 `locks` 前置(每局 2 次) | `isTargetLocked()` | **绕过** |
|
||||||
|
| 15 | 针门顺行 | 忽略 `gate.angle` 方向校验 | `checkSegmentBlock:506` | **绕过** |
|
||||||
|
| 16 | 纽扣免穿 | `buttons` 需求 -1 | `PlayView` 通关判定 1354 行 | **绕过** |
|
||||||
|
|
||||||
|
**分档的意义**:数值档只改系数,求解器容易验证;规则档改上限,需逐组合验证;**绕过档会直接把设计好的关卡机制变成摆设**,等于抵消关卡内容。裁定:绕过档**不进官方关卡池**,仅可在无尽绣坊后段(第 7 关起)出现,且必须由求解器按「带该词条的关卡」重新验证可解性(扩展门禁 G15)。
|
||||||
|
|
||||||
|
### 11.3 数据结构
|
||||||
|
|
||||||
|
```ts
|
||||||
|
export type ModifierId =
|
||||||
|
| 'yarnDiscount' | 'fineNeedle' | 'roughImmune' | 'spoolBoost'
|
||||||
|
| 'deliveryRefund' | 'yarnStarBoost' | 'smoothStitch'
|
||||||
|
| 'tripleCarry' | 'flipHoop' | 'whiteUniversal' | 'dyeRefill' | 'extraDispatch'
|
||||||
|
| 'bridgeEarly' | 'lockSmith' | 'gateFree' | 'buttonSkip';
|
||||||
|
|
||||||
|
export type ModifierTier = 'numeric' | 'rule' | 'bypass';
|
||||||
|
|
||||||
|
export interface RunModifier {
|
||||||
|
id: ModifierId;
|
||||||
|
tier: ModifierTier;
|
||||||
|
charges?: number; // 翻绷 / 锁匠的限次
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RunState {
|
||||||
|
seed: number;
|
||||||
|
depth: number; // 0..10
|
||||||
|
levelIds: string[];
|
||||||
|
modifiers: RunModifier[];
|
||||||
|
pendingChoices: ModifierId[];
|
||||||
|
metrics: RunMetrics; // 累计三轴
|
||||||
|
settled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RuleContext {
|
||||||
|
modifiers: RunModifier[]; // 透传给所有纯函数
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**引擎改造原则**:`segmentCost()` / `planStops()` / `checkSegmentBlock()` / `effectiveBudget()` / `evaluateRun()` / `isTargetLocked()` / `isPondBridged()` / `dyeRemainingUses()` 统一增加可选 `ctx?: RuleContext` 末位参数,**缺省时行为与 `v1.0.1` 逐字节一致**。禁止在引擎内读全局状态,保证可离线跑与可单测。
|
||||||
|
|
||||||
|
### 11.4 平衡与门禁
|
||||||
|
|
||||||
|
| 门禁 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| G18 | 任一合法词条组合(数值+规则档全组合抽样)下,10 关序列 `solveLevel()` 全部 `feasible` |
|
||||||
|
| G19 | 同一关在 ≥2 种不同构筑下,求解器给出的最优笔序签名不同(证明「最优策略随构筑变化」) |
|
||||||
|
| G20 | 不存在严格支配词条:每个词条在抽样序列中至少 1 次成为最优选择 |
|
||||||
|
| G21 | 绕过档词条只在 `depth ≥ 7` 出现,且对应关卡重算后 `solutionCount ≥ 1` |
|
||||||
|
| G22 | 经典模式(无词条)60 关 `cost` 与 `v1.0.1` 基线一致(与 G8 同源) |
|
||||||
|
|
||||||
|
### 11.5 验证判据(可勾选)
|
||||||
|
|
||||||
|
- [ ] 关掉全部词条时,`--quick` 7 项基线与 G8 全绿,60 关耗线零变化。
|
||||||
|
- [ ] 三选一 UI 复用 `ui_linen_modal` + `ui_wood_round`,新增美术资源为 0。
|
||||||
|
- [ ] 同一 seed 在 iOS / 微信小游戏 / H5 上生成完全相同的 10 关序列与 3 次候选卡。
|
||||||
|
- [ ] 「串三球」生效时,渲染层工蚁编队数量同步为 3,且 `dispatchWarning()` 的 `minTrips` 按 3 颗重新估算。
|
||||||
|
- [ ] 「翻绷」撤回后 `costCum` 与预算快照一致,不能出现可无限刷返还的循环。
|
||||||
|
- [ ] 收工后 `ant-embroidery-run-v1` 幂等写入,杀进程重进不重复发奖。
|
||||||
|
|
||||||
|
### 11.6 与既有方案的挂接
|
||||||
|
|
||||||
|
| 依赖 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| P0 三维星级(M1) | `RunState.metrics` 直接复用 `RunMetrics`;省线星放宽 / 针脚顺滑词条才有意义 |
|
||||||
|
| P0 针法(M1) | `StitchStyle` 与 `RunModifier` 分层,前者每笔、后者整局 |
|
||||||
|
| P1 求解器(M2) | G18–G21 全部依赖 `solveLevel()`;`generateDailyLevel()` 扩展为 `generateRun(seed, depth)` |
|
||||||
|
| P2 Loadout(M6) | 与 `Loadout` 合并为同一套 `RuleContext`,避免两套规则补丁 |
|
||||||
|
| §3 A2 绣坊装扮 | 行囊奖励只兑外观 / 故事,不兑数值,避免叠加成肝度 |
|
||||||
|
|
||||||
|
**排期建议**:M1 之后、M2 求解器稳定之前,只做「词条数据结构 + 三选一 UI + 数值档 7 个」的原型(不依赖求解器即可跑);规则档与绕过档等 G18–G21 上线后再开放。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 12. UI 承载量裁定(2026-11-25 实测反馈)
|
||||||
|
|
||||||
|
### 12.1 现象
|
||||||
|
|
||||||
|
A 档三项已实现并同时进入大厅顶部,实测反馈「感觉有点多了」。截图中可数出:**三个平级胶囊页签**(蚂蚁工坊 / 绣品展柜 / 委托信箱)+ 页签下方**第二排小标签**+ 委托信弹窗内**「特别番外 · 拆旧织新」3 个关卡按钮**+ 返回按钮。首屏可点击入口 ≥ 6 个。
|
||||||
|
|
||||||
|
### 12.2 判断:不是功能多,是入口层级与职责混装
|
||||||
|
|
||||||
|
| 问题 | 说明 |
|
||||||
|
| --- | --- |
|
||||||
|
| 三个都是「看」型功能 | 并列顶层会稀释「开始织画」这个唯一主行动;主界面本该只有一个动作 |
|
||||||
|
| 违反 §7 约束 | §7 写过「每批最多两个新入口」,三个同时上且每个都开顶层 tab,实测证明该条必须升级为硬规则 |
|
||||||
|
| 弹窗职责过载 | 委托信弹窗同时承担「叙事」与「选关」,变成半个选关界面 |
|
||||||
|
| 两套导航叠加 | 顶部 tab + 第二排小标签是视觉拥挤的直接来源 |
|
||||||
|
|
||||||
|
**结论:三个功能都留,一个都不删;只收层级、拆职责。** 已实现的文本、插画、展柜数据、工坊逻辑全部不作废。
|
||||||
|
|
||||||
|
### 12.3 收敛裁定
|
||||||
|
|
||||||
|
| 元素 | 现状 | 裁定 | 理由 | 改动面 |
|
||||||
|
| --- | --- | --- | --- | --- |
|
||||||
|
| 蚂蚁工坊 | 顶层 tab + 独立页 | **降级**为大厅角落动态挂件 + 红点,点一下直接收菜 | 放置类的最佳形态是「顺路看见」,不是「专程进去」;旅行青蛙主界面即内容 | `LobbyView` 加挂件,隐藏 tab |
|
||||||
|
| 绣品展柜 | 顶层 tab | **保留独立页**,收进统一「绣坊」入口作二级 | 唯一有回看 / 筛选 / 导出 / 装裱需求,值得一个页面 | 路由改一层 |
|
||||||
|
| 委托信箱 | 顶层 tab + 弹窗 | **取消顶层入口**;信件正文下沉到「关卡开始卡片」与通关页 | 叙事是「顺路读到」,不是「专程去点」;零成本项一旦常驻顶层就变贵 | 纯 UI 位置调整,文案资源不动 |
|
||||||
|
| 特别番外 3 关 | 委托信弹窗内 3 个按钮 | **移回关卡地图 / 章节丝签**;委托信只留一个「去绣这一幅」 | 选关与叙事职责分离 | 弹窗瘦身 |
|
||||||
|
| 第二排小标签 | 与顶部 tab 叠加 | **删除**,功能并入「绣坊」二级 | 两套导航叠加是拥挤主因 | 删一层 |
|
||||||
|
|
||||||
|
### 12.4 升级为硬规则(写入设计约定)
|
||||||
|
|
||||||
|
1. 大厅顶层导航**最多 2 个**(首页 / 绣坊);任何新功能先进「绣坊」二级,不许再开顶层 tab。
|
||||||
|
2. 主界面只能有**一个主行动按钮**(开始织画),其它入口视觉权重必须低于它。
|
||||||
|
3. 「看」型功能(工坊 / 展柜 / 图鉴 / 信件)合计只占 **1 个入口**;「玩」型功能(关卡 / 番外 / 每日)一律回关卡地图。
|
||||||
|
4. **一个弹窗只承担一个职责**,弹窗内不出现关卡选择列表。
|
||||||
|
5. §7「每批最多两个新入口」由建议升级为**发版前强制检查项**。
|
||||||
|
|
||||||
|
### 12.5 最小改动路径(不删功能、不重做美术)
|
||||||
|
|
||||||
|
1. 顶部三 tab 合成一个「绣坊」胶囊(复用现有胶囊样式,选中态默认落在展柜);
|
||||||
|
2. 工坊内容搬成大厅左下角小挂件 + 红点,收菜原地完成;
|
||||||
|
3. 委托信文本**一行不改**搬到关卡开始卡片与通关页;
|
||||||
|
4. 番外 3 关挂到章节丝签下,弹窗只留「去绣这一幅」;
|
||||||
|
5. 删掉第二排小标签。
|
||||||
|
|
||||||
|
**验收**:首屏可点击入口从 ≥ 6 降到 ≤ 2;「开始织画」仍是唯一最大按钮;三项功能全部可达、存档与进度零丢失;`--quick` 7 项门禁不受影响(纯 UI 改动)。
|
||||||
|
|
||||||
|
### 12.6 对 §7 推荐组合的修正
|
||||||
|
|
||||||
|
§7 的「最小可验证融合包 = A1 工坊 + A2 绣坊装扮 + P0 三维星级」在**功能维度**仍成立,但在**入口维度**需补一句:A1 与 A2 必须共用同一个「绣坊」入口,A2 的装扮与 A3 的展柜合并为同一页面。三个功能 ≠ 三个入口。
|
||||||
|
|
||||||
|
> **注**:本节回答的是「入口怎么摆」。用户实际追问的是「这三个功能有没有存在必要」,见 §13——按该标准复核后,§7 的推荐组合已被修正,§12 降级为过渡态方案。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 13. 功能必要性裁定(2026-11-25,修正 §7 / §12)
|
||||||
|
|
||||||
|
### 13.1 复核缘由
|
||||||
|
|
||||||
|
§12 把问题理解成 UI 承载量,答偏了。按用户原始诉求「游戏深度不够」与「删除测试」(假装删掉该功能,玩家究竟少什么)重新裁定。**§12 的 UI 收口结论仍然有效,但降级为过渡态方案**——即三项暂留时的最小承载方式,不再代表「三项都该做」。
|
||||||
|
|
||||||
|
### 13.2 删除测试
|
||||||
|
|
||||||
|
| 功能 | 删掉后玩家少什么 | 可否被替代 | 不可替代性 |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| **蚂蚁工坊** | 没有任何理由明天再打开游戏 | 无 | **高** |
|
||||||
|
| **绣品展柜** | 成品无处回看;但当前 60 张成品人人相同,仅星级数字不同,损失很小 | 海报导出可部分替代 | 低(当前)/ 高(成品差异化后) |
|
||||||
|
| **委托信箱** | 关卡少一句情绪文案;把文案移到关卡开始卡片即可补回 | 完全可替代 | 无 |
|
||||||
|
|
||||||
|
### 13.3 裁定
|
||||||
|
|
||||||
|
| 功能 | 裁定 | 理由 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| **蚂蚁工坊** | **留** | 三者中唯一在玩家**离线时**也产生变化的系统,制造回访理由;另两个都只在「玩家已经来了」之后才有用。题材上蚂蚁本就是主角,日记明信片有情感钩子。前提:8h 封顶、只兑外观、不做「错过就亏」的焦虑 |
|
||||||
|
| **绣品展柜** | **缓** | 价值完全依赖上游差异化:`P0 针法`(线迹不同)→ `P2 配色 / 题字` → 装裱。当前展示的是**无差异成品**,本质是仓库不是展柜。已做的数据与页面不废,但暂停加「装裱评分 / 墙面自由摆放」,等 M1 之后启用 |
|
||||||
|
| **委托信箱** | **降**(保留文字,砍掉系统) | 静态文本不响应玩家操作(绣得好坏、用什么针法、省多少线,信都不变);60 封读完即耗尽;不制造回访。一次性内容却被做成常驻系统 + 独立 tab + 回信档案 + 番外选关,**系统重量远超内容重量**。全部文案原样下沉到关卡开始卡片与通关页,取消信箱页面 |
|
||||||
|
|
||||||
|
### 13.4 修正 §7 推荐组合
|
||||||
|
|
||||||
|
| | 组合 |
|
||||||
|
| --- | --- |
|
||||||
|
| 原(§7) | A1 蚂蚁工坊 + A2 绣坊装扮 + P0 三维星级 |
|
||||||
|
| **修正后** | **P0 三维星级 + 负重耗线 + 蚂蚁工坊(轻量版)** |
|
||||||
|
|
||||||
|
理由:三项 A 档留存 / 表达件按「治深度不够」标准**都是 0 分**——它们补的是回访与意义,不增加一关内的决策。真正治病根的是核心规则层(三维星级让单轴变三轴、负重耗线让「串双球」从伪决策变成计算题)。三个留存件里只保留唯一不可替代的工坊;装扮 / 展柜 / 图鉴 / 长卷全部推到 M1 之后。
|
||||||
|
|
||||||
|
### 13.5 若必须砍,按此顺序
|
||||||
|
|
||||||
|
1. **先砍「信箱系统」**(文字全留)——零内容损失,省掉一整个页面、弹窗、回信档案与番外选关逻辑;
|
||||||
|
2. **再缓「展柜扩展」**(保留已有回看,停装裱与墙面)——等成品差异化后自然成立;
|
||||||
|
3. **工坊不砍,但保持轻量**——一个挂件 + 红点 + 原地收菜,不做独立页、不做日记图鉴。
|
||||||
|
|
||||||
|
### 13.6 验收
|
||||||
|
|
||||||
|
- 删除信箱系统后,60 关委托文本仍 100% 可见(在关卡开始卡片);
|
||||||
|
- 工坊离线产出不影响任一关 `evaluateRun()` 星级;
|
||||||
|
- 展柜暂停扩展期间,`--quick` 7 项门禁保持全绿;
|
||||||
|
- 三项功能若暂留,仍按 §12 合成一个「绣坊」入口。
|
||||||
@@ -0,0 +1,525 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to Funplay MCP for Cocos will be documented in this file.
|
||||||
|
|
||||||
|
This project follows a simple changelog format inspired by [Keep a Changelog](https://keepachangelog.com/), and uses semantic versioning when releases are tagged.
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.7.6] - 2026-11-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- One-click MCP setup for Pi 1.0+ writes the project-bound Streamable HTTP endpoint to `.pi/mcp.json`. Configure + Skills installs missing built-ins into the shared `.agents/skills` directory.
|
||||||
|
|
||||||
|
## [0.7.5] - 2026-11-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- One-click MCP setup for Google Antigravity writes the project-bound Streamable HTTP endpoint to `.agents/mcp_config.json`. Configure + Skills installs missing built-ins into `.agents/skills`, which Antigravity and Codex both discover.
|
||||||
|
|
||||||
|
## [0.7.4] - 2026-11-17
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#28](https://github.com/FunplayAI/funplay-cocos-mcp/issues/28): Game View screenshots recognize Windows-style and URL-encoded WebView preload paths. Game capture uses a visible native Game View or Cocos GameCanvas and reports an error when no game render surface is available.
|
||||||
|
|
||||||
|
## [0.7.3] - 2026-11-17
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- The built-in Cocos UI Skill v5 guides conversion from a full-page design image to an editable, responsive prefab. It covers asset reuse, separate navigation layers, reusable list rows, and region-by-region fidelity checks against captures from the Cocos preview. Image generation is optional when missing artwork needs to be recreated.
|
||||||
|
|
||||||
|
## [0.7.2] - 2026-11-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Configure + Skills, Project Skills, and MCP Skill tools now support Trae (`.trae/skills`), VS Code / Copilot (`.github/skills`), and Kiro (`.kiro/skills`), covering all 11 one-click clients with managed references, version checks, diffs, backups and restore.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Trae setup writes the active Cocos project's `.trae/mcp.json` instead of guessing a global file. Bilingual setup guidance remains visible in the dashboard and explains the required Project MCP switch.
|
||||||
|
- VS Code setup always uses its canonical user-profile path on macOS, honors Linux XDG and portable/appdata overrides, and preserves JSONC comments and unrelated configuration.
|
||||||
|
- Codex setup honors `CODEX_HOME` and accepts an empty `[mcp_servers]` parent table with explicit server children while retaining conservative rejection of inline/ambiguous TOML.
|
||||||
|
- OpenCode recognizes existing V2 `mcp.servers` and global timeout settings, retains compatible V1 flat entries, matches previews to the chosen layout, and refuses duplicate registrations across both maps.
|
||||||
|
- Strict JSON clients reject duplicate keys before writing. URL-only clients no longer confuse explicit SSE/stdio with HTTP; setup removes the obsolete transport while retaining custom options. Disabled and local-command registrations require review instead of falsely reporting a configured HTTP connection.
|
||||||
|
|
||||||
|
## [0.7.1] - 2026-11-09
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a bilingual Funplay > Contact & Feedback menu and dedicated panel with the author's email, QQ group `1108522331`, and copy buttons.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Serialized server start, stop, restart, and runtime configuration changes so overlapping requests cannot lose the owning listener or report a stopped server while its HTTP port remains open.
|
||||||
|
- Legacy-coordinate mouse clicks/drags and calibrated input with legacy timing now share owned release cleanup and uncertain-delivery reporting. Failed release retains the window lock; MCP stop/restart retries cleanup without replaying the press, and shutdown prevents suspended legacy gestures from sending more input.
|
||||||
|
- `refresh_assets` now requests `db://assets` instead of `db://assets/` when refreshing the assets root, avoiding Cocos Creator's missing-asset/meta errors. Contributed in [#27](https://github.com/FunplayAI/funplay-cocos-mcp/pull/27).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Corrected the README's built-in project Skills version from v3 to v4.
|
||||||
|
|
||||||
|
## [0.7.0] - 2026-10-29
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Project-scoped MCP URLs and explicit project/extension-session guards for mutating legacy-URL calls. Initialize, tool results and screenshot geometry carry structural identity evidence. Old URLs remain readable; writes require a verified `expected_context` pin. These checks prevent accidental misrouting, not unauthorized access.
|
||||||
|
- Opt-in `timing: "frame-paced"` for calibrated mouse drags: unscaled duration/holds, separate target-renderer animation frames, bounded receipts, retained request-key deduplication, same-tool status/cancel, stale/focus/pause checks and owned shutdown cleanup. Renderer frames are explicitly not native Game View Update evidence or gameplay acceptance. Legacy step timing remains the default.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- One-click setup generates project-bound URLs. The existing Skills notice also reports old endpoints and offers explicit combined reconfiguration; unreadable, unsupported, unverified and manually repointed entries remain protected, including custom headers/timeouts and historical shared entries. TOML updates retain the existing conservative URL-block editor, not a full-document TOML validator.
|
||||||
|
- Built-in workflow/UI Skills v4 add conditional identity/input guidance with managed reference updates, legacy-v3 recognition and protection for locally modified content. Core/Full tool counts and project settings are unchanged.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Frame-paced input recognizes native Game View child focus inside the captured foreground window, and a focus handoff after release no longer marks a finished drag as failed. Window focus loss while a button is held still interrupts input and attempts owned release cleanup.
|
||||||
|
|
||||||
|
## [0.6.10] - 2026-10-29
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#26](https://github.com/FunplayAI/funplay-cocos-mcp/issues/26): an unavailable configured Host (such as a stopped WSL network adapter) no longer prevents Cocos Creator from loading the extension. MCP stays stopped, the original startup error remains visible, and editor panels remain available for recovery. Explicit start/restart failures still report errors; no automatic Host substitution or startup config rewrite is performed.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added Server Host and Apply Host to the MCP Server panel. Address edits are validated before saving or stopping a healthy listener; applying a corrected Host retries startup when MCP is enabled. Environment-variable overrides are identified without changing their persisted project value. Bilingual guidance explains local-only access, trusted-network exposure, and client reconfiguration after an address change.
|
||||||
|
|
||||||
|
## [0.6.9] - 2026-10-27
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added DeepSeek Harness (DSH) support for [#25](https://github.com/FunplayAI/funplay-cocos-mcp/issues/25): generate a dedicated project-local Cordis overlay using the official Streamable HTTP MCP client. The dashboard displays an explicit `dsh web --patch` launch command; the overlay is not auto-loaded and existing global/profile YAML is never edited. Malformed, unrelated, disabled, or manually repointed entries remain protected, and owned endpoint updates are atomic.
|
||||||
|
- Configure + Skills, Project Skills, and MCP instruction/Skill tools now support DSH's nearest-Git-root `.dsh/skills` directory, including managed references, update notices, backups, and restore. Existing or locally edited Skills are preserved.
|
||||||
|
|
||||||
|
## [0.6.8] - 2026-10-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added CodeBuddy IDE 4.0+ to one-click MCP setup using the active Cocos project's `.mcp.json`, with comment-preserving JSONC updates and project-specific server names. Configure + Skills installs missing workflow/UI Skills under `.codebuddy/skills`; Project Skills and MCP instruction/Skill tools support the same client, including managed references, update notices, backups, and restore. Existing configuration and locally edited Skills remain protected.
|
||||||
|
|
||||||
|
## [0.6.7] - 2026-10-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#24](https://github.com/FunplayAI/funplay-cocos-mcp/issues/24): normal SSE GET probes no longer produce console warnings or fill the MCP runtime log. The server still returns HTTP 405 when SSE streams are unsupported, as required by Streamable HTTP; invalid Origin headers and unexpected HTTP methods retain their rejection warnings. POST tool calls, `/health`, `/tools`, and the console logging toggle are unchanged.
|
||||||
|
|
||||||
|
## [0.6.6] - 2026-10-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added read-only `check_asset_ready` in the Full profile: bounded native Asset Database queries confirm an exact asset's imported metadata and stable UUID/URL identity. Database readiness does not imply script compilation, an empty import queue, or runtime loading.
|
||||||
|
- Added screenshot calibration metadata, including `captureId`, actual PNG dimensions, viewport zoom/DPR, and crop origin. Mouse click/drag and preview input support opt-in `image-pixels` coordinates, bound to the captured window and project. Stale or changed geometry is rejected; interrupted input reports uncertain delivery and attempts to release a held button without replaying.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Upgraded both built-in project Skills to v3 with concise entrypoints and on-demand Cocos-specific references for readiness, layout, nine-slice/importer settings, fonts/localization, and input validation. Preserve project baselines; do not proactively add SafeArea containers, scripts, or inset adjustments.
|
||||||
|
- Project Skills version checks, diffs, backups, and restore now include managed reference files across all six supported clients, while preserving unrelated files and refusing to overwrite user-owned reference destinations.
|
||||||
|
- Screenshot MCP responses retain native image content and add calibration text/structured metadata without duplicating Base64 in structured results or Recent Activity. Legacy mouse coordinate semantics remain unchanged; explicit unavailable window targets no longer fall back to another window.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Game View screenshot cropping now prefers Creator's native preview WebView over text-matched toolbar elements, preserving the actual game render area and its calibrated input origin. Scene screenshots prefer the visible edit WebView; hidden, not-yet-ready, or ambiguous native viewport matches are rejected.
|
||||||
|
- Native mouse input now supplies screen coordinates and consistent pressed-button flags, allowing Creator's Game View to receive actual button clicks and the complete drag start/move/end chain without changing legacy coordinate semantics.
|
||||||
|
|
||||||
|
## [0.6.5] - 2026-10-07
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed stdio wrapper initialization with standard MCP clients by supporting newline-delimited UTF-8 JSON-RPC messages (NDJSON), while retaining the existing `Content-Length` framing. NDJSON responses are serialized on a single line. Contributed in [#23](https://github.com/FunplayAI/funplay-cocos-mcp/pull/23).
|
||||||
|
|
||||||
|
## [0.6.4] - 2026-09-19
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed Claude Code one-click configuration on Windows by writing forward-slash project scope paths and reusing existing scope keys regardless of drive-letter case. Contributed in [#22](https://github.com/FunplayAI/funplay-cocos-mcp/pull/22).
|
||||||
|
|
||||||
|
## [0.6.3] - 2026-09-12
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `Object.hasOwn is not a function` in older Cocos Creator editor runtimes (reported on 3.8.3), affecting Configure + Skills, JSONC configuration, and project prompts. Use compatible own-property checks while retaining duplicate-key validation and concurrent-edit protection. Contributed in [#21](https://github.com/FunplayAI/funplay-cocos-mcp/pull/21).
|
||||||
|
|
||||||
|
## [0.6.2] - 2026-09-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added OpenCode one-click MCP configuration and project-local Skills support (`.opencode/skills`), contributed in [#19](https://github.com/FunplayAI/funplay-cocos-mcp/pull/19).
|
||||||
|
- OpenCode configuration reads and updates JSON/JSONC with comments and trailing commas, preserves unrelated text and settings, and rejects malformed or duplicate-key configurations without overwriting them.
|
||||||
|
|
||||||
|
## [0.6.1] - 2026-09-10
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed Game View preview started through MCP leaving the native toolbar in a stopped or wrong-platform state, which disabled manual pause controls. Preview starts and mode changes now use the toolbar's own logic, repair legacy state mismatches, and verify the actual preview state.
|
||||||
|
- Routed `pause_runtime` and `resume_runtime` to the Game View preview controller instead of the edit-scene director. Repeated start/pause/resume calls are idempotent; stopped previews, rejected operations, busy or unavailable toolbars now report explicit errors.
|
||||||
|
- `get_runtime_state` and scene validation now report Game View running/paused state and toolbar synchronization. Edit-scene frame/time-scale counters remain in performance snapshots and are explicitly labeled to avoid confusing them with preview state.
|
||||||
|
|
||||||
|
## [0.6.0] - 2026-09-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added isolated per-script console capture for editor/scene execution and compatibility aliases. Logs survive failures and remain available when MCP console printing is disabled; optional execution metadata preserves existing tool return data.
|
||||||
|
- Added a project-persisted Print MCP logs toggle in Settings. It immediately controls extension and HTTP server console printing, including startup messages, while preserving Recent Activity, internal diagnostics, and live MCP connections.
|
||||||
|
- Added project-derived default ports and project-specific MCP entry names. Existing fixed-port configurations remain compatible; temporary fallback endpoints must be pinned before one-click configuration.
|
||||||
|
- Added per-client Project Skills installation, status, diff, backup, and restore for Codex, Claude Code, Cursor, Qoder, and Kimi Code. Codex now uses `.agents/skills`, with protected migration of legacy `.codex/skills` built-ins.
|
||||||
|
- Added parameterized project workflows from `mcp-prompts/*.md`, refreshed on list/get, with required-argument validation, bounded file discovery, and visible parse warnings.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Recent Activity now preserves result hierarchy, array items, and scalar values instead of selecting six flattened fields. Script cards separate summaries, execution logs, and return values; expandable branches survive refreshes, and large/sensitive results stay bounded and redacted.
|
||||||
|
- Redesigned MCP Server, Tool Exposure, Settings, and Project Skills with consistent headings, aligned controls, lightweight sections, and responsive layouts. Skills show only available actions with file/backup details collapsed; extension update controls are in Settings.
|
||||||
|
- Removed all Output sections and the standalone Activity/log-viewing window and menu, while retaining the dashboard's Recent Activity with bounded result previews. Clear removes only interaction history. Action notices preserve success/failure feedback; backend diagnostic tools and resources are unchanged.
|
||||||
|
- Added Configure + Skills for supported clients, installing only missing built-ins and preserving existing or locally modified copies, including when files change during setup.
|
||||||
|
- One-click configuration preserves other projects and manually repointed entries, checks for concurrent edits, and writes configuration atomically. Claude Code entries are scoped to the nearest Git root.
|
||||||
|
- Dashboard Skills notices now follow the selected supported client. Project Skills includes a client selector and explicit managed-directory paths.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#18](https://github.com/FunplayAI/funplay-cocos-mcp/issues/18): corrected the built-in UI Skill's UI system overview link to the working Cocos Creator 3.8 manual URL, while retaining valid component reference links. Upgraded the UI Skill template to v2 and preserved recognition of unmodified v1 installs as updateable, including those without managed metadata.
|
||||||
|
|
||||||
|
## [0.5.2] - 2026-09-03
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added one-click MCP client configuration for Qoder and Kimi Code, including their documented custom configuration-directory environment variables.
|
||||||
|
- Added a dashboard alert that names built-in project Skills that are not installed, have updates available, or contain local modifications, with a direct link to Project Skills management.
|
||||||
|
|
||||||
|
## [0.5.1] - 2026-08-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Normalize every cloned node produced by `create_prefab_from_node` to Cocos Creator's `UI_2D` layer (`33554432`) before serialization, while leaving the source scene hierarchy unchanged.
|
||||||
|
- Reject generated Prefab content whose serialized `cc.Node._layer` values do not match `UI_2D` before writing the asset.
|
||||||
|
|
||||||
|
## [0.5.0] - 2026-08-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a dedicated **Project Skills** panel for listing project-local Codex skills, independently installing and updating both built-in Funplay skills, previewing template differences, backing up updates, restoring the latest backup, and creating custom skills.
|
||||||
|
- Added the built-in `funplay-cocos-ui-composition` Skill for Cocos-native responsive UI work across `UITransform`, `Widget`, `SafeArea`, `Layout`, scrolling, text, input, animation, prefabs, and performance validation.
|
||||||
|
- Added managed per-Skill template version/hash metadata so MCP upgrades can report built-in Skill updates without silently replacing local changes.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Generate project Skills with standard `SKILL.md` YAML frontmatter containing `name` and `description`.
|
||||||
|
- Expanded `funplay-cocos-mcp-workflow` from a short checklist into a complete inspect/edit/readback/diagnostics/preview workflow adapted from the proven Funplay Unity MCP Skill structure.
|
||||||
|
- Preserve existing UI and gameplay-object Prefabs by default, editing only necessary nodes/components unless a full rebuild is explicitly requested.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#17](https://github.com/FunplayAI/funplay-cocos-mcp/issues/17): `create_prefab_from_node` now assigns unique `cc.PrefabInfo` and `cc.CompPrefabInfo` metadata before serialization and rejects incomplete output, allowing generated Prefabs to open in Cocos Creator's Prefab editor.
|
||||||
|
|
||||||
|
## [0.4.7] - 2026-08-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a checksum-verified **Install for All Projects** workflow that installs the latest release into the active Cocos Creator version's managed global extension directory, asks Creator to scan and register it without replacing a running project copy, detects conflicts, and makes it automatically available to projects opened with that Creator version.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Targeted Cocos Creator 3.8's version-scoped `builtin-extensions/<version>` directory instead of the legacy user extension path.
|
||||||
|
- Kept the active project copy running after global registration so MCP Settings can report the installed global version and duplicate-copy guidance without being unloaded mid-install.
|
||||||
|
|
||||||
|
## [0.4.6] - 2026-07-30
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#6](https://github.com/FunplayAI/funplay-cocos-mcp/issues/6): browser preview results now default `url` and `localUrl` to a same-host loopback address while preserving Cocos Creator's reported LAN address in `networkUrl` and `reportedUrl`.
|
||||||
|
|
||||||
|
## [0.4.5] - 2026-07-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#5](https://github.com/FunplayAI/funplay-cocos-mcp/issues/5): create and verify genuinely linked Prefab instances, include the required `cc.Prefab` node type, and clean up nodes that fail post-creation linkage checks.
|
||||||
|
|
||||||
|
## [0.4.4] - 2026-07-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added English and Chinese localization for extension menus, panel titles, controls, status messages, prompts, and empty states.
|
||||||
|
- Added a project-level language setting with `Auto / 跟随 Cocos Creator`, `中文`, and `English` options.
|
||||||
|
- Added Chinese descriptions and localized profile labels for all 105 tools shown in the Tool Exposure window while preserving MCP tool IDs and schemas in English.
|
||||||
|
|
||||||
|
### Optimized
|
||||||
|
|
||||||
|
- Kept the four focused management windows on one shared localization layer so language changes remain consistent across dashboard, tool exposure, settings, and activity workflows.
|
||||||
|
- Prevented interface-only configuration changes, including language selection, from rebuilding MCP runtime state or clearing activity logs.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed 12-hour timestamps such as `11:37:12 PM` overlapping tool names in the Activity window.
|
||||||
|
|
||||||
|
## [0.4.3] - 2026-07-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `get_preview_mode` and `set_preview_mode` with explicit `browser`, `gameView`, and `simulator` semantics.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Reworked `run_project_preview` to use the Cocos Creator 3.8.x preview APIs, return the effective mode and browser preview URL, and retain `platform` as a deprecated alias for `mode`.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed [#3](https://github.com/FunplayAI/funplay-cocos-mcp/issues/3): restored preview launch on Cocos Creator 3.8.8 by replacing the nonexistent `preview.start`, `preview.open-preview`, and `builder.preview` messages.
|
||||||
|
|
||||||
|
## [0.4.2] - 2026-07-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `create_scene` to the default `core` profile for creating an empty scene or copying the active scene directly to an assets path without an interactive save dialog.
|
||||||
|
|
||||||
|
### Optimized
|
||||||
|
|
||||||
|
- Expanded the default `core` profile to 38 tools and the `full` profile to 103 tools, with synchronized English, Chinese, and generated tool documentation.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed `run_script_diagnostics` returning `spawn EINVAL` on Windows by running the TypeScript compiler script through Node instead of launching `tsc.cmd` directly.
|
||||||
|
- Fixed TypeScript diagnostics inside Cocos Creator incorrectly treating the Creator executable as a normal Node runtime, which could report a false successful result without running `tsc`.
|
||||||
|
|
||||||
|
## [0.4.1] - 2026-07-02
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `create_prefab_from_node`, a Cocos Creator 3.8.x-friendly prefab creation tool that serializes a scene node in the scene process and persists the prefab through asset-db instead of relying on the brittle `scene:create-prefab` message.
|
||||||
|
- Added automatic release checks and panel actions for opening the latest GitHub Release or installing a verified update package.
|
||||||
|
- Added a checksum-verified one-click updater that downloads the release zip, verifies `SHA256SUMS.txt`, backs up the current extension, replaces package files, and reloads the extension when the Cocos package API supports it.
|
||||||
|
- Added focused Cocos panel windows for Tool Exposure, MCP Settings, and Activity & Logs, with the main MCP Server panel reduced to a dashboard-style workflow.
|
||||||
|
- Added a Unity MCP-style Tool Exposure window with grouped tool lists, per-tool toggles, category select/clear actions, and a single-card Recent Activity stream with status badges.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Treat undefined editor message responses as inconclusive for prefab creation and verify the resulting prefab file/asset before reporting success.
|
||||||
|
- Refuse one-click updates for symlink or git-worktree extension installs so local development checkouts are not overwritten accidentally.
|
||||||
|
|
||||||
|
## [0.4.0] - 2026-06-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added project identity metadata to `/health` and MCP `initialize` responses so clients and duplicate listeners can verify the active Cocos project safely.
|
||||||
|
- Added same-project listener attach behavior before port fallback, preventing accidental attachment to a different Cocos project on the same port.
|
||||||
|
- Added default-on JavaScript safety checks for `execute_javascript`, `execute_scene_script`, and `execute_editor_script`, with per-call `safety_checks` overrides.
|
||||||
|
- Added named tool profiles in the Cocos panel, including save, apply, delete, import, and export workflows.
|
||||||
|
- Added category-level tool exposure controls in the panel for quick enable, disable, and clear actions.
|
||||||
|
- Added asset dependency tools: `inspect_asset_dependencies` and `validate_asset_dependencies`.
|
||||||
|
- Added Cocos project/editor tools: `get_build_status`, `open_build_panel`, `run_project_preview`, `save_current_scene`, `get_editor_preference`, `set_editor_preference`, and `broadcast_editor_message`.
|
||||||
|
- Added Button event binding tools: `list_button_click_events` and `bind_button_click_event`.
|
||||||
|
- Added `create_cocos_mcp_project_skill` for generating a recommended local Codex workflow skill.
|
||||||
|
- Added release package sensitive-content scanning for npm/GitHub/MCP token-like values and private keys.
|
||||||
|
|
||||||
|
### Optimized
|
||||||
|
|
||||||
|
- Improved tool exposure UX for larger projects by making custom profiles reusable and shareable.
|
||||||
|
- Expanded generated tool documentation and README coverage for the new 37-tool `core` profile and 101-tool `full` profile.
|
||||||
|
- Improved release packaging confidence with checksum verification and content scanning.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Expanded the default `core` profile from 34 tools to 37 tools.
|
||||||
|
- Expanded the `full` profile from 89 tools to 101 tools.
|
||||||
|
- Split more tool implementations into focused modules under `lib/tools/`, including advanced assets, Cocos project/editor helpers, and scene event helpers.
|
||||||
|
- Persisted `executeJavascriptSafetyChecks`, active tool profile names, and saved tool profiles in project configuration.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the GitHub Release workflow so release pages use generated English changelog-style `RELEASE_NOTES.md` instead of the artifact installation README.
|
||||||
|
- Fixed release package scanning false positives around normal MCP server config names while preserving credential detection.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
- Added guardrails for JavaScript execution against obvious risky file-system and shell patterns, including delete/truncate calls, raw writable streams, path traversal, user/system absolute paths, and `child_process`.
|
||||||
|
|
||||||
|
## [0.3.3] - 2026-05-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added generated tool reference documentation in `docs/TOOLS.md`.
|
||||||
|
- Added `docs:generate` and `docs:check` scripts to keep tool counts, profiles, categories, and descriptions synchronized with `lib/tool-registry.js`.
|
||||||
|
- Added a read-only `GET /tools` debug endpoint with curl examples for quick local troubleshooting.
|
||||||
|
- Added panel activity previews for recent tool calls and runtime logs.
|
||||||
|
- Added panel curl copy actions for `/health` and `/tools`.
|
||||||
|
|
||||||
|
### Optimized
|
||||||
|
|
||||||
|
- Added CI and release validation for generated tool documentation.
|
||||||
|
- Improved the MCP client config panel so the preview follows the selected client target.
|
||||||
|
- Improved the panel information architecture around troubleshooting and maintenance: version, update status, tool profile, client config, recent calls, and logs.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Refined tool category inference so `get_tool_catalog` is grouped with project/context tools.
|
||||||
|
- Split file-system tools and asset refresh helpers into `lib/tools/files.js` as the first registry modularization step.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- No runtime bug fixes in this release; this release focuses on product polish, debugging ergonomics, and maintainability.
|
||||||
|
|
||||||
|
## [0.3.2] - 2026-05-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added an npm-installable `funplay-cocos-mcp` stdio wrapper that bridges MCP clients to the local Cocos HTTP endpoint.
|
||||||
|
- Added MCP Registry metadata in `server.json`, including npm package ownership metadata via `mcpName`.
|
||||||
|
- Added wrapper tests, npm pack dry-run verification, and registry validation scripts.
|
||||||
|
|
||||||
|
## [0.3.1] - 2026-05-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a documented release workflow and release checklist for Cocos extension publishing.
|
||||||
|
- Added release packaging scripts that generate a Cocos extension zip, release manifest, checksum file, and per-release README.
|
||||||
|
- Added CI validation for release metadata.
|
||||||
|
|
||||||
|
## [0.3.0] - 2026-05-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added MCP `outputSchema` and `annotations` to listed tools.
|
||||||
|
- Added a standard structured tool result envelope with `ok`, `tool`, `callId`, `summary`, `data`, and follow-up `refs`.
|
||||||
|
- Added prefab workflow tools: `inspect_prefab`, `validate_prefab_references`, `duplicate_prefab`, `edit_prefab_json`, `create_prefab_instance`, `inspect_prefab_instance`, `apply_prefab_instance`, and `revert_prefab_instance`.
|
||||||
|
- Added `get_performance_snapshot` and expanded `validate_scene` with scene scale/performance-oriented counters.
|
||||||
|
- Added project AI instruction tools: `list_project_instructions`, `read_project_instruction`, `write_project_instruction`, and `create_project_skill`.
|
||||||
|
- Added tests for tool metadata, result envelopes, and project instruction helpers.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Expanded the default `core` profile from 28 tools to 34 tools.
|
||||||
|
- Expanded the `full` profile from 76 tools to 89 tools.
|
||||||
|
- Updated tool interaction logs to store concise result summaries from the standard envelope.
|
||||||
|
|
||||||
|
## [0.2.0] - 2026-05-20
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a panel and tool-level update checker for comparing the installed extension version with the latest GitHub release.
|
||||||
|
- Added `custom` tool exposure with per-category and per-tool include/exclude configuration.
|
||||||
|
- Added `get_tool_catalog`, `check_for_updates`, `get_recent_logs`, `search_project_logs`, `clear_logs`, and `validate_scene`.
|
||||||
|
- Added MCP log resources: `cocos://logs/editor` and `cocos://logs/project`.
|
||||||
|
- Added in-memory runtime logs alongside the existing MCP interaction history.
|
||||||
|
- Added optional Streamable HTTP session support via `enableSessions` and `Mcp-Session-Id`.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Expanded the default `core` profile from 22 tools to 28 tools.
|
||||||
|
- Expanded the `full` profile from 70 tools to 76 tools.
|
||||||
|
- Updated the Cocos panel to show installed version, update status, session toggle, and tool exposure controls.
|
||||||
|
- Tightened Streamable HTTP behavior for `Accept` headers, JSON-RPC notifications/responses, `202 Accepted`, unsupported GET/SSE requests, and DELETE session termination.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Improved project log tailing so trailing blank lines do not hide the last useful log entries.
|
||||||
|
|
||||||
|
## [0.1.4] - 2026-05-11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed CI test expectations after expanding the documented `core` and `full` tool profiles.
|
||||||
|
- Aligned the latest release line with the current tested `main` branch state.
|
||||||
|
|
||||||
|
## [0.1.3] - 2026-05-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added `get_editor_state` as a compact structured editor-state summary tool.
|
||||||
|
- Added `get_selection` and `set_selection` as explicit selection workflow tools for editor-side automation.
|
||||||
|
- Added persistence for the selected one-click MCP client target in the Cocos panel configuration.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Expanded the default `core` profile from 19 tools to 22 tools by promoting editor-state and selection workflows.
|
||||||
|
- Expanded the `full` profile from 67 tools to 70 tools.
|
||||||
|
- Updated panel config persistence so changing the selected MCP client target no longer restarts the server unnecessarily.
|
||||||
|
|
||||||
|
## [0.1.2] - 2026-04-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added Node.js unit tests for MCP protocol negotiation, tool profile exports, tool execution errors, and project file path safety.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated the MCP initialize response to negotiate protocol version `2025-11-25` by default while retaining compatibility with older supported protocol versions.
|
||||||
|
- Added `structuredContent` to tool call results when a tool returns structured JSON data.
|
||||||
|
- Changed tool execution failures to return MCP tool errors instead of JSON-RPC internal errors, improving client-side self-correction.
|
||||||
|
- Updated CI to run the new Node.js test suite.
|
||||||
|
|
||||||
|
### Security
|
||||||
|
|
||||||
|
- Restricted project file and asset-path resources to paths inside the active Cocos project root.
|
||||||
|
- Added HTTP request body size limits and invalid `Origin` header rejection for the embedded MCP server.
|
||||||
|
|
||||||
|
## [0.1.1] - 2026-04-16
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added automatic port fallback when the configured MCP port is already occupied.
|
||||||
|
- Added actual-running-port reporting in MCP server status and panel state.
|
||||||
|
- Added `.github/pull_request_template.md` for repository contribution guidance.
|
||||||
|
- Added `.github/workflows/ci.yml` for lightweight GitHub validation.
|
||||||
|
- Added a lightweight GitHub Star promotion log after successful MCP server startup.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Updated one-click MCP client configuration to write the actual running server port instead of the requested port when port fallback is active.
|
||||||
|
- Updated the MCP panel status line to show configured-port to actual-port fallback information.
|
||||||
|
- Updated the English and Chinese README files to document automatic port fallback behavior.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed VS Code one-click configuration to use platform-specific config paths with macOS fallback behavior.
|
||||||
|
- Fixed Windows one-click MCP configuration path resolution by using a more reliable home/appdata lookup strategy.
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-04-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Embedded HTTP MCP server inside a Cocos Creator extension.
|
||||||
|
- `Funplay > MCP Server` editor panel for service management and one-click MCP client configuration.
|
||||||
|
- One-click configuration support for Claude Code / Claude Desktop, Cursor, VS Code, Trae, Kiro, and Codex.
|
||||||
|
- Primary unified tool: `execute_javascript`.
|
||||||
|
- `context: "scene"` for active scene/runtime automation.
|
||||||
|
- `context: "editor"` for Cocos editor/browser automation.
|
||||||
|
- Compatibility execution tools:
|
||||||
|
- `execute_scene_script`
|
||||||
|
- `execute_editor_script`
|
||||||
|
- MCP protocol capabilities:
|
||||||
|
- `initialize`
|
||||||
|
- `tools/list`
|
||||||
|
- `tools/call`
|
||||||
|
- `resources/list`
|
||||||
|
- `resources/read`
|
||||||
|
- `resources/templates/list`
|
||||||
|
- `prompts/list`
|
||||||
|
- `prompts/get`
|
||||||
|
- `core` tool profile with 19 high-signal tools.
|
||||||
|
- `full` tool profile with 67 tools.
|
||||||
|
- Scene and hierarchy inspection tools.
|
||||||
|
- Node, component, UI, camera, animation, prefab, and asset tools.
|
||||||
|
- File read/write/search tools and asset refresh helpers.
|
||||||
|
- TypeScript diagnostic tools for Cocos projects.
|
||||||
|
- Runtime state and time-scale control tools.
|
||||||
|
- Button, node event, component method, mouse, keyboard, and preview input simulation tools.
|
||||||
|
- Desktop, editor, scene, game, and preview screenshot tools.
|
||||||
|
- MCP resources for project context, scene state, selection, script errors, and interaction history.
|
||||||
|
- MCP prompts for script repair, playable prototype creation, scene validation, and scene auto-wiring.
|
||||||
|
- Debug logs for server lifecycle events.
|
||||||
|
- English and Chinese README files.
|
||||||
|
- MIT license file.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Promoted `execute_javascript` as the recommended primary tool across tool descriptions, prompts, and documentation.
|
||||||
|
- Simplified the Cocos panel to focus on service management and MCP client configuration.
|
||||||
|
- Changed the menu entry to `Funplay > MCP Server`.
|
||||||
|
- Slimmed the default `core` profile from 50 tools to 19 high-signal tools centered on project understanding, diagnostics, and visual validation.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed panel initialization issues caused by unsafe DOM querying.
|
||||||
|
- Fixed relative-path handling for asset open/select workflows.
|
||||||
|
- Fixed bundled Cocos TypeScript diagnostic lookup.
|
||||||
|
- Improved scene/game screenshot targeting with panel-level cropping when available.
|
||||||
|
- Improved low-level mouse drag coordinates for panel-relative input injection.
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
# Contributing to Funplay MCP for Cocos
|
||||||
|
|
||||||
|
Thanks for your interest in contributing to Funplay MCP for Cocos.
|
||||||
|
|
||||||
|
This repository is a Cocos Creator editor extension that embeds an MCP server. Contributions that improve reliability, editor compatibility, documentation, and AI-driven Cocos workflows are welcome.
|
||||||
|
|
||||||
|
## Development Setup
|
||||||
|
|
||||||
|
1. Clone the repository:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/FunplayAI/funplay-cocos-mcp.git
|
||||||
|
cd funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Install it into a Cocos project as an extension:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p /path/to/your-cocos-project/extensions
|
||||||
|
ln -s "$PWD" /path/to/your-cocos-project/extensions/funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also copy the repository folder instead of using a symlink.
|
||||||
|
|
||||||
|
3. Restart Cocos Creator or reload extensions.
|
||||||
|
|
||||||
|
4. Open the panel:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Funplay > MCP Server
|
||||||
|
```
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
Before opening a pull request, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run check
|
||||||
|
```
|
||||||
|
|
||||||
|
This validates the JavaScript syntax for the extension entry points and helper modules.
|
||||||
|
|
||||||
|
If your change affects live MCP behavior, also test against a running Cocos project:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -sS http://127.0.0.1:8765/health
|
||||||
|
```
|
||||||
|
|
||||||
|
If you use a custom port, replace `8765` with your configured port.
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```text
|
||||||
|
browser.js Cocos browser/editor extension entry and service lifecycle
|
||||||
|
scene.js Scene-side execution bridge and scene tool implementations
|
||||||
|
panel/index.js Minimal MCP Server panel UI
|
||||||
|
lib/server.js HTTP JSON-RPC MCP server
|
||||||
|
lib/tool-registry.js Tool definitions and handlers
|
||||||
|
lib/resources.js MCP resources
|
||||||
|
lib/prompts.js MCP prompts
|
||||||
|
lib/client-config.js One-click MCP client configuration
|
||||||
|
lib/assets.js Asset database helpers
|
||||||
|
lib/diagnostics.js TypeScript diagnostics
|
||||||
|
lib/input.js Electron input simulation
|
||||||
|
lib/screenshots.js Screenshot helpers
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contribution Guidelines
|
||||||
|
|
||||||
|
- Keep the `core` profile focused. Avoid adding noisy tools to `core` unless they are broadly useful for AI clients.
|
||||||
|
- Prefer improving `execute_javascript` workflows when one flexible tool is better than many narrow tools.
|
||||||
|
- Add tools to `full` when they are useful but not essential for the default AI workflow.
|
||||||
|
- Keep the Cocos panel simple. The main panel should focus on service management and MCP client configuration.
|
||||||
|
- Avoid adding runtime dependencies to built games; this extension should remain editor-only.
|
||||||
|
- Keep changes small and focused.
|
||||||
|
- Update `README.md`, `README_CN.md`, or `CHANGELOG.md` when behavior changes.
|
||||||
|
- Do not commit generated Cocos folders such as `library/`, `temp/`, or build output.
|
||||||
|
|
||||||
|
## Tool Design Notes
|
||||||
|
|
||||||
|
When adding a new tool:
|
||||||
|
|
||||||
|
1. Add the tool definition in `lib/tool-registry.js`.
|
||||||
|
2. Use `profile: "core"` only for high-signal tools.
|
||||||
|
3. Put scene/runtime work behind `sceneBridge.call(...)` when it must run in the active Cocos scene.
|
||||||
|
4. Use editor-side helpers for asset-db, filesystem, and panel/client configuration workflows.
|
||||||
|
5. Return JSON-serializable data where possible.
|
||||||
|
6. Add clear input schema descriptions so AI clients can choose the tool correctly.
|
||||||
|
7. Test the tool with `tools/list` and `tools/call`.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
The documentation is bilingual:
|
||||||
|
|
||||||
|
- `README.md` for English
|
||||||
|
- `README_CN.md` for Chinese
|
||||||
|
|
||||||
|
When adding user-facing behavior, update both files when possible.
|
||||||
|
|
||||||
|
## Pull Requests
|
||||||
|
|
||||||
|
A good pull request should include:
|
||||||
|
|
||||||
|
- A clear summary of the change
|
||||||
|
- What Cocos Creator version was tested
|
||||||
|
- Whether the MCP server was tested through an AI client or direct HTTP calls
|
||||||
|
- Any screenshots if the change affects the panel or visual scene output
|
||||||
|
- Notes about compatibility or limitations
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing, you agree that your contributions will be licensed under the MIT License used by this repository.
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Funplay
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,709 @@
|
|||||||
|
<p align="center">
|
||||||
|
<h1 align="center">Funplay MCP for Cocos</h1>
|
||||||
|
<p align="center">
|
||||||
|
<strong>An Embedded MCP Server for Cocos Creator Editor</strong>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/Cocos%20Creator-3.8%2B-blue" alt="Cocos Creator 3.8+"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/MCP-Compatible-green" alt="MCP Compatible"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/Platform-Editor%20Only-orange" alt="Editor Only"></a>
|
||||||
|
<a href="https://store.cocos.com/app/detail/8913"><img src="https://img.shields.io/badge/Cocos%20Store-Install-brightgreen" alt="Install from Cocos Store"></a>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="./README_CN.md">中文</a> | English
|
||||||
|
</p>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> If this project helps your Cocos workflow, please consider giving it a Star. It helps more developers discover the project and supports ongoing development.
|
||||||
|
|
||||||
|
For discussion and feedback, join our QQ group: **1108522331**. Open **Funplay > Contact & Feedback** to find the author's email and copy either contact detail.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Funplay MCP for Cocos is an MIT-licensed Cocos Creator extension that embeds an HTTP MCP server directly inside the editor. It lets AI assistants such as Claude Code, Cursor, Codex, VS Code Copilot, Trae, Antigravity, Pi, Kiro, Qoder, Kimi Code, OpenCode, CodeBuddy, and DeepSeek Harness (DSH) inspect and operate your running Cocos project.
|
||||||
|
|
||||||
|
The package follows the same product direction as Funplay MCP for Unity: keep the default tool surface focused, provide a one-click client configuration window, and make one high-flexibility execution tool the primary workflow.
|
||||||
|
|
||||||
|
For Cocos, the primary tool is `execute_javascript`:
|
||||||
|
|
||||||
|
- `context: "scene"` runs JavaScript in the active Cocos scene/runtime context
|
||||||
|
- `context: "editor"` runs JavaScript in the Cocos editor/browser context
|
||||||
|
|
||||||
|
> *"Create a login page UI with account/password fields and a main login button."*
|
||||||
|
>
|
||||||
|
> Your AI assistant can call `execute_javascript`, build the UI hierarchy under the active Canvas, attach Cocos components, inspect the result, and capture a screenshot for validation.
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
If you just want to connect quickly, do these three things:
|
||||||
|
|
||||||
|
- Install this repository as a Cocos Creator extension
|
||||||
|
- Open `Funplay > MCP Server`
|
||||||
|
- Use the built-in one-click MCP client configuration
|
||||||
|
|
||||||
|
### 1. Install as a Cocos Creator Extension
|
||||||
|
|
||||||
|
Recommended install: use the official [Cocos Store page](https://store.cocos.com/app/detail/8913) and install the extension into your target Cocos Creator project.
|
||||||
|
|
||||||
|
For local development or unreleased builds, clone or copy this repository into your Cocos project extension directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/your-cocos-project
|
||||||
|
mkdir -p extensions
|
||||||
|
git clone https://github.com/FunplayAI/funplay-cocos-mcp.git extensions/funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
Then restart Cocos Creator or reload extensions from the editor.
|
||||||
|
|
||||||
|
For a non-git install, download `Funplay.CocosMcp.v<version>.zip` from the GitHub Releases page, unzip it, and move the extracted `funplay-cocos-mcp` folder into your project `extensions/` directory.
|
||||||
|
|
||||||
|
#### Install for All Projects (Recommended)
|
||||||
|
|
||||||
|
Install and open the extension in any project first. Then open `Funplay > MCP Settings` and click **Install for All Projects** in the All Projects section. The extension downloads the latest GitHub Release, verifies `SHA256SUMS.txt`, and installs it into the active Cocos Creator version's managed global extension directory:
|
||||||
|
|
||||||
|
- macOS / Linux: `~/.CocosCreator/builtin-extensions/<Creator version>/funplay-cocos-mcp`
|
||||||
|
- Windows: `%USERPROFILE%\.CocosCreator\builtin-extensions\<Creator version>\funplay-cocos-mcp`
|
||||||
|
|
||||||
|
Cocos Creator scans and registers the installed copy immediately. Projects opened or created with that Creator version then load it automatically, and the MCP server keeps its default autostart behavior. Reopen an already-running project if its project-level copy has priority. No extension files are copied into each project's `extensions/` directory.
|
||||||
|
|
||||||
|
Global extensions are isolated by Cocos Creator version. If you use multiple Creator versions, run **Install for All Projects** once from each version.
|
||||||
|
|
||||||
|
The installer does not delete the current project copy, which protects development worktrees. If both copies exist, MCP Settings shows a duplicate-install warning. After confirming that the global copy works, remove or disable the project copy to avoid extension conflicts.
|
||||||
|
|
||||||
|
### 2. Start the MCP Server
|
||||||
|
|
||||||
|
Open the editor menu:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Funplay > MCP Server
|
||||||
|
```
|
||||||
|
|
||||||
|
New projects get a stable project-derived port in `20000–29999`. Existing saved configurations keep their fixed port (including `8765`). Use the exact URL shown in MCP Server; if a temporary fallback port is active, click **Pin Current Port** or **Use Per-Project Port** before configuring a client.
|
||||||
|
|
||||||
|
If the configured port is already occupied, the extension first checks whether the existing listener belongs to the same Cocos project. Same-project listeners are reused safely; unrelated listeners trigger automatic fallback to the next available local port.
|
||||||
|
|
||||||
|
The panel is intentionally small:
|
||||||
|
|
||||||
|
- Enable or disable the MCP server
|
||||||
|
- Open focused Tool Exposure, MCP Settings, and Project Skills windows
|
||||||
|
- Automatically check the installed version against the latest GitHub release
|
||||||
|
- Open the release page or install verified release packages from the panel
|
||||||
|
- Install once in the Cocos Creator global extensions directory so existing and new projects can use it automatically
|
||||||
|
- Configure AI clients with one click and preview the selected client config
|
||||||
|
- Keep advanced tool profile editing, transport settings, and installation management out of the main server window
|
||||||
|
- Follow the Cocos Creator interface language automatically, or select Chinese/English per project in MCP Settings
|
||||||
|
- Toggle **Print MCP logs** in Settings to silence MCP console messages without losing Recent Activity or internal diagnostics
|
||||||
|
|
||||||
|
All management pages use consistent headings, aligned controls, and lightweight sections. Tool Exposure groups per-tool toggles by category; Project Skills highlights available actions and folds away file paths and backups. Recent Activity shows each call's summary and actual result as an expandable object/array tree, with execution logs and return values in separate sections for scripts. Output sections and the standalone log-viewing panel are removed. Short action notices preserve success/failure feedback, while diagnostic logs remain available to MCP tools and resources.
|
||||||
|
|
||||||
|
Script tools capture per-call `console.log/info/warn/error/debug` output, including logs before a failure, independently of **Print MCP logs**. Capture is isolated across concurrent and nested calls and stops when the script settles; global/project logs and logs from separately required modules are not collected. Use the injected `console` (also available as `env.console` in `run`/module exports). MCP responses retain their existing `data` shape and add optional `execution` metadata with context, duration, bounded/redacted logs, and an omitted-entry count. Recent Activity preserves result hierarchy and scalar values; large results and file/script bodies remain limited or omitted, with truncation notices.
|
||||||
|
|
||||||
|
The extension menu and native panel titles follow the Cocos Creator interface language. Panel controls, tool descriptions, status messages, prompts, and empty states support English and Chinese; open `Funplay > MCP Settings` to follow Creator or set a project-specific content-language override. MCP tool IDs and schemas remain in English so client integrations stay stable.
|
||||||
|
|
||||||
|
### 3. Configure Your AI Client
|
||||||
|
|
||||||
|
Use the built-in **MCP Client Config** section in the `Funplay > MCP Server` panel first.
|
||||||
|
|
||||||
|
Select your target client, click **One-Click Configure**, and the extension writes the recommended MCP config entry for you.
|
||||||
|
|
||||||
|
The MCP server name written to clients is:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cocos-<project>-<hash>
|
||||||
|
```
|
||||||
|
|
||||||
|
If you prefer to edit config files manually, use the examples below as fallback references. Replace their legacy `funplay_cocos` name and `8765` port with the name and URL shown in your panel. One-click Claude Code configuration uses the project's Git-root scope in `~/.claude.json`, not the global example below. See [project setup and migration](docs/PROJECT_WORKFLOWS.md).
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Claude Code / Claude Desktop</summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Cursor</summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>VS Code</summary>
|
||||||
|
|
||||||
|
One-click setup writes the user-profile `mcp.json` using VS Code's `servers` format and preserves JSONC comments. It uses `~/Library/Application Support/Code/User` on macOS, `%APPDATA%/Code/User` on Windows, and `$XDG_CONFIG_HOME/Code/User` (default `~/.config/Code/User`) on Linux, with `VSCODE_PORTABLE` / `VSCODE_APPDATA` overrides. **Configure + Skills** installs project Skills in [`.github/skills`](https://code.visualstudio.com/docs/agent-customization/agent-skills).
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"servers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Trae</summary>
|
||||||
|
|
||||||
|
One-click setup writes `<Cocos project>/.trae/mcp.json`, following [Trae's project MCP configuration](https://docs.trae.cn/ide_add-mcp-servers). Open this Cocos folder in Trae and enable **Project MCP** in **Settings > MCP**. This target no longer writes `~/.trae/mcp.json`. **Configure + Skills** installs missing built-ins into [`.trae/skills`](https://docs.trae.cn/ide_skills).
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Antigravity</summary>
|
||||||
|
|
||||||
|
One-click setup writes the active Cocos project's `.agents/mcp_config.json` using `mcpServers` and `serverUrl` for Streamable HTTP. Open this Cocos folder in Antigravity and reload its MCP configuration. **Configure + Skills** installs missing built-ins into `.agents/skills`, the project directory shared with Codex. [MCP configuration](https://antigravity.google/docs/mcp/) · [Project Skills](https://antigravity.google/docs/skills/)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"cocos-demo-012345": {
|
||||||
|
"serverUrl": "http://127.0.0.1:8765/mcp/project/0123456789abcdef01234567/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Pi (1.0+)</summary>
|
||||||
|
|
||||||
|
Select **Pi** under **Funplay > MCP Server**. One-click setup saves the project's Streamable HTTP URL in `.pi/mcp.json`. **Configure + Skills** installs missing built-ins into `.agents/skills`, shared with Codex and Antigravity. [Pi MCP configuration](https://docs.pi.dev/latest/mcp) · [Pi Skills](https://docs.pi.dev/latest/skills)
|
||||||
|
|
||||||
|
Start `pi` from the Cocos project directory and trust the project when prompted. In an already trusted session, run `/reload` and check `/mcp` for connection status.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"cocos-demo-012345": {
|
||||||
|
"url": "http://127.0.0.1:8765/mcp/project/0123456789abcdef01234567/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Kiro</summary>
|
||||||
|
|
||||||
|
One-click MCP setup uses `~/.kiro/settings/mcp.json`. **Configure + Skills** also installs missing built-ins in the project's [`.kiro/skills`](https://kiro.dev/docs/skills/) directory.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Qoder</summary>
|
||||||
|
|
||||||
|
The user-level configuration is written to `~/.qoder/settings.json`, or to `$QODER_CONFIG_DIR/settings.json` when that environment variable is set.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Kimi Code</summary>
|
||||||
|
|
||||||
|
The user-level configuration is written to `~/.kimi-code/mcp.json`, or to `$KIMI_CODE_HOME/mcp.json` when that environment variable is set.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Codex</summary>
|
||||||
|
|
||||||
|
One-click setup uses `$CODEX_HOME/config.toml`, defaulting to `~/.codex/config.toml`, following [Codex's configuration directory](https://learn.chatgpt.com/docs/config-file/config-advanced#config-and-state-locations). An empty `[mcp_servers]` parent followed by explicit server tables is supported; inline MCP tables still require manual editing.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[mcp_servers.funplay_cocos]
|
||||||
|
url = "http://127.0.0.1:8765/"
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>OpenCode</summary>
|
||||||
|
|
||||||
|
The global config lives in `$XDG_CONFIG_HOME/opencode/opencode.json` or `~/.config/opencode/opencode.json` on every platform (`opencode.jsonc` also works).
|
||||||
|
|
||||||
|
One-click configuration prefers an existing `opencode.jsonc`. It supports comments and trailing commas in either file, preserves unrelated settings and comments, and leaves malformed or ambiguous configurations unchanged.
|
||||||
|
|
||||||
|
Existing [OpenCode V2](https://opencode.ai/docs/mcp-servers) `mcp.servers` configurations keep that nested structure. New files use the flat `mcp` map below for V1 compatibility; the current [OpenCode schema](https://opencode.ai/config.json) also accepts that legacy form. Setup does not migrate custom timeout/authentication options between formats.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcp": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "remote",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>CodeBuddy (IDE 4.0+)</summary>
|
||||||
|
|
||||||
|
One-click setup writes `<Cocos project>/.mcp.json`, the project configuration supported by [CodeBuddy IDE 4.0+](https://intl.cloud.tencent.com/zh/document/product/1256/77264). It preserves other servers, comments, and trailing commas. Open this Cocos project folder as the CodeBuddy workspace, reload the client if necessary, and enable/approve the MCP server when prompted. Older IDE versions and the standalone CodeBuddy editor extension have different configuration locations; this target does not write their global settings or the CLI's global files.
|
||||||
|
|
||||||
|
**Configure + Skills** also installs missing built-in Skills into `<Cocos project>/.codebuddy/skills`, following the [official Skills directory](https://www.codebuddy.cn/docs/ide/Features/Skills). Existing Skills are kept; review updates in **Project Skills**.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>DeepSeek Harness (DSH)</summary>
|
||||||
|
|
||||||
|
Select **DeepSeek Harness (DSH)** in the MCP Server panel. Configure generates `<Cocos project>/.dsh/funplay-cocos-mcp.patch.json`, a JSON-formatted YAML overlay for the [official Cordis MCP client](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/mcp/mcp-client/README.md). It does not change `$DSH_HOME`, global/profile YAML, dependencies, credentials, or approval settings.
|
||||||
|
|
||||||
|
**The overlay is not auto-loaded.** Start DSH from the Cocos project directory using the exact command shown in the panel, or add its `--patch` argument to your existing DSH launch command. For example, with `dsh` installed:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dsh web --patch '/absolute/path/to/cocos-project/.dsh/funplay-cocos-mcp.patch.json'
|
||||||
|
```
|
||||||
|
|
||||||
|
When launching through npm, use `npx @deepseek-ai/dsh web --patch <the same absolute path>`. Other official profiles can use the same overlay through `--patch`; third-party desktop launchers may require their own launch configuration. Keep Cocos and its MCP server running. The generated overlay uses the project's actual server name and URL, not the legacy example name/port.
|
||||||
|
|
||||||
|
**Configure + Skills** also installs missing built-ins under `<nearest Git root>/.dsh/skills`, or under the Cocos project when no Git root exists, following [DSH's filesystem Skills provider](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/skill/skill-filesystem/README.md). Existing copies remain protected and can be reviewed in Project Skills. Multiple Cocos projects inside one Git repository share that Skills root but have separate MCP overlays.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Optional: npm stdio Wrapper
|
||||||
|
|
||||||
|
If your MCP client prefers a local `stdio` command, install the npm wrapper after starting the Cocos editor server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
Example MCP client entry:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"command": "funplay-cocos-mcp",
|
||||||
|
"env": {
|
||||||
|
"FUNPLAY_COCOS_MCP_URL": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The wrapper bridges stdio MCP traffic to the embedded Cocos HTTP endpoint. You can also run it with `npx funplay-cocos-mcp --url http://127.0.0.1:8765/`.
|
||||||
|
|
||||||
|
The stdio transport supports standard newline-delimited UTF-8 JSON-RPC messages (NDJSON). The wrapper also accepts the existing `Content-Length` framing and writes responses using the same framing as the incoming message.
|
||||||
|
|
||||||
|
### 4. Verify the Connection
|
||||||
|
|
||||||
|
Open your AI client and try a few safe requests first:
|
||||||
|
|
||||||
|
- "Call `get_project_info` and summarize the current Cocos project."
|
||||||
|
- "Read `cocos://project/context` and tell me the editor status."
|
||||||
|
- "Use `execute_javascript` with `context: \"scene\"` to return the active scene name."
|
||||||
|
- "Use `execute_javascript` with `context: \"editor\"` to return the project path."
|
||||||
|
|
||||||
|
If these work, the MCP server, resources, prompts, and primary execution tool are connected correctly.
|
||||||
|
|
||||||
|
For local transport debugging, the panel can copy these commands, or you can run them directly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://127.0.0.1:8765/health
|
||||||
|
curl http://127.0.0.1:8765/tools
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Start Building
|
||||||
|
|
||||||
|
Try a higher-level prompt in your AI client:
|
||||||
|
|
||||||
|
> Create a login page UI in the current Cocos scene with account/password fields, a login button, and a guest-login button. Use `execute_javascript` first, inspect the hierarchy, then capture a screenshot.
|
||||||
|
|
||||||
|
## Before You Start
|
||||||
|
|
||||||
|
- This extension is **Editor-only**. It is meant to automate Cocos Creator, not to add runtime dependencies to your final game build.
|
||||||
|
- New projects use a project-derived port. The MCP Server dashboard shows the exact endpoint and supports pinning a fixed port.
|
||||||
|
- If the configured port is busy, the server automatically falls back to the next available port and the panel/client config use the actual running port.
|
||||||
|
- `GET /health` and `GET /tools` are read-only debug endpoints for quick local checks outside an MCP client.
|
||||||
|
- The default `core` profile exposes 39 high-signal tools. Switch to `full` for all 106 tools, or use `custom` to include/exclude tool categories and individual tools.
|
||||||
|
- The panel checks GitHub releases automatically and also supports manual checks.
|
||||||
|
- One-click update downloads the GitHub Release zip, verifies `SHA256SUMS.txt`, backs up the current extension, replaces the package files, and reloads the extension when the Cocos package API supports it. If reload is unavailable, restart Cocos Creator after installation. Git worktree and symlink installs are intentionally left to manual `git pull` or package replacement.
|
||||||
|
- **Install for All Projects** uses the same release and SHA256 verification flow, targets the active Creator version's managed global directory, then asks Creator to scan and register the package. It preserves an active project copy instead of switching packages underneath an open settings window; the global copy is enabled immediately when no project copy is active, or on the next project open otherwise.
|
||||||
|
- **Project Skills** manages the built-in `funplay-cocos-mcp-workflow` and `funplay-cocos-ui-composition` skills plus custom skills for all 13 one-click clients. The workflow skill is v4. The UI composition skill is v5 and covers splitting full-page designs into editable prefabs and checking fidelity by region. Version checks, diffs, backups, and restore include managed references, and user-owned reference files are protected. Codex, Antigravity, and Pi share `.agents/skills`. Codex and Antigravity can migrate their legacy built-ins while retaining the original files.
|
||||||
|
- Streamable HTTP responses follow the MCP transport requirements for `Accept`, `MCP-Protocol-Version`, JSON-RPC notifications/responses, and optional `Mcp-Session-Id` sessions.
|
||||||
|
- Tool listings include MCP `outputSchema` and `annotations`; structured tool results use a standard envelope with `ok`, `tool`, `callId`, `summary`, `data`, and follow-up `refs`.
|
||||||
|
- `execute_javascript` safety checks are enabled by default. They block obvious risky filesystem and shell patterns such as delete/truncate calls, raw writable streams, path traversal, user/system absolute paths, and `child_process`. This is a guardrail, not a full sandbox; a call can explicitly pass `safety_checks: false` when you have reviewed the risk.
|
||||||
|
- All exposed MCP tools execute directly. There is no extra approval toggle inside the Cocos extension.
|
||||||
|
- File tools and `cocos://asset/path/...` resources are restricted to the active Cocos project root.
|
||||||
|
- The recommended workflow is `execute_javascript` first, then focused helper tools for screenshots, diagnostics, assets, and inspection.
|
||||||
|
- If you change the server port or tool exposure in the panel, the extension saves the config and restarts the server when needed.
|
||||||
|
|
||||||
|
## Why This Project
|
||||||
|
|
||||||
|
- **`execute_javascript` First** — One high-flexibility JavaScript tool can orchestrate scene/runtime work and editor-side automation without flooding AI clients with too many narrow tool calls
|
||||||
|
- **Embedded Cocos Extension** — No separate Python daemon or external bridge process is required for the Cocos-side plugin
|
||||||
|
- **One-Click Client Configuration** — Configure Claude Code, Cursor, VS Code, Trae, Antigravity, Pi (1.0+), Kiro, Qoder, Kimi Code, Codex, OpenCode, and CodeBuddy (IDE 4.0+), or generate a DSH overlay with an explicit `--patch` launch command
|
||||||
|
- **Project Context Built In** — Exposes live project, scene, selection, script diagnostics, logs, and interaction-history resources
|
||||||
|
- **Focused by Default, Full When Needed** — `core` reduces tool-list noise; `full` exposes every available tool; `custom` plus saved profiles lets you tune and restore tool exposure by category or tool
|
||||||
|
- **Visual Validation** — Scene/editor/preview screenshots and input simulation help AI verify UI and gameplay changes
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
- **106 Built-in Tools** — Scene hierarchy, editor state, selection workflows, prefabs, assets, asset dependencies, project instructions, UI creation, components, files, logs, script diagnostics, screenshots, runtime control, build/preview helpers, editor preferences, event binding, and input simulation
|
||||||
|
- **Primary Unified Tool** — `execute_javascript` supports both `scene` and `editor` contexts
|
||||||
|
- **Resources & Prompts** — Live project/log resources plus reusable workflows like script fixing, scene validation, and playable prototype creation
|
||||||
|
- **Cocos Panel UI** — A compact `Funplay > MCP Server` dashboard plus focused Tool Exposure, MCP Settings, and Project Skills windows for larger workflows
|
||||||
|
- **Screenshot and Input Support** — Capture editor/scene/game/preview screenshots and send Electron-level mouse/keyboard events; mouse clicks/drags can use exact PNG pixels with a fresh screenshot `captureId`
|
||||||
|
- **Vendor Agnostic** — Works with any AI client that supports MCP over HTTP JSON-RPC
|
||||||
|
|
||||||
|
## Relationship to Funplay MCP for Unity
|
||||||
|
|
||||||
|
Funplay MCP for Cocos follows the same design principles as Funplay MCP for Unity, adapted to Cocos Creator's JavaScript/TypeScript editor environment.
|
||||||
|
|
||||||
|
| Area | Funplay MCP for Cocos | Funplay MCP for Unity |
|
||||||
|
|------|------------------------|------------------------|
|
||||||
|
| Editor integration | Cocos Creator extension | Unity Editor package |
|
||||||
|
| Embedded server | Built-in HTTP MCP server | Built-in HTTP MCP server |
|
||||||
|
| Primary execution tool | `execute_javascript` | `execute_code` |
|
||||||
|
| Primary language | JavaScript in scene/editor contexts | C# in Unity editor/runtime contexts |
|
||||||
|
| Default profile | `core` with 39 tools | `core` focused tool profile |
|
||||||
|
| Full profile | 106 tools plus `custom` exposure | 79 tools |
|
||||||
|
| Client setup | One-click config panel | One-click config window |
|
||||||
|
|
||||||
|
## MCP Capabilities
|
||||||
|
|
||||||
|
The current package exposes four capability layers:
|
||||||
|
|
||||||
|
- **Tools** — 39 tools in `core`, 106 tools in `full`, plus `custom` include/exclude rules and saved tool profiles
|
||||||
|
- **Primary execution** — `execute_javascript` for scene/runtime and editor/browser automation
|
||||||
|
- **Prompts** — `fix_script_errors`, `create_playable_prototype`, `scene_validation`, and `auto_wire_scene`, plus parameterized project workflows loaded from `mcp-prompts/*.md`. See [project isolation, Skills and workflow setup](docs/PROJECT_WORKFLOWS.md).
|
||||||
|
- **Resources** — project context, scene summaries, current selection, script diagnostics, asset selection, logs, and MCP interaction history
|
||||||
|
|
||||||
|
For the generated tool reference, including categories, profiles, and read/mutation hints, see [docs/TOOLS.md](./docs/TOOLS.md).
|
||||||
|
|
||||||
|
The default `core` set is intentionally small: `execute_javascript`, `execute_scene_script`, `execute_editor_script`, `get_editor_state`, `get_tool_catalog`, `check_for_updates`, `get_selection`, `list_project_instructions`, `read_project_instruction`, `set_selection`, `get_project_info`, `get_build_status`, `get_preview_mode`, `create_scene`, `get_scene_info`, `get_hierarchy`, `list_scenes`, `open_scene`, `inspect_prefab`, `validate_prefab_references`, `inspect_prefab_instance`, `list_assets`, `inspect_asset`, `inspect_asset_dependencies`, `validate_asset_dependencies`, `open_asset`, `select_asset`, `run_script_diagnostics`, `get_recent_logs`, `search_project_logs`, `clear_logs`, `validate_scene`, `get_performance_snapshot`, `get_script_diagnostic_context`, `get_runtime_state`, `capture_editor_screenshot`, `capture_scene_screenshot`, `capture_preview_screenshot`, and `list_editor_windows`.
|
||||||
|
|
||||||
|
### Preview Modes
|
||||||
|
|
||||||
|
Creator 3.8.x preview automation uses the same modes and editor APIs as the built-in preview toolbar:
|
||||||
|
|
||||||
|
| Mode | Behavior |
|
||||||
|
|------|----------|
|
||||||
|
| `browser` | Opens the scene in the system browser; `get_preview_mode` and `run_project_preview` return same-host and network preview URLs when available. |
|
||||||
|
| `gameView` | Starts the scene inside Cocos Creator's Game View. |
|
||||||
|
| `simulator` | Starts the scene in the native simulator. |
|
||||||
|
|
||||||
|
Use `get_preview_mode` to inspect the active mode, `set_preview_mode` to switch it, and `run_project_preview` to start it. `run_project_preview` still accepts `platform` as a deprecated alias for `mode`.
|
||||||
|
|
||||||
|
Game View starts through the native preview toolbar so its manual Pause/Resume buttons remain usable. Repeated starts leave an existing preview running (including its paused state). `pause_runtime` and `resume_runtime` control that same Game View preview and are idempotent; they require a running Game View and do not control browser/simulator previews or the edit-scene director. Switching away from Game View stops it through the toolbar first; rejected operations report an error instead of claiming success.
|
||||||
|
|
||||||
|
Enable these control tools in `full` or a custom tool profile. When scripting, prefer them over directly calling `scene.editor-preview-set-play`, which bypasses toolbar synchronization.
|
||||||
|
|
||||||
|
`get_runtime_state` (also used by `validate_scene`) reports `scope: "gameView"`, actual `running`/`paused` values, `busy`, and `toolbarSynchronized`. It no longer presents edit-scene frame/time-scale counters as preview state; those remain in `get_performance_snapshot.runtime` with `scope: "editScene"`. `set_time_scale` continues to affect only the edit scene. Preview controls require a compatible, ready Creator main-window toolbar; an unavailable toolbar produces an explicit error.
|
||||||
|
|
||||||
|
Browser preview results distinguish same-host automation from LAN access:
|
||||||
|
|
||||||
|
| Field | Meaning |
|
||||||
|
|-------|---------|
|
||||||
|
| `url` / `localUrl` | Loopback URL intended for an MCP client or browser running on the same computer as Cocos Creator. |
|
||||||
|
| `networkUrl` | Original non-loopback URL for another device on the same network; empty when Creator reports a loopback or wildcard host. |
|
||||||
|
| `reportedUrl` | Exact URL string reported by Cocos Creator before normalization. |
|
||||||
|
| `urlWarning` | Non-empty only when the reported value cannot be normalized as an absolute HTTP(S) URL. |
|
||||||
|
|
||||||
|
## Built-in Resources
|
||||||
|
|
||||||
|
| Resource | Description |
|
||||||
|
|----------|-------------|
|
||||||
|
| `cocos://project/context` | Full project and editor context |
|
||||||
|
| `cocos://project/summary` | Short project summary |
|
||||||
|
| `cocos://scene/active` | Active scene snapshot |
|
||||||
|
| `cocos://scene/current` | Alias for the current scene |
|
||||||
|
| `cocos://selection/current` | Current editor selection |
|
||||||
|
| `cocos://selection/asset` | Current selected asset |
|
||||||
|
| `cocos://errors/scripts` | Script diagnostics |
|
||||||
|
| `cocos://logs/editor` | Recent MCP runtime logs and tool interactions |
|
||||||
|
| `cocos://logs/project` | Recent tails from common project log files |
|
||||||
|
| `cocos://mcp/interactions` | Recent MCP interaction history |
|
||||||
|
|
||||||
|
## Built-in Tools
|
||||||
|
|
||||||
|
Funplay MCP for Cocos currently ships with **106 tool functions** in the `full` profile:
|
||||||
|
|
||||||
|
| Category | Tools |
|
||||||
|
|----------|-------|
|
||||||
|
| **Script Execution** | `execute_javascript`, `execute_scene_script`, `execute_editor_script` |
|
||||||
|
| **Editor State** | `get_editor_state`, `get_tool_catalog`, `check_for_updates`, `get_selection`, `set_selection`, `get_editor_selection` |
|
||||||
|
| **Project Instructions** | `list_project_instructions`, `read_project_instruction`, `write_project_instruction`, `create_project_skill`, `create_cocos_mcp_project_skill` |
|
||||||
|
| **Project & Scene** | `get_project_info`, `get_scene_info`, `get_hierarchy`, `find_nodes`, `inspect_node`, `list_scenes`, `open_scene`, `run_scene_asset` |
|
||||||
|
| **Node Editing** | `create_node`, `delete_node`, `set_node_transform` |
|
||||||
|
| **Assets & Prefabs** | `list_assets`, `inspect_asset`, `inspect_asset_dependencies`, `validate_asset_dependencies`, `check_asset_ready`, `open_asset`, `select_asset`, `delete_asset`, `list_prefabs`, `inspect_prefab`, `validate_prefab_references`, `duplicate_prefab`, `edit_prefab_json`, `create_prefab_from_node`, `create_prefab_instance`, `inspect_prefab_instance`, `apply_prefab_instance`, `revert_prefab_instance`, `instantiate_prefab` |
|
||||||
|
| **Components** | `list_components`, `inspect_component`, `add_component`, `remove_component`, `set_component_property`, `reset_component_property` |
|
||||||
|
| **UI** | `create_canvas`, `create_label`, `create_button`, `create_sprite` |
|
||||||
|
| **Camera** | `list_cameras`, `create_camera`, `set_camera_properties` |
|
||||||
|
| **Animation** | `list_animations`, `add_animation_clip`, `play_animation`, `stop_animation` |
|
||||||
|
| **Files** | `read_file`, `get_file_snippet`, `write_file`, `replace_in_file`, `search_files`, `list_directory`, `exists`, `refresh_assets` |
|
||||||
|
| **Diagnostics & Logs** | `run_script_diagnostics`, `get_script_diagnostic_context`, `get_recent_logs`, `search_project_logs`, `clear_logs`, `validate_scene`, `get_performance_snapshot` |
|
||||||
|
| **Build & Editor** | `get_build_status`, `get_preview_mode`, `set_preview_mode`, `open_build_panel`, `run_project_preview`, `save_current_scene`, `get_editor_preference`, `set_editor_preference`, `broadcast_editor_message` |
|
||||||
|
| **Runtime** | `get_runtime_state`, `pause_runtime`, `resume_runtime`, `set_time_scale` |
|
||||||
|
| **Interaction & Events** | `emit_node_event`, `simulate_button_click`, `list_button_click_events`, `bind_button_click_event`, `invoke_component_method`, `simulate_mouse_click`, `simulate_mouse_drag`, `simulate_key_press`, `simulate_key_combo`, `simulate_preview_input` |
|
||||||
|
| **Screenshots & Windows** | `capture_desktop_screenshot`, `capture_editor_screenshot`, `capture_scene_screenshot`, `capture_game_screenshot`, `capture_preview_screenshot`, `list_editor_windows` |
|
||||||
|
|
||||||
|
## Primary Tool Examples
|
||||||
|
|
||||||
|
### Scene Context
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"context": "scene",
|
||||||
|
"code": "return { sceneName: scene.name, rootCount: scene.children.length };",
|
||||||
|
"args": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Editor Context
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"context": "editor",
|
||||||
|
"code": "return { projectPath: context.projectPath, toolCount: helpers.listTools().length };",
|
||||||
|
"args": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Editor-context scripts receive `Editor`, `fs`, `path`, `os`, `require`, `context`, `args`, and helper functions such as `helpers.getStatus()`, `helpers.listTools()`, `helpers.readResource(uri)`, `helpers.callTool(name, args)`, and `helpers.configureClient(targetId)`.
|
||||||
|
|
||||||
|
## Optional Configuration
|
||||||
|
|
||||||
|
Place `funplay-cocos-mcp.config.json` in the Cocos project root:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 8765,
|
||||||
|
"toolProfile": "core",
|
||||||
|
"enabledToolCategories": [],
|
||||||
|
"disabledToolCategories": [],
|
||||||
|
"enabledTools": [],
|
||||||
|
"disabledTools": [],
|
||||||
|
"enableSessions": false,
|
||||||
|
"enableConsoleLogging": true,
|
||||||
|
"executeJavascriptSafetyChecks": true,
|
||||||
|
"autostart": true,
|
||||||
|
"maxInteractionLogEntries": 50,
|
||||||
|
"activeToolProfileName": "",
|
||||||
|
"savedToolProfiles": []
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Environment variables are also supported:
|
||||||
|
|
||||||
|
- `COCOS_MCP_HOST`
|
||||||
|
- `COCOS_MCP_PORT`
|
||||||
|
- `COCOS_MCP_PROFILE`
|
||||||
|
|
||||||
|
If a configured Host is unavailable (for example, a stopped WSL adapter), only
|
||||||
|
the MCP listener stops; the extension and its panels remain available. Open
|
||||||
|
**Funplay > MCP Server**, edit **Server Host**, and click **Apply Host**. Use
|
||||||
|
`127.0.0.1` for same-machine access. Applying the address retries startup when
|
||||||
|
MCP is enabled; otherwise use **Enable MCP Server** or **Restart** when ready.
|
||||||
|
The panel retains the startup error until a successful start. No address is
|
||||||
|
silently substituted and existing configuration is not rewritten at startup.
|
||||||
|
`COCOS_MCP_HOST` takes priority over the project file; if set, change that
|
||||||
|
environment variable and restart Creator instead. Network/wildcard addresses
|
||||||
|
can expose unauthenticated editor access: use only on a trusted network and
|
||||||
|
reconfigure MCP clients after changing the address.
|
||||||
|
|
||||||
|
`toolProfile: "custom"` starts from the `core` set, then adds `enabledToolCategories` / `enabledTools` and removes `disabledToolCategories` / `disabledTools`. The panel can save these exposure settings as named `savedToolProfiles` for quick restore or sharing. `enableSessions` is off by default because this server does not need cross-request client state for normal editor automation.
|
||||||
|
|
||||||
|
`enableConsoleLogging` defaults to `true`. Turn it off in **MCP Settings > Console Logs > Print MCP logs** to stop the extension and HTTP server from printing MCP information, warnings, and errors to the Cocos console. It takes effect immediately, persists per project, and does not restart MCP, clear history, mute project-script logs, or change stdio protocol output.
|
||||||
|
|
||||||
|
## v0.7.0: project-bound connections and frame-paced input
|
||||||
|
|
||||||
|
New generated MCP URLs use `http://127.0.0.1:<port>/mcp/project/<project-id>/`.
|
||||||
|
Existing pinned ports are preserved. Independently compare
|
||||||
|
`initialize.funplay.context.project_path` and `project_id` with your intended project
|
||||||
|
before writing. Legacy `/` and `/mcp` endpoints remain readable, but mutations need
|
||||||
|
the verified `expected_context` token, either in tool arguments or
|
||||||
|
`params._meta.expected_context`. A scoped URL binds the project; an explicit token
|
||||||
|
also pins the extension/Editor lifetime. Reinitializing an arbitrary responding
|
||||||
|
server is not proof that it is the intended project. This is routing protection,
|
||||||
|
not authentication.
|
||||||
|
|
||||||
|
For old configurations, use the existing connection/Skills notice to reconfigure,
|
||||||
|
then reconnect/restart your MCP client. Migration preserves unrelated entries,
|
||||||
|
custom headers/timeouts, historical shared entries and locally edited Skills.
|
||||||
|
Unreadable or unverified configurations require review instead of an automatic rewrite.
|
||||||
|
|
||||||
|
The Full-profile `simulate_mouse_drag` keeps legacy `steps`/`stepDelayMs` by default.
|
||||||
|
For a new calibrated gesture, explicitly use:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"timing": "frame-paced",
|
||||||
|
"coordinateSpace": "image-pixels",
|
||||||
|
"captureId": "<fresh screenshot captureId>",
|
||||||
|
"requestKey": "drag-test-001",
|
||||||
|
"startX": 100, "startY": 100, "endX": 300, "endY": 200,
|
||||||
|
"durationMs": 600, "pressHoldMs": 100, "endHoldMs": 100,
|
||||||
|
"waitMs": 1200
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Measure coordinates from that exact PNG. A running response is only an
|
||||||
|
acknowledgment. Query the same tool with `action: "status"` and its `jobId` or
|
||||||
|
`requestKey`; cancel with `action: "cancel"`, without coordinates. Retained
|
||||||
|
identical starts recover their original receipt rather than replaying. Only the
|
||||||
|
latest 32 receipts are retained, not across eviction or Editor reload. Missing
|
||||||
|
receipts require state inspection before any new gesture. `simulate_preview_input`
|
||||||
|
supports the same fields in drag mode, with separate receipt ownership and tool exposure.
|
||||||
|
|
||||||
|
Frames come from the target Electron renderer, not a verified native Game View
|
||||||
|
engine Update loop. Receipts explicitly report `nativeGameUpdateVerified: false`
|
||||||
|
and `businessOutcomeVerified: false`. Game View pause/stop is checked separately.
|
||||||
|
Focus loss, stale geometry, stalled frames or cancellation interrupt input and
|
||||||
|
attempt only the owned release. Failed release keeps that window locked until
|
||||||
|
explicit cleanup succeeds. No project input/background policies are changed.
|
||||||
|
|
||||||
|
Legacy-coordinate clicks/drags and calibrated input with legacy timing also
|
||||||
|
attempt owned release after interrupted dispatch. If release fails, the result
|
||||||
|
reports uncertain delivery and the window remains locked. Stop/restart MCP to
|
||||||
|
retry that release cleanup; do not replay the gesture without inspecting the
|
||||||
|
actual state. Shutdown also cancels suspended legacy mouse gestures.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
```text
|
||||||
|
Cocos Creator Extension
|
||||||
|
├─ browser.js
|
||||||
|
│ ├─ Embedded HTTP MCP Server
|
||||||
|
│ ├─ Tool Registry
|
||||||
|
│ ├─ Resource Provider
|
||||||
|
│ ├─ Prompt Provider
|
||||||
|
│ └─ One-Click Client Configuration
|
||||||
|
├─ scene.js
|
||||||
|
│ └─ Scene/runtime execution bridge
|
||||||
|
├─ panel/index.js
|
||||||
|
│ └─ Minimal MCP Server dashboard
|
||||||
|
├─ panel/tool-exposure.js, panel/settings.js, panel/project-skills.js
|
||||||
|
│ └─ Focused maintenance windows
|
||||||
|
└─ lib/
|
||||||
|
├─ assets, diagnostics, screenshots, input
|
||||||
|
├─ tool-profiles, javascript-safety
|
||||||
|
├─ tools/
|
||||||
|
│ ├─ files
|
||||||
|
│ ├─ assets-advanced
|
||||||
|
│ ├─ cocos-project
|
||||||
|
│ └─ scene-events
|
||||||
|
└─ server, resources, prompts, tool registry
|
||||||
|
```
|
||||||
|
|
||||||
|
The server speaks MCP-style HTTP JSON-RPC 2.0 and supports tools, resources, resource templates, prompts, health checks, and a read-only `/tools` debug endpoint.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
Run checks before publishing changes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run check
|
||||||
|
npm test
|
||||||
|
npm run docs:check
|
||||||
|
npm run release:check
|
||||||
|
npm run pack:dry-run
|
||||||
|
```
|
||||||
|
|
||||||
|
Regenerate the tool reference after changing `lib/tool-registry.js`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run docs:generate
|
||||||
|
```
|
||||||
|
|
||||||
|
To generate a GitHub Release-ready extension package:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run release:package
|
||||||
|
```
|
||||||
|
|
||||||
|
The package is written to `releases/<version>/` with a zip, manifest, generated release notes, checksum file, and release README. Upload all five files so the public checksums can be verified. See [RELEASE_WORKFLOW.md](./RELEASE_WORKFLOW.md) and [RELEASE_CHECKLIST.md](./RELEASE_CHECKLIST.md) for the full process.
|
||||||
|
|
||||||
|
Validate MCP Registry metadata before publishing:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run registry:validate
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT License. See [LICENSE](./LICENSE).
|
||||||
@@ -0,0 +1,681 @@
|
|||||||
|
<p align="center">
|
||||||
|
<h1 align="center">Funplay MCP for Cocos</h1>
|
||||||
|
<p align="center">
|
||||||
|
<strong>嵌入 Cocos Creator 编辑器的 MCP Server</strong>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/Cocos%20Creator-3.8%2B-blue" alt="Cocos Creator 3.8+"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/MCP-Compatible-green" alt="MCP Compatible"></a>
|
||||||
|
<a href="#"><img src="https://img.shields.io/badge/Platform-Editor%20Only-orange" alt="Editor Only"></a>
|
||||||
|
<a href="https://store.cocos.com/app/detail/8913"><img src="https://img.shields.io/badge/Cocos%20Store-Install-brightgreen" alt="Install from Cocos Store"></a>
|
||||||
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
中文 | <a href="./README.md">English</a>
|
||||||
|
</p>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> 如果这个项目对你有帮助,欢迎顺手点一个 Star。它能帮助更多 Cocos 开发者发现项目,也能支持后续持续维护。
|
||||||
|
|
||||||
|
交流或问题反馈欢迎加入 QQ 群:**1108522331**。打开 **Funplay > 联系反馈**,可以查看作者邮箱并复制邮箱或群号。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Funplay MCP for Cocos 是一个采用 MIT 协议的 Cocos Creator 扩展,它把 HTTP MCP Server 直接嵌入编辑器,让 Claude Code、Cursor、Codex、VS Code Copilot、Trae、Antigravity、Pi、Kiro、Qoder、Kimi Code、OpenCode、CodeBuddy、DeepSeek Harness(DSH)等 AI 助手可以直接检查和操作正在运行的 Cocos 项目。
|
||||||
|
|
||||||
|
这个项目延续 Funplay MCP for Unity 的产品方向:默认工具面保持聚焦,提供一键客户端配置,并围绕一个高灵活度主执行工具组织工作流。
|
||||||
|
|
||||||
|
在 Cocos 里,主工具是 `execute_javascript`:
|
||||||
|
|
||||||
|
- `context: "scene"` 在当前 Cocos 场景/运行态上下文执行 JavaScript
|
||||||
|
- `context: "editor"` 在 Cocos 编辑器/browser 上下文执行 JavaScript
|
||||||
|
|
||||||
|
> *“在当前场景里创建一个登录页 UI,包含账号/密码输入框和登录按钮。”*
|
||||||
|
>
|
||||||
|
> AI 助手可以调用 `execute_javascript`,在当前 Canvas 下生成 UI 层级,挂载 Cocos 组件,检查层级,并截图验证效果。
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
如果你只想尽快连上,先做这三步:
|
||||||
|
|
||||||
|
- 把这个仓库安装为 Cocos Creator 扩展
|
||||||
|
- 打开 `Funplay > MCP Server`
|
||||||
|
- 使用内置的一键 MCP 客户端配置
|
||||||
|
|
||||||
|
### 1. 安装为 Cocos Creator 扩展
|
||||||
|
|
||||||
|
推荐安装方式:通过官方 [Cocos Store 页面](https://store.cocos.com/app/detail/8913) 安装到目标 Cocos Creator 项目。
|
||||||
|
|
||||||
|
如果要本地开发或使用未发布版本,可以把仓库 clone 或复制到 Cocos 项目的扩展目录:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /path/to/your-cocos-project
|
||||||
|
mkdir -p extensions
|
||||||
|
git clone https://github.com/FunplayAI/funplay-cocos-mcp.git extensions/funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
然后重启 Cocos Creator,或在编辑器里重新加载扩展。
|
||||||
|
|
||||||
|
如果不想用 git 安装,可以从 GitHub Releases 下载 `Funplay.CocosMcp.v<version>.zip`,解压后把 `funplay-cocos-mcp` 目录移动到项目的 `extensions/` 目录。
|
||||||
|
|
||||||
|
#### 为所有项目安装(推荐)
|
||||||
|
|
||||||
|
先在任意一个项目中安装并打开扩展,然后进入 `Funplay > MCP Settings`,在“所有项目”区域点击 **为所有项目安装**。扩展会下载最新 GitHub Release、校验 `SHA256SUMS.txt`,再安装到当前 Cocos Creator 版本管理的全局扩展目录:
|
||||||
|
|
||||||
|
- macOS / Linux:`~/.CocosCreator/builtin-extensions/<Creator 版本>/funplay-cocos-mcp`
|
||||||
|
- Windows:`%USERPROFILE%\.CocosCreator\builtin-extensions\<Creator 版本>\funplay-cocos-mcp`
|
||||||
|
|
||||||
|
安装完成后,扩展会让 Cocos Creator 立即扫描并注册这份全局副本。之后由同一 Creator 版本打开或新建的项目都会自动加载它,MCP Server 仍默认自动启动;如果当前已打开项目的项目副本优先,请重新打开项目。不会向每个项目的 `extensions/` 目录重复复制文件。
|
||||||
|
|
||||||
|
Cocos Creator 会按版本隔离全局扩展。如果同时使用多个 Creator 版本,需要在每个版本中分别执行一次“为所有项目安装”。
|
||||||
|
|
||||||
|
为了避免覆盖开发代码,安装过程不会删除当前项目副本。如果当前项目同时存在同名扩展,设置窗口会显示重复安装提示;确认全局副本正常工作后,请移除或禁用项目副本,避免扩展冲突。
|
||||||
|
|
||||||
|
### 2. 启动 MCP Server
|
||||||
|
|
||||||
|
打开编辑器菜单:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Funplay > MCP Server
|
||||||
|
```
|
||||||
|
|
||||||
|
新项目会获得 `20000–29999` 范围内的稳定项目独立端口。已有配置保留原来的固定端口(包括 `8765`)。请使用 MCP Server 面板显示的实际 URL;如果当前使用临时回退端口,请先点击“固定当前端口”或“使用项目独立端口”,再配置客户端。
|
||||||
|
|
||||||
|
如果配置端口已被占用,扩展会先检查已有 listener 是否属于同一个 Cocos 项目;同项目 listener 会被安全复用,无关 listener 才会自动回退到下一个可用本地端口。
|
||||||
|
|
||||||
|
面板刻意保持精简:
|
||||||
|
|
||||||
|
- 启用或停用 MCP Server
|
||||||
|
- 打开聚焦的 Tool Exposure、MCP Settings 和 Project Skills 子窗口
|
||||||
|
- 自动检查当前安装版本是否落后于 GitHub 最新 Release
|
||||||
|
- 从面板打开 Release 页面,或安装已校验的 Release 包
|
||||||
|
- 一键安装到 Cocos Creator 全局扩展目录,让已有项目和新项目自动可用
|
||||||
|
- 一键配置 AI 客户端,并随目标客户端预览对应配置
|
||||||
|
- 把高级工具 profile 编辑、传输设置和安装管理从主窗口拆出去
|
||||||
|
- 自动跟随 Cocos Creator 的界面语言,或在 MCP Settings 中为项目指定中文/英文
|
||||||
|
- 在设置中关闭“打印 MCP 日志”,停止控制台刷屏,同时保留最近活动和内部诊断记录
|
||||||
|
|
||||||
|
各管理页面统一标题、对齐控件和轻量分区。Tool Exposure 按分类管理工具开关;Project Skills 突出可用操作,将文件路径和备份信息折叠收纳。“最近活动”显示每次调用的摘要和真实结果,对象、数组按层级展开;脚本调用分开展示执行日志与返回值。各页“输出”与独立日志查看窗口仍保持移除。操作后显示简短成功/失败提示,底层诊断记录仍可通过 MCP 工具和资源读取。
|
||||||
|
|
||||||
|
脚本工具按次采集 `console.log/info/warn/error/debug` 输出,失败前的日志也会保留,不受“打印 MCP 日志”开关影响。并发、嵌套调用的日志相互隔离,脚本完成后停止采集;不混入全局/项目日志或单独 require 的模块内部日志。使用脚本中注入的 `console`(`run`/模块导出函数也可通过 `env.console` 使用)。MCP 响应保持原有 `data` 结构,新增可选的 `execution` 信息,包含执行上下文、耗时、已限量并脱敏的日志及省略条数。最近活动保留结果层级和标量值;大结果及文件/脚本正文仍限量或省略,并显示截断提示。
|
||||||
|
|
||||||
|
扩展菜单和原生窗口标题会跟随 Cocos Creator 的界面语言。窗口内的控件、工具描述、状态提示、确认信息和空状态支持中文与英文;打开 `Funplay > MCP Settings` 可以跟随 Creator,也可以为当前项目固定内容语言。MCP 工具 ID 和 schema 保持英文,确保客户端集成稳定。
|
||||||
|
|
||||||
|
### 3. 配置 AI 客户端
|
||||||
|
|
||||||
|
优先使用 `Funplay > MCP Server` 面板里的 **MCP Client Config** 区域。
|
||||||
|
|
||||||
|
选择目标客户端,点击 **One-Click Configure**,扩展会直接写入推荐的 MCP 配置项。
|
||||||
|
|
||||||
|
写入客户端的 MCP server 名称是:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cocos-<project>-<hash>
|
||||||
|
```
|
||||||
|
|
||||||
|
如果你更想手动编辑配置文件,再参考下面这些示例,并将示例中的旧名称 `funplay_cocos` 和端口 `8765` 替换为面板显示的名称和 URL。Claude Code 一键配置使用 `~/.claude.json` 中按 Git 根目录划分的项目配置,而不是下面的全局示例。详见[配置与迁移说明](docs/PROJECT_WORKFLOWS.md)。
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Claude Code / Claude Desktop</summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Cursor</summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>VS Code</summary>
|
||||||
|
|
||||||
|
一键配置使用 VS Code 用户配置目录的 `mcp.json` 和 `servers` 格式,并保留 JSONC 注释。macOS 使用 `~/Library/Application Support/Code/User`,Windows 使用 `%APPDATA%/Code/User`,Linux 使用 `$XDG_CONFIG_HOME/Code/User`(默认 `~/.config/Code/User`),同时支持 `VSCODE_PORTABLE` / `VSCODE_APPDATA` 覆盖。“配置 + Skills”会将项目 Skills 安装至 [`.github/skills`](https://code.visualstudio.com/docs/agent-customization/agent-skills)。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"servers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Trae</summary>
|
||||||
|
|
||||||
|
一键配置按 [Trae 官方项目 MCP 规则](https://docs.trae.cn/ide_add-mcp-servers)写入 `<Cocos 项目>/.trae/mcp.json`。请在 Trae 中打开此 Cocos 项目目录,并在“设置 > MCP”启用“项目级 MCP”。此目标不再写入 `~/.trae/mcp.json`。“配置 + Skills”会将缺失的内置 Skill 安装至 [`.trae/skills`](https://docs.trae.cn/ide_skills)。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Antigravity(反重力)</summary>
|
||||||
|
|
||||||
|
一键配置写入当前 Cocos 项目的 `.agents/mcp_config.json`,通过 `mcpServers` 下的 `serverUrl` 配置 Streamable HTTP。请在 Antigravity 中打开此 Cocos 项目并重新加载 MCP 配置。“配置 + Skills”会把缺失的内置 Skill 安装到与 Codex 共用的 `.agents/skills`。[MCP 配置文档](https://antigravity.google/docs/mcp/) · [项目 Skills 文档](https://antigravity.google/docs/skills/)
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"cocos-demo-012345": {
|
||||||
|
"serverUrl": "http://127.0.0.1:8765/mcp/project/0123456789abcdef01234567/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Pi(1.0 或更高版本)</summary>
|
||||||
|
|
||||||
|
在 **Funplay > MCP Server** 中选择 **Pi**。一键配置把项目专属的 Streamable HTTP 地址写入 `.pi/mcp.json`。“配置 + Skills”会把缺失的内置 Skill 安装到与 Codex、Antigravity 共用的 `.agents/skills`。[Pi MCP 配置](https://docs.pi.dev/latest/mcp) · [Pi Skills](https://docs.pi.dev/latest/skills)
|
||||||
|
|
||||||
|
在 Cocos 项目目录运行 `pi`,并按提示信任项目。已信任的会话可以执行 `/reload`,再用 `/mcp` 查看连接状态。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"cocos-demo-012345": {
|
||||||
|
"url": "http://127.0.0.1:8765/mcp/project/0123456789abcdef01234567/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Kiro</summary>
|
||||||
|
|
||||||
|
一键 MCP 配置使用 `~/.kiro/settings/mcp.json`。“配置 + Skills”同时将缺失的内置 Skill 安装至项目的 [`.kiro/skills`](https://kiro.dev/docs/skills/) 目录。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Qoder</summary>
|
||||||
|
|
||||||
|
用户级配置会写入 `~/.qoder/settings.json`;设置了 `QODER_CONFIG_DIR` 环境变量时,则写入 `$QODER_CONFIG_DIR/settings.json`。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Kimi Code</summary>
|
||||||
|
|
||||||
|
用户级配置会写入 `~/.kimi-code/mcp.json`;设置了 `KIMI_CODE_HOME` 环境变量时,则写入 `$KIMI_CODE_HOME/mcp.json`。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Codex</summary>
|
||||||
|
|
||||||
|
一键配置遵循 [Codex 配置目录规则](https://learn.chatgpt.com/docs/config-file/config-advanced#config-and-state-locations),使用 `$CODEX_HOME/config.toml`,默认是 `~/.codex/config.toml`。支持空的 `[mcp_servers]` 父表配合显式服务器子表;内联 MCP 表仍需手动编辑。
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[mcp_servers.funplay_cocos]
|
||||||
|
url = "http://127.0.0.1:8765/"
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>OpenCode</summary>
|
||||||
|
|
||||||
|
全局配置位于所有平台的 `$XDG_CONFIG_HOME/opencode/opencode.json` 或 `~/.config/opencode/opencode.json`(`opencode.jsonc` 同样可用)。
|
||||||
|
|
||||||
|
一键配置优先使用已有的 `opencode.jsonc`,支持两种文件中的注释和尾逗号,保留其他设置及注释;遇到格式错误或存在歧义的配置时,不会覆盖原文件。
|
||||||
|
|
||||||
|
已有 [OpenCode V2](https://opencode.ai/docs/mcp-servers) 的 `mcp.servers` 配置会保持嵌套结构。新文件使用下方的平铺 `mcp` 格式以兼容 V1;当前 [OpenCode 配置 schema](https://opencode.ai/config.json) 仍接受此旧格式。工具不会在新旧格式之间迁移自定义超时或认证选项。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcp": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "remote",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>CodeBuddy(IDE 4.0+)</summary>
|
||||||
|
|
||||||
|
一键配置写入 `<Cocos 项目>/.mcp.json`,使用 [CodeBuddy IDE 4.0 起支持的项目级配置](https://intl.cloud.tencent.com/zh/document/product/1256/77264),并保留其他服务器、注释和尾逗号。请在 CodeBuddy 中直接打开此 Cocos 项目目录,必要时重载客户端,并按提示启用或批准 MCP 服务器。旧版 IDE 和独立的 CodeBuddy 编辑器插件使用不同的配置位置;此选项不会写入它们的全局设置或 CLI 全局文件。
|
||||||
|
|
||||||
|
“配置 + Skills”还会按 [官方 Skills 目录规范](https://www.codebuddy.cn/docs/ide/Features/Skills),将缺少的内置 Skills 安装到 `<Cocos 项目>/.codebuddy/skills`。已有 Skills 保持不变;需要更新时可在“项目 Skills”中预览确认。
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"type": "http",
|
||||||
|
"url": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>DeepSeek Harness(DSH)</summary>
|
||||||
|
|
||||||
|
在 MCP Server 面板选择 **DeepSeek Harness (DSH)**,点击配置会生成 `<Cocos 项目>/.dsh/funplay-cocos-mcp.patch.json`,这是供 [官方 Cordis MCP 客户端](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/mcp/mcp-client/README.md) 使用的 JSON 格式 YAML 覆盖层。不会修改 `$DSH_HOME`、全局或 profile YAML、依赖、凭据及审批设置。
|
||||||
|
|
||||||
|
**该文件不会自动加载。** 请在 Cocos 项目目录使用面板显示的完整命令启动 DSH,或将其中的 `--patch` 参数追加到原有 DSH 启动命令。例如已安装 `dsh` 时:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dsh web --patch '/absolute/path/to/cocos-project/.dsh/funplay-cocos-mcp.patch.json'
|
||||||
|
```
|
||||||
|
|
||||||
|
通过 npm 启动时使用 `npx @deepseek-ai/dsh web --patch <同一绝对路径>`。其他官方 profile 也可通过 `--patch` 使用此文件;第三方桌面启动器可能需要单独设置启动参数。请保持 Cocos 及其 MCP 服务运行。生成文件会使用当前项目实际的服务器名称与 URL,不沿用旧示例名称及端口。
|
||||||
|
|
||||||
|
“配置 + Skills”还会按 [DSH 文件系统 Skills 规范](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/skill/skill-filesystem/README.md),将缺少的内置 Skills 安装到 `<最近 Git 根目录>/.dsh/skills`;没有 Git 仓库时使用 Cocos 项目目录。已有文件保持不变,可在“项目 Skills”中检查更新。同一 Git 仓库中的多个 Cocos 项目共用 Skills 根目录,但各有独立 MCP 覆盖层。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### 可选:npm stdio Wrapper
|
||||||
|
|
||||||
|
如果 MCP 客户端更适合使用本地 `stdio` 命令,可以在启动 Cocos 编辑器内置服务后安装 npm wrapper:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g funplay-cocos-mcp
|
||||||
|
```
|
||||||
|
|
||||||
|
示例 MCP 客户端配置:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"funplay_cocos": {
|
||||||
|
"command": "funplay-cocos-mcp",
|
||||||
|
"env": {
|
||||||
|
"FUNPLAY_COCOS_MCP_URL": "http://127.0.0.1:8765/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
这个 wrapper 会把 stdio MCP 流量桥接到 Cocos 内置 HTTP endpoint。也可以直接运行 `npx funplay-cocos-mcp --url http://127.0.0.1:8765/`。
|
||||||
|
|
||||||
|
stdio 传输支持标准的换行分隔 UTF-8 JSON-RPC 消息(NDJSON)。wrapper 同时接受原有的 `Content-Length` 分帧格式,并使用与输入消息相同的分帧格式返回响应。
|
||||||
|
|
||||||
|
### 4. 验证连接
|
||||||
|
|
||||||
|
先在 AI 客户端里试几个安全请求:
|
||||||
|
|
||||||
|
- “调用 `get_project_info`,总结当前 Cocos 项目。”
|
||||||
|
- “读取 `cocos://project/context`,告诉我当前编辑器状态。”
|
||||||
|
- “用 `execute_javascript` 的 `context: \"scene\"` 返回当前场景名。”
|
||||||
|
- “用 `execute_javascript` 的 `context: \"editor\"` 返回项目路径。”
|
||||||
|
|
||||||
|
如果这些都正常返回,说明 MCP server、resources、prompts 和主执行工具已经连通。
|
||||||
|
|
||||||
|
如果要排查本地传输链路,面板可以直接复制下面的命令,也可以手动执行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://127.0.0.1:8765/health
|
||||||
|
curl http://127.0.0.1:8765/tools
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. 开始构建
|
||||||
|
|
||||||
|
可以在 AI 客户端里尝试:
|
||||||
|
|
||||||
|
> 在当前 Cocos 场景里创建一个登录页 UI,包含账号/密码输入框、登录按钮和游客登录按钮。优先使用 `execute_javascript`,创建后检查层级并截图验证。
|
||||||
|
|
||||||
|
## 开始前说明
|
||||||
|
|
||||||
|
- 这是一个 **仅限 Editor** 的扩展,用于自动化 Cocos Creator,不会给最终游戏包添加运行时依赖。
|
||||||
|
- 新项目使用稳定的项目独立端口;MCP Server 面板会显示实际地址,也支持固定端口。
|
||||||
|
- 如果配置端口被占用,服务会先通过项目身份识别同项目已有 listener;无法确认同项目时才会自动回退到下一个可用端口,面板与一键客户端配置会使用实际运行端口。
|
||||||
|
- `GET /health` 和 `GET /tools` 是只读调试端点,方便不用 MCP 客户端也能快速检查本地服务。
|
||||||
|
- 默认 `core` profile 暴露 39 个高频工具;如果需要完整工具集,可在面板切到 `full`,暴露全部 106 个工具;也可以用 `custom` 按分类或工具名增删。
|
||||||
|
- 面板会自动检查 GitHub Release,也支持手动检查。
|
||||||
|
- 一键更新会下载 GitHub Release zip,校验 `SHA256SUMS.txt`,备份当前扩展目录,替换插件文件,并在 Cocos package API 支持时 reload 扩展;如果当前 Cocos 版本没有可靠 reload 能力,安装后重启 Cocos Creator 即可。Git worktree 和 symlink 安装会保留为手动 `git pull` 或手动替换包,避免覆盖开发目录。
|
||||||
|
- “为所有项目安装”使用同一套 Release 与 SHA256 校验流程,目标是当前 Creator 版本管理的全局目录,并会请求 Creator 扫描和注册扩展。为了避免在设置窗口打开时切换扩展,它会保留正在运行的项目副本;没有项目副本时会立即启用全局副本,否则在下次打开项目时启用。
|
||||||
|
- **项目 Skills** 按客户端管理 `funplay-cocos-mcp-workflow`、`funplay-cocos-ui-composition` 和自定义 Skills,覆盖 13 个一键配置客户端。MCP 工作流技能为 v4,UI 组合技能为 v5,涵盖整页效果图拆分、可编辑 Prefab 搭建和逐区保真验收。版本检测、差异、备份与恢复包含托管参考文件,用户自有参考文件受保护。Codex、Antigravity 和 Pi 共用 `.agents/skills`。Codex 和 Antigravity 迁移旧路径中的内置 Skill 时会保留原文件。
|
||||||
|
- Streamable HTTP 响应已补齐 MCP 传输层要求,包括 `Accept`、`MCP-Protocol-Version`、JSON-RPC notification/response,以及可选 `Mcp-Session-Id` session。
|
||||||
|
- 工具列表会包含 MCP `outputSchema` 和 `annotations`;结构化工具结果统一使用包含 `ok`、`tool`、`callId`、`summary`、`data`、`refs` 的标准 envelope。
|
||||||
|
- `execute_javascript` 安全检查默认开启,会拦截明显高风险的文件系统和 shell 模式,例如删除/截断调用、原始写入流、路径穿越、用户/系统绝对路径和 `child_process`。这是防护栏,不是完整沙箱;确认风险后可在单次调用中显式传入 `safety_checks: false`。
|
||||||
|
- 所有已暴露的 MCP 工具都会直接执行,Cocos 扩展里没有额外 approval 开关。
|
||||||
|
- 文件工具和 `cocos://asset/path/...` 资源默认只能访问当前 Cocos 项目根目录内的路径。
|
||||||
|
- 推荐工作流是优先使用 `execute_javascript`,再配合截图、诊断、资产、检查类工具。
|
||||||
|
- 如果在面板里修改端口或工具暴露模式,扩展会自动保存配置,并在需要时重启服务。
|
||||||
|
|
||||||
|
## 为什么做这个项目
|
||||||
|
|
||||||
|
- **`execute_javascript` 主工具优先** — 一个高灵活度 JavaScript 工具就能编排场景/运行态和编辑器自动化,避免 AI 客户端被大量细碎工具干扰
|
||||||
|
- **嵌入式 Cocos 扩展** — Cocos 侧不需要单独 Python 守护进程或外部 bridge
|
||||||
|
- **一键客户端配置** — 在 Cocos Creator 内直接配置 Claude Code、Cursor、VS Code、Trae、Antigravity、Pi(1.0+)、Kiro、Qoder、Kimi Code、Codex、OpenCode、CodeBuddy(IDE 4.0+),或生成 DSH 配置文件及明确的 `--patch` 启动命令
|
||||||
|
- **内建项目上下文** — 直接暴露项目、场景、选择、脚本诊断、日志和交互历史资源
|
||||||
|
- **默认聚焦,必要时全量** — `core` 降低工具列表噪音,需要时切到 `full` 暴露全部工具;`custom` 与保存的 profile 可按分类或工具名调整并恢复
|
||||||
|
- **可视化验证** — 截图和输入模拟让 AI 能验证 UI 与玩法改动
|
||||||
|
|
||||||
|
## 核心特性
|
||||||
|
|
||||||
|
- **106 个内置工具** — 覆盖场景层级、编辑器状态、选择工作流、Prefab、资产、资产依赖、项目指令、UI 创建、组件、文件、日志、脚本诊断、截图、运行态控制、构建/预览辅助、编辑器偏好、事件绑定和输入模拟
|
||||||
|
- **统一主工具** — `execute_javascript` 同时支持 `scene` 和 `editor` 两种上下文
|
||||||
|
- **Resources 与 Prompts** — 实时项目/日志资源,以及脚本修复、场景验证、可玩原型等可复用工作流
|
||||||
|
- **Cocos 图形面板** — `Funplay > MCP Server` 是精简 Dashboard,并提供 Tool Exposure、MCP Settings、Project Skills 子窗口承载复杂工作流
|
||||||
|
- **截图与输入支持** — 支持编辑器/场景/Game/Preview 截图,以及 Electron 级鼠标键盘事件;鼠标点击和拖拽可绑定新截图的 `captureId`,使用实际 PNG 像素坐标
|
||||||
|
- **厂商无关** — 兼容任意支持 HTTP JSON-RPC MCP 的 AI 客户端
|
||||||
|
|
||||||
|
## 与 Funplay MCP for Unity 的关系
|
||||||
|
|
||||||
|
Funplay MCP for Cocos 延续 Funplay MCP for Unity 的设计原则,并针对 Cocos Creator 的 JavaScript/TypeScript 编辑器环境做了适配。
|
||||||
|
|
||||||
|
| 维度 | Funplay MCP for Cocos | Funplay MCP for Unity |
|
||||||
|
|------|------------------------|------------------------|
|
||||||
|
| 编辑器集成 | Cocos Creator 扩展 | Unity Editor 包 |
|
||||||
|
| 内置服务 | 内嵌 HTTP MCP Server | 内嵌 HTTP MCP Server |
|
||||||
|
| 主执行工具 | `execute_javascript` | `execute_code` |
|
||||||
|
| 主语言 | 场景/编辑器上下文中的 JavaScript | Unity 编辑器/运行态中的 C# |
|
||||||
|
| 默认工具集 | `core`,39 个工具 | 聚焦版 `core` 工具集 |
|
||||||
|
| 完整工具集 | 106 个工具,并支持 `custom` 暴露 | 79 个工具 |
|
||||||
|
| 客户端配置 | 一键配置面板 | 一键配置窗口 |
|
||||||
|
|
||||||
|
## MCP 能力结构
|
||||||
|
|
||||||
|
当前包提供四层能力:
|
||||||
|
|
||||||
|
- **Tools** — `core` 下 39 个工具,`full` 下 106 个工具,并支持 `custom` include/exclude 规则和命名工具 profile
|
||||||
|
- **Primary execution** — `execute_javascript` 用于场景/运行态和编辑器/browser 自动化
|
||||||
|
- **Prompts** — `fix_script_errors`、`create_playable_prototype`、`scene_validation`、`auto_wire_scene`,以及从 `mcp-prompts/*.md` 读取的带参数项目工作流。详见[项目隔离、Skills 与工作流配置](docs/PROJECT_WORKFLOWS.md)。
|
||||||
|
- **Resources** — 项目上下文、场景摘要、当前选择、脚本诊断、资产选择、日志和 MCP 交互历史
|
||||||
|
|
||||||
|
自动生成的工具参考文档见 [docs/TOOLS.md](./docs/TOOLS.md),里面包含工具分类、profile 和读写/变更提示。
|
||||||
|
|
||||||
|
当前默认 `core` 工具集刻意保持精简,只包含:`execute_javascript`、`execute_scene_script`、`execute_editor_script`、`get_editor_state`、`get_tool_catalog`、`check_for_updates`、`get_selection`、`list_project_instructions`、`read_project_instruction`、`set_selection`、`get_project_info`、`get_build_status`、`get_preview_mode`、`create_scene`、`get_scene_info`、`get_hierarchy`、`list_scenes`、`open_scene`、`inspect_prefab`、`validate_prefab_references`、`inspect_prefab_instance`、`list_assets`、`inspect_asset`、`inspect_asset_dependencies`、`validate_asset_dependencies`、`open_asset`、`select_asset`、`run_script_diagnostics`、`get_recent_logs`、`search_project_logs`、`clear_logs`、`validate_scene`、`get_performance_snapshot`、`get_script_diagnostic_context`、`get_runtime_state`、`capture_editor_screenshot`、`capture_scene_screenshot`、`capture_preview_screenshot`、`list_editor_windows`。
|
||||||
|
|
||||||
|
### 预览模式
|
||||||
|
|
||||||
|
Creator 3.8.x 的预览自动化使用与内置预览工具栏相同的模式和编辑器 API:
|
||||||
|
|
||||||
|
| 模式 | 行为 |
|
||||||
|
|------|------|
|
||||||
|
| `browser` | 在系统浏览器中打开场景;可用时,`get_preview_mode` 和 `run_project_preview` 会分别返回同机和局域网预览 URL。 |
|
||||||
|
| `gameView` | 在 Cocos Creator 的 Game View 中启动场景。 |
|
||||||
|
| `simulator` | 在原生模拟器中启动场景。 |
|
||||||
|
|
||||||
|
使用 `get_preview_mode` 查询当前模式,使用 `set_preview_mode` 切换模式,使用 `run_project_preview` 启动预览。`run_project_preview` 仍兼容旧的 `platform` 参数,但该参数已弃用,推荐改用 `mode`。
|
||||||
|
|
||||||
|
Game View 通过原生预览工具栏启动,手动暂停/恢复按钮会保持可用。重复启动不会停止已有预览,也会保留其暂停状态。`pause_runtime` 和 `resume_runtime` 控制同一个 Game View 预览且可重复调用;它们要求 Game View 已启动,不控制浏览器、模拟器或编辑场景 director。切换到其他模式前会先通过工具栏停止 Game View,操作被拒绝时会明确报错,不会误报成功。
|
||||||
|
|
||||||
|
请使用 `full` 范围,或在自定义范围中启用上述控制工具。编写脚本时也应优先使用这些工具,避免直接调用会绕过工具栏同步的 `scene.editor-preview-set-play`。
|
||||||
|
|
||||||
|
`get_runtime_state`(`validate_scene` 也使用它)返回 `scope: "gameView"`、实际的 `running`/`paused`、`busy` 和 `toolbarSynchronized`。它不再将编辑场景的帧数/时间缩放当作预览状态;这些计数仍可通过 `get_performance_snapshot.runtime` 查询,并标记为 `scope: "editScene"`。`set_time_scale` 仍只影响编辑场景。预览控制要求 Creator 主窗口的兼容工具栏已就绪;工具栏不可用时会明确报错。
|
||||||
|
|
||||||
|
浏览器预览结果会区分同机自动化与局域网访问:
|
||||||
|
|
||||||
|
| 字段 | 含义 |
|
||||||
|
|------|------|
|
||||||
|
| `url` / `localUrl` | 供与 Cocos Creator 运行在同一台电脑上的 MCP 客户端或浏览器使用的 loopback 地址。 |
|
||||||
|
| `networkUrl` | 供同一局域网内其他设备使用的 Creator 原始非 loopback 地址;当 Creator 返回 loopback 或通配主机时为空。 |
|
||||||
|
| `reportedUrl` | Cocos Creator 返回且尚未规范化的原始 URL 字符串。 |
|
||||||
|
| `urlWarning` | 仅当原始值无法按绝对 HTTP(S) URL 规范化时返回非空警告。 |
|
||||||
|
|
||||||
|
## 内置 Resources
|
||||||
|
|
||||||
|
| Resource | 说明 |
|
||||||
|
|----------|------|
|
||||||
|
| `cocos://project/context` | 完整项目与编辑器上下文 |
|
||||||
|
| `cocos://project/summary` | 项目摘要 |
|
||||||
|
| `cocos://scene/active` | 当前场景快照 |
|
||||||
|
| `cocos://scene/current` | 当前场景别名 |
|
||||||
|
| `cocos://selection/current` | 当前编辑器选择 |
|
||||||
|
| `cocos://selection/asset` | 当前选中资产 |
|
||||||
|
| `cocos://errors/scripts` | 脚本诊断信息 |
|
||||||
|
| `cocos://logs/editor` | 最近 MCP 运行日志和工具交互 |
|
||||||
|
| `cocos://logs/project` | 常见项目日志文件的尾部内容 |
|
||||||
|
| `cocos://mcp/interactions` | 最近 MCP 交互历史 |
|
||||||
|
|
||||||
|
## 内置工具
|
||||||
|
|
||||||
|
Funplay MCP for Cocos 当前在 `full` profile 下提供 **106 个工具函数**:
|
||||||
|
|
||||||
|
| 分类 | 工具 |
|
||||||
|
|------|------|
|
||||||
|
| **脚本执行** | `execute_javascript`, `execute_scene_script`, `execute_editor_script` |
|
||||||
|
| **编辑器状态** | `get_editor_state`, `get_tool_catalog`, `check_for_updates`, `get_selection`, `set_selection`, `get_editor_selection` |
|
||||||
|
| **项目指令** | `list_project_instructions`, `read_project_instruction`, `write_project_instruction`, `create_project_skill`, `create_cocos_mcp_project_skill` |
|
||||||
|
| **项目与场景** | `get_project_info`, `get_scene_info`, `get_hierarchy`, `find_nodes`, `inspect_node`, `list_scenes`, `open_scene`, `run_scene_asset` |
|
||||||
|
| **节点编辑** | `create_node`, `delete_node`, `set_node_transform` |
|
||||||
|
| **资产与 Prefab** | `list_assets`, `inspect_asset`, `inspect_asset_dependencies`, `validate_asset_dependencies`, `check_asset_ready`, `open_asset`, `select_asset`, `delete_asset`, `list_prefabs`, `inspect_prefab`, `validate_prefab_references`, `duplicate_prefab`, `edit_prefab_json`, `create_prefab_from_node`, `create_prefab_instance`, `inspect_prefab_instance`, `apply_prefab_instance`, `revert_prefab_instance`, `instantiate_prefab` |
|
||||||
|
| **组件** | `list_components`, `inspect_component`, `add_component`, `remove_component`, `set_component_property`, `reset_component_property` |
|
||||||
|
| **UI** | `create_canvas`, `create_label`, `create_button`, `create_sprite` |
|
||||||
|
| **相机** | `list_cameras`, `create_camera`, `set_camera_properties` |
|
||||||
|
| **动画** | `list_animations`, `add_animation_clip`, `play_animation`, `stop_animation` |
|
||||||
|
| **文件** | `read_file`, `get_file_snippet`, `write_file`, `replace_in_file`, `search_files`, `list_directory`, `exists`, `refresh_assets` |
|
||||||
|
| **诊断与日志** | `run_script_diagnostics`, `get_script_diagnostic_context`, `get_recent_logs`, `search_project_logs`, `clear_logs`, `validate_scene`, `get_performance_snapshot` |
|
||||||
|
| **构建与编辑器** | `get_build_status`, `get_preview_mode`, `set_preview_mode`, `open_build_panel`, `run_project_preview`, `save_current_scene`, `get_editor_preference`, `set_editor_preference`, `broadcast_editor_message` |
|
||||||
|
| **运行态** | `get_runtime_state`, `pause_runtime`, `resume_runtime`, `set_time_scale` |
|
||||||
|
| **交互与事件** | `emit_node_event`, `simulate_button_click`, `list_button_click_events`, `bind_button_click_event`, `invoke_component_method`, `simulate_mouse_click`, `simulate_mouse_drag`, `simulate_key_press`, `simulate_key_combo`, `simulate_preview_input` |
|
||||||
|
| **截图与窗口** | `capture_desktop_screenshot`, `capture_editor_screenshot`, `capture_scene_screenshot`, `capture_game_screenshot`, `capture_preview_screenshot`, `list_editor_windows` |
|
||||||
|
|
||||||
|
## 主工具示例
|
||||||
|
|
||||||
|
### Scene 上下文
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"context": "scene",
|
||||||
|
"code": "return { sceneName: scene.name, rootCount: scene.children.length };",
|
||||||
|
"args": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Editor 上下文
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"context": "editor",
|
||||||
|
"code": "return { projectPath: context.projectPath, toolCount: helpers.listTools().length };",
|
||||||
|
"args": {}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Editor 上下文脚本可以访问 `Editor`、`fs`、`path`、`os`、`require`、`context`、`args`,以及 `helpers.getStatus()`、`helpers.listTools()`、`helpers.readResource(uri)`、`helpers.callTool(name, args)`、`helpers.configureClient(targetId)` 等辅助函数。
|
||||||
|
|
||||||
|
## 可选配置
|
||||||
|
|
||||||
|
在 Cocos 项目根目录放置 `funplay-cocos-mcp.config.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 8765,
|
||||||
|
"toolProfile": "core",
|
||||||
|
"enabledToolCategories": [],
|
||||||
|
"disabledToolCategories": [],
|
||||||
|
"enabledTools": [],
|
||||||
|
"disabledTools": [],
|
||||||
|
"enableSessions": false,
|
||||||
|
"enableConsoleLogging": true,
|
||||||
|
"executeJavascriptSafetyChecks": true,
|
||||||
|
"autostart": true,
|
||||||
|
"maxInteractionLogEntries": 50,
|
||||||
|
"activeToolProfileName": "",
|
||||||
|
"savedToolProfiles": []
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
也支持环境变量:
|
||||||
|
|
||||||
|
- `COCOS_MCP_HOST`
|
||||||
|
- `COCOS_MCP_PORT`
|
||||||
|
- `COCOS_MCP_PROFILE`
|
||||||
|
|
||||||
|
当配置的 Host 不可用(例如 WSL 网卡尚未启动)时,仅 MCP 监听服务停止,插件及面板仍可打开。
|
||||||
|
进入 **Funplay > MCP 服务**,修改 **监听地址** 后点击 **应用地址**;本机访问可填写
|
||||||
|
`127.0.0.1`。启用服务时会重试启动,否则可在需要时点击 **启用 MCP 服务** 或 **重启**。
|
||||||
|
面板保留启动错误,直到服务成功启动;不会自动替换监听地址,也不会在启动失败时改写配置文件。
|
||||||
|
`COCOS_MCP_HOST` 环境变量优先于项目文件;设置了该变量时,需修改环境变量并重启 Creator。
|
||||||
|
网络/通配地址可能开放未认证的编辑器访问,请仅在可信网络使用,并在修改地址后重新配置 MCP 客户端。
|
||||||
|
|
||||||
|
`toolProfile: "custom"` 会从 `core` 集合开始,再加入 `enabledToolCategories` / `enabledTools`,并移除 `disabledToolCategories` / `disabledTools`。面板可以把这些暴露设置保存为命名 `savedToolProfiles`,方便恢复或分享。`enableSessions` 默认关闭,因为常规编辑器自动化不需要跨请求客户端状态。
|
||||||
|
|
||||||
|
`enableConsoleLogging` 默认开启。在 **MCP 设置 > 控制台日志 > 打印 MCP 日志** 取消勾选,即可停止扩展及 HTTP 服务向 Cocos 控制台打印 MCP 信息、警告和错误。设置立即生效并按项目保存,不会重启 MCP、清空历史、静音项目脚本日志或影响 stdio 协议输出。
|
||||||
|
|
||||||
|
## v0.7.0:项目专属连接与跨渲染帧拖拽
|
||||||
|
|
||||||
|
新生成的 MCP 地址使用 `http://127.0.0.1:<端口>/mcp/project/<项目标识>/`,保留已有固定端口。
|
||||||
|
写入前需独立核对 `initialize.funplay.context` 中的 `project_path` 和 `project_id`,不能把任意响应服务当成目标项目。
|
||||||
|
旧 `/`、`/mcp` 地址仍允许读取;写入需把核对过的 `expected_context` 放在工具参数或 `params._meta.expected_context` 中。
|
||||||
|
项目专属地址绑定项目;显式标识还会固定扩展/编辑器实例,重载后旧标识可能失效。这是防串线机制,不是身份认证。
|
||||||
|
|
||||||
|
旧客户端可从现有连接/Skills 提示卡显式重新配置,然后重连或重启客户端。
|
||||||
|
其他项目、手动修改的地址、自定义请求头与超时、历史通用条目和本地 Skills 修改会保留;配置不可读或归属不明时不会自动覆盖。
|
||||||
|
|
||||||
|
Full 工具 `simulate_mouse_drag` 默认保留旧 `steps`/`stepDelayMs` 模式。
|
||||||
|
需要跨渲染帧测试时,显式传入 `timing: "frame-paced"`、`coordinateSpace: "image-pixels"`、
|
||||||
|
新截图的 `captureId`、唯一的 `requestKey`,以及从该 PNG 量取的起止坐标。
|
||||||
|
`durationMs` 范围 50~10000,默认 600;`pressHoldMs`、`endHoldMs` 范围 0~2000,默认 100。
|
||||||
|
`waitMs` 默认 1200,超过等待时间可先返回运行中的回执,而不是宣称拖拽完成。
|
||||||
|
|
||||||
|
通过**同一个工具**传 `action: "status"` 和 `jobId` 或 `requestKey` 查询;传 `action: "cancel"` 取消时无需坐标。
|
||||||
|
相同且仍保留的请求不会重复发送,不同参数复用同一个 key 会报冲突。
|
||||||
|
仅保留最近 32 份回执,不能跨淘汰或编辑器重载充当持久事务;回执丢失时先检查实际状态,不自动换 key 重放。
|
||||||
|
`simulate_preview_input` 的拖拽模式也支持这些字段,但回执按原始工具分别归属,并遵守当前工具开放范围。
|
||||||
|
|
||||||
|
这里观察的是目标 Electron 渲染器的帧,不是经过验证的原生 Game View 游戏 Update 帧。
|
||||||
|
回执明确返回 `nativeGameUpdateVerified: false`、`businessOutcomeVerified: false`,游戏行为仍需独立回读或截图确认。
|
||||||
|
Game View 的暂停/停止状态另行检查;失焦、截图过期、几何变化、帧停滞和取消会中断并尝试释放本次按键。
|
||||||
|
释放失败时保留窗口锁,需显式取消该任务重试清理;不会自动更改项目输入或后台运行策略。
|
||||||
|
|
||||||
|
旧坐标点击/拖拽及使用旧计时的截图校准输入,也会在发送异常后尝试释放本次按下的鼠标。
|
||||||
|
释放失败时返回投递结果不确定并保留窗口锁,可停止或重启 MCP 重试释放清理;先检查实际状态,勿直接重放手势。
|
||||||
|
停止服务也会取消仍在等待中的旧鼠标手势,阻止后续输入继续发送。
|
||||||
|
|
||||||
|
## 架构
|
||||||
|
|
||||||
|
```text
|
||||||
|
Cocos Creator Extension
|
||||||
|
├─ browser.js
|
||||||
|
│ ├─ Embedded HTTP MCP Server
|
||||||
|
│ ├─ Tool Registry
|
||||||
|
│ ├─ Resource Provider
|
||||||
|
│ ├─ Prompt Provider
|
||||||
|
│ └─ One-Click Client Configuration
|
||||||
|
├─ scene.js
|
||||||
|
│ └─ Scene/runtime execution bridge
|
||||||
|
├─ panel/index.js
|
||||||
|
│ └─ Minimal MCP Server dashboard
|
||||||
|
├─ panel/tool-exposure.js, panel/settings.js, panel/project-skills.js
|
||||||
|
│ └─ Focused maintenance windows
|
||||||
|
└─ lib/
|
||||||
|
├─ assets, diagnostics, screenshots, input
|
||||||
|
├─ tool-profiles, javascript-safety
|
||||||
|
├─ tools/
|
||||||
|
│ ├─ files
|
||||||
|
│ ├─ assets-advanced
|
||||||
|
│ ├─ cocos-project
|
||||||
|
│ └─ scene-events
|
||||||
|
└─ server, resources, prompts, tool registry
|
||||||
|
```
|
||||||
|
|
||||||
|
服务使用 MCP 风格的 HTTP JSON-RPC 2.0,支持 tools、resources、resource templates、prompts、health check 和只读 `/tools` 调试端点。
|
||||||
|
|
||||||
|
## 开发
|
||||||
|
|
||||||
|
发布改动前可以跑检查:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run check
|
||||||
|
npm test
|
||||||
|
npm run docs:check
|
||||||
|
npm run release:check
|
||||||
|
npm run pack:dry-run
|
||||||
|
```
|
||||||
|
|
||||||
|
修改 `lib/tool-registry.js` 后可以重新生成工具参考:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run docs:generate
|
||||||
|
```
|
||||||
|
|
||||||
|
生成可上传到 GitHub Release 的扩展包:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run release:package
|
||||||
|
```
|
||||||
|
|
||||||
|
产物会写入 `releases/<version>/`,包含 zip、manifest、生成的 release notes、checksum 和 release README。请上传全部五个文件,确保公开附件可以完整校验。完整流程见 [RELEASE_WORKFLOW.md](./RELEASE_WORKFLOW.md) 和 [RELEASE_CHECKLIST.md](./RELEASE_CHECKLIST.md)。
|
||||||
|
|
||||||
|
发布 MCP Registry 前可以验证元数据:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run registry:validate
|
||||||
|
```
|
||||||
|
|
||||||
|
## 协议
|
||||||
|
|
||||||
|
MIT License。详见 [LICENSE](./LICENSE)。
|
||||||
@@ -0,0 +1,387 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const http = require('http');
|
||||||
|
const https = require('https');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const DEFAULT_URL = 'http://127.0.0.1:8765/';
|
||||||
|
const DEFAULT_TIMEOUT_SECONDS = 120;
|
||||||
|
const ACCEPT_HEADER = 'application/json, text/event-stream';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (hasFlag(args, '--help') || hasFlag(args, '-h')) {
|
||||||
|
printHelp();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasFlag(args, '--version')) {
|
||||||
|
console.error(`funplay-cocos-mcp ${readPackageVersion()}`);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const urlText = getOption(args, '--url')
|
||||||
|
|| process.env.FUNPLAY_COCOS_MCP_URL
|
||||||
|
|| DEFAULT_URL;
|
||||||
|
const timeoutText = getOption(args, '--timeout-seconds')
|
||||||
|
|| process.env.FUNPLAY_COCOS_MCP_TIMEOUT_SECONDS
|
||||||
|
|| String(DEFAULT_TIMEOUT_SECONDS);
|
||||||
|
|
||||||
|
const endpoint = parseEndpoint(urlText);
|
||||||
|
if (!endpoint) {
|
||||||
|
console.error(`Invalid --url value: ${urlText}`);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const timeoutSeconds = Number.parseInt(timeoutText, 10);
|
||||||
|
if (!Number.isFinite(timeoutSeconds) || timeoutSeconds <= 0) {
|
||||||
|
console.error(`Invalid timeout value: ${timeoutText}`);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.error(`[Funplay Cocos MCP] Bridging stdio to ${endpoint.href}`);
|
||||||
|
await bridgeStdioToHttp({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout,
|
||||||
|
endpoint,
|
||||||
|
timeoutMs: timeoutSeconds * 1000
|
||||||
|
});
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function bridgeStdioToHttp({ input, output, endpoint, timeoutMs }) {
|
||||||
|
let sessionId = '';
|
||||||
|
let activeFraming = 'content-length';
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const { message, framing } = await readMessage(input);
|
||||||
|
if (message === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (framing) {
|
||||||
|
activeFraming = framing;
|
||||||
|
}
|
||||||
|
|
||||||
|
let parsed = null;
|
||||||
|
let requestId = null;
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(message);
|
||||||
|
requestId = getRequestId(parsed);
|
||||||
|
} catch (error) {
|
||||||
|
await writeJsonRpcError(output, null, -32700, 'Parse error', activeFraming);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await postJsonRpc(endpoint, message, {
|
||||||
|
timeoutMs,
|
||||||
|
sessionId
|
||||||
|
});
|
||||||
|
|
||||||
|
const nextSessionId = response.headers['mcp-session-id'];
|
||||||
|
if (typeof nextSessionId === 'string' && nextSessionId) {
|
||||||
|
sessionId = nextSessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300 && response.body.trim()) {
|
||||||
|
await writeMessage(output, response.body, activeFraming);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode >= 200 && response.statusCode < 300 && isNotification(parsed)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestId !== null) {
|
||||||
|
const messageText = response.body.trim()
|
||||||
|
? `Cocos MCP server returned HTTP ${response.statusCode}: ${response.body}`
|
||||||
|
: `Cocos MCP server returned HTTP ${response.statusCode}.`;
|
||||||
|
await writeJsonRpcError(output, requestId, -32000, messageText, activeFraming);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`[Funplay Cocos MCP] ${error.message}`);
|
||||||
|
if (requestId !== null) {
|
||||||
|
await writeJsonRpcError(output, requestId, -32000, `Proxy transport error: ${error.message}`, activeFraming);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function postJsonRpc(endpoint, body, { timeoutMs, sessionId }) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const client = endpoint.protocol === 'https:' ? https : http;
|
||||||
|
const request = client.request(
|
||||||
|
endpoint,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Accept: ACCEPT_HEADER,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Content-Length': Buffer.byteLength(body),
|
||||||
|
...(sessionId ? { 'Mcp-Session-Id': sessionId } : {})
|
||||||
|
},
|
||||||
|
timeout: timeoutMs
|
||||||
|
},
|
||||||
|
(response) => {
|
||||||
|
const chunks = [];
|
||||||
|
response.on('data', (chunk) => chunks.push(chunk));
|
||||||
|
response.on('end', () => {
|
||||||
|
resolve({
|
||||||
|
statusCode: response.statusCode || 0,
|
||||||
|
headers: response.headers,
|
||||||
|
body: Buffer.concat(chunks).toString('utf8')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
request.on('timeout', () => {
|
||||||
|
request.destroy(new Error(`HTTP request timed out after ${timeoutMs / 1000} seconds.`));
|
||||||
|
});
|
||||||
|
request.on('error', reject);
|
||||||
|
request.end(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseEndpoint(value) {
|
||||||
|
try {
|
||||||
|
const endpoint = new URL(value);
|
||||||
|
if (endpoint.protocol !== 'http:' && endpoint.protocol !== 'https:') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return endpoint;
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRequestId(value) {
|
||||||
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Object.prototype.hasOwnProperty.call(value, 'id') ? value.id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isNotification(value) {
|
||||||
|
return Boolean(value && typeof value === 'object' && !Array.isArray(value) && value.method && !Object.prototype.hasOwnProperty.call(value, 'id'));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function writeJsonRpcError(output, id, code, message, framing = 'content-length') {
|
||||||
|
await writeMessage(output, JSON.stringify({
|
||||||
|
jsonrpc: '2.0',
|
||||||
|
id,
|
||||||
|
error: {
|
||||||
|
code,
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}), framing);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readMessage(input) {
|
||||||
|
const headers = new Map();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const line = await readHeaderLine(input);
|
||||||
|
if (line === null) {
|
||||||
|
if (headers.size === 0) {
|
||||||
|
return { message: null, framing: 'content-length' };
|
||||||
|
}
|
||||||
|
return Promise.reject(new Error('Unexpected EOF while reading MCP headers.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (headers.size === 0 && (trimmed.startsWith('{') || trimmed.startsWith('['))) {
|
||||||
|
// Direct NDJSON line (standard MCP stdio specification)
|
||||||
|
return { message: trimmed, framing: 'ndjson' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line === '') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const separator = line.indexOf(':');
|
||||||
|
if (separator <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
headers.set(line.slice(0, separator).trim().toLowerCase(), line.slice(separator + 1).trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
const contentLength = Number.parseInt(headers.get('content-length') || '', 10);
|
||||||
|
if (!Number.isFinite(contentLength) || contentLength < 0) {
|
||||||
|
throw new Error('Missing Content-Length header.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = await readExact(input, contentLength);
|
||||||
|
return { message: payload.toString('utf8'), framing: 'content-length' };
|
||||||
|
}
|
||||||
|
|
||||||
|
function readHeaderLine(input) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const chunks = [];
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
input.off('readable', onReadable);
|
||||||
|
input.off('end', onEnd);
|
||||||
|
input.off('error', onError);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onReadable() {
|
||||||
|
let byte;
|
||||||
|
while ((byte = input.read(1)) !== null) {
|
||||||
|
if (byte[0] === 0x0a) {
|
||||||
|
cleanup();
|
||||||
|
if (chunks.length > 0 && chunks[chunks.length - 1][0] === 0x0d) {
|
||||||
|
chunks.pop();
|
||||||
|
}
|
||||||
|
resolve(Buffer.concat(chunks).toString('utf8'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chunks.push(byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEnd() {
|
||||||
|
cleanup();
|
||||||
|
resolve(chunks.length === 0 ? null : Buffer.concat(chunks).toString('utf8'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onError(error) {
|
||||||
|
cleanup();
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.on('readable', onReadable);
|
||||||
|
input.once('end', onEnd);
|
||||||
|
input.once('error', onError);
|
||||||
|
onReadable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function readExact(input, length) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const chunks = [];
|
||||||
|
let remaining = length;
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
input.off('readable', onReadable);
|
||||||
|
input.off('end', onEnd);
|
||||||
|
input.off('error', onError);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onReadable() {
|
||||||
|
while (remaining > 0) {
|
||||||
|
const chunk = input.read(remaining);
|
||||||
|
if (chunk === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chunks.push(chunk);
|
||||||
|
remaining -= chunk.length;
|
||||||
|
}
|
||||||
|
cleanup();
|
||||||
|
resolve(Buffer.concat(chunks, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEnd() {
|
||||||
|
cleanup();
|
||||||
|
reject(new Error('Unexpected EOF while reading MCP payload.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function onError(error) {
|
||||||
|
cleanup();
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
input.on('readable', onReadable);
|
||||||
|
input.once('end', onEnd);
|
||||||
|
input.once('error', onError);
|
||||||
|
onReadable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeMessage(output, json, framing = 'content-length') {
|
||||||
|
const body = framing === 'ndjson' ? JSON.stringify(JSON.parse(json)) : json;
|
||||||
|
const payload = Buffer.from(body, 'utf8');
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (framing === 'ndjson') {
|
||||||
|
output.write(payload, (payloadError) => {
|
||||||
|
if (payloadError) {
|
||||||
|
reject(payloadError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
output.write('\n', (newlineError) => {
|
||||||
|
if (newlineError) {
|
||||||
|
reject(newlineError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
output.write(`Content-Length: ${payload.length}\r\n\r\n`, 'ascii', (headerError) => {
|
||||||
|
if (headerError) {
|
||||||
|
reject(headerError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
output.write(payload, (payloadError) => {
|
||||||
|
if (payloadError) {
|
||||||
|
reject(payloadError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasFlag(args, name) {
|
||||||
|
return args.some((arg) => arg.toLowerCase() === name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOption(args, name) {
|
||||||
|
for (let i = 0; i < args.length - 1; i += 1) {
|
||||||
|
if (args[i].toLowerCase() === name.toLowerCase()) {
|
||||||
|
return args[i + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function readPackageVersion() {
|
||||||
|
try {
|
||||||
|
const packagePath = path.resolve(__dirname, '..', 'package.json');
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
||||||
|
return packageJson.version || '0.0.0';
|
||||||
|
} catch (error) {
|
||||||
|
return '0.0.0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function printHelp() {
|
||||||
|
console.error('funplay-cocos-mcp');
|
||||||
|
console.error('Bridges stdio MCP traffic to a local Cocos Creator HTTP MCP server.');
|
||||||
|
console.error();
|
||||||
|
console.error('Options:');
|
||||||
|
console.error(' --url <http://127.0.0.1:8765/> Cocos MCP HTTP endpoint.');
|
||||||
|
console.error(' --timeout-seconds <120> HTTP timeout per request.');
|
||||||
|
console.error(' --version Print the proxy version.');
|
||||||
|
console.error(' --help Show this help.');
|
||||||
|
console.error();
|
||||||
|
console.error('Environment:');
|
||||||
|
console.error(' FUNPLAY_COCOS_MCP_URL');
|
||||||
|
console.error(' FUNPLAY_COCOS_MCP_TIMEOUT_SECONDS');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) {
|
||||||
|
main().then((code) => {
|
||||||
|
process.exitCode = code;
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(`[Funplay Cocos MCP] ${error.message}`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
|
}
|
||||||