1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- 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: [104, 82],
- pos: [323, 331],
- 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();
- if (Global.debug) {
- for(let i = 0; i < 35; i++) {
- let state = `state${i}`;
- if (this.guideState[state] != undefined) {
- this.guideState[state].pass = 1;
- }
- }
- }
- 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;
- } else if (this.vsize.height <= 1000) {
- this.taskNode.y -= 180;
- }
- },
- 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个明星
- // 3. 是否已签到过
- let unLockStatus1 = Global.userData.buildingLevel >= 25;
- let unLockStatus2 = Global.userData.buyStarCount > 0;
- let unLockStatus3 = Global.signCount > 0;
- if (unLockStatus1 && unLockStatus2) {
- if (unLockStatus3) {
- for(let i = 1; i < 35; 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 = Global.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;
- } else if (this.vsize.height <= 1000) {
- offsetY = -150;
- }
- //显示箭头
- 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;
- } else if (this.vsize.height <= 1000) {
- this.specialMask.y -= 334;
- }
- 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 (Global.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 = Global.BuildingManager.getRoomLevel(1);
- this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
- let data = Global.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 = Global.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 = Global.BuildingManager.getRoomLevel(1);
- this.taskCoditionLabel.string = `(${level}/${target.taskCodition})`;
- let data = Global.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) {},
- });
|