const Api = require('../net/Api'); const { GameNotificationKey, HomeGuideDialogType, HomeGuideArrowType } = require("../utils/GameEnum"); const GameModule = require("../utils/GameModule"); const TapTapTool = require("../utils/TapTapTool"); const buildingLevel = require('../data/buildingLevel'); cc.Class({ extends: cc.Component, properties: { blockNode: cc.Node, touchNode: cc.Node, taskNode: cc.Node, taskTitleLabel: cc.Label, taskCoditionLabel: cc.Label, specialFrames: [cc.SpriteFrame], specialMask: cc.Node, specialMaskBg: cc.Node, mask: cc.Node, maskBg: cc.Node, arrowNode: cc.Node, blackGuideNode: cc.Node, tipsNode: cc.Node, descNode: cc.Node, //不同方向的对话框 dialogTopRight: cc.Node, dialogTopLeft: cc.Node, dialogBottomLeft: cc.Node, //不同方向的人物 figureLeft: cc.Node, figureRight: cc.Node, blockEvent: cc.Node, //手指 fingerNode: cc.Node, finger: cc.Node }, onLoad () { this.isPlaying = false; }, init () { this.vsize = cc.view.getVisibleSize(); this.initEvent(); this.stateRecord = {}; this._show13 = false; this.isShowFinger = false; this.guideState = { state1 : { tips: '纸醉金迷的城市某一处。。。', pass: 0, mask: 1, once: true }, state2 : { tips: '一家经纪公司在默默成长。。。', pass: 0, mask: 1, once: true }, state3 : { tips: '一个娱乐圈创业者的故事。。。', pass: 0, mask: 1, once: true }, state4 : { tips: '嘿~老板!你回来啦!\n愣着出神在想什么呢?', pass: 0, mask: 1, dialogType: HomeGuideDialogType.BottomLeft, rect: [0, 0], pos: [0, 0], once: true }, state5 : { tips: '开始努力赚钱啦~\n我们公司还没签约明星呢', pass: 0, mask: 1, dialogType: HomeGuideDialogType.BottomLeft, rect: [0, 0], pos: [0, 0], once: true }, state6 : { tips: '点击下方的招财猫\n就可以获得金币啦', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopLeft, rect: [212, 244], pos: [13, -685], once: true, special: 'guide_black_cat' }, state7 : { tips: '', taskTitle: '累积赚取200金币', taskCodition: 200, pass: 0, mask: 0, once: false }, state8 : { tips: '金币可以升级总部大楼\n和购买明星', pass: 0, mask: 1, dialogType: HomeGuideDialogType.BottomLeft, rect: [0, 0], pos: [0, 0], once: true }, state9 : { tips: '积累的金币可在屏幕的\n正上方查看噢', pass: 0, mask: 1, dialogType: HomeGuideDialogType.BottomLeft, rect: [0, 0], pos: [0, 0], arrowType: HomeGuideArrowType.Top, arrowPos: [0, 500], once: true }, state10 : { tips: '金币的计算单位是\n1000=1A,1000A=1B...\n1000Y=1Z!!!', pass: 0, mask: 1, dialogType: HomeGuideDialogType.BottomLeft, rect: [0, 0], pos: [0, 0], arrowType: HomeGuideArrowType.Top, arrowPos: [0, 500], once: true }, state11 : { tips: '点击左下角的总部大楼', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [103, 95], pos: [-264, -760], once: true, special: 'guide_black_office' }, state12 : { tips: '在这个界面升级你的总部大楼', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [0, 0], pos: [0, 0], once: true }, state13 : { tips: '', taskTitle: '总部大楼达到5级', taskCodition: 5, pass: 0, mask: 0, rect: [328, 160], pos: [80, 100], //手指点猫的位置 arrowType: HomeGuideArrowType.Right, arrowPos: [80, 100],/// 箭头的位置 once: false }, state14 : { tips: '总部大楼等级越高\n点击产生的金币就越多!', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [0, 0], pos: [0, 0], once: true }, state15 : { tips: '', taskTitle: '总部大楼达到25级', taskCodition: 25, pass: 0, mask: 0, rect: [328, 160], pos: [80, 100], //手指点猫的位置 arrowType: HomeGuideArrowType.Right, arrowPos: [80, 100],/// 箭头的位置 once: false }, state16 : { tips: '这是每25级获得的奖励!\n领取后该房间自动产出X2', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, arrowType: HomeGuideArrowType.Left, arrowPos: [-180, 100],/// 箭头的位置 rect: [108, 105], pos: [-279, -44], once: true, special: 'guide_black_award' }, state17 : { tips: '现在我们来解锁房间吧', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [0, 0], pos: [0, 0], once: true }, state20 : { tips: '在主界面你可以解锁房间\n解锁后房间会自动产出金币', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [0, 0], pos: [0, 0], once: true }, state21 : { tips: '', taskTitle: '豪华的服装间达到5级', taskCodition: 5, pass: 0, mask: 0, rect: [328, 160], pos: [0, -500], //手指点猫的位置 pos2: [100, 50], //手指点解锁房间位置 pos3: [280, -65], //手指点升级位置 once: false }, state23 : { tips: '房间等级越高,自动产出的\n金币就越多哦~', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [0, 0], pos: [0, 0], once: true }, state24 : { tips: '', taskTitle: '豪华的服装间达到25级', taskCodition: 25, pass: 0, mask: 0, rect: [328, 160], pos: [0, -500], //手指点猫的位置 pos2: [100, 50], //手指点解锁房间位置 pos3: [280, -65], //手指点升级位置 once: false }, state26 : { tips: '这是每25级获得的奖励!\n领取后该房间自动产出X2', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopRight, rect: [92, 109], pos: [0, -100], once: true, special: 'guide_black_levelHome_award' }, state27 : { tips: '现在我们可以签约明星啦!', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopLeft, rect: [0, 0], pos: [0, 0], once: true }, state28 : { tips: '点击右下角的明星', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopLeft, rect: [64, 90], pos: [260, -760], once: true, special: 'guide_black_star' }, state29 : { tips: '', pass: 0, mask: 0, rect: [0, 0], pos: [0, 0], //手指点猫的位置 arrowType: HomeGuideArrowType.Right, arrowPos: [80, 255],/// 箭头的位置 once: false }, state31 : { tips: '查看右上角的任务中心', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopLeft, rect: [100, 74], pos: [322, 328], once: true, special: 'guide_black_task' }, state32 : { tips: '如果不知道干什么...\n那就看下每日任务!', pass: 0, mask: 1, dialogType: HomeGuideDialogType.TopLeft, rect: [0, 0], pos: [0, 0], once: true }, state33 : { tips: '', pass: 0, mask: 0, rect: [0, 0], pos: [0, 0], arrowType: HomeGuideArrowType.Right, arrowPos: [245, 515], once: true }, state34 : { tips: '今天是我们的第一次签到哦~', pass: 0, mask: 0, rect: [0, 0], pos: [0, 0], dialogType: HomeGuideDialogType.TopLeft, once: true }, }; this.setupUI(); this.syncStatePass(); this.setupAllFinished(); // for(let i = 1; i < 34; i++) { // let state = `state${i}`; // if (this.guideState[state] != undefined) { // this.guideState[state].pass = 0; // } // } // for(let i = 0; i < 34; i++) { // let state = `state${i}`; // if (this.guideState[state] != undefined) { // this.guideState[state].pass = 1; // } // } // this.guideState.state13.pass = 0; // this.guideState.state8.pass = 1; // this.guideState.state9.pass = 0;14 // this.guideState.state10.pass = 0; // this.guideState.state11.pass = 0; // this.setupAllFinished(); let self = this; this.finishState7 = _.debounce(() => { self.updateGuideState(); self.handlePass(this.curState); self.handleState('state8'); }, 1000, true); this.finishState13 = _.debounce(() => { let state = this.curState; self.updateGuideState(); self.handlePass(this.curState); if (state === 'state13') { self.handleState('state14'); } else { self.handleState('state16'); } }, 1000, true); this.finishState21 = _.debounce(() => { self.updateGuideState(); self.handlePass(this.curState); self.handleState('state23'); }, 1000, true); this.finishState24 = _.debounce(() => { // this.node.emit(`Fire_${this.curState}`); self.updateGuideState(); self.handlePass(this.curState); }, 1000, true); }, setupUI() { let secretaryY = this.figureLeft.height / 2 - this.vsize.height / 2 + 20; this.figureLeft.y = secretaryY; this.figureRight.y = secretaryY; this.dialogY = this.dialogTopLeft.height / 2 - this.vsize.height / 2 + 270; this.dialogTopLeft.y = this.dialogY; this.dialogTopRight.y = this.dialogY; this.bottomDialogY = (344 - this.vsize.height) / 2; this.dialogBottomLeft.y = this.bottomDialogY; if (this.vsize.height >= 1624) { this.taskNode.y += 120; } else if (this.vsize.height >= 1500) { this.taskNode.y += 80; } }, tabbarHideCat() { this.fingerNode.active = false; this.isShowFinger = false; }, tabbarShowCat() { this.isShowFinger = true; }, onDestroy() { }, /**F * 同步用户guideState */ syncStatePass () { let _guideState = window.guideState; // let _guideState = cc.sys.localStorage.getItem('guideState'); if(!!_guideState) { for(let i in _guideState) { if(this.guideState[i]) { this.guideState[i].pass = _guideState[i]; } } } else { let _guideState = Object.assign({}, this.guideState); this.uploadUserState(_guideState); } }, setupAllFinished() { // 判断满足以下条件时为已完成购买明星前的教程: // 1. 总部大楼大于25级 // 2. 已拥有1个明星 let unLockStatus1 = GameGlobal.userData.buildingLevel >= 25; let unLockStatus2 = GameGlobal.userData.buyStarCount > 0; // 3. 是否已签到过 let unLockStatus3 = GameGlobal.signCount > 0; if (unLockStatus1 && unLockStatus2) { if (unLockStatus3) { for(let i = 1; i < 34; i++) { let state = `state${i}`; if (this.guideState[state] != undefined) { this.guideState[state].pass = 1; } } } else { for(let i = 1; i < 31; i++) { let state = `state${i}`; if (this.guideState[state] != undefined) { this.guideState[state].pass = 1; } } } } }, /** * 上报用户guideState * @param {Object} stateObj guideState对象 */ uploadUserState (stateObj) { // return; for(let i in stateObj) { stateObj[i] = stateObj[i].pass; } let stateStr = JSON.stringify(stateObj); // cc.sys.localStorage.setItem('guideState', stateStr) // 上报用户数据 Api.httpPost({ url: "/direct/add.do", data: { directJson: stateStr }, success: res => { } }) }, initEvent() { this.blackGuideNode.on(cc.Node.EventType.TOUCH_END, () => { if (this.curState == 'state1') { this.hideBlackGuide(); } else if (this.curState == 'state2') { this.hideBlackGuide(); } else if (this.curState == 'state3') { this.hideBlackGuide(); } }); this.touchNode.on(cc.Node.EventType.TOUCH_END, () => { if (this.isPlaying) { return; } if (this.curState == 'state4') { this.handlePass(this.curState); this.handleState('state5'); } else if (this.curState == 'state5') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state6'); } else if (this.curState == 'state8') { this.handlePass(this.curState); this.handleState('state9'); } else if (this.curState == 'state9') { this.handlePass(this.curState); this.handleState('state10'); } else if (this.curState == 'state10') { this.handlePass(this.curState); this.handleState('state11'); } else if (this.curState == 'state12') { this.handlePass(this.curState); this.handleState('state13'); } else if (this.curState == 'state14') { this.handlePass(this.curState); this.handleState('state15'); } else if (this.curState == 'state17') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state20'); } else if (this.curState == 'state20') { this.handlePass(this.curState); this.handleState('state21'); } else if (this.curState == 'state23') { this.handlePass(this.curState); this.handleState('state24'); } else if (this.curState == 'state27') { this.handlePass(this.curState); this.handleState('state28'); } else if (this.curState == 'state32') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state33'); } else if (this.curState == 'state34') { this.handlePass(this.curState); } }); //点击遮罩指定地方触发 this.mask.on(cc.Node.EventType.TOUCH_END, () => { if (this.isPlaying) { return; } if(!!this.curState) { // 其他state的操作处理,触发在此节点上的自定义事件 this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); } }, this); //点击特殊遮罩指定地方触发 this.specialMask.on(cc.Node.EventType.TOUCH_END, () => { if (this.isPlaying) { return; } if (this.curState == 'state6') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state7'); } else if (this.curState == 'state16') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state17'); } else if (this.curState == 'state26') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state27'); } else if (this.curState == 'state31') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); this.handleState('state32'); } else if(!!this.curState) { // 其他state的操作处理,触发在此节点上的自定义事件 this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); } }, this); }, /** * 设置手指指示位置 * @param {Number} x mask的x坐标 * @param {Number} y mask的y坐标 */ setFingerPos (x, y, isReversal = false) { this.fingerNode.active = true; if (isReversal) { this.finger.rotation = -150; this.finger.x = -47; this.finger.y = 120; } // 手指当前位置 = mask矩形位置的右下角 + 偏移量 this.fingerNode.x = x; this.fingerNode.y = y - this.fingerNode.height / 2; let offsetY = 20; let actionUp = cc.moveBy(0.5, 0, offsetY); let actionDown = cc.moveBy(0.5, 0, -offsetY); let seq = cc.repeatForever(cc.sequence(actionUp, actionDown)); this.finger.runAction(seq); }, //重设手指位置 resetFingerPos (x, y) { if (this.isShowFinger) { this.fingerNode.active = true; } if (this.fingerNode.x == x && this.fingerNode.y == (y - this.fingerNode.height / 2)) { return; } this.fingerNode.x = x; this.fingerNode.y = y - this.fingerNode.height / 2; }, resetFingerPosIsReversalUp (x, y, isReversalUp = false) { if (this.isShowFinger) { this.fingerNode.active = true; } if (this.fingerNode.x == x && this.fingerNode.y == (y - this.fingerNode.height / 2)) { return; } this.finger.stopAllActions(); if (isReversalUp) { this.finger.rotation = -150; this.finger.x = -47; this.finger.y = 125; } else { this.finger.rotation = 0; this.finger.x = 0; this.finger.y = 0; } this.fingerNode.x = x; this.fingerNode.y = y - this.fingerNode.height / 2; let offsetY = 20; let actionUp = cc.moveBy(0.5, 0, offsetY); let actionDown = cc.moveBy(0.5, 0, -offsetY); let seq = cc.repeatForever(cc.sequence(actionUp, actionDown)); this.finger.runAction(seq); }, //隐藏指示点击手指,部分引导不需要 hideFinger () { this.fingerNode.active = false; this.finger.stopAllActions(); this.finger.x = 0; this.finger.y = 0; this.finger.rotation = 0; }, //隐藏箭头,部分引导不需要 hideArrow () { this.arrowNode.active = false; this.arrowNode.stopAllActions(); }, // hideBlock() { this.blockNode.active = false; this.touchNode.active = false; }, /** * 显示遮罩层 */ showMask () { let target = this.guideState[this.curState]; this.maskBg.active = !!target.mask; this.mask.active = true; this.mask.width = target.rect[0]; this.mask.height = target.rect[1]; this.mask.x = target.pos[0]; this.mask.y = (1624 - this.vsize.height) / 2 + target.pos[1]; }, /** * 显示特殊不规则遮罩 */ showSpecialMask() { let target = this.guideState[this.curState]; this.specialMaskBg.active = !!target.mask; this.specialMask.active = true; this.specialMask.width = target.rect[0]; this.specialMask.height = target.rect[1]; this.specialMask.x = target.pos[0]; this.specialMask.y = (1624 - this.vsize.height) / 2 + target.pos[1]; for(let i = 0; i < this.specialFrames.length; i++) { let spriteFrame = this.specialFrames[i]; if (spriteFrame.name == target.special) { this.specialMask.getComponent(cc.Mask).spriteFrame = spriteFrame; break; } } }, /** * 显示秘书人物内容 * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0 * @param {Bool} 默认左边人物,默认为true */ showSecretary (isLeft = true) { if (isLeft) { this.figureLeft.active = true; let action1 = cc.moveBy(0.4,cc.v2(550,0)); let action2 = cc.moveBy(0.2,cc.v2(-100,0)); this.figureLeft.runAction(cc.sequence(action1, action2)); } else { this.figureRight.active = true; let action1 = cc.moveBy(0.4,cc.v2(-550,0)); let action2 = cc.moveBy(0.2,cc.v2(100,0)); this.figureRight.runAction(cc.sequence(action1, action2)); } }, /** * 显示箭头 */ showArrow(offsetY = 0) { let target = this.guideState[this.curState]; this.arrowNode.active = true; let offset = 20; var actionUp = cc.moveBy(0.4, 0, offset); var actionDown = cc.moveBy(0.4, 0, -offset); if (target.arrowType == HomeGuideArrowType.Top) { this.arrowNode.rotation = 0; } else if (target.arrowType == HomeGuideArrowType.Right) { this.arrowNode.rotation = 90; var actionUp = cc.moveBy(0.4, offset, 0); var actionDown = cc.moveBy(0.4, -offset, 0); } else if (target.arrowType == HomeGuideArrowType.Bottom) { this.arrowNode.rotation = 180; } else { this.arrowNode.rotation = -90; var actionUp = cc.moveBy(0.4, offset, 0); var actionDown = cc.moveBy(0.4, -offset, 0); } // 手指当前位置 = mask矩形位置的右下角 + 偏移量 this.arrowNode.x = target.arrowPos[0]; this.arrowNode.y = target.arrowPos[1] + offsetY; let seq = cc.repeatForever(cc.sequence(actionUp, actionDown)); this.arrowNode.runAction(seq); }, /** * 显示对话框内容 * @param {Number} offsetY 显示节点的Y轴偏移量,默认为0 */ showDialog () { let callback = cc.callFunc(() => { this.isPlaying = false; }); this.isPlaying = true; let target = this.guideState[this.curState]; var textNode = cc.find('/text', this.dialogTopLeft); if (target.dialogType == HomeGuideDialogType.TopLeft) { this.dialogTopLeft.active = true; textNode = cc.find('/text', this.dialogTopLeft); let action1 = cc.moveTo(0.4,100,this.dialogY); let action2 = cc.moveTo(0.2,0,this.dialogY); this.dialogTopLeft.runAction(cc.sequence(action1, action2, callback)); } else if (target.dialogType == HomeGuideDialogType.TopRight) { this.dialogTopRight.active = true; textNode = cc.find('/text', this.dialogTopRight); let action1 = cc.moveTo(0.4,-100,this.dialogY); let action2 = cc.moveTo(0.2,0,this.dialogY); this.dialogTopRight.runAction(cc.sequence(action1, action2, callback)); } else if (target.dialogType == HomeGuideDialogType.BottomLeft) { this.dialogBottomLeft.active = true; textNode = cc.find('/text', this.dialogBottomLeft); let action1 = cc.moveTo(0.4,100,this.bottomDialogY); let action2 = cc.moveTo(0.2,0,this.bottomDialogY); this.dialogBottomLeft.runAction(cc.sequence(action1, action2, callback)); } textNode.getComponent(cc.Label).string = target.tips; }, showTask() { let target = this.guideState[this.curState]; this.taskNode.active = true; this.taskTitleLabel.string = target.taskTitle; if (this.curState == 'state7') { this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`; } else if (this.curState == 'state21') { let level = GameGlobal.BuildingManager.getRoomLevel(1); this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`; } else if (this.curState == 'state13' || this.curState == 'state15') { let currentLevel = GameModule.userInfo.buildingLevel; this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`; } }, /** * 上报已过指引 */ updateGuideState() { if (this.guideState[this.curState] != undefined) { this.guideState[this.curState].pass = 1; let stateClone = Object.assign({}, this.guideState); // 显示引导之后立即上报同步对应state数据 this.uploadUserState(stateClone); } }, /** * 显示第一次玩游戏黑色引导 */ showBlackGuide() { this.tipsNode.stopAllActions(); this.descNode.stopAllActions(); this.blackGuideNode.active = true; this.tipsNode.opacity = 0; this.descNode.opacity = 0; let target = this.guideState[this.curState]; this.tipsNode.getComponent(cc.Label).string = `${target.tips}`; let fadeIn = cc.fadeIn(1.2); this.tipsNode.runAction(fadeIn); let nextFadeIn = cc.fadeIn(1.2); let nextFadeOut = cc.fadeOut(1.2); let seq = cc.repeatForever(cc.sequence(nextFadeIn, nextFadeOut)); this.descNode.runAction(seq); }, //关闭开始游戏的黑色遮罩 hideBlackGuide() { this.tipsNode.stopAllActions(); this.descNode.stopAllActions(); let finished = cc.callFunc(() => { this.nextBlackState(); }, this); let fadeOut1 = cc.fadeOut(0.5); let fadeOut2 = cc.fadeOut(0.5); this.tipsNode.runAction(fadeOut1); var seq = cc.sequence(fadeOut2, finished); this.descNode.runAction(seq); }, nextBlackState() { if (this.curState == 'state1') { this.handlePass(this.curState); this.handleState('state2'); } else if (this.curState == 'state2') { this.handlePass(this.curState); this.handleState('state3'); } else if (this.curState == 'state3') { this.handlePass(this.curState); this.handleState('state4'); } }, /** * 隐藏遮罩半透明层 */ hideMask () { this.mask.active = false; this.specialMask.active = false; }, /** * 已完成某一State,并上报 * */ handlePass (state) { let stateClone = Object.assign({}, this.guideState); this.curState = null; this.handleEnd(); }, handleEnd () { this.node.active = false; this.taskNode.active = false; this.blockNode.active = true; this.touchNode.active = true; this.blackGuideNode.active = false; this.arrowNode.active = false; this.figureLeft.active = false; this.figureRight.active = false; this.figureLeft.x = -this.vsize.width + 50; this.figureRight.x = this.vsize.width - 50; this.dialogTopLeft.active = false; this.dialogTopRight.active = false; this.dialogBottomLeft.active = false; this.dialogTopLeft.x = -this.vsize.width; this.dialogTopRight.x = this.vsize.width; this.dialogBottomLeft.x = -this.vsize.width; this.hideMask (); this.hideFinger(); this.hideArrow(); }, /** * 根据状态key显示对应引导内容 * @param {String} state 当前状态key */ handleState (state) { if(this.stateRecord[state] || this.curState != null) { return; } else { this.stateRecord[state] = true; } if(state && !this.guideState[state].pass) { if(this.guideState[state]) { this.node.active = true; this.curState = state; if (this.guideState[state].once) { this.guideState[state].pass = 1; let stateClone = Object.assign({}, this.guideState); // 显示引导之后立即上报同步对应state数据 this.uploadUserState(stateClone); } } else { return } console.log("Show " + state); switch (state) { case 'state1': { this.showBlackGuide(); break; } case 'state2' : { this.showBlackGuide(); break; } case 'state3' : { this.showBlackGuide(); break; } case 'state4' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); break; } case 'state5' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); break; } case 'state6' : { // 遮罩区域 this.hideMask(); //特殊遮罩区域 this.showSpecialMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); // 指示位置 this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 70, this.specialMask.y + 60); break; } case 'state7' : { this.hideBlock(); this.hideMask(); this.showTask(); break; } case 'state8' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); break; } case 'state9' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = 130; } else if (this.vsize.height >= 1500) { offsetY = 90; } //显示箭头 this.showArrow(offsetY); break; } case 'state10' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = 130; } else if (this.vsize.height >= 1500) { offsetY = 90; } //显示箭头 this.showArrow(offsetY); break; } case 'state11' : { this.hideMask(); //特殊遮罩区域 this.showSpecialMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 - 10, this.specialMask.y, true); break; } case 'state12' : { this.showMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); break; } case 'state13' : { this.hideBlock(); this.hideMask(); this.showTask(); this._show13 = true; //显示箭头 var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -140; } else if (this.vsize.height >= 1500) { offsetY = -90; } //显示箭头 this.showArrow(offsetY); this.setFingerPos(10000, 0, true); break; } case 'state14' : { this.showMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); break; } case 'state15' : { this.hideBlock(); this.hideMask(); this.showTask(); this._show13 = true; //显示箭头 var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -140; } else if (this.vsize.height >= 1500) { offsetY = -90; } //显示箭头 this.showArrow(offsetY); this.setFingerPos(10000, 0, true); this.hideFinger(); break; } case 'state16' : { this.hideMask(); this.showSpecialMask(); this.taskNode.active = false; //显示箭头 var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -140; } else if (this.vsize.height >= 1500) { offsetY = -90; } //显示箭头 this.showArrow(offsetY); this.showSecretary(false); this.showDialog(); // this.mask.setPosition(-278, 100 + offsetY); break; } case 'state17' : { this.showMask(); this.mask.width = 0; this.mask.height = 0; this.hideArrow(); this.showSecretary(false); this.showDialog(); break; } case 'state20' : { // 遮罩区域 this.showMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); break; } case 'state21' : { this.hideBlock(); this.hideMask(); this.showTask(); let target = this.guideState[this.curState]; // 指示位置 this.setFingerPos(target.pos[0] + 40, target.pos[1]); break; } case 'state23' : { this.showMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); break; } case 'state24' : { this.hideBlock(); this.hideMask(); this.showTask(); let target = this.guideState[this.curState]; // 指示位置 this.setFingerPos(target.pos[0] + 40, target.pos[1]); break; } case 'state26' : { // this.showMask(); this.hideMask(); this.showSpecialMask(); // 秘书人物 this.showSecretary(false); // 对话框 this.showDialog(); this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 20, this.specialMask.y - 20); break; } case 'state27' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); break; } case 'state28' : { this.hideMask(); //特殊遮罩区域 this.showSpecialMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); this.setFingerPos(this.specialMask.x + this.specialMask.width / 2 + 10, this.specialMask.y + 10, true); break; } case 'state29' : { this.hideMask(); this.hideBlock(); this.hideFinger(); //显示箭头 var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -140; } else if (this.vsize.height >= 1500) { offsetY = -80; } this.showArrow(offsetY); this.figureLeft.active = false; this.figureRight.active = false; break; } case 'state31' : { this.hideMask(); //特殊遮罩区域 this.showSpecialMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); if (this.vsize.height >= 1624) { this.specialMask.y += 260; } else if (this.vsize.height >= 1500) { this.specialMask.y += 168; } this.setFingerPos(this.specialMask.x + this.specialMask.width / 2, this.specialMask.y - 20); break; } case 'state32' : { this.showMask(); // 秘书人物 this.showSecretary(); // 对话框 this.showDialog(); break; } case 'state33' : { this.hideBlock(); this.hideMask(); this.showArrow(); break; } case 'state34' : { this.hideMask(); this.showSecretary(); this.showDialog(); break; } default: break; } return true } else { // return false } }, /** * 【特殊处理】关闭任务界面 */ handleGuideState33 () { if (this.curState == 'state33') { this.node.emit(`Fire_${this.curState}`); this.handlePass(this.curState); if (GameGlobal.isSignAward == false) { this.handleState('state34'); } } }, /** * 【特殊处理】判断当前引导结束后才执行下一个引导 */ handleGuideStateNext(current, next) { if (this.guideState[current].pass) { this.handleState(next); } }, isPassGuideState(state) { if (this.guideState[state].pass) { return true; } else { return false; } }, start () { }, update() { this.guideTask7(); this.guideTask13(); this.guideTask21(); this.guideTask24(); }, guideTask7() { if (this.curState == 'state7') { let target = this.guideState[this.curState]; let coditionGold = {'n': target.taskCodition, 'e': 0}; this.taskCoditionLabel.string = `${TapTapTool.parseToString(GameModule.userInfo.gold)}/${target.taskCodition}`; if (TapTapTool.compare(GameModule.userInfo.gold, coditionGold)) { this.finishState7(); } } }, guideTask13() { if ((this.curState == 'state13' || this.curState == 'state15')) { let currentLevel = GameModule.userInfo.buildingLevel; let target = this.guideState[this.curState]; /// 小于它 说明还没有完成任务 if (currentLevel < target.taskCodition) { this.taskCoditionLabel.string = `(${currentLevel}/${target.taskCodition})`; let upGold = {}; if (this._show13) { let buildingObjct = buildingLevel.find((n) => { return n.level == currentLevel; }) upGold = {'n': parseInt(buildingObjct.upGold), 'e': 0}; } else { let minIndex = currentLevel - 1; let maxIndex = (minIndex + 5) > 24 ? 24 : (minIndex + 5); let upGolds = 0; for (let i = minIndex; i < maxIndex; ++ i) { upGolds += parseInt(buildingLevel[i].upGold); } upGold = {'n': upGolds, 'e': 0}; } //// 金币不够 if (!TapTapTool.compare(GameModule.userInfo.gold, upGold)) { // 指示位置 this.arrowNode.active = false; this.fingerNode.active = true; if (this._show13 == false) { this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 190, false); } else { this.resetFingerPosIsReversalUp(50, - this.node.height / 2 + 40, true); } } else { if (this._show13 === false) { this.fingerNode.active = true; this.resetFingerPosIsReversalUp(- this.node.width / 2 + 150, - this.node.height / 2 + 40, true); } else { this.arrowNode.active = true; this.fingerNode.active = false; } } } else { this.finishState13(); } } }, //// 特别针对技能的方法 只对13 15有效 changeGuideTask1315(isShow) { if (this.curState == 'state13' || this.curState == 'state15') { this.arrowNode.active = isShow; this._show13 = isShow; } }, guideTask21() { if (this.curState == 'state21') { let target = this.guideState[this.curState]; let level = GameGlobal.BuildingManager.getRoomLevel(1); this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`; let data = GameGlobal.BuildingManager.getBuildingInfo(1, level); // 判断是否已经解锁 if (data.isUnlocked || level > 0) { // 判断是否有足够的金额升级 if (TapTapTool.compare(GameModule.userInfo.gold, data.nextUpGold)) { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -160; } else if (this.vsize.height >= 1500) { offsetY = -90; } this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY); } else { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -130; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY); } } else { // 判断是否有足够的金额解锁 if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -160; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY); } else { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -130; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY); } } if (level >= target.taskCodition) { this.finishState21(); } } }, getLevelHomeGold(level) { //判断当前楼层等级相减后是否大于25级 let maxLevel = (25 - level) > 5 ? (level + 5) : 25; let buildingGold = {'n': 0, 'e': 0}; for (let i = level; i <= maxLevel; ++ i) { let data = GameGlobal.BuildingManager.getBuildingInfo(1, level); buildingGold = TapTapTool.add(buildingGold, data.nextUpGold); } return buildingGold; }, guideTask24() { if (this.curState == 'state24') { let target = this.guideState[this.curState]; let level = GameGlobal.BuildingManager.getRoomLevel(1); this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`; let data = GameGlobal.BuildingManager.getBuildingInfo(1, level); // 判断是否已经解锁 if (data.isUnlocked || level > 0) { //判断楼层是否可以连升5级 let upGold = this.getLevelHomeGold(level); // 判断是否有足够的金额升级 if (TapTapTool.compare(GameModule.userInfo.gold, upGold)) { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -160; } else if (this.vsize.height >= 1500) { offsetY = -90; } this.resetFingerPos(target.pos3[0] + 20, target.pos3[1] + offsetY); } else { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -130; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY); } } else { // 判断是否有足够的金额解锁 if (TapTapTool.compare(GameModule.userInfo.gold, data.unlockScore)) { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -160; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos2[0] + 40, target.pos2[1] + offsetY); } else { var offsetY = 0; if (this.vsize.height >= 1624) { offsetY = -130; } else if (this.vsize.height >= 1500) { offsetY = -70; } this.resetFingerPos(target.pos[0] + 40, target.pos[1] + offsetY); } } if (level >= target.taskCodition) { this.finishState24(); } } }, // update (dt) {}, });