egret-code-RedPoint

简介

RedPointLogic监听各种事件,事件触发就触发一次红点的检测,然后在绑定各种关联的子红点类型,子红点变动也通知一遍重新检测红点,并把最新的状态缓存起来。
RedPointMgr检测各种已经变动事件,做时间差,等待一段时间才真的检测一遍,以防事件重复触发。对于进入同样回调的事件,过滤只会触发一次。
RedPointItem默认一开始显示就获取一次红点状态控制显示,之后的显示与否会因事件触发导致的红点状态变动而被动控制显示与否。

RedPointMgr

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
class RedPointMgr
{
private static $inst:RedPointMgr;

public static getInstance():RedPointMgr
{
if(!RedPointMgr.$inst){
RedPointMgr.$inst = new RedPointMgr();
}

return RedPointMgr.$inst;
}

private arrRedPointSort:RedPointLogic[] = []; // 红点逻辑有序集合,关联的红点逻辑会丢到最后面

// 有监听的消息映射
// key => 消息名称
// val => 随意
private mapListenEvent:{[key:string]:boolean} = {};

// 红点逻辑映射
// key => 红点类型
// val => 红点逻辑
private mapRedPointLogic:{[key:number]:RedPointLogic} = {};

private readonly RED_POINT_CHECK_TIME_STRIDE = 0.5; // 红点检测的时间间隔

private constructor()
{
// 宠物界面的
this.AddRedPointLogic(new RedPointPetUiBtnUpTen());
this.AddRedPointLogic(new RedPointPetUiBtnUpOne());
this.AddRedPointLogic(new RedPointPetUiBtnSwitch());
this.AddRedPointLogic(new RedPointTabTuPo());
this.AddRedPointLogic(new RedPointTabJinHua());
this.AddRedPointLogic(new RedPointTabOverview());
this.AddRedPointLogic(new RedPointPetUiItemWarSlot());
this.AddRedPointLogic(new RedPointPetUiItemEquipSlot());
this.AddRedPointLogic(new RedPointPetUiBatSixEquip());
this.AddRedPointLogic(new RedPointBomUiIconPet());
this.AddRedPointLogic(new RedPointPetOtherUpOne());
this.AddRedPointLogic(new RedPointBagUiItemBtn());
this.AddRedPointLogic(new RedPointBagUiPieceBtn());
this.AddRedPointLogic(new RedPointBagUiSlotItem());
this.AddRedPointLogic(new RedPointBagUiRecovery());
this.AddRedPointLogic(new RedPointBagUiEggButton());
this.AddRedPointLogic(new RedPointBomUiIconBag());
this.AddRedPointLogic(new RedPointRightUiIconAchieve());
this.AddRedPointLogic(new RedPointAchievbeUiItemReward());
this.AddRedPointLogic(new RedPointElecPetTrival());
this.AddRedPointLogic(new RedPointLeftUiIconMail());

this.AddRedPointLogic(new RedPointDaoguanAwardBox());
this.AddRedPointLogic(new RedPointDaoguanMonsterButton());

this.AddRedPointLogic(new RedPointBomUiIconEgg());
this.AddRedPointLogic(new RedPointEggUiCatchPetBtn());
this.AddRedPointLogic(new RedPointEggUiEggLotteryBtn());

this.AddRedPointLogic(new RedPointVipUiButton());
this.AddRedPointLogic(new RedPointMonthCard());
this.AddRedPointLogic(new RedPointGodBossPrivateButton());
this.AddRedPointLogic(new RedPointSevenDayTaskDayButton());
this.AddRedPointLogic(new RedPointSevenDayTaskGetButton());
this.AddRedPointLogic(new RedPointSevenDayTaskTabButton());

this.AddRedPointLogic(new RedPointBomUiIconRole());
this.AddRedPointLogic(new RedPointRoleUiEquipTab());
this.AddRedPointLogic(new RedPointRoleUiEquipBetterSlot());
this.AddRedPointLogic(new RedPointRoleUiItemEquipSlot());
this.AddRedPointLogic(new RedPointRoleUiOneKeyEquip());
this.AddRedPointLogic(new RedPointRoleUiHorseTab());
this.AddRedPointLogic(new RedPointRoleUiMedalTab());


this.AddRedPointLogic(new RedPointBomUiIconPetEquip());
this.AddRedPointLogic(new RedPointPetEquipUiItemWarSlot());
this.AddRedPointLogic(new RedPointPetEquipUiSlotGem());
this.AddRedPointLogic(new RedPointPetEquipUiSlotQiangHua());
this.AddRedPointLogic(new RedPointPetEquipUiSlotStar());
this.AddRedPointLogic(new RedPointPetEquipUiSlotTuPo());
this.AddRedPointLogic(new RedPointPetEquipUiTabGem());
this.AddRedPointLogic(new RedPointPetEquipUiTabQiangHua());
this.AddRedPointLogic(new RedPointPetEquipUiTabStar());
this.AddRedPointLogic(new RedPointPetEquipUiTabTuPo());
this.AddRedPointLogic(new RedPointPetEquipUiItemEquipImprove());


this.AddRedPointLogic(new RedPointLeftUiIconActivity());
this.AddRedPointLogic(new RedPointLeftUiIconDailyRecharge());
this.AddRedPointLogic(new RedPointLeftUiIconFristRecharge());
this.AddRedPointLogic(new RedPointLeftUiIconFund());
this.AddRedPointLogic(new RedPointLeftUiIconLevelGift());
this.AddRedPointLogic(new RedPointLeftUiIconMonthCard());
this.AddRedPointLogic(new RedPointLeftUiIconSevenday());
this.AddRedPointLogic(new RedPointLeftUiIconSevendayTask());
this.AddRedPointLogic(new RedPointLeftUiIconTimeGodPet());
this.AddRedPointLogic(new RedPointLeftUiIconVIP());
this.AddRedPointLogic(new RedPointLeftUiIconXinShouHaoLi());
this.AddRedPointLogic(new RedPointLeftUiIconLvLimit());
this.AddRedPointLogic(new RedPointLeftUiIconLimitBuy());
this.AddRedPointLogic(new RedPointLeftUiIconWheelFortune());

this.AddRedPointLogic(new RedPointEquipDetailButton());
this.AddRedPointLogic(new RedPointGodBossFightButton());
this.AddRedPointLogic(new RedPointPetEquipDetailButton());
this.AddRedPointLogic(new RedPointRoleUiHorseButton());
this.AddRedPointLogic(new RedPointRoleUiHorseNewHuanhua());
this.AddRedPointLogic(new RedPointMedalUi());
this.AddRedPointLogic(new RedPointMedalItem());

this.AddRedPointLogic(new RedPointWelfareUITabLevel());
this.AddRedPointLogic(new RedPointWelfareUITabOnline());
this.AddRedPointLogic(new RedPointWelfareUITabSignIn());

this.AddRedPointLogic(new RedPointActUITabTimeRecharge());
this.AddRedPointLogic(new RedPointActUITabDailyCumulRecharge());
this.AddRedPointLogic(new RedPointActUITabCumulCost());
this.AddRedPointLogic(new RedPointActUITabDailyCumulCost());
this.AddRedPointLogic(new RedPointActUITabLoginGift());
this.AddRedPointLogic(new RedPointActUITabHangupLvRoulette());
this.AddRedPointLogic(new RedPointActUITabHolidayChange());
this.AddRedPointLogic(new RedPointActUITabRankLevel());
this.AddRedPointLogic(new RedPointActUITabRankAllFight());
this.AddRedPointLogic(new RedPointActUITabRankPetFight());
this.AddRedPointLogic(new RedPointActUITabRankHorse());
this.AddRedPointLogic(new RedPointTimeGodPetFreeBuy());
this.AddRedPointLogic(new RedPointHomeTopUIBecomeStrongBtn());
this.AddRedPointLogic(new RedPointHomeTopUIRankBtn());
this.AddRedPointLogic(new RedPointRankUITabLevel());
this.AddRedPointLogic(new RedPointRankUITabTotalFight());

this.AddRedPointLogic(new RedPointHomeUIRightBtnElecPet());
this.AddRedPointLogic(new RedPointElecPetUIBtnDiet());
this.AddRedPointLogic(new RedPointElecPetUIBtnHealth());
this.AddRedPointLogic(new RedPointElecPetUIBtnIntimacy());
this.AddRedPointLogic(new RedPointElecPetUIBtnSleep());

this.AddRedPointLogic(new RedPointRightUiIconBOSS());
this.AddRedPointLogic(new RedPointRightUiIconRecovery());
this.AddRedPointLogic(new RedPointRightUiIconShop());
this.AddRedPointLogic(new RedPointShopUiTabMallType());

this.AddRedPointLogic(new RedPointFriendUiBtnInvite());
this.AddRedPointLogic(new RedPointBomUiIconFriend());

this.AddRedPointLogic(new RedPointRightUiIconDaily());
this.AddRedPointLogic(new RedPointDailyChallengeUiBtnGym());
this.AddRedPointLogic(new RedPointDailyChallengeUiTabDaily());
this.AddRedPointLogic(new RedPointDailyChallengeUiBtnAward());

this.AddRedPointLogic(new RedPointDaMuFollowPetSelectBtn());

this.AddRedPointLogic(new RedPointLogicAlwayTrue());

this.AddRedPointLogic(new RedPointActUILvLimitBuy());
this.AddRedPointLogic(new RedPointActUILimitBuyOne());
this.AddRedPointLogic(new RedPointChatUIPrivateBtn());
this.AddRedPointLogic(new RedPointChatUIPrivateCell());

this.AddRedPointLogic(new RedPointWheelFreeButton());
this.AddRedPointLogic(new RedPointWheelNewDay());

this.AddRedPointLogic(new RedPointDailyRecharge());
this.AddRedPointLogic(new RedPointDailyRechargeAwards());
this.AddRedPointLogic(new RedPointDailyRechargeCache());
this.AddRedPointLogic(new RedPointDailyRechargeIcon());

this.AddRedPointLogic(new RedPointRightUiIconChallenge());
this.AddRedPointLogic(new RedPointChallengeUiGym());
this.AddRedPointLogic(new RedPointGymButtonArea());

this.AddRedPointLogic(new RedPointFirstRechargeButtonVOne());
this.AddRedPointLogic(new RedPointFirstRechargeButtonVFour());
this.AddRedPointLogic(new RedPointFirstRechargeClick());

this.AddRedPointLogic(new RedPointHomeUIRightBtnLeague());
this.AddRedPointLogic(new RedPointLeagueMainUIBtnMember());
this.AddRedPointLogic(new RedPointLeagueMainUIBtnMessage());
this.AddRedPointLogic(new RedPointLeagueMainUIBtnDonate());
this.AddRedPointLogic(new RedPointLeagueMainUIBtnSkill());
this.AddRedPointLogic(new RedPointLeagueMainUIBtnBonus());
this.AddRedPointLogic(new RedPointLeagueLeaderUIBtnApplyAdd());
this.AddRedPointLogic(new RedPointLeagueLeaderUIBtnApplyPost());


this.SortRedPointLogic();
this.BindRelateRedPointChildEvent();
this.CacheListenMsg();

GameTimer.AddTimerBehavior(this.OnTimer, -1, 0, 0, this);
}

// 定时器行为
// @deltaTime:帧时间
// @runTime:定时器已经运行时间
private OnTimer(deltaTime:number, runTime:number)
{
if(!GameData.isEnterGame){
// 这里不加判断,断线重连的时候可能会因为数据已清除导致在判断的时候没有数据
return
}

let timeNowSec = GameHelp.LocalTimeNowSec;

for(let i = 0; i < this.arrRedPointSort.length; ++i){
let logic = this.arrRedPointSort[i];
logic.OnTimer(deltaTime, timeNowSec);
}
}

// 清理定时器的检测行为
public CleanTimerCheck()
{
for(let i = 0; i < this.arrRedPointSort.length; ++i){
let logic = this.arrRedPointSort[i];
logic.CleanTimerCheck();
}
}

// 绑定红点
// @redPointItem:红点图标
public BindRedPoint(redPointItem:RedPointItem) : void
{
if(redPointItem.OldRedPointType){
// 要先移除红点,进来这里有可能参数变了
let oldLogic = this.mapRedPointLogic[redPointItem.OldRedPointType];
oldLogic.UnbindRedPoint(redPointItem);
}

let logic = this.mapRedPointLogic[redPointItem.RedPointType];
if(logic){
logic.BindRedPoint(redPointItem);
}
}

// 解除红点的绑定
public UnbindRedPoint(redPointItem:RedPointItem) : void
{
let logic = this.mapRedPointLogic[redPointItem.RedPointType];
if(logic){
logic.UnbindRedPoint(redPointItem);
}
}

// 事件处理
// @msgName:事件名称
// @data:事件参数
public HandleEvent(msgName:string, data:any) : void
{
if(this.mapListenEvent[msgName] == null){
return;
}

let num = 0;

let timeNowSec = GameHelp.LocalTimeNowSec;

let eIdx = 0;
for(let i = 0; i < this.arrRedPointSort.length; ++i){
let logic = this.arrRedPointSort[i];
let listen = logic.HandleEvent(msgName, data, timeNowSec, eIdx);
if(listen){
++eIdx;
}

num += logic.GetBindRedPointNum();;
}

//Logger.Error("红点绑定数量" + num);
}

// 查询其它红点在某参数下的状态
// @pointType:红点类型
// @param:参数集合
// return:需要显示返回true;否则false
public QueryOtherRedPointParamStatus(pointType:RedPointType, param:any[])
{
let logic = this.mapRedPointLogic[pointType];
if(logic == null){
return false;
}

return logic.GetRedPointParamStatus(param);
}

// 添加红点逻辑
// @redPointLogic:红点逻辑
private AddRedPointLogic(redPointLogic:RedPointLogic) : void
{
let redPointType = redPointLogic.GetRedPoinType();
if(this.mapRedPointLogic[redPointType] != null){
console.error("红点类型重复绑定!" + redPointType);
}

this.mapRedPointLogic[redPointType] = redPointLogic;
redPointLogic.Init();
}

// 排序红点逻辑
private SortRedPointLogic()
{
let mapSortLogic = {};
let arrSortKey:number[] = [];

for(let key in this.mapRedPointLogic){
let val = this.mapRedPointLogic[key];
//let weight = this.CaclRedPointLogicSortValue(+key);
let depth = this.CalcRedPointDepth(+key);

while(mapSortLogic[depth] != null){
depth += 0.01;
}

val.SetDepth(depth);
mapSortLogic[depth] = val;
arrSortKey.push(depth);
}

arrSortKey.sort((a,b)=>{
return a-b;
});

for(let i = 0; i < arrSortKey.length; ++i){
let key = arrSortKey[i];
let logic = mapSortLogic[key];
this.arrRedPointSort.push(logic);
}
}

// 绑定关联红点的子事件
// 绑定子事件,是用于子事件变动了,通知更新关联的红点
private BindRelateRedPointChildEvent()
{
for(let i = 0; i < this.arrRedPointSort.length; ++i){
let logic = this.arrRedPointSort[i];
let logicType = logic.GetRedPoinType();
let arrEvt = this.GetRedPointAllRelateChildEvent(logicType);

if(arrEvt == null){
continue;
}

for(let j = 0; j < arrEvt.length; ++j){
logic.ListenMsg(arrEvt[j]);
}
}
}

// 缓存监听的消息
private CacheListenMsg()
{
for(let i = 0; i < this.arrRedPointSort.length; ++i){
let logic = this.arrRedPointSort[i];
let mapEvent = logic.MapEventHandle;

for(let key in mapEvent){
this.mapListenEvent[key] = true;
}
}
}

// 获取红点关联的所有子事件
// @logicType:逻辑类型
// return:事件集合
private GetRedPointAllRelateChildEvent(logicType:RedPointType) : string[]
{
let logic = this.mapRedPointLogic[logicType];

let arrRelate = logic.GetRelateRedPoints();
if(arrRelate == null){
return null;
}

let arrAllEvent:string[] = [];

for(let i = 0; i < arrRelate.length; ++i){
let rType = arrRelate[i];
let rLogic = this.mapRedPointLogic[rType];
let arrEvt = rLogic.GetBindEvents();

for(let j = 0; j < arrEvt.length; ++j){
arrAllEvent.push(arrEvt[j]);
}

let arrChildEvt = this.GetRedPointAllRelateChildEvent(rType);
if(arrChildEvt == null){
continue;
}

for(let j = 0; j < arrChildEvt.length; ++j){
arrAllEvent.push(arrChildEvt[j]);
}
}

return arrAllEvent;
}

// 计算红点逻辑的排序值
// @logicType:逻辑类型
// return:排序值
private CaclRedPointLogicSortValue(logicType:RedPointType) : number
{
let logic = this.mapRedPointLogic[logicType];

let value = logic.GetRedPoinType();

let arrRelate = logic.GetRelateRedPoints();
if(arrRelate != null){
for(let i = 0; i < arrRelate.length; ++i){
let rType = arrRelate[i];
if(rType == logicType){
console.error("red point relate cycle: " + RedPointType[rType]);
continue;
}

value += this.CaclRedPointLogicSortValue(rType);
}
}

return value;
}

// 计算红点逻辑的深度
// @logicType:逻辑类型
private CalcRedPointDepth(logicType:RedPointType) : number
{
let arrDepthCache:number[] = [];
this.CalcRedPointDepthWithData(logicType, 0, arrDepthCache);

let maxDepth = 0;
for(let i = 0; i < arrDepthCache.length; ++i){
if(arrDepthCache[i] > maxDepth){
maxDepth = arrDepthCache[i];
}
}

return maxDepth;
}

// 计算红点逻辑的深度
// @logicType:逻辑类型
// @curDepth:当前深度值
// @arrDepthCache:深度缓存集合
private CalcRedPointDepthWithData(logicType:RedPointType, curDepth:number, arrDepthCache:number[]) : void
{
let logic = this.mapRedPointLogic[logicType];

let newDepth = curDepth + 1;
arrDepthCache.push(newDepth);
let arrRelate = logic.GetRelateRedPoints();
if(arrRelate != null){
for(let i = 0; i < arrRelate.length; ++i){
let rType = arrRelate[i];
if(rType == logicType){
console.error("red point relate cycle: " + RedPointType[rType]);
continue;
}

this.CalcRedPointDepthWithData(rType, newDepth, arrDepthCache);
}
}
}
}

