@playcraft/cli 0.0.53 → 0.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/REMIX.md +103 -19
- package/dist/atom-tree/fusion-hints.js +8 -3
- package/dist/atom-tree/fusion-intent.js +62 -0
- package/dist/atom-tree/selection.js +3 -1
- package/dist/commands/create.js +439 -159
- package/dist/commands/image.js +79 -69
- package/dist/commands/levels.js +29 -0
- package/dist/commands/patterns.js +75 -0
- package/dist/commands/remix.js +47 -0
- package/dist/commands/skills.js +48 -17
- package/dist/index.js +13 -6
- package/dist/remix/clone-source.js +208 -0
- package/dist/remix/clone.js +255 -0
- package/dist/scaffold/templates.js +35 -0
- package/dist/utils/agent-api-client.js +10 -3
- package/dist/utils/remix-image-attachments.js +4 -32
- package/dist/utils/sandbox-path.js +20 -0
- package/package.json +3 -3
- package/project-template/.claude/agents/creative-director.md +114 -0
- package/project-template/.claude/agents/developer.md +5 -2
- package/project-template/.claude/agents/game-designer.md +41 -20
- package/project-template/.claude/agents/refs/README.md +8 -0
- package/project-template/.claude/agents/refs/creative-director-guide.md +35 -0
- package/project-template/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
- package/project-template/.claude/agents/refs/creative-discovery-guide.md +76 -0
- package/project-template/.claude/agents/refs/creative-north-star-examples.md +82 -0
- package/project-template/.claude/agents/refs/developer-dev-handoff.md +1 -1
- package/project-template/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
- package/project-template/.claude/agents/refs/game-designer-gameplay-sufficiency.md +4 -4
- package/project-template/.claude/agents/reviewer.md +11 -0
- package/project-template/.claude/hooks/README.md +12 -12
- package/project-template/.claude/hooks/block-developer-preflight.mjs +49 -13
- package/project-template/.claude/hooks/block-ring1-tasklist.mjs +1 -1
- package/project-template/.claude/hooks/user-prompt.mjs +3 -13
- package/project-template/.claude/hooks/validate-workflow-stop.mjs +209 -12
- package/project-template/.claude/settings.json +2 -2
- package/project-template/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
- package/project-template/.claude/skills/session-analyzer/scripts/resolve-session.mjs +0 -1
- package/project-template/.claude/snapshot.mjs +0 -1
- package/project-template/.codebuddy/settings.json +1 -1
- package/project-template/.cursor/rules/playcraft-orchestrator.mdc +1 -1
- package/project-template/CLAUDE.md +9 -9
- package/project-template/docs/project-state.md +1 -1
- package/project-template/docs/team/agent-conduct.md +18 -18
- package/project-template/docs/team/collaboration.md +19 -7
- package/project-template/docs/team/workflow-changelog.md +15 -0
- package/project-template/fusion-patterns/catalog.json +77 -0
- package/project-template/package.json +2 -0
- package/project-template/skills/_shared/scripts/create-playable.mjs +31 -11
- package/project-template/skills/_shared/scripts/dev-start.mjs +3 -3
- package/project-template/skills/_shared/scripts/disclosure-config.mjs +65 -39
- package/project-template/skills/_shared/scripts/harness-smoke.mjs +3 -1
- package/project-template/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
- package/project-template/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
- package/project-template/skills/_shared/scripts/slice-set.mjs +29 -2
- package/project-template/skills/_shared/scripts/state-get.mjs +124 -7
- package/project-template/skills/_shared/scripts/state-store.mjs +25 -2
- package/project-template/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
- package/project-template/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
- package/project-template/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
- package/project-template/skills/playable-record/scripts/record-playable.mjs +2 -1
- package/project-template/skills/playable-record/scripts/verify-contract.mjs +4 -4
- package/project-template/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
- package/project-template/skills/playable-record/scripts/verify-fusion.mjs +37 -2
- package/project-template/skills/playable-record/scripts/verify-slice.mjs +2 -2
- package/project-template/templates/design-brief.template.md +34 -0
- package/project-template/templates/design-methodology.md +1 -2
- package/project-template/templates/design.template.md +65 -0
- package/project-template/templates/developer-log.template.md +12 -1
- package/project-template/templates/five-axis-framework.md +12 -0
- package/project-template/templates/game-designer-creative-process.template.md +99 -0
- package/project-template/templates/level-sketch.template.json +56 -0
- package/project-template/templates/north-star.template.md +43 -0
- package/project-template/templates/project-state.template.md +1 -1
- package/project-template/vite.config.ts +4 -5
- package/project-templates/phaser/.claude/agents/creative-director.md +114 -0
- package/project-templates/phaser/.claude/agents/game-designer.md +41 -20
- package/project-templates/phaser/.claude/agents/refs/creative-director-guide.md +35 -0
- package/project-templates/phaser/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
- package/project-templates/phaser/.claude/agents/refs/creative-discovery-guide.md +76 -0
- package/project-templates/phaser/.claude/agents/refs/creative-north-star-examples.md +82 -0
- package/project-templates/phaser/.claude/agents/refs/developer-dev-handoff.md +1 -1
- package/project-templates/phaser/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
- package/project-templates/phaser/.claude/agents/reviewer.md +11 -0
- package/project-templates/phaser/.claude/hooks/block-ring1-tasklist.mjs +2 -2
- package/project-templates/phaser/.claude/hooks/user-prompt.mjs +17 -18
- package/project-templates/phaser/.claude/hooks/validate-workflow-stop.mjs +209 -12
- package/project-templates/phaser/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
- package/project-templates/phaser/.cursor/rules/playcraft-orchestrator.mdc +1 -1
- package/project-templates/phaser/CLAUDE.md +88 -54
- package/project-templates/phaser/docs/DESIGN.md +25 -0
- package/project-templates/phaser/docs/project-state.md +1 -1
- package/project-templates/phaser/docs/team/collaboration.md +19 -7
- package/project-templates/phaser/docs/team/workflow-changelog.md +14 -0
- package/project-templates/phaser/fusion-patterns/catalog.json +77 -0
- package/project-templates/phaser/package.json +3 -1
- package/project-templates/phaser/skills/_shared/scripts/dev-start.mjs +3 -3
- package/project-templates/phaser/skills/_shared/scripts/disclosure-config.mjs +65 -39
- package/project-templates/phaser/skills/_shared/scripts/harness-smoke.mjs +3 -1
- package/project-templates/phaser/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
- package/project-templates/phaser/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
- package/project-templates/phaser/skills/_shared/scripts/state-get.mjs +124 -7
- package/project-templates/phaser/skills/_shared/scripts/state-store.mjs +25 -2
- package/project-templates/phaser/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
- package/project-templates/phaser/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
- package/project-templates/phaser/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
- package/project-templates/phaser/skills/playable-record/scripts/record-playable.mjs +2 -1
- package/project-templates/phaser/skills/playable-record/scripts/verify-contract.mjs +4 -4
- package/project-templates/phaser/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
- package/project-templates/phaser/skills/playable-record/scripts/verify-fusion.mjs +37 -2
- package/project-templates/phaser/skills/playable-record/scripts/verify-slice.mjs +2 -2
- package/project-templates/phaser/templates/design-brief.template.md +42 -11
- package/project-templates/phaser/templates/design-methodology.md +1 -2
- package/project-templates/phaser/templates/design.template.md +77 -0
- package/project-templates/phaser/templates/five-axis-framework.md +50 -1
- package/project-templates/phaser/templates/game-designer-creative-process.template.md +99 -0
- package/project-templates/phaser/templates/level-sketch.template.json +56 -0
- package/project-templates/phaser/templates/north-star.template.md +43 -0
- package/project-templates/phaser/templates/project-state.template.md +1 -1
- package/project-templates/phaser/vite.config.ts +4 -5
- package/project-templates/playable-template-phaser/.playcraftignore +10 -0
- package/project-templates/playable-template-phaser/CLAUDE.md +178 -0
- package/project-templates/playable-template-phaser/PLAYCRAFT-MIGRATION.md +328 -0
- package/project-templates/playable-template-phaser/README.md +381 -0
- package/project-templates/playable-template-phaser/assets/brain.png +0 -0
- package/project-templates/playable-template-phaser/assets/button.png +0 -0
- package/project-templates/playable-template-phaser/assets/interact.png +0 -0
- package/project-templates/playable-template-phaser/assets/logo.webp +0 -0
- package/project-templates/playable-template-phaser/assets/warn_brain.png +0 -0
- package/project-templates/playable-template-phaser/builds.config.js +12 -0
- package/project-templates/playable-template-phaser/globals.d.ts +2 -0
- package/project-templates/playable-template-phaser/index.html +12 -0
- package/project-templates/playable-template-phaser/package.json +45 -0
- package/project-templates/playable-template-phaser/scripts/base64-to-mp3.js +340 -0
- package/project-templates/playable-template-phaser/scripts/convert-to-webp.js +370 -0
- package/project-templates/playable-template-phaser/src/Game.ts +154 -0
- package/project-templates/playable-template-phaser/src/config/LoadingConfig.ts +40 -0
- package/project-templates/playable-template-phaser/src/config/ThemeConfig.ts +81 -0
- package/project-templates/playable-template-phaser/src/index.css +18 -0
- package/project-templates/playable-template-phaser/src/index.html +9 -0
- package/project-templates/playable-template-phaser/src/index.ts +30 -0
- package/project-templates/playable-template-phaser/src/json5.d.ts +4 -0
- package/project-templates/playable-template-phaser/src/managers/AudioManager.ts +559 -0
- package/project-templates/playable-template-phaser/src/scenes/MainScene.ts +301 -0
- package/project-templates/playable-template-phaser/src/scenes/PreloadScene.ts +256 -0
- package/project-templates/playable-template-phaser/src/theme/README.md +194 -0
- package/project-templates/playable-template-phaser/src/theme/blue-theme/assets/.gitkeep +24 -0
- package/project-templates/playable-template-phaser/src/theme/blue-theme/index.ts +27 -0
- package/project-templates/playable-template-phaser/src/theme/blue-theme/theme.data.json5 +19 -0
- package/project-templates/playable-template-phaser/src/theme/green-theme/assets/.gitkeep +3 -0
- package/project-templates/playable-template-phaser/src/theme/green-theme/index.ts +20 -0
- package/project-templates/playable-template-phaser/src/theme/green-theme/theme.data.json5 +19 -0
- package/project-templates/playable-template-phaser/src/theme/index.ts +1 -0
- package/project-templates/playable-template-phaser/src/theme/red-theme/assets/.gitkeep +3 -0
- package/project-templates/playable-template-phaser/src/theme/red-theme/index.ts +20 -0
- package/project-templates/playable-template-phaser/src/theme/red-theme/theme.data.json5 +19 -0
- package/project-templates/playable-template-phaser/src/theme/theme.metadata.md +60 -0
- package/project-templates/playable-template-phaser/src/theme/theme.schema.json5 +149 -0
- package/project-templates/playable-template-phaser/src/ui/BrainAgeUI.ts +681 -0
- package/project-templates/playable-template-phaser/src/ui/CountdownUI.ts +565 -0
- package/project-templates/playable-template-phaser/src/ui/PlayButton.ts +51 -0
- package/project-templates/playable-template-phaser/src/ui/ScoreUI.ts +207 -0
- package/project-templates/playable-template-phaser/src/ui/SuccessUI.ts +43 -0
- package/project-templates/playable-template-phaser/src/ui/index.ts +15 -0
- package/project-templates/playable-template-phaser/tsconfig.json +26 -0
- package/project-templates/playable-template-phaser/vite.config.ts +64 -0
- package/project-templates/playable-template-phaser//346/226/260/346/211/213/345/274/200/345/217/221/346/214/207/345/215/227.md +209 -0
- package/project-templates/playable-template-three/README.md +795 -0
- package/project-templates/playable-template-three/assets/Stork.glb +0 -0
- package/project-templates/playable-template-three/assets/button.png +0 -0
- package/project-templates/playable-template-three/assets/logo.webp +0 -0
- package/project-templates/playable-template-three/build.json +7 -0
- package/project-templates/playable-template-three/builds.config.example.js +151 -0
- package/project-templates/playable-template-three/builds.config.js +158 -0
- package/project-templates/playable-template-three/package.json +36 -0
- package/project-templates/playable-template-three/scripts/convert-to-webp.js +370 -0
- package/project-templates/playable-template-three/scripts/theme-builds.js +514 -0
- package/project-templates/playable-template-three/src/Game.ts +215 -0
- package/project-templates/playable-template-three/src/config/LoadingConfig.ts +27 -0
- package/project-templates/playable-template-three/src/config/ThemeConfig.ts +36 -0
- package/project-templates/playable-template-three/src/global.d.ts +108 -0
- package/project-templates/playable-template-three/src/index.css +18 -0
- package/project-templates/playable-template-three/src/index.html +9 -0
- package/project-templates/playable-template-three/src/index.ts +20 -0
- package/project-templates/playable-template-three/src/managers/AudioManager.ts +538 -0
- package/project-templates/playable-template-three/src/scenes/PreloadScene.ts +305 -0
- package/project-templates/playable-template-three/src/theme/README.md +225 -0
- package/project-templates/playable-template-three/src/theme/blue-theme/assets/.gitkeep +28 -0
- package/project-templates/playable-template-three/src/theme/blue-theme/index.ts +45 -0
- package/project-templates/playable-template-three/src/theme/current.ts +12 -0
- package/project-templates/playable-template-three/src/theme/green-theme/assets/.gitkeep +3 -0
- package/project-templates/playable-template-three/src/theme/green-theme/index.ts +34 -0
- package/project-templates/playable-template-three/src/theme/red-theme/assets/.gitkeep +3 -0
- package/project-templates/playable-template-three/src/theme/red-theme/index.ts +34 -0
- package/project-templates/playable-template-three/tsconfig.json +24 -0
- package/project-templates/threejs/.claude/agents/creative-director.md +114 -0
- package/project-templates/threejs/.claude/agents/game-designer.md +41 -20
- package/project-templates/threejs/.claude/agents/refs/creative-director-guide.md +35 -0
- package/project-templates/threejs/.claude/agents/refs/creative-director-kickoff-guide.md +52 -0
- package/project-templates/threejs/.claude/agents/refs/creative-discovery-guide.md +76 -0
- package/project-templates/threejs/.claude/agents/refs/creative-north-star-examples.md +82 -0
- package/project-templates/threejs/.claude/agents/refs/developer-dev-handoff.md +1 -1
- package/project-templates/threejs/.claude/agents/refs/game-designer-fusion-depth-playbook.md +28 -0
- package/project-templates/threejs/.claude/agents/reviewer.md +11 -0
- package/project-templates/threejs/.claude/hooks/block-ring1-tasklist.mjs +2 -2
- package/project-templates/threejs/.claude/hooks/user-prompt.mjs +17 -18
- package/project-templates/threejs/.claude/hooks/validate-workflow-stop.mjs +209 -12
- package/project-templates/threejs/.claude/skills/playcraft-playable-optimization/SKILL.md +20 -20
- package/project-templates/threejs/.cursor/rules/playcraft-orchestrator.mdc +1 -1
- package/project-templates/threejs/CLAUDE.md +88 -54
- package/project-templates/threejs/docs/DESIGN.md +25 -0
- package/project-templates/threejs/docs/project-state.md +1 -1
- package/project-templates/threejs/docs/team/collaboration.md +19 -7
- package/project-templates/threejs/docs/team/workflow-changelog.md +14 -0
- package/project-templates/threejs/fusion-patterns/catalog.json +77 -0
- package/project-templates/threejs/package.json +3 -1
- package/project-templates/threejs/skills/_shared/scripts/dev-start.mjs +3 -3
- package/project-templates/threejs/skills/_shared/scripts/disclosure-config.mjs +65 -39
- package/project-templates/threejs/skills/_shared/scripts/harness-smoke.mjs +3 -1
- package/project-templates/threejs/skills/_shared/scripts/lib/fusion-intent.mjs +88 -0
- package/project-templates/threejs/skills/_shared/scripts/lib/skill-fidelity.mjs +185 -0
- package/project-templates/threejs/skills/_shared/scripts/state-get.mjs +124 -7
- package/project-templates/threejs/skills/_shared/scripts/state-store.mjs +25 -2
- package/project-templates/threejs/skills/_shared/scripts/validate-level-sketch.mjs +444 -0
- package/project-templates/threejs/skills/_shared/scripts/verify-design-consistency.mjs +728 -0
- package/project-templates/threejs/skills/playable-record/scripts/lib/dev-server.mjs +46 -11
- package/project-templates/threejs/skills/playable-record/scripts/record-playable.mjs +2 -1
- package/project-templates/threejs/skills/playable-record/scripts/verify-contract.mjs +4 -4
- package/project-templates/threejs/skills/playable-record/scripts/verify-firstwin.mjs +3 -3
- package/project-templates/threejs/skills/playable-record/scripts/verify-fusion.mjs +37 -2
- package/project-templates/threejs/skills/playable-record/scripts/verify-slice.mjs +2 -2
- package/project-templates/threejs/templates/design-brief.template.md +42 -11
- package/project-templates/threejs/templates/design-methodology.md +1 -2
- package/project-templates/threejs/templates/design.template.md +77 -0
- package/project-templates/threejs/templates/five-axis-framework.md +50 -1
- package/project-templates/threejs/templates/game-designer-creative-process.template.md +99 -0
- package/project-templates/threejs/templates/level-sketch.template.json +56 -0
- package/project-templates/threejs/templates/north-star.template.md +43 -0
- package/project-templates/threejs/templates/project-state.template.md +1 -1
- package/project-templates/threejs/vite.config.ts +4 -5
- package/project-template/docs/DESIGN.md +0 -65
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { sdk } from '@playcraft/adsdk';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { AudioManager } from './managers/AudioManager';
|
|
4
|
+
import { PreloadScene, PreloadResources } from './scenes/PreloadScene';
|
|
5
|
+
import themeConfig from './theme/current';
|
|
6
|
+
|
|
7
|
+
export class Game {
|
|
8
|
+
private scene: THREE.Scene;
|
|
9
|
+
private camera: THREE.PerspectiveCamera;
|
|
10
|
+
private renderer: THREE.WebGLRenderer;
|
|
11
|
+
private uiContainer: HTMLDivElement;
|
|
12
|
+
private installButton: HTMLDivElement;
|
|
13
|
+
private storkModel: THREE.Group;
|
|
14
|
+
private mixer: THREE.AnimationMixer;
|
|
15
|
+
private clock: THREE.Clock;
|
|
16
|
+
public isPaused: boolean = false;
|
|
17
|
+
|
|
18
|
+
// Audio Manager
|
|
19
|
+
private audioManager: AudioManager;
|
|
20
|
+
|
|
21
|
+
constructor(width: number, height: number) {
|
|
22
|
+
// 创建 PreloadScene
|
|
23
|
+
const preloadScene = new PreloadScene();
|
|
24
|
+
preloadScene.start((resources: PreloadResources) => {
|
|
25
|
+
// 资源加载完成,初始化游戏
|
|
26
|
+
this.initGame(width, height, resources);
|
|
27
|
+
// 通知 SDK 游戏开始
|
|
28
|
+
sdk.start();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private initGame(width: number, height: number, resources: PreloadResources): void {
|
|
33
|
+
// 初始化 AudioManager(示例配置,可根据需要调整)
|
|
34
|
+
this.audioManager = new AudioManager({
|
|
35
|
+
bgmVolume: 0.5,
|
|
36
|
+
effectVolume: 0.6,
|
|
37
|
+
enableBackgroundPause: true,
|
|
38
|
+
watchdogInterval: 500
|
|
39
|
+
});
|
|
40
|
+
this.audioManager.init();
|
|
41
|
+
|
|
42
|
+
// Create renderer
|
|
43
|
+
this.renderer = new THREE.WebGLRenderer({ antialias: true });
|
|
44
|
+
this.renderer.setSize(width, height);
|
|
45
|
+
this.renderer.setPixelRatio(1.5);
|
|
46
|
+
document.body.appendChild(this.renderer.domElement);
|
|
47
|
+
|
|
48
|
+
// Create THREE.js scene(使用主题配置)
|
|
49
|
+
this.scene = new THREE.Scene();
|
|
50
|
+
this.scene.background = new THREE.Color(themeConfig.sceneBackground);
|
|
51
|
+
|
|
52
|
+
// Create camera
|
|
53
|
+
this.camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
|
|
54
|
+
|
|
55
|
+
// Initialize clock for animations
|
|
56
|
+
this.clock = new THREE.Clock();
|
|
57
|
+
|
|
58
|
+
// Create UI container
|
|
59
|
+
this.uiContainer = document.createElement('div');
|
|
60
|
+
this.uiContainer.style.cssText = 'position: absolute; top: 0px; left: 0px; transform-origin: top left;';
|
|
61
|
+
document.body.appendChild(this.uiContainer);
|
|
62
|
+
|
|
63
|
+
// 使用预加载的资源创建场景
|
|
64
|
+
this.create(resources);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private create(resources: PreloadResources): void {
|
|
68
|
+
this.createUI(resources.buttonImage);
|
|
69
|
+
|
|
70
|
+
// Add lights(使用主题配置)
|
|
71
|
+
const ambientLight = new THREE.AmbientLight(
|
|
72
|
+
themeConfig.ambientLightColor,
|
|
73
|
+
themeConfig.ambientLightIntensity
|
|
74
|
+
);
|
|
75
|
+
this.scene.add(ambientLight);
|
|
76
|
+
|
|
77
|
+
const directionalLight = new THREE.DirectionalLight(
|
|
78
|
+
themeConfig.directionalLightColor,
|
|
79
|
+
themeConfig.directionalLightIntensity
|
|
80
|
+
);
|
|
81
|
+
directionalLight.position.set(5, 5, 5);
|
|
82
|
+
this.scene.add(directionalLight);
|
|
83
|
+
|
|
84
|
+
// 添加 3D 模型(使用主题配置的缩放)
|
|
85
|
+
if (resources.storkModel) {
|
|
86
|
+
this.storkModel = resources.storkModel.scene;
|
|
87
|
+
const scale = themeConfig.modelScale || 0.5;
|
|
88
|
+
this.storkModel.scale.set(scale, scale, scale);
|
|
89
|
+
this.scene.add(this.storkModel);
|
|
90
|
+
|
|
91
|
+
// Set up animation mixer
|
|
92
|
+
this.mixer = new THREE.AnimationMixer(this.storkModel);
|
|
93
|
+
|
|
94
|
+
// Play first animation
|
|
95
|
+
if (resources.storkModel.animations.length > 0) {
|
|
96
|
+
const action = this.mixer.clipAction(resources.storkModel.animations[0]);
|
|
97
|
+
action.play();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Set up interaction listener
|
|
102
|
+
sdk.on('interaction', (count: number) => {
|
|
103
|
+
console.log(`Interaction count: ${count}`);
|
|
104
|
+
|
|
105
|
+
if (sdk.interactions >= 10) {
|
|
106
|
+
sdk.finish();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Start animation loop
|
|
111
|
+
this.animate();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private createUI(buttonImage: HTMLImageElement | null): void {
|
|
115
|
+
this.installButton = document.createElement('div');
|
|
116
|
+
this.installButton.style.cssText =
|
|
117
|
+
'cursor: pointer; width: 200px; display: flex; align-items: center; justify-content: center; margin: 20px;';
|
|
118
|
+
this.installButton.onclick = () => {
|
|
119
|
+
// 用户交互时可以播放音效或BGM
|
|
120
|
+
// 示例:this.audioManager.playEffect('click');
|
|
121
|
+
// 示例:this.audioManager.playBgm();
|
|
122
|
+
sdk.install();
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// Add image
|
|
126
|
+
if (buttonImage) {
|
|
127
|
+
buttonImage.style.width = '100%';
|
|
128
|
+
this.installButton.appendChild(buttonImage);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Add text overlay(使用主题配置)
|
|
132
|
+
const text = document.createElement('div');
|
|
133
|
+
text.textContent = 'Install';
|
|
134
|
+
text.style.cssText = `
|
|
135
|
+
position: absolute;
|
|
136
|
+
color: ${themeConfig.uiTextColor};
|
|
137
|
+
font-size: ${themeConfig.buttonStyle.fontSize};
|
|
138
|
+
font-weight: ${themeConfig.buttonStyle.fontWeight};
|
|
139
|
+
text-shadow: ${themeConfig.buttonStyle.textShadow};
|
|
140
|
+
pointer-events: none;
|
|
141
|
+
font-family: cursive;
|
|
142
|
+
`;
|
|
143
|
+
this.installButton.appendChild(text);
|
|
144
|
+
|
|
145
|
+
this.uiContainer.appendChild(this.installButton);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private update(): void {
|
|
149
|
+
if (this.mixer) {
|
|
150
|
+
const delta = this.clock.getDelta();
|
|
151
|
+
this.mixer.update(delta);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this.storkModel) {
|
|
155
|
+
const speed = themeConfig.rotationSpeed || 0.01;
|
|
156
|
+
this.storkModel.rotation.y += speed;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private animate(): void {
|
|
161
|
+
requestAnimationFrame(() => this.animate());
|
|
162
|
+
|
|
163
|
+
if (!this.isPaused) this.update();
|
|
164
|
+
|
|
165
|
+
this.renderer.render(this.scene, this.camera);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
public resize(width: number, height: number): void {
|
|
169
|
+
// Update container size
|
|
170
|
+
this.uiContainer.style.width = `${width}px`;
|
|
171
|
+
this.uiContainer.style.height = `${height}px`;
|
|
172
|
+
|
|
173
|
+
// Calculate scale based on screen dimensions
|
|
174
|
+
const scaleX = width / 320;
|
|
175
|
+
const scaleY = height / 480;
|
|
176
|
+
const scale = Math.min(scaleX, scaleY); // Use smaller scale to fit both dimensions
|
|
177
|
+
|
|
178
|
+
this.uiContainer.style.transform = `scale(${scale})`;
|
|
179
|
+
|
|
180
|
+
// Update camera aspect ratio
|
|
181
|
+
this.camera.aspect = width / height;
|
|
182
|
+
|
|
183
|
+
// 使用主题配置的相机距离(如果有),否则使用默认值
|
|
184
|
+
const landscapeDistance = themeConfig.cameraDistance || 80;
|
|
185
|
+
const portraitDistance = landscapeDistance * 2;
|
|
186
|
+
this.camera.position.z = width > height ? landscapeDistance : portraitDistance;
|
|
187
|
+
|
|
188
|
+
this.camera.updateProjectionMatrix();
|
|
189
|
+
|
|
190
|
+
// Resize renderer
|
|
191
|
+
this.renderer.setSize(width, height);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public pause(): void {
|
|
195
|
+
this.isPaused = true;
|
|
196
|
+
this.audioManager.setGamePaused(true);
|
|
197
|
+
console.log('Game paused');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public resume(): void {
|
|
201
|
+
this.isPaused = false;
|
|
202
|
+
this.audioManager.setGamePaused(false);
|
|
203
|
+
console.log('Game resumed');
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public volume(value: number): void {
|
|
207
|
+
this.audioManager.setVolume(value);
|
|
208
|
+
console.log(`Volume changed to: ${value}`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
public finish(): void {
|
|
212
|
+
this.audioManager.setGameEnded(true);
|
|
213
|
+
console.log('Game finished');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loading 页面配置
|
|
3
|
+
* 可根据实际项目需要修改
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// TODO: 替换为实际的 Logo 图片路径
|
|
7
|
+
import logoImage from 'assets/logo.webp';
|
|
8
|
+
|
|
9
|
+
export const LoadingConfig = {
|
|
10
|
+
// 文案配置
|
|
11
|
+
LOGO_IMAGE: logoImage, // Logo 图片
|
|
12
|
+
APP_TITLE: 'Vita Mahjong', // 应用标题
|
|
13
|
+
APP_STARS: '★★★★★', // 评分星星
|
|
14
|
+
APP_DESC: 'Relaxing Vita Mahjong: Classic Tile\nMatching and Offline Puzzle Games!...', // 应用描述
|
|
15
|
+
LOADING_TEXT: 'Loading Playable Ads', // 加载文字
|
|
16
|
+
GAMEPAD_ICON: '🎮',
|
|
17
|
+
|
|
18
|
+
// 时间配置
|
|
19
|
+
SCENE_DURATION: 100, // Loading 页面最小显示时长(毫秒)
|
|
20
|
+
DOT_ANIM_DELAY: 200, // 点号动画间隔(毫秒)
|
|
21
|
+
|
|
22
|
+
// 跳跃动画配置
|
|
23
|
+
BOUNCE_HEIGHT_LANDSCAPE: 8, // 横屏跳跃高度
|
|
24
|
+
BOUNCE_HEIGHT_PORTRAIT: 10, // 竖屏跳跃高度
|
|
25
|
+
BOUNCE_DURATION: 300, // 跳跃动画时长(毫秒)
|
|
26
|
+
BOUNCE_REPEAT_DELAY: 100, // 跳跃重复延迟(毫秒)
|
|
27
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题配置接口
|
|
3
|
+
* 定义主题的数据结构,包括颜色、样式等配置
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface ThemeConfig {
|
|
7
|
+
// 基础信息
|
|
8
|
+
name: string; // 主题名称
|
|
9
|
+
id: string; // 主题唯一标识
|
|
10
|
+
|
|
11
|
+
// 场景配置
|
|
12
|
+
sceneBackground: number; // 场景背景色(THREE.Color 值)
|
|
13
|
+
|
|
14
|
+
// 光照配置
|
|
15
|
+
ambientLightColor: number; // 环境光颜色
|
|
16
|
+
ambientLightIntensity: number; // 环境光强度
|
|
17
|
+
directionalLightColor: number; // 方向光颜色
|
|
18
|
+
directionalLightIntensity: number; // 方向光强度
|
|
19
|
+
|
|
20
|
+
// UI 配置
|
|
21
|
+
uiPrimaryColor: string; // 主色调(CSS 颜色)
|
|
22
|
+
uiTextColor: string; // 文字颜色
|
|
23
|
+
buttonStyle: {
|
|
24
|
+
fontSize: string;
|
|
25
|
+
fontWeight: string;
|
|
26
|
+
textShadow: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// 可选:游戏特定配置
|
|
30
|
+
modelScale?: number; // 模型缩放比例
|
|
31
|
+
cameraDistance?: number; // 相机距离
|
|
32
|
+
rotationSpeed?: number; // 旋转速度
|
|
33
|
+
|
|
34
|
+
// 可选:自定义配置
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局类型声明
|
|
3
|
+
* 用于声明非 TypeScript 模块的类型
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// 图片资源模块声明
|
|
7
|
+
declare module '*.png' {
|
|
8
|
+
const value: string;
|
|
9
|
+
export default value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '*.jpg' {
|
|
13
|
+
const value: string;
|
|
14
|
+
export default value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare module '*.jpeg' {
|
|
18
|
+
const value: string;
|
|
19
|
+
export default value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: string;
|
|
24
|
+
export default value;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '*.svg' {
|
|
28
|
+
const value: string;
|
|
29
|
+
export default value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare module '*.webp' {
|
|
33
|
+
const value: string;
|
|
34
|
+
export default value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare module '*.ico' {
|
|
38
|
+
const value: string;
|
|
39
|
+
export default value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare module '*.bmp' {
|
|
43
|
+
const value: string;
|
|
44
|
+
export default value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 3D 模型文件声明
|
|
48
|
+
declare module '*.glb' {
|
|
49
|
+
const value: string;
|
|
50
|
+
export default value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare module '*.gltf' {
|
|
54
|
+
const value: string;
|
|
55
|
+
export default value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare module '*.fbx' {
|
|
59
|
+
const value: string;
|
|
60
|
+
export default value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.obj' {
|
|
64
|
+
const value: string;
|
|
65
|
+
export default value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 音频文件声明
|
|
69
|
+
declare module '*.mp3' {
|
|
70
|
+
const value: string;
|
|
71
|
+
export default value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare module '*.wav' {
|
|
75
|
+
const value: string;
|
|
76
|
+
export default value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
declare module '*.ogg' {
|
|
80
|
+
const value: string;
|
|
81
|
+
export default value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare module '*.m4a' {
|
|
85
|
+
const value: string;
|
|
86
|
+
export default value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 其他资源文件声明
|
|
90
|
+
declare module '*.json' {
|
|
91
|
+
const value: any;
|
|
92
|
+
export default value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare module '*.css' {
|
|
96
|
+
const value: any;
|
|
97
|
+
export default value;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare module '*.scss' {
|
|
101
|
+
const value: any;
|
|
102
|
+
export default value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
declare module '*.less' {
|
|
106
|
+
const value: any;
|
|
107
|
+
export default value;
|
|
108
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
body,
|
|
2
|
+
html {
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
}
|
|
6
|
+
html {
|
|
7
|
+
background-color: #fff;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
}
|
|
12
|
+
body {
|
|
13
|
+
height: inherit;
|
|
14
|
+
width: inherit;
|
|
15
|
+
}
|
|
16
|
+
* {
|
|
17
|
+
-webkit-tap-highlight-color: transparent;
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Game } from './Game';
|
|
2
|
+
import './index.css';
|
|
3
|
+
import { sdk } from '@playcraft/adsdk';
|
|
4
|
+
|
|
5
|
+
// Initialize the SDK
|
|
6
|
+
sdk.init((width: number, height: number) => {
|
|
7
|
+
// Initialize game with container dimensions
|
|
8
|
+
const game = new Game(width, height);
|
|
9
|
+
|
|
10
|
+
// Set up all event listeners
|
|
11
|
+
sdk.on('resize', game.resize, game);
|
|
12
|
+
sdk.on('pause', game.pause, game);
|
|
13
|
+
sdk.on('resume', game.resume, game);
|
|
14
|
+
sdk.on('volume', game.volume, game);
|
|
15
|
+
sdk.on('finish', game.finish, game);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (__DEV__) {
|
|
19
|
+
console.log('Development mode');
|
|
20
|
+
}
|