feat: 星域故事汇小游戏初始版本

This commit is contained in:
2026-03-03 16:57:49 +08:00
commit cc0e39cccc
34 changed files with 6556 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
/**
* 场景管理器
*/
import HomeScene from './HomeScene';
import StoryScene from './StoryScene';
import EndingScene from './EndingScene';
import ProfileScene from './ProfileScene';
import ChapterScene from './ChapterScene';
export default class SceneManager {
constructor(main) {
this.main = main;
this.currentScene = null;
this.scenes = {
home: HomeScene,
story: StoryScene,
ending: EndingScene,
profile: ProfileScene,
chapter: ChapterScene
};
}
/**
* 切换场景
*/
switchScene(sceneName, params = {}) {
const SceneClass = this.scenes[sceneName];
if (!SceneClass) {
console.error('场景不存在:', sceneName);
return;
}
// 销毁当前场景
if (this.currentScene && this.currentScene.destroy) {
this.currentScene.destroy();
}
// 创建新场景
this.currentScene = new SceneClass(this.main, params);
// 初始化场景
if (this.currentScene.init) {
this.currentScene.init();
}
console.log('切换到场景:', sceneName);
}
/**
* 获取当前场景名称
*/
getCurrentSceneName() {
if (!this.currentScene) return null;
return this.currentScene.constructor.name;
}
}