RedPointLogic

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
// 红点模块类型
enum RedPointType
{
BOM_UI_ICON_PET = 1, // 宠物底部图标

PET_UI_ITEM_WAR_SLOT, // 宠物界面,顶部的宠物图标
PET_UI_ITEM_EQUIP_SLOT, // 宠物界面,装备位置
PET_UI_BTN_UP_TEN, // 宠物界面,升10级按钮
PET_UI_BTN_UP_ONE, // 宠物界面,升1级按钮
PET_UI_BTN_SWITCH, // 宠物界面,切换按钮
PET_UI_TAB_OVERVIEW, // 宠物界面,总览页签
PET_UI_TAB_JINHU, // 宠物界面,进化页签
PET_UI_TAB_TUPO, // 宠物界面,突破页签
PET_UI_BAT_SIX_EQUIP, // 宠物界面,6件装备
PET_OTHER_UP_ONE, // 其它用途,可以升一级



BOM_UI_ICON_BAG, // 背包底部图标
BAG_UI_BTN_ITEM, // 背包界面,顶部的道具按钮
BAG_UI_BTN_PIECE, // 背包界面,顶部的碎片按钮
BAG_UI_SLOT_ITEM, // 背包界面,每個道具
BAG_UI_RECOVERY_BUTTON, // 背包界面,熔炼按钮
BAG_UI_EGG_BUTTON, // 背包界面,宠物蛋孵化按钮

BOM_UI_ICON_ROLE, // 角色底部图标
ROLE_UI_TAB_EQUIP, //角色界面,装备标签
ROLE_UI_TAB_HORSE, //角色界面,坐骑标签
ROLE_UI_TAB_MEDAL, //角色界面,勋章标签
ROLE_UI_BTN_ONEKEY_EQUIP, //角色界面,一键换装
ROLE_UI_ITEM_EQUIP_SLOT, //装备界面,装备位置
ROLE_UI_ITEM_BETTER_SLOT, //装备界面,装备位置有更好的
ROLE_UI_HORSE_LEVEL_UP_BUTTON, //坐骑界面升星按钮
ROLE_UI_HORSE_NEW_HUANHUA, //坐骑界面新的幻化
ROLE_UI_MEDAL_UI, //勋章界面激活按钮
ROLE_UI_MEDAL_ITEM, //勋章界面勋章

EQUIP_DETAIL_BUTTON, //人物装备更换按钮
PET_EQUIP_DETAIL_BUTTON, //宠物装备更换按钮

BOM_UI_ICON_EGG, // 扭蛋底部图标
EGG_UI_BTN_CATCH_PET, // 扭蛋界面,有免费狩猎次数
EGG_UI_BTN_EGG_LOTTERY, // 扭蛋界面,有免费扭蛋次数或者是道具

BOM_UI_ICON_PETEQUIP, // 装备底部图标
PETEQUIP_UI_ITEM_WAR_SLOT, // 宠物装备界面,顶部的宠物图标
PETEQUIP_UI_TAB_QIANGHUA, // 宠物装备界面,强化页签
PETEQUIP_UI_TAB_STAR, // 宠物装备界面,升星页签
PETEQUIP_UI_TAB_TUPO, // 宠物装备界面,突破页签
PETEQUIP_UI_TAB_GEM, // 宠物装备界面,宝石页签
PETEQUIP_UI_QIANGHUA_SLOT, // 宠物装备界面,每件装备强化
PETEQUIP_UI_STAR_SLOT, // 宠物装备界面,每件装备升星
PETEQUIP_UI_TUPO_SLOT, // 宠物装备界面,每件装备突破
PETEQUIP_UI_GEM_SLOT, // 宠物装备界面,每件装备宝石
PETEQUIP_UI_ITEM_EQUIP_IMPROVE, // 宠物装备界面,每件装备是否可以有红点

RIGHT_UI_ICON_ACHIEVE, // 成就按钮
ACHIEVE_UI_BTN_REWARD, // 成就按钮

ELECPET_UI_BTN_TRIVAL, // 電子寵物旅游按鈕

LEFT_UI_ICON_MAIL, // 邮件


//----- 下面这一串不能修改顺序
LEFTPANEL_BTN_BEGIN, //左边层的按钮事件
LEFTPANEL_BTN_MONTHCARD, //左边层的按钮 月卡
LEFTPANEL_BTN_VIP, //左边层的按钮 VIP
LEFTPANEL_BTN_FRISTRECHARGE, //左边层的按钮 首充
LEFTPANEL_BTN_DAILYRECHARGE, //左边层的按钮 每日首充
LEFTPANEL_BTN_SEVENDAY, //左边层的按钮 七天
LEFTPANEL_BTN_LEVELGIFT, //左边层的按钮 福利
LEFTPANEL_BTN_SEVENDAYTASK, //左边层的按钮 七日任务
LEFTPANEL_BTN_TIMEGODPET , //左边层的按钮 限时神兽
LEFTPANEL_BTN_ACTIVITY , //左边层的按钮 活动
LEFTPANEL_BTN_FUND , //左边层的按钮 基金
LEFTPANEL_BTN_XINSHOUHAOLI , //左边层的按钮 新手豪礼
LEFTPANEL_BTN_LVLIMIT , //左边层的按钮 等级限购
LEFTPANEL_BTN_LIMIT_BUY , //左边层的按钮 限购特惠
LEFTPANEL_BTN_WHEEL_FORTUNE , //左边层的按钮 大转盘
//----- 上面这一串不能修改顺序

VIP_UI_BUTTON, // VIP界面内按钮红点
MONTH_CARD_BUTTON, // 月卡按钮
FIRST_RECHARGE_V1_BUTTON, // 首充v1奖励获取按钮
FIRST_RECHARGE_V4_BUTTON, // 首充v1奖励获取按钮
FIRST_RECHARGE_CLICK, // 首充点击红点

SEVEN_DAY_TASK_BUTTON, // 七日任务领取按钮
SEVEN_DAY_TASK_DAY_BUTTON, // 七日任务天数按钮
SEVEN_DAY_TASK_TAB_BUTTON, // 七日任务菜单按钮

GODBOOS_PRIVATE_BUTTON, // 个人boss按钮
WELFARE_GIFT_LEVEL, //福利-等级礼包
WELFARE_GIFT_ONLINE, //福利-在线礼包
WELFARE_GIFT_SIGNIN, //福利-签到礼包

ACT_TIME_RECHARGE, //活动-限时充值
ACT_DAILY_CUMUL_RECHARGE, //活动-每日累计充值
ACT_CUMUL_COST, //活动-累计消耗
ACT_DAILY_CUMUL_COST, //活动-每日累计消耗
ACT_LOGIN_GIFT, //活动-登录礼包
ACT_HANGUP_LV_ROULETTE, //活动-关卡转盘
ACT_HOLIDAY_CHANGE, //活动-节日兑换
ACT_OPEN_LV_RANK, //活动-开服排行-等级
ACT_OPEN_FIGHT_VALUE_ALL_RANK, //活动-开服排行-总战力
ACT_OPEN_ALL_PET_RANK, //活动-开服排行-宠物战力
ACT_OPEN_MOUNT_RANK, //活动-开服排行-坐骑

TIMEGODPET_FREEBUY, //限时神兽免费购买

GOD_BOSS_FIGHT_BUTTON, //神兽挑战按钮

HOMETOP_UI_BTN_BECOMESTRONG, //首页上部按钮-变强
HOMETOP_UI_BTN_RANK, //首页上部按钮-排行
RANK_UI_TAB_TOTALFIGHT, //排行榜-总战力按钮
RANK_UI_TAB_LEVEL, //排行榜-等级按钮

ELECPET_UI_BTN_INTIMACY, // 电子宠物按鈕-亲密度
ELECPET_UI_BTN_HEALTH, // 电子宠物按鈕-健康
ELECPET_UI_BTN_SLEEP, // 电子宠物按鈕-睡觉
ELECPET_UI_BTN_DIET, // 电子宠物按鈕-吃东西

HOMERIGHT_UI_BTN_ELECPET, // 首页右边按钮-电子宠物

RIGHT_UI_ICON_BOSS, //挂机boss可挑战按钮
RIGHT_UI_ICON_SHOP, //主頁商店按钮
SHOP_UI_TAB_MALLTYPE, //具体每个商店红点

RIGHT_UI_ICON_RECOVERY, //熔炼按钮

RIGHT_UI_ICON_DAILY, //右边日常按钮
DAILYCHALLENGE_UI_TAB_DAILY, //日常活动界面道馆提示
DAILYCHALLENGE_UI_BTN_GYM, //日常活动界面道馆提示
DAILYCHALLENGE_UI_AWARD, //日常活动可领取奖励

HOME_UI_BTN_FRIEND, //好友按钮
FRIEND_UI_BTN_INVITE, //邀请按钮

DAMU_FOLLOWPET_SELECT_UI_BTN, // 大木博士家选择跟随宠物确定按钮红点提示

DAOGUAN_MONSTER_CELL_BUTTON, //道馆挑战红点
DAOGUAN_MONSTER_AWARD_BOX, //道馆挑战宝箱红点

LV_LIMIT_BUY, // 等级限购
LIMIT_BUY_ONE, // 限购1

ALWAY_TRUE, // 总是显示的红点
CHAT_PRIVATE_BTN, // 私聊按钮
CHAT_PRIVATE_CELL, // 单个私聊

WHEEL_FREE_BUTTON, // 大转盘免费次数按钮红点
WHEEL_NEW_DAY, // 转盘新一天红点提示

DAILY_RECHARGE_CAN_GET_AWARD, // 每日充值可领取宝箱红点
DAILY_RECHARGE_AWARD, // 每日充值可领取红点
DAILY_RECHARGE_CACHE, // 每日充值每日出现一次缓存红点
DAILY_RECHARGE_ICON, // 每日充值可领取宝箱红点


RIGHT_UI_ICON_CHALLENGE, //挑战底部图标
RIGHT_UI_CHALLENGE_GYM, //挑战道馆红点
GYM_UI_BUTTON_AREA, //道馆每个区域红点
// GYM_UI_BOX_AREA, //道馆每个区域宝箱红点

HOME_UI_RIGHT_ICON_LEAGUE, // 首页联盟按钮
LEAGUE_MAIN_UI_BTN_MEMBER, // 联盟主页面按钮-查看成员
LEAGUE_MAIN_UI_BTN_MESSAGE, // 联盟主页面按钮-留言板
LEAGUE_MAIN_UI_BTN_DONATE, // 联盟主页面按钮-联盟捐献
LEAGUE_MAIN_UI_BTN_SKILL, // 联盟主页面按钮-联盟技能
LEAGUE_MAIN_UI_BTN_BONUS, // 联盟主页面按钮-联盟分红
LEAGUE_LEADER_UI_BTN_APPLYADD, // 联盟查看成员页面按钮-加入申请
LEAGUE_LEADER_UI_BTN_APPLYPOST, // 联盟查看成员页面按钮-官员申请

}

