/** * 技师的解锁数据 */ import { BaseData } from "./BaseData"; import proto from 'db://assets/Scripts/proto/proto.pb.js'; export class GirlUnlockData extends BaseData { // id private id: number; // 付费技师是否已经解锁 private isRelease: boolean; // 解锁图片 id private unlockedImageIds: number[]; // 解锁视频 id private unlockedVideoIds: number[]; constructor() { super(); this.id = 0; this.isRelease = false; this.unlockedImageIds = []; this.unlockedVideoIds = []; } public reset(): void { this.id = 0; this.isRelease = false; this.unlockedImageIds = []; this.unlockedVideoIds = []; } public clear(): void { this.id = 0; this.isRelease = false; this.unlockedImageIds = []; this.unlockedVideoIds = []; } public destroy(): void { super.destroy(); this.id = null; this.isRelease = null; this.unlockedImageIds = null; this.unlockedVideoIds = null; } /** 获取 id */ public getId(): number { return this.id; } /** 保存 id */ public setId(value: number): void { this.id = value; } /** 获取 付费技师是否已经解锁 */ public getIsRelease(): boolean { return this.isRelease; } /** 保存 付费技师是否已经解锁 */ public setIsRelease(value: boolean): void { this.isRelease = value; } /** 判断图片是否解锁,根据 id */ public isImageUnlock(id: number): boolean { for (let i = 0; i < this.unlockedImageIds.length; i++) { if (this.unlockedImageIds[i] === id) { return true; } } return false; } /** 解锁图片 */ public unlockImage(id: number) { // 去重 let exists = this.isImageUnlock(id); if (!exists) { this.unlockedImageIds.push(id); } console.log("技师 ", this.id, " 当前解锁图片的所有id:",this.unlockedImageIds); } /** 获取所有解锁图片的 id */ public getUnlockedImageIds(): number[] { return this.unlockedImageIds; } /** 保存解锁图片 id */ public setUnlockedImageIds(value: number[]): void { for(let one of value) { this.unlockImage(one); } } /** 判断视频是否解锁,根据 id */ public isVideoUnlock(id: number): boolean { for (let i = 0; i < this.unlockedVideoIds.length; i++) { if (this.unlockedVideoIds[i] === id) { return true; } } return false; } /** 解锁视频 */ public unlockVideo(id: number) { // 去重 let exists = this.isVideoUnlock(id);; if (!exists) { this.unlockedVideoIds.push(id); } console.log("技师 ", this.id, " 当前解锁视频的所有id:",this.unlockedVideoIds); } /** 获取所有解锁视频的 id */ public getUnlockedVideoIds(): number[] { return this.unlockedVideoIds; } /** 保存解锁视频 id */ public setUnlockedVideoIds(value: number[]): void { for(let one of value) { this.unlockVideo(one); } } }