"use strict";
cc._RF.push(module, 'ddbf4iIJnhHIImfp+SKRF1C', 'OP15');
// OP15/scene/OP15.js

"use strict";

var _util_OP = require("../script/util_OP15");

var _defaultData_OP = require("../script/defaultData_OP15");

var _xstate_OP = require("../script/xstate_OP15");

function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

var pure = _xstate_OP.actions.pure,
    send = _xstate_OP.actions.send,
    raise = _xstate_OP.actions.raise,
    sendParent = _xstate_OP.actions.sendParent;
cc.Class({
  "extends": cc.Component,
  properties: {
    /*ant: {
    	default: null,
    	type: cc.Node,
    },
    apple: {
    	default: null,
    	type: cc.Node,
    },
    bird: {
    	default: null,
    	type: cc.Node,
    },
    car: {
    	default: null,
    	type: cc.Node,
    },
    cat: {
    	default: null,
    	type: cc.Node,
    },
    cow: {
    	default: null,
    	type: cc.Node,
    },
    duck: {
    	default: null,
    	type: cc.Node,
    },
    egg: {
    	default: null,
    	type: cc.Node,
    },
    farmer: {
    	default: null,
    	type: cc.Node,
    },
    fish: {
    	default: null,
    	type: cc.Node,
    },
    girl: {
    	default: null,
    	type: cc.Node,
    },
    hen: {
    	default: null,
    	type: cc.Node,
    },
    house: {
    	default: null,
    	type: cc.Node,
    },*/
    rightAudio: {
      "default": null,
      type: cc.AudioClip
    },
    wrongAudio: {
      "default": null,
      type: cc.AudioClip
    },
    logoCat: {
      "default": null,
      type: cc.Node
    }
  },
  playAni: function playAni(idx, name, options) {
    var times = options && options.times || 1;
    var cb = options && options.callback || null; // const cat = cc.find(`Canvas/frame-border/ground/${node}`);

    var node = this._figurePointRectArray[idx].node;
    var dragonDisplay = node.getComponent(dragonBones.ArmatureDisplay);
    var state = dragonDisplay.playAnimation(name, times); // dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
    // 	//TODO 这里写触发事件
    // 	//event.name为事件名称
    // 	console.log(event.name)
    // }, this);
    // animationDisplay.addEventListener(dragonBones.EventObject.COMPLETE, completeCallback);

    return state;
  },
  // 生命周期 onLoad
  onLoad: function onLoad() {
    this._timeoutIds = [];
    this._intervalIds = [];
    this.initSceneData();
    this.initSize();
    window.ccc = this;
  },
  _imageResList: null,
  _audioResList: null,
  _animaResList: null,
  _lastFingerPosition: null,
  _hintsNodeList: null,
  _figurePointRectArray: null,
  _allAnimationNodes: null,
  initSceneData: function initSceneData() {
    this._imageResList = [];
    this._audioResList = [];
    this._animaResList = [];
    this._allAnimationNodes = [];
    this._hintsNodeList = [];
    this._lastFingerPosition = {
      pos: null,
      dirty: false
    };
    this._figurePointRectArray = [];
  },
  _designSize: null,
  // 设计分辨率
  _frameSize: null,
  // 屏幕分辨率
  _mapScaleMin: null,
  // 场景中常用缩放（取大值）
  _mapScaleMax: null,
  // 场景中常用缩放（取小值）
  _cocosScale: null,
  // cocos 自缩放 （较少用到）
  initSize: function initSize() {
    // 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
    var screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height;
    var design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height;
    var f = screen_size >= design_size;
    cc.Canvas.instance.fitHeight = f;
    cc.Canvas.instance.fitWidth = !f;
    var frameSize = cc.view.getFrameSize();
    this._frameSize = frameSize;
    this._designSize = cc.view.getDesignResolutionSize();
    var sx = cc.winSize.width / frameSize.width;
    var sy = cc.winSize.height / frameSize.height;
    this._cocosScale = Math.min(sx, sy);
    sx = frameSize.width / this._designSize.width;
    sy = frameSize.height / this._designSize.height;
    this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
    this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
  },
  createStateMachine: function createStateMachine() {
    var _this = this;

    var check = [{
      target: '#game.end',
      cond: function cond(ctx, evt) {
        console.log('[answer NEXT] check if end', ctx.questionIndex >= ctx.questionsCount - 1);
        return ctx.questionIndex >= ctx.questionsCount - 1;
      }
    }, {
      target: 'hint'
    } // reenter 'hint' state
    ];
    var QuestionState = {
      id: 'question',
      initial: 'hint',
      states: {
        hint: {
          invoke: {
            src: function src(ctx, event) {
              console.log("[hint] play question " + ctx.questionIndex + ": " + ctx.questionPlayTimes + " audio");
              ctx.questionPlayTimes += 1;
              return new Promise(function (resolve, reject) {
                (0, _util_OP.playAudioByUrl)(ctx.questions[ctx.questionIndex].audio_url, function () {
                  console.log('hint finish');
                  resolve();
                });
              });
            },
            onDone: 'answer',
            onError: 'answer'
          }
        },
        answer: {
          after: {
            8000: [{
              target: 'wrong'
            } // reenter 'hint' state
            ]
          },
          invoke: {
            src: function src(context, event) {
              return function (callback, onReceive) {
                console.log('[answer] thinking and playing'); // check every second

                var id = setInterval(function () {
                  if (!_this._lastFingerPosition.dirty) {
                    return;
                  }

                  var region = context.questions[context.questionIndex];

                  var result = _this.checkInRegion(region.rect);

                  if (result === null) {
                    return;
                  }

                  console.log('[Genise JS] checkInRegion' + result);

                  if (result) {
                    callback('RIGHT');
                  } else {
                    callback('WRONG');
                  }
                }, 1000);

                _this._intervalIds.push(id); // Perform cleanup


                return function () {
                  return clearInterval(id);
                };
              };
            }
          },
          on: {
            RIGHT: {
              target: 'right'
            },
            WRONG: {
              target: 'wrong'
            }
          }
        },
        right: {
          invoke: {
            src: function src(context, event) {
              _this._lastFingerPosition.pos = null;
              _this._lastFingerPosition.dirty = false;
              return new Promise(function (resolve, reject) {
                console.log('answer right'); // this.playAni(context.questionIndex, 'normal')

                var an = context.questions[context.questionIndex].node;
                console.log('in right ' + typeof an);
                an.active = true;

                if (an.isSpine) {
                  var skeleton = an.getComponent(sp.Skeleton);
                  skeleton.setToSetupPose();
                  setTimeout(function () {
                    skeleton.setAnimation(0, 'normal', true);
                  }, 1);
                } else {
                  var dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
                  dragonDisplay.playAnimation('normal', 0);
                }

                var ddLogoCat = _this.logoCat.getComponent(dragonBones.ArmatureDisplay);

                ddLogoCat.playAnimation('right', 1);
                ddLogoCat.once(dragonBones.EventObject.COMPLETE, function () {
                  this.logoCat.getComponent(dragonBones.ArmatureDisplay).playAnimation('normal', 0);
                }, _this);
                (0, _util_OP.playAudioByUrl)(_this.rightAudio, function () {
                  resolve();
                });
              });
            },
            onDone: {
              target: '#QuestionsArray.next',
              actions: raise('CHECK')
            },
            onError: {
              target: '#QuestionsArray.next',
              actions: raise('CHECK')
            }
          }
        },
        wrong: {
          invoke: {
            src: function src(context, event) {
              _this._lastFingerPosition.pos = null;
              _this._lastFingerPosition.dirty = false;
              return new Promise(function (resolve, reject) {
                console.log('answer wrong', context.questionIndex, context.questionPlayTimes, context.maxQuestionTryTimes);

                var ddLogoCat = _this.logoCat.getComponent(dragonBones.ArmatureDisplay);

                ddLogoCat.playAnimation('wrong', 1);
                ddLogoCat.once(dragonBones.EventObject.COMPLETE, function () {
                  this.logoCat.getComponent(dragonBones.ArmatureDisplay).playAnimation('normal', 0);
                }, _this);
                var wrongEffect = _this.wrongAudio; // 第一和第二题的提示音

                if ([0, 1].includes(context.questionIndex)) {// wrongEffect = this.data[`wrong_audio${context.questionPlayTimes}`]
                } else {// 非第一和第二题，并且做第二遍的提示音
                    // if (context.questionPlayTimes == 2) {
                    // 	wrongEffect = this.data[`wrong_audio${context.questionPlayTimes}`]
                    // }
                  }

                if (context.questionPlayTimes >= context.maxQuestionTryTimes) {
                  var an = context.questions[context.questionIndex].node;
                  an.active = true;

                  if (an.isSpine) {
                    var skeleton = an.getComponent(sp.Skeleton);
                    skeleton.setToSetupPose();
                    setTimeout(function () {
                      skeleton.setAnimation(0, 'normal', true);
                    }, 1);
                  } else {
                    var dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
                    dragonDisplay.playAnimation('normal', 0);
                    console.log('show animation', an.active);
                  }
                }

                (0, _util_OP.playAudioByUrl)(wrongEffect, function () {
                  if (context.questionPlayTimes >= context.maxQuestionTryTimes) {
                    // const an = context.questions[context.questionIndex].node;
                    // an.active = true;
                    // const dragonDisplay = an.getComponent(dragonBones.ArmatureDisplay);
                    // dragonDisplay.playAnimation('normal', 0);
                    // console.log('show animation', an.active);
                    reject();
                  } else {
                    resolve();
                  }
                });
              });
            },
            onDone: {
              target: 'hint' // actions: raise('CHECK')

            },
            onError: {
              target: '#QuestionsArray.next',
              actions: raise('CHECK')
            }
          }
        }
      }
    };
    var QuestionsArrayStatus = {
      id: 'QuestionsArray',
      initial: 'play',
      states: {
        play: _extends({}, QuestionState),
        next: {
          on: {
            CHECK: [{
              target: '#game.end',
              cond: function cond(ctx, evt) {
                ctx.questionIndex += 1;
                ctx.questionPlayTimes = 0;
                console.log('#game.end', ctx.questionIndex >= ctx.questionsCount);
                return ctx.questionIndex >= ctx.questionsCount;
              }
            }, {
              target: 'play'
            }]
          }
        }
      }
    };
    var state = {
      id: 'game',
      initial: 'begin',
      context: {
        questionIndex: 0,
        questionPlayTimes: 0,
        maxQuestionTryTimes: 5,
        questionsCount: this._figurePointRectArray.length,
        questions: this._figurePointRectArray
      },
      states: {
        begin: {
          invoke: {
            src: function src(ctx) {
              console.log('game begin 1');

              if (window.courseware && window.courseware.openOsmoFingerRead) {
                _this.isOpenedOsmoFingerRead = true;
                window.courseware.openOsmoFingerRead({
                  "page": false,
                  "book_name": "Oxford_Phonics_World_1_SB"
                });
              }

              var dragonDisplay = _this.logoCat.getComponent(dragonBones.ArmatureDisplay);

              var state = dragonDisplay.playAnimation('begin', 0);
              return new Promise(function (resolve, reject) {
                (0, _util_OP.playAudioByUrl)(_this.data.begin_audio, function () {
                  console.log('game begin audio finish');
                  resolve();
                });
              });
            },
            onDone: 'guide',
            onError: 'guide'
          }
        },
        guide: {
          invoke: {
            src: function src(ctx) {
              return new Promise(function (resolve, reject) {
                (0, _util_OP.playAudioByUrl)(_this.data.guide_audio, function () {
                  console.log('game guide audio finish');
                  reject();
                });
              });
            },
            onDone: 'playing',
            onError: 'playing'
          }
        },
        playing: _extends({
          entry: function entry(ctx) {
            console.log('entry play stage');

            var dragonDisplay = _this.logoCat.getComponent(dragonBones.ArmatureDisplay);

            var state = dragonDisplay.playAnimation('normal', 0);
            cc.assetManager.loadRemote(_this.data.playing_audio, function (err, audioClip) {
              cc.audioEngine.playMusic(audioClip, true, 0.8);
            });
            ctx.questions.forEach(function (block) {
              block.node.active = false;
            });
          },
          exit: function exit() {
            console.log('exit play stage');
            cc.audioEngine.stopMusic();
          },
          on: {
            NEXT: 'end'
          }
        }, QuestionsArrayStatus),
        end: {
          entry: function entry(ctx, event) {
            console.log('game end');

            var dragonDisplay = _this.logoCat.getComponent(dragonBones.ArmatureDisplay);

            var state = dragonDisplay.playAnimation('finish', 0);

            if (window.courseware && window.courseware.closeOsmoFingerRead) {
              _this.isOpenedOsmoFingerRead = false;
              window.courseware.closeOsmoFingerRead();
            }

            (0, _util_OP.playAudioByUrl)(_this.data.end_audio, function () {
              console.log('game finish');
              (0, _util_OP.onHomeworkFinish)();
            }); // return new Promise((resolve,reject) => {
            // 	setTimeout(() => {
            // 		console.log('hint finish');
            // 		resolve()
            // 	}, 2000)
            // })
          }
        }
      }
    };
    var after = {};

    var _loop = function _loop(i) {
      var t = _this._hintsNodeList[i].node;
      var k = _this._hintsNodeList[i].after;
      after[k] = {
        actions: function actions() {
          if (t.isSpine) {
            var skeleton = t.getComponent(sp.Skeleton);
            skeleton.setToSetupPose();
            setTimeout(function () {
              skeleton.setAnimation(0, 'enlarge', false);
            }, 1); // skeleton.animation = skeleton.animationNames[0];
          } else {
            var dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
            dragonDisplay.playAnimation('enlarge', 1);
            console.log(dragonDisplay._armatureKey, 'enlarge');
            dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, function (event) {// TODO 这里写触发事件
              // event.name为事件名称
              // event.armature.animation.play('normal', 0);
              // console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
            }, _this);
          } // const dragonDisplay = t.getComponent(dragonBones.ArmatureDisplay);
          // dragonDisplay.playAnimation('enlarge', 1);
          // console.log(dragonDisplay._armatureKey, 'enlarge')
          // dragonDisplay.addEventListener(dragonBones.EventObject.COMPLETE, (event) => {
          // 	//TODO 这里写触发事件
          // 	//event.name为事件名称
          // 	event.armature.animation.play('normal', 0);
          // 	console.log(event.animationState.name, dragonDisplay._armatureKey, 'end')
          // }, this);

        }
      };
    };

    for (var i = 0; i < this._hintsNodeList.length; i++) {
      _loop(i);
    }

    if (this.data.begin_sep_time) {
      var t = +this.data.begin_sep_time * 1000;
      after[t] = {
        actions: function actions() {
          console.log('game begin 2');

          for (var _i = 0; _i < _this._allAnimationNodes.length; _i++) {
            var _t = _this._allAnimationNodes[_i];

            if (_t.isSpine) {
              (function () {
                var skeleton = _t.getComponent(sp.Skeleton);

                console.log('skeleton: ', skeleton);
                skeleton.setToSetupPose();
                setTimeout(function () {
                  skeleton.setAnimation(0, 'normal', true);
                }, 1);
                console.log('skeleton 22: ', skeleton); // skeleton.animation = skeleton.animationNames[0];
              })();
            } else {
              var dragonDisplay = _t.getComponent(dragonBones.ArmatureDisplay);

              dragonDisplay.playAnimation('normal', 0);
            }
          }
        }
      };
    }

    state.states.begin.after = after;
    var gameMachine = (0, _xstate_OP.createMachine)(state);
    window.gameMachine = gameMachine;
    this.gameMachineService = (0, _xstate_OP.interpret)(gameMachine).onTransition(function (state) {// console.log(1, state.value, state.context);
    });
    this.gameMachineService.start();

    if (window.gameMachineService) {
      window.gameMachineService = gameMachineService;
    }
  },
  // 生命周期 start
  start: function start() {
    var _this2 = this;

    var getData = this.getData.bind(this);

    if (window && window.courseware) {
      getData = window.courseware.getData;
    }

    getData(function (data) {
      // console.log('data:', data);
      _this2.data = data || _this2.getDefaultData();
      _this2.data = JSON.parse(JSON.stringify(_this2.data));

      _this2.preloadItem();
    });
    window.air = window.air || {};

    if (window.air) {
      window.air.osmoFingerReadCallback = function (result) {
        if (!_this2.gameMachineService) {
          return;
        } // const st = this.gameMachineService.state.value.constructor.name == 'Object' 
        // && this.gameMachineService.state.value['playing']
        // && this.gameMachineService.state.value['playing'].constructor.name == 'Object'
        // && this.gameMachineService.state.value['playing']['play']
        // && this.gameMachineService.state.value['playing']['play'] == 'answer'
        // if (st) {
        // }


        var p = JSON.parse(result);

        if (p.x == -1 || p.y == -1) {
          _this2._lastFingerPosition.pos = null;
          _this2._lastFingerPosition.dirty = false;
          return;
        }

        _this2._lastFingerPosition = {
          pos: {
            x: _this2.boundedPostion(p.x),
            y: _this2.boundedPostion(p.y)
          },
          dirty: true
        };

        _this2.debugPointer(_this2.boundedPostion(p.x), _this2.boundedPostion(p.y));
      };
    }

    this.isDebug = false;
  },
  // 限定坐标值
  boundedPostion: function boundedPostion(value) {
    if (value < 0) {
      return 0;
    }

    if (value > 1) {
      return 1;
    }

    return value;
  },
  checkInRegion: function checkInRegion(r) {
    if (!this._lastFingerPosition && !this._lastFingerPosition.pos) {
      return null;
    }

    var p = this._lastFingerPosition ? this._lastFingerPosition.pos || {
      x: 0,
      y: 0
    } : {
      x: 0,
      y: 0
    };
    console.log('~p: ', p);
    console.log('~r: ', r);
    var w = p.x > r.x && p.x < r.x + r.width;
    var h = p.y > r.y && p.y < r.y + r.height;
    return w && h;
  },
  getData: function getData(func) {
    if (window && window.courseware) {
      window.courseware.getData(func, 'scene');
      return;
    }

    var middleLayer = cc.find('middleLayer');

    if (middleLayer) {
      var middleLayerComponent = middleLayer.getComponent('middleLayer');
      middleLayerComponent.getData(func);
      return;
    }

    func(this.getDefaultData());
  },
  getDefaultData: function getDefaultData() {
    // return {"begin_audio":"https://teach.cdn.ireadabc.com/9be46c9adb540ed8a60763f1e657ccb7.mp3","begin_sep_time":66,"guide_audio":"https://teach.cdn.ireadabc.com/9523c8ed45faee686363dd157b0d7426.mp3","playing_audio":"https://teach.cdn.ireadabc.com/d6a953052a6f80549730cb4307c55719.mp3","right_audio":"https://teach.cdn.ireadabc.com/43791fc418e666df5e9ec1b7bf936409.mp3","wrong_audio":"https://teach.cdn.ireadabc.com/7dd85f025a132c2eef8daee38d900287.mp3","wrong_audio1":"https://teach.cdn.ireadabc.com/a76afb06af0799bf538e38f9f80a2261.mp3","wrong_audio2":"https://teach.cdn.ireadabc.com/daee88b6f2eadd78b60436eedffcae08.mp3","end_audio":"https://teach.cdn.ireadabc.com/9c1e87b3c184b06e14e44bb058b9804e.mp3","bgItem":{"url":"https://teach.cdn.ireadabc.com/16b6dacd8e6c1ce6da16f500a66b366b.jpg","rect":{"x":319.68,"y":0,"width":257.64,"height":342}},"hotZoneItemArr":[{"id":"1650544807877","index":0,"itemType":"pic","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":176.65207877461702},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/66c7c0847c33f7f95cb0035fe14c4405.json","name":"monkey_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/98a8272cd2d97047b090ff10e948b978.json","name":"monkey_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/c35ced408ad68a52c4ec5375373d3627.png","name":"monkey_tex.png"},"rect":{"x":128.83,"y":171,"width":0,"height":0}},{"id":"1650546079000","index":1,"audio_url":"https://teach.cdn.ireadabc.com/f9edc84a669688c5abddd55e2aab015d.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"21.3","posX":692.4127500193598,"posY":218.14695959185556,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/e3c67a25dd3bb34fe113e126e6e1cc81.json","name":"ox_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/81d487bf31d3a4d0f25f44c184ba9233.json","name":"ox_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/e199392b52a735f6e37a6815ec3bb10e.png","name":"ox_tex.png"},"rect":{"x":159.34,"y":138.66,"width":38.83,"height":38.83}},{"id":"1650546232189","index":2,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/0a3ea93c62ff4087859ed587020c53b5.json","name":"car_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/6000e4fbbb95f545afa5456c64d8c7d1.json","name":"car_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/75e9972c15d2a67deedf60d448fd4e69.png","name":"car_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650546321127","index":3,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/d4c1e1abcf3d8f5415747fd2599b8a8c.json","name":"Chair_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/1d7254eb7fa3008e8178347bb944cdcb.json","name":"Chair_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/48e85e8ff384eed72dfe865fc981e18c.png","name":"Chair_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650546335240","index":4,"audio_url":"https://teach.cdn.ireadabc.com/6182d46bad09fccb8934217d33557204.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"53","posX":452.5,"posY":129,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/b462d80c21aa75995dd99f0f43ccf1e6.json","name":"quilt_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/866c9e2987870947fc63bce108ef157a.json","name":"quilt_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/d952c37f40c3cf07e024edfd4416423e.png","name":"quilt_tex.png"},"rect":{"x":71.99,"y":100.75,"width":50.83,"height":36.97}},{"id":"1650546644333","index":5,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/6b8a1a7b0fd23686ea60465279cd4da0.json","name":"robot_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/31a74ed95fe48adab00702675811c3a8.json","name":"robot_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/e57052537d89356b0a79d8cb77980219.png","name":"robot_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650546658697","index":6,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/bf3616060460439eeb3fd5227370e15a.json","name":"panda_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/2dafeb25c973c910035ff7ed1a6a6334.json","name":"panda_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/75d90b05345fa470285ac488cb205cfd.png","name":"panda_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650546672448","index":7,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/5feff811b0117dd8e67973072e60d310.json","name":"queen_1_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/bb5856b92b09c5fe7a1da00bb68134ca.json","name":"queen_1_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/f4e5a138b086ef3dcfa57432543b66e9.png","name":"queen_1_tex.png"},"animType":"dragonBone","rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650546687069","index":8,"audio_url":"https://teach.cdn.ireadabc.com/301858df7b07e661426a006acb26059c.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"42.5","posX":512.3883524629834,"posY":259.83617125849,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/f3a8efcd1850ee8a6cee89a18e86dc4a.json","name":"milk_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/73b05f19d419bd3ac17c2b92dab88423.json","name":"milk_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/e38375da46f85a23202d5cbc812d62e4.png","name":"milk_tex.png"},"rect":{"x":37.72,"y":168.1,"width":21.17,"height":40.34}},{"id":"1650547060490","index":9,"audio_url":"https://teach.cdn.ireadabc.com/05e5b29aeffa4ef94bcc5b23167aec90.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"47.7","posX":483.22135734006736,"posY":245.38039407076505,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/99a6e6d9361eca7e51ed34ca2e0fd017.json","name":"bird_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/6a379ddbe6df1806368c43c8ee82332d.json","name":"bird_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/cf04c63104d89511902578944061f980.png","name":"bird_tex.png"},"rect":{"x":17.91,"y":140.83,"width":18.52,"height":73.95}},{"id":"1650547373869","index":10,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","labelText":"60","posX":420.5,"posY":295,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/7ebc28f3f339b16ca48d20f2a3eb44c1.json","name":"alligator_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/b04e8206fd217bd22dcdac1008393317.json","name":"alligator_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/b3990d94612bd3d6e25cf200f85e4334.png","name":"alligator_tex.png"},"rect":{"x":16.06,"y":229.24,"width":103.52,"height":86.89}},{"id":"1650547482398","index":11,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/a19f2ed7c297c70c639e54e969d64593.json","name":"rabbit_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/4b4f8189cf79fadd7e6533ad84db96be.json","name":"rabbit_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/8f953c861eac94e4e22a8e4ec3eb56b5.png","name":"rabbit_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650547496232","index":12,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/89e0fc6085c294866142803b4ff267ba.json","name":"King_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/d6cfd2d9cd2cd9aff09ab7f03e287421.json","name":"King_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/8c02c3561a2eea0423cb1102200e76f9.png","name":"King_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650547510648","index":13,"audio_url":"https://teach.cdn.ireadabc.com/717ee9713b18d32d38ee089c0abc85ea.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"10.2","posX":641.6680134951944,"posY":288.93672702541255,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/3b7113ebdedcae54be6d0b9633875b88.json","name":"net_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/fc810762f1f2025585e722e43e94137b.json","name":"net_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/5c90820da4f559280fee4579e8db2dbc.png","name":"net_tex.png"},"rect":{"x":123.03,"y":183.02,"width":37.9,"height":52.68}},{"id":"1650547555018","index":14,"itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"1","skeJsonData":{"url":"https://teach.cdn.ireadabc.com/0a5c8df5a23aca7a7540b87340c7608f.json","name":"ostrich_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/2478573c91d1a83fa038e7f6a9db8a85.json","name":"ostrich_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/4619ace67e5770e1fd7fc3ff76e7263e.png","name":"ostrich_tex.png"},"rect":{"x":36.4,"y":78.56,"width":184.87,"height":184.87}},{"id":"1650547573305","index":15,"audio_url":"https://teach.cdn.ireadabc.com/b7bc161c3a3ee143a53058691abf4fa9.mp3","itemType":"rect","fontScale":0.70078125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.70078125,"dragDot":{"x":448.5,"y":170.54984583761566},"gIdx":"0","labelText":"15.9","posX":670.8119839772754,"posY":137.87940870201697,"skeJsonData":{"url":"https://teach.cdn.ireadabc.com/91e8ca03d1df89e4ec2404421d4c692f.json","name":"durazno_ske.json"},"texJsonData":{"url":"https://teach.cdn.ireadabc.com/32d259b0194370625f8fe94b1ddc0a85.json","name":"durazno_tex.json"},"texPngData":{"url":"https://teach.cdn.ireadabc.com/8eef56b20e221a36fce1d672199859ff.png","name":"durazno_tex.png"},"rect":{"x":146.92,"y":83.73,"width":32.34,"height":32.34}}]}
    // return  {"begin_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","begin_sep_time":1,"guide_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","playing_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","right_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio1":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","wrong_audio2":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","end_audio":"http://staging-teach.cdn.ireadabc.com/3d307a02663e1cd667b7c951340ec98b.mp3","bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/84ec6edc20bceaaa9dbe824092b6860d.png","rect":{"x":736.95,"y":0,"width":599.09,"height":775}},"hotZoneItemArr":[{"id":"1659333645573","index":0,"audio_url":"http://staging-teach.cdn.ireadabc.com/5a1a2670845bfe76662e86d9a3a69f81.mp3","itemType":"rect","fontScale":1.61953125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.61953125,"dragDot":{"x":1036.5,"y":387.5},"gIdx":"1","labelText":"1","posX":887.5,"posY":165.5,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/133a1f60719ed26247e35dc022d82862.json","name":"spineboy-pro.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/e0945b8265ea3b8053afb814c6b849d3.atlas","name":"spineboy-pro.atlas"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/517553f50224915148f9efc5b7556798.png","name":"spineboy-pro.png"},"animType":"spine","rect":{"x":48.05,"y":65.5,"width":205,"height":200}},{"id":"1659334098930","index":1,"audio_url":"http://staging-teach.cdn.ireadabc.com/16eb06a6beb9e4fa77c9b5d2d643ab29.mp3","itemType":"rect","fontScale":1.61953125,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":1.61953125,"dragDot":{"x":1036.5,"y":387.5},"gIdx":"0","labelText":"1","posX":1212.5,"posY":643.5,"skeJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/679fed26daa464819d553de6331b3552.json","name":"alien-pro.json"},"texJsonData":{"url":"http://staging-teach.cdn.ireadabc.com/65d8214c6b5c5d0496e17adb0408276a.atlas","name":"alien-pro.atlas"},"texPngData":{"url":"http://staging-teach.cdn.ireadabc.com/a319b372899239325b90bb4ec07b4970.png","name":"alien-pro.png"},"animType":"spine","rect":{"x":375.56,"y":543.5,"width":200,"height":200}}]}
    return _defaultData_OP.defaultData;
  },
  preloadItem: function preloadItem() {
    this.addPreloadImage();
    this.addPreloadAudio();
    this.addPreloadAnima();
    this.preload();
  },
  addPreloadImage: function addPreloadImage() {
    this._imageResList.push({
      url: this.data.bgItem.url
    });

    for (var _iterator = _createForOfIteratorHelperLoose(this.data.hotZoneItemArr), _step; !(_step = _iterator()).done;) {
      var q = _step.value;

      if (q.gIdx == '0') {
        this._imageResList.push({
          url: q.texPngData.url
        });
      }

      if (q.gIdx == '1') {
        this._imageResList.push({
          url: q.texPngData.url
        });
      }

      if (q.gIdx == '2') {
        this._imageResList.push({
          url: q.pic_url
        });
      }
    }
  },
  prepareAudioClip: function prepareAudioClip(url, key) {
    var _this3 = this;

    if (url) {
      cc.assetManager.loadRemote(url, function (err, audioClip) {
        if (audioClip) {
          _this3[key] = audioClip;
        }
      });
    }
  },
  addPreloadAudio: function addPreloadAudio() {
    this._audioResList.push({
      url: this.data.begin_audio
    }); // this.prepareAudioClip(this.data.begin_audio1, 'begin_audio1')
    // this._audioResList.push({ url: this.data.begin_audio2 });
    // this.prepareAudioClip(this.data.begin_audio2, 'begin_audio2')


    this._audioResList.push({
      url: this.data.guide_audio
    });

    this._audioResList.push({
      url: this.data.playing_audio
    });

    if (this.data.wrong_audio) {
      this._audioResList.push({
        url: this.data.wrong_audio
      });

      this.wrongAudio = this.data.wrong_audio;
    }

    if (this.data.right_audio) {
      this._audioResList.push({
        url: this.data.right_audio
      });

      this.rightAudio = this.data.right_audio;
    }

    this._audioResList.push({
      url: this.data.wrong_audio1
    });

    this._audioResList.push({
      url: this.data.wrong_audio2
    });

    this._audioResList.push({
      url: this.data.end_audio
    });

    for (var _iterator2 = _createForOfIteratorHelperLoose(this.data.hotZoneItemArr), _step2; !(_step2 = _iterator2()).done;) {
      var q = _step2.value;

      if (q.gIdx == '0') {
        this._audioResList.push({
          url: q.audio_url
        });
      }
    }
  },
  debugPointer: function debugPointer() {
    var boxDebugger = cc.find('Canvas/box-debugger');

    if (!this.isDebug) {
      boxDebugger.active = false;
      return;
    }

    if (!this.POINTER_NODE) {
      this.POINTER_NODE = new cc.Node();
      this.POINTER_NODE.parent = boxDebugger;
      this.POINTER_NODE.name = 'POINTER_NODE';
      this.POINTER_NODE.addComponent(cc.Graphics);
    }

    var grap = this.POINTER_NODE.getComponent(cc.Graphics);
    grap.clear();
    var ground = cc.find('Canvas/frame-border/ground');
    var baseW = ground.width,
        baseH = ground.height;
    var _this$_lastFingerPosi = this._lastFingerPosition.pos,
        px = _this$_lastFingerPosi.x,
        py = _this$_lastFingerPosi.y;
    var x = baseW * px - baseW / 2;
    var y = baseH - baseH * py - baseH / 2 - 16;
    var pn = new cc.Node();
    grap.fillColor = cc.color(255, 0, 0);
    grap.circle(x, y, 32);
    grap.fill();
    grap.stroke();
  },
  debugGraphics: function debugGraphics() {
    var boxDebugger = cc.find('Canvas/box-debugger');

    if (!this.isDebug) {
      boxDebugger.active = false;
      return;
    }

    boxDebugger.active = true;
    console.log('show debug graphics');
    var ground = cc.find('Canvas/frame-border/ground');
    var canvas = cc.find('Canvas');
    var baseW = ground.width,
        baseH = ground.height;
    var _this$data$bgItem$rec = this.data.bgItem.rect,
        bgW = _this$data$bgItem$rec.width,
        bgH = _this$data$bgItem$rec.height;
    var scaleX = bgW / baseW;
    var scaleY = bgH / baseH;
    var added = false;
    this.data.hotZoneItemArr.forEach(function (area) {
      if (added) {// return
      }

      if (area.gIdx != '0') {
        return;
      }

      added = true;
      var dn = new cc.Node();
      var lblNode = new cc.Node();
      lblNode.parent = dn;
      var lbl = lblNode.addComponent(cc.Label);
      lblNode.color = cc.color(0, 0, 0);
      lbl.string = area.skeJsonData.name.substring(0, area.skeJsonData.name.length - 9);
      dn.name = lbl.string;
      dn.parent = boxDebugger;
      dn.width = baseW;
      dn.height = baseH;
      var grap = dn.addComponent(cc.Graphics);
      var r = (0, _util_OP.RandomInt)(1, 255);
      var g = (0, _util_OP.RandomInt)(1, 255);
      var b = (0, _util_OP.RandomInt)(1, 255);
      grap.fillColor = cc.color(r, g, b, 127);
      var _area$rect = area.rect,
          rx = _area$rect.x,
          ry = _area$rect.y,
          rw = _area$rect.width,
          rh = _area$rect.height;
      var w = rw / bgW * baseW;
      var h = rh / bgH * baseH;
      var x = rx / bgW * baseW - baseW / 2;
      var y = baseH - ry / bgH * baseH - h - baseH / 2; // w *= scaleX
      // h *= scaleY
      // x *= scaleX
      // y *= scaleY
      // const p = boxDebugger.convertToNodeSpaceAR(cc.v2(x,y));
      // x = p.x;
      // y = p.y;

      lblNode.x = x;
      lblNode.y = y + h; // dn.scaleX = scaleX;
      // dn.scaleY = scaleY;
      // dn.scale = area.mapScale; // minScale; // this._mapScaleMax * area.mapScale; // ;

      console.log('[debug]', area.skeJsonData.name, x, y, w, h);
      grap.fillRect(x, y, w, h);
      grap.stroke();
    });
  },
  addPreloadAnima: function addPreloadAnima() {},
  preload: function preload() {
    var _this4 = this;

    var preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList); // console.log(preloadArr);


    cc.assetManager.loadAny(preloadArr, null, function (f, t, item) {// console.log(f, t, item)
    }, function (err, data) {
      // console.log(err, data);
      var ground = cc.find("Canvas/frame-border/ground");
      var groundBg = cc.find("Canvas/frame-border/ground/bg");
      groundBg.active = false;
      var baseRect = _this4.data.bgItem.rect;
      (0, _util_OP.getSpriteFrimeByUrl)(_this4.data.bgItem.url, function (sf) {
        var gs = groundBg.getComponent(cc.Sprite);
        gs.spriteFrame = sf;
        groundBg.active = true;
        var dbCount = 0;
        var finishDbCount = 0;

        for (var _iterator3 = _createForOfIteratorHelperLoose(_this4.data.hotZoneItemArr), _step3; !(_step3 = _iterator3()).done;) {
          var block = _step3.value;

          if (block.gIdx == '0' || block.gIdx == '1') {
            dbCount++;
          }
        }

        for (var _iterator4 = _createForOfIteratorHelperLoose(_this4.data.hotZoneItemArr), _step4; !(_step4 = _iterator4()).done;) {
          var _block = _step4.value;

          if (_block.gIdx == '2') {
            (function () {
              var s1 = (ground.width / _block.imgSizeW + ground.height / _block.imgSizeH) / 2;
              var node = new cc.Node();
              node.parent = ground;
              var spr = node.addComponent(cc.Sprite);
              (0, _util_OP.getSpriteFrimeByUrl)(_block.pic_url, function (sf) {
                spr.spriteFrame = sf;
                node.scale = s1;
              });
            })();
          }

          if (_block.gIdx == '0' || _block.gIdx == '1') {
            (function () {
              var n = new cc.Node(); // n.scale = 0.25;

              n.scale = ground.width / groundBg.width;
              n.parent = ground;
              n.active = false;

              if (_block.animType == 'spine') {
                var skeleton = n.addComponent(sp.Skeleton);
                n.isSpine = true;
                (0, _util_OP.loadSpine)(skeleton, _block.texPngData.name, {
                  tex: _block.texPngData.url,
                  atlas: _block.texJsonData.url,
                  ske: _block.skeJsonData.url
                }).then(function (_ref) {
                  var width = _ref.width,
                      height = _ref.height;
                  n.width = width;
                  n.height = height;
                  n.active = true; // db.playAnimation('null', 0);
                  // skeleton.setToSetupPose();
                  // skeleton.setAnimation(0, 'enlarge', true);				

                  _this4._allAnimationNodes.push(n);

                  finishDbCount++;
                  console.log(finishDbCount, dbCount);

                  if (finishDbCount == dbCount) {
                    _this4.loadEnd();
                  }
                })["catch"](function () {
                  finishDbCount++;
                  console.log(finishDbCount, dbCount);

                  if (finishDbCount == dbCount) {
                    _this4.loadEnd();
                  }
                });
              } else {
                var db = n.addComponent(dragonBones.ArmatureDisplay);
                (0, _util_OP.loadDragonBones)(db, {
                  tex: _block.texPngData.url,
                  atlas: _block.texJsonData.url,
                  ske: _block.skeJsonData.url
                }).then(function (_ref2) {
                  var width = _ref2.width,
                      height = _ref2.height;
                  n.width = width;
                  n.height = height;
                  n.active = true;
                  db.playAnimation('null', 0);

                  _this4._allAnimationNodes.push(n);

                  finishDbCount++;
                  console.log(finishDbCount, dbCount);

                  if (finishDbCount == dbCount) {
                    _this4.loadEnd();
                  }
                })["catch"](function () {
                  finishDbCount++;
                  console.log(finishDbCount, dbCount);

                  if (finishDbCount == dbCount) {
                    _this4.loadEnd();
                  }
                });
              }

              if (_block.gIdx == '0') {
                var rectInfo = {
                  node: n,
                  audio_url: _block.audio_url,
                  rect: {
                    x: _block.rect.x / baseRect.width,
                    y: _block.rect.y / baseRect.height,
                    width: _block.rect.width / baseRect.width,
                    height: _block.rect.height / baseRect.height
                  }
                };

                _this4._figurePointRectArray.push(rectInfo); // this.addRectNodeListener(block);


                if (_block.labelText) {
                  var k = +_block.labelText * 1000;

                  if (!isNaN(k)) {
                    _this4._hintsNodeList.push({
                      node: n,
                      after: k
                    });
                  }
                }
              }
            })();
          }
        }
      }); // console.log(this.data);

      console.log('resource perload finish'); // <<<<<<< HEAD
      // =======
      // 			if (window && window["air"]) {
      // 				// cc.find('Canvas').opacity = 0;
      // 				window.air.onCourseInScreen = (next) => {
      // 					// cc.find('Canvas').opacity = 255;
      // 					this.loadEnd();
      // 					next();
      // 				}
      // 				window.air.hideAirClassLoading();
      // 			} else {
      // 				this.loadEnd();
      // 			}
      // >>>>>>> 2d461e1910571bcfc6ad4dc93c2cedafc20923ea

      cc.debug.setDisplayStats(false);
    });
  },
  loadEnd: function loadEnd() {
    if (window && window["air"] && window["air"].hideAirClassLoading) {
      window["air"].hideAirClassLoading();
    }

    this.initData(); // this.initAudio();
    // this.initView();

    this.initBg(); // this.initListener();

    this.debugGraphics();
    this.createStateMachine();
  },
  _cantouch: null,
  initData: function initData() {
    // 所有全局变量 默认都是null 
    this._cantouch = true;
  },
  // audioBtn: null,
  // initAudio() {
  // 	const audioNode = cc.find('Canvas/res/audio');
  // 	const getAudioByResName = (resName) => {
  // 		return audioNode.getChildByName(resName).getComponent(cc.AudioSource);
  // 	}
  // 	this.audioBtn = getAudioByResName('btn');
  // },
  // initView() {
  // 	// this.initBg();
  // 	// this.initPic();
  // 	// this.initBtn();
  // 	this.initIcon();
  // },
  addRectNodeListener: function addRectNodeListener(data) {
    var _this5 = this;

    var bg = cc.find("Canvas/frame-border/ground/bg").parent;
    var rate = bg.scale * bg.width / this.data.bgItem.rect.width;
    var rectNode = new cc.Node();
    rectNode.name = 'rect' + data.index;
    bg.addChild(rectNode, 20);
    var ctx = rectNode.addComponent(cc.Graphics); // 红色矩形

    ctx.lineWidth = 4;
    ctx.strokeColor = cc.Color.BLACK;
    ctx.fillColor = cc.Color.WHITE.setA(100);
    var scale = rate / bg.scaleY;
    console.log('scale~ : ', scale);
    rectNode.width = data.rect.width * scale;
    rectNode.height = data.rect.height * scale;
    rectNode.x = -bg.width / 2 + data.rect.x * scale + bg.x;
    rectNode.y = bg.height / 2 - data.rect.height * scale - data.rect.y * scale + bg.y;
    rectNode.anchorX = rectNode.anchorY = 0;
    console.log('data: ', data);
    console.log('rectNode: ', rectNode); // if (pageData.bgItem.isShowDebugLine) {

    ctx.rect(0, 0, rectNode.width, rectNode.height); // ctx.fillRect(0, 0, 200, 200);
    // }

    ctx.stroke();
    ctx.fill();
    rectNode.addComponent(cc.Button);
    rectNode.on("click", function () {
      console.log(" in rectNode click");

      var _x = rectNode.x / bg.width;

      var _y = rectNode.y / bg.height;

      var _w = rectNode.width / bg.width;

      var _h = rectNode.height / bg.height;

      var pos = {
        x: _x + _w / 2 + 0.5,
        y: -(_y + _h / 2 - 0.5)
      };
      _this5._lastFingerPosition = {
        pos: pos,
        dirty: true
      };
    });
  },
  initBg: function initBg() {
    var bgNode = cc.find('Canvas/bg');
    bgNode.scale = this._mapScaleMax;
    console.log('this._mapScaleMax', this._mapScaleMax);
  },

  /*initBtn() {
  		this.curPage = 0;
  	const bottomPart = cc.find('Canvas/bottomPart');
  	bottomPart.zIndex = 5; // 提高层级
  		bottomPart.x = bottomPart.parent.width / 2;
  	bottomPart.y = -bottomPart.parent.height / 2;
  		const leftBtnNode = bottomPart.getChildByName('btn_left');
  	//节点中添加了button组件 则可以添加click事件监听
  	leftBtnNode.on('click', () => {
  		if (!this._cantouch) {
  			return;
  		}
  		if (this.curPage == 0) {
  			return;
  		}
  		this.curPage = 0
  		this.leftMove();
  			// 游戏结束时需要调用这个方法通知系统作业完成
  		onHomeworkFinish();
  			cc.audioEngine.play(this.audioBtn.clip, false, 0.8)
  	})
  		const rightBtnNode = bottomPart.getChildByName('btn_right');
  	//节点中添加了button组件 则可以添加click事件监听
  	rightBtnNode.on('click', () => {
  		if (!this._cantouch) {
  			return;
  		}
  		if (this.curPage == 1) {
  			return;
  		}
  			this.curPage = 1
  		this.rightMove();
  			cc.audioEngine.play(this.audioBtn.clip, false, 0.5)
  	})
  },*/
  // update (dt) {},
  _timeoutIds: null,
  _intervalIds: null,
  // 生命周期
  onDestroy: function onDestroy() {
    console.log('op15 onDestroy');

    this._timeoutIds.forEach(function (id) {
      clearTimeout(id);
    });

    this._intervalIds.forEach(function (id) {
      clearInterval(id);
    });

    this.gameMachineService.stopChild();
    this.gameMachineService.stop();

    if (window.courseware && window.courseware.closeOsmoFingerRead) {
      if (this.isOpenedOsmoFingerRead) {
        window.courseware.closeOsmoFingerRead();
      }
    }
  }
});

cc._RF.pop();