// 红点状态数据
interface RedPointStatusData
{
arrParam:any[]; // 参数集合
isRed:boolean; // 红点是否显示的标识
}

// 红点检测数据
interface RedPointCheckData
{
isComm:boolean; // 是否是通用检测函数的标识
handle:Function; // 事件检测回调
binder:any; // 事件回调绑定者
}

abstract class RedPointLogic
{
private depth:number; // 红点深度
private nextNoParamCommEventCheckTime:number; // 下一次没有参数的通用事件检测时间

private arrRedPointStatus:RedPointStatusData[] = []; // 红点状态缓存集合

// 监听的事件回调映射
// key => 事件名称
// val => 事件处理回调
private mapEventHandle:{[key:number]:RedPointCheckData} = {};

// 红点实例映射
// key => 红点ID
// val => 红点图标
private mapRedPoint:{[key:number]:RedPointItem} = {};

//private static readonly RED_POINT_CHECK_TIME_STRIDE = 0.25; // 红点检测的时间间隔

public get MapEventHandle() { return this.mapEventHandle;}

protected get MapRedPoint() { return this.mapRedPoint; }

// 获取红点类型
// return:红点类型
public abstract GetRedPoinType();

// 检测红点参数的状态
// @param:红点参数集合
// return:显示返回true;否则false
protected abstract CheckRedPointParamStatus(param:any[]):boolean;

// 初始化自定义行为
protected abstract OnInit();

constructor()
{
this.depth = 0;
}

// 初始化
public Init()
{
this.OnInit();
}

// 获取绑定的红点数量
// return:红点数量
public GetBindRedPointNum()
{
let num = 0;
for(let key in this.mapRedPoint){
++num;
}

return num;
}

// 定时器行为
// @deltaTime:帧时间
// @timeNowSec:当前客户端时间
public OnTimer(deltaTime:number, timeNowSec:number)
{
if(!(this.nextNoParamCommEventCheckTime > 0 && timeNowSec > this.nextNoParamCommEventCheckTime)){
return;
}

//console.time("红点消耗" + this.GetRedPoinType());

//let _time1 = GameHelp.LocalTimeNow;

this.nextNoParamCommEventCheckTime = -1;
this.ResetCache();
this.Handle_CommEvent(null);

//console.timeEnd("红点消耗" + this.GetRedPoinType());

//let _time2 = GameHelp.LocalTimeNow;

//if(_time2 - _time1 > 0){
// Logger.Log("进入一个比较耗时的通用红点检测" + RedPointType[this.GetRedPoinType()] + " 消耗时间: " + (_time2 - _time1));
//}
}

// 清理定时器的检测
public CleanTimerCheck()
{
this.nextNoParamCommEventCheckTime = -1;
}
// 设置深度
// @depth:红点逻辑深度
public SetDepth(depth:number)
{
this.depth = depth;
}

// 获取关联的红点
// return:关联的红点集合
public GetRelateRedPoints() : RedPointType[]
{
return null;
}

// 获取监听的事件集合
public GetBindEvents() : string[]
{
let arrEvt:string[] = [];
for(let key in this.mapEventHandle){
arrEvt.push(key);
}

return arrEvt;
}

// 绑定红点
// @redPoint:红点实例
public BindRedPoint(redPoint:RedPointItem) : void
{
let isRead = this.GetRedPointParamStatus(redPoint.Param);
redPoint.SetVisible(isRead);

this.mapRedPoint[redPoint.Id] = redPoint;
}

// 移除一个红点的绑定
// @redPoint:红点实例
public UnbindRedPoint(redPoint:RedPointItem) : void
{
delete this.mapRedPoint[redPoint.Id];
}

// 事件处理
// @msgName:事件名称
// @data:事件参数
// @timeNowSec:当前客户端时间
// return:有监听返回ture;否则false
public HandleEvent(msgName:string, data:any, timeNowSec:number, idx:number) : boolean
{
if(GameUtil.isMapNullOrEmpty(this.mapRedPoint)){
this.ResetCache();
return;
} else {
// let num = 0;
// for(let key in this.mapRedPoint){
// ++num;
// }

// Logger.Error("红点绑定数量:" + RedPointType[this.GetRedPoinType()] + " " + num)
}

let checkData:RedPointCheckData = this.mapEventHandle[msgName];
if(checkData){
if((checkData.isComm)){
// 优化,没有参数的通用事件,间隔触发,不需要每次都离开全部触发
this.nextNoParamCommEventCheckTime = timeNowSec + idx * 0.15; // + 0.05 * this.depth; // + RedPointLogic.RED_POINT_CHECK_TIME_STRIDE;
//Logger.Log("通用红点检测时间:" + RedPointType[this.GetRedPoinType()] + " " + this.nextNoParamCommEventCheckTime);
} else {
// 每次遇到数据变动,都要把缓存清除
this.ResetCache();
checkData.handle.call(checkData.binder, data);

Logger.Log("进入一个有参数的红点检测" , RedPointType[this.GetRedPoinType()]);
}
}

return checkData != null;
}

// 获取红点某参数下的状态
// @param:该参数下的红点状态
// return:需要显示返回true;否则false
public GetRedPointParamStatus(param:any[]) : boolean
{
// 缓存判断
for(let i = 0; i < this.arrRedPointStatus.length; ++i){
let statusData = this.arrRedPointStatus[i];
if(statusData.arrParam == param){
// 参数一致
return statusData.isRed;
}

if(statusData.arrParam && param && statusData.arrParam.length == param.length){
// 进一步进行参数一致判断
let allRight = true;
for(let j = 0; j < param.length; ++j){
if(statusData.arrParam[j] != param[j]){
allRight = false;
break;
}
}

if(allRight){
return statusData.isRed;
}
}
}

// 没有缓存的重新判断
let isRed = this.CheckRedPointParamStatus(param);

let newStatusData = <RedPointStatusData>{};
newStatusData.isRed = isRed;
newStatusData.arrParam = param;

this.arrRedPointStatus.push(newStatusData);

return isRed;
}

// 查询其它红点在某参数下的状态
// @pointType:红点类型
// @param:该参数下的红点状态
// return:需要显示返回true;否则false
public QueryOtherRedPointParamStatus(pointType:RedPointType, param:any[])
{
return RedPointMgr.getInstance().QueryOtherRedPointParamStatus(pointType, param);
}

// 查询关联的红点状态
// @param:该参数下的红点状态
// return:有一个需要显示红点就返回true了否则false
public QueryRelateRedPointParamStatus(param:any[]) : boolean
{
let arrRelate = this.GetRelateRedPoints();
for(let i = 0; i < arrRelate.length; ++i){
let redShow = this.QueryOtherRedPointParamStatus(arrRelate[i], param);
if(redShow){
return true;
}
}

return false;
}

// 监听消息
// @binder:消息绑定者
// @msgName:消息名称
// @handle:消息回调
public ListenMsg(msgName:string, handle:Function = null) : void
{
if(this.mapEventHandle[msgName]){
return;
}

let checkData = <RedPointCheckData>{};
checkData.handle = handle;
checkData.isComm = false;
checkData.binder = this;

if(handle == null){
checkData.isComm = true;
checkData.handle = this.Handle_CommEvent;
}

this.mapEventHandle[msgName] = checkData;
}

// 事件通用回调处理
protected Handle_CommEvent(data:any) : void
{
this.UpdateRedPoinsItemStatus();
}

// 更新红点图标的状态
protected UpdateRedPoinsItemStatus()
{
for(let key in this.mapRedPoint){
let point = this.mapRedPoint[key];

let status = this.GetRedPointParamStatus(point.Param);
point.SetVisible(status);
}
}

// 重置红点缓存
private ResetCache()
{
this.arrRedPointStatus = [];
}


}

