QuestTab.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. const TapTapTool = require("../utils/TapTapTool");
  2. const GameRedDot = require('../utils/GameEnum').GameRedDot;
  3. const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. bgFrames: [cc.SpriteFrame],
  8. noticeNode: cc.Node
  9. },
  10. onLoad () {
  11. this.handelQuestShowRedDot();
  12. GameEvent.on(GameNotificationKey.GameRedDotUpdate, this, this.handelQuestShowRedDot);
  13. },
  14. init (quest, isMain) {
  15. this.quest = quest;
  16. this.isMain = isMain;
  17. if (this.isMain) {
  18. GameEvent.on('quest_main_notice', this, (isCancel) => {
  19. console.log('主线任务isCancel为======' + isCancel);
  20. if (isCancel) {
  21. this.noticeNode.active = false;
  22. TapTapTool.removeRedDot(GameRedDot.mainTask);
  23. } else {
  24. this.noticeNode.active = true;
  25. }
  26. });
  27. } else {
  28. GameEvent.on('quest_daily_notice', this, (isCancel) => {
  29. console.log('每日任务isCancel为======' + isCancel);
  30. if (isCancel) {
  31. this.noticeNode.active = false;
  32. TapTapTool.removeRedDot(GameRedDot.dayTask);
  33. } else {
  34. this.noticeNode.active = true;
  35. }
  36. });
  37. }
  38. },
  39. handelQuestShowRedDot() {
  40. if (Global._redTypes == null || Global._redTypes == undefined || Global._redTypes.length == 0) {
  41. this.noticeNode.active = false;
  42. return;
  43. }
  44. let redTypes = Global._redTypes;
  45. if (this.isMain) {
  46. this.noticeNode.active = redTypes.indexOf(GameRedDot.mainTask) != -1;
  47. } else {
  48. this.noticeNode.active = redTypes.indexOf(GameRedDot.dayTask) != -1;
  49. }
  50. },
  51. show () {
  52. this.getComponent(cc.Button).interactable = false;
  53. this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[1];
  54. },
  55. hide () {
  56. this.getComponent(cc.Button).interactable = true;
  57. this.getComponent('cc.Sprite').spriteFrame = this.bgFrames[0];
  58. },
  59. onDestroy() {
  60. GameEvent.off('quest_main_notice', this);
  61. GameEvent.off('quest_daily_notice', this);
  62. GameEvent.off(GameNotificationKey.GameRedDotUpdate, this);
  63. }
  64. // update (dt) {},
  65. });