feat: 接入关卡配置 API 并支持降级到本地配置
- 新增 LevelDataManager 单例管理关卡数据 - 新增 HttpUtil 封装 XMLHttpRequest 请求 - 新增 LevelTypes 类型定义 - PageLoading 集成 API 数据预加载(0-80% 进度) - PageLevel 支持优先使用 API 数据,失败时降级到本地配置 - 字段映射: hint1/2/3 → clue1/2/3, imageUrl → SpriteFrame
This commit is contained in:
53
assets/scripts/types/LevelTypes.ts
Normal file
53
assets/scripts/types/LevelTypes.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { SpriteFrame } from 'cc';
|
||||
|
||||
/**
|
||||
* API 返回的单个关卡数据结构
|
||||
*/
|
||||
export interface ApiLevelData {
|
||||
/** 关卡 ID */
|
||||
id: number;
|
||||
/** 关卡名称 */
|
||||
name: string;
|
||||
/** 主图 URL */
|
||||
imageUrl: string;
|
||||
/** 线索1(映射到 clue1) */
|
||||
hint1: string;
|
||||
/** 线索2(映射到 clue2) */
|
||||
hint2: string;
|
||||
/** 线索3(映射到 clue3) */
|
||||
hint3: string;
|
||||
/** 答案 */
|
||||
answer: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* API 响应结构
|
||||
*/
|
||||
export interface ApiResponse {
|
||||
/** 状态码,0 表示成功 */
|
||||
code: number;
|
||||
/** 响应消息 */
|
||||
message: string;
|
||||
/** 关卡数据数组 */
|
||||
data: ApiLevelData[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行时关卡配置(包含已加载的图片)
|
||||
*/
|
||||
export interface RuntimeLevelConfig {
|
||||
/** 关卡 ID */
|
||||
id: number;
|
||||
/** 关卡名称 */
|
||||
name: string;
|
||||
/** 主图 SpriteFrame(可能为 null 如果加载失败) */
|
||||
spriteFrame: SpriteFrame | null;
|
||||
/** 线索1 */
|
||||
clue1: string;
|
||||
/** 线索2 */
|
||||
clue2: string;
|
||||
/** 线索3 */
|
||||
clue3: string;
|
||||
/** 答案 */
|
||||
answer: string;
|
||||
}
|
||||
Reference in New Issue
Block a user