RedPointItem

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// 红点显示类型
enum RedPointDispType
{
RED_POINT_BIG, // 大红点
RED_POINT_SMALL, // 小红点
ADD, // 加号
ARROW, // 箭头
}

class RedPointItem extends eui.ItemRenderer
{
private static s_id:number = 0; // 红点id

//private effImgAuto:EffectImageAuto; // 特效播放器
private groupTipNode:eui.Group; // 提示节点

private id:number; // 红点id
private param:any[]; // 参数集合
private redPointType:RedPointType; // 绑定红点类型
private oldRedPointType:RedPointType;// 旧的红点类型

private timerId:number; // 定时器id
private dispType:RedPointDispType; // 红点显示类型

private static REDPOINT_ANICURVE:AniCurve = new AniCurve([{time:0,value:0,inTangent:600,outTangent:-225.0225},
{time:0.06666,value:-15,inTangent:-225.0225,outTangent:719.964},
{time:0.13333,value:33,inTangent:719.964,outTangent:-429.9871},
{time:0.233333,value:-10,inTangent:-429.9871,outTangent:-127.5061},
{time:0.36666,value:-27,inTangent:-127.5061,outTangent:202.4899},
{time:0.5,value:0,inTangent:202.4899,outTangent:0},
{time:1,value:0,inTangent:0,outTangent:0}]); // 红点动画曲线

private static ADD_ANICURVE:AniCurve = new AniCurve([{time:0,value:1,inTangent:600,outTangent:2.5},
{time:0.1,value:1.25,inTangent:2.5,outTangent:-1.071582},
{time:0.3333,value:1,inTangent:-1.071582,outTangent:0},
{time:1,value:1,inTangent:0,outTangent:0}]); // 加号动画曲线

private static ARROW_ANICURVES:AniCurves = new AniCurves(
[{time:0,value:0,inTangent:600,outTangent:0},
{time:0.2,value:0,inTangent:0,outTangent:-106.3827},
{time:0.2564001,value:-6,inTangent:-106.3827,outTangent:24.63056},
{time:0.5,value:0,inTangent:24.63056,outTangent:0},
{time:0.6,value:0,inTangent:0,outTangent:600}],

[{time:0,value:1,inTangent:600,outTangent:1.6379},
{time:0.2,value:1.32758,inTangent:1.6379,outTangent:-5.808142},
{time:0.2564001,value:1,inTangent:-5.808142,outTangent:0},
{time:0.5,value:1,inTangent:0,outTangent:0},
{time:0.6,value:1,inTangent:0,outTangent:600}],

[{time:0,value:1,inTangent:600,outTangent:-1.8966},
{time:0.2,value:0.62068,inTangent:-1.8966,outTangent:10.39377},
{time:0.2564001,value:1.20689,inTangent:10.39377,outTangent:-0.5661926},
{time:0.5,value:1.068966,inTangent:-0.5661926,outTangent:-0.6896554},
{time:0.6,value:1,inTangent:-0.6896554,outTangent:600}]
); // 箭头的动画曲线

public get Id() { if(!(this.id > 0)) { this.id = ++RedPointItem.s_id } return this.id; }
public get Param() { return this.param; }
public get RedPointType() { return this.redPointType; }
public get OldRedPointType() { return this.oldRedPointType; }
//public get Display() { return this.effImgAuto && this.effImgAuto.visible; }

constructor()
{
super();

this.skinName = "CommSkins_Item_RedPoint";
this.touchEnabled = false;
this.touchChildren = false;

this.addEventListener(egret.Event.ADDED_TO_STAGE, this.OnAddFromStage, this);
this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.OnRemoveFromStage, this);
}

