const AlertManager = require('../utils/AlertManager'); const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey; const GameModule = require("../utils/GameModule"); const GameRedDot = require('../utils/GameEnum').GameRedDot; const TapTapTool = require("../utils/TapTapTool"); cc.Class({ extends: cc.Component, properties: { officeNode: cc.Node, officeCommonNode: cc.Node, officeSelectedNode: cc.Node, starNode: cc.Node, starCommonNode: cc.Node, starSelectedNode: cc.Node, catNode: cc.Node, skillRedNode: cc.Node, starRedNode: cc.Node, }, // LIFE-CYCLE CALLBACKS: onLoad () { this.isShowOffice = false; this.isShowStar = false; this.catMng = this.catNode.getComponent('MoneyCat'); let self = this; this.handleChangeTab = _.throttle((index) => { self.handleTabbarClick(index); }, 500, true); this.officeNode.on(cc.Node.EventType.TOUCH_END, () => { self.handleChangeTab(0); }); this.starNode.on(cc.Node.EventType.TOUCH_END, () => { self.handleChangeTab(2); }); GameEvent.on(GameNotificationKey.TabbarClickCat, this, () => { self.handleChangeTab(1); }); this.handelHomeTabbarShowRedDot(); GameEvent.on(GameNotificationKey.GameRedDotUpdate, this, this.handelHomeTabbarShowRedDot); GameModule.homeGuide.on('Fire_state11', this.handleSkillAction, this); GameModule.homeGuide.on('Fire_state28', this.handleStarAction, this); GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state8', 'state10'); GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state26', 'state27'); this.schedule(this.updateRedDot, 1); }, updateRedDot () { if (Global._gold10 === undefined) { return; } if (TapTapTool.compare(GameModule.userInfo.gold, Global._gold10)) { this.skillRedNode.active = true; /// 如果是小于 说明金币不满足 } else if (this.skillRedNode.active == true) { this.skillRedNode.active = false; } if (TapTapTool.compare(GameModule.userInfo.gold, Global._buyStarGold)) { this.starRedNode.active = true; } else { this.starRedNode.active = false; } }, start () { }, handelHomeTabbarShowRedDot() { if (Global._redTypes == null || Global._redTypes == undefined || Global._redTypes.length == 0) { this.skillRedNode.active = false; this.starRedNode.active = false; return; } let redTypes = Global._redTypes; // this.skillRedNode.active = redTypes.indexOf(GameRedDot.skill) != -1; let starActive = redTypes.indexOf(GameRedDot.star) != -1 this.starRedNode.active = starActive; }, handleTabbarClick(index) { switch (index) { case 0: this.handleSkillAction(); break; case 1: this.handleCatAction(); break; case 2: this.handleStarAction(); break; default: break; } }, //显示招财猫 handleCatAction() { if (this.catMng.isHided) { this.isShowOffice = false; this.isShowStar = false; this.officeCommonNode.active = true; this.officeSelectedNode.active = false; this.starCommonNode.active = true; this.starSelectedNode.active = false; GameEvent.fire("skillAlert_done"); GameEvent.fire("starAlert_done"); this.showCat(); } }, //显示技能界面 handleSkillAction() { if (!GameModule.homeGuide.getComponent('HomeGuide').isPassGuideState('state7')) { return; } if (this.isShowOffice) { this.officeCommonNode.active = true; this.officeSelectedNode.active = false; this.showCat(); GameEvent.fire("skillAlert_done"); } else { //如果已点开明星界面则需要关闭 if (this.isShowStar) { this.starCommonNode.active = true; this.starSelectedNode.active = false; GameEvent.fire("starAlert_done"); this.isShowStar = false; } AlertManager.showSkillAlert(); this.officeCommonNode.active = false; this.officeSelectedNode.active = true; if (!this.catMng.isHided) { this.hideCat(); } else { this.resetCatPosition(); } } this.isShowOffice = !this.isShowOffice; }, //显示明星界面 handleStarAction() { if (!GameModule.homeGuide.getComponent('HomeGuide').isPassGuideState('state27')) { return; } if (this.isShowStar) { this.starCommonNode.active = true; this.starSelectedNode.active = false; this.showCat(); GameEvent.fire("starAlert_done"); } else { //如果已点开技能界面则需要关闭 if (this.isShowOffice) { this.officeCommonNode.active = true; this.officeSelectedNode.active = false; GameEvent.fire("skillAlert_done"); this.isShowOffice = false; } GameEvent.fire("skillAlert_done"); AlertManager.showStarAlert(); this.starCommonNode.active = false; this.starSelectedNode.active = true; if (!this.catMng.isHided) { this.hideCat(); } else { this.resetCatPosition(); } } this.isShowStar = !this.isShowStar; }, showCat() { GameModule.audioMng.playClickButton(); this.catNode.stopAllActions(); let showAction = cc.moveTo(0.2,0,-11); this.catNode.runAction(showAction); this.catMng.isHided = false; GameModule.homeGuide.getComponent('HomeGuide').tabbarShowCat(); }, hideCat() { this.catNode.stopAllActions(); let hideAction = cc.moveTo(0.2,0,-161); this.catNode.runAction(hideAction); this.catMng.isHided = true; GameModule.homeGuide.getComponent('HomeGuide').tabbarHideCat(); }, resetCatPosition() { this.catNode.y = -161; } // update (dt) {}, });