123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- 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) {},
- });
|