// 设置红点的显示
// @show:是否显示
public SetVisible(show:boolean) : void
{
this.groupTipNode.visible = show;

if(show){
if(!(this.timerId > 0)){
this.timerId = GameTimer.AddTimerBehavior(this.OnTimer, -1, 0, 0, this);
}
} else {
if(this.timerId > 0){
GameTimer.RemoveTimerBehavior(this.timerId);
this.timerId = -1;
}
}

// if(this.effImgAuto){
// this.effImgAuto.visible = show;
// }
}


// 定时器行为
// @d:帧率时间
// @r:已经运行时间
private OnTimer(d:number, r:number)
{
if(this.dispType == RedPointDispType.RED_POINT_BIG || this.dispType == RedPointDispType.RED_POINT_SMALL){
let val = RedPointItem.REDPOINT_ANICURVE.EvaluateLoop(r);
this.groupTipNode.rotation = val;
} else if(this.dispType == RedPointDispType.ADD){
let val = RedPointItem.ADD_ANICURVE.EvaluateLoop(r);
this.groupTipNode.scaleX = val;
this.groupTipNode.scaleY = val;
} else if(this.dispType == RedPointDispType.ARROW){
let arrVal = RedPointItem.ARROW_ANICURVES.EvaluateLoop(r);
this.groupTipNode.y = arrVal[0] + 16;
this.groupTipNode.scaleX = arrVal[1];
this.groupTipNode.scaleY = arrVal[2];
}
}

