12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- const TapTapTool = require("../utils/TapTapTool");
- const GameRedDot = require('../utils/GameEnum').GameRedDot;
- const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
- cc.Class({
- extends: cc.Component,
- properties: {
- bgFrames: [cc.SpriteFrame],
- noticeNode: cc.Node
- },
- onLoad () {
- this.handelQuestShowRedDot();
- GameEvent.on(GameNotificationKey.GameRedDotUpdate, this, this.handelQuestShowRedDot);
- },
- init (quest, isMain) {
- this.quest = quest;
- this.isMain = isMain;
- if (this.isMain) {
- GameEvent.on('quest_main_notice', this, (isCancel) => {
- console.log('主线任务isCancel为======' + isCancel);
- if (isCancel) {
- this.noticeNode.active = false;
- TapTapTool.removeRedDot(GameRedDot.mainTask);
- } else {
- this.noticeNode.active = true;
- }
- });
- } else {
- GameEvent.on('quest_daily_notice', this, (isCancel) => {
- console.log('每日任务isCancel为======' + isCancel);
- if (isCancel) {
- this.noticeNode.active = false;
- TapTapTool.removeRedDot(GameRedDot.dayTask);
- } else {
- this.noticeNode.active = true;
- }
- });
- }
- },
- handelQuestShowRedDot() {
- if (Global._redTypes == null || Global._redTypes == undefined || Global._redTypes.length == 0) {
- this.noticeNode.active = false;
- return;
- }
- let redTypes = Global._redTypes;
- if (this.isMain) {
- this.noticeNode.active = redTypes.indexOf(GameRedDot.mainTask) != -1;
- } else {
- this.noticeNode.active = redTypes.indexOf(GameRedDot.dayTask) != -1;
- }
- },
-
- show () {
- this.getComponent(cc.Button).interactable = false;
- this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[1]
- },
- hide () {
- this.getComponent(cc.Button).interactable = true;
- this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[0]
- },
- onDestroy() {
- GameEvent.off('quest_main_notice', this);
- GameEvent.off('quest_daily_notice', this);
- GameEvent.off(GameNotificationKey.GameRedDotUpdate, this);
- }
- // update (dt) {},
- });
|