UnlockSpecialPlotEventManager.ts
2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { UIManager } from "../../common/gameplay/managers/UIManager";
import { GameModelManager } from "./GameModelManager";
import { UnlockItemModelManager } from "./UnlockItemModelManager";
import { UnlockSpecialPlotModelManager } from "./UnlockSpecialPlotModelManager";
export default class UnlockSpecialPlotEventManager {
/**单例对象 */
private static _instance: UnlockSpecialPlotEventManager | undefined;
/**创建单例 */
public static getInstance(): UnlockSpecialPlotEventManager {
if (!UnlockSpecialPlotEventManager._instance) {
UnlockSpecialPlotEventManager._instance = new UnlockSpecialPlotEventManager();
}
return UnlockSpecialPlotEventManager._instance;
}
/**
* 兑换码解锁番外
* @param specialPlotId 要解锁的番外Id
* @param itemId 要解锁的和物品相关的Id,可为空
*/
cdKeyUnlockSpecialPlot(specialPlotId: number, itemId?: number) {
UnlockSpecialPlotModelManager.saveUnlockedSpecialPlotIdByItemIdToGameRecord(specialPlotId);
if (itemId) {
UnlockItemModelManager.saveItemIdToGameRecord(itemId);
UnlockItemModelManager.saveUnlockedIntroductionItemIdToGameRecord(itemId);
}
UIManager.showToast("兑换成功,请前往卧室查看呦~~");
}
/**
* 次日登陆解锁番外
* @param specialPlotId 要解锁的番外Id
*/
nextDayUnlockedSpecialPlot(specialPlotId: number) {
//检测手表番外2次日是否需要解锁,手表番外2的番外剧情Id是4
let needUnlock: boolean = false;
if (!UnlockSpecialPlotModelManager.checkSpecialPlotIdIsUnlocked(specialPlotId)) {
needUnlock = true;
}
//获取第一次登陆的时间
UnlockSpecialPlotModelManager.saveFirstDayTime();
let firstDayTime = UnlockSpecialPlotModelManager.getFirstDayTime();
if (needUnlock && firstDayTime) {
let canUnlock: boolean = GameModelManager.checkOverdue(firstDayTime);
if (canUnlock) {
UnlockSpecialPlotModelManager.saveUnlockedSpecialPlotIdByItemIdToGameRecord(specialPlotId);
UIManager.showSceneToast("解锁了新的番外,记得去卧室查看哦~");
}
}
}
isShowBedRoomRedDotStatus(itemId: number): boolean {
let allSpecialPlotId = UnlockSpecialPlotModelManager.allSpecialPlotIdByItemId(itemId);
//判断是否有未解锁的番外
let unlockedSpecialPlotId = UnlockSpecialPlotModelManager.unlockedSpecialPlotIdByItemId(itemId);
if (unlockedSpecialPlotId.length !== allSpecialPlotId.length) {
return true;
}
//判断是否有未观看的番外
let clickedSpecialPlotId = UnlockSpecialPlotModelManager.clickedSpecialPlotIdByItemId(itemId);
if (clickedSpecialPlotId.length !== allSpecialPlotId.length) {
return true;
}
return false;
}
}