window.__require = function t(e, n, i) {
function a(r, c) {
if (!n[r]) {
if (!e[r]) {
var s = r.split("/");
s = s[s.length - 1];
if (!e[s]) {
var h = "function" == typeof __require && __require;
if (!c && h) return h(s, !0);
if (o) return o(s, !0);
throw new Error("Cannot find module '" + r + "'");
}
r = s;
}
var d = n[r] = {
exports: {}
};
e[r][0].call(d.exports, function(t) {
return a(e[r][1][t] || t);
}, d, d.exports, t, e, n, i);
}
return n[r].exports;
}
for (var o = "function" == typeof __require && __require, r = 0; r < i.length; r++) a(i[r]);
return a;
}({
PS02: [ function(t, e) {
"use strict";
cc._RF.push(e, "8b6622IIfBDFrKy2BvAvT4U", "PS02");
cc.Class({
extends: cc.Component,
properties: {},
start: function() {}
});
cc._RF.pop();
}, {} ],
scene: [ function(t, e) {
"use strict";
cc._RF.push(e, "1e6c5bmzb5Cw7tGU+6pyb+T", "scene");
var n, i = t("./util");
cc.Class(((n = {
extends: cc.Component,
properties: {
baseWidth: 1280,
baseHeight: 720
},
onLoad: function() {
cc.debug.setDisplayStats(!1);
this.initSceneData();
this.initSize();
},
initSceneData: function() {
this._imageResList = [];
this._audioResList = [];
this._animaResList = [];
},
_designSize: null,
_frameSize: null,
_mapScaleMin: null,
_mapScaleMax: null,
_cocosScale: null,
canvas: null,
initSize: function() {
var t = cc.view.getFrameSize().width / cc.view.getFrameSize().height >= cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height;
cc.Canvas.instance.fitHeight = t;
cc.Canvas.instance.fitWidth = !t;
var e = cc.view.getFrameSize();
this._frameSize = e;
this._designSize = cc.view.getDesignResolutionSize();
var n = cc.winSize.width / e.width, i = cc.winSize.height / e.height;
this._cocosScale = Math.min(n, i);
n = e.width / this._designSize.width;
i = e.height / this._designSize.height;
this._mapScaleMin = Math.min(n, i) * this._cocosScale;
this._mapScaleMax = Math.max(n, i) * this._cocosScale;
this.canvas = cc.find("Canvas");
},
start: function() {
var t = this;
this.getData(function(e) {
console.log("data:", e);
t.data = e || t.getDefaultData();
t.preloadItem();
});
},
_imageResList: null,
_audioResList: null,
_animaResList: null,
preloadItem: function() {
this.addPreloadImage();
this.addPreloadAudio();
this.preload();
},
getData: function(t) {
if (window && window.courseware) window.courseware.getData(t, "Z_05_nxuan1"); else {
var e = cc.find("middleLayer");
e ? e.getComponent("middleLayer").getData(t) : t(this.getDefaultData());
}
},
getDefaultData: function() {
return JSON.parse('{"groupArr":[{"ques":"","optionArr":[{"text":"A"},{"text":"pp","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/b75df34ef55bd1c6e3a799f1dac87fec.mp3"},{"text":"l","isEmpty":false,"audio_url":"http://staging-teach.cdn.ireadabc.com/3c070a33d021725219ab7eec9e60cb39.mp3"},{"text":"e","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/3c070a33d021725219ab7eec9e60cb39.mp3"},{"text":"l","isEmpty":true},{"text":"l","isEmpty":true}],"wrongArr":[{"text":"acw","audio_url":"http://staging-teach.cdn.ireadabc.com/736c616e8b66a3ae03c8e8636ca46f0f.mp3"},{"text":"w","audio_url":"http://staging-teach.cdn.ireadabc.com/89060c9eddd5f0f67908cce77ee74f94.mp3"}],"word_audio_url":"http://staging-teach.cdn.ireadabc.com/1961d807c944e6551af02c7b57e117f3.mp3","audio_url":"http://staging-teach.cdn.ireadabc.com/0128a59057e63c4c6b4b96556d077a98.mp3","pic_url":"http://staging-teach.cdn.ireadabc.com/991a9dd15e889ee4ff13538e49f6a0d7.png"},{"ques":"","optionArr":[{"text":"O","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/1961d807c944e6551af02c7b57e117f3.mp3"},{"text":"r","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/0128a59057e63c4c6b4b96556d077a98.mp3"},{"text":"an"},{"text":"g","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/70f35e529377b982daebc23ad92fa670.mp3"},{"text":"e","audio_url":"http://staging-teach.cdn.ireadabc.com/0128a59057e63c4c6b4b96556d077a98.mp3"}],"wrongArr":[{"text":"c","audio_url":"http://staging-teach.cdn.ireadabc.com/9259e1b99cc17f61210e7edc17f1d697.mp3"}],"pic_url":"http://staging-teach.cdn.ireadabc.com/f6f4bbef497409fef3c8f1d375893829.png","audio_url":"http://staging-teach.cdn.ireadabc.com/a5fa20e0c6024421b0d9a7007c303503.mp3","word_audio_url":"http://staging-teach.cdn.ireadabc.com/32258b839eca32b6ccf94f3dd6c86e0c.mp3"},{"ques":"","optionArr":[{"text":"F","audio_url":"http://staging-teach.cdn.ireadabc.com/c870b402b69186efb491d62f8da98d24.mp3","isEmpty":true},{"text":"i","audio_url":"http://staging-teach.cdn.ireadabc.com/ed1a2dc4bfa7d35041ca94d1badde8ed.mp3","isEmpty":true},{"text":"r"},{"text":"e"},{"text":"f"},{"text":"i"},{"text":"h"},{"text":"h","isEmpty":true,"audio_url":"http://staging-teach.cdn.ireadabc.com/0d11dcd7138f61dbead3dfaa5eb84b47.mp3"},{"text":"t"},{"text":"e"},{"text":"r"}],"wrongArr":[],"word_audio_url":"http://staging-teach.cdn.ireadabc.com/78ba347c18b181fd4550d30bb14c90c5.mp3"}],"isHideShadow":true}');
},
preload: function() {
var t = this, e = this._imageResList.concat(this._audioResList).concat(this._animaResList);
cc.assetManager.loadAny(e, null, null, function() {
t.loadEnd();
window && window.air && window.air.hideAirClassLoading();
});
},
addPreloadImage: function() {
var t = this.data.groupArr;
if (t) for (var e = 0; e < t.length; e++) this._imageResList.push({
url: t[e].pic_url || ""
});
},
addPreloadAudio: function() {
var t = this.data.groupArr;
if (t) for (var e = 0; e < t.length; e++) {
for (var n = t[e].optionArr, i = 0; i < n.length; i++) this._audioResList.push({
url: n[i].audio_url || ""
});
this._audioResList.push({
url: t[e].audio_url || ""
});
this._audioResList.push({
url: t[e].word_audio_url || ""
});
}
},
addPreloadAnima: function() {},
loadEnd: function() {
this.initData();
this.initView();
this.initListener();
},
initMusic: function() {
cc.assetManager.loadRemote(this.data.bg_audio_url, function(t, e) {
cc.audioEngine.setMusicVolume(.3);
cc.audioEngine.playMusic(e, !0);
});
},
groupIndex: null,
wordDisWidth: null,
_curShowItem: null,
emptyGroupArr: null,
initData: function() {
this.groupIndex = 0;
this.wordDisWidth = 10;
this.initCurGroup();
this.initAudioEffect();
},
rightClip: null,
wrongClip: null,
bigStarClip: null,
nextClip: null,
endClip: null,
initAudioEffect: function() {
this.rightClip = cc.find("Canvas/res/audio/right").getComponent(cc.AudioSource).clip;
this.wrongClip = cc.find("Canvas/res/audio/wrong").getComponent(cc.AudioSource).clip;
this.bigStarClip = cc.find("Canvas/res/audio/big_star").getComponent(cc.AudioSource).clip;
this.nextClip = cc.find("Canvas/res/audio/next").getComponent(cc.AudioSource).clip;
this.endClip = cc.find("Canvas/res/audio/end").getComponent(cc.AudioSource).clip;
},
curGroup: null,
initCurGroup: function() {
this.curGroup = JSON.parse(JSON.stringify(this.data.groupArr[this.groupIndex]));
},
initListener: function() {
var t = this, e = cc.find("Canvas"), n = !1, i = function(n) {
t.canvasTouchMove(n);
e.hasEventListener(cc.Node.EventType.MOUSE_MOVE) && e.off(cc.Node.EventType.MOUSE_MOVE, a);
}, a = function(a) {
if (n) {
t.canvasTouchMove(a);
if (e.hasEventListener(cc.Node.EventType.TOUCH_MOVE)) {
e.off(cc.Node.EventType.TOUCH_MOVE, i);
t.removeHtmlCanvasListener("touchmove");
}
}
}, o = function(i) {
n = !1;
t.canvasTouchEnd(i);
e.hasEventListener(cc.Node.EventType.MOUSE_UP) && e.off(cc.Node.EventType.MOUSE_UP, r);
e.hasEventListener(cc.Node.EventType.MOUSE_LEAVE) && e.off(cc.Node.EventType.MOUSE_LEAVE, r);
t.removeHtmlTouchEnd();
}, r = function(i) {
n = !1;
t.canvasTouchEnd(i);
e.hasEventListener(cc.Node.EventType.TOUCH_END) && e.off(cc.Node.EventType.TOUCH_END, o);
e.hasEventListener(cc.Node.EventType.TOUCH_CANCEL) && e.off(cc.Node.EventType.TOUCH_CANCEL, o);
};
e.on(cc.Node.EventType.TOUCH_MOVE, i);
e.on(cc.Node.EventType.MOUSE_MOVE, a);
e.on(cc.Node.EventType.TOUCH_END, o);
e.on(cc.Node.EventType.TOUCH_CANCEL, o);
e.on(cc.Node.EventType.MOUSE_UP, r);
},
removeHtmlCanvasListener: function(t) {
document.querySelector("canvas").addEventListener(t, function() {});
},
removeHtmlTouchEnd: function() {
document.querySelector("canvas").removeEventListener("touchend", this.htmlCanvasTouchendFunc, this);
},
canvasTouchMove: function(t) {
if (this._curShowItem) {
var e = t.getLocation();
this._curShowItem.x = e.x - t.currentTarget.width / 2;
this._curShowItem.y = e.y - t.currentTarget.height / 2;
}
},
canvasTouchEnd: function() {
if (this._curShowItem) {
this.checkOnEmptyLetter();
this._curShowItem = null;
}
},
initView: function() {
this.initQuestion();
this.initAnswerGroup();
this.initStar();
this.refreshWordNode();
},
bigStarArr: null,
initStar: function() {
var t = this.data.groupArr;
if (!(t.length <= 1)) {
this.bigStarArr = [];
var e = this.canvas.width / 2 - 80 * this._mapScaleMin, n = this.canvas.height / 2 - 80 * this._mapScaleMin, a = 80 * this._mapScaleMin, o = 1;
if (t.length > 5) {
a = 400 / t.length * this._mapScaleMin;
o = 5 / t.length;
}
for (var r = 0; r < t.length; r++) {
var c = (0, i.getSprNode)("star_bg");
this.canvas.addChild(c, 2);
c.x = e;
c.y = n - r * a;
c.scale = o;
var s = (0, i.getSprNode)("star");
c.addChild(s);
s.active = !1;
c.star = s;
var h = (0, i.getSprNode)("icon_bigstar");
s.addChild(h);
h.angle = -90;
c.starBig = h;
this.bigStarArr.push(c);
}
}
},
initQuestion: function() {
this.initQuestionPanel();
this.initQuestionLabel();
this.initQuestionSound();
},
panel: null,
initQuestionPanel: function() {
var t = (0, i.getSprNode)("panel");
t.scale = this._mapScaleMin;
t.x = 0;
t.y = 170 * this._mapScaleMin;
this.canvas.addChild(t);
this.panel = t;
this.refreshCurPic();
},
refreshCurPic: function() {
var t = this;
(0, i.getSprNodeByUrl)(this.curGroup.pic_url, function(e) {
var n = t.panel.pic, a = function() {
cc.tween(e.node).to(.3, {
opacity: 255
}, {
easing: "sineInOut"
}).start();
t.playQuestionSound();
};
t.panel.addChild(e.node);
e.node.y = 10;
var o = 489 / e.node.width, r = 290 / e.node.height;
e.node.scale = Math.min(o, r);
t.panel.pic = e.node;
e.node.opacity = 0;
if (n) {
cc.tween(n).to(.2, {
opacity: 0
}, {
easing: "sineOut"
}).call(function() {
n.removeFromParent();
a();
}).start();
(0, i.playAudioByUrl)(t.nextClip);
} else a();
});
},
soundNode: null,
initQuestionSound: function() {
var t = this, e = new cc.Node();
e.x = this.panel.width / 2 - 30;
e.y = this.panel.height / 2 - 30;
e.parent = this.panel;
e.zIndex = 12;
this.soundNode = e;
var n = cc.find("Canvas/btn_laba");
n.parent = e;
n.x = 0;
n.y = 0;
e.anima = n;
var a = (0, i.getSprNode)("btn_laba");
e.addChild(a, 2);
e.icon = a;
a.addComponent(cc.Button);
a.on("click", function() {
t.playQuestionSound();
});
},
playQuestionSound: function() {
var t = this;
this.soundNode.icon.active = !1;
var e = this.soundNode.anima.getComponent(cc.Animation);
e.play();
(0, i.playAudioByUrl)(this.curGroup.audio_url, function() {
e.stop();
t.soundNode.icon.active = !0;
});
},
wordNode: null,
initQuestionLabel: function() {
var t = new cc.Node();
t.scale = .9 * this._mapScaleMin;
this.emptyGroupArr = [];
for (var e = this.curGroup.optionArr, n = 0; n < e.length; n++) {
var i = e[n], a = this.getLetterGroup(i);
a.x = t.width + a.width / 2;
t.addChild(a);
t.width += a.width;
i.isEmpty && this.emptyGroupArr.push(a);
}
t.y = this.panel.y - 247 * this._mapScaleMin;
this.canvas.addChild(t);
this.wordNode = t;
for (var o = t.width, r = 0; r < t.children.length; r++) t.children[r].x -= o / 2;
},
refreshQuestionLabel: function() {
var t = this;
cc.tween(this.wordNode).to(.2, {
opacity: 0
}, {
easing: "cubicIn"
}).call(function() {
t.resetWordNode();
}).to(.3, {
opacity: 255
}, {
easing: "cubicInOut"
}).start();
},
resetWordNode: function() {
var t = this.wordNode;
t.width = 0;
t.removeAllChildren();
this.emptyGroupArr = [];
for (var e = this.curGroup.optionArr, n = 0; n < e.length; n++) {
var i = e[n], a = this.getLetterGroup(i);
a.x = t.width + a.width / 2;
t.addChild(a);
t.width += a.width;
i.isEmpty && this.emptyGroupArr.push(a);
}
t.y = this.panel.y - 247 * this._mapScaleMin;
this.refreshWordNode();
},
getLetterGroup: function(t, e) {
void 0 === e && (e = !0);
var n = t.text, a = new cc.Node();
a.width = this.wordDisWidth;
a.data = t;
a.emptyArr = [];
a.letterArr = [];
for (var o = !!e && t.isEmpty, r = 0; r < n.length; r++) {
var c = this.getLetterResName(n[r], !1);
console.log("resName: ", c);
var s = (0, i.getSprNode)(c);
a.addChild(s);
s.x = a.width + s.width / 2;
a.width += s.width + this.wordDisWidth;
a.height = s.height;
a.letterArr.push(s);
if (o) {
var h = this.getLetterResName(n[r], o), d = (0, i.getSprNode)(h);
a.addChild(d);
d.x = s.x;
d.y = 12;
a.emptyArr.push(d);
}
}
if (o) {
this.hideGroupLetter(a);
this.data.isHideShadow && this.changeShadowToBg(a);
}
for (var u = a.width, l = 0; l < a.children.length; l++) a.children[l].x -= u / 2;
return a;
},
changeShadowToBg: function(t) {
for (var e = t.emptyArr, n = 0; n < e.length; n++) e[n].removeFromParent();
var a = (0, i.getSprNode)("ques_bg");
t.addChild(a);
t.emptyArr = [ a ];
},
refreshWordNode: function() {
console.log("this.wordNode: ", this.wordNode);
for (var t = this.wordNode.children, e = 0, n = 0; n < t.length; n++) {
var i = t[n];
this.refreshLetterGroup(i);
i.x = e;
e += i.totalW + this.wordDisWidth;
}
e -= this.wordDisWidth;
this.wordNode.width = e;
var a = this.wordNode, o = a.width;
o > .9 * this.canvas.width ? a.scale = .9 * this.canvas.width / o : a.scale = 1;
for (var r = 0; r < a.children.length; r++) a.children[r].x -= o / 2;
},
refreshLetterGroup: function(t) {
var e, n = t.letterArr, i = t.emptyArr;
console.log("letterArr: ", n);
console.log("emptyArr: ", i);
var a = n;
i && null != (e = i[0]) && e.active && (a = i);
t.width = 0;
for (var o = 0, r = 0; r < a.length; r++) {
a[r].x = o + a[r].width / 2;
o += a[r].width + this.wordDisWidth;
}
t.totalW = o;
},
showGroupLetter: function(t) {
console.log("showGroupLetter : ", t);
for (var e = t.letterArr, n = t.emptyArr, i = 0; i < e.length; i++) e[i].active = !0;
for (var a = 0; a < n.length; a++) n[a].active = !1;
},
hideGroupLetter: function(t) {
for (var e = t.letterArr, n = t.emptyArr, i = 0; i < e.length; i++) e[i].active = !1;
for (var a = 0; a < n.length; a++) n[a].active = !0;
},
getLetterResName: function(t, e) {
return e ? /[A-Z]/.test(t) ? "letter_big_bg/" + t.toLowerCase() + "2_di" : "letter_small_bg/" + t + "_di" : /[A-Z]/.test(t) ? "letter_big/" + t.toLowerCase() + "2" : "letter_small/" + t;
},
answerGroupArr: null,
answerNode: null,
initAnswerGroup: function(t) {
void 0 === t && (t = !1);
var e;
if (this.answerNode) this.answerNode.width = 0; else {
(e = new cc.Node()).scale = this._mapScaleMin;
this.answerNode = e;
this.canvas.addChild(e);
}
e = this.answerNode;
for (var n = this.getAnswerArr(), i = [], a = 0; a < n.length; a++) {
var o = n[a], r = this.getLetterGroup(o, !1);
this.addLetterDragListener(r);
this.addLetterSound(o, r);
r.x = e.width + r.width / 2;
e.addChild(r);
e.width += r.width + 30;
i.push(r);
}
var c = .9 * this.canvas.width;
e.width > c && (e.scale = c / e.width);
e.x = -e.width / 2 * e.scale;
e.y = -230 * this._mapScaleMin;
this.answerGroupArr = i;
for (var s = 0; s < i.length; s++) {
var h = i[s], d = this.canvas.convertToNodeSpaceAR(h.parent.convertToWorldSpaceAR(cc.v2(h.x, h.y)));
h.x = d.x;
h.y = d.y;
h.parent = this.canvas;
h.scale = e.scale;
h.baseX = h.x;
h.baseY = h.y;
h.baseS = h.scale;
if (t) {
h.opacity = 0;
cc.tween(h).delay(.2).to(.3, {
opacity: 255
}, {
easing: "cubicInOut"
}).start();
}
}
},
addLetterSound: function(t, e) {
t.audio_url && cc.assetManager.loadRemote(t.audio_url, function(t, n) {
e.audioClip = n;
});
},
addLetterDragListener: function(t) {
var e = this;
t.on(cc.Node.EventType.TOUCH_START, function() {
if (!t.data.isEnd) {
e._curShowItem = t;
t.zIndex = 3;
t.tween && t.tween.stop();
e.dragCurItem();
}
});
},
getAnswerArr: function() {
for (var t = this.curGroup.optionArr, e = [], n = 0; n < t.length; n++) t[n].isEmpty && e.push(t[n]);
e = e.concat(this.curGroup.wrongArr);
return (0, i.randomSortByArr)(e);
},
checkOnEmptyLetter: function() {
console.log("emptyGroupArr: ", this.emptyGroupArr);
for (var t = 0; t < this.emptyGroupArr.length; t++) {
var e = this.emptyGroupArr[t];
console.log("letterGroup.data: ", e.data);
console.log("this._curShowItem.data: ", this._curShowItem.data);
if (e.data && e.data.text == this._curShowItem.data.text) {
console.log("data in ");
var n = this._curShowItem.parent.convertToWorldSpaceAR(cc.v2(this._curShowItem.x, this._curShowItem.y));
if (e.getBoundingBoxToWorld().contains(n)) {
console.log("rect in ");
(0, i.removeItemFromArr)(this.emptyGroupArr, e);
this.showLetterSuccess(e);
this.checkGroupEnd();
return;
}
}
}
this.letterBack();
},
letterBack: function() {
if (this._curShowItem) {
(0, i.playAudio)(this.wrongClip);
var t = this._curShowItem;
t.tween = cc.tween(t).to(.5, {
x: t.baseX,
y: t.baseY
}, {
easing: "elasticOut"
}).call(function() {
t.zIndex = 0;
t.tween = null;
}).start();
}
},
isDrag: null,
dragCurItem: function() {
this.isDrag = !0;
this.playCurItemAudio();
},
playCurItemAnima: function() {
if (this._curShowItem) {
var t = this._curShowItem;
t.tween && t.tween.stop();
var e = this._curShowItem.baseS;
t.tween = cc.tween(t).to(.075, {
scaleX: 1.22 * e,
scaleY: .78 * e
}, {
easing: "quadOut"
}).to(.15, {
scaleX: .95 * e,
scaleY: 1.05 * e
}, {
easing: "quadInOut"
}).to(.15, {
scaleX: 1.02 * e,
scaleY: .98 * e
}, {
easing: "quadInOut"
}).to(.15, {
scaleX: 1 * e,
scaleY: 1 * e
}, {
easing: "quadInOut"
}).call(function() {
t.tween = null;
}).start();
}
},
playCurItemAudio: function() {
var t = this;
if (this._curShowItem && this._curShowItem.audioClip) {
this.playEffectByAudioClip(this._curShowItem.audioClip, function() {
t.isDrag && t.playCurItemAudio();
});
this.playCurItemAnima();
}
},
playEffectByAudioClip: function(t, e) {
void 0 === e && (e = null);
if (t) {
var n = cc.audioEngine.playEffect(t, !1, .8);
e && cc.audioEngine.setFinishCallback(n, function() {
e();
});
}
},
showLetterSuccess: function(t) {
console.log(" in showLetterSuccess");
this.showGroupLetter(t);
this.refreshWordNode();
this.showDragSuccessAnima(t);
this._curShowItem.active = !1;
},
showDragSuccessAnima: function(t) {
var e = cc.find("Canvas/res/anima/right"), n = cc.instantiate(e);
t.addChild(n, 20);
n.x = t.totalW / 2;
(0, i.playAudio)(this.rightClip);
},
checkGroupEnd: function() {
var t = this;
if (0 == this.emptyGroupArr.length) {
(0, i.delayCall)(.4, function() {
t.showGroupEndAnima();
t.playWordAudio();
t.wrongLetterLeave();
});
(0, i.delayCall)(1, function() {
t.showBigStar();
});
}
},
wrongLetterLeave: function() {
for (var t = this.answerGroupArr, e = 0; e < t.length; e++) t[e].active && this.showLetterLeaveAnima(t[e]);
},
showLetterLeaveAnima: function(t) {
t.data.isEnd = !0;
cc.tween(t).delay(1 * Math.random()).to(1.5, {
y: t.y - this.canvas.height,
angle: 520 * Math.random() - 260
}, {
easing: "cubicIn"
}).start();
},
showGroupEndAnima: function() {
var t = this.wordNode.scale;
cc.tween(this.wordNode).to(.4, {
scaleX: 1.3 * t,
scaleY: 1.3 * t
}, {
easing: "quintOut"
}).delay(.01).to(.4, {
scaleX: 1 * t,
scaleY: 1 * t
}, {
easing: "quintIn"
}).call(function() {}).start();
},
playWordAudio: function() {
this.curGroup.word_audio_url && (0, i.playAudioByUrl)(this.curGroup.word_audio_url, function() {});
},
enterNext: function() {},
checkGameEnd: function() {
this.groupIndex++;
if (this.data.groupArr[this.groupIndex]) {
this.initCurGroup();
this.refreshQuestionLabel();
this.refreshCurPic();
this.initAnswerGroup(!0);
} else {
console.log("this.gameEnd");
this.gameEnd();
}
},
holeArr: null,
initHole: function() {
this.holeArr = [];
for (var t = 100 * this._mapScaleMin, e = 260 * this._mapScaleMin, n = (this.canvas.width - 2 * t - 4 * e) / 3, i = -this.canvas.width / 2 + t + e / 2, a = 200 * this._mapScaleMin, o = -this.canvas.height / 2 + 260 * this._mapScaleMin, r = 0, c = 0; c < 8; c++) {
var s = this.getHole();
this.canvas.addChild(s);
this.holeArr.push(s);
s.x = i + c % 4 * (e + n);
s.y = o - r * a;
3 == c && r++;
}
}
}).bigStarArr = null, n.initStar_ = function() {
var t = this.data.groupArr;
if (!(t.length <= 1)) {
this.bigStarArr = [];
var e = this.canvas.width / 2 - 80 * this._mapScaleMin, n = this.canvas.height / 2 - 80 * this._mapScaleMin, a = 80 * this._mapScaleMin, o = 1;
if (t.length > 5) {
a = 400 / t.length * this._mapScaleMin;
o = 5 / t.length;
}
for (var r = 0; r < t.length; r++) {
var c = (0, i.getSprNode)("star_bg");
this.canvas.addChild(c, 2);
c.x = e;
c.y = n - r * a;
c.scale = o;
var s = (0, i.getSprNode)("star");
c.addChild(s);
s.active = !1;
c.star = s;
var h = (0, i.getSprNode)("icon_bigstar");
s.addChild(h);
h.angle = -90;
c.starBig = h;
this.bigStarArr.push(c);
}
}
}, n.startBtn = null, n.restartBtn = null, n.initBtn = function() {
var t = this, e = cc.find("Canvas/btn_start");
e.scale = this._mapScaleMin;
e.active = !0;
e.zIndex = 50;
e.on(cc.Node.EventType.TOUCH_START, function() {
console.log(" in click");
cc.tween(e).to(.05, {
scale: .9 * t._mapScaleMin
}).to(.05, {
scale: 1 * t._mapScaleMin
}).call(function() {
e.active = !1;
t.startBtnClicked();
t.addSoundBtnListner();
}).start();
});
this.startBtn = e;
var n = cc.find("Canvas/btn_restart");
n.zIndex = 50;
n.on(cc.Node.EventType.TOUCH_START, function() {
console.log(" in click");
cc.tween(n).to(.05, {
scale: .9 * t._mapScaleMin
}).to(.05, {
scale: 1 * t._mapScaleMin
}).call(function() {
n.active = !1;
t.restartBtnClicked();
}).start();
});
this.restartBtn = e;
}, n.showSoundBtn = function() {
var t = cc.find("Canvas/btn_laba");
t.scale = this._mapScaleMin;
t.zIndex = 1;
}, n.startBtnClicked = function() {
var t = this;
this.showQuestion(function() {
cc.tween(t).delay(.3).call(function() {
t.showPenguin();
}).start();
});
(0, i.playAudio)(this.btnClip);
}, n.restartBtnClicked = function() {
this.groupIndex = 0;
this.initCurGroup();
this.hideBigStar();
this.startBtnClicked();
}, n.hideBigStar = function() {
if (this.bigStarArr) for (var t = 0; t < this.bigStarArr.length; t++) cc.tween(this.bigStarArr[t].star).to(.5, {
scale: 0
}, {
easing: "cubicOut"
}).start();
}, n.soundAnima = null, n.addSoundBtnListner = function() {
var t = this, e = cc.find("Canvas/btn_laba");
e.addComponent(cc.Button);
e.on("click", function() {
(0, i.playAudio)(t.btnClip, function() {
t.showQuestion();
});
});
}, n.showQuestion = function(t) {
var e = cc.find("Canvas/btn_laba").getComponent(cc.Animation);
e.play();
(0, i.playAudioByUrl)(this.curGroup.audio_url, function() {
e.stop();
t && "function" == typeof t && t();
});
}, n.getHole = function() {
var t = new cc.Node();
t.scale = this._mapScaleMin;
var e = (0, i.getSprNode)("hole_1");
t.addChild(e, 1);
var n = (0, i.getSprNode)("hole_2");
t.addChild(n, 10);
return t;
}, n.showPenguin = function() {
this.showOnePenguin();
}, n.showOnePenguin = function() {
var t = this;
if (!this.checkIsGroupEnd()) {
var e = this.getFreeHole();
if (e) {
var n = this.getPenguin(), i = this.getOptionData();
this.addPenguin(e, n, i);
} else cc.tween(this).delay(.3).call(function() {
t.showOnePenguin();
}).start();
}
}, n.getOptionData = function() {
return (0, i.randomSortByArr)(this.curGroup.optionArr)[0];
}, n.getPenguin = function() {
if (this.penguinPool.length > 0) return this.penguinPool.shift();
var t = new cc.Node(), e = (0, i.RandomInt)(1, 2), n = (0, i.getSprNode)("penguin_" + e);
t.penguin = n;
this.addPenguinWrong(t, e);
this.addTextPanel(t);
this.addPicPanel(t);
this.addClickNode(t);
t.textPanel.y = n.height / 2 + t.textPanel.height / 2 - 25;
t.picPanel.y = n.height / 2 + t.picPanel.height / 2 - 25;
t.addChild(t.picPanel);
t.addChild(t.textPanel);
t.addChild(n);
t.addChild(t.wrong);
return t;
}, n.addClickNode = function(t) {
var e = this, n = new cc.Node();
n.addComponent(cc.Button);
n.width = 270;
n.height = 180;
n.anchorX = 0;
n.anchorY = 0;
n.on("click", function() {
e.checkPenguinIsRight(t);
});
t.addChild(n, 10);
n.x = -130;
n.y = 40;
n.opacity = 50;
}, n.checkPenguinIsRight = function(t) {
if (t.data && !this.isRightDuration && !t.data.end) if ("1" == t.data.isRight) {
this.showPenguinRight(t);
t.data.end = !0;
} else this.showPenguinWrong(t);
}, n.isRightDuration = null, n.showPenguinRight = function(t) {
this.isRightDuration = !0;
this.showAnimaStar(t);
this.stopPenguin(t);
this.showRightSound(t);
}, n.showPenguinWrong = function(t) {
t.penguin.active = !1;
t.wrong.active = !0;
(0, i.playAudio)(this.wrongClip);
}, n.showAnimaStar = function(t) {
var e = cc.find("Canvas/res/anima/star"), n = cc.instantiate(e);
t.addChild(n, 20);
n.x = 0;
n.y = t.textPanel.y;
}, n.checkNextStar = function(t) {
var e = this, n = t.data;
console.log("this.curGroup: ", this.curGroup);
var i = this.curGroup.optionArr, a = i.indexOf(n);
-1 != a && i.splice(a, 1);
this.checkIsGroupEnd() ? this.showBigStar() : cc.tween(this).delay(1).call(function() {
e.showOnePenguin();
}).start();
this.hideCurPenguin(t);
this.isRightDuration = !1;
}, n.hideCurPenguin = function(t) {
var e = this, n = t.hideData, i = n.downY, a = n.moveTime, o = n.panel, r = n.hole;
cc.tween(t).call(function() {
c();
}).to(a, {
y: i
}, {
easing: "quadInOut"
}).call(function() {
t.active = !1;
t.penguin.active = !0;
t.wrong.active = !1;
r.penguin = null;
e.penguinPool.push(t);
t.moveTween = null;
}).start();
var c = function() {
cc.tween(o).to(.3 * a, {
opacity: 0
}).call(function() {
o.active = !1;
}).start();
};
}, n.showBigStar = function() {
var t = this;
if (!this.bigStarArr || this.bigStarArr.length <= 0) this.checkGameEnd(); else {
var e = this.bigStarArr[this.groupIndex], n = e.starBig;
n.scale = 1;
var a = e.star;
a.active = !0;
a.scaleX = .7 / e.scale;
a.scaleY = 1 / e.scale;
a.angle = 90;
var o = cc.find("Canvas"), r = (0, i.exchangeNodePos)(a.parent, o, cc.v2(0, -o.height / 2)), c = (0, 
i.exchangeNodePos)(a.parent, o, cc.v2(0, -o.height / 4));
a.x = r.x;
a.y = r.y - n.height;
console.log("middlePos = " + JSON.stringify(c));
cc.tween(a).to(.3, {
y: c.y + 80
}, {
easing: "quadOut"
}).to(.1, {
y: c.y + 40,
scaleX: 1.2 / e.scale,
scaleY: .8 / e.scale
}, {
easing: "quadOut"
}).to(.1, {
y: c.y,
scaleX: 1 / e.scale,
scaleY: 1 / e.scale
}, {
easing: "quadOut"
}).delay(.1).to(.8, {
angle: -720,
scale: 1
}).start();
cc.tween(a).delay(.6).to(.8, {
x: 0
}, {
easing: "quadIn"
}).start();
cc.tween(a).delay(.6).to(.8, {
y: 0
}, {
easing: "quadOut"
}).start();
cc.tween(n).delay(.6).to(.8, {
scale: 0
}, {
easing: "quadOut"
}).call(function() {
t.checkGameEnd();
}).start();
(0, i.playAudio)(this.bigStarClip);
}
}, n.gameEnd = function() {
var t = this;
this.playEndEffect();
cc.tween(this).delay(.2).call(function() {
(0, i.onHomeworkFinish)();
t.showRestartBtn();
}).start();
}, n.showRestartBtn = function() {
var t = cc.find("Canvas/btn_restart");
t.zIndex = 20;
t.active = !0;
t.scale = 0;
cc.tween(t).to(1, {
scale: this._mapScaleMin
}, {
easing: "elasticOut"
}).start();
}, n.playEndEffect = function() {
(0, i.playAudio)(this.endClip);
var t = cc.find("Canvas/Main Camera");
t.zIndex = 100;
(0, i.showTrebleFirework)(t, cc.find("RibbonNodeBase").children);
}, n.checkIsGroupEnd = function() {
for (var t = this.curGroup.optionArr, e = 0; e < t.length; e++) if ("1" == t[e].isRight) return !1;
return !0;
}, n.stopPenguin = function(t) {
if (t.moveTween) {
console.log("node.moveTween: ", t.moveTween);
t.moveTween.stop();
}
}, n.showRightSound = function(t) {
var e = this;
(0, i.playAudio)(this.rightClip, function() {
t.data.audio_url ? (0, i.playAudioByUrl)(t.data.audio_url, function() {
e.checkNextStar(t);
}) : e.checkNextStar(t);
});
}, n.addPenguinWrong = function(t, e) {
var n = (0, i.getSprNode)("penguin_" + e + "_wrong");
n.active = !1;
t.wrong = n;
}, n.addTextPanel = function(t) {
var e = this, n = (0, i.getSprNode)("panel_text");
n.active = !1;
t.textPanel = n;
var a = new cc.Node(), o = a.addComponent(cc.Label);
n.addChild(a, 5);
o.fontSize = 54;
o.lineHeight = 54;
o.font = cc.find("Canvas/res/font/Berlin Sans FB").getComponent(cc.Label).font;
var r = new cc.Color();
cc.Color.fromHEX(r, "c1431d");
a.color = r;
a.y = -2.5;
n.label = o;
n.addComponent(cc.Button);
n.on("click", function() {
e.checkPenguinIsRight(t);
});
}, n.addPicPanel = function(t) {
var e = this, n = (0, i.getSprNode)("panel_pic");
n.active = !1;
t.picPanel = n;
var a = new cc.Node(), o = a.addComponent(cc.Sprite);
n.addChild(a);
a.y = 0;
n.spr = o;
n.addComponent(cc.Button);
n.on("click", function() {
e.checkPenguinIsRight(t);
});
}, n.getFreeHole = function() {
for (var t = (0, i.randomSortByArr)(this.holeArr), e = 0; e < t.length; e++) if (!t[e].penguin) return t[e];
return null;
}, n.addPenguin = function(t, e, n) {
var a, o = this;
e.active = !0;
e.parent = t;
e.zIndex = 5;
t.penguin = e;
e.y = -180;
a = "text" == n.type ? e.textPanel : e.picPanel;
this.setPanelData(a, n);
var r = .2 + .1 * Math.random(), c = 1 + 2 * Math.random();
e.hideData = {
downY: -180,
moveTime: r,
panel: a,
hole: t
};
e.moveTween = cc.tween(e).to(r, {
y: 0
}, {
easing: "quadInOut"
}).delay(c).call(function() {
h();
}).to(r, {
y: -180
}, {
easing: "quadInOut"
}).call(function() {
e.active = !1;
e.penguin.active = !0;
e.wrong.active = !1;
t.penguin = null;
o.penguinPool.push(e);
e.moveTween = null;
}).start();
var s = .3 + 2 * Math.random();
cc.tween(this).delay(s).call(function() {
o.isRightDuration || o.showOnePenguin();
}).start();
var h = function() {
cc.tween(a).to(.3 * r, {
opacity: 0
}).call(function() {
a.active = !1;
}).start();
};
(function() {
a.active = !0;
a.opacity = 0;
cc.tween(a).to(.3 * r, {
opacity: 255
}).start();
})();
(0, i.playAudio)(this.appearClip);
}, n.setPanelData = function(t, e) {
t.data = e;
t.parent.data = e;
"text" == e.type ? this.setTextPanelData(t, e) : this.setPicPanelData(t, e);
}, n.setTextPanelData = function(t, e) {
t.label.string = e.text;
t.label._forceUpdateRenderData(!0);
t.label.node.width > 255 ? t.label.node.scale = 255 / t.label.node.width : t.label.node.scale = 1;
}, n.setPicPanelData = function(t, e) {
cc.loader.load({
url: e.pic_url
}, function(e, n) {
var i = new cc.SpriteFrame(n);
t.spr.spriteFrame = i;
var a = 215 / n.width, o = 135 / n.height, r = Math.min(a, o);
t.spr.node.scale = r;
});
}, n._cocosScale = null, n.initBg = function() {
var t = cc.view.getFrameSize(), e = cc.winSize.width / t.width, n = cc.winSize.height / t.height, i = Math.min(e, n);
this._cocosScale = i;
var a = cc.find("Canvas/bg");
e = t.width / a.width;
n = t.height / a.height;
a.scale = Math.max(e, n) * i;
a.anchorX = 1;
a.anchorY = 0;
a.x = t.width / 2 * i;
a.y = -t.height / 2 * i;
var o = cc.find("Canvas/bg"), r = new cc.Node();
r.x = -o.x;
r.y = -o.y;
r.scaleX = o.scaleX;
r.scaleY = o.scaleY;
o.addChild(r);
var c = r.addComponent(cc.Graphics);
c.fillColor = this.data.bgColor || "#f9bd03";
c.fillRect(-o.width / 2, -o.height / 2, o.width, o.height);
c.fill();
}, n.initHotZone = function() {
this.initHotZoneBg();
}, n.hotZoneBg = null, n.initHotZoneBg = function() {
var t = this;
this.hotZoneBg = new cc.Node();
this.hotZoneBg.name = "hotZoneBg";
this.hotZoneBg.parent = cc.find("Canvas");
var e = 107 * this._mapScaleMin + 22;
this.data.bgItem && cc.loader.load({
url: this.data.bgItem.url
}, function(n, i) {
t.hotZoneBg.width = i.width;
t.hotZoneBg.height = i.height;
var a = new cc.Node();
a.name = "bgItemSpr";
var o = new cc.SpriteFrame(i);
a.addComponent(cc.Sprite).spriteFrame = o;
a.width = t.hotZoneBg.width;
a.height = t.hotZoneBg.height;
a.parent = t.hotZoneBg;
window.bg = a;
var r = t.canvas.width / t.hotZoneBg.width, c = (t.canvas.height - e) / t.hotZoneBg.height, s = Math.min(r, c);
t.hotZoneBg.scale = s;
t.hotZoneBg.y = 0 - e / 2;
t.initHotZoneItem();
});
}, n.initHotZoneItem = function() {
var t = this;
this.data.hotZoneItemArr.forEach(function(e) {
"0" == e.gIdx ? t.setOneAnimaSmall(e) : "1" == e.gIdx ? t.setOnePic(e) : "2" == e.gIdx ? t.setOneRect(e) : "3" == e.gIdx && t.setOneAction(e);
});
}, n.setOneAction = function(t) {
var e = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width, n = new cc.Node();
n.name = "rect" + t.index;
this.hotZoneBg.addChild(n);
var i = n.addComponent(cc.Graphics);
i.lineWidth = 4;
i.strokeColor = cc.Color.BLACK;
i.fillColor = cc.Color.WHITE.setA(100);
var a = e / this.hotZoneBg.scaleY;
n.width = t.rect.width * a;
n.height = t.rect.height * a;
n.x = -this.hotZoneBg.width / 2 + t.rect.x * a;
n.y = this.hotZoneBg.height / 2 - t.rect.height * a - t.rect.y * a;
n.x, n.y, n.width, n.height;
n.anchorX = n.anchorY = 0;
this.data.bgItem.isShowDebugLine && i.rect(0, 0, n.width, n.height);
i.stroke();
i.fill();
var o = t["actionData_" + t.gIdx];
if (o && "text" == o.type) {
var r = this.setOneActionText(n, o);
r.node.scale = a * t.fontScale;
r._forceUpdateRenderData(!0);
}
}, n.setOneActionText = function(t, e) {
var n = new cc.Node();
n.parent = t;
var i = n.addComponent(cc.Label);
i.font = cc.find("Canvas/res/font/aharoni").getComponent(cc.Label).font;
i.string = e.text;
n.color = cc.Color.BLACK;
for (var a = e.changeOption, o = [], r = 0; r < a.length; r++) {
var c = a[r];
console.log("opArr[0]", a[r]);
if ("fontColor" == c[0]) {
var s = new cc.Color();
cc.Color.fromHEX(s, c[1]);
n.color = s;
} else if ("opacity" == c[0]) {
n.opacity = Number(c[1] / 100 * 255) + .1;
o.push({
item: n,
option: '{"' + c[0] + '" : ' + c[2] / 100 * 255 + "}",
optionName: c[0]
});
} else {
i[c[0]] = c[1];
o.push({
item: i,
option: '{"' + c[0] + '" : ' + c[2] + "}",
optionName: c[0]
});
}
}
e.audio_url && cc.assetManager.loadRemote(e.audio_url, function(t, e) {
n.audioClip = e;
});
i.lineHeight = i.fontSize;
n.y += t.height / 2;
n.x += t.width / 2;
t.addComponent(cc.Button);
t.on("click", function() {
if (n.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(n.audioClip, !1, .8);
}
n.isClicked;
n.isClicked = !0;
for (var t = 0; t < o.length; t++) {
var i = o[t];
if ("opacity" == i.optionName) {
console.log("~~~ ", i.item[i.optionName]);
cc.tween(i.item).to(e.changeTime, JSON.parse(i.option)).start();
}
}
});
return i;
}, n.setOneAnimaSmall = function(t) {
var e = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width, n = new cc.Node();
n.name = "rect" + t.index;
this.hotZoneBg.addChild(n);
var i = n.addComponent(cc.Graphics);
i.lineWidth = 4;
i.strokeColor = cc.Color.BLACK;
i.fillColor = cc.Color.WHITE.setA(100);
var a = e / this.hotZoneBg.scaleY;
n.width = t.rect.width * a;
n.height = t.rect.height * a;
n.x = -this.hotZoneBg.width / 2 + t.rect.x * a;
n.y = this.hotZoneBg.height / 2 - t.rect.height * a - t.rect.y * a;
n.anchorX = n.anchorY = 0;
this.data.bgItem.isShowDebugLine && i.rect(0, 0, n.width, n.height);
i.stroke();
i.fill();
var o = new cc.Node();
o.name = "anima_" + t.index;
this.hotZoneBg.addChild(o);
t.audio_url && cc.assetManager.loadRemote(t.audio_url, function(t, e) {
o.audioClip = e;
});
var r = o.addComponent(dragonBones.ArmatureDisplay);
if (t.texPngData) {
var c = t.texPngData.url, s = t.skeJsonData.url, h = t.texJsonData.url;
cc.loader.load(c, function(t, e) {
cc.loader.load({
url: h,
type: "txt"
}, function(t, i) {
cc.loader.load({
url: s,
type: "txt"
}, function(t, a) {
var c = new dragonBones.DragonBonesAtlasAsset();
c.atlasJson = i;
c.texture = e;
var s = new dragonBones.DragonBonesAsset();
s.dragonBonesJson = a;
r.dragonAtlasAsset = c;
r.dragonAsset = s;
for (var h = JSON.parse(s.dragonBonesJson).armature, d = [], u = 0; u < h.length; u++) d.push(h[u].name);
if (d.length > 0) {
var l = d[0];
r.armatureName = l;
for (var p = h[0].animation, g = [], f = 0; f < p.length; f++) g.push(p[f].name);
n.addComponent(cc.Button);
n.on("click", function() {
n.isClicked;
n.isClicked = !0;
console.log("clicked");
if (o.audioClip) {
cc.audioEngine.stopAllEffects();
cc.director.emit("STOP_ALL_AUDIO");
cc.audioEngine.playEffect(o.audioClip, !1, .8);
}
g.length > 0 && r.playAnimation(g[0], 1);
});
}
o.x = n.x + n.width / 2;
o.y = n.y + n.height / 2;
var v = n.width / o.width, m = n.height / o.height, w = Math.min(v, m);
o.scale = w;
});
});
});
}
}, n.setOnePic = function(t) {
var e = this, n = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width, i = new cc.Node();
i.name = "pic" + t.index;
i.data = t;
this.hotZoneBg.addChild(i);
cc.loader.load({
url: t.pic_url
}, function(a, o) {
i.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(o);
var r = n / e.hotZoneBg.scaleY;
i.width = t.rect.width * r;
i.height = t.rect.height * r;
i.x = -e.hotZoneBg.width / 2 + t.rect.x * r;
i.y = e.hotZoneBg.height / 2 - t.rect.height * r - t.rect.y * r;
i.anchorX = i.anchorY = 0;
t.audio_url && e.addPicAudio(i);
});
}, n.setOneRect = function(t) {
var e = this.hotZoneBg.scale * this.hotZoneBg.width / this.data.bgItem.rect.width, n = new cc.Node();
n.name = "rect" + t.index;
this.hotZoneBg.addChild(n);
var i = n.addComponent(cc.Graphics);
i.lineWidth = 4;
i.strokeColor = cc.Color.BLACK;
i.fillColor = cc.Color.WHITE.setA(100);
var a = e / this.hotZoneBg.scaleY;
n.width = t.rect.width * a;
n.height = t.rect.height * a;
n.x = -this.hotZoneBg.width / 2 + t.rect.x * a;
n.y = this.hotZoneBg.height / 2 - t.rect.height * a - t.rect.y * a;
n.anchorX = n.anchorY = 0;
this.data.bgItem.isShowDebugLine && i.rect(0, 0, n.width, n.height);
i.stroke();
i.fill();
t.audio_url && cc.assetManager.loadRemote(t.audio_url, function(t, e) {
n.audioClip = e;
});
n.addComponent(cc.Button);
n.on("click", function() {
n.isClicked;
n.isClicked = !0;
console.log("clicked");
if (n.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(n.audioClip, !1, .8);
}
});
}, n.addPicAudio = function(t) {
var e = t.data;
cc.assetManager.loadRemote(e.audio_url, function(e, n) {
t.audioClip = n;
});
t.addComponent(cc.Button);
t.on("click", function() {
if (t.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(t.audioClip, !1, .8);
}
});
}, n));
cc._RF.pop();
}, {
"./util": "util"
} ],
util: [ function(t, e, n) {
"use strict";
cc._RF.push(e, "25ccfBBvfNLaoaDwk5MOf7U", "util");
n.__esModule = !0;
n.getPosByAngle = function(t, e) {
var n = t * Math.PI / 180;
return {
x: Math.sin(n) * e,
y: Math.cos(n) * e
};
};
n.getAngleByPos = function(t, e, n, i) {
var a = Math.abs(t - n), o = Math.abs(e - i), r = o / Math.sqrt(Math.pow(a, 2) + Math.pow(o, 2)), c = Math.acos(r), s = Math.floor(180 / (Math.PI / c) * 100) / 100;
n > t && i > e && (s = 180 - s);
n === t && i > e && (s = 180);
n > t && i === e && (s = 90);
n < t && i > e && (s = 180 + s);
n < t && i === e && (s = 270);
n < t && i < e && (s = 360 - s);
return s;
};
n.exchangeNodePos = function(t, e, n) {
return t.convertToNodeSpaceAR(e.convertToWorldSpaceAR(cc.v2(n.x, n.y)));
};
n.RandomInt = o;
n.randomSortByArr = function(t) {
for (var e = [], n = t.concat(); n.length > 0; ) {
var i = Math.floor(n.length * Math.random());
e.push(n[i]);
n.splice(i, 1);
}
return e;
};
n.setSprNodeMaxLen = function(t, e, n) {
var i = e / t.width, a = n / t.height, o = Math.min(i, a);
t.scale = Math.round(1e3 * o) / 1e3;
};
n.getSpriteFrimeByUrl = r;
n.getSprNode = function(t) {
var e = cc.find("Canvas/res/img/" + t).getComponent(cc.Sprite).spriteFrame, n = new cc.Node();
n.addComponent(cc.Sprite).spriteFrame = e;
return n;
};
n.getSprNodeByUrl = function(t, e) {
var n = new cc.Node().addComponent(cc.Sprite);
r(t, function(t) {
n.spriteFrame = t;
e && e(n);
});
};
n.playAudio = c;
n.playAudioByUrl = function(t, e) {
void 0 === e && (e = null);
t ? cc.assetManager.loadRemote(t, function(t, n) {
c(n, e);
}) : e && "function" == typeof e && e();
};
n.asyncDelay = s;
n.showFireworks = u;
n.asyncTweenTo = function() {
return f.apply(this, arguments);
};
n.asyncTweenBy = v;
n.showTrebleFirework = function(t, e) {
var n = new d(t, e);
n.pos = cc.v2(0, -400);
n.side = cc.v2(0, 1e3);
n.range = 200;
n.number = 100;
n.scalseRange = .4;
var i = d.copy(n);
i.pos = cc.v2(-600, -400);
i.side = cc.v2(200, 1e3);
var a = d.copy(n);
a.pos = cc.v2(600, -400);
a.side = cc.v2(-200, 1e3);
u(n);
u(i);
u(a);
};
n.onHomeworkFinish = function() {
var t = cc.find("middleLayer");
if (t) {
var e = t.getComponent("middleLayer");
"student" == e.role && e.onHomeworkFinish(function() {});
} else ;
};
n.getRect = function(t, e, n, i, a) {
void 0 === a && (a = !0);
if (a) {
t = -n / 2;
e = -i / 2;
}
var o = new cc.Node(), r = o.addComponent(cc.Graphics);
r.lineWidth = 2;
r.strokeColor = cc.Color.BLACK;
r.fillColor = cc.Color.GREEN.setA(50);
r.rect(t, e, n, i);
r.stroke();
r.fill();
return o;
};
n.removeItemFromArr = function(t, e) {
var n = t.indexOf(e);
-1 != n && t.splice(n, 1);
};
n.delayCall = function(t, e) {
return cc.tween({}).delay(t).call(function() {
e && e();
}).start();
};
n.FireworkSettings = void 0;
function i(t, e, n, i, a, o, r) {
try {
var c = t[o](r), s = c.value;
} catch (t) {
n(t);
return;
}
c.done ? e(s) : Promise.resolve(s).then(i, a);
}
function a(t) {
return function() {
var e = this, n = arguments;
return new Promise(function(a, o) {
var r = t.apply(e, n);
function c(t) {
i(r, a, o, c, s, "next", t);
}
function s(t) {
i(r, a, o, c, s, "throw", t);
}
c(void 0);
});
};
}
function o(t, e) {
void 0 === e && (e = 0);
var n = Math.max(t, e), i = Math.min(t, e);
return Math.floor(Math.random() * (n - i) + i);
}
function r(t, e) {
cc.loader.load({
url: t
}, function(t, n) {
var i = new cc.SpriteFrame(n);
e && e(i);
});
}
function c(t, e) {
void 0 === e && (e = null);
if (t) {
var n = cc.audioEngine.playEffect(t, !1, .8);
e && cc.audioEngine.setFinishCallback(n, function() {
e();
});
}
}
function s() {
return h.apply(this, arguments);
}
function h() {
return (h = a(regeneratorRuntime.mark(function t(e) {
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
return t.abrupt("return", new Promise(function(t, n) {
try {
setTimeout(function() {
t();
}, 1e3 * e);
} catch (t) {
n(t);
}
}));

case 1:
case "end":
return t.stop();
}
}, t);
}))).apply(this, arguments);
}
var d = function() {
function t(t, e, n, i, a, o, r) {
void 0 === n && (n = cc.v2(0, 0));
void 0 === i && (i = cc.v2(0, 100));
void 0 === a && (a = 50);
void 0 === o && (o = 100);
void 0 === r && (r = 0);
this.baseNode = void 0;
this.nodeList = void 0;
this.pos = void 0;
this.side = void 0;
this.range = void 0;
this.number = void 0;
this.scalseRange = void 0;
this.baseNode = t;
this.nodeList = e;
this.pos = n;
this.side = i;
this.range = a;
this.number = o;
this.scalseRange = r;
}
t.copy = function(e) {
return new t(e.baseNode, e.nodeList, e.pos, e.side, e.range, e.number);
};
return t;
}();
n.FireworkSettings = d;
function u() {
return l.apply(this, arguments);
}
function l() {
return (l = a(regeneratorRuntime.mark(function t(e) {
var n, i, r, c, h, d, u;
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
n = e.baseNode, i = e.nodeList, r = e.pos, c = e.side, h = e.range, d = e.number, 
u = e.scalseRange;
new Array(d).fill(" ").forEach(function() {
var t = a(regeneratorRuntime.mark(function t() {
var e, a, d, l;
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
(e = new cc.Node()).parent = n;
e.x = r.x;
e.y = r.y;
e.angle = 60 * Math.random() - 30;
(a = cc.instantiate(i[o(i.length)])).parent = e;
a.active = !0;
a.x = 0;
a.y = 0;
a.angle = 0;
a.scale = (Math.random() - .5) * u + 1;
d = Math.random();
l = Math.PI * (2 * Math.random() - 1);
t.next = 16;
return v(e, .3, {
x: c.x * d + Math.cos(l) * h * d,
y: c.y * d + Math.sin(l) * h * d
}, {
easing: "quadIn"
});

case 16:
cc.tween(e).by(8, {
y: -2e3
}).start();
cc.tween(e).to(5, {
scale: (Math.random() - .5) * u + 1
}).start();
p(e);
t.next = 21;
return s(Math.random());

case 21:
cc.tween(a).by(.15, {
x: -10,
angle: -10
}).by(.3, {
x: 20,
angle: 20
}).by(.15, {
x: -10,
angle: -10
}).union().repeatForever().start();
cc.tween(e).delay(5).to(.3, {
opacity: 0
}).call(function() {
a.stopAllActions();
a.active = !1;
a.parent = null;
a = null;
}).start();

case 23:
case "end":
return t.stop();
}
}, t);
}));
return function(e, n) {
return t.apply(this, arguments);
};
}());

case 2:
case "end":
return t.stop();
}
}, t);
}))).apply(this, arguments);
}
function p() {
return g.apply(this, arguments);
}
function g() {
return (g = a(regeneratorRuntime.mark(function t(e) {
var n, i;
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
n = 1 + Math.random();
i = o(-200, 200) * n;
t.next = 4;
return v(e, n, {
x: i,
angle: 60 * i / 200
});

case 4:
p(e);

case 5:
case "end":
return t.stop();
}
}, t);
}))).apply(this, arguments);
}
function f() {
return (f = a(regeneratorRuntime.mark(function t(e, n, i, a) {
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
void 0 === a && (a = void 0);
return t.abrupt("return", new Promise(function(t, o) {
try {
cc.tween(e).to(n, i, a).call(function() {
t();
}).start();
} catch (t) {
o(t);
}
}));

case 2:
case "end":
return t.stop();
}
}, t);
}))).apply(this, arguments);
}
function v() {
return m.apply(this, arguments);
}
function m() {
return (m = a(regeneratorRuntime.mark(function t(e, n, i, a) {
return regeneratorRuntime.wrap(function(t) {
for (;;) switch (t.prev = t.next) {
case 0:
void 0 === a && (a = void 0);
return t.abrupt("return", new Promise(function(t, o) {
try {
cc.tween(e).by(n, i, a).call(function() {
t();
}).start();
} catch (t) {
o(t);
}
}));

case 2:
case "end":
return t.stop();
}
}, t);
}))).apply(this, arguments);
}
cc._RF.pop();
}, {} ]
}, {}, [ "PS02", "scene", "util" ]);