const HomeApi = require("../net/HomeApi"); const AlertManager = require('../utils/AlertManager'); const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey; const ShareAction = require('../utils/ShareAction'); const GameModule = require("../utils/GameModule"); cc.Class({ extends: cc.Component, properties: { levelHomePrefab: cc.Prefab, myInfoTop: cc.Node, sidebar: cc.Node, clickAddMoney: cc.Prefab, additionTipsNode: cc.Node, homeGuide: cc.Node }, // LIFE-CYCLE CALLBACKS: onLoad () { this.isShowBar = false; // 引导界面 this.homeGuide.zIndex = 200; GameModule.homeGuide = this.homeGuide; this.homeGuide = this.homeGuide.getComponent('HomeGuide'); this.homeGuide.init(); // 创建一个事件监听实例, 用来实现跨节点监听事件 GameEvent.init(); cc.debug.setDisplayStats(false); //建筑展示 let levelHome = cc.instantiate(this.levelHomePrefab); levelHome = levelHome.getComponent('LevelHome'); levelHome.init(Global.user.uid); this.levelHome = levelHome; this.levelHome.node.active = true; let XHeight = 1624; this.winSize = cc.view.getVisibleSize(); console.log('game ======================= ' + this.winSize); if (this.winSize.height >= XHeight) { this.myInfoTop.height = 200; this.sidebar.getComponent(cc.Widget).top = 180; } this.additionTipsNode = this.additionTipsNode.getComponent('AdditionTips'); this._setEventListener(); if (Global.shareType == ShareAction.SHOW_GROUP_RANK && Global.shareTicket.length > 0) { if (this.homeGuide.guideState.state1.pass) { GameEvent.fire(GameNotificationKey.GameShowGroupRank); } } }, start () { if (!this.homeGuide.guideState.state1.pass) { // 触发引导系统state1状态 GameModule.homeGuide.getComponent('HomeGuide').handleState('state1'); } GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state4', 'state5'); GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state6', 'state7'); // GameModule.homeGuide.getComponent('HomeGuide').handleState('state31'); GameModule.homeGuide.getComponent('HomeGuide').handleGuideStateNext('state29', 'state31'); GameModule.homeGuide.on('Fire_state29', this.finishState29, this); GameModule.homeGuide.on('Fire_state31', this.handleQuestPopup, this); if (this.homeGuide.guideState.state7.pass || this.homeGuide.guideState.state11.pass) { GameModule.homeGuide.getComponent('HomeGuide').handleState('state13'); GameModule.homeGuide.getComponent('HomeGuide').changeGuideTask1315(false); if (this.homeGuide.guideState.state13.pass) { GameModule.homeGuide.getComponent('HomeGuide').handleState('state15'); GameModule.homeGuide.getComponent('HomeGuide').changeGuideTask1315(false); } } this._showSidebarUI(); }, update (dt) { if (GameModule.skill.isUsingSkill3) { GameEvent.fire(GameNotificationKey.PlaySuccessAnimation); } }, _setEventListener() { GameEvent.on(GameNotificationKey.GameShowAdditionTips, this, this.showAdditionTips); GameEvent.on(GameNotificationKey.GameShowGroupRank, this, this.showGroupRank); }, onDestroy() { GameEvent.off(GameNotificationKey.GameShowAdditionTips, this); GameEvent.off(GameNotificationKey.GameShowGroupRank, this); }, _showSidebarUI() { let isOk = false; //教程31还没有完成不显示 if (!this.homeGuide.guideState.state31.pass) { // 1. 总部大楼大于25级 // 2. 已拥有1个明星 let unLockStatus1 = GameModule.userInfo.buildingLevel >= 25; let unLockStatus2 = GameModule.userInfo.buyStarCount > 0; if (unLockStatus1 && unLockStatus2) { isOk = true } } else { isOk = true } if (!isOk) { return; } this.isShowBar = true; let action = cc.moveBy(0.3, cc.v2(-this.sidebar.width, 0)); this.sidebar.runAction(action); }, finishState29() { if (this.isShowBar) { return; } this.isShowBar = true; let action = cc.moveBy(0.3, cc.v2(-this.sidebar.width, 0)); this.sidebar.runAction(action); }, // handleQuestPopup: _.debounce((event) => { AlertManager.showQuestPopup(); if (event) { event.target.getChildByName("notice_point").active = false; } }, 1000, true), //显示抽奖界面 handleShowDraw: _.debounce((event) => { AlertManager.showDrawAlert(); }, 1000, true), //显示商城界面 handleShowStore: _.debounce((event) => { AlertManager.showStoreAlert(); }, 1000, true), //显示排行榜界面 handleShowRank: _.debounce((event) => { AlertManager.showRankAlert(); }, 1000, true), showGroupRank() { AlertManager.showRankAlert(2); }, showAdditionTips(text, type) { if (this.node.active) { this.additionTipsNode.show(text, type); } }, // update (dt) {}, });