12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544 |
- 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;
- },
- onDestory() {
- },
- /**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 = Global.userData.buildingLevel >= 25;
- let unLockStatus2 = Global.userData.buyStarCount > 0;
- if (unLockStatus1 && unLockStatus2) {
- for(let i = 1; i < 31; i++) {
- let state = `state${i}`;
- if (this.guideState[state] != undefined) {
- this.guideState[state].pass = 1;
- }
- }
- }
- // this.guideState.state16.pass = 0;
- },
- /**
- * 上报用户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;
- }
- //显示箭头
- 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 (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();
- }
- }
- },
- 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) {
- // 判断是否有足够的金额升级
- 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.finishState24();
- }
- }
- },
- // update (dt) {},
- });
|