import { Color } from "cc"; import { ConfigParseUtils } from "./ConfigParseUtils"; /** * PetConfig数据结构 */ export class PetConfigData { private _id: number; public get id(): number { return this._id; } private _key: string; public get key(): string { return this._key; } private _bundle: string; public get bundle(): string { return this._bundle; } private _path: string; public get path(): string { return this._path; } private _name: string; public get name(): string { return this._name; } private _color: Color; public get color(): Color { return this._color; } private _desc: string; public get desc(): string { return this._desc; } public constructor( id: number, key: string, bundle: string, path: string, name: string, color: Color, desc: string ) { this._id = id; this._key = key; this._bundle = bundle; this._path = path; this._name = name; this._color = color; this._desc = desc; } } /** * 解析配置数据 */ export function parsePetConfigData(data: any): PetConfigData { return new PetConfigData( ConfigParseUtils.parseInt(data.id), ConfigParseUtils.parseString(data.key), ConfigParseUtils.parseString(data.bundle), ConfigParseUtils.parseString(data.path), ConfigParseUtils.parseString(data.name), ConfigParseUtils.parseColor(data.color), ConfigParseUtils.parseString(data.desc) ); }