123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- 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();
- GameEvent.fire("show_home_more");
- },
- //隐藏招财猫
- 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();
- GameEvent.fire("hide_home_more");
- },
- resetCatPosition() {
- this.catNode.y = -161;
- }
- // update (dt) {},
- });
|