98 lines
2.6 KiB
Plaintext
98 lines
2.6 KiB
Plaintext
import { _decorator, Node, v2 } from "cc";
|
|
import { I_LevelConfig, I_LevelStepData, I_TalkRecordInfo } from "../Config/CommonConfig";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
//游戏管理器
|
|
@ccclass('GameManager')
|
|
export default class GameManager {
|
|
|
|
private static _I: GameManager = null;
|
|
public static get I(): GameManager {
|
|
if (!GameManager._I) {
|
|
GameManager._I = new GameManager();
|
|
GameManager._I.init();
|
|
}
|
|
return GameManager._I;
|
|
}
|
|
|
|
private init(){
|
|
|
|
}
|
|
|
|
|
|
private static _levelCfgArray: I_LevelConfig[] = [];
|
|
private static _levelCfgMap: {[key: string]: I_LevelConfig} = {};
|
|
/**设置关卡数据 */
|
|
public static SetLevelCfg(levelCfg: any[]) {
|
|
GameManager._levelCfgArray = levelCfg;
|
|
let info:any = null;
|
|
for (let i = 0; i < levelCfg.length; i++) {
|
|
info = levelCfg[i];
|
|
GameManager._levelCfgMap[info.id] = info;
|
|
}
|
|
}
|
|
|
|
|
|
/**获取关卡配置 */
|
|
public static getLevelCfg(levelId: string): I_LevelConfig {
|
|
return GameManager._levelCfgMap[levelId];
|
|
}
|
|
|
|
|
|
private static _curLevelId: string = "";
|
|
/**设置当前关卡ID */
|
|
public static set CurLevelId(value: string) {
|
|
GameManager._curLevelId = value;
|
|
}
|
|
/**获取当前关卡ID */
|
|
public static get CurLevelId(): string {
|
|
return GameManager._curLevelId;
|
|
}
|
|
|
|
|
|
private static _recordId: string = "";
|
|
/**设置当前关卡流程ID */
|
|
public static set RecordId(value: string) {
|
|
GameManager._recordId = value;
|
|
}
|
|
/**获取当前关卡流程ID */
|
|
public static get RecordId(): string {
|
|
return GameManager._recordId;
|
|
}
|
|
|
|
|
|
private static _curStepData: I_LevelStepData = null;
|
|
/**设置当前步骤数据 */
|
|
public static set CurStepData(value: I_LevelStepData) {
|
|
GameManager._curStepData = value;
|
|
}
|
|
/**获取当前步骤数据 */
|
|
public static get CurStepData(): I_LevelStepData {
|
|
return GameManager._curStepData;
|
|
}
|
|
|
|
|
|
private static stepDataList: I_LevelStepData[] = [];
|
|
/**设置关卡步骤数据 */
|
|
public static AddStepData(stepData: I_LevelStepData) {
|
|
GameManager.stepDataList.push(stepData);
|
|
}
|
|
/**清空关卡步骤数据 */
|
|
public static ClearStepData() {
|
|
GameManager.stepDataList = [];
|
|
}
|
|
|
|
|
|
private static talkRecordList: I_TalkRecordInfo[] = [];
|
|
/**添加对话记录 */
|
|
public static AddTalkRecord(record: I_TalkRecordInfo) {
|
|
GameManager.talkRecordList.push(record);
|
|
}
|
|
/**清空对话记录 */
|
|
public static ClearTalkRecord() {
|
|
GameManager.talkRecordList = [];
|
|
}
|
|
} |