// 绑定红点
// @redPoinType:绑定的红点类型
// @param:参数
public BindSmall(redPoinType:RedPointType, ...param:any[])
{
this.BindWithEffId(redPoinType, RedPointDispType.RED_POINT_SMALL, ...param);

// if(this.effImgAuto){
// this.effImgAuto.scaleX = 1;
// this.effImgAuto.scaleY = 1;
//}
}

// 绑定红点
// @redPoinType:绑定的红点类型
// @param:参数
public BindBig(redPoinType:RedPointType, ...param:any[])
{
this.BindWithEffId(redPoinType, RedPointDispType.RED_POINT_BIG, ...param);
}

// 绑定红点(绿色加号按钮)
// @redPoinType:绑定的红点类型
// @param:参数
public BindAddEquip(redPoinType:RedPointType, ...param:any[])
{
this.BindWithEffId(redPoinType, RedPointDispType.ADD, ...param);
}

// 绑定红点(向上绿色箭头)
// @redPoinType:绑定的红点类型
// @param:参数
public BindBetterEquip(redPoinType:RedPointType, ...param:any[])
{
this.BindWithEffId(redPoinType, RedPointDispType.ARROW, ...param);
}

// 绑定红点
// @redPoinType:绑定的红点类型
// @effectId:特效id
// @param:参数集合
public BindWithEffId(redPoinType:RedPointType, dispType:RedPointDispType, ...param:any[])
{
if(!this.visible){
// 没有显示的红点没有必要绑定
return;
}

this.oldRedPointType = this.redPointType;
this.redPointType = redPoinType;
this.dispType = dispType;
this.param = param;

if(this.dispType == RedPointDispType.RED_POINT_BIG){
this.currentState = "redBig";
} else if(this.dispType == RedPointDispType.RED_POINT_SMALL){
this.currentState = "redSmall";
} else if(this.dispType == RedPointDispType.ADD){
this.currentState = "add";
} else if(this.dispType == RedPointDispType.ARROW){
this.currentState = "arrow";
}


// if(this.effImgAuto == null){
// this.effImgAuto = new EffectImageAuto();
// this.effImgAuto.PlayById(effectId, -1);
// this.addChild(this.effImgAuto);
// } else {
// this.effImgAuto.PlayById(effectId, -1);
// }

RedPointMgr.getInstance().BindRedPoint(this);
}

