123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563 |
- 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 (GameGlobal.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个明星
- 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 < 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 = 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;
- } 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 (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) {},
- });
|