// 添加到舞台消息处理
private OnAddFromStage(evt:egret.Event)
{
if( this.groupTipNode.visible){
if(!(this.timerId > 0)){
this.timerId = GameTimer.AddTimerBehaviorEffect(this.OnTimer, -1, 0, 0, this);
}
}
}

// 从舞台移除消息处理
private OnRemoveFromStage( evt:egret.Event )
{
RedPointMgr.getInstance().UnbindRedPoint(this);

if(this.timerId > 0){
GameTimer.RemoveTimerBehavior(this.timerId);
this.timerId = -1;
}
}
}

参考

宠物的总览页签红点

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
// 需求:
// 1:可升级10级红点
// 2:可升1级红点显示
// 3:切换按钮红点显示
// 4:有装备可以穿戴
class RedPointTabOverview extends RedPointLogic
{
// 获取红点类型
// return:红点类型
public GetRedPoinType()
{
return RedPointType.PET_UI_TAB_OVERVIEW;
}

// 获取关联的红点
// return:关联的红点集合
public GetRelateRedPoints() : RedPointType[]
{
return [RedPointType.PET_UI_BTN_UP_TEN,
RedPointType.PET_UI_BTN_UP_ONE,
RedPointType.PET_UI_BTN_SWITCH,
RedPointType.PET_UI_BAT_SIX_EQUIP];
}

// 初始化自定义行为
protected OnInit()
{

}

// 检测红点参数的状态
// @param:[宠物数据]
// return:显示返回true;否则false
protected CheckRedPointParamStatus(param:any[]):boolean
{
let petData:PetInfoData = param[0];
return this.QueryRelateRedPointParamStatus([petData]);
}
}