new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
14491 lines
1.8 MiB
14491 lines
1.8 MiB
! function(t) { var e; "object" == typeof exports ? module.exports = t() : ("undefined" != typeof window ? e = window : "undefined" != typeof global ? e = global : "undefined" != typeof self && (e = self), e.p2 = t()) }(function() {
|
|
return function o(n, a, r) {
|
|
function h(i, t) {
|
|
if (!a[i]) {
|
|
if (!n[i]) { var e = "function" == typeof require && require; if (!t && e) return e(i, !0); if (l) return l(i, !0); throw new Error("Cannot find module '" + i + "'") }
|
|
var s = a[i] = { exports: {} };
|
|
n[i][0].call(s.exports, function(t) { var e = n[i][1][t]; return h(e || t) }, s, s.exports, o, n, a, r)
|
|
}
|
|
return a[i].exports
|
|
}
|
|
for (var l = "function" == typeof require && require, t = 0; t < r.length; t++) h(r[t]);
|
|
return h
|
|
}({
|
|
1: [function(t, e, i) {
|
|
var p = t("./Scalar");
|
|
|
|
function s() {}(e.exports = s).lineInt = function(t, e, i) { i = i || 0; var s, o, n, a, r, h, l, c = [0, 0]; return s = t[1][1] - t[0][1], o = t[0][0] - t[1][0], n = s * t[0][0] + o * t[0][1], a = e[1][1] - e[0][1], r = e[0][0] - e[1][0], h = a * e[0][0] + r * e[0][1], l = s * r - a * o, p.eq(l, 0, i) || (c[0] = (r * n - o * h) / l, c[1] = (s * h - a * n) / l), c }, s.segmentsIntersect = function(t, e, i, s) {
|
|
var o = e[0] - t[0],
|
|
n = e[1] - t[1],
|
|
a = s[0] - i[0],
|
|
r = s[1] - i[1];
|
|
if (a * n - r * o == 0) return !1;
|
|
var h = (o * (i[1] - t[1]) + n * (t[0] - i[0])) / (a * n - r * o),
|
|
l = (a * (t[1] - i[1]) + r * (i[0] - t[0])) / (r * o - a * n);
|
|
return 0 <= h && h <= 1 && 0 <= l && l <= 1
|
|
}
|
|
}, { "./Scalar": 4 }],
|
|
2: [function(t, e, i) {
|
|
function l() {}(e.exports = l).area = function(t, e, i) { return (e[0] - t[0]) * (i[1] - t[1]) - (i[0] - t[0]) * (e[1] - t[1]) }, l.left = function(t, e, i) { return 0 < l.area(t, e, i) }, l.leftOn = function(t, e, i) { return 0 <= l.area(t, e, i) }, l.right = function(t, e, i) { return l.area(t, e, i) < 0 }, l.rightOn = function(t, e, i) { return l.area(t, e, i) <= 0 };
|
|
var c = [],
|
|
p = [];
|
|
l.collinear = function(t, e, i, s) {
|
|
if (s) {
|
|
var o = c,
|
|
n = p;
|
|
o[0] = e[0] - t[0], o[1] = e[1] - t[1], n[0] = i[0] - e[0], n[1] = i[1] - e[1];
|
|
var a = o[0] * n[0] + o[1] * n[1],
|
|
r = Math.sqrt(o[0] * o[0] + o[1] * o[1]),
|
|
h = Math.sqrt(n[0] * n[0] + n[1] * n[1]);
|
|
return Math.acos(a / (r * h)) < s
|
|
}
|
|
return 0 == l.area(t, e, i)
|
|
}, l.sqdist = function(t, e) {
|
|
var i = e[0] - t[0],
|
|
s = e[1] - t[1];
|
|
return i * i + s * s
|
|
}
|
|
}, {}],
|
|
3: [function(t, e, i) {
|
|
var r = t("./Line"),
|
|
P = t("./Point"),
|
|
u = t("./Scalar");
|
|
|
|
function _() { this.vertices = [] }(e.exports = _).prototype.at = function(t) {
|
|
var e = this.vertices,
|
|
i = e.length;
|
|
return e[t < 0 ? t % i + i : t % i]
|
|
}, _.prototype.first = function() { return this.vertices[0] }, _.prototype.last = function() { return this.vertices[this.vertices.length - 1] }, _.prototype.clear = function() { this.vertices.length = 0 }, _.prototype.append = function(t, e, i) { if (void 0 === e) throw new Error("From is not given!"); if (void 0 === i) throw new Error("To is not given!"); if (i - 1 < e) throw new Error("lol1"); if (i > t.vertices.length) throw new Error("lol2"); if (e < 0) throw new Error("lol3"); for (var s = e; s < i; s++) this.vertices.push(t.vertices[s]) }, _.prototype.makeCCW = function() {
|
|
for (var t = 0, e = this.vertices, i = 1; i < this.vertices.length; ++i)(e[i][1] < e[t][1] || e[i][1] == e[t][1] && e[i][0] > e[t][0]) && (t = i);
|
|
P.left(this.at(t - 1), this.at(t), this.at(t + 1)) || this.reverse()
|
|
}, _.prototype.reverse = function() {
|
|
for (var t = [], e = 0, i = this.vertices.length; e !== i; e++) t.push(this.vertices.pop());
|
|
this.vertices = t
|
|
}, _.prototype.isReflex = function(t) { return P.right(this.at(t - 1), this.at(t), this.at(t + 1)) };
|
|
var h = [],
|
|
l = [];
|
|
|
|
function T(t, e, i, s, o) {
|
|
o = o || 0;
|
|
var n = e[1] - t[1],
|
|
a = t[0] - e[0],
|
|
r = n * t[0] + a * t[1],
|
|
h = s[1] - i[1],
|
|
l = i[0] - s[0],
|
|
c = h * i[0] + l * i[1],
|
|
p = n * l - h * a;
|
|
return u.eq(p, 0, o) ? [0, 0] : [(l * r - a * c) / p, (n * c - h * r) / p]
|
|
}
|
|
_.prototype.canSee = function(t, e) {
|
|
var i, s, o = h,
|
|
n = l;
|
|
if (P.leftOn(this.at(t + 1), this.at(t), this.at(e)) && P.rightOn(this.at(t - 1), this.at(t), this.at(e))) return !1;
|
|
s = P.sqdist(this.at(t), this.at(e));
|
|
for (var a = 0; a !== this.vertices.length; ++a)
|
|
if ((a + 1) % this.vertices.length !== t && a !== t && P.leftOn(this.at(t), this.at(e), this.at(a + 1)) && P.rightOn(this.at(t), this.at(e), this.at(a)) && (o[0] = this.at(t), o[1] = this.at(e), n[0] = this.at(a), n[1] = this.at(a + 1), i = r.lineInt(o, n), P.sqdist(this.at(t), i) < s)) return !1;
|
|
return !0
|
|
}, _.prototype.copy = function(t, e, i) {
|
|
var s = i || new _;
|
|
if (s.clear(), t < e)
|
|
for (var o = t; o <= e; o++) s.vertices.push(this.vertices[o]);
|
|
else { for (o = 0; o <= e; o++) s.vertices.push(this.vertices[o]); for (o = t; o < this.vertices.length; o++) s.vertices.push(this.vertices[o]) }
|
|
return s
|
|
}, _.prototype.getCutEdges = function() {
|
|
for (var t = [], e = [], i = [], s = new _, o = Number.MAX_VALUE, n = 0; n < this.vertices.length; ++n)
|
|
if (this.isReflex(n))
|
|
for (var a = 0; a < this.vertices.length; ++a)
|
|
if (this.canSee(n, a)) {
|
|
e = this.copy(n, a, s).getCutEdges(), i = this.copy(a, n, s).getCutEdges();
|
|
for (var r = 0; r < i.length; r++) e.push(i[r]);
|
|
e.length < o && (o = (t = e).length, t.push([this.at(n), this.at(a)]))
|
|
}
|
|
return t
|
|
}, _.prototype.decomp = function() { var t = this.getCutEdges(); return 0 < t.length ? this.slice(t) : [this] }, _.prototype.slice = function(t) {
|
|
if (0 == t.length) return [this];
|
|
if (t instanceof Array && t.length && t[0] instanceof Array && 2 == t[0].length && t[0][0] instanceof Array) {
|
|
for (var e = [this], i = 0; i < t.length; i++)
|
|
for (var s = t[i], o = 0; o < e.length; o++) { var n = e[o].slice(s); if (n) { e.splice(o, 1), e.push(n[0], n[1]); break } }
|
|
return e
|
|
}
|
|
s = t, i = this.vertices.indexOf(s[0]), o = this.vertices.indexOf(s[1]);
|
|
return -1 != i && -1 != o && [this.copy(i, o), this.copy(o, i)]
|
|
}, _.prototype.isSimple = function() {
|
|
for (var t = this.vertices, e = 0; e < t.length - 1; e++)
|
|
for (var i = 0; i < e - 1; i++)
|
|
if (r.segmentsIntersect(t[e], t[e + 1], t[i], t[i + 1])) return !1;
|
|
for (e = 1; e < t.length - 2; e++)
|
|
if (r.segmentsIntersect(t[0], t[t.length - 1], t[e], t[e + 1])) return !1;
|
|
return !0
|
|
}, _.prototype.quickDecomp = function(t, e, i, s, o, n) {
|
|
o = o || 100, n = n || 0, s = s || 25, t = void 0 !== t ? t : [], e = e || [], i = i || [];
|
|
var a = [0, 0],
|
|
r = [0, 0],
|
|
h = [0, 0],
|
|
l = 0,
|
|
c = 0,
|
|
p = 0,
|
|
u = 0,
|
|
d = 0,
|
|
y = 0,
|
|
g = 0,
|
|
f = new _,
|
|
m = new _,
|
|
v = this,
|
|
x = this.vertices;
|
|
if (x.length < 3) return t;
|
|
if (o < ++n) return t;
|
|
for (var b = 0; b < this.vertices.length; ++b)
|
|
if (v.isReflex(b)) {
|
|
e.push(v.vertices[b]), l = c = Number.MAX_VALUE;
|
|
for (var w = 0; w < this.vertices.length; ++w) P.left(v.at(b - 1), v.at(b), v.at(w)) && P.rightOn(v.at(b - 1), v.at(b), v.at(w - 1)) && (h = T(v.at(b - 1), v.at(b), v.at(w), v.at(w - 1)), P.right(v.at(b + 1), v.at(b), h) && (p = P.sqdist(v.vertices[b], h)) < c && (c = p, r = h, y = w)), P.left(v.at(b + 1), v.at(b), v.at(w + 1)) && P.rightOn(v.at(b + 1), v.at(b), v.at(w)) && (h = T(v.at(b + 1), v.at(b), v.at(w), v.at(w + 1)), P.left(v.at(b - 1), v.at(b), h) && (p = P.sqdist(v.vertices[b], h)) < l && (l = p, a = h, d = w));
|
|
if (y == (d + 1) % this.vertices.length) h[0] = (r[0] + a[0]) / 2, h[1] = (r[1] + a[1]) / 2, i.push(h), b < d ? (f.append(v, b, d + 1), f.vertices.push(h), m.vertices.push(h), 0 != y && m.append(v, y, v.vertices.length), m.append(v, 0, b + 1)) : (0 != b && f.append(v, b, v.vertices.length), f.append(v, 0, d + 1), f.vertices.push(h), m.vertices.push(h), m.append(v, y, b + 1));
|
|
else {
|
|
if (d < y && (d += this.vertices.length), u = Number.MAX_VALUE, d < y) return t;
|
|
for (w = y; w <= d; ++w) P.leftOn(v.at(b - 1), v.at(b), v.at(w)) && P.rightOn(v.at(b + 1), v.at(b), v.at(w)) && (p = P.sqdist(v.at(b), v.at(w))) < u && (u = p, g = w % this.vertices.length);
|
|
b < g ? (f.append(v, b, g + 1), 0 != g && m.append(v, g, x.length), m.append(v, 0, b + 1)) : (0 != b && f.append(v, b, x.length), f.append(v, 0, g + 1), m.append(v, g, b + 1))
|
|
}
|
|
return f.vertices.length < m.vertices.length ? (f.quickDecomp(t, e, i, s, o, n), m.quickDecomp(t, e, i, s, o, n)) : (m.quickDecomp(t, e, i, s, o, n), f.quickDecomp(t, e, i, s, o, n)), t
|
|
}
|
|
return t.push(this), t
|
|
}, _.prototype.removeCollinearPoints = function(t) { for (var e = 0, i = this.vertices.length - 1; 3 < this.vertices.length && 0 <= i; --i) P.collinear(this.at(i - 1), this.at(i), this.at(i + 1), t) && (this.vertices.splice(i % this.vertices.length, 1), i--, e++); return e }
|
|
}, { "./Line": 1, "./Point": 2, "./Scalar": 4 }],
|
|
4: [function(t, e, i) {
|
|
function s() {}(e.exports = s).eq = function(t, e, i) { return i = i || 0, Math.abs(t - e) < i }
|
|
}, {}],
|
|
5: [function(t, e, i) { e.exports = { Polygon: t("./Polygon"), Point: t("./Point") } }, { "./Point": 2, "./Polygon": 3 }],
|
|
6: [function(t, e, i) { e.exports = { name: "p2", version: "0.7.0", description: "A JavaScript 2D physics engine.", author: "Stefan Hedman <schteppe@gmail.com> (http://steffe.se)", keywords: ["p2.js", "p2", "physics", "engine", "2d"], main: "./src/p2.js", engines: { node: "*" }, repository: { type: "git", url: "https://github.com/schteppe/p2.js.git" }, bugs: { url: "https://github.com/schteppe/p2.js/issues" }, licenses: [{ type: "MIT" }], devDependencies: { grunt: "^0.4.5", "grunt-contrib-jshint": "^0.11.2", "grunt-contrib-nodeunit": "^0.4.1", "grunt-contrib-uglify": "~0.4.0", "grunt-contrib-watch": "~0.5.0", "grunt-browserify": "~2.0.1", "grunt-contrib-concat": "^0.4.0" }, dependencies: { "poly-decomp": "0.1.0" } } }, {}],
|
|
7: [function(t, e, i) {
|
|
var d = t("../math/vec2");
|
|
t("../utils/Utils");
|
|
|
|
function s(t) { this.lowerBound = d.create(), t && t.lowerBound && d.copy(this.lowerBound, t.lowerBound), this.upperBound = d.create(), t && t.upperBound && d.copy(this.upperBound, t.upperBound) } e.exports = s;
|
|
var y = d.create();
|
|
s.prototype.setFromPoints = function(t, e, i, s) {
|
|
var o = this.lowerBound,
|
|
n = this.upperBound;
|
|
"number" != typeof i && (i = 0), 0 !== i ? d.rotate(o, t[0], i) : d.copy(o, t[0]), d.copy(n, o);
|
|
for (var a = Math.cos(i), r = Math.sin(i), h = 1; h < t.length; h++) {
|
|
var l = t[h];
|
|
if (0 !== i) {
|
|
var c = l[0],
|
|
p = l[1];
|
|
y[0] = a * c - r * p, y[1] = r * c + a * p, l = y
|
|
}
|
|
for (var u = 0; u < 2; u++) l[u] > n[u] && (n[u] = l[u]), l[u] < o[u] && (o[u] = l[u])
|
|
}
|
|
e && (d.add(this.lowerBound, this.lowerBound, e), d.add(this.upperBound, this.upperBound, e)), s && (this.lowerBound[0] -= s, this.lowerBound[1] -= s, this.upperBound[0] += s, this.upperBound[1] += s)
|
|
}, s.prototype.copy = function(t) { d.copy(this.lowerBound, t.lowerBound), d.copy(this.upperBound, t.upperBound) }, s.prototype.extend = function(t) {
|
|
for (var e = 2; e--;) {
|
|
var i = t.lowerBound[e];
|
|
this.lowerBound[e] > i && (this.lowerBound[e] = i);
|
|
var s = t.upperBound[e];
|
|
this.upperBound[e] < s && (this.upperBound[e] = s)
|
|
}
|
|
}, s.prototype.overlaps = function(t) {
|
|
var e = this.lowerBound,
|
|
i = this.upperBound,
|
|
s = t.lowerBound,
|
|
o = t.upperBound;
|
|
return (s[0] <= i[0] && i[0] <= o[0] || e[0] <= o[0] && o[0] <= i[0]) && (s[1] <= i[1] && i[1] <= o[1] || e[1] <= o[1] && o[1] <= i[1])
|
|
}, s.prototype.containsPoint = function(t) {
|
|
var e = this.lowerBound,
|
|
i = this.upperBound;
|
|
return e[0] <= t[0] && t[0] <= i[0] && e[1] <= t[1] && t[1] <= i[1]
|
|
}, s.prototype.overlapsRay = function(t) {
|
|
var e = 1 / t.direction[0],
|
|
i = 1 / t.direction[1],
|
|
s = (this.lowerBound[0] - t.from[0]) * e,
|
|
o = (this.upperBound[0] - t.from[0]) * e,
|
|
n = (this.lowerBound[1] - t.from[1]) * i,
|
|
a = (this.upperBound[1] - t.from[1]) * i,
|
|
r = Math.max(Math.max(Math.min(s, o), Math.min(n, a))),
|
|
h = Math.min(Math.min(Math.max(s, o), Math.max(n, a)));
|
|
return h < 0 ? -1 : h < r ? -1 : r
|
|
}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57 }],
|
|
8: [function(t, e, i) {
|
|
var o = t("../math/vec2"),
|
|
n = t("../objects/Body");
|
|
|
|
function s(t) { this.type = t, this.result = [], this.world = null, this.boundingVolumeType = s.AABB }(e.exports = s).AABB = 1, s.BOUNDING_CIRCLE = 2, s.prototype.setWorld = function(t) { this.world = t }, s.prototype.getCollisionPairs = function(t) {};
|
|
var a = o.create();
|
|
s.boundingRadiusCheck = function(t, e) {
|
|
o.sub(a, t.position, e.position);
|
|
var i = o.squaredLength(a),
|
|
s = t.boundingRadius + e.boundingRadius;
|
|
return i <= s * s
|
|
}, s.aabbCheck = function(t, e) { return t.getAABB().overlaps(e.getAABB()) }, s.prototype.boundingVolumeCheck = function(t, e) {
|
|
var i;
|
|
switch (this.boundingVolumeType) {
|
|
case s.BOUNDING_CIRCLE:
|
|
i = s.boundingRadiusCheck(t, e);
|
|
break;
|
|
case s.AABB:
|
|
i = s.aabbCheck(t, e);
|
|
break;
|
|
default:
|
|
throw new Error("Bounding volume type not recognized: " + this.boundingVolumeType)
|
|
}
|
|
return i
|
|
}, s.canCollide = function(t, e) {
|
|
var i = n.KINEMATIC,
|
|
s = n.STATIC;
|
|
return (t.type !== s || e.type !== s) && (!(t.type === i && e.type === s || t.type === s && e.type === i) && ((t.type !== i || e.type !== i) && ((t.sleepState !== n.SLEEPING || e.sleepState !== n.SLEEPING) && !(t.sleepState === n.SLEEPING && e.type === s || e.sleepState === n.SLEEPING && t.type === s))))
|
|
}, s.NAIVE = 1, s.SAP = 2
|
|
}, { "../math/vec2": 30, "../objects/Body": 31 }],
|
|
9: [function(t, e, i) {
|
|
t("../shapes/Circle"), t("../shapes/Plane"), t("../shapes/Shape"), t("../shapes/Particle");
|
|
var h = t("../collision/Broadphase");
|
|
t("../math/vec2");
|
|
|
|
function s() { h.call(this, h.NAIVE) }(((e.exports = s).prototype = new h).constructor = s).prototype.getCollisionPairs = function(t) {
|
|
for (var e = t.bodies, i = this.result, s = i.length = 0, o = e.length; s !== o; s++)
|
|
for (var n = e[s], a = 0; a < s; a++) {
|
|
var r = e[a];
|
|
h.canCollide(n, r) && this.boundingVolumeCheck(n, r) && i.push(n, r)
|
|
}
|
|
return i
|
|
}, s.prototype.aabbQuery = function(t, e, i) {
|
|
i = i || [];
|
|
for (var s = t.bodies, o = 0; o < s.length; o++) {
|
|
var n = s[o];
|
|
n.aabbNeedsUpdate && n.updateAABB(), n.aabb.overlaps(e) && i.push(n)
|
|
}
|
|
return i
|
|
}
|
|
}, { "../collision/Broadphase": 8, "../math/vec2": 30, "../shapes/Circle": 39, "../shapes/Particle": 43, "../shapes/Plane": 44, "../shapes/Shape": 45 }],
|
|
10: [function(t, e, i) {
|
|
var V = t("../math/vec2"),
|
|
H = V.sub,
|
|
z = V.add,
|
|
X = V.dot,
|
|
s = (t("../utils/Utils"), t("../utils/ContactEquationPool")),
|
|
o = t("../utils/FrictionEquationPool"),
|
|
n = t("../utils/TupleDictionary"),
|
|
a = t("../equations/Equation"),
|
|
r = (t("../equations/ContactEquation"), t("../equations/FrictionEquation"), t("../shapes/Circle")),
|
|
h = t("../shapes/Convex"),
|
|
l = t("../shapes/Shape"),
|
|
_ = (t("../objects/Body"), t("../shapes/Box"));
|
|
e.exports = $;
|
|
var T = V.fromValues(0, 1),
|
|
j = V.fromValues(0, 0),
|
|
W = V.fromValues(0, 0),
|
|
q = V.fromValues(0, 0),
|
|
Y = V.fromValues(0, 0),
|
|
K = V.fromValues(0, 0),
|
|
L = V.fromValues(0, 0),
|
|
Q = V.fromValues(0, 0),
|
|
J = V.fromValues(0, 0),
|
|
Z = V.fromValues(0, 0),
|
|
R = V.fromValues(0, 0),
|
|
D = V.fromValues(0, 0),
|
|
F = V.fromValues(0, 0),
|
|
U = V.fromValues(0, 0),
|
|
G = V.fromValues(0, 0),
|
|
I = V.fromValues(0, 0),
|
|
E = V.fromValues(0, 0),
|
|
A = V.fromValues(0, 0),
|
|
C = V.fromValues(0, 0),
|
|
N = [];
|
|
|
|
function $() { this.contactEquations = [], this.frictionEquations = [], this.enableFriction = !0, this.enabledEquations = !0, this.slipForce = 10, this.frictionCoefficient = .3, this.surfaceVelocity = 0, this.contactEquationPool = new s({ size: 32 }), this.frictionEquationPool = new o({ size: 64 }), this.restitution = 0, this.stiffness = a.DEFAULT_STIFFNESS, this.relaxation = a.DEFAULT_RELAXATION, this.frictionStiffness = a.DEFAULT_STIFFNESS, this.frictionRelaxation = a.DEFAULT_RELAXATION, this.enableFrictionReduction = !0, this.collidingBodiesLastStep = new n, this.contactSkinSize = .01 }
|
|
var c = V.create(),
|
|
p = V.create();
|
|
|
|
function x(t, e) { V.set(t.vertices[0], .5 * -e.length, -e.radius), V.set(t.vertices[1], .5 * e.length, -e.radius), V.set(t.vertices[2], .5 * e.length, e.radius), V.set(t.vertices[3], .5 * -e.length, e.radius) } $.prototype.bodiesOverlap = function(t, e) {
|
|
for (var i = c, s = p, o = 0, n = t.shapes.length; o !== n; o++) {
|
|
var a = t.shapes[o];
|
|
t.toWorldFrame(i, a.position);
|
|
for (var r = 0, h = e.shapes.length; r !== h; r++) { var l = e.shapes[r]; if (e.toWorldFrame(s, l.position), this[a.type | l.type](t, a, i, a.angle + t.angle, e, l, s, l.angle + e.angle, !0)) return !0 }
|
|
}
|
|
return !1
|
|
}, $.prototype.collidedLastStep = function(t, e) {
|
|
var i = 0 | t.id,
|
|
s = 0 | e.id;
|
|
return !!this.collidingBodiesLastStep.get(i, s)
|
|
}, $.prototype.reset = function() {
|
|
this.collidingBodiesLastStep.reset();
|
|
for (var t = this.contactEquations, e = t.length; e--;) {
|
|
var i = t[e],
|
|
s = i.bodyA.id,
|
|
o = i.bodyB.id;
|
|
this.collidingBodiesLastStep.set(s, o, !0)
|
|
}
|
|
for (var n = this.contactEquations, a = this.frictionEquations, r = 0; r < n.length; r++) this.contactEquationPool.release(n[r]);
|
|
for (r = 0; r < a.length; r++) this.frictionEquationPool.release(a[r]);
|
|
this.contactEquations.length = this.frictionEquations.length = 0
|
|
}, $.prototype.createContactEquation = function(t, e, i, s) { var o = this.contactEquationPool.get(); return o.bodyA = t, o.bodyB = e, o.shapeA = i, o.shapeB = s, o.restitution = this.restitution, o.firstImpact = !this.collidedLastStep(t, e), o.stiffness = this.stiffness, o.relaxation = this.relaxation, o.needsUpdate = !0, o.enabled = this.enabledEquations, o.offset = this.contactSkinSize, o }, $.prototype.createFrictionEquation = function(t, e, i, s) { var o = this.frictionEquationPool.get(); return o.bodyA = t, o.bodyB = e, o.shapeA = i, o.shapeB = s, o.setSlipForce(this.slipForce), o.frictionCoefficient = this.frictionCoefficient, o.relativeVelocity = this.surfaceVelocity, o.enabled = this.enabledEquations, o.needsUpdate = !0, o.stiffness = this.frictionStiffness, o.relaxation = this.frictionRelaxation, o.contactEquations.length = 0, o }, $.prototype.createFrictionFromContact = function(t) { var e = this.createFrictionEquation(t.bodyA, t.bodyB, t.shapeA, t.shapeB); return V.copy(e.contactPointA, t.contactPointA), V.copy(e.contactPointB, t.contactPointB), V.rotate90cw(e.t, t.normalA), e.contactEquations.push(t), e }, $.prototype.createFrictionFromAverage = function(t) {
|
|
var e = this.contactEquations[this.contactEquations.length - 1],
|
|
i = this.createFrictionEquation(e.bodyA, e.bodyB, e.shapeA, e.shapeB),
|
|
s = e.bodyA;
|
|
e.bodyB;
|
|
V.set(i.contactPointA, 0, 0), V.set(i.contactPointB, 0, 0), V.set(i.t, 0, 0);
|
|
for (var o = 0; o !== t; o++)(e = this.contactEquations[this.contactEquations.length - 1 - o]).bodyA === s ? (V.add(i.t, i.t, e.normalA), V.add(i.contactPointA, i.contactPointA, e.contactPointA), V.add(i.contactPointB, i.contactPointB, e.contactPointB)) : (V.sub(i.t, i.t, e.normalA), V.add(i.contactPointA, i.contactPointA, e.contactPointB), V.add(i.contactPointB, i.contactPointB, e.contactPointA)), i.contactEquations.push(e);
|
|
var n = 1 / t;
|
|
return V.scale(i.contactPointA, i.contactPointA, n), V.scale(i.contactPointB, i.contactPointB, n), V.normalize(i.t, i.t), V.rotate90cw(i.t, i.t), i
|
|
}, $.prototype[l.LINE | l.CONVEX] = $.prototype.convexLine = function(t, e, i, s, o, n, a, r, h) { return !h && 0 }, $.prototype[l.LINE | l.BOX] = $.prototype.lineBox = function(t, e, i, s, o, n, a, r, h) { return !h && 0 };
|
|
var d = new _({ width: 1, height: 1 }),
|
|
y = V.create();
|
|
$.prototype[l.CAPSULE | l.CONVEX] = $.prototype[l.CAPSULE | l.BOX] = $.prototype.convexCapsule = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = y;
|
|
V.set(l, n.length / 2, 0), V.rotate(l, l, r), V.add(l, l, a);
|
|
var c = this.circleConvex(o, n, l, r, t, e, i, s, h, n.radius);
|
|
V.set(l, -n.length / 2, 0), V.rotate(l, l, r), V.add(l, l, a);
|
|
var p = this.circleConvex(o, n, l, r, t, e, i, s, h, n.radius);
|
|
if (h && (c || p)) return !0;
|
|
var u = d;
|
|
return x(u, n), this.convexConvex(t, e, i, s, o, u, a, r, h) + c + p
|
|
}, $.prototype[l.CAPSULE | l.LINE] = $.prototype.lineCapsule = function(t, e, i, s, o, n, a, r, h) { return !h && 0 };
|
|
var b = V.create(),
|
|
w = V.create(),
|
|
P = new _({ width: 1, height: 1 });
|
|
$.prototype[l.CAPSULE | l.CAPSULE] = $.prototype.capsuleCapsule = function(t, e, i, s, o, n, a, r, h) {
|
|
for (var l = b, c = w, p = 0, u = 0; u < 2; u++) {
|
|
V.set(l, (0 === u ? -1 : 1) * e.length / 2, 0), V.rotate(l, l, s), V.add(l, l, i);
|
|
for (var d = 0; d < 2; d++) {
|
|
V.set(c, (0 === d ? -1 : 1) * n.length / 2, 0), V.rotate(c, c, r), V.add(c, c, a), this.enableFrictionReduction && (m = this.enableFriction, this.enableFriction = !1);
|
|
var y = this.circleCircle(t, e, l, s, o, n, c, r, h, e.radius, n.radius);
|
|
if (this.enableFrictionReduction && (this.enableFriction = m), h && y) return !0;
|
|
p += y
|
|
}
|
|
}
|
|
this.enableFrictionReduction && (m = this.enableFriction, this.enableFriction = !1);
|
|
var g = P;
|
|
x(g, e);
|
|
var f = this.convexCapsule(t, g, i, s, o, n, a, r, h);
|
|
if (this.enableFrictionReduction && (this.enableFriction = m), h && f) return !0;
|
|
if (p += f, this.enableFrictionReduction) {
|
|
var m = this.enableFriction;
|
|
this.enableFriction = !1
|
|
}
|
|
x(g, n);
|
|
var v = this.convexCapsule(o, g, a, r, t, e, i, s, h);
|
|
return this.enableFrictionReduction && (this.enableFriction = m), !(!h || !v) || (p += v, this.enableFrictionReduction && p && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(p)), p)
|
|
}, $.prototype[l.LINE | l.LINE] = $.prototype.lineLine = function(t, e, i, s, o, n, a, r, h) { return !h && 0 }, $.prototype[l.PLANE | l.LINE] = $.prototype.planeLine = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = j,
|
|
c = W,
|
|
p = q,
|
|
u = Y,
|
|
d = K,
|
|
y = L,
|
|
g = Q,
|
|
f = J,
|
|
m = Z,
|
|
v = N,
|
|
x = 0;
|
|
V.set(l, -n.length / 2, 0), V.set(c, n.length / 2, 0), V.rotate(p, l, r), V.rotate(u, c, r), z(p, p, a), z(u, u, a), V.copy(l, p), V.copy(c, u), H(d, c, l), V.normalize(y, d), V.rotate90cw(m, y), V.rotate(f, T, s), v[0] = l, v[1] = c;
|
|
for (var b = 0; b < v.length; b++) {
|
|
var w = v[b];
|
|
H(g, w, i);
|
|
var P = X(g, f);
|
|
if (P < 0) {
|
|
if (h) return !0;
|
|
var _ = this.createContactEquation(t, o, e, n);
|
|
x++, V.copy(_.normalA, f), V.normalize(_.normalA, _.normalA), V.scale(g, f, P), H(_.contactPointA, w, g), H(_.contactPointA, _.contactPointA, t.position), H(_.contactPointB, w, a), z(_.contactPointB, _.contactPointB, a), H(_.contactPointB, _.contactPointB, o.position), this.contactEquations.push(_), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(_))
|
|
}
|
|
}
|
|
return !h && (this.enableFrictionReduction || x && this.enableFriction && this.frictionEquations.push(this.createFrictionFromAverage(x)), x)
|
|
}, $.prototype[l.PARTICLE | l.CAPSULE] = $.prototype.particleCapsule = function(t, e, i, s, o, n, a, r, h) { return this.circleLine(t, e, i, s, o, n, a, r, h, n.radius, 0) }, $.prototype[l.CIRCLE | l.LINE] = $.prototype.circleLine = function(t, e, i, s, o, n, a, r, h, l, c) {
|
|
l = l || 0, c = void 0 !== c ? c : e.radius;
|
|
var p = j,
|
|
u = W,
|
|
d = q,
|
|
y = Y,
|
|
g = K,
|
|
f = L,
|
|
m = Q,
|
|
v = J,
|
|
x = Z,
|
|
b = R,
|
|
w = D,
|
|
P = F,
|
|
_ = U,
|
|
T = G,
|
|
S = N;
|
|
V.set(v, -n.length / 2, 0), V.set(x, n.length / 2, 0), V.rotate(b, v, r), V.rotate(w, x, r), z(b, b, a), z(w, w, a), V.copy(v, b), V.copy(x, w), H(f, x, v), V.normalize(m, f), V.rotate90cw(g, m), H(P, i, v);
|
|
var k = X(P, g);
|
|
H(y, v, a), H(_, i, a);
|
|
var B = c + l;
|
|
if (Math.abs(k) < B) {
|
|
V.scale(p, g, k), H(d, i, p), V.scale(u, g, X(g, _)), V.normalize(u, u), V.scale(u, u, l), z(d, d, u);
|
|
var A = X(m, d),
|
|
C = X(m, v),
|
|
I = X(m, x);
|
|
if (C < A && A < I) { if (h) return !0; var E = this.createContactEquation(t, o, e, n); return V.scale(E.normalA, p, -1), V.normalize(E.normalA, E.normalA), V.scale(E.contactPointA, E.normalA, c), z(E.contactPointA, E.contactPointA, i), H(E.contactPointA, E.contactPointA, t.position), H(E.contactPointB, d, a), z(E.contactPointB, E.contactPointB, a), H(E.contactPointB, E.contactPointB, o.position), this.contactEquations.push(E), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(E)), 1 }
|
|
}
|
|
S[0] = v, S[1] = x;
|
|
for (var O = 0; O < S.length; O++) {
|
|
var M = S[O];
|
|
if (H(P, M, i), V.squaredLength(P) < Math.pow(B, 2)) {
|
|
if (h) return !0;
|
|
E = this.createContactEquation(t, o, e, n);
|
|
return V.copy(E.normalA, P), V.normalize(E.normalA, E.normalA), V.scale(E.contactPointA, E.normalA, c), z(E.contactPointA, E.contactPointA, i), H(E.contactPointA, E.contactPointA, t.position), H(E.contactPointB, M, a), V.scale(T, E.normalA, -l), z(E.contactPointB, E.contactPointB, T), z(E.contactPointB, E.contactPointB, a), H(E.contactPointB, E.contactPointB, o.position), this.contactEquations.push(E), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(E)), 1
|
|
}
|
|
}
|
|
return 0
|
|
}, $.prototype[l.CIRCLE | l.CAPSULE] = $.prototype.circleCapsule = function(t, e, i, s, o, n, a, r, h) { return this.circleLine(t, e, i, s, o, n, a, r, h, n.radius) }, $.prototype[l.CIRCLE | l.CONVEX] = $.prototype[l.CIRCLE | l.BOX] = $.prototype.circleConvex = function(t, e, i, s, o, n, a, r, h, l) {
|
|
l = "number" == typeof l ? l : e.radius;
|
|
for (var c = j, p = W, u = q, d = Y, y = K, g = R, f = D, m = U, v = G, x = I, b = E, w = !1, P = Number.MAX_VALUE, _ = n.vertices, T = 0; T !== _.length + 1; T++) {
|
|
var S = _[T % _.length],
|
|
k = _[(T + 1) % _.length];
|
|
if (V.rotate(c, S, r), V.rotate(p, k, r), z(c, c, a), z(p, p, a), H(u, p, c), V.normalize(d, u), V.rotate90cw(y, d), V.scale(v, y, -e.radius), z(v, v, i), O(v, n, a, r)) {
|
|
V.sub(x, c, v);
|
|
var B = Math.abs(V.dot(x, y));
|
|
B < P && (V.copy(b, v), P = B, V.scale(m, y, B), V.add(m, m, v), w = !0)
|
|
}
|
|
}
|
|
if (w) { if (h) return !0; var A = this.createContactEquation(t, o, e, n); return V.sub(A.normalA, b, i), V.normalize(A.normalA, A.normalA), V.scale(A.contactPointA, A.normalA, l), z(A.contactPointA, A.contactPointA, i), H(A.contactPointA, A.contactPointA, t.position), H(A.contactPointB, m, a), z(A.contactPointB, A.contactPointB, a), H(A.contactPointB, A.contactPointB, o.position), this.contactEquations.push(A), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(A)), 1 }
|
|
if (0 < l)
|
|
for (T = 0; T < _.length; T++) {
|
|
var C = _[T];
|
|
if (V.rotate(f, C, r), z(f, f, a), H(g, f, i), V.squaredLength(g) < Math.pow(l, 2)) {
|
|
if (h) return !0;
|
|
A = this.createContactEquation(t, o, e, n);
|
|
return V.copy(A.normalA, g), V.normalize(A.normalA, A.normalA), V.scale(A.contactPointA, A.normalA, l), z(A.contactPointA, A.contactPointA, i), H(A.contactPointA, A.contactPointA, t.position), H(A.contactPointB, f, a), z(A.contactPointB, A.contactPointB, a), H(A.contactPointB, A.contactPointB, o.position), this.contactEquations.push(A), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(A)), 1
|
|
}
|
|
}
|
|
return 0
|
|
};
|
|
var g = V.create(),
|
|
f = V.create(),
|
|
m = V.create(),
|
|
v = V.create();
|
|
|
|
function O(t, e, i, s) {
|
|
for (var o = g, n = f, a = m, r = v, h = t, l = e.vertices, c = null, p = 0; p !== l.length + 1; p++) {
|
|
var u = l[p % l.length],
|
|
d = l[(p + 1) % l.length];
|
|
V.rotate(o, u, s), V.rotate(n, d, s), z(o, o, i), z(n, n, i), H(a, o, h), H(r, n, h);
|
|
var y = V.crossLength(a, r);
|
|
if (null === c && (c = y), y * c <= 0) return !1;
|
|
c = y
|
|
}
|
|
return !0
|
|
}
|
|
$.prototype[l.PARTICLE | l.CONVEX] = $.prototype[l.PARTICLE | l.BOX] = $.prototype.particleConvex = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = j,
|
|
c = W,
|
|
p = q,
|
|
u = Y,
|
|
d = K,
|
|
y = L,
|
|
g = Q,
|
|
f = R,
|
|
m = U,
|
|
v = A,
|
|
x = C,
|
|
b = Number.MAX_VALUE,
|
|
w = !1,
|
|
P = n.vertices;
|
|
if (!O(i, n, a, r)) return 0;
|
|
if (h) return !0;
|
|
for (var _ = 0; _ !== P.length + 1; _++) {
|
|
var T = P[_ % P.length],
|
|
S = P[(_ + 1) % P.length];
|
|
V.rotate(l, T, r), V.rotate(c, S, r), z(l, l, a), z(c, c, a), H(p, c, l), V.normalize(u, p), V.rotate90cw(d, u), H(f, i, l);
|
|
X(f, d);
|
|
H(y, l, a), H(g, i, a), V.sub(v, l, i);
|
|
var k = Math.abs(V.dot(v, d));
|
|
k < b && (b = k, V.scale(m, d, k), V.add(m, m, i), V.copy(x, d), w = !0)
|
|
}
|
|
if (w) { var B = this.createContactEquation(t, o, e, n); return V.scale(B.normalA, x, -1), V.normalize(B.normalA, B.normalA), V.set(B.contactPointA, 0, 0), z(B.contactPointA, B.contactPointA, i), H(B.contactPointA, B.contactPointA, t.position), H(B.contactPointB, m, a), z(B.contactPointB, B.contactPointB, a), H(B.contactPointB, B.contactPointB, o.position), this.contactEquations.push(B), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(B)), 1 }
|
|
return 0
|
|
}, $.prototype[l.CIRCLE] = $.prototype.circleCircle = function(t, e, i, s, o, n, a, r, h, l, c) {
|
|
var p = j;
|
|
l = l || e.radius, c = c || n.radius;
|
|
H(p, i, a);
|
|
var u = l + c;
|
|
if (V.squaredLength(p) > Math.pow(u, 2)) return 0;
|
|
if (h) return !0;
|
|
var d = this.createContactEquation(t, o, e, n);
|
|
return H(d.normalA, a, i), V.normalize(d.normalA, d.normalA), V.scale(d.contactPointA, d.normalA, l), V.scale(d.contactPointB, d.normalA, -c), z(d.contactPointA, d.contactPointA, i), H(d.contactPointA, d.contactPointA, t.position), z(d.contactPointB, d.contactPointB, a), H(d.contactPointB, d.contactPointB, o.position), this.contactEquations.push(d), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(d)), 1
|
|
}, $.prototype[l.PLANE | l.CONVEX] = $.prototype[l.PLANE | l.BOX] = $.prototype.planeConvex = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = j,
|
|
c = W,
|
|
p = q,
|
|
u = 0;
|
|
V.rotate(c, T, s);
|
|
for (var d = 0; d !== n.vertices.length; d++) {
|
|
var y = n.vertices[d];
|
|
if (V.rotate(l, y, r), z(l, l, a), H(p, l, i), X(p, c) <= 0) {
|
|
if (h) return !0;
|
|
u++;
|
|
var g = this.createContactEquation(t, o, e, n);
|
|
H(p, l, i), V.copy(g.normalA, c);
|
|
var f = X(p, g.normalA);
|
|
V.scale(p, g.normalA, f), H(g.contactPointB, l, o.position), H(g.contactPointA, l, p), H(g.contactPointA, g.contactPointA, t.position), this.contactEquations.push(g), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(g))
|
|
}
|
|
}
|
|
return this.enableFrictionReduction && this.enableFriction && u && this.frictionEquations.push(this.createFrictionFromAverage(u)), u
|
|
}, $.prototype[l.PARTICLE | l.PLANE] = $.prototype.particlePlane = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = j,
|
|
c = W;
|
|
r = r || 0, H(l, i, a), V.rotate(c, T, r);
|
|
var p = X(l, c);
|
|
if (0 < p) return 0;
|
|
if (h) return !0;
|
|
var u = this.createContactEquation(o, t, n, e);
|
|
return V.copy(u.normalA, c), V.scale(l, u.normalA, p), H(u.contactPointA, i, l), H(u.contactPointA, u.contactPointA, o.position), H(u.contactPointB, i, t.position), this.contactEquations.push(u), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(u)), 1
|
|
}, $.prototype[l.CIRCLE | l.PARTICLE] = $.prototype.circleParticle = function(t, e, i, s, o, n, a, r, h) { var l = j; if (H(l, a, i), V.squaredLength(l) > Math.pow(e.radius, 2)) return 0; if (h) return !0; var c = this.createContactEquation(t, o, e, n); return V.copy(c.normalA, l), V.normalize(c.normalA, c.normalA), V.scale(c.contactPointA, c.normalA, e.radius), z(c.contactPointA, c.contactPointA, i), H(c.contactPointA, c.contactPointA, t.position), H(c.contactPointB, a, o.position), this.contactEquations.push(c), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(c)), 1 };
|
|
var S = new r({ radius: 1 }),
|
|
k = V.create(),
|
|
B = V.create();
|
|
V.create();
|
|
$.prototype[l.PLANE | l.CAPSULE] = $.prototype.planeCapsule = function(t, e, i, s, o, n, a, r, h) {
|
|
var l, c = k,
|
|
p = B,
|
|
u = S;
|
|
V.set(c, -n.length / 2, 0), V.rotate(c, c, r), z(c, c, a), V.set(p, n.length / 2, 0), V.rotate(p, p, r), z(p, p, a), u.radius = n.radius, this.enableFrictionReduction && (l = this.enableFriction, this.enableFriction = !1);
|
|
var d = this.circlePlane(o, u, c, 0, t, e, i, s, h),
|
|
y = this.circlePlane(o, u, p, 0, t, e, i, s, h);
|
|
if (this.enableFrictionReduction && (this.enableFriction = l), h) return d || y;
|
|
var g = d + y;
|
|
return this.enableFrictionReduction && g && this.frictionEquations.push(this.createFrictionFromAverage(g)), g
|
|
}, $.prototype[l.CIRCLE | l.PLANE] = $.prototype.circlePlane = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = t,
|
|
c = e,
|
|
p = i,
|
|
u = o,
|
|
d = a,
|
|
y = r;
|
|
y = y || 0;
|
|
var g = j,
|
|
f = W,
|
|
m = q;
|
|
H(g, p, d), V.rotate(f, T, y);
|
|
var v = X(f, g);
|
|
if (v > c.radius) return 0;
|
|
if (h) return !0;
|
|
var x = this.createContactEquation(u, l, n, e);
|
|
return V.copy(x.normalA, f), V.scale(x.contactPointB, x.normalA, -c.radius), z(x.contactPointB, x.contactPointB, p), H(x.contactPointB, x.contactPointB, l.position), V.scale(m, x.normalA, v), H(x.contactPointA, g, m), z(x.contactPointA, x.contactPointA, d), H(x.contactPointA, x.contactPointA, u.position), this.contactEquations.push(x), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(x)), 1
|
|
}, $.prototype[l.CONVEX] = $.prototype[l.CONVEX | l.BOX] = $.prototype[l.BOX] = $.prototype.convexConvex = function(t, e, i, s, o, n, a, r, h, l) {
|
|
var c = j,
|
|
p = W,
|
|
u = q,
|
|
d = Y,
|
|
y = K,
|
|
g = Q,
|
|
f = J,
|
|
m = Z,
|
|
v = 0;
|
|
l = "number" == typeof l ? l : 0;
|
|
if (!$.findSeparatingAxis(e, i, s, n, a, r, c)) return 0;
|
|
H(f, a, i), 0 < X(c, f) && V.scale(c, c, -1);
|
|
var x = $.getClosestEdge(e, s, c, !0),
|
|
b = $.getClosestEdge(n, r, c);
|
|
if (-1 === x || -1 === b) return 0;
|
|
for (var w = 0; w < 2; w++) {
|
|
var P, _ = x,
|
|
T = b,
|
|
S = e,
|
|
k = n,
|
|
B = i,
|
|
A = a,
|
|
C = s,
|
|
I = r,
|
|
E = t,
|
|
O = o;
|
|
if (0 === w) P = _, _ = T, T = P, P = S, S = k, k = P, P = B, B = A, A = P, P = C, C = I, I = P, P = E, E = O, O = P;
|
|
for (var M = T; M < T + 2; M++) {
|
|
var L = k.vertices[(M + k.vertices.length) % k.vertices.length];
|
|
V.rotate(p, L, I), z(p, p, A);
|
|
for (var R = 0, D = _ - 1; D < _ + 2; D++) {
|
|
var F = S.vertices[(D + S.vertices.length) % S.vertices.length],
|
|
U = S.vertices[(D + 1 + S.vertices.length) % S.vertices.length];
|
|
V.rotate(u, F, C), V.rotate(d, U, C), z(u, u, B), z(d, d, B), H(y, d, u), V.rotate90cw(m, y), V.normalize(m, m), H(f, p, u);
|
|
var G = X(m, f);
|
|
(D === _ && G <= l || D !== _ && G <= 0) && R++
|
|
}
|
|
if (3 <= R) {
|
|
if (h) return !0;
|
|
var N = this.createContactEquation(E, O, S, k);
|
|
v++;
|
|
F = S.vertices[_ % S.vertices.length], U = S.vertices[(_ + 1) % S.vertices.length];
|
|
V.rotate(u, F, C), V.rotate(d, U, C), z(u, u, B), z(d, d, B), H(y, d, u), V.rotate90cw(N.normalA, y), V.normalize(N.normalA, N.normalA), H(f, p, u);
|
|
G = X(N.normalA, f);
|
|
V.scale(g, N.normalA, G), H(N.contactPointA, p, B), H(N.contactPointA, N.contactPointA, g), z(N.contactPointA, N.contactPointA, B), H(N.contactPointA, N.contactPointA, E.position), H(N.contactPointB, p, A), z(N.contactPointB, N.contactPointB, A), H(N.contactPointB, N.contactPointB, O.position), this.contactEquations.push(N), this.enableFrictionReduction || this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(N))
|
|
}
|
|
}
|
|
}
|
|
return this.enableFrictionReduction && this.enableFriction && v && this.frictionEquations.push(this.createFrictionFromAverage(v)), v
|
|
};
|
|
var M = V.fromValues(0, 0);
|
|
$.projectConvexOntoAxis = function(t, e, i, s, o) {
|
|
var n, a, r = null,
|
|
h = null,
|
|
l = M;
|
|
V.rotate(l, s, -i);
|
|
for (var c = 0; c < t.vertices.length; c++) n = t.vertices[c], a = X(n, l), (null === r || r < a) && (r = a), (null === h || a < h) && (h = a);
|
|
if (r < h) {
|
|
var p = h;
|
|
h = r, r = p
|
|
}
|
|
var u = X(e, s);
|
|
V.set(o, h + u, r + u)
|
|
};
|
|
var tt = V.fromValues(0, 0),
|
|
et = V.fromValues(0, 0),
|
|
it = V.fromValues(0, 0),
|
|
st = V.fromValues(0, 0),
|
|
ot = V.fromValues(0, 0),
|
|
nt = V.fromValues(0, 0);
|
|
$.findSeparatingAxis = function(t, e, i, s, o, n, a) {
|
|
var r = null,
|
|
h = !1,
|
|
l = !1,
|
|
c = tt,
|
|
p = et,
|
|
u = it,
|
|
d = st,
|
|
y = ot,
|
|
g = nt;
|
|
if (t instanceof _ && s instanceof _)
|
|
for (var f = 0; 2 !== f; f++) {
|
|
var m = t,
|
|
v = i;
|
|
1 === f && (m = s, v = n);
|
|
for (var x = 0; 2 !== x; x++) {
|
|
0 === x ? V.set(d, 0, 1) : 1 === x && V.set(d, 1, 0), 0 !== v && V.rotate(d, d, v), $.projectConvexOntoAxis(t, e, i, d, y), $.projectConvexOntoAxis(s, o, n, d, g);
|
|
var b = y,
|
|
w = g;
|
|
y[0] > g[0] && (w = y, b = g, !0), h = (P = w[0] - b[1]) <= 0, (null === r || r < P) && (V.copy(a, d), r = P, l = h)
|
|
}
|
|
}
|
|
else
|
|
for (f = 0; 2 !== f; f++) {
|
|
m = t, v = i;
|
|
1 === f && (m = s, v = n);
|
|
for (x = 0; x !== m.vertices.length; x++) {
|
|
V.rotate(p, m.vertices[x], v), V.rotate(u, m.vertices[(x + 1) % m.vertices.length], v), H(c, u, p), V.rotate90cw(d, c), V.normalize(d, d), $.projectConvexOntoAxis(t, e, i, d, y), $.projectConvexOntoAxis(s, o, n, d, g);
|
|
var P;
|
|
b = y, w = g;
|
|
y[0] > g[0] && (w = y, b = g, !0), h = (P = w[0] - b[1]) <= 0, (null === r || r < P) && (V.copy(a, d), r = P, l = h)
|
|
}
|
|
}
|
|
return l
|
|
};
|
|
var u = V.fromValues(0, 0),
|
|
at = V.fromValues(0, 0),
|
|
rt = V.fromValues(0, 0);
|
|
$.getClosestEdge = function(t, e, i, s) {
|
|
var o = u,
|
|
n = at,
|
|
a = rt;
|
|
V.rotate(o, i, -e), s && V.scale(o, o, -1);
|
|
for (var r = -1, h = t.vertices.length, l = -1, c = 0; c !== h; c++) {
|
|
H(n, t.vertices[(c + 1) % h], t.vertices[c % h]), V.rotate90cw(a, n), V.normalize(a, a);
|
|
var p = X(a, o);
|
|
(-1 === r || l < p) && (r = c % h, l = p)
|
|
}
|
|
return r
|
|
};
|
|
var ht = V.create(),
|
|
lt = V.create(),
|
|
ct = V.create(),
|
|
pt = V.create(),
|
|
ut = V.create(),
|
|
dt = V.create(),
|
|
yt = V.create();
|
|
$.prototype[l.CIRCLE | l.HEIGHTFIELD] = $.prototype.circleHeightfield = function(t, e, i, s, o, n, a, r, h, l) {
|
|
var c = n.heights,
|
|
p = (l = l || e.radius, n.elementWidth),
|
|
u = lt,
|
|
d = ht,
|
|
y = ut,
|
|
g = yt,
|
|
f = dt,
|
|
m = ct,
|
|
v = pt,
|
|
x = Math.floor((i[0] - l - a[0]) / p),
|
|
b = Math.ceil((i[0] + l - a[0]) / p);
|
|
x < 0 && (x = 0), b >= c.length && (b = c.length - 1);
|
|
for (var w = c[x], P = c[b], _ = x; _ < b; _++) c[_] < P && (P = c[_]), c[_] > w && (w = c[_]);
|
|
if (i[1] - l > w) return !h && 0;
|
|
var T = !1;
|
|
for (_ = x; _ < b; _++) {
|
|
V.set(m, _ * p, c[_]), V.set(v, (_ + 1) * p, c[_ + 1]), V.add(m, m, a), V.add(v, v, a), V.sub(f, v, m), V.rotate(f, f, Math.PI / 2), V.normalize(f, f), V.scale(d, f, -l), V.add(d, d, i), V.sub(u, d, m);
|
|
var S = V.dot(u, f);
|
|
if (d[0] >= m[0] && d[0] < v[0] && S <= 0) {
|
|
if (h) return !0;
|
|
T = !0, V.scale(u, f, -S), V.add(y, d, u), V.copy(g, f);
|
|
var k = this.createContactEquation(o, t, n, e);
|
|
V.copy(k.normalA, g), V.scale(k.contactPointB, k.normalA, -l), z(k.contactPointB, k.contactPointB, i), H(k.contactPointB, k.contactPointB, t.position), V.copy(k.contactPointA, y), V.sub(k.contactPointA, k.contactPointA, o.position), this.contactEquations.push(k), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(k))
|
|
}
|
|
}
|
|
if (T = !1, 0 < l)
|
|
for (_ = x; _ <= b; _++)
|
|
if (V.set(m, _ * p, c[_]), V.add(m, m, a), V.sub(u, i, m), V.squaredLength(u) < Math.pow(l, 2)) {
|
|
if (h) return !0;
|
|
T = !0;
|
|
k = this.createContactEquation(o, t, n, e);
|
|
V.copy(k.normalA, u), V.normalize(k.normalA, k.normalA), V.scale(k.contactPointB, k.normalA, -l), z(k.contactPointB, k.contactPointB, i), H(k.contactPointB, k.contactPointB, t.position), H(k.contactPointA, m, a), z(k.contactPointA, k.contactPointA, a), H(k.contactPointA, k.contactPointA, o.position), this.contactEquations.push(k), this.enableFriction && this.frictionEquations.push(this.createFrictionFromContact(k))
|
|
}
|
|
return T ? 1 : 0
|
|
};
|
|
var gt = V.create(),
|
|
ft = V.create(),
|
|
mt = V.create(),
|
|
vt = new h({ vertices: [V.create(), V.create(), V.create(), V.create()] });
|
|
$.prototype[l.BOX | l.HEIGHTFIELD] = $.prototype[l.CONVEX | l.HEIGHTFIELD] = $.prototype.convexHeightfield = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = n.heights,
|
|
c = n.elementWidth,
|
|
p = gt,
|
|
u = ft,
|
|
d = mt,
|
|
y = vt,
|
|
g = Math.floor((t.aabb.lowerBound[0] - a[0]) / c),
|
|
f = Math.ceil((t.aabb.upperBound[0] - a[0]) / c);
|
|
g < 0 && (g = 0), f >= l.length && (f = l.length - 1);
|
|
for (var m = l[g], v = l[f], x = g; x < f; x++) l[x] < v && (v = l[x]), l[x] > m && (m = l[x]);
|
|
if (t.aabb.lowerBound[1] > m) return !h && 0;
|
|
var b = 0;
|
|
for (x = g; x < f; x++) {
|
|
V.set(p, x * c, l[x]), V.set(u, (x + 1) * c, l[x + 1]), V.add(p, p, a), V.add(u, u, a);
|
|
V.set(d, .5 * (u[0] + p[0]), .5 * (u[1] + p[1] - 100)), V.sub(y.vertices[0], u, d), V.sub(y.vertices[1], p, d), V.copy(y.vertices[2], y.vertices[1]), V.copy(y.vertices[3], y.vertices[0]), y.vertices[2][1] -= 100, y.vertices[3][1] -= 100, b += this.convexConvex(t, e, i, s, o, y, d, 0, h)
|
|
}
|
|
return b
|
|
}
|
|
}, { "../equations/ContactEquation": 21, "../equations/Equation": 22, "../equations/FrictionEquation": 23, "../math/vec2": 30, "../objects/Body": 31, "../shapes/Box": 37, "../shapes/Circle": 39, "../shapes/Convex": 40, "../shapes/Shape": 45, "../utils/ContactEquationPool": 48, "../utils/FrictionEquationPool": 49, "../utils/TupleDictionary": 56, "../utils/Utils": 57 }],
|
|
11: [function(t, e, i) {
|
|
e.exports = a;
|
|
var h = t("../math/vec2");
|
|
t("../collision/RaycastResult"), t("../shapes/Shape"), t("../collision/AABB");
|
|
|
|
function a(t) { t = t || {}, this.from = t.from ? h.fromValues(t.from[0], t.from[1]) : h.create(), this.to = t.to ? h.fromValues(t.to[0], t.to[1]) : h.create(), this.checkCollisionResponse = void 0 === t.checkCollisionResponse || t.checkCollisionResponse, this.skipBackfaces = !!t.skipBackfaces, this.collisionMask = void 0 !== t.collisionMask ? t.collisionMask : -1, this.collisionGroup = void 0 !== t.collisionGroup ? t.collisionGroup : -1, this.mode = void 0 !== t.mode ? t.mode : a.ANY, this.callback = t.callback || function(t) {}, this.direction = h.create(), this.length = 1, this.update() }(a.prototype.constructor = a).CLOSEST = 1, a.ANY = 2, a.ALL = 4, a.prototype.update = function() {
|
|
var t = this.direction;
|
|
h.sub(t, this.to, this.from), this.length = h.length(t), h.normalize(t, t)
|
|
}, a.prototype.intersectBodies = function(t, e) {
|
|
for (var i = 0, s = e.length; !t.shouldStop(this) && i < s; i++) {
|
|
var o = e[i],
|
|
n = o.getAABB();
|
|
(0 <= n.overlapsRay(this) || n.containsPoint(this.from)) && this.intersectBody(t, o)
|
|
}
|
|
};
|
|
var l = h.create();
|
|
a.prototype.intersectBody = function(t, e) {
|
|
var i = this.checkCollisionResponse;
|
|
if (!i || e.collisionResponse)
|
|
for (var s = l, o = 0, n = e.shapes.length; o < n; o++) { var a = e.shapes[o]; if ((!i || a.collisionResponse) && (0 != (this.collisionGroup & a.collisionMask) && 0 != (a.collisionGroup & this.collisionMask))) { h.rotate(s, a.position, e.angle), h.add(s, s, e.position); var r = a.angle + e.angle; if (this.intersectShape(t, a, r, s, e), t.shouldStop(this)) break } }
|
|
}, a.prototype.intersectShape = function(t, e, i, s, o) {
|
|
(function(t, e, i) { h.sub(n, i, t); var s = h.dot(n, e); return h.scale(r, e, s), h.add(r, r, t), h.squaredDistance(i, r) })(this.from, this.direction, s) > e.boundingRadius * e.boundingRadius || (this._currentBody = o, (this._currentShape = e).raycast(t, this, s, i), this._currentBody = this._currentShape = null)
|
|
}, a.prototype.getAABB = function(t) {
|
|
var e = this.to,
|
|
i = this.from;
|
|
h.set(t.lowerBound, Math.min(e[0], i[0]), Math.min(e[1], i[1])), h.set(t.upperBound, Math.max(e[0], i[0]), Math.max(e[1], i[1]))
|
|
};
|
|
h.create();
|
|
a.prototype.reportIntersection = function(t, e, i, s) {
|
|
this.from, this.to;
|
|
var o = this._currentShape,
|
|
n = this._currentBody;
|
|
if (!(this.skipBackfaces && 0 < h.dot(i, this.direction))) switch (this.mode) {
|
|
case a.ALL:
|
|
t.set(i, o, n, e, s), this.callback(t);
|
|
break;
|
|
case a.CLOSEST:
|
|
(e < t.fraction || !t.hasHit()) && t.set(i, o, n, e, s);
|
|
break;
|
|
case a.ANY:
|
|
t.set(i, o, n, e, s)
|
|
}
|
|
};
|
|
var n = h.create(),
|
|
r = h.create()
|
|
}, { "../collision/AABB": 7, "../collision/RaycastResult": 12, "../math/vec2": 30, "../shapes/Shape": 45 }],
|
|
12: [function(t, e, i) {
|
|
var n = t("../math/vec2"),
|
|
s = t("../collision/Ray");
|
|
|
|
function o() { this.normal = n.create(), this.shape = null, this.body = null, this.faceIndex = -1, this.fraction = -1, this.isStopped = !1 }(e.exports = o).prototype.reset = function() { n.set(this.normal, 0, 0), this.shape = null, this.body = null, this.faceIndex = -1, this.fraction = -1, this.isStopped = !1 }, o.prototype.getHitDistance = function(t) { return n.distance(t.from, t.to) * this.fraction }, o.prototype.hasHit = function() { return -1 !== this.fraction }, o.prototype.getHitPoint = function(t, e) { n.lerp(t, e.from, e.to, this.fraction) }, o.prototype.stop = function() { this.isStopped = !0 }, o.prototype.shouldStop = function(t) { return this.isStopped || -1 !== this.fraction && t.mode === s.ANY }, o.prototype.set = function(t, e, i, s, o) { n.copy(this.normal, t), this.shape = e, this.body = i, this.fraction = s, this.faceIndex = o }
|
|
}, { "../collision/Ray": 11, "../math/vec2": 30 }],
|
|
13: [function(t, e, i) {
|
|
var s = t("../utils/Utils"),
|
|
p = t("../collision/Broadphase");
|
|
|
|
function o() {
|
|
p.call(this, p.SAP), this.axisList = [], this.axisIndex = 0;
|
|
var i = this;
|
|
this._addBodyHandler = function(t) { i.axisList.push(t.body) }, this._removeBodyHandler = function(t) { var e = i.axisList.indexOf(t.body); - 1 !== e && i.axisList.splice(e, 1) }
|
|
}(((e.exports = o).prototype = new p).constructor = o).prototype.setWorld = function(t) { this.axisList.length = 0, s.appendArray(this.axisList, t.bodies), t.off("addBody", this._addBodyHandler).off("removeBody", this._removeBodyHandler), t.on("addBody", this._addBodyHandler).on("removeBody", this._removeBodyHandler), this.world = t }, o.sortAxisList = function(t, e) {
|
|
e |= 0;
|
|
for (var i = 1, s = t.length; i < s; i++) {
|
|
for (var o = t[i], n = i - 1; 0 <= n && !(t[n].aabb.lowerBound[e] <= o.aabb.lowerBound[e]); n--) t[n + 1] = t[n];
|
|
t[n + 1] = o
|
|
}
|
|
return t
|
|
}, o.prototype.sortList = function() {
|
|
var t = this.axisList,
|
|
e = this.axisIndex;
|
|
o.sortAxisList(t, e)
|
|
}, o.prototype.getCollisionPairs = function(t) {
|
|
var e = this.axisList,
|
|
i = this.result,
|
|
s = this.axisIndex;
|
|
i.length = 0;
|
|
for (var o = e.length; o--;) {
|
|
var n = e[o];
|
|
n.aabbNeedsUpdate && n.updateAABB()
|
|
}
|
|
this.sortList();
|
|
for (var a = 0, r = 0 | e.length; a !== r; a++)
|
|
for (var h = e[a], l = a + 1; l < r; l++) {
|
|
var c = e[l];
|
|
if (!(c.aabb.lowerBound[s] <= h.aabb.upperBound[s])) break;
|
|
p.canCollide(h, c) && this.boundingVolumeCheck(h, c) && i.push(h, c)
|
|
}
|
|
return i
|
|
}, o.prototype.aabbQuery = function(t, e, i) {
|
|
i = i || [], this.sortList();
|
|
var s = this.axisIndex,
|
|
o = "x";
|
|
1 === s && (o = "y"), 2 === s && (o = "z");
|
|
for (var n = this.axisList, a = (e.lowerBound[o], e.upperBound[o], 0); a < n.length; a++) {
|
|
var r = n[a];
|
|
r.aabbNeedsUpdate && r.updateAABB(), r.aabb.overlaps(e) && i.push(r)
|
|
}
|
|
return i
|
|
}
|
|
}, { "../collision/Broadphase": 8, "../utils/Utils": 57 }],
|
|
14: [function(t, e, i) {
|
|
e.exports = s;
|
|
var o = t("../utils/Utils");
|
|
|
|
function s(t, e, i, s) { this.type = i, s = o.defaults(s, { collideConnected: !0, wakeUpBodies: !0 }), this.equations = [], this.bodyA = t, this.bodyB = e, this.collideConnected = s.collideConnected, s.wakeUpBodies && (t && t.wakeUp(), e && e.wakeUp()) } s.prototype.update = function() { throw new Error("method update() not implmemented in this Constraint subclass!") }, s.DISTANCE = 1, s.GEAR = 2, s.LOCK = 3, s.PRISMATIC = 4, s.REVOLUTE = 5, s.prototype.setStiffness = function(t) {
|
|
for (var e = this.equations, i = 0; i !== e.length; i++) {
|
|
var s = e[i];
|
|
s.stiffness = t, s.needsUpdate = !0
|
|
}
|
|
}, s.prototype.setRelaxation = function(t) {
|
|
for (var e = this.equations, i = 0; i !== e.length; i++) {
|
|
var s = e[i];
|
|
s.relaxation = t, s.needsUpdate = !0
|
|
}
|
|
}
|
|
}, { "../utils/Utils": 57 }],
|
|
15: [function(t, e, i) {
|
|
var d = t("./Constraint"),
|
|
y = t("../equations/Equation"),
|
|
g = t("../math/vec2"),
|
|
f = t("../utils/Utils");
|
|
|
|
function s(t, e, i) {
|
|
i = f.defaults(i, { localAnchorA: [0, 0], localAnchorB: [0, 0] }), d.call(this, t, e, d.DISTANCE, i), this.localAnchorA = g.fromValues(i.localAnchorA[0], i.localAnchorA[1]), this.localAnchorB = g.fromValues(i.localAnchorB[0], i.localAnchorB[1]);
|
|
var s, o = this.localAnchorA,
|
|
n = this.localAnchorB;
|
|
if (this.distance = 0, "number" == typeof i.distance) this.distance = i.distance;
|
|
else {
|
|
var a = g.create(),
|
|
r = g.create(),
|
|
h = g.create();
|
|
g.rotate(a, o, t.angle), g.rotate(r, n, e.angle), g.add(h, e.position, r), g.sub(h, h, a), g.sub(h, h, t.position), this.distance = g.length(h)
|
|
}
|
|
s = void 0 === i.maxForce ? Number.MAX_VALUE : i.maxForce;
|
|
var l = new y(t, e, -s, s);
|
|
this.equations = [l], this.maxForce = s;
|
|
h = g.create();
|
|
var c = g.create(),
|
|
p = g.create(),
|
|
u = this;
|
|
l.computeGq = function() {
|
|
var t = this.bodyA,
|
|
e = this.bodyB,
|
|
i = t.position,
|
|
s = e.position;
|
|
return g.rotate(c, o, t.angle), g.rotate(p, n, e.angle), g.add(h, s, p), g.sub(h, h, c), g.sub(h, h, i), g.length(h) - u.distance
|
|
}, this.setMaxForce(s), this.upperLimitEnabled = !1, this.upperLimit = 1, this.lowerLimitEnabled = !1, this.lowerLimit = 0, this.position = 0
|
|
}((e.exports = s).prototype = new d).constructor = s;
|
|
var c = g.create(),
|
|
p = g.create(),
|
|
u = g.create();
|
|
s.prototype.update = function() {
|
|
var t = this.equations[0],
|
|
e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = (this.distance, e.position),
|
|
o = i.position,
|
|
n = this.equations[0],
|
|
a = t.G;
|
|
g.rotate(p, this.localAnchorA, e.angle), g.rotate(u, this.localAnchorB, i.angle), g.add(c, o, u), g.sub(c, c, p), g.sub(c, c, s), this.position = g.length(c);
|
|
var r = !1;
|
|
if (this.upperLimitEnabled && this.position > this.upperLimit && (n.maxForce = 0, n.minForce = -this.maxForce, this.distance = this.upperLimit, r = !0), this.lowerLimitEnabled && this.position < this.lowerLimit && (n.maxForce = this.maxForce, n.minForce = 0, this.distance = this.lowerLimit, r = !0), !this.lowerLimitEnabled && !this.upperLimitEnabled || r) {
|
|
n.enabled = !0, g.normalize(c, c);
|
|
var h = g.crossLength(p, c),
|
|
l = g.crossLength(u, c);
|
|
a[0] = -c[0], a[1] = -c[1], a[2] = -h, a[3] = c[0], a[4] = c[1], a[5] = l
|
|
}
|
|
else n.enabled = !1
|
|
}, s.prototype.setMaxForce = function(t) {
|
|
var e = this.equations[0];
|
|
e.minForce = -t, e.maxForce = t
|
|
}, s.prototype.getMaxForce = function() { return this.equations[0].maxForce }
|
|
}, { "../equations/Equation": 22, "../math/vec2": 30, "../utils/Utils": 57, "./Constraint": 14 }],
|
|
16: [function(t, e, i) {
|
|
var s = t("./Constraint"),
|
|
o = (t("../equations/Equation"), t("../equations/AngleLockEquation"));
|
|
t("../math/vec2");
|
|
|
|
function n(t, e, i) { i = i || {}, s.call(this, t, e, s.GEAR, i), this.ratio = void 0 !== i.ratio ? i.ratio : 1, this.angle = void 0 !== i.angle ? i.angle : e.angle - this.ratio * t.angle, i.angle = this.angle, i.ratio = this.ratio, this.equations = [new o(t, e, i)], void 0 !== i.maxTorque && this.setMaxTorque(i.maxTorque) }(((e.exports = n).prototype = new s).constructor = n).prototype.update = function() {
|
|
var t = this.equations[0];
|
|
t.ratio !== this.ratio && t.setRatio(this.ratio), t.angle = this.angle
|
|
}, n.prototype.setMaxTorque = function(t) { this.equations[0].setMaxTorque(t) }, n.prototype.getMaxTorque = function(t) { return this.equations[0].maxForce }
|
|
}, { "../equations/AngleLockEquation": 20, "../equations/Equation": 22, "../math/vec2": 30, "./Constraint": 14 }],
|
|
17: [function(t, e, i) {
|
|
var u = t("./Constraint"),
|
|
d = t("../math/vec2"),
|
|
y = t("../equations/Equation");
|
|
|
|
function s(t, e, i) {
|
|
i = i || {}, u.call(this, t, e, u.LOCK, i);
|
|
var s = void 0 === i.maxForce ? Number.MAX_VALUE : i.maxForce,
|
|
o = (i.localAngleB, new y(t, e, -s, s)),
|
|
n = new y(t, e, -s, s),
|
|
a = new y(t, e, -s, s),
|
|
r = d.create(),
|
|
h = d.create(),
|
|
l = this;
|
|
o.computeGq = function() { return d.rotate(r, l.localOffsetB, t.angle), d.sub(h, e.position, t.position), d.sub(h, h, r), h[0] }, n.computeGq = function() { return d.rotate(r, l.localOffsetB, t.angle), d.sub(h, e.position, t.position), d.sub(h, h, r), h[1] };
|
|
var c = d.create(),
|
|
p = d.create();
|
|
a.computeGq = function() { return d.rotate(c, l.localOffsetB, e.angle - l.localAngleB), d.scale(c, c, -1), d.sub(h, t.position, e.position), d.add(h, h, c), d.rotate(p, c, -Math.PI / 2), d.normalize(p, p), d.dot(h, p) }, this.localOffsetB = d.create(), i.localOffsetB ? d.copy(this.localOffsetB, i.localOffsetB) : (d.sub(this.localOffsetB, e.position, t.position), d.rotate(this.localOffsetB, this.localOffsetB, -t.angle)), this.localAngleB = 0, "number" == typeof i.localAngleB ? this.localAngleB = i.localAngleB : this.localAngleB = e.angle - t.angle, this.equations.push(o, n, a), this.setMaxForce(s)
|
|
}(((e.exports = s).prototype = new u).constructor = s).prototype.setMaxForce = function(t) { for (var e = this.equations, i = 0; i < this.equations.length; i++) e[i].maxForce = t, e[i].minForce = -t }, s.prototype.getMaxForce = function() { return this.equations[0].maxForce };
|
|
var n = d.create(),
|
|
a = d.create(),
|
|
r = d.create(),
|
|
h = d.fromValues(1, 0),
|
|
l = d.fromValues(0, 1);
|
|
s.prototype.update = function() {
|
|
var t = this.equations[0],
|
|
e = this.equations[1],
|
|
i = this.equations[2],
|
|
s = this.bodyA,
|
|
o = this.bodyB;
|
|
d.rotate(n, this.localOffsetB, s.angle), d.rotate(a, this.localOffsetB, o.angle - this.localAngleB), d.scale(a, a, -1), d.rotate(r, a, Math.PI / 2), d.normalize(r, r), t.G[0] = -1, t.G[1] = 0, t.G[2] = -d.crossLength(n, h), t.G[3] = 1, e.G[0] = 0, e.G[1] = -1, e.G[2] = -d.crossLength(n, l), e.G[4] = 1, i.G[0] = -r[0], i.G[1] = -r[1], i.G[3] = r[0], i.G[4] = r[1], i.G[5] = d.crossLength(a, r)
|
|
}
|
|
}, { "../equations/Equation": 22, "../math/vec2": 30, "./Constraint": 14 }],
|
|
18: [function(t, e, i) {
|
|
var g = t("./Constraint"),
|
|
f = t("../equations/ContactEquation"),
|
|
m = t("../equations/Equation"),
|
|
v = t("../math/vec2"),
|
|
x = t("../equations/RotationalLockEquation");
|
|
|
|
function s(s, o, t) {
|
|
t = t || {}, g.call(this, s, o, g.PRISMATIC, t);
|
|
var n = v.fromValues(0, 0),
|
|
a = v.fromValues(1, 0),
|
|
r = v.fromValues(0, 0);
|
|
t.localAnchorA && v.copy(n, t.localAnchorA), t.localAxisA && v.copy(a, t.localAxisA), t.localAnchorB && v.copy(r, t.localAnchorB), this.localAnchorA = n, this.localAnchorB = r, this.localAxisA = a;
|
|
var e = this.maxForce = void 0 !== t.maxForce ? t.maxForce : Number.MAX_VALUE,
|
|
i = new m(s, o, -e, e),
|
|
h = new v.create,
|
|
l = new v.create,
|
|
c = new v.create,
|
|
p = new v.create;
|
|
if (i.computeGq = function() { return v.dot(c, p) }, i.updateJacobian = function() {
|
|
var t = this.G,
|
|
e = s.position,
|
|
i = o.position;
|
|
v.rotate(h, n, s.angle), v.rotate(l, r, o.angle), v.add(c, i, l), v.sub(c, c, e), v.sub(c, c, h), v.rotate(p, a, s.angle + Math.PI / 2), t[0] = -p[0], t[1] = -p[1], t[2] = -v.crossLength(h, p) + v.crossLength(p, c), t[3] = p[0], t[4] = p[1], t[5] = v.crossLength(l, p)
|
|
}, this.equations.push(i), !t.disableRotationalLock) {
|
|
var u = new x(s, o, -e, e);
|
|
this.equations.push(u)
|
|
}
|
|
this.position = 0, this.velocity = 0, this.lowerLimitEnabled = void 0 !== t.lowerLimit, this.upperLimitEnabled = void 0 !== t.upperLimit, this.lowerLimit = void 0 !== t.lowerLimit ? t.lowerLimit : 0, this.upperLimit = void 0 !== t.upperLimit ? t.upperLimit : 1, this.upperLimitEquation = new f(s, o), this.lowerLimitEquation = new f(s, o), this.upperLimitEquation.minForce = this.lowerLimitEquation.minForce = 0, this.upperLimitEquation.maxForce = this.lowerLimitEquation.maxForce = e, this.motorEquation = new m(s, o), this.motorEnabled = !1, this.motorSpeed = 0;
|
|
var d = this,
|
|
y = this.motorEquation;
|
|
y.computeGW;
|
|
y.computeGq = function() { return 0 }, y.computeGW = function() {
|
|
var t = this.G,
|
|
e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = e.velocity,
|
|
o = i.velocity,
|
|
n = e.angularVelocity,
|
|
a = i.angularVelocity;
|
|
return this.gmult(t, s, n, o, a) + d.motorSpeed
|
|
}
|
|
}((e.exports = s).prototype = new g).constructor = s;
|
|
var y = v.create(),
|
|
b = v.create(),
|
|
w = v.create(),
|
|
P = v.create(),
|
|
_ = v.create(),
|
|
T = v.create();
|
|
s.prototype.update = function() {
|
|
var t = this.equations,
|
|
e = t[0],
|
|
i = this.upperLimit,
|
|
s = this.lowerLimit,
|
|
o = this.upperLimitEquation,
|
|
n = this.lowerLimitEquation,
|
|
a = this.bodyA,
|
|
r = this.bodyB,
|
|
h = this.localAxisA,
|
|
l = this.localAnchorA,
|
|
c = this.localAnchorB;
|
|
e.updateJacobian(), v.rotate(y, h, a.angle), v.rotate(P, l, a.angle), v.add(b, P, a.position), v.rotate(_, c, r.angle), v.add(w, _, r.position);
|
|
var p, u = this.position = v.dot(w, y) - v.dot(b, y);
|
|
if (this.motorEnabled) {
|
|
var d = this.motorEquation.G;
|
|
d[0] = y[0], d[1] = y[1], d[2] = v.crossLength(y, _), d[3] = -y[0], d[4] = -y[1], d[5] = -v.crossLength(y, P)
|
|
}
|
|
this.upperLimitEnabled && i < u ? (v.scale(o.normalA, y, -1), v.sub(o.contactPointA, b, a.position), v.sub(o.contactPointB, w, r.position), v.scale(T, y, i), v.add(o.contactPointA, o.contactPointA, T), -1 === t.indexOf(o) && t.push(o)) : -1 !== (p = t.indexOf(o)) && t.splice(p, 1);
|
|
this.lowerLimitEnabled && u < s ? (v.scale(n.normalA, y, 1), v.sub(n.contactPointA, b, a.position), v.sub(n.contactPointB, w, r.position), v.scale(T, y, s), v.sub(n.contactPointB, n.contactPointB, T), -1 === t.indexOf(n) && t.push(n)) : -1 !== (p = t.indexOf(n)) && t.splice(p, 1)
|
|
}, s.prototype.enableMotor = function() { this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0) }, s.prototype.disableMotor = function() {
|
|
if (this.motorEnabled) {
|
|
var t = this.equations.indexOf(this.motorEquation);
|
|
this.equations.splice(t, 1), this.motorEnabled = !1
|
|
}
|
|
}, s.prototype.setLimits = function(t, e) { this.lowerLimitEnabled = "number" == typeof t ? (this.lowerLimit = t, !0) : (this.lowerLimit = t, !1), this.upperLimitEnabled = "number" == typeof e ? (this.upperLimit = e, !0) : (this.upperLimit = e, !1) }
|
|
}, { "../equations/ContactEquation": 21, "../equations/Equation": 22, "../equations/RotationalLockEquation": 24, "../math/vec2": 30, "./Constraint": 14 }],
|
|
19: [function(t, e, i) {
|
|
var h = t("./Constraint"),
|
|
l = t("../equations/Equation"),
|
|
c = t("../equations/RotationalVelocityEquation"),
|
|
p = t("../equations/RotationalLockEquation"),
|
|
d = t("../math/vec2");
|
|
e.exports = s;
|
|
var y = d.create(),
|
|
g = d.create(),
|
|
f = d.fromValues(1, 0),
|
|
m = d.fromValues(0, 1),
|
|
u = d.create();
|
|
|
|
function s(t, e, i) {
|
|
i = i || {}, h.call(this, t, e, h.REVOLUTE, i);
|
|
var s = this.maxForce = void 0 !== i.maxForce ? i.maxForce : Number.MAX_VALUE;
|
|
this.pivotA = d.create(), this.pivotB = d.create(), i.worldPivot ? (d.sub(this.pivotA, i.worldPivot, t.position), d.sub(this.pivotB, i.worldPivot, e.position), d.rotate(this.pivotA, this.pivotA, -t.angle), d.rotate(this.pivotB, this.pivotB, -e.angle)) : (d.copy(this.pivotA, i.localPivotA), d.copy(this.pivotB, i.localPivotB));
|
|
var o = this.equations = [new l(t, e, -s, s), new l(t, e, -s, s)],
|
|
n = o[0],
|
|
a = o[1],
|
|
r = this;
|
|
n.computeGq = function() { return d.rotate(y, r.pivotA, t.angle), d.rotate(g, r.pivotB, e.angle), d.add(u, e.position, g), d.sub(u, u, t.position), d.sub(u, u, y), d.dot(u, f) }, a.computeGq = function() { return d.rotate(y, r.pivotA, t.angle), d.rotate(g, r.pivotB, e.angle), d.add(u, e.position, g), d.sub(u, u, t.position), d.sub(u, u, y), d.dot(u, m) }, a.minForce = n.minForce = -s, a.maxForce = n.maxForce = s, this.motorEquation = new c(t, e), this.motorEnabled = !1, this.angle = 0, this.lowerLimitEnabled = !1, this.upperLimitEnabled = !1, this.lowerLimit = 0, this.upperLimit = 0, this.upperLimitEquation = new p(t, e), this.lowerLimitEquation = new p(t, e), this.upperLimitEquation.minForce = 0, this.lowerLimitEquation.maxForce = 0
|
|
}((s.prototype = new h).constructor = s).prototype.setLimits = function(t, e) { this.lowerLimitEnabled = "number" == typeof t ? (this.lowerLimit = t, !0) : (this.lowerLimit = t, !1), this.upperLimitEnabled = "number" == typeof e ? (this.upperLimit = e, !0) : (this.upperLimit = e, !1) }, s.prototype.update = function() {
|
|
var t, e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = this.pivotA,
|
|
o = this.pivotB,
|
|
n = this.equations,
|
|
a = (n[0], n[1], n[0]),
|
|
r = n[1],
|
|
h = this.upperLimit,
|
|
l = this.lowerLimit,
|
|
c = this.upperLimitEquation,
|
|
p = this.lowerLimitEquation,
|
|
u = this.angle = i.angle - e.angle;
|
|
this.upperLimitEnabled && h < u ? (c.angle = h, -1 === n.indexOf(c) && n.push(c)) : -1 !== (t = n.indexOf(c)) && n.splice(t, 1);
|
|
this.lowerLimitEnabled && u < l ? (p.angle = l, -1 === n.indexOf(p) && n.push(p)) : -1 !== (t = n.indexOf(p)) && n.splice(t, 1);
|
|
d.rotate(y, s, e.angle), d.rotate(g, o, i.angle), a.G[0] = -1, a.G[1] = 0, a.G[2] = -d.crossLength(y, f), a.G[3] = 1, a.G[4] = 0, a.G[5] = d.crossLength(g, f), r.G[0] = 0, r.G[1] = -1, r.G[2] = -d.crossLength(y, m), r.G[3] = 0, r.G[4] = 1, r.G[5] = d.crossLength(g, m)
|
|
}, s.prototype.enableMotor = function() { this.motorEnabled || (this.equations.push(this.motorEquation), this.motorEnabled = !0) }, s.prototype.disableMotor = function() {
|
|
if (this.motorEnabled) {
|
|
var t = this.equations.indexOf(this.motorEquation);
|
|
this.equations.splice(t, 1), this.motorEnabled = !1
|
|
}
|
|
}, s.prototype.motorIsEnabled = function() { return !!this.motorEnabled }, s.prototype.setMotorSpeed = function(t) {
|
|
if (this.motorEnabled) {
|
|
var e = this.equations.indexOf(this.motorEquation);
|
|
this.equations[e].relativeVelocity = t
|
|
}
|
|
}, s.prototype.getMotorSpeed = function() { return !!this.motorEnabled && this.motorEquation.relativeVelocity }
|
|
}, { "../equations/Equation": 22, "../equations/RotationalLockEquation": 24, "../equations/RotationalVelocityEquation": 25, "../math/vec2": 30, "./Constraint": 14 }],
|
|
20: [function(t, e, i) {
|
|
var s = t("./Equation");
|
|
t("../math/vec2");
|
|
|
|
function o(t, e, i) { i = i || {}, s.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = i.angle || 0, this.ratio = "number" == typeof i.ratio ? i.ratio : 1, this.setRatio(this.ratio) }(((e.exports = o).prototype = new s).constructor = o).prototype.computeGq = function() { return this.ratio * this.bodyA.angle - this.bodyB.angle + this.angle }, o.prototype.setRatio = function(t) {
|
|
var e = this.G;
|
|
e[2] = t, e[5] = -1, this.ratio = t
|
|
}, o.prototype.setMaxTorque = function(t) { this.maxForce = t, this.minForce = -t }
|
|
}, { "../math/vec2": 30, "./Equation": 22 }],
|
|
21: [function(t, e, i) {
|
|
var s = t("./Equation"),
|
|
f = t("../math/vec2");
|
|
|
|
function o(t, e) { s.call(this, t, e, 0, Number.MAX_VALUE), this.contactPointA = f.create(), this.penetrationVec = f.create(), this.contactPointB = f.create(), this.normalA = f.create(), this.restitution = 0, this.firstImpact = !1, this.shapeA = null, this.shapeB = null }(((e.exports = o).prototype = new s).constructor = o).prototype.computeB = function(t, e, i) {
|
|
var s, o, n = this.bodyA,
|
|
a = this.bodyB,
|
|
r = this.contactPointA,
|
|
h = this.contactPointB,
|
|
l = n.position,
|
|
c = a.position,
|
|
p = this.penetrationVec,
|
|
u = this.normalA,
|
|
d = this.G,
|
|
y = f.crossLength(r, u),
|
|
g = f.crossLength(h, u);
|
|
return d[0] = -u[0], d[1] = -u[1], d[2] = -y, d[3] = u[0], d[4] = u[1], d[5] = g, f.add(p, c, h), f.sub(p, p, l), f.sub(p, p, r), s = this.firstImpact && 0 !== this.restitution ? (o = 0, 1 / e * (1 + this.restitution) * this.computeGW()) : (o = f.dot(u, p) + this.offset, this.computeGW()), -o * t - s * e - i * this.computeGiMf()
|
|
}
|
|
}, { "../math/vec2": 30, "./Equation": 22 }],
|
|
22: [function(t, e, i) {
|
|
e.exports = a;
|
|
var p = t("../math/vec2"),
|
|
n = t("../utils/Utils");
|
|
t("../objects/Body");
|
|
|
|
function a(t, e, i, s) {
|
|
this.minForce = void 0 === i ? -Number.MAX_VALUE : i, this.maxForce = void 0 === s ? Number.MAX_VALUE : s, this.bodyA = t, this.bodyB = e, this.stiffness = a.DEFAULT_STIFFNESS, this.relaxation = a.DEFAULT_RELAXATION, this.G = new n.ARRAY_TYPE(6);
|
|
for (var o = 0; o < 6; o++) this.G[o] = 0;
|
|
this.offset = 0, this.a = 0, this.b = 0, this.epsilon = 0, this.timeStep = 1 / 60, this.needsUpdate = !0, this.multiplier = 0, this.relativeVelocity = 0, this.enabled = !0
|
|
}(a.prototype.constructor = a).DEFAULT_STIFFNESS = 1e6, a.DEFAULT_RELAXATION = 4, a.prototype.update = function() {
|
|
var t = this.stiffness,
|
|
e = this.relaxation,
|
|
i = this.timeStep;
|
|
this.a = 4 / (i * (1 + 4 * e)), this.b = 4 * e / (1 + 4 * e), this.epsilon = 4 / (i * i * t * (1 + 4 * e)), this.needsUpdate = !1
|
|
}, a.prototype.gmult = function(t, e, i, s, o) { return t[0] * e[0] + t[1] * e[1] + t[2] * i + t[3] * s[0] + t[4] * s[1] + t[5] * o }, a.prototype.computeB = function(t, e, i) { var s = this.computeGW(); return -this.computeGq() * t - s * e - this.computeGiMf() * i };
|
|
var r = p.create(),
|
|
h = p.create();
|
|
a.prototype.computeGq = function() {
|
|
var t = this.G,
|
|
e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = (e.position, i.position, e.angle),
|
|
o = i.angle;
|
|
return this.gmult(t, r, s, h, o) + this.offset
|
|
}, a.prototype.computeGW = function() {
|
|
var t = this.G,
|
|
e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = e.velocity,
|
|
o = i.velocity,
|
|
n = e.angularVelocity,
|
|
a = i.angularVelocity;
|
|
return this.gmult(t, s, n, o, a) + this.relativeVelocity
|
|
}, a.prototype.computeGWlambda = function() {
|
|
var t = this.G,
|
|
e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = e.vlambda,
|
|
o = i.vlambda,
|
|
n = e.wlambda,
|
|
a = i.wlambda;
|
|
return this.gmult(t, s, n, o, a)
|
|
};
|
|
var u = p.create(),
|
|
d = p.create();
|
|
a.prototype.computeGiMf = function() {
|
|
var t = this.bodyA,
|
|
e = this.bodyB,
|
|
i = t.force,
|
|
s = t.angularForce,
|
|
o = e.force,
|
|
n = e.angularForce,
|
|
a = t.invMassSolve,
|
|
r = e.invMassSolve,
|
|
h = t.invInertiaSolve,
|
|
l = e.invInertiaSolve,
|
|
c = this.G;
|
|
return p.scale(u, i, a), p.multiply(u, t.massMultiplier, u), p.scale(d, o, r), p.multiply(d, e.massMultiplier, d), this.gmult(c, u, s * h, d, n * l)
|
|
}, a.prototype.computeGiMGt = function() {
|
|
var t = this.bodyA,
|
|
e = this.bodyB,
|
|
i = t.invMassSolve,
|
|
s = e.invMassSolve,
|
|
o = t.invInertiaSolve,
|
|
n = e.invInertiaSolve,
|
|
a = this.G;
|
|
return a[0] * a[0] * i * t.massMultiplier[0] + a[1] * a[1] * i * t.massMultiplier[1] + a[2] * a[2] * o + a[3] * a[3] * s * e.massMultiplier[0] + a[4] * a[4] * s * e.massMultiplier[1] + a[5] * a[5] * n
|
|
};
|
|
var y = p.create(),
|
|
g = p.create(),
|
|
f = p.create();
|
|
p.create(), p.create(), p.create();
|
|
a.prototype.addToWlambda = function(t) {
|
|
var e = this.bodyA,
|
|
i = this.bodyB,
|
|
s = y,
|
|
o = g,
|
|
n = f,
|
|
a = e.invMassSolve,
|
|
r = i.invMassSolve,
|
|
h = e.invInertiaSolve,
|
|
l = i.invInertiaSolve,
|
|
c = this.G;
|
|
o[0] = c[0], o[1] = c[1], n[0] = c[3], n[1] = c[4], p.scale(s, o, a * t), p.multiply(s, s, e.massMultiplier), p.add(e.vlambda, e.vlambda, s), e.wlambda += h * c[2] * t, p.scale(s, n, r * t), p.multiply(s, s, i.massMultiplier), p.add(i.vlambda, i.vlambda, s), i.wlambda += l * c[5] * t
|
|
}, a.prototype.computeInvC = function(t) { return 1 / (this.computeGiMGt() + t) }
|
|
}, { "../math/vec2": 30, "../objects/Body": 31, "../utils/Utils": 57 }],
|
|
23: [function(t, e, i) {
|
|
var r = t("../math/vec2"),
|
|
s = t("./Equation");
|
|
t("../utils/Utils");
|
|
|
|
function o(t, e, i) { s.call(this, t, e, -i, i), this.contactPointA = r.create(), this.contactPointB = r.create(), this.t = r.create(), this.contactEquations = [], this.shapeA = null, this.shapeB = null, this.frictionCoefficient = .3 }(((e.exports = o).prototype = new s).constructor = o).prototype.setSlipForce = function(t) { this.maxForce = t, this.minForce = -t }, o.prototype.getSlipForce = function() { return this.maxForce }, o.prototype.computeB = function(t, e, i) {
|
|
this.bodyA, this.bodyB;
|
|
var s = this.contactPointA,
|
|
o = this.contactPointB,
|
|
n = this.t,
|
|
a = this.G;
|
|
return a[0] = -n[0], a[1] = -n[1], a[2] = -r.crossLength(s, n), a[3] = n[0], a[4] = n[1], a[5] = r.crossLength(o, n), -this.computeGW() * e - i * this.computeGiMf()
|
|
}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57, "./Equation": 22 }],
|
|
24: [function(t, e, i) {
|
|
var o = t("./Equation"),
|
|
s = t("../math/vec2");
|
|
|
|
function n(t, e, i) {
|
|
i = i || {}, o.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.angle = i.angle || 0;
|
|
var s = this.G;
|
|
s[2] = 1, s[5] = -1
|
|
}((e.exports = n).prototype = new o).constructor = n;
|
|
var a = s.create(),
|
|
r = s.create(),
|
|
h = s.fromValues(1, 0),
|
|
l = s.fromValues(0, 1);
|
|
n.prototype.computeGq = function() { return s.rotate(a, h, this.bodyA.angle + this.angle), s.rotate(r, l, this.bodyB.angle), s.dot(a, r) }
|
|
}, { "../math/vec2": 30, "./Equation": 22 }],
|
|
25: [function(t, e, i) {
|
|
var s = t("./Equation");
|
|
t("../math/vec2");
|
|
|
|
function o(t, e) { s.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE), this.relativeVelocity = 1, this.ratio = 1 }(((e.exports = o).prototype = new s).constructor = o).prototype.computeB = function(t, e, i) {
|
|
var s = this.G;
|
|
s[2] = -1, s[5] = this.ratio;
|
|
var o = this.computeGiMf();
|
|
return -this.computeGW() * e - i * o
|
|
}
|
|
}, { "../math/vec2": 30, "./Equation": 22 }],
|
|
26: [function(t, e, i) {
|
|
var s = function() {};
|
|
(e.exports = s).prototype = {
|
|
constructor: s,
|
|
on: function(t, e, i) { e.context = i || this, void 0 === this._listeners && (this._listeners = {}); var s = this._listeners; return void 0 === s[t] && (s[t] = []), -1 === s[t].indexOf(e) && s[t].push(e), this },
|
|
has: function(t, e) { if (void 0 === this._listeners) return !1; var i = this._listeners; if (e) { if (void 0 !== i[t] && -1 !== i[t].indexOf(e)) return !0 } else if (void 0 !== i[t]) return !0; return !1 },
|
|
off: function(t, e) {
|
|
if (void 0 === this._listeners) return this;
|
|
var i = this._listeners,
|
|
s = i[t].indexOf(e);
|
|
return -1 !== s && i[t].splice(s, 1), this
|
|
},
|
|
emit: function(t) {
|
|
if (void 0 === this._listeners) return this;
|
|
var e = this._listeners[t.type];
|
|
if (void 0 !== e) {
|
|
t.target = this;
|
|
for (var i = 0, s = e.length; i < s; i++) {
|
|
var o = e[i];
|
|
o.call(o.context, t)
|
|
}
|
|
}
|
|
return this
|
|
}
|
|
}
|
|
}, {}],
|
|
27: [function(t, e, i) {
|
|
var s = t("./Material"),
|
|
o = t("../equations/Equation");
|
|
|
|
function n(t, e, i) {
|
|
if (i = i || {}, !(t instanceof s && e instanceof s)) throw new Error("First two arguments must be Material instances.");
|
|
this.id = n.idCounter++, this.materialA = t, this.materialB = e, this.friction = void 0 !== i.friction ? Number(i.friction) : .3, this.restitution = void 0 !== i.restitution ? Number(i.restitution) : 0, this.stiffness = void 0 !== i.stiffness ? Number(i.stiffness) : o.DEFAULT_STIFFNESS, this.relaxation = void 0 !== i.relaxation ? Number(i.relaxation) : o.DEFAULT_RELAXATION, this.frictionStiffness = void 0 !== i.frictionStiffness ? Number(i.frictionStiffness) : o.DEFAULT_STIFFNESS, this.frictionRelaxation = void 0 !== i.frictionRelaxation ? Number(i.frictionRelaxation) : o.DEFAULT_RELAXATION, this.surfaceVelocity = void 0 !== i.surfaceVelocity ? Number(i.surfaceVelocity) : 0, this.contactSkinSize = .005
|
|
}(e.exports = n).idCounter = 0
|
|
}, { "../equations/Equation": 22, "./Material": 28 }],
|
|
28: [function(t, e, i) {
|
|
function s(t) { this.id = t || s.idCounter++ }(e.exports = s).idCounter = 0
|
|
}, {}],
|
|
29: [function(t, e, i) {
|
|
var v = {
|
|
GetArea: function(t) { if (t.length < 6) return 0; for (var e = t.length - 2, i = 0, s = 0; s < e; s += 2) i += (t[s + 2] - t[s]) * (t[s + 1] + t[s + 3]); return .5 * -(i += (t[0] - t[e]) * (t[e + 1] + t[1])) },
|
|
Triangulate: function(t) {
|
|
var e = t.length >> 1;
|
|
if (e < 3) return [];
|
|
for (var i = [], s = [], o = 0; o < e; o++) s.push(o);
|
|
o = 0;
|
|
for (var n = e; 3 < n;) {
|
|
var a = s[(o + 0) % n],
|
|
r = s[(o + 1) % n],
|
|
h = s[(o + 2) % n],
|
|
l = t[2 * a],
|
|
c = t[2 * a + 1],
|
|
p = t[2 * r],
|
|
u = t[2 * r + 1],
|
|
d = t[2 * h],
|
|
y = t[2 * h + 1],
|
|
g = !1;
|
|
if (v._convex(l, c, p, u, d, y)) { g = !0; for (var f = 0; f < n; f++) { var m = s[f]; if (m != a && m != r && m != h && v._PointInTriangle(t[2 * m], t[2 * m + 1], l, c, p, u, d, y)) { g = !1; break } } }
|
|
if (g) i.push(a, r, h), s.splice((o + 1) % n, 1), n--, o = 0;
|
|
else if (o++ > 3 * n) break
|
|
}
|
|
return i.push(s[0], s[1], s[2]), i
|
|
},
|
|
_PointInTriangle: function(t, e, i, s, o, n, a, r) {
|
|
var h = a - i,
|
|
l = r - s,
|
|
c = o - i,
|
|
p = n - s,
|
|
u = t - i,
|
|
d = e - s,
|
|
y = h * h + l * l,
|
|
g = h * c + l * p,
|
|
f = h * u + l * d,
|
|
m = c * c + p * p,
|
|
v = c * u + p * d,
|
|
x = 1 / (y * m - g * g),
|
|
b = (m * f - g * v) * x,
|
|
w = (y * v - g * f) * x;
|
|
return 0 <= b && 0 <= w && b + w < 1
|
|
},
|
|
_convex: function(t, e, i, s, o, n) { return 0 <= (e - s) * (o - i) + (i - t) * (n - s) }
|
|
};
|
|
e.exports = v
|
|
}, {}],
|
|
30: [function(t, e, i) {
|
|
var a = e.exports = {},
|
|
s = t("../utils/Utils");
|
|
a.crossLength = function(t, e) { return t[0] * e[1] - t[1] * e[0] }, a.crossVZ = function(t, e, i) { return a.rotate(t, e, -Math.PI / 2), a.scale(t, t, i), t }, a.crossZV = function(t, e, i) { return a.rotate(t, i, Math.PI / 2), a.scale(t, t, e), t }, a.rotate = function(t, e, i) {
|
|
if (0 !== i) {
|
|
var s = Math.cos(i),
|
|
o = Math.sin(i),
|
|
n = e[0],
|
|
a = e[1];
|
|
t[0] = s * n - o * a, t[1] = o * n + s * a
|
|
}
|
|
else t[0] = e[0], t[1] = e[1]
|
|
}, a.rotate90cw = function(t, e) {
|
|
var i = e[0],
|
|
s = e[1];
|
|
t[0] = s, t[1] = -i
|
|
}, a.toLocalFrame = function(t, e, i, s) { a.copy(t, e), a.sub(t, t, i), a.rotate(t, t, -s) }, a.toGlobalFrame = function(t, e, i, s) { a.copy(t, e), a.rotate(t, t, s), a.add(t, t, i) }, a.vectorToLocalFrame = function(t, e, i) { a.rotate(t, e, -i) }, a.vectorToGlobalFrame = function(t, e, i) { a.rotate(t, e, i) }, a.centroid = function(t, e, i, s) { return a.add(t, e, i), a.add(t, t, s), a.scale(t, t, 1 / 3), t }, a.create = function() { var t = new s.ARRAY_TYPE(2); return t[0] = 0, t[1] = 0, t }, a.clone = function(t) { var e = new s.ARRAY_TYPE(2); return e[0] = t[0], e[1] = t[1], e }, a.fromValues = function(t, e) { var i = new s.ARRAY_TYPE(2); return i[0] = t, i[1] = e, i }, a.copy = function(t, e) { return t[0] = e[0], t[1] = e[1], t }, a.set = function(t, e, i) { return t[0] = e, t[1] = i, t }, a.add = function(t, e, i) { return t[0] = e[0] + i[0], t[1] = e[1] + i[1], t }, a.subtract = function(t, e, i) { return t[0] = e[0] - i[0], t[1] = e[1] - i[1], t }, a.sub = a.subtract, a.multiply = function(t, e, i) { return t[0] = e[0] * i[0], t[1] = e[1] * i[1], t }, a.mul = a.multiply, a.divide = function(t, e, i) { return t[0] = e[0] / i[0], t[1] = e[1] / i[1], t }, a.div = a.divide, a.scale = function(t, e, i) { return t[0] = e[0] * i, t[1] = e[1] * i, t }, a.distance = function(t, e) {
|
|
var i = e[0] - t[0],
|
|
s = e[1] - t[1];
|
|
return Math.sqrt(i * i + s * s)
|
|
}, a.dist = a.distance, a.squaredDistance = function(t, e) {
|
|
var i = e[0] - t[0],
|
|
s = e[1] - t[1];
|
|
return i * i + s * s
|
|
}, a.sqrDist = a.squaredDistance, a.length = function(t) {
|
|
var e = t[0],
|
|
i = t[1];
|
|
return Math.sqrt(e * e + i * i)
|
|
}, a.len = a.length, a.squaredLength = function(t) {
|
|
var e = t[0],
|
|
i = t[1];
|
|
return e * e + i * i
|
|
}, a.sqrLen = a.squaredLength, a.negate = function(t, e) { return t[0] = -e[0], t[1] = -e[1], t }, a.normalize = function(t, e) {
|
|
var i = e[0],
|
|
s = e[1],
|
|
o = i * i + s * s;
|
|
return 0 < o && (o = 1 / Math.sqrt(o), t[0] = e[0] * o, t[1] = e[1] * o), t
|
|
}, a.dot = function(t, e) { return t[0] * e[0] + t[1] * e[1] }, a.str = function(t) { return "vec2(" + t[0] + ", " + t[1] + ")" }, a.lerp = function(t, e, i, s) {
|
|
var o = e[0],
|
|
n = e[1];
|
|
return t[0] = o + s * (i[0] - o), t[1] = n + s * (i[1] - n), t
|
|
}, a.reflect = function(t, e, i) {
|
|
var s = e[0] * i[0] + e[1] * i[1];
|
|
t[0] = e[0] - 2 * i[0] * s, t[1] = e[1] - 2 * i[1] * s
|
|
}, a.getLineSegmentsIntersection = function(t, e, i, s, o) { var n = a.getLineSegmentsIntersectionFraction(e, i, s, o); return !(n < 0) && (t[0] = e[0] + n * (i[0] - e[0]), t[1] = e[1] + n * (i[1] - e[1]), !0) }, a.getLineSegmentsIntersectionFraction = function(t, e, i, s) {
|
|
var o, n, a = e[0] - t[0],
|
|
r = e[1] - t[1],
|
|
h = s[0] - i[0],
|
|
l = s[1] - i[1];
|
|
return o = (-r * (t[0] - i[0]) + a * (t[1] - i[1])) / (-h * r + a * l), n = (h * (t[1] - i[1]) - l * (t[0] - i[0])) / (-h * r + a * l), 0 <= o && o <= 1 && 0 <= n && n <= 1 ? n : -1
|
|
}
|
|
}, { "../utils/Utils": 57 }],
|
|
31: [function(t, e, i) {
|
|
var p = t("../math/vec2"),
|
|
l = t("poly-decomp"),
|
|
c = t("../shapes/Convex"),
|
|
s = t("../collision/RaycastResult"),
|
|
o = t("../collision/Ray"),
|
|
n = t("../collision/AABB"),
|
|
a = t("../events/EventEmitter");
|
|
|
|
function r(t) { t = t || {}, a.call(this), this.id = t.id || ++r._idCounter, this.world = null, this.shapes = [], this.mass = t.mass || 0, this.invMass = 0, this.inertia = 0, this.invInertia = 0, this.invMassSolve = 0, this.invInertiaSolve = 0, this.fixedRotation = !!t.fixedRotation, this.fixedX = !!t.fixedX, this.fixedY = !!t.fixedY, this.massMultiplier = p.create(), this.position = p.fromValues(0, 0), t.position && p.copy(this.position, t.position), this.interpolatedPosition = p.fromValues(0, 0), this.interpolatedAngle = 0, this.previousPosition = p.fromValues(0, 0), this.previousAngle = 0, this.velocity = p.fromValues(0, 0), t.velocity && p.copy(this.velocity, t.velocity), this.vlambda = p.fromValues(0, 0), this.wlambda = 0, this.angle = t.angle || 0, this.angularVelocity = t.angularVelocity || 0, this.force = p.create(), t.force && p.copy(this.force, t.force), this.angularForce = t.angularForce || 0, this.damping = "number" == typeof t.damping ? t.damping : .1, this.angularDamping = "number" == typeof t.angularDamping ? t.angularDamping : .1, this.type = r.STATIC, void 0 !== t.type ? this.type = t.type : t.mass ? this.type = r.DYNAMIC : this.type = r.STATIC, this.boundingRadius = 0, this.aabb = new n, this.aabbNeedsUpdate = !0, this.allowSleep = void 0 === t.allowSleep || t.allowSleep, this.wantsToSleep = !1, this.sleepState = r.AWAKE, this.sleepSpeedLimit = void 0 !== t.sleepSpeedLimit ? t.sleepSpeedLimit : .2, this.sleepTimeLimit = void 0 !== t.sleepTimeLimit ? t.sleepTimeLimit : 1, this.gravityScale = void 0 !== t.gravityScale ? t.gravityScale : 1, this.collisionResponse = void 0 === t.collisionResponse || t.collisionResponse, this.idleTime = 0, this.timeLastSleepy = 0, this.ccdSpeedThreshold = void 0 !== t.ccdSpeedThreshold ? t.ccdSpeedThreshold : -1, this.ccdIterations = void 0 !== t.ccdIterations ? t.ccdIterations : 10, this.concavePath = null, this._wakeUpAfterNarrowphase = !1, this.updateMassProperties() }(((e.exports = r).prototype = new a).constructor = r)._idCounter = 0, r.prototype.updateSolveMassProperties = function() { this.sleepState === r.SLEEPING || this.type === r.KINEMATIC ? (this.invMassSolve = 0, this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass, this.invInertiaSolve = this.invInertia) }, r.prototype.setDensity = function(t) {
|
|
var e = this.getArea();
|
|
this.mass = e * t, this.updateMassProperties()
|
|
}, r.prototype.getArea = function() { for (var t = 0, e = 0; e < this.shapes.length; e++) t += this.shapes[e].area; return t }, r.prototype.getAABB = function() { return this.aabbNeedsUpdate && this.updateAABB(), this.aabb };
|
|
var h = new n,
|
|
u = p.create();
|
|
r.prototype.updateAABB = function() {
|
|
for (var t = this.shapes, e = t.length, i = u, s = this.angle, o = 0; o !== e; o++) {
|
|
var n = t[o],
|
|
a = n.angle + s;
|
|
p.rotate(i, n.position, s), p.add(i, i, this.position), n.computeAABB(h, i, a), 0 === o ? this.aabb.copy(h) : this.aabb.extend(h)
|
|
}
|
|
this.aabbNeedsUpdate = !1
|
|
}, r.prototype.updateBoundingRadius = function() {
|
|
for (var t = this.shapes, e = t.length, i = 0, s = 0; s !== e; s++) {
|
|
var o = t[s],
|
|
n = p.length(o.position),
|
|
a = o.boundingRadius;
|
|
i < n + a && (i = n + a)
|
|
}
|
|
this.boundingRadius = i
|
|
}, r.prototype.addShape = function(t, e, i) {
|
|
if (t.body) throw new Error("A shape can only be added to one body.");
|
|
t.body = this, e ? p.copy(t.position, e) : p.set(t.position, 0, 0), t.angle = i || 0, this.shapes.push(t), this.updateMassProperties(), this.updateBoundingRadius(), this.aabbNeedsUpdate = !0
|
|
}, r.prototype.removeShape = function(t) { var e = this.shapes.indexOf(t); return -1 !== e && (this.shapes.splice(e, 1), this.aabbNeedsUpdate = !0, !(t.body = null)) }, r.prototype.updateMassProperties = function() {
|
|
if (this.type === r.STATIC || this.type === r.KINEMATIC) this.mass = Number.MAX_VALUE, this.invMass = 0, this.inertia = Number.MAX_VALUE, this.invInertia = 0;
|
|
else {
|
|
var t = this.shapes,
|
|
e = t.length,
|
|
i = this.mass / e,
|
|
s = 0;
|
|
if (this.fixedRotation) this.inertia = Number.MAX_VALUE, this.invInertia = 0;
|
|
else {
|
|
for (var o = 0; o < e; o++) {
|
|
var n = t[o],
|
|
a = p.squaredLength(n.position);
|
|
s += n.computeMomentOfInertia(i) + i * a
|
|
}
|
|
this.inertia = s, this.invInertia = 0 < s ? 1 / s : 0
|
|
}
|
|
this.invMass = 1 / this.mass, p.set(this.massMultiplier, this.fixedX ? 0 : 1, this.fixedY ? 0 : 1)
|
|
}
|
|
};
|
|
p.create();
|
|
r.prototype.applyForce = function(t, e) {
|
|
if (p.add(this.force, this.force, t), e) {
|
|
var i = p.crossLength(e, t);
|
|
this.angularForce += i
|
|
}
|
|
};
|
|
var d = p.create(),
|
|
y = p.create(),
|
|
g = p.create();
|
|
r.prototype.applyForceLocal = function(t, e) {
|
|
e = e || g;
|
|
var i = d,
|
|
s = y;
|
|
this.vectorToWorldFrame(i, t), this.vectorToWorldFrame(s, e), this.applyForce(i, s)
|
|
};
|
|
var f = p.create();
|
|
r.prototype.applyImpulse = function(t, e) {
|
|
if (this.type === r.DYNAMIC) {
|
|
var i = f;
|
|
if (p.scale(i, t, this.invMass), p.multiply(i, this.massMultiplier, i), p.add(this.velocity, i, this.velocity), e) {
|
|
var s = p.crossLength(e, t);
|
|
s *= this.invInertia, this.angularVelocity += s
|
|
}
|
|
}
|
|
};
|
|
var m = p.create(),
|
|
v = p.create(),
|
|
x = p.create();
|
|
r.prototype.applyImpulseLocal = function(t, e) {
|
|
e = e || x;
|
|
var i = m,
|
|
s = v;
|
|
this.vectorToWorldFrame(i, t), this.vectorToWorldFrame(s, e), this.applyImpulse(i, s)
|
|
}, r.prototype.toLocalFrame = function(t, e) { p.toLocalFrame(t, e, this.position, this.angle) }, r.prototype.toWorldFrame = function(t, e) { p.toGlobalFrame(t, e, this.position, this.angle) }, r.prototype.vectorToLocalFrame = function(t, e) { p.vectorToLocalFrame(t, e, this.angle) }, r.prototype.vectorToWorldFrame = function(t, e) { p.vectorToGlobalFrame(t, e, this.angle) }, r.prototype.fromPolygon = function(t, e) {
|
|
e = e || {};
|
|
for (var i = this.shapes.length; 0 <= i; --i) this.removeShape(this.shapes[i]);
|
|
var s, o = new l.Polygon;
|
|
if (o.vertices = t, o.makeCCW(), "number" == typeof e.removeCollinearPoints && o.removeCollinearPoints(e.removeCollinearPoints), void 0 === e.skipSimpleCheck && !o.isSimple()) return !1;
|
|
this.concavePath = o.vertices.slice(0);
|
|
for (i = 0; i < this.concavePath.length; i++) {
|
|
var n = [0, 0];
|
|
p.copy(n, this.concavePath[i]), this.concavePath[i] = n
|
|
}
|
|
s = e.optimalDecomp ? o.decomp() : o.quickDecomp();
|
|
var a = p.create();
|
|
for (i = 0; i !== s.length; i++) {
|
|
for (var r = new c({ vertices: s[i].vertices }), h = 0; h !== r.vertices.length; h++) {
|
|
n = r.vertices[h];
|
|
p.sub(n, n, r.centerOfMass)
|
|
}
|
|
p.scale(a, r.centerOfMass, 1), r.updateTriangles(), r.updateCenterOfMass(), r.updateBoundingRadius(), this.addShape(r, a)
|
|
}
|
|
return this.adjustCenterOfMass(), this.aabbNeedsUpdate = !0
|
|
};
|
|
p.fromValues(0, 0);
|
|
var b = p.fromValues(0, 0),
|
|
w = p.fromValues(0, 0),
|
|
P = p.fromValues(0, 0);
|
|
r.prototype.adjustCenterOfMass = function() {
|
|
var t = b,
|
|
e = w,
|
|
i = P,
|
|
s = 0;
|
|
p.set(e, 0, 0);
|
|
for (var o = 0; o !== this.shapes.length; o++) {
|
|
var n = this.shapes[o];
|
|
p.scale(t, n.position, n.area), p.add(e, e, t), s += n.area
|
|
}
|
|
p.scale(i, e, 1 / s);
|
|
for (o = 0; o !== this.shapes.length; o++) {
|
|
n = this.shapes[o];
|
|
p.sub(n.position, n.position, i)
|
|
}
|
|
p.add(this.position, this.position, i);
|
|
for (o = 0; this.concavePath && o < this.concavePath.length; o++) p.sub(this.concavePath[o], this.concavePath[o], i);
|
|
this.updateMassProperties(), this.updateBoundingRadius()
|
|
}, r.prototype.setZeroForce = function() { p.set(this.force, 0, 0), this.angularForce = 0 }, r.prototype.resetConstraintVelocity = function() {
|
|
var t = this.vlambda;
|
|
p.set(t, 0, 0), this.wlambda = 0
|
|
}, r.prototype.addConstraintVelocity = function() {
|
|
var t = this.velocity;
|
|
p.add(t, t, this.vlambda), this.angularVelocity += this.wlambda
|
|
}, r.prototype.applyDamping = function(t) {
|
|
if (this.type === r.DYNAMIC) {
|
|
var e = this.velocity;
|
|
p.scale(e, e, Math.pow(1 - this.damping, t)), this.angularVelocity *= Math.pow(1 - this.angularDamping, t)
|
|
}
|
|
}, r.prototype.wakeUp = function() {
|
|
var t = this.sleepState;
|
|
this.sleepState = r.AWAKE, this.idleTime = 0, t !== r.AWAKE && this.emit(r.wakeUpEvent)
|
|
}, r.prototype.sleep = function() { this.sleepState = r.SLEEPING, this.angularVelocity = 0, this.angularForce = 0, p.set(this.velocity, 0, 0), p.set(this.force, 0, 0), this.emit(r.sleepEvent) }, r.prototype.sleepTick = function(t, e, i) {
|
|
if (this.allowSleep && this.type !== r.SLEEPING) {
|
|
this.wantsToSleep = !1;
|
|
this.sleepState;
|
|
var s = p.squaredLength(this.velocity) + Math.pow(this.angularVelocity, 2),
|
|
o = Math.pow(this.sleepSpeedLimit, 2);
|
|
this.sleepState = o <= s ? (this.idleTime = 0, r.AWAKE) : (this.idleTime += i, r.SLEEPY), this.idleTime > this.sleepTimeLimit && (e ? this.wantsToSleep = !0 : this.sleep())
|
|
}
|
|
}, r.prototype.overlaps = function(t) { return this.world.overlapKeeper.bodiesAreOverlapping(this, t) };
|
|
var _ = p.create(),
|
|
T = p.create();
|
|
r.prototype.integrate = function(t) {
|
|
var e = this.invMass,
|
|
i = this.force,
|
|
s = this.position,
|
|
o = this.velocity;
|
|
p.copy(this.previousPosition, this.position), this.previousAngle = this.angle, this.fixedRotation || (this.angularVelocity += this.angularForce * this.invInertia * t), p.scale(_, i, t * e), p.multiply(_, this.massMultiplier, _), p.add(o, _, o), this.integrateToTimeOfImpact(t) || (p.scale(T, o, t), p.add(s, s, T), this.fixedRotation || (this.angle += this.angularVelocity * t)), this.aabbNeedsUpdate = !0
|
|
};
|
|
var S = new s,
|
|
k = new o({ mode: o.ALL }),
|
|
B = p.create(),
|
|
A = p.create(),
|
|
C = p.create(),
|
|
I = p.create();
|
|
r.prototype.integrateToTimeOfImpact = function(t) {
|
|
if (this.ccdSpeedThreshold < 0 || p.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2)) return !1;
|
|
p.normalize(B, this.velocity), p.scale(A, this.velocity, t), p.add(A, A, this.position), p.sub(C, A, this.position);
|
|
var e, i = this.angularVelocity * t,
|
|
s = p.length(C),
|
|
o = 1,
|
|
n = this;
|
|
if (S.reset(), k.callback = function(t) { t.body !== n && (e = t.body, t.getHitPoint(A, k), p.sub(C, A, n.position), o = p.length(C) / s, t.stop()) }, p.copy(k.from, this.position), p.copy(k.to, A), k.update(), this.world.raycast(S, k), !e) return !1;
|
|
var a = this.angle;
|
|
p.copy(I, this.position);
|
|
for (var r = 0, h = 0, l = 0, c = o; h <= c && r < this.ccdIterations;) { r++, l = (c - h) / 2, p.scale(T, C, o), p.add(this.position, I, T), this.angle = a + i * o, this.updateAABB(), this.aabb.overlaps(e.aabb) && this.world.narrowphase.bodiesOverlap(this, e) ? h = l : c = l }
|
|
return o = l, p.copy(this.position, I), this.angle = a, p.scale(T, C, o), p.add(this.position, this.position, T), this.fixedRotation || (this.angle += i * o), !0
|
|
}, r.prototype.getVelocityAtPoint = function(t, e) { return p.crossVZ(t, e, this.angularVelocity), p.subtract(t, this.velocity, t), t }, r.sleepyEvent = { type: "sleepy" }, r.sleepEvent = { type: "sleep" }, r.wakeUpEvent = { type: "wakeup" }, r.DYNAMIC = 1, r.STATIC = 2, r.KINEMATIC = 4, r.AWAKE = 0, r.SLEEPY = 1, r.SLEEPING = 2
|
|
}, { "../collision/AABB": 7, "../collision/Ray": 11, "../collision/RaycastResult": 12, "../events/EventEmitter": 26, "../math/vec2": 30, "../shapes/Convex": 40, "poly-decomp": 5 }],
|
|
32: [function(t, e, i) {
|
|
var m = t("../math/vec2"),
|
|
a = t("./Spring");
|
|
t("../utils/Utils");
|
|
|
|
function s(t, e, i) {
|
|
i = i || {}, a.call(this, t, e, i), this.localAnchorA = m.fromValues(0, 0), this.localAnchorB = m.fromValues(0, 0), i.localAnchorA && m.copy(this.localAnchorA, i.localAnchorA), i.localAnchorB && m.copy(this.localAnchorB, i.localAnchorB), i.worldAnchorA && this.setWorldAnchorA(i.worldAnchorA), i.worldAnchorB && this.setWorldAnchorB(i.worldAnchorB);
|
|
var s = m.create(),
|
|
o = m.create();
|
|
this.getWorldAnchorA(s), this.getWorldAnchorB(o);
|
|
var n = m.distance(s, o);
|
|
this.restLength = "number" == typeof i.restLength ? i.restLength : n
|
|
}(((e.exports = s).prototype = new a).constructor = s).prototype.setWorldAnchorA = function(t) { this.bodyA.toLocalFrame(this.localAnchorA, t) }, s.prototype.setWorldAnchorB = function(t) { this.bodyB.toLocalFrame(this.localAnchorB, t) }, s.prototype.getWorldAnchorA = function(t) { this.bodyA.toWorldFrame(t, this.localAnchorA) }, s.prototype.getWorldAnchorB = function(t) { this.bodyB.toWorldFrame(t, this.localAnchorB) };
|
|
var v = m.create(),
|
|
x = m.create(),
|
|
b = m.create(),
|
|
w = m.create(),
|
|
P = m.create(),
|
|
_ = m.create(),
|
|
T = m.create(),
|
|
S = m.create(),
|
|
k = m.create();
|
|
s.prototype.applyForce = function() {
|
|
var t = this.stiffness,
|
|
e = this.damping,
|
|
i = this.restLength,
|
|
s = this.bodyA,
|
|
o = this.bodyB,
|
|
n = v,
|
|
a = x,
|
|
r = b,
|
|
h = w,
|
|
l = k,
|
|
c = P,
|
|
p = _,
|
|
u = T,
|
|
d = S;
|
|
this.getWorldAnchorA(c), this.getWorldAnchorB(p), m.sub(u, c, s.position), m.sub(d, p, o.position), m.sub(n, p, c);
|
|
var y = m.len(n);
|
|
m.normalize(a, n), m.sub(r, o.velocity, s.velocity), m.crossZV(l, o.angularVelocity, d), m.add(r, r, l), m.crossZV(l, s.angularVelocity, u), m.sub(r, r, l), m.scale(h, a, -t * (y - i) - e * m.dot(r, a)), m.sub(s.force, s.force, h), m.add(o.force, o.force, h);
|
|
var g = m.crossLength(u, h),
|
|
f = m.crossLength(d, h);
|
|
s.angularForce -= g, o.angularForce += f
|
|
}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57, "./Spring": 34 }],
|
|
33: [function(t, e, i) {
|
|
t("../math/vec2");
|
|
var s = t("./Spring");
|
|
|
|
function o(t, e, i) { i = i || {}, s.call(this, t, e, i), this.restAngle = "number" == typeof i.restAngle ? i.restAngle : e.angle - t.angle }(((e.exports = o).prototype = new s).constructor = o).prototype.applyForce = function() {
|
|
var t = this.stiffness,
|
|
e = this.damping,
|
|
i = this.restAngle,
|
|
s = this.bodyA,
|
|
o = this.bodyB,
|
|
n = -t * (o.angle - s.angle - i) - e * (o.angularVelocity - s.angularVelocity) * 0;
|
|
s.angularForce -= n, o.angularForce += n
|
|
}
|
|
}, { "../math/vec2": 30, "./Spring": 34 }],
|
|
34: [function(t, e, i) {
|
|
t("../math/vec2");
|
|
var s = t("../utils/Utils");
|
|
|
|
function o(t, e, i) { i = s.defaults(i, { stiffness: 100, damping: 1 }), this.stiffness = i.stiffness, this.damping = i.damping, this.bodyA = t, this.bodyB = e }(e.exports = o).prototype.applyForce = function() {}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57 }],
|
|
35: [function(t, e, i) {
|
|
var s = t("../math/vec2"),
|
|
o = (t("../utils/Utils"), t("../constraints/Constraint")),
|
|
n = t("../equations/FrictionEquation"),
|
|
a = t("../objects/Body");
|
|
|
|
function r(t, e) {
|
|
e = e || {}, this.chassisBody = t, this.wheels = [], this.groundBody = new a({ mass: 0 }), this.world = null;
|
|
var i = this;
|
|
this.preStepCallback = function() { i.update() }
|
|
}
|
|
|
|
function h(t, e) { e = e || {}, this.vehicle = t, this.forwardEquation = new n(t.chassisBody, t.groundBody), this.sideEquation = new n(t.chassisBody, t.groundBody), this.steerValue = 0, this.engineForce = 0, this.setSideFriction(void 0 !== e.sideFriction ? e.sideFriction : 5), this.localForwardVector = s.fromValues(0, 1), e.localForwardVector && s.copy(this.localForwardVector, e.localForwardVector), this.localPosition = s.fromValues(0, 0), e.localPosition && s.copy(this.localPosition, e.localPosition), o.apply(this, t.chassisBody, t.groundBody), this.equations.push(this.forwardEquation, this.sideEquation), this.setBrakeForce(0) }(e.exports = r).prototype.addToWorld = function(t) {
|
|
(this.world = t).addBody(this.groundBody), t.on("preStep", this.preStepCallback);
|
|
for (var e = 0; e < this.wheels.length; e++) {
|
|
var i = this.wheels[e];
|
|
t.addConstraint(i)
|
|
}
|
|
}, r.prototype.removeFromWorld = function() {
|
|
var t = this.world;
|
|
t.removeBody(this.groundBody), t.off("preStep", this.preStepCallback);
|
|
for (var e = 0; e < this.wheels.length; e++) {
|
|
var i = this.wheels[e];
|
|
t.removeConstraint(i)
|
|
}
|
|
this.world = null
|
|
}, r.prototype.addWheel = function(t) { var e = new h(this, t); return this.wheels.push(e), e }, r.prototype.update = function() { for (var t = 0; t < this.wheels.length; t++) this.wheels[t].update() }, (h.prototype = new o).setBrakeForce = function(t) { this.forwardEquation.setSlipForce(t) }, h.prototype.setSideFriction = function(t) { this.sideEquation.setSlipForce(t) };
|
|
var l = s.create(),
|
|
c = s.create();
|
|
h.prototype.getSpeed = function() { return this.vehicle.chassisBody.vectorToWorldFrame(c, this.localForwardVector), this.vehicle.chassisBody.getVelocityAtPoint(l, c), s.dot(l, c) };
|
|
var p = s.create();
|
|
h.prototype.update = function() { this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t, this.localForwardVector), s.rotate(this.sideEquation.t, this.localForwardVector, Math.PI / 2), this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t, this.sideEquation.t), s.rotate(this.forwardEquation.t, this.forwardEquation.t, this.steerValue), s.rotate(this.sideEquation.t, this.sideEquation.t, this.steerValue), this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB, this.localPosition), s.copy(this.sideEquation.contactPointB, this.forwardEquation.contactPointB), this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA, this.localPosition), s.copy(this.sideEquation.contactPointA, this.forwardEquation.contactPointA), s.normalize(p, this.forwardEquation.t), s.scale(p, p, this.engineForce), this.vehicle.chassisBody.applyForce(p, this.forwardEquation.contactPointA) }
|
|
}, { "../constraints/Constraint": 14, "../equations/FrictionEquation": 23, "../math/vec2": 30, "../objects/Body": 31, "../utils/Utils": 57 }],
|
|
36: [function(t, e, i) {
|
|
var s = e.exports = { AABB: t("./collision/AABB"), AngleLockEquation: t("./equations/AngleLockEquation"), Body: t("./objects/Body"), Broadphase: t("./collision/Broadphase"), Capsule: t("./shapes/Capsule"), Circle: t("./shapes/Circle"), Constraint: t("./constraints/Constraint"), ContactEquation: t("./equations/ContactEquation"), ContactEquationPool: t("./utils/ContactEquationPool"), ContactMaterial: t("./material/ContactMaterial"), Convex: t("./shapes/Convex"), DistanceConstraint: t("./constraints/DistanceConstraint"), Equation: t("./equations/Equation"), EventEmitter: t("./events/EventEmitter"), FrictionEquation: t("./equations/FrictionEquation"), FrictionEquationPool: t("./utils/FrictionEquationPool"), GearConstraint: t("./constraints/GearConstraint"), GSSolver: t("./solver/GSSolver"), Heightfield: t("./shapes/Heightfield"), Line: t("./shapes/Line"), LockConstraint: t("./constraints/LockConstraint"), Material: t("./material/Material"), Narrowphase: t("./collision/Narrowphase"), NaiveBroadphase: t("./collision/NaiveBroadphase"), Particle: t("./shapes/Particle"), Plane: t("./shapes/Plane"), Pool: t("./utils/Pool"), RevoluteConstraint: t("./constraints/RevoluteConstraint"), PrismaticConstraint: t("./constraints/PrismaticConstraint"), Ray: t("./collision/Ray"), RaycastResult: t("./collision/RaycastResult"), Box: t("./shapes/Box"), RotationalVelocityEquation: t("./equations/RotationalVelocityEquation"), SAPBroadphase: t("./collision/SAPBroadphase"), Shape: t("./shapes/Shape"), Solver: t("./solver/Solver"), Spring: t("./objects/Spring"), TopDownVehicle: t("./objects/TopDownVehicle"), LinearSpring: t("./objects/LinearSpring"), RotationalSpring: t("./objects/RotationalSpring"), Utils: t("./utils/Utils"), World: t("./world/World"), vec2: t("./math/vec2"), version: t("../package.json").version };
|
|
Object.defineProperty(s, "Rectangle", { get: function() { return this.Box } })
|
|
}, { "../package.json": 6, "./collision/AABB": 7, "./collision/Broadphase": 8, "./collision/NaiveBroadphase": 9, "./collision/Narrowphase": 10, "./collision/Ray": 11, "./collision/RaycastResult": 12, "./collision/SAPBroadphase": 13, "./constraints/Constraint": 14, "./constraints/DistanceConstraint": 15, "./constraints/GearConstraint": 16, "./constraints/LockConstraint": 17, "./constraints/PrismaticConstraint": 18, "./constraints/RevoluteConstraint": 19, "./equations/AngleLockEquation": 20, "./equations/ContactEquation": 21, "./equations/Equation": 22, "./equations/FrictionEquation": 23, "./equations/RotationalVelocityEquation": 25, "./events/EventEmitter": 26, "./material/ContactMaterial": 27, "./material/Material": 28, "./math/vec2": 30, "./objects/Body": 31, "./objects/LinearSpring": 32, "./objects/RotationalSpring": 33, "./objects/Spring": 34, "./objects/TopDownVehicle": 35, "./shapes/Box": 37, "./shapes/Capsule": 38, "./shapes/Circle": 39, "./shapes/Convex": 40, "./shapes/Heightfield": 41, "./shapes/Line": 42, "./shapes/Particle": 43, "./shapes/Plane": 44, "./shapes/Shape": 45, "./solver/GSSolver": 46, "./solver/Solver": 47, "./utils/ContactEquationPool": 48, "./utils/FrictionEquationPool": 49, "./utils/Pool": 55, "./utils/Utils": 57, "./world/World": 61 }],
|
|
37: [function(t, e, i) {
|
|
var n = t("../math/vec2"),
|
|
a = t("./Shape"),
|
|
r = t("./Convex");
|
|
|
|
function s(t) {
|
|
"number" == typeof t && "number" == typeof arguments[1] && (t = { width: t, height: arguments[1] }), t = t || {};
|
|
var e = this.width = t.width || 1,
|
|
i = this.height = t.height || 1,
|
|
s = [n.fromValues(-e / 2, -i / 2), n.fromValues(e / 2, -i / 2), n.fromValues(e / 2, i / 2), n.fromValues(-e / 2, i / 2)],
|
|
o = [n.fromValues(1, 0), n.fromValues(0, 1)];
|
|
t.vertices = s, t.axes = o, t.type = a.BOX, r.call(this, t)
|
|
}(((e.exports = s).prototype = new r).constructor = s).prototype.computeMomentOfInertia = function(t) {
|
|
var e = this.width,
|
|
i = this.height;
|
|
return t * (i * i + e * e) / 12
|
|
}, s.prototype.updateBoundingRadius = function() {
|
|
var t = this.width,
|
|
e = this.height;
|
|
this.boundingRadius = Math.sqrt(t * t + e * e) / 2
|
|
};
|
|
n.create(), n.create(), n.create(), n.create();
|
|
s.prototype.computeAABB = function(t, e, i) { t.setFromPoints(this.vertices, e, i, 0) }, s.prototype.updateArea = function() { this.area = this.width * this.height }
|
|
}, { "../math/vec2": 30, "./Convex": 40, "./Shape": 45 }],
|
|
38: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
P = t("../math/vec2");
|
|
|
|
function o(t) { "number" == typeof t && "number" == typeof arguments[1] && (t = { length: t, radius: arguments[1] }), t = t || {}, this.length = t.length || 1, this.radius = t.radius || 1, t.type = s.CAPSULE, s.call(this, t) }(((e.exports = o).prototype = new s).constructor = o).prototype.computeMomentOfInertia = function(t) {
|
|
var e = this.radius,
|
|
i = this.length + e,
|
|
s = 2 * e;
|
|
return t * (s * s + i * i) / 12
|
|
}, o.prototype.updateBoundingRadius = function() { this.boundingRadius = this.radius + this.length / 2 }, o.prototype.updateArea = function() { this.area = Math.PI * this.radius * this.radius + 2 * this.radius * this.length };
|
|
var n = P.create();
|
|
o.prototype.computeAABB = function(t, e, i) {
|
|
var s = this.radius;
|
|
P.set(n, this.length / 2, 0), 0 !== i && P.rotate(n, n, i), P.set(t.upperBound, Math.max(n[0] + s, -n[0] + s), Math.max(n[1] + s, -n[1] + s)), P.set(t.lowerBound, Math.min(n[0] - s, -n[0] - s), Math.min(n[1] - s, -n[1] - s)), P.add(t.lowerBound, t.lowerBound, e), P.add(t.upperBound, t.upperBound, e)
|
|
};
|
|
var _ = P.create(),
|
|
T = P.create(),
|
|
S = P.create(),
|
|
k = P.create(),
|
|
B = P.fromValues(0, 1);
|
|
o.prototype.raycast = function(t, e, i, s) {
|
|
for (var o = e.from, n = e.to, a = (e.direction, _), r = T, h = S, l = k, c = this.length / 2, p = 0; p < 2; p++) { var u = this.radius * (2 * p - 1); if (P.set(h, -c, u), P.set(l, c, u), P.toGlobalFrame(h, h, i, s), P.toGlobalFrame(l, l, i, s), 0 <= (y = P.getLineSegmentsIntersectionFraction(o, n, h, l)) && (P.rotate(r, B, s), P.scale(r, r, 2 * p - 1), e.reportIntersection(t, y, r, -1), t.shouldStop(e))) return }
|
|
var d = Math.pow(this.radius, 2) + Math.pow(c, 2);
|
|
for (p = 0; p < 2; p++) {
|
|
P.set(h, c * (2 * p - 1), 0), P.toGlobalFrame(h, h, i, s);
|
|
var y, g = Math.pow(n[0] - o[0], 2) + Math.pow(n[1] - o[1], 2),
|
|
f = 2 * ((n[0] - o[0]) * (o[0] - h[0]) + (n[1] - o[1]) * (o[1] - h[1])),
|
|
m = Math.pow(o[0] - h[0], 2) + Math.pow(o[1] - h[1], 2) - Math.pow(this.radius, 2);
|
|
if (!((y = Math.pow(f, 2) - 4 * g * m) < 0))
|
|
if (0 === y) { if (P.lerp(a, o, n, y), P.squaredDistance(a, i) > d && (P.sub(r, a, h), P.normalize(r, r), e.reportIntersection(t, y, r, -1), t.shouldStop(e))) return }
|
|
else {
|
|
var v = Math.sqrt(y),
|
|
x = 1 / (2 * g),
|
|
b = (-f - v) * x,
|
|
w = (-f + v) * x;
|
|
if (0 <= b && b <= 1 && (P.lerp(a, o, n, b), P.squaredDistance(a, i) > d && (P.sub(r, a, h), P.normalize(r, r), e.reportIntersection(t, b, r, -1), t.shouldStop(e)))) return;
|
|
if (0 <= w && w <= 1 && (P.lerp(a, o, n, w), P.squaredDistance(a, i) > d && (P.sub(r, a, h), P.normalize(r, r), e.reportIntersection(t, w, r, -1), t.shouldStop(e)))) return
|
|
}
|
|
}
|
|
}
|
|
}, { "../math/vec2": 30, "./Shape": 45 }],
|
|
39: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
m = t("../math/vec2");
|
|
|
|
function o(t) { "number" == typeof t && (t = { radius: t }), t = t || {}, this.radius = t.radius || 1, t.type = s.CIRCLE, s.call(this, t) }(((e.exports = o).prototype = new s).constructor = o).prototype.computeMomentOfInertia = function(t) { var e = this.radius; return t * e * e / 2 }, o.prototype.updateBoundingRadius = function() { this.boundingRadius = this.radius }, o.prototype.updateArea = function() { this.area = Math.PI * this.radius * this.radius }, o.prototype.computeAABB = function(t, e, i) {
|
|
var s = this.radius;
|
|
m.set(t.upperBound, s, s), m.set(t.lowerBound, -s, -s), e && (m.add(t.lowerBound, t.lowerBound, e), m.add(t.upperBound, t.upperBound, e))
|
|
};
|
|
var v = m.create(),
|
|
x = m.create();
|
|
o.prototype.raycast = function(t, e, i, s) {
|
|
var o = e.from,
|
|
n = e.to,
|
|
a = this.radius,
|
|
r = Math.pow(n[0] - o[0], 2) + Math.pow(n[1] - o[1], 2),
|
|
h = 2 * ((n[0] - o[0]) * (o[0] - i[0]) + (n[1] - o[1]) * (o[1] - i[1])),
|
|
l = Math.pow(o[0] - i[0], 2) + Math.pow(o[1] - i[1], 2) - Math.pow(a, 2),
|
|
c = Math.pow(h, 2) - 4 * r * l,
|
|
p = v,
|
|
u = x;
|
|
if (!(c < 0))
|
|
if (0 === c) m.lerp(p, o, n, c), m.sub(u, p, i), m.normalize(u, u), e.reportIntersection(t, c, u, -1);
|
|
else {
|
|
var d = Math.sqrt(c),
|
|
y = 1 / (2 * r),
|
|
g = (-h - d) * y,
|
|
f = (-h + d) * y;
|
|
if (0 <= g && g <= 1 && (m.lerp(p, o, n, g), m.sub(u, p, i), m.normalize(u, u), e.reportIntersection(t, g, u, -1), t.shouldStop(e))) return;
|
|
0 <= f && f <= 1 && (m.lerp(p, o, n, f), m.sub(u, p, i), m.normalize(u, u), e.reportIntersection(t, f, u, -1))
|
|
}
|
|
}
|
|
}, { "../math/vec2": 30, "./Shape": 45 }],
|
|
40: [function(t, e, i) {
|
|
var h = t("./Shape"),
|
|
d = t("../math/vec2"),
|
|
r = t("../math/polyk");
|
|
t("poly-decomp");
|
|
|
|
function u(t) {
|
|
Array.isArray(t) && (t = { vertices: t, axes: arguments[1] }), t = t || {}, this.vertices = [];
|
|
for (var e = void 0 !== t.vertices ? t.vertices : [], i = 0; i < e.length; i++) {
|
|
var s = d.create();
|
|
d.copy(s, e[i]), this.vertices.push(s)
|
|
}
|
|
if (this.axes = [], t.axes)
|
|
for (i = 0; i < t.axes.length; i++) {
|
|
var o = d.create();
|
|
d.copy(o, t.axes[i]), this.axes.push(o)
|
|
}
|
|
else
|
|
for (i = 0; i < this.vertices.length; i++) {
|
|
var n = this.vertices[i],
|
|
a = this.vertices[(i + 1) % this.vertices.length],
|
|
r = d.create();
|
|
d.sub(r, a, n), d.rotate90cw(r, r), d.normalize(r, r), this.axes.push(r)
|
|
}
|
|
if (this.centerOfMass = d.fromValues(0, 0), this.triangles = [], this.vertices.length && (this.updateTriangles(), this.updateCenterOfMass()), this.boundingRadius = 0, t.type = h.CONVEX, h.call(this, t), this.updateBoundingRadius(), this.updateArea(), this.area < 0) throw new Error("Convex vertices must be given in conter-clockwise winding.")
|
|
}((e.exports = u).prototype = new h).constructor = u;
|
|
var l = d.create(),
|
|
a = d.create();
|
|
u.prototype.projectOntoLocalAxis = function(t, e) {
|
|
for (var i, s, o = null, n = null, a = (t = l, 0); a < this.vertices.length; a++) i = this.vertices[a], s = d.dot(i, t), (null === o || o < s) && (o = s), (null === n || s < n) && (n = s);
|
|
if (o < n) {
|
|
var r = n;
|
|
n = o, o = r
|
|
}
|
|
d.set(e, n, o)
|
|
}, u.prototype.projectOntoWorldAxis = function(t, e, i, s) {
|
|
var o = a;
|
|
this.projectOntoLocalAxis(t, s), 0 !== i ? d.rotate(o, t, i) : o = t;
|
|
var n = d.dot(e, o);
|
|
d.set(s, s[0] + n, s[1] + n)
|
|
}, u.prototype.updateTriangles = function() {
|
|
for (var t = [], e = this.triangles.length = 0; e < this.vertices.length; e++) {
|
|
var i = this.vertices[e];
|
|
t.push(i[0], i[1])
|
|
}
|
|
var s = r.Triangulate(t);
|
|
for (e = 0; e < s.length; e += 3) {
|
|
var o = s[e],
|
|
n = s[e + 1],
|
|
a = s[e + 2];
|
|
this.triangles.push([o, n, a])
|
|
}
|
|
};
|
|
var y = d.create(),
|
|
g = d.create(),
|
|
f = d.create(),
|
|
m = d.create(),
|
|
v = d.create();
|
|
d.create(), d.create(), d.create(), d.create();
|
|
u.prototype.updateCenterOfMass = function() {
|
|
var t = this.triangles,
|
|
e = this.vertices,
|
|
i = this.centerOfMass,
|
|
s = y,
|
|
o = f,
|
|
n = m,
|
|
a = v,
|
|
r = g;
|
|
d.set(i, 0, 0);
|
|
for (var h = 0, l = 0; l !== t.length; l++) {
|
|
var c = t[l];
|
|
o = e[c[0]], n = e[c[1]], a = e[c[2]];
|
|
d.centroid(s, o, n, a);
|
|
var p = u.triangleArea(o, n, a);
|
|
h += p, d.scale(r, s, p), d.add(i, i, r)
|
|
}
|
|
d.scale(i, i, 1 / h)
|
|
}, u.prototype.computeMomentOfInertia = function(t) {
|
|
for (var e = 0, i = 0, s = this.vertices.length, o = s - 1, n = 0; n < s; o = n, n++) {
|
|
var a = this.vertices[o],
|
|
r = this.vertices[n],
|
|
h = Math.abs(d.crossLength(a, r));
|
|
e += h * (d.dot(r, r) + d.dot(r, a) + d.dot(a, a)), i += h
|
|
}
|
|
return t / 6 * (e / i)
|
|
}, u.prototype.updateBoundingRadius = function() {
|
|
for (var t = this.vertices, e = 0, i = 0; i !== t.length; i++) {
|
|
var s = d.squaredLength(t[i]);
|
|
e < s && (e = s)
|
|
}
|
|
this.boundingRadius = Math.sqrt(e)
|
|
}, u.triangleArea = function(t, e, i) { return .5 * ((e[0] - t[0]) * (i[1] - t[1]) - (i[0] - t[0]) * (e[1] - t[1])) }, u.prototype.updateArea = function() {
|
|
this.updateTriangles(), this.area = 0;
|
|
for (var t = this.triangles, e = this.vertices, i = 0; i !== t.length; i++) {
|
|
var s = t[i],
|
|
o = e[s[0]],
|
|
n = e[s[1]],
|
|
a = e[s[2]],
|
|
r = u.triangleArea(o, n, a);
|
|
this.area += r
|
|
}
|
|
}, u.prototype.computeAABB = function(t, e, i) { t.setFromPoints(this.vertices, e, i, 0) };
|
|
var x = d.create(),
|
|
b = d.create(),
|
|
w = d.create();
|
|
u.prototype.raycast = function(t, e, i, s) {
|
|
var o = x,
|
|
n = b,
|
|
a = w,
|
|
r = this.vertices;
|
|
d.toLocalFrame(o, e.from, i, s), d.toLocalFrame(n, e.to, i, s);
|
|
for (var h = r.length, l = 0; l < h && !t.shouldStop(e); l++) {
|
|
var c = r[l],
|
|
p = r[(l + 1) % h],
|
|
u = d.getLineSegmentsIntersectionFraction(o, n, c, p);
|
|
0 <= u && (d.sub(a, p, c), d.rotate(a, a, -Math.PI / 2 + s), d.normalize(a, a), e.reportIntersection(t, u, a, l))
|
|
}
|
|
}
|
|
}, { "../math/polyk": 29, "../math/vec2": 30, "./Shape": 45, "poly-decomp": 5 }],
|
|
41: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
f = t("../math/vec2");
|
|
t("../utils/Utils");
|
|
|
|
function o(t) {
|
|
if (Array.isArray(t) && (t = { heights: t }, "object" == typeof arguments[1]))
|
|
for (var e in arguments[1]) t[e] = arguments[1][e];
|
|
t = t || {}, this.heights = t.heights ? t.heights.slice(0) : [], this.maxValue = t.maxValue || null, this.minValue = t.minValue || null, this.elementWidth = t.elementWidth || .1, void 0 !== t.maxValue && void 0 !== t.minValue || this.updateMaxMinValues(), t.type = s.HEIGHTFIELD, s.call(this, t)
|
|
}(((e.exports = o).prototype = new s).constructor = o).prototype.updateMaxMinValues = function() {
|
|
for (var t = this.heights, e = t[0], i = t[0], s = 0; s !== t.length; s++) {
|
|
var o = t[s];
|
|
e < o && (e = o), o < i && (i = o)
|
|
}
|
|
this.maxValue = e, this.minValue = i
|
|
}, o.prototype.computeMomentOfInertia = function(t) { return Number.MAX_VALUE }, o.prototype.updateBoundingRadius = function() { this.boundingRadius = Number.MAX_VALUE }, o.prototype.updateArea = function() {
|
|
for (var t = this.heights, e = 0, i = 0; i < t.length - 1; i++) e += (t[i] + t[i + 1]) / 2 * this.elementWidth;
|
|
this.area = e
|
|
};
|
|
var n = [f.create(), f.create(), f.create(), f.create()];
|
|
o.prototype.computeAABB = function(t, e, i) { f.set(n[0], 0, this.maxValue), f.set(n[1], this.elementWidth * this.heights.length, this.maxValue), f.set(n[2], this.elementWidth * this.heights.length, this.minValue), f.set(n[3], 0, this.minValue), t.setFromPoints(n, e, i) }, o.prototype.getLineSegment = function(t, e, i) {
|
|
var s = this.heights,
|
|
o = this.elementWidth;
|
|
f.set(t, i * o, s[i]), f.set(e, (i + 1) * o, s[i + 1])
|
|
}, o.prototype.getSegmentIndex = function(t) { return Math.floor(t[0] / this.elementWidth) }, o.prototype.getClampedSegmentIndex = function(t) { var e = this.getSegmentIndex(t); return e = Math.min(this.heights.length, Math.max(e, 0)) };
|
|
f.create();
|
|
var m = f.create(),
|
|
v = f.create(),
|
|
x = f.create(),
|
|
b = f.create(),
|
|
w = f.create();
|
|
f.fromValues(0, 1);
|
|
o.prototype.raycast = function(t, e, i, s) {
|
|
var o = e.from,
|
|
n = e.to,
|
|
a = (e.direction, m),
|
|
r = v,
|
|
h = x,
|
|
l = b,
|
|
c = w;
|
|
f.toLocalFrame(l, o, i, s), f.toLocalFrame(c, n, i, s);
|
|
var p = this.getClampedSegmentIndex(l),
|
|
u = this.getClampedSegmentIndex(c);
|
|
if (u < p) {
|
|
var d = p;
|
|
p = u, u = d
|
|
}
|
|
for (var y = 0; y < this.heights.length - 1; y++) { this.getLineSegment(r, h, y); var g = f.getLineSegmentsIntersectionFraction(l, c, r, h); if (0 <= g && (f.sub(a, h, r), f.rotate(a, a, s + Math.PI / 2), f.normalize(a, a), e.reportIntersection(t, g, a, -1), t.shouldStop(e))) return }
|
|
}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57, "./Shape": 45 }],
|
|
42: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
p = t("../math/vec2");
|
|
|
|
function o(t) { "number" == typeof t && (t = { length: t }), t = t || {}, this.length = t.length || 1, t.type = s.LINE, s.call(this, t) }(((e.exports = o).prototype = new s).constructor = o).prototype.computeMomentOfInertia = function(t) { return t * Math.pow(this.length, 2) / 12 }, o.prototype.updateBoundingRadius = function() { this.boundingRadius = this.length / 2 };
|
|
var n = [p.create(), p.create()];
|
|
o.prototype.computeAABB = function(t, e, i) {
|
|
var s = this.length / 2;
|
|
p.set(n[0], -s, 0), p.set(n[1], s, 0), t.setFromPoints(n, e, i, 0)
|
|
};
|
|
p.create();
|
|
var u = p.create(),
|
|
d = p.create(),
|
|
y = p.create(),
|
|
g = p.fromValues(0, 1);
|
|
o.prototype.raycast = function(t, e, i, s) {
|
|
var o = e.from,
|
|
n = e.to,
|
|
a = d,
|
|
r = y,
|
|
h = this.length / 2;
|
|
p.set(a, -h, 0), p.set(r, h, 0), p.toGlobalFrame(a, a, i, s), p.toGlobalFrame(r, r, i, s);
|
|
var l = p.getLineSegmentsIntersectionFraction(a, r, o, n);
|
|
if (0 <= l) {
|
|
var c = u;
|
|
p.rotate(c, g, s), e.reportIntersection(t, l, c, -1)
|
|
}
|
|
}
|
|
}, { "../math/vec2": 30, "./Shape": 45 }],
|
|
43: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
o = t("../math/vec2");
|
|
|
|
function n(t) {
|
|
(t = t || {}).type = s.PARTICLE, s.call(this, t)
|
|
}(((e.exports = n).prototype = new s).constructor = n).prototype.computeMomentOfInertia = function(t) { return 0 }, n.prototype.updateBoundingRadius = function() { this.boundingRadius = 0 }, n.prototype.computeAABB = function(t, e, i) { o.copy(t.lowerBound, e), o.copy(t.upperBound, e) }
|
|
}, { "../math/vec2": 30, "./Shape": 45 }],
|
|
44: [function(t, e, i) {
|
|
var s = t("./Shape"),
|
|
d = t("../math/vec2");
|
|
t("../utils/Utils");
|
|
|
|
function o(t) {
|
|
(t = t || {}).type = s.PLANE, s.call(this, t)
|
|
}(((e.exports = o).prototype = new s).constructor = o).prototype.computeMomentOfInertia = function(t) { return 0 }, o.prototype.updateBoundingRadius = function() { this.boundingRadius = Number.MAX_VALUE }, o.prototype.computeAABB = function(t, e, i) {
|
|
var s = i % (2 * Math.PI),
|
|
o = d.set,
|
|
n = Number.MAX_VALUE,
|
|
a = t.lowerBound,
|
|
r = t.upperBound;
|
|
0 === s ? (o(a, -n, -n), o(r, n, 0)) : s === Math.PI / 2 ? (o(a, 0, -n), o(r, n, n)) : s === Math.PI ? (o(a, -n, 0), o(r, n, n)) : s === 3 * Math.PI / 2 ? (o(a, -n, -n), o(r, 0, n)) : (o(a, -n, -n), o(r, n, n)), d.add(a, a, e), d.add(r, r, e)
|
|
}, o.prototype.updateArea = function() { this.area = Number.MAX_VALUE };
|
|
var y = d.create(),
|
|
g = (d.create(), d.create(), d.create()),
|
|
f = d.create();
|
|
o.prototype.raycast = function(t, e, i, s) {
|
|
var o = e.from,
|
|
n = e.to,
|
|
a = e.direction,
|
|
r = y,
|
|
h = g,
|
|
l = f;
|
|
d.set(h, 0, 1), d.rotate(h, h, s), d.sub(l, o, i);
|
|
var c = d.dot(l, h);
|
|
if (d.sub(l, n, i), !(0 < c * d.dot(l, h) || d.squaredDistance(o, n) < c * c)) {
|
|
var p = d.dot(h, a);
|
|
d.sub(r, o, i);
|
|
var u = -d.dot(h, r) / p / e.length;
|
|
e.reportIntersection(t, u, h, -1)
|
|
}
|
|
}
|
|
}, { "../math/vec2": 30, "../utils/Utils": 57, "./Shape": 45 }],
|
|
45: [function(t, e, i) {
|
|
e.exports = o;
|
|
var s = t("../math/vec2");
|
|
|
|
function o(t) { t = t || {}, this.body = null, this.position = s.fromValues(0, 0), t.position && s.copy(this.position, t.position), this.angle = t.angle || 0, this.type = t.type || 0, this.id = o.idCounter++, this.boundingRadius = 0, this.collisionGroup = void 0 !== t.collisionGroup ? t.collisionGroup : 1, this.collisionResponse = void 0 === t.collisionResponse || t.collisionResponse, this.collisionMask = void 0 !== t.collisionMask ? t.collisionMask : 1, this.material = t.material || null, this.area = 0, this.sensor = void 0 !== t.sensor && t.sensor, this.type && this.updateBoundingRadius(), this.updateArea() } o.idCounter = 0, o.CIRCLE = 1, o.PARTICLE = 2, o.PLANE = 4, o.CONVEX = 8, o.LINE = 16, o.BOX = 32, Object.defineProperty(o, "RECTANGLE", { get: function() { return o.BOX } }), o.CAPSULE = 64, o.HEIGHTFIELD = 128, o.prototype.computeMomentOfInertia = function(t) {}, o.prototype.updateBoundingRadius = function() {}, o.prototype.updateArea = function() {}, o.prototype.computeAABB = function(t, e, i) {}, o.prototype.raycast = function(t, e, i, s) {}
|
|
}, { "../math/vec2": 30 }],
|
|
46: [function(t, e, i) {
|
|
var P = t("../math/vec2"),
|
|
s = t("./Solver"),
|
|
_ = t("../utils/Utils"),
|
|
T = t("../equations/FrictionEquation");
|
|
|
|
function S(t) { s.call(this, t, s.GS), t = t || {}, this.iterations = t.iterations || 10, this.tolerance = t.tolerance || 1e-7, this.arrayStep = 30, this.lambda = new _.ARRAY_TYPE(this.arrayStep), this.Bs = new _.ARRAY_TYPE(this.arrayStep), this.invCs = new _.ARRAY_TYPE(this.arrayStep), this.useZeroRHS = !1, this.frictionIterations = 0, this.usedIterations = 0 }(((e.exports = S).prototype = new s).constructor = S).prototype.solve = function(t, e) {
|
|
this.sortEquations();
|
|
var i = 0,
|
|
s = this.iterations,
|
|
o = this.frictionIterations,
|
|
n = this.equations,
|
|
a = n.length,
|
|
r = Math.pow(this.tolerance * a, 2),
|
|
h = e.bodies,
|
|
l = e.bodies.length,
|
|
c = (P.add, P.set, this.useZeroRHS),
|
|
p = this.lambda;
|
|
if (this.usedIterations = 0, a)
|
|
for (var u = 0; u !== l; u++) { h[u].updateSolveMassProperties() } p.length < a && (p = this.lambda = new _.ARRAY_TYPE(a + this.arrayStep), this.Bs = new _.ARRAY_TYPE(a + this.arrayStep), this.invCs = new _.ARRAY_TYPE(a + this.arrayStep)),
|
|
function(t) { for (var e = t.length; e--;) t[e] = 0 }(p);
|
|
var d, y, g = this.invCs,
|
|
f = this.Bs;
|
|
for (p = this.lambda, u = 0; u !== n.length; u++) {
|
|
var m;
|
|
((m = n[u]).timeStep !== t || m.needsUpdate) && (m.timeStep = t, m.update()), f[u] = m.computeB(m.a, m.b, t), g[u] = m.computeInvC(m.epsilon)
|
|
}
|
|
if (0 !== a) {
|
|
for (u = 0; u !== l; u++) { h[u].resetConstraintVelocity() }
|
|
if (o) {
|
|
for (i = 0; i !== o; i++) {
|
|
for (y = d = 0; y !== a; y++) {
|
|
m = n[y];
|
|
var v = S.iterateEquation(y, m, m.epsilon, f, g, p, c, t, i);
|
|
d += Math.abs(v)
|
|
}
|
|
if (this.usedIterations++, d * d <= r) break
|
|
}
|
|
for (S.updateMultipliers(n, p, 1 / t), y = 0; y !== a; y++) {
|
|
var x = n[y];
|
|
if (x instanceof T) {
|
|
for (var b = 0, w = 0; w !== x.contactEquations.length; w++) b += x.contactEquations[w].multiplier;
|
|
b *= x.frictionCoefficient / x.contactEquations.length, x.maxForce = b, x.minForce = -b
|
|
}
|
|
}
|
|
}
|
|
for (i = 0; i !== s; i++) {
|
|
for (y = d = 0; y !== a; y++) {
|
|
m = n[y];
|
|
v = S.iterateEquation(y, m, m.epsilon, f, g, p, c, t, i);
|
|
d += Math.abs(v)
|
|
}
|
|
if (this.usedIterations++, d * d <= r) break
|
|
}
|
|
for (u = 0; u !== l; u++) h[u].addConstraintVelocity();
|
|
S.updateMultipliers(n, p, 1 / t)
|
|
}
|
|
}, S.updateMultipliers = function(t, e, i) { for (var s = t.length; s--;) t[s].multiplier = e[s] * i }, S.iterateEquation = function(t, e, i, s, o, n, a, r, h) {
|
|
var l = s[t],
|
|
c = o[t],
|
|
p = n[t],
|
|
u = e.computeGWlambda(),
|
|
d = e.maxForce,
|
|
y = e.minForce;
|
|
a && (l = 0);
|
|
var g = c * (l - u - i * p),
|
|
f = p + g;
|
|
return f < y * r ? g = y * r - p : d * r < f && (g = d * r - p), n[t] += g, e.addToWlambda(g), g
|
|
}
|
|
}, { "../equations/FrictionEquation": 23, "../math/vec2": 30, "../utils/Utils": 57, "./Solver": 47 }],
|
|
47: [function(t, e, i) {
|
|
t("../utils/Utils");
|
|
var s = t("../events/EventEmitter");
|
|
|
|
function o(t, e) { t = t || {}, s.call(this), this.type = e, this.equations = [], this.equationSortFunction = t.equationSortFunction || !1 }(((e.exports = o).prototype = new s).constructor = o).prototype.solve = function(t, e) { throw new Error("Solver.solve should be implemented by subclasses!") };
|
|
var n = { bodies: [] };
|
|
o.prototype.solveIsland = function(t, e) { this.removeAllEquations(), e.equations.length && (this.addEquations(e.equations), n.bodies.length = 0, e.getBodies(n.bodies), n.bodies.length && this.solve(t, n)) }, o.prototype.sortEquations = function() { this.equationSortFunction && this.equations.sort(this.equationSortFunction) }, o.prototype.addEquation = function(t) { t.enabled && this.equations.push(t) }, o.prototype.addEquations = function(t) {
|
|
for (var e = 0, i = t.length; e !== i; e++) {
|
|
var s = t[e];
|
|
s.enabled && this.equations.push(s)
|
|
}
|
|
}, o.prototype.removeEquation = function(t) { var e = this.equations.indexOf(t); - 1 !== e && this.equations.splice(e, 1) }, o.prototype.removeAllEquations = function() { this.equations.length = 0 }, o.GS = 1, o.ISLAND = 2
|
|
}, { "../events/EventEmitter": 26, "../utils/Utils": 57 }],
|
|
48: [function(t, e, i) {
|
|
var s = t("../equations/ContactEquation"),
|
|
o = t("./Pool");
|
|
|
|
function n() { o.apply(this, arguments) }(((e.exports = n).prototype = new o).constructor = n).prototype.create = function() { return new s }, n.prototype.destroy = function(t) { return t.bodyA = t.bodyB = null, this }
|
|
}, { "../equations/ContactEquation": 21, "./Pool": 55 }],
|
|
49: [function(t, e, i) {
|
|
var s = t("../equations/FrictionEquation"),
|
|
o = t("./Pool");
|
|
|
|
function n() { o.apply(this, arguments) }(((e.exports = n).prototype = new o).constructor = n).prototype.create = function() { return new s }, n.prototype.destroy = function(t) { return t.bodyA = t.bodyB = null, this }
|
|
}, { "../equations/FrictionEquation": 23, "./Pool": 55 }],
|
|
50: [function(t, e, i) {
|
|
var s = t("../world/IslandNode"),
|
|
o = t("./Pool");
|
|
|
|
function n() { o.apply(this, arguments) }(((e.exports = n).prototype = new o).constructor = n).prototype.create = function() { return new s }, n.prototype.destroy = function(t) { return t.reset(), this }
|
|
}, { "../world/IslandNode": 60, "./Pool": 55 }],
|
|
51: [function(t, e, i) {
|
|
var s = t("../world/Island"),
|
|
o = t("./Pool");
|
|
|
|
function n() { o.apply(this, arguments) }(((e.exports = n).prototype = new o).constructor = n).prototype.create = function() { return new s }, n.prototype.destroy = function(t) { return t.reset(), this }
|
|
}, { "../world/Island": 58, "./Pool": 55 }],
|
|
52: [function(t, e, i) {
|
|
var s = t("./TupleDictionary"),
|
|
o = (t("./OverlapKeeperRecord"), t("./OverlapKeeperRecordPool"));
|
|
t("./Utils");
|
|
|
|
function n() { this.overlappingShapesLastState = new s, this.overlappingShapesCurrentState = new s, this.recordPool = new o({ size: 16 }), this.tmpDict = new s, this.tmpArray1 = [] }(e.exports = n).prototype.tick = function() {
|
|
for (var t = this.overlappingShapesLastState, e = this.overlappingShapesCurrentState, i = t.keys.length; i--;) {
|
|
var s = t.keys[i],
|
|
o = t.getByKey(s);
|
|
e.getByKey(s);
|
|
o && this.recordPool.release(o)
|
|
}
|
|
t.reset(), t.copy(e), e.reset()
|
|
}, n.prototype.setOverlapping = function(t, e, i, s) {
|
|
this.overlappingShapesLastState;
|
|
var o = this.overlappingShapesCurrentState;
|
|
if (!o.get(e.id, s.id)) {
|
|
var n = this.recordPool.get();
|
|
n.set(t, e, i, s), o.set(e.id, s.id, n)
|
|
}
|
|
}, n.prototype.getNewOverlaps = function(t) { return this.getDiff(this.overlappingShapesLastState, this.overlappingShapesCurrentState, t) }, n.prototype.getEndOverlaps = function(t) { return this.getDiff(this.overlappingShapesCurrentState, this.overlappingShapesLastState, t) }, n.prototype.bodiesAreOverlapping = function(t, e) {
|
|
for (var i = this.overlappingShapesCurrentState, s = i.keys.length; s--;) {
|
|
var o = i.keys[s],
|
|
n = i.data[o];
|
|
if (n.bodyA === t && n.bodyB === e || n.bodyA === e && n.bodyB === t) return !0
|
|
}
|
|
return !1
|
|
}, n.prototype.getDiff = function(t, e, i) {
|
|
var s = t,
|
|
o = e;
|
|
(i = i || []).length = 0;
|
|
for (var n = o.keys.length; n--;) {
|
|
var a = o.keys[n],
|
|
r = o.data[a];
|
|
if (!r) throw new Error("Key " + a + " had no data!");
|
|
s.data[a] || i.push(r)
|
|
}
|
|
return i
|
|
}, n.prototype.isNewOverlap = function(t, e) {
|
|
var i = 0 | t.id,
|
|
s = 0 | e.id,
|
|
o = this.overlappingShapesLastState,
|
|
n = this.overlappingShapesCurrentState;
|
|
return !o.get(i, s) && !!n.get(i, s)
|
|
}, n.prototype.getNewBodyOverlaps = function(t) { this.tmpArray1.length = 0; var e = this.getNewOverlaps(this.tmpArray1); return this.getBodyDiff(e, t) }, n.prototype.getEndBodyOverlaps = function(t) { this.tmpArray1.length = 0; var e = this.getEndOverlaps(this.tmpArray1); return this.getBodyDiff(e, t) }, n.prototype.getBodyDiff = function(t, e) {
|
|
e = e || [];
|
|
for (var i = this.tmpDict, s = t.length; s--;) {
|
|
var o = t[s];
|
|
i.set(0 | o.bodyA.id, 0 | o.bodyB.id, o)
|
|
}
|
|
for (s = i.keys.length; s--;) {
|
|
(o = i.getByKey(i.keys[s])) && e.push(o.bodyA, o.bodyB)
|
|
}
|
|
return i.reset(), e
|
|
}
|
|
}, { "./OverlapKeeperRecord": 53, "./OverlapKeeperRecordPool": 54, "./TupleDictionary": 56, "./Utils": 57 }],
|
|
53: [function(t, e, i) {
|
|
function o(t, e, i, s) { this.shapeA = e, this.shapeB = s, this.bodyA = t, this.bodyB = i }(e.exports = o).prototype.set = function(t, e, i, s) { o.call(this, t, e, i, s) }
|
|
}, {}],
|
|
54: [function(t, e, i) {
|
|
var s = t("./OverlapKeeperRecord"),
|
|
o = t("./Pool");
|
|
|
|
function n() { o.apply(this, arguments) }(((e.exports = n).prototype = new o).constructor = n).prototype.create = function() { return new s }, n.prototype.destroy = function(t) { return t.bodyA = t.bodyB = t.shapeA = t.shapeB = null, this }
|
|
}, { "./OverlapKeeperRecord": 53, "./Pool": 55 }],
|
|
55: [function(t, e, i) {
|
|
function s(t) { t = t || {}, this.objects = [], void 0 !== t.size && this.resize(t.size) }(e.exports = s).prototype.resize = function(t) { for (var e = this.objects; e.length > t;) e.pop(); for (; e.length < t;) e.push(this.create()); return this }, s.prototype.get = function() { var t = this.objects; return t.length ? t.pop() : this.create() }, s.prototype.release = function(t) { return this.destroy(t), this.objects.push(t), this }
|
|
}, {}],
|
|
56: [function(t, e, i) {
|
|
var s = t("./Utils");
|
|
|
|
function o() { this.data = {}, this.keys = [] }(e.exports = o).prototype.getKey = function(t, e) { return (0 | (t |= 0)) == (0 | (e |= 0)) ? -1 : 0 | ((0 | e) < (0 | t) ? t << 16 | 65535 & e : e << 16 | 65535 & t) }, o.prototype.getByKey = function(t) { return t |= 0, this.data[t] }, o.prototype.get = function(t, e) { return this.data[this.getKey(t, e)] }, o.prototype.set = function(t, e, i) { if (!i) throw new Error("No data!"); var s = this.getKey(t, e); return this.data[s] || this.keys.push(s), this.data[s] = i, s }, o.prototype.reset = function() {
|
|
for (var t = this.data, e = this.keys, i = e.length; i--;) delete t[e[i]];
|
|
e.length = 0
|
|
}, o.prototype.copy = function(t) {
|
|
this.reset(), s.appendArray(this.keys, t.keys);
|
|
for (var e = t.keys.length; e--;) {
|
|
var i = t.keys[e];
|
|
this.data[i] = t.data[i]
|
|
}
|
|
}
|
|
}, { "./Utils": 57 }],
|
|
57: [function(t, e, i) {
|
|
function s() {}(e.exports = s).appendArray = function(t, e) {
|
|
if (e.length < 15e4) t.push.apply(t, e);
|
|
else
|
|
for (var i = 0, s = e.length; i !== s; ++i) t.push(e[i])
|
|
}, s.splice = function(t, e, i) {
|
|
i = i || 1;
|
|
for (var s = e, o = t.length - i; s < o; s++) t[s] = t[s + i];
|
|
t.length = o
|
|
}, s.ARRAY_TYPE = "undefined" != typeof P2_ARRAY_TYPE ? P2_ARRAY_TYPE : "undefined" != typeof Float32Array ? Float32Array : Array, s.extend = function(t, e) { for (var i in e) t[i] = e[i] }, s.defaults = function(t, e) { for (var i in t = t || {}, e) i in t || (t[i] = e[i]); return t }
|
|
}, {}],
|
|
58: [function(t, e, i) {
|
|
var s = t("../objects/Body");
|
|
|
|
function o() { this.equations = [], this.bodies = [] }(e.exports = o).prototype.reset = function() { this.equations.length = this.bodies.length = 0 };
|
|
var n = [];
|
|
o.prototype.getBodies = function(t) { for (var e = t || [], i = this.equations, s = n.length = 0; s !== i.length; s++) { var o = i[s]; - 1 === n.indexOf(o.bodyA.id) && (e.push(o.bodyA), n.push(o.bodyA.id)), -1 === n.indexOf(o.bodyB.id) && (e.push(o.bodyB), n.push(o.bodyB.id)) } return e }, o.prototype.wantsToSleep = function() { for (var t = 0; t < this.bodies.length; t++) { var e = this.bodies[t]; if (e.type === s.DYNAMIC && !e.wantsToSleep) return !1 } return !0 }, o.prototype.sleep = function() { for (var t = 0; t < this.bodies.length; t++) { this.bodies[t].sleep() } return !0 }
|
|
}, { "../objects/Body": 31 }],
|
|
59: [function(t, e, i) {
|
|
t("../math/vec2"), t("./Island"), t("./IslandNode");
|
|
var s = t("./../utils/IslandNodePool"),
|
|
o = t("./../utils/IslandPool"),
|
|
a = t("../objects/Body");
|
|
|
|
function y(t) { this.nodePool = new s({ size: 16 }), this.islandPool = new o({ size: 8 }), this.equations = [], this.islands = [], this.nodes = [], this.queue = [] }(e.exports = y).getUnvisitedNode = function(t) { for (var e = t.length, i = 0; i !== e; i++) { var s = t[i]; if (!s.visited && s.body.type === a.DYNAMIC) return s } return !1 }, y.prototype.visit = function(t, e, i) { e.push(t.body); for (var s = t.equations.length, o = 0; o !== s; o++) { var n = t.equations[o]; - 1 === i.indexOf(n) && i.push(n) } }, y.prototype.bfs = function(t, e, i) {
|
|
var s = this.queue;
|
|
for (s.length = 0, s.push(t), t.visited = !0, this.visit(t, e, i); s.length;)
|
|
for (var o, n = s.pop(); o = y.getUnvisitedNode(n.neighbors);) o.visited = !0, this.visit(o, e, i), o.body.type === a.DYNAMIC && s.push(o)
|
|
}, y.prototype.split = function(t) {
|
|
for (var e = t.bodies, i = this.nodes, s = this.equations; i.length;) this.nodePool.release(i.pop());
|
|
for (var o = 0; o !== e.length; o++) {
|
|
var n = this.nodePool.get();
|
|
n.body = e[o], i.push(n)
|
|
}
|
|
for (var a = 0; a !== s.length; a++) {
|
|
var r = s[a],
|
|
h = (o = e.indexOf(r.bodyA), e.indexOf(r.bodyB)),
|
|
l = i[o],
|
|
c = i[h];
|
|
l.neighbors.push(c), c.neighbors.push(l), l.equations.push(r), c.equations.push(r)
|
|
}
|
|
var p, u = this.islands;
|
|
for (o = 0; o < u.length; o++) this.islandPool.release(u[o]);
|
|
for (u.length = 0; p = y.getUnvisitedNode(i);) {
|
|
var d = this.islandPool.get();
|
|
this.bfs(p, d.bodies, d.equations), u.push(d)
|
|
}
|
|
return u
|
|
}
|
|
}, { "../math/vec2": 30, "../objects/Body": 31, "./../utils/IslandNodePool": 50, "./../utils/IslandPool": 51, "./Island": 58, "./IslandNode": 60 }],
|
|
60: [function(t, e, i) {
|
|
function s(t) { this.body = t, this.neighbors = [], this.equations = [], this.visited = !1 }(e.exports = s).prototype.reset = function() { this.equations.length = 0, this.neighbors.length = 0, this.visited = !1, this.body = null }
|
|
}, {}],
|
|
61: [function(t, e, i) {
|
|
var s = t("../solver/GSSolver"),
|
|
j = (t("../solver/Solver"), t("../collision/Ray"), t("../math/vec2")),
|
|
m = t("../shapes/Circle"),
|
|
v = t("../shapes/Convex"),
|
|
x = (t("../shapes/Line"), t("../shapes/Plane")),
|
|
b = t("../shapes/Capsule"),
|
|
w = t("../shapes/Particle"),
|
|
o = t("../events/EventEmitter"),
|
|
W = t("../objects/Body"),
|
|
n = (t("../shapes/Shape"), t("../objects/LinearSpring"), t("../material/Material")),
|
|
a = t("../material/ContactMaterial"),
|
|
r = (t("../constraints/DistanceConstraint"), t("../constraints/Constraint"), t("../constraints/LockConstraint"), t("../constraints/RevoluteConstraint"), t("../constraints/PrismaticConstraint"), t("../constraints/GearConstraint"), t("../../package.json"), t("../collision/Broadphase"), t("../collision/AABB")),
|
|
h = t("../collision/SAPBroadphase"),
|
|
l = t("../collision/Narrowphase"),
|
|
q = t("../utils/Utils"),
|
|
c = t("../utils/OverlapKeeper"),
|
|
p = t("./IslandManager");
|
|
t("../objects/RotationalSpring");
|
|
|
|
function Y(t) { o.apply(this), t = t || {}, this.springs = [], this.bodies = [], this.disabledBodyCollisionPairs = [], this.solver = t.solver || new s, this.narrowphase = new l(this), this.islandManager = new p, this.gravity = j.fromValues(0, -9.78), t.gravity && j.copy(this.gravity, t.gravity), this.frictionGravity = j.length(this.gravity) || 10, this.useWorldGravityAsFrictionGravity = !0, this.useFrictionGravityOnZeroGravity = !0, this.broadphase = t.broadphase || new h, this.broadphase.setWorld(this), this.constraints = [], this.defaultMaterial = new n, this.defaultContactMaterial = new a(this.defaultMaterial, this.defaultMaterial), this.lastTimeStep = 1 / 60, this.applySpringForces = !0, this.applyDamping = !0, this.applyGravity = !0, this.solveConstraints = !0, this.contactMaterials = [], this.time = 0, this.accumulator = 0, this.stepping = !1, this.bodiesToBeRemoved = [], this.islandSplit = void 0 === t.islandSplit || !!t.islandSplit, this.emitImpactEvent = !0, this._constraintIdCounter = 0, this._bodyIdCounter = 0, this.postStepEvent = { type: "postStep" }, this.addBodyEvent = { type: "addBody", body: null }, this.removeBodyEvent = { type: "removeBody", body: null }, this.addSpringEvent = { type: "addSpring", spring: null }, this.impactEvent = { type: "impact", bodyA: null, bodyB: null, shapeA: null, shapeB: null, contactEquation: null }, this.postBroadphaseEvent = { type: "postBroadphase", pairs: null }, this.sleepMode = Y.NO_SLEEPING, this.beginContactEvent = { type: "beginContact", shapeA: null, shapeB: null, bodyA: null, bodyB: null, contactEquations: [] }, this.endContactEvent = { type: "endContact", shapeA: null, shapeB: null, bodyA: null, bodyB: null }, this.preSolveEvent = { type: "preSolve", contactEquations: null, frictionEquations: null }, this.overlappingShapesLastState = { keys: [] }, this.overlappingShapesCurrentState = { keys: [] }, this.overlapKeeper = new c }(((e.exports = Y).prototype = new Object(o.prototype)).constructor = Y).NO_SLEEPING = 1, Y.BODY_SLEEPING = 2, Y.ISLAND_SLEEPING = 4, Y.prototype.addConstraint = function(t) { this.constraints.push(t) }, Y.prototype.addContactMaterial = function(t) { this.contactMaterials.push(t) }, Y.prototype.removeContactMaterial = function(t) { var e = this.contactMaterials.indexOf(t); - 1 !== e && q.splice(this.contactMaterials, e, 1) }, Y.prototype.getContactMaterial = function(t, e) { for (var i = this.contactMaterials, s = 0, o = i.length; s !== o; s++) { var n = i[s]; if (n.materialA.id === t.id && n.materialB.id === e.id || n.materialA.id === e.id && n.materialB.id === t.id) return n } return !1 }, Y.prototype.removeConstraint = function(t) { var e = this.constraints.indexOf(t); - 1 !== e && q.splice(this.constraints, e, 1) };
|
|
j.create(), j.create(), j.create(), j.create(), j.create(), j.create();
|
|
var K = j.create(),
|
|
T = j.fromValues(0, 0),
|
|
S = j.fromValues(0, 0);
|
|
j.fromValues(0, 0), j.fromValues(0, 0);
|
|
Y.prototype.step = function(t, e, i) {
|
|
if (i = i || 10, 0 === (e = e || 0)) this.internalStep(t), this.time += t;
|
|
else {
|
|
this.accumulator += e;
|
|
for (var s = 0; this.accumulator >= t && s < i;) this.internalStep(t), this.time += t, this.accumulator -= t, s++;
|
|
for (var o = this.accumulator % t / t, n = 0; n !== this.bodies.length; n++) {
|
|
var a = this.bodies[n];
|
|
j.lerp(a.interpolatedPosition, a.previousPosition, a.position, o), a.interpolatedAngle = a.previousAngle + o * (a.angle - a.previousAngle)
|
|
}
|
|
}
|
|
};
|
|
var Q = [];
|
|
Y.prototype.internalStep = function(t) {
|
|
this.stepping = !0;
|
|
var e = this.springs.length,
|
|
i = this.springs,
|
|
s = this.bodies,
|
|
o = this.gravity,
|
|
n = this.solver,
|
|
a = this.bodies.length,
|
|
r = this.broadphase,
|
|
h = this.narrowphase,
|
|
l = this.constraints,
|
|
c = K,
|
|
p = (j.scale, j.add),
|
|
u = (j.rotate, this.islandManager);
|
|
if (this.overlapKeeper.tick(), this.lastTimeStep = t, this.useWorldGravityAsFrictionGravity) {
|
|
var d = j.length(this.gravity);
|
|
0 === d && this.useFrictionGravityOnZeroGravity || (this.frictionGravity = d)
|
|
}
|
|
if (this.applyGravity)
|
|
for (var y = 0; y !== a; y++) {
|
|
var g = (f = s[y]).force;
|
|
f.type === W.DYNAMIC && f.sleepState !== W.SLEEPING && (j.scale(c, o, f.mass * f.gravityScale), p(g, g, c))
|
|
}
|
|
if (this.applySpringForces)
|
|
for (y = 0; y !== e; y++) { i[y].applyForce() }
|
|
if (this.applyDamping)
|
|
for (y = 0; y !== a; y++) {
|
|
var f;
|
|
(f = s[y]).type === W.DYNAMIC && f.applyDamping(t)
|
|
}
|
|
var m = r.getCollisionPairs(this),
|
|
v = this.disabledBodyCollisionPairs;
|
|
for (y = v.length - 2; 0 <= y; y -= 2)
|
|
for (var x = m.length - 2; 0 <= x; x -= 2)(v[y] === m[x] && v[y + 1] === m[x + 1] || v[y + 1] === m[x] && v[y] === m[x + 1]) && m.splice(x, 2);
|
|
var b = l.length;
|
|
for (y = 0; y !== b; y++) {
|
|
var w = l[y];
|
|
if (!w.collideConnected)
|
|
for (x = m.length - 2; 0 <= x; x -= 2)(w.bodyA === m[x] && w.bodyB === m[x + 1] || w.bodyB === m[x] && w.bodyA === m[x + 1]) && m.splice(x, 2)
|
|
}
|
|
this.postBroadphaseEvent.pairs = m, this.emit(this.postBroadphaseEvent), this.postBroadphaseEvent.pairs = null, h.reset(this);
|
|
y = 0;
|
|
for (var P = m.length; y !== P; y += 2)
|
|
for (var _ = m[y], T = m[y + 1], S = 0, k = _.shapes.length; S !== k; S++)
|
|
for (var B = _.shapes[S], A = B.position, C = B.angle, I = 0, E = T.shapes.length; I !== E; I++) {
|
|
var O = T.shapes[I],
|
|
M = O.position,
|
|
L = O.angle,
|
|
R = this.defaultContactMaterial;
|
|
if (B.material && O.material) {
|
|
var D = this.getContactMaterial(B.material, O.material);
|
|
D && (R = D)
|
|
}
|
|
this.runNarrowphase(h, _, B, A, C, T, O, M, L, R, this.frictionGravity)
|
|
}
|
|
for (y = 0; y !== a; y++) {
|
|
(N = s[y])._wakeUpAfterNarrowphase && (N.wakeUp(), N._wakeUpAfterNarrowphase = !1)
|
|
}
|
|
if (this.has("endContact")) {
|
|
this.overlapKeeper.getEndOverlaps(Q);
|
|
var F = this.endContactEvent;
|
|
for (I = Q.length; I--;) {
|
|
var U = Q[I];
|
|
F.shapeA = U.shapeA, F.shapeB = U.shapeB, F.bodyA = U.bodyA, F.bodyB = U.bodyB, this.emit(F)
|
|
}
|
|
Q.length = 0
|
|
}
|
|
var G = this.preSolveEvent;
|
|
G.contactEquations = h.contactEquations, G.frictionEquations = h.frictionEquations, this.emit(G), G.contactEquations = G.frictionEquations = null;
|
|
b = l.length;
|
|
for (y = 0; y !== b; y++) l[y].update();
|
|
if (h.contactEquations.length || h.frictionEquations.length || b)
|
|
if (this.islandSplit) {
|
|
for (u.equations.length = 0, q.appendArray(u.equations, h.contactEquations), q.appendArray(u.equations, h.frictionEquations), y = 0; y !== b; y++) q.appendArray(u.equations, l[y].equations);
|
|
u.split(this);
|
|
for (y = 0; y !== u.islands.length; y++) {
|
|
(z = u.islands[y]).equations.length && n.solveIsland(t, z)
|
|
}
|
|
}
|
|
else {
|
|
for (n.addEquations(h.contactEquations), n.addEquations(h.frictionEquations), y = 0; y !== b; y++) n.addEquations(l[y].equations);
|
|
this.solveConstraints && n.solve(t, this), n.removeAllEquations()
|
|
}
|
|
for (y = 0; y !== a; y++) {
|
|
var N;
|
|
(N = s[y]).integrate(t)
|
|
}
|
|
for (y = 0; y !== a; y++) s[y].setZeroForce();
|
|
if (this.emitImpactEvent && this.has("impact")) {
|
|
var V = this.impactEvent;
|
|
for (y = 0; y !== h.contactEquations.length; y++) {
|
|
var H = h.contactEquations[y];
|
|
H.firstImpact && (V.bodyA = H.bodyA, V.bodyB = H.bodyB, V.shapeA = H.shapeA, V.shapeB = H.shapeB, V.contactEquation = H, this.emit(V))
|
|
}
|
|
}
|
|
if (this.sleepMode === Y.BODY_SLEEPING)
|
|
for (y = 0; y !== a; y++) s[y].sleepTick(this.time, !1, t);
|
|
else if (this.sleepMode === Y.ISLAND_SLEEPING && this.islandSplit) {
|
|
for (y = 0; y !== a; y++) s[y].sleepTick(this.time, !0, t);
|
|
for (y = 0; y < this.islandManager.islands.length; y++) {
|
|
var z;
|
|
(z = this.islandManager.islands[y]).wantsToSleep() && z.sleep()
|
|
}
|
|
}
|
|
this.stepping = !1;
|
|
var X = this.bodiesToBeRemoved;
|
|
for (y = 0; y !== X.length; y++) this.removeBody(X[y]);
|
|
X.length = 0, this.emit(this.postStepEvent)
|
|
}, Y.prototype.runNarrowphase = function(t, e, i, s, o, n, a, r, h, l, c) {
|
|
if (0 != (i.collisionGroup & a.collisionMask) && 0 != (a.collisionGroup & i.collisionMask)) {
|
|
j.rotate(T, s, e.angle), j.rotate(S, r, n.angle), j.add(T, T, e.position), j.add(S, S, n.position);
|
|
var p, u = o + e.angle,
|
|
d = h + n.angle;
|
|
t.enableFriction = 0 < l.friction, t.frictionCoefficient = l.friction, p = e.type === W.STATIC || e.type === W.KINEMATIC ? n.mass : n.type === W.STATIC || n.type === W.KINEMATIC ? e.mass : e.mass * n.mass / (e.mass + n.mass), t.slipForce = l.friction * c * p, t.restitution = l.restitution, t.surfaceVelocity = l.surfaceVelocity, t.frictionStiffness = l.frictionStiffness, t.frictionRelaxation = l.frictionRelaxation, t.stiffness = l.stiffness, t.relaxation = l.relaxation, t.contactSkinSize = l.contactSkinSize, t.enabledEquations = e.collisionResponse && n.collisionResponse && i.collisionResponse && a.collisionResponse;
|
|
var y = t[i.type | a.type],
|
|
g = 0;
|
|
if (y) {
|
|
var f = i.sensor || a.sensor,
|
|
m = t.frictionEquations.length;
|
|
g = i.type < a.type ? y.call(t, e, i, T, u, n, a, S, d, f) : y.call(t, n, a, S, d, e, i, T, u, f);
|
|
var v = t.frictionEquations.length - m;
|
|
if (g) {
|
|
if (e.allowSleep && e.type === W.DYNAMIC && e.sleepState === W.SLEEPING && n.sleepState === W.AWAKE && n.type !== W.STATIC) {
|
|
var x = j.squaredLength(n.velocity) + Math.pow(n.angularVelocity, 2);
|
|
2 * Math.pow(n.sleepSpeedLimit, 2) <= x && (e._wakeUpAfterNarrowphase = !0)
|
|
}
|
|
if (n.allowSleep && n.type === W.DYNAMIC && n.sleepState === W.SLEEPING && e.sleepState === W.AWAKE && e.type !== W.STATIC) {
|
|
var b = j.squaredLength(e.velocity) + Math.pow(e.angularVelocity, 2);
|
|
2 * Math.pow(e.sleepSpeedLimit, 2) <= b && (n._wakeUpAfterNarrowphase = !0)
|
|
}
|
|
if (this.overlapKeeper.setOverlapping(e, i, n, a), this.has("beginContact") && this.overlapKeeper.isNewOverlap(i, a)) {
|
|
var w = this.beginContactEvent;
|
|
if (w.shapeA = i, w.shapeB = a, w.bodyA = e, w.bodyB = n, w.contactEquations.length = 0, "number" == typeof g)
|
|
for (var P = t.contactEquations.length - g; P < t.contactEquations.length; P++) w.contactEquations.push(t.contactEquations[P]);
|
|
this.emit(w)
|
|
}
|
|
if ("number" == typeof g && 1 < v)
|
|
for (P = t.frictionEquations.length - v; P < t.frictionEquations.length; P++) {
|
|
var _ = t.frictionEquations[P];
|
|
_.setSlipForce(_.getSlipForce() / v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, Y.prototype.addSpring = function(t) {
|
|
this.springs.push(t);
|
|
var e = this.addSpringEvent;
|
|
e.spring = t, this.emit(e), e.spring = null
|
|
}, Y.prototype.removeSpring = function(t) { var e = this.springs.indexOf(t); - 1 !== e && q.splice(this.springs, e, 1) }, Y.prototype.addBody = function(t) {
|
|
if (-1 === this.bodies.indexOf(t)) {
|
|
this.bodies.push(t);
|
|
var e = (t.world = this).addBodyEvent;
|
|
e.body = t, this.emit(e), e.body = null
|
|
}
|
|
}, Y.prototype.removeBody = function(t) {
|
|
if (this.stepping) this.bodiesToBeRemoved.push(t);
|
|
else { t.world = null; var e = this.bodies.indexOf(t); - 1 !== e && (q.splice(this.bodies, e, 1), (this.removeBodyEvent.body = t).resetConstraintVelocity(), this.emit(this.removeBodyEvent), this.removeBodyEvent.body = null) }
|
|
}, Y.prototype.getBodyById = function(t) { for (var e = this.bodies, i = 0; i < e.length; i++) { var s = e[i]; if (s.id === t) return s } return !1 }, Y.prototype.disableBodyCollision = function(t, e) { this.disabledBodyCollisionPairs.push(t, e) }, Y.prototype.enableBodyCollision = function(t, e) {
|
|
for (var i = this.disabledBodyCollisionPairs, s = 0; s < i.length; s += 2)
|
|
if (i[s] === t && i[s + 1] === e || i[s + 1] === t && i[s] === e) return void i.splice(s, 2)
|
|
}, Y.prototype.clear = function() {
|
|
this.time = 0, this.solver && this.solver.equations.length && this.solver.removeAllEquations();
|
|
for (var t = this.constraints, e = t.length - 1; 0 <= e; e--) this.removeConstraint(t[e]);
|
|
var i = this.bodies;
|
|
for (e = i.length - 1; 0 <= e; e--) this.removeBody(i[e]);
|
|
var s = this.springs;
|
|
for (e = s.length - 1; 0 <= e; e--) this.removeSpring(s[e]);
|
|
var o = this.contactMaterials;
|
|
for (e = o.length - 1; 0 <= e; e--) this.removeContactMaterial(o[e]);
|
|
Y.apply(this)
|
|
};
|
|
var P = j.create(),
|
|
_ = (j.fromValues(0, 0), j.fromValues(0, 0));
|
|
Y.prototype.hitTest = function(t, e, i) {
|
|
i = i || 0;
|
|
var s = new W({ position: t }),
|
|
o = new w,
|
|
n = t,
|
|
a = P,
|
|
r = _;
|
|
s.addShape(o);
|
|
for (var h = this.narrowphase, l = [], c = 0, p = e.length; c !== p; c++)
|
|
for (var u = e[c], d = 0, y = u.shapes.length; d !== y; d++) {
|
|
var g = u.shapes[d];
|
|
j.rotate(a, g.position, u.angle), j.add(a, a, u.position);
|
|
var f = g.angle + u.angle;
|
|
(g instanceof m && h.circleParticle(u, g, a, f, s, o, n, 0, !0) || g instanceof v && h.particleConvex(s, o, n, 0, u, g, a, f, !0) || g instanceof x && h.particlePlane(s, o, n, 0, u, g, a, f, !0) || g instanceof b && h.particleCapsule(s, o, n, 0, u, g, a, f, !0) || g instanceof w && j.squaredLength(j.sub(r, a, t)) < i * i) && l.push(u)
|
|
}
|
|
return l
|
|
}, Y.prototype.setGlobalStiffness = function(t) {
|
|
for (var e = this.constraints, i = 0; i !== e.length; i++)
|
|
for (var s = e[i], o = 0; o !== s.equations.length; o++) {
|
|
var n = s.equations[o];
|
|
n.stiffness = t, n.needsUpdate = !0
|
|
}
|
|
var a = this.contactMaterials;
|
|
for (i = 0; i !== a.length; i++) {
|
|
(s = a[i]).stiffness = s.frictionStiffness = t
|
|
}(s = this.defaultContactMaterial).stiffness = s.frictionStiffness = t
|
|
}, Y.prototype.setGlobalRelaxation = function(t) {
|
|
for (var e = 0; e !== this.constraints.length; e++)
|
|
for (var i = this.constraints[e], s = 0; s !== i.equations.length; s++) {
|
|
var o = i.equations[s];
|
|
o.relaxation = t, o.needsUpdate = !0
|
|
}
|
|
for (e = 0; e !== this.contactMaterials.length; e++) {
|
|
(i = this.contactMaterials[e]).relaxation = i.frictionRelaxation = t
|
|
}(i = this.defaultContactMaterial).relaxation = i.frictionRelaxation = t
|
|
};
|
|
var u = new r,
|
|
d = [];
|
|
Y.prototype.raycast = function(t, e) { return e.getAABB(u), this.broadphase.aabbQuery(this, u, d), e.intersectBodies(t, d), d.length = 0, t.hasHit() }
|
|
}, { "../../package.json": 6, "../collision/AABB": 7, "../collision/Broadphase": 8, "../collision/Narrowphase": 10, "../collision/Ray": 11, "../collision/SAPBroadphase": 13, "../constraints/Constraint": 14, "../constraints/DistanceConstraint": 15, "../constraints/GearConstraint": 16, "../constraints/LockConstraint": 17, "../constraints/PrismaticConstraint": 18, "../constraints/RevoluteConstraint": 19, "../events/EventEmitter": 26, "../material/ContactMaterial": 27, "../material/Material": 28, "../math/vec2": 30, "../objects/Body": 31, "../objects/LinearSpring": 32, "../objects/RotationalSpring": 33, "../shapes/Capsule": 38, "../shapes/Circle": 39, "../shapes/Convex": 40, "../shapes/Line": 42, "../shapes/Particle": 43, "../shapes/Plane": 44, "../shapes/Shape": 45, "../solver/GSSolver": 46, "../solver/Solver": 47, "../utils/OverlapKeeper": 52, "../utils/Utils": 57, "./IslandManager": 59 }]
|
|
}, {}, [36])(36)
|
|
}),
|
|
function() {
|
|
var t = this,
|
|
L = L || {};
|
|
return L.game = null, L.WEBGL_RENDERER = 0, L.CANVAS_RENDERER = 1, L.VERSION = "v2.2.9", L._UID = 0, "undefined" != typeof Float32Array ? (L.Float32Array = Float32Array, L.Uint16Array = Uint16Array, L.Uint32Array = Uint32Array, L.ArrayBuffer = ArrayBuffer) : (L.Float32Array = Array, L.Uint16Array = Array), L.PI_2 = 2 * Math.PI, L.RAD_TO_DEG = 180 / Math.PI, L.DEG_TO_RAD = Math.PI / 180, L.RETINA_PREFIX = "@2x", L.DisplayObject = function() { this.position = new L.Point(0, 0), this.scale = new L.Point(1, 1), this.pivot = new L.Point(0, 0), this.rotation = 0, this.alpha = 1, this.visible = !0, this.hitArea = null, this.renderable = !1, this.parent = null, this.worldAlpha = 1, this.worldTransform = new L.Matrix, this.worldPosition = new L.Point(0, 0), this.worldScale = new L.Point(1, 1), this.worldRotation = 0, this.filterArea = null, this._sr = 0, this._cr = 1, this._bounds = new L.Rectangle(0, 0, 0, 0), this._currentBounds = null, this._mask = null, this._cacheAsBitmap = !1, this._cacheIsDirty = !1 }, L.DisplayObject.prototype.constructor = L.DisplayObject, L.DisplayObject.prototype = {
|
|
destroy: function() {
|
|
if (this.children) {
|
|
for (var t = this.children.length; t--;) this.children[t].destroy();
|
|
this.children = []
|
|
}
|
|
this.hitArea = null, this.parent = null, this.worldTransform = null, this.filterArea = null, this.renderable = !1, this._bounds = null, this._currentBounds = null, this._mask = null, this._destroyCachedSprite()
|
|
},
|
|
updateTransform: function(t) {
|
|
if (!t && !this.parent && !this.game) return this;
|
|
var e = this.parent;
|
|
t ? e = t : this.parent || (e = this.game.world);
|
|
var i, s, o, n, a, r, h = e.worldTransform,
|
|
l = this.worldTransform;
|
|
return this.rotation % L.PI_2 ? (this.rotation !== this.rotationCache && (this.rotationCache = this.rotation, this._sr = Math.sin(this.rotation), this._cr = Math.cos(this.rotation)), i = this._cr * this.scale.x, s = this._sr * this.scale.x, o = -this._sr * this.scale.y, n = this._cr * this.scale.y, a = this.position.x, r = this.position.y, (this.pivot.x || this.pivot.y) && (a -= this.pivot.x * i + this.pivot.y * o, r -= this.pivot.x * s + this.pivot.y * n), l.a = i * h.a + s * h.c, l.b = i * h.b + s * h.d, l.c = o * h.a + n * h.c, l.d = o * h.b + n * h.d) : (i = this.scale.x, n = this.scale.y, a = this.position.x - this.pivot.x * i, r = this.position.y - this.pivot.y * n, l.a = i * h.a, l.b = i * h.b, l.c = n * h.c, l.d = n * h.d), l.tx = a * h.a + r * h.c + h.tx, l.ty = a * h.b + r * h.d + h.ty, this.worldAlpha = this.alpha * e.worldAlpha, this.worldPosition.set(l.tx, l.ty), this.worldScale.set(this.scale.x * Math.sqrt(l.a * l.a + l.c * l.c), this.scale.y * Math.sqrt(l.b * l.b + l.d * l.d)), this.worldRotation = Math.atan2(-l.c, l.d), this._currentBounds = null, this.transformCallback && this.transformCallback.call(this.transformCallbackContext, l, h), this
|
|
},
|
|
preUpdate: function() {},
|
|
generateTexture: function(t, e, i) {
|
|
var s = this.getLocalBounds(),
|
|
o = new L.RenderTexture(0 | s.width, 0 | s.height, i, e, t);
|
|
return L.DisplayObject._tempMatrix.tx = -s.x, L.DisplayObject._tempMatrix.ty = -s.y, o.render(this, L.DisplayObject._tempMatrix), o
|
|
},
|
|
updateCache: function() { return this._generateCachedSprite(), this },
|
|
toGlobal: function(t) { return this.updateTransform(), this.worldTransform.apply(t) },
|
|
toLocal: function(t, e) { return e && (t = e.toGlobal(t)), this.updateTransform(), this.worldTransform.applyInverse(t) },
|
|
_renderCachedSprite: function(t) { this._cachedSprite.worldAlpha = this.worldAlpha, t.gl ? L.Sprite.prototype._renderWebGL.call(this._cachedSprite, t) : L.Sprite.prototype._renderCanvas.call(this._cachedSprite, t) },
|
|
_generateCachedSprite: function() {
|
|
this._cacheAsBitmap = !1;
|
|
var t = this.getLocalBounds();
|
|
if (t.width = Math.max(1, Math.ceil(t.width)), t.height = Math.max(1, Math.ceil(t.height)), this.updateTransform(), this._cachedSprite) this._cachedSprite.texture.resize(t.width, t.height);
|
|
else {
|
|
var e = new L.RenderTexture(t.width, t.height);
|
|
this._cachedSprite = new L.Sprite(e), this._cachedSprite.worldTransform = this.worldTransform
|
|
}
|
|
var i = this._filters;
|
|
this._filters = null, this._cachedSprite.filters = i, L.DisplayObject._tempMatrix.tx = -t.x, L.DisplayObject._tempMatrix.ty = -t.y, this._cachedSprite.texture.render(this, L.DisplayObject._tempMatrix, !0), this._cachedSprite.anchor.x = -t.x / t.width, this._cachedSprite.anchor.y = -t.y / t.height, this._filters = i, this._cacheAsBitmap = !0
|
|
},
|
|
_destroyCachedSprite: function() { this._cachedSprite && (this._cachedSprite.texture.destroy(!0), this._cachedSprite = null) }
|
|
}, L.DisplayObject.prototype.displayObjectUpdateTransform = L.DisplayObject.prototype.updateTransform, Object.defineProperties(L.DisplayObject.prototype, {
|
|
x: { get: function() { return this.position.x }, set: function(t) { this.position.x = t } },
|
|
y: { get: function() { return this.position.y }, set: function(t) { this.position.y = t } },
|
|
worldVisible: {
|
|
get: function() {
|
|
if (this.visible) {
|
|
var t = this.parent;
|
|
if (!t) return this.visible;
|
|
do {
|
|
if (!t.visible) return !1;
|
|
t = t.parent
|
|
} while (t);
|
|
return !0
|
|
}
|
|
return !1
|
|
}
|
|
},
|
|
mask: { get: function() { return this._mask }, set: function(t) { this._mask && (this._mask.isMask = !1), (this._mask = t) && (this._mask.isMask = !0) } },
|
|
filters: {
|
|
get: function() { return this._filters },
|
|
set: function(t) {
|
|
if (Array.isArray(t)) {
|
|
for (var e = [], i = 0; i < t.length; i++)
|
|
for (var s = t[i].passes, o = 0; o < s.length; o++) e.push(s[o]);
|
|
this._filterBlock = { target: this, filterPasses: e }
|
|
}
|
|
this._filters = t, this.blendMode && this.blendMode === L.blendModes.MULTIPLY && (this.blendMode = L.blendModes.NORMAL)
|
|
}
|
|
},
|
|
cacheAsBitmap: { get: function() { return this._cacheAsBitmap }, set: function(t) { this._cacheAsBitmap !== t && (t ? this._generateCachedSprite() : this._destroyCachedSprite(), this._cacheAsBitmap = t) } }
|
|
}), L.DisplayObjectContainer = function() { L.DisplayObject.call(this), this.children = [], this.ignoreChildInput = !1 }, L.DisplayObjectContainer.prototype = Object.create(L.DisplayObject.prototype), L.DisplayObjectContainer.prototype.constructor = L.DisplayObjectContainer, L.DisplayObjectContainer.prototype.addChild = function(t) { return this.addChildAt(t, this.children.length) }, L.DisplayObjectContainer.prototype.addChildAt = function(t, e) { if (0 <= e && e <= this.children.length) return t.parent && t.parent.removeChild(t), (t.parent = this).children.splice(e, 0, t), t; throw new Error(t + "addChildAt: The index " + e + " supplied is out of bounds " + this.children.length) }, L.DisplayObjectContainer.prototype.swapChildren = function(t, e) {
|
|
if (t !== e) {
|
|
var i = this.getChildIndex(t),
|
|
s = this.getChildIndex(e);
|
|
if (i < 0 || s < 0) throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");
|
|
this.children[i] = e, this.children[s] = t
|
|
}
|
|
}, L.DisplayObjectContainer.prototype.getChildIndex = function(t) { var e = this.children.indexOf(t); if (-1 === e) throw new Error("The supplied DisplayObject must be a child of the caller"); return e }, L.DisplayObjectContainer.prototype.setChildIndex = function(t, e) {
|
|
if (e < 0 || e >= this.children.length) throw new Error("The supplied index is out of bounds");
|
|
var i = this.getChildIndex(t);
|
|
this.children.splice(i, 1), this.children.splice(e, 0, t)
|
|
}, L.DisplayObjectContainer.prototype.getChildAt = function(t) { if (t < 0 || t >= this.children.length) throw new Error("getChildAt: Supplied index " + t + " does not exist in the child list, or the supplied DisplayObject must be a child of the caller"); return this.children[t] }, L.DisplayObjectContainer.prototype.removeChild = function(t) { var e = this.children.indexOf(t); if (-1 !== e) return this.removeChildAt(e) }, L.DisplayObjectContainer.prototype.removeChildAt = function(t) { var e = this.getChildAt(t); return e && (e.parent = void 0, this.children.splice(t, 1)), e }, L.DisplayObjectContainer.prototype.removeChildren = function(t, e) { void 0 === t && (t = 0), void 0 === e && (e = this.children.length); var i = e - t; if (0 < i && i <= e) { for (var s = this.children.splice(begin, i), o = 0; o < s.length; o++) { s[o].parent = void 0 } return s } if (0 === i && 0 === this.children.length) return []; throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range") }, L.DisplayObjectContainer.prototype.updateTransform = function() {
|
|
if (this.visible && (this.displayObjectUpdateTransform(), !this._cacheAsBitmap))
|
|
for (var t = 0; t < this.children.length; t++) this.children[t].updateTransform()
|
|
}, L.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform = L.DisplayObjectContainer.prototype.updateTransform, L.DisplayObjectContainer.prototype.getBounds = function(t) {
|
|
var e, i = t && t instanceof L.DisplayObject,
|
|
s = !0;
|
|
if (i ? s = t instanceof L.DisplayObjectContainer && t.contains(this) : t = this, i) { var o = t.worldTransform; for (t.worldTransform = L.identityMatrix, e = 0; e < t.children.length; e++) t.children[e].updateTransform() }
|
|
var n, a, r, h = 1 / 0,
|
|
l = 1 / 0,
|
|
c = -1 / 0,
|
|
p = -1 / 0,
|
|
u = !1;
|
|
for (e = 0; e < this.children.length; e++) { this.children[e].visible && (u = !0, h = h < (n = this.children[e].getBounds()).x ? h : n.x, l = l < n.y ? l : n.y, c = (a = n.width + n.x) < c ? c : a, p = (r = n.height + n.y) < p ? p : r) }
|
|
var d = this._bounds;
|
|
if (!u) {
|
|
var y = (d = new L.Rectangle).x,
|
|
g = d.width + d.x,
|
|
f = d.y,
|
|
m = d.height + d.y,
|
|
v = this.worldTransform,
|
|
x = v.a,
|
|
b = v.b,
|
|
w = v.c,
|
|
P = v.d,
|
|
_ = v.tx,
|
|
T = v.ty,
|
|
S = x * g + w * m + _,
|
|
k = P * m + b * g + T,
|
|
B = x * y + w * m + _,
|
|
A = P * m + b * y + T,
|
|
C = x * y + w * f + _,
|
|
I = P * f + b * y + T,
|
|
E = x * g + w * f + _,
|
|
O = P * f + b * g + T;
|
|
h = E < (h = C < (h = B < (h = c = S) ? B : h) ? C : h) ? E : h, l = O < (l = I < (l = A < (l = p = k) ? A : l) ? I : l) ? O : l, c = (c = (c = c < B ? B : c) < C ? C : c) < E ? E : c, p = (p = (p = p < A ? A : p) < I ? I : p) < O ? O : p
|
|
}
|
|
if (d.x = h, d.y = l, d.width = c - h, d.height = p - l, i)
|
|
for (t.worldTransform = o, e = 0; e < t.children.length; e++) t.children[e].updateTransform();
|
|
if (!s) {
|
|
var M = t.getBounds();
|
|
d.x -= M.x, d.y -= M.y
|
|
}
|
|
return d
|
|
}, L.DisplayObjectContainer.prototype.getLocalBounds = function() { return this.getBounds(this) }, L.DisplayObjectContainer.prototype.contains = function(t) { return !!t && (t === this || this.contains(t.parent)) }, L.DisplayObjectContainer.prototype._renderWebGL = function(t) {
|
|
var e;
|
|
if (this.visible && !(this.alpha <= 0))
|
|
if (this._cacheAsBitmap) this._renderCachedSprite(t);
|
|
else if (this._mask || this._filters) {
|
|
for (this._filters && (t.spriteBatch.flush(), t.filterManager.pushFilter(this._filterBlock)), this._mask && (t.spriteBatch.stop(), t.maskManager.pushMask(this.mask, t), t.spriteBatch.start()), e = 0; e < this.children.length; e++) this.children[e]._renderWebGL(t);
|
|
t.spriteBatch.stop(), this._mask && t.maskManager.popMask(this._mask, t), this._filters && t.filterManager.popFilter(), t.spriteBatch.start()
|
|
}
|
|
else
|
|
for (e = 0; e < this.children.length; e++) this.children[e]._renderWebGL(t)
|
|
}, L.DisplayObjectContainer.prototype._renderCanvas = function(t) {
|
|
if (!1 !== this.visible && 0 !== this.alpha)
|
|
if (this._cacheAsBitmap) this._renderCachedSprite(t);
|
|
else {
|
|
this._mask && t.maskManager.pushMask(this._mask, t);
|
|
for (var e = 0; e < this.children.length; e++) this.children[e]._renderCanvas(t);
|
|
this._mask && t.maskManager.popMask(t)
|
|
}
|
|
}, Object.defineProperty(L.DisplayObjectContainer.prototype, "width", {
|
|
get: function() { return this.getLocalBounds().width * this.scale.x },
|
|
set: function(t) {
|
|
var e = this.getLocalBounds().width;
|
|
this.scale.x = 0 !== e ? t / e : 1, this._width = t
|
|
}
|
|
}), Object.defineProperty(L.DisplayObjectContainer.prototype, "height", {
|
|
get: function() { return this.getLocalBounds().height * this.scale.y },
|
|
set: function(t) {
|
|
var e = this.getLocalBounds().height;
|
|
this.scale.y = 0 !== e ? t / e : 1, this._height = t
|
|
}
|
|
}), L.Sprite = function(t) { L.DisplayObjectContainer.call(this), this.anchor = new L.Point, this.texture = t || L.Texture.emptyTexture, this._width = 0, this._height = 0, this.tint = 16777215, this.cachedTint = -1, this.tintedTexture = null, this.blendMode = L.blendModes.NORMAL, this.shader = null, this.exists = !0, this.texture.baseTexture.hasLoaded && this.onTextureUpdate(), this.renderable = !0 }, L.Sprite.prototype = Object.create(L.DisplayObjectContainer.prototype), L.Sprite.prototype.constructor = L.Sprite, Object.defineProperty(L.Sprite.prototype, "width", { get: function() { return this.scale.x * this.texture.frame.width }, set: function(t) { this.scale.x = t / this.texture.frame.width, this._width = t } }), Object.defineProperty(L.Sprite.prototype, "height", { get: function() { return this.scale.y * this.texture.frame.height }, set: function(t) { this.scale.y = t / this.texture.frame.height, this._height = t } }), L.Sprite.prototype.setTexture = function(t, e) { void 0 !== e && this.texture.baseTexture.destroy(), this.texture.baseTexture.skipRender = !1, this.texture = t, this.texture.valid = !0, this.cachedTint = -1 }, L.Sprite.prototype.onTextureUpdate = function() { this._width && (this.scale.x = this._width / this.texture.frame.width), this._height && (this.scale.y = this._height / this.texture.frame.height) }, L.Sprite.prototype.getBounds = function(t) {
|
|
var e = this.texture.frame.width,
|
|
i = this.texture.frame.height,
|
|
s = e * (1 - this.anchor.x),
|
|
o = e * -this.anchor.x,
|
|
n = i * (1 - this.anchor.y),
|
|
a = i * -this.anchor.y,
|
|
r = t || this.worldTransform,
|
|
h = r.a,
|
|
l = r.b,
|
|
c = r.c,
|
|
p = r.d,
|
|
u = r.tx,
|
|
d = r.ty,
|
|
y = -1 / 0,
|
|
g = -1 / 0,
|
|
f = 1 / 0,
|
|
m = 1 / 0;
|
|
if (0 === l && 0 === c) {
|
|
if (h < 0) {
|
|
h *= -1;
|
|
var v = s;
|
|
s = -o, o = -v
|
|
}
|
|
if (p < 0) {
|
|
p *= -1;
|
|
v = n;
|
|
n = -a, a = -v
|
|
}
|
|
f = h * o + u, y = h * s + u, m = p * a + d, g = p * n + d
|
|
}
|
|
else {
|
|
var x = h * o + c * a + u,
|
|
b = p * a + l * o + d,
|
|
w = h * s + c * a + u,
|
|
P = p * a + l * s + d,
|
|
_ = h * s + c * n + u,
|
|
T = p * n + l * s + d,
|
|
S = h * o + c * n + u,
|
|
k = p * n + l * o + d;
|
|
f = S < (f = _ < (f = w < (f = x < f ? x : f) ? w : f) ? _ : f) ? S : f, m = k < (m = T < (m = P < (m = b < m ? b : m) ? P : m) ? T : m) ? k : m, y = (y = (y = (y = y < x ? x : y) < w ? w : y) < _ ? _ : y) < S ? S : y, g = (g = (g = (g = g < b ? b : g) < P ? P : g) < T ? T : g) < k ? k : g
|
|
}
|
|
var B = this._bounds;
|
|
return B.x = f, B.width = y - f, B.y = m, B.height = g - m, this._currentBounds = B
|
|
}, L.Sprite.prototype.getLocalBounds = function() {
|
|
var t = this.worldTransform;
|
|
this.worldTransform = L.identityMatrix;
|
|
for (var e = 0; e < this.children.length; e++) this.children[e].updateTransform();
|
|
var i = this.getBounds();
|
|
for (this.worldTransform = t, e = 0; e < this.children.length; e++) this.children[e].updateTransform();
|
|
return i
|
|
}, L.Sprite.prototype._renderWebGL = function(t, e) {
|
|
if (this.visible && !(this.alpha <= 0) && this.renderable) {
|
|
var i = this.worldTransform;
|
|
if (e && (i = e), this._mask || this._filters) {
|
|
var s = t.spriteBatch;
|
|
this._filters && (s.flush(), t.filterManager.pushFilter(this._filterBlock)), this._mask && (s.stop(), t.maskManager.pushMask(this.mask, t), s.start()), s.render(this);
|
|
for (var o = 0; o < this.children.length; o++) this.children[o]._renderWebGL(t);
|
|
s.stop(), this._mask && t.maskManager.popMask(this._mask, t), this._filters && t.filterManager.popFilter(), s.start()
|
|
}
|
|
else { t.spriteBatch.render(this); for (o = 0; o < this.children.length; o++) this.children[o]._renderWebGL(t, i) }
|
|
}
|
|
}, L.Sprite.prototype._renderCanvas = function(t, e) {
|
|
if (!(!this.visible || 0 === this.alpha || !this.renderable || this.texture.crop.width <= 0 || this.texture.crop.height <= 0)) {
|
|
var i = this.worldTransform;
|
|
if (e && (i = e), this.blendMode !== t.currentBlendMode && (t.currentBlendMode = this.blendMode, t.context.globalCompositeOperation = L.blendModesCanvas[t.currentBlendMode]), this._mask && t.maskManager.pushMask(this._mask, t), this.texture.valid) {
|
|
var s = this.texture.baseTexture.resolution / t.resolution;
|
|
t.context.globalAlpha = this.worldAlpha, t.smoothProperty && t.scaleMode !== this.texture.baseTexture.scaleMode && (t.scaleMode = this.texture.baseTexture.scaleMode, t.context[t.smoothProperty] = t.scaleMode === L.scaleModes.LINEAR);
|
|
var o = this.texture.trim ? this.texture.trim.x - this.anchor.x * this.texture.trim.width : this.anchor.x * -this.texture.frame.width,
|
|
n = this.texture.trim ? this.texture.trim.y - this.anchor.y * this.texture.trim.height : this.anchor.y * -this.texture.frame.height,
|
|
a = i.tx * t.resolution + t.shakeX,
|
|
r = i.ty * t.resolution + t.shakeY;
|
|
t.roundPixels ? (t.context.setTransform(i.a, i.b, i.c, i.d, 0 | a, 0 | r), o |= 0, n |= 0) : t.context.setTransform(i.a, i.b, i.c, i.d, a, r);
|
|
var h = this.texture.crop.width,
|
|
l = this.texture.crop.height;
|
|
if (o /= s, n /= s, 16777215 !== this.tint)(this.texture.requiresReTint || this.cachedTint !== this.tint) && (this.tintedTexture = L.CanvasTinter.getTintedTexture(this, this.tint), this.cachedTint = this.tint, this.texture.requiresReTint = !1), t.context.drawImage(this.tintedTexture, 0, 0, h, l, o, n, h / s, l / s);
|
|
else {
|
|
var c = this.texture.crop.x,
|
|
p = this.texture.crop.y;
|
|
t.context.drawImage(this.texture.baseTexture.source, c, p, h, l, o, n, h / s, l / s)
|
|
}
|
|
}
|
|
for (var u = 0; u < this.children.length; u++) this.children[u]._renderCanvas(t);
|
|
this._mask && t.maskManager.popMask(t)
|
|
}
|
|
}, L.SpriteBatch = function(t) { L.DisplayObjectContainer.call(this), this.textureThing = t, this.ready = !1 }, L.SpriteBatch.prototype = Object.create(L.DisplayObjectContainer.prototype), L.SpriteBatch.prototype.constructor = L.SpriteBatch, L.SpriteBatch.prototype.initWebGL = function(t) { this.fastSpriteBatch = new L.WebGLFastSpriteBatch(t), this.ready = !0 }, L.SpriteBatch.prototype.updateTransform = function() { this.displayObjectUpdateTransform() }, L.SpriteBatch.prototype._renderWebGL = function(t) {!this.visible || this.alpha <= 0 || !this.children.length || (this.ready || this.initWebGL(t.gl), this.fastSpriteBatch.gl !== t.gl && this.fastSpriteBatch.setContext(t.gl), t.spriteBatch.stop(), t.shaderManager.setShader(t.shaderManager.fastShader), this.fastSpriteBatch.begin(this, t), this.fastSpriteBatch.render(this), t.spriteBatch.start()) }, L.SpriteBatch.prototype._renderCanvas = function(t) {
|
|
if (this.visible && !(this.alpha <= 0) && this.children.length) {
|
|
var e = t.context;
|
|
e.globalAlpha = this.worldAlpha, this.displayObjectUpdateTransform();
|
|
for (var i = this.worldTransform, s = !0, o = 0; o < this.children.length; o++) {
|
|
var n = this.children[o];
|
|
if (n.visible) {
|
|
var a = n.texture,
|
|
r = a.frame;
|
|
if (e.globalAlpha = this.worldAlpha * n.alpha, n.rotation % (2 * Math.PI) == 0) s && (e.setTransform(i.a, i.b, i.c, i.d, i.tx, i.ty), s = !1), e.drawImage(a.baseTexture.source, r.x, r.y, r.width, r.height, n.anchor.x * (-r.width * n.scale.x) + n.position.x + .5 + t.shakeX | 0, n.anchor.y * (-r.height * n.scale.y) + n.position.y + .5 + t.shakeY | 0, r.width * n.scale.x, r.height * n.scale.y);
|
|
else {
|
|
s || (s = !0), n.displayObjectUpdateTransform();
|
|
var h = n.worldTransform,
|
|
l = h.tx * t.resolution + t.shakeX,
|
|
c = h.ty * t.resolution + t.shakeY;
|
|
t.roundPixels ? e.setTransform(h.a, h.b, h.c, h.d, 0 | l, 0 | c) : e.setTransform(h.a, h.b, h.c, h.d, l, c), e.drawImage(a.baseTexture.source, r.x, r.y, r.width, r.height, n.anchor.x * -r.width + .5 | 0, n.anchor.y * -r.height + .5 | 0, r.width, r.height)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, L.hex2rgb = function(t) { return [(t >> 16 & 255) / 255, (t >> 8 & 255) / 255, (255 & t) / 255] }, L.rgb2hex = function(t) { return (255 * t[0] << 16) + (255 * t[1] << 8) + 255 * t[2] }, L.canUseNewCanvasBlendModes = function() {
|
|
if (void 0 === document) return !1;
|
|
var t = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",
|
|
e = "AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",
|
|
i = new Image;
|
|
i.src = t + "AP804Oa6" + e;
|
|
var s = new Image;
|
|
s.src = t + "/wCKxvRF" + e;
|
|
var o = L.CanvasPool.create(this, 6, 1).getContext("2d");
|
|
if (o.globalCompositeOperation = "multiply", o.drawImage(i, 0, 0), o.drawImage(s, 2, 0), !o.getImageData(2, 0, 1, 1)) return !1;
|
|
var n = o.getImageData(2, 0, 1, 1).data;
|
|
return L.CanvasPool.remove(this), 255 === n[0] && 0 === n[1] && 0 === n[2]
|
|
}, L.getNextPowerOfTwo = function(t) { if (0 < t && 0 == (t & t - 1)) return t; for (var e = 1; e < t;) e <<= 1; return e }, L.isPowerOfTwo = function(t, e) { return 0 < t && 0 == (t & t - 1) && 0 < e && 0 == (e & e - 1) }, L.CanvasPool = {
|
|
create: function(t, e, i) {
|
|
var s, o = L.CanvasPool.getFirst();
|
|
if (-1 === o) {
|
|
var n = { parent: t, canvas: document.createElement("canvas") };
|
|
L.CanvasPool.pool.push(n), s = n.canvas
|
|
}
|
|
else L.CanvasPool.pool[o].parent = t, s = L.CanvasPool.pool[o].canvas;
|
|
return void 0 !== e && (s.width = e, s.height = i), s
|
|
},
|
|
getFirst: function() {
|
|
for (var t = L.CanvasPool.pool, e = 0; e < t.length; e++)
|
|
if (!t[e].parent) return e;
|
|
return -1
|
|
},
|
|
remove: function(t) { for (var e = L.CanvasPool.pool, i = 0; i < e.length; i++) e[i].parent === t && (e[i].parent = null, e[i].canvas.width = 1, e[i].canvas.height = 1) },
|
|
removeByCanvas: function(t) { for (var e = L.CanvasPool.pool, i = 0; i < e.length; i++) e[i].canvas === t && (e[i].parent = null, e[i].canvas.width = 1, e[i].canvas.height = 1) },
|
|
getTotal: function() { for (var t = L.CanvasPool.pool, e = 0, i = 0; i < t.length; i++) t[i].parent && e++; return e },
|
|
getFree: function() { for (var t = L.CanvasPool.pool, e = 0, i = 0; i < t.length; i++) t[i].parent || e++; return e }
|
|
}, L.CanvasPool.pool = [], L.initDefaultShaders = function() {}, L.CompileVertexShader = function(t, e) { return L._CompileShader(t, e, t.VERTEX_SHADER) }, L.CompileFragmentShader = function(t, e) { return L._CompileShader(t, e, t.FRAGMENT_SHADER) }, L._CompileShader = function(t, e, i) {
|
|
var s = e;
|
|
Array.isArray(e) && (s = e.join("\n"));
|
|
var o = t.createShader(i);
|
|
return t.shaderSource(o, s), t.compileShader(o), t.getShaderParameter(o, t.COMPILE_STATUS) ? o : (window.console.log(t.getShaderInfoLog(o)), null)
|
|
}, L.compileProgram = function(t, e, i) {
|
|
var s = L.CompileFragmentShader(t, i),
|
|
o = L.CompileVertexShader(t, e),
|
|
n = t.createProgram();
|
|
return t.attachShader(n, o), t.attachShader(n, s), t.linkProgram(n), t.getProgramParameter(n, t.LINK_STATUS) || (window.console.log(t.getProgramInfoLog(n)), window.console.log("Could not initialise shaders")), n
|
|
}, L.PixiShader = function(t) { this._UID = L._UID++, this.gl = t, this.program = null, this.fragmentSrc = ["precision lowp float;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"], this.textureCount = 0, this.firstRun = !0, this.dirty = !0, this.attributes = [], this.init() }, L.PixiShader.prototype.constructor = L.PixiShader, L.PixiShader.prototype.init = function() {
|
|
var t = this.gl,
|
|
e = L.compileProgram(t, this.vertexSrc || L.PixiShader.defaultVertexSrc, this.fragmentSrc);
|
|
for (var i in t.useProgram(e), this.uSampler = t.getUniformLocation(e, "uSampler"), this.projectionVector = t.getUniformLocation(e, "projectionVector"), this.offsetVector = t.getUniformLocation(e, "offsetVector"), this.dimensions = t.getUniformLocation(e, "dimensions"), this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"), this.aTextureCoord = t.getAttribLocation(e, "aTextureCoord"), this.colorAttribute = t.getAttribLocation(e, "aColor"), -1 === this.colorAttribute && (this.colorAttribute = 2), this.attributes = [this.aVertexPosition, this.aTextureCoord, this.colorAttribute], this.uniforms) this.uniforms[i].uniformLocation = t.getUniformLocation(e, i);
|
|
this.initUniforms(), this.program = e
|
|
}, L.PixiShader.prototype.initUniforms = function() { this.textureCount = 1; var t, e = this.gl; for (var i in this.uniforms) { var s = (t = this.uniforms[i]).type; "sampler2D" === s ? (t._init = !1, null !== t.value && this.initSampler2D(t)) : "mat2" === s || "mat3" === s || "mat4" === s ? (t.glMatrix = !0, t.glValueLength = 1, "mat2" === s ? t.glFunc = e.uniformMatrix2fv : "mat3" === s ? t.glFunc = e.uniformMatrix3fv : "mat4" === s && (t.glFunc = e.uniformMatrix4fv)) : (t.glFunc = e["uniform" + s], t.glValueLength = "2f" === s || "2i" === s ? 2 : "3f" === s || "3i" === s ? 3 : "4f" === s || "4i" === s ? 4 : 1) } }, L.PixiShader.prototype.initSampler2D = function(t) {
|
|
if (t.value && t.value.baseTexture && t.value.baseTexture.hasLoaded) {
|
|
var e = this.gl;
|
|
if (e.activeTexture(e["TEXTURE" + this.textureCount]), e.bindTexture(e.TEXTURE_2D, t.value.baseTexture._glTextures[e.id]), t.textureData) {
|
|
var i = t.textureData,
|
|
s = i.magFilter ? i.magFilter : e.LINEAR,
|
|
o = i.minFilter ? i.minFilter : e.LINEAR,
|
|
n = i.wrapS ? i.wrapS : e.CLAMP_TO_EDGE,
|
|
a = i.wrapT ? i.wrapT : e.CLAMP_TO_EDGE,
|
|
r = i.luminance ? e.LUMINANCE : e.RGBA;
|
|
if (i.repeat && (n = e.REPEAT, a = e.REPEAT), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !!i.flipY), i.width) {
|
|
var h = i.width ? i.width : 512,
|
|
l = i.height ? i.height : 2,
|
|
c = i.border ? i.border : 0;
|
|
e.texImage2D(e.TEXTURE_2D, 0, r, h, l, c, r, e.UNSIGNED_BYTE, null)
|
|
}
|
|
else e.texImage2D(e.TEXTURE_2D, 0, r, e.RGBA, e.UNSIGNED_BYTE, t.value.baseTexture.source);
|
|
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, s), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, o), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, n), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, a)
|
|
}
|
|
e.uniform1i(t.uniformLocation, this.textureCount), t._init = !0, this.textureCount++
|
|
}
|
|
}, L.PixiShader.prototype.syncUniforms = function() {
|
|
var t;
|
|
this.textureCount = 1;
|
|
var e = this.gl;
|
|
for (var i in this.uniforms) 1 === (t = this.uniforms[i]).glValueLength ? !0 === t.glMatrix ? t.glFunc.call(e, t.uniformLocation, t.transpose, t.value) : t.glFunc.call(e, t.uniformLocation, t.value) : 2 === t.glValueLength ? t.glFunc.call(e, t.uniformLocation, t.value.x, t.value.y) : 3 === t.glValueLength ? t.glFunc.call(e, t.uniformLocation, t.value.x, t.value.y, t.value.z) : 4 === t.glValueLength ? t.glFunc.call(e, t.uniformLocation, t.value.x, t.value.y, t.value.z, t.value.w) : "sampler2D" === t.type && (t._init ? (e.activeTexture(e["TEXTURE" + this.textureCount]), t.value.baseTexture._dirty[e.id] ? L.instances[e.id].updateTexture(t.value.baseTexture) : e.bindTexture(e.TEXTURE_2D, t.value.baseTexture._glTextures[e.id]), e.uniform1i(t.uniformLocation, this.textureCount), this.textureCount++) : this.initSampler2D(t))
|
|
}, L.PixiShader.prototype.destroy = function() { this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null }, L.PixiShader.defaultVertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "attribute vec4 aColor;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "const vec2 center = vec2(-1.0, 1.0);", "void main(void) {", " gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", " vColor = vec4(aColor.rgb * aColor.a, aColor.a);", "}"], L.PixiFastShader = function(t) { this._UID = L._UID++, this.gl = t, this.program = null, this.fragmentSrc = ["precision lowp float;", "varying vec2 vTextureCoord;", "varying float vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aPositionCoord;", "attribute vec2 aScale;", "attribute float aRotation;", "attribute vec2 aTextureCoord;", "attribute float aColor;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform mat3 uMatrix;", "varying vec2 vTextureCoord;", "varying float vColor;", "const vec2 center = vec2(-1.0, 1.0);", "void main(void) {", " vec2 v;", " vec2 sv = aVertexPosition * aScale;", " v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);", " v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);", " v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;", " gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", " vColor = aColor;", "}"], this.textureCount = 0, this.init() }, L.PixiFastShader.prototype.constructor = L.PixiFastShader, L.PixiFastShader.prototype.init = function() {
|
|
var t = this.gl,
|
|
e = L.compileProgram(t, this.vertexSrc, this.fragmentSrc);
|
|
t.useProgram(e), this.uSampler = t.getUniformLocation(e, "uSampler"), this.projectionVector = t.getUniformLocation(e, "projectionVector"), this.offsetVector = t.getUniformLocation(e, "offsetVector"), this.dimensions = t.getUniformLocation(e, "dimensions"), this.uMatrix = t.getUniformLocation(e, "uMatrix"), this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"), this.aPositionCoord = t.getAttribLocation(e, "aPositionCoord"), this.aScale = t.getAttribLocation(e, "aScale"), this.aRotation = t.getAttribLocation(e, "aRotation"), this.aTextureCoord = t.getAttribLocation(e, "aTextureCoord"), this.colorAttribute = t.getAttribLocation(e, "aColor"), -1 === this.colorAttribute && (this.colorAttribute = 2), this.attributes = [this.aVertexPosition, this.aPositionCoord, this.aScale, this.aRotation, this.aTextureCoord, this.colorAttribute], this.program = e
|
|
}, L.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null }, L.StripShader = function(t) { this._UID = L._UID++, this.gl = t, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec2 vTextureCoord;", "uniform float alpha;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec2 aTextureCoord;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", " vTextureCoord = aTextureCoord;", "}"], this.init() }, L.StripShader.prototype.constructor = L.StripShader, L.StripShader.prototype.init = function() {
|
|
var t = this.gl,
|
|
e = L.compileProgram(t, this.vertexSrc, this.fragmentSrc);
|
|
t.useProgram(e), this.uSampler = t.getUniformLocation(e, "uSampler"), this.projectionVector = t.getUniformLocation(e, "projectionVector"), this.offsetVector = t.getUniformLocation(e, "offsetVector"), this.colorAttribute = t.getAttribLocation(e, "aColor"), this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"), this.aTextureCoord = t.getAttribLocation(e, "aTextureCoord"), this.attributes = [this.aVertexPosition, this.aTextureCoord], this.translationMatrix = t.getUniformLocation(e, "translationMatrix"), this.alpha = t.getUniformLocation(e, "alpha"), this.program = e
|
|
}, L.StripShader.prototype.destroy = function() { this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null }, L.PrimitiveShader = function(t) { this._UID = L._UID++, this.gl = t, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "attribute vec4 aColor;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform float alpha;", "uniform float flipY;", "uniform vec3 tint;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);", " vColor = aColor * vec4(tint * alpha, alpha);", "}"], this.init() }, L.PrimitiveShader.prototype.constructor = L.PrimitiveShader, L.PrimitiveShader.prototype.init = function() {
|
|
var t = this.gl,
|
|
e = L.compileProgram(t, this.vertexSrc, this.fragmentSrc);
|
|
t.useProgram(e), this.projectionVector = t.getUniformLocation(e, "projectionVector"), this.offsetVector = t.getUniformLocation(e, "offsetVector"), this.tintColor = t.getUniformLocation(e, "tint"), this.flipY = t.getUniformLocation(e, "flipY"), this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"), this.colorAttribute = t.getAttribLocation(e, "aColor"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = t.getUniformLocation(e, "translationMatrix"), this.alpha = t.getUniformLocation(e, "alpha"), this.program = e
|
|
}, L.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attributes = null }, L.ComplexPrimitiveShader = function(t) { this._UID = L._UID++, this.gl = t, this.program = null, this.fragmentSrc = ["precision mediump float;", "varying vec4 vColor;", "void main(void) {", " gl_FragColor = vColor;", "}"], this.vertexSrc = ["attribute vec2 aVertexPosition;", "uniform mat3 translationMatrix;", "uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "uniform vec3 tint;", "uniform float alpha;", "uniform vec3 color;", "uniform float flipY;", "varying vec4 vColor;", "void main(void) {", " vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);", " v -= offsetVector.xyx;", " gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);", " vColor = vec4(color * alpha * tint, alpha);", "}"], this.init() }, L.ComplexPrimitiveShader.prototype.constructor = L.ComplexPrimitiveShader, L.ComplexPrimitiveShader.prototype.init = function() {
|
|
var t = this.gl,
|
|
e = L.compileProgram(t, this.vertexSrc, this.fragmentSrc);
|
|
t.useProgram(e), this.projectionVector = t.getUniformLocation(e, "projectionVector"), this.offsetVector = t.getUniformLocation(e, "offsetVector"), this.tintColor = t.getUniformLocation(e, "tint"), this.color = t.getUniformLocation(e, "color"), this.flipY = t.getUniformLocation(e, "flipY"), this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"), this.attributes = [this.aVertexPosition, this.colorAttribute], this.translationMatrix = t.getUniformLocation(e, "translationMatrix"), this.alpha = t.getUniformLocation(e, "alpha"), this.program = e
|
|
}, L.ComplexPrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram(this.program), this.uniforms = null, this.gl = null, this.attribute = null }, L.glContexts = [], L.instances = [], L.WebGLRenderer = function(t) { this.game = t, L.defaultRenderer || (L.defaultRenderer = this), this.type = L.WEBGL_RENDERER, this.resolution = t.resolution, this.transparent = t.transparent, this.autoResize = !1, this.preserveDrawingBuffer = t.preserveDrawingBuffer, this.clearBeforeRender = t.clearBeforeRender, this.width = t.width, this.height = t.height, this.view = t.canvas, this._contextOptions = { alpha: this.transparent, antialias: t.antialias, premultipliedAlpha: this.transparent && "notMultiplied" !== this.transparent, stencil: !0, preserveDrawingBuffer: this.preserveDrawingBuffer }, this.projection = new L.Point, this.offset = new L.Point, this.shaderManager = new L.WebGLShaderManager, this.spriteBatch = new L.WebGLSpriteBatch, this.maskManager = new L.WebGLMaskManager, this.filterManager = new L.WebGLFilterManager, this.stencilManager = new L.WebGLStencilManager, this.blendModeManager = new L.WebGLBlendModeManager, this.renderSession = {}, this.renderSession.game = this.game, this.renderSession.gl = this.gl, this.renderSession.drawCount = 0, this.renderSession.shaderManager = this.shaderManager, this.renderSession.maskManager = this.maskManager, this.renderSession.filterManager = this.filterManager, this.renderSession.blendModeManager = this.blendModeManager, this.renderSession.spriteBatch = this.spriteBatch, this.renderSession.stencilManager = this.stencilManager, (this.renderSession.renderer = this).renderSession.resolution = this.resolution, this.initContext(), this.mapBlendModes() }, L.WebGLRenderer.prototype.constructor = L.WebGLRenderer, L.WebGLRenderer.prototype.initContext = function() {
|
|
var t = this.view.getContext("webgl", this._contextOptions) || this.view.getContext("experimental-webgl", this._contextOptions);
|
|
if (!(this.gl = t)) throw new Error("This browser does not support webGL. Try using the canvas renderer");
|
|
this.glContextId = t.id = L.WebGLRenderer.glContextId++, L.glContexts[this.glContextId] = t, L.instances[this.glContextId] = this, t.disable(t.DEPTH_TEST), t.disable(t.CULL_FACE), t.enable(t.BLEND), this.shaderManager.setContext(t), this.spriteBatch.setContext(t), this.maskManager.setContext(t), this.filterManager.setContext(t), this.blendModeManager.setContext(t), this.stencilManager.setContext(t), this.renderSession.gl = this.gl, this.resize(this.width, this.height)
|
|
}, L.WebGLRenderer.prototype.render = function(t) {
|
|
if (!this.contextLost) {
|
|
var e = this.gl;
|
|
e.viewport(0, 0, this.width, this.height), e.bindFramebuffer(e.FRAMEBUFFER, null), this.game.clearBeforeRender && (e.clearColor(t._bgColor.r, t._bgColor.g, t._bgColor.b, t._bgColor.a), e.clear(e.COLOR_BUFFER_BIT)), this.offset.x = this.game.camera._shake.x, this.offset.y = this.game.camera._shake.y, this.renderDisplayObject(t, this.projection)
|
|
}
|
|
}, L.WebGLRenderer.prototype.renderDisplayObject = function(t, e, i, s) { this.renderSession.blendModeManager.setBlendMode(L.blendModes.NORMAL), this.renderSession.drawCount = 0, this.renderSession.flipY = i ? -1 : 1, this.renderSession.projection = e, this.renderSession.offset = this.offset, this.spriteBatch.begin(this.renderSession), this.filterManager.begin(this.renderSession, i), t._renderWebGL(this.renderSession, s), this.spriteBatch.end() }, L.WebGLRenderer.prototype.resize = function(t, e) { this.width = t * this.resolution, this.height = e * this.resolution, this.view.width = this.width, this.view.height = this.height, this.autoResize && (this.view.style.width = this.width / this.resolution + "px", this.view.style.height = this.height / this.resolution + "px"), this.gl.viewport(0, 0, this.width, this.height), this.projection.x = this.width / 2 / this.resolution, this.projection.y = -this.height / 2 / this.resolution }, L.WebGLRenderer.prototype.updateTexture = function(t) { if (!t.hasLoaded) return !1; var e = this.gl; return t._glTextures[e.id] || (t._glTextures[e.id] = e.createTexture()), e.bindTexture(e.TEXTURE_2D, t._glTextures[e.id]), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultipliedAlpha), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t.source), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, t.scaleMode === L.scaleModes.LINEAR ? e.LINEAR : e.NEAREST), t.mipmap && L.isPowerOfTwo(t.width, t.height) ? (e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, t.scaleMode === L.scaleModes.LINEAR ? e.LINEAR_MIPMAP_LINEAR : e.NEAREST_MIPMAP_NEAREST), e.generateMipmap(e.TEXTURE_2D)) : e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, t.scaleMode === L.scaleModes.LINEAR ? e.LINEAR : e.NEAREST), t._powerOf2 ? (e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.REPEAT), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.REPEAT)) : (e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE)), !(t._dirty[e.id] = !1) }, L.WebGLRenderer.prototype.destroy = function() { L.glContexts[this.glContextId] = null, this.projection = null, this.offset = null, this.shaderManager.destroy(), this.spriteBatch.destroy(), this.maskManager.destroy(), this.filterManager.destroy(), this.shaderManager = null, this.spriteBatch = null, this.maskManager = null, this.filterManager = null, this.gl = null, this.renderSession = null, L.CanvasPool.remove(this), L.instances[this.glContextId] = null, L.WebGLRenderer.glContextId-- }, L.WebGLRenderer.prototype.mapBlendModes = function() {
|
|
var t = this.gl;
|
|
if (!L.blendModesWebGL) {
|
|
var e = [],
|
|
i = L.blendModes;
|
|
e[i.NORMAL] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.ADD] = [t.SRC_ALPHA, t.DST_ALPHA], e[i.MULTIPLY] = [t.DST_COLOR, t.ONE_MINUS_SRC_ALPHA], e[i.SCREEN] = [t.SRC_ALPHA, t.ONE], e[i.OVERLAY] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.DARKEN] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.LIGHTEN] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.COLOR_DODGE] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.COLOR_BURN] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.HARD_LIGHT] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.SOFT_LIGHT] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.DIFFERENCE] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.EXCLUSION] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.HUE] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.SATURATION] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.COLOR] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], e[i.LUMINOSITY] = [t.ONE, t.ONE_MINUS_SRC_ALPHA], L.blendModesWebGL = e
|
|
}
|
|
}, L.WebGLRenderer.glContextId = 0, L.WebGLBlendModeManager = function() { this.currentBlendMode = 99999 }, L.WebGLBlendModeManager.prototype.constructor = L.WebGLBlendModeManager, L.WebGLBlendModeManager.prototype.setContext = function(t) { this.gl = t }, L.WebGLBlendModeManager.prototype.setBlendMode = function(t) {
|
|
if (this.currentBlendMode === t) return !1;
|
|
this.currentBlendMode = t;
|
|
var e = L.blendModesWebGL[this.currentBlendMode];
|
|
return e && this.gl.blendFunc(e[0], e[1]), !0
|
|
}, L.WebGLBlendModeManager.prototype.destroy = function() { this.gl = null }, L.WebGLMaskManager = function() {}, L.WebGLMaskManager.prototype.constructor = L.WebGLMaskManager, L.WebGLMaskManager.prototype.setContext = function(t) { this.gl = t }, L.WebGLMaskManager.prototype.pushMask = function(t, e) {
|
|
var i = e.gl;
|
|
t.dirty && L.WebGLGraphics.updateGraphics(t, i), void 0 !== t._webGL[i.id] && void 0 !== t._webGL[i.id].data && 0 !== t._webGL[i.id].data.length && e.stencilManager.pushStencil(t, t._webGL[i.id].data[0], e)
|
|
}, L.WebGLMaskManager.prototype.popMask = function(t, e) {
|
|
var i = this.gl;
|
|
void 0 !== t._webGL[i.id] && void 0 !== t._webGL[i.id].data && 0 !== t._webGL[i.id].data.length && e.stencilManager.popStencil(t, t._webGL[i.id].data[0], e)
|
|
}, L.WebGLMaskManager.prototype.destroy = function() { this.gl = null }, L.WebGLStencilManager = function() { this.stencilStack = [], this.reverse = !0, this.count = 0 }, L.WebGLStencilManager.prototype.setContext = function(t) { this.gl = t }, L.WebGLStencilManager.prototype.pushStencil = function(t, e, i) {
|
|
var s = this.gl;
|
|
this.bindGraphics(t, e, i), 0 === this.stencilStack.length && (s.enable(s.STENCIL_TEST), s.clear(s.STENCIL_BUFFER_BIT), this.reverse = !0, this.count = 0), this.stencilStack.push(e);
|
|
var o = this.count;
|
|
s.colorMask(!1, !1, !1, !1), s.stencilFunc(s.ALWAYS, 0, 255), s.stencilOp(s.KEEP, s.KEEP, s.INVERT), 1 === e.mode ? (s.drawElements(s.TRIANGLE_FAN, e.indices.length - 4, s.UNSIGNED_SHORT, 0), this.reverse ? (s.stencilFunc(s.EQUAL, 255 - o, 255), s.stencilOp(s.KEEP, s.KEEP, s.DECR)) : (s.stencilFunc(s.EQUAL, o, 255), s.stencilOp(s.KEEP, s.KEEP, s.INCR)), s.drawElements(s.TRIANGLE_FAN, 4, s.UNSIGNED_SHORT, 2 * (e.indices.length - 4)), this.reverse ? s.stencilFunc(s.EQUAL, 255 - (o + 1), 255) : s.stencilFunc(s.EQUAL, o + 1, 255), this.reverse = !this.reverse) : (this.reverse ? (s.stencilFunc(s.EQUAL, o, 255), s.stencilOp(s.KEEP, s.KEEP, s.INCR)) : (s.stencilFunc(s.EQUAL, 255 - o, 255), s.stencilOp(s.KEEP, s.KEEP, s.DECR)), s.drawElements(s.TRIANGLE_STRIP, e.indices.length, s.UNSIGNED_SHORT, 0), this.reverse ? s.stencilFunc(s.EQUAL, o + 1, 255) : s.stencilFunc(s.EQUAL, 255 - (o + 1), 255)), s.colorMask(!0, !0, !0, !0), s.stencilOp(s.KEEP, s.KEEP, s.KEEP), this.count++
|
|
}, L.WebGLStencilManager.prototype.bindGraphics = function(t, e, i) {
|
|
this._currentGraphics = t;
|
|
var s, o = this.gl,
|
|
n = i.projection,
|
|
a = i.offset;
|
|
1 === e.mode ? (s = i.shaderManager.complexPrimitiveShader, i.shaderManager.setShader(s), o.uniform1f(s.flipY, i.flipY), o.uniformMatrix3fv(s.translationMatrix, !1, t.worldTransform.toArray(!0)), o.uniform2f(s.projectionVector, n.x, -n.y), o.uniform2f(s.offsetVector, -a.x, -a.y), o.uniform3fv(s.tintColor, L.hex2rgb(t.tint)), o.uniform3fv(s.color, e.color), o.uniform1f(s.alpha, t.worldAlpha * e.alpha), o.bindBuffer(o.ARRAY_BUFFER, e.buffer), o.vertexAttribPointer(s.aVertexPosition, 2, o.FLOAT, !1, 8, 0)) : (s = i.shaderManager.primitiveShader, i.shaderManager.setShader(s), o.uniformMatrix3fv(s.translationMatrix, !1, t.worldTransform.toArray(!0)), o.uniform1f(s.flipY, i.flipY), o.uniform2f(s.projectionVector, n.x, -n.y), o.uniform2f(s.offsetVector, -a.x, -a.y), o.uniform3fv(s.tintColor, L.hex2rgb(t.tint)), o.uniform1f(s.alpha, t.worldAlpha), o.bindBuffer(o.ARRAY_BUFFER, e.buffer), o.vertexAttribPointer(s.aVertexPosition, 2, o.FLOAT, !1, 24, 0), o.vertexAttribPointer(s.colorAttribute, 4, o.FLOAT, !1, 24, 8)), o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, e.indexBuffer)
|
|
}, L.WebGLStencilManager.prototype.popStencil = function(t, e, i) {
|
|
var s = this.gl;
|
|
if (this.stencilStack.pop(), this.count--, 0 === this.stencilStack.length) s.disable(s.STENCIL_TEST);
|
|
else {
|
|
var o = this.count;
|
|
this.bindGraphics(t, e, i), s.colorMask(!1, !1, !1, !1), 1 === e.mode ? (this.reverse = !this.reverse, this.reverse ? (s.stencilFunc(s.EQUAL, 255 - (o + 1), 255), s.stencilOp(s.KEEP, s.KEEP, s.INCR)) : (s.stencilFunc(s.EQUAL, o + 1, 255), s.stencilOp(s.KEEP, s.KEEP, s.DECR)), s.drawElements(s.TRIANGLE_FAN, 4, s.UNSIGNED_SHORT, 2 * (e.indices.length - 4)), s.stencilFunc(s.ALWAYS, 0, 255), s.stencilOp(s.KEEP, s.KEEP, s.INVERT), s.drawElements(s.TRIANGLE_FAN, e.indices.length - 4, s.UNSIGNED_SHORT, 0)) : (this.reverse ? (s.stencilFunc(s.EQUAL, o + 1, 255), s.stencilOp(s.KEEP, s.KEEP, s.DECR)) : (s.stencilFunc(s.EQUAL, 255 - (o + 1), 255), s.stencilOp(s.KEEP, s.KEEP, s.INCR)), s.drawElements(s.TRIANGLE_STRIP, e.indices.length, s.UNSIGNED_SHORT, 0)), this.reverse ? s.stencilFunc(s.EQUAL, o, 255) : s.stencilFunc(s.EQUAL, 255 - o, 255), s.colorMask(!0, !0, !0, !0), s.stencilOp(s.KEEP, s.KEEP, s.KEEP)
|
|
}
|
|
}, L.WebGLStencilManager.prototype.destroy = function() { this.stencilStack = null, this.gl = null }, L.WebGLShaderManager = function() {
|
|
this.maxAttibs = 10, this.attribState = [], this.tempAttribState = [];
|
|
for (var t = 0; t < this.maxAttibs; t++) this.attribState[t] = !1;
|
|
this.stack = []
|
|
}, L.WebGLShaderManager.prototype.constructor = L.WebGLShaderManager, L.WebGLShaderManager.prototype.setContext = function(t) { this.gl = t, this.primitiveShader = new L.PrimitiveShader(t), this.complexPrimitiveShader = new L.ComplexPrimitiveShader(t), this.defaultShader = new L.PixiShader(t), this.fastShader = new L.PixiFastShader(t), this.stripShader = new L.StripShader(t), this.setShader(this.defaultShader) }, L.WebGLShaderManager.prototype.setAttribs = function(t) {
|
|
var e;
|
|
for (e = 0; e < this.tempAttribState.length; e++) this.tempAttribState[e] = !1;
|
|
for (e = 0; e < t.length; e++) {
|
|
var i = t[e];
|
|
this.tempAttribState[i] = !0
|
|
}
|
|
var s = this.gl;
|
|
for (e = 0; e < this.attribState.length; e++) this.attribState[e] !== this.tempAttribState[e] && (this.attribState[e] = this.tempAttribState[e], this.tempAttribState[e] ? s.enableVertexAttribArray(e) : s.disableVertexAttribArray(e))
|
|
}, L.WebGLShaderManager.prototype.setShader = function(t) { return this._currentId !== t._UID && (this._currentId = t._UID, this.currentShader = t, this.gl.useProgram(t.program), this.setAttribs(t.attributes), !0) }, L.WebGLShaderManager.prototype.destroy = function() { this.attribState = null, this.tempAttribState = null, this.primitiveShader.destroy(), this.complexPrimitiveShader.destroy(), this.defaultShader.destroy(), this.fastShader.destroy(), this.stripShader.destroy(), this.gl = null }, L.WebGLSpriteBatch = function() {
|
|
this.vertSize = 5, this.size = 2e3;
|
|
var t = 4 * this.size * 4 * this.vertSize,
|
|
e = 6 * this.size;
|
|
this.vertices = new L.ArrayBuffer(t), this.positions = new L.Float32Array(this.vertices), this.colors = new L.Uint32Array(this.vertices), this.indices = new L.Uint16Array(e);
|
|
for (var i = this.lastIndexCount = 0, s = 0; i < e; i += 6, s += 4) this.indices[i + 0] = s + 0, this.indices[i + 1] = s + 1, this.indices[i + 2] = s + 2, this.indices[i + 3] = s + 0, this.indices[i + 4] = s + 2, this.indices[i + 5] = s + 3;
|
|
this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.dirty = !0, this.textures = [], this.blendModes = [], this.shaders = [], this.sprites = [], this.defaultShader = new L.AbstractFilter(["precision lowp float;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "uniform sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"])
|
|
}, L.WebGLSpriteBatch.prototype.setContext = function(t) {
|
|
this.gl = t, this.vertexBuffer = t.createBuffer(), this.indexBuffer = t.createBuffer(), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER, this.indices, t.STATIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), t.bufferData(t.ARRAY_BUFFER, this.vertices, t.DYNAMIC_DRAW), this.currentBlendMode = 99999;
|
|
var e = new L.PixiShader(t);
|
|
e.fragmentSrc = this.defaultShader.fragmentSrc, e.uniforms = {}, e.init(), this.defaultShader.shaders[t.id] = e
|
|
}, L.WebGLSpriteBatch.prototype.begin = function(t) { this.renderSession = t, this.shader = this.renderSession.shaderManager.defaultShader, this.start() }, L.WebGLSpriteBatch.prototype.end = function() { this.flush() }, L.WebGLSpriteBatch.prototype.render = function(t, e) {
|
|
var i = t.texture,
|
|
s = t.worldTransform;
|
|
e && (s = e), this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = i.baseTexture);
|
|
var o = i._uvs;
|
|
if (o) {
|
|
var n, a, r, h, l = t.anchor.x,
|
|
c = t.anchor.y;
|
|
if (i.trim) {
|
|
var p = i.trim;
|
|
n = (a = p.x - l * p.width) + i.crop.width, r = (h = p.y - c * p.height) + i.crop.height
|
|
}
|
|
else n = i.frame.width * (1 - l), a = i.frame.width * -l, r = i.frame.height * (1 - c), h = i.frame.height * -c;
|
|
var u = 4 * this.currentBatchSize * this.vertSize,
|
|
d = i.baseTexture.resolution,
|
|
y = s.a / d,
|
|
g = s.b / d,
|
|
f = s.c / d,
|
|
m = s.d / d,
|
|
v = s.tx,
|
|
x = s.ty,
|
|
b = this.colors,
|
|
w = this.positions;
|
|
this.renderSession.roundPixels ? (w[u] = y * a + f * h + v | 0, w[u + 1] = m * h + g * a + x | 0, w[u + 5] = y * n + f * h + v | 0, w[u + 6] = m * h + g * n + x | 0, w[u + 10] = y * n + f * r + v | 0, w[u + 11] = m * r + g * n + x | 0, w[u + 15] = y * a + f * r + v | 0, w[u + 16] = m * r + g * a + x | 0) : (w[u] = y * a + f * h + v, w[u + 1] = m * h + g * a + x, w[u + 5] = y * n + f * h + v, w[u + 6] = m * h + g * n + x, w[u + 10] = y * n + f * r + v, w[u + 11] = m * r + g * n + x, w[u + 15] = y * a + f * r + v, w[u + 16] = m * r + g * a + x), w[u + 2] = o.x0, w[u + 3] = o.y0, w[u + 7] = o.x1, w[u + 8] = o.y1, w[u + 12] = o.x2, w[u + 13] = o.y2, w[u + 17] = o.x3, w[u + 18] = o.y3;
|
|
var P = t.tint;
|
|
b[u + 4] = b[u + 9] = b[u + 14] = b[u + 19] = (P >> 16) + (65280 & P) + ((255 & P) << 16) + (255 * t.worldAlpha << 24), this.sprites[this.currentBatchSize++] = t
|
|
}
|
|
}, L.WebGLSpriteBatch.prototype.renderTilingSprite = function(t) {
|
|
var e = t.tilingTexture;
|
|
this.currentBatchSize >= this.size && (this.flush(), this.currentBaseTexture = e.baseTexture), t._uvs || (t._uvs = new L.TextureUvs);
|
|
var i = t._uvs,
|
|
s = e.baseTexture.width,
|
|
o = e.baseTexture.height;
|
|
t.tilePosition.x %= s * t.tileScaleOffset.x, t.tilePosition.y %= o * t.tileScaleOffset.y;
|
|
var n = t.tilePosition.x / (s * t.tileScaleOffset.x),
|
|
a = t.tilePosition.y / (o * t.tileScaleOffset.y),
|
|
r = t.width / s / (t.tileScale.x * t.tileScaleOffset.x),
|
|
h = t.height / o / (t.tileScale.y * t.tileScaleOffset.y);
|
|
i.x0 = 0 - n, i.y0 = 0 - a, i.x1 = 1 * r - n, i.y1 = 0 - a, i.x2 = 1 * r - n, i.y2 = 1 * h - a, i.x3 = 0 - n, i.y3 = 1 * h - a;
|
|
var l = t.tint,
|
|
c = (l >> 16) + (65280 & l) + ((255 & l) << 16) + (255 * t.worldAlpha << 24),
|
|
p = this.positions,
|
|
u = this.colors,
|
|
d = t.width,
|
|
y = t.height,
|
|
g = t.anchor.x,
|
|
f = t.anchor.y,
|
|
m = d * (1 - g),
|
|
v = d * -g,
|
|
x = y * (1 - f),
|
|
b = y * -f,
|
|
w = 4 * this.currentBatchSize * this.vertSize,
|
|
P = e.baseTexture.resolution,
|
|
_ = t.worldTransform,
|
|
T = _.a / P,
|
|
S = _.b / P,
|
|
k = _.c / P,
|
|
B = _.d / P,
|
|
A = _.tx,
|
|
C = _.ty;
|
|
p[w++] = T * v + k * b + A, p[w++] = B * b + S * v + C, p[w++] = i.x0, p[w++] = i.y0, u[w++] = c, p[w++] = T * m + k * b + A, p[w++] = B * b + S * m + C, p[w++] = i.x1, p[w++] = i.y1, u[w++] = c, p[w++] = T * m + k * x + A, p[w++] = B * x + S * m + C, p[w++] = i.x2, p[w++] = i.y2, u[w++] = c, p[w++] = T * v + k * x + A, p[w++] = B * x + S * v + C, p[w++] = i.x3, p[w++] = i.y3, u[w++] = c, this.sprites[this.currentBatchSize++] = t
|
|
}, L.WebGLSpriteBatch.prototype.flush = function() {
|
|
if (0 !== this.currentBatchSize) {
|
|
var t, e, i, s, o = this.gl;
|
|
if (this.dirty) {
|
|
this.dirty = !1, o.activeTexture(o.TEXTURE0), o.bindBuffer(o.ARRAY_BUFFER, this.vertexBuffer), o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, this.indexBuffer), t = this.defaultShader.shaders[o.id];
|
|
var n = 4 * this.vertSize;
|
|
o.vertexAttribPointer(t.aVertexPosition, 2, o.FLOAT, !1, n, 0), o.vertexAttribPointer(t.aTextureCoord, 2, o.FLOAT, !1, n, 8), o.vertexAttribPointer(t.colorAttribute, 4, o.UNSIGNED_BYTE, !0, n, 16)
|
|
}
|
|
if (this.currentBatchSize > .5 * this.size) o.bufferSubData(o.ARRAY_BUFFER, 0, this.vertices);
|
|
else {
|
|
var a = this.positions.subarray(0, 4 * this.currentBatchSize * this.vertSize);
|
|
o.bufferSubData(o.ARRAY_BUFFER, 0, a)
|
|
}
|
|
for (var r, h = 0, l = 0, c = null, p = this.renderSession.blendModeManager.currentBlendMode, u = null, d = !1, y = !1, g = 0, f = this.currentBatchSize; g < f; g++) {
|
|
e = (r = this.sprites[g]).tilingTexture ? r.tilingTexture.baseTexture : r.texture.baseTexture, d = p !== (i = r.blendMode), y = u !== (s = r.shader || this.defaultShader);
|
|
var m = e.skipRender;
|
|
if (m && 0 < r.children.length && (m = !1), (c !== e && !m || d || y) && (this.renderBatch(c, h, l), l = g, h = 0, c = e, d && (p = i, this.renderSession.blendModeManager.setBlendMode(p)), y)) {
|
|
(t = (u = s).shaders[o.id]) || ((t = new L.PixiShader(o)).fragmentSrc = u.fragmentSrc, t.uniforms = u.uniforms, t.init(), u.shaders[o.id] = t), this.renderSession.shaderManager.setShader(t), t.dirty && t.syncUniforms();
|
|
var v = this.renderSession.projection;
|
|
o.uniform2f(t.projectionVector, v.x, v.y);
|
|
var x = this.renderSession.offset;
|
|
o.uniform2f(t.offsetVector, x.x, x.y)
|
|
}
|
|
h++
|
|
}
|
|
this.renderBatch(c, h, l), this.currentBatchSize = 0
|
|
}
|
|
}, L.WebGLSpriteBatch.prototype.renderBatch = function(t, e, i) {
|
|
if (0 !== e) {
|
|
var s = this.gl;
|
|
if (t._dirty[s.id]) { if (!this.renderSession.renderer.updateTexture(t)) return }
|
|
else s.bindTexture(s.TEXTURE_2D, t._glTextures[s.id]);
|
|
s.drawElements(s.TRIANGLES, 6 * e, s.UNSIGNED_SHORT, 6 * i * 2), this.renderSession.drawCount++
|
|
}
|
|
}, L.WebGLSpriteBatch.prototype.stop = function() { this.flush(), this.dirty = !0 }, L.WebGLSpriteBatch.prototype.start = function() { this.dirty = !0 }, L.WebGLSpriteBatch.prototype.destroy = function() { this.vertices = null, this.indices = null, this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer), this.currentBaseTexture = null, this.gl = null }, L.WebGLFastSpriteBatch = function(t) {
|
|
this.vertSize = 10, this.maxSize = 6e3, this.size = this.maxSize;
|
|
var e = 4 * this.size * this.vertSize,
|
|
i = 6 * this.maxSize;
|
|
this.vertices = new L.Float32Array(e), this.indices = new L.Uint16Array(i), this.vertexBuffer = null, this.indexBuffer = null;
|
|
for (var s = this.lastIndexCount = 0, o = 0; s < i; s += 6, o += 4) this.indices[s + 0] = o + 0, this.indices[s + 1] = o + 1, this.indices[s + 2] = o + 2, this.indices[s + 3] = o + 0, this.indices[s + 4] = o + 2, this.indices[s + 5] = o + 3;
|
|
this.drawing = !1, this.currentBatchSize = 0, this.currentBaseTexture = null, this.currentBlendMode = 0, this.renderSession = null, this.shader = null, this.matrix = null, this.setContext(t)
|
|
}, L.WebGLFastSpriteBatch.prototype.constructor = L.WebGLFastSpriteBatch, L.WebGLFastSpriteBatch.prototype.setContext = function(t) { this.gl = t, this.vertexBuffer = t.createBuffer(), this.indexBuffer = t.createBuffer(), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER, this.indices, t.STATIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), t.bufferData(t.ARRAY_BUFFER, this.vertices, t.DYNAMIC_DRAW) }, L.WebGLFastSpriteBatch.prototype.begin = function(t, e) { this.renderSession = e, this.shader = this.renderSession.shaderManager.fastShader, this.matrix = t.worldTransform.toArray(!0), this.start() }, L.WebGLFastSpriteBatch.prototype.end = function() { this.flush() }, L.WebGLFastSpriteBatch.prototype.render = function(t) {
|
|
var e = t.children,
|
|
i = e[0];
|
|
if (i.texture._uvs) {
|
|
this.currentBaseTexture = i.texture.baseTexture, i.blendMode !== this.renderSession.blendModeManager.currentBlendMode && (this.flush(), this.renderSession.blendModeManager.setBlendMode(i.blendMode));
|
|
for (var s = 0, o = e.length; s < o; s++) this.renderSprite(e[s]);
|
|
this.flush()
|
|
}
|
|
}, L.WebGLFastSpriteBatch.prototype.renderSprite = function(t) {
|
|
if (t.visible && (t.texture.baseTexture === this.currentBaseTexture || t.texture.baseTexture.skipRender || (this.flush(), this.currentBaseTexture = t.texture.baseTexture, t.texture._uvs))) {
|
|
var e, i, s, o, n, a, r = this.vertices;
|
|
if (e = t.texture._uvs, t.texture.frame.width, t.texture.frame.height, t.texture.trim) {
|
|
var h = t.texture.trim;
|
|
i = (s = h.x - t.anchor.x * h.width) + t.texture.crop.width, o = (n = h.y - t.anchor.y * h.height) + t.texture.crop.height
|
|
}
|
|
else i = t.texture.frame.width * (1 - t.anchor.x), s = t.texture.frame.width * -t.anchor.x, o = t.texture.frame.height * (1 - t.anchor.y), n = t.texture.frame.height * -t.anchor.y;
|
|
a = 4 * this.currentBatchSize * this.vertSize, r[a++] = s, r[a++] = n, r[a++] = t.position.x, r[a++] = t.position.y, r[a++] = t.scale.x, r[a++] = t.scale.y, r[a++] = t.rotation, r[a++] = e.x0, r[a++] = e.y1, r[a++] = t.alpha, r[a++] = i, r[a++] = n, r[a++] = t.position.x, r[a++] = t.position.y, r[a++] = t.scale.x, r[a++] = t.scale.y, r[a++] = t.rotation, r[a++] = e.x1, r[a++] = e.y1, r[a++] = t.alpha, r[a++] = i, r[a++] = o, r[a++] = t.position.x, r[a++] = t.position.y, r[a++] = t.scale.x, r[a++] = t.scale.y, r[a++] = t.rotation, r[a++] = e.x2, r[a++] = e.y2, r[a++] = t.alpha, r[a++] = s, r[a++] = o, r[a++] = t.position.x, r[a++] = t.position.y, r[a++] = t.scale.x, r[a++] = t.scale.y, r[a++] = t.rotation, r[a++] = e.x3, r[a++] = e.y3, r[a++] = t.alpha, this.currentBatchSize++, this.currentBatchSize >= this.size && this.flush()
|
|
}
|
|
}, L.WebGLFastSpriteBatch.prototype.flush = function() {
|
|
if (0 !== this.currentBatchSize) {
|
|
var t = this.gl;
|
|
if (this.currentBaseTexture._glTextures[t.id] || this.renderSession.renderer.updateTexture(this.currentBaseTexture, t), t.bindTexture(t.TEXTURE_2D, this.currentBaseTexture._glTextures[t.id]), this.currentBatchSize > .5 * this.size) t.bufferSubData(t.ARRAY_BUFFER, 0, this.vertices);
|
|
else {
|
|
var e = this.vertices.subarray(0, 4 * this.currentBatchSize * this.vertSize);
|
|
t.bufferSubData(t.ARRAY_BUFFER, 0, e)
|
|
}
|
|
t.drawElements(t.TRIANGLES, 6 * this.currentBatchSize, t.UNSIGNED_SHORT, 0), this.currentBatchSize = 0, this.renderSession.drawCount++
|
|
}
|
|
}, L.WebGLFastSpriteBatch.prototype.stop = function() { this.flush() }, L.WebGLFastSpriteBatch.prototype.start = function() {
|
|
var t = this.gl;
|
|
t.activeTexture(t.TEXTURE0), t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
|
var e = this.renderSession.projection;
|
|
t.uniform2f(this.shader.projectionVector, e.x, e.y), t.uniformMatrix3fv(this.shader.uMatrix, !1, this.matrix);
|
|
var i = 4 * this.vertSize;
|
|
t.vertexAttribPointer(this.shader.aVertexPosition, 2, t.FLOAT, !1, i, 0), t.vertexAttribPointer(this.shader.aPositionCoord, 2, t.FLOAT, !1, i, 8), t.vertexAttribPointer(this.shader.aScale, 2, t.FLOAT, !1, i, 16), t.vertexAttribPointer(this.shader.aRotation, 1, t.FLOAT, !1, i, 24), t.vertexAttribPointer(this.shader.aTextureCoord, 2, t.FLOAT, !1, i, 28), t.vertexAttribPointer(this.shader.colorAttribute, 1, t.FLOAT, !1, i, 36)
|
|
}, L.WebGLFilterManager = function() { this.filterStack = [], this.offsetX = 0, this.offsetY = 0 }, L.WebGLFilterManager.prototype.constructor = L.WebGLFilterManager, L.WebGLFilterManager.prototype.setContext = function(t) { this.gl = t, this.texturePool = [], this.initShaderBuffers() }, L.WebGLFilterManager.prototype.begin = function(t, e) {
|
|
this.renderSession = t, this.defaultShader = t.shaderManager.defaultShader;
|
|
var i = this.renderSession.projection;
|
|
this.width = 2 * i.x, this.height = 2 * -i.y, this.buffer = e
|
|
}, L.WebGLFilterManager.prototype.pushFilter = function(t) {
|
|
var e = this.gl,
|
|
i = this.renderSession.projection,
|
|
s = this.renderSession.offset;
|
|
t._filterArea = t.target.filterArea || t.target.getBounds(), t._previous_stencil_mgr = this.renderSession.stencilManager, this.renderSession.stencilManager = new L.WebGLStencilManager, this.renderSession.stencilManager.setContext(e), e.disable(e.STENCIL_TEST), this.filterStack.push(t);
|
|
var o = t.filterPasses[0];
|
|
this.offsetX += t._filterArea.x, this.offsetY += t._filterArea.y;
|
|
var n = this.texturePool.pop();
|
|
n ? n.resize(this.width * this.renderSession.resolution, this.height * this.renderSession.resolution) : n = new L.FilterTexture(this.gl, this.width * this.renderSession.resolution, this.height * this.renderSession.resolution), e.bindTexture(e.TEXTURE_2D, n.texture);
|
|
var a = t._filterArea,
|
|
r = o.padding;
|
|
a.x -= r, a.y -= r, a.width += 2 * r, a.height += 2 * r, a.x < 0 && (a.x = 0), a.width > this.width && (a.width = this.width), a.y < 0 && (a.y = 0), a.height > this.height && (a.height = this.height), e.bindFramebuffer(e.FRAMEBUFFER, n.frameBuffer), e.viewport(0, 0, a.width * this.renderSession.resolution, a.height * this.renderSession.resolution), i.x = a.width / 2, i.y = -a.height / 2, s.x = -a.x, s.y = -a.y, e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.clear(e.COLOR_BUFFER_BIT), t._glFilterTexture = n
|
|
}, L.WebGLFilterManager.prototype.popFilter = function() {
|
|
var t = this.gl,
|
|
e = this.filterStack.pop(),
|
|
i = e._filterArea,
|
|
s = e._glFilterTexture,
|
|
o = this.renderSession.projection,
|
|
n = this.renderSession.offset;
|
|
if (1 < e.filterPasses.length) {
|
|
t.viewport(0, 0, i.width * this.renderSession.resolution, i.height * this.renderSession.resolution), t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = 0, this.vertexArray[1] = i.height, this.vertexArray[2] = i.width, this.vertexArray[3] = i.height, this.vertexArray[4] = 0, this.vertexArray[5] = 0, this.vertexArray[6] = i.width, this.vertexArray[7] = 0, t.bufferSubData(t.ARRAY_BUFFER, 0, this.vertexArray), t.bindBuffer(t.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = i.width / this.width, this.uvArray[5] = i.height / this.height, this.uvArray[6] = i.width / this.width, this.uvArray[7] = i.height / this.height, t.bufferSubData(t.ARRAY_BUFFER, 0, this.uvArray);
|
|
var a = s,
|
|
r = this.texturePool.pop();
|
|
r || (r = new L.FilterTexture(this.gl, this.width * this.renderSession.resolution, this.height * this.renderSession.resolution)), r.resize(this.width * this.renderSession.resolution, this.height * this.renderSession.resolution), t.bindFramebuffer(t.FRAMEBUFFER, r.frameBuffer), t.clear(t.COLOR_BUFFER_BIT), t.disable(t.BLEND);
|
|
for (var h = 0; h < e.filterPasses.length - 1; h++) {
|
|
var l = e.filterPasses[h];
|
|
t.bindFramebuffer(t.FRAMEBUFFER, r.frameBuffer), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, a.texture), this.applyFilterPass(l, i, i.width, i.height);
|
|
var c = a;
|
|
a = r, r = c
|
|
}
|
|
t.enable(t.BLEND), s = a, this.texturePool.push(r)
|
|
}
|
|
var p = e.filterPasses[e.filterPasses.length - 1];
|
|
this.offsetX -= i.x, this.offsetY -= i.y;
|
|
var u = this.width,
|
|
d = this.height,
|
|
y = 0,
|
|
g = 0,
|
|
f = this.buffer;
|
|
if (0 === this.filterStack.length) t.colorMask(!0, !0, !0, !0);
|
|
else {
|
|
var m = this.filterStack[this.filterStack.length - 1];
|
|
u = (i = m._filterArea).width, d = i.height, y = i.x, g = i.y, f = m._glFilterTexture.frameBuffer
|
|
}
|
|
o.x = u / 2, o.y = -d / 2, n.x = y, n.y = g;
|
|
var v = (i = e._filterArea).x - y,
|
|
x = i.y - g;
|
|
t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), this.vertexArray[0] = v, this.vertexArray[1] = x + i.height, this.vertexArray[2] = v + i.width, this.vertexArray[3] = x + i.height, this.vertexArray[4] = v, this.vertexArray[5] = x, this.vertexArray[6] = v + i.width, this.vertexArray[7] = x, t.bufferSubData(t.ARRAY_BUFFER, 0, this.vertexArray), t.bindBuffer(t.ARRAY_BUFFER, this.uvBuffer), this.uvArray[2] = i.width / this.width, this.uvArray[5] = i.height / this.height, this.uvArray[6] = i.width / this.width, this.uvArray[7] = i.height / this.height, t.bufferSubData(t.ARRAY_BUFFER, 0, this.uvArray), t.viewport(0, 0, u * this.renderSession.resolution, d * this.renderSession.resolution), t.bindFramebuffer(t.FRAMEBUFFER, f), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, s.texture), this.renderSession.stencilManager && this.renderSession.stencilManager.destroy(), this.renderSession.stencilManager = e._previous_stencil_mgr, e._previous_stencil_mgr = null, 0 < this.renderSession.stencilManager.count ? t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST), this.applyFilterPass(p, i, u, d), this.texturePool.push(s), e._glFilterTexture = null
|
|
}, L.WebGLFilterManager.prototype.applyFilterPass = function(t, e, i, s) {
|
|
var o = this.gl,
|
|
n = t.shaders[o.id];
|
|
n || ((n = new L.PixiShader(o)).fragmentSrc = t.fragmentSrc, n.uniforms = t.uniforms, n.init(), t.shaders[o.id] = n), this.renderSession.shaderManager.setShader(n), o.uniform2f(n.projectionVector, i / 2, -s / 2), o.uniform2f(n.offsetVector, 0, 0), t.uniforms.dimensions && (t.uniforms.dimensions.value[0] = this.width, t.uniforms.dimensions.value[1] = this.height, t.uniforms.dimensions.value[2] = this.vertexArray[0], t.uniforms.dimensions.value[3] = this.vertexArray[5]), n.syncUniforms(), o.bindBuffer(o.ARRAY_BUFFER, this.vertexBuffer), o.vertexAttribPointer(n.aVertexPosition, 2, o.FLOAT, !1, 0, 0), o.bindBuffer(o.ARRAY_BUFFER, this.uvBuffer), o.vertexAttribPointer(n.aTextureCoord, 2, o.FLOAT, !1, 0, 0), o.bindBuffer(o.ARRAY_BUFFER, this.colorBuffer), o.vertexAttribPointer(n.colorAttribute, 2, o.FLOAT, !1, 0, 0), o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, this.indexBuffer), o.drawElements(o.TRIANGLES, 6, o.UNSIGNED_SHORT, 0), this.renderSession.drawCount++
|
|
}, L.WebGLFilterManager.prototype.initShaderBuffers = function() {
|
|
var t = this.gl;
|
|
this.vertexBuffer = t.createBuffer(), this.uvBuffer = t.createBuffer(), this.colorBuffer = t.createBuffer(), this.indexBuffer = t.createBuffer(), this.vertexArray = new L.Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer), t.bufferData(t.ARRAY_BUFFER, this.vertexArray, t.STATIC_DRAW), this.uvArray = new L.Float32Array([0, 0, 1, 0, 0, 1, 1, 1]), t.bindBuffer(t.ARRAY_BUFFER, this.uvBuffer), t.bufferData(t.ARRAY_BUFFER, this.uvArray, t.STATIC_DRAW), this.colorArray = new L.Float32Array([1, 16777215, 1, 16777215, 1, 16777215, 1, 16777215]), t.bindBuffer(t.ARRAY_BUFFER, this.colorBuffer), t.bufferData(t.ARRAY_BUFFER, this.colorArray, t.STATIC_DRAW), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER, new Uint16Array([0, 1, 2, 1, 3, 2]), t.STATIC_DRAW)
|
|
}, L.WebGLFilterManager.prototype.destroy = function() {
|
|
var t = this.gl;
|
|
this.filterStack = null, this.offsetX = 0;
|
|
for (var e = this.offsetY = 0; e < this.texturePool.length; e++) this.texturePool[e].destroy();
|
|
this.texturePool = null, t.deleteBuffer(this.vertexBuffer), t.deleteBuffer(this.uvBuffer), t.deleteBuffer(this.colorBuffer), t.deleteBuffer(this.indexBuffer)
|
|
}, L.FilterTexture = function(t, e, i, s) { this.gl = t, this.frameBuffer = t.createFramebuffer(), this.texture = t.createTexture(), s = s || L.scaleModes.DEFAULT, t.bindTexture(t.TEXTURE_2D, this.texture), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, s === L.scaleModes.LINEAR ? t.LINEAR : t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, s === L.scaleModes.LINEAR ? t.LINEAR : t.NEAREST), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE), t.bindFramebuffer(t.FRAMEBUFFER, this.frameBuffer), t.bindFramebuffer(t.FRAMEBUFFER, this.frameBuffer), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.texture, 0), this.renderBuffer = t.createRenderbuffer(), t.bindRenderbuffer(t.RENDERBUFFER, this.renderBuffer), t.framebufferRenderbuffer(t.FRAMEBUFFER, t.DEPTH_STENCIL_ATTACHMENT, t.RENDERBUFFER, this.renderBuffer), this.resize(e, i) }, L.FilterTexture.prototype.constructor = L.FilterTexture, L.FilterTexture.prototype.clear = function() {
|
|
var t = this.gl;
|
|
t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT)
|
|
}, L.FilterTexture.prototype.resize = function(t, e) {
|
|
if (this.width !== t || this.height !== e) {
|
|
this.width = t, this.height = e;
|
|
var i = this.gl;
|
|
i.bindTexture(i.TEXTURE_2D, this.texture), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, t, e, 0, i.RGBA, i.UNSIGNED_BYTE, null), i.bindRenderbuffer(i.RENDERBUFFER, this.renderBuffer), i.renderbufferStorage(i.RENDERBUFFER, i.DEPTH_STENCIL, t, e)
|
|
}
|
|
}, L.FilterTexture.prototype.destroy = function() {
|
|
var t = this.gl;
|
|
t.deleteFramebuffer(this.frameBuffer), t.deleteTexture(this.texture), this.frameBuffer = null, this.texture = null
|
|
}, L.CanvasBuffer = function(t, e) { this.width = t, this.height = e, this.canvas = L.CanvasPool.create(this, this.width, this.height), this.context = this.canvas.getContext("2d"), this.canvas.width = t, this.canvas.height = e }, L.CanvasBuffer.prototype.constructor = L.CanvasBuffer, L.CanvasBuffer.prototype.clear = function() { this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.clearRect(0, 0, this.width, this.height) }, L.CanvasBuffer.prototype.resize = function(t, e) { this.width = this.canvas.width = t, this.height = this.canvas.height = e }, L.CanvasBuffer.prototype.destroy = function() { L.CanvasPool.remove(this) }, L.CanvasMaskManager = function() {}, L.CanvasMaskManager.prototype.constructor = L.CanvasMaskManager, L.CanvasMaskManager.prototype.pushMask = function(t, e) {
|
|
var i = e.context;
|
|
i.save();
|
|
var s = t.alpha,
|
|
o = t.worldTransform,
|
|
n = e.resolution;
|
|
i.setTransform(o.a * n, o.b * n, o.c * n, o.d * n, o.tx * n, o.ty * n), L.CanvasGraphics.renderGraphicsMask(t, i), i.clip(), t.worldAlpha = s
|
|
}, L.CanvasMaskManager.prototype.popMask = function(t) { t.context.restore() }, L.CanvasTinter = function() {}, L.CanvasTinter.getTintedTexture = function(t, e) { var i = t.tintedTexture || L.CanvasPool.create(this); return L.CanvasTinter.tintMethod(t.texture, e, i), i }, L.CanvasTinter.tintWithMultiply = function(t, e, i) {
|
|
var s = i.getContext("2d"),
|
|
o = t.crop;
|
|
i.width === o.width && i.height === o.height || (i.width = o.width, i.height = o.height), s.clearRect(0, 0, o.width, o.height), s.fillStyle = "#" + ("00000" + (0 | e).toString(16)).substr(-6), s.fillRect(0, 0, o.width, o.height), s.globalCompositeOperation = "multiply", s.drawImage(t.baseTexture.source, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height), s.globalCompositeOperation = "destination-atop", s.drawImage(t.baseTexture.source, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height)
|
|
}, L.CanvasTinter.tintWithPerPixel = function(t, e, i) {
|
|
var s = i.getContext("2d"),
|
|
o = t.crop;
|
|
i.width = o.width, i.height = o.height, s.globalCompositeOperation = "copy", s.drawImage(t.baseTexture.source, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height);
|
|
for (var n = L.hex2rgb(e), a = n[0], r = n[1], h = n[2], l = s.getImageData(0, 0, o.width, o.height), c = l.data, p = 0; p < c.length; p += 4)
|
|
if (c[p + 0] *= a, c[p + 1] *= r, c[p + 2] *= h, !L.CanvasTinter.canHandleAlpha) {
|
|
var u = c[p + 3];
|
|
c[p + 0] /= 255 / u, c[p + 1] /= 255 / u, c[p + 2] /= 255 / u
|
|
}
|
|
s.putImageData(l, 0, 0)
|
|
}, L.CanvasTinter.checkInverseAlpha = function() {
|
|
var t = new L.CanvasBuffer(2, 1);
|
|
t.context.fillStyle = "rgba(10, 20, 30, 0.5)", t.context.fillRect(0, 0, 1, 1);
|
|
var e = t.context.getImageData(0, 0, 1, 1);
|
|
if (null === e) return !1;
|
|
t.context.putImageData(e, 1, 0);
|
|
var i = t.context.getImageData(1, 0, 1, 1);
|
|
return i.data[0] === e.data[0] && i.data[1] === e.data[1] && i.data[2] === e.data[2] && i.data[3] === e.data[3]
|
|
}, L.CanvasTinter.canHandleAlpha = L.CanvasTinter.checkInverseAlpha(), L.CanvasTinter.canUseMultiply = L.canUseNewCanvasBlendModes(), L.CanvasTinter.tintMethod = L.CanvasTinter.canUseMultiply ? L.CanvasTinter.tintWithMultiply : L.CanvasTinter.tintWithPerPixel, L.CanvasRenderer = function(t) { this.game = t, L.defaultRenderer || (L.defaultRenderer = this), this.type = L.CANVAS_RENDERER, this.resolution = t.resolution, this.clearBeforeRender = t.clearBeforeRender, this.transparent = t.transparent, this.autoResize = !1, this.width = t.width * this.resolution, this.height = t.height * this.resolution, this.view = t.canvas, this.context = this.view.getContext("2d", { alpha: this.transparent }), this.refresh = !0, this.count = 0, this.maskManager = new L.CanvasMaskManager, this.renderSession = { context: this.context, maskManager: this.maskManager, scaleMode: null, smoothProperty: Phaser.Canvas.getSmoothingPrefix(this.context), roundPixels: !1 }, this.mapBlendModes(), this.resize(this.width, this.height) }, L.CanvasRenderer.prototype.constructor = L.CanvasRenderer, L.CanvasRenderer.prototype.render = function(t) { this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.globalAlpha = 1, this.renderSession.currentBlendMode = 0, this.renderSession.shakeX = this.game.camera._shake.x, this.renderSession.shakeY = this.game.camera._shake.y, this.context.globalCompositeOperation = "source-over", navigator.isCocoonJS && this.view.screencanvas && (this.context.fillStyle = "black", this.context.clear()), this.clearBeforeRender && (this.transparent ? this.context.clearRect(0, 0, this.width, this.height) : t._bgColor && (this.context.fillStyle = t._bgColor.rgba, this.context.fillRect(0, 0, this.width, this.height))), this.renderDisplayObject(t) }, L.CanvasRenderer.prototype.destroy = function(t) { void 0 === t && (t = !0), t && this.view.parent && this.view.parent.removeChild(this.view), this.view = null, this.context = null, this.maskManager = null, this.renderSession = null }, L.CanvasRenderer.prototype.resize = function(t, e) { this.width = t * this.resolution, this.height = e * this.resolution, this.view.width = this.width, this.view.height = this.height, this.autoResize && (this.view.style.width = this.width / this.resolution + "px", this.view.style.height = this.height / this.resolution + "px"), this.renderSession.smoothProperty && (this.context[this.renderSession.smoothProperty] = this.renderSession.scaleMode === L.scaleModes.LINEAR) }, L.CanvasRenderer.prototype.renderDisplayObject = function(t, e, i) { this.renderSession.context = e || this.context, this.renderSession.resolution = this.resolution, t._renderCanvas(this.renderSession, i) }, L.CanvasRenderer.prototype.mapBlendModes = function() {
|
|
if (!L.blendModesCanvas) {
|
|
var t = [],
|
|
e = L.blendModes,
|
|
i = L.canUseNewCanvasBlendModes();
|
|
t[e.NORMAL] = "source-over", t[e.ADD] = "lighter", t[e.MULTIPLY] = i ? "multiply" : "source-over", t[e.SCREEN] = i ? "screen" : "source-over", t[e.OVERLAY] = i ? "overlay" : "source-over", t[e.DARKEN] = i ? "darken" : "source-over", t[e.LIGHTEN] = i ? "lighten" : "source-over", t[e.COLOR_DODGE] = i ? "color-dodge" : "source-over", t[e.COLOR_BURN] = i ? "color-burn" : "source-over", t[e.HARD_LIGHT] = i ? "hard-light" : "source-over", t[e.SOFT_LIGHT] = i ? "soft-light" : "source-over", t[e.DIFFERENCE] = i ? "difference" : "source-over", t[e.EXCLUSION] = i ? "exclusion" : "source-over", t[e.HUE] = i ? "hue" : "source-over", t[e.SATURATION] = i ? "saturation" : "source-over", t[e.COLOR] = i ? "color" : "source-over", t[e.LUMINOSITY] = i ? "luminosity" : "source-over", L.blendModesCanvas = t
|
|
}
|
|
}, L.BaseTexture = function(t, e) { this.resolution = 1, this.width = 100, this.height = 100, this.scaleMode = e || L.scaleModes.DEFAULT, this.hasLoaded = !1, this.source = t, this.premultipliedAlpha = !0, this._glTextures = [], this.mipmap = !1, this._dirty = [!0, !0, !0, !0], t && ((this.source.complete || this.source.getContext) && this.source.width && this.source.height && (this.hasLoaded = !0, this.width = this.source.naturalWidth || this.source.width, this.height = this.source.naturalHeight || this.source.height, this.dirty()), this.skipRender = !1, this._powerOf2 = !1) }, L.BaseTexture.prototype.constructor = L.BaseTexture, L.BaseTexture.prototype.forceLoaded = function(t, e) { this.hasLoaded = !0, this.width = t, this.height = e, this.dirty() }, L.BaseTexture.prototype.destroy = function() { this.source && L.CanvasPool.removeByCanvas(this.source), this.source = null, this.unloadFromGPU() }, L.BaseTexture.prototype.updateSourceImage = function(t) {}, L.BaseTexture.prototype.dirty = function() { for (var t = 0; t < this._glTextures.length; t++) this._dirty[t] = !0 }, L.BaseTexture.prototype.unloadFromGPU = function() {
|
|
this.dirty();
|
|
for (var t = this._glTextures.length - 1; 0 <= t; t--) {
|
|
var e = this._glTextures[t],
|
|
i = L.glContexts[t];
|
|
i && e && i.deleteTexture(e)
|
|
}
|
|
this._glTextures.length = 0, this.dirty()
|
|
}, L.BaseTexture.fromCanvas = function(t, e) { return 0 === t.width && (t.width = 1), 0 === t.height && (t.height = 1), new L.BaseTexture(t, e) }, L.TextureSilentFail = !1, L.Texture = function(t, e, i, s) { this.noFrame = !1, e || (this.noFrame = !0, e = new L.Rectangle(0, 0, 1, 1)), t instanceof L.Texture && (t = t.baseTexture), this.baseTexture = t, this.frame = e, this.trim = s, this.valid = !1, this.isTiling = !1, this.requiresUpdate = !1, this.requiresReTint = !1, this._uvs = null, this.width = 0, this.height = 0, this.crop = i || new L.Rectangle(0, 0, 1, 1), t.hasLoaded && (this.noFrame && (e = new L.Rectangle(0, 0, t.width, t.height)), this.setFrame(e)) }, L.Texture.prototype.constructor = L.Texture, L.Texture.prototype.onBaseTextureLoaded = function() {
|
|
var t = this.baseTexture;
|
|
this.noFrame && (this.frame = new L.Rectangle(0, 0, t.width, t.height)), this.setFrame(this.frame)
|
|
}, L.Texture.prototype.destroy = function(t) { t && this.baseTexture.destroy(), this.valid = !1 }, L.Texture.prototype.setFrame = function(t) {
|
|
if (this.noFrame = !1, this.frame = t, this.width = t.width, this.height = t.height, this.crop.x = t.x, this.crop.y = t.y, this.crop.width = t.width, this.crop.height = t.height, this.trim || !(t.x + t.width > this.baseTexture.width || t.y + t.height > this.baseTexture.height)) this.valid = t && t.width && t.height && this.baseTexture.source && this.baseTexture.hasLoaded, this.trim && (this.width = this.trim.width, this.height = this.trim.height, this.frame.width = this.trim.width, this.frame.height = this.trim.height), this.valid && this._updateUvs();
|
|
else {
|
|
if (!L.TextureSilentFail) throw new Error("Texture Error: frame does not fit inside the base Texture dimensions " + this);
|
|
this.valid = !1
|
|
}
|
|
}, L.Texture.prototype._updateUvs = function() {
|
|
this._uvs || (this._uvs = new L.TextureUvs);
|
|
var t = this.crop,
|
|
e = this.baseTexture.width,
|
|
i = this.baseTexture.height;
|
|
this._uvs.x0 = t.x / e, this._uvs.y0 = t.y / i, this._uvs.x1 = (t.x + t.width) / e, this._uvs.y1 = t.y / i, this._uvs.x2 = (t.x + t.width) / e, this._uvs.y2 = (t.y + t.height) / i, this._uvs.x3 = t.x / e, this._uvs.y3 = (t.y + t.height) / i
|
|
}, L.Texture.fromCanvas = function(t, e) { var i = L.BaseTexture.fromCanvas(t, e); return new L.Texture(i) }, L.TextureUvs = function() { this.x0 = 0, this.y0 = 0, this.x1 = 0, this.y1 = 0, this.x2 = 0, this.y2 = 0, this.x3 = 0, this.y3 = 0 }, L.RenderTexture = function(t, e, i, s, o) {
|
|
if (this.width = t || 100, this.height = e || 100, this.resolution = o || 1, this.frame = new L.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution), this.crop = new L.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution), this.baseTexture = new L.BaseTexture, this.baseTexture.width = this.width * this.resolution, this.baseTexture.height = this.height * this.resolution, this.baseTexture._glTextures = [], this.baseTexture.resolution = this.resolution, this.baseTexture.scaleMode = s || L.scaleModes.DEFAULT, this.baseTexture.hasLoaded = !0, L.Texture.call(this, this.baseTexture, new L.Rectangle(0, 0, this.width * this.resolution, this.height * this.resolution)), this.renderer = i || L.defaultRenderer, this.renderer.type === L.WEBGL_RENDERER) {
|
|
var n = this.renderer.gl;
|
|
this.baseTexture._dirty[n.id] = !1, this.textureBuffer = new L.FilterTexture(n, this.width, this.height, this.baseTexture.scaleMode), this.baseTexture._glTextures[n.id] = this.textureBuffer.texture, this.render = this.renderWebGL, this.projection = new L.Point(.5 * this.width, .5 * -this.height)
|
|
}
|
|
else this.render = this.renderCanvas, this.textureBuffer = new L.CanvasBuffer(this.width * this.resolution, this.height * this.resolution), this.baseTexture.source = this.textureBuffer.canvas;
|
|
this.valid = !0, this.tempMatrix = new Phaser.Matrix, this._updateUvs()
|
|
}, L.RenderTexture.prototype = Object.create(L.Texture.prototype), L.RenderTexture.prototype.constructor = L.RenderTexture, L.RenderTexture.prototype.resize = function(t, e, i) { t === this.width && e === this.height || (this.valid = 0 < t && 0 < e, this.width = t, this.height = e, this.frame.width = this.crop.width = t * this.resolution, this.frame.height = this.crop.height = e * this.resolution, i && (this.baseTexture.width = this.width * this.resolution, this.baseTexture.height = this.height * this.resolution), this.renderer.type === L.WEBGL_RENDERER && (this.projection.x = this.width / 2, this.projection.y = -this.height / 2), this.valid && this.textureBuffer.resize(this.width, this.height)) }, L.RenderTexture.prototype.clear = function() { this.valid && (this.renderer.type === L.WEBGL_RENDERER && this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer), this.textureBuffer.clear()) }, L.RenderTexture.prototype.renderWebGL = function(t, e, i) {
|
|
if (this.valid && 0 !== t.alpha) {
|
|
var s = t.worldTransform;
|
|
s.identity(), s.translate(0, 2 * this.projection.y), e && s.append(e), s.scale(1, -1);
|
|
for (var o = 0; o < t.children.length; o++) t.children[o].updateTransform();
|
|
var n = this.renderer.gl;
|
|
n.viewport(0, 0, this.width * this.resolution, this.height * this.resolution), n.bindFramebuffer(n.FRAMEBUFFER, this.textureBuffer.frameBuffer), i && this.textureBuffer.clear(), this.renderer.spriteBatch.dirty = !0, this.renderer.renderDisplayObject(t, this.projection, this.textureBuffer.frameBuffer, e), this.renderer.spriteBatch.dirty = !0
|
|
}
|
|
}, L.RenderTexture.prototype.renderCanvas = function(t, e, i) {
|
|
if (this.valid && 0 !== t.alpha) {
|
|
var s = t.worldTransform;
|
|
s.identity(), e && s.append(e);
|
|
for (var o = 0; o < t.children.length; o++) t.children[o].updateTransform();
|
|
i && this.textureBuffer.clear();
|
|
var n = this.renderer.resolution;
|
|
this.renderer.resolution = this.resolution, this.renderer.renderDisplayObject(t, this.textureBuffer.context, e), this.renderer.resolution = n
|
|
}
|
|
}, L.RenderTexture.prototype.getImage = function() { var t = new Image; return t.src = this.getBase64(), t }, L.RenderTexture.prototype.getBase64 = function() { return this.getCanvas().toDataURL() }, L.RenderTexture.prototype.getCanvas = function() {
|
|
if (this.renderer.type !== L.WEBGL_RENDERER) return this.textureBuffer.canvas;
|
|
var t = this.renderer.gl,
|
|
e = this.textureBuffer.width,
|
|
i = this.textureBuffer.height,
|
|
s = new Uint8Array(4 * e * i);
|
|
t.bindFramebuffer(t.FRAMEBUFFER, this.textureBuffer.frameBuffer), t.readPixels(0, 0, e, i, t.RGBA, t.UNSIGNED_BYTE, s), t.bindFramebuffer(t.FRAMEBUFFER, null);
|
|
var o = new L.CanvasBuffer(e, i),
|
|
n = o.context.getImageData(0, 0, e, i);
|
|
return n.data.set(s), o.context.putImageData(n, 0, 0), o.canvas
|
|
}, L.AbstractFilter = function(t, e) { this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.uniforms = e || {}, this.fragmentSrc = t || [] }, L.AbstractFilter.prototype.constructor = L.AbstractFilter, L.AbstractFilter.prototype.syncUniforms = function() { for (var t = 0, e = this.shaders.length; t < e; t++) this.shaders[t].dirty = !0 }, L.Strip = function(t) { L.DisplayObjectContainer.call(this), this.texture = t, this.uvs = new L.Float32Array([0, 1, 1, 1, 1, 0, 0, 1]), this.vertices = new L.Float32Array([0, 0, 100, 0, 100, 100, 0, 100]), this.colors = new L.Float32Array([1, 1, 1, 1]), this.indices = new L.Uint16Array([0, 1, 2, 3]), this.dirty = !0, this.blendMode = L.blendModes.NORMAL, this.canvasPadding = 0, this.drawMode = L.Strip.DrawModes.TRIANGLE_STRIP }, L.Strip.prototype = Object.create(L.DisplayObjectContainer.prototype), L.Strip.prototype.constructor = L.Strip, L.Strip.prototype._renderWebGL = function(t) {!this.visible || this.alpha <= 0 || (t.spriteBatch.stop(), this._vertexBuffer || this._initWebGL(t), t.shaderManager.setShader(t.shaderManager.stripShader), this._renderStrip(t), t.spriteBatch.start()) }, L.Strip.prototype._initWebGL = function(t) {
|
|
var e = t.gl;
|
|
this._vertexBuffer = e.createBuffer(), this._indexBuffer = e.createBuffer(), this._uvBuffer = e.createBuffer(), this._colorBuffer = e.createBuffer(), e.bindBuffer(e.ARRAY_BUFFER, this._vertexBuffer), e.bufferData(e.ARRAY_BUFFER, this.vertices, e.DYNAMIC_DRAW), e.bindBuffer(e.ARRAY_BUFFER, this._uvBuffer), e.bufferData(e.ARRAY_BUFFER, this.uvs, e.STATIC_DRAW), e.bindBuffer(e.ARRAY_BUFFER, this._colorBuffer), e.bufferData(e.ARRAY_BUFFER, this.colors, e.STATIC_DRAW), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, this.indices, e.STATIC_DRAW)
|
|
}, L.Strip.prototype._renderStrip = function(t) {
|
|
var e = t.gl,
|
|
i = t.projection,
|
|
s = t.offset,
|
|
o = t.shaderManager.stripShader,
|
|
n = this.drawMode === L.Strip.DrawModes.TRIANGLE_STRIP ? e.TRIANGLE_STRIP : e.TRIANGLES;
|
|
t.blendModeManager.setBlendMode(this.blendMode), e.uniformMatrix3fv(o.translationMatrix, !1, this.worldTransform.toArray(!0)), e.uniform2f(o.projectionVector, i.x, -i.y), e.uniform2f(o.offsetVector, -s.x, -s.y), e.uniform1f(o.alpha, this.worldAlpha), this.dirty ? (this.dirty = !1, e.bindBuffer(e.ARRAY_BUFFER, this._vertexBuffer), e.bufferData(e.ARRAY_BUFFER, this.vertices, e.STATIC_DRAW), e.vertexAttribPointer(o.aVertexPosition, 2, e.FLOAT, !1, 0, 0), e.bindBuffer(e.ARRAY_BUFFER, this._uvBuffer), e.bufferData(e.ARRAY_BUFFER, this.uvs, e.STATIC_DRAW), e.vertexAttribPointer(o.aTextureCoord, 2, e.FLOAT, !1, 0, 0), e.activeTexture(e.TEXTURE0), this.texture.baseTexture._dirty[e.id] ? t.renderer.updateTexture(this.texture.baseTexture) : e.bindTexture(e.TEXTURE_2D, this.texture.baseTexture._glTextures[e.id]), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._indexBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER, this.indices, e.STATIC_DRAW)) : (e.bindBuffer(e.ARRAY_BUFFER, this._vertexBuffer), e.bufferSubData(e.ARRAY_BUFFER, 0, this.vertices), e.vertexAttribPointer(o.aVertexPosition, 2, e.FLOAT, !1, 0, 0), e.bindBuffer(e.ARRAY_BUFFER, this._uvBuffer), e.vertexAttribPointer(o.aTextureCoord, 2, e.FLOAT, !1, 0, 0), e.activeTexture(e.TEXTURE0), this.texture.baseTexture._dirty[e.id] ? t.renderer.updateTexture(this.texture.baseTexture) : e.bindTexture(e.TEXTURE_2D, this.texture.baseTexture._glTextures[e.id]), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this._indexBuffer)), e.drawElements(n, this.indices.length, e.UNSIGNED_SHORT, 0)
|
|
}, L.Strip.prototype._renderCanvas = function(t) {
|
|
var e = t.context,
|
|
i = this.worldTransform,
|
|
s = i.tx * t.resolution + t.shakeX,
|
|
o = i.ty * t.resolution + t.shakeY;
|
|
t.roundPixels ? e.setTransform(i.a, i.b, i.c, i.d, 0 | s, 0 | o) : e.setTransform(i.a, i.b, i.c, i.d, s, o), this.drawMode === L.Strip.DrawModes.TRIANGLE_STRIP ? this._renderCanvasTriangleStrip(e) : this._renderCanvasTriangles(e)
|
|
}, L.Strip.prototype._renderCanvasTriangleStrip = function(t) {
|
|
var e = this.vertices,
|
|
i = this.uvs,
|
|
s = e.length / 2;
|
|
this.count++;
|
|
for (var o = 0; o < s - 2; o++) {
|
|
var n = 2 * o;
|
|
this._renderCanvasDrawTriangle(t, e, i, n, n + 2, n + 4)
|
|
}
|
|
}, L.Strip.prototype._renderCanvasTriangles = function(t) {
|
|
var e = this.vertices,
|
|
i = this.uvs,
|
|
s = this.indices,
|
|
o = s.length;
|
|
this.count++;
|
|
for (var n = 0; n < o; n += 3) {
|
|
var a = 2 * s[n],
|
|
r = 2 * s[n + 1],
|
|
h = 2 * s[n + 2];
|
|
this._renderCanvasDrawTriangle(t, e, i, a, r, h)
|
|
}
|
|
}, L.Strip.prototype._renderCanvasDrawTriangle = function(t, e, i, s, o, n) {
|
|
var a = this.texture.baseTexture.source,
|
|
r = this.texture.width,
|
|
h = this.texture.height,
|
|
l = e[s],
|
|
c = e[o],
|
|
p = e[n],
|
|
u = e[s + 1],
|
|
d = e[o + 1],
|
|
y = e[n + 1],
|
|
g = i[s] * r,
|
|
f = i[o] * r,
|
|
m = i[n] * r,
|
|
v = i[s + 1] * h,
|
|
x = i[o + 1] * h,
|
|
b = i[n + 1] * h;
|
|
if (0 < this.canvasPadding) {
|
|
var w = this.canvasPadding / this.worldTransform.a,
|
|
P = this.canvasPadding / this.worldTransform.d,
|
|
_ = (l + c + p) / 3,
|
|
T = (u + d + y) / 3,
|
|
S = l - _,
|
|
k = u - T,
|
|
B = Math.sqrt(S * S + k * k);
|
|
l = _ + S / B * (B + w), u = T + k / B * (B + P), k = d - T, c = _ + (S = c - _) / (B = Math.sqrt(S * S + k * k)) * (B + w), d = T + k / B * (B + P), k = y - T, p = _ + (S = p - _) / (B = Math.sqrt(S * S + k * k)) * (B + w), y = T + k / B * (B + P)
|
|
}
|
|
t.save(), t.beginPath(), t.moveTo(l, u), t.lineTo(c, d), t.lineTo(p, y), t.closePath(), t.clip();
|
|
var A = g * x + v * m + f * b - x * m - v * f - g * b,
|
|
C = l * x + v * p + c * b - x * p - v * c - l * b,
|
|
I = g * c + l * m + f * p - c * m - l * f - g * p,
|
|
E = g * x * p + v * c * m + l * f * b - l * x * m - v * f * p - g * c * b,
|
|
O = u * x + v * y + d * b - x * y - v * d - u * b,
|
|
M = g * d + u * m + f * y - d * m - u * f - g * y,
|
|
L = g * x * y + v * d * m + u * f * b - u * x * m - v * f * y - g * d * b;
|
|
t.transform(C / A, O / A, I / A, M / A, E / A, L / A), t.drawImage(a, 0, 0), t.restore()
|
|
}, L.Strip.prototype.renderStripFlat = function(t) {
|
|
var e = this.context,
|
|
i = t.vertices,
|
|
s = i.length / 2;
|
|
this.count++, e.beginPath();
|
|
for (var o = 1; o < s - 2; o++) {
|
|
var n = 2 * o,
|
|
a = i[n],
|
|
r = i[n + 2],
|
|
h = i[n + 4],
|
|
l = i[n + 1],
|
|
c = i[n + 3],
|
|
p = i[n + 5];
|
|
e.moveTo(a, l), e.lineTo(r, c), e.lineTo(h, p)
|
|
}
|
|
e.fillStyle = "#FF0000", e.fill(), e.closePath()
|
|
}, L.Strip.prototype.onTextureUpdate = function() { this.updateFrame = !0 }, L.Strip.prototype.getBounds = function(t) {
|
|
for (var e = t || this.worldTransform, i = e.a, s = e.b, o = e.c, n = e.d, a = e.tx, r = e.ty, h = -1 / 0, l = -1 / 0, c = 1 / 0, p = 1 / 0, u = this.vertices, d = 0, y = u.length; d < y; d += 2) {
|
|
var g = u[d],
|
|
f = u[d + 1],
|
|
m = i * g + o * f + a,
|
|
v = n * f + s * g + r;
|
|
c = m < c ? m : c, p = v < p ? v : p, h = h < m ? m : h, l = l < v ? v : l
|
|
}
|
|
if (c === -1 / 0 || l === 1 / 0) return L.EmptyRectangle;
|
|
var x = this._bounds;
|
|
return x.x = c, x.width = h - c, x.y = p, x.height = l - p, this._currentBounds = x
|
|
}, L.Strip.DrawModes = { TRIANGLE_STRIP: 0, TRIANGLES: 1 }, L.Rope = function(t, e) { L.Strip.call(this, t), this.points = e, this.vertices = new L.Float32Array(4 * e.length), this.uvs = new L.Float32Array(4 * e.length), this.colors = new L.Float32Array(2 * e.length), this.indices = new L.Uint16Array(2 * e.length), this.refresh() }, L.Rope.prototype = Object.create(L.Strip.prototype), L.Rope.prototype.constructor = L.Rope, L.Rope.prototype.refresh = function() {
|
|
var t = this.points;
|
|
if (!(t.length < 1)) {
|
|
var e = this.uvs,
|
|
i = (t[0], this.indices),
|
|
s = this.colors;
|
|
this.count -= .2, e[0] = 0, e[1] = 0, e[2] = 0, e[3] = 1, s[0] = 1, s[1] = 1, i[0] = 0, i[1] = 1;
|
|
for (var o, n, a, r = t.length, h = 1; h < r; h++) o = t[h], a = h / (r - 1), e[(n = 4 * h) + 3] = (e[n] = a, e[n + 1] = 0, e[n + 2] = a, 1), s[n = 2 * h] = 1, s[n + 1] = 1, i[n = 2 * h] = n, i[n + 1] = n + 1, o
|
|
}
|
|
}, L.Rope.prototype.updateTransform = function() {
|
|
var t = this.points;
|
|
if (!(t.length < 1)) {
|
|
var e, i = t[0],
|
|
s = { x: 0, y: 0 };
|
|
this.count -= .2;
|
|
for (var o, n, a, r, h = this.vertices, l = t.length, c = 0; c < l; c++) o = t[c], n = 4 * c, e = c < t.length - 1 ? t[c + 1] : o, s.y = -(e.x - i.x), s.x = e.y - i.y, 1 < 10 * (1 - c / (l - 1)) && 1, a = Math.sqrt(s.x * s.x + s.y * s.y), r = this.texture.height / 2, s.x /= a, s.y /= a, s.x *= r, s.y *= r, h[n] = o.x + s.x, h[n + 1] = o.y + s.y, h[n + 2] = o.x - s.x, h[n + 3] = o.y - s.y, i = o;
|
|
L.DisplayObjectContainer.prototype.updateTransform.call(this)
|
|
}
|
|
}, L.Rope.prototype.setTexture = function(t) { this.texture = t }, L.TilingSprite = function(t, e, i) { L.Sprite.call(this, t), this._width = e || 128, this._height = i || 128, this.tileScale = new L.Point(1, 1), this.tileScaleOffset = new L.Point(1, 1), this.tilePosition = new L.Point, this.renderable = !0, this.tint = 16777215, this.textureDebug = !1, this.blendMode = L.blendModes.NORMAL, this.canvasBuffer = null, this.tilingTexture = null, this.tilePattern = null, this.refreshTexture = !0, this.frameWidth = 0, this.frameHeight = 0 }, L.TilingSprite.prototype = Object.create(L.Sprite.prototype), L.TilingSprite.prototype.constructor = L.TilingSprite, L.TilingSprite.prototype.setTexture = function(t) { this.texture !== t && (this.texture = t, this.refreshTexture = !0, this.cachedTint = 16777215) }, L.TilingSprite.prototype._renderWebGL = function(t) {
|
|
if (this.visible && this.renderable && 0 !== this.alpha) {
|
|
if (this._mask && (t.spriteBatch.stop(), t.maskManager.pushMask(this.mask, t), t.spriteBatch.start()), this._filters && (t.spriteBatch.flush(), t.filterManager.pushFilter(this._filterBlock)), this.refreshTexture) {
|
|
if (this.generateTilingTexture(!0, t), !this.tilingTexture) return;
|
|
this.tilingTexture.needsUpdate && (t.renderer.updateTexture(this.tilingTexture.baseTexture), this.tilingTexture.needsUpdate = !1)
|
|
}
|
|
t.spriteBatch.renderTilingSprite(this);
|
|
for (var e = 0; e < this.children.length; e++) this.children[e]._renderWebGL(t);
|
|
t.spriteBatch.stop(), this._filters && t.filterManager.popFilter(), this._mask && t.maskManager.popMask(this._mask, t), t.spriteBatch.start()
|
|
}
|
|
}, L.TilingSprite.prototype._renderCanvas = function(t) {
|
|
if (this.visible && this.renderable && 0 !== this.alpha) {
|
|
var e = t.context;
|
|
this._mask && t.maskManager.pushMask(this._mask, t), e.globalAlpha = this.worldAlpha;
|
|
var i = this.worldTransform,
|
|
s = t.resolution,
|
|
o = i.tx * s + t.shakeX,
|
|
n = i.ty * s + t.shakeY;
|
|
if (e.setTransform(i.a * s, i.b * s, i.c * s, i.d * s, o, n), this.refreshTexture) {
|
|
if (this.generateTilingTexture(!1, t), !this.tilingTexture) return;
|
|
this.tilePattern = e.createPattern(this.tilingTexture.baseTexture.source, "repeat")
|
|
}
|
|
var a = t.currentBlendMode;
|
|
this.blendMode !== t.currentBlendMode && (t.currentBlendMode = this.blendMode, e.globalCompositeOperation = L.blendModesCanvas[t.currentBlendMode]);
|
|
var r = this.tilePosition,
|
|
h = this.tileScale;
|
|
r.x %= this.tilingTexture.baseTexture.width, r.y %= this.tilingTexture.baseTexture.height, e.scale(h.x, h.y), e.translate(r.x + this.anchor.x * -this._width, r.y + this.anchor.y * -this._height), e.fillStyle = this.tilePattern;
|
|
o = -r.x, n = -r.y;
|
|
var l = this._width / h.x,
|
|
c = this._height / h.y;
|
|
t.roundPixels && (o |= 0, n |= 0, l |= 0, c |= 0), e.fillRect(o, n, l, c), e.scale(1 / h.x, 1 / h.y), e.translate(-r.x + this.anchor.x * this._width, -r.y + this.anchor.y * this._height), this._mask && t.maskManager.popMask(t);
|
|
for (var p = 0; p < this.children.length; p++) this.children[p]._renderCanvas(t);
|
|
a !== this.blendMode && (t.currentBlendMode = a, e.globalCompositeOperation = L.blendModesCanvas[a])
|
|
}
|
|
}, L.TilingSprite.prototype.onTextureUpdate = function() {}, L.TilingSprite.prototype.generateTilingTexture = function(t, e) {
|
|
if (this.texture.baseTexture.hasLoaded) {
|
|
var i = this.texture,
|
|
s = i.frame,
|
|
o = this._frame.sourceSizeW || this._frame.width,
|
|
n = this._frame.sourceSizeH || this._frame.height,
|
|
a = 0,
|
|
r = 0;
|
|
this._frame.trimmed && (a = this._frame.spriteSourceSizeX, r = this._frame.spriteSourceSizeY), t && (o = L.getNextPowerOfTwo(o), n = L.getNextPowerOfTwo(n)), this.canvasBuffer ? (this.canvasBuffer.resize(o, n), this.tilingTexture.baseTexture.width = o, this.tilingTexture.baseTexture.height = n) : (this.canvasBuffer = new L.CanvasBuffer(o, n), this.tilingTexture = L.Texture.fromCanvas(this.canvasBuffer.canvas), this.tilingTexture.isTiling = !0), this.tilingTexture.needsUpdate = !0, this.textureDebug && (this.canvasBuffer.context.strokeStyle = "#00ff00", this.canvasBuffer.context.strokeRect(0, 0, o, n));
|
|
var h = i.crop.width,
|
|
l = i.crop.height;
|
|
h === o && l === n || (h = o, l = n), this.canvasBuffer.context.drawImage(i.baseTexture.source, i.crop.x, i.crop.y, i.crop.width, i.crop.height, a, r, h, l), this.tileScaleOffset.x = s.width / o, this.tileScaleOffset.y = s.height / n, this.refreshTexture = !1, this.tilingTexture.baseTexture._powerOf2 = !0
|
|
}
|
|
}, L.TilingSprite.prototype.getBounds = function() {
|
|
var t = this._width,
|
|
e = this._height,
|
|
i = t * (1 - this.anchor.x),
|
|
s = t * -this.anchor.x,
|
|
o = e * (1 - this.anchor.y),
|
|
n = e * -this.anchor.y,
|
|
a = this.worldTransform,
|
|
r = a.a,
|
|
h = a.b,
|
|
l = a.c,
|
|
c = a.d,
|
|
p = a.tx,
|
|
u = a.ty,
|
|
d = r * s + l * n + p,
|
|
y = c * n + h * s + u,
|
|
g = r * i + l * n + p,
|
|
f = c * n + h * i + u,
|
|
m = r * i + l * o + p,
|
|
v = c * o + h * i + u,
|
|
x = r * s + l * o + p,
|
|
b = c * o + h * s + u,
|
|
w = -1 / 0,
|
|
P = -1 / 0,
|
|
_ = 1 / 0,
|
|
T = 1 / 0;
|
|
_ = x < (_ = m < (_ = g < (_ = d < _ ? d : _) ? g : _) ? m : _) ? x : _, T = b < (T = v < (T = f < (T = y < T ? y : T) ? f : T) ? v : T) ? b : T, w = (w = (w = (w = w < d ? d : w) < g ? g : w) < m ? m : w) < x ? x : w, P = (P = (P = (P = P < y ? y : P) < f ? f : P) < v ? v : P) < b ? b : P;
|
|
var S = this._bounds;
|
|
return S.x = _, S.width = w - _, S.y = T, S.height = P - T, this._currentBounds = S
|
|
}, L.TilingSprite.prototype.destroy = function() { L.Sprite.prototype.destroy.call(this), this.canvasBuffer && (this.canvasBuffer.destroy(), this.canvasBuffer = null), this.tileScale = null, this.tileScaleOffset = null, this.tilePosition = null, this.tilingTexture && (this.tilingTexture.destroy(!0), this.tilingTexture = null) }, Object.defineProperty(L.TilingSprite.prototype, "width", { get: function() { return this._width }, set: function(t) { this._width = t } }), Object.defineProperty(L.TilingSprite.prototype, "height", { get: function() { return this._height }, set: function(t) { this._height = t } }), "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = L), exports.PIXI = L) : "undefined" != typeof define && define.amd ? define("PIXI", t.PIXI = L) : t.PIXI = L, L
|
|
}.call(this),
|
|
function() {
|
|
var n, t = this,
|
|
H = H || { VERSION: "2.6.12", GAMES: [], AUTO: 0, CANVAS: 1, WEBGL: 2, HEADLESS: 3, NONE: 0, LEFT: 1, RIGHT: 2, UP: 3, DOWN: 4, SPRITE: 0, BUTTON: 1, IMAGE: 2, GRAPHICS: 3, TEXT: 4, TILESPRITE: 5, BITMAPTEXT: 6, GROUP: 7, RENDERTEXTURE: 8, TILEMAP: 9, TILEMAPLAYER: 10, EMITTER: 11, POLYGON: 12, BITMAPDATA: 13, CANVAS_FILTER: 14, WEBGL_FILTER: 15, ELLIPSE: 16, SPRITEBATCH: 17, RETROFONT: 18, POINTER: 19, ROPE: 20, CIRCLE: 21, RECTANGLE: 22, LINE: 23, MATRIX: 24, POINT: 25, ROUNDEDRECTANGLE: 26, CREATURE: 27, VIDEO: 28, PENDING_ATLAS: -1, HORIZONTAL: 0, VERTICAL: 1, LANDSCAPE: 0, PORTRAIT: 1, ANGLE_UP: 270, ANGLE_DOWN: 90, ANGLE_LEFT: 180, ANGLE_RIGHT: 0, ANGLE_NORTH_EAST: 315, ANGLE_NORTH_WEST: 225, ANGLE_SOUTH_EAST: 45, ANGLE_SOUTH_WEST: 135, TOP_LEFT: 0, TOP_CENTER: 1, TOP_RIGHT: 2, LEFT_TOP: 3, LEFT_CENTER: 4, LEFT_BOTTOM: 5, CENTER: 6, RIGHT_TOP: 7, RIGHT_CENTER: 8, RIGHT_BOTTOM: 9, BOTTOM_LEFT: 10, BOTTOM_CENTER: 11, BOTTOM_RIGHT: 12, blendModes: { NORMAL: 0, ADD: 1, MULTIPLY: 2, SCREEN: 3, OVERLAY: 4, DARKEN: 5, LIGHTEN: 6, COLOR_DODGE: 7, COLOR_BURN: 8, HARD_LIGHT: 9, SOFT_LIGHT: 10, DIFFERENCE: 11, EXCLUSION: 12, HUE: 13, SATURATION: 14, COLOR: 15, LUMINOSITY: 16 }, scaleModes: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 }, PIXI: PIXI || {} };
|
|
if (Math.trunc || (Math.trunc = function(t) { return t < 0 ? Math.ceil(t) : Math.floor(t) }), Function.prototype.bind || (Function.prototype.bind = (n = Array.prototype.slice, function(e) {
|
|
var i = this,
|
|
s = n.call(arguments, 1);
|
|
if ("function" != typeof i) throw new TypeError;
|
|
|
|
function o() {
|
|
var t = s.concat(n.call(arguments));
|
|
i.apply(this instanceof o ? this : e, t)
|
|
}
|
|
return o.prototype = function t(e) { if (e && (t.prototype = e), !(this instanceof t)) return new t }(i.prototype), o
|
|
})), Array.isArray || (Array.isArray = function(t) { return "[object Array]" === Object.prototype.toString.call(t) }), Array.prototype.forEach || (Array.prototype.forEach = function(t) {
|
|
"use strict";
|
|
if (null == this) throw new TypeError;
|
|
var e = Object(this),
|
|
i = e.length >>> 0;
|
|
if ("function" != typeof t) throw new TypeError;
|
|
for (var s = 2 <= arguments.length ? arguments[1] : void 0, o = 0; o < i; o++) o in e && t.call(s, e[o], o, e)
|
|
}), "function" != typeof window.Uint32Array && "object" != typeof window.Uint32Array) {
|
|
var e = function(t) {
|
|
var e = new Array;
|
|
window[t] = function(t) { if ("number" == typeof t) { Array.call(this, t), this.length = t; for (var e = 0; e < this.length; e++) this[e] = 0 } else { Array.call(this, t.length), this.length = t.length; for (e = 0; e < this.length; e++) this[e] = t[e] } }, window[t].prototype = e, window[t].constructor = window[t]
|
|
};
|
|
e("Uint32Array"), e("Int16Array")
|
|
}
|
|
|
|
function s(t, e) { this._scaleFactor = t, this._deltaMode = e, this.originalEvent = null }
|
|
for (var i in window.console || (window.console = {}, window.console.log = window.console.assert = function() {}, window.console.warn = window.console.assert = function() {}), /firefox/i.test(navigator.userAgent) && (window.oldGetComputedStyle = window.getComputedStyle, window.getComputedStyle = function(t, e) { var i = window.oldGetComputedStyle(t, e); return null === i ? { getPropertyValue: function() {} } : i }), H.Utils = {
|
|
reverseString: function(t) { return t.split("").reverse().join("") },
|
|
getProperty: function(t, e) { for (var i = e.split("."), s = i.pop(), o = i.length, n = 1, a = i[0]; n < o && (t = t[a]);) a = i[n], n++; return t ? t[s] : null },
|
|
setProperty: function(t, e, i) { for (var s = e.split("."), o = s.pop(), n = s.length, a = 1, r = s[0]; a < n && (t = t[r]);) r = s[a], a++; return t && (t[o] = i), t },
|
|
chanceRoll: function(t) { return void 0 === t && (t = 50), 0 < t && 100 * Math.random() <= t },
|
|
randomChoice: function(t, e) { return Math.random() < .5 ? t : e },
|
|
parseDimension: function(t, e) { var i = 0; return "string" == typeof t ? "%" === t.substr(-1) ? (i = parseInt(t, 10) / 100, 0 === e ? window.innerWidth * i : window.innerHeight * i) : parseInt(t, 10) : t },
|
|
pad: function(t, e, i, s) {
|
|
if (void 0 === e) e = 0;
|
|
if (void 0 === i) i = " ";
|
|
if (void 0 === s) s = 3;
|
|
var o = 0;
|
|
if (e + 1 >= (t = t.toString()).length) switch (s) {
|
|
case 1:
|
|
t = new Array(e + 1 - t.length).join(i) + t;
|
|
break;
|
|
case 3:
|
|
var n = Math.ceil((o = e - t.length) / 2);
|
|
t = new Array(o - n + 1).join(i) + t + new Array(n + 1).join(i);
|
|
break;
|
|
default:
|
|
t += new Array(e + 1 - t.length).join(i)
|
|
}
|
|
return t
|
|
},
|
|
isPlainObject: function(t) { if ("object" != typeof t || t.nodeType || t === t.window) return !1; try { if (t.constructor && !{}.hasOwnProperty.call(t.constructor.prototype, "isPrototypeOf")) return !1 } catch (t) { return !1 } return !0 },
|
|
extend: function() {
|
|
var t, e, i, s, o, n, a = arguments[0] || {},
|
|
r = 1,
|
|
h = arguments.length,
|
|
l = !1;
|
|
for ("boolean" == typeof a && (l = a, a = arguments[1] || {}, r = 2), h === r && (a = this, --r); r < h; r++)
|
|
if (null != (t = arguments[r]))
|
|
for (e in t) i = a[e], a !== (s = t[e]) && (l && s && (H.Utils.isPlainObject(s) || (o = Array.isArray(s))) ? (n = o ? (o = !1, i && Array.isArray(i) ? i : []) : i && H.Utils.isPlainObject(i) ? i : {}, a[e] = H.Utils.extend(l, n, s)) : void 0 !== s && (a[e] = s));
|
|
return a
|
|
},
|
|
mixinPrototype: function(t, e, i) {
|
|
void 0 === i && (i = !1);
|
|
for (var s = Object.keys(e), o = 0; o < s.length; o++) {
|
|
var n = s[o],
|
|
a = e[n];
|
|
!i && n in t || (!a || "function" != typeof a.get && "function" != typeof a.set ? t[n] = a : "function" == typeof a.clone ? t[n] = a.clone() : Object.defineProperty(t, n, a))
|
|
}
|
|
},
|
|
mixin: function(t, e) {
|
|
if (!t || "object" != typeof t) return e;
|
|
for (var i in t) {
|
|
var s = t[i];
|
|
if (!s.childNodes && !s.cloneNode) {
|
|
var o = typeof t[i];
|
|
t[i] && "object" === o ? typeof e[i] === o ? e[i] = H.Utils.mixin(t[i], e[i]) : e[i] = H.Utils.mixin(t[i], new s.constructor) : e[i] = t[i]
|
|
}
|
|
}
|
|
return e
|
|
}
|
|
}, H.Circle = function(t, e, i) { t = t || 0, e = e || 0, i = i || 0, this.x = t, this.y = e, this._diameter = i, (this._radius = 0) < i && (this._radius = .5 * i), this.type = H.CIRCLE }, H.Circle.prototype = {
|
|
circumference: function() { return Math.PI * this._radius * 2 },
|
|
random: function(t) {
|
|
void 0 === t && (t = new H.Point);
|
|
var e = 2 * Math.PI * Math.random(),
|
|
i = Math.random() + Math.random(),
|
|
s = 1 < i ? 2 - i : i,
|
|
o = s * Math.cos(e),
|
|
n = s * Math.sin(e);
|
|
return t.x = this.x + o * this.radius, t.y = this.y + n * this.radius, t
|
|
},
|
|
getBounds: function() { return new H.Rectangle(this.x - this.radius, this.y - this.radius, this.diameter, this.diameter) },
|
|
setTo: function(t, e, i) { return this.x = t, this.y = e, this._diameter = i, this._radius = .5 * i, this },
|
|
copyFrom: function(t) { return this.setTo(t.x, t.y, t.diameter) },
|
|
copyTo: function(t) { return t.x = this.x, t.y = this.y, t.diameter = this._diameter, t },
|
|
distance: function(t, e) { var i = H.Math.distance(this.x, this.y, t.x, t.y); return e ? Math.round(i) : i },
|
|
clone: function(t) { return null == t ? t = new H.Circle(this.x, this.y, this.diameter) : t.setTo(this.x, this.y, this.diameter), t },
|
|
contains: function(t, e) { return H.Circle.contains(this, t, e) },
|
|
circumferencePoint: function(t, e, i) { return H.Circle.circumferencePoint(this, t, e, i) },
|
|
offset: function(t, e) { return this.x += t, this.y += e, this },
|
|
offsetPoint: function(t) { return this.offset(t.x, t.y) },
|
|
toString: function() { return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]" }
|
|
}, H.Circle.prototype.constructor = H.Circle, Object.defineProperty(H.Circle.prototype, "diameter", { get: function() { return this._diameter }, set: function(t) { 0 < t && (this._diameter = t, this._radius = .5 * t) } }), Object.defineProperty(H.Circle.prototype, "radius", { get: function() { return this._radius }, set: function(t) { 0 < t && (this._radius = t, this._diameter = 2 * t) } }), Object.defineProperty(H.Circle.prototype, "left", { get: function() { return this.x - this._radius }, set: function(t) { t > this.x ? (this._radius = 0, this._diameter = 0) : this.radius = this.x - t } }), Object.defineProperty(H.Circle.prototype, "right", { get: function() { return this.x + this._radius }, set: function(t) { t < this.x ? (this._radius = 0, this._diameter = 0) : this.radius = t - this.x } }), Object.defineProperty(H.Circle.prototype, "top", { get: function() { return this.y - this._radius }, set: function(t) { t > this.y ? (this._radius = 0, this._diameter = 0) : this.radius = this.y - t } }), Object.defineProperty(H.Circle.prototype, "bottom", { get: function() { return this.y + this._radius }, set: function(t) { t < this.y ? (this._radius = 0, this._diameter = 0) : this.radius = t - this.y } }), Object.defineProperty(H.Circle.prototype, "area", { get: function() { return 0 < this._radius ? Math.PI * this._radius * this._radius : 0 } }), Object.defineProperty(H.Circle.prototype, "empty", { get: function() { return 0 === this._diameter }, set: function(t) {!0 === t && this.setTo(0, 0, 0) } }), H.Circle.contains = function(t, e, i) { return 0 < t.radius && e >= t.left && e <= t.right && i >= t.top && i <= t.bottom && (t.x - e) * (t.x - e) + (t.y - i) * (t.y - i) <= t.radius * t.radius }, H.Circle.equals = function(t, e) { return t.x === e.x && t.y === e.y && t.diameter === e.diameter }, H.Circle.intersects = function(t, e) { return H.Math.distance(t.x, t.y, e.x, e.y) <= t.radius + e.radius }, H.Circle.circumferencePoint = function(t, e, i, s) { return void 0 === i && (i = !1), void 0 === s && (s = new H.Point), !0 === i && (e = H.Math.degToRad(e)), s.x = t.x + t.radius * Math.cos(e), s.y = t.y + t.radius * Math.sin(e), s }, H.Circle.intersectsRectangle = function(t, e) {
|
|
var i = Math.abs(t.x - e.x - e.halfWidth);
|
|
if (e.halfWidth + t.radius < i) return !1;
|
|
var s = Math.abs(t.y - e.y - e.halfHeight);
|
|
if (e.halfHeight + t.radius < s) return !1;
|
|
if (i <= e.halfWidth || s <= e.halfHeight) return !0;
|
|
var o = i - e.halfWidth,
|
|
n = s - e.halfHeight;
|
|
return o * o + n * n <= t.radius * t.radius
|
|
}, PIXI.Circle = H.Circle, H.Ellipse = function(t, e, i, s) { t = t || 0, e = e || 0, i = i || 0, s = s || 0, this.x = t, this.y = e, this.width = i, this.height = s, this.type = H.ELLIPSE }, H.Ellipse.prototype = {
|
|
setTo: function(t, e, i, s) { return this.x = t, this.y = e, this.width = i, this.height = s, this },
|
|
getBounds: function() { return new H.Rectangle(this.x - this.width, this.y - this.height, this.width, this.height) },
|
|
copyFrom: function(t) { return this.setTo(t.x, t.y, t.width, t.height) },
|
|
copyTo: function(t) { return t.x = this.x, t.y = this.y, t.width = this.width, t.height = this.height, t },
|
|
clone: function(t) { return null == t ? t = new H.Ellipse(this.x, this.y, this.width, this.height) : t.setTo(this.x, this.y, this.width, this.height), t },
|
|
contains: function(t, e) { return H.Ellipse.contains(this, t, e) },
|
|
random: function(t) {
|
|
void 0 === t && (t = new H.Point);
|
|
var e = Math.random() * Math.PI * 2,
|
|
i = Math.random();
|
|
return t.x = Math.sqrt(i) * Math.cos(e), t.y = Math.sqrt(i) * Math.sin(e), t.x = this.x + t.x * this.width / 2, t.y = this.y + t.y * this.height / 2, t
|
|
},
|
|
toString: function() { return "[{Phaser.Ellipse (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]" }
|
|
}, H.Ellipse.prototype.constructor = H.Ellipse, Object.defineProperty(H.Ellipse.prototype, "left", { get: function() { return this.x }, set: function(t) { this.x = t } }), Object.defineProperty(H.Ellipse.prototype, "right", { get: function() { return this.x + this.width }, set: function(t) { t < this.x ? this.width = 0 : this.width = t - this.x } }), Object.defineProperty(H.Ellipse.prototype, "top", { get: function() { return this.y }, set: function(t) { this.y = t } }), Object.defineProperty(H.Ellipse.prototype, "bottom", { get: function() { return this.y + this.height }, set: function(t) { t < this.y ? this.height = 0 : this.height = t - this.y } }), Object.defineProperty(H.Ellipse.prototype, "empty", { get: function() { return 0 === this.width || 0 === this.height }, set: function(t) {!0 === t && this.setTo(0, 0, 0, 0) } }), H.Ellipse.contains = function(t, e, i) {
|
|
if (t.width <= 0 || t.height <= 0) return !1;
|
|
var s = (e - t.x) / t.width - .5,
|
|
o = (i - t.y) / t.height - .5;
|
|
return (s *= s) + (o *= o) < .25
|
|
}, PIXI.Ellipse = H.Ellipse, H.Line = function(t, e, i, s) { t = t || 0, e = e || 0, i = i || 0, s = s || 0, this.start = new H.Point(t, e), this.end = new H.Point(i, s), this.type = H.LINE }, H.Line.prototype = {
|
|
setTo: function(t, e, i, s) { return this.start.setTo(t, e), this.end.setTo(i, s), this },
|
|
fromSprite: function(t, e, i) { return void 0 === i && (i = !1), i ? this.setTo(t.center.x, t.center.y, e.center.x, e.center.y) : this.setTo(t.x, t.y, e.x, e.y) },
|
|
fromAngle: function(t, e, i, s) { return this.start.setTo(t, e), this.end.setTo(t + Math.cos(i) * s, e + Math.sin(i) * s), this },
|
|
rotate: function(t, e) {
|
|
var i = (this.start.x + this.end.x) / 2,
|
|
s = (this.start.y + this.end.y) / 2;
|
|
return this.start.rotate(i, s, t, e), this.end.rotate(i, s, t, e), this
|
|
},
|
|
rotateAround: function(t, e, i, s) { return this.start.rotate(t, e, i, s), this.end.rotate(t, e, i, s), this },
|
|
intersects: function(t, e, i) { return H.Line.intersectsPoints(this.start, this.end, t.start, t.end, e, i) },
|
|
reflect: function(t) { return H.Line.reflect(this, t) },
|
|
midPoint: function(t) { return void 0 === t && (t = new H.Point), t.x = (this.start.x + this.end.x) / 2, t.y = (this.start.y + this.end.y) / 2, t },
|
|
centerOn: function(t, e) {
|
|
var i = t - (this.start.x + this.end.x) / 2,
|
|
s = e - (this.start.y + this.end.y) / 2;
|
|
this.start.add(i, s), this.end.add(i, s)
|
|
},
|
|
pointOnLine: function(t, e) { return (t - this.start.x) * (this.end.y - this.start.y) == (this.end.x - this.start.x) * (e - this.start.y) },
|
|
pointOnSegment: function(t, e) {
|
|
var i = Math.min(this.start.x, this.end.x),
|
|
s = Math.max(this.start.x, this.end.x),
|
|
o = Math.min(this.start.y, this.end.y),
|
|
n = Math.max(this.start.y, this.end.y);
|
|
return this.pointOnLine(t, e) && i <= t && t <= s && o <= e && e <= n
|
|
},
|
|
random: function(t) { void 0 === t && (t = new H.Point); var e = Math.random(); return t.x = this.start.x + e * (this.end.x - this.start.x), t.y = this.start.y + e * (this.end.y - this.start.y), t },
|
|
coordinatesOnLine: function(t, e) {
|
|
void 0 === t && (t = 1), void 0 === e && (e = []);
|
|
var i = Math.round(this.start.x),
|
|
s = Math.round(this.start.y),
|
|
o = Math.round(this.end.x),
|
|
n = Math.round(this.end.y),
|
|
a = Math.abs(o - i),
|
|
r = Math.abs(n - s),
|
|
h = i < o ? 1 : -1,
|
|
l = s < n ? 1 : -1,
|
|
c = a - r;
|
|
e.push([i, s]);
|
|
for (var p = 1; i !== o || s !== n;) { var u = c << 1; - r < u && (c -= r, i += h), u < a && (c += a, s += l), p % t == 0 && e.push([i, s]), p++ }
|
|
return e
|
|
},
|
|
clone: function(t) { return null == t ? t = new H.Line(this.start.x, this.start.y, this.end.x, this.end.y) : t.setTo(this.start.x, this.start.y, this.end.x, this.end.y), t }
|
|
}, Object.defineProperty(H.Line.prototype, "length", { get: function() { return Math.sqrt((this.end.x - this.start.x) * (this.end.x - this.start.x) + (this.end.y - this.start.y) * (this.end.y - this.start.y)) } }), Object.defineProperty(H.Line.prototype, "angle", { get: function() { return Math.atan2(this.end.y - this.start.y, this.end.x - this.start.x) } }), Object.defineProperty(H.Line.prototype, "slope", { get: function() { return (this.end.y - this.start.y) / (this.end.x - this.start.x) } }), Object.defineProperty(H.Line.prototype, "perpSlope", { get: function() { return -(this.end.x - this.start.x) / (this.end.y - this.start.y) } }), Object.defineProperty(H.Line.prototype, "x", { get: function() { return Math.min(this.start.x, this.end.x) } }), Object.defineProperty(H.Line.prototype, "y", { get: function() { return Math.min(this.start.y, this.end.y) } }), Object.defineProperty(H.Line.prototype, "left", { get: function() { return Math.min(this.start.x, this.end.x) } }), Object.defineProperty(H.Line.prototype, "right", { get: function() { return Math.max(this.start.x, this.end.x) } }), Object.defineProperty(H.Line.prototype, "top", { get: function() { return Math.min(this.start.y, this.end.y) } }), Object.defineProperty(H.Line.prototype, "bottom", { get: function() { return Math.max(this.start.y, this.end.y) } }), Object.defineProperty(H.Line.prototype, "width", { get: function() { return Math.abs(this.start.x - this.end.x) } }), Object.defineProperty(H.Line.prototype, "height", { get: function() { return Math.abs(this.start.y - this.end.y) } }), Object.defineProperty(H.Line.prototype, "normalX", { get: function() { return Math.cos(this.angle - 1.5707963267948966) } }), Object.defineProperty(H.Line.prototype, "normalY", { get: function() { return Math.sin(this.angle - 1.5707963267948966) } }), Object.defineProperty(H.Line.prototype, "normalAngle", { get: function() { return H.Math.wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI) } }), H.Line.intersectsPoints = function(t, e, i, s, o, n) {
|
|
void 0 === o && (o = !0), void 0 === n && (n = new H.Point);
|
|
var a = e.y - t.y,
|
|
r = s.y - i.y,
|
|
h = t.x - e.x,
|
|
l = i.x - s.x,
|
|
c = e.x * t.y - t.x * e.y,
|
|
p = s.x * i.y - i.x * s.y,
|
|
u = a * l - r * h;
|
|
if (0 === u) return null;
|
|
if (n.x = (h * p - l * c) / u, n.y = (r * c - a * p) / u, o) {
|
|
var d = (s.y - i.y) * (e.x - t.x) - (s.x - i.x) * (e.y - t.y),
|
|
y = ((s.x - i.x) * (t.y - i.y) - (s.y - i.y) * (t.x - i.x)) / d,
|
|
g = ((e.x - t.x) * (t.y - i.y) - (e.y - t.y) * (t.x - i.x)) / d;
|
|
return 0 <= y && y <= 1 && 0 <= g && g <= 1 ? n : null
|
|
}
|
|
return n
|
|
}, H.Line.intersects = function(t, e, i, s) { return H.Line.intersectsPoints(t.start, t.end, e.start, e.end, i, s) }, H.Line.intersectsRectangle = function(t, e) {
|
|
if (!H.Rectangle.intersects(t, e)) return !1;
|
|
var i = t.start.x,
|
|
s = t.start.y,
|
|
o = t.end.x,
|
|
n = t.end.y,
|
|
a = e.x,
|
|
r = e.y,
|
|
h = e.right,
|
|
l = e.bottom,
|
|
c = 0;
|
|
if (a <= i && i <= h && r <= s && s <= l || a <= o && o <= h && r <= n && n <= l) return !0;
|
|
if (i < a && a <= o) { if (r < (c = s + (n - s) * (a - i) / (o - i)) && c <= l) return !0 }
|
|
else if (h < i && o <= h && r <= (c = s + (n - s) * (h - i) / (o - i)) && c <= l) return !0;
|
|
if (s < r && r <= n) { if (a <= (c = i + (o - i) * (r - s) / (n - s)) && c <= h) return !0 }
|
|
else if (l < s && n <= l && a <= (c = i + (o - i) * (l - s) / (n - s)) && c <= h) return !0;
|
|
return !1
|
|
}, H.Line.reflect = function(t, e) { return 2 * e.normalAngle - 3.141592653589793 - t.angle }, H.Matrix = function(t, e, i, s, o, n) { null == t && (t = 1), null == e && (e = 0), null == i && (i = 0), null == s && (s = 1), null == o && (o = 0), null == n && (n = 0), this.a = t, this.b = e, this.c = i, this.d = s, this.tx = o, this.ty = n, this.type = H.MATRIX }, H.Matrix.prototype = {
|
|
fromArray: function(t) { return this.setTo(t[0], t[1], t[3], t[4], t[2], t[5]) },
|
|
setTo: function(t, e, i, s, o, n) { return this.a = t, this.b = e, this.c = i, this.d = s, this.tx = o, this.ty = n, this },
|
|
clone: function(t) { return null == t ? t = new H.Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty) : (t.a = this.a, t.b = this.b, t.c = this.c, t.d = this.d, t.tx = this.tx, t.ty = this.ty), t },
|
|
copyTo: function(t) { return t.copyFrom(this), t },
|
|
copyFrom: function(t) { return this.a = t.a, this.b = t.b, this.c = t.c, this.d = t.d, this.tx = t.tx, this.ty = t.ty, this },
|
|
toArray: function(t, e) { return void 0 === e && (e = new PIXI.Float32Array(9)), e[8] = (e[7] = t ? (e[0] = this.a, e[1] = this.b, e[2] = 0, e[3] = this.c, e[4] = this.d, e[5] = 0, e[6] = this.tx, this.ty) : (e[0] = this.a, e[1] = this.c, e[2] = this.tx, e[3] = this.b, e[4] = this.d, e[5] = this.ty, e[6] = 0), 1), e },
|
|
apply: function(t, e) { return void 0 === e && (e = new H.Point), e.x = this.a * t.x + this.c * t.y + this.tx, e.y = this.b * t.x + this.d * t.y + this.ty, e },
|
|
applyInverse: function(t, e) {
|
|
void 0 === e && (e = new H.Point);
|
|
var i = 1 / (this.a * this.d + this.c * -this.b),
|
|
s = t.x,
|
|
o = t.y;
|
|
return e.x = this.d * i * s + -this.c * i * o + (this.ty * this.c - this.tx * this.d) * i, e.y = this.a * i * o + -this.b * i * s + (-this.ty * this.a + this.tx * this.b) * i, e
|
|
},
|
|
translate: function(t, e) { return this.tx += t, this.ty += e, this },
|
|
scale: function(t, e) { return this.a *= t, this.d *= e, this.c *= t, this.b *= e, this.tx *= t, this.ty *= e, this },
|
|
rotate: function(t) {
|
|
var e = Math.cos(t),
|
|
i = Math.sin(t),
|
|
s = this.a,
|
|
o = this.c,
|
|
n = this.tx;
|
|
return this.a = s * e - this.b * i, this.b = s * i + this.b * e, this.c = o * e - this.d * i, this.d = o * i + this.d * e, this.tx = n * e - this.ty * i, this.ty = n * i + this.ty * e, this
|
|
},
|
|
append: function(t) {
|
|
var e = this.a,
|
|
i = this.b,
|
|
s = this.c,
|
|
o = this.d;
|
|
return this.a = t.a * e + t.b * s, this.b = t.a * i + t.b * o, this.c = t.c * e + t.d * s, this.d = t.c * i + t.d * o, this.tx = t.tx * e + t.ty * s + this.tx, this.ty = t.tx * i + t.ty * o + this.ty, this
|
|
},
|
|
identity: function() { return this.setTo(1, 0, 0, 1, 0, 0) }
|
|
}, H.identityMatrix = new H.Matrix, PIXI.Matrix = H.Matrix, PIXI.identityMatrix = H.identityMatrix, H.Point = function(t, e) { t = t || 0, e = e || 0, this.x = t, this.y = e, this.type = H.POINT }, H.Point.prototype = {
|
|
copyFrom: function(t) { return this.setTo(t.x, t.y) },
|
|
invert: function() { return this.setTo(this.y, this.x) },
|
|
setTo: function(t, e) { return this.x = t || 0, this.y = e || (0 !== e ? this.x : 0), this },
|
|
set: function(t, e) { return this.x = t || 0, this.y = e || (0 !== e ? this.x : 0), this },
|
|
add: function(t, e) { return this.x += t, this.y += e, this },
|
|
subtract: function(t, e) { return this.x -= t, this.y -= e, this },
|
|
multiply: function(t, e) { return this.x *= t, this.y *= e, this },
|
|
divide: function(t, e) { return this.x /= t, this.y /= e, this },
|
|
clampX: function(t, e) { return this.x = H.Math.clamp(this.x, t, e), this },
|
|
clampY: function(t, e) { return this.y = H.Math.clamp(this.y, t, e), this },
|
|
clamp: function(t, e) { return this.x = H.Math.clamp(this.x, t, e), this.y = H.Math.clamp(this.y, t, e), this },
|
|
clone: function(t) { return null == t ? t = new H.Point(this.x, this.y) : t.setTo(this.x, this.y), t },
|
|
copyTo: function(t) { return t.x = this.x, t.y = this.y, t },
|
|
distance: function(t, e) { return H.Point.distance(this, t, e) },
|
|
equals: function(t) { return t.x === this.x && t.y === this.y },
|
|
angle: function(t, e) { return void 0 === e && (e = !1), e ? H.Math.radToDeg(Math.atan2(t.y - this.y, t.x - this.x)) : Math.atan2(t.y - this.y, t.x - this.x) },
|
|
rotate: function(t, e, i, s, o) { return H.Point.rotate(this, t, e, i, s, o) },
|
|
getMagnitude: function() { return Math.sqrt(this.x * this.x + this.y * this.y) },
|
|
getMagnitudeSq: function() { return this.x * this.x + this.y * this.y },
|
|
setMagnitude: function(t) { return this.normalize().multiply(t, t) },
|
|
normalize: function() {
|
|
if (!this.isZero()) {
|
|
var t = this.getMagnitude();
|
|
this.x /= t, this.y /= t
|
|
}
|
|
return this
|
|
},
|
|
isZero: function() { return 0 === this.x && 0 === this.y },
|
|
dot: function(t) { return this.x * t.x + this.y * t.y },
|
|
cross: function(t) { return this.x * t.y - this.y * t.x },
|
|
perp: function() { return this.setTo(-this.y, this.x) },
|
|
rperp: function() { return this.setTo(this.y, -this.x) },
|
|
normalRightHand: function() { return this.setTo(-1 * this.y, this.x) },
|
|
floor: function() { return this.setTo(Math.floor(this.x), Math.floor(this.y)) },
|
|
ceil: function() { return this.setTo(Math.ceil(this.x), Math.ceil(this.y)) },
|
|
toString: function() { return "[{Point (x=" + this.x + " y=" + this.y + ")}]" }
|
|
}, H.Point.prototype.constructor = H.Point, H.Point.add = function(t, e, i) { return void 0 === i && (i = new H.Point), i.x = t.x + e.x, i.y = t.y + e.y, i }, H.Point.subtract = function(t, e, i) { return void 0 === i && (i = new H.Point), i.x = t.x - e.x, i.y = t.y - e.y, i }, H.Point.multiply = function(t, e, i) { return void 0 === i && (i = new H.Point), i.x = t.x * e.x, i.y = t.y * e.y, i }, H.Point.divide = function(t, e, i) { return void 0 === i && (i = new H.Point), i.x = t.x / e.x, i.y = t.y / e.y, i }, H.Point.equals = function(t, e) { return t.x === e.x && t.y === e.y }, H.Point.angle = function(t, e) { return Math.atan2(t.y - e.y, t.x - e.x) }, H.Point.negative = function(t, e) { return void 0 === e && (e = new H.Point), e.setTo(-t.x, -t.y) }, H.Point.multiplyAdd = function(t, e, i, s) { return void 0 === s && (s = new H.Point), s.setTo(t.x + e.x * i, t.y + e.y * i) }, H.Point.interpolate = function(t, e, i, s) { return void 0 === s && (s = new H.Point), s.setTo(t.x + (e.x - t.x) * i, t.y + (e.y - t.y) * i) }, H.Point.perp = function(t, e) { return void 0 === e && (e = new H.Point), e.setTo(-t.y, t.x) }, H.Point.rperp = function(t, e) { return void 0 === e && (e = new H.Point), e.setTo(t.y, -t.x) }, H.Point.distance = function(t, e, i) { var s = H.Math.distance(t.x, t.y, e.x, e.y); return i ? Math.round(s) : s }, H.Point.project = function(t, e, i) { void 0 === i && (i = new H.Point); var s = t.dot(e) / e.getMagnitudeSq(); return 0 !== s && i.setTo(s * e.x, s * e.y), i }, H.Point.projectUnit = function(t, e, i) { void 0 === i && (i = new H.Point); var s = t.dot(e); return 0 !== s && i.setTo(s * e.x, s * e.y), i }, H.Point.normalRightHand = function(t, e) { return void 0 === e && (e = new H.Point), e.setTo(-1 * t.y, t.x) }, H.Point.normalize = function(t, e) { void 0 === e && (e = new H.Point); var i = t.getMagnitude(); return 0 !== i && e.setTo(t.x / i, t.y / i), e }, H.Point.rotate = function(t, e, i, s, o, n) {
|
|
if (o && (s = H.Math.degToRad(s)), void 0 === n) {
|
|
t.subtract(e, i);
|
|
var a = Math.sin(s),
|
|
r = Math.cos(s),
|
|
h = r * t.x - a * t.y,
|
|
l = a * t.x + r * t.y;
|
|
t.x = h + e, t.y = l + i
|
|
}
|
|
else {
|
|
var c = s + Math.atan2(t.y - i, t.x - e);
|
|
t.x = e + n * Math.cos(c), t.y = i + n * Math.sin(c)
|
|
}
|
|
return t
|
|
}, H.Point.centroid = function(t, e) { if (void 0 === e && (e = new H.Point), "[object Array]" !== Object.prototype.toString.call(t)) throw new Error("Phaser.Point. Parameter 'points' must be an array"); var i = t.length; if (i < 1) throw new Error("Phaser.Point. Parameter 'points' array must not be empty"); if (1 === i) return e.copyFrom(t[0]), e; for (var s = 0; s < i; s++) H.Point.add(e, t[s], e); return e.divide(i, i), e }, H.Point.parse = function(t, e, i) { e = e || "x", i = i || "y"; var s = new H.Point; return t[e] && (s.x = parseInt(t[e], 10)), t[i] && (s.y = parseInt(t[i], 10)), s }, PIXI.Point = H.Point, H.Polygon = function() { this.area = 0, this._points = [], 0 < arguments.length && this.setTo.apply(this, arguments), this.closed = !0, this.flattened = !1, this.type = H.POLYGON }, H.Polygon.prototype = {
|
|
toNumberArray: function(t) { void 0 === t && (t = []); for (var e = 0; e < this._points.length; e++) "number" == typeof this._points[e] ? (t.push(this._points[e]), t.push(this._points[e + 1]), e++) : (t.push(this._points[e].x), t.push(this._points[e].y)); return t },
|
|
flatten: function() { return this._points = this.toNumberArray(), this.flattened = !0, this },
|
|
clone: function(t) { var e = this._points.slice(); return null == t ? t = new H.Polygon(e) : t.setTo(e), t },
|
|
contains: function(t, e) {
|
|
var i = !1;
|
|
if (this.flattened)
|
|
for (var s = -2, o = this._points.length - 2;
|
|
(s += 2) < this._points.length; o = s) {
|
|
var n = this._points[s],
|
|
a = this._points[s + 1],
|
|
r = this._points[o],
|
|
h = this._points[o + 1];
|
|
(a <= e && e < h || h <= e && e < a) && t < (r - n) * (e - a) / (h - a) + n && (i = !i)
|
|
}
|
|
else
|
|
for (s = -1, o = this._points.length - 1; ++s < this._points.length; o = s) {
|
|
n = this._points[s].x, a = this._points[s].y, r = this._points[o].x, h = this._points[o].y;
|
|
(a <= e && e < h || h <= e && e < a) && t < (r - n) * (e - a) / (h - a) + n && (i = !i)
|
|
}
|
|
return i
|
|
},
|
|
setTo: function(t) {
|
|
if (this.area = 0, this._points = [], 0 < arguments.length) {
|
|
Array.isArray(t) || (t = Array.prototype.slice.call(arguments));
|
|
for (var e = Number.MAX_VALUE, i = 0, s = t.length; i < s; i++) {
|
|
if ("number" == typeof t[i]) {
|
|
var o = new PIXI.Point(t[i], t[i + 1]);
|
|
i++
|
|
}
|
|
else if (Array.isArray(t[i])) o = new PIXI.Point(t[i][0], t[i][1]);
|
|
else o = new PIXI.Point(t[i].x, t[i].y);
|
|
this._points.push(o), o.y < e && (e = o.y)
|
|
}
|
|
this.calculateArea(e)
|
|
}
|
|
return this
|
|
},
|
|
calculateArea: function(t) { for (var e, i, s, o, n = 0, a = this._points.length; n < a; n++) e = this._points[n], i = n === a - 1 ? this._points[0] : this._points[n + 1], s = (e.y - t + (i.y - t)) / 2, o = e.x - i.x, this.area += s * o; return this.area }
|
|
}, H.Polygon.prototype.constructor = H.Polygon, Object.defineProperty(H.Polygon.prototype, "points", { get: function() { return this._points }, set: function(t) { null != t ? this.setTo(t) : this.setTo() } }), PIXI.Polygon = H.Polygon, H.Rectangle = function(t, e, i, s) { t = t || 0, e = e || 0, i = i || 0, s = s || 0, this.x = t, this.y = e, this.width = i, this.height = s, this.type = H.RECTANGLE }, H.Rectangle.prototype = {
|
|
offset: function(t, e) { return this.x += t, this.y += e, this },
|
|
offsetPoint: function(t) { return this.offset(t.x, t.y) },
|
|
setTo: function(t, e, i, s) { return this.x = t, this.y = e, this.width = i, this.height = s, this },
|
|
scale: function(t, e) { return void 0 === e && (e = t), this.width *= t, this.height *= e, this },
|
|
centerOn: function(t, e) { return this.centerX = t, this.centerY = e, this },
|
|
floor: function() { this.x = Math.floor(this.x), this.y = Math.floor(this.y) },
|
|
floorAll: function() { this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.width = Math.floor(this.width), this.height = Math.floor(this.height) },
|
|
ceil: function() { this.x = Math.ceil(this.x), this.y = Math.ceil(this.y) },
|
|
ceilAll: function() { this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.width = Math.ceil(this.width), this.height = Math.ceil(this.height) },
|
|
copyFrom: function(t) { return this.setTo(t.x, t.y, t.width, t.height) },
|
|
copyTo: function(t) { return t.x = this.x, t.y = this.y, t.width = this.width, t.height = this.height, t },
|
|
inflate: function(t, e) { return H.Rectangle.inflate(this, t, e) },
|
|
size: function(t) { return H.Rectangle.size(this, t) },
|
|
resize: function(t, e) { return this.width = t, this.height = e, this },
|
|
clone: function(t) { return H.Rectangle.clone(this, t) },
|
|
contains: function(t, e) { return H.Rectangle.contains(this, t, e) },
|
|
containsRect: function(t) { return H.Rectangle.containsRect(t, this) },
|
|
equals: function(t) { return H.Rectangle.equals(this, t) },
|
|
intersection: function(t, e) { return H.Rectangle.intersection(this, t, e) },
|
|
intersects: function(t) { return H.Rectangle.intersects(this, t) },
|
|
intersectsRaw: function(t, e, i, s, o) { return H.Rectangle.intersectsRaw(this, t, e, i, s, o) },
|
|
union: function(t, e) { return H.Rectangle.union(this, t, e) },
|
|
random: function(t) { return void 0 === t && (t = new H.Point), t.x = this.randomX, t.y = this.randomY, t },
|
|
getPoint: function(t, e) {
|
|
switch (void 0 === e && (e = new H.Point), t) {
|
|
default:
|
|
case H.TOP_LEFT:
|
|
return e.set(this.x, this.y);
|
|
case H.TOP_CENTER:
|
|
return e.set(this.centerX, this.y);
|
|
case H.TOP_RIGHT:
|
|
return e.set(this.right, this.y);
|
|
case H.LEFT_CENTER:
|
|
return e.set(this.x, this.centerY);
|
|
case H.CENTER:
|
|
return e.set(this.centerX, this.centerY);
|
|
case H.RIGHT_CENTER:
|
|
return e.set(this.right, this.centerY);
|
|
case H.BOTTOM_LEFT:
|
|
return e.set(this.x, this.bottom);
|
|
case H.BOTTOM_CENTER:
|
|
return e.set(this.centerX, this.bottom);
|
|
case H.BOTTOM_RIGHT:
|
|
return e.set(this.right, this.bottom)
|
|
}
|
|
},
|
|
toString: function() { return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]" }
|
|
}, Object.defineProperty(H.Rectangle.prototype, "halfWidth", { get: function() { return Math.round(this.width / 2) } }), Object.defineProperty(H.Rectangle.prototype, "halfHeight", { get: function() { return Math.round(this.height / 2) } }), Object.defineProperty(H.Rectangle.prototype, "bottom", { get: function() { return this.y + this.height }, set: function(t) { t <= this.y ? this.height = 0 : this.height = t - this.y } }), Object.defineProperty(H.Rectangle.prototype, "bottomLeft", { get: function() { return new H.Point(this.x, this.bottom) }, set: function(t) { this.x = t.x, this.bottom = t.y } }), Object.defineProperty(H.Rectangle.prototype, "bottomRight", { get: function() { return new H.Point(this.right, this.bottom) }, set: function(t) { this.right = t.x, this.bottom = t.y } }), Object.defineProperty(H.Rectangle.prototype, "left", { get: function() { return this.x }, set: function(t) { t >= this.right ? this.width = 0 : this.width = this.right - t, this.x = t } }), Object.defineProperty(H.Rectangle.prototype, "right", { get: function() { return this.x + this.width }, set: function(t) { t <= this.x ? this.width = 0 : this.width = t - this.x } }), Object.defineProperty(H.Rectangle.prototype, "volume", { get: function() { return this.width * this.height } }), Object.defineProperty(H.Rectangle.prototype, "perimeter", { get: function() { return 2 * this.width + 2 * this.height } }), Object.defineProperty(H.Rectangle.prototype, "centerX", { get: function() { return this.x + this.halfWidth }, set: function(t) { this.x = t - this.halfWidth } }), Object.defineProperty(H.Rectangle.prototype, "centerY", { get: function() { return this.y + this.halfHeight }, set: function(t) { this.y = t - this.halfHeight } }), Object.defineProperty(H.Rectangle.prototype, "randomX", { get: function() { return this.x + Math.random() * this.width } }), Object.defineProperty(H.Rectangle.prototype, "randomY", { get: function() { return this.y + Math.random() * this.height } }), Object.defineProperty(H.Rectangle.prototype, "top", { get: function() { return this.y }, set: function(t) { t >= this.bottom ? (this.height = 0, this.y = t) : this.height = this.bottom - t } }), Object.defineProperty(H.Rectangle.prototype, "topLeft", { get: function() { return new H.Point(this.x, this.y) }, set: function(t) { this.x = t.x, this.y = t.y } }), Object.defineProperty(H.Rectangle.prototype, "topRight", { get: function() { return new H.Point(this.x + this.width, this.y) }, set: function(t) { this.right = t.x, this.y = t.y } }), Object.defineProperty(H.Rectangle.prototype, "empty", { get: function() { return !this.width || !this.height }, set: function(t) {!0 === t && this.setTo(0, 0, 0, 0) } }), H.Rectangle.prototype.constructor = H.Rectangle, H.Rectangle.inflate = function(t, e, i) { return t.x -= e, t.width += 2 * e, t.y -= i, t.height += 2 * i, t }, H.Rectangle.inflatePoint = function(t, e) { return H.Rectangle.inflate(t, e.x, e.y) }, H.Rectangle.size = function(t, e) { return null == e ? e = new H.Point(t.width, t.height) : e.setTo(t.width, t.height), e }, H.Rectangle.clone = function(t, e) { return null == e ? e = new H.Rectangle(t.x, t.y, t.width, t.height) : e.setTo(t.x, t.y, t.width, t.height), e }, H.Rectangle.contains = function(t, e, i) { return !(t.width <= 0 || t.height <= 0) && (e >= t.x && e < t.right && i >= t.y && i < t.bottom) }, H.Rectangle.containsRaw = function(t, e, i, s, o, n) { return t <= o && o < t + i && e <= n && n < e + s }, H.Rectangle.containsPoint = function(t, e) { return H.Rectangle.contains(t, e.x, e.y) }, H.Rectangle.containsRect = function(t, e) { return !(t.volume > e.volume) && (t.x >= e.x && t.y >= e.y && t.right < e.right && t.bottom < e.bottom) }, H.Rectangle.equals = function(t, e) { return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height }, H.Rectangle.sameDimensions = function(t, e) { return t.width === e.width && t.height === e.height }, H.Rectangle.intersection = function(t, e, i) { return void 0 === i && (i = new H.Rectangle), H.Rectangle.intersects(t, e) && (i.x = Math.max(t.x, e.x), i.y = Math.max(t.y, e.y), i.width = Math.min(t.right, e.right) - i.x, i.height = Math.min(t.bottom, e.bottom) - i.y), i }, H.Rectangle.intersects = function(t, e) { return !(t.width <= 0 || t.height <= 0 || e.width <= 0 || e.height <= 0) && !(t.right < e.x || t.bottom < e.y || t.x > e.right || t.y > e.bottom) }, H.Rectangle.intersectsRaw = function(t, e, i, s, o, n) { return void 0 === n && (n = 0), !(e > t.right + n || i < t.left - n || s > t.bottom + n || o < t.top - n) }, H.Rectangle.union = function(t, e, i) { return void 0 === i && (i = new H.Rectangle), i.setTo(Math.min(t.x, e.x), Math.min(t.y, e.y), Math.max(t.right, e.right) - Math.min(t.left, e.left), Math.max(t.bottom, e.bottom) - Math.min(t.top, e.top)) }, H.Rectangle.aabb = function(t, e) {
|
|
void 0 === e && (e = new H.Rectangle);
|
|
var i = Number.NEGATIVE_INFINITY,
|
|
s = Number.POSITIVE_INFINITY,
|
|
o = Number.NEGATIVE_INFINITY,
|
|
n = Number.POSITIVE_INFINITY;
|
|
return t.forEach(function(t) { t.x > i && (i = t.x), t.x < s && (s = t.x), t.y > o && (o = t.y), t.y < n && (n = t.y) }), e.setTo(s, n, i - s, o - n), e
|
|
}, PIXI.Rectangle = H.Rectangle, PIXI.EmptyRectangle = new H.Rectangle(0, 0, 0, 0), H.RoundedRectangle = function(t, e, i, s, o) { void 0 === t && (t = 0), void 0 === e && (e = 0), void 0 === i && (i = 0), void 0 === s && (s = 0), void 0 === o && (o = 20), this.x = t, this.y = e, this.width = i, this.height = s, this.radius = o || 20, this.type = H.ROUNDEDRECTANGLE }, H.RoundedRectangle.prototype = { clone: function() { return new H.RoundedRectangle(this.x, this.y, this.width, this.height, this.radius) }, contains: function(t, e) { if (this.width <= 0 || this.height <= 0) return !1; var i = this.x; if (i <= t && t <= i + this.width) { var s = this.y; if (s <= e && e <= s + this.height) return !0 } return !1 } }, H.RoundedRectangle.prototype.constructor = H.RoundedRectangle, PIXI.RoundedRectangle = H.RoundedRectangle, H.Camera = function(t, e, i, s, o, n) { this.game = t, this.world = t.world, this.id = 0, this.view = new H.Rectangle(i, s, o, n), this.bounds = new H.Rectangle(i, s, o, n), this.deadzone = null, this.visible = !0, this.roundPx = !0, this.atLimit = { x: !1, y: !1 }, this.target = null, this.displayObject = null, this.scale = null, this.totalInView = 0, this.lerp = new H.Point(1, 1), this.onShakeComplete = new H.Signal, this.onFlashComplete = new H.Signal, this.onFadeComplete = new H.Signal, this.fx = null, this._targetPosition = new H.Point, this._edge = 0, this._position = new H.Point, this._shake = { intensity: 0, duration: 0, horizontal: !1, vertical: !1, shakeBounds: !0, x: 0, y: 0 }, this._fxDuration = 0, this._fxType = 0 }, H.Camera.FOLLOW_LOCKON = 0, H.Camera.FOLLOW_PLATFORMER = 1, H.Camera.FOLLOW_TOPDOWN = 2, H.Camera.FOLLOW_TOPDOWN_TIGHT = 3, H.Camera.SHAKE_BOTH = 4, H.Camera.SHAKE_HORIZONTAL = 5, H.Camera.SHAKE_VERTICAL = 6, H.Camera.ENABLE_FX = !0, H.Camera.prototype = {
|
|
boot: function() { this.displayObject = this.game.world, this.scale = this.game.world.scale, this.game.camera = this, H.Graphics && H.Camera.ENABLE_FX && (this.fx = new H.Graphics(this.game), this.game.stage.addChild(this.fx)) },
|
|
preUpdate: function() { this.totalInView = 0 },
|
|
follow: function(t, e, i, s) {
|
|
var o;
|
|
switch (void 0 === e && (e = H.Camera.FOLLOW_LOCKON), void 0 === i && (i = 1), void 0 === s && (s = 1), this.target = t, this.lerp.set(i, s), e) {
|
|
case H.Camera.FOLLOW_PLATFORMER:
|
|
var n = this.width / 8,
|
|
a = this.height / 3;
|
|
this.deadzone = new H.Rectangle((this.width - n) / 2, (this.height - a) / 2 - .25 * a, n, a);
|
|
break;
|
|
case H.Camera.FOLLOW_TOPDOWN:
|
|
o = Math.max(this.width, this.height) / 4, this.deadzone = new H.Rectangle((this.width - o) / 2, (this.height - o) / 2, o, o);
|
|
break;
|
|
case H.Camera.FOLLOW_TOPDOWN_TIGHT:
|
|
o = Math.max(this.width, this.height) / 8, this.deadzone = new H.Rectangle((this.width - o) / 2, (this.height - o) / 2, o, o);
|
|
break;
|
|
case H.Camera.FOLLOW_LOCKON:
|
|
default:
|
|
this.deadzone = null
|
|
}
|
|
},
|
|
unfollow: function() { this.target = null },
|
|
focusOn: function(t) { this.setPosition(Math.round(t.x - this.view.halfWidth), Math.round(t.y - this.view.halfHeight)) },
|
|
focusOnXY: function(t, e) { this.setPosition(Math.round(t - this.view.halfWidth), Math.round(e - this.view.halfHeight)) },
|
|
shake: function(t, e, i, s, o) { return void 0 === t && (t = .05), void 0 === e && (e = 500), void 0 === i && (i = !0), void 0 === s && (s = H.Camera.SHAKE_BOTH), void 0 === o && (o = !0), !(!i && 0 < this._shake.duration) && (this._shake.intensity = t, this._shake.duration = e, this._shake.shakeBounds = o, this._shake.x = 0, this._shake.y = 0, this._shake.horizontal = s === H.Camera.SHAKE_BOTH || s === H.Camera.SHAKE_HORIZONTAL, this._shake.vertical = s === H.Camera.SHAKE_BOTH || s === H.Camera.SHAKE_VERTICAL, !0) },
|
|
flash: function(t, e, i) { return void 0 === t && (t = 16777215), void 0 === e && (e = 500), void 0 === i && (i = !1), !(!this.fx || !i && 0 < this._fxDuration) && (this.fx.clear(), this.fx.beginFill(t), this.fx.drawRect(0, 0, this.width, this.height), this.fx.endFill(), this.fx.alpha = 1, this._fxDuration = e, !(this._fxType = 0)) },
|
|
fade: function(t, e, i) { return void 0 === t && (t = 0), void 0 === e && (e = 500), void 0 === i && (i = !1), !(!this.fx || !i && 0 < this._fxDuration) && (this.fx.clear(), this.fx.beginFill(t), this.fx.drawRect(0, 0, this.width, this.height), this.fx.endFill(), this.fx.alpha = 0, this._fxDuration = e, this._fxType = 1, !0) },
|
|
update: function() { 0 < this._fxDuration && this.updateFX(), 0 < this._shake.duration && this.updateShake(), this.bounds && this.checkBounds(), this.roundPx && (this.view.floor(), this._shake.x = Math.floor(this._shake.x), this._shake.y = Math.floor(this._shake.y)), this.displayObject.position.x = -this.view.x, this.displayObject.position.y = -this.view.y },
|
|
updateFX: function() { 0 === this._fxType ? (this.fx.alpha -= this.game.time.elapsedMS / this._fxDuration, this.fx.alpha <= 0 && (this._fxDuration = 0, this.fx.alpha = 0, this.onFlashComplete.dispatch())) : (this.fx.alpha += this.game.time.elapsedMS / this._fxDuration, 1 <= this.fx.alpha && (this._fxDuration = 0, this.fx.alpha = 1, this.onFadeComplete.dispatch())) },
|
|
updateShake: function() { this._shake.duration -= this.game.time.elapsedMS, this._shake.duration <= 0 ? (this.onShakeComplete.dispatch(), this._shake.x = 0, this._shake.y = 0) : (this._shake.horizontal && (this._shake.x = this.game.rnd.frac() * this._shake.intensity * this.view.width * 2 - this._shake.intensity * this.view.width), this._shake.vertical && (this._shake.y = this.game.rnd.frac() * this._shake.intensity * this.view.height * 2 - this._shake.intensity * this.view.height)) },
|
|
updateTarget: function() { this._targetPosition.x = this.view.x + this.target.worldPosition.x, this._targetPosition.y = this.view.y + this.target.worldPosition.y, this.deadzone ? (this._edge = this._targetPosition.x - this.view.x, this._edge < this.deadzone.left ? this.view.x = this.game.math.linear(this.view.x, this._targetPosition.x - this.deadzone.left, this.lerp.x) : this._edge > this.deadzone.right && (this.view.x = this.game.math.linear(this.view.x, this._targetPosition.x - this.deadzone.right, this.lerp.x)), this._edge = this._targetPosition.y - this.view.y, this._edge < this.deadzone.top ? this.view.y = this.game.math.linear(this.view.y, this._targetPosition.y - this.deadzone.top, this.lerp.y) : this._edge > this.deadzone.bottom && (this.view.y = this.game.math.linear(this.view.y, this._targetPosition.y - this.deadzone.bottom, this.lerp.y))) : (this.view.x = this.game.math.linear(this.view.x, this._targetPosition.x - this.view.halfWidth, this.lerp.x), this.view.y = this.game.math.linear(this.view.y, this._targetPosition.y - this.view.halfHeight, this.lerp.y)), this.bounds && this.checkBounds(), this.roundPx && this.view.floor(), this.displayObject.position.x = -this.view.x, this.displayObject.position.y = -this.view.y },
|
|
setBoundsToWorld: function() { this.bounds && this.bounds.copyFrom(this.game.world.bounds) },
|
|
checkBounds: function() {
|
|
this.atLimit.x = !1, this.atLimit.y = !1;
|
|
var t = this.view.x + this._shake.x,
|
|
e = this.view.right + this._shake.x,
|
|
i = this.view.y + this._shake.y,
|
|
s = this.view.bottom + this._shake.y;
|
|
t <= this.bounds.x * this.scale.x && (this.atLimit.x = !0, this.view.x = this.bounds.x * this.scale.x, this._shake.shakeBounds || (this._shake.x = 0)), e >= this.bounds.right * this.scale.x && (this.atLimit.x = !0, this.view.x = this.bounds.right * this.scale.x - this.width, this._shake.shakeBounds || (this._shake.x = 0)), i <= this.bounds.top * this.scale.y && (this.atLimit.y = !0, this.view.y = this.bounds.top * this.scale.y, this._shake.shakeBounds || (this._shake.y = 0)), s >= this.bounds.bottom * this.scale.y && (this.atLimit.y = !0, this.view.y = this.bounds.bottom * this.scale.y - this.height, this._shake.shakeBounds || (this._shake.y = 0))
|
|
},
|
|
setPosition: function(t, e) { this.view.x = t, this.view.y = e, this.bounds && this.checkBounds() },
|
|
setSize: function(t, e) { this.view.width = t, this.view.height = e },
|
|
reset: function() { this.target = null, this.view.x = 0, this.view.y = 0, this._shake.duration = 0, this.resetFX() },
|
|
resetFX: function() { this.fx && (this.fx.clear(), this.fx.alpha = 0, this._fxDuration = 0) }
|
|
}, H.Camera.prototype.constructor = H.Camera, Object.defineProperty(H.Camera.prototype, "x", { get: function() { return this.view.x }, set: function(t) { this.view.x = t, this.bounds && this.checkBounds() } }), Object.defineProperty(H.Camera.prototype, "y", { get: function() { return this.view.y }, set: function(t) { this.view.y = t, this.bounds && this.checkBounds() } }), Object.defineProperty(H.Camera.prototype, "position", { get: function() { return this._position.set(this.view.x, this.view.y), this._position }, set: function(t) { void 0 !== t.x && (this.view.x = t.x), void 0 !== t.y && (this.view.y = t.y), this.bounds && this.checkBounds() } }), Object.defineProperty(H.Camera.prototype, "width", { get: function() { return this.view.width }, set: function(t) { this.view.width = t } }), Object.defineProperty(H.Camera.prototype, "height", { get: function() { return this.view.height }, set: function(t) { this.view.height = t } }), Object.defineProperty(H.Camera.prototype, "shakeIntensity", { get: function() { return this._shake.intensity }, set: function(t) { this._shake.intensity = t } }), H.State = function() { this.game = null, this.key = "", this.add = null, this.make = null, this.camera = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.sound = null, this.scale = null, this.stage = null, this.state = null, this.time = null, this.tweens = null, this.world = null, this.particles = null, this.physics = null, this.rnd = null }, H.State.prototype = { init: function() {}, preload: function() {}, loadUpdate: function() {}, loadRender: function() {}, create: function() {}, update: function() {}, preRender: function() {}, render: function() {}, resize: function() {}, paused: function() {}, resumed: function() {}, pauseUpdate: function() {}, shutdown: function() {} }, H.State.prototype.constructor = H.State, H.StateManager = function(t, e) { this.game = t, this.states = {}, (this._pendingState = null) != e && (this._pendingState = e), this._clearWorld = !1, this._clearCache = !1, this._created = !1, this._args = [], this.current = "", this.onStateChange = new H.Signal, this.onInitCallback = null, this.onPreloadCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onResizeCallback = null, this.onPreRenderCallback = null, this.onLoadUpdateCallback = null, this.onLoadRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null, this.onShutDownCallback = null }, H.StateManager.prototype = {
|
|
boot: function() { this.game.onPause.add(this.pause, this), this.game.onResume.add(this.resume, this), null !== this._pendingState && "string" != typeof this._pendingState && this.add("default", this._pendingState, !0) },
|
|
add: function(t, e, i) { var s; return void 0 === i && (i = !1), e instanceof H.State ? s = e : "object" == typeof e ? (s = e).game = this.game : "function" == typeof e && (s = new e(this.game)), this.states[t] = s, i && (this.game.isBooted ? this.start(t) : this._pendingState = t), s },
|
|
remove: function(t) { this.current === t && (this.callbackContext = null, this.onInitCallback = null, this.onShutDownCallback = null, this.onPreloadCallback = null, this.onLoadRenderCallback = null, this.onLoadUpdateCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onPreRenderCallback = null, this.onRenderCallback = null, this.onResizeCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null), delete this.states[t] },
|
|
start: function(t, e, i) { void 0 === e && (e = !0), void 0 === i && (i = !1), this.checkState(t) && (this._pendingState = t, this._clearWorld = e, this._clearCache = i, 3 < arguments.length && (this._args = Array.prototype.splice.call(arguments, 3))) },
|
|
restart: function(t, e) { void 0 === t && (t = !0), void 0 === e && (e = !1), this._pendingState = this.current, this._clearWorld = t, this._clearCache = e, 2 < arguments.length && (this._args = Array.prototype.slice.call(arguments, 2)) },
|
|
dummy: function() {},
|
|
preUpdate: function() {
|
|
if (this._pendingState && this.game.isBooted) {
|
|
var t = this.current;
|
|
if (this.clearCurrentState(), this.setCurrentState(this._pendingState), this.onStateChange.dispatch(this.current, t), this.current !== this._pendingState) return;
|
|
this._pendingState = null, this.onPreloadCallback ? (this.game.load.reset(!0), this.onPreloadCallback.call(this.callbackContext, this.game), 0 === this.game.load.totalQueuedFiles() && 0 === this.game.load.totalQueuedPacks() ? this.loadComplete() : this.game.load.start()) : this.loadComplete()
|
|
}
|
|
},
|
|
clearCurrentState: function() { this.current && (this.onShutDownCallback && this.onShutDownCallback.call(this.callbackContext, this.game), this.game.tweens.removeAll(), this.game.camera.reset(), this.game.input.reset(!0), this.game.physics.clear(), this.game.time.removeAll(), this.game.scale.reset(this._clearWorld), this.game.debug && this.game.debug.reset(), this._clearWorld && (this.game.world.shutdown(), this._clearCache && this.game.cache.destroy())) },
|
|
checkState: function(t) { return !!this.states[t] && !!(this.states[t].preload || this.states[t].create || this.states[t].update || this.states[t].render) },
|
|
link: function(t) { this.states[t].game = this.game, this.states[t].add = this.game.add, this.states[t].make = this.game.make, this.states[t].camera = this.game.camera, this.states[t].cache = this.game.cache, this.states[t].input = this.game.input, this.states[t].load = this.game.load, this.states[t].math = this.game.math, this.states[t].sound = this.game.sound, this.states[t].scale = this.game.scale, (this.states[t].state = this).states[t].stage = this.game.stage, this.states[t].time = this.game.time, this.states[t].tweens = this.game.tweens, this.states[t].world = this.game.world, this.states[t].particles = this.game.particles, this.states[t].rnd = this.game.rnd, this.states[t].physics = this.game.physics, this.states[t].key = t },
|
|
unlink: function(t) { this.states[t] && (this.states[t].game = null, this.states[t].add = null, this.states[t].make = null, this.states[t].camera = null, this.states[t].cache = null, this.states[t].input = null, this.states[t].load = null, this.states[t].math = null, this.states[t].sound = null, this.states[t].scale = null, this.states[t].state = null, this.states[t].stage = null, this.states[t].time = null, this.states[t].tweens = null, this.states[t].world = null, this.states[t].particles = null, this.states[t].rnd = null, this.states[t].physics = null) },
|
|
setCurrentState: function(t) { this.callbackContext = this.states[t], this.link(t), this.onInitCallback = this.states[t].init || this.dummy, this.onPreloadCallback = this.states[t].preload || null, this.onLoadRenderCallback = this.states[t].loadRender || null, this.onLoadUpdateCallback = this.states[t].loadUpdate || null, this.onCreateCallback = this.states[t].create || null, this.onUpdateCallback = this.states[t].update || null, this.onPreRenderCallback = this.states[t].preRender || null, this.onRenderCallback = this.states[t].render || null, this.onResizeCallback = this.states[t].resize || null, this.onPausedCallback = this.states[t].paused || null, this.onResumedCallback = this.states[t].resumed || null, this.onPauseUpdateCallback = this.states[t].pauseUpdate || null, this.onShutDownCallback = this.states[t].shutdown || this.dummy, "" !== this.current && this.game.physics.reset(), this.current = t, this._created = !1, this.onInitCallback.apply(this.callbackContext, this._args), t === this._pendingState && (this._args = []), this.game._kickstart = !0 },
|
|
getCurrentState: function() { return this.states[this.current] },
|
|
loadComplete: function() {!1 === this._created && this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game), !1 === this._created && this.onCreateCallback ? (this._created = !0, this.onCreateCallback.call(this.callbackContext, this.game)) : this._created = !0 },
|
|
pause: function() { this._created && this.onPausedCallback && this.onPausedCallback.call(this.callbackContext, this.game) },
|
|
resume: function() { this._created && this.onResumedCallback && this.onResumedCallback.call(this.callbackContext, this.game) },
|
|
update: function() { this._created ? this.onUpdateCallback && this.onUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game) },
|
|
pauseUpdate: function() { this._created ? this.onPauseUpdateCallback && this.onPauseUpdateCallback.call(this.callbackContext, this.game) : this.onLoadUpdateCallback && this.onLoadUpdateCallback.call(this.callbackContext, this.game) },
|
|
preRender: function(t) { this._created && this.onPreRenderCallback && this.onPreRenderCallback.call(this.callbackContext, this.game, t) },
|
|
resize: function(t, e) { this.onResizeCallback && this.onResizeCallback.call(this.callbackContext, t, e) },
|
|
render: function() { this._created ? this.onRenderCallback && (this.game.renderType === H.CANVAS ? (this.game.context.save(), this.game.context.setTransform(1, 0, 0, 1, 0, 0), this.onRenderCallback.call(this.callbackContext, this.game), this.game.context.restore()) : this.onRenderCallback.call(this.callbackContext, this.game)) : this.onLoadRenderCallback && this.onLoadRenderCallback.call(this.callbackContext, this.game) },
|
|
destroy: function() { this._clearWorld = !0, this._clearCache = !0, this.clearCurrentState(), this.callbackContext = null, this.onInitCallback = null, this.onShutDownCallback = null, this.onPreloadCallback = null, this.onLoadRenderCallback = null, this.onLoadUpdateCallback = null, this.onCreateCallback = null, this.onUpdateCallback = null, this.onRenderCallback = null, this.onPausedCallback = null, this.onResumedCallback = null, this.onPauseUpdateCallback = null, this.game = null, this.states = {}, this._pendingState = null, this.current = "" }
|
|
}, H.StateManager.prototype.constructor = H.StateManager, Object.defineProperty(H.StateManager.prototype, "created", { get: function() { return this._created } }), H.Signal = function() {}, H.Signal.prototype = {
|
|
_bindings: null,
|
|
_prevParams: null,
|
|
memorize: !1,
|
|
_shouldPropagate: !0,
|
|
active: !0,
|
|
_boundDispatch: !1,
|
|
validateListener: function(t, e) { if ("function" != typeof t) throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}", e)) },
|
|
_registerListener: function(t, e, i, s, o) { var n, a = this._indexOfListener(t, i); if (-1 !== a) { if ((n = this._bindings[a]).isOnce() !== e) throw new Error("You cannot add" + (e ? "" : "Once") + "() then add" + (e ? "Once" : "") + "() the same listener without removing the relationship first.") } else n = new H.SignalBinding(this, t, e, i, s, o), this._addBinding(n); return this.memorize && this._prevParams && n.execute(this._prevParams), n },
|
|
_addBinding: function(t) {
|
|
this._bindings || (this._bindings = []);
|
|
for (var e = this._bindings.length; e--, this._bindings[e] && t._priority <= this._bindings[e]._priority;);
|
|
this._bindings.splice(e + 1, 0, t)
|
|
},
|
|
_indexOfListener: function(t, e) {
|
|
if (!this._bindings) return -1;
|
|
void 0 === e && (e = null);
|
|
for (var i, s = this._bindings.length; s--;)
|
|
if ((i = this._bindings[s])._listener === t && i.context === e) return s;
|
|
return -1
|
|
},
|
|
has: function(t, e) { return -1 !== this._indexOfListener(t, e) },
|
|
add: function(t, e, i) {
|
|
this.validateListener(t, "add");
|
|
var s = [];
|
|
if (3 < arguments.length)
|
|
for (var o = 3; o < arguments.length; o++) s.push(arguments[o]);
|
|
return this._registerListener(t, !1, e, i, s)
|
|
},
|
|
addOnce: function(t, e, i) {
|
|
this.validateListener(t, "addOnce");
|
|
var s = [];
|
|
if (3 < arguments.length)
|
|
for (var o = 3; o < arguments.length; o++) s.push(arguments[o]);
|
|
return this._registerListener(t, !0, e, i, s)
|
|
},
|
|
remove: function(t, e) { this.validateListener(t, "remove"); var i = this._indexOfListener(t, e); return -1 !== i && (this._bindings[i]._destroy(), this._bindings.splice(i, 1)), t },
|
|
removeAll: function(t) {
|
|
if (void 0 === t && (t = null), this._bindings) {
|
|
for (var e = this._bindings.length; e--;) t ? this._bindings[e].context === t && (this._bindings[e]._destroy(), this._bindings.splice(e, 1)) : this._bindings[e]._destroy();
|
|
t || (this._bindings.length = 0)
|
|
}
|
|
},
|
|
getNumListeners: function() { return this._bindings ? this._bindings.length : 0 },
|
|
halt: function() { this._shouldPropagate = !1 },
|
|
dispatch: function() {
|
|
if (this.active && this._bindings) {
|
|
var t, e = Array.prototype.slice.call(arguments),
|
|
i = this._bindings.length;
|
|
if (this.memorize && (this._prevParams = e), i)
|
|
for (t = this._bindings.slice(), this._shouldPropagate = !0; t[--i] && this._shouldPropagate && !1 !== t[i].execute(e););
|
|
}
|
|
},
|
|
forget: function() { this._prevParams && (this._prevParams = null) },
|
|
dispose: function() { this.removeAll(), this._bindings = null, this._prevParams && (this._prevParams = null) },
|
|
toString: function() { return "[Phaser.Signal active:" + this.active + " numListeners:" + this.getNumListeners() + "]" }
|
|
}, Object.defineProperty(H.Signal.prototype, "boundDispatch", { get: function() { var t = this; return this._boundDispatch || (this._boundDispatch = function() { return t.dispatch.apply(t, arguments) }) } }), H.Signal.prototype.constructor = H.Signal, H.SignalBinding = function(t, e, i, s, o, n) { this._listener = e, i && (this._isOnce = !0), null != s && (this.context = s), this._signal = t, o && (this._priority = o), n && n.length && (this._args = n) }, H.SignalBinding.prototype = { context: null, _isOnce: !1, _priority: 0, _args: null, callCount: 0, active: !0, params: null, execute: function(t) { var e, i; return this.active && this._listener && (i = this.params ? this.params.concat(t) : t, this._args && (i = i.concat(this._args)), e = this._listener.apply(this.context, i), this.callCount++, this._isOnce && this.detach()), e }, detach: function() { return this.isBound() ? this._signal.remove(this._listener, this.context) : null }, isBound: function() { return !!this._signal && !!this._listener }, isOnce: function() { return this._isOnce }, getListener: function() { return this._listener }, getSignal: function() { return this._signal }, _destroy: function() { delete this._signal, delete this._listener, delete this.context }, toString: function() { return "[Phaser.SignalBinding isOnce:" + this._isOnce + ", isBound:" + this.isBound() + ", active:" + this.active + "]" } }, H.SignalBinding.prototype.constructor = H.SignalBinding, H.Filter = function(t, e, i) {
|
|
this.game = t, this.type = H.WEBGL_FILTER, this.passes = [this], this.shaders = [], this.dirty = !0, this.padding = 0, this.prevPoint = new H.Point;
|
|
var s = new Date;
|
|
if (this.uniforms = { resolution: { type: "2f", value: { x: 256, y: 256 } }, time: { type: "1f", value: 0 }, mouse: { type: "2f", value: { x: 0, y: 0 } }, date: { type: "4fv", value: [s.getFullYear(), s.getMonth(), s.getDate(), 60 * s.getHours() * 60 + 60 * s.getMinutes() + s.getSeconds()] }, sampleRate: { type: "1f", value: 44100 }, iChannel0: { type: "sampler2D", value: null, textureData: { repeat: !0 } }, iChannel1: { type: "sampler2D", value: null, textureData: { repeat: !0 } }, iChannel2: { type: "sampler2D", value: null, textureData: { repeat: !0 } }, iChannel3: { type: "sampler2D", value: null, textureData: { repeat: !0 } } }, e)
|
|
for (var o in e) this.uniforms[o] = e[o];
|
|
this.fragmentSrc = i || ""
|
|
}, H.Filter.prototype = {
|
|
init: function() {},
|
|
setResolution: function(t, e) { this.uniforms.resolution.value.x = t, this.uniforms.resolution.value.y = e },
|
|
update: function(t) {
|
|
if (void 0 !== t) {
|
|
var e = t.x / this.game.width,
|
|
i = 1 - t.y / this.game.height;
|
|
e === this.prevPoint.x && i === this.prevPoint.y || (this.uniforms.mouse.value.x = e.toFixed(2), this.uniforms.mouse.value.y = i.toFixed(2), this.prevPoint.set(e, i))
|
|
}
|
|
this.uniforms.time.value = this.game.time.totalElapsedSeconds()
|
|
},
|
|
addToWorld: function(t, e, i, s, o, n) { void 0 === o && (o = 0), void 0 === n && (n = 0), null != i ? this.width = i : i = this.width, null != s ? this.height = s : s = this.height; var a = this.game.add.image(t, e, "__default"); return a.width = i, a.height = s, a.anchor.set(o, n), a.filters = [this], a },
|
|
destroy: function() { this.game = null }
|
|
}, H.Filter.prototype.constructor = H.Filter, Object.defineProperty(H.Filter.prototype, "width", { get: function() { return this.uniforms.resolution.value.x }, set: function(t) { this.uniforms.resolution.value.x = t } }), Object.defineProperty(H.Filter.prototype, "height", { get: function() { return this.uniforms.resolution.value.y }, set: function(t) { this.uniforms.resolution.value.y = t } }), H.Plugin = function(t, e) { void 0 === e && (e = null), this.game = t, this.parent = e, this.active = !1, this.visible = !1, this.hasPreUpdate = !1, this.hasUpdate = !1, this.hasPostUpdate = !1, this.hasRender = !1, this.hasPostRender = !1 }, H.Plugin.prototype = { preUpdate: function() {}, update: function() {}, render: function() {}, postRender: function() {}, destroy: function() { this.game = null, this.parent = null, this.active = !1, this.visible = !1 } }, H.Plugin.prototype.constructor = H.Plugin, H.PluginManager = function(t) { this.game = t, this.plugins = [], this._len = 0, this._i = 0 }, H.PluginManager.prototype = {
|
|
add: function(t) {
|
|
var e = Array.prototype.slice.call(arguments, 1),
|
|
i = !1;
|
|
return "function" == typeof t ? t = new t(this.game, this) : (t.game = this.game, t.parent = this), "function" == typeof t.preUpdate && (i = t.hasPreUpdate = !0), "function" == typeof t.update && (i = t.hasUpdate = !0), "function" == typeof t.postUpdate && (i = t.hasPostUpdate = !0), "function" == typeof t.render && (i = t.hasRender = !0), "function" == typeof t.postRender && (i = t.hasPostRender = !0), i ? ((t.hasPreUpdate || t.hasUpdate || t.hasPostUpdate) && (t.active = !0), (t.hasRender || t.hasPostRender) && (t.visible = !0), this._len = this.plugins.push(t), "function" == typeof t.init && t.init.apply(t, e), t) : null
|
|
},
|
|
remove: function(t, e) {
|
|
for (void 0 === e && (e = !0), this._i = this._len; this._i--;)
|
|
if (this.plugins[this._i] === t) return e && t.destroy(), this.plugins.splice(this._i, 1), void this._len--
|
|
},
|
|
removeAll: function() {
|
|
for (this._i = this._len; this._i--;) this.plugins[this._i].destroy();
|
|
this.plugins.length = 0, this._len = 0
|
|
},
|
|
preUpdate: function() { for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPreUpdate && this.plugins[this._i].preUpdate() },
|
|
update: function() { for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasUpdate && this.plugins[this._i].update() },
|
|
postUpdate: function() { for (this._i = this._len; this._i--;) this.plugins[this._i].active && this.plugins[this._i].hasPostUpdate && this.plugins[this._i].postUpdate() },
|
|
render: function() { for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasRender && this.plugins[this._i].render() },
|
|
postRender: function() { for (this._i = this._len; this._i--;) this.plugins[this._i].visible && this.plugins[this._i].hasPostRender && this.plugins[this._i].postRender() },
|
|
destroy: function() { this.removeAll(), this.game = null }
|
|
}, H.PluginManager.prototype.constructor = H.PluginManager, H.Stage = function(t) { this.game = t, PIXI.DisplayObjectContainer.call(this), this.name = "_stage_root", this.disableVisibilityChange = !1, this.exists = !0, this.worldTransform = new PIXI.Matrix, (this.stage = this).currentRenderOrderID = 0, this._hiddenVar = "hidden", this._onChange = null, this._bgColor = { r: 0, g: 0, b: 0, a: 0, color: 0, rgba: "#000000" }, this.game.transparent || (this._bgColor.a = 1), t.config && this.parseConfig(t.config) }, H.Stage.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), H.Stage.prototype.constructor = H.Stage, H.Stage.prototype.parseConfig = function(t) { t.disableVisibilityChange && (this.disableVisibilityChange = t.disableVisibilityChange), t.backgroundColor && this.setBackgroundColor(t.backgroundColor) }, H.Stage.prototype.boot = function() { H.DOM.getOffset(this.game.canvas, this.offset), H.Canvas.setUserSelect(this.game.canvas, "none"), H.Canvas.setTouchAction(this.game.canvas, "none"), this.checkVisibility() }, H.Stage.prototype.preUpdate = function() { for (var t = this.currentRenderOrderID = 0; t < this.children.length; t++) this.children[t].preUpdate() }, H.Stage.prototype.update = function() { for (var t = this.children.length; t--;) this.children[t].update() }, H.Stage.prototype.postUpdate = function() {
|
|
this.game.camera.update(), this.game.camera.target && (this.game.camera.target.postUpdate(), this.updateTransform(), this.game.camera.updateTarget());
|
|
for (var t = 0; t < this.children.length; t++) this.children[t].postUpdate();
|
|
this.updateTransform()
|
|
}, H.Stage.prototype.updateTransform = function() { this.worldAlpha = 1; for (var t = 0; t < this.children.length; t++) this.children[t].updateTransform() }, H.Stage.prototype.checkVisibility = function() {
|
|
void 0 !== document.hidden ? this._hiddenVar = "visibilitychange" : void 0 !== document.webkitHidden ? this._hiddenVar = "webkitvisibilitychange" : void 0 !== document.mozHidden ? this._hiddenVar = "mozvisibilitychange" : void 0 !== document.msHidden ? this._hiddenVar = "msvisibilitychange" : this._hiddenVar = null;
|
|
var e = this;
|
|
this._onChange = function(t) { return e.visibilityChange(t) }, this._hiddenVar && document.addEventListener(this._hiddenVar, this._onChange, !1), window.onblur = this._onChange, window.onfocus = this._onChange, window.onpagehide = this._onChange, window.onpageshow = this._onChange, this.game.device.cocoonJSApp && (CocoonJS.App.onSuspended.addEventListener(function() { H.Stage.prototype.visibilityChange.call(e, { type: "pause" }) }), CocoonJS.App.onActivated.addEventListener(function() { H.Stage.prototype.visibilityChange.call(e, { type: "resume" }) }))
|
|
}, H.Stage.prototype.visibilityChange = function(t) { "pagehide" !== t.type && "blur" !== t.type && "pageshow" !== t.type && "focus" !== t.type ? this.disableVisibilityChange || (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden || "pause" === t.type ? this.game.gamePaused(t) : this.game.gameResumed(t)) : "pagehide" === t.type || "blur" === t.type ? this.game.focusLoss(t) : "pageshow" !== t.type && "focus" !== t.type || this.game.focusGain(t) }, H.Stage.prototype.setBackgroundColor = function(t) { this.game.transparent || (H.Color.valueToColor(t, this._bgColor), H.Color.updateColor(this._bgColor), this._bgColor.r /= 255, this._bgColor.g /= 255, this._bgColor.b /= 255, this._bgColor.a = 1) }, H.Stage.prototype.destroy = function() { this._hiddenVar && document.removeEventListener(this._hiddenVar, this._onChange, !1), window.onpagehide = null, window.onpageshow = null, window.onblur = null, window.onfocus = null }, Object.defineProperty(H.Stage.prototype, "backgroundColor", { get: function() { return this._bgColor.color }, set: function(t) { this.setBackgroundColor(t) } }), Object.defineProperty(H.Stage.prototype, "smoothed", { get: function() { return PIXI.scaleModes.DEFAULT === PIXI.scaleModes.LINEAR }, set: function(t) { PIXI.scaleModes.DEFAULT = t ? PIXI.scaleModes.LINEAR : PIXI.scaleModes.NEAREST } }), H.Group = function(t, e, i, s, o, n) { void 0 === s && (s = !1), void 0 === o && (o = !1), void 0 === n && (n = H.Physics.ARCADE), this.game = t, void 0 === e && (e = t.world), this.name = i || "group", this.z = 0, PIXI.DisplayObjectContainer.call(this), s ? (this.game.stage.addChild(this), this.z = this.game.stage.children.length) : e && (e.addChild(this), this.z = e.children.length), this.type = H.GROUP, this.physicsType = H.GROUP, this.alive = !0, this.exists = !0, this.ignoreDestroy = !1, this.pendingDestroy = !1, this.classType = H.Sprite, this.cursor = null, this.inputEnableChildren = !1, this.onChildInputDown = new H.Signal, this.onChildInputUp = new H.Signal, this.onChildInputOver = new H.Signal, this.onChildInputOut = new H.Signal, this.enableBody = o, this.enableBodyDebug = !1, this.physicsBodyType = n, this.physicsSortDirection = null, this.onDestroy = new H.Signal, this.cursorIndex = 0, this.fixedToCamera = !1, this.cameraOffset = new H.Point, this.hash = [], this._sortProperty = "z" }, H.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), H.Group.prototype.constructor = H.Group, H.Group.RETURN_NONE = 0, H.Group.RETURN_TOTAL = 1, H.Group.RETURN_CHILD = 2, H.Group.RETURN_ALL = 3, H.Group.SORT_ASCENDING = -1, H.Group.SORT_DESCENDING = 1, H.Group.prototype.add = function(t, e, i) { return void 0 === e && (e = !1), t.parent === this || (t.body && t.parent && t.parent.hash && t.parent.removeFromHash(t), void 0 === i ? (t.z = this.children.length, this.addChild(t)) : (this.addChildAt(t, i), this.updateZ()), this.enableBody && t.hasOwnProperty("body") && null === t.body ? this.game.physics.enable(t, this.physicsBodyType) : t.body && this.addToHash(t), !this.inputEnableChildren || t.input && !t.inputEnabled || (t.inputEnabled = !0), !e && t.events && t.events.onAddedToGroup$dispatch(t, this), null === this.cursor && (this.cursor = t)), t }, H.Group.prototype.addAt = function(t, e, i) { this.add(t, i, e) }, H.Group.prototype.addToHash = function(t) { if (t.parent === this && -1 === this.hash.indexOf(t)) return this.hash.push(t), !0; return !1 }, H.Group.prototype.removeFromHash = function(t) { if (t) { var e = this.hash.indexOf(t); if (-1 !== e) return this.hash.splice(e, 1), !0 } return !1 }, H.Group.prototype.addMultiple = function(t, e) {
|
|
if (t instanceof H.Group) t.moveAll(this, e);
|
|
else if (Array.isArray(t))
|
|
for (var i = 0; i < t.length; i++) this.add(t[i], e);
|
|
return t
|
|
}, H.Group.prototype.getAt = function(t) { return t < 0 || t >= this.children.length ? -1 : this.getChildAt(t) }, H.Group.prototype.create = function(t, e, i, s, o, n) { void 0 === o && (o = !0); var a = new this.classType(this.game, t, e, i, s); return a.exists = o, a.visible = o, a.alive = o, this.add(a, !1, n) }, H.Group.prototype.createMultiple = function(s, t, e, o) {
|
|
void 0 === e && (e = 0), void 0 === o && (o = !1), Array.isArray(t) || (t = [t]), Array.isArray(e) || (e = [e]);
|
|
var n = this,
|
|
a = [];
|
|
return t.forEach(function(i) { e.forEach(function(t) { for (var e = 0; e < s; e++) a.push(n.create(0, 0, i, t, o)) }) }), a
|
|
}, H.Group.prototype.updateZ = function() { for (var t = this.children.length; t--;) this.children[t].z = t }, H.Group.prototype.align = function(t, e, i, s, o, n) {
|
|
if (void 0 === o && (o = H.TOP_LEFT), void 0 === n && (n = 0), 0 === this.children.length || n > this.children.length || -1 === t && -1 === e) return !1;
|
|
for (var a = new H.Rectangle(0, 0, i, s), r = t * i, h = e * s, l = n; l < this.children.length; l++) {
|
|
var c = this.children[l];
|
|
if (c.alignIn)
|
|
if (c.alignIn(a, o), -1 === t) a.y += s, a.y === h && (a.x += i, a.y = 0);
|
|
else if (-1 === e) a.x += i, a.x === r && (a.x = 0, a.y += s);
|
|
else if (a.x += i, a.x === r && (a.x = 0, a.y += s, a.y === h)) return !0
|
|
}
|
|
return !0
|
|
}, H.Group.prototype.resetCursor = function(t) { if (void 0 === t && (t = 0), t > this.children.length - 1 && (t = 0), this.cursor) return this.cursorIndex = t, this.cursor = this.children[this.cursorIndex], this.cursor }, H.Group.prototype.next = function() { if (this.cursor) return this.cursorIndex >= this.children.length - 1 ? this.cursorIndex = 0 : this.cursorIndex++, this.cursor = this.children[this.cursorIndex], this.cursor }, H.Group.prototype.previous = function() { if (this.cursor) return 0 === this.cursorIndex ? this.cursorIndex = this.children.length - 1 : this.cursorIndex--, this.cursor = this.children[this.cursorIndex], this.cursor }, H.Group.prototype.swap = function(t, e) { this.swapChildren(t, e), this.updateZ() }, H.Group.prototype.bringToTop = function(t) { return t.parent === this && this.getIndex(t) < this.children.length && (this.remove(t, !1, !0), this.add(t, !0)), t }, H.Group.prototype.sendToBack = function(t) { return t.parent === this && 0 < this.getIndex(t) && (this.remove(t, !1, !0), this.addAt(t, 0, !0)), t }, H.Group.prototype.moveUp = function(t) {
|
|
if (t.parent === this && this.getIndex(t) < this.children.length - 1) {
|
|
var e = this.getIndex(t),
|
|
i = this.getAt(e + 1);
|
|
i && this.swap(t, i)
|
|
}
|
|
return t
|
|
}, H.Group.prototype.moveDown = function(t) {
|
|
if (t.parent === this && 0 < this.getIndex(t)) {
|
|
var e = this.getIndex(t),
|
|
i = this.getAt(e - 1);
|
|
i && this.swap(t, i)
|
|
}
|
|
return t
|
|
}, H.Group.prototype.xy = function(t, e, i) {
|
|
if (t < 0 || t > this.children.length) return -1;
|
|
this.getChildAt(t).x = e, this.getChildAt(t).y = i
|
|
}, H.Group.prototype.reverse = function() { this.children.reverse(), this.updateZ() }, H.Group.prototype.getIndex = function(t) { return this.children.indexOf(t) }, H.Group.prototype.getByName = function(t) {
|
|
for (var e = 0; e < this.children.length; e++)
|
|
if (this.children[e].name === t) return this.children[e];
|
|
return null
|
|
}, H.Group.prototype.replace = function(t, e) { var i = this.getIndex(t); if (-1 !== i) return e.parent && (e.parent instanceof H.Group ? e.parent.remove(e) : e.parent.removeChild(e)), this.remove(t), this.addAt(e, i), t }, H.Group.prototype.hasProperty = function(t, e) { var i = e.length; return 1 === i && e[0] in t || (2 === i && e[0] in t && e[1] in t[e[0]] || (3 === i && e[0] in t && e[1] in t[e[0]] && e[2] in t[e[0]][e[1]] || 4 === i && e[0] in t && e[1] in t[e[0]] && e[2] in t[e[0]][e[1]] && e[3] in t[e[0]][e[1]][e[2]])) }, H.Group.prototype.setProperty = function(t, e, i, s, o) { if (void 0 === o && (o = !1), s = s || 0, !this.hasProperty(t, e) && (!o || 0 < s)) return !1; var n = e.length; return 1 === n ? 0 === s ? t[e[0]] = i : 1 === s ? t[e[0]] += i : 2 === s ? t[e[0]] -= i : 3 === s ? t[e[0]] *= i : 4 === s && (t[e[0]] /= i) : 2 === n ? 0 === s ? t[e[0]][e[1]] = i : 1 === s ? t[e[0]][e[1]] += i : 2 === s ? t[e[0]][e[1]] -= i : 3 === s ? t[e[0]][e[1]] *= i : 4 === s && (t[e[0]][e[1]] /= i) : 3 === n ? 0 === s ? t[e[0]][e[1]][e[2]] = i : 1 === s ? t[e[0]][e[1]][e[2]] += i : 2 === s ? t[e[0]][e[1]][e[2]] -= i : 3 === s ? t[e[0]][e[1]][e[2]] *= i : 4 === s && (t[e[0]][e[1]][e[2]] /= i) : 4 === n && (0 === s ? t[e[0]][e[1]][e[2]][e[3]] = i : 1 === s ? t[e[0]][e[1]][e[2]][e[3]] += i : 2 === s ? t[e[0]][e[1]][e[2]][e[3]] -= i : 3 === s ? t[e[0]][e[1]][e[2]][e[3]] *= i : 4 === s && (t[e[0]][e[1]][e[2]][e[3]] /= i)), !0 }, H.Group.prototype.checkProperty = function(t, e, i, s) { return void 0 === s && (s = !1), !(!H.Utils.getProperty(t, e) && s) && H.Utils.getProperty(t, e) === i }, H.Group.prototype.set = function(t, e, i, s, o, n, a) { if (void 0 === a && (a = !1), e = e.split("."), void 0 === s && (s = !1), void 0 === o && (o = !1), (!1 === s || s && t.alive) && (!1 === o || o && t.visible)) return this.setProperty(t, e, i, n, a) }, H.Group.prototype.setAll = function(t, e, i, s, o, n) { void 0 === i && (i = !1), void 0 === s && (s = !1), void 0 === n && (n = !1), t = t.split("."), o = o || 0; for (var a = 0; a < this.children.length; a++)(!i || i && this.children[a].alive) && (!s || s && this.children[a].visible) && this.setProperty(this.children[a], t, e, o, n) }, H.Group.prototype.setAllChildren = function(t, e, i, s, o, n) { void 0 === i && (i = !1), void 0 === s && (s = !1), void 0 === n && (n = !1), o = o || 0; for (var a = 0; a < this.children.length; a++)(!i || i && this.children[a].alive) && (!s || s && this.children[a].visible) && (this.children[a] instanceof H.Group ? this.children[a].setAllChildren(t, e, i, s, o, n) : this.setProperty(this.children[a], t.split("."), e, o, n)) }, H.Group.prototype.checkAll = function(t, e, i, s, o) {
|
|
void 0 === i && (i = !1), void 0 === s && (s = !1), void 0 === o && (o = !1);
|
|
for (var n = 0; n < this.children.length; n++)
|
|
if ((!i || i && this.children[n].alive) && (!s || s && this.children[n].visible) && !this.checkProperty(this.children[n], t, e, o)) return !1;
|
|
return !0
|
|
}, H.Group.prototype.addAll = function(t, e, i, s) { this.setAll(t, e, i, s, 1) }, H.Group.prototype.subAll = function(t, e, i, s) { this.setAll(t, e, i, s, 2) }, H.Group.prototype.multiplyAll = function(t, e, i, s) { this.setAll(t, e, i, s, 3) }, H.Group.prototype.divideAll = function(t, e, i, s) { this.setAll(t, e, i, s, 4) }, H.Group.prototype.callAllExists = function(t, e) { var i; if (2 < arguments.length) { i = []; for (var s = 2; s < arguments.length; s++) i.push(arguments[s]) } for (s = 0; s < this.children.length; s++) this.children[s].exists === e && this.children[s][t] && this.children[s][t].apply(this.children[s], i) }, H.Group.prototype.callbackFromArray = function(t, e, i) { if (1 === i) { if (t[e[0]]) return t[e[0]] } else if (2 === i) { if (t[e[0]][e[1]]) return t[e[0]][e[1]] } else if (3 === i) { if (t[e[0]][e[1]][e[2]]) return t[e[0]][e[1]][e[2]] } else if (4 === i) { if (t[e[0]][e[1]][e[2]][e[3]]) return t[e[0]][e[1]][e[2]][e[3]] } else if (t[e]) return t[e]; return !1 }, H.Group.prototype.callAll = function(t, e) {
|
|
if (void 0 !== t) {
|
|
var i, s = (t = t.split(".")).length;
|
|
if (null == e || "" === e) e = null;
|
|
else if ("string" == typeof e) var o = (e = e.split(".")).length;
|
|
if (2 < arguments.length) { i = []; for (var n = 2; n < arguments.length; n++) i.push(arguments[n]) }
|
|
var a = null,
|
|
r = null;
|
|
for (n = 0; n < this.children.length; n++) a = this.callbackFromArray(this.children[n], t, s), e && a ? (r = this.callbackFromArray(this.children[n], e, o), a && a.apply(r, i)) : a && a.apply(this.children[n], i)
|
|
}
|
|
}, H.Group.prototype.preUpdate = function() { if (this.pendingDestroy) return this.destroy(), !1; if (!this.exists || !this.parent.exists) return !(this.renderOrderID = -1); for (var t = 0; t < this.children.length; t++) this.children[t].preUpdate(); return !0 }, H.Group.prototype.update = function() { for (var t = this.children.length; t--;) this.children[t].update() }, H.Group.prototype.postUpdate = function() { this.fixedToCamera && (this.x = this.game.camera.view.x + this.cameraOffset.x, this.y = this.game.camera.view.y + this.cameraOffset.y); for (var t = 0; t < this.children.length; t++) this.children[t].postUpdate() }, H.Group.prototype.filter = function(t, e) {
|
|
for (var i = -1, s = this.children.length, o = []; ++i < s;) {
|
|
var n = this.children[i];
|
|
(!e || e && n.exists) && t(n, i, this.children) && o.push(n)
|
|
}
|
|
return new H.ArraySet(o)
|
|
}, H.Group.prototype.forEach = function(t, e, i) {
|
|
if (void 0 === i && (i = !1), arguments.length <= 3)
|
|
for (var s = 0; s < this.children.length; s++)(!i || i && this.children[s].exists) && t.call(e, this.children[s]);
|
|
else { var o = [null]; for (s = 3; s < arguments.length; s++) o.push(arguments[s]); for (s = 0; s < this.children.length; s++)(!i || i && this.children[s].exists) && (o[0] = this.children[s], t.apply(e, o)) }
|
|
}, H.Group.prototype.forEachExists = function(t, e) { var i; if (2 < arguments.length) { i = [null]; for (var s = 2; s < arguments.length; s++) i.push(arguments[s]) } this.iterate("exists", !0, H.Group.RETURN_TOTAL, t, e, i) }, H.Group.prototype.forEachAlive = function(t, e) { var i; if (2 < arguments.length) { i = [null]; for (var s = 2; s < arguments.length; s++) i.push(arguments[s]) } this.iterate("alive", !0, H.Group.RETURN_TOTAL, t, e, i) }, H.Group.prototype.forEachDead = function(t, e) { var i; if (2 < arguments.length) { i = [null]; for (var s = 2; s < arguments.length; s++) i.push(arguments[s]) } this.iterate("alive", !1, H.Group.RETURN_TOTAL, t, e, i) }, H.Group.prototype.sort = function(t, e) { this.children.length < 2 || (void 0 === t && (t = "z"), void 0 === e && (e = H.Group.SORT_ASCENDING), this._sortProperty = t, e === H.Group.SORT_ASCENDING ? this.children.sort(this.ascendingSortHandler.bind(this)) : this.children.sort(this.descendingSortHandler.bind(this)), this.updateZ()) }, H.Group.prototype.customSort = function(t, e) { this.children.length < 2 || (this.children.sort(t.bind(e)), this.updateZ()) }, H.Group.prototype.ascendingSortHandler = function(t, e) { return t[this._sortProperty] < e[this._sortProperty] ? -1 : t[this._sortProperty] > e[this._sortProperty] ? 1 : t.z < e.z ? -1 : 1 }, H.Group.prototype.descendingSortHandler = function(t, e) { return t[this._sortProperty] < e[this._sortProperty] ? 1 : t[this._sortProperty] > e[this._sortProperty] ? -1 : 0 }, H.Group.prototype.iterate = function(t, e, i, s, o, n) {
|
|
if (0 === this.children.length) { if (i === H.Group.RETURN_TOTAL) return 0; if (i === H.Group.RETURN_ALL) return [] }
|
|
var a = 0;
|
|
if (i === H.Group.RETURN_ALL) var r = [];
|
|
for (var h = 0; h < this.children.length; h++)
|
|
if (this.children[h][t] === e) {
|
|
if (a++, s && (n ? (n[0] = this.children[h], s.apply(o, n)) : s.call(o, this.children[h])), i === H.Group.RETURN_CHILD) return this.children[h];
|
|
i === H.Group.RETURN_ALL && r.push(this.children[h])
|
|
}
|
|
return i === H.Group.RETURN_TOTAL ? a : i === H.Group.RETURN_ALL ? r : null
|
|
}, H.Group.prototype.getFirstExists = function(t, e, i, s, o, n) { void 0 === e && (e = !1), "boolean" != typeof t && (t = !0); var a = this.iterate("exists", t, H.Group.RETURN_CHILD); return null === a && e ? this.create(i, s, o, n) : this.resetChild(a, i, s, o, n) }, H.Group.prototype.getFirstAlive = function(t, e, i, s, o) { void 0 === t && (t = !1); var n = this.iterate("alive", !0, H.Group.RETURN_CHILD); return null === n && t ? this.create(e, i, s, o) : this.resetChild(n, e, i, s, o) }, H.Group.prototype.getFirstDead = function(t, e, i, s, o) { void 0 === t && (t = !1); var n = this.iterate("alive", !1, H.Group.RETURN_CHILD); return null === n && t ? this.create(e, i, s, o) : this.resetChild(n, e, i, s, o) }, H.Group.prototype.resetChild = function(t, e, i, s, o) { return null === t ? null : (void 0 === e && (e = null), void 0 === i && (i = null), null !== e && null !== i && t.reset(e, i), void 0 !== s && t.loadTexture(s, o), t) }, H.Group.prototype.getTop = function() { if (0 < this.children.length) return this.children[this.children.length - 1] }, H.Group.prototype.getBottom = function() { if (0 < this.children.length) return this.children[0] }, H.Group.prototype.getClosestTo = function(t, e, i) {
|
|
for (var s = Number.MAX_VALUE, o = 0, n = null, a = 0; a < this.children.length; a++) {
|
|
var r = this.children[a];
|
|
r.exists && (o = Math.abs(H.Point.distance(t, r))) < s && (!e || e.call(i, r, o)) && (s = o, n = r)
|
|
}
|
|
return n
|
|
}, H.Group.prototype.getFurthestFrom = function(t, e, i) {
|
|
for (var s = 0, o = 0, n = null, a = 0; a < this.children.length; a++) {
|
|
var r = this.children[a];
|
|
r.exists && s < (o = Math.abs(H.Point.distance(t, r))) && (!e || e.call(i, r, o)) && (s = o, n = r)
|
|
}
|
|
return n
|
|
}, H.Group.prototype.countLiving = function() { return this.iterate("alive", !0, H.Group.RETURN_TOTAL) }, H.Group.prototype.countDead = function() { return this.iterate("alive", !1, H.Group.RETURN_TOTAL) }, H.Group.prototype.getRandom = function(t, e) { return void 0 === t && (t = 0), void 0 === e && (e = this.children.length), 0 === e ? null : H.ArrayUtils.getRandomItem(this.children, t, e) }, H.Group.prototype.getRandomExists = function(t, e) { var i = this.getAll("exists", !0, t, e); return this.game.rnd.pick(i) }, H.Group.prototype.getAll = function(t, e, i, s) {
|
|
void 0 === i && (i = 0), void 0 === s && (s = this.children.length);
|
|
for (var o = [], n = i; n < s; n++) {
|
|
var a = this.children[n];
|
|
t && a[t] === e && o.push(a)
|
|
}
|
|
return o
|
|
}, H.Group.prototype.remove = function(t, e, i) {
|
|
if (void 0 === e && (e = !1), void 0 === i && (i = !1), 0 === this.children.length || -1 === this.children.indexOf(t)) return !1;
|
|
i || !t.events || t.destroyPhase || t.events.onRemovedFromGroup$dispatch(t, this);
|
|
var s = this.removeChild(t);
|
|
return this.removeFromHash(t), this.updateZ(), this.cursor === t && this.next(), e && s && s.destroy(!0), !0
|
|
}, H.Group.prototype.moveAll = function(t, e) {
|
|
if (void 0 === e && (e = !1), 0 < this.children.length && t instanceof H.Group) {
|
|
for (; t.add(this.children[0], e), 0 < this.children.length;);
|
|
this.hash = [], this.cursor = null
|
|
}
|
|
return t
|
|
}, H.Group.prototype.removeAll = function(t, e, i) {
|
|
if (void 0 === t && (t = !1), void 0 === e && (e = !1), void 0 === i && (i = !1), 0 !== this.children.length) {
|
|
do {
|
|
!e && this.children[0].events && this.children[0].events.onRemovedFromGroup$dispatch(this.children[0], this);
|
|
var s = this.removeChild(this.children[0]);
|
|
this.removeFromHash(s), t && s && s.destroy(!0, i)
|
|
} while (0 < this.children.length);
|
|
this.hash = [], this.cursor = null
|
|
}
|
|
}, H.Group.prototype.removeBetween = function(t, e, i, s) {
|
|
if (void 0 === e && (e = this.children.length - 1), void 0 === i && (i = !1), void 0 === s && (s = !1), 0 !== this.children.length) {
|
|
if (e < t || t < 0 || e > this.children.length) return !1;
|
|
for (var o = e; t <= o;) {
|
|
!s && this.children[o].events && this.children[o].events.onRemovedFromGroup$dispatch(this.children[o], this);
|
|
var n = this.removeChild(this.children[o]);
|
|
this.removeFromHash(n), i && n && n.destroy(!0), this.cursor === this.children[o] && (this.cursor = null), o--
|
|
}
|
|
this.updateZ()
|
|
}
|
|
}, H.Group.prototype.destroy = function(t, e) { null === this.game || this.ignoreDestroy || (void 0 === t && (t = !0), void 0 === e && (e = !1), this.onDestroy.dispatch(this, t, e), this.removeAll(t), this.cursor = null, this.filters = null, this.pendingDestroy = !1, e || (this.parent && this.parent.removeChild(this), this.game = null, this.exists = !1)) }, Object.defineProperty(H.Group.prototype, "total", { get: function() { return this.iterate("exists", !0, H.Group.RETURN_TOTAL) } }), Object.defineProperty(H.Group.prototype, "length", { get: function() { return this.children.length } }), Object.defineProperty(H.Group.prototype, "angle", { get: function() { return H.Math.radToDeg(this.rotation) }, set: function(t) { this.rotation = H.Math.degToRad(t) } }), Object.defineProperty(H.Group.prototype, "centerX", {
|
|
get: function() { return this.getBounds(this.parent).centerX },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.x - e.x;
|
|
this.x = t + i - e.halfWidth
|
|
}
|
|
}), Object.defineProperty(H.Group.prototype, "centerY", {
|
|
get: function() { return this.getBounds(this.parent).centerY },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.y - e.y;
|
|
this.y = t + i - e.halfHeight
|
|
}
|
|
}), Object.defineProperty(H.Group.prototype, "left", {
|
|
get: function() { return this.getBounds(this.parent).left },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.x - e.x;
|
|
this.x = t + i
|
|
}
|
|
}), Object.defineProperty(H.Group.prototype, "right", {
|
|
get: function() { return this.getBounds(this.parent).right },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.x - e.x;
|
|
this.x = t + i - e.width
|
|
}
|
|
}), Object.defineProperty(H.Group.prototype, "top", {
|
|
get: function() { return this.getBounds(this.parent).top },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.y - e.y;
|
|
this.y = t + i
|
|
}
|
|
}), Object.defineProperty(H.Group.prototype, "bottom", {
|
|
get: function() { return this.getBounds(this.parent).bottom },
|
|
set: function(t) {
|
|
var e = this.getBounds(this.parent),
|
|
i = this.y - e.y;
|
|
this.y = t + i - e.height
|
|
}
|
|
}), H.World = function(t) { H.Group.call(this, t, null, "__world", !1), this.bounds = new H.Rectangle(0, 0, t.width, t.height), this.camera = null, this._definedSize = !1, this._width = t.width, this._height = t.height, this.game.state.onStateChange.add(this.stateChange, this) }, H.World.prototype = Object.create(H.Group.prototype), H.World.prototype.constructor = H.World, H.World.prototype.boot = function() { this.camera = new H.Camera(this.game, 0, 0, 0, this.game.width, this.game.height), this.game.stage.addChild(this), this.camera.boot() }, H.World.prototype.stateChange = function() { this.x = 0, this.y = 0, this.camera.reset() }, H.World.prototype.setBounds = function(t, e, i, s) { this._definedSize = !0, this._width = i, this._height = s, this.bounds.setTo(t, e, i, s), this.x = t, this.y = e, this.camera.bounds && this.camera.bounds.setTo(t, e, Math.max(i, this.game.width), Math.max(s, this.game.height)), this.game.physics.setBoundsToWorld() }, H.World.prototype.resize = function(t, e) { this._definedSize && (t < this._width && (t = this._width), e < this._height && (e = this._height)), this.bounds.width = t, this.bounds.height = e, this.game.camera.setBoundsToWorld(), this.game.physics.setBoundsToWorld() }, H.World.prototype.shutdown = function() { this.destroy(!0, !0) }, H.World.prototype.wrap = function(t, e, i, s, o) { void 0 === e && (e = 0), void 0 === i && (i = !1), void 0 === s && (s = !0), void 0 === o && (o = !0), i ? (t.getBounds(), s && (t.x + t._currentBounds.width < this.bounds.x ? t.x = this.bounds.right : t.x > this.bounds.right && (t.x = this.bounds.left)), o && (t.y + t._currentBounds.height < this.bounds.top ? t.y = this.bounds.bottom : t.y > this.bounds.bottom && (t.y = this.bounds.top))) : (s && t.x + e < this.bounds.x ? t.x = this.bounds.right + e : s && t.x - e > this.bounds.right && (t.x = this.bounds.left - e), o && t.y + e < this.bounds.top ? t.y = this.bounds.bottom + e : o && t.y - e > this.bounds.bottom && (t.y = this.bounds.top - e)) }, Object.defineProperty(H.World.prototype, "width", { get: function() { return this.bounds.width }, set: function(t) { t < this.game.width && (t = this.game.width), this.bounds.width = t, this._width = t, this._definedSize = !0 } }), Object.defineProperty(H.World.prototype, "height", { get: function() { return this.bounds.height }, set: function(t) { t < this.game.height && (t = this.game.height), this.bounds.height = t, this._height = t, this._definedSize = !0 } }), Object.defineProperty(H.World.prototype, "centerX", { get: function() { return this.bounds.halfWidth + this.bounds.x } }), Object.defineProperty(H.World.prototype, "centerY", { get: function() { return this.bounds.halfHeight + this.bounds.y } }), Object.defineProperty(H.World.prototype, "randomX", { get: function() { return this.bounds.x < 0 ? this.game.rnd.between(this.bounds.x, this.bounds.width - Math.abs(this.bounds.x)) : this.game.rnd.between(this.bounds.x, this.bounds.width) } }), Object.defineProperty(H.World.prototype, "randomY", { get: function() { return this.bounds.y < 0 ? this.game.rnd.between(this.bounds.y, this.bounds.height - Math.abs(this.bounds.y)) : this.game.rnd.between(this.bounds.y, this.bounds.height) } }), H.Game = function(t, e, i, s, o, n, a, r) { return this.id = H.GAMES.push(this) - 1, this.config = null, this.physicsConfig = r, this.parent = "", this.width = 800, this.height = 600, this.resolution = 1, this._width = 800, this._height = 600, this.transparent = !1, this.antialias = !0, this.preserveDrawingBuffer = !1, this.clearBeforeRender = !0, this.renderer = null, this.renderType = H.AUTO, this.state = null, this.isBooted = !1, this.isRunning = !1, this.raf = null, this.add = null, this.make = null, this.cache = null, this.input = null, this.load = null, this.math = null, this.net = null, this.scale = null, this.sound = null, this.stage = null, this.time = null, this.tweens = null, this.world = null, this.physics = null, this.plugins = null, this.rnd = null, this.device = H.Device, this.camera = null, this.canvas = null, this.context = null, this.debug = null, this.particles = null, this.create = null, this.lockRender = !1, this.stepping = !1, this.pendingStep = !1, this.stepCount = 0, this.onPause = null, this.onResume = null, this.onBlur = null, this.onFocus = null, this._paused = !1, this._codePaused = !1, this.currentUpdateID = 0, this.updatesThisFrame = 1, this._deltaTime = 0, this._lastCount = 0, this._spiraling = 0, this._kickstart = !0, this.fpsProblemNotifier = new H.Signal, this.forceSingleUpdate = !0, this._nextFpsNotification = 0, 1 === arguments.length && "object" == typeof t ? this.parseConfig(t) : (this.config = { enableDebug: !0 }, void 0 !== t && (this._width = t), void 0 !== e && (this._height = e), void 0 !== i && (this.renderType = i), void 0 !== s && (this.parent = s), void 0 !== n && (this.transparent = n), void 0 !== a && (this.antialias = a), this.rnd = new H.RandomDataGenerator([(Date.now() * Math.random()).toString()]), this.state = new H.StateManager(this, o)), this.device.whenReady(this.boot, this), this }, H.Game.prototype = {
|
|
parseConfig: function(t) {
|
|
void 0 === (this.config = t).enableDebug && (this.config.enableDebug = !0), t.width && (this._width = t.width), t.height && (this._height = t.height), t.renderer && (this.renderType = t.renderer), t.parent && (this.parent = t.parent), void 0 !== t.transparent && (this.transparent = t.transparent), void 0 !== t.antialias && (this.antialias = t.antialias), t.resolution && (this.resolution = t.resolution), void 0 !== t.preserveDrawingBuffer && (this.preserveDrawingBuffer = t.preserveDrawingBuffer), t.physicsConfig && (this.physicsConfig = t.physicsConfig);
|
|
var e = [(Date.now() * Math.random()).toString()];
|
|
t.seed && (e = t.seed), this.rnd = new H.RandomDataGenerator(e);
|
|
var i = null;
|
|
t.state && (i = t.state), this.state = new H.StateManager(this, i)
|
|
},
|
|
boot: function() { this.isBooted || (this.onPause = new H.Signal, this.onResume = new H.Signal, this.onBlur = new H.Signal, this.onFocus = new H.Signal, this.isBooted = !0, (PIXI.game = this).math = H.Math, this.scale = new H.ScaleManager(this, this._width, this._height), this.stage = new H.Stage(this), this.setUpRenderer(), this.world = new H.World(this), this.add = new H.GameObjectFactory(this), this.make = new H.GameObjectCreator(this), this.cache = new H.Cache(this), this.load = new H.Loader(this), this.time = new H.Time(this), this.tweens = new H.TweenManager(this), this.input = new H.Input(this), this.sound = new H.SoundManager(this), this.physics = new H.Physics(this, this.physicsConfig), this.particles = new H.Particles(this), this.create = new H.Create(this), this.plugins = new H.PluginManager(this), this.net = new H.Net(this), this.time.boot(), this.stage.boot(), this.world.boot(), this.scale.boot(), this.input.boot(), this.sound.boot(), this.state.boot(), this.config.enableDebug ? (this.debug = new H.Utils.Debug(this), this.debug.boot()) : this.debug = { preUpdate: function() {}, update: function() {}, reset: function() {} }, this.showDebugHeader(), this.isRunning = !0, this.config && this.config.forceSetTimeOut ? this.raf = new H.RequestAnimationFrame(this, this.config.forceSetTimeOut) : this.raf = new H.RequestAnimationFrame(this, !1), this._kickstart = !0, window.focus && (!window.PhaserGlobal || window.PhaserGlobal && !window.PhaserGlobal.stopFocus) && window.focus(), this.raf.start()) },
|
|
showDebugHeader: function() {
|
|
if (!window.PhaserGlobal || !window.PhaserGlobal.hideBanner) {
|
|
var t = H.VERSION,
|
|
e = "Canvas",
|
|
i = "HTML Audio",
|
|
s = 1;
|
|
if (this.renderType === H.WEBGL ? (e = "WebGL", s++) : this.renderType === H.HEADLESS && (e = "Headless"), this.device.webAudio && (i = "WebAudio", s++), this.device.chrome)
|
|
for (var o = ["%c %c %c @orange-games/phaser v" + t + " | Pixi.js | " + e + " | " + i + " %c %c %c https://github.com/orange-games / https://www.orangegames.com %c♥%c♥%c♥", "background: #F47820", "background: #ED873F", "color: #ffffff; background: #DD6612;", "background: #ED873F", "background: #F47820", "background: #ffffff"], n = 0; n < 3; n++) n < s ? o.push("color: #ff2424; background: #fff") : o.push("color: #959595; background: #fff");
|
|
else window.console
|
|
}
|
|
},
|
|
setUpRenderer: function() {
|
|
if (this.config.canvas ? this.canvas = this.config.canvas : this.canvas = H.Canvas.create(this, this.width, this.height, this.config.canvasID, !0), this.config.canvasStyle ? this.canvas.style = this.config.canvasStyle : this.canvas.style["-webkit-full-screen"] = "width: 100%; height: 100%", this.renderType === H.HEADLESS || this.renderType === H.CANVAS || this.renderType === H.AUTO && !this.device.webGL) {
|
|
if (!this.device.canvas) throw new Error("Phaser.Game - Cannot create Canvas or WebGL context, aborting.");
|
|
this.renderType = H.CANVAS, this.renderer = new PIXI.CanvasRenderer(this), this.context = this.renderer.context
|
|
}
|
|
else this.renderType = H.WEBGL, this.renderer = new PIXI.WebGLRenderer(this), this.context = null, this.canvas.addEventListener("webglcontextlost", this.contextLost.bind(this), !1), this.canvas.addEventListener("webglcontextrestored", this.contextRestored.bind(this), !1);
|
|
this.device.cocoonJS && (this.canvas.screencanvas = this.renderType === H.CANVAS), this.renderType !== H.HEADLESS && (this.stage.smoothed = this.antialias, H.Canvas.addToDOM(this.canvas, this.parent, !1), H.Canvas.setTouchAction(this.canvas))
|
|
},
|
|
contextLost: function(t) { t.preventDefault(), this.renderer.contextLost = !0 },
|
|
contextRestored: function() { this.renderer.initContext(), this.cache.clearGLTextures(), this.renderer.contextLost = !1 },
|
|
update: function(t) {
|
|
if (this.time.update(t), this._kickstart) return this.updateLogic(this.time.desiredFpsMult), this.updateRender(this.time.slowMotion * this.time.desiredFps), void(this._kickstart = !1);
|
|
if (1 < this._spiraling && !this.forceSingleUpdate) this.time.time > this._nextFpsNotification && (this._nextFpsNotification = this.time.time + 1e4, this.fpsProblemNotifier.dispatch()), this._deltaTime = 0, this._spiraling = 0, this.updateRender(this.time.slowMotion * this.time.desiredFps);
|
|
else {
|
|
var e = 1e3 * this.time.slowMotion / this.time.desiredFps;
|
|
this._deltaTime += Math.max(Math.min(3 * e, this.time.elapsed), 0);
|
|
var i = 0;
|
|
for (this.updatesThisFrame = Math.floor(this._deltaTime / e), this.forceSingleUpdate && (this.updatesThisFrame = Math.min(1, this.updatesThisFrame)); this._deltaTime >= e && (this._deltaTime -= e, this.currentUpdateID = i, this.updateLogic(this.time.desiredFpsMult), i++, !this.forceSingleUpdate || 1 !== i);) this.time.refresh();
|
|
i > this._lastCount ? this._spiraling++ : i < this._lastCount && (this._spiraling = 0), this._lastCount = i, this.updateRender(this._deltaTime / e)
|
|
}
|
|
},
|
|
updateLogic: function(t) { this._paused || this.pendingStep ? (this.scale.pauseUpdate(), this.state.pauseUpdate(), this.debug.preUpdate()) : (this.stepping && (this.pendingStep = !0), this.scale.preUpdate(), this.debug.preUpdate(), this.camera.preUpdate(), this.physics.preUpdate(), this.state.preUpdate(t), this.plugins.preUpdate(t), this.stage.preUpdate(), this.state.update(), this.stage.update(), this.tweens.update(), this.sound.update(), this.input.update(), this.physics.update(), this.particles.update(), this.plugins.update(), this.stage.postUpdate(), this.plugins.postUpdate()), this.stage.updateTransform() },
|
|
updateRender: function(t) { this.lockRender || (this.state.preRender(t), this.renderType !== H.HEADLESS && (this.renderer.render(this.stage), this.plugins.render(t), this.state.render(t)), this.plugins.postRender(t)) },
|
|
enableStep: function() { this.stepping = !0, this.pendingStep = !1, this.stepCount = 0 },
|
|
disableStep: function() { this.stepping = !1, this.pendingStep = !1 },
|
|
step: function() { this.pendingStep = !1, this.stepCount++ },
|
|
destroy: function() { this.raf.stop(), this.state.destroy(), this.sound.destroy(), this.scale.destroy(), this.stage.destroy(), this.input.destroy(), this.physics.destroy(), this.plugins.destroy(), this.state = null, this.sound = null, this.scale = null, this.stage = null, this.input = null, this.physics = null, this.plugins = null, this.cache = null, this.load = null, this.time = null, this.world = null, this.isBooted = !1, this.renderer.destroy(!1), H.Canvas.removeFromDOM(this.canvas), PIXI.defaultRenderer = null, H.GAMES[this.id] = null },
|
|
gamePaused: function(t) { this._paused || (this._paused = !0, this.time.gamePaused(), this.sound.muteOnPause && this.sound.setMute(), this.onPause.dispatch(t), this.device.cordova && this.device.iOS && (this.lockRender = !0)) },
|
|
gameResumed: function(t) { this._paused && !this._codePaused && (this._paused = !1, this.time.gameResumed(), this.input.reset(), this.sound.muteOnPause && this.sound.unsetMute(), this.onResume.dispatch(t), this.device.cordova && this.device.iOS && (this.lockRender = !1)) },
|
|
focusLoss: function(t) { this.onBlur.dispatch(t), this.stage.disableVisibilityChange || this.gamePaused(t) },
|
|
focusGain: function(t) { this.onFocus.dispatch(t), this.stage.disableVisibilityChange || this.gameResumed(t) }
|
|
}, H.Game.prototype.constructor = H.Game, Object.defineProperty(H.Game.prototype, "paused", { get: function() { return this._paused }, set: function(t) { this._codePaused = !0 === t ? (!1 === this._paused && (this._paused = !0, this.sound.setMute(), this.time.gamePaused(), this.onPause.dispatch(this)), !0) : (this._paused && (this._paused = !1, this.input.reset(), this.sound.unsetMute(), this.time.gameResumed(), this.onResume.dispatch(this)), !1) } }), H.Input = function(t) { this.game = t, this.hitCanvas = null, this.hitContext = null, this.moveCallbacks = [], this.customCandidateHandler = null, this.customCandidateHandlerContext = null, this.pollRate = 0, this.enabled = !0, this.multiInputOverride = H.Input.MOUSE_TOUCH_COMBINE, this.position = null, this.speed = null, this.circle = null, this.scale = null, this.maxPointers = -1, this.tapRate = 200, this.doubleTapRate = 300, this.holdRate = 2e3, this.justPressedRate = 200, this.justReleasedRate = 200, this.recordPointerHistory = !1, this.recordRate = 100, this.recordLimit = 100, this.pointer1 = null, this.pointer2 = null, this.pointer3 = null, this.pointer4 = null, this.pointer5 = null, this.pointer6 = null, this.pointer7 = null, this.pointer8 = null, this.pointer9 = null, this.pointer10 = null, this.pointers = [], this.activePointer = null, this.mousePointer = null, this.mouse = null, this.keyboard = null, this.touch = null, this.mspointer = null, this.gamepad = null, this.resetLocked = !1, this.onDown = null, this.onUp = null, this.onTap = null, this.onHold = null, this.minPriorityID = 0, this.interactiveItems = new H.ArraySet, this._localPoint = new H.Point, this._pollCounter = 0, this._oldPosition = null, this._x = 0, this._y = 0 }, H.Input.MOUSE_OVERRIDES_TOUCH = 0, H.Input.TOUCH_OVERRIDES_MOUSE = 1, H.Input.MOUSE_TOUCH_COMBINE = 2, H.Input.MAX_POINTERS = 10, H.Input.prototype = {
|
|
boot: function() {
|
|
this.mousePointer = new H.Pointer(this.game, 0, H.PointerMode.CURSOR), this.addPointer(), this.addPointer(), this.mouse = new H.Mouse(this.game), this.touch = new H.Touch(this.game), this.mspointer = new H.MSPointer(this.game), H.Keyboard && (this.keyboard = new H.Keyboard(this.game)), H.Gamepad && (this.gamepad = new H.Gamepad(this.game)), this.onDown = new H.Signal, this.onUp = new H.Signal, this.onTap = new H.Signal, this.onHold = new H.Signal, this.scale = new H.Point(1, 1), this.speed = new H.Point, this.position = new H.Point, this._oldPosition = new H.Point, this.circle = new H.Circle(0, 0, 44), this.activePointer = this.mousePointer, this.hitCanvas = PIXI.CanvasPool.create(this, 1, 1), this.hitContext = this.hitCanvas.getContext("2d"), this.game.device.touch ? this.touch.start() : this.game.device.mspointer && this.mspointer.start(), this.mspointer.active || this.mouse.start(), this.mousePointer.active = !0, this.keyboard && this.keyboard.start();
|
|
var e = this;
|
|
this._onClickTrampoline = function(t) { e.onClickTrampoline(t) }, this.game.canvas.addEventListener("click", this._onClickTrampoline, !1)
|
|
},
|
|
destroy: function() { this.mouse.stop(), this.touch.stop(), this.mspointer.stop(), this.keyboard && this.keyboard.stop(), this.gamepad && this.gamepad.stop(), this.moveCallbacks = [], PIXI.CanvasPool.remove(this), this.game.canvas.removeEventListener("click", this._onClickTrampoline) },
|
|
setInteractiveCandidateHandler: function(t, e) { this.customCandidateHandler = t, this.customCandidateHandlerContext = e },
|
|
addMoveCallback: function(t, e) { this.moveCallbacks.push({ callback: t, context: e }) },
|
|
deleteMoveCallback: function(t, e) {
|
|
for (var i = this.moveCallbacks.length; i--;)
|
|
if (this.moveCallbacks[i].callback === t && this.moveCallbacks[i].context === e) return void this.moveCallbacks.splice(i, 1)
|
|
},
|
|
addPointer: function() {
|
|
if (this.pointers.length >= H.Input.MAX_POINTERS) return null;
|
|
var t = this.pointers.length + 1,
|
|
e = new H.Pointer(this.game, t, H.PointerMode.TOUCH);
|
|
return this.pointers.push(e), this["pointer" + t] = e
|
|
},
|
|
update: function() {
|
|
if (this.keyboard && this.keyboard.update(), 0 < this.pollRate && this._pollCounter < this.pollRate) this._pollCounter++;
|
|
else {
|
|
this.speed.x = this.position.x - this._oldPosition.x, this.speed.y = this.position.y - this._oldPosition.y, this._oldPosition.copyFrom(this.position), this.mousePointer.update(), this.gamepad && this.gamepad.active && this.gamepad.update();
|
|
for (var t = 0; t < this.pointers.length; t++) this.pointers[t].update();
|
|
this._pollCounter = 0
|
|
}
|
|
},
|
|
reset: function(t) { if (this.game.isBooted && !this.resetLocked) { void 0 === t && (t = !1), this.mousePointer.reset(), this.keyboard && this.keyboard.reset(t), this.gamepad && this.gamepad.reset(); for (var e = 0; e < this.pointers.length; e++) this.pointers[e].reset(); "none" !== this.game.canvas.style.cursor && (this.game.canvas.style.cursor = "inherit"), t && (this.onDown.dispose(), this.onUp.dispose(), this.onTap.dispose(), this.onHold.dispose(), this.onDown = new H.Signal, this.onUp = new H.Signal, this.onTap = new H.Signal, this.onHold = new H.Signal, this.moveCallbacks = []), this._pollCounter = 0 } },
|
|
resetSpeed: function(t, e) { this._oldPosition.setTo(t, e), this.speed.setTo(0, 0) },
|
|
startPointer: function(t) { if (0 <= this.maxPointers && this.countActivePointers(this.maxPointers) >= this.maxPointers) return null; if (!this.pointer1.active) return this.pointer1.start(t); if (!this.pointer2.active) return this.pointer2.start(t); for (var e = 2; e < this.pointers.length; e++) { var i = this.pointers[e]; if (!i.active) return i.start(t) } return null },
|
|
updatePointer: function(t) { if (this.pointer1.active && this.pointer1.identifier === t.identifier) return this.pointer1.move(t); if (this.pointer2.active && this.pointer2.identifier === t.identifier) return this.pointer2.move(t); for (var e = 2; e < this.pointers.length; e++) { var i = this.pointers[e]; if (i.active && i.identifier === t.identifier) return i.move(t) } return null },
|
|
stopPointer: function(t) { if (this.pointer1.active && this.pointer1.identifier === t.identifier) return this.pointer1.stop(t); if (this.pointer2.active && this.pointer2.identifier === t.identifier) return this.pointer2.stop(t); for (var e = 2; e < this.pointers.length; e++) { var i = this.pointers[e]; if (i.active && i.identifier === t.identifier) return i.stop(t) } return null },
|
|
countActivePointers: function(t) { void 0 === t && (t = this.pointers.length); for (var e = t, i = 0; i < this.pointers.length && 0 < e; i++) { this.pointers[i].active && e-- } return t - e },
|
|
getPointer: function(t) { void 0 === t && (t = !1); for (var e = 0; e < this.pointers.length; e++) { var i = this.pointers[e]; if (i.active === t) return i } return null },
|
|
getPointerFromIdentifier: function(t) { for (var e = 0; e < this.pointers.length; e++) { var i = this.pointers[e]; if (i.identifier === t) return i } return null },
|
|
getPointerFromId: function(t) { for (var e = 0; e < this.pointers.length; e++) { var i = this.pointers[e]; if (i.pointerId === t) return i } return null },
|
|
getLocalPosition: function(t, e, i) {
|
|
void 0 === i && (i = new H.Point);
|
|
var s = t.worldTransform,
|
|
o = 1 / (s.a * s.d + s.c * -s.b);
|
|
return i.setTo(s.d * o * e.x + -s.c * o * e.y + (s.ty * s.c - s.tx * s.d) * o, s.a * o * e.y + -s.b * o * e.x + (-s.ty * s.a + s.tx * s.b) * o)
|
|
},
|
|
hitTest: function(t, e, i) {
|
|
if (!t.worldVisible) return !1;
|
|
if (this.getLocalPosition(t, e, this._localPoint), i.copyFrom(this._localPoint), t.hitArea && t.hitArea.contains) return t.hitArea.contains(this._localPoint.x, this._localPoint.y);
|
|
if (t instanceof H.TileSprite) {
|
|
var s = t.width,
|
|
o = t.height,
|
|
n = -s * t.anchor.x;
|
|
if (this._localPoint.x >= n && this._localPoint.x < n + s) { var a = -o * t.anchor.y; if (this._localPoint.y >= a && this._localPoint.y < a + o) return !0 }
|
|
}
|
|
else if (t instanceof PIXI.Sprite) { s = t.texture.frame.width, o = t.texture.frame.height, n = -s * t.anchor.x; if (this._localPoint.x >= n && this._localPoint.x < n + s) { a = -o * t.anchor.y; if (this._localPoint.y >= a && this._localPoint.y < a + o) return !0 } }
|
|
else if (H.Graphics && t instanceof H.Graphics)
|
|
for (var r = 0; r < t.graphicsData.length; r++) { var h = t.graphicsData[r]; if (h.fill && (h.shape && h.shape.contains(this._localPoint.x, this._localPoint.y))) return !0 }
|
|
for (r = 0; r < t.children.length; r++)
|
|
if (this.hitTest(t.children[r], e, i)) return !0;
|
|
return !1
|
|
},
|
|
onClickTrampoline: function() { this.activePointer.processClickTrampolines() }
|
|
}, H.Input.prototype.constructor = H.Input, Object.defineProperty(H.Input.prototype, "x", { get: function() { return this._x }, set: function(t) { this._x = Math.floor(t) } }), Object.defineProperty(H.Input.prototype, "y", { get: function() { return this._y }, set: function(t) { this._y = Math.floor(t) } }), Object.defineProperty(H.Input.prototype, "pollLocked", { get: function() { return 0 < this.pollRate && this._pollCounter < this.pollRate } }), Object.defineProperty(H.Input.prototype, "totalInactivePointers", { get: function() { return this.pointers.length - this.countActivePointers() } }), Object.defineProperty(H.Input.prototype, "totalActivePointers", { get: function() { return this.countActivePointers() } }), Object.defineProperty(H.Input.prototype, "worldX", { get: function() { return this.game.camera.view.x + this.x } }), Object.defineProperty(H.Input.prototype, "worldY", { get: function() { return this.game.camera.view.y + this.y } }), H.Mouse = function(t) { this.game = t, this.input = t.input, this.callbackContext = this.game, this.mouseDownCallback = null, this.mouseUpCallback = null, this.mouseOutCallback = null, this.mouseOverCallback = null, this.mouseWheelCallback = null, this.capture = !1, this.button = -1, this.wheelDelta = 0, this.enabled = !0, this.locked = !1, this.stopOnGameOut = !1, this.pointerLock = new H.Signal, this.event = null, this._onMouseDown = null, this._onMouseMove = null, this._onMouseUp = null, this._onMouseOut = null, this._onMouseOver = null, this._onMouseWheel = null, this._wheelEvent = null }, H.Mouse.NO_BUTTON = -1, H.Mouse.LEFT_BUTTON = 0, H.Mouse.MIDDLE_BUTTON = 1, H.Mouse.RIGHT_BUTTON = 2, H.Mouse.BACK_BUTTON = 3, H.Mouse.FORWARD_BUTTON = 4, H.Mouse.WHEEL_UP = 1, H.Mouse.WHEEL_DOWN = -1, H.Mouse.prototype = {
|
|
start: function() {
|
|
if ((!this.game.device.android || !1 !== this.game.device.chrome) && null === this._onMouseDown) {
|
|
var e = this;
|
|
this._onMouseDown = function(t) { return e.onMouseDown(t) }, this._onMouseMove = function(t) { return e.onMouseMove(t) }, this._onMouseUp = function(t) { return e.onMouseUp(t) }, this._onMouseUpGlobal = function(t) { return e.onMouseUpGlobal(t) }, this._onMouseOutGlobal = function(t) { return e.onMouseOutGlobal(t) }, this._onMouseOut = function(t) { return e.onMouseOut(t) }, this._onMouseOver = function(t) { return e.onMouseOver(t) }, this._onMouseWheel = function(t) { return e.onMouseWheel(t) };
|
|
var t = this.game.canvas;
|
|
t.addEventListener("mousedown", this._onMouseDown, !0), t.addEventListener("mousemove", this._onMouseMove, !0), t.addEventListener("mouseup", this._onMouseUp, !0), this.game.device.cocoonJS || (window.addEventListener("mouseup", this._onMouseUpGlobal, !0), window.addEventListener("mouseout", this._onMouseOutGlobal, !0), t.addEventListener("mouseover", this._onMouseOver, !0), t.addEventListener("mouseout", this._onMouseOut, !0));
|
|
var i = this.game.device.wheelEvent;
|
|
i && (t.addEventListener(i, this._onMouseWheel, !0), "mousewheel" === i ? this._wheelEvent = new s(-.025, 1) : "DOMMouseScroll" === i && (this._wheelEvent = new s(1, 1)))
|
|
}
|
|
},
|
|
onMouseDown: function(t) { this.event = t, this.capture && t.preventDefault(), this.mouseDownCallback && this.mouseDownCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = 0, this.input.mousePointer.start(t)) },
|
|
onMouseMove: function(t) { this.event = t, this.capture && t.preventDefault(), this.mouseMoveCallback && this.mouseMoveCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = 0, this.input.mousePointer.move(t)) },
|
|
onMouseUp: function(t) { this.event = t, this.capture && t.preventDefault(), this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = 0, this.input.mousePointer.stop(t)) },
|
|
onMouseUpGlobal: function(t) { this.input.mousePointer.withinGame || (this.mouseUpCallback && this.mouseUpCallback.call(this.callbackContext, t), t.identifier = 0, this.input.mousePointer.stop(t)) },
|
|
onMouseOutGlobal: function(t) { this.event = t, this.capture && t.preventDefault(), this.input.mousePointer.withinGame = !1, this.input.enabled && this.enabled && (this.input.mousePointer.stop(t), this.input.mousePointer.leftButton.stop(t), this.input.mousePointer.rightButton.stop(t)) },
|
|
onMouseOut: function(t) { this.event = t, this.capture && t.preventDefault(), this.input.mousePointer.withinGame = !1, this.mouseOutCallback && this.mouseOutCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && this.stopOnGameOut && (t.identifier = 0, this.input.mousePointer.stop(t)) },
|
|
onMouseOver: function(t) { this.event = t, this.capture && t.preventDefault(), this.input.mousePointer.withinGame = !0, this.mouseOverCallback && this.mouseOverCallback.call(this.callbackContext, t) },
|
|
onMouseWheel: function(t) { this._wheelEvent && (t = this._wheelEvent.bindEvent(t)), this.event = t, this.capture && t.preventDefault(), this.wheelDelta = H.Math.clamp(-t.deltaY, -1, 1), this.mouseWheelCallback && this.mouseWheelCallback.call(this.callbackContext, t) },
|
|
requestPointerLock: function() {
|
|
if (this.game.device.pointerLock) {
|
|
var t = this.game.canvas;
|
|
t.requestPointerLock = t.requestPointerLock || t.mozRequestPointerLock || t.webkitRequestPointerLock, t.requestPointerLock();
|
|
var e = this;
|
|
this._pointerLockChange = function(t) { return e.pointerLockChange(t) }, document.addEventListener("pointerlockchange", this._pointerLockChange, !0), document.addEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.addEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
|
|
}
|
|
},
|
|
pointerLockChange: function(t) {
|
|
var e = this.game.canvas;
|
|
document.pointerLockElement === e || document.mozPointerLockElement === e || document.webkitPointerLockElement === e ? (this.locked = !0, this.pointerLock.dispatch(!0, t)) : (this.locked = !1, this.pointerLock.dispatch(!1, t))
|
|
},
|
|
releasePointerLock: function() { document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock, document.exitPointerLock(), document.removeEventListener("pointerlockchange", this._pointerLockChange, !0), document.removeEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.removeEventListener("webkitpointerlockchange", this._pointerLockChange, !0) },
|
|
stop: function() {
|
|
var t = this.game.canvas;
|
|
t.removeEventListener("mousedown", this._onMouseDown, !0), t.removeEventListener("mousemove", this._onMouseMove, !0), t.removeEventListener("mouseup", this._onMouseUp, !0), t.removeEventListener("mouseover", this._onMouseOver, !0), t.removeEventListener("mouseout", this._onMouseOut, !0);
|
|
var e = this.game.device.wheelEvent;
|
|
e && t.removeEventListener(e, this._onMouseWheel, !0), window.removeEventListener("mouseup", this._onMouseUpGlobal, !0), window.removeEventListener("mouseout", this._onMouseOutGlobal, !0), document.removeEventListener("pointerlockchange", this._pointerLockChange, !0), document.removeEventListener("mozpointerlockchange", this._pointerLockChange, !0), document.removeEventListener("webkitpointerlockchange", this._pointerLockChange, !0)
|
|
}
|
|
}, H.Mouse.prototype.constructor = H.Mouse, ((s.prototype = {}).constructor = s).prototype.bindEvent = function(t) {
|
|
if (!s._stubsGenerated && t) {
|
|
var e = function(e) { return function() { var t = this.originalEvent[e]; return "function" != typeof t ? t : t.bind(this.originalEvent) } };
|
|
for (var i in t) i in s.prototype || Object.defineProperty(s.prototype, i, { get: e(i) });
|
|
s._stubsGenerated = !0
|
|
}
|
|
return this.originalEvent = t, this
|
|
}, Object.defineProperties(s.prototype, { type: { value: "wheel" }, deltaMode: { get: function() { return this._deltaMode } }, deltaY: { get: function() { return this._scaleFactor * (this.originalEvent.wheelDelta || this.originalEvent.detail) || 0 } }, deltaX: { get: function() { return this._scaleFactor * this.originalEvent.wheelDeltaX || 0 } }, deltaZ: { value: 0 } }), H.MSPointer = function(t) { this.game = t, this.input = t.input, this.callbackContext = this.game, this.pointerDownCallback = null, this.pointerMoveCallback = null, this.pointerUpCallback = null, this.capture = !0, this.button = -1, this.event = null, this.enabled = !0, this._onMSPointerDown = null, this._onMSPointerMove = null, this._onMSPointerUp = null, this._onMSPointerUpGlobal = null, this._onMSPointerOut = null, this._onMSPointerOver = null }, H.MSPointer.prototype = {
|
|
start: function() {
|
|
if (null === this._onMSPointerDown) {
|
|
var e = this;
|
|
if (this.game.device.mspointer) {
|
|
this._onMSPointerDown = function(t) { return e.onPointerDown(t) }, this._onMSPointerMove = function(t) { return e.onPointerMove(t) }, this._onMSPointerUp = function(t) { return e.onPointerUp(t) }, this._onMSPointerUpGlobal = function(t) { return e.onPointerUpGlobal(t) }, this._onMSPointerOut = function(t) { return e.onPointerOut(t) }, this._onMSPointerOver = function(t) { return e.onPointerOver(t) };
|
|
var t = this.game.canvas;
|
|
t.addEventListener("MSPointerDown", this._onMSPointerDown, !1), t.addEventListener("MSPointerMove", this._onMSPointerMove, !1), t.addEventListener("MSPointerUp", this._onMSPointerUp, !1), t.addEventListener("pointerdown", this._onMSPointerDown, !1), t.addEventListener("pointermove", this._onMSPointerMove, !1), t.addEventListener("pointerup", this._onMSPointerUp, !1), t.style["-ms-content-zooming"] = "none", t.style["-ms-touch-action"] = "none", this.game.device.cocoonJS || (window.addEventListener("MSPointerUp", this._onMSPointerUpGlobal, !0), t.addEventListener("MSPointerOver", this._onMSPointerOver, !0), t.addEventListener("MSPointerOut", this._onMSPointerOut, !0), window.addEventListener("pointerup", this._onMSPointerUpGlobal, !0), t.addEventListener("pointerover", this._onMSPointerOver, !0), t.addEventListener("pointerout", this._onMSPointerOut, !0))
|
|
}
|
|
}
|
|
},
|
|
onPointerDown: function(t) { this.event = t, this.capture && t.preventDefault(), this.pointerDownCallback && this.pointerDownCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = t.pointerId, "mouse" === t.pointerType || 4 === t.pointerType ? this.input.mousePointer.start(t) : this.input.startPointer(t)) },
|
|
onPointerMove: function(t) { this.event = t, this.capture && t.preventDefault(), this.pointerMoveCallback && this.pointerMoveCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = t.pointerId, "mouse" === t.pointerType || 4 === t.pointerType ? this.input.mousePointer.move(t) : this.input.updatePointer(t)) },
|
|
onPointerUp: function(t) { this.event = t, this.capture && t.preventDefault(), this.pointerUpCallback && this.pointerUpCallback.call(this.callbackContext, t), this.input.enabled && this.enabled && (t.identifier = t.pointerId, "mouse" === t.pointerType || 4 === t.pointerType ? this.input.mousePointer.stop(t) : this.input.stopPointer(t)) },
|
|
onPointerUpGlobal: function(t) {
|
|
if ("mouse" !== t.pointerType && 4 !== t.pointerType || this.input.mousePointer.withinGame) {
|
|
var e = this.input.getPointerFromIdentifier(t.identifier);
|
|
e && e.withinGame && this.onPointerUp(t)
|
|
}
|
|
else this.onPointerUp(t)
|
|
},
|
|
onPointerOut: function(t) {
|
|
if (this.event = t, this.capture && t.preventDefault(), "mouse" === t.pointerType || 4 === t.pointerType) this.input.mousePointer.withinGame = !1;
|
|
else {
|
|
var e = this.input.getPointerFromIdentifier(t.identifier);
|
|
e && (e.withinGame = !1)
|
|
}
|
|
this.input.mouse.mouseOutCallback && this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext, t), this.input.enabled && this.enabled && this.input.mouse.stopOnGameOut && (t.identifier = 0, e ? e.stop(t) : this.input.mousePointer.stop(t))
|
|
},
|
|
onPointerOver: function(t) {
|
|
if (this.event = t, this.capture && t.preventDefault(), "mouse" === t.pointerType || 4 === t.pointerType) this.input.mousePointer.withinGame = !0;
|
|
else {
|
|
var e = this.input.getPointerFromIdentifier(t.identifier);
|
|
e && (e.withinGame = !0)
|
|
}
|
|
this.input.mouse.mouseOverCallback && this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext, t)
|
|
},
|
|
stop: function() {
|
|
var t = this.game.canvas;
|
|
t.removeEventListener("MSPointerDown", this._onMSPointerDown, !1), t.removeEventListener("MSPointerMove", this._onMSPointerMove, !1), t.removeEventListener("MSPointerUp", this._onMSPointerUp, !1), t.removeEventListener("pointerdown", this._onMSPointerDown, !1), t.removeEventListener("pointermove", this._onMSPointerMove, !1), t.removeEventListener("pointerup", this._onMSPointerUp, !1), window.removeEventListener("MSPointerUp", this._onMSPointerUpGlobal, !0), t.removeEventListener("MSPointerOver", this._onMSPointerOver, !0), t.removeEventListener("MSPointerOut", this._onMSPointerOut, !0), window.removeEventListener("pointerup", this._onMSPointerUpGlobal, !0), t.removeEventListener("pointerover", this._onMSPointerOver, !0), t.removeEventListener("pointerout", this._onMSPointerOut, !0)
|
|
}
|
|
}, H.MSPointer.prototype.constructor = H.MSPointer, H.DeviceButton = function(t, e) { this.parent = t, this.game = t.game, this.event = null, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.timeUp = 0, this.repeats = 0, this.altKey = !1, this.shiftKey = !1, this.ctrlKey = !1, this.value = 0, this.buttonCode = e, this.onDown = new H.Signal, this.onUp = new H.Signal, this.onFloat = new H.Signal }, H.DeviceButton.prototype = { start: function(t, e) { this.isDown || (this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.time, this.repeats = 0, this.event = t, this.value = e, t && (this.altKey = t.altKey, this.shiftKey = t.shiftKey, this.ctrlKey = t.ctrlKey), this.onDown.dispatch(this, e)) }, stop: function(t, e) { this.isUp || (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.event = t, this.value = e, t && (this.altKey = t.altKey, this.shiftKey = t.shiftKey, this.ctrlKey = t.ctrlKey), this.onUp.dispatch(this, e)) }, padFloat: function(t) { this.value = t, this.onFloat.dispatch(this, t) }, justPressed: function(t) { return t = t || 250, this.isDown && this.timeDown + t > this.game.time.time }, justReleased: function(t) { return t = t || 250, this.isUp && this.timeUp + t > this.game.time.time }, reset: function() { this.isDown = !1, this.isUp = !0, this.timeDown = this.game.time.time, this.repeats = 0, this.altKey = !1, this.shiftKey = !1, this.ctrlKey = !1 }, destroy: function() { this.onDown.dispose(), this.onUp.dispose(), this.onFloat.dispose(), this.parent = null, this.game = null } }, H.DeviceButton.prototype.constructor = H.DeviceButton, Object.defineProperty(H.DeviceButton.prototype, "duration", { get: function() { return this.isUp ? -1 : this.game.time.time - this.timeDown } }), H.Pointer = function(t, e, i) { this.game = t, this.id = e, this.type = H.POINTER, this.exists = !0, this.identifier = 0, this.pointerId = null, this.pointerMode = i || H.PointerMode.CURSOR | H.PointerMode.CONTACT, this.target = null, this.button = null, this.leftButton = new H.DeviceButton(this, H.Pointer.LEFT_BUTTON), this.middleButton = new H.DeviceButton(this, H.Pointer.MIDDLE_BUTTON), this.rightButton = new H.DeviceButton(this, H.Pointer.RIGHT_BUTTON), this.backButton = new H.DeviceButton(this, H.Pointer.BACK_BUTTON), this.forwardButton = new H.DeviceButton(this, H.Pointer.FORWARD_BUTTON), this.eraserButton = new H.DeviceButton(this, H.Pointer.ERASER_BUTTON), this._holdSent = !1, this._history = [], this._nextDrop = 0, this._stateReset = !1, this.withinGame = !1, this.clientX = -1, this.clientY = -1, this.pageX = -1, this.pageY = -1, this.screenX = -1, this.screenY = -1, this.rawMovementX = 0, this.rawMovementY = 0, this.movementX = 0, this.movementY = 0, this.x = -1, this.y = -1, this.isMouse = 0 === e, this.isDown = !1, this.isUp = !0, this.timeDown = 0, this.timeUp = 0, this.previousTapTime = 0, this.totalTouches = 0, this.msSinceLastClick = Number.MAX_VALUE, this.targetObject = null, this.interactiveCandidates = [], this.active = !1, this.dirty = !1, this.position = new H.Point, this.positionDown = new H.Point, this.positionUp = new H.Point, this.circle = new H.Circle(0, 0, 44), this._clickTrampolines = null, this._trampolineTargetObject = null }, H.Pointer.NO_BUTTON = 0, H.Pointer.LEFT_BUTTON = 1, H.Pointer.RIGHT_BUTTON = 2, H.Pointer.MIDDLE_BUTTON = 4, H.Pointer.BACK_BUTTON = 8, H.Pointer.FORWARD_BUTTON = 16, H.Pointer.ERASER_BUTTON = 32, H.Pointer.prototype = {
|
|
resetButtons: function() { this.isDown = !1, this.isUp = !0, this.isMouse && (this.leftButton.reset(), this.middleButton.reset(), this.rightButton.reset(), this.backButton.reset(), this.forwardButton.reset(), this.eraserButton.reset()) },
|
|
processButtonsDown: function(t, e) { H.Pointer.LEFT_BUTTON & t && this.leftButton.start(e), H.Pointer.RIGHT_BUTTON & t && this.rightButton.start(e), H.Pointer.MIDDLE_BUTTON & t && this.middleButton.start(e), H.Pointer.BACK_BUTTON & t && this.backButton.start(e), H.Pointer.FORWARD_BUTTON & t && this.forwardButton.start(e), H.Pointer.ERASER_BUTTON & t && this.eraserButton.start(e) },
|
|
processButtonsUp: function(t, e) { t === H.Mouse.LEFT_BUTTON && this.leftButton.stop(e), t === H.Mouse.RIGHT_BUTTON && this.rightButton.stop(e), t === H.Mouse.MIDDLE_BUTTON && this.middleButton.stop(e), t === H.Mouse.BACK_BUTTON && this.backButton.stop(e), t === H.Mouse.FORWARD_BUTTON && this.forwardButton.stop(e), 5 === t && this.eraserButton.stop(e) },
|
|
updateButtons: function(t) {
|
|
this.button = t.button;
|
|
var e = "down" === t.type.toLowerCase().substr(-4);
|
|
void 0 !== t.buttons ? e ? this.processButtonsDown(t.buttons, t) : this.processButtonsUp(t.button, t) : e ? this.leftButton.start(t) : (this.leftButton.stop(t), this.rightButton.stop(t)), 1 === t.buttons && t.ctrlKey && this.leftButton.isDown && (this.leftButton.stop(t), this.rightButton.start(t)), this.isUp = !0, this.isDown = !1, (this.leftButton.isDown || this.rightButton.isDown || this.middleButton.isDown || this.backButton.isDown || this.forwardButton.isDown || this.eraserButton.isDown) && (this.isUp = !1, this.isDown = !0)
|
|
},
|
|
start: function(t) { var e = this.game.input; return t.pointerId && (this.pointerId = t.pointerId), this.identifier = t.identifier, this.target = t.target, this.isMouse ? this.updateButtons(t) : (this.isDown = !0, this.isUp = !1), this.active = !0, this.withinGame = !0, this.dirty = !1, this._history = [], this._clickTrampolines = null, this._trampolineTargetObject = null, this.msSinceLastClick = this.game.time.time - this.timeDown, this.timeDown = this.game.time.time, this._holdSent = !1, this.move(t, !0), this.positionDown.setTo(this.x, this.y), (e.multiInputOverride === H.Input.MOUSE_OVERRIDES_TOUCH || e.multiInputOverride === H.Input.MOUSE_TOUCH_COMBINE || e.multiInputOverride === H.Input.TOUCH_OVERRIDES_MOUSE && 0 === e.totalActivePointers) && (e.x = this.x, e.y = this.y, e.position.setTo(this.x, this.y), e.onDown.dispatch(this, t), e.resetSpeed(this.x, this.y)), this._stateReset = !1, this.totalTouches++, null !== this.targetObject && this.targetObject._touchedHandler(this), this },
|
|
update: function() {
|
|
var t = this.game.input;
|
|
this.active && (this.dirty && (0 < t.interactiveItems.total && this.processInteractiveObjects(!1), this.dirty = !1), !1 === this._holdSent && this.duration >= t.holdRate && ((t.multiInputOverride === H.Input.MOUSE_OVERRIDES_TOUCH || t.multiInputOverride === H.Input.MOUSE_TOUCH_COMBINE || t.multiInputOverride === H.Input.TOUCH_OVERRIDES_MOUSE && 0 === t.totalActivePointers) && t.onHold.dispatch(this), this._holdSent = !0), t.recordPointerHistory && this.game.time.time >= this._nextDrop && (this._nextDrop = this.game.time.time + t.recordRate, this._history.push({ x: this.position.x, y: this.position.y }), this._history.length > t.recordLimit && this._history.shift()))
|
|
},
|
|
move: function(t, e) { var i = this.game.input; if (!i.pollLocked) { void 0 === e && (e = !1), void 0 !== t.button && (this.button = t.button), e && this.isMouse && this.updateButtons(t), this.clientX = t.clientX, this.clientY = t.clientY, this.pageX = t.pageX, this.pageY = t.pageY, this.screenX = t.screenX, this.screenY = t.screenY, this.isMouse && i.mouse.locked && !e && (this.rawMovementX = t.movementX || t.mozMovementX || t.webkitMovementX || 0, this.rawMovementY = t.movementY || t.mozMovementY || t.webkitMovementY || 0, this.movementX += this.rawMovementX, this.movementY += this.rawMovementY), this.x = (this.pageX - this.game.scale.offset.x) * i.scale.x, this.y = (this.pageY - this.game.scale.offset.y) * i.scale.y, this.position.setTo(this.x, this.y), this.circle.x = this.x, this.circle.y = this.y, (i.multiInputOverride === H.Input.MOUSE_OVERRIDES_TOUCH || i.multiInputOverride === H.Input.MOUSE_TOUCH_COMBINE || i.multiInputOverride === H.Input.TOUCH_OVERRIDES_MOUSE && 0 === i.totalActivePointers) && (i.activePointer = this, i.x = this.x, i.y = this.y, i.position.setTo(i.x, i.y), i.circle.x = i.x, i.circle.y = i.y), this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY); for (var s = i.moveCallbacks.length; s--;) i.moveCallbacks[s].callback.call(i.moveCallbacks[s].context, this, this.x, this.y, e); return null !== this.targetObject && !0 === this.targetObject.isDragged ? !1 === this.targetObject.update(this) && (this.targetObject = null) : 0 < i.interactiveItems.total && this.processInteractiveObjects(e), this } },
|
|
processInteractiveObjects: function(t) {
|
|
var e = 0,
|
|
i = -1,
|
|
s = null,
|
|
o = this.game.input.interactiveItems.first;
|
|
for (this.interactiveCandidates = []; o;) o.checked = !1, o.validForInput(i, e, !1) && (o.checked = !0, (t && o.checkPointerDown(this, !0) || !t && o.checkPointerOver(this, !0)) && (e = o.sprite.renderOrderID, i = o.priorityID, s = o, this.interactiveCandidates.push(o))), o = this.game.input.interactiveItems.next;
|
|
for (o = this.game.input.interactiveItems.first; o;) !o.checked && o.validForInput(i, e, !0) && (t && o.checkPointerDown(this, !1) || !t && o.checkPointerOver(this, !1)) && (e = o.sprite.renderOrderID, i = o.priorityID, s = o, this.interactiveCandidates.push(o)), o = this.game.input.interactiveItems.next;
|
|
return this.game.input.customCandidateHandler && (s = this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext, this, this.interactiveCandidates, s)), this.swapTarget(s, !1), null !== this.targetObject
|
|
},
|
|
swapTarget: function(t, e) { void 0 === e && (e = !1), null === t ? this.targetObject && (this.targetObject._pointerOutHandler(this, e), this.targetObject = null) : null === this.targetObject ? (this.targetObject = t)._pointerOverHandler(this, e) : this.targetObject === t ? !1 === t.update(this) && (this.targetObject = null) : (this.targetObject._pointerOutHandler(this, e), this.targetObject = t, this.targetObject._pointerOverHandler(this, e)) },
|
|
leave: function(t) { this.withinGame = !1, this.move(t, !1) },
|
|
stop: function(t) {
|
|
var e = this.game.input;
|
|
if (!this._stateReset || !this.withinGame) return this.timeUp = this.game.time.time, (e.multiInputOverride === H.Input.MOUSE_OVERRIDES_TOUCH || e.multiInputOverride === H.Input.MOUSE_TOUCH_COMBINE || e.multiInputOverride === H.Input.TOUCH_OVERRIDES_MOUSE && 0 === e.totalActivePointers) && (e.onUp.dispatch(this, t), 0 <= this.duration && this.duration <= e.tapRate && (this.timeUp - this.previousTapTime < e.doubleTapRate ? e.onTap.dispatch(this, !0) : e.onTap.dispatch(this, !1), this.previousTapTime = this.timeUp)), this.isMouse ? this.updateButtons(t) : (this.isDown = !1, this.isUp = !0), 0 < this.id && (this.active = !1), this.withinGame = this.game.scale.bounds.contains(t.pageX, t.pageY), this.pointerId = null, this.identifier = null, this.positionUp.setTo(this.x, this.y), !1 === this.isMouse && e.currentPointers--, e.interactiveItems.callAll("_releasedHandler", this), this._clickTrampolines && (this._trampolineTargetObject = this.targetObject), this.targetObject = null, this;
|
|
t.preventDefault()
|
|
},
|
|
justPressed: function(t) { return t = t || this.game.input.justPressedRate, !0 === this.isDown && this.timeDown + t > this.game.time.time },
|
|
justReleased: function(t) { return t = t || this.game.input.justReleasedRate, this.isUp && this.timeUp + t > this.game.time.time },
|
|
addClickTrampoline: function(t, e, i, s) {
|
|
if (this.isDown) {
|
|
for (var o = this._clickTrampolines = this._clickTrampolines || [], n = 0; n < o.length; n++)
|
|
if (o[n].name === t) { o.splice(n, 1); break }
|
|
o.push({ name: t, targetObject: this.targetObject, callback: e, callbackContext: i, callbackArgs: s })
|
|
}
|
|
},
|
|
processClickTrampolines: function() {
|
|
var t = this._clickTrampolines;
|
|
if (t) {
|
|
for (var e = 0; e < t.length; e++) {
|
|
var i = t[e];
|
|
i.targetObject === this._trampolineTargetObject && i.callback.apply(i.callbackContext, i.callbackArgs)
|
|
}
|
|
this._clickTrampolines = null, this._trampolineTargetObject = null
|
|
}
|
|
},
|
|
reset: function() {!1 === this.isMouse && (this.active = !1), this.pointerId = null, this.identifier = null, this.dirty = !1, this.totalTouches = 0, this._holdSent = !1, this._history.length = 0, this._stateReset = !0, this.resetButtons(), this.targetObject && this.targetObject._releasedHandler(this), this.targetObject = null },
|
|
resetMovement: function() { this.movementX = 0, this.movementY = 0 }
|
|
}, H.Pointer.prototype.constructor = H.Pointer, Object.defineProperty(H.Pointer.prototype, "duration", { get: function() { return this.isUp ? -1 : this.game.time.time - this.timeDown } }), Object.defineProperty(H.Pointer.prototype, "worldX", { get: function() { return this.game.world.camera.x + this.x } }), Object.defineProperty(H.Pointer.prototype, "worldY", { get: function() { return this.game.world.camera.y + this.y } }), H.PointerMode = { CURSOR: 1, CONTACT: 2 }, H.Touch = function(t) { this.game = t, this.enabled = !0, this.touchLockCallbacks = [], this.callbackContext = this.game, this.touchStartCallback = null, this.touchMoveCallback = null, this.touchEndCallback = null, this.touchEnterCallback = null, this.touchLeaveCallback = null, this.touchCancelCallback = null, this.preventDefault = !0, this.event = null, this._onTouchStart = null, this._onTouchMove = null, this._onTouchEnd = null, this._onTouchEnter = null, this._onTouchLeave = null, this._onTouchCancel = null, this._onTouchMove = null }, H.Touch.prototype = {
|
|
start: function() {
|
|
if (null === this._onTouchStart) {
|
|
var e = this;
|
|
this.game.device.touch && (this._onTouchStart = function(t) { return e.onTouchStart(t) }, this._onTouchMove = function(t) { return e.onTouchMove(t) }, this._onTouchEnd = function(t) { return e.onTouchEnd(t) }, this._onTouchEnter = function(t) { return e.onTouchEnter(t) }, this._onTouchLeave = function(t) { return e.onTouchLeave(t) }, this._onTouchCancel = function(t) { return e.onTouchCancel(t) }, this.game.canvas.addEventListener("touchstart", this._onTouchStart, !1), this.game.canvas.addEventListener("touchmove", this._onTouchMove, !1), this.game.canvas.addEventListener("touchend", this._onTouchEnd, !1), this.game.canvas.addEventListener("touchcancel", this._onTouchCancel, !1), this.game.device.cocoonJS || (this.game.canvas.addEventListener("touchenter", this._onTouchEnter, !1), this.game.canvas.addEventListener("touchleave", this._onTouchLeave, !1)))
|
|
}
|
|
},
|
|
consumeDocumentTouches: function() { this._documentTouchMove = function(t) { t.preventDefault() }, document.addEventListener("touchmove", this._documentTouchMove, !1) },
|
|
addTouchLockCallback: function(t, e, i) { void 0 === i && (i = !1), this.touchLockCallbacks.push({ callback: t, context: e, onEnd: i }) },
|
|
removeTouchLockCallback: function(t, e) {
|
|
for (var i = this.touchLockCallbacks.length; i--;)
|
|
if (this.touchLockCallbacks[i].callback === t && this.touchLockCallbacks[i].context === e) return this.touchLockCallbacks.splice(i, 1), !0;
|
|
return !1
|
|
},
|
|
onTouchStart: function(t) { for (var e = this.touchLockCallbacks.length; e--;) { var i = this.touchLockCallbacks[e];!i.onEnd && i.callback.call(i.context, this, t) && this.touchLockCallbacks.splice(e, 1) } if (this.event = t, this.game.input.enabled && this.enabled) { this.touchStartCallback && this.touchStartCallback.call(this.callbackContext, t), this.preventDefault && t.preventDefault(); for (e = 0; e < t.changedTouches.length; e++) this.game.input.startPointer(t.changedTouches[e]) } },
|
|
onTouchCancel: function(t) { if (this.event = t, this.touchCancelCallback && this.touchCancelCallback.call(this.callbackContext, t), this.game.input.enabled && this.enabled) { this.preventDefault && t.preventDefault(); for (var e = 0; e < t.changedTouches.length; e++) this.game.input.stopPointer(t.changedTouches[e]) } },
|
|
onTouchEnter: function(t) { this.event = t, this.touchEnterCallback && this.touchEnterCallback.call(this.callbackContext, t), this.game.input.enabled && this.enabled && this.preventDefault && t.preventDefault() },
|
|
onTouchLeave: function(t) { this.event = t, this.touchLeaveCallback && this.touchLeaveCallback.call(this.callbackContext, t), this.preventDefault && t.preventDefault() },
|
|
onTouchMove: function(t) { this.event = t, this.touchMoveCallback && this.touchMoveCallback.call(this.callbackContext, t), this.preventDefault && t.preventDefault(); for (var e = 0; e < t.changedTouches.length; e++) this.game.input.updatePointer(t.changedTouches[e]) },
|
|
onTouchEnd: function(t) {
|
|
for (var e = this.touchLockCallbacks.length; e--;) {
|
|
var i = this.touchLockCallbacks[e];
|
|
i.onEnd && i.callback.call(i.context, this, t) && this.touchLockCallbacks.splice(e, 1)
|
|
}
|
|
this.event = t, this.touchEndCallback && this.touchEndCallback.call(this.callbackContext, t), this.preventDefault && t.preventDefault();
|
|
for (e = 0; e < t.changedTouches.length; e++) this.game.input.stopPointer(t.changedTouches[e])
|
|
},
|
|
stop: function() { this.game.device.touch && (this.game.canvas.removeEventListener("touchstart", this._onTouchStart), this.game.canvas.removeEventListener("touchmove", this._onTouchMove), this.game.canvas.removeEventListener("touchend", this._onTouchEnd), this.game.canvas.removeEventListener("touchenter", this._onTouchEnter), this.game.canvas.removeEventListener("touchleave", this._onTouchLeave), this.game.canvas.removeEventListener("touchcancel", this._onTouchCancel)) }
|
|
}, H.Touch.prototype.constructor = H.Touch, H.InputHandler = function(t) { this.sprite = t, this.game = t.game, this.enabled = !1, this.checked = !1, this.priorityID = 0, this.useHandCursor = !1, this._setHandCursor = !1, this.isDragged = !1, this.allowHorizontalDrag = !0, this.allowVerticalDrag = !0, this.bringToTop = !1, this.snapOffset = null, this.snapOnDrag = !1, this.snapOnRelease = !1, this.snapX = 0, this.snapY = 0, this.snapOffsetX = 0, this.snapOffsetY = 0, this.pixelPerfectOver = !1, this.pixelPerfectClick = !1, this.pixelPerfectAlpha = 255, this.draggable = !1, this.boundsRect = null, this.boundsSprite = null, this.scaleLayer = !1, this.dragOffset = new H.Point, this.dragFromCenter = !1, this.dragStopBlocksInputUp = !1, this.dragStartPoint = new H.Point, this.dragDistanceThreshold = 0, this.dragTimeThreshold = 0, this.downPoint = new H.Point, this.snapPoint = new H.Point, this._dragPoint = new H.Point, this._dragPhase = !1, this._pendingDrag = !1, this._dragTimePass = !1, this._dragDistancePass = !1, this._wasEnabled = !1, this._tempPoint = new H.Point, this._pointerData = [], this._pointerData.push({ id: 0, x: 0, y: 0, camX: 0, camY: 0, isDown: !1, isUp: !1, isOver: !1, isOut: !1, timeOver: 0, timeOut: 0, timeDown: 0, timeUp: 0, downDuration: 0, isDragged: !1 }) }, H.InputHandler.prototype = {
|
|
start: function(t, e) {
|
|
if (t = t || 0, void 0 === e && (e = !1), !1 === this.enabled) {
|
|
this.game.input.interactiveItems.add(this), this.useHandCursor = e, this.priorityID = t;
|
|
for (var i = 0; i < 10; i++) this._pointerData[i] = { id: i, x: 0, y: 0, isDown: !1, isUp: !1, isOver: !1, isOut: !1, timeOver: 0, timeOut: 0, timeDown: 0, timeUp: 0, downDuration: 0, isDragged: !1 };
|
|
this.snapOffset = new H.Point, this.enabled = !0, this._wasEnabled = !0
|
|
}
|
|
return this.sprite.events.onAddedToGroup.add(this.addedToGroup, this), this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup, this), this.sprite
|
|
},
|
|
addedToGroup: function() { this._dragPhase || this._wasEnabled && !this.enabled && this.start() },
|
|
removedFromGroup: function() { this._dragPhase || (this.enabled ? (this._wasEnabled = !0, this.stop()) : this._wasEnabled = !1) },
|
|
reset: function() { this.enabled = !1; for (var t = 0; t < 10; t++) this._pointerData[t] = { id: t, x: 0, y: 0, isDown: !1, isUp: !1, isOver: !1, isOut: !1, timeOver: 0, timeOut: 0, timeDown: 0, timeUp: 0, downDuration: 0, isDragged: !1 } },
|
|
stop: function() {!1 !== this.enabled && (this.enabled = !1, this.game.input.interactiveItems.remove(this)) },
|
|
destroy: function() { this.sprite && (this._setHandCursor && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), this.enabled = !1, this.game.input.interactiveItems.remove(this), this._pointerData.length = 0, this.boundsRect = null, this.boundsSprite = null, this.sprite = null) },
|
|
validForInput: function(t, e, i) { return void 0 === i && (i = !0), !(!this.enabled || 0 === this.sprite.scale.x || 0 === this.sprite.scale.y || this.priorityID < this.game.input.minPriorityID || this.sprite.parent && this.sprite.parent.ignoreChildInput) && (!(!i && (this.pixelPerfectClick || this.pixelPerfectOver)) && (this.priorityID > t || this.priorityID === t && this.sprite.renderOrderID > e)) },
|
|
isPixelPerfect: function() { return this.pixelPerfectClick || this.pixelPerfectOver },
|
|
pointerX: function(t) { return t = t || 0, this._pointerData[t].x },
|
|
pointerY: function(t) { return t = t || 0, this._pointerData[t].y },
|
|
pointerDown: function(t) { return t = t || 0, this._pointerData[t].isDown },
|
|
pointerUp: function(t) { return t = t || 0, this._pointerData[t].isUp },
|
|
pointerTimeDown: function(t) { return t = t || 0, this._pointerData[t].timeDown },
|
|
pointerTimeUp: function(t) { return t = t || 0, this._pointerData[t].timeUp },
|
|
pointerOver: function(t) {
|
|
if (!this.enabled) return !1;
|
|
if (void 0 !== t) return this._pointerData[t].isOver;
|
|
for (var e = 0; e < 10; e++)
|
|
if (this._pointerData[e].isOver) return !0;
|
|
return !1
|
|
},
|
|
pointerOut: function(t) {
|
|
if (!this.enabled) return !1;
|
|
if (void 0 !== t) return this._pointerData[t].isOut;
|
|
for (var e = 0; e < 10; e++)
|
|
if (this._pointerData[e].isOut) return !0
|
|
},
|
|
pointerTimeOver: function(t) { return t = t || 0, this._pointerData[t].timeOver },
|
|
pointerTimeOut: function(t) { return t = t || 0, this._pointerData[t].timeOut },
|
|
pointerDragged: function(t) { return t = t || 0, this._pointerData[t].isDragged },
|
|
checkPointerDown: function(t, e) { return !!(t.isDown && this.enabled && this.sprite && this.sprite.parent && this.sprite.visible && this.sprite.parent.visible && 0 !== this.sprite.worldScale.x && 0 !== this.sprite.worldScale.y) && (!!this.game.input.hitTest(this.sprite, t, this._tempPoint) && (void 0 === e && (e = !1), !(!e && this.pixelPerfectClick) || this.checkPixel(this._tempPoint.x, this._tempPoint.y))) },
|
|
checkPointerOver: function(t, e) { return !!(this.enabled && this.sprite && this.sprite.parent && this.sprite.visible && this.sprite.parent.visible && 0 !== this.sprite.worldScale.x && 0 !== this.sprite.worldScale.y) && (!!this.game.input.hitTest(this.sprite, t, this._tempPoint) && (void 0 === e && (e = !1), !(!e && this.pixelPerfectOver) || this.checkPixel(this._tempPoint.x, this._tempPoint.y))) },
|
|
checkPixel: function(t, e, i) {
|
|
if (this.sprite.texture.baseTexture.source) {
|
|
if (null === t && null === e) {
|
|
this.game.input.getLocalPosition(this.sprite, i, this._tempPoint);
|
|
t = this._tempPoint.x, e = this._tempPoint.y
|
|
}
|
|
if (0 !== this.sprite.anchor.x && (t -= -this.sprite.texture.frame.width * this.sprite.anchor.x), 0 !== this.sprite.anchor.y && (e -= -this.sprite.texture.frame.height * this.sprite.anchor.y), t += this.sprite.texture.frame.x, e += this.sprite.texture.frame.y, this.sprite.texture.trim && (t -= this.sprite.texture.trim.x, e -= this.sprite.texture.trim.y, t < this.sprite.texture.crop.x || t > this.sprite.texture.crop.right || e < this.sprite.texture.crop.y || e > this.sprite.texture.crop.bottom)) return this._dx = t, this._dy = e, !1;
|
|
if (this._dx = t, this._dy = e, this.game.input.hitContext.clearRect(0, 0, 1, 1), this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, t, e, 1, 1, 0, 0, 1, 1), this.game.input.hitContext.getImageData(0, 0, 1, 1).data[3] >= this.pixelPerfectAlpha) return !0
|
|
}
|
|
return !1
|
|
},
|
|
update: function(t) { if (null !== this.sprite && void 0 !== this.sprite.parent) return this.enabled && this.sprite.visible && this.sprite.parent.visible ? this._pendingDrag ? (this._dragDistancePass || (this._dragDistancePass = H.Math.distance(t.x, t.y, this.downPoint.x, this.downPoint.y) >= this.dragDistanceThreshold), this._dragDistancePass && this._dragTimePass && this.startDrag(t), !0) : this.draggable && this._draggedPointerID === t.id ? this.updateDrag(t, !1) : this._pointerData[t.id].isOver ? this.checkPointerOver(t) ? (this._pointerData[t.id].x = t.x - this.sprite.x, this._pointerData[t.id].y = t.y - this.sprite.y, !0) : (this._pointerOutHandler(t), !1) : void 0 : (this._pointerOutHandler(t), !1) },
|
|
_pointerOverHandler: function(t, e) {
|
|
if (null !== this.sprite) {
|
|
var i = this._pointerData[t.id];
|
|
if (!1 === i.isOver || t.dirty) {
|
|
var s = !1 === i.isOver;
|
|
i.isOver = !0, i.isOut = !1, i.timeOver = this.game.time.time, i.x = t.x - this.sprite.x, i.y = t.y - this.sprite.y, this.useHandCursor && !1 === i.isDragged && (this.game.canvas.style.cursor = "pointer", this._setHandCursor = !0), !e && s && this.sprite && this.sprite.events && this.sprite.events.onInputOver$dispatch(this.sprite, t), this.sprite.parent && this.sprite.parent.type === H.GROUP && this.sprite.parent.onChildInputOver.dispatch(this.sprite, t)
|
|
}
|
|
}
|
|
},
|
|
_pointerOutHandler: function(t, e) {
|
|
if (null !== this.sprite) {
|
|
var i = this._pointerData[t.id];
|
|
i.isOver = !1, i.isOut = !0, i.timeOut = this.game.time.time, this.useHandCursor && !1 === i.isDragged && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), !e && this.sprite && this.sprite.events && (this.sprite.events.onInputOut$dispatch(this.sprite, t), this.sprite && this.sprite.parent && this.sprite.parent.type === H.GROUP && this.sprite.parent.onChildInputOut.dispatch(this.sprite, t))
|
|
}
|
|
},
|
|
_touchedHandler: function(t) {
|
|
if (null !== this.sprite) {
|
|
var e = this._pointerData[t.id];
|
|
if (!e.isDown && e.isOver) {
|
|
if (this.pixelPerfectClick && !this.checkPixel(null, null, t)) return;
|
|
if (e.isDown = !0, e.isUp = !1, e.timeDown = this.game.time.time, this.downPoint.set(t.x, t.y), t.dirty = !0, this.sprite && this.sprite.events && (this.sprite.events.onInputDown$dispatch(this.sprite, t), this.sprite && this.sprite.parent && this.sprite.parent.type === H.GROUP && this.sprite.parent.onChildInputDown.dispatch(this.sprite, t), null === this.sprite)) return;
|
|
this.draggable && !1 === this.isDragged && (0 === this.dragTimeThreshold && 0 === this.dragDistanceThreshold ? this.startDrag(t) : (this._pendingDrag = !0, this._dragDistancePass = 0 === this.dragDistanceThreshold, 0 < this.dragTimeThreshold ? (this._dragTimePass = !1, this.game.time.events.add(this.dragTimeThreshold, this.dragTimeElapsed, this, t)) : this._dragTimePass = !0)), this.bringToTop && this.sprite.bringToTop()
|
|
}
|
|
}
|
|
},
|
|
dragTimeElapsed: function(t) { this._dragTimePass = !0, this._pendingDrag && this.sprite && this._dragDistancePass && this.startDrag(t) },
|
|
_releasedHandler: function(t) {
|
|
if (null !== this.sprite) {
|
|
var e = this._pointerData[t.id];
|
|
if (e.isDown && t.isUp) {
|
|
e.isDown = !1, e.isUp = !0, e.timeUp = this.game.time.time, e.downDuration = e.timeUp - e.timeDown;
|
|
var i = this.checkPointerOver(t);
|
|
this.sprite && this.sprite.events && (this.dragStopBlocksInputUp && (!this.dragStopBlocksInputUp || this.draggable && this.isDragged && this._draggedPointerID === t.id) || this.sprite.events.onInputUp$dispatch(this.sprite, t, i), this.sprite && this.sprite.parent && this.sprite.parent.type === H.GROUP && this.sprite.parent.onChildInputUp.dispatch(this.sprite, t, i), i && (i = this.checkPointerOver(t))), !(e.isOver = i) && this.useHandCursor && (this.game.canvas.style.cursor = "default", this._setHandCursor = !1), t.dirty = !0, this._pendingDrag = !1, this.draggable && this.isDragged && this._draggedPointerID === t.id && this.stopDrag(t)
|
|
}
|
|
}
|
|
},
|
|
updateDrag: function(t, e) {
|
|
if (void 0 === e && (e = !1), t.isUp) return this.stopDrag(t), !1;
|
|
var i = this.globalToLocalX(t.x) + this._dragPoint.x + this.dragOffset.x,
|
|
s = this.globalToLocalY(t.y) + this._dragPoint.y + this.dragOffset.y;
|
|
if (this.sprite.fixedToCamera) this.allowHorizontalDrag && (this.sprite.cameraOffset.x = i), this.allowVerticalDrag && (this.sprite.cameraOffset.y = s), this.boundsRect && this.checkBoundsRect(), this.boundsSprite && this.checkBoundsSprite(), this.snapOnDrag && (this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY, this.snapPoint.set(this.sprite.cameraOffset.x, this.sprite.cameraOffset.y));
|
|
else {
|
|
var o = this.game.camera.x - this._pointerData[t.id].camX,
|
|
n = this.game.camera.y - this._pointerData[t.id].camY;
|
|
this.allowHorizontalDrag && (this.sprite.x = i + o), this.allowVerticalDrag && (this.sprite.y = s + n), this.boundsRect && this.checkBoundsRect(), this.boundsSprite && this.checkBoundsSprite(), this.snapOnDrag && (this.sprite.x = Math.round((this.sprite.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.y = Math.round((this.sprite.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY, this.snapPoint.set(this.sprite.x, this.sprite.y))
|
|
}
|
|
return this.sprite.events.onDragUpdate.dispatch(this.sprite, t, i, s, this.snapPoint, e), !0
|
|
},
|
|
justOver: function(t, e) { return t = t || 0, e = e || 500, this._pointerData[t].isOver && this.overDuration(t) < e },
|
|
justOut: function(t, e) { return t = t || 0, e = e || 500, this._pointerData[t].isOut && this.game.time.time - this._pointerData[t].timeOut < e },
|
|
justPressed: function(t, e) { return t = t || 0, e = e || 500, this._pointerData[t].isDown && this.downDuration(t) < e },
|
|
justReleased: function(t, e) { return t = t || 0, e = e || 500, this._pointerData[t].isUp && this.game.time.time - this._pointerData[t].timeUp < e },
|
|
overDuration: function(t) { return t = t || 0, this._pointerData[t].isOver ? this.game.time.time - this._pointerData[t].timeOver : -1 },
|
|
downDuration: function(t) { return t = t || 0, this._pointerData[t].isDown ? this.game.time.time - this._pointerData[t].timeDown : -1 },
|
|
enableDrag: function(t, e, i, s, o, n) { void 0 === t && (t = !1), void 0 === e && (e = !1), void 0 === i && (i = !1), void 0 === s && (s = 255), void 0 === o && (o = null), void 0 === n && (n = null), this._dragPoint = new H.Point, this.draggable = !0, this.bringToTop = e, this.dragOffset = new H.Point, this.dragFromCenter = t, this.pixelPerfectClick = i, this.pixelPerfectAlpha = s, o && (this.boundsRect = o), n && (this.boundsSprite = n) },
|
|
disableDrag: function() {
|
|
if (this._pointerData)
|
|
for (var t = 0; t < 10; t++) this._pointerData[t].isDragged = !1;
|
|
this.draggable = !1, this.isDragged = !1, this._draggedPointerID = -1, this._pendingDrag = !1
|
|
},
|
|
startDrag: function(t) {
|
|
var e = this.sprite.x,
|
|
i = this.sprite.y;
|
|
if (this.isDragged = !0, this._draggedPointerID = t.id, this._pointerData[t.id].camX = this.game.camera.x, this._pointerData[t.id].camY = this.game.camera.y, this._pointerData[t.id].isDragged = !0, this.sprite.fixedToCamera) {
|
|
if (this.dragFromCenter) {
|
|
var s = this.sprite.getBounds();
|
|
this.sprite.cameraOffset.x = this.globalToLocalX(t.x) + (this.sprite.cameraOffset.x - s.centerX), this.sprite.cameraOffset.y = this.globalToLocalY(t.y) + (this.sprite.cameraOffset.y - s.centerY)
|
|
}
|
|
this._dragPoint.setTo(this.sprite.cameraOffset.x - t.x, this.sprite.cameraOffset.y - t.y)
|
|
}
|
|
else {
|
|
if (this.dragFromCenter) {
|
|
s = this.sprite.getBounds();
|
|
this.sprite.x = this.globalToLocalX(t.x) + (this.sprite.x - s.centerX), this.sprite.y = this.globalToLocalY(t.y) + (this.sprite.y - s.centerY)
|
|
}
|
|
this._dragPoint.setTo(this.sprite.x - this.globalToLocalX(t.x), this.sprite.y - this.globalToLocalY(t.y))
|
|
}
|
|
this.updateDrag(t, !0), this.bringToTop && (this._dragPhase = !0, this.sprite.bringToTop()), this.dragStartPoint.set(e, i), this.sprite.events.onDragStart$dispatch(this.sprite, t, e, i), this._pendingDrag = !1
|
|
},
|
|
globalToLocalX: function(t) { return this.scaleLayer && (t -= this.game.scale.grid.boundsFluid.x, t *= this.game.scale.grid.scaleFluidInversed.x), t },
|
|
globalToLocalY: function(t) { return this.scaleLayer && (t -= this.game.scale.grid.boundsFluid.y, t *= this.game.scale.grid.scaleFluidInversed.y), t },
|
|
stopDrag: function(t) { this.isDragged = !1, this._draggedPointerID = -1, this._pointerData[t.id].isDragged = !1, this._dragPhase = !1, this._pendingDrag = !1, this.snapOnRelease && (this.sprite.fixedToCamera ? (this.sprite.cameraOffset.x = Math.round((this.sprite.cameraOffset.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.cameraOffset.y = Math.round((this.sprite.cameraOffset.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY) : (this.sprite.x = Math.round((this.sprite.x - this.snapOffsetX % this.snapX) / this.snapX) * this.snapX + this.snapOffsetX % this.snapX, this.sprite.y = Math.round((this.sprite.y - this.snapOffsetY % this.snapY) / this.snapY) * this.snapY + this.snapOffsetY % this.snapY)), this.sprite.events.onDragStop$dispatch(this.sprite, t), !1 === this.checkPointerOver(t) && this._pointerOutHandler(t) },
|
|
setDragLock: function(t, e) { void 0 === t && (t = !0), void 0 === e && (e = !0), this.allowHorizontalDrag = t, this.allowVerticalDrag = e },
|
|
enableSnap: function(t, e, i, s, o, n) { void 0 === i && (i = !0), void 0 === s && (s = !1), void 0 === o && (o = 0), void 0 === n && (n = 0), this.snapX = t, this.snapY = e, this.snapOffsetX = o, this.snapOffsetY = n, this.snapOnDrag = i, this.snapOnRelease = s },
|
|
disableSnap: function() { this.snapOnDrag = !1, this.snapOnRelease = !1 },
|
|
checkBoundsRect: function() { this.sprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsRect.left ? this.sprite.cameraOffset.x = this.boundsRect.left : this.sprite.cameraOffset.x + this.sprite.width > this.boundsRect.right && (this.sprite.cameraOffset.x = this.boundsRect.right - this.sprite.width), this.sprite.cameraOffset.y < this.boundsRect.top ? this.sprite.cameraOffset.y = this.boundsRect.top : this.sprite.cameraOffset.y + this.sprite.height > this.boundsRect.bottom && (this.sprite.cameraOffset.y = this.boundsRect.bottom - this.sprite.height)) : (this.sprite.left < this.boundsRect.left ? this.sprite.x = this.boundsRect.x + this.sprite.offsetX : this.sprite.right > this.boundsRect.right && (this.sprite.x = this.boundsRect.right - (this.sprite.width - this.sprite.offsetX)), this.sprite.top < this.boundsRect.top ? this.sprite.y = this.boundsRect.top + this.sprite.offsetY : this.sprite.bottom > this.boundsRect.bottom && (this.sprite.y = this.boundsRect.bottom - (this.sprite.height - this.sprite.offsetY))) },
|
|
checkBoundsSprite: function() { this.sprite.fixedToCamera && this.boundsSprite.fixedToCamera ? (this.sprite.cameraOffset.x < this.boundsSprite.cameraOffset.x ? this.sprite.cameraOffset.x = this.boundsSprite.cameraOffset.x : this.sprite.cameraOffset.x + this.sprite.width > this.boundsSprite.cameraOffset.x + this.boundsSprite.width && (this.sprite.cameraOffset.x = this.boundsSprite.cameraOffset.x + this.boundsSprite.width - this.sprite.width), this.sprite.cameraOffset.y < this.boundsSprite.cameraOffset.y ? this.sprite.cameraOffset.y = this.boundsSprite.cameraOffset.y : this.sprite.cameraOffset.y + this.sprite.height > this.boundsSprite.cameraOffset.y + this.boundsSprite.height && (this.sprite.cameraOffset.y = this.boundsSprite.cameraOffset.y + this.boundsSprite.height - this.sprite.height)) : (this.sprite.left < this.boundsSprite.left ? this.sprite.x = this.boundsSprite.left + this.sprite.offsetX : this.sprite.right > this.boundsSprite.right && (this.sprite.x = this.boundsSprite.right - (this.sprite.width - this.sprite.offsetX)), this.sprite.top < this.boundsSprite.top ? this.sprite.y = this.boundsSprite.top + this.sprite.offsetY : this.sprite.bottom > this.boundsSprite.bottom && (this.sprite.y = this.boundsSprite.bottom - (this.sprite.height - this.sprite.offsetY))) }
|
|
}, H.InputHandler.prototype.constructor = H.InputHandler, H.Gamepad = function(t) { this.game = t, this._gamepadIndexMap = {}, this._rawPads = [], this._active = !1, this.enabled = !0, this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || -1 !== navigator.userAgent.indexOf("Firefox/") || !!navigator.getGamepads, this._prevRawGamepadTypes = [], this._prevTimestamps = [], (this.callbackContext = this).onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null, this._ongamepadconnected = null, this._gamepaddisconnected = null, this._gamepads = [new H.SinglePad(t, this), new H.SinglePad(t, this), new H.SinglePad(t, this), new H.SinglePad(t, this)] }, H.Gamepad.prototype = {
|
|
addCallbacks: function(t, e) { void 0 !== e && (this.onConnectCallback = "function" == typeof e.onConnect ? e.onConnect : this.onConnectCallback, this.onDisconnectCallback = "function" == typeof e.onDisconnect ? e.onDisconnect : this.onDisconnectCallback, this.onDownCallback = "function" == typeof e.onDown ? e.onDown : this.onDownCallback, this.onUpCallback = "function" == typeof e.onUp ? e.onUp : this.onUpCallback, this.onAxisCallback = "function" == typeof e.onAxis ? e.onAxis : this.onAxisCallback, this.onFloatCallback = "function" == typeof e.onFloat ? e.onFloat : this.onFloatCallback, this.callbackContext = t) },
|
|
start: function() {
|
|
if (!this._active) {
|
|
this._active = !0;
|
|
var e = this;
|
|
this._onGamepadConnected = function(t) { return e.onGamepadConnected(t) }, this._onGamepadDisconnected = function(t) { return e.onGamepadDisconnected(t) }, window.addEventListener("gamepadconnected", this._onGamepadConnected, !1), window.addEventListener("gamepaddisconnected", this._onGamepadDisconnected, !1)
|
|
}
|
|
},
|
|
onGamepadConnected: function(t) {
|
|
var e = t.gamepad;
|
|
this._rawPads.push(e), this._gamepads[e.index].connect(e)
|
|
},
|
|
onGamepadDisconnected: function(t) {
|
|
var e = t.gamepad;
|
|
for (var i in this._rawPads) this._rawPads[i].index === e.index && this._rawPads.splice(i, 1);
|
|
this._gamepads[e.index].disconnect()
|
|
},
|
|
update: function() { this._pollGamepads(), this.pad1.pollStatus(), this.pad2.pollStatus(), this.pad3.pollStatus(), this.pad4.pollStatus() },
|
|
_pollGamepads: function() {
|
|
if (this._active) {
|
|
if (navigator.getGamepads) var t = navigator.getGamepads();
|
|
else if (navigator.webkitGetGamepads) t = navigator.webkitGetGamepads();
|
|
else if (navigator.webkitGamepads) t = navigator.webkitGamepads();
|
|
if (t) {
|
|
for (var e = !(this._rawPads = []), i = 0; i < t.length && (typeof t[i] !== this._prevRawGamepadTypes[i] && (e = !0, this._prevRawGamepadTypes[i] = typeof t[i]), t[i] && this._rawPads.push(t[i]), 3 !== i); i++);
|
|
for (var s = 0; s < this._gamepads.length; s++) this._gamepads[s]._rawPad = this._rawPads[s];
|
|
if (e) {
|
|
for (var o, n = { rawIndices: {}, padIndices: {} }, a = 0; a < this._gamepads.length; a++)
|
|
if ((o = this._gamepads[a]).connected)
|
|
for (var r = 0; r < this._rawPads.length; r++) this._rawPads[r].index === o.index && (n.rawIndices[o.index] = !0, n.padIndices[a] = !0);
|
|
for (var h = 0; h < this._gamepads.length; h++)
|
|
if (o = this._gamepads[h], !n.padIndices[h]) { this._rawPads.length < 1 && o.disconnect(); for (var l = 0; l < this._rawPads.length && !n.padIndices[h]; l++) { var c = this._rawPads[l]; if (c) { if (n.rawIndices[c.index]) { o.disconnect(); continue } o.connect(c), n.rawIndices[c.index] = !0, n.padIndices[h] = !0 } else o.disconnect() } }
|
|
}
|
|
}
|
|
}
|
|
},
|
|
setDeadZones: function(t) { for (var e = 0; e < this._gamepads.length; e++) this._gamepads[e].deadZone = t },
|
|
stop: function() { this._active = !1, window.removeEventListener("gamepadconnected", this._onGamepadConnected), window.removeEventListener("gamepaddisconnected", this._onGamepadDisconnected) },
|
|
reset: function() { this.update(); for (var t = 0; t < this._gamepads.length; t++) this._gamepads[t].reset() },
|
|
justPressed: function(t, e) {
|
|
for (var i = 0; i < this._gamepads.length; i++)
|
|
if (!0 === this._gamepads[i].justPressed(t, e)) return !0;
|
|
return !1
|
|
},
|
|
justReleased: function(t, e) {
|
|
for (var i = 0; i < this._gamepads.length; i++)
|
|
if (!0 === this._gamepads[i].justReleased(t, e)) return !0;
|
|
return !1
|
|
},
|
|
isDown: function(t) {
|
|
for (var e = 0; e < this._gamepads.length; e++)
|
|
if (!0 === this._gamepads[e].isDown(t)) return !0;
|
|
return !1
|
|
},
|
|
destroy: function() { this.stop(); for (var t = 0; t < this._gamepads.length; t++) this._gamepads[t].destroy() }
|
|
}, H.Gamepad.prototype.constructor = H.Gamepad, Object.defineProperty(H.Gamepad.prototype, "active", { get: function() { return this._active } }), Object.defineProperty(H.Gamepad.prototype, "supported", { get: function() { return this._gamepadSupportAvailable } }), Object.defineProperty(H.Gamepad.prototype, "padsConnected", { get: function() { return this._rawPads.length } }), Object.defineProperty(H.Gamepad.prototype, "pad1", { get: function() { return this._gamepads[0] } }), Object.defineProperty(H.Gamepad.prototype, "pad2", { get: function() { return this._gamepads[1] } }), Object.defineProperty(H.Gamepad.prototype, "pad3", { get: function() { return this._gamepads[2] } }), Object.defineProperty(H.Gamepad.prototype, "pad4", { get: function() { return this._gamepads[3] } }), H.Gamepad.BUTTON_0 = 0, H.Gamepad.BUTTON_1 = 1, H.Gamepad.BUTTON_2 = 2, H.Gamepad.BUTTON_3 = 3, H.Gamepad.BUTTON_4 = 4, H.Gamepad.BUTTON_5 = 5, H.Gamepad.BUTTON_6 = 6, H.Gamepad.BUTTON_7 = 7, H.Gamepad.BUTTON_8 = 8, H.Gamepad.BUTTON_9 = 9, H.Gamepad.BUTTON_10 = 10, H.Gamepad.BUTTON_11 = 11, H.Gamepad.BUTTON_12 = 12, H.Gamepad.BUTTON_13 = 13, H.Gamepad.BUTTON_14 = 14, H.Gamepad.BUTTON_15 = 15, H.Gamepad.AXIS_0 = 0, H.Gamepad.AXIS_1 = 1, H.Gamepad.AXIS_2 = 2, H.Gamepad.AXIS_3 = 3, H.Gamepad.AXIS_4 = 4, H.Gamepad.AXIS_5 = 5, H.Gamepad.AXIS_6 = 6, H.Gamepad.AXIS_7 = 7, H.Gamepad.AXIS_8 = 8, H.Gamepad.AXIS_9 = 9, H.Gamepad.XBOX360_A = 0, H.Gamepad.XBOX360_B = 1, H.Gamepad.XBOX360_X = 2, H.Gamepad.XBOX360_Y = 3, H.Gamepad.XBOX360_LEFT_BUMPER = 4, H.Gamepad.XBOX360_RIGHT_BUMPER = 5, H.Gamepad.XBOX360_LEFT_TRIGGER = 6, H.Gamepad.XBOX360_RIGHT_TRIGGER = 7, H.Gamepad.XBOX360_BACK = 8, H.Gamepad.XBOX360_START = 9, H.Gamepad.XBOX360_STICK_LEFT_BUTTON = 10, H.Gamepad.XBOX360_STICK_RIGHT_BUTTON = 11, H.Gamepad.XBOX360_DPAD_LEFT = 14, H.Gamepad.XBOX360_DPAD_RIGHT = 15, H.Gamepad.XBOX360_DPAD_UP = 12, H.Gamepad.XBOX360_DPAD_DOWN = 13, H.Gamepad.XBOX360_STICK_LEFT_X = 0, H.Gamepad.XBOX360_STICK_LEFT_Y = 1, H.Gamepad.XBOX360_STICK_RIGHT_X = 2, H.Gamepad.XBOX360_STICK_RIGHT_Y = 3, H.Gamepad.PS3XC_X = 0, H.Gamepad.PS3XC_CIRCLE = 1, H.Gamepad.PS3XC_SQUARE = 2, H.Gamepad.PS3XC_TRIANGLE = 3, H.Gamepad.PS3XC_L1 = 4, H.Gamepad.PS3XC_R1 = 5, H.Gamepad.PS3XC_L2 = 6, H.Gamepad.PS3XC_R2 = 7, H.Gamepad.PS3XC_SELECT = 8, H.Gamepad.PS3XC_START = 9, H.Gamepad.PS3XC_STICK_LEFT_BUTTON = 10, H.Gamepad.PS3XC_STICK_RIGHT_BUTTON = 11, H.Gamepad.PS3XC_DPAD_UP = 12, H.Gamepad.PS3XC_DPAD_DOWN = 13, H.Gamepad.PS3XC_DPAD_LEFT = 14, H.Gamepad.PS3XC_DPAD_RIGHT = 15, H.Gamepad.PS3XC_STICK_LEFT_X = 0, H.Gamepad.PS3XC_STICK_LEFT_Y = 1, H.Gamepad.PS3XC_STICK_RIGHT_X = 2, H.Gamepad.PS3XC_STICK_RIGHT_Y = 3, H.SinglePad = function(t, e) { this.game = t, this.index = null, this.connected = !1, (this.callbackContext = this).onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null, this.deadZone = .26, this._padParent = e, this._rawPad = null, this._prevTimestamp = null, this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0 }, H.SinglePad.prototype = {
|
|
addCallbacks: function(t, e) { void 0 !== e && (this.onConnectCallback = "function" == typeof e.onConnect ? e.onConnect : this.onConnectCallback, this.onDisconnectCallback = "function" == typeof e.onDisconnect ? e.onDisconnect : this.onDisconnectCallback, this.onDownCallback = "function" == typeof e.onDown ? e.onDown : this.onDownCallback, this.onUpCallback = "function" == typeof e.onUp ? e.onUp : this.onUpCallback, this.onAxisCallback = "function" == typeof e.onAxis ? e.onAxis : this.onAxisCallback, this.onFloatCallback = "function" == typeof e.onFloat ? e.onFloat : this.onFloatCallback, this.callbackContext = t) },
|
|
getButton: function(t) { return this._buttons[t] ? this._buttons[t] : null },
|
|
pollStatus: function() {
|
|
if (this.connected && this.game.input.enabled && this.game.input.gamepad.enabled && (!this._rawPad.timestamp || this._rawPad.timestamp !== this._prevTimestamp)) {
|
|
for (var t = 0; t < this._buttonsLen; t++) {
|
|
var e = isNaN(this._rawPad.buttons[t]) ? this._rawPad.buttons[t].value : this._rawPad.buttons[t];
|
|
e !== this._buttons[t].value && (1 === e ? this.processButtonDown(t, e) : 0 === e ? this.processButtonUp(t, e) : this.processButtonFloat(t, e))
|
|
}
|
|
for (var i = 0; i < this._axesLen; i++) {
|
|
var s = this._rawPad.axes[i];
|
|
0 < s && s > this.deadZone || s < 0 && s < -this.deadZone ? this.processAxisChange(i, s) : this.processAxisChange(i, 0)
|
|
}
|
|
this._prevTimestamp = this._rawPad.timestamp
|
|
}
|
|
},
|
|
connect: function(t) {
|
|
var e = !this.connected;
|
|
this.connected = !0, this.index = t.index, this._rawPad = t, this._buttons = [], this._buttonsLen = t.buttons.length, this._axes = [], this._axesLen = t.axes.length;
|
|
for (var i = 0; i < this._axesLen; i++) this._axes[i] = t.axes[i];
|
|
for (var s in t.buttons) s = parseInt(s, 10), this._buttons[s] = new H.DeviceButton(this, s);
|
|
e && this._padParent.onConnectCallback && this._padParent.onConnectCallback.call(this._padParent.callbackContext, this.index), e && this.onConnectCallback && this.onConnectCallback.call(this.callbackContext)
|
|
},
|
|
disconnect: function() {
|
|
var t = this.connected,
|
|
e = this.index;
|
|
this.connected = !1, this.index = null, this._rawPad = void 0;
|
|
for (var i = 0; i < this._buttonsLen; i++) this._buttons[i].destroy();
|
|
this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0, t && this._padParent.onDisconnectCallback && this._padParent.onDisconnectCallback.call(this._padParent.callbackContext, e), t && this.onDisconnectCallback && this.onDisconnectCallback.call(this.callbackContext)
|
|
},
|
|
destroy: function() {
|
|
this._rawPad = void 0;
|
|
for (var t = 0; t < this._buttonsLen; t++) this._buttons[t].destroy();
|
|
this._buttons = [], this._buttonsLen = 0, this._axes = [], this._axesLen = 0, this.onConnectCallback = null, this.onDisconnectCallback = null, this.onDownCallback = null, this.onUpCallback = null, this.onAxisCallback = null, this.onFloatCallback = null
|
|
},
|
|
processAxisChange: function(t, e) { this._axes[t] !== e && (this._axes[t] = e, this._padParent.onAxisCallback && this._padParent.onAxisCallback.call(this._padParent.callbackContext, this, t, e), this.onAxisCallback && this.onAxisCallback.call(this.callbackContext, this, t, e)) },
|
|
processButtonDown: function(t, e) { this._buttons[t] && this._buttons[t].start(null, e), this._padParent.onDownCallback && this._padParent.onDownCallback.call(this._padParent.callbackContext, t, e, this.index), this.onDownCallback && this.onDownCallback.call(this.callbackContext, t, e) },
|
|
processButtonUp: function(t, e) { this._padParent.onUpCallback && this._padParent.onUpCallback.call(this._padParent.callbackContext, t, e, this.index), this.onUpCallback && this.onUpCallback.call(this.callbackContext, t, e), this._buttons[t] && this._buttons[t].stop(null, e) },
|
|
processButtonFloat: function(t, e) { this._padParent.onFloatCallback && this._padParent.onFloatCallback.call(this._padParent.callbackContext, t, e, this.index), this.onFloatCallback && this.onFloatCallback.call(this.callbackContext, t, e), this._buttons[t] && this._buttons[t].padFloat(e) },
|
|
axis: function(t) { return !!this._axes[t] && this._axes[t] },
|
|
isDown: function(t) { return !!this._buttons[t] && this._buttons[t].isDown },
|
|
isUp: function(t) { return !!this._buttons[t] && this._buttons[t].isUp },
|
|
justReleased: function(t, e) { if (this._buttons[t]) return this._buttons[t].justReleased(e) },
|
|
justPressed: function(t, e) { if (this._buttons[t]) return this._buttons[t].justPressed(e) },
|
|
buttonValue: function(t) { return this._buttons[t] ? this._buttons[t].value : null },
|
|
reset: function() { for (var t = 0; t < this._axes.length; t++) this._axes[t] = 0 }
|
|
}, H.SinglePad.prototype.constructor = H.SinglePad, H.Key = function(t, e) { this.game = t, this._enabled = !0, this.event = null, this.isDown = !1, this.isUp = !0, this.altKey = !1, this.ctrlKey = !1, this.shiftKey = !1, this.timeDown = 0, this.duration = 0, this.timeUp = -2500, this.repeats = 0, this.keyCode = e, this.onDown = new H.Signal, this.onHoldCallback = null, this.onHoldContext = null, this.onUp = new H.Signal, this._justDown = !1, this._justUp = !1 }, H.Key.prototype = { update: function() { this._enabled && this.isDown && (this.duration = this.game.time.time - this.timeDown, this.repeats++, this.onHoldCallback && this.onHoldCallback.call(this.onHoldContext, this)) }, processKeyDown: function(t) { this._enabled && (this.event = t, this.isDown || (this.altKey = t.altKey, this.ctrlKey = t.ctrlKey, this.shiftKey = t.shiftKey, this.isDown = !0, this.isUp = !1, this.timeDown = this.game.time.time, this.duration = 0, this.repeats = 0, this._justDown = !0, this.onDown.dispatch(this))) }, processKeyUp: function(t) { this._enabled && (this.event = t, this.isUp || (this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.duration = this.game.time.time - this.timeDown, this._justUp = !0, this.onUp.dispatch(this))) }, reset: function(t) { void 0 === t && (t = !0), this.isDown = !1, this.isUp = !0, this.timeUp = this.game.time.time, this.duration = 0, this._enabled = !0, this._justDown = !1, this._justUp = !1, t && (this.onDown.removeAll(), this.onUp.removeAll(), this.onHoldCallback = null, this.onHoldContext = null) }, downDuration: function(t) { return void 0 === t && (t = 50), this.isDown && this.duration < t }, upDuration: function(t) { return void 0 === t && (t = 50), !this.isDown && this.game.time.time - this.timeUp < t } }, Object.defineProperty(H.Key.prototype, "justDown", { get: function() { var t = this._justDown; return this._justDown = !1, t } }), Object.defineProperty(H.Key.prototype, "justUp", { get: function() { var t = this._justUp; return this._justUp = !1, t } }), Object.defineProperty(H.Key.prototype, "enabled", {
|
|
get: function() { return this._enabled },
|
|
set: function(t) {
|
|
(t = !!t) !== this._enabled && (t || this.reset(!1), this._enabled = t)
|
|
}
|
|
}), H.Key.prototype.constructor = H.Key, H.Keyboard = function(t) { this.game = t, this.enabled = !0, this.event = null, this.pressEvent = null, (this.callbackContext = this).onDownCallback = null, this.onPressCallback = null, this.onUpCallback = null, this._keys = [], this._capture = [], this._onKeyDown = null, this._onKeyPress = null, this._onKeyUp = null, this._i = 0, this._k = 0 }, H.Keyboard.prototype = {
|
|
addCallbacks: function(t, e, i, s) { this.callbackContext = t, null != e && (this.onDownCallback = e), null != i && (this.onUpCallback = i), null != s && (this.onPressCallback = s) },
|
|
addKey: function(t) { return this._keys[t] || (this._keys[t] = new H.Key(this.game, t), this.addKeyCapture(t)), this._keys[t] },
|
|
addKeys: function(t) { var e = {}; for (var i in t) e[i] = this.addKey(t[i]); return e },
|
|
removeKey: function(t) { this._keys[t] && (this._keys[t] = null, this.removeKeyCapture(t)) },
|
|
createCursorKeys: function() { return this.addKeys({ up: H.KeyCode.UP, down: H.KeyCode.DOWN, left: H.KeyCode.LEFT, right: H.KeyCode.RIGHT }) },
|
|
start: function() {
|
|
if (!this.game.device.cocoonJS && null === this._onKeyDown) {
|
|
var e = this;
|
|
this._onKeyDown = function(t) { return e.processKeyDown(t) }, this._onKeyUp = function(t) { return e.processKeyUp(t) }, this._onKeyPress = function(t) { return e.processKeyPress(t) }, window.addEventListener("keydown", this._onKeyDown, !1), window.addEventListener("keyup", this._onKeyUp, !1), window.addEventListener("keypress", this._onKeyPress, !1)
|
|
}
|
|
},
|
|
stop: function() { window.removeEventListener("keydown", this._onKeyDown), window.removeEventListener("keyup", this._onKeyUp), window.removeEventListener("keypress", this._onKeyPress), this._onKeyDown = null, this._onKeyUp = null, this._onKeyPress = null },
|
|
destroy: function() { this.stop(), this.clearCaptures(), this._keys.length = 0, this._i = 0 },
|
|
addKeyCapture: function(t) {
|
|
if ("object" == typeof t)
|
|
for (var e in t) this._capture[t[e]] = !0;
|
|
else this._capture[t] = !0
|
|
},
|
|
removeKeyCapture: function(t) { delete this._capture[t] },
|
|
clearCaptures: function() { this._capture = {} },
|
|
update: function() { for (this._i = this._keys.length; this._i--;) this._keys[this._i] && this._keys[this._i].update() },
|
|
processKeyDown: function(t) {
|
|
if (this.event = t, this.game.input.enabled && this.enabled) {
|
|
var e = t.keyCode;
|
|
this._capture[e] && t.preventDefault(), this._keys[e] || (this._keys[e] = new H.Key(this.game, e)), this._keys[e].processKeyDown(t), this._k = e, this.onDownCallback && this.onDownCallback.call(this.callbackContext, t)
|
|
}
|
|
},
|
|
processKeyPress: function(t) { this.pressEvent = t, this.game.input.enabled && this.enabled && this.onPressCallback && this.onPressCallback.call(this.callbackContext, String.fromCharCode(t.charCode), t) },
|
|
processKeyUp: function(t) {
|
|
if (this.event = t, this.game.input.enabled && this.enabled) {
|
|
var e = t.keyCode;
|
|
this._capture[e] && t.preventDefault(), this._keys[e] || (this._keys[e] = new H.Key(this.game, e)), this._keys[e].processKeyUp(t), this.onUpCallback && this.onUpCallback.call(this.callbackContext, t)
|
|
}
|
|
},
|
|
reset: function(t) { void 0 === t && (t = !0), this.event = null; for (var e = this._keys.length; e--;) this._keys[e] && this._keys[e].reset(t) },
|
|
downDuration: function(t, e) { return this._keys[t] ? this._keys[t].downDuration(e) : null },
|
|
upDuration: function(t, e) { return this._keys[t] ? this._keys[t].upDuration(e) : null },
|
|
isDown: function(t) { return this._keys[t] ? this._keys[t].isDown : null }
|
|
}, Object.defineProperty(H.Keyboard.prototype, "lastChar", { get: function() { return 32 === this.event.charCode ? "" : String.fromCharCode(this.pressEvent.charCode) } }), Object.defineProperty(H.Keyboard.prototype, "lastKey", { get: function() { return this._keys[this._k] } }), H.Keyboard.prototype.constructor = H.Keyboard, H.KeyCode = { A: "A".charCodeAt(0), B: "B".charCodeAt(0), C: "C".charCodeAt(0), D: "D".charCodeAt(0), E: "E".charCodeAt(0), F: "F".charCodeAt(0), G: "G".charCodeAt(0), H: "H".charCodeAt(0), I: "I".charCodeAt(0), J: "J".charCodeAt(0), K: "K".charCodeAt(0), L: "L".charCodeAt(0), M: "M".charCodeAt(0), N: "N".charCodeAt(0), O: "O".charCodeAt(0), P: "P".charCodeAt(0), Q: "Q".charCodeAt(0), R: "R".charCodeAt(0), S: "S".charCodeAt(0), T: "T".charCodeAt(0), U: "U".charCodeAt(0), V: "V".charCodeAt(0), W: "W".charCodeAt(0), X: "X".charCodeAt(0), Y: "Y".charCodeAt(0), Z: "Z".charCodeAt(0), ZERO: "0".charCodeAt(0), ONE: "1".charCodeAt(0), TWO: "2".charCodeAt(0), THREE: "3".charCodeAt(0), FOUR: "4".charCodeAt(0), FIVE: "5".charCodeAt(0), SIX: "6".charCodeAt(0), SEVEN: "7".charCodeAt(0), EIGHT: "8".charCodeAt(0), NINE: "9".charCodeAt(0), NUMPAD_0: 96, NUMPAD_1: 97, NUMPAD_2: 98, NUMPAD_3: 99, NUMPAD_4: 100, NUMPAD_5: 101, NUMPAD_6: 102, NUMPAD_7: 103, NUMPAD_8: 104, NUMPAD_9: 105, NUMPAD_MULTIPLY: 106, NUMPAD_ADD: 107, NUMPAD_ENTER: 108, NUMPAD_SUBTRACT: 109, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123, F13: 124, F14: 125, F15: 126, COLON: 186, EQUALS: 187, COMMA: 188, UNDERSCORE: 189, PERIOD: 190, QUESTION_MARK: 191, TILDE: 192, OPEN_BRACKET: 219, BACKWARD_SLASH: 220, CLOSED_BRACKET: 221, QUOTES: 222, BACKSPACE: 8, TAB: 9, CLEAR: 12, ENTER: 13, SHIFT: 16, CONTROL: 17, ALT: 18, CAPS_LOCK: 20, ESC: 27, SPACEBAR: 32, PAGE_UP: 33, PAGE_DOWN: 34, END: 35, HOME: 36, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, PLUS: 43, MINUS: 44, INSERT: 45, DELETE: 46, HELP: 47, NUM_LOCK: 144 }, H.KeyCode) H.KeyCode.hasOwnProperty(i) && !i.match(/[a-z]/) && (H.Keyboard[i] = H.KeyCode[i]);
|
|
for (var o in H.Component = function() {}, H.Component.Angle = function() {}, H.Component.Angle.prototype = { angle: { get: function() { return H.Math.wrapAngle(H.Math.radToDeg(this.rotation)) }, set: function(t) { this.rotation = H.Math.degToRad(H.Math.wrapAngle(t)) } } }, H.Component.Animation = function() {}, H.Component.Animation.prototype = { play: function(t, e, i, s) { if (this.animations) return this.animations.play(t, e, i, s) } }, H.Component.AutoCull = function() {}, H.Component.AutoCull.prototype = { autoCull: !1, inCamera: { get: function() { return this.autoCull || this.checkWorldBounds || (this._bounds.copyFrom(this.getBounds()), this._bounds.x += this.game.camera.view.x, this._bounds.y += this.game.camera.view.y), this.game.world.camera.view.intersects(this._bounds) } } }, H.Component.Bounds = function() {}, H.Component.Bounds.prototype = {
|
|
offsetX: { get: function() { return this.anchor.x * this.width } },
|
|
offsetY: { get: function() { return this.anchor.y * this.height } },
|
|
centerX: { get: function() { return this.x - this.offsetX + .5 * this.width }, set: function(t) { this.x = t + this.offsetX - .5 * this.width } },
|
|
centerY: { get: function() { return this.y - this.offsetY + .5 * this.height }, set: function(t) { this.y = t + this.offsetY - .5 * this.height } },
|
|
left: { get: function() { return this.x - this.offsetX }, set: function(t) { this.x = t + this.offsetX } },
|
|
right: { get: function() { return this.x + this.width - this.offsetX }, set: function(t) { this.x = t - this.width + this.offsetX } },
|
|
top: { get: function() { return this.y - this.offsetY }, set: function(t) { this.y = t + this.offsetY } },
|
|
bottom: { get: function() { return this.y + this.height - this.offsetY }, set: function(t) { this.y = t - this.height + this.offsetY } },
|
|
alignIn: function(t, e, i, s) {
|
|
switch (void 0 === i && (i = 0), void 0 === s && (s = 0), e) {
|
|
default:
|
|
case H.TOP_LEFT:
|
|
this.left = t.left - i,
|
|
this.top = t.top - s;
|
|
break;
|
|
case H.TOP_CENTER:
|
|
this.centerX = t.centerX + i,
|
|
this.top = t.top - s;
|
|
break;
|
|
case H.TOP_RIGHT:
|
|
this.right = t.right + i,
|
|
this.top = t.top - s;
|
|
break;
|
|
case H.LEFT_CENTER:
|
|
this.left = t.left - i,
|
|
this.centerY = t.centerY + s;
|
|
break;
|
|
case H.CENTER:
|
|
this.centerX = t.centerX + i,
|
|
this.centerY = t.centerY + s;
|
|
break;
|
|
case H.RIGHT_CENTER:
|
|
this.right = t.right + i,
|
|
this.centerY = t.centerY + s;
|
|
break;
|
|
case H.BOTTOM_LEFT:
|
|
this.left = t.left - i,
|
|
this.bottom = t.bottom + s;
|
|
break;
|
|
case H.BOTTOM_CENTER:
|
|
this.centerX = t.centerX + i,
|
|
this.bottom = t.bottom + s;
|
|
break;
|
|
case H.BOTTOM_RIGHT:
|
|
this.right = t.right + i,
|
|
this.bottom = t.bottom + s
|
|
}
|
|
return this
|
|
},
|
|
alignTo: function(t, e, i, s) {
|
|
switch (void 0 === i && (i = 0), void 0 === s && (s = 0), e) {
|
|
default:
|
|
case H.TOP_LEFT:
|
|
this.left = t.left - i,
|
|
this.bottom = t.top - s;
|
|
break;
|
|
case H.TOP_CENTER:
|
|
this.centerX = t.centerX + i,
|
|
this.bottom = t.top - s;
|
|
break;
|
|
case H.TOP_RIGHT:
|
|
this.right = t.right + i,
|
|
this.bottom = t.top - s;
|
|
break;
|
|
case H.LEFT_TOP:
|
|
this.right = t.left - i,
|
|
this.top = t.top - s;
|
|
break;
|
|
case H.LEFT_CENTER:
|
|
this.right = t.left - i,
|
|
this.centerY = t.centerY + s;
|
|
break;
|
|
case H.LEFT_BOTTOM:
|
|
this.right = t.left - i,
|
|
this.bottom = t.bottom + s;
|
|
break;
|
|
case H.RIGHT_TOP:
|
|
this.left = t.right + i,
|
|
this.top = t.top - s;
|
|
break;
|
|
case H.RIGHT_CENTER:
|
|
this.left = t.right + i,
|
|
this.centerY = t.centerY + s;
|
|
break;
|
|
case H.RIGHT_BOTTOM:
|
|
this.left = t.right + i,
|
|
this.bottom = t.bottom + s;
|
|
break;
|
|
case H.BOTTOM_LEFT:
|
|
this.left = t.left - i,
|
|
this.top = t.bottom + s;
|
|
break;
|
|
case H.BOTTOM_CENTER:
|
|
this.centerX = t.centerX + i,
|
|
this.top = t.bottom + s;
|
|
break;
|
|
case H.BOTTOM_RIGHT:
|
|
this.right = t.right + i,
|
|
this.top = t.bottom + s
|
|
}
|
|
return this
|
|
}
|
|
}, H.Group.prototype.alignIn = H.Component.Bounds.prototype.alignIn, H.Group.prototype.alignTo = H.Component.Bounds.prototype.alignTo, H.Component.BringToTop = function() {}, H.Component.BringToTop.prototype.bringToTop = function() { return this.parent && this.parent.bringToTop(this), this }, H.Component.BringToTop.prototype.sendToBack = function() { return this.parent && this.parent.sendToBack(this), this }, H.Component.BringToTop.prototype.moveUp = function() { return this.parent && this.parent.moveUp(this), this }, H.Component.BringToTop.prototype.moveDown = function() { return this.parent && this.parent.moveDown(this), this }, H.Component.Core = function() {}, H.Component.Core.install = function(t) {
|
|
H.Utils.mixinPrototype(this, H.Component.Core.prototype), this.components = {};
|
|
for (var e = 0; e < t.length; e++) {
|
|
var i = t[e],
|
|
s = !1;
|
|
"Destroy" === i && (s = !0), H.Utils.mixinPrototype(this, H.Component[i].prototype, s), this.components[i] = !0
|
|
}
|
|
}, H.Component.Core.init = function(t, e, i, s, o) { this.game = t, this.key = s, this.data = {}, this.position.set(e, i), this.world = new H.Point(e, i), this.previousPosition = new H.Point(e, i), this.events = new H.Events(this), this._bounds = new H.Rectangle, this.components.PhysicsBody && (this.body = this.body), this.components.Animation && (this.animations = new H.AnimationManager(this)), this.components.LoadTexture && null !== s && this.loadTexture(s, o), this.components.FixedToCamera && (this.cameraOffset = new H.Point(e, i)) }, H.Component.Core.preUpdate = function() {
|
|
if (!this.pendingDestroy) {
|
|
if (this.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, !this.exists || !this.parent.exists) return !(this.renderOrderID = -1);
|
|
this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty), this.visible && (this.renderOrderID = this.game.stage.currentRenderOrderID++), this.animations && this.animations.update(), this.body && this.body.preUpdate();
|
|
for (var t = 0; t < this.children.length; t++) this.children[t].preUpdate();
|
|
return !0
|
|
}
|
|
this.destroy()
|
|
}, H.Component.Core.prototype = { game: null, name: "", data: {}, components: {}, z: 0, events: void 0, animations: void 0, key: "", world: null, debug: !1, previousPosition: null, previousRotation: 0, renderOrderID: 0, fresh: !0, pendingDestroy: !1, _bounds: null, _exists: !0, exists: { get: function() { return this._exists }, set: function(t) { this.visible = t ? (this._exists = !0, this.body && this.body.type === H.Physics.P2JS && this.body.addToWorld(), !0) : (this._exists = !1, this.body && this.body.type === H.Physics.P2JS && this.body.removeFromWorld(), !1) } }, update: function() {}, postUpdate: function() { this.customRender && this.key.render(), this.components.PhysicsBody && H.Component.PhysicsBody.postUpdate.call(this), this.components.FixedToCamera && H.Component.FixedToCamera.postUpdate.call(this); for (var t = 0; t < this.children.length; t++) this.children[t].postUpdate() } }, H.Component.Crop = function() {}, H.Component.Crop.prototype = {
|
|
cropRect: null,
|
|
_crop: null,
|
|
crop: function(t, e) { void 0 === e && (e = !1), t ? (e && null !== this.cropRect ? this.cropRect.setTo(t.x, t.y, t.width, t.height) : e && null === this.cropRect ? this.cropRect = new H.Rectangle(t.x, t.y, t.width, t.height) : this.cropRect = t, this.updateCrop()) : (this._crop = null, this.cropRect = null, this.resetFrame()) },
|
|
updateCrop: function() {
|
|
if (this.cropRect) {
|
|
var t = this.texture.crop.x,
|
|
e = this.texture.crop.y,
|
|
i = this.texture.crop.width,
|
|
s = this.texture.crop.height;
|
|
this._crop = H.Rectangle.clone(this.cropRect, this._crop), this._crop.x += this._frame.x, this._crop.y += this._frame.y;
|
|
var o = Math.max(this._frame.x, this._crop.x),
|
|
n = Math.max(this._frame.y, this._crop.y),
|
|
a = Math.min(this._frame.right, this._crop.right) - o,
|
|
r = Math.min(this._frame.bottom, this._crop.bottom) - n;
|
|
this.texture.crop.x = o, this.texture.crop.y = n, this.texture.crop.width = a, this.texture.crop.height = r, this.texture.frame.width = Math.min(a, this.cropRect.width), this.texture.frame.height = Math.min(r, this.cropRect.height), this.texture.width = this.texture.frame.width, this.texture.height = this.texture.frame.height, this.texture._updateUvs(), 16777215 === this.tint || t === o && e === n && i === a && s === r || (this.texture.requiresReTint = !0)
|
|
}
|
|
}
|
|
}, H.Component.Delta = function() {}, H.Component.Delta.prototype = { deltaX: { get: function() { return this.world.x - this.previousPosition.x } }, deltaY: { get: function() { return this.world.y - this.previousPosition.y } }, deltaZ: { get: function() { return this.rotation - this.previousRotation } } }, H.Component.Destroy = function() {}, H.Component.Destroy.prototype = {
|
|
destroyPhase: !1,
|
|
destroy: function(t, e) {
|
|
if (null !== this.game && !this.destroyPhase) {
|
|
void 0 === t && (t = !0), void 0 === e && (e = !1), this.destroyPhase = !0, this.events && this.events.onDestroy$dispatch(this), this.parent && (this.parent instanceof H.Group ? this.parent.remove(this) : this.parent.removeChild(this)), this.input && this.input.destroy(), this.animations && this.animations.destroy(), this.body && this.body.destroy(), this.events && this.events.destroy(), this.game.tweens.removeFrom(this);
|
|
var i = this.children.length;
|
|
if (t)
|
|
for (; i--;) this.children[i].destroy(t);
|
|
else
|
|
for (; i--;) this.removeChild(this.children[i]);
|
|
this._crop && (this._crop = null, this.cropRect = null), this._frame && (this._frame = null), H.Video && this.key instanceof H.Video && this.key.onChangeSource.remove(this.resizeFrame, this), H.BitmapText && this._glyphs && (this._glyphs = []), this.alive = !1, this.exists = !1, this.visible = !1, this.filters = null, this.mask = null, this.game = null, this.data = {}, this.renderable = !1, this.transformCallback && (this.transformCallback = null, this.transformCallbackContext = null), this.hitArea = null, this.parent = null, this.stage = null, this.worldTransform = null, this.filterArea = null, this._bounds = null, this._currentBounds = null, this._mask = null, this._destroyCachedSprite(), e && this.texture.destroy(!0), this.destroyPhase = !1, this.pendingDestroy = !1
|
|
}
|
|
}
|
|
}, H.Events = function(t) { this.parent = t }, H.Events.prototype = { destroy: function() { this._parent = null, this._onDestroy && this._onDestroy.dispose(), this._onAddedToGroup && this._onAddedToGroup.dispose(), this._onRemovedFromGroup && this._onRemovedFromGroup.dispose(), this._onRemovedFromWorld && this._onRemovedFromWorld.dispose(), this._onKilled && this._onKilled.dispose(), this._onRevived && this._onRevived.dispose(), this._onEnterBounds && this._onEnterBounds.dispose(), this._onOutOfBounds && this._onOutOfBounds.dispose(), this._onInputOver && this._onInputOver.dispose(), this._onInputOut && this._onInputOut.dispose(), this._onInputDown && this._onInputDown.dispose(), this._onInputUp && this._onInputUp.dispose(), this._onDragStart && this._onDragStart.dispose(), this._onDragUpdate && this._onDragUpdate.dispose(), this._onDragStop && this._onDragStop.dispose(), this._onAnimationStart && this._onAnimationStart.dispose(), this._onAnimationComplete && this._onAnimationComplete.dispose(), this._onAnimationLoop && this._onAnimationLoop.dispose() }, onAddedToGroup: null, onRemovedFromGroup: null, onRemovedFromWorld: null, onDestroy: null, onKilled: null, onRevived: null, onOutOfBounds: null, onEnterBounds: null, onInputOver: null, onInputOut: null, onInputDown: null, onInputUp: null, onDragStart: null, onDragUpdate: null, onDragStop: null, onAnimationStart: null, onAnimationComplete: null, onAnimationLoop: null }, H.Events.prototype.constructor = H.Events, H.Events.prototype) H.Events.prototype.hasOwnProperty(o) && 0 === o.indexOf("on") && null === H.Events.prototype[o] && function(t, e) {
|
|
"use strict";
|
|
Object.defineProperty(H.Events.prototype, t, { get: function() { return this[e] || (this[e] = new H.Signal) } }), H.Events.prototype[t + "$dispatch"] = function() { return this[e] ? this[e].dispatch.apply(this[e], arguments) : null }
|
|
}(o, "_" + o);
|
|
H.Component.FixedToCamera = function() {}, H.Component.FixedToCamera.postUpdate = function() { this.fixedToCamera && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y) }, H.Component.FixedToCamera.prototype = { _fixedToCamera: !1, fixedToCamera: { get: function() { return this._fixedToCamera }, set: function(t) { t ? (this._fixedToCamera = !0, this.cameraOffset.set(this.x, this.y)) : this._fixedToCamera = !1 } }, cameraOffset: new H.Point }, H.Component.Health = function() {}, H.Component.Health.prototype = { health: 1, maxHealth: 100, damage: function(t) { return this.alive && (this.health -= t, this.health <= 0 && this.kill()), this }, setHealth: function(t) { return this.health = t, this.health > this.maxHealth && (this.health = this.maxHealth), this }, heal: function(t) { return this.alive && (this.health += t, this.health > this.maxHealth && (this.health = this.maxHealth)), this } }, H.Component.InCamera = function() {}, H.Component.InCamera.prototype = { inCamera: { get: function() { return this.game.world.camera.view.intersects(this._bounds) } } }, H.Component.InputEnabled = function() {}, H.Component.InputEnabled.prototype = { input: null, inputEnabled: { get: function() { return this.input && this.input.enabled }, set: function(t) { t ? null === this.input ? (this.input = new H.InputHandler(this), this.input.start()) : this.input && !this.input.enabled && this.input.start() : this.input && this.input.enabled && this.input.stop() } } }, H.Component.InWorld = function() {}, H.Component.InWorld.preUpdate = function() {
|
|
if (this.autoCull || this.checkWorldBounds) {
|
|
if (this._bounds.copyFrom(this.getBounds()), this._bounds.x += this.game.camera.view.x, this._bounds.y += this.game.camera.view.y, this.autoCull)
|
|
if (this.game.world.camera.view.intersects(this._bounds)) this.renderable = !0, this.game.world.camera.totalInView++;
|
|
else if (this.renderable = !1, this.outOfCameraBoundsKill) return this.kill(), !1;
|
|
if (this.checkWorldBounds)
|
|
if (this._outOfBoundsFired && this.game.world.bounds.intersects(this._bounds)) this._outOfBoundsFired = !1, this.events.onEnterBounds$dispatch(this);
|
|
else if (!this._outOfBoundsFired && !this.game.world.bounds.intersects(this._bounds) && (this._outOfBoundsFired = !0, this.events.onOutOfBounds$dispatch(this), this.outOfBoundsKill)) return this.kill(), !1
|
|
}
|
|
return !0
|
|
}, H.Component.InWorld.prototype = { checkWorldBounds: !1, outOfBoundsKill: !1, outOfCameraBoundsKill: !1, _outOfBoundsFired: !1, inWorld: { get: function() { return this.game.world.bounds.intersects(this.getBounds()) } } }, H.Component.LifeSpan = function() {}, H.Component.LifeSpan.preUpdate = function() { return !(0 < this.lifespan && (this.lifespan -= this.game.time.physicsElapsedMS, this.lifespan <= 0)) || (this.kill(), !1) }, H.Component.LifeSpan.prototype = { alive: !0, lifespan: 0, revive: function(t) { return void 0 === t && (t = 100), this.alive = !0, this.exists = !0, this.visible = !0, "function" == typeof this.setHealth && this.setHealth(t), this.events && this.events.onRevived$dispatch(this), this }, kill: function() { return this.alive = !1, this.exists = !1, this.visible = !1, this.events && this.events.onKilled$dispatch(this), this } }, H.Component.LoadTexture = function() {}, H.Component.LoadTexture.prototype = {
|
|
customRender: !1,
|
|
_frame: null,
|
|
loadTexture: function(t, e, i) {
|
|
e = t === H.PENDING_ATLAS ? (t = e, 0) : e || 0, (i || void 0 === i) && this.animations && this.animations.stop(), this.key = t, this.customRender = !1;
|
|
var s = this.game.cache,
|
|
o = !0,
|
|
n = !this.texture.baseTexture.scaleMode;
|
|
if (H.RenderTexture && t instanceof H.RenderTexture) this.key = t.key, this.setTexture(t);
|
|
else if (H.BitmapData && t instanceof H.BitmapData) this.customRender = !0, this.setTexture(t.texture), o = s.hasFrameData(t.key, H.Cache.BITMAPDATA) ? !this.animations.loadFrameData(s.getFrameData(t.key, H.Cache.BITMAPDATA), e) : !this.animations.loadFrameData(t.frameData, 0);
|
|
else if (H.Video && t instanceof H.Video) {
|
|
this.customRender = !0;
|
|
var a = t.texture.valid;
|
|
this.setTexture(t.texture), this.setFrame(t.texture.frame.clone()), t.onChangeSource.add(this.resizeFrame, this), this.texture.valid = a
|
|
}
|
|
else if (H.Tilemap && t instanceof H.TilemapLayer) this.setTexture(PIXI.Texture.fromCanvas(t.canvas));
|
|
else if (t instanceof PIXI.Texture) this.setTexture(t);
|
|
else {
|
|
var r = s.getImage(t, !0);
|
|
this.key = r.key, this.setTexture(new PIXI.Texture(r.base)), this.texture.baseTexture.skipRender = "__default" === t, o = !this.animations.loadFrameData(r.frameData, e)
|
|
}
|
|
o && (this._frame = H.Rectangle.clone(this.texture.frame)), n || (this.texture.baseTexture.scaleMode = 1)
|
|
},
|
|
setFrame: function(t) { this._frame = t, this.texture.frame.x = t.x, this.texture.frame.y = t.y, this.texture.frame.width = t.width, this.texture.frame.height = t.height, this.texture.crop.x = t.x, this.texture.crop.y = t.y, this.texture.crop.width = t.width, this.texture.crop.height = t.height, t.trimmed ? (this.texture.trim ? (this.texture.trim.x = t.spriteSourceSizeX, this.texture.trim.y = t.spriteSourceSizeY, this.texture.trim.width = t.sourceSizeW, this.texture.trim.height = t.sourceSizeH) : this.texture.trim = { x: t.spriteSourceSizeX, y: t.spriteSourceSizeY, width: t.sourceSizeW, height: t.sourceSizeH }, this.texture.width = t.sourceSizeW, this.texture.height = t.sourceSizeH, this.texture.frame.width = t.sourceSizeW, this.texture.frame.height = t.sourceSizeH) : !t.trimmed && this.texture.trim && (this.texture.trim = null), this.cropRect && this.updateCrop(), this.texture.requiresReTint = !0, this.texture._updateUvs(), this.tilingTexture && (this.refreshTexture = !0) },
|
|
resizeFrame: function(t, e, i) { this.texture.frame.resize(e, i), this.texture.setFrame(this.texture.frame) },
|
|
resetFrame: function() { this._frame && this.setFrame(this._frame) },
|
|
frame: { get: function() { return this.animations.frame }, set: function(t) { this.animations.frame = t } },
|
|
frameName: { get: function() { return this.animations.frameName }, set: function(t) { this.animations.frameName = t } }
|
|
}, H.Component.Overlap = function() {}, H.Component.Overlap.prototype = { overlap: function(t) { return H.Rectangle.intersects(this.getBounds(), t.getBounds()) } }, H.Component.PhysicsBody = function() {}, H.Component.PhysicsBody.preUpdate = function() { return this.fresh && this.exists ? (this.world.setTo(this.parent.position.x + this.position.x, this.parent.position.y + this.position.y), this.worldTransform.tx = this.world.x, this.worldTransform.ty = this.world.y, this.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, this.body && this.body.preUpdate(), this.fresh = !1) : (this.previousPosition.set(this.world.x, this.world.y), this.previousRotation = this.rotation, !(!this._exists || !this.parent.exists) || !(this.renderOrderID = -1)) }, H.Component.PhysicsBody.postUpdate = function() { this.exists && this.body && this.body.postUpdate() }, H.Component.PhysicsBody.prototype = { body: null, x: { get: function() { return this.position.x }, set: function(t) { this.position.x = t, this.body && !this.body.dirty && (this.body._reset = !0) } }, y: { get: function() { return this.position.y }, set: function(t) { this.position.y = t, this.body && !this.body.dirty && (this.body._reset = !0) } } }, H.Component.Reset = function() {}, H.Component.Reset.prototype.reset = function(t, e, i) { return void 0 === i && (i = 1), this.world.set(t, e), this.position.set(t, e), this.fresh = !0, this.exists = !0, this.visible = !0, this.renderable = !0, this.components.InWorld && (this._outOfBoundsFired = !1), this.components.LifeSpan && (this.alive = !0, this.health = i), this.components.PhysicsBody && this.body && this.body.reset(t, e, !1, !1), this }, H.Component.ScaleMinMax = function() {}, H.Component.ScaleMinMax.prototype = { transformCallback: null, transformCallbackContext: this, scaleMin: null, scaleMax: null, checkTransform: function(t) { this.scaleMin && (t.a < this.scaleMin.x && (t.a = this.scaleMin.x), t.d < this.scaleMin.y && (t.d = this.scaleMin.y)), this.scaleMax && (t.a > this.scaleMax.x && (t.a = this.scaleMax.x), t.d > this.scaleMax.y && (t.d = this.scaleMax.y)) }, setScaleMinMax: function(t, e, i, s) { void 0 === e ? e = i = s = t : void 0 === i && (i = s = e, e = t), null === t ? this.scaleMin = null : this.scaleMin ? this.scaleMin.set(t, e) : this.scaleMin = new H.Point(t, e), null === i ? this.scaleMax = null : this.scaleMax ? this.scaleMax.set(i, s) : this.scaleMax = new H.Point(i, s), null === this.scaleMin ? this.transformCallback = null : (this.transformCallback = this.checkTransform, this.transformCallbackContext = this) } }, H.Component.Smoothed = function() {}, H.Component.Smoothed.prototype = { smoothed: { get: function() { return !this.texture.baseTexture.scaleMode }, set: function(t) { t ? this.texture && (this.texture.baseTexture.scaleMode = 0) : this.texture && (this.texture.baseTexture.scaleMode = 1) } } }, H.GameObjectFactory = function(t) { this.game = t, this.world = this.game.world }, H.GameObjectFactory.prototype = { existing: function(t) { return this.world.add(t) }, weapon: function(t, e, i, s) { var o = this.game.plugins.add(H.Weapon); return o.createBullets(t, e, i, s), o }, image: function(t, e, i, s, o) { return void 0 === o && (o = this.world), o.add(new H.Image(this.game, t, e, i, s)) }, sprite: function(t, e, i, s, o) { return void 0 === o && (o = this.world), o.create(t, e, i, s) }, creature: function(t, e, i, s, o) { void 0 === o && (o = this.world); var n = new H.Creature(this.game, t, e, i, s); return o.add(n), n }, tween: function(t) { return this.game.tweens.create(t) }, group: function(t, e, i, s, o) { return new H.Group(this.game, t, e, i, s, o) }, physicsGroup: function(t, e, i, s) { return new H.Group(this.game, e, i, s, !0, t) }, spriteBatch: function(t, e, i) { return void 0 === t && (t = null), void 0 === e && (e = "group"), void 0 === i && (i = !1), new H.SpriteBatch(this.game, t, e, i) }, audio: function(t, e, i, s) { return this.game.sound.add(t, e, i, s) }, sound: function(t, e, i, s) { return this.game.sound.add(t, e, i, s) }, audioSprite: function(t) { return this.game.sound.addSprite(t) }, tileSprite: function(t, e, i, s, o, n, a) { return void 0 === a && (a = this.world), a.add(new H.TileSprite(this.game, t, e, i, s, o, n)) }, rope: function(t, e, i, s, o, n) { return void 0 === n && (n = this.world), n.add(new H.Rope(this.game, t, e, i, s, o)) }, text: function(t, e, i, s, o) { return void 0 === o && (o = this.world), o.add(new H.Text(this.game, t, e, i, s)) }, button: function(t, e, i, s, o, n, a, r, h, l) { return void 0 === l && (l = this.world), l.add(new H.Button(this.game, t, e, i, s, o, n, a, r, h)) }, graphics: function(t, e, i) { return void 0 === i && (i = this.world), i.add(new H.Graphics(this.game, t, e)) }, emitter: function(t, e, i) { return this.game.particles.add(new H.Particles.Arcade.Emitter(this.game, t, e, i)) }, retroFont: function(t, e, i, s, o, n, a, r, h) { return new H.RetroFont(this.game, t, e, i, s, o, n, a, r, h) }, bitmapText: function(t, e, i, s, o, n) { return void 0 === n && (n = this.world), n.add(new H.BitmapText(this.game, t, e, i, s, o)) }, tilemap: function(t, e, i, s, o) { return new H.Tilemap(this.game, t, e, i, s, o) }, renderTexture: function(t, e, i, s) { void 0 !== i && "" !== i || (i = this.game.rnd.uuid()), void 0 === s && (s = !1); var o = new H.RenderTexture(this.game, t, e, i); return s && this.game.cache.addRenderTexture(i, o), o }, video: function(t, e) { return new H.Video(this.game, t, e) }, bitmapData: function(t, e, i, s) { void 0 === s && (s = !1), void 0 !== i && "" !== i || (i = this.game.rnd.uuid()); var o = new H.BitmapData(this.game, i, t, e); return s && this.game.cache.addBitmapData(i, o), o }, filter: function(t) { var e = Array.prototype.slice.call(arguments, 1); return (t = new H.Filter[t](this.game)).init.apply(t, e), t }, plugin: function(t) { return this.game.plugins.add(t) } }, H.GameObjectFactory.prototype.constructor = H.GameObjectFactory, H.GameObjectCreator = function(t) { this.game = t, this.world = this.game.world }, H.GameObjectCreator.prototype = { image: function(t, e, i, s) { return new H.Image(this.game, t, e, i, s) }, sprite: function(t, e, i, s) { return new H.Sprite(this.game, t, e, i, s) }, tween: function(t) { return new H.Tween(t, this.game, this.game.tweens) }, group: function(t, e, i, s, o) { return new H.Group(this.game, t, e, i, s, o) }, spriteBatch: function(t, e, i) { return void 0 === e && (e = "group"), void 0 === i && (i = !1), new H.SpriteBatch(this.game, t, e, i) }, audio: function(t, e, i, s) { return this.game.sound.add(t, e, i, s) }, audioSprite: function(t) { return this.game.sound.addSprite(t) }, sound: function(t, e, i, s) { return this.game.sound.add(t, e, i, s) }, tileSprite: function(t, e, i, s, o, n) { return new H.TileSprite(this.game, t, e, i, s, o, n) }, rope: function(t, e, i, s, o) { return new H.Rope(this.game, t, e, i, s, o) }, text: function(t, e, i, s) { return new H.Text(this.game, t, e, i, s) }, button: function(t, e, i, s, o, n, a, r, h) { return new H.Button(this.game, t, e, i, s, o, n, a, r, h) }, graphics: function(t, e) { return new H.Graphics(this.game, t, e) }, emitter: function(t, e, i) { return new H.Particles.Arcade.Emitter(this.game, t, e, i) }, retroFont: function(t, e, i, s, o, n, a, r, h) { return new H.RetroFont(this.game, t, e, i, s, o, n, a, r, h) }, bitmapText: function(t, e, i, s, o, n) { return new H.BitmapText(this.game, t, e, i, s, o, n) }, tilemap: function(t, e, i, s, o) { return new H.Tilemap(this.game, t, e, i, s, o) }, renderTexture: function(t, e, i, s) { void 0 !== i && "" !== i || (i = this.game.rnd.uuid()), void 0 === s && (s = !1); var o = new H.RenderTexture(this.game, t, e, i); return s && this.game.cache.addRenderTexture(i, o), o }, bitmapData: function(t, e, i, s) { void 0 === s && (s = !1), void 0 !== i && "" !== i || (i = this.game.rnd.uuid()); var o = new H.BitmapData(this.game, i, t, e); return s && this.game.cache.addBitmapData(i, o), o }, filter: function(t) { var e = Array.prototype.slice.call(arguments, 1); return (t = new H.Filter[t](this.game)).init.apply(t, e), t } }, H.GameObjectCreator.prototype.constructor = H.GameObjectCreator, H.Sprite = function(t, e, i, s, o) { e = e || 0, i = i || 0, s = s || null, o = o || null, this.type = H.SPRITE, this.physicsType = H.SPRITE, PIXI.Sprite.call(this, H.Cache.DEFAULT), H.Component.Core.init.call(this, t, e, i, s, o) }, H.Sprite.prototype = Object.create(PIXI.Sprite.prototype), H.Sprite.prototype.constructor = H.Sprite, H.Component.Core.install.call(H.Sprite.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera", "Health", "InCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "ScaleMinMax", "Smoothed"]), H.Sprite.prototype.preUpdatePhysics = H.Component.PhysicsBody.preUpdate, H.Sprite.prototype.preUpdateLifeSpan = H.Component.LifeSpan.preUpdate, H.Sprite.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.Sprite.prototype.preUpdateCore = H.Component.Core.preUpdate, H.Sprite.prototype.preUpdate = function() { return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.Image = function(t, e, i, s, o) { e = e || 0, i = i || 0, s = s || null, o = o || null, this.type = H.IMAGE, PIXI.Sprite.call(this, H.Cache.DEFAULT), H.Component.Core.init.call(this, t, e, i, s, o) }, H.Image.prototype = Object.create(PIXI.Sprite.prototype), H.Image.prototype.constructor = H.Image, H.Component.Core.install.call(H.Image.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Destroy", "FixedToCamera", "InputEnabled", "LifeSpan", "LoadTexture", "Overlap", "Reset", "ScaleMinMax", "Smoothed"]), H.Image.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.Image.prototype.preUpdateCore = H.Component.Core.preUpdate, H.Image.prototype.preUpdate = function() { return !!this.preUpdateInWorld() && this.preUpdateCore() }, H.Button = function(t, e, i, s, o, n, a, r, h, l) { e = e || 0, i = i || 0, s = s || null, o = o || null, n = n || this, H.Image.call(this, t, e, i, s, r), this.type = H.BUTTON, this.physicsType = H.SPRITE, this._onOverFrame = null, this._onOutFrame = null, this._onDownFrame = null, this._onUpFrame = null, this.onOverSound = null, this.onOutSound = null, this.onDownSound = null, this.onUpSound = null, this.onOverSoundMarker = "", this.onOutSoundMarker = "", this.onDownSoundMarker = "", this.onUpSoundMarker = "", this.onInputOver = new H.Signal, this.onInputOut = new H.Signal, this.onInputDown = new H.Signal, this.onInputUp = new H.Signal, this.onOverMouseOnly = !0, this.justReleasedPreventsOver = H.PointerMode.TOUCH, this.freezeFrames = !1, this.forceOut = !1, this.inputEnabled = !0, this.input.start(0, !0), this.input.useHandCursor = !0, this.setFrames(a, r, h, l), null !== o && this.onInputUp.add(o, n), this.events.onInputOver.add(this.onInputOverHandler, this), this.events.onInputOut.add(this.onInputOutHandler, this), this.events.onInputDown.add(this.onInputDownHandler, this), this.events.onInputUp.add(this.onInputUpHandler, this), this.events.onRemovedFromWorld.add(this.removedFromWorld, this) }, H.Button.prototype = Object.create(H.Image.prototype), H.Button.prototype.constructor = H.Button;
|
|
var h = "Over",
|
|
l = "Out",
|
|
c = "Down",
|
|
p = "Up";
|
|
H.Button.prototype.clearFrames = function() { this.setFrames(null, null, null, null) }, H.Button.prototype.removedFromWorld = function() { this.inputEnabled = !1 }, H.Button.prototype.setStateFrame = function(t, e, i) {
|
|
var s = "_on" + t + "Frame";
|
|
null !== e ? (this[s] = e, i && this.changeStateFrame(t)) : this[s] = null
|
|
}, H.Button.prototype.changeStateFrame = function(t) { if (this.freezeFrames) return !1; var e = this["_on" + t + "Frame"]; return "string" == typeof e ? (this.frameName = e, !0) : "number" == typeof e && (this.frame = e, !0) }, H.Button.prototype.setFrames = function(t, e, i, s) { this.setStateFrame(h, t, this.input.pointerOver()), this.setStateFrame(l, e, !this.input.pointerOver()), this.setStateFrame(c, i, this.input.pointerDown()), this.setStateFrame(p, s, this.input.pointerUp()) }, H.Button.prototype.setStateSound = function(t, e, i) {
|
|
var s = "on" + t + "Sound",
|
|
o = "on" + t + "SoundMarker";
|
|
e instanceof H.Sound || e instanceof H.AudioSprite ? (this[s] = e, this[o] = "string" == typeof i ? i : "") : (this[s] = null, this[o] = "")
|
|
}, H.Button.prototype.playStateSound = function(t) { var e = this["on" + t + "Sound"]; if (e) { var i = this["on" + t + "SoundMarker"]; return e.play(i), !0 } return !1 }, H.Button.prototype.setSounds = function(t, e, i, s, o, n, a, r) { this.setStateSound(h, t, e), this.setStateSound(l, o, n), this.setStateSound(c, i, s), this.setStateSound(p, a, r) }, H.Button.prototype.setOverSound = function(t, e) { this.setStateSound(h, t, e) }, H.Button.prototype.setOutSound = function(t, e) { this.setStateSound(l, t, e) }, H.Button.prototype.setDownSound = function(t, e) { this.setStateSound(c, t, e) }, H.Button.prototype.setUpSound = function(t, e) { this.setStateSound(p, t, e) }, H.Button.prototype.onInputOverHandler = function(t, e) { e.justReleased() && (this.justReleasedPreventsOver & e.pointerMode) === e.pointerMode || (this.changeStateFrame(h), this.onOverMouseOnly && !e.isMouse || (this.playStateSound(h), this.onInputOver && this.onInputOver.dispatch(this, e))) }, H.Button.prototype.onInputOutHandler = function(t, e) { this.changeStateFrame(l), this.playStateSound(l), this.onInputOut && this.onInputOut.dispatch(this, e) }, H.Button.prototype.onInputDownHandler = function(t, e) { this.changeStateFrame(c), this.playStateSound(c), this.onInputDown && this.onInputDown.dispatch(this, e) }, H.Button.prototype.onInputUpHandler = function(t, e, i) {
|
|
(this.playStateSound(p), this.onInputUp && this.onInputUp.dispatch(this, e, i), this.freezeFrames) || (!0 === this.forceOut || (this.forceOut & e.pointerMode) === e.pointerMode ? this.changeStateFrame(l) : this.changeStateFrame(p) || (i ? this.changeStateFrame(h) : this.changeStateFrame(l)))
|
|
}, H.SpriteBatch = function(t, e, i, s) { null == e && (e = t.world), PIXI.SpriteBatch.call(this), H.Group.call(this, t, e, i, s), this.type = H.SPRITEBATCH }, H.SpriteBatch.prototype = H.Utils.extend(!0, H.SpriteBatch.prototype, PIXI.SpriteBatch.prototype, H.Group.prototype), H.SpriteBatch.prototype.constructor = H.SpriteBatch, H.BitmapData = function(t, e, i, s, o) { void 0 !== i && 0 !== i || (i = 256), void 0 !== s && 0 !== s || (s = 256), void 0 === o && (o = !1), this.game = t, this.key = e, this.width = i, this.height = s, this.canvas = H.Canvas.create(this, i, s, null, o), this.context = this.canvas.getContext("2d", { alpha: !0 }), this.ctx = this.context, this.smoothProperty = t.renderType === H.CANVAS ? t.renderer.renderSession.smoothProperty : H.Canvas.getSmoothingPrefix(this.context), this.imageData = this.context.getImageData(0, 0, i, s), this.data = null, this.imageData && (this.data = this.imageData.data), this.pixels = null, this.data && (this.imageData.data.buffer ? (this.buffer = this.imageData.data.buffer, this.pixels = new Uint32Array(this.buffer)) : window.ArrayBuffer ? (this.buffer = new ArrayBuffer(this.imageData.data.length), this.pixels = new Uint32Array(this.buffer)) : this.pixels = this.imageData.data), this.baseTexture = new PIXI.BaseTexture(this.canvas), this.texture = new PIXI.Texture(this.baseTexture), this.frameData = new H.FrameData, this.textureFrame = this.frameData.addFrame(new H.Frame(0, 0, 0, i, s, "bitmapData")), this.texture.frame = this.textureFrame, this.type = H.BITMAPDATA, this.disableTextureUpload = !1, this.dirty = !1, this.cls = this.clear, this._image = null, this._pos = new H.Point, this._size = new H.Point, this._scale = new H.Point, this._rotate = 0, this._alpha = { prev: 1, current: 1 }, this._anchor = new H.Point, this._tempR = 0, this._tempG = 0, this._tempB = 0, this._circle = new H.Circle, this._swapCanvas = void 0 }, H.BitmapData.prototype = {
|
|
move: function(t, e, i) { return 0 !== t && this.moveH(t, i), 0 !== e && this.moveV(e, i), this },
|
|
moveH: function(t, e) {
|
|
void 0 === e && (e = !0), void 0 === this._swapCanvas && (this._swapCanvas = PIXI.CanvasPool.create(this, this.width, this.height));
|
|
var i = this._swapCanvas.getContext("2d"),
|
|
s = this.height,
|
|
o = this.canvas;
|
|
if (i.clearRect(0, 0, this.width, this.height), t < 0) {
|
|
t = Math.abs(t);
|
|
var n = this.width - t;
|
|
e && i.drawImage(o, 0, 0, t, s, n, 0, t, s), i.drawImage(o, t, 0, n, s, 0, 0, n, s)
|
|
}
|
|
else {
|
|
n = this.width - t;
|
|
e && i.drawImage(o, n, 0, t, s, 0, 0, t, s), i.drawImage(o, 0, 0, n, s, t, 0, n, s)
|
|
}
|
|
return this.clear(), this.copy(this._swapCanvas)
|
|
},
|
|
moveV: function(t, e) {
|
|
void 0 === e && (e = !0), void 0 === this._swapCanvas && (this._swapCanvas = PIXI.CanvasPool.create(this, this.width, this.height));
|
|
var i = this._swapCanvas.getContext("2d"),
|
|
s = this.width,
|
|
o = this.canvas;
|
|
if (i.clearRect(0, 0, this.width, this.height), t < 0) {
|
|
t = Math.abs(t);
|
|
var n = this.height - t;
|
|
e && i.drawImage(o, 0, 0, s, t, 0, n, s, t), i.drawImage(o, 0, t, s, n, 0, 0, s, n)
|
|
}
|
|
else {
|
|
n = this.height - t;
|
|
e && i.drawImage(o, 0, n, s, t, 0, 0, s, t), i.drawImage(o, 0, 0, s, n, 0, t, s, n)
|
|
}
|
|
return this.clear(), this.copy(this._swapCanvas)
|
|
},
|
|
add: function(t) {
|
|
if (Array.isArray(t))
|
|
for (var e = 0; e < t.length; e++) t[e].loadTexture && t[e].loadTexture(this);
|
|
else t.loadTexture(this);
|
|
return this
|
|
},
|
|
load: function(t) { if ("string" == typeof t && (t = this.game.cache.getImage(t)), t) return this.resize(t.width, t.height), this.cls(), this.draw(t), this.update(), this },
|
|
clear: function(t, e, i, s) { return void 0 === t && (t = 0), void 0 === e && (e = 0), void 0 === i && (i = this.width), void 0 === s && (s = this.height), this.context.clearRect(t, e, i, s), this.dirty = !0, this },
|
|
fill: function(t, e, i, s) { return void 0 === s && (s = 1), this.context.fillStyle = "rgba(" + t + "," + e + "," + i + "," + s + ")", this.context.fillRect(0, 0, this.width, this.height), this.dirty = !0, this },
|
|
generateTexture: function(t) {
|
|
var e = new Image;
|
|
e.src = this.canvas.toDataURL("image/png");
|
|
var i = this.game.cache.addImage(t, "", e);
|
|
return new PIXI.Texture(i.base)
|
|
},
|
|
resize: function(t, e) { return t === this.width && e === this.height || (this.width = t, this.height = e, this.canvas.width = t, this.canvas.height = e, void 0 !== this._swapCanvas && (this._swapCanvas.width = t, this._swapCanvas.height = e), this.baseTexture.width = t, this.baseTexture.height = e, this.textureFrame.width = t, this.textureFrame.height = e, this.texture.width = t, this.texture.height = e, this.texture.crop.width = t, this.texture.crop.height = e, this.update(), this.dirty = !0), this },
|
|
update: function(t, e, i, s) { return void 0 === t && (t = 0), void 0 === e && (e = 0), void 0 === i && (i = Math.max(1, this.width)), void 0 === s && (s = Math.max(1, this.height)), this.imageData = this.context.getImageData(t, e, i, s), this.data = this.imageData.data, this.imageData.data.buffer ? (this.buffer = this.imageData.data.buffer, this.pixels = new Uint32Array(this.buffer)) : window.ArrayBuffer ? (this.buffer = new ArrayBuffer(this.imageData.data.length), this.pixels = new Uint32Array(this.buffer)) : this.pixels = this.imageData.data, this },
|
|
processPixelRGB: function(t, e, i, s, o, n) {
|
|
void 0 === i && (i = 0), void 0 === s && (s = 0), void 0 === o && (o = this.width), void 0 === n && (n = this.height);
|
|
for (var a = i + o, r = s + n, h = H.Color.createColor(), l = { r: 0, g: 0, b: 0, a: 0 }, c = !1, p = s; p < r; p++)
|
|
for (var u = i; u < a; u++) H.Color.unpackPixel(this.getPixel32(u, p), h), !1 !== (l = t.call(e, h, u, p)) && null != l && (this.setPixel32(u, p, l.r, l.g, l.b, l.a, !1), c = !0);
|
|
return c && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
|
|
},
|
|
processPixel: function(t, e, i, s, o, n) {
|
|
void 0 === i && (i = 0), void 0 === s && (s = 0), void 0 === o && (o = this.width), void 0 === n && (n = this.height);
|
|
for (var a = i + o, r = s + n, h = 0, l = 0, c = !1, p = s; p < r; p++)
|
|
for (var u = i; u < a; u++) h = this.getPixel32(u, p), (l = t.call(e, h, u, p)) !== h && (this.pixels[p * this.width + u] = l, c = !0);
|
|
return c && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0), this
|
|
},
|
|
replaceRGB: function(t, e, i, s, o, n, a, r, h) {
|
|
var l = 0,
|
|
c = 0,
|
|
p = this.width,
|
|
u = this.height,
|
|
d = H.Color.packPixel(t, e, i, s);
|
|
void 0 !== h && h instanceof H.Rectangle && (l = h.x, c = h.y, p = h.width, u = h.height);
|
|
for (var y = 0; y < u; y++)
|
|
for (var g = 0; g < p; g++) this.getPixel32(l + g, c + y) === d && this.setPixel32(l + g, c + y, o, n, a, r, !1);
|
|
return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
|
|
},
|
|
setHSL: function(t, e, i, s) {
|
|
var o = t || 0 === t,
|
|
n = e || 0 === e,
|
|
a = i || 0 === i;
|
|
if (o || n || a) {
|
|
void 0 === s && (s = new H.Rectangle(0, 0, this.width, this.height));
|
|
for (var r = H.Color.createColor(), h = s.y; h < s.bottom; h++)
|
|
for (var l = s.x; l < s.right; l++) H.Color.unpackPixel(this.getPixel32(l, h), r, !0), o && (r.h = t), n && (r.s = e), a && (r.l = i), H.Color.HSLtoRGB(r.h, r.s, r.l, r), this.setPixel32(l, h, r.r, r.g, r.b, r.a, !1);
|
|
return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
|
|
}
|
|
},
|
|
shiftHSL: function(t, e, i, s) {
|
|
if (null == t && (t = !1), null == e && (e = !1), null == i && (i = !1), t || e || i) {
|
|
void 0 === s && (s = new H.Rectangle(0, 0, this.width, this.height));
|
|
for (var o = H.Color.createColor(), n = s.y; n < s.bottom; n++)
|
|
for (var a = s.x; a < s.right; a++) H.Color.unpackPixel(this.getPixel32(a, n), o, !0), t && (o.h = this.game.math.wrap(o.h + t, 0, 1)), e && (o.s = this.game.math.clamp(o.s + e, 0, 1)), i && (o.l = this.game.math.clamp(o.l + i, 0, 1)), H.Color.HSLtoRGB(o.h, o.s, o.l, o), this.setPixel32(a, n, o.r, o.g, o.b, o.a, !1);
|
|
return this.context.putImageData(this.imageData, 0, 0), this.dirty = !0, this
|
|
}
|
|
},
|
|
setPixel32: function(t, e, i, s, o, n, a) { return void 0 === a && (a = !0), 0 <= t && t <= this.width && 0 <= e && e <= this.height && (H.Device.LITTLE_ENDIAN ? this.pixels[e * this.width + t] = n << 24 | o << 16 | s << 8 | i : this.pixels[e * this.width + t] = i << 24 | s << 16 | o << 8 | n, a && (this.context.putImageData(this.imageData, 0, 0), this.dirty = !0)), this },
|
|
setPixel: function(t, e, i, s, o, n) { return this.setPixel32(t, e, i, s, o, 255, n) },
|
|
getPixel: function(t, e, i) { i || (i = H.Color.createColor()); var s = ~~(t + e * this.width); return s *= 4, i.r = this.data[s], i.g = this.data[++s], i.b = this.data[++s], i.a = this.data[++s], i },
|
|
getPixel32: function(t, e) { if (0 <= t && t <= this.width && 0 <= e && e <= this.height) return this.pixels[e * this.width + t] },
|
|
getPixelRGB: function(t, e, i, s, o) { return H.Color.unpackPixel(this.getPixel32(t, e), i, s, o) },
|
|
getPixels: function(t) { return this.context.getImageData(t.x, t.y, t.width, t.height) },
|
|
getFirstPixel: function(t) {
|
|
void 0 === t && (t = 0);
|
|
var e = H.Color.createColor(),
|
|
i = 0,
|
|
s = 0,
|
|
o = 1,
|
|
n = !1;
|
|
for (1 === t ? (o = -1, s = this.height) : 3 === t && (o = -1, i = this.width); H.Color.unpackPixel(this.getPixel32(i, s), e), 0 === t || 1 === t ? ++i === this.width && (i = 0, ((s += o) >= this.height || s <= 0) && (n = !0)) : 2 !== t && 3 !== t || ++s === this.height && (s = 0, ((i += o) >= this.width || i <= 0) && (n = !0)), 0 === e.a && !n;);
|
|
return e.x = i, e.y = s, e
|
|
},
|
|
getBounds: function(t) { return void 0 === t && (t = new H.Rectangle), t.x = this.getFirstPixel(2).x, t.x === this.width ? t.setTo(0, 0, 0, 0) : (t.y = this.getFirstPixel(0).y, t.width = this.getFirstPixel(3).x - t.x + 1, t.height = this.getFirstPixel(1).y - t.y + 1, t) },
|
|
addToWorld: function(t, e, i, s, o, n) { o = o || 1, n = n || 1; var a = this.game.add.image(t, e, this); return a.anchor.set(i, s), a.scale.set(o, n), a },
|
|
copy: function(t, e, i, s, o, n, a, r, h, l, c, p, u, d, y, g, f) {
|
|
if (null == t && (t = this), (t instanceof H.RenderTexture || t instanceof PIXI.RenderTexture) && (t = t.getCanvas()), (this._image = t) instanceof H.Sprite || t instanceof H.Image || t instanceof H.Text || t instanceof PIXI.Sprite) this._pos.set(t.texture.crop.x, t.texture.crop.y), this._size.set(t.texture.crop.width, t.texture.crop.height), this._scale.set(t.scale.x, t.scale.y), this._anchor.set(t.anchor.x, t.anchor.y), this._rotate = t.rotation, this._alpha.current = t.alpha, t.texture instanceof H.RenderTexture || t.texture instanceof PIXI.RenderTexture ? this._image = t.texture.getCanvas() : this._image = t.texture.baseTexture.source, null == n && (n = t.x), null == a && (a = t.y), t.texture.trim && (n += t.texture.trim.x - t.anchor.x * t.texture.trim.width, a += t.texture.trim.y - t.anchor.y * t.texture.trim.height), 16777215 !== t.tint && (t.cachedTint !== t.tint && (t.cachedTint = t.tint, t.tintedTexture = PIXI.CanvasTinter.getTintedTexture(t, t.tint)), this._image = t.tintedTexture, this._pos.set(0));
|
|
else {
|
|
if (this._pos.set(0), this._scale.set(1), this._anchor.set(0), this._rotate = 0, this._alpha.current = 1, t instanceof H.BitmapData) this._image = t.canvas;
|
|
else if ("string" == typeof t) {
|
|
if (null === (t = this.game.cache.getImage(t))) return;
|
|
this._image = t
|
|
}
|
|
this._size.set(this._image.width, this._image.height)
|
|
}
|
|
if (null == e && (e = 0), null == i && (i = 0), s && (this._size.x = s), o && (this._size.y = o), null == n && (n = e), null == a && (a = i), null == r && (r = this._size.x), null == h && (h = this._size.y), "number" == typeof l && (this._rotate = l), "number" == typeof c && (this._anchor.x = c), "number" == typeof p && (this._anchor.y = p), "number" == typeof u && (this._scale.x = u), "number" == typeof d && (this._scale.y = d), "number" == typeof y && (this._alpha.current = y), void 0 === g && (g = null), void 0 === f && (f = !1), !(this._alpha.current <= 0 || 0 === this._scale.x || 0 === this._scale.y || 0 === this._size.x || 0 === this._size.y)) { var m = this.context; return this._alpha.prev = m.globalAlpha, m.save(), m.globalAlpha = this._alpha.current, g && (this.op = g), f && (n |= 0, a |= 0), m.translate(n, a), m.scale(this._scale.x, this._scale.y), m.rotate(this._rotate), m.drawImage(this._image, this._pos.x + e, this._pos.y + i, this._size.x, this._size.y, -r * this._anchor.x, -h * this._anchor.y, r, h), m.restore(), m.globalAlpha = this._alpha.prev, this.dirty = !0, this }
|
|
},
|
|
copyTransform: function(t, e, i) {
|
|
if (void 0 === e && (e = null), void 0 === i && (i = !1), !t.hasOwnProperty("worldTransform") || !t.worldVisible || 0 === t.worldAlpha) return this;
|
|
var s = t.worldTransform;
|
|
if (this._pos.set(t.texture.crop.x, t.texture.crop.y), this._size.set(t.texture.crop.width, t.texture.crop.height), 0 === s.a || 0 === s.d || 0 === this._size.x || 0 === this._size.y) return this;
|
|
t.texture instanceof H.RenderTexture || t.texture instanceof PIXI.RenderTexture ? this._image = t.texture.getCanvas() : this._image = t.texture.baseTexture.source;
|
|
var o = s.tx,
|
|
n = s.ty;
|
|
t.texture.trim && (o += t.texture.trim.x - t.anchor.x * t.texture.trim.width, n += t.texture.trim.y - t.anchor.y * t.texture.trim.height), 16777215 !== t.tint && (t.cachedTint !== t.tint && (t.cachedTint = t.tint, t.tintedTexture = PIXI.CanvasTinter.getTintedTexture(t, t.tint)), this._image = t.tintedTexture, this._pos.set(0)), i && (o |= 0, n |= 0);
|
|
var a = this.context;
|
|
return this._alpha.prev = a.globalAlpha, a.save(), a.globalAlpha = this._alpha.current, e && (this.op = e), a[this.smoothProperty] = t.texture.baseTexture.scaleMode === PIXI.scaleModes.LINEAR, a.setTransform(s.a, s.b, s.c, s.d, o, n), a.drawImage(this._image, this._pos.x, this._pos.y, this._size.x, this._size.y, -this._size.x * t.anchor.x, -this._size.y * t.anchor.y, this._size.x, this._size.y), a.restore(), a.globalAlpha = this._alpha.prev, this.dirty = !0, this
|
|
},
|
|
copyRect: function(t, e, i, s, o, n, a) { return this.copy(t, e.x, e.y, e.width, e.height, i, s, e.width, e.height, 0, 0, 0, 1, 1, o, n, a) },
|
|
draw: function(t, e, i, s, o, n, a) { return this.copy(t, null, null, null, null, e, i, s, o, null, null, null, null, null, null, n, a) },
|
|
drawGroup: function(t, e, i) { return 0 < t.total && t.forEachExists(this.drawGroupProxy, this, e, i), this },
|
|
drawGroupProxy: function(t, e, i) {
|
|
if (t.hasOwnProperty("texture") && this.copyTransform(t, e, i), t.type === H.GROUP && t.exists) this.drawGroup(t, e, i);
|
|
else if (t.hasOwnProperty("children") && 0 < t.children.length)
|
|
for (var s = 0; s < t.children.length; s++) t.children[s].exists && this.copyTransform(t.children[s], e, i)
|
|
},
|
|
drawFull: function(t, e, i) {
|
|
if (!1 === t.worldVisible || 0 === t.worldAlpha || t.hasOwnProperty("exists") && !1 === t.exists) return this;
|
|
if (t.type !== H.GROUP && t.type !== H.EMITTER && t.type !== H.BITMAPTEXT)
|
|
if (t.type === H.GRAPHICS) {
|
|
var s = t.getBounds();
|
|
this.ctx.save(), this.ctx.translate(s.x, s.y), PIXI.CanvasGraphics.renderGraphics(t, this.ctx), this.ctx.restore()
|
|
}
|
|
else this.copy(t, null, null, null, null, t.worldPosition.x, t.worldPosition.y, null, null, t.worldRotation, null, null, t.worldScale.x, t.worldScale.y, t.worldAlpha, e, i);
|
|
if (t.children)
|
|
for (var o = 0; o < t.children.length; o++) this.drawFull(t.children[o], e, i);
|
|
return this
|
|
},
|
|
shadow: function(t, e, i, s) { var o = this.context; return null == t ? o.shadowColor = "rgba(0,0,0,0)" : (o.shadowColor = t, o.shadowBlur = e || 5, o.shadowOffsetX = i || 10, o.shadowOffsetY = s || 10), this },
|
|
alphaMask: function(t, e, i, s) { return null == s ? this.draw(e).blendSourceAtop() : this.draw(e, s.x, s.y, s.width, s.height).blendSourceAtop(), null == i ? this.draw(t).blendReset() : this.draw(t, i.x, i.y, i.width, i.height).blendReset(), this },
|
|
extract: function(s, o, n, a, r, t, h, l, c) { return void 0 === r && (r = 255), void 0 === t && (t = !1), void 0 === h && (h = o), void 0 === l && (l = n), void 0 === c && (c = a), t && s.resize(this.width, this.height), this.processPixelRGB(function(t, e, i) { return t.r === o && t.g === n && t.b === a && s.setPixel32(e, i, h, l, c, r, !1), !1 }, this), s.context.putImageData(s.imageData, 0, 0), s.dirty = !0, s },
|
|
rect: function(t, e, i, s, o) { return void 0 !== o && (this.context.fillStyle = o), this.context.fillRect(t, e, i, s), this },
|
|
text: function(t, e, i, s, o, n) {
|
|
void 0 === e && (e = 0), void 0 === i && (i = 0), void 0 === s && (s = "14px Courier"), void 0 === o && (o = "rgb(255,255,255)"), void 0 === n && (n = !0);
|
|
var a = this.context,
|
|
r = a.font;
|
|
return a.font = s, n && (a.fillStyle = "rgb(0,0,0)", a.fillText(t, e + 1, i + 1)), a.fillStyle = o, a.fillText(t, e, i), a.font = r, this
|
|
},
|
|
circle: function(t, e, i, s) { var o = this.context; return void 0 !== s && (o.fillStyle = s), o.beginPath(), o.arc(t, e, i, 0, 2 * Math.PI, !1), o.closePath(), o.fill(), this },
|
|
line: function(t, e, i, s, o, n) { void 0 === o && (o = "#fff"), void 0 === n && (n = 1); var a = this.context; return a.beginPath(), a.moveTo(t, e), a.lineTo(i, s), a.lineWidth = n, a.strokeStyle = o, a.stroke(), a.closePath(), this },
|
|
textureLine: function(t, e, i) { if (void 0 === i && (i = "repeat-x"), "string" != typeof e || (e = this.game.cache.getImage(e))) { var s = t.length; "no-repeat" === i && s > e.width && (s = e.width); var o = this.context; return o.fillStyle = o.createPattern(e, i), this._circle = new H.Circle(t.start.x, t.start.y, e.height), this._circle.circumferencePoint(t.angle - 1.5707963267948966, !1, this._pos), o.save(), o.translate(this._pos.x, this._pos.y), o.rotate(t.angle), o.fillRect(0, 0, s, e.height), o.restore(), this.dirty = !0, this } },
|
|
render: function() { return !this.disableTextureUpload && this.dirty && (this.baseTexture.dirty(), this.dirty = !1), this },
|
|
destroy: function() { this.frameData.destroy(), this.texture.destroy(!0), PIXI.CanvasPool.remove(this) },
|
|
blendReset: function() { return this.op = "source-over", this },
|
|
blendSourceOver: function() { return this.op = "source-over", this },
|
|
blendSourceIn: function() { return this.op = "source-in", this },
|
|
blendSourceOut: function() { return this.op = "source-out", this },
|
|
blendSourceAtop: function() { return this.op = "source-atop", this },
|
|
blendDestinationOver: function() { return this.op = "destination-over", this },
|
|
blendDestinationIn: function() { return this.op = "destination-in", this },
|
|
blendDestinationOut: function() { return this.op = "destination-out", this },
|
|
blendDestinationAtop: function() { return this.op = "destination-atop", this },
|
|
blendXor: function() { return this.op = "xor", this },
|
|
blendAdd: function() { return this.op = "lighter", this },
|
|
blendMultiply: function() { return this.op = "multiply", this },
|
|
blendScreen: function() { return this.op = "screen", this },
|
|
blendOverlay: function() { return this.op = "overlay", this },
|
|
blendDarken: function() { return this.op = "darken", this },
|
|
blendLighten: function() { return this.op = "lighten", this },
|
|
blendColorDodge: function() { return this.op = "color-dodge", this },
|
|
blendColorBurn: function() { return this.op = "color-burn", this },
|
|
blendHardLight: function() { return this.op = "hard-light", this },
|
|
blendSoftLight: function() { return this.op = "soft-light", this },
|
|
blendDifference: function() { return this.op = "difference", this },
|
|
blendExclusion: function() { return this.op = "exclusion", this },
|
|
blendHue: function() { return this.op = "hue", this },
|
|
blendSaturation: function() { return this.op = "saturation", this },
|
|
blendColor: function() { return this.op = "color", this },
|
|
blendLuminosity: function() { return this.op = "luminosity", this }
|
|
}, Object.defineProperty(H.BitmapData.prototype, "smoothed", { get: function() { H.Canvas.getSmoothingEnabled(this.context) }, set: function(t) { H.Canvas.setSmoothingEnabled(this.context, t) } }), Object.defineProperty(H.BitmapData.prototype, "op", { get: function() { return this.context.globalCompositeOperation }, set: function(t) { this.context.globalCompositeOperation = t } }), H.BitmapData.getTransform = function(t, e, i, s, o, n) { return "number" != typeof t && (t = 0), "number" != typeof e && (e = 0), "number" != typeof i && (i = 1), "number" != typeof s && (s = 1), "number" != typeof o && (o = 0), "number" != typeof n && (n = 0), { sx: i, sy: s, scaleX: i, scaleY: s, skewX: o, skewY: n, translateX: t, translateY: e, tx: t, ty: e } }, H.BitmapData.prototype.constructor = H.BitmapData, PIXI.Graphics = function() { PIXI.DisplayObjectContainer.call(this), this.renderable = !0, this.fillAlpha = 1, this.lineWidth = 0, this.lineColor = 0, this.graphicsData = [], this.tint = 16777215, this.blendMode = PIXI.blendModes.NORMAL, this.currentPath = null, this._webGL = [], this.isMask = !1, this.boundsPadding = 0, this._localBounds = new PIXI.Rectangle(0, 0, 1, 1), this.dirty = !0, this._boundsDirty = !1, this.webGLDirty = !1, this.cachedSpriteDirty = !1 }, PIXI.Graphics.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), PIXI.Graphics.prototype.constructor = PIXI.Graphics, PIXI.Graphics.prototype.lineStyle = function(t, e, i) { return this.lineWidth = t || 0, this.lineColor = e || 0, this.lineAlpha = void 0 === i ? 1 : i, this.currentPath && (this.currentPath.shape.points.length ? this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))) : (this.currentPath.lineWidth = this.lineWidth, this.currentPath.lineColor = this.lineColor, this.currentPath.lineAlpha = this.lineAlpha)), this }, PIXI.Graphics.prototype.moveTo = function(t, e) { return this.drawShape(new PIXI.Polygon([t, e])), this }, PIXI.Graphics.prototype.lineTo = function(t, e) { return this.currentPath || this.moveTo(0, 0), this.currentPath.shape.points.push(t, e), this.dirty = !0, this._boundsDirty = !0, this }, PIXI.Graphics.prototype.quadraticCurveTo = function(t, e, i, s) {
|
|
this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
|
|
var o, n, a = this.currentPath.shape.points;
|
|
0 === a.length && this.moveTo(0, 0);
|
|
for (var r = a[a.length - 2], h = a[a.length - 1], l = 0, c = 1; c <= 20; ++c) o = r + (t - r) * (l = c / 20), n = h + (e - h) * l, a.push(o + (t + (i - t) * l - o) * l, n + (e + (s - e) * l - n) * l);
|
|
return this.dirty = !0, this._boundsDirty = !0, this
|
|
}, PIXI.Graphics.prototype.bezierCurveTo = function(t, e, i, s, o, n) { this.currentPath ? 0 === this.currentPath.shape.points.length && (this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0); for (var a, r, h, l, c, p = this.currentPath.shape.points, u = p[p.length - 2], d = p[p.length - 1], y = 0, g = 1; g <= 20; ++g) h = (r = (a = 1 - (y = g / 20)) * a) * a, c = (l = y * y) * y, p.push(h * u + 3 * r * y * t + 3 * a * l * i + c * o, h * d + 3 * r * y * e + 3 * a * l * s + c * n); return this.dirty = !0, this._boundsDirty = !0, this }, PIXI.Graphics.prototype.arcTo = function(t, e, i, s, o) {
|
|
this.currentPath ? 0 === this.currentPath.shape.points.length && this.currentPath.shape.points.push(t, e) : this.moveTo(t, e);
|
|
var n = this.currentPath.shape.points,
|
|
a = n[n.length - 2],
|
|
r = n[n.length - 1] - e,
|
|
h = a - t,
|
|
l = s - e,
|
|
c = i - t,
|
|
p = Math.abs(r * c - h * l);
|
|
if (p < 1e-8 || 0 === o) n[n.length - 2] === t && n[n.length - 1] === e || n.push(t, e);
|
|
else {
|
|
var u = r * r + h * h,
|
|
d = l * l + c * c,
|
|
y = r * l + h * c,
|
|
g = o * Math.sqrt(u) / p,
|
|
f = o * Math.sqrt(d) / p,
|
|
m = g * y / u,
|
|
v = f * y / d,
|
|
x = g * c + f * h,
|
|
b = g * l + f * r,
|
|
w = h * (f + m),
|
|
P = r * (f + m),
|
|
_ = c * (g + v),
|
|
T = l * (g + v),
|
|
S = Math.atan2(P - b, w - x),
|
|
k = Math.atan2(T - b, _ - x);
|
|
this.arc(x + t, b + e, o, S, k, c * r < h * l)
|
|
}
|
|
return this.dirty = !0, this._boundsDirty = !0, this
|
|
}, PIXI.Graphics.prototype.arc = function(t, e, i, s, o, n, a) {
|
|
if (s === o) return this;
|
|
void 0 === n && (n = !1), void 0 === a && (a = 40), !n && o <= s ? o += 2 * Math.PI : n && s <= o && (s += 2 * Math.PI);
|
|
var r = n ? -1 * (s - o) : o - s,
|
|
h = Math.ceil(Math.abs(r) / (2 * Math.PI)) * a;
|
|
if (0 === r) return this;
|
|
var l = t + Math.cos(s) * i,
|
|
c = e + Math.sin(s) * i;
|
|
n && this.filling ? this.moveTo(t, e) : this.moveTo(l, c);
|
|
for (var p = this.currentPath.shape.points, u = r / (2 * h), d = 2 * u, y = Math.cos(u), g = Math.sin(u), f = h - 1, m = f % 1 / f, v = 0; v <= f; v++) {
|
|
var x = u + s + d * (v + m * v),
|
|
b = Math.cos(x),
|
|
w = -Math.sin(x);
|
|
p.push((y * b + g * w) * i + t, (y * -w + g * b) * i + e)
|
|
}
|
|
return this.dirty = !0, this._boundsDirty = !0, this
|
|
}, PIXI.Graphics.prototype.beginFill = function(t, e) { return this.filling = !0, this.fillColor = t || 0, this.fillAlpha = void 0 === e ? 1 : e, this.currentPath && this.currentPath.shape.points.length <= 2 && (this.currentPath.fill = this.filling, this.currentPath.fillColor = this.fillColor, this.currentPath.fillAlpha = this.fillAlpha), this }, PIXI.Graphics.prototype.endFill = function() { return this.filling = !1, this.fillColor = null, this.fillAlpha = 1, this }, PIXI.Graphics.prototype.drawRect = function(t, e, i, s) { return this.drawShape(new PIXI.Rectangle(t, e, i, s)), this }, PIXI.Graphics.prototype.drawRoundedRect = function(t, e, i, s, o) { return this.drawShape(new PIXI.RoundedRectangle(t, e, i, s, o)), this }, PIXI.Graphics.prototype.drawCircle = function(t, e, i) { return this.drawShape(new PIXI.Circle(t, e, i)), this }, PIXI.Graphics.prototype.drawEllipse = function(t, e, i, s) { return this.drawShape(new PIXI.Ellipse(t, e, i, s)), this }, PIXI.Graphics.prototype.drawPolygon = function(t) {
|
|
(t instanceof H.Polygon || t instanceof PIXI.Polygon) && (t = t.points);
|
|
var e = t;
|
|
if (!Array.isArray(e)) { e = new Array(arguments.length); for (var i = 0; i < e.length; ++i) e[i] = arguments[i] }
|
|
return this.drawShape(new H.Polygon(e)), this
|
|
}, PIXI.Graphics.prototype.clear = function() { return this.lineWidth = 0, this.filling = !1, this.dirty = !0, this._boundsDirty = !0, this.clearDirty = !0, this.graphicsData = [], this.updateLocalBounds(), this }, PIXI.Graphics.prototype.generateTexture = function(t, e, i) {
|
|
void 0 === t && (t = 1), void 0 === e && (e = PIXI.scaleModes.DEFAULT), void 0 === i && (i = 0);
|
|
var s = this.getBounds();
|
|
s.width += i, s.height += i;
|
|
var o = new PIXI.CanvasBuffer(s.width * t, s.height * t),
|
|
n = PIXI.Texture.fromCanvas(o.canvas, e);
|
|
return n.baseTexture.resolution = t, o.context.scale(t, t), o.context.translate(-s.x, -s.y), PIXI.CanvasGraphics.renderGraphics(this, o.context), n
|
|
}, PIXI.Graphics.prototype._renderWebGL = function(t) {
|
|
if (!1 !== this.visible && 0 !== this.alpha && !0 !== this.isMask) {
|
|
if (this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.worldAlpha = this.worldAlpha, void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, t);
|
|
if (t.spriteBatch.stop(), t.blendModeManager.setBlendMode(this.blendMode), this._mask && t.maskManager.pushMask(this._mask, t), this._filters && t.filterManager.pushFilter(this._filterBlock), this.blendMode !== t.spriteBatch.currentBlendMode) {
|
|
t.spriteBatch.currentBlendMode = this.blendMode;
|
|
var e = PIXI.blendModesWebGL[t.spriteBatch.currentBlendMode];
|
|
t.spriteBatch.gl.blendFunc(e[0], e[1])
|
|
}
|
|
if (this.webGLDirty && (this.dirty = !0, this.webGLDirty = !1), PIXI.WebGLGraphics.renderGraphics(this, t), this.children.length) {
|
|
t.spriteBatch.start();
|
|
for (var i = 0; i < this.children.length; i++) this.children[i]._renderWebGL(t);
|
|
t.spriteBatch.stop()
|
|
}
|
|
this._filters && t.filterManager.popFilter(), this._mask && t.maskManager.popMask(this.mask, t), t.drawCount++, t.spriteBatch.start()
|
|
}
|
|
}, PIXI.Graphics.prototype._renderCanvas = function(t) {
|
|
if (!1 !== this.visible && 0 !== this.alpha && !0 !== this.isMask) {
|
|
if (this._prevTint !== this.tint && (this.dirty = !0, this._prevTint = this.tint), this._cacheAsBitmap) return (this.dirty || this.cachedSpriteDirty) && (this._generateCachedSprite(), this.updateCachedSpriteTexture(), this.cachedSpriteDirty = !1, this.dirty = !1), this._cachedSprite.alpha = this.alpha, void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite, t);
|
|
var e = t.context,
|
|
i = this.worldTransform;
|
|
this.blendMode !== t.currentBlendMode && (t.currentBlendMode = this.blendMode, e.globalCompositeOperation = PIXI.blendModesCanvas[t.currentBlendMode]), this._mask && t.maskManager.pushMask(this._mask, t);
|
|
var s = t.resolution,
|
|
o = i.tx * t.resolution + t.shakeX,
|
|
n = i.ty * t.resolution + t.shakeY;
|
|
e.setTransform(i.a * s, i.b * s, i.c * s, i.d * s, o, n), PIXI.CanvasGraphics.renderGraphics(this, e);
|
|
for (var a = 0; a < this.children.length; a++) this.children[a]._renderCanvas(t);
|
|
this._mask && t.maskManager.popMask(t)
|
|
}
|
|
}, PIXI.Graphics.prototype.getBounds = function(t) {
|
|
if (!this._currentBounds) {
|
|
if (!this.renderable) return PIXI.EmptyRectangle;
|
|
this.dirty && (this.updateLocalBounds(), this.webGLDirty = !0, this.cachedSpriteDirty = !0, this.dirty = !1);
|
|
var e = this._localBounds,
|
|
i = e.x,
|
|
s = e.width + e.x,
|
|
o = e.y,
|
|
n = e.height + e.y,
|
|
a = t || this.worldTransform,
|
|
r = a.a,
|
|
h = a.b,
|
|
l = a.c,
|
|
c = a.d,
|
|
p = a.tx,
|
|
u = a.ty,
|
|
d = r * s + l * n + p,
|
|
y = c * n + h * s + u,
|
|
g = r * i + l * n + p,
|
|
f = c * n + h * i + u,
|
|
m = r * i + l * o + p,
|
|
v = c * o + h * i + u,
|
|
x = r * s + l * o + p,
|
|
b = c * o + h * s + u,
|
|
w = d,
|
|
P = y,
|
|
_ = d,
|
|
T = y;
|
|
_ = x < (_ = m < (_ = g < _ ? g : _) ? m : _) ? x : _, T = b < (T = v < (T = f < T ? f : T) ? v : T) ? b : T, w = (w = (w = w < g ? g : w) < m ? m : w) < x ? x : w, P = (P = (P = P < f ? f : P) < v ? v : P) < b ? b : P, this._bounds.x = _, this._bounds.width = w - _, this._bounds.y = T, this._bounds.height = P - T, this._currentBounds = this._bounds
|
|
}
|
|
return this._currentBounds
|
|
}, PIXI.Graphics.prototype.getLocalBounds = function() {
|
|
var t = this.worldTransform;
|
|
this.worldTransform = PIXI.identityMatrix;
|
|
for (var e = 0; e < this.children.length; e++) this.children[e].updateTransform();
|
|
var i = this.getBounds();
|
|
for (this.worldTransform = t, e = 0; e < this.children.length; e++) this.children[e].updateTransform();
|
|
return i
|
|
}, PIXI.Graphics.prototype.containsPoint = function(t) { this.worldTransform.applyInverse(t, tempPoint); for (var e = this.graphicsData, i = 0; i < e.length; i++) { var s = e[i]; if (s.fill && (s.shape && s.shape.contains(tempPoint.x, tempPoint.y))) return !0 } return !1 }, PIXI.Graphics.prototype.updateLocalBounds = function() {
|
|
var t = 1 / 0,
|
|
e = -1 / 0,
|
|
i = 1 / 0,
|
|
s = -1 / 0;
|
|
if (this.graphicsData.length)
|
|
for (var o, n, a, r, h, l, c = 0; c < this.graphicsData.length; c++) {
|
|
var p = this.graphicsData[c],
|
|
u = p.type,
|
|
d = p.lineWidth;
|
|
if (o = p.shape, u === PIXI.Graphics.RECT || u === PIXI.Graphics.RREC) a = o.x - d / 2, r = o.y - d / 2, t = a < t ? a : t, e = e < a + (h = o.width + d) ? a + h : e, i = r < i ? r : i, s = s < r + (l = o.height + d) ? r + l : s;
|
|
else if (u === PIXI.Graphics.CIRC) a = o.x, r = o.y, t = a - (h = o.radius + d / 2) < t ? a - h : t, e = e < a + h ? a + h : e, i = r - (l = o.radius + d / 2) < i ? r - l : i, s = s < r + l ? r + l : s;
|
|
else if (u === PIXI.Graphics.ELIP) a = o.x, r = o.y, t = a - (h = o.width + d / 2) < t ? a - h : t, e = e < a + h ? a + h : e, i = r - (l = o.height + d / 2) < i ? r - l : i, s = s < r + l ? r + l : s;
|
|
else { n = o.points; for (var y = 0; y < n.length; y++) n[y] instanceof H.Point ? (a = n[y].x, r = n[y].y) : (a = n[y], r = n[y + 1], y < n.length - 1 && y++), t = a - d < t ? a - d : t, e = e < a + d ? a + d : e, i = r - d < i ? r - d : i, s = s < r + d ? r + d : s }
|
|
}
|
|
else s = i = e = t = 0;
|
|
var g = this.boundsPadding;
|
|
this._localBounds.x = t - g, this._localBounds.width = e - t + 2 * g, this._localBounds.y = i - g, this._localBounds.height = s - i + 2 * g
|
|
}, PIXI.Graphics.prototype._generateCachedSprite = function() {
|
|
var t = this.getLocalBounds();
|
|
if (this._cachedSprite) this._cachedSprite.buffer.resize(t.width, t.height);
|
|
else {
|
|
var e = new PIXI.CanvasBuffer(t.width, t.height),
|
|
i = PIXI.Texture.fromCanvas(e.canvas);
|
|
this._cachedSprite = new PIXI.Sprite(i), this._cachedSprite.buffer = e, this._cachedSprite.worldTransform = this.worldTransform
|
|
}
|
|
this._cachedSprite.anchor.x = -t.x / t.width, this._cachedSprite.anchor.y = -t.y / t.height, this._cachedSprite.buffer.context.translate(-t.x, -t.y), this.worldAlpha = 1, PIXI.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context), this._cachedSprite.alpha = this.alpha
|
|
}, PIXI.Graphics.prototype.updateCachedSpriteTexture = function() {
|
|
var t = this._cachedSprite,
|
|
e = t.texture,
|
|
i = t.buffer.canvas;
|
|
e.baseTexture.width = i.width, e.baseTexture.height = i.height, e.crop.width = e.frame.width = i.width, e.crop.height = e.frame.height = i.height, t._width = i.width, t._height = i.height, e.baseTexture.dirty()
|
|
}, PIXI.Graphics.prototype.destroyCachedSprite = function() { this._cachedSprite.texture.destroy(!0), this._cachedSprite = null }, PIXI.Graphics.prototype.drawShape = function(t) { this.currentPath && this.currentPath.shape.points.length <= 2 && this.graphicsData.pop(), this.currentPath = null, t instanceof H.Polygon && (t = t.clone()).flatten(); var e = new PIXI.GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, t); return this.graphicsData.push(e), e.type === PIXI.Graphics.POLY && (e.shape.closed = this.filling, this.currentPath = e), this.dirty = !0, this._boundsDirty = !0, e }, Object.defineProperty(PIXI.Graphics.prototype, "cacheAsBitmap", { get: function() { return this._cacheAsBitmap }, set: function(t) { this._cacheAsBitmap = t, this._cacheAsBitmap ? this._generateCachedSprite() : this.destroyCachedSprite(), this.dirty = !0, this.webGLDirty = !0 } }), PIXI.GraphicsData = function(t, e, i, s, o, n, a) { this.lineWidth = t, this.lineColor = e, this.lineAlpha = i, this._lineTint = e, this.fillColor = s, this.fillAlpha = o, this._fillTint = s, this.fill = n, this.shape = a, this.type = a.type }, PIXI.GraphicsData.prototype.constructor = PIXI.GraphicsData, PIXI.GraphicsData.prototype.clone = function() { return new GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.fill, this.shape) }, PIXI.EarCut = {}, PIXI.EarCut.Triangulate = function(t, e, i) {
|
|
i = i || 2;
|
|
var s, o, n, a, r, h, l, c = e && e.length,
|
|
p = c ? e[0] * i : t.length,
|
|
u = PIXI.EarCut.linkedList(t, 0, p, i, !0),
|
|
d = [];
|
|
if (!u) return d;
|
|
if (c && (u = PIXI.EarCut.eliminateHoles(t, e, u, i)), t.length > 80 * i) {
|
|
s = n = t[0], o = a = t[1];
|
|
for (var y = i; y < p; y += i)(r = t[y]) < s && (s = r), (h = t[y + 1]) < o && (o = h), n < r && (n = r), a < h && (a = h);
|
|
l = Math.max(n - s, a - o)
|
|
}
|
|
return PIXI.EarCut.earcutLinked(u, d, i, s, o, l), d
|
|
}, PIXI.EarCut.linkedList = function(t, e, i, s, o) {
|
|
var n, a, r, h = 0;
|
|
for (n = e, a = i - s; n < i; n += s) h += (t[a] - t[n]) * (t[n + 1] + t[a + 1]), a = n;
|
|
if (o === 0 < h)
|
|
for (n = e; n < i; n += s) r = PIXI.EarCut.insertNode(n, t[n], t[n + 1], r);
|
|
else
|
|
for (n = i - s; e <= n; n -= s) r = PIXI.EarCut.insertNode(n, t[n], t[n + 1], r);
|
|
return r
|
|
}, PIXI.EarCut.filterPoints = function(t, e) {
|
|
if (!t) return t;
|
|
e || (e = t);
|
|
var i, s = t;
|
|
do {
|
|
if (i = !1, s.steiner || !PIXI.EarCut.equals(s, s.next) && 0 !== PIXI.EarCut.area(s.prev, s, s.next)) s = s.next;
|
|
else {
|
|
if (PIXI.EarCut.removeNode(s), (s = e = s.prev) === s.next) return null;
|
|
i = !0
|
|
}
|
|
} while (i || s !== e);
|
|
return e
|
|
}, PIXI.EarCut.earcutLinked = function(t, e, i, s, o, n, a) {
|
|
if (t) {
|
|
!a && n && PIXI.EarCut.indexCurve(t, s, o, n);
|
|
for (var r, h, l = t; t.prev !== t.next;)
|
|
if (r = t.prev, h = t.next, n ? PIXI.EarCut.isEarHashed(t, s, o, n) : PIXI.EarCut.isEar(t)) e.push(r.i / i), e.push(t.i / i), e.push(h.i / i), PIXI.EarCut.removeNode(t), t = h.next, l = h.next;
|
|
else if ((t = h) === l) { a ? 1 === a ? (t = PIXI.EarCut.cureLocalIntersections(t, e, i), PIXI.EarCut.earcutLinked(t, e, i, s, o, n, 2)) : 2 === a && PIXI.EarCut.splitEarcut(t, e, i, s, o, n) : PIXI.EarCut.earcutLinked(PIXI.EarCut.filterPoints(t), e, i, s, o, n, 1); break }
|
|
}
|
|
}, PIXI.EarCut.isEar = function(t) {
|
|
var e = t.prev,
|
|
i = t,
|
|
s = t.next;
|
|
if (0 <= PIXI.EarCut.area(e, i, s)) return !1;
|
|
for (var o = t.next.next; o !== t.prev;) {
|
|
if (PIXI.EarCut.pointInTriangle(e.x, e.y, i.x, i.y, s.x, s.y, o.x, o.y) && 0 <= PIXI.EarCut.area(o.prev, o, o.next)) return !1;
|
|
o = o.next
|
|
}
|
|
return !0
|
|
}, PIXI.EarCut.isEarHashed = function(t, e, i, s) {
|
|
var o = t.prev,
|
|
n = t,
|
|
a = t.next;
|
|
if (0 <= PIXI.EarCut.area(o, n, a)) return !1;
|
|
for (var r = o.x < n.x ? o.x < a.x ? o.x : a.x : n.x < a.x ? n.x : a.x, h = o.y < n.y ? o.y < a.y ? o.y : a.y : n.y < a.y ? n.y : a.y, l = o.x > n.x ? o.x > a.x ? o.x : a.x : n.x > a.x ? n.x : a.x, c = o.y > n.y ? o.y > a.y ? o.y : a.y : n.y > a.y ? n.y : a.y, p = PIXI.EarCut.zOrder(r, h, e, i, s), u = PIXI.EarCut.zOrder(l, c, e, i, s), d = t.nextZ; d && d.z <= u;) {
|
|
if (d !== t.prev && d !== t.next && PIXI.EarCut.pointInTriangle(o.x, o.y, n.x, n.y, a.x, a.y, d.x, d.y) && 0 <= PIXI.EarCut.area(d.prev, d, d.next)) return !1;
|
|
d = d.nextZ
|
|
}
|
|
for (d = t.prevZ; d && d.z >= p;) {
|
|
if (d !== t.prev && d !== t.next && PIXI.EarCut.pointInTriangle(o.x, o.y, n.x, n.y, a.x, a.y, d.x, d.y) && 0 <= PIXI.EarCut.area(d.prev, d, d.next)) return !1;
|
|
d = d.prevZ
|
|
}
|
|
return !0
|
|
}, PIXI.EarCut.cureLocalIntersections = function(t, e, i) {
|
|
var s = t;
|
|
do {
|
|
var o = s.prev,
|
|
n = s.next.next;
|
|
PIXI.EarCut.intersects(o, s, s.next, n) && PIXI.EarCut.locallyInside(o, n) && PIXI.EarCut.locallyInside(n, o) && (e.push(o.i / i), e.push(s.i / i), e.push(n.i / i), PIXI.EarCut.removeNode(s), PIXI.EarCut.removeNode(s.next), s = t = n), s = s.next
|
|
} while (s !== t);
|
|
return s
|
|
}, PIXI.EarCut.splitEarcut = function(t, e, i, s, o, n) {
|
|
var a = t;
|
|
do { for (var r = a.next.next; r !== a.prev;) { if (a.i !== r.i && PIXI.EarCut.isValidDiagonal(a, r)) { var h = PIXI.EarCut.splitPolygon(a, r); return a = PIXI.EarCut.filterPoints(a, a.next), h = PIXI.EarCut.filterPoints(h, h.next), PIXI.EarCut.earcutLinked(a, e, i, s, o, n), void PIXI.EarCut.earcutLinked(h, e, i, s, o, n) } r = r.next } a = a.next } while (a !== t)
|
|
}, PIXI.EarCut.eliminateHoles = function(t, e, i, s) { var o, n, a, r, h, l = []; for (o = 0, n = e.length; o < n; o++) a = e[o] * s, r = o < n - 1 ? e[o + 1] * s : t.length, (h = PIXI.EarCut.linkedList(t, a, r, s, !1)) === h.next && (h.steiner = !0), l.push(PIXI.EarCut.getLeftmost(h)); for (l.sort(compareX), o = 0; o < l.length; o++) PIXI.EarCut.eliminateHole(l[o], i), i = PIXI.EarCut.filterPoints(i, i.next); return i }, PIXI.EarCut.compareX = function(t, e) { return t.x - e.x }, PIXI.EarCut.eliminateHole = function(t, e) {
|
|
if (e = PIXI.EarCut.findHoleBridge(t, e)) {
|
|
var i = PIXI.EarCut.splitPolygon(e, t);
|
|
PIXI.EarCut.filterPoints(i, i.next)
|
|
}
|
|
}, PIXI.EarCut.findHoleBridge = function(t, e) {
|
|
var i, s = e,
|
|
o = t.x,
|
|
n = t.y,
|
|
a = -1 / 0;
|
|
do {
|
|
if (n <= s.y && n >= s.next.y) {
|
|
var r = s.x + (n - s.y) * (s.next.x - s.x) / (s.next.y - s.y);
|
|
r <= o && a < r && (a = r, i = s.x < s.next.x ? s : s.next)
|
|
}
|
|
s = s.next
|
|
} while (s !== e);
|
|
if (!i) return null;
|
|
if (t.x === i.x) return i.prev;
|
|
var h, l = i,
|
|
c = 1 / 0;
|
|
for (s = i.next; s !== l;) o >= s.x && s.x >= i.x && PIXI.EarCut.pointInTriangle(n < i.y ? o : a, n, i.x, i.y, n < i.y ? a : o, n, s.x, s.y) && ((h = Math.abs(n - s.y) / (o - s.x)) < c || h === c && s.x > i.x) && PIXI.EarCut.locallyInside(s, t) && (i = s, c = h), s = s.next;
|
|
return i
|
|
}, PIXI.EarCut.indexCurve = function(t, e, i, s) {
|
|
for (var o = t; null === o.z && (o.z = PIXI.EarCut.zOrder(o.x, o.y, e, i, s)), o.prevZ = o.prev, o.nextZ = o.next, (o = o.next) !== t;);
|
|
o.prevZ.nextZ = null, o.prevZ = null, PIXI.EarCut.sortLinked(o)
|
|
}, PIXI.EarCut.sortLinked = function(t) {
|
|
var e, i, s, o, n, a, r, h, l = 1;
|
|
do {
|
|
for (i = t, n = t = null, a = 0; i;) {
|
|
for (a++, s = i, e = r = 0; e < l && (r++, s = s.nextZ); e++);
|
|
for (h = l; 0 < r || 0 < h && s;) 0 === r ? (s = (o = s).nextZ, h--) : 0 !== h && s ? i.z <= s.z ? (i = (o = i).nextZ, r--) : (s = (o = s).nextZ, h--) : (i = (o = i).nextZ, r--), n ? n.nextZ = o : t = o, o.prevZ = n, n = o;
|
|
i = s
|
|
}
|
|
n.nextZ = null, l *= 2
|
|
} while (1 < a);
|
|
return t
|
|
}, PIXI.EarCut.zOrder = function(t, e, i, s, o) { return (t = 1431655765 & ((t = 858993459 & ((t = 252645135 & ((t = 16711935 & ((t = 32767 * (t - i) / o) | t << 8)) | t << 4)) | t << 2)) | t << 1)) | (e = 1431655765 & ((e = 858993459 & ((e = 252645135 & ((e = 16711935 & ((e = 32767 * (e - s) / o) | e << 8)) | e << 4)) | e << 2)) | e << 1)) << 1 }, PIXI.EarCut.getLeftmost = function(t) { for (var e = t, i = t; e.x < i.x && (i = e), (e = e.next) !== t;); return i }, PIXI.EarCut.pointInTriangle = function(t, e, i, s, o, n, a, r) { return 0 <= (o - a) * (e - r) - (t - a) * (n - r) && 0 <= (t - a) * (s - r) - (i - a) * (e - r) && 0 <= (i - a) * (n - r) - (o - a) * (s - r) }, PIXI.EarCut.isValidDiagonal = function(t, e) { return PIXI.EarCut.equals(t, e) || t.next.i !== e.i && t.prev.i !== e.i && !PIXI.EarCut.intersectsPolygon(t, e) && PIXI.EarCut.locallyInside(t, e) && PIXI.EarCut.locallyInside(e, t) && PIXI.EarCut.middleInside(t, e) }, PIXI.EarCut.area = function(t, e, i) { return (e.y - t.y) * (i.x - e.x) - (e.x - t.x) * (i.y - e.y) }, PIXI.EarCut.equals = function(t, e) { return t.x === e.x && t.y === e.y }, PIXI.EarCut.intersects = function(t, e, i, s) { return 0 < PIXI.EarCut.area(t, e, i) != 0 < PIXI.EarCut.area(t, e, s) && 0 < PIXI.EarCut.area(i, s, t) != 0 < PIXI.EarCut.area(i, s, e) }, PIXI.EarCut.intersectsPolygon = function(t, e) {
|
|
var i = t;
|
|
do {
|
|
if (i.i !== t.i && i.next.i !== t.i && i.i !== e.i && i.next.i !== e.i && PIXI.EarCut.intersects(i, i.next, t, e)) return !0;
|
|
i = i.next
|
|
} while (i !== t);
|
|
return !1
|
|
}, PIXI.EarCut.locallyInside = function(t, e) { return PIXI.EarCut.area(t.prev, t, t.next) < 0 ? 0 <= PIXI.EarCut.area(t, e, t.next) && 0 <= PIXI.EarCut.area(t, t.prev, e) : PIXI.EarCut.area(t, e, t.prev) < 0 || PIXI.EarCut.area(t, t.next, e) < 0 }, PIXI.EarCut.middleInside = function(t, e) { for (var i = t, s = !1, o = (t.x + e.x) / 2, n = (t.y + e.y) / 2; i.y > n != i.next.y > n && o < (i.next.x - i.x) * (n - i.y) / (i.next.y - i.y) + i.x && (s = !s), (i = i.next) !== t;); return s }, PIXI.EarCut.splitPolygon = function(t, e) {
|
|
var i = new PIXI.EarCut.Node(t.i, t.x, t.y),
|
|
s = new PIXI.EarCut.Node(e.i, e.x, e.y),
|
|
o = t.next,
|
|
n = e.prev;
|
|
return (t.next = e).prev = t, (i.next = o).prev = i, (s.next = i).prev = s, (n.next = s).prev = n, s
|
|
}, PIXI.EarCut.insertNode = function(t, e, i, s) { var o = new PIXI.EarCut.Node(t, e, i); return s ? (o.next = s.next, (o.prev = s).next.prev = o, s.next = o) : (o.prev = o).next = o, o }, PIXI.EarCut.removeNode = function(t) { t.next.prev = t.prev, t.prev.next = t.next, t.prevZ && (t.prevZ.nextZ = t.nextZ), t.nextZ && (t.nextZ.prevZ = t.prevZ) }, PIXI.EarCut.Node = function(t, e, i) { this.i = t, this.x = e, this.y = i, this.prev = null, this.next = null, this.z = null, this.prevZ = null, this.nextZ = null, this.steiner = !1 }, PIXI.WebGLGraphics = function() {}, PIXI.WebGLGraphics.stencilBufferLimit = 6, PIXI.WebGLGraphics.renderGraphics = function(t, e) {
|
|
var i, s = e.gl,
|
|
o = e.projection,
|
|
n = e.offset,
|
|
a = e.shaderManager.primitiveShader;
|
|
t.dirty && PIXI.WebGLGraphics.updateGraphics(t, s);
|
|
for (var r = t._webGL[s.id], h = 0; h < r.data.length; h++) 1 === r.data[h].mode ? (i = r.data[h], e.stencilManager.pushStencil(t, i, e), s.drawElements(s.TRIANGLE_FAN, 4, s.UNSIGNED_SHORT, 2 * (i.indices.length - 4)), e.stencilManager.popStencil(t, i, e)) : (i = r.data[h], e.shaderManager.setShader(a), a = e.shaderManager.primitiveShader, s.uniformMatrix3fv(a.translationMatrix, !1, t.worldTransform.toArray(!0)), s.uniform1f(a.flipY, 1), s.uniform2f(a.projectionVector, o.x, -o.y), s.uniform2f(a.offsetVector, -n.x, -n.y), s.uniform3fv(a.tintColor, PIXI.hex2rgb(t.tint)), s.uniform1f(a.alpha, t.worldAlpha), s.bindBuffer(s.ARRAY_BUFFER, i.buffer), s.vertexAttribPointer(a.aVertexPosition, 2, s.FLOAT, !1, 24, 0), s.vertexAttribPointer(a.colorAttribute, 4, s.FLOAT, !1, 24, 8), s.bindBuffer(s.ELEMENT_ARRAY_BUFFER, i.indexBuffer), s.drawElements(s.TRIANGLE_STRIP, i.indices.length, s.UNSIGNED_SHORT, 0))
|
|
}, PIXI.WebGLGraphics.updateGraphics = function(t, e) {
|
|
var i, s, o = t._webGL[e.id];
|
|
if (o || (o = t._webGL[e.id] = { lastIndex: 0, data: [], gl: e }), t.dirty = !1, t.clearDirty) {
|
|
for (t.clearDirty = !1, i = 0; i < o.data.length; i++) {
|
|
var n = o.data[i];
|
|
n.reset(), PIXI.WebGLGraphics.graphicsDataPool.push(n)
|
|
}
|
|
o.data = [], o.lastIndex = 0
|
|
}
|
|
for (i = o.lastIndex; i < t.graphicsData.length; i++) {
|
|
var a = t.graphicsData[i];
|
|
if (a.type === PIXI.Graphics.POLY) {
|
|
if (a.points = a.shape.points.slice(), a.shape.closed && (a.points[0] === a.points[a.points.length - 2] && a.points[1] === a.points[a.points.length - 1] || a.points.push(a.points[0], a.points[1])), a.fill)
|
|
if (a.points.length >= PIXI.WebGLGraphics.stencilBufferLimit)
|
|
if (a.points.length < 2 * PIXI.WebGLGraphics.stencilBufferLimit) s = PIXI.WebGLGraphics.switchMode(o, 0), PIXI.WebGLGraphics.buildPoly(a, s) || (s = PIXI.WebGLGraphics.switchMode(o, 1), PIXI.WebGLGraphics.buildComplexPoly(a, s));
|
|
else s = PIXI.WebGLGraphics.switchMode(o, 1), PIXI.WebGLGraphics.buildComplexPoly(a, s);
|
|
0 < a.lineWidth && (s = PIXI.WebGLGraphics.switchMode(o, 0), PIXI.WebGLGraphics.buildLine(a, s))
|
|
}
|
|
else s = PIXI.WebGLGraphics.switchMode(o, 0), a.type === PIXI.Graphics.RECT ? PIXI.WebGLGraphics.buildRectangle(a, s) : a.type === PIXI.Graphics.CIRC || a.type === PIXI.Graphics.ELIP ? PIXI.WebGLGraphics.buildCircle(a, s) : a.type === PIXI.Graphics.RREC && PIXI.WebGLGraphics.buildRoundedRectangle(a, s);
|
|
o.lastIndex++
|
|
}
|
|
for (i = 0; i < o.data.length; i++)(s = o.data[i]).dirty && s.upload()
|
|
}, PIXI.WebGLGraphics.switchMode = function(t, e) { var i; return t.data.length && (i = t.data[t.data.length - 1]).mode === e && 1 !== e || ((i = PIXI.WebGLGraphics.graphicsDataPool.pop() || new PIXI.WebGLGraphicsData(t.gl)).mode = e, t.data.push(i)), i.dirty = !0, i }, PIXI.WebGLGraphics.buildRectangle = function(t, e) {
|
|
var i = t.shape,
|
|
s = i.x,
|
|
o = i.y,
|
|
n = i.width,
|
|
a = i.height;
|
|
if (t.fill) {
|
|
var r = PIXI.hex2rgb(t.fillColor),
|
|
h = t.fillAlpha,
|
|
l = r[0] * h,
|
|
c = r[1] * h,
|
|
p = r[2] * h,
|
|
u = e.points,
|
|
d = e.indices,
|
|
y = u.length / 6;
|
|
u.push(s, o), u.push(l, c, p, h), u.push(s + n, o), u.push(l, c, p, h), u.push(s, o + a), u.push(l, c, p, h), u.push(s + n, o + a), u.push(l, c, p, h), d.push(y, y, y + 1, y + 2, y + 3, y + 3)
|
|
}
|
|
if (t.lineWidth) {
|
|
var g = t.points;
|
|
t.points = [s, o, s + n, o, s + n, o + a, s, o + a, s, o], PIXI.WebGLGraphics.buildLine(t, e), t.points = g
|
|
}
|
|
}, PIXI.WebGLGraphics.buildRoundedRectangle = function(t, e) {
|
|
var i = t.shape,
|
|
s = i.x,
|
|
o = i.y,
|
|
n = i.width,
|
|
a = i.height,
|
|
r = i.radius,
|
|
h = [];
|
|
if (h.push(s, o + r), h = (h = (h = (h = h.concat(PIXI.WebGLGraphics.quadraticBezierCurve(s, o + a - r, s, o + a, s + r, o + a))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(s + n - r, o + a, s + n, o + a, s + n, o + a - r))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(s + n, o + r, s + n, o, s + n - r, o))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(s + r, o, s, o, s, o + r)), t.fill) {
|
|
var l = PIXI.hex2rgb(t.fillColor),
|
|
c = t.fillAlpha,
|
|
p = l[0] * c,
|
|
u = l[1] * c,
|
|
d = l[2] * c,
|
|
y = e.points,
|
|
g = e.indices,
|
|
f = y.length / 6,
|
|
m = PIXI.EarCut.Triangulate(h, null, 2),
|
|
v = 0;
|
|
for (v = 0; v < m.length; v += 3) g.push(m[v] + f), g.push(m[v] + f), g.push(m[v + 1] + f), g.push(m[v + 2] + f), g.push(m[v + 2] + f);
|
|
for (v = 0; v < h.length; v++) y.push(h[v], h[++v], p, u, d, c)
|
|
}
|
|
if (t.lineWidth) {
|
|
var x = t.points;
|
|
t.points = h, PIXI.WebGLGraphics.buildLine(t, e), t.points = x
|
|
}
|
|
}, PIXI.WebGLGraphics.quadraticBezierCurve = function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p, u = [];
|
|
|
|
function d(t, e, i) { return t + (e - t) * i }
|
|
for (var y = 0, g = 0; g <= 20; g++) a = d(t, i, y = g / 20), r = d(e, s, y), h = d(i, o, y), l = d(s, n, y), c = d(a, h, y), p = d(r, l, y), u.push(c, p);
|
|
return u
|
|
}, PIXI.WebGLGraphics.buildCircle = function(t, e) {
|
|
var i, s, o = t.shape,
|
|
n = o.x,
|
|
a = o.y;
|
|
s = t.type === PIXI.Graphics.CIRC ? (i = o.radius, o.radius) : (i = o.width, o.height);
|
|
var r = 2 * Math.PI / 40,
|
|
h = 0;
|
|
if (t.fill) {
|
|
var l = PIXI.hex2rgb(t.fillColor),
|
|
c = t.fillAlpha,
|
|
p = l[0] * c,
|
|
u = l[1] * c,
|
|
d = l[2] * c,
|
|
y = e.points,
|
|
g = e.indices,
|
|
f = y.length / 6;
|
|
for (g.push(f), h = 0; h < 41; h++) y.push(n, a, p, u, d, c), y.push(n + Math.sin(r * h) * i, a + Math.cos(r * h) * s, p, u, d, c), g.push(f++, f++);
|
|
g.push(f - 1)
|
|
}
|
|
if (t.lineWidth) {
|
|
var m = t.points;
|
|
for (t.points = [], h = 0; h < 41; h++) t.points.push(n + Math.sin(r * h) * i, a + Math.cos(r * h) * s);
|
|
PIXI.WebGLGraphics.buildLine(t, e), t.points = m
|
|
}
|
|
}, PIXI.WebGLGraphics.buildLine = function(t, e) {
|
|
var i = 0,
|
|
s = t.points;
|
|
if (0 !== s.length) {
|
|
if (t.lineWidth % 2)
|
|
for (i = 0; i < s.length; i++) s[i] += .5;
|
|
var o = new PIXI.Point(s[0], s[1]),
|
|
n = new PIXI.Point(s[s.length - 2], s[s.length - 1]);
|
|
if (o.x === n.x && o.y === n.y) {
|
|
(s = s.slice()).pop(), s.pop();
|
|
var a = (n = new PIXI.Point(s[s.length - 2], s[s.length - 1])).x + .5 * (o.x - n.x),
|
|
r = n.y + .5 * (o.y - n.y);
|
|
s.unshift(a, r), s.push(a, r)
|
|
}
|
|
var h, l, c, p, u, d, y, g, f, m, v, x, b, w, P, _, T, S, k, B, A, C, I = e.points,
|
|
E = e.indices,
|
|
O = s.length / 2,
|
|
M = s.length,
|
|
L = I.length / 6,
|
|
R = t.lineWidth / 2,
|
|
D = PIXI.hex2rgb(t.lineColor),
|
|
F = t.lineAlpha,
|
|
U = D[0] * F,
|
|
G = D[1] * F,
|
|
N = D[2] * F;
|
|
for (c = s[0], p = s[1], u = s[2], f = -(p - (d = s[3])), m = c - u, f /= C = Math.sqrt(f * f + m * m), m /= C, f *= R, m *= R, I.push(c - f, p - m, U, G, N, F), I.push(c + f, p + m, U, G, N, F), i = 1; i < O - 1; i++) c = s[2 * (i - 1)], p = s[2 * (i - 1) + 1], u = s[2 * i], d = s[2 * i + 1], y = s[2 * (i + 1)], g = s[2 * (i + 1) + 1], f = -(p - d), m = c - u, f /= C = Math.sqrt(f * f + m * m), m /= C, f *= R, m *= R, v = -(d - g), x = u - y, v /= C = Math.sqrt(v * v + x * x), x /= C, T = (-f + c) * (-m + d) - (-f + u) * (-m + p), B = (-(v *= R) + y) * (-(x *= R) + d) - (-v + u) * (-x + g), A = (P = -m + p - (-m + d)) * (k = -v + u - (-v + y)) - (S = -x + g - (-x + d)) * (_ = -f + u - (-f + c)), Math.abs(A) < .1 ? (A += 10.1, I.push(u - f, d - m, U, G, N, F), I.push(u + f, d + m, U, G, N, F)) : 19600 < ((h = (_ * B - k * T) / A) - u) * (h - u) + ((l = (S * T - P * B) / A) - d) + (l - d) ? (b = f - v, w = m - x, b /= C = Math.sqrt(b * b + w * w), w /= C, b *= R, w *= R, I.push(u - b, d - w), I.push(U, G, N, F), I.push(u + b, d + w), I.push(U, G, N, F), I.push(u - b, d - w), I.push(U, G, N, F), M++) : (I.push(h, l), I.push(U, G, N, F), I.push(u - (h - u), d - (l - d)), I.push(U, G, N, F));
|
|
for (c = s[2 * (O - 2)], p = s[2 * (O - 2) + 1], u = s[2 * (O - 1)], f = -(p - (d = s[2 * (O - 1) + 1])), m = c - u, f /= C = Math.sqrt(f * f + m * m), m /= C, f *= R, m *= R, I.push(u - f, d - m), I.push(U, G, N, F), I.push(u + f, d + m), I.push(U, G, N, F), E.push(L), i = 0; i < M; i++) E.push(L++);
|
|
E.push(L - 1)
|
|
}
|
|
}, PIXI.WebGLGraphics.buildComplexPoly = function(t, e) {
|
|
var i = t.points.slice();
|
|
if (!(i.length < 6)) {
|
|
var s = e.indices;
|
|
e.points = i, e.alpha = t.fillAlpha, e.color = PIXI.hex2rgb(t.fillColor);
|
|
for (var o, n, a = 1 / 0, r = -1 / 0, h = 1 / 0, l = -1 / 0, c = 0; c < i.length; c += 2) a = (o = i[c]) < a ? o : a, r = r < o ? o : r, h = (n = i[c + 1]) < h ? n : h, l = l < n ? n : l;
|
|
i.push(a, h, r, h, r, l, a, l);
|
|
var p = i.length / 2;
|
|
for (c = 0; c < p; c++) s.push(c)
|
|
}
|
|
}, PIXI.WebGLGraphics.buildPoly = function(t, e) {
|
|
var i = t.points;
|
|
if (!(i.length < 6)) {
|
|
var s = e.points,
|
|
o = e.indices,
|
|
n = i.length / 2,
|
|
a = PIXI.hex2rgb(t.fillColor),
|
|
r = t.fillAlpha,
|
|
h = a[0] * r,
|
|
l = a[1] * r,
|
|
c = a[2] * r,
|
|
p = PIXI.EarCut.Triangulate(i, null, 2);
|
|
if (!p) return !1;
|
|
var u = s.length / 6,
|
|
d = 0;
|
|
for (d = 0; d < p.length; d += 3) o.push(p[d] + u), o.push(p[d] + u), o.push(p[d + 1] + u), o.push(p[d + 2] + u), o.push(p[d + 2] + u);
|
|
for (d = 0; d < n; d++) s.push(i[2 * d], i[2 * d + 1], h, l, c, r);
|
|
return !0
|
|
}
|
|
}, PIXI.WebGLGraphics.graphicsDataPool = [], PIXI.WebGLGraphicsData = function(t) { this.gl = t, this.color = [0, 0, 0], this.points = [], this.indices = [], this.buffer = t.createBuffer(), this.indexBuffer = t.createBuffer(), this.mode = 1, this.alpha = 1, this.dirty = !0 }, PIXI.WebGLGraphicsData.prototype.reset = function() { this.points = [], this.indices = [] }, PIXI.WebGLGraphicsData.prototype.upload = function() {
|
|
var t = this.gl;
|
|
this.glPoints = new PIXI.Float32Array(this.points), t.bindBuffer(t.ARRAY_BUFFER, this.buffer), t.bufferData(t.ARRAY_BUFFER, this.glPoints, t.STATIC_DRAW), this.glIndicies = new PIXI.Uint16Array(this.indices), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer), t.bufferData(t.ELEMENT_ARRAY_BUFFER, this.glIndicies, t.STATIC_DRAW), this.dirty = !1
|
|
}, PIXI.CanvasGraphics = function() {}, PIXI.CanvasGraphics.renderGraphics = function(t, e) {
|
|
var i = t.worldAlpha;
|
|
t.dirty && (this.updateGraphicsTint(t), t.dirty = !1);
|
|
for (var s = 0; s < t.graphicsData.length; s++) {
|
|
var o = t.graphicsData[s],
|
|
n = o.shape,
|
|
a = o._fillTint,
|
|
r = o._lineTint;
|
|
if (e.lineWidth = o.lineWidth, o.type === PIXI.Graphics.POLY) {
|
|
e.beginPath();
|
|
var h = n.points;
|
|
e.moveTo(h[0], h[1]);
|
|
for (var l = 1; l < h.length / 2; l++) e.lineTo(h[2 * l], h[2 * l + 1]);
|
|
n.closed && e.lineTo(h[0], h[1]), h[0] === h[h.length - 2] && h[1] === h[h.length - 1] && e.closePath(), o.fill && (e.globalAlpha = o.fillAlpha * i, e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-6), e.fill()), o.lineWidth && (e.globalAlpha = o.lineAlpha * i, e.strokeStyle = "#" + ("00000" + (0 | r).toString(16)).substr(-6), e.stroke())
|
|
}
|
|
else if (o.type === PIXI.Graphics.RECT)(o.fillColor || 0 === o.fillColor) && (e.globalAlpha = o.fillAlpha * i, e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-6), e.fillRect(n.x, n.y, n.width, n.height)), o.lineWidth && (e.globalAlpha = o.lineAlpha * i, e.strokeStyle = "#" + ("00000" + (0 | r).toString(16)).substr(-6), e.strokeRect(n.x, n.y, n.width, n.height));
|
|
else if (o.type === PIXI.Graphics.CIRC) e.beginPath(), e.arc(n.x, n.y, n.radius, 0, 2 * Math.PI), e.closePath(), o.fill && (e.globalAlpha = o.fillAlpha * i, e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-6), e.fill()), o.lineWidth && (e.globalAlpha = o.lineAlpha * i, e.strokeStyle = "#" + ("00000" + (0 | r).toString(16)).substr(-6), e.stroke());
|
|
else if (o.type === PIXI.Graphics.ELIP) {
|
|
var c = 2 * n.width,
|
|
p = 2 * n.height,
|
|
u = n.x - c / 2,
|
|
d = n.y - p / 2;
|
|
e.beginPath();
|
|
var y = c / 2 * .5522848,
|
|
g = p / 2 * .5522848,
|
|
f = u + c,
|
|
m = d + p,
|
|
v = u + c / 2,
|
|
x = d + p / 2;
|
|
e.moveTo(u, x), e.bezierCurveTo(u, x - g, v - y, d, v, d), e.bezierCurveTo(v + y, d, f, x - g, f, x), e.bezierCurveTo(f, x + g, v + y, m, v, m), e.bezierCurveTo(v - y, m, u, x + g, u, x), e.closePath(), o.fill && (e.globalAlpha = o.fillAlpha * i, e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-6), e.fill()), o.lineWidth && (e.globalAlpha = o.lineAlpha * i, e.strokeStyle = "#" + ("00000" + (0 | r).toString(16)).substr(-6), e.stroke())
|
|
}
|
|
else if (o.type === PIXI.Graphics.RREC) {
|
|
var b = n.x,
|
|
w = n.y,
|
|
P = n.width,
|
|
_ = n.height,
|
|
T = n.radius,
|
|
S = Math.min(P, _) / 2 | 0;
|
|
T = S < T ? S : T, e.beginPath(), e.moveTo(b, w + T), e.lineTo(b, w + _ - T), e.quadraticCurveTo(b, w + _, b + T, w + _), e.lineTo(b + P - T, w + _), e.quadraticCurveTo(b + P, w + _, b + P, w + _ - T), e.lineTo(b + P, w + T), e.quadraticCurveTo(b + P, w, b + P - T, w), e.lineTo(b + T, w), e.quadraticCurveTo(b, w, b, w + T), e.closePath(), (o.fillColor || 0 === o.fillColor) && (e.globalAlpha = o.fillAlpha * i, e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-6), e.fill()), o.lineWidth && (e.globalAlpha = o.lineAlpha * i, e.strokeStyle = "#" + ("00000" + (0 | r).toString(16)).substr(-6), e.stroke())
|
|
}
|
|
}
|
|
}, PIXI.CanvasGraphics.renderGraphicsMask = function(t, e) {
|
|
var i = t.graphicsData.length;
|
|
if (0 !== i) {
|
|
e.beginPath();
|
|
for (var s = 0; s < i; s++) {
|
|
var o = t.graphicsData[s],
|
|
n = o.shape;
|
|
if (o.type === PIXI.Graphics.POLY) {
|
|
var a = n.points;
|
|
e.moveTo(a[0], a[1]);
|
|
for (var r = 1; r < a.length / 2; r++) e.lineTo(a[2 * r], a[2 * r + 1]);
|
|
a[0] === a[a.length - 2] && a[1] === a[a.length - 1] && e.closePath()
|
|
}
|
|
else if (o.type === PIXI.Graphics.RECT) e.rect(n.x, n.y, n.width, n.height), e.closePath();
|
|
else if (o.type === PIXI.Graphics.CIRC) e.arc(n.x, n.y, n.radius, 0, 2 * Math.PI), e.closePath();
|
|
else if (o.type === PIXI.Graphics.ELIP) {
|
|
var h = 2 * n.width,
|
|
l = 2 * n.height,
|
|
c = n.x - h / 2,
|
|
p = n.y - l / 2,
|
|
u = h / 2 * .5522848,
|
|
d = l / 2 * .5522848,
|
|
y = c + h,
|
|
g = p + l,
|
|
f = c + h / 2,
|
|
m = p + l / 2;
|
|
e.moveTo(c, m), e.bezierCurveTo(c, m - d, f - u, p, f, p), e.bezierCurveTo(f + u, p, y, m - d, y, m), e.bezierCurveTo(y, m + d, f + u, g, f, g), e.bezierCurveTo(f - u, g, c, m + d, c, m), e.closePath()
|
|
}
|
|
else if (o.type === PIXI.Graphics.RREC) {
|
|
var v = n.x,
|
|
x = n.y,
|
|
b = n.width,
|
|
w = n.height,
|
|
P = n.radius,
|
|
_ = Math.min(b, w) / 2 | 0;
|
|
P = _ < P ? _ : P, e.moveTo(v, x + P), e.lineTo(v, x + w - P), e.quadraticCurveTo(v, x + w, v + P, x + w), e.lineTo(v + b - P, x + w), e.quadraticCurveTo(v + b, x + w, v + b, x + w - P), e.lineTo(v + b, x + P), e.quadraticCurveTo(v + b, x, v + b - P, x), e.lineTo(v + P, x), e.quadraticCurveTo(v, x, v, x + P), e.closePath()
|
|
}
|
|
}
|
|
}
|
|
}, PIXI.CanvasGraphics.updateGraphicsTint = function(t) {
|
|
if (16777215 !== t.tint)
|
|
for (var e = (t.tint >> 16 & 255) / 255, i = (t.tint >> 8 & 255) / 255, s = (255 & t.tint) / 255, o = 0; o < t.graphicsData.length; o++) {
|
|
var n = t.graphicsData[o],
|
|
a = 0 | n.fillColor,
|
|
r = 0 | n.lineColor;
|
|
n._fillTint = ((a >> 16 & 255) / 255 * e * 255 << 16) + ((a >> 8 & 255) / 255 * i * 255 << 8) + (255 & a) / 255 * s * 255, n._lineTint = ((r >> 16 & 255) / 255 * e * 255 << 16) + ((r >> 8 & 255) / 255 * i * 255 << 8) + (255 & r) / 255 * s * 255
|
|
}
|
|
}, H.Graphics = function(t, e, i) { void 0 === e && (e = 0), void 0 === i && (i = 0), this.type = H.GRAPHICS, this.physicsType = H.SPRITE, this.anchor = new H.Point, PIXI.Graphics.call(this), H.Component.Core.init.call(this, t, e, i, "", null) }, H.Graphics.prototype = Object.create(PIXI.Graphics.prototype), H.Graphics.prototype.constructor = H.Graphics, H.Component.Core.install.call(H.Graphics.prototype, ["Angle", "AutoCull", "Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "PhysicsBody", "Reset"]), H.Graphics.prototype.preUpdatePhysics = H.Component.PhysicsBody.preUpdate, H.Graphics.prototype.preUpdateLifeSpan = H.Component.LifeSpan.preUpdate, H.Graphics.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.Graphics.prototype.preUpdateCore = H.Component.Core.preUpdate, H.Graphics.prototype.preUpdate = function() { return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.Graphics.prototype.postUpdate = function() { H.Component.PhysicsBody.postUpdate.call(this), H.Component.FixedToCamera.postUpdate.call(this), this._boundsDirty && (this.updateLocalBounds(), this._boundsDirty = !1); for (var t = 0; t < this.children.length; t++) this.children[t].postUpdate() }, H.Graphics.prototype.destroy = function(t) { this.clear(), H.Component.Destroy.prototype.destroy.call(this, t) }, H.Graphics.prototype.drawTriangle = function(t, e) {
|
|
void 0 === e && (e = !1);
|
|
var i = new H.Polygon(t);
|
|
if (e) {
|
|
var s = new H.Point(this.game.camera.x - t[0].x, this.game.camera.y - t[0].y),
|
|
o = new H.Point(t[1].x - t[0].x, t[1].y - t[0].y),
|
|
n = new H.Point(t[1].x - t[2].x, t[1].y - t[2].y).cross(o);
|
|
0 < s.dot(n) && this.drawPolygon(i)
|
|
}
|
|
else this.drawPolygon(i)
|
|
}, H.Graphics.prototype.drawTriangles = function(t, e, i) {
|
|
void 0 === i && (i = !1);
|
|
var s, o = new H.Point,
|
|
n = new H.Point,
|
|
a = new H.Point,
|
|
r = [];
|
|
if (e)
|
|
if (t[0] instanceof H.Point)
|
|
for (s = 0; s < e.length / 3; s++) r.push(t[e[3 * s]]), r.push(t[e[3 * s + 1]]), r.push(t[e[3 * s + 2]]), 3 === r.length && (this.drawTriangle(r, i), r = []);
|
|
else
|
|
for (s = 0; s < e.length; s++) o.x = t[2 * e[s]], o.y = t[2 * e[s] + 1], r.push(o.copyTo({})), 3 === r.length && (this.drawTriangle(r, i), r = []);
|
|
else if (t[0] instanceof H.Point)
|
|
for (s = 0; s < t.length / 3; s++) this.drawTriangle([t[3 * s], t[3 * s + 1], t[3 * s + 2]], i);
|
|
else
|
|
for (s = 0; s < t.length / 6; s++) o.x = t[6 * s + 0], o.y = t[6 * s + 1], n.x = t[6 * s + 2], n.y = t[6 * s + 3], a.x = t[6 * s + 4], a.y = t[6 * s + 5], this.drawTriangle([o, n, a], i)
|
|
}, H.RenderTexture = function(t, e, i, s, o, n) { void 0 === s && (s = ""), void 0 === o && (o = H.scaleModes.DEFAULT), void 0 === n && (n = 1), this.game = t, this.key = s, this.type = H.RENDERTEXTURE, this._tempMatrix = new PIXI.Matrix, PIXI.RenderTexture.call(this, e, i, this.game.renderer, o, n), this.render = H.RenderTexture.prototype.render }, H.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype), H.RenderTexture.prototype.constructor = H.RenderTexture, H.RenderTexture.prototype.renderXY = function(t, e, i, s) { t.updateTransform(), this._tempMatrix.copyFrom(t.worldTransform), this._tempMatrix.tx = e, this._tempMatrix.ty = i, this.renderer.type === PIXI.WEBGL_RENDERER ? this.renderWebGL(t, this._tempMatrix, s) : this.renderCanvas(t, this._tempMatrix, s) }, H.RenderTexture.prototype.renderRawXY = function(t, e, i, s) { this._tempMatrix.identity().translate(e, i), this.renderer.type === PIXI.WEBGL_RENDERER ? this.renderWebGL(t, this._tempMatrix, s) : this.renderCanvas(t, this._tempMatrix, s) }, H.RenderTexture.prototype.render = function(t, e, i) { null == e ? this._tempMatrix.copyFrom(t.worldTransform) : this._tempMatrix.copyFrom(e), this.renderer.type === PIXI.WEBGL_RENDERER ? this.renderWebGL(t, this._tempMatrix, i) : this.renderCanvas(t, this._tempMatrix, i) }, H.Text = function(t, e, i, s, o) { e = e || 0, i = i || 0, s = null == s ? "" : s.toString(), o = H.Utils.extend({}, o), this.type = H.TEXT, this.physicsType = H.SPRITE, this.padding = new H.Point, this.textBounds = null, this.canvas = PIXI.CanvasPool.create(this), this.context = this.canvas.getContext("2d"), this.colors = [], this.strokeColors = [], this.fontStyles = [], this.fontWeights = [], this.autoRound = !1, this.useAdvancedWrap = !1, this._res = t.renderer.resolution, this._text = s, this._fontComponents = null, this._lineSpacing = 0, this._charCount = 0, this._width = 0, this._height = 0, H.Sprite.call(this, t, e, i, PIXI.Texture.fromCanvas(this.canvas)), this.setStyle(o), "" !== s && this.updateText() }, H.Text.prototype = Object.create(H.Sprite.prototype), H.Text.prototype.constructor = H.Text, H.Text.prototype.preUpdate = function() { return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.Text.prototype.update = function() {}, H.Text.prototype.destroy = function(t) { this.texture.destroy(!0), H.Component.Destroy.prototype.destroy.call(this, t) }, H.Text.prototype.setShadow = function(t, e, i, s, o, n) { return void 0 === t && (t = 0), void 0 === e && (e = 0), void 0 === i && (i = "rgba(0, 0, 0, 1)"), void 0 === s && (s = 0), void 0 === o && (o = !0), void 0 === n && (n = !0), this.style.shadowOffsetX = t, this.style.shadowOffsetY = e, this.style.shadowColor = i, this.style.shadowBlur = s, this.style.shadowStroke = o, this.style.shadowFill = n, this.dirty = !0, this }, H.Text.prototype.setStyle = function(t, e) { void 0 === e && (e = !1), (t = t || {}).font = t.font || "bold 20pt Arial", t.backgroundColor = t.backgroundColor || null, t.fill = t.fill || "black", t.align = t.align || "left", t.boundsAlignH = t.boundsAlignH || "left", t.boundsAlignV = t.boundsAlignV || "top", t.stroke = t.stroke || "black", t.strokeThickness = t.strokeThickness || 0, t.wordWrap = t.wordWrap || !1, t.wordWrapWidth = t.wordWrapWidth || 100, t.maxLines = t.maxLines || 0, t.shadowOffsetX = t.shadowOffsetX || 0, t.shadowOffsetY = t.shadowOffsetY || 0, t.shadowColor = t.shadowColor || "rgba(0,0,0,0)", t.shadowBlur = t.shadowBlur || 0, t.tabs = t.tabs || 0; var i = this.fontToComponents(t.font); return t.fontStyle && (i.fontStyle = t.fontStyle), t.fontVariant && (i.fontVariant = t.fontVariant), t.fontWeight && (i.fontWeight = t.fontWeight), t.fontSize && ("number" == typeof t.fontSize && (t.fontSize = t.fontSize + "px"), i.fontSize = t.fontSize), this._fontComponents = i, t.font = this.componentsToFont(this._fontComponents), this.style = t, this.dirty = !0, e && this.updateText(), this }, H.Text.prototype.updateText = function() {
|
|
this.texture.baseTexture.resolution = this._res, this.context.font = this.style.font;
|
|
var t = this.text;
|
|
this.style.wordWrap && (t = this.runWordWrap(this.text));
|
|
var e = t.split(/(?:\r\n|\r|\n)/),
|
|
i = this.style.tabs,
|
|
s = [],
|
|
o = 0,
|
|
n = this.determineFontProperties(this.style.font),
|
|
a = e.length;
|
|
0 < this.style.maxLines && this.style.maxLines < e.length && (a = this.style.maxLines);
|
|
for (var r = this._charCount = 0; r < a; r++) {
|
|
if (0 === i) {
|
|
var h = this.style.strokeThickness + this.padding.x;
|
|
0 < this.colors.length || 0 < this.strokeColors.length || 0 < this.fontWeights.length || 0 < this.fontStyles.length ? h += this.measureLine(e[r]) : h += this.context.measureText(e[r]).width, this.style.wordWrap && (h -= this.context.measureText(" ").width)
|
|
}
|
|
else {
|
|
var l = e[r].split(/(?:\t)/);
|
|
h = this.padding.x + this.style.strokeThickness;
|
|
if (Array.isArray(i))
|
|
for (var c = 0, p = 0; p < l.length; p++) {
|
|
var u = 0;
|
|
u = 0 < this.colors.length || 0 < this.strokeColors.length || 0 < this.fontWeights.length || 0 < this.fontStyles.length ? this.measureLine(l[p]) : Math.ceil(this.context.measureText(l[p]).width), 0 < p && (c += i[p - 1]), h = c + u
|
|
}
|
|
else
|
|
for (p = 0; p < l.length; p++) { 0 < this.colors.length || 0 < this.strokeColors.length || 0 < this.fontWeights.length || 0 < this.fontStyles.length ? h += this.measureLine(l[p]) : h += Math.ceil(this.context.measureText(l[p]).width), h += this.game.math.snapToCeil(h, i) - h }
|
|
}
|
|
s[r] = Math.ceil(h), o = Math.max(o, s[r])
|
|
}
|
|
this.canvas.width = o * this._res;
|
|
var d, y, g = n.fontSize + this.style.strokeThickness + this.padding.y,
|
|
f = g * a,
|
|
m = this._lineSpacing;
|
|
for (m < 0 && Math.abs(m) > g && (m = -g), 0 !== m && (f += 0 < m ? m * e.length : m * (e.length - 1)), this.canvas.height = f * this._res, this.context.scale(this._res, this._res), navigator.isCocoonJS && this.context.clearRect(0, 0, this.canvas.width, this.canvas.height), this.style.backgroundColor && (this.context.fillStyle = this.style.backgroundColor, this.context.fillRect(0, 0, this.canvas.width, this.canvas.height)), this.context.fillStyle = this.style.fill, this.context.font = this.style.font, this.context.strokeStyle = this.style.stroke, this.context.textBaseline = "alphabetic", this.context.lineWidth = this.style.strokeThickness, this.context.lineCap = "round", this.context.lineJoin = "round", r = this._charCount = 0; r < a; r++) d = this.style.strokeThickness / 2, y = this.style.strokeThickness / 2 + r * g + n.ascent, 0 < r && (y += m * r), "right" === this.style.align ? d += o - s[r] : "center" === this.style.align && (d += (o - s[r]) / 2), this.autoRound && (d = Math.round(d), y = Math.round(y)), 0 < this.colors.length || 0 < this.strokeColors.length || 0 < this.fontWeights.length || 0 < this.fontStyles.length ? this.updateLine(e[r], d, y) : (this.style.stroke && this.style.strokeThickness && (this.updateShadow(this.style.shadowStroke), 0 === i ? this.context.strokeText(e[r], d, y) : this.renderTabLine(e[r], d, y, !1)), this.style.fill && (this.updateShadow(this.style.shadowFill), 0 === i ? this.context.fillText(e[r], d, y) : this.renderTabLine(e[r], d, y, !0)));
|
|
this.updateTexture(), this.dirty = !1
|
|
}, H.Text.prototype.renderTabLine = function(t, e, i, s) {
|
|
var o = t.split(/(?:\t)/),
|
|
n = this.style.tabs,
|
|
a = 0;
|
|
if (Array.isArray(n))
|
|
for (var r = 0, h = 0; h < o.length; h++) 0 < h && (r += n[h - 1]), a = e + r, s ? this.context.fillText(o[h], a, i) : this.context.strokeText(o[h], a, i);
|
|
else
|
|
for (h = 0; h < o.length; h++) {
|
|
var l = Math.ceil(this.context.measureText(o[h]).width);
|
|
a = this.game.math.snapToCeil(e, n), s ? this.context.fillText(o[h], a, i) : this.context.strokeText(o[h], a, i), e = a + l
|
|
}
|
|
}, H.Text.prototype.updateShadow = function(t) { this.context.shadowBlur = t ? (this.context.shadowOffsetX = this.style.shadowOffsetX, this.context.shadowOffsetY = this.style.shadowOffsetY, this.context.shadowColor = this.style.shadowColor, this.style.shadowBlur) : (this.context.shadowOffsetX = 0, this.context.shadowOffsetY = 0, this.context.shadowColor = 0) }, H.Text.prototype.measureLine = function(t) {
|
|
for (var e = 0, i = 0; i < t.length; i++) {
|
|
var s = t[i];
|
|
if (0 < this.fontWeights.length || 0 < this.fontStyles.length) {
|
|
var o = this.fontToComponents(this.context.font);
|
|
this.fontStyles[this._charCount] && (o.fontStyle = this.fontStyles[this._charCount]), this.fontWeights[this._charCount] && (o.fontWeight = this.fontWeights[this._charCount]), this.context.font = this.componentsToFont(o)
|
|
}
|
|
this.style.stroke && this.style.strokeThickness && (this.strokeColors[this._charCount] && (this.context.strokeStyle = this.strokeColors[this._charCount]), this.updateShadow(this.style.shadowStroke)), this.style.fill && (this.colors[this._charCount] && (this.context.fillStyle = this.colors[this._charCount]), this.updateShadow(this.style.shadowFill)), e += this.context.measureText(s).width, this._charCount++
|
|
}
|
|
return Math.ceil(e)
|
|
}, H.Text.prototype.updateLine = function(t, e, i) {
|
|
for (var s = 0; s < t.length; s++) {
|
|
var o = t[s];
|
|
if (0 < this.fontWeights.length || 0 < this.fontStyles.length) {
|
|
var n = this.fontToComponents(this.context.font);
|
|
this.fontStyles[this._charCount] && (n.fontStyle = this.fontStyles[this._charCount]), this.fontWeights[this._charCount] && (n.fontWeight = this.fontWeights[this._charCount]), this.context.font = this.componentsToFont(n)
|
|
}
|
|
this.style.stroke && this.style.strokeThickness && (this.strokeColors[this._charCount] && (this.context.strokeStyle = this.strokeColors[this._charCount]), this.updateShadow(this.style.shadowStroke), this.context.strokeText(o, e, i)), this.style.fill && (this.colors[this._charCount] && (this.context.fillStyle = this.colors[this._charCount]), this.updateShadow(this.style.shadowFill), this.context.fillText(o, e, i)), e += this.context.measureText(o).width, this._charCount++
|
|
}
|
|
}, H.Text.prototype.clearColors = function() { return this.colors = [], this.strokeColors = [], this.dirty = !0, this }, H.Text.prototype.clearFontValues = function() { return this.fontStyles = [], this.fontWeights = [], this.dirty = !0, this }, H.Text.prototype.addColor = function(t, e) { return this.colors[e] = t, this.dirty = !0, this }, H.Text.prototype.addStrokeColor = function(t, e) { return this.strokeColors[e] = t, this.dirty = !0, this }, H.Text.prototype.addFontStyle = function(t, e) { return this.fontStyles[e] = t, this.dirty = !0, this }, H.Text.prototype.addFontWeight = function(t, e) { return this.fontWeights[e] = t, this.dirty = !0, this }, H.Text.prototype.precalculateWordWrap = function(t) { return this.texture.baseTexture.resolution = this._res, this.context.font = this.style.font, this.runWordWrap(t).split(/(?:\r\n|\r|\n)/) }, H.Text.prototype.runWordWrap = function(t) { return this.useAdvancedWrap ? this.advancedWordWrap(t) : this.basicWordWrap(t) }, H.Text.prototype.advancedWordWrap = function(t) {
|
|
for (var e = this.context, i = this.style.wordWrapWidth, s = "", o = t.replace(/ +/gi, " ").split(/\r?\n/gi), n = o.length, a = 0; a < n; a++) {
|
|
var r = o[a],
|
|
h = "";
|
|
if (r = r.replace(/^ *|\s*$/gi, ""), e.measureText(r).width < i) s += r + "\n";
|
|
else {
|
|
for (var l = i, c = r.split(" "), p = 0; p < c.length; p++) {
|
|
var u = c[p],
|
|
d = u + " ",
|
|
y = e.measureText(d).width;
|
|
if (l < y) {
|
|
if (0 === p) {
|
|
for (var g = d; g.length && (g = g.slice(0, -1), !((y = e.measureText(g).width) <= l)););
|
|
if (!g.length) throw new Error("This text's wordWrapWidth setting is less than a single character!");
|
|
var f = u.substr(g.length);
|
|
c[p] = f, h += g
|
|
}
|
|
var m = c[p].length ? p : p + 1,
|
|
v = c.slice(m).join(" ").replace(/[ \n]*$/gi, "");
|
|
o[a + 1] = v + " " + (o[a + 1] || ""), n = o.length;
|
|
break
|
|
}
|
|
h += d, l -= y
|
|
}
|
|
s += h.replace(/[ \n]*$/gi, "") + "\n"
|
|
}
|
|
}
|
|
return s = s.replace(/[\s|\n]*$/gi, "")
|
|
}, H.Text.prototype.basicWordWrap = function(t) {
|
|
for (var e = "", i = t.split("\n"), s = 0; s < i.length; s++) {
|
|
for (var o = this.style.wordWrapWidth, n = i[s].split(" "), a = 0; a < n.length; a++) {
|
|
var r = this.context.measureText(n[a]).width,
|
|
h = r + this.context.measureText(" ").width;
|
|
o < h ? (0 < a && (e += "\n"), e += n[a] + " ", o = this.style.wordWrapWidth - r) : (o -= h, e += n[a] + " ")
|
|
}
|
|
s < i.length - 1 && (e += "\n")
|
|
}
|
|
return e
|
|
}, H.Text.prototype.updateFont = function(t) {
|
|
var e = this.componentsToFont(t);
|
|
this.style.font !== e && (this.style.font = e, this.dirty = !0, this.parent && this.updateTransform())
|
|
}, H.Text.prototype.fontToComponents = function(t) { var e = t.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/); if (e) { var i = e[5].trim(); return /^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(i) || /['",]/.exec(i) || (i = "'" + i + "'"), { font: t, fontStyle: e[1] || "normal", fontVariant: e[2] || "normal", fontWeight: e[3] || "normal", fontSize: e[4] || "medium", fontFamily: i } } return { font: t } }, H.Text.prototype.componentsToFont = function(t) { var e, i = []; return (e = t.fontStyle) && "normal" !== e && i.push(e), (e = t.fontVariant) && "normal" !== e && i.push(e), (e = t.fontWeight) && "normal" !== e && i.push(e), (e = t.fontSize) && "medium" !== e && i.push(e), (e = t.fontFamily) && i.push(e), i.length || i.push(t.font), i.join(" ") }, H.Text.prototype.setText = function(t, e) { return void 0 === e && (e = !1), this.text = t.toString() || "", e ? this.updateText() : this.dirty = !0, this }, H.Text.prototype.parseList = function(t) { if (!Array.isArray(t)) return this; for (var e = "", i = 0; i < t.length; i++) Array.isArray(t[i]) ? (e += t[i].join("\t"), i < t.length - 1 && (e += "\n")) : (e += t[i], i < t.length - 1 && (e += "\t")); return this.text = e, this.dirty = !0, this }, H.Text.prototype.setTextBounds = function(t, e, i, s) { return void 0 === t ? this.textBounds = null : (this.textBounds ? this.textBounds.setTo(t, e, i, s) : this.textBounds = new H.Rectangle(t, e, i, s), this.style.wordWrapWidth > i && (this.style.wordWrapWidth = i)), this.updateTexture(), this }, H.Text.prototype.updateTexture = function() {
|
|
var t = this.texture.baseTexture,
|
|
e = this.texture.crop,
|
|
i = this.texture.frame,
|
|
s = this.canvas.width,
|
|
o = this.canvas.height;
|
|
if (t.width = s, t.height = o, e.width = s, e.height = o, i.width = s, i.height = o, this.texture.width = s, this.texture.height = o, this._width = s, this._height = o, this.textBounds) {
|
|
var n = this.textBounds.x,
|
|
a = this.textBounds.y;
|
|
"right" === this.style.boundsAlignH ? n += this.textBounds.width - this.canvas.width / this.resolution : "center" === this.style.boundsAlignH && (n += this.textBounds.halfWidth - this.canvas.width / this.resolution / 2), "bottom" === this.style.boundsAlignV ? a += this.textBounds.height - this.canvas.height / this.resolution : "middle" === this.style.boundsAlignV && (a += this.textBounds.halfHeight - this.canvas.height / this.resolution / 2), this.pivot.x = -n, this.pivot.y = -a
|
|
}
|
|
this.renderable = 0 !== s && 0 !== o, this.texture.requiresReTint = !0, this.texture.baseTexture.dirty()
|
|
}, H.Text.prototype._renderWebGL = function(t) { this.dirty && (this.updateText(), this.dirty = !1), PIXI.Sprite.prototype._renderWebGL.call(this, t) }, H.Text.prototype._renderCanvas = function(t) { this.dirty && (this.updateText(), this.dirty = !1), PIXI.Sprite.prototype._renderCanvas.call(this, t) }, H.Text.prototype.determineFontProperties = function(t) {
|
|
var e = H.Text.fontPropertiesCache[t];
|
|
if (!e) {
|
|
e = {};
|
|
var i = H.Text.fontPropertiesCanvas,
|
|
s = H.Text.fontPropertiesContext;
|
|
s.font = t;
|
|
var o = Math.ceil(s.measureText("|MÉq").width),
|
|
n = Math.ceil(s.measureText("|MÉq").width),
|
|
a = 2 * n;
|
|
if (n = 1.4 * n | 0, i.width = o, i.height = a, s.fillStyle = "#f00", s.fillRect(0, 0, o, a), s.font = t, s.textBaseline = "alphabetic", s.fillStyle = "#000", s.fillText("|MÉq", 0, n), !s.getImageData(0, 0, o, a)) return e.ascent = n, e.descent = n + 6, e.fontSize = e.ascent + e.descent, H.Text.fontPropertiesCache[t] = e;
|
|
var r, h, l = s.getImageData(0, 0, o, a).data,
|
|
c = l.length,
|
|
p = 4 * o,
|
|
u = 0,
|
|
d = !1;
|
|
for (r = 0; r < n; r++) {
|
|
for (h = 0; h < p; h += 4)
|
|
if (255 !== l[u + h]) { d = !0; break }
|
|
if (d) break;
|
|
u += p
|
|
}
|
|
for (e.ascent = n - r, u = c - p, d = !1, r = a; n < r; r--) {
|
|
for (h = 0; h < p; h += 4)
|
|
if (255 !== l[u + h]) { d = !0; break }
|
|
if (d) break;
|
|
u -= p
|
|
}
|
|
e.descent = r - n, e.descent += 6, e.fontSize = e.ascent + e.descent, H.Text.fontPropertiesCache[t] = e
|
|
}
|
|
return e
|
|
}, H.Text.prototype.getBounds = function(t) { return this.dirty && (this.updateText(), this.dirty = !1), PIXI.Sprite.prototype.getBounds.call(this, t) }, Object.defineProperty(H.Text.prototype, "text", { get: function() { return this._text }, set: function(t) { t !== this._text && (this._text = t.toString() || "", this.dirty = !0, this.parent && this.updateTransform()) } }), Object.defineProperty(H.Text.prototype, "cssFont", { get: function() { return this.componentsToFont(this._fontComponents) }, set: function(t) { t = t || "bold 20pt Arial", this._fontComponents = this.fontToComponents(t), this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "font", { get: function() { return this._fontComponents.fontFamily }, set: function(t) { t = (t = t || "Arial").trim(), /^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t) || /['",]/.exec(t) || (t = "'" + t + "'"), this._fontComponents.fontFamily = t, this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "fontSize", { get: function() { var t = this._fontComponents.fontSize; return t && /(?:^0$|px$)/.exec(t) ? parseInt(t, 10) : t }, set: function(t) { "number" == typeof(t = t || "0") && (t += "px"), this._fontComponents.fontSize = t, this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "fontWeight", { get: function() { return this._fontComponents.fontWeight || "normal" }, set: function(t) { t = t || "normal", this._fontComponents.fontWeight = t, this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "fontStyle", { get: function() { return this._fontComponents.fontStyle || "normal" }, set: function(t) { t = t || "normal", this._fontComponents.fontStyle = t, this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "fontVariant", { get: function() { return this._fontComponents.fontVariant || "normal" }, set: function(t) { t = t || "normal", this._fontComponents.fontVariant = t, this.updateFont(this._fontComponents) } }), Object.defineProperty(H.Text.prototype, "fill", { get: function() { return this.style.fill }, set: function(t) { t !== this.style.fill && (this.style.fill = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "align", { get: function() { return this.style.align }, set: function(t) { t !== this.style.align && (this.style.align = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "resolution", { get: function() { return this._res }, set: function(t) { t !== this._res && (this._res = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "tabs", { get: function() { return this.style.tabs }, set: function(t) { t !== this.style.tabs && (this.style.tabs = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "boundsAlignH", { get: function() { return this.style.boundsAlignH }, set: function(t) { t !== this.style.boundsAlignH && (this.style.boundsAlignH = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "boundsAlignV", { get: function() { return this.style.boundsAlignV }, set: function(t) { t !== this.style.boundsAlignV && (this.style.boundsAlignV = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "stroke", { get: function() { return this.style.stroke }, set: function(t) { t !== this.style.stroke && (this.style.stroke = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "strokeThickness", { get: function() { return this.style.strokeThickness }, set: function(t) { t !== this.style.strokeThickness && (this.style.strokeThickness = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "wordWrap", { get: function() { return this.style.wordWrap }, set: function(t) { t !== this.style.wordWrap && (this.style.wordWrap = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "wordWrapWidth", { get: function() { return this.style.wordWrapWidth }, set: function(t) { t !== this.style.wordWrapWidth && (this.style.wordWrapWidth = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "lineSpacing", { get: function() { return this._lineSpacing }, set: function(t) { t !== this._lineSpacing && (this._lineSpacing = parseFloat(t), this.dirty = !0, this.parent && this.updateTransform()) } }), Object.defineProperty(H.Text.prototype, "shadowOffsetX", { get: function() { return this.style.shadowOffsetX }, set: function(t) { t !== this.style.shadowOffsetX && (this.style.shadowOffsetX = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "shadowOffsetY", { get: function() { return this.style.shadowOffsetY }, set: function(t) { t !== this.style.shadowOffsetY && (this.style.shadowOffsetY = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "shadowColor", { get: function() { return this.style.shadowColor }, set: function(t) { t !== this.style.shadowColor && (this.style.shadowColor = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "shadowBlur", { get: function() { return this.style.shadowBlur }, set: function(t) { t !== this.style.shadowBlur && (this.style.shadowBlur = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "shadowStroke", { get: function() { return this.style.shadowStroke }, set: function(t) { t !== this.style.shadowStroke && (this.style.shadowStroke = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "shadowFill", { get: function() { return this.style.shadowFill }, set: function(t) { t !== this.style.shadowFill && (this.style.shadowFill = t, this.dirty = !0) } }), Object.defineProperty(H.Text.prototype, "width", { get: function() { return this.dirty && (this.updateText(), this.dirty = !1), this.scale.x * this.texture.frame.width }, set: function(t) { this.scale.x = t / this.texture.frame.width, this._width = t } }), Object.defineProperty(H.Text.prototype, "height", { get: function() { return this.dirty && (this.updateText(), this.dirty = !1), this.scale.y * this.texture.frame.height }, set: function(t) { this.scale.y = t / this.texture.frame.height, this._height = t } }), H.Text.fontPropertiesCache = {}, H.Text.fontPropertiesCanvas = document.createElement("canvas"), H.Text.fontPropertiesContext = H.Text.fontPropertiesCanvas.getContext("2d"), H.BitmapText = function(t, e, i, s, o, n, a) { e = e || 0, i = i || 0, s = s || "", o = o || "", n = n || 32, a = a || "left", PIXI.DisplayObjectContainer.call(this), this.type = H.BITMAPTEXT, this.physicsType = H.SPRITE, this.textWidth = 0, this.textHeight = 0, this.anchor = new H.Point, this._prevAnchor = new H.Point, this._glyphs = [], this._maxWidth = 0, this._text = o.toString() || "", this._data = t.cache.getBitmapFont(s), this._font = s, this._fontSize = n, this._align = a, this._tint = 16777215, this.updateText(), this.dirty = !1, H.Component.Core.init.call(this, t, e, i, "", null) }, H.BitmapText.prototype = Object.create(PIXI.DisplayObjectContainer.prototype), H.BitmapText.prototype.constructor = H.BitmapText, H.Component.Core.install.call(H.BitmapText.prototype, ["Angle", "AutoCull", "Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan", "PhysicsBody", "Reset"]), H.BitmapText.prototype.preUpdatePhysics = H.Component.PhysicsBody.preUpdate, H.BitmapText.prototype.preUpdateLifeSpan = H.Component.LifeSpan.preUpdate, H.BitmapText.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.BitmapText.prototype.preUpdateCore = H.Component.Core.preUpdate, H.BitmapText.prototype.preUpdate = function() { return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.BitmapText.prototype.postUpdate = function() { H.Component.PhysicsBody.postUpdate.call(this), H.Component.FixedToCamera.postUpdate.call(this), this.body && this.body.type === H.Physics.ARCADE && (this.textWidth === this.body.sourceWidth && this.textHeight === this.body.sourceHeight || this.body.setSize(this.textWidth, this.textHeight)) }, H.BitmapText.prototype.setText = function(t) { this.text = t }, H.BitmapText.prototype.scanLine = function(t, e, i) {
|
|
for (var s = 0, o = 0, n = -1, a = 0, r = null, h = 0 < this._maxWidth ? this._maxWidth : null, l = [], c = 0; c < i.length; c++) {
|
|
var p = c === i.length - 1;
|
|
if (/(?:\r\n|\r|\n)/.test(i.charAt(c))) return { width: o, text: i.substr(0, c), end: p, chars: l };
|
|
var u, d = i.charCodeAt(c),
|
|
y = t.chars[d];
|
|
void 0 === y && (d = 32, y = t.chars[d]);
|
|
var g = r && y.kerning[r] ? y.kerning[r] : 0;
|
|
if (/(\s)/.test(i.charAt(c)) && (n = c, a = o), u = (g + y.texture.width + y.xOffset) * e, h && h <= o + u && -1 < n) return { width: a || o, text: i.substr(0, c - (c - n)), end: p, chars: l };
|
|
o += (y.xAdvance + g) * e, l.push(s + (y.xOffset + g) * e), s += (y.xAdvance + g) * e, r = d
|
|
}
|
|
return { width: o, text: i, end: p, chars: l }
|
|
}, H.BitmapText.prototype.cleanText = function(t, e) {
|
|
void 0 === e && (e = "");
|
|
var i = this._data.font;
|
|
if (!i) return "";
|
|
for (var s = t.replace(/\r\n|\n\r|\n|\r/g, "\n").split("\n"), o = 0; o < s.length; o++) {
|
|
for (var n = "", a = s[o], r = 0; r < a.length; r++) n = i.chars[a.charCodeAt(r)] ? n.concat(a[r]) : n.concat(e);
|
|
s[o] = n
|
|
}
|
|
return s.join("\n")
|
|
}, H.BitmapText.prototype.updateText = function() {
|
|
var t = this._data.font;
|
|
if (t) {
|
|
var e = this.text,
|
|
i = this._fontSize / t.size,
|
|
s = [],
|
|
o = 0;
|
|
this.textWidth = 0;
|
|
do {
|
|
(c = this.scanLine(t, i, e)).y = o, s.push(c), c.width > this.textWidth && (this.textWidth = c.width), o += t.lineHeight * i, e = e.substr(c.text.length + 1)
|
|
} while (!1 === c.end);
|
|
this.textHeight = o;
|
|
for (var n = 0, a = 0, r = this.textWidth * this.anchor.x, h = this.textHeight * this.anchor.y, l = 0; l < s.length; l++) {
|
|
var c = s[l];
|
|
"right" === this._align ? a = this.textWidth - c.width : "center" === this._align && (a = (this.textWidth - c.width) / 2);
|
|
for (var p = 0; p < c.text.length; p++) {
|
|
var u = c.text.charCodeAt(p),
|
|
d = t.chars[u];
|
|
void 0 === d && (u = 32, d = t.chars[u]);
|
|
var y = this._glyphs[n];
|
|
y ? y.texture = d.texture : ((y = new PIXI.Sprite(d.texture)).name = c.text[p], this._glyphs.push(y)), y.position.x = c.chars[p] + a - r, y.position.y = c.y + d.yOffset * i - h, y.scale.set(i), y.tint = this.tint, y.texture.requiresReTint = !0, y.parent || this.addChild(y), n++
|
|
}
|
|
}
|
|
for (l = n; l < this._glyphs.length; l++) this.removeChild(this._glyphs[l])
|
|
}
|
|
}, H.BitmapText.prototype.purgeGlyphs = function() { for (var t = this._glyphs.length, e = [], i = 0; i < this._glyphs.length; i++) this._glyphs[i].parent !== this ? this._glyphs[i].destroy() : e.push(this._glyphs[i]); return this._glyphs = [], this._glyphs = e, this.updateText(), t - e.length }, H.BitmapText.prototype.updateTransform = function() {!this.dirty && this.anchor.equals(this._prevAnchor) || (this.updateText(), this.dirty = !1, this._prevAnchor.copyFrom(this.anchor)), PIXI.DisplayObjectContainer.prototype.updateTransform.call(this) }, Object.defineProperty(H.BitmapText.prototype, "align", { get: function() { return this._align }, set: function(t) { t === this._align || "left" !== t && "center" !== t && "right" !== t || (this._align = t, this.updateText()) } }), Object.defineProperty(H.BitmapText.prototype, "tint", { get: function() { return this._tint }, set: function(t) { t !== this._tint && (this._tint = t, this.updateText()) } }), Object.defineProperty(H.BitmapText.prototype, "font", { get: function() { return this._font }, set: function(t) { t !== this._font && (this._font = t.trim(), this._data = this.game.cache.getBitmapFont(this._font), this.updateText()) } }), Object.defineProperty(H.BitmapText.prototype, "fontSize", {
|
|
get: function() { return this._fontSize },
|
|
set: function(t) {
|
|
(t = parseInt(t, 10)) !== this._fontSize && 0 < t && (this._fontSize = t, this.updateText())
|
|
}
|
|
}), Object.defineProperty(H.BitmapText.prototype, "text", { get: function() { return this._text }, set: function(t) { t !== this._text && (this._text = t.toString() || "", this.updateText()) } }), Object.defineProperty(H.BitmapText.prototype, "maxWidth", { get: function() { return this._maxWidth }, set: function(t) { t !== this._maxWidth && (this._maxWidth = t, this.updateText()) } }), Object.defineProperty(H.BitmapText.prototype, "smoothed", { get: function() { return !this._data.base.scaleMode }, set: function(t) { this._data.base.scaleMode = t ? 0 : 1 } }), H.RetroFont = function(t, e, i, s, o, n, a, r, h, l) {
|
|
if (!t.cache.checkImageKey(e)) return !1;
|
|
null == n && (n = t.cache.getImage(e).width / i), this.characterWidth = i, this.characterHeight = s, this.characterSpacingX = a || 0, this.characterSpacingY = r || 0, this.characterPerRow = n, this.offsetX = h || 0, this.offsetY = l || 0, this.align = "left", this.multiLine = !1, this.autoUpperCase = !0, this.customSpacingX = 0, this.customSpacingY = 0, this.fixedWidth = 0, this.fontSet = t.cache.getImage(e), this._text = "", this.grabData = [], this.frameData = new H.FrameData;
|
|
for (var c = this.offsetX, p = this.offsetY, u = 0, d = 0; d < o.length; d++) {
|
|
var y = this.frameData.addFrame(new H.Frame(d, c, p, this.characterWidth, this.characterHeight));
|
|
this.grabData[o.charCodeAt(d)] = y.index, ++u === this.characterPerRow ? (u = 0, c = this.offsetX, p += this.characterHeight + this.characterSpacingY) : c += this.characterWidth + this.characterSpacingX
|
|
}
|
|
t.cache.updateFrameData(e, this.frameData), this.stamp = new H.Image(t, 0, 0, e, 0), H.RenderTexture.call(this, t, 100, 100, "", H.scaleModes.NEAREST), this.type = H.RETROFONT
|
|
}, H.RetroFont.prototype = Object.create(H.RenderTexture.prototype), H.RetroFont.prototype.constructor = H.RetroFont, H.RetroFont.ALIGN_LEFT = "left", H.RetroFont.ALIGN_RIGHT = "right", H.RetroFont.ALIGN_CENTER = "center", H.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", H.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ", H.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ", H.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789", H.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789", H.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ", H.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39", H.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ", H.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!", H.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", H.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789", H.RetroFont.prototype.setFixedWidth = function(t, e) { void 0 === e && (e = "left"), this.fixedWidth = t, this.align = e }, H.RetroFont.prototype.setText = function(t, e, i, s, o, n) { this.multiLine = e || !1, this.customSpacingX = i || 0, this.customSpacingY = s || 0, this.align = o || "left", this.autoUpperCase = !n, 0 < t.length && (this.text = t) }, H.RetroFont.prototype.buildRetroFontText = function() {
|
|
var t = 0,
|
|
e = 0;
|
|
if (this.clear(), this.multiLine) {
|
|
var i = this._text.split("\n");
|
|
0 < this.fixedWidth ? this.resize(this.fixedWidth, i.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0) : this.resize(this.getLongestLine() * (this.characterWidth + this.customSpacingX), i.length * (this.characterHeight + this.customSpacingY) - this.customSpacingY, !0);
|
|
for (var s = 0; s < i.length; s++) t = 0, this.align === H.RetroFont.ALIGN_RIGHT ? t = this.width - i[s].length * (this.characterWidth + this.customSpacingX) : this.align === H.RetroFont.ALIGN_CENTER && (t = this.width / 2 - i[s].length * (this.characterWidth + this.customSpacingX) / 2, t += this.customSpacingX / 2), t < 0 && (t = 0), this.pasteLine(i[s], t, e, this.customSpacingX), e += this.characterHeight + this.customSpacingY
|
|
}
|
|
else 0 < this.fixedWidth ? this.resize(this.fixedWidth, this.characterHeight, !0) : this.resize(this._text.length * (this.characterWidth + this.customSpacingX), this.characterHeight, !0), t = 0, this.align === H.RetroFont.ALIGN_RIGHT ? t = this.width - this._text.length * (this.characterWidth + this.customSpacingX) : this.align === H.RetroFont.ALIGN_CENTER && (t = this.width / 2 - this._text.length * (this.characterWidth + this.customSpacingX) / 2, t += this.customSpacingX / 2), t < 0 && (t = 0), this.pasteLine(this._text, t, 0, this.customSpacingX);
|
|
this.requiresReTint = !0
|
|
}, H.RetroFont.prototype.pasteLine = function(t, e, i, s) {
|
|
for (var o = 0; o < t.length; o++)
|
|
if (" " === t.charAt(o)) e += this.characterWidth + s;
|
|
else if (0 <= this.grabData[t.charCodeAt(o)] && (this.stamp.frame = this.grabData[t.charCodeAt(o)], this.renderXY(this.stamp, e, i, !1), (e += this.characterWidth + s) > this.width)) break
|
|
}, H.RetroFont.prototype.getLongestLine = function() {
|
|
var t = 0;
|
|
if (0 < this._text.length)
|
|
for (var e = this._text.split("\n"), i = 0; i < e.length; i++) e[i].length > t && (t = e[i].length);
|
|
return t
|
|
}, H.RetroFont.prototype.removeUnsupportedCharacters = function(t) {
|
|
for (var e = "", i = 0; i < this._text.length; i++) {
|
|
var s = this._text[i],
|
|
o = s.charCodeAt(0);
|
|
(0 <= this.grabData[o] || !t && "\n" === s) && (e = e.concat(s))
|
|
}
|
|
return e
|
|
}, H.RetroFont.prototype.updateOffset = function(t, e) {
|
|
if (this.offsetX !== t || this.offsetY !== e) {
|
|
for (var i = t - this.offsetX, s = e - this.offsetY, o = this.game.cache.getFrameData(this.stamp.key).getFrames(), n = o.length; n--;) o[n].x += i, o[n].y += s;
|
|
this.buildRetroFontText()
|
|
}
|
|
}, Object.defineProperty(H.RetroFont.prototype, "text", {
|
|
get: function() { return this._text },
|
|
set: function(t) {
|
|
var e;
|
|
(e = this.autoUpperCase ? t.toUpperCase() : t) !== this._text && (this._text = e, this.removeUnsupportedCharacters(this.multiLine), this.buildRetroFontText())
|
|
}
|
|
}), Object.defineProperty(H.RetroFont.prototype, "smoothed", { get: function() { return this.stamp.smoothed }, set: function(t) { this.stamp.smoothed = t, this.buildRetroFontText() } }), H.Rope = function(t, e, i, s, o, n) { this.points = [], this.points = n, this._hasUpdateAnimation = !1, this._updateAnimationCallback = null, e = e || 0, i = i || 0, s = s || null, o = o || null, this.type = H.ROPE, PIXI.Rope.call(this, H.Cache.DEFAULT, this.points), H.Component.Core.init.call(this, t, e, i, s, o) }, H.Rope.prototype = Object.create(PIXI.Rope.prototype), H.Rope.prototype.constructor = H.Rope, H.Component.Core.install.call(H.Rope.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera", "InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "ScaleMinMax", "Smoothed"]), H.Rope.prototype.preUpdatePhysics = H.Component.PhysicsBody.preUpdate, H.Rope.prototype.preUpdateLifeSpan = H.Component.LifeSpan.preUpdate, H.Rope.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.Rope.prototype.preUpdateCore = H.Component.Core.preUpdate, H.Rope.prototype.preUpdate = function() { return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.Rope.prototype.update = function() { this._hasUpdateAnimation && this.updateAnimation.call(this) }, H.Rope.prototype.reset = function(t, e) { return H.Component.Reset.prototype.reset.call(this, t, e), this }, Object.defineProperty(H.Rope.prototype, "updateAnimation", { get: function() { return this._updateAnimation }, set: function(t) { this._updateAnimation = t && "function" == typeof t ? (this._hasUpdateAnimation = !0, t) : (this._hasUpdateAnimation = !1, null) } }), Object.defineProperty(H.Rope.prototype, "segments", { get: function() { for (var t, e, i, s, o, n, a, r, h = [], l = 0; l < this.points.length; l++) t = 4 * l, e = this.vertices[t] * this.scale.x, i = this.vertices[t + 1] * this.scale.y, s = this.vertices[t + 4] * this.scale.x, o = this.vertices[t + 3] * this.scale.y, n = H.Math.difference(e, s), a = H.Math.difference(i, o), e += this.world.x, i += this.world.y, r = new H.Rectangle(e, i, n, a), h.push(r); return h } }), H.TileSprite = function(t, e, i, s, o, n, a) {
|
|
e = e || 0, i = i || 0, s = s || 256, o = o || 256, n = n || null, a = a || null, this.type = H.TILESPRITE, this.physicsType = H.SPRITE, this._scroll = new H.Point;
|
|
var r = t.cache.getImage("__default", !0);
|
|
PIXI.TilingSprite.call(this, new PIXI.Texture(r.base), s, o), H.Component.Core.init.call(this, t, e, i, n, a)
|
|
}, H.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype), H.TileSprite.prototype.constructor = H.TileSprite, H.Component.Core.install.call(H.TileSprite.prototype, ["Angle", "Animation", "AutoCull", "Bounds", "BringToTop", "Destroy", "FixedToCamera", "Health", "InCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset", "Smoothed"]), H.TileSprite.prototype.preUpdatePhysics = H.Component.PhysicsBody.preUpdate, H.TileSprite.prototype.preUpdateLifeSpan = H.Component.LifeSpan.preUpdate, H.TileSprite.prototype.preUpdateInWorld = H.Component.InWorld.preUpdate, H.TileSprite.prototype.preUpdateCore = H.Component.Core.preUpdate, H.TileSprite.prototype.preUpdate = function() { return 0 !== this._scroll.x && (this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed), 0 !== this._scroll.y && (this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed), !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() && this.preUpdateInWorld()) && this.preUpdateCore() }, H.TileSprite.prototype.autoScroll = function(t, e) { this._scroll.set(t, e) }, H.TileSprite.prototype.stopScroll = function() { this._scroll.set(0, 0) }, H.TileSprite.prototype.destroy = function(t) { H.Component.Destroy.prototype.destroy.call(this, t), PIXI.TilingSprite.prototype.destroy.call(this) }, H.TileSprite.prototype.reset = function(t, e) { return H.Component.Reset.prototype.reset.call(this, t, e), this.tilePosition.x = 0, this.tilePosition.y = 0, this }, H.Device = function() { this.deviceReadyAt = 0, this.initialized = !1, this.desktop = !1, this.iOS = !1, this.iOSVersion = 0, this.cocoonJS = !1, this.cocoonJSApp = !1, this.wechatMinigame = !1, this.cordova = !1, this.node = !1, this.nodeWebkit = !1, this.electron = !1, this.ejecta = !1, this.crosswalk = !1, this.android = !1, this.chromeOS = !1, this.linux = !1, this.macOS = !1, this.windows = !1, this.windowsPhone = !1, this.canvas = !1, this.canvasBitBltShift = null, this.webGL = !1, this.file = !1, this.fileSystem = !1, this.localStorage = !1, this.worker = !1, this.css3D = !1, this.pointerLock = !1, this.typedArray = !1, this.vibration = !1, this.getUserMedia = !0, this.quirksMode = !1, this.touch = !1, this.mspointer = !1, this.wheelEvent = null, this.arora = !1, this.chrome = !1, this.chromeVersion = 0, this.epiphany = !1, this.firefox = !1, this.firefoxVersion = 0, this.ie = !1, this.ieVersion = 0, this.trident = !1, this.tridentVersion = 0, this.edge = !1, this.mobileSafari = !1, this.midori = !1, this.opera = !1, this.safari = !1, this.safariVersion = 0, this.webApp = !1, this.silk = !1, this.audioData = !1, this.webAudio = !1, this.ogg = !1, this.opus = !1, this.mp3 = !1, this.wav = !1, this.m4a = !1, this.webm = !1, this.dolby = !1, this.oggVideo = !1, this.h264Video = !1, this.mp4Video = !1, this.webmVideo = !1, this.vp9Video = !1, this.hlsVideo = !1, this.iPhone = !1, this.iPhone4 = !1, this.iPad = !1, this.pixelRatio = 0, this.littleEndian = !1, this.LITTLE_ENDIAN = !1, this.support32bit = !1, this.fullscreen = !1, this.requestFullscreen = "", this.cancelFullscreen = "", this.fullscreenKeyboard = !1 }, H.Device = new H.Device, H.Device.onInitialized = new H.Signal, H.Device.whenReady = function(t, e, i) {
|
|
var s = this._readyCheck;
|
|
if (this.deviceReadyAt || !s) t.call(e, this);
|
|
else if (s._monitor || i) s._queue = s._queue || [], s._queue.push([t, e]);
|
|
else {
|
|
s._monitor = s.bind(this), s._queue = s._queue || [], s._queue.push([t, e]);
|
|
var o = void 0 !== window.cordova,
|
|
n = navigator.isCocoonJS;
|
|
"complete" === document.readyState || "interactive" === document.readyState ? window.setTimeout(s._monitor, 0) : o && !n ? document.addEventListener("deviceready", s._monitor, !1) : (document.addEventListener("DOMContentLoaded", s._monitor, !1), window.addEventListener("load", s._monitor, !1))
|
|
}
|
|
}, H.Device._readyCheck = function() {
|
|
var t = this._readyCheck;
|
|
if (document.body) {
|
|
if (!this.deviceReadyAt) {
|
|
var e;
|
|
for (this.deviceReadyAt = Date.now(), document.removeEventListener("deviceready", t._monitor), document.removeEventListener("DOMContentLoaded", t._monitor), window.removeEventListener("load", t._monitor), this._initialize(), this.initialized = !0, this.onInitialized.dispatch(this); e = t._queue.shift();) {
|
|
var i = e[0],
|
|
s = e[1];
|
|
i.call(s, this)
|
|
}
|
|
this._readyCheck = null, this._initialize = null, this.onInitialized = null
|
|
}
|
|
}
|
|
else window.setTimeout(t._monitor, 20)
|
|
}, H.Device._initialize = function() {
|
|
var t, e, i, o = this;
|
|
! function() {
|
|
var t = navigator.userAgent;
|
|
/Playstation Vita/.test(t) ? o.vita = !0 : /Kindle/.test(t) || /\bKF[A-Z][A-Z]+/.test(t) || /Silk.*Mobile Safari/.test(t) ? o.kindle = !0 : /Android/.test(t) ? o.android = !0 : /CrOS/.test(t) ? o.chromeOS = !0 : /iP[ao]d|iPhone/i.test(t) ? (o.iOS = !0, navigator.appVersion.match(/OS (\d+)/), o.iOSVersion = parseInt(RegExp.$1, 10)) : /Linux/.test(t) ? o.linux = !0 : /Mac OS/.test(t) ? o.macOS = !0 : /Windows/.test(t) && (o.windows = !0), (/Windows Phone/i.test(t) || /IEMobile/i.test(t)) && (o.android = !1, o.iOS = !1, o.macOS = !1, o.windows = !0, o.windowsPhone = !0);
|
|
var e = /Silk/.test(t);
|
|
(o.windows || o.macOS || o.linux && !e || o.chromeOS) && (o.desktop = !0), (o.windowsPhone || /Windows NT/i.test(t) && /Touch/i.test(t)) && (o.desktop = !1)
|
|
}(),
|
|
function() {
|
|
var t = navigator.userAgent;
|
|
if (/Arora/.test(t) ? o.arora = !0 : /Edge\/\d+/.test(t) ? o.edge = !0 : /Chrome\/(\d+)/.test(t) && !o.windowsPhone ? (o.chrome = !0, o.chromeVersion = parseInt(RegExp.$1, 10)) : /Epiphany/.test(t) ? o.epiphany = !0 : /Firefox\D+(\d+)/.test(t) ? (o.firefox = !0, o.firefoxVersion = parseInt(RegExp.$1, 10)) : /AppleWebKit/.test(t) && o.iOS ? o.mobileSafari = !0 : /MSIE (\d+\.\d+);/.test(t) ? (o.ie = !0, o.ieVersion = parseInt(RegExp.$1, 10)) : /Midori/.test(t) ? o.midori = !0 : /Opera/.test(t) ? o.opera = !0 : /Safari\/(\d+)/.test(t) && !o.windowsPhone ? (o.safari = !0, /Version\/(\d+)\./.test(t) && (o.safariVersion = parseInt(RegExp.$1, 10))) : /Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(t) && (o.ie = !0, o.trident = !0, o.tridentVersion = parseInt(RegExp.$1, 10), o.ieVersion = parseInt(RegExp.$3, 10)), /Silk/.test(t) && (o.silk = !0), navigator.standalone && (o.webApp = !0), void 0 !== window.cordova && (o.cordova = !0), "undefined" != typeof process && "undefined" != typeof require && (o.node = !0), o.node && "object" == typeof process.versions && (o.nodeWebkit = !!process.versions["node-webkit"], o.electron = !!process.versions.electron), navigator.isCocoonJS && (o.cocoonJS = !0), void 0 !== window.wx && (o.wechatMinigame = !0), o.cocoonJS) try { o.cocoonJSApp = "undefined" != typeof CocoonJS }
|
|
catch (t) { o.cocoonJSApp = !1 } void 0 !== window.ejecta && (o.ejecta = !0), /Crosswalk/.test(t) && (o.crosswalk = !0)
|
|
}(),
|
|
function() {
|
|
o.audioData = !!window.Audio, o.webAudio = !(!window.AudioContext && !window.webkitAudioContext);
|
|
var t = document.createElement("audio");
|
|
try {
|
|
if (t.canPlayType && (t.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, "") && (o.ogg = !0), (t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, "") || t.canPlayType("audio/opus;").replace(/^no$/, "")) && (o.opus = !0), t.canPlayType("audio/mpeg;").replace(/^no$/, "") && (o.mp3 = !0), t.canPlayType('audio/wav; codecs="1"').replace(/^no$/, "") && (o.wav = !0), (t.canPlayType("audio/x-m4a;") || t.canPlayType("audio/aac;").replace(/^no$/, "")) && (o.m4a = !0), t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "") && (o.webm = !0), "" !== t.canPlayType('audio/mp4;codecs="ec-3"')))
|
|
if (o.edge) o.dolby = !0;
|
|
else if (o.safari && 9 <= o.safariVersion && /Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)) {
|
|
var e = parseInt(RegExp.$1, 10),
|
|
i = parseInt(RegExp.$2, 10);
|
|
(10 === e && 11 <= i || 10 < e) && (o.dolby = !0)
|
|
}
|
|
}
|
|
catch (t) {}
|
|
}(),
|
|
function() { var t = document.createElement("video"); try { t.canPlayType && (t.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, "") && (o.oggVideo = !0), t.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, "") && (o.h264Video = !0, o.mp4Video = !0), t.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, "") && (o.webmVideo = !0), t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, "") && (o.vp9Video = !0), t.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, "") && (o.hlsVideo = !0)) } catch (t) {} }(),
|
|
function() {
|
|
var t, e = document.createElement("p"),
|
|
i = { webkitTransform: "-webkit-transform", OTransform: "-o-transform", msTransform: "-ms-transform", MozTransform: "-moz-transform", transform: "transform" };
|
|
for (var s in document.body.insertBefore(e, null), i) void 0 !== e.style[s] && (e.style[s] = "translate3d(1px,1px,1px)", t = window.getComputedStyle(e).getPropertyValue(i[s]));
|
|
document.body.removeChild(e), o.css3D = void 0 !== t && 0 < t.length && "none" !== t
|
|
}(), o.pixelRatio = window.devicePixelRatio || 1, o.iPhone = -1 !== navigator.userAgent.toLowerCase().indexOf("iphone"), o.iPhone4 = 2 === o.pixelRatio && o.iPhone, o.iPad = -1 !== navigator.userAgent.toLowerCase().indexOf("ipad"), "undefined" != typeof Int8Array ? o.typedArray = !0 : o.typedArray = !1, "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8Array && "undefined" != typeof Uint32Array && (o.littleEndian = (t = new ArrayBuffer(4), e = new Uint8Array(t), i = new Uint32Array(t), e[0] = 161, e[1] = 178, e[2] = 195, e[3] = 212, 3569595041 === i[0] || 2712847316 !== i[0] && null), o.LITTLE_ENDIAN = o.littleEndian), o.support32bit = "undefined" != typeof ArrayBuffer && "undefined" != typeof Uint8ClampedArray && "undefined" != typeof Int32Array && null !== o.littleEndian && function() { if (void 0 === Uint8ClampedArray) return !1; var t = PIXI.CanvasPool.create(this, 1, 1).getContext("2d"); if (!t) return !1; var e = t.createImageData(1, 1); return PIXI.CanvasPool.remove(this), e.data instanceof Uint8ClampedArray }(), navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate, navigator.vibrate && (o.vibration = !0),
|
|
function() {
|
|
o.canvas = !!window.CanvasRenderingContext2D || o.cocoonJS;
|
|
try { o.localStorage = !!localStorage.getItem }
|
|
catch (t) { o.localStorage = !1 } o.file = !!(window.File && window.FileReader && window.FileList && window.Blob), o.fileSystem = !!window.requestFileSystem;
|
|
var e = { stencil: !0 };
|
|
o.webGL = function() { try { var t = document.createElement("canvas"); return t.screencanvas = !1, !!window.WebGLRenderingContext && (t.getContext("webgl", e) || t.getContext("experimental-webgl", e)) } catch (t) { return !1 } }(), o.webGL = !!o.webGL, o.worker = !!window.Worker, o.pointerLock = "pointerLockElement" in document || "mozPointerLockElement" in document || "webkitPointerLockElement" in document, o.quirksMode = "CSS1Compat" !== document.compatMode, navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia, window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL, o.getUserMedia = o.getUserMedia && !!navigator.getUserMedia && !!window.URL, o.firefox && o.firefoxVersion < 21 && (o.getUserMedia = !1), !o.iOS && (o.ie || o.firefox || o.chrome) && (o.canvasBitBltShift = !0), (o.safari || o.mobileSafari) && (o.canvasBitBltShift = !1)
|
|
}(),
|
|
function() {
|
|
for (var t = ["requestFullscreen", "requestFullScreen", "webkitRequestFullscreen", "webkitRequestFullScreen", "msRequestFullscreen", "msRequestFullScreen", "mozRequestFullScreen", "mozRequestFullscreen"], e = document.createElement("div"), i = 0; i < t.length; i++)
|
|
if (e[t[i]]) { o.fullscreen = !0, o.requestFullscreen = t[i]; break }
|
|
var s = ["cancelFullScreen", "exitFullscreen", "webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen", "msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
|
|
if (o.fullscreen)
|
|
for (i = 0; i < s.length; i++)
|
|
if (document[s[i]]) { o.cancelFullscreen = s[i]; break }
|
|
window.Element && Element.ALLOW_KEYBOARD_INPUT && (o.fullscreenKeyboard = !0)
|
|
}(), ("ontouchstart" in document.documentElement || window.navigator.maxTouchPoints && 1 <= window.navigator.maxTouchPoints) && (o.touch = !0), (window.PointerEvent || window.MSPointerEvent || window.navigator.msPointerEnabled || window.navigator.pointerEnabled) && (o.mspointer = !0), o.cocoonJS || ("onwheel" in window || o.ie && "WheelEvent" in window ? o.wheelEvent = "wheel" : "onmousewheel" in window ? o.wheelEvent = "mousewheel" : o.firefox && "MouseScrollEvent" in window && (o.wheelEvent = "DOMMouseScroll"))
|
|
}, H.Device.canPlayAudio = function(t) { return !("mp3" !== t || !this.mp3) || (!("ogg" !== t || !this.ogg && !this.opus) || (!("m4a" !== t || !this.m4a) || (!("opus" !== t || !this.opus) || (!("wav" !== t || !this.wav) || (!("webm" !== t || !this.webm) || !("mp4" !== t || !this.dolby)))))) }, H.Device.canPlayVideo = function(t) { return !("webm" !== t || !this.webmVideo && !this.vp9Video) || (!("mp4" !== t || !this.mp4Video && !this.h264Video) || (!("ogg" !== t && "ogv" !== t || !this.oggVideo) || !("mpeg" !== t || !this.hlsVideo))) }, H.Device.isConsoleOpen = function() { return !(!window.console || !window.console.firebug) || !(!window.console || (console.clear, !console.profiles)) && 0 < console.profiles.length }, H.Device.isAndroidStockBrowser = function() { var t = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/); return t && t[1] < 537 }, H.Canvas = { create: function(t, e, i, s, o) { e = e || 256, i = i || 256; var n = o ? document.createElement("canvas") : PIXI.CanvasPool.create(t, e, i); return "string" == typeof s && "" !== s && (n.id = s), n.width = e, n.height = i, n.style.display = "block", n }, setBackgroundColor: function(t, e) { return e = e || "rgb(0,0,0)", t.style.backgroundColor = e, t }, setTouchAction: function(t, e) { return e = e || "none", t.style.msTouchAction = e, t.style["ms-touch-action"] = e, t.style["touch-action"] = e, t }, setUserSelect: function(t, e) { return e = e || "none", t.style["-webkit-touch-callout"] = e, t.style["-webkit-user-select"] = e, t.style["-khtml-user-select"] = e, t.style["-moz-user-select"] = e, t.style["-ms-user-select"] = e, t.style["user-select"] = e, t.style["-webkit-tap-highlight-color"] = "rgba(0, 0, 0, 0)", t }, addToDOM: function(t, e, i) { var s; return void 0 === i && (i = !0), e && ("string" == typeof e ? s = document.getElementById(e) : "object" == typeof e && 1 === e.nodeType && (s = e)), s || (s = document.body), i && s.style && (s.style.overflow = "hidden"), s.appendChild(t), t }, removeFromDOM: function(t) { t.parentNode && t.parentNode.removeChild(t) }, setTransform: function(t, e, i, s, o, n, a) { return t.setTransform(s, n, a, o, e, i), t }, setSmoothingEnabled: function(t, e) { var i = H.Canvas.getSmoothingPrefix(t); return i && (t[i] = e), t }, getSmoothingPrefix: function(t) { var e = ["i", "webkitI", "msI", "mozI", "oI"]; for (var i in e) { var s = e[i] + "mageSmoothingEnabled"; if (s in t) return s } return null }, getSmoothingEnabled: function(t) { var e = H.Canvas.getSmoothingPrefix(t); if (e) return t[e] }, setImageRenderingCrisp: function(t) { for (var e = ["optimizeSpeed", "crisp-edges", "-moz-crisp-edges", "-webkit-optimize-contrast", "optimize-contrast", "pixelated"], i = 0; i < e.length; i++) t.style["image-rendering"] = e[i]; return t.style.msInterpolationMode = "nearest-neighbor", t }, setImageRenderingBicubic: function(t) { return t.style["image-rendering"] = "auto", t.style.msInterpolationMode = "bicubic", t } }, H.RequestAnimationFrame = function(t, e) {
|
|
void 0 === e && (e = !1), this.game = t, this.isRunning = !1, this.forceSetTimeOut = e;
|
|
for (var i = ["ms", "moz", "webkit", "o"], s = 0; s < i.length && !window.requestAnimationFrame; s++) window.requestAnimationFrame = window[i[s] + "RequestAnimationFrame"], window.cancelAnimationFrame = window[i[s] + "CancelAnimationFrame"];
|
|
this._isSetTimeOut = !1, this._onLoop = null, this._timeOutID = null
|
|
}, H.RequestAnimationFrame.prototype = { start: function() { this.isRunning = !0; var e = this;!window.requestAnimationFrame || this.forceSetTimeOut ? (this._isSetTimeOut = !0, this._onLoop = function() { return e.updateSetTimeout() }, this._timeOutID = window.setTimeout(this._onLoop, 0)) : (this._isSetTimeOut = !1, this._onLoop = function(t) { return e.updateRAF(t) }, this._timeOutID = window.requestAnimationFrame(this._onLoop)) }, updateRAF: function(t) { this.isRunning && (this.game.update(Math.floor(t)), this._timeOutID = window.requestAnimationFrame(this._onLoop)) }, updateSetTimeout: function() { this.isRunning && (this.game.update(Date.now()), this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall)) }, stop: function() { this._isSetTimeOut ? clearTimeout(this._timeOutID) : window.cancelAnimationFrame(this._timeOutID), this.isRunning = !1 }, isSetTimeOut: function() { return this._isSetTimeOut }, isRAF: function() { return !1 === this._isSetTimeOut } }, H.RequestAnimationFrame.prototype.constructor = H.RequestAnimationFrame, H.Math = {
|
|
PI2: 2 * Math.PI,
|
|
between: function(t, e) { return Math.floor(Math.random() * (e - t + 1) + t) },
|
|
fuzzyEqual: function(t, e, i) { return void 0 === i && (i = 1e-4), Math.abs(t - e) < i },
|
|
fuzzyLessThan: function(t, e, i) { return void 0 === i && (i = 1e-4), t < e + i },
|
|
fuzzyGreaterThan: function(t, e, i) { return void 0 === i && (i = 1e-4), e - i < t },
|
|
fuzzyCeil: function(t, e) { return void 0 === e && (e = 1e-4), Math.ceil(t - e) },
|
|
fuzzyFloor: function(t, e) { return void 0 === e && (e = 1e-4), Math.floor(t + e) },
|
|
average: function() { for (var t = 0, e = arguments.length, i = 0; i < e; i++) t += +arguments[i]; return t / e },
|
|
shear: function(t) { return t % 1 },
|
|
snapTo: function(t, e, i) { return void 0 === i && (i = 0), 0 === e ? t : (t -= i, i + (t = e * Math.round(t / e))) },
|
|
snapToFloor: function(t, e, i) { return void 0 === i && (i = 0), 0 === e ? t : (t -= i, i + (t = e * Math.floor(t / e))) },
|
|
snapToCeil: function(t, e, i) { return void 0 === i && (i = 0), 0 === e ? t : (t -= i, i + (t = e * Math.ceil(t / e))) },
|
|
roundTo: function(t, e, i) { void 0 === e && (e = 0), void 0 === i && (i = 10); var s = Math.pow(i, -e); return Math.round(t * s) / s },
|
|
floorTo: function(t, e, i) { void 0 === e && (e = 0), void 0 === i && (i = 10); var s = Math.pow(i, -e); return Math.floor(t * s) / s },
|
|
ceilTo: function(t, e, i) { void 0 === e && (e = 0), void 0 === i && (i = 10); var s = Math.pow(i, -e); return Math.ceil(t * s) / s },
|
|
rotateToAngle: function(t, e, i) { return void 0 === i && (i = .05), t === e || (Math.abs(e - t) <= i || Math.abs(e - t) >= H.Math.PI2 - i ? t = e : (Math.abs(e - t) > Math.PI && (e < t ? e += H.Math.PI2 : e -= H.Math.PI2), t < e ? t += i : e < t && (t -= i))), t },
|
|
getShortestAngle: function(t, e) { var i = e - t; return 0 === i ? 0 : i - 360 * Math.floor((i - -180) / 360) },
|
|
angleBetween: function(t, e, i, s) { return Math.atan2(s - e, i - t) },
|
|
angleBetweenY: function(t, e, i, s) { return Math.atan2(i - t, s - e) },
|
|
angleBetweenPoints: function(t, e) { return Math.atan2(e.y - t.y, e.x - t.x) },
|
|
angleBetweenPointsY: function(t, e) { return Math.atan2(e.x - t.x, e.y - t.y) },
|
|
reverseAngle: function(t) { return this.normalizeAngle(t + Math.PI, !0) },
|
|
normalizeAngle: function(t) { return 0 <= (t %= 2 * Math.PI) ? t : t + 2 * Math.PI },
|
|
maxAdd: function(t, e, i) { return Math.min(t + e, i) },
|
|
minSub: function(t, e, i) { return Math.max(t - e, i) },
|
|
wrap: function(t, e, i) { var s = i - e; if (s <= 0) return 0; var o = (t - e) % s; return o < 0 && (o += s), o + e },
|
|
wrapValue: function(t, e, i) { return ((t = Math.abs(t)) + (e = Math.abs(e))) % (i = Math.abs(i)) },
|
|
isOdd: function(t) { return !!(1 & t) },
|
|
isEven: function(t) { return !(1 & t) },
|
|
min: function() {
|
|
if (1 === arguments.length && "object" == typeof arguments[0]) var t = arguments[0];
|
|
else t = arguments;
|
|
for (var e = 1, i = 0, s = t.length; e < s; e++) t[e] < t[i] && (i = e);
|
|
return t[i]
|
|
},
|
|
max: function() {
|
|
if (1 === arguments.length && "object" == typeof arguments[0]) var t = arguments[0];
|
|
else t = arguments;
|
|
for (var e = 1, i = 0, s = t.length; e < s; e++) t[e] > t[i] && (i = e);
|
|
return t[i]
|
|
},
|
|
minProperty: function(t) {
|
|
if (2 === arguments.length && "object" == typeof arguments[1]) var e = arguments[1];
|
|
else e = arguments.slice(1);
|
|
for (var i = 1, s = 0, o = e.length; i < o; i++) e[i][t] < e[s][t] && (s = i);
|
|
return e[s][t]
|
|
},
|
|
maxProperty: function(t) {
|
|
if (2 === arguments.length && "object" == typeof arguments[1]) var e = arguments[1];
|
|
else e = arguments.slice(1);
|
|
for (var i = 1, s = 0, o = e.length; i < o; i++) e[i][t] > e[s][t] && (s = i);
|
|
return e[s][t]
|
|
},
|
|
wrapAngle: function(t, e) { return e ? this.wrap(t, -Math.PI, Math.PI) : this.wrap(t, -180, 180) },
|
|
linearInterpolation: function(t, e) {
|
|
var i = t.length - 1,
|
|
s = i * e,
|
|
o = Math.floor(s);
|
|
return e < 0 ? this.linear(t[0], t[1], s) : 1 < e ? this.linear(t[i], t[i - 1], i - s) : this.linear(t[o], t[i < o + 1 ? i : o + 1], s - o)
|
|
},
|
|
bezierInterpolation: function(t, e) { for (var i = 0, s = t.length - 1, o = 0; o <= s; o++) i += Math.pow(1 - e, s - o) * Math.pow(e, o) * t[o] * this.bernstein(s, o); return i },
|
|
catmullRomInterpolation: function(t, e) {
|
|
var i = t.length - 1,
|
|
s = i * e,
|
|
o = Math.floor(s);
|
|
return t[0] === t[i] ? (e < 0 && (o = Math.floor(s = i * (1 + e))), this.catmullRom(t[(o - 1 + i) % i], t[o], t[(o + 1) % i], t[(o + 2) % i], s - o)) : e < 0 ? t[0] - (this.catmullRom(t[0], t[0], t[1], t[1], -s) - t[0]) : 1 < e ? t[i] - (this.catmullRom(t[i], t[i], t[i - 1], t[i - 1], s - i) - t[i]) : this.catmullRom(t[o ? o - 1 : 0], t[o], t[i < o + 1 ? i : o + 1], t[i < o + 2 ? i : o + 2], s - o)
|
|
},
|
|
linear: function(t, e, i) { return (e - t) * i + t },
|
|
bernstein: function(t, e) { return this.factorial(t) / this.factorial(e) / this.factorial(t - e) },
|
|
factorial: function(t) { if (0 === t) return 1; for (var e = t; --t;) e *= t; return e },
|
|
catmullRom: function(t, e, i, s, o) {
|
|
var n = .5 * (i - t),
|
|
a = .5 * (s - e),
|
|
r = o * o;
|
|
return (2 * e - 2 * i + n + a) * (o * r) + (-3 * e + 3 * i - 2 * n - a) * r + n * o + e
|
|
},
|
|
difference: function(t, e) { return Math.abs(t - e) },
|
|
roundAwayFromZero: function(t) { return 0 < t ? Math.ceil(t) : Math.floor(t) },
|
|
sinCosGenerator: function(t, e, i, s) { void 0 === e && (e = 1), void 0 === i && (i = 1), void 0 === s && (s = 1); for (var o = e, n = i, a = s * Math.PI / t, r = [], h = [], l = 0; l < t; l++) o += (n -= o * a) * a, r[l] = n, h[l] = o; return { sin: h, cos: r, length: t } },
|
|
distance: function(t, e, i, s) {
|
|
var o = t - i,
|
|
n = e - s;
|
|
return Math.sqrt(o * o + n * n)
|
|
},
|
|
distanceSq: function(t, e, i, s) {
|
|
var o = t - i,
|
|
n = e - s;
|
|
return o * o + n * n
|
|
},
|
|
distancePow: function(t, e, i, s, o) { return void 0 === o && (o = 2), Math.sqrt(Math.pow(i - t, o) + Math.pow(s - e, o)) },
|
|
clamp: function(t, e, i) { return t < e ? e : i < t ? i : t },
|
|
clampBottom: function(t, e) { return t < e ? e : t },
|
|
within: function(t, e, i) { return Math.abs(t - e) <= i },
|
|
mapLinear: function(t, e, i, s, o) { return s + (t - e) * (o - s) / (i - e) },
|
|
smoothstep: function(t, e, i) { return (t = Math.max(0, Math.min(1, (t - e) / (i - e)))) * t * (3 - 2 * t) },
|
|
smootherstep: function(t, e, i) { return (t = Math.max(0, Math.min(1, (t - e) / (i - e)))) * t * t * (t * (6 * t - 15) + 10) },
|
|
sign: function(t) { return t < 0 ? -1 : 0 < t ? 1 : 0 },
|
|
percent: function(t, e, i) { return void 0 === i && (i = 0), e < t || e < i ? 1 : t < i || t < i ? 0 : (t - i) / e }
|
|
};
|
|
var a = Math.PI / 180,
|
|
r = 180 / Math.PI;
|
|
return H.Math.degToRad = function(t) { return t * a }, H.Math.radToDeg = function(t) { return t * r }, H.RandomDataGenerator = function(t) { void 0 === t && (t = []), this.c = 1, this.s0 = 0, this.s1 = 0, this.s2 = 0, "string" == typeof t ? this.state(t) : this.sow(t) }, H.RandomDataGenerator.prototype = {
|
|
rnd: function() { var t = 2091639 * this.s0 + 2.3283064365386963e-10 * this.c; return this.c = 0 | t, this.s0 = this.s1, this.s1 = this.s2, this.s2 = t - this.c, this.s2 },
|
|
sow: function(t) {
|
|
if (this.s0 = this.hash(" "), this.s1 = this.hash(this.s0), this.s2 = this.hash(this.s1), this.c = 1, t)
|
|
for (var e = 0; e < t.length && null != t[e]; e++) {
|
|
var i = t[e];
|
|
this.s0 -= this.hash(i), this.s0 += ~~(this.s0 < 0), this.s1 -= this.hash(i), this.s1 += ~~(this.s1 < 0), this.s2 -= this.hash(i), this.s2 += ~~(this.s2 < 0)
|
|
}
|
|
},
|
|
hash: function(t) { var e, i, s; for (s = 4022871197, t = t.toString(), i = 0; i < t.length; i++) e = .02519603282416938 * (s += t.charCodeAt(i)), e -= s = e >>> 0, s = (e *= s) >>> 0, s += 4294967296 * (e -= s); return 2.3283064365386963e-10 * (s >>> 0) },
|
|
integer: function() { return 4294967296 * this.rnd.apply(this) },
|
|
frac: function() { return this.rnd.apply(this) + 11102230246251565e-32 * (2097152 * this.rnd.apply(this) | 0) },
|
|
real: function() { return this.integer() + this.frac() },
|
|
integerInRange: function(t, e) { return Math.floor(this.realInRange(0, e - t + 1) + t) },
|
|
between: function(t, e) { return this.integerInRange(t, e) },
|
|
realInRange: function(t, e) { return this.frac() * (e - t) + t },
|
|
normal: function() { return 1 - 2 * this.frac() },
|
|
uuid: function() {
|
|
var t = "",
|
|
e = "";
|
|
for (e = t = ""; t++ < 36; e += ~t % 5 | 3 * t & 4 ? (15 ^ t ? 8 ^ this.frac() * (20 ^ t ? 16 : 4) : 4).toString(16) : "-");
|
|
return e
|
|
},
|
|
pick: function(t) { return t[this.integerInRange(0, t.length - 1)] },
|
|
sign: function() { return this.pick([-1, 1]) },
|
|
weightedPick: function(t) { return t[~~(Math.pow(this.frac(), 2) * (t.length - 1) + .5)] },
|
|
timestamp: function(t, e) { return this.realInRange(t || 9466848e5, e || 1577862e6) },
|
|
angle: function() { return this.integerInRange(-180, 180) },
|
|
state: function(t) { return "string" == typeof t && t.match(/^!rnd/) && (t = t.split(","), this.c = parseFloat(t[1]), this.s0 = parseFloat(t[2]), this.s1 = parseFloat(t[3]), this.s2 = parseFloat(t[4])), ["!rnd", this.c, this.s0, this.s1, this.s2].join(",") }
|
|
}, H.RandomDataGenerator.prototype.constructor = H.RandomDataGenerator, H.QuadTree = function(t, e, i, s, o, n, a) { this.maxObjects = 10, this.maxLevels = 4, this.level = 0, this.bounds = {}, this.objects = [], this.nodes = [], this._empty = [], this.reset(t, e, i, s, o, n, a) }, H.QuadTree.prototype = {
|
|
reset: function(t, e, i, s, o, n, a) { this.maxObjects = o || 10, this.maxLevels = n || 4, this.level = a || 0, this.bounds = { x: Math.round(t), y: Math.round(e), width: i, height: s, subWidth: Math.floor(i / 2), subHeight: Math.floor(s / 2), right: Math.round(t) + Math.floor(i / 2), bottom: Math.round(e) + Math.floor(s / 2) }, this.objects.length = 0, this.nodes.length = 0 },
|
|
populate: function(t) { t.forEach(this.populateHandler, this, !0) },
|
|
populateHandler: function(t) { t.body && t.exists && this.insert(t.body) },
|
|
split: function() { this.nodes[0] = new H.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[1] = new H.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[2] = new H.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1), this.nodes[3] = new H.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level + 1) },
|
|
insert: function(t) {
|
|
var e, i = 0;
|
|
if (null == this.nodes[0] || -1 === (e = this.getIndex(t))) {
|
|
if (this.objects.push(t), this.objects.length > this.maxObjects && this.level < this.maxLevels)
|
|
for (null == this.nodes[0] && this.split(); i < this.objects.length;) - 1 !== (e = this.getIndex(this.objects[i])) ? this.nodes[e].insert(this.objects.splice(i, 1)[0]) : i++
|
|
}
|
|
else this.nodes[e].insert(t)
|
|
},
|
|
getIndex: function(t) { var e = -1; return t.x < this.bounds.right && t.right < this.bounds.right ? t.y < this.bounds.bottom && t.bottom < this.bounds.bottom ? e = 1 : t.y > this.bounds.bottom && (e = 2) : t.x > this.bounds.right && (t.y < this.bounds.bottom && t.bottom < this.bounds.bottom ? e = 0 : t.y > this.bounds.bottom && (e = 3)), e },
|
|
retrieve: function(t) {
|
|
if (t instanceof H.Rectangle) var e = this.objects,
|
|
i = this.getIndex(t);
|
|
else {
|
|
if (!t.body) return this._empty;
|
|
e = this.objects, i = this.getIndex(t.body)
|
|
}
|
|
return this.nodes[0] && (e = -1 !== i ? e.concat(this.nodes[i].retrieve(t)) : (e = (e = (e = e.concat(this.nodes[0].retrieve(t))).concat(this.nodes[1].retrieve(t))).concat(this.nodes[2].retrieve(t))).concat(this.nodes[3].retrieve(t))), e
|
|
},
|
|
clear: function() {
|
|
this.objects.length = 0;
|
|
for (var t = this.nodes.length; t--;) this.nodes[t].clear(), this.nodes.splice(t, 1);
|
|
this.nodes.length = 0
|
|
}
|
|
}, H.QuadTree.prototype.constructor = H.QuadTree, H.Net = function(t) { this.game = t }, H.Net.prototype = {
|
|
getHostName: function() { return window.location && window.location.hostname ? window.location.hostname : null },
|
|
checkDomainName: function(t) { return -1 !== window.location.hostname.indexOf(t) },
|
|
updateQueryString: function(t, e, i, s) {
|
|
void 0 === i && (i = !1), void 0 !== s && "" !== s || (s = window.location.href);
|
|
var o = "",
|
|
n = new RegExp("([?|&])" + t + "=.*?(&|#|$)(.*)", "gi");
|
|
if (n.test(s)) o = null != e ? s.replace(n, "$1" + t + "=" + e + "$2$3") : s.replace(n, "$1$3").replace(/(&|\?)$/, "");
|
|
else if (null != e) {
|
|
var a = -1 !== s.indexOf("?") ? "&" : "?",
|
|
r = s.split("#");
|
|
s = r[0] + a + t + "=" + e, r[1] && (s += "#" + r[1]), o = s
|
|
}
|
|
else o = s;
|
|
if (!i) return o;
|
|
window.location.href = o
|
|
},
|
|
getQueryString: function(t) {
|
|
void 0 === t && (t = "");
|
|
var e = {},
|
|
i = location.search.substring(1).split("&");
|
|
for (var s in i) {
|
|
var o = i[s].split("=");
|
|
if (1 < o.length) {
|
|
if (t && t === this.decodeURI(o[0])) return this.decodeURI(o[1]);
|
|
e[this.decodeURI(o[0])] = this.decodeURI(o[1])
|
|
}
|
|
}
|
|
return e
|
|
},
|
|
decodeURI: function(t) { return decodeURIComponent(t.replace(/\+/g, " ")) }
|
|
}, H.Net.prototype.constructor = H.Net, H.TweenManager = function(t) { this.game = t, this.frameBased = !1, this._tweens = [], this._add = [], this.easeMap = { Power0: H.Easing.Power0, Power1: H.Easing.Power1, Power2: H.Easing.Power2, Power3: H.Easing.Power3, Power4: H.Easing.Power4, Linear: H.Easing.Linear.None, Quad: H.Easing.Quadratic.Out, Cubic: H.Easing.Cubic.Out, Quart: H.Easing.Quartic.Out, Quint: H.Easing.Quintic.Out, Sine: H.Easing.Sinusoidal.Out, Expo: H.Easing.Exponential.Out, Circ: H.Easing.Circular.Out, Elastic: H.Easing.Elastic.Out, Back: H.Easing.Back.Out, Bounce: H.Easing.Bounce.Out, "Quad.easeIn": H.Easing.Quadratic.In, "Cubic.easeIn": H.Easing.Cubic.In, "Quart.easeIn": H.Easing.Quartic.In, "Quint.easeIn": H.Easing.Quintic.In, "Sine.easeIn": H.Easing.Sinusoidal.In, "Expo.easeIn": H.Easing.Exponential.In, "Circ.easeIn": H.Easing.Circular.In, "Elastic.easeIn": H.Easing.Elastic.In, "Back.easeIn": H.Easing.Back.In, "Bounce.easeIn": H.Easing.Bounce.In, "Quad.easeOut": H.Easing.Quadratic.Out, "Cubic.easeOut": H.Easing.Cubic.Out, "Quart.easeOut": H.Easing.Quartic.Out, "Quint.easeOut": H.Easing.Quintic.Out, "Sine.easeOut": H.Easing.Sinusoidal.Out, "Expo.easeOut": H.Easing.Exponential.Out, "Circ.easeOut": H.Easing.Circular.Out, "Elastic.easeOut": H.Easing.Elastic.Out, "Back.easeOut": H.Easing.Back.Out, "Bounce.easeOut": H.Easing.Bounce.Out, "Quad.easeInOut": H.Easing.Quadratic.InOut, "Cubic.easeInOut": H.Easing.Cubic.InOut, "Quart.easeInOut": H.Easing.Quartic.InOut, "Quint.easeInOut": H.Easing.Quintic.InOut, "Sine.easeInOut": H.Easing.Sinusoidal.InOut, "Expo.easeInOut": H.Easing.Exponential.InOut, "Circ.easeInOut": H.Easing.Circular.InOut, "Elastic.easeInOut": H.Easing.Elastic.InOut, "Back.easeInOut": H.Easing.Back.InOut, "Bounce.easeInOut": H.Easing.Bounce.InOut }, this.game.onPause.add(this._pauseAll, this), this.game.onResume.add(this._resumeAll, this) }, H.TweenManager.prototype = {
|
|
getAll: function() { return this._tweens },
|
|
removeAll: function() {
|
|
for (var t = 0; t < this._tweens.length; t++) this._tweens[t].pendingDelete = !0;
|
|
this._add = []
|
|
},
|
|
removeFrom: function(t, e) {
|
|
if (void 0 === e && (e = !0), Array.isArray(t))
|
|
for (i = 0, s = t.length; i < s; i++) this.removeFrom(t[i]);
|
|
else if (t.type === H.GROUP && e)
|
|
for (var i = 0, s = t.children.length; i < s; i++) this.removeFrom(t.children[i]);
|
|
else { for (i = 0, s = this._tweens.length; i < s; i++) t === this._tweens[i].target && this.remove(this._tweens[i]); for (i = 0, s = this._add.length; i < s; i++) t === this._add[i].target && this.remove(this._add[i]) }
|
|
},
|
|
add: function(t) {
|
|
(t._manager = this)._add.push(t)
|
|
},
|
|
create: function(t) { return new H.Tween(t, this.game, this) },
|
|
remove: function(t) { var e = this._tweens.indexOf(t); - 1 !== e ? this._tweens[e].pendingDelete = !0 : -1 !== (e = this._add.indexOf(t)) && (this._add[e].pendingDelete = !0) },
|
|
update: function() {
|
|
var t = this._add.length,
|
|
e = this._tweens.length;
|
|
if (0 === e && 0 === t) return !1;
|
|
for (var i = 0; i < e;) this._tweens[i].update(this.game.time.time) ? i++ : (this._tweens.splice(i, 1), e--);
|
|
return 0 < t && (this._tweens = this._tweens.concat(this._add), this._add.length = 0), !0
|
|
},
|
|
isTweening: function(e) { return this._tweens.some(function(t) { return t.target === e }) },
|
|
_pauseAll: function() { for (var t = this._tweens.length - 1; 0 <= t; t--) this._tweens[t]._pause() },
|
|
_resumeAll: function() { for (var t = this._tweens.length - 1; 0 <= t; t--) this._tweens[t]._resume() },
|
|
pauseAll: function() { for (var t = this._tweens.length - 1; 0 <= t; t--) this._tweens[t].pause() },
|
|
resumeAll: function() { for (var t = this._tweens.length - 1; 0 <= t; t--) this._tweens[t].resume(!0) }
|
|
}, H.TweenManager.prototype.constructor = H.TweenManager, H.Tween = function(t, e, i) { this.game = e, this.target = t, this.manager = i, this.timeline = [], this.reverse = !1, this.timeScale = 1, this.repeatCounter = 0, this.pendingDelete = !1, this.onStart = new H.Signal, this.onLoop = new H.Signal, this.onRepeat = new H.Signal, this.onChildComplete = new H.Signal, this.onComplete = new H.Signal, this.isRunning = !1, this.current = 0, this.properties = {}, this.chainedTween = null, this.isPaused = !1, this.frameBased = i.frameBased, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, this._pausedTime = 0, this._codePaused = !1, this._hasStarted = !1 }, H.Tween.prototype = {
|
|
to: function(t, e, i, s, o, n, a) { return (void 0 === e || e <= 0) && (e = 1e3), null == i && (i = H.Easing.Default), void 0 === s && (s = !1), void 0 === o && (o = 0), void 0 === n && (n = 0), void 0 === a && (a = !1), "string" == typeof i && this.manager.easeMap[i] && (i = this.manager.easeMap[i]), this.isRunning || (this.timeline.push(new H.TweenData(this).to(t, e, i, o, n, a)), s && this.start()), this },
|
|
from: function(t, e, i, s, o, n, a) { return void 0 === e && (e = 1e3), null == i && (i = H.Easing.Default), void 0 === s && (s = !1), void 0 === o && (o = 0), void 0 === n && (n = 0), void 0 === a && (a = !1), "string" == typeof i && this.manager.easeMap[i] && (i = this.manager.easeMap[i]), this.isRunning || (this.timeline.push(new H.TweenData(this).from(t, e, i, o, n, a)), s && this.start()), this },
|
|
start: function(t) {
|
|
if (void 0 === t && (t = 0), null === this.game || null === this.target || 0 === this.timeline.length || this.isRunning) return this;
|
|
for (var e = 0; e < this.timeline.length; e++)
|
|
for (var i in this.timeline[e].vEnd) this.properties[i] = this.target[i] || 0, Array.isArray(this.properties[i]) || (this.properties[i] *= 1);
|
|
for (e = 0; e < this.timeline.length; e++) this.timeline[e].loadValues();
|
|
return this.manager.add(this), this.isRunning = !0, (t < 0 || t > this.timeline.length - 1) && (t = 0), this.current = t, this.timeline[this.current].start(), this
|
|
},
|
|
stop: function(t) { return void 0 === t && (t = !1), this.isRunning = !1, this._onUpdateCallback = null, this._onUpdateCallbackContext = null, t && (this.onComplete.dispatch(this.target, this), this._hasStarted = !1, this.chainedTween && this.chainedTween.start()), this.manager.remove(this), this },
|
|
updateTweenData: function(t, e, i) {
|
|
if (0 === this.timeline.length) return this;
|
|
if (void 0 === i && (i = 0), -1 === i)
|
|
for (var s = 0; s < this.timeline.length; s++) this.timeline[s][t] = e;
|
|
else this.timeline[i][t] = e;
|
|
return this
|
|
},
|
|
delay: function(t, e) { return this.updateTweenData("delay", t, e) },
|
|
repeat: function(t, e, i) { return void 0 === e && (e = 0), this.updateTweenData("repeatCounter", t, i), this.updateTweenData("repeatDelay", e, i) },
|
|
repeatDelay: function(t, e) { return this.updateTweenData("repeatDelay", t, e) },
|
|
yoyo: function(t, e, i) { return void 0 === e && (e = 0), this.updateTweenData("yoyo", t, i), this.updateTweenData("yoyoDelay", e, i) },
|
|
yoyoDelay: function(t, e) { return this.updateTweenData("yoyoDelay", t, e) },
|
|
easing: function(t, e) { return "string" == typeof t && this.manager.easeMap[t] && (t = this.manager.easeMap[t]), this.updateTweenData("easingFunction", t, e) },
|
|
interpolation: function(t, e, i) { return void 0 === e && (e = H.Math), this.updateTweenData("interpolationFunction", t, i), this.updateTweenData("interpolationContext", e, i) },
|
|
repeatAll: function(t) { return void 0 === t && (t = 0), this.repeatCounter = t, this },
|
|
chain: function() { for (var t = arguments.length; t--;) 0 < t ? arguments[t - 1].chainedTween = arguments[t] : this.chainedTween = arguments[t]; return this },
|
|
loop: function(t) { return void 0 === t && (t = !0), this.repeatCounter = t ? -1 : 0, this },
|
|
onUpdateCallback: function(t, e) { return this._onUpdateCallback = t, this._onUpdateCallbackContext = e, this },
|
|
pause: function() { this.isPaused = !0, this._codePaused = !0, this._pausedTime = this.game.time.time },
|
|
_pause: function() { this._codePaused || (this.isPaused = !0, this._pausedTime = this.game.time.time) },
|
|
resume: function() { if (this.isPaused) { this.isPaused = !1, this._codePaused = !1; for (var t = 0; t < this.timeline.length; t++) this.timeline[t].isRunning || (this.timeline[t].startTime += this.game.time.time - this._pausedTime) } },
|
|
_resume: function() { this._codePaused || this.resume() },
|
|
update: function(t) { if (this.pendingDelete || !this.target) return !1; if (this.isPaused) return !0; var e = this.timeline[this.current].update(t); if (e === H.TweenData.PENDING) return !0; if (e === H.TweenData.RUNNING) return this._hasStarted || (this.onStart.dispatch(this.target, this), this._hasStarted = !0), null !== this._onUpdateCallback && this._onUpdateCallback.call(this._onUpdateCallbackContext, this, this.timeline[this.current].value, this.timeline[this.current]), this.isRunning; if (e === H.TweenData.LOOPED) return -1 === this.timeline[this.current].repeatCounter ? this.onLoop.dispatch(this.target, this) : this.onRepeat.dispatch(this.target, this), !0; if (e === H.TweenData.COMPLETE) { var i = !1; return this.reverse ? (this.current--, this.current < 0 && (this.current = this.timeline.length - 1, i = !0)) : (this.current++, this.current === this.timeline.length && (i = !(this.current = 0))), i ? -1 === this.repeatCounter ? (this.timeline[this.current].start(), this.onLoop.dispatch(this.target, this), !0) : 0 < this.repeatCounter ? (this.repeatCounter--, this.timeline[this.current].start(), this.onRepeat.dispatch(this.target, this), !0) : (this.isRunning = !1, this.onComplete.dispatch(this.target, this), this._hasStarted = !1, this.chainedTween && this.chainedTween.start(), !1) : (this.onChildComplete.dispatch(this.target, this), this.timeline[this.current].start(), !0) } },
|
|
generateData: function(t, e) {
|
|
if (null === this.game || null === this.target) return null;
|
|
void 0 === t && (t = 60), void 0 === e && (e = []);
|
|
for (var i = 0; i < this.timeline.length; i++)
|
|
for (var s in this.timeline[i].vEnd) this.properties[s] = this.target[s] || 0, Array.isArray(this.properties[s]) || (this.properties[s] *= 1);
|
|
for (i = 0; i < this.timeline.length; i++) this.timeline[i].loadValues();
|
|
for (i = 0; i < this.timeline.length; i++) e = e.concat(this.timeline[i].generateData(t));
|
|
return e
|
|
}
|
|
}, Object.defineProperty(H.Tween.prototype, "totalDuration", { get: function() { for (var t = 0, e = 0; e < this.timeline.length; e++) t += this.timeline[e].duration; return t } }), H.Tween.prototype.constructor = H.Tween, H.TweenData = function(t) { this.parent = t, this.game = t.game, this.vStart = {}, this.vStartCache = {}, this.vEnd = {}, this.vEndCache = {}, this.duration = 1e3, this.percent = 0, this.value = 0, this.repeatCounter = 0, this.repeatDelay = 0, this.repeatTotal = 0, this.interpolate = !1, this.yoyo = !1, this.yoyoDelay = 0, this.inReverse = !1, this.delay = 0, this.dt = 0, this.startTime = null, this.easingFunction = H.Easing.Default, this.interpolationFunction = H.Math.linearInterpolation, this.interpolationContext = H.Math, this.isRunning = !1, this.isFrom = !1 }, H.TweenData.PENDING = 0, H.TweenData.RUNNING = 1, H.TweenData.LOOPED = 2, H.TweenData.COMPLETE = 3, H.TweenData.prototype = {
|
|
to: function(t, e, i, s, o, n) { return this.vEnd = t, this.duration = e, this.easingFunction = i, this.delay = s, this.repeatTotal = o, this.yoyo = n, this.isFrom = !1, this },
|
|
from: function(t, e, i, s, o, n) { return this.vEnd = t, this.duration = e, this.easingFunction = i, this.delay = s, this.repeatTotal = o, this.yoyo = n, this.isFrom = !0, this },
|
|
start: function() {
|
|
if (this.startTime = this.game.time.time + this.delay, this.parent.reverse ? this.dt = this.duration : this.dt = 0, 0 < this.delay ? this.isRunning = !1 : this.isRunning = !0, this.isFrom)
|
|
for (var t in this.vStartCache) this.vStart[t] = this.vEndCache[t], this.vEnd[t] = this.vStartCache[t], this.parent.target[t] = this.vStart[t];
|
|
return this.value = 0, this.yoyoCounter = 0, this.repeatCounter = this.repeatTotal, this
|
|
},
|
|
loadValues: function() {
|
|
for (var t in this.parent.properties) {
|
|
if (this.vStart[t] = this.parent.properties[t], Array.isArray(this.vEnd[t])) {
|
|
if (0 === this.vEnd[t].length) continue;
|
|
0 === this.percent && (this.vEnd[t] = [this.vStart[t]].concat(this.vEnd[t]))
|
|
}
|
|
void 0 !== this.vEnd[t] ? ("string" == typeof this.vEnd[t] && (this.vEnd[t] = this.vStart[t] + parseFloat(this.vEnd[t], 10)), this.parent.properties[t] = this.vEnd[t]) : this.vEnd[t] = this.vStart[t], this.vStartCache[t] = this.vStart[t], this.vEndCache[t] = this.vEnd[t]
|
|
}
|
|
return this
|
|
},
|
|
update: function(t) {
|
|
if (this.isRunning) { if (t < this.startTime) return H.TweenData.RUNNING }
|
|
else {
|
|
if (!(t >= this.startTime)) return H.TweenData.PENDING;
|
|
this.isRunning = !0
|
|
}
|
|
var e = this.parent.frameBased ? this.game.time.physicsElapsedMS : this.game.time.elapsedMS;
|
|
for (var i in this.parent.reverse ? (this.dt -= e * this.parent.timeScale, this.dt = Math.max(this.dt, 0)) : (this.dt += e * this.parent.timeScale, this.dt = Math.min(this.dt, this.duration)), this.percent = this.dt / this.duration, this.value = this.easingFunction(this.percent), this.vEnd) {
|
|
var s = this.vStart[i],
|
|
o = this.vEnd[i];
|
|
Array.isArray(o) ? this.parent.target[i] = this.interpolationFunction.call(this.interpolationContext, o, this.value) : this.parent.target[i] = s + (o - s) * this.value
|
|
}
|
|
return !this.parent.reverse && 1 === this.percent || this.parent.reverse && 0 === this.percent ? this.repeat() : H.TweenData.RUNNING
|
|
},
|
|
generateData: function(t) {
|
|
this.parent.reverse ? this.dt = this.duration : this.dt = 0;
|
|
var e = [],
|
|
i = !1,
|
|
s = 1 / t * 1e3;
|
|
do {
|
|
this.parent.reverse ? (this.dt -= s, this.dt = Math.max(this.dt, 0)) : (this.dt += s, this.dt = Math.min(this.dt, this.duration)), this.percent = this.dt / this.duration, this.value = this.easingFunction(this.percent);
|
|
var o = {};
|
|
for (var n in this.vEnd) {
|
|
var a = this.vStart[n],
|
|
r = this.vEnd[n];
|
|
Array.isArray(r) ? o[n] = this.interpolationFunction(r, this.value) : o[n] = a + (r - a) * this.value
|
|
}
|
|
e.push(o), (!this.parent.reverse && 1 === this.percent || this.parent.reverse && 0 === this.percent) && (i = !0)
|
|
} while (!i);
|
|
if (this.yoyo) {
|
|
var h = e.slice();
|
|
h.reverse(), e = e.concat(h)
|
|
}
|
|
return e
|
|
},
|
|
repeat: function() {
|
|
if (this.yoyo) { if (this.inReverse && 0 === this.repeatCounter) { for (var t in this.vStartCache) this.vStart[t] = this.vStartCache[t], this.vEnd[t] = this.vEndCache[t]; return this.inReverse = !1, H.TweenData.COMPLETE } this.inReverse = !this.inReverse }
|
|
else if (0 === this.repeatCounter) return H.TweenData.COMPLETE;
|
|
if (this.inReverse)
|
|
for (var t in this.vStartCache) this.vStart[t] = this.vEndCache[t], this.vEnd[t] = this.vStartCache[t];
|
|
else {
|
|
for (var t in this.vStartCache) this.vStart[t] = this.vStartCache[t], this.vEnd[t] = this.vEndCache[t];
|
|
0 < this.repeatCounter && this.repeatCounter--
|
|
}
|
|
return this.startTime = this.game.time.time, this.yoyo && this.inReverse ? this.startTime += this.yoyoDelay : this.inReverse || (this.startTime += this.repeatDelay), this.parent.reverse ? this.dt = this.duration : this.dt = 0, H.TweenData.LOOPED
|
|
}
|
|
}, H.TweenData.prototype.constructor = H.TweenData, H.Easing = { Linear: { None: function(t) { return t } }, Quadratic: { In: function(t) { return t * t }, Out: function(t) { return t * (2 - t) }, InOut: function(t) { return (t *= 2) < 1 ? .5 * t * t : -.5 * (--t * (t - 2) - 1) } }, Cubic: { In: function(t) { return t * t * t }, Out: function(t) { return --t * t * t + 1 }, InOut: function(t) { return (t *= 2) < 1 ? .5 * t * t * t : .5 * ((t -= 2) * t * t + 2) } }, Quartic: { In: function(t) { return t * t * t * t }, Out: function(t) { return 1 - --t * t * t * t }, InOut: function(t) { return (t *= 2) < 1 ? .5 * t * t * t * t : -.5 * ((t -= 2) * t * t * t - 2) } }, Quintic: { In: function(t) { return t * t * t * t * t }, Out: function(t) { return --t * t * t * t * t + 1 }, InOut: function(t) { return (t *= 2) < 1 ? .5 * t * t * t * t * t : .5 * ((t -= 2) * t * t * t * t + 2) } }, Sinusoidal: { In: function(t) { return 0 === t ? 0 : 1 === t ? 1 : 1 - Math.cos(t * Math.PI / 2) }, Out: function(t) { return 0 === t ? 0 : 1 === t ? 1 : Math.sin(t * Math.PI / 2) }, InOut: function(t) { return 0 === t ? 0 : 1 === t ? 1 : .5 * (1 - Math.cos(Math.PI * t)) } }, Exponential: { In: function(t) { return 0 === t ? 0 : Math.pow(1024, t - 1) }, Out: function(t) { return 1 === t ? 1 : 1 - Math.pow(2, -10 * t) }, InOut: function(t) { return 0 === t ? 0 : 1 === t ? 1 : (t *= 2) < 1 ? .5 * Math.pow(1024, t - 1) : .5 * (2 - Math.pow(2, -10 * (t - 1))) } }, Circular: { In: function(t) { return 1 - Math.sqrt(1 - t * t) }, Out: function(t) { return Math.sqrt(1 - --t * t) }, InOut: function(t) { return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1) } }, Elastic: { In: function(t) { var e, i = .1; return 0 === t ? 0 : 1 === t ? 1 : (e = !i || i < 1 ? (i = 1, .1) : .4 * Math.asin(1 / i) / (2 * Math.PI), -i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4)) }, Out: function(t) { var e, i = .1; return 0 === t ? 0 : 1 === t ? 1 : (e = !i || i < 1 ? (i = 1, .1) : .4 * Math.asin(1 / i) / (2 * Math.PI), i * Math.pow(2, -10 * t) * Math.sin((t - e) * (2 * Math.PI) / .4) + 1) }, InOut: function(t) { var e, i = .1; return 0 === t ? 0 : 1 === t ? 1 : (e = !i || i < 1 ? (i = 1, .1) : .4 * Math.asin(1 / i) / (2 * Math.PI), (t *= 2) < 1 ? i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4) * -.5 : i * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - e) * (2 * Math.PI) / .4) * .5 + 1) } }, Back: { In: function(t) { return t * t * (2.70158 * t - 1.70158) }, Out: function(t) { return --t * t * (2.70158 * t + 1.70158) + 1 }, InOut: function(t) { var e = 2.5949095; return (t *= 2) < 1 ? t * t * ((e + 1) * t - e) * .5 : .5 * ((t -= 2) * t * ((e + 1) * t + e) + 2) } }, Bounce: { In: function(t) { return 1 - H.Easing.Bounce.Out(1 - t) }, Out: function(t) { return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375 }, InOut: function(t) { return t < .5 ? .5 * H.Easing.Bounce.In(2 * t) : .5 * H.Easing.Bounce.Out(2 * t - 1) + .5 } } }, H.Easing.Default = H.Easing.Linear.None, H.Easing.Power0 = H.Easing.Linear.None, H.Easing.Power1 = H.Easing.Quadratic.Out, H.Easing.Power2 = H.Easing.Cubic.Out, H.Easing.Power3 = H.Easing.Quartic.Out, H.Easing.Power4 = H.Easing.Quintic.Out, H.Time = function(t) { this.game = t, this.time = 0, this.prevTime = 0, this.now = 0, this.elapsed = 0, this.elapsedMS = 0, this.physicsElapsed = 1 / 60, this.physicsElapsedMS = 1 / 60 * 1e3, this.desiredFpsMult = 1 / 60, this._desiredFps = 60, this.suggestedFps = this.desiredFps, this.slowMotion = 1, this.advancedTiming = !1, this.frames = 0, this.fps = 0, this.fpsMin = 1e3, this.fpsMax = 0, this.msMin = 1e3, this.msMax = 0, this.pauseDuration = 0, this.timeToCall = 0, this.timeExpected = 0, this.events = new H.Timer(this.game, !1), this._frameCount = 0, this._elapsedAccumulator = 0, this._started = 0, this._timeLastSecond = 0, this._pauseStarted = 0, this._justResumed = !1, this._timers = [] }, H.Time.prototype = {
|
|
boot: function() { this._started = Date.now(), this.time = Date.now(), this.events.start(), this.timeExpected = this.time },
|
|
add: function(t) { return this._timers.push(t), t },
|
|
create: function(t) { void 0 === t && (t = !0); var e = new H.Timer(this.game, t); return this._timers.push(e), e },
|
|
removeAll: function() {
|
|
for (var t = 0; t < this._timers.length; t++) this._timers[t].destroy();
|
|
this._timers = [], this.events.removeAll()
|
|
},
|
|
refresh: function() {
|
|
var t = this.time;
|
|
this.time = Date.now(), this.elapsedMS = this.time - t
|
|
},
|
|
update: function(t) {
|
|
var e = this.time;
|
|
this.time = Date.now(), this.elapsedMS = this.time - e, this.prevTime = this.now, this.now = t, this.elapsed = this.now - this.prevTime, this.game.raf._isSetTimeOut && (this.timeToCall = Math.floor(Math.max(0, 1e3 / this._desiredFps - (this.timeExpected - t))), this.timeExpected = t + this.timeToCall), this.advancedTiming && this.updateAdvancedTiming(), this.game.paused || (this.events.update(this.time), this._timers.length && this.updateTimers())
|
|
},
|
|
updateTimers: function() { for (var t = 0, e = this._timers.length; t < e;) this._timers[t].update(this.time) ? t++ : (this._timers.splice(t, 1), e--) },
|
|
updateAdvancedTiming: function() { this._frameCount++, this._elapsedAccumulator += this.elapsed, this._frameCount >= 2 * this._desiredFps && (this.suggestedFps = 5 * Math.floor(200 / (this._elapsedAccumulator / this._frameCount)), this._frameCount = 0, this._elapsedAccumulator = 0), this.msMin = Math.min(this.msMin, this.elapsed), this.msMax = Math.max(this.msMax, this.elapsed), this.frames++, this.now > this._timeLastSecond + 1e3 && (this.fps = Math.round(1e3 * this.frames / (this.now - this._timeLastSecond)), this.fpsMin = Math.min(this.fpsMin, this.fps), this.fpsMax = Math.max(this.fpsMax, this.fps), this._timeLastSecond = this.now, this.frames = 0) },
|
|
gamePaused: function() { this._pauseStarted = Date.now(), this.events.pause(); for (var t = this._timers.length; t--;) this._timers[t]._pause() },
|
|
gameResumed: function() { this.time = Date.now(), this.pauseDuration = this.time - this._pauseStarted, this.events.resume(); for (var t = this._timers.length; t--;) this._timers[t]._resume() },
|
|
totalElapsedSeconds: function() { return .001 * (this.time - this._started) },
|
|
elapsedSince: function(t) { return this.time - t },
|
|
elapsedSecondsSince: function(t) { return .001 * (this.time - t) },
|
|
reset: function() { this._started = this.time, this.removeAll() }
|
|
}, Object.defineProperty(H.Time.prototype, "desiredFps", { get: function() { return this._desiredFps }, set: function(t) { this._desiredFps = t, this.physicsElapsed = 1 / t, this.physicsElapsedMS = 1e3 * this.physicsElapsed, this.desiredFpsMult = 1 / t } }), H.Time.prototype.constructor = H.Time, H.Timer = function(t, e) { void 0 === e && (e = !0), this.game = t, this.running = !1, this.autoDestroy = e, this.expired = !1, this.elapsed = 0, this.events = [], this.onComplete = new H.Signal, this.nextTick = 0, this.timeCap = 1e3, this.paused = !1, this._codePaused = !1, this._started = 0, this._pauseStarted = 0, this._pauseTotal = 0, this._now = Date.now(), this._len = 0, this._marked = 0, this._i = 0, this._diff = 0, this._newTick = 0 }, H.Timer.MINUTE = 6e4, H.Timer.SECOND = 1e3, H.Timer.HALF = 500, H.Timer.QUARTER = 250, H.Timer.prototype = {
|
|
create: function(t, e, i, s, o, n) {
|
|
var a = t = Math.round(t);
|
|
0 === this._now ? a += this.game.time.time : a += this._now;
|
|
var r = new H.TimerEvent(this, t, a, i, e, s, o, n);
|
|
return this.events.push(r), this.order(), this.expired = !1, r
|
|
},
|
|
add: function(t, e, i) { return this.create(t, !1, 0, e, i, Array.prototype.slice.call(arguments, 3)) },
|
|
repeat: function(t, e, i, s) { return this.create(t, !1, e, i, s, Array.prototype.slice.call(arguments, 4)) },
|
|
loop: function(t, e, i) { return this.create(t, !0, 0, e, i, Array.prototype.slice.call(arguments, 3)) },
|
|
start: function(t) { if (!this.running) { this._started = this.game.time.time + (t || 0), this.running = !0; for (var e = 0; e < this.events.length; e++) this.events[e].tick = this.events[e].delay + this._started } },
|
|
stop: function(t) { this.running = !1, void 0 === t && (t = !0), t && (this.events.length = 0) },
|
|
remove: function(t) {
|
|
for (var e = 0; e < this.events.length; e++)
|
|
if (this.events[e] === t) return this.events[e].pendingDelete = !0;
|
|
return !1
|
|
},
|
|
order: function() { 0 < this.events.length && (this.events.sort(this.sortHandler), this.nextTick = this.events[0].tick) },
|
|
sortHandler: function(t, e) { return t.tick < e.tick ? -1 : t.tick > e.tick ? 1 : 0 },
|
|
clearPendingEvents: function() {
|
|
for (this._i = this.events.length; this._i--;) this.events[this._i].pendingDelete && this.events.splice(this._i, 1);
|
|
this._len = this.events.length, this._i = 0
|
|
},
|
|
update: function(t) {
|
|
if (this.paused) return !0;
|
|
if (this.elapsed = t - this._now, this._now = t, this.elapsed > this.timeCap && this.adjustEvents(t - this.elapsed), this._marked = 0, this.clearPendingEvents(), this.running && this._now >= this.nextTick && 0 < this._len) {
|
|
for (; this._i < this._len && this.running && this._now >= this.events[this._i].tick && !this.events[this._i].pendingDelete;) this._newTick = this._now + this.events[this._i].delay - (this._now - this.events[this._i].tick), this._newTick < 0 && (this._newTick = this._now + this.events[this._i].delay), !0 === this.events[this._i].loop ? this.events[this._i].tick = this._newTick : 0 < this.events[this._i].repeatCount ? (this.events[this._i].repeatCount--, this.events[this._i].tick = this._newTick) : (this._marked++, this.events[this._i].pendingDelete = !0), this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args), this._i++;
|
|
this.events.length > this._marked ? this.order() : (this.expired = !0, this.onComplete.dispatch(this))
|
|
}
|
|
return !this.expired || !this.autoDestroy
|
|
},
|
|
pause: function() { this.running && (this._codePaused = !0, this.paused || (this._pauseStarted = this.game.time.time, this.paused = !0)) },
|
|
_pause: function() {!this.paused && this.running && (this._pauseStarted = this.game.time.time, this.paused = !0) },
|
|
adjustEvents: function(t) {
|
|
for (var e = 0; e < this.events.length; e++)
|
|
if (!this.events[e].pendingDelete) {
|
|
var i = this.events[e].tick - t;
|
|
i < 0 && (i = 0), this.events[e].tick = this._now + i
|
|
}
|
|
var s = this.nextTick - t;
|
|
this.nextTick = s < 0 ? this._now : this._now + s
|
|
},
|
|
resume: function() {
|
|
if (this.paused) {
|
|
var t = this.game.time.time;
|
|
this._pauseTotal += t - this._now, this._now = t, this.adjustEvents(this._pauseStarted), this.paused = !1, this._codePaused = !1
|
|
}
|
|
},
|
|
_resume: function() { this._codePaused || this.resume() },
|
|
removeAll: function() { this.onComplete.removeAll(), this.events.length = 0, this._len = 0, this._i = 0 },
|
|
destroy: function() { this.onComplete.removeAll(), this.running = !1, this.events = [], this._len = 0, this._i = 0 }
|
|
}, Object.defineProperty(H.Timer.prototype, "next", { get: function() { return this.nextTick } }), Object.defineProperty(H.Timer.prototype, "duration", { get: function() { return this.running && this.nextTick > this._now ? this.nextTick - this._now : 0 } }), Object.defineProperty(H.Timer.prototype, "length", { get: function() { return this.events.length } }), Object.defineProperty(H.Timer.prototype, "ms", { get: function() { return this.running ? this._now - this._started - this._pauseTotal : 0 } }), Object.defineProperty(H.Timer.prototype, "seconds", { get: function() { return this.running ? .001 * this.ms : 0 } }), H.Timer.prototype.constructor = H.Timer, H.TimerEvent = function(t, e, i, s, o, n, a, r) { this.timer = t, this.delay = e, this.tick = i, this.repeatCount = s - 1, this.loop = o, this.callback = n, this.callbackContext = a, this.args = r, this.pendingDelete = !1 }, H.TimerEvent.prototype.constructor = H.TimerEvent, H.AnimationManager = function(t) { this.sprite = t, this.game = t.game, this.currentFrame = null, this.currentAnim = null, this.updateIfVisible = !0, this.isLoaded = !1, this._frameData = null, this._anims = {}, this._outputFrames = [] }, H.AnimationManager.prototype = {
|
|
loadFrameData: function(t, e) {
|
|
if (void 0 === t) return !1;
|
|
if (this.isLoaded)
|
|
for (var i in this._anims) this._anims[i].updateFrameData(t);
|
|
return this._frameData = t, null == e ? this.frame = 0 : "string" == typeof e ? this.frameName = e : this.frame = e, this.isLoaded = !0
|
|
},
|
|
copyFrameData: function(t, e) {
|
|
if (this._frameData = t.clone(), this.isLoaded)
|
|
for (var i in this._anims) this._anims[i].updateFrameData(this._frameData);
|
|
return null == e ? this.frame = 0 : "string" == typeof e ? this.frameName = e : this.frame = e, this.isLoaded = !0
|
|
},
|
|
add: function(t, e, i, s, o) { return e = e || [], i = i || 60, void 0 === s && (s = !1), void 0 === o && (o = !(!e || "number" != typeof e[0])), this._outputFrames = [], this._frameData.getFrameIndexes(e, o, this._outputFrames), this._anims[t] = new H.Animation(this.game, this.sprite, t, this._frameData, this._outputFrames, i, s), this.currentAnim = this._anims[t], this.sprite.tilingTexture && (this.sprite.refreshTexture = !0), this._anims[t] },
|
|
validateFrames: function(t, e) {
|
|
void 0 === e && (e = !0);
|
|
for (var i = 0; i < t.length; i++)
|
|
if (!0 === e) { if (t[i] > this._frameData.total) return !1 }
|
|
else if (!1 === this._frameData.checkFrameName(t[i])) return !1;
|
|
return !0
|
|
},
|
|
play: function(t, e, i, s) { if (this._anims[t]) return this.currentAnim === this._anims[t] ? !1 === this.currentAnim.isPlaying ? (this.currentAnim.paused = !1, this.currentAnim.play(e, i, s)) : this.currentAnim : (this.currentAnim && this.currentAnim.isPlaying && this.currentAnim.stop(), this.currentAnim = this._anims[t], this.currentAnim.paused = !1, this.currentFrame = this.currentAnim.currentFrame, this.currentAnim.play(e, i, s)) },
|
|
stop: function(t, e) { void 0 === e && (e = !1), !this.currentAnim || "string" == typeof t && t !== this.currentAnim.name || this.currentAnim.stop(e) },
|
|
update: function() { return !(this.updateIfVisible && !this.sprite.visible) && (!(!this.currentAnim || !this.currentAnim.update()) && (this.currentFrame = this.currentAnim.currentFrame, !0)) },
|
|
next: function(t) { this.currentAnim && (this.currentAnim.next(t), this.currentFrame = this.currentAnim.currentFrame) },
|
|
previous: function(t) { this.currentAnim && (this.currentAnim.previous(t), this.currentFrame = this.currentAnim.currentFrame) },
|
|
getAnimation: function(t) { return "string" == typeof t && this._anims[t] ? this._anims[t] : null },
|
|
refreshFrame: function() {},
|
|
destroy: function() {
|
|
var t = null;
|
|
for (var t in this._anims) this._anims.hasOwnProperty(t) && this._anims[t].destroy();
|
|
this._anims = {}, this._outputFrames = [], this._frameData = null, this.currentAnim = null, this.currentFrame = null, this.sprite = null, this.game = null
|
|
}
|
|
}, H.AnimationManager.prototype.constructor = H.AnimationManager, Object.defineProperty(H.AnimationManager.prototype, "frameData", { get: function() { return this._frameData } }), Object.defineProperty(H.AnimationManager.prototype, "frameTotal", { get: function() { return this._frameData.total } }), Object.defineProperty(H.AnimationManager.prototype, "paused", { get: function() { return this.currentAnim.isPaused }, set: function(t) { this.currentAnim.paused = t } }), Object.defineProperty(H.AnimationManager.prototype, "name", { get: function() { if (this.currentAnim) return this.currentAnim.name } }), Object.defineProperty(H.AnimationManager.prototype, "frame", { get: function() { if (this.currentFrame) return this.currentFrame.index }, set: function(t) { "number" == typeof t && this._frameData && null !== this._frameData.getFrame(t) && (this.currentFrame = this._frameData.getFrame(t), this.currentFrame && this.sprite.setFrame(this.currentFrame)) } }), Object.defineProperty(H.AnimationManager.prototype, "frameName", { get: function() { if (this.currentFrame) return this.currentFrame.name }, set: function(t) { "string" == typeof t && this._frameData && null !== this._frameData.getFrameByName(t) && (this.currentFrame = this._frameData.getFrameByName(t), this.currentFrame && (this._frameIndex = this.currentFrame.index, this.sprite.setFrame(this.currentFrame))) } }), H.Animation = function(t, e, i, s, o, n, a) { void 0 === a && (a = !1), this.game = t, this._parent = e, this._frameData = s, this.name = i, this._frames = [], this._frames = this._frames.concat(o), this.delay = 1e3 / n, this.loop = a, this.loopCount = 0, this.killOnComplete = !1, this.isFinished = !1, this.isPlaying = !1, this.isPaused = !1, this._pauseStartTime = 0, this._frameIndex = 0, this._frameDiff = 0, this._frameSkip = 1, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.onStart = new H.Signal, this.onUpdate = null, this.onComplete = new H.Signal, this.onLoop = new H.Signal, this.isReversed = !1, this.game.onPause.add(this.onPause, this), this.game.onResume.add(this.onResume, this) }, H.Animation.prototype = {
|
|
play: function(t, e, i) { return "number" == typeof t && (this.delay = 1e3 / t), "boolean" == typeof e && (this.loop = e), void 0 !== i && (this.killOnComplete = i), this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.time, this._timeNextFrame = this.game.time.time + this.delay, this._frameIndex = this.isReversed ? this._frames.length - 1 : 0, this.updateCurrentFrame(!1, !0), this._parent.events.onAnimationStart$dispatch(this._parent, this), this.onStart.dispatch(this._parent, this), (this._parent.animations.currentAnim = this)._parent.animations.currentFrame = this.currentFrame, this },
|
|
restart: function() { this.isPlaying = !0, this.isFinished = !1, this.paused = !1, this.loopCount = 0, this._timeLastFrame = this.game.time.time, this._timeNextFrame = this.game.time.time + this.delay, this._frameIndex = 0, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this._parent.setFrame(this.currentFrame), (this._parent.animations.currentAnim = this)._parent.animations.currentFrame = this.currentFrame, this.onStart.dispatch(this._parent, this) },
|
|
reverse: function() { return this.reversed = !this.reversed, this },
|
|
reverseOnce: function() { return this.onComplete.addOnce(this.reverse, this), this.reverse() },
|
|
setFrame: function(t, e) {
|
|
var i;
|
|
if (void 0 === e && (e = !1), "string" == typeof t)
|
|
for (var s = 0; s < this._frames.length; s++) this._frameData.getFrame(this._frames[s]).name === t && (i = s);
|
|
else if ("number" == typeof t)
|
|
if (e) i = t;
|
|
else
|
|
for (s = 0; s < this._frames.length; s++) this._frames[s] === t && (i = s);
|
|
i && (this._frameIndex = i - 1, this._timeNextFrame = this.game.time.time, this.update())
|
|
},
|
|
stop: function(t, e) { void 0 === t && (t = !1), void 0 === e && (e = !1), this.isPlaying = !1, this.isFinished = !0, this.paused = !1, t && (this.currentFrame = this._frameData.getFrame(this._frames[0]), this._parent.setFrame(this.currentFrame)), e && (this._parent.events.onAnimationComplete$dispatch(this._parent, this), this.onComplete.dispatch(this._parent, this)) },
|
|
onPause: function() { this.isPlaying && (this._frameDiff = this._timeNextFrame - this.game.time.time) },
|
|
onResume: function() { this.isPlaying && (this._timeNextFrame = this.game.time.time + this._frameDiff) },
|
|
update: function() { return !this.isPaused && (!!(this.isPlaying && this.game.time.time >= this._timeNextFrame) && (this._frameSkip = 1, this._frameDiff = this.game.time.time - this._timeNextFrame, this._timeLastFrame = this.game.time.time, this._frameDiff > this.delay && (this._frameSkip = Math.floor(this._frameDiff / this.delay), this._frameDiff -= this._frameSkip * this.delay), this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff), this.isReversed ? this._frameIndex -= this._frameSkip : this._frameIndex += this._frameSkip, !this.isReversed && this._frameIndex >= this._frames.length || this.isReversed && this._frameIndex <= -1 ? this.loop ? (this._frameIndex = Math.abs(this._frameIndex) % this._frames.length, this.isReversed && (this._frameIndex = this._frames.length - 1 - this._frameIndex), this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && this._parent.setFrame(this.currentFrame), this.loopCount++, this._parent.events.onAnimationLoop$dispatch(this._parent, this), this.onLoop.dispatch(this._parent, this), !this.onUpdate || (this.onUpdate.dispatch(this, this.currentFrame), !!this._frameData)) : (this.complete(), !1) : this.updateCurrentFrame(!0))) },
|
|
updateCurrentFrame: function(t, e) { if (void 0 === e && (e = !1), !this._frameData) return !1; var i = this.currentFrame.index; return this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.currentFrame && (e || !e && i !== this.currentFrame.index) && this._parent.setFrame(this.currentFrame), !this.onUpdate || !t || (this.onUpdate.dispatch(this, this.currentFrame), !!this._frameData) },
|
|
next: function(t) {
|
|
void 0 === t && (t = 1);
|
|
var e = this._frameIndex + t;
|
|
e >= this._frames.length && (this.loop ? e %= this._frames.length : e = this._frames.length - 1), e !== this._frameIndex && (this._frameIndex = e, this.updateCurrentFrame(!0))
|
|
},
|
|
previous: function(t) {
|
|
void 0 === t && (t = 1);
|
|
var e = this._frameIndex - t;
|
|
e < 0 && (this.loop ? e = this._frames.length + e : e++), e !== this._frameIndex && (this._frameIndex = e, this.updateCurrentFrame(!0))
|
|
},
|
|
updateFrameData: function(t) { this._frameData = t, this.currentFrame = this._frameData ? this._frameData.getFrame(this._frames[this._frameIndex % this._frames.length]) : null },
|
|
destroy: function() { this._frameData && (this.game.onPause.remove(this.onPause, this), this.game.onResume.remove(this.onResume, this), this.game = null, this._parent = null, this._frames = null, this._frameData = null, this.currentFrame = null, this.isPlaying = !1, this.onStart.dispose(), this.onLoop.dispose(), this.onComplete.dispose(), this.onUpdate && this.onUpdate.dispose()) },
|
|
complete: function() { this._frameIndex = this._frames.length - 1, this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]), this.isPlaying = !1, this.isFinished = !0, this.paused = !1, this._parent.events.onAnimationComplete$dispatch(this._parent, this), this.onComplete.dispatch(this._parent, this), this.killOnComplete && this._parent.kill() }
|
|
}, H.Animation.prototype.constructor = H.Animation, Object.defineProperty(H.Animation.prototype, "paused", {
|
|
get: function() { return this.isPaused },
|
|
set: function(t) {
|
|
(this.isPaused = t) ? this._pauseStartTime = this.game.time.time: this.isPlaying && (this._timeNextFrame = this.game.time.time + this.delay)
|
|
}
|
|
}), Object.defineProperty(H.Animation.prototype, "reversed", { get: function() { return this.isReversed }, set: function(t) { this.isReversed = t } }), Object.defineProperty(H.Animation.prototype, "frameTotal", { get: function() { return this._frames.length } }), Object.defineProperty(H.Animation.prototype, "frame", { get: function() { return null !== this.currentFrame ? this.currentFrame.index : this._frameIndex }, set: function(t) { this.currentFrame = this._frameData.getFrame(this._frames[t]), null !== this.currentFrame && (this._frameIndex = t, this._parent.setFrame(this.currentFrame), this.onUpdate && this.onUpdate.dispatch(this, this.currentFrame)) } }), Object.defineProperty(H.Animation.prototype, "speed", { get: function() { return 1e3 / this.delay }, set: function(t) { 0 < t && (this.delay = 1e3 / t) } }), Object.defineProperty(H.Animation.prototype, "enableUpdate", { get: function() { return null !== this.onUpdate }, set: function(t) { t && null === this.onUpdate ? this.onUpdate = new H.Signal : t || null === this.onUpdate || (this.onUpdate.dispose(), this.onUpdate = null) } }), H.Animation.generateFrameNames = function(t, e, i, s, o) {
|
|
void 0 === s && (s = "");
|
|
var n = [],
|
|
a = "";
|
|
if (e < i)
|
|
for (var r = e; r <= i; r++) a = t + (a = "number" == typeof o ? H.Utils.pad(r.toString(), o, "0", 1) : r.toString()) + s, n.push(a);
|
|
else
|
|
for (r = e; i <= r; r--) a = t + (a = "number" == typeof o ? H.Utils.pad(r.toString(), o, "0", 1) : r.toString()) + s, n.push(a);
|
|
return n
|
|
}, H.Frame = function(t, e, i, s, o, n) { this.index = t, this.x = e, this.y = i, this.width = s, this.height = o, this.name = n, this.centerX = Math.floor(s / 2), this.centerY = Math.floor(o / 2), this.distance = H.Math.distance(0, 0, s, o), this.rotated = !1, this.rotationDirection = "cw", this.trimmed = !1, this.sourceSizeW = s, this.sourceSizeH = o, this.spriteSourceSizeX = 0, this.spriteSourceSizeY = 0, this.spriteSourceSizeW = 0, this.spriteSourceSizeH = 0, this.right = this.x + this.width, this.bottom = this.y + this.height }, H.Frame.prototype = {
|
|
resize: function(t, e) { this.width = t, this.height = e, this.centerX = Math.floor(t / 2), this.centerY = Math.floor(e / 2), this.distance = H.Math.distance(0, 0, t, e), this.sourceSizeW = t, this.sourceSizeH = e, this.right = this.x + t, this.bottom = this.y + e },
|
|
setTrim: function(t, e, i, s, o, n, a) {
|
|
(this.trimmed = t) && (this.sourceSizeW = e, this.sourceSizeH = i, this.centerX = Math.floor(e / 2), this.centerY = Math.floor(i / 2), this.spriteSourceSizeX = s, this.spriteSourceSizeY = o, this.spriteSourceSizeW = n, this.spriteSourceSizeH = a)
|
|
},
|
|
clone: function() { var t = new H.Frame(this.index, this.x, this.y, this.width, this.height, this.name); for (var e in this) this.hasOwnProperty(e) && (t[e] = this[e]); return t },
|
|
getRect: function(t) { return void 0 === t ? t = new H.Rectangle(this.x, this.y, this.width, this.height) : t.setTo(this.x, this.y, this.width, this.height), t }
|
|
}, H.Frame.prototype.constructor = H.Frame, H.FrameData = function() { this._frames = [], this._frameNames = [] }, H.FrameData.prototype = {
|
|
addFrame: function(t) { return t.index = this._frames.length, this._frames.push(t), "" !== t.name && (this._frameNames[t.name] = t.index), t },
|
|
getFrame: function(t) { return t >= this._frames.length && (t = 0), this._frames[t] },
|
|
getFrameByName: function(t) { return "number" == typeof this._frameNames[t] ? this._frames[this._frameNames[t]] : null },
|
|
checkFrameName: function(t) { return null != this._frameNames[t] },
|
|
clone: function() { for (var t = new H.FrameData, e = 0; e < this._frames.length; e++) t._frames.push(this._frames[e].clone()); for (var i in this._frameNames) this._frameNames.hasOwnProperty(i) && t._frameNames.push(this._frameNames[i]); return t },
|
|
getFrameRange: function(t, e, i) { void 0 === i && (i = []); for (var s = t; s <= e; s++) i.push(this._frames[s]); return i },
|
|
getFrames: function(t, e, i) {
|
|
if (void 0 === e && (e = !0), void 0 === i && (i = []), void 0 === t || 0 === t.length)
|
|
for (var s = 0; s < this._frames.length; s++) i.push(this._frames[s]);
|
|
else
|
|
for (s = 0; s < t.length; s++) e ? i.push(this.getFrame(t[s])) : i.push(this.getFrameByName(t[s]));
|
|
return i
|
|
},
|
|
getFrameIndexes: function(t, e, i) {
|
|
if (void 0 === e && (e = !0), void 0 === i && (i = []), void 0 === t || 0 === t.length)
|
|
for (var s = 0; s < this._frames.length; s++) i.push(this._frames[s].index);
|
|
else
|
|
for (s = 0; s < t.length; s++) e && this._frames[t[s]] ? i.push(this._frames[t[s]].index) : this.getFrameByName(t[s]) && i.push(this.getFrameByName(t[s]).index);
|
|
return i
|
|
},
|
|
destroy: function() { this._frames = null, this._frameNames = null }
|
|
}, H.FrameData.prototype.constructor = H.FrameData, Object.defineProperty(H.FrameData.prototype, "total", { get: function() { return this._frames.length } }), H.AnimationParser = {
|
|
spriteSheet: function(t, e, i, s, o, n, a) {
|
|
var r = e;
|
|
if ("string" == typeof e && (r = t.cache.getImage(e)), null === r) return null;
|
|
var h = r.width,
|
|
l = r.height;
|
|
i <= 0 && (i = Math.floor(-h / Math.min(-1, i))), s <= 0 && (s = Math.floor(-l / Math.min(-1, s)));
|
|
var c = Math.floor((h - n) / (i + a)) * Math.floor((l - n) / (s + a));
|
|
if (-1 !== o && (c = o), 0 === h || 0 === l || h < i || l < s || 0 === c) return null;
|
|
for (var p = new H.FrameData, u = n, d = n, y = 0; y < c; y++) p.addFrame(new H.Frame(y, u, d, i, s, "")), h < (u += i + a) + i && (u = n, d += s + a);
|
|
return p
|
|
},
|
|
JSONData: function(t, e) { if (e.frames) { for (var i, s = new H.FrameData, o = e.frames, n = 0; n < o.length; n++) i = s.addFrame(new H.Frame(n, o[n].frame.x, o[n].frame.y, o[n].frame.w, o[n].frame.h, o[n].filename)), o[n].trimmed && i.setTrim(o[n].trimmed, o[n].sourceSize.w, o[n].sourceSize.h, o[n].spriteSourceSize.x, o[n].spriteSourceSize.y, o[n].spriteSourceSize.w, o[n].spriteSourceSize.h); return s } },
|
|
JSONDataPyxel: function(t, e) { if (["layers", "tilewidth", "tileheight", "tileswide", "tileshigh"].forEach(function(t) { e[t] }), 1 === e.layers.length) { for (var i = new H.FrameData, s = e.tileheight, o = e.tilewidth, n = e.layers[0].tiles, a = 0; a < n.length; a++) i.addFrame(new H.Frame(a, n[a].x, n[a].y, o, s, "frame_" + a)).setTrim(!1); return i } },
|
|
JSONDataHash: function(t, e) {
|
|
if (e.frames) {
|
|
var i, s = new H.FrameData,
|
|
o = e.frames,
|
|
n = 0;
|
|
for (var a in o) i = s.addFrame(new H.Frame(n, o[a].frame.x, o[a].frame.y, o[a].frame.w, o[a].frame.h, a)), o[a].trimmed && i.setTrim(o[a].trimmed, o[a].sourceSize.w, o[a].sourceSize.h, o[a].spriteSourceSize.x, o[a].spriteSourceSize.y, o[a].spriteSourceSize.w, o[a].spriteSourceSize.h), n++;
|
|
return s
|
|
}
|
|
},
|
|
XMLData: function(t, e) { if (e.getElementsByTagName("TextureAtlas")) { for (var i, s, o, n, a, r, h, l, c, p, u, d = new H.FrameData, y = e.getElementsByTagName("SubTexture"), g = 0; g < y.length; g++) s = (o = y[g].attributes).name.value, n = parseInt(o.x.value, 10), a = parseInt(o.y.value, 10), r = parseInt(o.width.value, 10), h = parseInt(o.height.value, 10), c = l = null, o.frameX && (l = Math.abs(parseInt(o.frameX.value, 10)), c = Math.abs(parseInt(o.frameY.value, 10)), p = parseInt(o.frameWidth.value, 10), u = parseInt(o.frameHeight.value, 10)), i = d.addFrame(new H.Frame(g, n, a, r, h, s)), null === l && null === c || i.setTrim(!0, r, h, l, c, p, u); return d } }
|
|
}, H.Cache = function(t) { this.game = t, this.autoResolveURL = !1, this._cache = { canvas: {}, image: {}, texture: {}, sound: {}, video: {}, text: {}, json: {}, xml: {}, physics: {}, tilemap: {}, binary: {}, bitmapData: {}, bitmapFont: {}, shader: {}, renderTexture: {} }, this._urlMap = {}, this._urlResolver = new Image, this._urlTemp = null, this.onSoundUnlock = new H.Signal, this._cacheMap = [], this._cacheMap[H.Cache.CANVAS] = this._cache.canvas, this._cacheMap[H.Cache.IMAGE] = this._cache.image, this._cacheMap[H.Cache.TEXTURE] = this._cache.texture, this._cacheMap[H.Cache.SOUND] = this._cache.sound, this._cacheMap[H.Cache.TEXT] = this._cache.text, this._cacheMap[H.Cache.PHYSICS] = this._cache.physics, this._cacheMap[H.Cache.TILEMAP] = this._cache.tilemap, this._cacheMap[H.Cache.BINARY] = this._cache.binary, this._cacheMap[H.Cache.BITMAPDATA] = this._cache.bitmapData, this._cacheMap[H.Cache.BITMAPFONT] = this._cache.bitmapFont, this._cacheMap[H.Cache.JSON] = this._cache.json, this._cacheMap[H.Cache.XML] = this._cache.xml, this._cacheMap[H.Cache.VIDEO] = this._cache.video, this._cacheMap[H.Cache.SHADER] = this._cache.shader, this._cacheMap[H.Cache.RENDER_TEXTURE] = this._cache.renderTexture, this.addDefaultImage(), this.addMissingImage() }, H.Cache.CANVAS = 1, H.Cache.IMAGE = 2, H.Cache.TEXTURE = 3, H.Cache.SOUND = 4, H.Cache.TEXT = 5, H.Cache.PHYSICS = 6, H.Cache.TILEMAP = 7, H.Cache.BINARY = 8, H.Cache.BITMAPDATA = 9, H.Cache.BITMAPFONT = 10, H.Cache.JSON = 11, H.Cache.XML = 12, H.Cache.VIDEO = 13, H.Cache.SHADER = 14, H.Cache.RENDER_TEXTURE = 15, H.Cache.DEFAULT = null, H.Cache.MISSING = null, H.Cache.prototype = {
|
|
addCanvas: function(t, e, i) { void 0 === i && (i = e.getContext("2d")), this._cache.canvas[t] = { canvas: e, context: i } },
|
|
addImage: function(t, e, i) { this.checkImageKey(t) && this.removeImage(t); var s = { key: t, url: e, data: i, base: new PIXI.BaseTexture(i), frame: new H.Frame(0, 0, 0, i.width, i.height, t), frameData: new H.FrameData }; return s.frameData.addFrame(new H.Frame(0, 0, 0, i.width, i.height, e)), this._cache.image[t] = s, this._resolveURL(e, s), "__default" === t ? H.Cache.DEFAULT = new PIXI.Texture(s.base) : "__missing" === t && (H.Cache.MISSING = new PIXI.Texture(s.base)), s },
|
|
addDefaultImage: function() {
|
|
var t = new Image;
|
|
t.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";
|
|
var e = this.addImage("__default", null, t);
|
|
e.base.skipRender = !0, H.Cache.DEFAULT = new PIXI.Texture(e.base)
|
|
},
|
|
addMissingImage: function() {
|
|
var t = new Image;
|
|
t.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";
|
|
var e = this.addImage("__missing", null, t);
|
|
H.Cache.MISSING = new PIXI.Texture(e.base)
|
|
},
|
|
addSound: function(t, e, i, s, o) {
|
|
void 0 === s && (o = !(s = !0)), void 0 === o && (o = !(s = !1));
|
|
var n = !1;
|
|
o && (n = !0), this._cache.sound[t] = { url: e, data: i, isDecoding: !1, decoded: n, webAudio: s, audioTag: o, locked: this.game.sound.touchLocked }, this._resolveURL(e, this._cache.sound[t])
|
|
},
|
|
addText: function(t, e, i) { this._cache.text[t] = { url: e, data: i }, this._resolveURL(e, this._cache.text[t]) },
|
|
addPhysicsData: function(t, e, i, s) { this._cache.physics[t] = { url: e, data: i, format: s }, this._resolveURL(e, this._cache.physics[t]) },
|
|
addTilemap: function(t, e, i, s) { this._cache.tilemap[t] = { url: e, data: i, format: s }, this._resolveURL(e, this._cache.tilemap[t]) },
|
|
addBinary: function(t, e) { this._cache.binary[t] = e },
|
|
addBitmapData: function(t, e, i) { return e.key = t, void 0 === i && (i = new H.FrameData).addFrame(e.textureFrame), this._cache.bitmapData[t] = { data: e, frameData: i }, e },
|
|
addBitmapFont: function(t, e, i, s, o, n, a) {
|
|
var r = { url: e, data: i, font: null, base: new PIXI.BaseTexture(i) };
|
|
void 0 === n && (n = 0), void 0 === a && (a = 0), r.font = "json" === o ? H.LoaderParser.jsonBitmapFont(s, r.base, n, a) : H.LoaderParser.xmlBitmapFont(s, r.base, n, a), this._cache.bitmapFont[t] = r, this._resolveURL(e, r)
|
|
},
|
|
addJSON: function(t, e, i) { this._cache.json[t] = { url: e, data: i }, this._resolveURL(e, this._cache.json[t]) },
|
|
addXML: function(t, e, i) { this._cache.xml[t] = { url: e, data: i }, this._resolveURL(e, this._cache.xml[t]) },
|
|
addVideo: function(t, e, i, s) { this._cache.video[t] = { url: e, data: i, isBlob: s, locked: !0 }, this._resolveURL(e, this._cache.video[t]) },
|
|
addShader: function(t, e, i) { this._cache.shader[t] = { url: e, data: i }, this._resolveURL(e, this._cache.shader[t]) },
|
|
addRenderTexture: function(t, e) { this._cache.renderTexture[t] = { texture: e, frame: new H.Frame(0, 0, 0, e.width, e.height, "", "") } },
|
|
addSpriteSheet: function(t, e, i, s, o, n, a, r) {
|
|
void 0 === n && (n = -1), void 0 === a && (a = 0), void 0 === r && (r = 0);
|
|
var h = { key: t, url: e, data: i, frameWidth: s, frameHeight: o, margin: a, spacing: r, base: new PIXI.BaseTexture(i), frameData: H.AnimationParser.spriteSheet(this.game, i, s, o, n, a, r) };
|
|
this._cache.image[t] = h, this._resolveURL(e, h)
|
|
},
|
|
addTextureAtlas: function(t, e, i, s, o) {
|
|
var n = { key: t, url: e, data: i, base: new PIXI.BaseTexture(i) };
|
|
o === H.Loader.TEXTURE_ATLAS_XML_STARLING ? n.frameData = H.AnimationParser.XMLData(this.game, s, t) : o === H.Loader.TEXTURE_ATLAS_JSON_PYXEL ? n.frameData = H.AnimationParser.JSONDataPyxel(this.game, s, t) : Array.isArray(s.frames) ? n.frameData = H.AnimationParser.JSONData(this.game, s, t) : n.frameData = H.AnimationParser.JSONDataHash(this.game, s, t), this._cache.image[t] = n, this._resolveURL(e, n)
|
|
},
|
|
reloadSound: function(t) {
|
|
var e = this,
|
|
i = this.getSound(t);
|
|
i && (i.data.src = i.url, i.data.addEventListener("canplaythrough", function() { return e.reloadSoundComplete(t) }, !1), i.data.load())
|
|
},
|
|
reloadSoundComplete: function(t) {
|
|
var e = this.getSound(t);
|
|
e && (e.locked = !1, this.onSoundUnlock.dispatch(t))
|
|
},
|
|
updateSound: function(t, e, i) {
|
|
var s = this.getSound(t);
|
|
s && (s[e] = i)
|
|
},
|
|
decodedSound: function(t, e) {
|
|
var i = this.getSound(t);
|
|
i.data = e, i.decoded = !0, i.isDecoding = !1
|
|
},
|
|
isSoundDecoded: function(t) { var e = this.getItem(t, H.Cache.SOUND, "isSoundDecoded"); if (e) return e.decoded },
|
|
isSoundReady: function(t) { var e = this.getItem(t, H.Cache.SOUND, "isSoundDecoded"); if (e) return e.decoded && !this.game.sound.touchLocked },
|
|
checkKey: function(t, e) { return !!this._cacheMap[t][e] },
|
|
checkURL: function(t) { return !!this._urlMap[this._resolveURL(t)] },
|
|
checkCanvasKey: function(t) { return this.checkKey(H.Cache.CANVAS, t) },
|
|
checkImageKey: function(t) { return this.checkKey(H.Cache.IMAGE, t) },
|
|
checkTextureKey: function(t) { return this.checkKey(H.Cache.TEXTURE, t) },
|
|
checkSoundKey: function(t) { return this.checkKey(H.Cache.SOUND, t) },
|
|
checkTextKey: function(t) { return this.checkKey(H.Cache.TEXT, t) },
|
|
checkPhysicsKey: function(t) { return this.checkKey(H.Cache.PHYSICS, t) },
|
|
checkTilemapKey: function(t) { return this.checkKey(H.Cache.TILEMAP, t) },
|
|
checkBinaryKey: function(t) { return this.checkKey(H.Cache.BINARY, t) },
|
|
checkBitmapDataKey: function(t) { return this.checkKey(H.Cache.BITMAPDATA, t) },
|
|
checkBitmapFontKey: function(t) { return this.checkKey(H.Cache.BITMAPFONT, t) },
|
|
checkJSONKey: function(t) { return this.checkKey(H.Cache.JSON, t) },
|
|
checkXMLKey: function(t) { return this.checkKey(H.Cache.XML, t) },
|
|
checkVideoKey: function(t) { return this.checkKey(H.Cache.VIDEO, t) },
|
|
checkShaderKey: function(t) { return this.checkKey(H.Cache.SHADER, t) },
|
|
checkRenderTextureKey: function(t) { return this.checkKey(H.Cache.RENDER_TEXTURE, t) },
|
|
getItem: function(t, e, i, s) { return this.checkKey(e, t) ? void 0 === s ? this._cacheMap[e][t] : this._cacheMap[e][t][s] : null },
|
|
getCanvas: function(t) { return this.getItem(t, H.Cache.CANVAS, "getCanvas", "canvas") },
|
|
getImage: function(t, e) { null == t && (t = "__default"), void 0 === e && (e = !1); var i = this.getItem(t, H.Cache.IMAGE, "getImage"); return null === i && (i = this.getItem("__missing", H.Cache.IMAGE, "getImage")), e ? i : i.data },
|
|
getTextureFrame: function(t) { return this.getItem(t, H.Cache.TEXTURE, "getTextureFrame", "frame") },
|
|
getSound: function(t) { return this.getItem(t, H.Cache.SOUND, "getSound") },
|
|
getSoundData: function(t) { return this.getItem(t, H.Cache.SOUND, "getSoundData", "data") },
|
|
getText: function(t) { return this.getItem(t, H.Cache.TEXT, "getText", "data") },
|
|
getPhysicsData: function(t, e, i) {
|
|
var s = this.getItem(t, H.Cache.PHYSICS, "getPhysicsData", "data");
|
|
if (null === s || null == e) return s;
|
|
if (s[e]) {
|
|
var o = s[e];
|
|
if (!o || !i) return o;
|
|
for (var n in o)
|
|
if ((n = o[n]).fixtureKey === i) return n
|
|
}
|
|
return null
|
|
},
|
|
getTilemapData: function(t) { return this.getItem(t, H.Cache.TILEMAP, "getTilemapData") },
|
|
getBinary: function(t) { return this.getItem(t, H.Cache.BINARY, "getBinary") },
|
|
getBitmapData: function(t) { return this.getItem(t, H.Cache.BITMAPDATA, "getBitmapData", "data") },
|
|
getBitmapFont: function(t) { return this.getItem(t, H.Cache.BITMAPFONT, "getBitmapFont") },
|
|
getJSON: function(t, e) { var i = this.getItem(t, H.Cache.JSON, "getJSON", "data"); return i ? e ? H.Utils.extend(!0, Array.isArray(i) ? [] : {}, i) : i : null },
|
|
getXML: function(t) { return this.getItem(t, H.Cache.XML, "getXML", "data") },
|
|
getVideo: function(t) { return this.getItem(t, H.Cache.VIDEO, "getVideo") },
|
|
getShader: function(t) { return this.getItem(t, H.Cache.SHADER, "getShader", "data") },
|
|
getRenderTexture: function(t) { return this.getItem(t, H.Cache.RENDER_TEXTURE, "getRenderTexture") },
|
|
getBaseTexture: function(t, e) { return void 0 === e && (e = H.Cache.IMAGE), this.getItem(t, e, "getBaseTexture", "base") },
|
|
getFrame: function(t, e) { return void 0 === e && (e = H.Cache.IMAGE), this.getItem(t, e, "getFrame", "frame") },
|
|
getFrameCount: function(t, e) { var i = this.getFrameData(t, e); return i ? i.total : 0 },
|
|
getFrameData: function(t, e) { return void 0 === e && (e = H.Cache.IMAGE), this.getItem(t, e, "getFrameData", "frameData") },
|
|
hasFrameData: function(t, e) { return void 0 === e && (e = H.Cache.IMAGE), null !== this.getItem(t, e, "", "frameData") },
|
|
updateFrameData: function(t, e, i) { void 0 === i && (i = H.Cache.IMAGE), this._cacheMap[i][t] && (this._cacheMap[i][t].frameData = e) },
|
|
getFrameByIndex: function(t, e, i) { var s = this.getFrameData(t, i); return s ? s.getFrame(e) : null },
|
|
getFrameByName: function(t, e, i) { var s = this.getFrameData(t, i); return s ? s.getFrameByName(e) : null },
|
|
getURL: function(t) { return (t = this._resolveURL(t)) ? this._urlMap[t] : null },
|
|
getKeys: function(t) {
|
|
void 0 === t && (t = H.Cache.IMAGE);
|
|
var e = [];
|
|
if (this._cacheMap[t])
|
|
for (var i in this._cacheMap[t]) "__default" !== i && "__missing" !== i && e.push(i);
|
|
return e
|
|
},
|
|
removeCanvas: function(t) { delete this._cache.canvas[t] },
|
|
removeImage: function(t, e) {
|
|
void 0 === e && (e = !0);
|
|
var i = this.getImage(t, !0);
|
|
e && i.base && i.base.destroy(), delete this._cache.image[t]
|
|
},
|
|
removeSound: function(t) { delete this._cache.sound[t] },
|
|
removeText: function(t) { delete this._cache.text[t] },
|
|
removePhysics: function(t) { delete this._cache.physics[t] },
|
|
removeTilemap: function(t) { delete this._cache.tilemap[t] },
|
|
removeBinary: function(t) { delete this._cache.binary[t] },
|
|
removeBitmapData: function(t) { delete this._cache.bitmapData[t] },
|
|
removeBitmapFont: function(t) { delete this._cache.bitmapFont[t] },
|
|
removeJSON: function(t) { delete this._cache.json[t] },
|
|
removeXML: function(t) { delete this._cache.xml[t] },
|
|
removeVideo: function(t) { delete this._cache.video[t] },
|
|
removeShader: function(t) { delete this._cache.shader[t] },
|
|
removeRenderTexture: function(t) { delete this._cache.renderTexture[t] },
|
|
removeSpriteSheet: function(t) { delete this._cache.spriteSheet[t] },
|
|
removeTextureAtlas: function(t) { delete this._cache.atlas[t] },
|
|
clearGLTextures: function() { for (var t in this._cache.image) this._cache.image[t].base._glTextures = [] },
|
|
_resolveURL: function(t, e) { return this.autoResolveURL ? (this._urlResolver.src = this.game.load.baseURL + t, this._urlTemp = this._urlResolver.src, this._urlResolver.src = "", e && (this._urlMap[this._urlTemp] = e), this._urlTemp) : null },
|
|
destroy: function() { for (var t = 0; t < this._cacheMap.length; t++) { var e = this._cacheMap[t]; for (var i in e) "__default" !== i && "__missing" !== i && (e[i].destroy && e[i].destroy(), delete e[i]) } this._urlMap = null, this._urlResolver = null, this._urlTemp = null }
|
|
}, H.Cache.prototype.constructor = H.Cache, H.Loader = function(t) { this.game = t, this.cache = t.cache, this.resetLocked = !1, this.isLoading = !1, this.hasLoaded = !1, this.preloadSprite = null, this.crossOrigin = !1, this.baseURL = "", this.path = "", this.headers = { requestedWith: !1, json: "application/json", xml: "application/xml" }, this.onLoadStart = new H.Signal, this.onLoadComplete = new H.Signal, this.onPackComplete = new H.Signal, this.onFileStart = new H.Signal, this.onFileComplete = new H.Signal, this.onFileError = new H.Signal, this.useXDomainRequest = !1, this._warnedAboutXDomainRequest = !1, this.enableParallel = !0, this.maxParallelDownloads = 4, this._withSyncPointDepth = 0, this._fileList = [], this._flightQueue = [], this._processingHead = 0, this._fileLoadStarted = !1, this._totalPackCount = 0, this._totalFileCount = 0, this._loadedPackCount = 0, this._loadedFileCount = 0 }, H.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0, H.Loader.TEXTURE_ATLAS_JSON_HASH = 1, H.Loader.TEXTURE_ATLAS_XML_STARLING = 2, H.Loader.PHYSICS_LIME_CORONA_JSON = 3, H.Loader.PHYSICS_PHASER_JSON = 4, H.Loader.TEXTURE_ATLAS_JSON_PYXEL = 5, H.Loader.prototype = {
|
|
setPreloadSprite: function(t, e) { e = e || 0, this.preloadSprite = { sprite: t, direction: e, width: t.width, height: t.height, rect: null }, this.preloadSprite.rect = 0 === e ? new H.Rectangle(0, 0, 1, t.height) : new H.Rectangle(0, 0, t.width, 1), t.crop(this.preloadSprite.rect), t.visible = !0 },
|
|
resize: function() { this.preloadSprite && this.preloadSprite.height !== this.preloadSprite.sprite.height && (this.preloadSprite.rect.height = this.preloadSprite.sprite.height) },
|
|
checkKeyExists: function(t, e) { return -1 < this.getAssetIndex(t, e) },
|
|
getAssetIndex: function(t, e) { for (var i = -1, s = 0; s < this._fileList.length; s++) { var o = this._fileList[s]; if (o.type === t && o.key === e && (i = s, !o.loaded && !o.loading)) break } return i },
|
|
getAsset: function(t, e) { var i = this.getAssetIndex(t, e); return -1 < i && { index: i, file: this._fileList[i] } },
|
|
reset: function(t, e) { void 0 === e && (e = !1), this.resetLocked || (t && (this.preloadSprite = null), this.isLoading = !1, this._processingHead = 0, this._fileList.length = 0, this._flightQueue.length = 0, this._fileLoadStarted = !1, this._totalFileCount = 0, this._totalPackCount = 0, this._loadedPackCount = 0, this._loadedFileCount = 0, e && (this.onLoadStart.removeAll(), this.onLoadComplete.removeAll(), this.onPackComplete.removeAll(), this.onFileStart.removeAll(), this.onFileComplete.removeAll(), this.onFileError.removeAll())) },
|
|
addToFileList: function(t, e, i, s, o, n) {
|
|
if (void 0 === o && (o = !1), void 0 === e || "" === e) return this;
|
|
if (null == i) {
|
|
if (!n) return this;
|
|
i = e + n
|
|
}
|
|
var a = { type: t, key: e, path: this.path, url: i, syncPoint: 0 < this._withSyncPointDepth, data: null, loading: !1, loaded: !1, error: !1 };
|
|
if (s)
|
|
for (var r in s) a[r] = s[r];
|
|
var h = this.getAssetIndex(t, e);
|
|
if (o && -1 < h) {
|
|
var l = this._fileList[h];
|
|
l.loading || l.loaded ? (this._fileList.push(a), this._totalFileCount++) : this._fileList[h] = a
|
|
}
|
|
else -1 === h && (this._fileList.push(a), this._totalFileCount++);
|
|
return this
|
|
},
|
|
replaceInFileList: function(t, e, i, s) { return this.addToFileList(t, e, i, s, !0) },
|
|
pack: function(t, e, i, s) {
|
|
if (void 0 === e && (e = null), void 0 === i && (i = null), void 0 === s && (s = null), !e && !i) return this;
|
|
var o = { type: "packfile", key: t, url: e, path: this.path, syncPoint: !0, data: null, loading: !1, loaded: !1, error: !1, callbackContext: s };
|
|
i && ("string" == typeof i && (i = JSON.parse(i)), o.data = i || {}, o.loaded = !0);
|
|
for (var n = 0; n < this._fileList.length + 1; n++) { var a = this._fileList[n]; if (!a || !a.loaded && !a.loading && "packfile" !== a.type) { this._fileList.splice(n, 0, o), this._totalPackCount++; break } }
|
|
return this
|
|
},
|
|
image: function(t, e, i) { return this.addToFileList("image", t, e, void 0, i, ".png") },
|
|
images: function(t, e) {
|
|
if (Array.isArray(e))
|
|
for (var i = 0; i < t.length; i++) this.image(t[i], e[i]);
|
|
else
|
|
for (i = 0; i < t.length; i++) this.image(t[i]);
|
|
return this
|
|
},
|
|
text: function(t, e, i) { return this.addToFileList("text", t, e, void 0, i, ".txt") },
|
|
json: function(t, e, i) { return this.addToFileList("json", t, e, void 0, i, ".json") },
|
|
shader: function(t, e, i) { return this.addToFileList("shader", t, e, void 0, i, ".frag") },
|
|
xml: function(t, e, i) { return this.addToFileList("xml", t, e, void 0, i, ".xml") },
|
|
script: function(t, e, i, s) { return void 0 === i && (i = !1), !1 !== i && void 0 === s && (s = this), this.addToFileList("script", t, e, { syncPoint: !0, callback: i, callbackContext: s }, !1, ".js") },
|
|
binary: function(t, e, i, s) { return void 0 === i && (i = !1), !1 !== i && void 0 === s && (s = i), this.addToFileList("binary", t, e, { callback: i, callbackContext: s }, !1, ".bin") },
|
|
spritesheet: function(t, e, i, s, o, n, a) { return void 0 === o && (o = -1), void 0 === n && (n = 0), void 0 === a && (a = 0), this.addToFileList("spritesheet", t, e, { frameWidth: i, frameHeight: s, frameMax: o, margin: n, spacing: a }, !1, ".png") },
|
|
audio: function(t, e, i) { return this.game.sound.noAudio ? this : (void 0 === i && (i = !0), "string" == typeof e && (e = [e]), this.addToFileList("audio", t, e, { buffer: null, autoDecode: i })) },
|
|
audioSprite: function(t, e, i, s, o) { return this.game.sound.noAudio || (void 0 === i && (i = null), void 0 === s && (s = null), void 0 === o && (o = !0), this.audio(t, e, o), i ? this.json(t + "-audioatlas", i) : s && ("string" == typeof s && (s = JSON.parse(s)), this.cache.addJSON(t + "-audioatlas", "", s))), this },
|
|
audiosprite: function(t, e, i, s, o) { return this.audioSprite(t, e, i, s, o) },
|
|
video: function(t, e, i, s) { return void 0 === i && (i = this.game.device.firefox ? "loadeddata" : "canplaythrough"), void 0 === s && (s = !1), "string" == typeof e && (e = [e]), this.addToFileList("video", t, e, { buffer: null, asBlob: s, loadEvent: i }) },
|
|
tilemap: function(t, e, i, s) {
|
|
if (void 0 === e && (e = null), void 0 === i && (i = null), void 0 === s && (s = H.Tilemap.CSV), e || i || (e = s === H.Tilemap.CSV ? t + ".csv" : t + ".json"), i) {
|
|
switch (s) {
|
|
case H.Tilemap.CSV:
|
|
break;
|
|
case H.Tilemap.TILED_JSON:
|
|
"string" == typeof i && (i = JSON.parse(i))
|
|
}
|
|
this.cache.addTilemap(t, null, i, s)
|
|
}
|
|
else this.addToFileList("tilemap", t, e, { format: s });
|
|
return this
|
|
},
|
|
physics: function(t, e, i, s) { return void 0 === e && (e = null), void 0 === i && (i = null), void 0 === s && (s = H.Physics.LIME_CORONA_JSON), e || i || (e = t + ".json"), i ? ("string" == typeof i && (i = JSON.parse(i)), this.cache.addPhysicsData(t, null, i, s)) : this.addToFileList("physics", t, e, { format: s }), this },
|
|
bitmapFont: function(t, e, i, s, o, n) {
|
|
if (null == e && (e = t + ".png"), void 0 === i && (i = null), void 0 === s && (s = null), null === i && null === s && (i = t + ".xml"), void 0 === o && (o = 0), void 0 === n && (n = 0), i) this.addToFileList("bitmapfont", t, e, { atlasURL: i, xSpacing: o, ySpacing: n });
|
|
else if ("string" == typeof s) {
|
|
var a, r;
|
|
try { a = JSON.parse(s) }
|
|
catch (t) { r = this.parseXml(s) }
|
|
if (!r && !a) throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");
|
|
this.addToFileList("bitmapfont", t, e, { atlasURL: null, atlasData: a || r, atlasType: a ? "json" : "xml", xSpacing: o, ySpacing: n })
|
|
}
|
|
return this
|
|
},
|
|
atlasJSONArray: function(t, e, i, s) { return this.atlas(t, e, i, s, H.Loader.TEXTURE_ATLAS_JSON_ARRAY) },
|
|
atlasJSONHash: function(t, e, i, s) { return this.atlas(t, e, i, s, H.Loader.TEXTURE_ATLAS_JSON_HASH) },
|
|
atlasXML: function(t, e, i, s) { return void 0 === i && (i = null), void 0 === s && (s = null), i || s || (i = t + ".xml"), this.atlas(t, e, i, s, H.Loader.TEXTURE_ATLAS_XML_STARLING) },
|
|
atlas: function(t, e, i, s, o) {
|
|
if (null == e && (e = t + ".png"), void 0 === i && (i = null), void 0 === s && (s = null), void 0 === o && (o = H.Loader.TEXTURE_ATLAS_JSON_ARRAY), i || s || (i = o === H.Loader.TEXTURE_ATLAS_XML_STARLING ? t + ".xml" : t + ".json"), i) this.addToFileList("textureatlas", t, e, { atlasURL: i, format: o });
|
|
else {
|
|
switch (o) {
|
|
case H.Loader.TEXTURE_ATLAS_JSON_ARRAY:
|
|
"string" == typeof s && (s = JSON.parse(s));
|
|
break;
|
|
case H.Loader.TEXTURE_ATLAS_XML_STARLING:
|
|
if ("string" == typeof s) {
|
|
var n = this.parseXml(s);
|
|
if (!n) throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
|
|
s = n
|
|
}
|
|
}
|
|
this.addToFileList("textureatlas", t, e, { atlasURL: null, atlasData: s, format: o })
|
|
}
|
|
return this
|
|
},
|
|
withSyncPoint: function(t, e) { this._withSyncPointDepth++; try { t.call(e || this, this) } finally { this._withSyncPointDepth-- } return this },
|
|
addSyncPoint: function(t, e) { var i = this.getAsset(t, e); return i && (i.file.syncPoint = !0), this },
|
|
removeFile: function(t, e) {
|
|
var i = this.getAsset(t, e);
|
|
i && (i.loaded || i.loading || this._fileList.splice(i.index, 1))
|
|
},
|
|
removeAll: function() { this._fileList.length = 0, this._flightQueue.length = 0 },
|
|
start: function() { this.isLoading || (this.hasLoaded = !1, this.isLoading = !0, this.updateProgress(), this.processLoadQueue()) },
|
|
processLoadQueue: function() {
|
|
if (this.isLoading) {
|
|
for (var t = 0; t < this._flightQueue.length; t++) {
|
|
((s = this._flightQueue[t]).loaded || s.error) && (this._flightQueue.splice(t, 1), t--, s.loading = !1, s.requestUrl = null, s.requestObject = null, s.error && this.onFileError.dispatch(s.key, s), "packfile" !== s.type ? (this._loadedFileCount++, this.onFileComplete.dispatch(this.progress, s.key, !s.error, this._loadedFileCount, this._totalFileCount)) : "packfile" === s.type && s.error && (this._loadedPackCount++, this.onPackComplete.dispatch(s.key, !s.error, this._loadedPackCount, this._totalPackCount)))
|
|
}
|
|
var e = !1,
|
|
i = this.enableParallel ? H.Math.clamp(this.maxParallelDownloads, 1, 12) : 1;
|
|
for (t = this._processingHead; t < this._fileList.length; t++) { var s; if ("packfile" === (s = this._fileList[t]).type && !s.error && s.loaded && t === this._processingHead && (this.processPack(s), this._loadedPackCount++, this.onPackComplete.dispatch(s.key, !s.error, this._loadedPackCount, this._totalPackCount)), s.loaded || s.error ? t === this._processingHead && (this._processingHead = t + 1) : !s.loading && this._flightQueue.length < i && ("packfile" !== s.type || s.data ? e || (this._fileLoadStarted || (this._fileLoadStarted = !0, this.onLoadStart.dispatch()), this._flightQueue.push(s), s.loading = !0, this.onFileStart.dispatch(this.progress, s.key, s.url), this.loadFile(s)) : (this._flightQueue.push(s), s.loading = !0, this.loadFile(s))), !s.loaded && s.syncPoint && (e = !0), this._flightQueue.length >= i || e && this._loadedPackCount === this._totalPackCount) break }
|
|
if (this.updateProgress(), this._processingHead >= this._fileList.length) this.finishedLoading();
|
|
else if (!this._flightQueue.length) {
|
|
var o = this;
|
|
setTimeout(function() { o.finishedLoading(!0) }, 2e3)
|
|
}
|
|
}
|
|
else this.finishedLoading(!0)
|
|
},
|
|
finishedLoading: function(t) { this.hasLoaded || (this.hasLoaded = !0, this.isLoading = !1, t || this._fileLoadStarted || (this._fileLoadStarted = !0, this.onLoadStart.dispatch()), this.onLoadComplete.dispatch(), this.game.state.loadComplete(), this.reset()) },
|
|
asyncComplete: function(t, e) { void 0 === e && (e = ""), t.loaded = !0, t.error = !!e, e && (t.errorMessage = e), this.processLoadQueue() },
|
|
processPack: function(t) {
|
|
var e = t.data[t.key];
|
|
if (e)
|
|
for (var i = 0; i < e.length; i++) {
|
|
var s = e[i];
|
|
switch (s.type) {
|
|
case "image":
|
|
this.image(s.key, s.url, s.overwrite);
|
|
break;
|
|
case "text":
|
|
this.text(s.key, s.url, s.overwrite);
|
|
break;
|
|
case "json":
|
|
this.json(s.key, s.url, s.overwrite);
|
|
break;
|
|
case "xml":
|
|
this.xml(s.key, s.url, s.overwrite);
|
|
break;
|
|
case "script":
|
|
this.script(s.key, s.url, s.callback, t.callbackContext || this);
|
|
break;
|
|
case "binary":
|
|
this.binary(s.key, s.url, s.callback, t.callbackContext || this);
|
|
break;
|
|
case "spritesheet":
|
|
this.spritesheet(s.key, s.url, s.frameWidth, s.frameHeight, s.frameMax, s.margin, s.spacing);
|
|
break;
|
|
case "video":
|
|
this.video(s.key, s.urls);
|
|
break;
|
|
case "audio":
|
|
this.audio(s.key, s.urls, s.autoDecode);
|
|
break;
|
|
case "audiosprite":
|
|
this.audiosprite(s.key, s.urls, s.jsonURL, s.jsonData, s.autoDecode);
|
|
break;
|
|
case "tilemap":
|
|
this.tilemap(s.key, s.url, s.data, H.Tilemap[s.format]);
|
|
break;
|
|
case "physics":
|
|
this.physics(s.key, s.url, s.data, H.Loader[s.format]);
|
|
break;
|
|
case "bitmapFont":
|
|
this.bitmapFont(s.key, s.textureURL, s.atlasURL, s.atlasData, s.xSpacing, s.ySpacing);
|
|
break;
|
|
case "atlasJSONArray":
|
|
this.atlasJSONArray(s.key, s.textureURL, s.atlasURL, s.atlasData);
|
|
break;
|
|
case "atlasJSONHash":
|
|
this.atlasJSONHash(s.key, s.textureURL, s.atlasURL, s.atlasData);
|
|
break;
|
|
case "atlasXML":
|
|
this.atlasXML(s.key, s.textureURL, s.atlasURL, s.atlasData);
|
|
break;
|
|
case "atlas":
|
|
this.atlas(s.key, s.textureURL, s.atlasURL, s.atlasData, H.Loader[s.format]);
|
|
break;
|
|
case "shader":
|
|
this.shader(s.key, s.url, s.overwrite)
|
|
}
|
|
}
|
|
},
|
|
transformUrl: function(t, e) { return !!t && (t.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/) ? t : this.baseURL + e.path + t) },
|
|
loadFile: function(t) {
|
|
switch (t.type) {
|
|
case "packfile":
|
|
this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.fileComplete);
|
|
break;
|
|
case "image":
|
|
case "spritesheet":
|
|
case "textureatlas":
|
|
case "bitmapfont":
|
|
this.loadImageTag(t);
|
|
break;
|
|
case "audio":
|
|
t.url = this.getAudioURL(t.url), t.url ? this.game.sound.usingWebAudio ? this.xhrLoad(t, this.transformUrl(t.url, t), "arraybuffer", this.fileComplete) : this.game.sound.usingAudioTag && this.loadAudioTag(t) : this.fileError(t, null, "No supported audio URL specified or device does not have audio playback support");
|
|
break;
|
|
case "video":
|
|
t.url = this.getVideoURL(t.url), t.url ? t.asBlob ? this.xhrLoad(t, this.transformUrl(t.url, t), "blob", this.fileComplete) : this.loadVideoTag(t) : this.fileError(t, null, "No supported video URL specified or device does not have video playback support");
|
|
break;
|
|
case "json":
|
|
this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.jsonLoadComplete);
|
|
break;
|
|
case "xml":
|
|
this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.xmlLoadComplete);
|
|
break;
|
|
case "tilemap":
|
|
t.format === H.Tilemap.TILED_JSON ? this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.jsonLoadComplete) : t.format === H.Tilemap.CSV ? this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.csvLoadComplete) : this.asyncComplete(t, "invalid Tilemap format: " + t.format);
|
|
break;
|
|
case "text":
|
|
case "script":
|
|
case "shader":
|
|
case "physics":
|
|
this.xhrLoad(t, this.transformUrl(t.url, t), "text", this.fileComplete);
|
|
break;
|
|
case "binary":
|
|
this.xhrLoad(t, this.transformUrl(t.url, t), "arraybuffer", this.fileComplete)
|
|
}
|
|
},
|
|
loadImageTag: function(t) {
|
|
var e = this;
|
|
t.data = new Image, t.data.name = t.key, this.crossOrigin && (t.data.crossOrigin = this.crossOrigin), t.data.onload = function() { t.data.onload && (t.data.onload = null, t.data.onerror = null, e.fileComplete(t)) }, t.data.onerror = function() { t.data.onload && (t.data.onload = null, t.data.onerror = null, e.fileError(t)) }, t.data.src = this.transformUrl(t.url, t), t.data.complete && t.data.width && t.data.height && (t.data.onload = null, t.data.onerror = null, this.fileComplete(t))
|
|
},
|
|
loadVideoTag: function(t) {
|
|
var e = this;
|
|
t.data = document.createElement("video"), t.data.name = t.key, t.data.controls = !1, t.data.autoplay = !1;
|
|
var i = function() { t.data.removeEventListener(t.loadEvent, i, !1), t.data.onerror = null, t.data.canplay = !0, H.GAMES[e.game.id].load.fileComplete(t) };
|
|
t.data.onerror = function() { t.data.removeEventListener(t.loadEvent, i, !1), t.data.onerror = null, t.data.canplay = !1, e.fileError(t) }, t.data.addEventListener(t.loadEvent, i, !1), t.data.src = this.transformUrl(t.url, t), t.data.load()
|
|
},
|
|
loadAudioTag: function(t) {
|
|
var e = this;
|
|
if (this.game.sound.touchLocked) t.data = new Audio, t.data.name = t.key, t.data.preload = "auto", t.data.src = this.transformUrl(t.url, t), this.fileComplete(t);
|
|
else {
|
|
t.data = new Audio, t.data.name = t.key;
|
|
var i = function() { t.data.removeEventListener("canplaythrough", i, !1), t.data.onerror = null, e.fileComplete(t) };
|
|
t.data.onerror = function() { t.data.removeEventListener("canplaythrough", i, !1), t.data.onerror = null, e.fileError(t) }, t.data.preload = "auto", t.data.src = this.transformUrl(t.url, t), t.data.addEventListener("canplaythrough", i, !1), t.data.load()
|
|
}
|
|
},
|
|
xhrLoad: function(e, t, i, s, o) {
|
|
if (this.useXDomainRequest && window.XDomainRequest) this.xhrLoadWithXDR(e, t, i, s, o);
|
|
else {
|
|
var n = new XMLHttpRequest;
|
|
n.open("GET", t, !0), n.responseType = i, !1 !== this.headers.requestedWith && n.setRequestHeader("X-Requested-With", this.headers.requestedWith), this.headers[e.type] && n.setRequestHeader("Accept", this.headers[e.type]), o = o || this.fileError;
|
|
var a = this;
|
|
n.onload = function() { try { return 4 === n.readyState && 400 <= n.status && n.status <= 599 ? o.call(a, e, n) : s.call(a, e, n) } catch (t) { a.hasLoaded ? window.console : a.asyncComplete(e, t.message || "Exception") } }, n.onerror = function() { try { return o.call(a, e, n) } catch (t) { a.hasLoaded ? window.console : a.asyncComplete(e, t.message || "Exception") } }, e.requestObject = n, e.requestUrl = t, n.send()
|
|
}
|
|
},
|
|
xhrLoadWithXDR: function(e, t, i, s, o) {
|
|
this._warnedAboutXDomainRequest || this.game.device.ie && !(10 <= this.game.device.ieVersion) || (this._warnedAboutXDomainRequest = !0);
|
|
var n = new window.XDomainRequest;
|
|
n.open("GET", t, !0), n.responseType = i, n.timeout = 3e3, o = o || this.fileError;
|
|
var a = this;
|
|
n.onerror = function() { try { return o.call(a, e, n) } catch (t) { a.asyncComplete(e, t.message || "Exception") } }, n.ontimeout = function() { try { return o.call(a, e, n) } catch (t) { a.asyncComplete(e, t.message || "Exception") } }, n.onprogress = function() {}, n.onload = function() { try { return 4 === n.readyState && 400 <= n.status && n.status <= 599 ? o.call(a, e, n) : s.call(a, e, n) } catch (t) { a.asyncComplete(e, t.message || "Exception") } }, e.requestObject = n, e.requestUrl = t, setTimeout(function() { n.send() }, 0)
|
|
},
|
|
getVideoURL: function(t) { for (var e = 0; e < t.length; e++) { var i, s = t[e]; if (s.uri) { if (i = s.type, s = s.uri, this.game.device.canPlayVideo(i)) return s } else { if (0 === s.indexOf("blob:") || 0 === s.indexOf("data:")) return s; if (0 <= s.indexOf("?") && (s = s.substr(0, s.indexOf("?"))), i = s.substr((Math.max(0, s.lastIndexOf(".")) || 1 / 0) + 1).toLowerCase(), this.game.device.canPlayVideo(i)) return t[e] } } return null },
|
|
getAudioURL: function(t) { if (this.game.sound.noAudio) return null; for (var e = 0; e < t.length; e++) { var i, s = t[e]; if (s.uri) { if (i = s.type, s = s.uri, this.game.device.canPlayAudio(i)) return s } else { if (0 === s.indexOf("blob:") || 0 === s.indexOf("data:")) return s; if (0 <= s.indexOf("?") && (s = s.substr(0, s.indexOf("?"))), i = s.substr((Math.max(0, s.lastIndexOf(".")) || 1 / 0) + 1).toLowerCase(), this.game.device.canPlayAudio(i)) return t[e] } } return null },
|
|
fileError: function(t, e, i) { var s = "error loading asset from URL " + (t.requestUrl || this.transformUrl(t.url, t));!i && e && (i = e.status), i && (s = s + " (" + i + ")"), this.asyncComplete(t, s) },
|
|
fileComplete: function(e, t) {
|
|
var i = !0;
|
|
switch (e.type) {
|
|
case "packfile":
|
|
var s = JSON.parse(t.responseText);
|
|
e.data = s || {};
|
|
break;
|
|
case "image":
|
|
this.cache.addImage(e.key, e.url, e.data);
|
|
break;
|
|
case "spritesheet":
|
|
this.cache.addSpriteSheet(e.key, e.url, e.data, e.frameWidth, e.frameHeight, e.frameMax, e.margin, e.spacing);
|
|
break;
|
|
case "textureatlas":
|
|
if (null == e.atlasURL) this.cache.addTextureAtlas(e.key, e.url, e.data, e.atlasData, e.format);
|
|
else if (i = !1, e.format === H.Loader.TEXTURE_ATLAS_JSON_ARRAY || e.format === H.Loader.TEXTURE_ATLAS_JSON_HASH || e.format === H.Loader.TEXTURE_ATLAS_JSON_PYXEL) this.xhrLoad(e, this.transformUrl(e.atlasURL, e), "text", this.jsonLoadComplete);
|
|
else {
|
|
if (e.format !== H.Loader.TEXTURE_ATLAS_XML_STARLING) throw new Error("Phaser.Loader. Invalid Texture Atlas format: " + e.format);
|
|
this.xhrLoad(e, this.transformUrl(e.atlasURL, e), "text", this.xmlLoadComplete)
|
|
}
|
|
break;
|
|
case "bitmapfont":
|
|
e.atlasURL ? (i = !1, this.xhrLoad(e, this.transformUrl(e.atlasURL, e), "text", function(t, e) { var i; try { i = JSON.parse(e.responseText) } catch (t) {} i ? (t.atlasType = "json", this.jsonLoadComplete(t, e)) : (t.atlasType = "xml", this.xmlLoadComplete(t, e)) })) : this.cache.addBitmapFont(e.key, e.url, e.data, e.atlasData, e.atlasType, e.xSpacing, e.ySpacing);
|
|
break;
|
|
case "video":
|
|
if (e.asBlob) try { e.data = t.response }
|
|
catch (t) { throw new Error("Phaser.Loader. Unable to parse video file as Blob: " + e.key) } this.cache.addVideo(e.key, e.url, e.data, e.asBlob);
|
|
break;
|
|
case "audio":
|
|
this.game.sound.usingWebAudio ? (e.data = t.response, this.cache.addSound(e.key, e.url, e.data, !0, !1), e.autoDecode && this.game.sound.decode(e.key)) : this.cache.addSound(e.key, e.url, e.data, !1, !0);
|
|
break;
|
|
case "text":
|
|
e.data = t.responseText, this.cache.addText(e.key, e.url, e.data);
|
|
break;
|
|
case "shader":
|
|
e.data = t.responseText, this.cache.addShader(e.key, e.url, e.data);
|
|
break;
|
|
case "physics":
|
|
s = JSON.parse(t.responseText);
|
|
this.cache.addPhysicsData(e.key, e.url, s, e.format);
|
|
break;
|
|
case "script":
|
|
e.data = document.createElement("script"), e.data.language = "javascript", e.data.type = "text/javascript", e.data.defer = !1, e.data.text = t.responseText, document.head.appendChild(e.data), e.callback && (e.data = e.callback.call(e.callbackContext, e.key, t.responseText));
|
|
break;
|
|
case "binary":
|
|
e.callback ? e.data = e.callback.call(e.callbackContext, e.key, t.response) : e.data = t.response, this.cache.addBinary(e.key, e.data)
|
|
}
|
|
i && this.asyncComplete(e)
|
|
},
|
|
jsonLoadComplete: function(t, e) { var i = JSON.parse(e.responseText); "tilemap" === t.type ? this.cache.addTilemap(t.key, t.url, i, t.format) : "bitmapfont" === t.type ? this.cache.addBitmapFont(t.key, t.url, t.data, i, t.atlasType, t.xSpacing, t.ySpacing) : "json" === t.type ? this.cache.addJSON(t.key, t.url, i) : this.cache.addTextureAtlas(t.key, t.url, t.data, i, t.format), this.asyncComplete(t) },
|
|
csvLoadComplete: function(t, e) {
|
|
var i = e.responseText;
|
|
this.cache.addTilemap(t.key, t.url, i, t.format), this.asyncComplete(t)
|
|
},
|
|
xmlLoadComplete: function(t, e) {
|
|
var i = e.responseText,
|
|
s = this.parseXml(i);
|
|
if (s) "bitmapfont" === t.type ? this.cache.addBitmapFont(t.key, t.url, t.data, s, t.atlasType, t.xSpacing, t.ySpacing) : "textureatlas" === t.type ? this.cache.addTextureAtlas(t.key, t.url, t.data, s, t.format) : "xml" === t.type && this.cache.addXML(t.key, t.url, s), this.asyncComplete(t);
|
|
else {
|
|
e.responseType || e.contentType;
|
|
this.asyncComplete(t, "invalid XML")
|
|
}
|
|
},
|
|
parseXml: function(t) {
|
|
var e;
|
|
try {
|
|
if (window.DOMParser) e = (new DOMParser).parseFromString(t, "text/xml");
|
|
else(e = new ActiveXObject("Microsoft.XMLDOM")).async = "false", e.loadXML(t)
|
|
}
|
|
catch (t) { e = null }
|
|
return e && e.documentElement && !e.getElementsByTagName("parsererror").length ? e : null
|
|
},
|
|
updateProgress: function() { this.preloadSprite && (0 === this.preloadSprite.direction ? this.preloadSprite.rect.width = Math.floor(this.preloadSprite.width / 100 * this.progress) : this.preloadSprite.rect.height = Math.floor(this.preloadSprite.height / 100 * this.progress), this.preloadSprite.sprite ? this.preloadSprite.sprite.updateCrop() : this.preloadSprite = null) },
|
|
totalLoadedFiles: function() { return this._loadedFileCount },
|
|
totalQueuedFiles: function() { return this._totalFileCount - this._loadedFileCount },
|
|
totalLoadedPacks: function() { return this._totalPackCount },
|
|
totalQueuedPacks: function() { return this._totalPackCount - this._loadedPackCount }
|
|
}, Object.defineProperty(H.Loader.prototype, "progressFloat", { get: function() { var t = this._loadedFileCount / this._totalFileCount * 100; return H.Math.clamp(t || 0, 0, 100) } }), Object.defineProperty(H.Loader.prototype, "progress", { get: function() { return Math.round(this.progressFloat) } }), H.Loader.prototype.constructor = H.Loader, H.LoaderParser = {
|
|
bitmapFont: function(t, e, i, s) { return this.xmlBitmapFont(t, e, i, s) },
|
|
xmlBitmapFont: function(t, e, i, s) {
|
|
var o = {},
|
|
n = t.getElementsByTagName("info")[0],
|
|
a = t.getElementsByTagName("common")[0];
|
|
o.font = n.getAttribute("face"), o.size = parseInt(n.getAttribute("size"), 10), o.lineHeight = parseInt(a.getAttribute("lineHeight"), 10) + s, o.chars = {};
|
|
for (var r = t.getElementsByTagName("char"), h = 0; h < r.length; h++) {
|
|
var l = parseInt(r[h].getAttribute("id"), 10);
|
|
o.chars[l] = { x: parseInt(r[h].getAttribute("x"), 10), y: parseInt(r[h].getAttribute("y"), 10), width: parseInt(r[h].getAttribute("width"), 10), height: parseInt(r[h].getAttribute("height"), 10), xOffset: parseInt(r[h].getAttribute("xoffset"), 10), yOffset: parseInt(r[h].getAttribute("yoffset"), 10), xAdvance: parseInt(r[h].getAttribute("xadvance"), 10) + i, kerning: {} }
|
|
}
|
|
var c = t.getElementsByTagName("kerning");
|
|
for (h = 0; h < c.length; h++) {
|
|
var p = parseInt(c[h].getAttribute("first"), 10),
|
|
u = parseInt(c[h].getAttribute("second"), 10),
|
|
d = parseInt(c[h].getAttribute("amount"), 10);
|
|
o.chars[u].kerning[p] = d
|
|
}
|
|
return this.finalizeBitmapFont(e, o)
|
|
},
|
|
jsonBitmapFont: function(t, e, i, s) {
|
|
var o = { font: t.font.info._face, size: parseInt(t.font.info._size, 10), lineHeight: parseInt(t.font.common._lineHeight, 10) + s, chars: {} };
|
|
return t.font.chars.char.forEach(function(t) {
|
|
var e = parseInt(t._id, 10);
|
|
o.chars[e] = { x: parseInt(t._x, 10), y: parseInt(t._y, 10), width: parseInt(t._width, 10), height: parseInt(t._height, 10), xOffset: parseInt(t._xoffset, 10), yOffset: parseInt(t._yoffset, 10), xAdvance: parseInt(t._xadvance, 10) + i, kerning: {} }
|
|
}), t.font.kernings && t.font.kernings.kerning && t.font.kernings.kerning.forEach(function(t) { o.chars[t._second].kerning[t._first] = parseInt(t._amount, 10) }), this.finalizeBitmapFont(e, o)
|
|
},
|
|
finalizeBitmapFont: function(i, s) {
|
|
return Object.keys(s.chars).forEach(function(t) {
|
|
var e = s.chars[t];
|
|
e.texture = new PIXI.Texture(i, new H.Rectangle(e.x, e.y, e.width, e.height))
|
|
}), s
|
|
}
|
|
}, H.AudioSprite = function(t, e) {
|
|
for (var i in this.game = t, this.key = e, this.config = this.game.cache.getJSON(e + "-audioatlas"), this.autoplayKey = null, this.autoplay = !1, this.sounds = {}, this.config.spritemap) {
|
|
var s = this.config.spritemap[i],
|
|
o = this.game.add.sound(this.key);
|
|
o.addMarker(i, s.start, s.end - s.start, null, s.loop), this.sounds[i] = o
|
|
}
|
|
this.config.autoplay && (this.autoplayKey = this.config.autoplay, this.play(this.autoplayKey), this.autoplay = this.sounds[this.autoplayKey])
|
|
}, H.AudioSprite.prototype = {
|
|
play: function(t, e) { return void 0 === e && (e = 1), this.sounds[t].play(t, null, e) },
|
|
stop: function(t) {
|
|
if (t) this.sounds[t].stop();
|
|
else
|
|
for (var e in this.sounds) this.sounds[e].stop()
|
|
},
|
|
get: function(t) { return this.sounds[t] }
|
|
}, H.AudioSprite.prototype.constructor = H.AudioSprite, H.Sound = function(t, e, i, s, o) { void 0 === i && (i = 1), void 0 === s && (s = !1), void 0 === o && (o = t.sound.connectToMaster), this.game = t, this.name = e, this.key = e, this.loop = s, this.markers = {}, this.context = null, this.autoplay = !1, this.totalDuration = 0, this.startTime = 0, this.currentTime = 0, this.duration = 0, this.durationMS = 0, this.position = 0, this.stopTime = 0, this.paused = !1, this.pausedPosition = 0, this.pausedTime = 0, this.isPlaying = !1, this.currentMarker = "", this.fadeTween = null, this.pendingPlayback = !1, this.override = !1, this.allowMultiple = !1, this.usingWebAudio = this.game.sound.usingWebAudio, this.usingAudioTag = this.game.sound.usingAudioTag, this.externalNode = null, this.masterGainNode = null, this.gainNode = null, this._sound = null, this.usingWebAudio ? (this.context = this.game.sound.context, this.masterGainNode = this.game.sound.masterGain, void 0 === this.context.createGain ? this.gainNode = this.context.createGainNode() : this.gainNode = this.context.createGain(), this.gainNode.gain.value = i * this.game.sound.volume, o && this.gainNode.connect(this.masterGainNode)) : this.usingAudioTag && (this.game.cache.getSound(e) && this.game.cache.isSoundReady(e) ? (this._sound = this.game.cache.getSoundData(e), this.totalDuration = 0, this._sound.duration && (this.totalDuration = this._sound.duration)) : this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this)), this.onDecoded = new H.Signal, this.onPlay = new H.Signal, this.onPause = new H.Signal, this.onResume = new H.Signal, this.onLoop = new H.Signal, this.onStop = new H.Signal, this.onMute = new H.Signal, this.onMarkerComplete = new H.Signal, this.onFadeComplete = new H.Signal, this._volume = i, this._buffer = null, this._muted = !1, this._tempMarker = 0, this._tempPosition = 0, this._tempVolume = 0, this._tempPause = 0, this._muteVolume = 0, this._tempLoop = 0, this._paused = !1, this._onDecodedEventDispatched = !1 }, H.Sound.prototype = {
|
|
soundHasUnlocked: function(t) { t === this.key && (this._sound = this.game.cache.getSoundData(this.key), this.totalDuration = this._sound.duration) },
|
|
addMarker: function(t, e, i, s, o) { null == i && (i = 1), null == s && (s = 1), void 0 === o && (o = !1), this.markers[t] = { name: t, start: e, stop: e + i, volume: s, duration: i, durationMS: 1e3 * i, loop: o } },
|
|
removeMarker: function(t) { delete this.markers[t] },
|
|
onEndedHandler: function() { this._sound.onended = null, this.isPlaying = !1, this.currentTime = this.durationMS, this.stop() },
|
|
update: function() { this.game.cache.checkSoundKey(this.key) ? (this.isDecoded && !this._onDecodedEventDispatched && (this.onDecoded.dispatch(this), this._onDecodedEventDispatched = !0), this.pendingPlayback && this.game.cache.isSoundReady(this.key) && (this.pendingPlayback = !1, this.play(this._tempMarker, this._tempPosition, this._tempVolume, this._tempLoop)), this.isPlaying && (this.currentTime = this.game.time.time - this.startTime, this.currentTime >= this.durationMS && (this.usingWebAudio ? this.loop ? (this.onLoop.dispatch(this), this.isPlaying = !1, "" === this.currentMarker ? (this.currentTime = 0, this.startTime = this.game.time.time, this.isPlaying = !0) : (this.onMarkerComplete.dispatch(this.currentMarker, this), this.play(this.currentMarker, 0, this.volume, !0, !0))) : "" !== this.currentMarker && this.stop() : this.loop ? (this.onLoop.dispatch(this), "" === this.currentMarker && (this.currentTime = 0, this.startTime = this.game.time.time), this.isPlaying = !1, this.play(this.currentMarker, 0, this.volume, !0, !0)) : this.stop()))) : this.destroy() },
|
|
loopFull: function(t) { return this.play(null, 0, t, !0) },
|
|
play: function(t, e, i, s, o) {
|
|
if (void 0 !== t && !1 !== t && null !== t || (t = ""), void 0 === o && (o = !0), this.isPlaying && !this.allowMultiple && !o && !this.override) return this;
|
|
if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || o)) {
|
|
if (this.usingWebAudio) {
|
|
if (void 0 === this._sound.stop) this._sound.noteOff(0);
|
|
else try { this._sound.stop(0) }
|
|
catch (t) {} this.externalNode ? this._sound.disconnect(this.externalNode) : this.gainNode && this._sound.disconnect(this.gainNode)
|
|
}
|
|
else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
|
|
this.isPlaying = !1
|
|
}
|
|
var n = Object.keys(this.markers);
|
|
if ("" === t && 1 === n.length && (t = n[0]), "" === t && 0 < n.length) return this;
|
|
if ("" !== t) {
|
|
if (!this.markers[t]) return this;
|
|
this.currentMarker = t, this.position = this.markers[t].start, this.volume = this.markers[t].volume, this.loop = this.markers[t].loop, this.duration = this.markers[t].duration, this.durationMS = this.markers[t].durationMS, void 0 !== i && (this.volume = i), void 0 !== s && (this.loop = s), this._tempMarker = t, this._tempPosition = this.position, this._tempVolume = this.volume, this._tempLoop = this.loop
|
|
}
|
|
else e = e || 0, void 0 === i && (i = this._volume), void 0 === s && (s = this.loop), this.position = Math.max(0, e), this.volume = i, this.loop = s, this.duration = 0, this.durationMS = 0, this._tempMarker = t, this._tempPosition = e, this._tempVolume = i, this._tempLoop = s;
|
|
return this.usingWebAudio ? this.game.cache.isSoundDecoded(this.key) ? (this._sound = this.context.createBufferSource(), this.externalNode ? this._sound.connect(this.externalNode) : this._sound.connect(this.gainNode), this._buffer = this.game.cache.getSoundData(this.key), this._sound.buffer = this._buffer, this.loop && "" === t && (this._sound.loop = !0), this.loop || "" !== t || (this._sound.onended = this.onEndedHandler.bind(this)), this.totalDuration = this._sound.buffer.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = Math.ceil(1e3 * this.totalDuration)), void 0 === this._sound.start ? this._sound.noteGrainOn(0, this.position, this.duration) : this.loop && "" === t ? this._sound.start(0, 0) : this._sound.start(0, this.position, this.duration), this.isPlaying = !0, this.startTime = this.game.time.time, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : (this.pendingPlayback = !0, this.game.cache.getSound(this.key) && !1 === this.game.cache.getSound(this.key).isDecoding && this.game.sound.decode(this.key, this)) : this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked ? (this.game.cache.reloadSound(this.key), this.pendingPlayback = !0) : this._sound && (this.game.device.wechatMinigame || this.game.device.cocoonJS || 4 === this._sound.readyState) ? (this.loop && (this._sound.loop = !0), !this.loop && "" === t && this.game.device.wechatMinigame && this._sound.addEventListener("ended", this.onEndedHandler.bind(this)), this._sound.play(), this.totalDuration = this._sound.duration, 0 === this.duration && (this.duration = this.totalDuration, this.durationMS = 1e3 * this.totalDuration), this._sound.currentTime = this.position, this._sound.muted = this._muted, this._muted || this.game.sound.mute ? this._sound.volume = 0 : this._sound.volume = this._volume, this.isPlaying = !0, this.startTime = this.game.time.time, this.currentTime = 0, this.stopTime = this.startTime + this.durationMS, this.onPlay.dispatch(this)) : this.pendingPlayback = !0, this
|
|
},
|
|
restart: function(t, e, i, s) { t = t || "", e = e || 0, i = i || 1, void 0 === s && (s = !1), this.play(t, e, i, s, !0) },
|
|
pause: function() { this.isPlaying && this._sound && (this.paused = !0, this.pausedPosition = this.currentTime, this.pausedTime = this.game.time.time, this._tempPause = this._sound.currentTime, this.onPause.dispatch(this), this.stop()) },
|
|
resume: function() {
|
|
if (this.paused && this._sound) {
|
|
if (this.usingWebAudio) {
|
|
var t = Math.max(0, this.position + this.pausedPosition / 1e3);
|
|
this._sound = this.context.createBufferSource(), this._sound.buffer = this._buffer, this.externalNode ? this._sound.connect(this.externalNode) : this._sound.connect(this.gainNode), this.loop && (this._sound.loop = !0), this.loop || "" !== this.currentMarker || (this._sound.onended = this.onEndedHandler.bind(this));
|
|
var e = this.duration - this.pausedPosition / 1e3;
|
|
void 0 === this._sound.start ? this._sound.noteGrainOn(0, t, e) : this.loop && this.game.device.chrome ? 42 === this.game.device.chromeVersion ? this._sound.start(0) : this._sound.start(0, t) : this._sound.start(0, t, e)
|
|
}
|
|
else this._sound.currentTime = this._tempPause, this._sound.play();
|
|
this.isPlaying = !0, this.paused = !1, this.startTime += this.game.time.time - this.pausedTime, this.onResume.dispatch(this)
|
|
}
|
|
},
|
|
stop: function() {
|
|
if (this.isPlaying && this._sound)
|
|
if (this.usingWebAudio) {
|
|
if (void 0 === this._sound.stop) this._sound.noteOff(0);
|
|
else try { this._sound.stop(0) }
|
|
catch (t) {} this.externalNode ? this._sound.disconnect(this.externalNode) : this.gainNode && this._sound.disconnect(this.gainNode)
|
|
}
|
|
else this.usingAudioTag && (this._sound.pause(), this._sound.currentTime = 0);
|
|
if (this.pendingPlayback = !1, this.isPlaying = !1, !this.paused) { var t = this.currentMarker; "" !== this.currentMarker && this.onMarkerComplete.dispatch(this.currentMarker, this), this.currentMarker = "", null !== this.fadeTween && this.fadeTween.stop(), this.onStop.dispatch(this, t) }
|
|
},
|
|
fadeIn: function(t, e, i) { void 0 === e && (e = !1), void 0 === i && (i = this.currentMarker), this.paused || (this.play(i, 0, 0, e), this.fadeTo(t, 1)) },
|
|
fadeOut: function(t) { this.fadeTo(t, 0) },
|
|
fadeTo: function(t, e) { this.isPlaying && !this.paused && e !== this.volume && (void 0 === t && (t = 1e3), void 0 !== e && (this.fadeTween = this.game.add.tween(this).to({ volume: e }, t, H.Easing.Linear.None, !0), this.fadeTween.onComplete.add(this.fadeComplete, this))) },
|
|
fadeComplete: function() { this.onFadeComplete.dispatch(this, this.volume), 0 === this.volume && this.stop() },
|
|
updateGlobalVolume: function(t) { this.usingAudioTag && this._sound && (this._sound.volume = t * this._volume) },
|
|
destroy: function(t) { void 0 === t && (t = !0), this.stop(), t ? this.game.sound.remove(this) : (this.markers = {}, this.context = null, this._buffer = null, this.externalNode = null, this.onDecoded.dispose(), this.onPlay.dispose(), this.onPause.dispose(), this.onResume.dispose(), this.onLoop.dispose(), this.onStop.dispose(), this.onMute.dispose(), this.onMarkerComplete.dispose()) }
|
|
}, H.Sound.prototype.constructor = H.Sound, Object.defineProperty(H.Sound.prototype, "isDecoding", { get: function() { return this.game.cache.getSound(this.key).isDecoding } }), Object.defineProperty(H.Sound.prototype, "isDecoded", { get: function() { return this.game.cache.isSoundDecoded(this.key) } }), Object.defineProperty(H.Sound.prototype, "mute", {
|
|
get: function() { return this._muted || this.game.sound.mute },
|
|
set: function(t) {
|
|
(t = t || !1) !== this._muted && (t ? (this._muted = !0, this._muteVolume = this._tempVolume, this.game.device.wechatMinigame ? this._sound.pause() : this.usingWebAudio ? this.gainNode.gain.value = 0 : this.usingAudioTag && this._sound && (this._sound.volume = 0)) : (this._muted = !1, this.game.device.wechatMinigame && this.isPlaying ? this._sound.play() : this.usingWebAudio ? this.gainNode.gain.value = this._muteVolume : this.usingAudioTag && this._sound && (this._sound.volume = this._muteVolume)), this.onMute.dispatch(this))
|
|
}
|
|
}), Object.defineProperty(H.Sound.prototype, "volume", { get: function() { return this._volume }, set: function(t) { this.game.device.firefox && this.usingAudioTag && (t = this.game.math.clamp(t, 0, 1)), this._muted ? this._muteVolume = t : (this._tempVolume = t, this._volume = t, this.usingWebAudio ? this.gainNode.gain.value = t : this.usingAudioTag && this._sound && (this._sound.volume = t)) } }), H.SoundManager = function(t) { this.game = t, this.onSoundDecode = new H.Signal, this.onVolumeChange = new H.Signal, this.onMute = new H.Signal, this.onUnMute = new H.Signal, this.context = null, this.usingWebAudio = !1, this.usingAudioTag = !1, this.noAudio = !1, this.connectToMaster = !0, this.touchLocked = !1, this.channels = 32, this.muteOnPause = !0, this._codeMuted = !1, this._muted = !1, this._unlockSource = null, this._volume = 1, this._sounds = [], this._watchList = new H.ArraySet, this._watching = !1, this._watchCallback = null, this._watchContext = null }, H.SoundManager.prototype = {
|
|
boot: function() {
|
|
if (this.game.device.iOS && !1 === this.game.device.webAudio && (this.channels = 1), window.PhaserGlobal) { if (!0 === window.PhaserGlobal.disableAudio) return this.noAudio = !0, void(this.touchLocked = !1); if (!0 === window.PhaserGlobal.disableWebAudio) return this.usingAudioTag = !0, void(this.touchLocked = !1) }
|
|
if (window.PhaserGlobal && window.PhaserGlobal.audioContext) this.context = window.PhaserGlobal.audioContext;
|
|
else if (window.AudioContext) try { this.context = new window.AudioContext }
|
|
catch (t) { this.context = null, this.usingWebAudio = !1, this.touchLocked = !1 }
|
|
else if (window.webkitAudioContext) try { this.context = new window.webkitAudioContext }
|
|
catch (t) { this.context = null, this.usingWebAudio = !1, this.touchLocked = !1 }
|
|
if (null === this.context) {
|
|
if (void 0 === window.Audio) return void(this.noAudio = !0);
|
|
this.usingAudioTag = !0
|
|
}
|
|
else this.usingWebAudio = !0, void 0 === this.context.createGain ? this.masterGain = this.context.createGainNode() : this.masterGain = this.context.createGain(), this.masterGain.gain.value = 1, this.masterGain.connect(this.context.destination);
|
|
this.noAudio || !this.game.device.cocoonJS && (this.game.device.chrome || this.game.device.iOS || window.PhaserGlobal && window.PhaserGlobal.fakeiOSTouchLock) && this.setTouchLock()
|
|
},
|
|
setTouchLock: function() { this.noAudio || window.PhaserGlobal && !0 === window.PhaserGlobal.disableAudio || (8 < this.game.device.iOSVersion || 55 <= this.game.device.chromeVersion ? this.game.input.touch.addTouchLockCallback(this.unlock, this, !0) : this.game.input.touch.addTouchLockCallback(this.unlock, this), this.touchLocked = !0) },
|
|
unlock: function() {
|
|
if (this.noAudio || !this.touchLocked || null !== this._unlockSource) return !0;
|
|
if (this.usingAudioTag) this.touchLocked = !1, this._unlockSource = null;
|
|
else if (this.usingWebAudio) {
|
|
var t = this.context.createBuffer(1, 1, 22050);
|
|
this._unlockSource = this.context.createBufferSource(), this._unlockSource.buffer = t, this._unlockSource.connect(this.context.destination), void 0 === this._unlockSource.start ? this._unlockSource.noteOn(0) : this._unlockSource.start(0), "suspended" === this._unlockSource.context.state && this._unlockSource.context.resume()
|
|
}
|
|
return !0
|
|
},
|
|
stopAll: function() {
|
|
if (!this.noAudio)
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t] && this._sounds[t].stop()
|
|
},
|
|
pauseAll: function() {
|
|
if (!this.noAudio)
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t] && this._sounds[t].pause()
|
|
},
|
|
resumeAll: function() {
|
|
if (!this.noAudio)
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t] && this._sounds[t].resume()
|
|
},
|
|
decode: function(e, i) { i = i || null; var t = this.game.cache.getSoundData(e); if (t && !1 === this.game.cache.isSoundDecoded(e)) { this.game.cache.updateSound(e, "isDecoding", !0); var s = this; try { this.context.decodeAudioData(t, function(t) { t && (s.game.cache.decodedSound(e, t), s.onSoundDecode.dispatch(e, i)) }) } catch (t) {} } },
|
|
setDecodedCallback: function(t, e, i) {
|
|
"string" == typeof t && (t = [t]), this._watchList.reset();
|
|
for (var s = 0; s < t.length; s++) t[s] instanceof H.Sound ? this.game.cache.isSoundDecoded(t[s].key) || this._watchList.add(t[s].key) : this.game.cache.isSoundDecoded(t[s]) || this._watchList.add(t[s]);
|
|
0 === this._watchList.total ? (this._watching = !1, e.call(i)) : (this._watching = !0, this._watchCallback = e, this._watchContext = i)
|
|
},
|
|
update: function() {
|
|
if (!this.noAudio) {
|
|
!this.touchLocked || null === this._unlockSource || this._unlockSource.playbackState !== this._unlockSource.PLAYING_STATE && this._unlockSource.playbackState !== this._unlockSource.FINISHED_STATE || (this.touchLocked = !1, this._unlockSource = null);
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t].update();
|
|
if (this._watching) {
|
|
for (var e = this._watchList.first; e;) this.game.cache.isSoundDecoded(e) && this._watchList.remove(e), e = this._watchList.next;
|
|
0 === this._watchList.total && (this._watching = !1, this._watchCallback.call(this._watchContext))
|
|
}
|
|
}
|
|
},
|
|
add: function(t, e, i, s) { void 0 === e && (e = 1), void 0 === i && (i = !1), void 0 === s && (s = this.connectToMaster); var o = new H.Sound(this.game, t, e, i, s); return this._sounds.push(o), o },
|
|
addSprite: function(t) { return new H.AudioSprite(this.game, t) },
|
|
remove: function(t) {
|
|
for (var e = this._sounds.length; e--;)
|
|
if (this._sounds[e] === t) return this._sounds[e].destroy(!1), this._sounds.splice(e, 1), !0;
|
|
return !1
|
|
},
|
|
removeByKey: function(t) { for (var e = this._sounds.length, i = 0; e--;) this._sounds[e].key === t && (this._sounds[e].destroy(!1), this._sounds.splice(e, 1), i++); return i },
|
|
play: function(t, e, i) { if (!this.noAudio) { var s = this.add(t, e, i); return s.play(), s } },
|
|
setMute: function() {
|
|
if (!this._muted) {
|
|
this._muted = !0, this.usingWebAudio && (this._muteVolume = this.masterGain.gain.value, this.masterGain.gain.value = 0);
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t].usingAudioTag && (this._sounds[t].mute = !0);
|
|
this.onMute.dispatch()
|
|
}
|
|
},
|
|
unsetMute: function() {
|
|
if (this._muted && !this._codeMuted) {
|
|
this._muted = !1, this.usingWebAudio && (this.masterGain.gain.value = this._muteVolume);
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t].usingAudioTag && (this._sounds[t].mute = !1);
|
|
this.onUnMute.dispatch()
|
|
}
|
|
},
|
|
destroy: function() {
|
|
this.stopAll();
|
|
for (var t = 0; t < this._sounds.length; t++) this._sounds[t] && this._sounds[t].destroy();
|
|
this._sounds = [], this.onSoundDecode.dispose(), this.context && (window.PhaserGlobal ? window.PhaserGlobal.audioContext = this.context : this.context.close && this.context.close())
|
|
}
|
|
}, H.SoundManager.prototype.constructor = H.SoundManager, Object.defineProperty(H.SoundManager.prototype, "mute", {
|
|
get: function() { return this._muted },
|
|
set: function(t) {
|
|
if (t = t || !1) {
|
|
if (this._muted) return;
|
|
this._codeMuted = !0, this.setMute()
|
|
}
|
|
else {
|
|
if (!this._muted) return;
|
|
this._codeMuted = !1, this.unsetMute()
|
|
}
|
|
}
|
|
}), Object.defineProperty(H.SoundManager.prototype, "volume", {
|
|
get: function() { return this._volume },
|
|
set: function(t) {
|
|
if (t < 0 ? t = 0 : 1 < t && (t = 1), this._volume !== t) {
|
|
if (this._volume = t, this.usingWebAudio) this.masterGain.gain.value = t;
|
|
else
|
|
for (var e = 0; e < this._sounds.length; e++) this._sounds[e].usingAudioTag && this._sounds[e].updateGlobalVolume(t);
|
|
this.onVolumeChange.dispatch(t)
|
|
}
|
|
}
|
|
}), H.ScaleManager = function(t, e, i) { this.game = t, this.dom = H.DOM, this.grid = null, this.width = 0, this.height = 0, this.minWidth = null, this.maxWidth = null, this.minHeight = null, this.maxHeight = null, this.offset = new H.Point, this.forceLandscape = !1, this.forcePortrait = !1, this.incorrectOrientation = !1, this._pageAlignHorizontally = !1, this._pageAlignVertically = !1, this.onOrientationChange = new H.Signal, this.enterIncorrectOrientation = new H.Signal, this.leaveIncorrectOrientation = new H.Signal, this.hasPhaserSetFullScreen = !1, this.fullScreenTarget = null, this._createdFullScreenTarget = null, this.onFullScreenInit = new H.Signal, this.onFullScreenChange = new H.Signal, this.onFullScreenError = new H.Signal, this.screenOrientation = this.dom.getScreenOrientation(), this.scaleFactor = new H.Point(1, 1), this.scaleFactorInversed = new H.Point(1, 1), this.margin = { left: 0, top: 0, right: 0, bottom: 0, x: 0, y: 0 }, this.bounds = new H.Rectangle, this.aspectRatio = 0, this.sourceAspectRatio = 0, this.event = null, this.windowConstraints = { right: "layout", bottom: "" }, this.compatibility = { supportsFullScreen: !1, orientationFallback: null, noMargins: !1, scrollTo: null, forceMinimumDocumentHeight: !1, canExpandParent: !0, clickTrampoline: "" }, this._scaleMode = H.ScaleManager.NO_SCALE, this._fullScreenScaleMode = H.ScaleManager.NO_SCALE, this.parentIsWindow = !1, this.parentNode = null, this.parentScaleFactor = new H.Point(1, 1), this.trackParentInterval = 2e3, this.onSizeChange = new H.Signal, this.onResize = null, this.onResizeContext = null, this._pendingScaleMode = null, this._fullScreenRestore = null, this._gameSize = new H.Rectangle, this._userScaleFactor = new H.Point(1, 1), this._userScaleTrim = new H.Point(0, 0), this._lastUpdate = 0, this._updateThrottle = 0, this._updateThrottleReset = 100, this._parentBounds = new H.Rectangle, this._tempBounds = new H.Rectangle, this._lastReportedCanvasSize = new H.Rectangle, this._lastReportedGameSize = new H.Rectangle, this._booted = !1, t.config && this.parseConfig(t.config), this.setupScale(e, i) }, H.ScaleManager.EXACT_FIT = 0, H.ScaleManager.NO_SCALE = 1, H.ScaleManager.SHOW_ALL = 2, H.ScaleManager.RESIZE = 3, H.ScaleManager.USER_SCALE = 4, H.ScaleManager.prototype = {
|
|
boot: function() {
|
|
var t = this.compatibility;
|
|
t.supportsFullScreen = this.game.device.fullscreen && !this.game.device.cocoonJS, this.game.device.iPad || this.game.device.webApp || this.game.device.desktop || (this.game.device.android && !this.game.device.chrome ? t.scrollTo = new H.Point(0, 1) : t.scrollTo = new H.Point(0, 0)), this.game.device.desktop ? (t.orientationFallback = "screen", t.clickTrampoline = "when-not-mouse") : (t.orientationFallback = "", t.clickTrampoline = "");
|
|
var e = this;
|
|
this._orientationChange = function(t) { return e.orientationChange(t) }, this._windowResize = function(t) { return e.windowResize(t) }, window.addEventListener("orientationchange", this._orientationChange, !1), window.addEventListener("resize", this._windowResize, !1), this.compatibility.supportsFullScreen && (this._fullScreenChange = function(t) { return e.fullScreenChange(t) }, this._fullScreenError = function(t) { return e.fullScreenError(t) }, document.addEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.addEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.addEventListener("MSFullscreenChange", this._fullScreenChange, !1), document.addEventListener("fullscreenchange", this._fullScreenChange, !1), document.addEventListener("webkitfullscreenerror", this._fullScreenError, !1), document.addEventListener("mozfullscreenerror", this._fullScreenError, !1), document.addEventListener("MSFullscreenError", this._fullScreenError, !1), document.addEventListener("fullscreenerror", this._fullScreenError, !1)), this.game.onResume.add(this._gameResumed, this), this.dom.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height), this.setGameSize(this.game.width, this.game.height), this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback), H.FlexGrid && (this.grid = new H.FlexGrid(this, this.width, this.height)), this._booted = !0, null !== this._pendingScaleMode && (this.scaleMode = this._pendingScaleMode, this._pendingScaleMode = null)
|
|
},
|
|
parseConfig: function(t) { void 0 !== t.scaleMode && (this._booted ? this.scaleMode = t.scaleMode : this._pendingScaleMode = t.scaleMode), void 0 !== t.fullScreenScaleMode && (this.fullScreenScaleMode = t.fullScreenScaleMode), t.fullScreenTarget && (this.fullScreenTarget = t.fullScreenTarget) },
|
|
setupScale: function(t, e) {
|
|
var i, s = new H.Rectangle;
|
|
"" !== this.game.parent && ("string" == typeof this.game.parent ? i = document.getElementById(this.game.parent) : this.game.parent && 1 === this.game.parent.nodeType && (i = this.game.parent)), i ? (this.parentNode = i, this.parentIsWindow = !1, this.getParentBounds(this._parentBounds), s.width = this._parentBounds.width, s.height = this._parentBounds.height, this.offset.set(this._parentBounds.x, this._parentBounds.y)) : (this.parentNode = null, this.parentIsWindow = !0, s.width = this.dom.visualBounds.width, s.height = this.dom.visualBounds.height, this.offset.set(0, 0));
|
|
var o = 0,
|
|
n = 0;
|
|
o = "number" == typeof t ? t : (this.parentScaleFactor.x = parseInt(t, 10) / 100, s.width * this.parentScaleFactor.x), n = "number" == typeof e ? e : (this.parentScaleFactor.y = parseInt(e, 10) / 100, s.height * this.parentScaleFactor.y), o = Math.floor(o), n = Math.floor(n), this._gameSize.setTo(0, 0, o, n), this.updateDimensions(o, n, !1)
|
|
},
|
|
_gameResumed: function() { this.queueUpdate(!0) },
|
|
setGameSize: function(t, e) { this._gameSize.setTo(0, 0, t, e), this.currentScaleMode !== H.ScaleManager.RESIZE && this.updateDimensions(t, e, !0), this.queueUpdate(!0) },
|
|
setUserScale: function(t, e, i, s) { this._userScaleFactor.setTo(t, e), this._userScaleTrim.setTo(0 | i, 0 | s), this.queueUpdate(!0) },
|
|
setResizeCallback: function(t, e) { this.onResize = t, this.onResizeContext = e },
|
|
signalSizeChange: function() {
|
|
if (!H.Rectangle.sameDimensions(this, this._lastReportedCanvasSize) || !H.Rectangle.sameDimensions(this.game, this._lastReportedGameSize)) {
|
|
var t = this.width,
|
|
e = this.height;
|
|
this._lastReportedCanvasSize.setTo(0, 0, t, e), this._lastReportedGameSize.setTo(0, 0, this.game.width, this.game.height), this.grid && this.grid.onResize(t, e), this.onSizeChange.dispatch(this, t, e), this.currentScaleMode === H.ScaleManager.RESIZE && (this.game.state.resize(t, e), this.game.load.resize(t, e))
|
|
}
|
|
},
|
|
setMinMax: function(t, e, i, s) { this.minWidth = t, this.minHeight = e, void 0 !== i && (this.maxWidth = i), void 0 !== s && (this.maxHeight = s) },
|
|
preUpdate: function() {
|
|
if (!(this.game.time.time < this._lastUpdate + this._updateThrottle)) {
|
|
var t = this._updateThrottle;
|
|
this._updateThrottleReset = 400 <= t ? 0 : 100, this.dom.getOffset(this.game.canvas, this.offset);
|
|
var e = this._parentBounds.width,
|
|
i = this._parentBounds.height,
|
|
s = this.getParentBounds(this._parentBounds),
|
|
o = s.width !== e || s.height !== i,
|
|
n = this.updateOrientationState();
|
|
(o || n) && (this.onResize && this.onResize.call(this.onResizeContext, this, s), this.updateLayout(), this.signalSizeChange());
|
|
var a = 2 * this._updateThrottle;
|
|
this._updateThrottle < t && (a = Math.min(t, this._updateThrottleReset)), this._updateThrottle = H.Math.clamp(a, 25, this.trackParentInterval), this._lastUpdate = this.game.time.time
|
|
}
|
|
},
|
|
pauseUpdate: function() { this.preUpdate(), this._updateThrottle = this.trackParentInterval },
|
|
updateDimensions: function(t, e, i) { this.width = t * this.parentScaleFactor.x, this.height = e * this.parentScaleFactor.y, this.game.width = this.width, this.game.height = this.height, this.sourceAspectRatio = this.width / this.height, this.updateScalingAndBounds(), i && (this.game.renderer.resize(this.width, this.height), this.game.camera.setSize(this.width, this.height), this.game.world.resize(this.width, this.height)) },
|
|
updateScalingAndBounds: function() { this.scaleFactor.x = this.game.width / this.width, this.scaleFactor.y = this.game.height / this.height, this.scaleFactorInversed.x = this.width / this.game.width, this.scaleFactorInversed.y = this.height / this.game.height, this.aspectRatio = this.width / this.height, this.game.canvas && this.dom.getOffset(this.game.canvas, this.offset), this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height), this.game.input && this.game.input.scale && this.game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y) },
|
|
forceOrientation: function(t, e) { void 0 === e && (e = !1), this.forceLandscape = t, this.forcePortrait = e, this.queueUpdate(!0) },
|
|
classifyOrientation: function(t) { return "portrait-primary" === t || "portrait-secondary" === t ? "portrait" : "landscape-primary" === t || "landscape-secondary" === t ? "landscape" : null },
|
|
updateOrientationState: function() {
|
|
var t = this.screenOrientation,
|
|
e = this.incorrectOrientation;
|
|
this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback), this.incorrectOrientation = this.forceLandscape && !this.isLandscape || this.forcePortrait && !this.isPortrait;
|
|
var i = t !== this.screenOrientation,
|
|
s = e !== this.incorrectOrientation;
|
|
return s && (this.incorrectOrientation ? this.enterIncorrectOrientation.dispatch() : this.leaveIncorrectOrientation.dispatch()), (i || s) && this.onOrientationChange.dispatch(this, t, e), i || s
|
|
},
|
|
orientationChange: function(t) { this.event = t, this.queueUpdate(!0) },
|
|
windowResize: function(t) { this.event = t, this.queueUpdate(!0) },
|
|
scrollTop: function() {
|
|
var t = this.compatibility.scrollTo;
|
|
t && window.scrollTo(t.x, t.y)
|
|
},
|
|
refresh: function() { this.scrollTop(), this.queueUpdate(!0) },
|
|
updateLayout: function() {
|
|
var t = this.currentScaleMode;
|
|
if (t !== H.ScaleManager.RESIZE) {
|
|
if (this.scrollTop(), this.compatibility.forceMinimumDocumentHeight && (document.documentElement.style.minHeight = window.innerHeight + "px"), this.incorrectOrientation ? this.setMaximum() : t === H.ScaleManager.EXACT_FIT ? this.setExactFit() : t === H.ScaleManager.SHOW_ALL ? (!this.isFullScreen && this.boundingParent && this.compatibility.canExpandParent && (this.setShowAll(!0), this.resetCanvas()), this.setShowAll()) : t === H.ScaleManager.NO_SCALE ? (this.width = this.game.width, this.height = this.game.height) : t === H.ScaleManager.USER_SCALE && (this.width = this.game.width * this._userScaleFactor.x - this._userScaleTrim.x, this.height = this.game.height * this._userScaleFactor.y - this._userScaleTrim.y), !this.compatibility.canExpandParent && (t === H.ScaleManager.SHOW_ALL || t === H.ScaleManager.USER_SCALE)) {
|
|
var e = this.getParentBounds(this._tempBounds);
|
|
this.width = Math.min(this.width, e.width), this.height = Math.min(this.height, e.height)
|
|
}
|
|
this.width = 0 | this.width, this.height = 0 | this.height, this.reflowCanvas()
|
|
}
|
|
else this.reflowGame()
|
|
},
|
|
getParentBounds: function(t) {
|
|
var e = t || new H.Rectangle,
|
|
i = this.boundingParent,
|
|
s = this.dom.visualBounds,
|
|
o = this.dom.layoutBounds;
|
|
if (i) {
|
|
var n = i.getBoundingClientRect(),
|
|
a = i.offsetParent ? i.offsetParent.getBoundingClientRect() : i.getBoundingClientRect();
|
|
e.setTo(n.left - a.left, n.top - a.top, n.width, n.height);
|
|
var r = this.windowConstraints;
|
|
if (r.right) {
|
|
var h = "layout" === r.right ? o : s;
|
|
e.right = Math.min(e.right, h.width)
|
|
}
|
|
if (r.bottom) {
|
|
h = "layout" === r.bottom ? o : s;
|
|
e.bottom = Math.min(e.bottom, h.height)
|
|
}
|
|
}
|
|
else e.setTo(0, 0, s.width, s.height);
|
|
return e.setTo(Math.round(e.x), Math.round(e.y), Math.round(e.width), Math.round(e.height)), e
|
|
},
|
|
alignCanvas: function(t, e) {
|
|
var i = this.getParentBounds(this._tempBounds),
|
|
s = this.game.canvas,
|
|
o = this.margin;
|
|
if (t) {
|
|
o.left = o.right = 0;
|
|
var n = s.getBoundingClientRect();
|
|
if (this.width < i.width && !this.incorrectOrientation) {
|
|
var a = n.left - i.x,
|
|
r = i.width / 2 - this.width / 2,
|
|
h = (r = Math.max(r, 0)) - a;
|
|
o.left = Math.round(h)
|
|
}
|
|
s.style.marginLeft = o.left + "px", 0 !== o.left && (o.right = -(i.width - n.width - o.left), s.style.marginRight = o.right + "px")
|
|
}
|
|
if (e) {
|
|
o.top = o.bottom = 0;
|
|
n = s.getBoundingClientRect();
|
|
if (this.height < i.height && !this.incorrectOrientation) {
|
|
a = n.top - i.y, r = i.height / 2 - this.height / 2, h = (r = Math.max(r, 0)) - a;
|
|
o.top = Math.round(h)
|
|
}
|
|
s.style.marginTop = o.top + "px", 0 !== o.top && (o.bottom = -(i.height - n.height - o.top), s.style.marginBottom = o.bottom + "px")
|
|
}
|
|
o.x = o.left, o.y = o.top
|
|
},
|
|
reflowGame: function() {
|
|
this.resetCanvas("", "");
|
|
var t = this.getParentBounds(this._tempBounds);
|
|
this.updateDimensions(t.width, t.height, !0)
|
|
},
|
|
reflowCanvas: function() { this.incorrectOrientation || (this.width = H.Math.clamp(this.width, this.minWidth || 0, this.maxWidth || this.width), this.height = H.Math.clamp(this.height, this.minHeight || 0, this.maxHeight || this.height)), this.resetCanvas(), this.compatibility.noMargins || (this.isFullScreen && this._createdFullScreenTarget ? this.alignCanvas(!0, !0) : this.alignCanvas(this.pageAlignHorizontally, this.pageAlignVertically)), this.updateScalingAndBounds() },
|
|
resetCanvas: function(t, e) {
|
|
void 0 === t && (t = this.width + "px"), void 0 === e && (e = this.height + "px");
|
|
var i = this.game.canvas;
|
|
this.compatibility.noMargins || (i.style.marginLeft = "", i.style.marginTop = "", i.style.marginRight = "", i.style.marginBottom = ""), i.style.width = t, i.style.height = e
|
|
},
|
|
queueUpdate: function(t) { t && (this._parentBounds.width = 0, this._parentBounds.height = 0), this._updateThrottle = this._updateThrottleReset },
|
|
reset: function(t) { t && this.grid && this.grid.reset() },
|
|
setMaximum: function() { this.width = this.dom.visualBounds.width, this.height = this.dom.visualBounds.height },
|
|
setShowAll: function(t) {
|
|
var e, i = this.getParentBounds(this._tempBounds),
|
|
s = i.width,
|
|
o = i.height;
|
|
e = t ? Math.max(o / this.game.height, s / this.game.width) : Math.min(o / this.game.height, s / this.game.width), this.width = Math.round(this.game.width * e), this.height = Math.round(this.game.height * e)
|
|
},
|
|
setExactFit: function() {
|
|
var t = this.getParentBounds(this._tempBounds);
|
|
this.width = t.width, this.height = t.height, this.isFullScreen || (this.maxWidth && (this.width = Math.min(this.width, this.maxWidth)), this.maxHeight && (this.height = Math.min(this.height, this.maxHeight)))
|
|
},
|
|
createFullScreenTarget: function() { var t = document.createElement("div"); return t.style.margin = "0", t.style.padding = "0", t.style.background = "#000", t },
|
|
startFullScreen: function(t, e) {
|
|
if (this.isFullScreen) return !1;
|
|
if (this.compatibility.supportsFullScreen) {
|
|
if ("when-not-mouse" === this.compatibility.clickTrampoline) { var i = this.game.input; if (i.activePointer && i.activePointer !== i.mousePointer && (e || !1 !== e)) return void i.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [t, !1]) } void 0 !== t && this.game.renderType === H.CANVAS && (this.game.stage.smoothed = t);
|
|
var s = this.fullScreenTarget;
|
|
s || (this.cleanupCreatedTarget(), this._createdFullScreenTarget = this.createFullScreenTarget(), s = this._createdFullScreenTarget);
|
|
var o = { targetElement: s };
|
|
if (this.hasPhaserSetFullScreen = !0, this.onFullScreenInit.dispatch(this, o), this._createdFullScreenTarget) {
|
|
var n = this.game.canvas;
|
|
n.parentNode.insertBefore(s, n), s.appendChild(n)
|
|
}
|
|
return this.game.device.fullscreenKeyboard ? s[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT) : s[this.game.device.requestFullscreen](), !0
|
|
}
|
|
var a = this;
|
|
setTimeout(function() { a.fullScreenError() }, 10)
|
|
},
|
|
stopFullScreen: function() { return !(!this.isFullScreen || !this.compatibility.supportsFullScreen) && (this.hasPhaserSetFullScreen = !1, document[this.game.device.cancelFullscreen](), !0) },
|
|
cleanupCreatedTarget: function() {
|
|
var t = this._createdFullScreenTarget;
|
|
if (t && t.parentNode) {
|
|
var e = t.parentNode;
|
|
e.insertBefore(this.game.canvas, t), e.removeChild(t)
|
|
}
|
|
this._createdFullScreenTarget = null
|
|
},
|
|
prepScreenMode: function(t) {
|
|
var e = !!this._createdFullScreenTarget,
|
|
i = this._createdFullScreenTarget || this.fullScreenTarget;
|
|
t ? (e || this.fullScreenScaleMode === H.ScaleManager.EXACT_FIT) && i !== this.game.canvas && (this._fullScreenRestore = { targetWidth: i.style.width, targetHeight: i.style.height }, i.style.width = "100%", i.style.height = "100%") : (this._fullScreenRestore && (i.style.width = this._fullScreenRestore.targetWidth, i.style.height = this._fullScreenRestore.targetHeight, this._fullScreenRestore = null), this.updateDimensions(this._gameSize.width, this._gameSize.height, !0), this.resetCanvas())
|
|
},
|
|
fullScreenChange: function(t) { this.event = t, this.isFullScreen ? this.prepScreenMode(!0) : (this.prepScreenMode(!1), this.cleanupCreatedTarget()), this.updateLayout(), this.queueUpdate(!0), this.onFullScreenChange.dispatch(this, this.width, this.height) },
|
|
fullScreenError: function(t) { this.event = t, this.cleanupCreatedTarget(), this.onFullScreenError.dispatch(this) },
|
|
scaleSprite: function(t, e, i, s) {
|
|
if (void 0 === e && (e = this.width), void 0 === i && (i = this.height), void 0 === s && (s = !1), !t || !t.scale) return t;
|
|
if (t.scale.x = 1, t.scale.y = 1, t.width <= 0 || t.height <= 0 || e <= 0 || i <= 0) return t;
|
|
var o = e,
|
|
n = t.height * e / t.width,
|
|
a = t.width * i / t.height,
|
|
r = i,
|
|
h = e < a;
|
|
return h = h ? s : !s, t.height = h ? (t.width = Math.floor(o), Math.floor(n)) : (t.width = Math.floor(a), Math.floor(r)), t
|
|
},
|
|
destroy: function() { this.game.onResume.remove(this._gameResumed, this), window.removeEventListener("orientationchange", this._orientationChange, !1), window.removeEventListener("resize", this._windowResize, !1), this.compatibility.supportsFullScreen && (document.removeEventListener("webkitfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("mozfullscreenchange", this._fullScreenChange, !1), document.removeEventListener("MSFullscreenChange", this._fullScreenChange, !1), document.removeEventListener("fullscreenchange", this._fullScreenChange, !1), document.removeEventListener("webkitfullscreenerror", this._fullScreenError, !1), document.removeEventListener("mozfullscreenerror", this._fullScreenError, !1), document.removeEventListener("MSFullscreenError", this._fullScreenError, !1), document.removeEventListener("fullscreenerror", this._fullScreenError, !1)) }
|
|
}, H.ScaleManager.prototype.constructor = H.ScaleManager, Object.defineProperty(H.ScaleManager.prototype, "boundingParent", { get: function() { return this.parentIsWindow || this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget ? null : this.game.canvas && this.game.canvas.parentNode || null } }), Object.defineProperty(H.ScaleManager.prototype, "scaleMode", { get: function() { return this._scaleMode }, set: function(t) { return t !== this._scaleMode && (this.isFullScreen || (this.updateDimensions(this._gameSize.width, this._gameSize.height, !0), this.queueUpdate(!0)), this._scaleMode = t), this._scaleMode } }), Object.defineProperty(H.ScaleManager.prototype, "fullScreenScaleMode", { get: function() { return this._fullScreenScaleMode }, set: function(t) { return t !== this._fullScreenScaleMode && (this.isFullScreen ? (this.prepScreenMode(!1), this._fullScreenScaleMode = t, this.prepScreenMode(!0), this.queueUpdate(!0)) : this._fullScreenScaleMode = t), this._fullScreenScaleMode } }), Object.defineProperty(H.ScaleManager.prototype, "currentScaleMode", { get: function() { return this.isFullScreen ? this._fullScreenScaleMode : this._scaleMode } }), Object.defineProperty(H.ScaleManager.prototype, "pageAlignHorizontally", { get: function() { return this._pageAlignHorizontally }, set: function(t) { t !== this._pageAlignHorizontally && (this._pageAlignHorizontally = t, this.queueUpdate(!0)) } }), Object.defineProperty(H.ScaleManager.prototype, "pageAlignVertically", { get: function() { return this._pageAlignVertically }, set: function(t) { t !== this._pageAlignVertically && (this._pageAlignVertically = t, this.queueUpdate(!0)) } }), Object.defineProperty(H.ScaleManager.prototype, "isFullScreen", { get: function() { return !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) } }), Object.defineProperty(H.ScaleManager.prototype, "isPortrait", { get: function() { return "portrait" === this.classifyOrientation(this.screenOrientation) } }), Object.defineProperty(H.ScaleManager.prototype, "isLandscape", { get: function() { return "landscape" === this.classifyOrientation(this.screenOrientation) } }), Object.defineProperty(H.ScaleManager.prototype, "isGamePortrait", { get: function() { return this.height > this.width } }), Object.defineProperty(H.ScaleManager.prototype, "isGameLandscape", { get: function() { return this.width > this.height } }), H.Utils.Debug = function(t) { this.game = t, this.sprite = null, this.bmd = null, this.canvas = null, this.context = null, this.font = "14px Courier", this.columnWidth = 100, this.lineHeight = 16, this.renderShadow = !0, this.currentX = 0, this.currentY = 0, this.currentAlpha = 1, this.dirty = !1 }, H.Utils.Debug.prototype = {
|
|
boot: function() { this.game.renderType === H.CANVAS ? this.context = this.game.context : (this.bmd = new H.BitmapData(this.game, "__DEBUG", this.game.width, this.game.height, !0), this.sprite = this.game.make.image(0, 0, this.bmd), this.game.stage.addChild(this.sprite), this.game.scale.onSizeChange.add(this.resize, this), this.canvas = PIXI.CanvasPool.create(this, this.game.width, this.game.height), this.context = this.canvas.getContext("2d")) },
|
|
resize: function(t, e, i) { this.bmd.resize(e, i), this.canvas.width = e, this.canvas.height = i },
|
|
preUpdate: function() { this.dirty && this.sprite && (this.bmd.clear(), this.bmd.draw(this.canvas, 0, 0), this.context.clearRect(0, 0, this.game.width, this.game.height), this.dirty = !1) },
|
|
reset: function() { this.context && this.context.clearRect(0, 0, this.game.width, this.game.height), this.sprite && this.bmd.clear() },
|
|
start: function(t, e, i, s) { "number" != typeof t && (t = 0), "number" != typeof e && (e = 0), i = i || "rgb(255,255,255)", void 0 === s && (s = 0), this.currentX = t, this.currentY = e, this.currentColor = i, this.columnWidth = s, this.dirty = !0, this.context.save(), this.context.setTransform(1, 0, 0, 1, 0, 0), this.context.strokeStyle = i, this.context.fillStyle = i, this.context.font = this.font, this.context.globalAlpha = this.currentAlpha },
|
|
stop: function() { this.context.restore() },
|
|
line: function() {
|
|
for (var t = this.currentX, e = 0; e < arguments.length; e++) this.renderShadow && (this.context.fillStyle = "rgb(0,0,0)", this.context.fillText(arguments[e], t + 1, this.currentY + 1), this.context.fillStyle = this.currentColor), this.context.fillText(arguments[e], t, this.currentY), t += this.columnWidth;
|
|
this.currentY += this.lineHeight
|
|
},
|
|
soundInfo: function(t, e, i, s) { this.start(e, i, s), this.line("Sound: " + t.key + " Locked: " + t.game.sound.touchLocked), this.line("Is Ready?: " + this.game.cache.isSoundReady(t.key) + " Pending Playback: " + t.pendingPlayback), this.line("Decoded: " + t.isDecoded + " Decoding: " + t.isDecoding), this.line("Total Duration: " + t.totalDuration + " Playing: " + t.isPlaying), this.line("Time: " + t.currentTime), this.line("Volume: " + t.volume + " Muted: " + t.mute), this.line("WebAudio: " + t.usingWebAudio + " Audio: " + t.usingAudioTag), "" !== t.currentMarker && (this.line("Marker: " + t.currentMarker + " Duration: " + t.duration + " (ms: " + t.durationMS + ")"), this.line("Start: " + t.markers[t.currentMarker].start + " Stop: " + t.markers[t.currentMarker].stop), this.line("Position: " + t.position)), this.stop() },
|
|
cameraInfo: function(t, e, i, s) { this.start(e, i, s), this.line("Camera (" + t.width + " x " + t.height + ")"), this.line("X: " + t.x + " Y: " + t.y), t.bounds && this.line("Bounds x: " + t.bounds.x + " Y: " + t.bounds.y + " w: " + t.bounds.width + " h: " + t.bounds.height), this.line("View x: " + t.view.x + " Y: " + t.view.y + " w: " + t.view.width + " h: " + t.view.height), this.line("Total in view: " + t.totalInView), this.stop() },
|
|
timer: function(t, e, i, s) { this.start(e, i, s), this.line("Timer (running: " + t.running + " expired: " + t.expired + ")"), this.line("Next Tick: " + t.next + " Duration: " + t.duration), this.line("Paused: " + t.paused + " Length: " + t.length), this.stop() },
|
|
pointer: function(t, e, i, s, o) { null != t && (void 0 === e && (e = !1), i = i || "rgba(0,255,0,0.5)", s = s || "rgba(255,0,0,0.5)", !0 === e && !0 === t.isUp || (this.start(t.x, t.y - 100, o), this.context.beginPath(), this.context.arc(t.x, t.y, t.circle.radius, 0, 2 * Math.PI), t.active ? this.context.fillStyle = i : this.context.fillStyle = s, this.context.fill(), this.context.closePath(), this.context.beginPath(), this.context.moveTo(t.positionDown.x, t.positionDown.y), this.context.lineTo(t.position.x, t.position.y), this.context.lineWidth = 2, this.context.stroke(), this.context.closePath(), this.line("ID: " + t.id + " Active: " + t.active), this.line("World X: " + t.worldX + " World Y: " + t.worldY), this.line("Screen X: " + t.x + " Screen Y: " + t.y + " In: " + t.withinGame), this.line("Duration: " + t.duration + " ms"), this.line("is Down: " + t.isDown + " is Up: " + t.isUp), this.stop())) },
|
|
spriteInputInfo: function(t, e, i, s) { this.start(e, i, s), this.line("Sprite Input: (" + t.width + " x " + t.height + ")"), this.line("x: " + t.input.pointerX().toFixed(1) + " y: " + t.input.pointerY().toFixed(1)), this.line("over: " + t.input.pointerOver() + " duration: " + t.input.overDuration().toFixed(0)), this.line("down: " + t.input.pointerDown() + " duration: " + t.input.downDuration().toFixed(0)), this.line("just over: " + t.input.justOver() + " just out: " + t.input.justOut()), this.stop() },
|
|
key: function(t, e, i, s) { this.start(e, i, s, 150), this.line("Key:", t.keyCode, "isDown:", t.isDown), this.line("justDown:", t.justDown, "justUp:", t.justUp), this.line("Time Down:", t.timeDown.toFixed(0), "duration:", t.duration.toFixed(0)), this.stop() },
|
|
inputInfo: function(t, e, i) { this.start(t, e, i), this.line("Input"), this.line("X: " + this.game.input.x + " Y: " + this.game.input.y), this.line("World X: " + this.game.input.worldX + " World Y: " + this.game.input.worldY), this.line("Scale X: " + this.game.input.scale.x.toFixed(1) + " Scale Y: " + this.game.input.scale.x.toFixed(1)), this.line("Screen X: " + this.game.input.activePointer.screenX + " Screen Y: " + this.game.input.activePointer.screenY), this.stop() },
|
|
spriteBounds: function(t, e, i) {
|
|
var s = t.getBounds();
|
|
s.x += this.game.camera.x, s.y += this.game.camera.y, this.rectangle(s, e, i)
|
|
},
|
|
ropeSegments: function(t, e, i) {
|
|
var s = t.segments,
|
|
o = this;
|
|
s.forEach(function(t) { o.rectangle(t, e, i) }, this)
|
|
},
|
|
spriteInfo: function(t, e, i, s) { this.start(e, i, s), this.line("Sprite: (" + t.width + " x " + t.height + ") anchor: " + t.anchor.x + " x " + t.anchor.y), this.line("x: " + t.x.toFixed(1) + " y: " + t.y.toFixed(1)), this.line("angle: " + t.angle.toFixed(1) + " rotation: " + t.rotation.toFixed(1)), this.line("visible: " + t.visible + " in camera: " + t.inCamera), this.line("bounds x: " + t._bounds.x.toFixed(1) + " y: " + t._bounds.y.toFixed(1) + " w: " + t._bounds.width.toFixed(1) + " h: " + t._bounds.height.toFixed(1)), this.stop() },
|
|
spriteCoords: function(t, e, i, s) { this.start(e, i, s, 100), t.name && this.line(t.name), this.line("x:", t.x.toFixed(2), "y:", t.y.toFixed(2)), this.line("pos x:", t.position.x.toFixed(2), "pos y:", t.position.y.toFixed(2)), this.line("world x:", t.world.x.toFixed(2), "world y:", t.world.y.toFixed(2)), this.stop() },
|
|
lineInfo: function(t, e, i, s) { this.start(e, i, s, 80), this.line("start.x:", t.start.x.toFixed(2), "start.y:", t.start.y.toFixed(2)), this.line("end.x:", t.end.x.toFixed(2), "end.y:", t.end.y.toFixed(2)), this.line("length:", t.length.toFixed(2), "angle:", t.angle), this.stop() },
|
|
pixel: function(t, e, i, s) { s = s || 2, this.start(), this.context.fillStyle = i, this.context.fillRect(t, e, s, s), this.stop() },
|
|
geom: function(t, e, i, s) { void 0 === i && (i = !0), void 0 === s && (s = 0), e = e || "rgba(0,255,0,0.4)", this.start(), this.context.fillStyle = e, this.context.strokeStyle = e, t instanceof H.Rectangle || 1 === s ? i ? this.context.fillRect(t.x - this.game.camera.x, t.y - this.game.camera.y, t.width, t.height) : this.context.strokeRect(t.x - this.game.camera.x, t.y - this.game.camera.y, t.width, t.height) : t instanceof H.Circle || 2 === s ? (this.context.beginPath(), this.context.arc(t.x - this.game.camera.x, t.y - this.game.camera.y, t.radius, 0, 2 * Math.PI, !1), this.context.closePath(), i ? this.context.fill() : this.context.stroke()) : t instanceof H.Point || 3 === s ? this.context.fillRect(t.x - this.game.camera.x, t.y - this.game.camera.y, 4, 4) : (t instanceof H.Line || 4 === s) && (this.context.lineWidth = 1, this.context.beginPath(), this.context.moveTo(t.start.x + .5 - this.game.camera.x, t.start.y + .5 - this.game.camera.y), this.context.lineTo(t.end.x + .5 - this.game.camera.x, t.end.y + .5 - this.game.camera.y), this.context.closePath(), this.context.stroke()), this.stop() },
|
|
rectangle: function(t, e, i) { void 0 === i && (i = !0), e = e || "rgba(0, 255, 0, 0.4)", this.start(), i ? (this.context.fillStyle = e, this.context.fillRect(t.x - this.game.camera.x, t.y - this.game.camera.y, t.width, t.height)) : (this.context.strokeStyle = e, this.context.strokeRect(t.x - this.game.camera.x, t.y - this.game.camera.y, t.width, t.height)), this.stop() },
|
|
text: function(t, e, i, s, o) { s = s || "rgb(255,255,255)", o = o || "16px Courier", this.start(), this.context.font = o, this.renderShadow && (this.context.fillStyle = "rgb(0,0,0)", this.context.fillText(t, e + 1, i + 1)), this.context.fillStyle = s, this.context.fillText(t, e, i), this.stop() },
|
|
quadTree: function(t, e) {
|
|
e = e || "rgba(255,0,0,0.3)", this.start();
|
|
var i = t.bounds;
|
|
if (0 === t.nodes.length) { this.context.strokeStyle = e, this.context.strokeRect(i.x, i.y, i.width, i.height), this.text("size: " + t.objects.length, i.x + 4, i.y + 16, "rgb(0,200,0)", "12px Courier"), this.context.strokeStyle = "rgb(0,255,0)"; for (var s = 0; s < t.objects.length; s++) this.context.strokeRect(t.objects[s].x, t.objects[s].y, t.objects[s].width, t.objects[s].height) }
|
|
else
|
|
for (s = 0; s < t.nodes.length; s++) this.quadTree(t.nodes[s]);
|
|
this.stop()
|
|
},
|
|
body: function(t, e, i) { t.body && (this.start(), t.body.type === H.Physics.ARCADE ? H.Physics.Arcade.Body.render(this.context, t.body, e, i) : t.body.type === H.Physics.NINJA ? H.Physics.Ninja.Body.render(this.context, t.body, e, i) : t.body.type === H.Physics.BOX2D && H.Physics.Box2D.renderBody(this.context, t.body, e), this.stop()) },
|
|
bodyInfo: function(t, e, i, s) { t.body && (this.start(e, i, s, 210), t.body.type === H.Physics.ARCADE ? H.Physics.Arcade.Body.renderBodyInfo(this, t.body) : t.body.type === H.Physics.BOX2D && this.game.physics.box2d.renderBodyInfo(this, t.body), this.stop()) },
|
|
box2dWorld: function() { this.start(), this.context.translate(-this.game.camera.view.x, -this.game.camera.view.y, 0), this.game.physics.box2d.renderDebugDraw(this.context), this.stop() },
|
|
box2dBody: function(t, e) { this.start(), H.Physics.Box2D.renderBody(this.context, t, e), this.stop() },
|
|
displayList: function(t) {
|
|
if (void 0 === t && (t = this.game.world), t.hasOwnProperty("renderOrderID"), t.children && 0 < t.children.length)
|
|
for (var e = 0; e < t.children.length; e++) this.game.debug.displayList(t.children[e])
|
|
},
|
|
destroy: function() { PIXI.CanvasPool.remove(this) }
|
|
}, H.Utils.Debug.prototype.constructor = H.Utils.Debug, H.DOM = {
|
|
getOffset: function(t, e) {
|
|
e = e || new H.Point;
|
|
var i = t.getBoundingClientRect(),
|
|
s = H.DOM.scrollY,
|
|
o = H.DOM.scrollX,
|
|
n = document.documentElement.clientTop,
|
|
a = document.documentElement.clientLeft;
|
|
return e.x = i.left + o - a, e.y = i.top + s - n, e
|
|
},
|
|
getBounds: function(t, e) { return void 0 === e && (e = 0), !(!(t = t && !t.nodeType ? t[0] : t) || 1 !== t.nodeType) && this.calibrate(t.getBoundingClientRect(), e) },
|
|
calibrate: function(t, e) { e = +e || 0; var i = { width: 0, height: 0, left: 0, right: 0, top: 0, bottom: 0 }; return i.width = (i.right = t.right + e) - (i.left = t.left - e), i.height = (i.bottom = t.bottom + e) - (i.top = t.top - e), i },
|
|
getAspectRatio: function(t) {
|
|
var e = (t = null == t ? this.visualBounds : 1 === t.nodeType ? this.getBounds(t) : t).width,
|
|
i = t.height;
|
|
return "function" == typeof e && (e = e.call(t)), "function" == typeof i && (i = i.call(t)), e / i
|
|
},
|
|
inLayoutViewport: function(t, e) { var i = this.getBounds(t, e); return !!i && 0 <= i.bottom && 0 <= i.right && i.top <= this.layoutBounds.width && i.left <= this.layoutBounds.height },
|
|
getScreenOrientation: function(t) {
|
|
var e = window.screen,
|
|
i = e.orientation || e.mozOrientation || e.msOrientation;
|
|
if (i && "string" == typeof i.type) return i.type;
|
|
if ("string" == typeof i) return i;
|
|
var s = "portrait-primary",
|
|
o = "landscape-primary";
|
|
if ("screen" === t) return e.height > e.width ? s : o;
|
|
if ("viewport" === t) return this.visualBounds.height > this.visualBounds.width ? s : o;
|
|
if ("window.orientation" === t && "number" == typeof window.orientation) return 0 === window.orientation || 180 === window.orientation ? s : o;
|
|
if (window.matchMedia) { if (window.matchMedia("(orientation: portrait)").matches) return s; if (window.matchMedia("(orientation: landscape)").matches) return o }
|
|
return this.visualBounds.height > this.visualBounds.width ? s : o
|
|
},
|
|
visualBounds: new H.Rectangle,
|
|
layoutBounds: new H.Rectangle,
|
|
documentBounds: new H.Rectangle
|
|
}, H.Device.whenReady(function(t) {
|
|
var e = window && "pageXOffset" in window ? function() { return window.pageXOffset } : function() { return document.documentElement.scrollLeft },
|
|
i = window && "pageYOffset" in window ? function() { return window.pageYOffset } : function() { return document.documentElement.scrollTop };
|
|
if (Object.defineProperty(H.DOM, "scrollX", { get: e }), Object.defineProperty(H.DOM, "scrollY", { get: i }), Object.defineProperty(H.DOM.visualBounds, "x", { get: e }), Object.defineProperty(H.DOM.visualBounds, "y", { get: i }), Object.defineProperty(H.DOM.layoutBounds, "x", { value: 0 }), Object.defineProperty(H.DOM.layoutBounds, "y", { value: 0 }), t.desktop && document.documentElement.clientWidth <= window.innerWidth && document.documentElement.clientHeight <= window.innerHeight) {
|
|
var s = function() { return Math.max(window.innerWidth, document.documentElement.clientWidth) },
|
|
o = function() { return Math.max(window.innerHeight, document.documentElement.clientHeight) };
|
|
Object.defineProperty(H.DOM.visualBounds, "width", { get: s }), Object.defineProperty(H.DOM.visualBounds, "height", { get: o }), Object.defineProperty(H.DOM.layoutBounds, "width", { get: s }), Object.defineProperty(H.DOM.layoutBounds, "height", { get: o })
|
|
}
|
|
else Object.defineProperty(H.DOM.visualBounds, "width", { get: function() { return window.innerWidth } }), Object.defineProperty(H.DOM.visualBounds, "height", { get: function() { return window.innerHeight } }), Object.defineProperty(H.DOM.layoutBounds, "width", {
|
|
get: function() {
|
|
var t = document.documentElement.clientWidth,
|
|
e = window.innerWidth;
|
|
return t < e ? e : t
|
|
}
|
|
}), Object.defineProperty(H.DOM.layoutBounds, "height", {
|
|
get: function() {
|
|
var t = document.documentElement.clientHeight,
|
|
e = window.innerHeight;
|
|
return t < e ? e : t
|
|
}
|
|
});
|
|
Object.defineProperty(H.DOM.documentBounds, "x", { value: 0 }), Object.defineProperty(H.DOM.documentBounds, "y", { value: 0 }), Object.defineProperty(H.DOM.documentBounds, "width", { get: function() { var t = document.documentElement; return Math.max(t.clientWidth, t.offsetWidth, t.scrollWidth) } }), Object.defineProperty(H.DOM.documentBounds, "height", { get: function() { var t = document.documentElement; return Math.max(t.clientHeight, t.offsetHeight, t.scrollHeight) } })
|
|
}, null, !0), H.ArraySet = function(t) { this.position = 0, this.list = t || [] }, H.ArraySet.prototype = {
|
|
add: function(t) { return this.exists(t) || this.list.push(t), t },
|
|
getIndex: function(t) { return this.list.indexOf(t) },
|
|
getByKey: function(t, e) {
|
|
for (var i = this.list.length; i--;)
|
|
if (this.list[i][t] === e) return this.list[i];
|
|
return null
|
|
},
|
|
exists: function(t) { return -1 < this.list.indexOf(t) },
|
|
reset: function() { this.list.length = 0 },
|
|
remove: function(t) { var e = this.list.indexOf(t); if (-1 < e) return this.list.splice(e, 1), t },
|
|
setAll: function(t, e) { for (var i = this.list.length; i--;) this.list[i] && (this.list[i][t] = e) },
|
|
callAll: function(t) { for (var e = Array.prototype.slice.call(arguments, 1), i = this.list.length; i--;) this.list[i] && this.list[i][t] && this.list[i][t].apply(this.list[i], e) },
|
|
removeAll: function(t) {
|
|
void 0 === t && (t = !1);
|
|
for (var e = this.list.length; e--;)
|
|
if (this.list[e]) {
|
|
var i = this.remove(this.list[e]);
|
|
t && i.destroy()
|
|
}
|
|
this.position = 0, this.list = []
|
|
}
|
|
}, Object.defineProperty(H.ArraySet.prototype, "total", { get: function() { return this.list.length } }), Object.defineProperty(H.ArraySet.prototype, "first", { get: function() { return (this.position = 0) < this.list.length ? this.list[0] : null } }), Object.defineProperty(H.ArraySet.prototype, "next", { get: function() { return this.position < this.list.length ? (this.position++, this.list[this.position]) : null } }), H.ArraySet.prototype.constructor = H.ArraySet, H.ArrayUtils = {
|
|
getRandomItem: function(t, e, i) {
|
|
if (null === t) return null;
|
|
void 0 === e && (e = 0), void 0 === i && (i = t.length);
|
|
var s = e + Math.floor(Math.random() * i);
|
|
return void 0 === t[s] ? null : t[s]
|
|
},
|
|
removeRandomItem: function(t, e, i) {
|
|
if (null == t) return null;
|
|
void 0 === e && (e = 0), void 0 === i && (i = t.length);
|
|
var s = e + Math.floor(Math.random() * i);
|
|
if (s < t.length) { var o = t.splice(s, 1); return void 0 === o[0] ? null : o[0] }
|
|
return null
|
|
},
|
|
shuffle: function(t) {
|
|
for (var e = t.length - 1; 0 < e; e--) {
|
|
var i = Math.floor(Math.random() * (e + 1)),
|
|
s = t[e];
|
|
t[e] = t[i], t[i] = s
|
|
}
|
|
return t
|
|
},
|
|
transposeMatrix: function(t) { for (var e = t.length, i = t[0].length, s = new Array(i), o = 0; o < i; o++) { s[o] = new Array(e); for (var n = e - 1; - 1 < n; n--) s[o][n] = t[n][o] } return s },
|
|
rotateMatrix: function(t, e) {
|
|
if ("string" != typeof e && (e = (e % 360 + 360) % 360), 90 === e || -270 === e || "rotateLeft" === e) t = (t = H.ArrayUtils.transposeMatrix(t)).reverse();
|
|
else if (-90 === e || 270 === e || "rotateRight" === e) t = t.reverse(), t = H.ArrayUtils.transposeMatrix(t);
|
|
else if (180 === Math.abs(e) || "rotate180" === e) {
|
|
for (var i = 0; i < t.length; i++) t[i].reverse();
|
|
t = t.reverse()
|
|
}
|
|
return t
|
|
},
|
|
findClosest: function(t, e) {
|
|
if (!e.length) return NaN;
|
|
if (1 === e.length || t < e[0]) return e[0];
|
|
for (var i = 1; e[i] < t;) i++;
|
|
var s = e[i - 1],
|
|
o = i < e.length ? e[i] : Number.POSITIVE_INFINITY;
|
|
return o - t <= t - s ? o : s
|
|
},
|
|
rotateRight: function(t) { var e = t.pop(); return t.unshift(e), e },
|
|
rotateLeft: function(t) { var e = t.shift(); return t.push(e), e },
|
|
rotate: function(t) { var e = t.shift(); return t.push(e), e },
|
|
numberArray: function(t, e) { for (var i = [], s = t; s <= e; s++) i.push(s); return i },
|
|
numberArrayStep: function(t, e, i) { null == t && (t = 0), null == e && (e = t, t = 0), void 0 === i && (i = 1); for (var s = [], o = Math.max(H.Math.roundAwayFromZero((e - t) / (i || 1)), 0), n = 0; n < o; n++) s.push(t), t += i; return s }
|
|
}, H.LinkedList = function() { this.next = null, this.prev = null, this.first = null, this.last = null, this.total = 0 }, H.LinkedList.prototype = {
|
|
add: function(t) { return 0 === this.total && null === this.first && null === this.last ? (this.first = t, this.last = t, ((this.next = t).prev = this).total++) : ((this.last.next = t).prev = this.last, this.last = t, this.total++), t },
|
|
reset: function() { this.first = null, this.last = null, this.next = null, this.prev = null, this.total = 0 },
|
|
remove: function(t) {
|
|
if (1 === this.total) return this.reset(), void(t.next = t.prev = null);
|
|
t === this.first ? this.first = this.first.next : t === this.last && (this.last = this.last.prev), t.prev && (t.prev.next = t.next), t.next && (t.next.prev = t.prev), t.next = t.prev = null, null === this.first && (this.last = null), this.total--
|
|
},
|
|
callAll: function(t) {
|
|
if (this.first && this.last)
|
|
for (var e = this.first; e && e[t] && e[t].call(e), (e = e.next) !== this.last.next;);
|
|
}
|
|
}, H.LinkedList.prototype.constructor = H.LinkedList, H.Create = function(t) { this.game = t, this.bmd = null, this.canvas = null, this.ctx = null, this.palettes = [{ 0: "#000", 1: "#9D9D9D", 2: "#FFF", 3: "#BE2633", 4: "#E06F8B", 5: "#493C2B", 6: "#A46422", 7: "#EB8931", 8: "#F7E26B", 9: "#2F484E", A: "#44891A", B: "#A3CE27", C: "#1B2632", D: "#005784", E: "#31A2F2", F: "#B2DCEF" }, { 0: "#000", 1: "#191028", 2: "#46af45", 3: "#a1d685", 4: "#453e78", 5: "#7664fe", 6: "#833129", 7: "#9ec2e8", 8: "#dc534b", 9: "#e18d79", A: "#d6b97b", B: "#e9d8a1", C: "#216c4b", D: "#d365c8", E: "#afaab9", F: "#f5f4eb" }, { 0: "#000", 1: "#2234d1", 2: "#0c7e45", 3: "#44aacc", 4: "#8a3622", 5: "#5c2e78", 6: "#aa5c3d", 7: "#b5b5b5", 8: "#5e606e", 9: "#4c81fb", A: "#6cd947", B: "#7be2f9", C: "#eb8a60", D: "#e23d69", E: "#ffd93f", F: "#fff" }, { 0: "#000", 1: "#fff", 2: "#8b4131", 3: "#7bbdc5", 4: "#8b41ac", 5: "#6aac41", 6: "#3931a4", 7: "#d5de73", 8: "#945a20", 9: "#5a4100", A: "#bd736a", B: "#525252", C: "#838383", D: "#acee8b", E: "#7b73de", F: "#acacac" }, { 0: "#000", 1: "#191028", 2: "#46af45", 3: "#a1d685", 4: "#453e78", 5: "#7664fe", 6: "#833129", 7: "#9ec2e8", 8: "#dc534b", 9: "#e18d79", A: "#d6b97b", B: "#e9d8a1", C: "#216c4b", D: "#d365c8", E: "#afaab9", F: "#fff" }] }, H.Create.PALETTE_ARNE = 0, H.Create.PALETTE_JMP = 1, H.Create.PALETTE_CGA = 2, H.Create.PALETTE_C64 = 3, H.Create.PALETTE_JAPANESE_MACHINE = 4, H.Create.prototype = {
|
|
texture: function(t, e, i, s, o) {
|
|
void 0 === i && (i = 8), void 0 === s && (s = i), void 0 === o && (o = 0);
|
|
var n = e[0].length * i,
|
|
a = e.length * s;
|
|
null === this.bmd && (this.bmd = this.game.make.bitmapData(), this.canvas = this.bmd.canvas, this.ctx = this.bmd.context), this.bmd.resize(n, a), this.bmd.clear();
|
|
for (var r = 0; r < e.length; r++)
|
|
for (var h = e[r], l = 0; l < h.length; l++) { var c = h[l]; "." !== c && " " !== c && (this.ctx.fillStyle = this.palettes[o][c], this.ctx.fillRect(l * i, r * s, i, s)) }
|
|
return this.bmd.generateTexture(t)
|
|
},
|
|
grid: function(t, e, i, s, o, n) { null === this.bmd && (this.bmd = this.game.make.bitmapData(), this.canvas = this.bmd.canvas, this.ctx = this.bmd.context), this.bmd.resize(e, i), this.ctx.fillStyle = n; for (var a = 0; a < i; a += o) this.ctx.fillRect(0, a, e, 1); for (var r = 0; r < e; r += s) this.ctx.fillRect(r, 0, 1, i); return this.bmd.generateTexture(t) }
|
|
}, H.Create.prototype.constructor = H.Create, H.FlexGrid = function(t, e, i) { this.game = t.game, this.manager = t, this.width = e, this.height = i, this.boundsCustom = new H.Rectangle(0, 0, e, i), this.boundsFluid = new H.Rectangle(0, 0, e, i), this.boundsFull = new H.Rectangle(0, 0, e, i), this.boundsNone = new H.Rectangle(0, 0, e, i), this.positionCustom = new H.Point(0, 0), this.positionFluid = new H.Point(0, 0), this.positionFull = new H.Point(0, 0), this.positionNone = new H.Point(0, 0), this.scaleCustom = new H.Point(1, 1), this.scaleFluid = new H.Point(1, 1), this.scaleFluidInversed = new H.Point(1, 1), this.scaleFull = new H.Point(1, 1), this.scaleNone = new H.Point(1, 1), this.customWidth = 0, this.customHeight = 0, this.customOffsetX = 0, this.customOffsetY = 0, this.ratioH = e / i, this.ratioV = i / e, this.multiplier = 0, this.layers = [] }, H.FlexGrid.prototype = { setSize: function(t, e) { this.width = t, this.height = e, this.ratioH = t / e, this.ratioV = e / t, this.scaleNone = new H.Point(1, 1), this.boundsNone.width = this.width, this.boundsNone.height = this.height, this.refresh() }, createCustomLayer: function(t, e, i, s) { void 0 === s && (s = !0), this.customWidth = t, this.customHeight = e, this.boundsCustom.width = t, this.boundsCustom.height = e; var o = new H.FlexLayer(this, this.positionCustom, this.boundsCustom, this.scaleCustom); return s && this.game.world.add(o), this.layers.push(o), void 0 !== i && null !== typeof i && o.addMultiple(i), o }, createFluidLayer: function(t, e) { void 0 === e && (e = !0); var i = new H.FlexLayer(this, this.positionFluid, this.boundsFluid, this.scaleFluid); return e && this.game.world.add(i), this.layers.push(i), void 0 !== t && null !== typeof t && i.addMultiple(t), i }, createFullLayer: function(t) { var e = new H.FlexLayer(this, this.positionFull, this.boundsFull, this.scaleFluid); return this.game.world.add(e), this.layers.push(e), void 0 !== t && e.addMultiple(t), e }, createFixedLayer: function(t) { var e = new H.FlexLayer(this, this.positionNone, this.boundsNone, this.scaleNone); return this.game.world.add(e), this.layers.push(e), void 0 !== t && e.addMultiple(t), e }, reset: function() { for (var t = this.layers.length; t--;) this.layers[t].persist || (this.layers[t].position = null, this.layers[t].scale = null, this.layers.slice(t, 1)) }, onResize: function(t, e) { this.ratioH = t / e, this.ratioV = e / t, this.refresh(t, e) }, refresh: function() { this.multiplier = Math.min(this.manager.height / this.height, this.manager.width / this.width), this.boundsFluid.width = Math.round(this.width * this.multiplier), this.boundsFluid.height = Math.round(this.height * this.multiplier), this.scaleFluid.set(this.boundsFluid.width / this.width, this.boundsFluid.height / this.height), this.scaleFluidInversed.set(this.width / this.boundsFluid.width, this.height / this.boundsFluid.height), this.scaleFull.set(this.boundsFull.width / this.width, this.boundsFull.height / this.height), this.boundsFull.width = Math.round(this.manager.width * this.scaleFluidInversed.x), this.boundsFull.height = Math.round(this.manager.height * this.scaleFluidInversed.y), this.boundsFluid.centerOn(this.manager.bounds.centerX, this.manager.bounds.centerY), this.boundsNone.centerOn(this.manager.bounds.centerX, this.manager.bounds.centerY), this.positionFluid.set(this.boundsFluid.x, this.boundsFluid.y), this.positionNone.set(this.boundsNone.x, this.boundsNone.y) }, fitSprite: function(t) { this.manager.scaleSprite(t), t.x = this.manager.bounds.centerX, t.y = this.manager.bounds.centerY }, debug: function() { this.game.debug.text(this.boundsFluid.width + " x " + this.boundsFluid.height, this.boundsFluid.x + 4, this.boundsFluid.y + 16), this.game.debug.geom(this.boundsFluid, "rgba(255,0,0,0.9", !1) } }, H.FlexGrid.prototype.constructor = H.FlexGrid, H.FlexLayer = function(t, e, i, s) { H.Group.call(this, t.game, null, "__flexLayer" + t.game.rnd.uuid(), !1), this.manager = t.manager, this.grid = t, this.persist = !1, this.position = e, this.bounds = i, this.scale = s, this.topLeft = i.topLeft, this.topMiddle = new H.Point(i.halfWidth, 0), this.topRight = i.topRight, this.bottomLeft = i.bottomLeft, this.bottomMiddle = new H.Point(i.halfWidth, i.bottom), this.bottomRight = i.bottomRight }, H.FlexLayer.prototype = Object.create(H.Group.prototype), H.FlexLayer.prototype.constructor = H.FlexLayer, H.FlexLayer.prototype.resize = function() {}, H.FlexLayer.prototype.debug = function() { this.game.debug.text(this.bounds.width + " x " + this.bounds.height, this.bounds.x + 4, this.bounds.y + 16), this.game.debug.geom(this.bounds, "rgba(0,0,255,0.9", !1), this.game.debug.geom(this.topLeft, "rgba(255,255,255,0.9"), this.game.debug.geom(this.topMiddle, "rgba(255,255,255,0.9"), this.game.debug.geom(this.topRight, "rgba(255,255,255,0.9") }, H.Color = {
|
|
packPixel: function(t, e, i, s) { return H.Device.LITTLE_ENDIAN ? (s << 24 | i << 16 | e << 8 | t) >>> 0 : (t << 24 | e << 16 | i << 8 | s) >>> 0 },
|
|
unpackPixel: function(t, e, i, s) { return null == e && (e = H.Color.createColor()), null == i && (i = !1), null == s && (s = !1), H.Device.LITTLE_ENDIAN ? (e.a = (4278190080 & t) >>> 24, e.b = (16711680 & t) >>> 16, e.g = (65280 & t) >>> 8, e.r = 255 & t) : (e.r = (4278190080 & t) >>> 24, e.g = (16711680 & t) >>> 16, e.b = (65280 & t) >>> 8, e.a = 255 & t), e.color = t, e.rgba = "rgba(" + e.r + "," + e.g + "," + e.b + "," + e.a / 255 + ")", i && H.Color.RGBtoHSL(e.r, e.g, e.b, e), s && H.Color.RGBtoHSV(e.r, e.g, e.b, e), e },
|
|
fromRGBA: function(t, e) { return e || (e = H.Color.createColor()), e.r = (4278190080 & t) >>> 24, e.g = (16711680 & t) >>> 16, e.b = (65280 & t) >>> 8, e.a = 255 & t, e.rgba = "rgba(" + e.r + "," + e.g + "," + e.b + "," + e.a + ")", e },
|
|
toRGBA: function(t, e, i, s) { return t << 24 | e << 16 | i << 8 | s },
|
|
toABGR: function(t, e, i, s) { return (s << 24 | i << 16 | e << 8 | t) >>> 0 },
|
|
RGBtoHSL: function(t, e, i, s) {
|
|
s || (s = H.Color.createColor(t, e, i, 1)), t /= 255, e /= 255, i /= 255;
|
|
var o = Math.min(t, e, i),
|
|
n = Math.max(t, e, i);
|
|
if (s.h = 0, s.s = 0, s.l = (n + o) / 2, n !== o) {
|
|
var a = n - o;
|
|
s.s = .5 < s.l ? a / (2 - n - o) : a / (n + o), n === t ? s.h = (e - i) / a + (e < i ? 6 : 0) : n === e ? s.h = (i - t) / a + 2 : n === i && (s.h = (t - e) / a + 4), s.h /= 6
|
|
}
|
|
return s
|
|
},
|
|
HSLtoRGB: function(t, e, i, s) {
|
|
if (s ? (s.r = i, s.g = i, s.b = i) : s = H.Color.createColor(i, i, i), 0 !== e) {
|
|
var o = i < .5 ? i * (1 + e) : i + e - i * e,
|
|
n = 2 * i - o;
|
|
s.r = H.Color.hueToColor(n, o, t + 1 / 3), s.g = H.Color.hueToColor(n, o, t), s.b = H.Color.hueToColor(n, o, t - 1 / 3)
|
|
}
|
|
return s.r = Math.floor(255 * s.r | 0), s.g = Math.floor(255 * s.g | 0), s.b = Math.floor(255 * s.b | 0), H.Color.updateColor(s), s
|
|
},
|
|
RGBtoHSV: function(t, e, i, s) {
|
|
s || (s = H.Color.createColor(t, e, i, 255)), t /= 255, e /= 255, i /= 255;
|
|
var o = Math.min(t, e, i),
|
|
n = Math.max(t, e, i),
|
|
a = n - o;
|
|
return s.h = 0, s.s = 0 === n ? 0 : a / n, (s.v = n) !== o && (n === t ? s.h = (e - i) / a + (e < i ? 6 : 0) : n === e ? s.h = (i - t) / a + 2 : n === i && (s.h = (t - e) / a + 4), s.h /= 6), s
|
|
},
|
|
HSVtoRGB: function(t, e, i, s) {
|
|
var o, n, a;
|
|
void 0 === s && (s = H.Color.createColor(0, 0, 0, 1, t, e, 0, i));
|
|
var r = Math.floor(6 * t),
|
|
h = 6 * t - r,
|
|
l = i * (1 - e),
|
|
c = i * (1 - h * e),
|
|
p = i * (1 - (1 - h) * e);
|
|
switch (r % 6) {
|
|
case 0:
|
|
o = i, n = p, a = l;
|
|
break;
|
|
case 1:
|
|
o = c, n = i, a = l;
|
|
break;
|
|
case 2:
|
|
o = l, n = i, a = p;
|
|
break;
|
|
case 3:
|
|
o = l, n = c, a = i;
|
|
break;
|
|
case 4:
|
|
o = p, n = l, a = i;
|
|
break;
|
|
case 5:
|
|
o = i, n = l, a = c
|
|
}
|
|
return s.r = Math.floor(255 * o), s.g = Math.floor(255 * n), s.b = Math.floor(255 * a), H.Color.updateColor(s), s
|
|
},
|
|
hueToColor: function(t, e, i) { return i < 0 && (i += 1), 1 < i && (i -= 1), i < 1 / 6 ? t + 6 * (e - t) * i : i < .5 ? e : i < 2 / 3 ? t + (e - t) * (2 / 3 - i) * 6 : t },
|
|
createColor: function(t, e, i, s, o, n, a, r) { var h = { r: t || 0, g: e || 0, b: i || 0, a: s || 1, h: o || 0, s: n || 0, l: a || 0, v: r || 0, color: 0, color32: 0, rgba: "" }; return H.Color.updateColor(h) },
|
|
updateColor: function(t) { return t.rgba = "rgba(" + t.r.toString() + "," + t.g.toString() + "," + t.b.toString() + "," + t.a.toString() + ")", t.color = H.Color.getColor(t.r, t.g, t.b), t.color32 = H.Color.getColor32(255 * t.a, t.r, t.g, t.b), t },
|
|
getColor32: function(t, e, i, s) { return t << 24 | e << 16 | i << 8 | s },
|
|
getColor: function(t, e, i) { return t << 16 | e << 8 | i },
|
|
RGBtoString: function(t, e, i, s, o) { return void 0 === s && (s = 255), void 0 === o && (o = "#"), "#" === o ? "#" + ((1 << 24) + (t << 16) + (e << 8) + i).toString(16).slice(1) : "0x" + H.Color.componentToHex(s) + H.Color.componentToHex(t) + H.Color.componentToHex(e) + H.Color.componentToHex(i) },
|
|
hexToRGB: function(t) { var e = H.Color.hexToColor(t); if (e) return H.Color.getColor32(e.a, e.r, e.g, e.b) },
|
|
hexToColor: function(t, e) {
|
|
t = t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function(t, e, i, s) { return e + e + i + i + s + s });
|
|
var i = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
|
|
if (i) {
|
|
var s = parseInt(i[1], 16),
|
|
o = parseInt(i[2], 16),
|
|
n = parseInt(i[3], 16);
|
|
e ? (e.r = s, e.g = o, e.b = n) : e = H.Color.createColor(s, o, n)
|
|
}
|
|
return e
|
|
},
|
|
webToColor: function(t, e) { e || (e = H.Color.createColor()); var i = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(t); return i && (e.r = parseInt(i[1], 10), e.g = parseInt(i[2], 10), e.b = parseInt(i[3], 10), e.a = void 0 !== i[4] ? parseFloat(i[4]) : 1, H.Color.updateColor(e)), e },
|
|
valueToColor: function(t, e) { if (e || (e = H.Color.createColor()), "string" == typeof t) return 0 === t.indexOf("rgb") ? H.Color.webToColor(t, e) : (e.a = 1, H.Color.hexToColor(t, e)); if ("number" != typeof t) return e; var i = H.Color.getRGB(t); return e.r = i.r, e.g = i.g, e.b = i.b, e.a = i.a / 255, e },
|
|
componentToHex: function(t) { var e = t.toString(16); return 1 === e.length ? "0" + e : e },
|
|
HSVColorWheel: function(t, e) { void 0 === t && (t = 1), void 0 === e && (e = 1); for (var i = [], s = 0; s <= 359; s++) i.push(H.Color.HSVtoRGB(s / 359, t, e)); return i },
|
|
HSLColorWheel: function(t, e) { void 0 === t && (t = .5), void 0 === e && (e = .5); for (var i = [], s = 0; s <= 359; s++) i.push(H.Color.HSLtoRGB(s / 359, t, e)); return i },
|
|
interpolateColor: function(t, e, i, s, o) {
|
|
void 0 === o && (o = 255);
|
|
var n = H.Color.getRGB(t),
|
|
a = H.Color.getRGB(e),
|
|
r = (a.red - n.red) * s / i + n.red,
|
|
h = (a.green - n.green) * s / i + n.green,
|
|
l = (a.blue - n.blue) * s / i + n.blue;
|
|
return H.Color.getColor32(o, r, h, l)
|
|
},
|
|
interpolateColorWithRGB: function(t, e, i, s, o, n) {
|
|
var a = H.Color.getRGB(t),
|
|
r = (e - a.red) * n / o + a.red,
|
|
h = (i - a.green) * n / o + a.green,
|
|
l = (s - a.blue) * n / o + a.blue;
|
|
return H.Color.getColor(r, h, l)
|
|
},
|
|
interpolateRGB: function(t, e, i, s, o, n, a, r) {
|
|
var h = (s - t) * r / a + t,
|
|
l = (o - e) * r / a + e,
|
|
c = (n - i) * r / a + i;
|
|
return H.Color.getColor(h, l, c)
|
|
},
|
|
getRandomColor: function(t, e, i) {
|
|
if (void 0 === t && (t = 0), void 0 === e && (e = 255), void 0 === i && (i = 255), 255 < e || e < t) return H.Color.getColor(255, 255, 255);
|
|
var s = t + Math.round(Math.random() * (e - t)),
|
|
o = t + Math.round(Math.random() * (e - t)),
|
|
n = t + Math.round(Math.random() * (e - t));
|
|
return H.Color.getColor32(i, s, o, n)
|
|
},
|
|
getRGB: function(t) { return 16777215 < t ? { alpha: t >>> 24, red: t >> 16 & 255, green: t >> 8 & 255, blue: 255 & t, a: t >>> 24, r: t >> 16 & 255, g: t >> 8 & 255, b: 255 & t } : { alpha: 255, red: t >> 16 & 255, green: t >> 8 & 255, blue: 255 & t, a: 255, r: t >> 16 & 255, g: t >> 8 & 255, b: 255 & t } },
|
|
getWebRGB: function(t) { if ("object" == typeof t) return "rgba(" + t.r.toString() + "," + t.g.toString() + "," + t.b.toString() + "," + (t.a / 255).toString() + ")"; var e = H.Color.getRGB(t); return "rgba(" + e.r.toString() + "," + e.g.toString() + "," + e.b.toString() + "," + (e.a / 255).toString() + ")" },
|
|
getAlpha: function(t) { return t >>> 24 },
|
|
getAlphaFloat: function(t) { return (t >>> 24) / 255 },
|
|
getRed: function(t) { return t >> 16 & 255 },
|
|
getGreen: function(t) { return t >> 8 & 255 },
|
|
getBlue: function(t) { return 255 & t },
|
|
blendNormal: function(t) { return t },
|
|
blendLighten: function(t, e) { return t < e ? e : t },
|
|
blendDarken: function(t, e) { return t < e ? t : e },
|
|
blendMultiply: function(t, e) { return t * e / 255 },
|
|
blendAverage: function(t, e) { return (t + e) / 2 },
|
|
blendAdd: function(t, e) { return Math.min(255, t + e) },
|
|
blendSubtract: function(t, e) { return Math.max(0, t + e - 255) },
|
|
blendDifference: function(t, e) { return Math.abs(t - e) },
|
|
blendNegation: function(t, e) { return 255 - Math.abs(255 - t - e) },
|
|
blendScreen: function(t, e) { return 255 - ((255 - t) * (255 - e) >> 8) },
|
|
blendExclusion: function(t, e) { return t + e - 2 * t * e / 255 },
|
|
blendOverlay: function(t, e) { return e < 128 ? 2 * t * e / 255 : 255 - 2 * (255 - t) * (255 - e) / 255 },
|
|
blendSoftLight: function(t, e) { return e < 128 ? 2 * (64 + (t >> 1)) * (e / 255) : 255 - 2 * (255 - (64 + (t >> 1))) * (255 - e) / 255 },
|
|
blendHardLight: function(t, e) { return H.Color.blendOverlay(e, t) },
|
|
blendColorDodge: function(t, e) { return 255 === e ? e : Math.min(255, (t << 8) / (255 - e)) },
|
|
blendColorBurn: function(t, e) { return 0 === e ? e : Math.max(0, 255 - (255 - t << 8) / e) },
|
|
blendLinearDodge: function(t, e) { return H.Color.blendAdd(t, e) },
|
|
blendLinearBurn: function(t, e) { return H.Color.blendSubtract(t, e) },
|
|
blendLinearLight: function(t, e) { return e < 128 ? H.Color.blendLinearBurn(t, 2 * e) : H.Color.blendLinearDodge(t, 2 * (e - 128)) },
|
|
blendVividLight: function(t, e) { return e < 128 ? H.Color.blendColorBurn(t, 2 * e) : H.Color.blendColorDodge(t, 2 * (e - 128)) },
|
|
blendPinLight: function(t, e) { return e < 128 ? H.Color.blendDarken(t, 2 * e) : H.Color.blendLighten(t, 2 * (e - 128)) },
|
|
blendHardMix: function(t, e) { return H.Color.blendVividLight(t, e) < 128 ? 0 : 255 },
|
|
blendReflect: function(t, e) { return 255 === e ? e : Math.min(255, t * t / (255 - e)) },
|
|
blendGlow: function(t, e) { return H.Color.blendReflect(e, t) },
|
|
blendPhoenix: function(t, e) { return Math.min(t, e) - Math.max(t, e) + 255 }
|
|
}, H.Physics = function(t, e) { e = e || {}, this.game = t, this.config = e, this.arcade = null, this.p2 = null, this.ninja = null, this.box2d = null, this.chipmunk = null, this.matter = null, this.parseConfig() }, H.Physics.ARCADE = 0, H.Physics.P2JS = 1, H.Physics.NINJA = 2, H.Physics.BOX2D = 3, H.Physics.CHIPMUNK = 4, H.Physics.MATTERJS = 5, H.Physics.prototype = { parseConfig: function() { this.config.hasOwnProperty("arcade") && !0 !== this.config.arcade || !H.Physics.hasOwnProperty("Arcade") || (this.arcade = new H.Physics.Arcade(this.game)), this.config.hasOwnProperty("ninja") && !0 === this.config.ninja && H.Physics.hasOwnProperty("Ninja") && (this.ninja = new H.Physics.Ninja(this.game)), this.config.hasOwnProperty("p2") && !0 === this.config.p2 && H.Physics.hasOwnProperty("P2") && (this.p2 = new H.Physics.P2(this.game, this.config)), this.config.hasOwnProperty("box2d") && !0 === this.config.box2d && H.Physics.hasOwnProperty("BOX2D") && (this.box2d = new H.Physics.BOX2D(this.game, this.config)), this.config.hasOwnProperty("matter") && !0 === this.config.matter && H.Physics.hasOwnProperty("Matter") && (this.matter = new H.Physics.Matter(this.game, this.config)) }, startSystem: function(t) { t === H.Physics.ARCADE ? this.arcade = new H.Physics.Arcade(this.game) : t === H.Physics.P2JS ? null === this.p2 ? this.p2 = new H.Physics.P2(this.game, this.config) : this.p2.reset() : t === H.Physics.NINJA ? this.ninja = new H.Physics.Ninja(this.game) : t === H.Physics.BOX2D ? null === this.box2d ? this.box2d = new H.Physics.Box2D(this.game, this.config) : this.box2d.reset() : t === H.Physics.MATTERJS && (null === this.matter ? this.matter = new H.Physics.Matter(this.game, this.config) : this.matter.reset()) }, enable: function(t, e, i) { void 0 === e && (e = H.Physics.ARCADE), void 0 === i && (i = !1), e === H.Physics.ARCADE ? this.arcade.enable(t) : e === H.Physics.P2JS && this.p2 ? this.p2.enable(t, i) : e === H.Physics.NINJA && this.ninja ? this.ninja.enableAABB(t) : e === H.Physics.BOX2D && this.box2d ? this.box2d.enable(t) : e === H.Physics.MATTERJS && this.matter && this.matter.enable(t) }, preUpdate: function() { this.p2 && this.p2.preUpdate(), this.box2d && this.box2d.preUpdate(), this.matter && this.matter.preUpdate() }, update: function() { this.p2 && this.p2.update(), this.box2d && this.box2d.update(), this.matter && this.matter.update() }, setBoundsToWorld: function() { this.arcade && this.arcade.setBoundsToWorld(), this.ninja && this.ninja.setBoundsToWorld(), this.p2 && this.p2.setBoundsToWorld(), this.box2d && this.box2d.setBoundsToWorld(), this.matter && this.matter.setBoundsToWorld() }, clear: function() { this.p2 && this.p2.clear(), this.box2d && this.box2d.clear(), this.matter && this.matter.clear() }, reset: function() { this.p2 && this.p2.reset(), this.box2d && this.box2d.reset(), this.matter && this.matter.reset() }, destroy: function() { this.p2 && this.p2.destroy(), this.box2d && this.box2d.destroy(), this.matter && this.matter.destroy(), this.arcade = null, this.ninja = null, this.p2 = null, this.box2d = null, this.matter = null } }, H.Physics.prototype.constructor = H.Physics, H.Physics.Arcade = function(t) { this.game = t, this.gravity = new H.Point, this.bounds = new H.Rectangle(0, 0, t.world.width, t.world.height), this.checkCollision = { up: !0, down: !0, left: !0, right: !0 }, this.maxObjects = 10, this.maxLevels = 4, this.OVERLAP_BIAS = 4, this.forceX = !1, this.sortDirection = H.Physics.Arcade.LEFT_RIGHT, this.skipQuadTree = !0, this.isPaused = !1, this.quadTree = new H.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this._total = 0, this.setBoundsToWorld() }, H.Physics.Arcade.prototype.constructor = H.Physics.Arcade, H.Physics.Arcade.SORT_NONE = 0, H.Physics.Arcade.LEFT_RIGHT = 1, H.Physics.Arcade.RIGHT_LEFT = 2, H.Physics.Arcade.TOP_BOTTOM = 3, H.Physics.Arcade.BOTTOM_TOP = 4, H.Physics.Arcade.prototype = {
|
|
setBounds: function(t, e, i, s) { this.bounds.setTo(t, e, i, s) },
|
|
setBoundsToWorld: function() { this.bounds.copyFrom(this.game.world.bounds) },
|
|
enable: function(t, e) {
|
|
void 0 === e && (e = !0);
|
|
var i = 1;
|
|
if (Array.isArray(t))
|
|
for (i = t.length; i--;) t[i] instanceof H.Group ? this.enable(t[i].children, e) : (this.enableBody(t[i]), e && t[i].hasOwnProperty("children") && 0 < t[i].children.length && this.enable(t[i], !0));
|
|
else t instanceof H.Group ? this.enable(t.children, e) : (this.enableBody(t), e && t.hasOwnProperty("children") && 0 < t.children.length && this.enable(t.children, !0))
|
|
},
|
|
enableBody: function(t) { t.hasOwnProperty("body") && null === t.body && (t.body = new H.Physics.Arcade.Body(t), t.parent && t.parent instanceof H.Group && t.parent.addToHash(t)) },
|
|
updateMotion: function(t) {
|
|
var e = this.computeVelocity(0, t, t.angularVelocity, t.angularAcceleration, t.angularDrag, t.maxAngular) - t.angularVelocity;
|
|
t.angularVelocity += e, t.rotation += t.angularVelocity * this.game.time.physicsElapsed, t.velocity.x = this.computeVelocity(1, t, t.velocity.x, t.acceleration.x, t.drag.x, t.maxVelocity.x), t.velocity.y = this.computeVelocity(2, t, t.velocity.y, t.acceleration.y, t.drag.y, t.maxVelocity.y)
|
|
},
|
|
computeVelocity: function(t, e, i, s, o, n) { return void 0 === n && (n = 1e4), 1 === t && e.allowGravity ? i += (this.gravity.x + e.gravity.x) * this.game.time.physicsElapsed : 2 === t && e.allowGravity && (i += (this.gravity.y + e.gravity.y) * this.game.time.physicsElapsed), s ? i += s * this.game.time.physicsElapsed : o && (0 < i - (o *= this.game.time.physicsElapsed) ? i -= o : i + o < 0 ? i += o : i = 0), n < i ? i = n : i < -n && (i = -n), i },
|
|
overlap: function(t, e, i, s, o) {
|
|
if (i = i || null, s = s || null, o = o || i, this._total = 0, !Array.isArray(t) && Array.isArray(e))
|
|
for (var n = 0; n < e.length; n++) this.collideHandler(t, e[n], i, s, o, !0);
|
|
else if (Array.isArray(t) && !Array.isArray(e))
|
|
for (n = 0; n < t.length; n++) this.collideHandler(t[n], e, i, s, o, !0);
|
|
else if (Array.isArray(t) && Array.isArray(e))
|
|
for (n = 0; n < t.length; n++)
|
|
for (var a = 0; a < e.length; a++) this.collideHandler(t[n], e[a], i, s, o, !0);
|
|
else this.collideHandler(t, e, i, s, o, !0);
|
|
return 0 < this._total
|
|
},
|
|
collide: function(t, e, i, s, o) {
|
|
if (i = i || null, s = s || null, o = o || i, this._total = 0, !Array.isArray(t) && Array.isArray(e))
|
|
for (var n = 0; n < e.length; n++) this.collideHandler(t, e[n], i, s, o, !1);
|
|
else if (Array.isArray(t) && !Array.isArray(e))
|
|
for (n = 0; n < t.length; n++) this.collideHandler(t[n], e, i, s, o, !1);
|
|
else if (Array.isArray(t) && Array.isArray(e))
|
|
for (n = 0; n < t.length; n++)
|
|
for (var a = 0; a < e.length; a++) this.collideHandler(t[n], e[a], i, s, o, !1);
|
|
else this.collideHandler(t, e, i, s, o, !1);
|
|
return 0 < this._total
|
|
},
|
|
sortLeftRight: function(t, e) { return t.body && e.body ? t.body.x - e.body.x : 0 },
|
|
sortRightLeft: function(t, e) { return t.body && e.body ? e.body.x - t.body.x : 0 },
|
|
sortTopBottom: function(t, e) { return t.body && e.body ? t.body.y - e.body.y : 0 },
|
|
sortBottomTop: function(t, e) { return t.body && e.body ? e.body.y - t.body.y : 0 },
|
|
sort: function(t, e) { null !== t.physicsSortDirection ? e = t.physicsSortDirection : void 0 === e && (e = this.sortDirection), e === H.Physics.Arcade.LEFT_RIGHT ? t.hash.sort(this.sortLeftRight) : e === H.Physics.Arcade.RIGHT_LEFT ? t.hash.sort(this.sortRightLeft) : e === H.Physics.Arcade.TOP_BOTTOM ? t.hash.sort(this.sortTopBottom) : e === H.Physics.Arcade.BOTTOM_TOP && t.hash.sort(this.sortBottomTop) },
|
|
collideHandler: function(t, e, i, s, o, n) {
|
|
if (void 0 === e && t.physicsType === H.GROUP) return this.sort(t), void this.collideGroupVsSelf(t, i, s, o, n);
|
|
t && e && t.exists && e.exists && (this.sortDirection !== H.Physics.Arcade.SORT_NONE && (t.physicsType === H.GROUP && this.sort(t), e.physicsType === H.GROUP && this.sort(e)), t.physicsType === H.SPRITE ? e.physicsType === H.SPRITE ? this.collideSpriteVsSprite(t, e, i, s, o, n) : e.physicsType === H.GROUP ? this.collideSpriteVsGroup(t, e, i, s, o, n) : e.physicsType === H.TILEMAPLAYER && this.collideSpriteVsTilemapLayer(t, e, i, s, o, n) : t.physicsType === H.GROUP ? e.physicsType === H.SPRITE ? this.collideSpriteVsGroup(e, t, i, s, o, n) : e.physicsType === H.GROUP ? this.collideGroupVsGroup(t, e, i, s, o, n) : e.physicsType === H.TILEMAPLAYER && this.collideGroupVsTilemapLayer(t, e, i, s, o, n) : t.physicsType === H.TILEMAPLAYER && (e.physicsType === H.SPRITE ? this.collideSpriteVsTilemapLayer(e, t, i, s, o, n) : e.physicsType === H.GROUP && this.collideGroupVsTilemapLayer(e, t, i, s, o, n)))
|
|
},
|
|
collideSpriteVsSprite: function(t, e, i, s, o, n) { return !(!t.body || !e.body) && (this.separate(t.body, e.body, s, o, n) && (i && i.call(o, t, e), this._total++), !0) },
|
|
collideSpriteVsGroup: function(t, e, i, s, o, n) {
|
|
if (0 !== e.length && t.body)
|
|
if (this.skipQuadTree || t.body.skipQuadTree)
|
|
for (var a = {}, r = 0; r < e.hash.length; r++) { var h = e.hash[r]; if (h && h.exists && h.body) { if (a = h.body.getBounds(a), this.sortDirection === H.Physics.Arcade.LEFT_RIGHT) { if (t.body.right < a.x) break; if (a.right < t.body.x) continue } else if (this.sortDirection === H.Physics.Arcade.RIGHT_LEFT) { if (t.body.x > a.right) break; if (a.x > t.body.right) continue } else if (this.sortDirection === H.Physics.Arcade.TOP_BOTTOM) { if (t.body.bottom < a.y) break; if (a.bottom < t.body.y) continue } else if (this.sortDirection === H.Physics.Arcade.BOTTOM_TOP) { if (t.body.y > a.bottom) break; if (a.y > t.body.bottom) continue } this.collideSpriteVsSprite(t, h, i, s, o, n) } }
|
|
else { this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(e); var l = this.quadTree.retrieve(t); for (r = 0; r < l.length; r++) this.separate(t.body, l[r], s, o, n) && (i && i.call(o, t, l[r].sprite), this._total++) }
|
|
},
|
|
collideGroupVsSelf: function(t, e, i, s, o) {
|
|
if (0 !== t.length)
|
|
for (var n = 0; n < t.hash.length; n++) {
|
|
var a = {},
|
|
r = t.hash[n];
|
|
if (r && r.exists && r.body) {
|
|
a = r.body.getBounds(a);
|
|
for (var h = n + 1; h < t.hash.length; h++) {
|
|
var l = {},
|
|
c = t.hash[h];
|
|
if (c && c.exists && c.body) { if (l = c.body.getBounds(l), this.sortDirection === H.Physics.Arcade.LEFT_RIGHT) { if (a.right < l.x) break; if (l.right < a.x) continue } else if (this.sortDirection === H.Physics.Arcade.RIGHT_LEFT) { if (a.x > l.right) continue; if (l.x > a.right) break } else if (this.sortDirection === H.Physics.Arcade.TOP_BOTTOM) { if (a.bottom < l.y) continue; if (l.bottom < a.y) break } else if (this.sortDirection === H.Physics.Arcade.BOTTOM_TOP) { if (a.y > l.bottom) continue; if (l.y > r.body.bottom) break } this.collideSpriteVsSprite(r, c, e, i, s, o) }
|
|
}
|
|
}
|
|
}
|
|
},
|
|
collideGroupVsGroup: function(t, e, i, s, o, n) {
|
|
if (0 !== t.length && 0 !== e.length)
|
|
for (var a = 0; a < t.children.length; a++) t.children[a].exists && (t.children[a].physicsType === H.GROUP ? this.collideGroupVsGroup(t.children[a], e, i, s, o, n) : this.collideSpriteVsGroup(t.children[a], e, i, s, o, n))
|
|
},
|
|
separate: function(t, e, i, s, o) {
|
|
if (!t.enable || !e.enable || t.checkCollision.none || e.checkCollision.none || !this.intersects(t, e)) return !1;
|
|
if (i && !1 === i.call(s, t.sprite, e.sprite)) return !1;
|
|
if (t.isCircle && e.isCircle) return this.separateCircle(t, e, o);
|
|
if (t.isCircle !== e.isCircle) {
|
|
var n = t.isCircle ? e : t,
|
|
a = t.isCircle ? t : e,
|
|
r = n.x,
|
|
h = n.y,
|
|
l = n.right,
|
|
c = n.bottom,
|
|
p = a.x + a.radius,
|
|
u = a.y + a.radius;
|
|
if ((u < h || c < u) && (p < r || l < p)) return this.separateCircle(t, e, o)
|
|
}
|
|
var d = !1,
|
|
y = !1;
|
|
this.forceX || Math.abs(this.gravity.y + t.gravity.y) < Math.abs(this.gravity.x + t.gravity.x) ? (d = this.separateX(t, e, o), this.intersects(t, e) && (y = this.separateY(t, e, o))) : (y = this.separateY(t, e, o), this.intersects(t, e) && (d = this.separateX(t, e, o)));
|
|
var g = d || y;
|
|
return g && (o ? (t.onOverlap && t.onOverlap.dispatch(t.sprite, e.sprite), e.onOverlap && e.onOverlap.dispatch(e.sprite, t.sprite)) : (t.onCollide && t.onCollide.dispatch(t.sprite, e.sprite), e.onCollide && e.onCollide.dispatch(e.sprite, t.sprite))), g
|
|
},
|
|
intersects: function(t, e) { return t !== e && (t.isCircle ? e.isCircle ? H.Math.distance(t.center.x, t.center.y, e.center.x, e.center.y) <= t.radius + e.radius : this.circleBodyIntersects(t, e) : e.isCircle ? this.circleBodyIntersects(e, t) : !(t.right <= e.position.x) && (!(t.bottom <= e.position.y) && (!(t.position.x >= e.right) && !(t.position.y >= e.bottom)))) },
|
|
circleBodyIntersects: function(t, e) {
|
|
var i = H.Math.clamp(t.center.x, e.left, e.right),
|
|
s = H.Math.clamp(t.center.y, e.top, e.bottom);
|
|
return (t.center.x - i) * (t.center.x - i) + (t.center.y - s) * (t.center.y - s) <= t.radius * t.radius
|
|
},
|
|
separateCircle: function(t, e, i) {
|
|
this.getOverlapX(t, e), this.getOverlapY(t, e);
|
|
var s = e.center.x - t.center.x,
|
|
o = e.center.y - t.center.y,
|
|
n = Math.atan2(o, s),
|
|
a = 0;
|
|
if (t.isCircle !== e.isCircle) {
|
|
var r = { x: e.isCircle ? t.position.x : e.position.x, y: e.isCircle ? t.position.y : e.position.y, right: e.isCircle ? t.right : e.right, bottom: e.isCircle ? t.bottom : e.bottom },
|
|
h = { x: t.isCircle ? t.position.x + t.radius : e.position.x + e.radius, y: t.isCircle ? t.position.y + t.radius : e.position.y + e.radius, radius: t.isCircle ? t.radius : e.radius };
|
|
h.y < r.y ? h.x < r.x ? a = H.Math.distance(h.x, h.y, r.x, r.y) - h.radius : r.right < h.x && (a = H.Math.distance(h.x, h.y, r.right, r.y) - h.radius) : r.bottom < h.y && (h.x < r.x ? a = H.Math.distance(h.x, h.y, r.x, r.bottom) - h.radius : r.right < h.x && (a = H.Math.distance(h.x, h.y, r.right, r.bottom) - h.radius)), a *= -1
|
|
}
|
|
else a = t.radius + e.radius - H.Math.distance(t.center.x, t.center.y, e.center.x, e.center.y);
|
|
if (i || 0 === a || t.immovable && e.immovable || t.customSeparateX || e.customSeparateX) return 0 !== a && (t.onOverlap && t.onOverlap.dispatch(t.sprite, e.sprite), e.onOverlap && e.onOverlap.dispatch(e.sprite, t.sprite)), 0 !== a;
|
|
var l = t.velocity.x * Math.cos(n) + t.velocity.y * Math.sin(n),
|
|
c = t.velocity.x * Math.sin(n) - t.velocity.y * Math.cos(n),
|
|
p = e.velocity.x * Math.cos(n) + e.velocity.y * Math.sin(n),
|
|
u = e.velocity.x * Math.sin(n) - e.velocity.y * Math.cos(n),
|
|
d = ((t.mass - e.mass) * l + 2 * e.mass * p) / (t.mass + e.mass),
|
|
y = (2 * t.mass * l + (e.mass - t.mass) * p) / (t.mass + e.mass);
|
|
return t.immovable || (t.velocity.x = (d * Math.cos(n) - c * Math.sin(n)) * t.bounce.x, t.velocity.y = (c * Math.cos(n) + d * Math.sin(n)) * t.bounce.y), e.immovable || (e.velocity.x = (y * Math.cos(n) - u * Math.sin(n)) * e.bounce.x, e.velocity.y = (u * Math.cos(n) + y * Math.sin(n)) * e.bounce.y), Math.abs(n) < Math.PI / 2 ? 0 < t.velocity.x && !t.immovable && e.velocity.x > t.velocity.x ? t.velocity.x *= -1 : e.velocity.x < 0 && !e.immovable && t.velocity.x < e.velocity.x ? e.velocity.x *= -1 : 0 < t.velocity.y && !t.immovable && e.velocity.y > t.velocity.y ? t.velocity.y *= -1 : e.velocity.y < 0 && !e.immovable && t.velocity.y < e.velocity.y && (e.velocity.y *= -1) : Math.abs(n) > Math.PI / 2 && (t.velocity.x < 0 && !t.immovable && e.velocity.x < t.velocity.x ? t.velocity.x *= -1 : 0 < e.velocity.x && !e.immovable && t.velocity.x > e.velocity.x ? e.velocity.x *= -1 : t.velocity.y < 0 && !t.immovable && e.velocity.y < t.velocity.y ? t.velocity.y *= -1 : 0 < e.velocity.y && !e.immovable && t.velocity.x > e.velocity.y && (e.velocity.y *= -1)), t.immovable || (t.x += t.velocity.x * this.game.time.physicsElapsed - a * Math.cos(n), t.y += t.velocity.y * this.game.time.physicsElapsed - a * Math.sin(n)), e.immovable || (e.x += e.velocity.x * this.game.time.physicsElapsed + a * Math.cos(n), e.y += e.velocity.y * this.game.time.physicsElapsed + a * Math.sin(n)), t.onCollide && t.onCollide.dispatch(t.sprite, e.sprite), e.onCollide && e.onCollide.dispatch(e.sprite, t.sprite), !0
|
|
},
|
|
getOverlapX: function(t, e, i) {
|
|
var s = 0,
|
|
o = t.deltaAbsX() + e.deltaAbsX() + this.OVERLAP_BIAS;
|
|
return 0 === t.deltaX() && 0 === e.deltaX() ? (t.embedded = !0, e.embedded = !0) : t.deltaX() > e.deltaX() ? o < (s = t.right - e.x) && !i || !1 === t.checkCollision.right || !1 === e.checkCollision.left ? s = 0 : (t.touching.none = !1, t.touching.right = !0, e.touching.none = !1, e.touching.left = !0) : t.deltaX() < e.deltaX() && (o < -(s = t.x - e.width - e.x) && !i || !1 === t.checkCollision.left || !1 === e.checkCollision.right ? s = 0 : (t.touching.none = !1, t.touching.left = !0, e.touching.none = !1, e.touching.right = !0)), t.overlapX = s, e.overlapX = s
|
|
},
|
|
getOverlapY: function(t, e, i) {
|
|
var s = 0,
|
|
o = t.deltaAbsY() + e.deltaAbsY() + this.OVERLAP_BIAS;
|
|
return 0 === t.deltaY() && 0 === e.deltaY() ? (t.embedded = !0, e.embedded = !0) : t.deltaY() > e.deltaY() ? o < (s = t.bottom - e.y) && !i || !1 === t.checkCollision.down || !1 === e.checkCollision.up ? s = 0 : (t.touching.none = !1, t.touching.down = !0, e.touching.none = !1, e.touching.up = !0) : t.deltaY() < e.deltaY() && (o < -(s = t.y - e.bottom) && !i || !1 === t.checkCollision.up || !1 === e.checkCollision.down ? s = 0 : (t.touching.none = !1, t.touching.up = !0, e.touching.none = !1, e.touching.down = !0)), t.overlapY = s, e.overlapY = s
|
|
},
|
|
separateX: function(t, e, i) {
|
|
var s = this.getOverlapX(t, e, i);
|
|
if (i || 0 === s || t.immovable && e.immovable || t.customSeparateX || e.customSeparateX) return 0 !== s || t.embedded && e.embedded;
|
|
var o = t.velocity.x,
|
|
n = e.velocity.x;
|
|
if (t.immovable || e.immovable) t.immovable ? (e.x += s, e.velocity.x = o - n * e.bounce.x, t.moves && (e.y += (t.y - t.prev.y) * t.friction.y)) : (t.x -= s, t.velocity.x = n - o * t.bounce.x, e.moves && (t.y += (e.y - e.prev.y) * e.friction.y));
|
|
else {
|
|
s *= .5, t.x -= s, e.x += s;
|
|
var a = Math.sqrt(n * n * e.mass / t.mass) * (0 < n ? 1 : -1),
|
|
r = Math.sqrt(o * o * t.mass / e.mass) * (0 < o ? 1 : -1),
|
|
h = .5 * (a + r);
|
|
a -= h, r -= h, t.velocity.x = h + a * t.bounce.x, e.velocity.x = h + r * e.bounce.x
|
|
}
|
|
return !0
|
|
},
|
|
separateY: function(t, e, i) {
|
|
var s = this.getOverlapY(t, e, i);
|
|
if (i || 0 === s || t.immovable && e.immovable || t.customSeparateY || e.customSeparateY) return 0 !== s || t.embedded && e.embedded;
|
|
var o = t.velocity.y,
|
|
n = e.velocity.y;
|
|
if (t.immovable || e.immovable) t.immovable ? (e.y += s, e.velocity.y = o - n * e.bounce.y, t.moves && (e.x += (t.x - t.prev.x) * t.friction.x)) : (t.y -= s, t.velocity.y = n - o * t.bounce.y, e.moves && (t.x += (e.x - e.prev.x) * e.friction.x));
|
|
else {
|
|
s *= .5, t.y -= s, e.y += s;
|
|
var a = Math.sqrt(n * n * e.mass / t.mass) * (0 < n ? 1 : -1),
|
|
r = Math.sqrt(o * o * t.mass / e.mass) * (0 < o ? 1 : -1),
|
|
h = .5 * (a + r);
|
|
a -= h, r -= h, t.velocity.y = h + a * t.bounce.y, e.velocity.y = h + r * e.bounce.y
|
|
}
|
|
return !0
|
|
},
|
|
getObjectsUnderPointer: function(t, e, i, s) { if (0 !== e.length && t.exists) return this.getObjectsAtLocation(t.x, t.y, e, i, s, t) },
|
|
getObjectsAtLocation: function(t, e, i, s, o, n) { this.quadTree.clear(), this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels), this.quadTree.populate(i); for (var a = new H.Rectangle(t, e, 1, 1), r = [], h = this.quadTree.retrieve(a), l = 0; l < h.length; l++) h[l].hitTest(t, e) && (s && s.call(o, n, h[l].sprite), r.push(h[l].sprite)); return r },
|
|
moveToObject: function(t, e, i, s) { void 0 === i && (i = 60), void 0 === s && (s = 0); var o = Math.atan2(e.y - t.y, e.x - t.x); return 0 < s && (i = this.distanceBetween(t, e) / (s / 1e3)), t.body.velocity.x = Math.cos(o) * i, t.body.velocity.y = Math.sin(o) * i, o },
|
|
moveToPointer: function(t, e, i, s) { void 0 === e && (e = 60), i = i || this.game.input.activePointer, void 0 === s && (s = 0); var o = this.angleToPointer(t, i); return 0 < s && (e = this.distanceToPointer(t, i) / (s / 1e3)), t.body.velocity.x = Math.cos(o) * e, t.body.velocity.y = Math.sin(o) * e, o },
|
|
moveToXY: function(t, e, i, s, o) { void 0 === s && (s = 60), void 0 === o && (o = 0); var n = Math.atan2(i - t.y, e - t.x); return 0 < o && (s = this.distanceToXY(t, e, i) / (o / 1e3)), t.body.velocity.x = Math.cos(n) * s, t.body.velocity.y = Math.sin(n) * s, n },
|
|
velocityFromAngle: function(t, e, i) { return void 0 === e && (e = 60), (i = i || new H.Point).setTo(Math.cos(this.game.math.degToRad(t)) * e, Math.sin(this.game.math.degToRad(t)) * e) },
|
|
velocityFromRotation: function(t, e, i) { return void 0 === e && (e = 60), (i = i || new H.Point).setTo(Math.cos(t) * e, Math.sin(t) * e) },
|
|
accelerationFromRotation: function(t, e, i) { return void 0 === e && (e = 60), (i = i || new H.Point).setTo(Math.cos(t) * e, Math.sin(t) * e) },
|
|
accelerateToObject: function(t, e, i, s, o) { void 0 === i && (i = 60), void 0 === s && (s = 1e3), void 0 === o && (o = 1e3); var n = this.angleBetween(t, e); return t.body.acceleration.setTo(Math.cos(n) * i, Math.sin(n) * i), t.body.maxVelocity.setTo(s, o), n },
|
|
accelerateToPointer: function(t, e, i, s, o) { void 0 === i && (i = 60), void 0 === e && (e = this.game.input.activePointer), void 0 === s && (s = 1e3), void 0 === o && (o = 1e3); var n = this.angleToPointer(t, e); return t.body.acceleration.setTo(Math.cos(n) * i, Math.sin(n) * i), t.body.maxVelocity.setTo(s, o), n },
|
|
accelerateToXY: function(t, e, i, s, o, n) { void 0 === s && (s = 60), void 0 === o && (o = 1e3), void 0 === n && (n = 1e3); var a = this.angleToXY(t, e, i); return t.body.acceleration.setTo(Math.cos(a) * s, Math.sin(a) * s), t.body.maxVelocity.setTo(o, n), a },
|
|
distanceBetween: function(t, e, i) {
|
|
void 0 === i && (i = !1);
|
|
var s = i ? t.world.x - e.world.x : t.x - e.x,
|
|
o = i ? t.world.y - e.world.y : t.y - e.y;
|
|
return Math.sqrt(s * s + o * o)
|
|
},
|
|
distanceToXY: function(t, e, i, s) {
|
|
void 0 === s && (s = !1);
|
|
var o = s ? t.world.x - e : t.x - e,
|
|
n = s ? t.world.y - i : t.y - i;
|
|
return Math.sqrt(o * o + n * n)
|
|
},
|
|
distanceToPointer: function(t, e, i) {
|
|
void 0 === e && (e = this.game.input.activePointer), void 0 === i && (i = !1);
|
|
var s = i ? t.world.x - e.worldX : t.x - e.worldX,
|
|
o = i ? t.world.y - e.worldY : t.y - e.worldY;
|
|
return Math.sqrt(s * s + o * o)
|
|
},
|
|
angleBetween: function(t, e, i) { return void 0 === i && (i = !1), i ? Math.atan2(e.world.y - t.world.y, e.world.x - t.world.x) : Math.atan2(e.y - t.y, e.x - t.x) },
|
|
angleBetweenCenters: function(t, e) {
|
|
var i = e.centerX - t.centerX,
|
|
s = e.centerY - t.centerY;
|
|
return Math.atan2(s, i)
|
|
},
|
|
angleToXY: function(t, e, i, s) { return void 0 === s && (s = !1), s ? Math.atan2(i - t.world.y, e - t.world.x) : Math.atan2(i - t.y, e - t.x) },
|
|
angleToPointer: function(t, e, i) { return void 0 === e && (e = this.game.input.activePointer), void 0 === i && (i = !1), i ? Math.atan2(e.worldY - t.world.y, e.worldX - t.world.x) : Math.atan2(e.worldY - t.y, e.worldX - t.x) },
|
|
worldAngleToPointer: function(t, e) { return this.angleToPointer(t, e, !0) }
|
|
}, H.Physics.Arcade.Body = function(t) { this.sprite = t, this.game = t.game, this.type = H.Physics.ARCADE, this.enable = !0, this.isCircle = !1, this.radius = 0, this.offset = new H.Point, this.position = new H.Point(t.x, t.y), this.prev = new H.Point(this.position.x, this.position.y), this.allowRotation = !0, this.rotation = t.angle, this.preRotation = t.angle, this.width = t.width, this.height = t.height, this.sourceWidth = t.width, this.sourceHeight = t.height, t.texture && (this.sourceWidth = t.texture.frame.width, this.sourceHeight = t.texture.frame.height), this.halfWidth = Math.abs(t.width / 2), this.halfHeight = Math.abs(t.height / 2), this.center = new H.Point(t.x + this.halfWidth, t.y + this.halfHeight), this.velocity = new H.Point, this.newVelocity = new H.Point, this.deltaMax = new H.Point, this.acceleration = new H.Point, this.drag = new H.Point, this.allowGravity = !0, this.gravity = new H.Point, this.bounce = new H.Point, this.worldBounce = null, this.onWorldBounds = null, this.onCollide = null, this.onOverlap = null, this.maxVelocity = new H.Point(1e4, 1e4), this.friction = new H.Point(1, 0), this.angularVelocity = 0, this.angularAcceleration = 0, this.angularDrag = 0, this.maxAngular = 1e3, this.mass = 1, this.angle = 0, this.speed = 0, this.facing = H.NONE, this.immovable = !1, this.moves = !0, this.customSeparateX = !1, this.customSeparateY = !1, this.overlapX = 0, this.overlapY = 0, this.overlapR = 0, this.embedded = !1, this.collideWorldBounds = !1, this.checkCollision = { none: !1, any: !0, up: !0, down: !0, left: !0, right: !0 }, this.touching = { none: !0, up: !1, down: !1, left: !1, right: !1 }, this.wasTouching = { none: !0, up: !1, down: !1, left: !1, right: !1 }, this.blocked = { up: !1, down: !1, left: !1, right: !1 }, this.tilePadding = new H.Point, this.dirty = !1, this.skipQuadTree = !1, this.syncBounds = !1, this.isMoving = !1, this.stopVelocityOnCollide = !0, this.moveTimer = 0, this.moveDistance = 0, this.moveDuration = 0, this.moveTarget = null, this.moveEnd = null, this.onMoveComplete = new H.Signal, this.movementCallback = null, this.movementCallbackContext = null, this._reset = !0, this._sx = t.scale.x, this._sy = t.scale.y, this._dx = 0, this._dy = 0 }, H.Physics.Arcade.Body.prototype = {
|
|
updateBounds: function() {
|
|
if (this.syncBounds) {
|
|
var t = this.sprite.getBounds();
|
|
t.ceilAll(), t.width === this.width && t.height === this.height || (this.width = t.width, this.height = t.height, this._reset = !0)
|
|
}
|
|
else {
|
|
var e = Math.abs(this.sprite.scale.x),
|
|
i = Math.abs(this.sprite.scale.y);
|
|
e === this._sx && i === this._sy || (this.width = this.sourceWidth * e, this.height = this.sourceHeight * i, this._sx = e, this._sy = i, this._reset = !0)
|
|
}
|
|
this._reset && (this.halfWidth = Math.floor(this.width / 2), this.halfHeight = Math.floor(this.height / 2), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight))
|
|
},
|
|
preUpdate: function() { this.enable && !this.game.physics.arcade.isPaused && (this.dirty = !0, this.wasTouching.none = this.touching.none, this.wasTouching.up = this.touching.up, this.wasTouching.down = this.touching.down, this.wasTouching.left = this.touching.left, this.wasTouching.right = this.touching.right, this.touching.none = !0, this.touching.up = !1, this.touching.down = !1, this.touching.left = !1, this.touching.right = !1, this.blocked.up = !1, this.blocked.down = !1, this.blocked.left = !1, this.blocked.right = !1, this.embedded = !1, this.updateBounds(), this.position.x = this.sprite.world.x - this.sprite.anchor.x * this.sprite.width + this.sprite.scale.x * this.offset.x, this.position.x -= this.sprite.scale.x < 0 ? this.width : 0, this.position.y = this.sprite.world.y - this.sprite.anchor.y * this.sprite.height + this.sprite.scale.y * this.offset.y, this.position.y -= this.sprite.scale.y < 0 ? this.height : 0, this.rotation = this.sprite.angle, this.preRotation = this.rotation, (this._reset || this.sprite.fresh) && (this.prev.x = this.position.x, this.prev.y = this.position.y), this.moves && (this.game.physics.arcade.updateMotion(this), this.newVelocity.set(this.velocity.x * this.game.time.physicsElapsed, this.velocity.y * this.game.time.physicsElapsed), this.position.x += this.newVelocity.x, this.position.y += this.newVelocity.y, this.position.x === this.prev.x && this.position.y === this.prev.y || (this.angle = Math.atan2(this.velocity.y, this.velocity.x)), this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y), this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds && this.onWorldBounds.dispatch(this.sprite, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right)), this._dx = this.deltaX(), this._dy = this.deltaY(), this._reset = !1) },
|
|
updateMovement: function() {
|
|
var t = 0,
|
|
e = 0 !== this.overlapX || 0 !== this.overlapY;
|
|
if (t = 0 < this.moveDuration ? (this.moveTimer += this.game.time.elapsedMS, this.moveTimer / this.moveDuration) : (this.moveTarget.end.set(this.position.x, this.position.y), this.moveTarget.length / this.moveDistance), this.movementCallback) var i = this.movementCallback.call(this.movementCallbackContext, this, this.velocity, t);
|
|
return !(e || 1 <= t || void 0 !== i && !0 !== i) || (this.stopMovement(1 <= t || this.stopVelocityOnCollide && e), !1)
|
|
},
|
|
stopMovement: function(t) { this.isMoving && (this.isMoving = !1, t && this.velocity.set(0), this.onMoveComplete.dispatch(this.sprite, 0 !== this.overlapX || 0 !== this.overlapY)) },
|
|
postUpdate: function() { this.enable && this.dirty && (this.isMoving && this.updateMovement(), this.dirty = !1, this.deltaX() < 0 ? this.facing = H.LEFT : 0 < this.deltaX() && (this.facing = H.RIGHT), this.deltaY() < 0 ? this.facing = H.UP : 0 < this.deltaY() && (this.facing = H.DOWN), this.moves && (this._dx = this.deltaX(), this._dy = this.deltaY(), 0 !== this.deltaMax.x && 0 !== this._dx && (this._dx < 0 && this._dx < -this.deltaMax.x ? this._dx = -this.deltaMax.x : 0 < this._dx && this._dx > this.deltaMax.x && (this._dx = this.deltaMax.x)), 0 !== this.deltaMax.y && 0 !== this._dy && (this._dy < 0 && this._dy < -this.deltaMax.y ? this._dy = -this.deltaMax.y : 0 < this._dy && this._dy > this.deltaMax.y && (this._dy = this.deltaMax.y)), this.sprite.position.x += this._dx, this.sprite.position.y += this._dy, this._reset = !0), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight), this.allowRotation && (this.sprite.angle += this.deltaZ()), this.prev.x = this.position.x, this.prev.y = this.position.y) },
|
|
checkWorldBounds: function() {
|
|
var t = this.position,
|
|
e = this.game.physics.arcade.bounds,
|
|
i = this.game.physics.arcade.checkCollision,
|
|
s = this.worldBounce ? -this.worldBounce.x : -this.bounce.x,
|
|
o = this.worldBounce ? -this.worldBounce.y : -this.bounce.y;
|
|
if (this.isCircle) {
|
|
var n = this.center.x - this.radius,
|
|
a = this.center.y - this.radius,
|
|
r = this.center.x + this.radius,
|
|
h = this.center.y + this.radius;
|
|
n < e.x && i.left ? (t.x = e.x - this.halfWidth + this.radius, this.velocity.x *= s, this.blocked.left = !0) : r > e.right && i.right && (t.x = e.right - this.halfWidth - this.radius, this.velocity.x *= s, this.blocked.right = !0), a < e.y && i.up ? (t.y = e.y - this.halfHeight + this.radius, this.velocity.y *= o, this.blocked.up = !0) : h > e.bottom && i.down && (t.y = e.bottom - this.halfHeight - this.radius, this.velocity.y *= o, this.blocked.down = !0)
|
|
}
|
|
else t.x < e.x && i.left ? (t.x = e.x, this.velocity.x *= s, this.blocked.left = !0) : this.right > e.right && i.right && (t.x = e.right - this.width, this.velocity.x *= s, this.blocked.right = !0), t.y < e.y && i.up ? (t.y = e.y, this.velocity.y *= o, this.blocked.up = !0) : this.bottom > e.bottom && i.down && (t.y = e.bottom - this.height, this.velocity.y *= o, this.blocked.down = !0);
|
|
return this.blocked.up || this.blocked.down || this.blocked.left || this.blocked.right
|
|
},
|
|
moveFrom: function(t, e, i) { return void 0 === e && (e = this.speed), 0 !== e && (void 0 === i ? (s = this.angle, i = this.game.math.radToDeg(s)) : s = this.game.math.degToRad(i), this.moveTimer = 0, this.moveDuration = t, 0 === i || 180 === i ? this.velocity.set(Math.cos(s) * e, 0) : 90 === i || 270 === i ? this.velocity.set(0, Math.sin(s) * e) : this.velocity.set(Math.cos(s) * e, Math.sin(s) * e), this.isMoving = !0); var s },
|
|
moveTo: function(t, e, i) { var s, o = e / (t / 1e3); return 0 !== o && (void 0 === i ? (s = this.angle, i = this.game.math.radToDeg(s)) : s = this.game.math.degToRad(i), e = Math.abs(e), this.moveDuration = 0, this.moveDistance = e, null === this.moveTarget && (this.moveTarget = new H.Line, this.moveEnd = new H.Point), this.moveTarget.fromAngle(this.x, this.y, s, e), this.moveEnd.set(this.moveTarget.end.x, this.moveTarget.end.y), this.moveTarget.setTo(this.x, this.y, this.x, this.y), 0 === i || 180 === i ? this.velocity.set(Math.cos(s) * o, 0) : 90 === i || 270 === i ? this.velocity.set(0, Math.sin(s) * o) : this.velocity.set(Math.cos(s) * o, Math.sin(s) * o), this.isMoving = !0) },
|
|
setSize: function(t, e, i, s) { void 0 === i && (i = this.offset.x), void 0 === s && (s = this.offset.y), this.sourceWidth = t, this.sourceHeight = e, this.width = this.sourceWidth * this._sx, this.height = this.sourceHeight * this._sy, this.halfWidth = Math.floor(this.width / 2), this.halfHeight = Math.floor(this.height / 2), this.offset.setTo(i, s), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight), this.isCircle = !1, this.radius = 0 },
|
|
setCircle: function(t, e, i) { void 0 === e && (e = this.offset.x), void 0 === i && (i = this.offset.y), 0 < t ? (this.isCircle = !0, this.radius = t, this.sourceWidth = 2 * t, this.sourceHeight = 2 * t, this.width = this.sourceWidth * this._sx, this.height = this.sourceHeight * this._sy, this.halfWidth = Math.floor(this.width / 2), this.halfHeight = Math.floor(this.height / 2), this.offset.setTo(e, i), this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight)) : this.isCircle = !1 },
|
|
reset: function(t, e) { this.velocity.set(0), this.acceleration.set(0), this.speed = 0, this.angularVelocity = 0, this.angularAcceleration = 0, this.position.x = t - this.sprite.anchor.x * this.sprite.width + this.sprite.scale.x * this.offset.x, this.position.x -= this.sprite.scale.x < 0 ? this.width : 0, this.position.y = e - this.sprite.anchor.y * this.sprite.height + this.sprite.scale.y * this.offset.y, this.position.y -= this.sprite.scale.y < 0 ? this.height : 0, this.prev.x = this.position.x, this.prev.y = this.position.y, this.rotation = this.sprite.angle, this.preRotation = this.rotation, this._sx = this.sprite.scale.x, this._sy = this.sprite.scale.y, this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight) },
|
|
getBounds: function(t) { return this.isCircle ? (t.x = this.center.x - this.radius, t.y = this.center.y - this.radius, t.right = this.center.x + this.radius, t.bottom = this.center.y + this.radius) : (t.x = this.x, t.y = this.y, t.right = this.right, t.bottom = this.bottom), t },
|
|
hitTest: function(t, e) { return this.isCircle ? H.Circle.contains(this, t, e) : H.Rectangle.contains(this, t, e) },
|
|
onFloor: function() { return this.blocked.down },
|
|
onCeiling: function() { return this.blocked.up },
|
|
onWall: function() { return this.blocked.left || this.blocked.right },
|
|
deltaAbsX: function() { return 0 < this.deltaX() ? this.deltaX() : -this.deltaX() },
|
|
deltaAbsY: function() { return 0 < this.deltaY() ? this.deltaY() : -this.deltaY() },
|
|
deltaX: function() { return this.position.x - this.prev.x },
|
|
deltaY: function() { return this.position.y - this.prev.y },
|
|
deltaZ: function() { return this.rotation - this.preRotation },
|
|
destroy: function() { this.sprite.parent && this.sprite.parent instanceof H.Group && this.sprite.parent.removeFromHash(this.sprite), this.sprite.body = null, this.sprite = null }
|
|
}, Object.defineProperty(H.Physics.Arcade.Body.prototype, "left", { get: function() { return this.position.x } }), Object.defineProperty(H.Physics.Arcade.Body.prototype, "right", { get: function() { return this.position.x + this.width } }), Object.defineProperty(H.Physics.Arcade.Body.prototype, "top", { get: function() { return this.position.y } }), Object.defineProperty(H.Physics.Arcade.Body.prototype, "bottom", { get: function() { return this.position.y + this.height } }), Object.defineProperty(H.Physics.Arcade.Body.prototype, "x", { get: function() { return this.position.x }, set: function(t) { this.position.x = t } }), Object.defineProperty(H.Physics.Arcade.Body.prototype, "y", { get: function() { return this.position.y }, set: function(t) { this.position.y = t } }), H.Physics.Arcade.Body.render = function(t, e, i, s) { void 0 === s && (s = !0), i = i || "rgba(0,255,0,0.4)", t.fillStyle = i, t.strokeStyle = i, e.isCircle ? (t.beginPath(), t.arc(e.center.x - e.game.camera.x, e.center.y - e.game.camera.y, e.radius, 0, 2 * Math.PI), s ? t.fill() : t.stroke()) : s ? t.fillRect(e.position.x - e.game.camera.x, e.position.y - e.game.camera.y, e.width, e.height) : t.strokeRect(e.position.x - e.game.camera.x, e.position.y - e.game.camera.y, e.width, e.height) }, H.Physics.Arcade.Body.renderBodyInfo = function(t, e) { t.line("x: " + e.x.toFixed(2), "y: " + e.y.toFixed(2), "width: " + e.width, "height: " + e.height), t.line("velocity x: " + e.velocity.x.toFixed(2), "y: " + e.velocity.y.toFixed(2), "deltaX: " + e._dx.toFixed(2), "deltaY: " + e._dy.toFixed(2)), t.line("acceleration x: " + e.acceleration.x.toFixed(2), "y: " + e.acceleration.y.toFixed(2), "speed: " + e.speed.toFixed(2), "angle: " + e.angle.toFixed(2)), t.line("gravity x: " + e.gravity.x, "y: " + e.gravity.y, "bounce x: " + e.bounce.x.toFixed(2), "y: " + e.bounce.y.toFixed(2)), t.line("touching left: " + e.touching.left, "right: " + e.touching.right, "up: " + e.touching.up, "down: " + e.touching.down), t.line("blocked left: " + e.blocked.left, "right: " + e.blocked.right, "up: " + e.blocked.up, "down: " + e.blocked.down) }, H.Physics.Arcade.Body.prototype.constructor = H.Physics.Arcade.Body, H.Physics.Arcade.TilemapCollision = function() {}, H.Physics.Arcade.TilemapCollision.prototype = {
|
|
TILE_BIAS: 16,
|
|
collideSpriteVsTilemapLayer: function(t, e, i, s, o, n) {
|
|
if (t.body) {
|
|
var a = e.getTiles(t.body.position.x - t.body.tilePadding.x, t.body.position.y - t.body.tilePadding.y, t.body.width + t.body.tilePadding.x, t.body.height + t.body.tilePadding.y, !1, !1);
|
|
if (0 !== a.length)
|
|
for (var r = 0; r < a.length; r++) s ? s.call(o, t, a[r]) && this.separateTile(r, t.body, a[r], e, n) && (this._total++, i && i.call(o, t, a[r])) : this.separateTile(r, t.body, a[r], e, n) && (this._total++, i && i.call(o, t, a[r]))
|
|
}
|
|
},
|
|
collideGroupVsTilemapLayer: function(t, e, i, s, o, n) {
|
|
if (0 !== t.length)
|
|
for (var a = 0; a < t.children.length; a++) t.children[a].exists && this.collideSpriteVsTilemapLayer(t.children[a], e, i, s, o, n)
|
|
},
|
|
separateTile: function(t, e, i, s, o) {
|
|
if (!e.enable) return !1;
|
|
var n = s.fixedToCamera ? 0 : s.position.x,
|
|
a = s.fixedToCamera ? 0 : s.position.y;
|
|
if (!i.intersects(e.position.x - n, e.position.y - a, e.right - n, e.bottom - a)) return !1;
|
|
if (o) return !0;
|
|
if (i.collisionCallback && !i.collisionCallback.call(i.collisionCallbackContext, e.sprite, i)) return !1;
|
|
if (void 0 !== i.layer.callbacks && i.layer.callbacks[i.index] && !i.layer.callbacks[i.index].callback.call(i.layer.callbacks[i.index].callbackContext, e.sprite, i)) return !1;
|
|
if (!(i.faceLeft || i.faceRight || i.faceTop || i.faceBottom)) return !1;
|
|
var r = 0,
|
|
h = 0,
|
|
l = 0,
|
|
c = 1;
|
|
if (e.deltaAbsX() > e.deltaAbsY() ? l = -1 : e.deltaAbsX() < e.deltaAbsY() && (c = -1), 0 !== e.deltaX() && 0 !== e.deltaY() && (i.faceLeft || i.faceRight) && (i.faceTop || i.faceBottom) && (l = Math.min(Math.abs(e.position.x - n - i.right), Math.abs(e.right - n - i.left)), c = Math.min(Math.abs(e.position.y - a - i.bottom), Math.abs(e.bottom - a - i.top))), l < c) {
|
|
if ((i.faceLeft || i.faceRight) && 0 !== (r = this.tileCheckX(e, i, s)) && !i.intersects(e.position.x - n, e.position.y - a, e.right - n, e.bottom - a)) return !0;
|
|
(i.faceTop || i.faceBottom) && (h = this.tileCheckY(e, i, s))
|
|
}
|
|
else {
|
|
if ((i.faceTop || i.faceBottom) && 0 !== (h = this.tileCheckY(e, i, s)) && !i.intersects(e.position.x - n, e.position.y - a, e.right - n, e.bottom - a)) return !0;
|
|
(i.faceLeft || i.faceRight) && (r = this.tileCheckX(e, i, s))
|
|
}
|
|
return 0 !== r || 0 !== h
|
|
},
|
|
tileCheckX: function(t, e, i) {
|
|
var s = 0,
|
|
o = i.fixedToCamera ? 0 : i.position.x;
|
|
return t.deltaX() < 0 && !t.blocked.left && e.collideRight && t.checkCollision.left ? e.faceRight && t.x - o < e.right && (s = t.x - o - e.right) < -this.TILE_BIAS && (s = 0) : 0 < t.deltaX() && !t.blocked.right && e.collideLeft && t.checkCollision.right && e.faceLeft && t.right - o > e.left && (s = t.right - o - e.left) > this.TILE_BIAS && (s = 0), 0 !== s && (t.customSeparateX ? t.overlapX = s : this.processTileSeparationX(t, s)), s
|
|
},
|
|
tileCheckY: function(t, e, i) {
|
|
var s = 0,
|
|
o = i.fixedToCamera ? 0 : i.position.y;
|
|
return t.deltaY() < 0 && !t.blocked.up && e.collideDown && t.checkCollision.up ? e.faceBottom && t.y - o < e.bottom && (s = t.y - o - e.bottom) < -this.TILE_BIAS && (s = 0) : 0 < t.deltaY() && !t.blocked.down && e.collideUp && t.checkCollision.down && e.faceTop && t.bottom - o > e.top && (s = t.bottom - o - e.top) > this.TILE_BIAS && (s = 0), 0 !== s && (t.customSeparateY ? t.overlapY = s : this.processTileSeparationY(t, s)), s
|
|
},
|
|
processTileSeparationX: function(t, e) { e < 0 ? t.blocked.left = !0 : 0 < e && (t.blocked.right = !0), t.position.x -= e, 0 === t.bounce.x ? t.velocity.x = 0 : t.velocity.x = -t.velocity.x * t.bounce.x },
|
|
processTileSeparationY: function(t, e) { e < 0 ? t.blocked.up = !0 : 0 < e && (t.blocked.down = !0), t.position.y -= e, 0 === t.bounce.y ? t.velocity.y = 0 : t.velocity.y = -t.velocity.y * t.bounce.y }
|
|
}, H.Utils.mixinPrototype(H.Physics.Arcade.prototype, H.Physics.Arcade.TilemapCollision.prototype), p2.Body.prototype.parent = null, p2.Spring.prototype.parent = null, H.Physics.P2 = function(t, e) { this.game = t, void 0 === e ? e = { gravity: [0, 0], broadphase: new p2.SAPBroadphase } : (e.hasOwnProperty("gravity") || (e.gravity = [0, 0]), e.hasOwnProperty("broadphase") || (e.broadphase = new p2.SAPBroadphase)), this.config = e, this.world = new p2.World(this.config), this.frameRate = 1 / 60, this.useElapsedTime = !1, this.paused = !1, this.materials = [], this.gravity = new H.Physics.P2.InversePointProxy(this, this.world.gravity), this.walls = { left: null, right: null, top: null, bottom: null }, this.onBodyAdded = new H.Signal, this.onBodyRemoved = new H.Signal, this.onSpringAdded = new H.Signal, this.onSpringRemoved = new H.Signal, this.onConstraintAdded = new H.Signal, this.onConstraintRemoved = new H.Signal, this.onContactMaterialAdded = new H.Signal, this.onContactMaterialRemoved = new H.Signal, this.postBroadphaseCallback = null, this.callbackContext = null, this.onBeginContact = new H.Signal, this.onEndContact = new H.Signal, e.hasOwnProperty("mpx") && e.hasOwnProperty("pxm") && e.hasOwnProperty("mpxi") && e.hasOwnProperty("pxmi") && (this.mpx = e.mpx, this.mpxi = e.mpxi, this.pxm = e.pxm, this.pxmi = e.pxmi), this.world.on("beginContact", this.beginContactHandler, this), this.world.on("endContact", this.endContactHandler, this), this.collisionGroups = [], this.nothingCollisionGroup = new H.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new H.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new H.Physics.P2.CollisionGroup(2147483648), this.boundsCollidesWith = [], this._toRemove = [], this._collisionGroupID = 2, this._boundsLeft = !0, this._boundsRight = !0, this._boundsTop = !0, this._boundsBottom = !0, this._boundsOwnGroup = !1, this.setBoundsToWorld(!0, !0, !0, !0, !1) }, H.Physics.P2.prototype = {
|
|
removeBodyNextStep: function(t) { this._toRemove.push(t) },
|
|
preUpdate: function() {
|
|
for (var t = this._toRemove.length; t--;) this.removeBody(this._toRemove[t]);
|
|
this._toRemove.length = 0
|
|
},
|
|
enable: function(t, e, i) {
|
|
void 0 === e && (e = !1), void 0 === i && (i = !0);
|
|
var s = 1;
|
|
if (Array.isArray(t))
|
|
for (s = t.length; s--;) t[s] instanceof H.Group ? this.enable(t[s].children, e, i) : (this.enableBody(t[s], e), i && t[s].hasOwnProperty("children") && 0 < t[s].children.length && this.enable(t[s], e, !0));
|
|
else t instanceof H.Group ? this.enable(t.children, e, i) : (this.enableBody(t, e), i && t.hasOwnProperty("children") && 0 < t.children.length && this.enable(t.children, e, !0))
|
|
},
|
|
enableBody: function(t, e) { t.hasOwnProperty("body") && null === t.body && (t.body = new H.Physics.P2.Body(this.game, t, t.x, t.y, 1), t.body.debug = e, void 0 !== t.anchor && t.anchor.set(.5)) },
|
|
setImpactEvents: function(t) { t ? this.world.on("impact", this.impactHandler, this) : this.world.off("impact", this.impactHandler, this) },
|
|
setPostBroadphaseCallback: function(t, e) { this.postBroadphaseCallback = t, this.callbackContext = e, null !== t ? this.world.on("postBroadphase", this.postBroadphaseHandler, this) : this.world.off("postBroadphase", this.postBroadphaseHandler, this) },
|
|
postBroadphaseHandler: function(t) {
|
|
if (this.postBroadphaseCallback && 0 !== t.pairs.length)
|
|
for (var e = t.pairs.length - 2; 0 <= e; e -= 2) t.pairs[e].parent && t.pairs[e + 1].parent && !this.postBroadphaseCallback.call(this.callbackContext, t.pairs[e].parent, t.pairs[e + 1].parent) && t.pairs.splice(e, 2)
|
|
},
|
|
impactHandler: function(t) {
|
|
if (t.bodyA.parent && t.bodyB.parent) {
|
|
var e = t.bodyA.parent,
|
|
i = t.bodyB.parent;
|
|
e._bodyCallbacks[t.bodyB.id] && e._bodyCallbacks[t.bodyB.id].call(e._bodyCallbackContext[t.bodyB.id], e, i, t.shapeA, t.shapeB), i._bodyCallbacks[t.bodyA.id] && i._bodyCallbacks[t.bodyA.id].call(i._bodyCallbackContext[t.bodyA.id], i, e, t.shapeB, t.shapeA), e._groupCallbacks[t.shapeB.collisionGroup] && e._groupCallbacks[t.shapeB.collisionGroup].call(e._groupCallbackContext[t.shapeB.collisionGroup], e, i, t.shapeA, t.shapeB), i._groupCallbacks[t.shapeA.collisionGroup] && i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.collisionGroup], i, e, t.shapeB, t.shapeA)
|
|
}
|
|
},
|
|
beginContactHandler: function(t) { t.bodyA && t.bodyB && (this.onBeginContact.dispatch(t.bodyA, t.bodyB, t.shapeA, t.shapeB, t.contactEquations), t.bodyA.parent && t.bodyA.parent.onBeginContact.dispatch(t.bodyB.parent, t.bodyB, t.shapeA, t.shapeB, t.contactEquations), t.bodyB.parent && t.bodyB.parent.onBeginContact.dispatch(t.bodyA.parent, t.bodyA, t.shapeB, t.shapeA, t.contactEquations)) },
|
|
endContactHandler: function(t) { t.bodyA && t.bodyB && (this.onEndContact.dispatch(t.bodyA, t.bodyB, t.shapeA, t.shapeB), t.bodyA.parent && t.bodyA.parent.onEndContact.dispatch(t.bodyB.parent, t.bodyB, t.shapeA, t.shapeB), t.bodyB.parent && t.bodyB.parent.onEndContact.dispatch(t.bodyA.parent, t.bodyA, t.shapeB, t.shapeA)) },
|
|
setBoundsToWorld: function(t, e, i, s, o) { this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, t, e, i, s, o) },
|
|
setWorldMaterial: function(t, e, i, s, o) { void 0 === e && (e = !0), void 0 === i && (i = !0), void 0 === s && (s = !0), void 0 === o && (o = !0), e && this.walls.left && (this.walls.left.shapes[0].material = t), i && this.walls.right && (this.walls.right.shapes[0].material = t), s && this.walls.top && (this.walls.top.shapes[0].material = t), o && this.walls.bottom && (this.walls.bottom.shapes[0].material = t) },
|
|
updateBoundsCollisionGroup: function(t) {
|
|
void 0 === t && (t = !0);
|
|
var e = t ? this.boundsCollisionGroup.mask : this.everythingCollisionGroup.mask;
|
|
this.walls.left && (this.walls.left.shapes[0].collisionGroup = e), this.walls.right && (this.walls.right.shapes[0].collisionGroup = e), this.walls.top && (this.walls.top.shapes[0].collisionGroup = e), this.walls.bottom && (this.walls.bottom.shapes[0].collisionGroup = e), this._boundsOwnGroup = t
|
|
},
|
|
setBounds: function(t, e, i, s, o, n, a, r, h) { void 0 === o && (o = this._boundsLeft), void 0 === n && (n = this._boundsRight), void 0 === a && (a = this._boundsTop), void 0 === r && (r = this._boundsBottom), void 0 === h && (h = this._boundsOwnGroup), this.setupWall(o, "left", t, e, 1.5707963267948966, h), this.setupWall(n, "right", t + i, e, -1.5707963267948966, h), this.setupWall(a, "top", t, e, -3.141592653589793, h), this.setupWall(r, "bottom", t, e + s, 0, h), this._boundsLeft = o, this._boundsRight = n, this._boundsTop = a, this._boundsBottom = r, this._boundsOwnGroup = h },
|
|
setupWall: function(t, e, i, s, o, n) { t ? (this.walls[e] ? this.walls[e].position = [this.pxmi(i), this.pxmi(s)] : (this.walls[e] = new p2.Body({ mass: 0, position: [this.pxmi(i), this.pxmi(s)], angle: o }), this.walls[e].addShape(new p2.Plane), this.world.addBody(this.walls[e])), n && (this.walls[e].shapes[0].collisionGroup = this.boundsCollisionGroup.mask)) : this.walls[e] && (this.world.removeBody(this.walls[e]), this.walls[e] = null) },
|
|
pause: function() { this.paused = !0 },
|
|
resume: function() { this.paused = !1 },
|
|
update: function() { this.paused || (this.useElapsedTime ? this.world.step(this.game.time.physicsElapsed) : this.world.step(this.frameRate)) },
|
|
reset: function() { this.world.on("beginContact", this.beginContactHandler, this), this.world.on("endContact", this.endContactHandler, this), this.nothingCollisionGroup = new H.Physics.P2.CollisionGroup(1), this.boundsCollisionGroup = new H.Physics.P2.CollisionGroup(2), this.everythingCollisionGroup = new H.Physics.P2.CollisionGroup(2147483648), this._collisionGroupID = 2, this.setBoundsToWorld(!0, !0, !0, !0, !1) },
|
|
clear: function() {
|
|
this.world.time = 0, this.world.fixedStepTime = 0, this.world.solver && this.world.solver.equations.length && this.world.solver.removeAllEquations();
|
|
for (var t = this.world.constraints, e = t.length - 1; 0 <= e; e--) this.world.removeConstraint(t[e]);
|
|
var i = this.world.bodies;
|
|
for (e = i.length - 1; 0 <= e; e--) this.world.removeBody(i[e]);
|
|
var s = this.world.springs;
|
|
for (e = s.length - 1; 0 <= e; e--) this.world.removeSpring(s[e]);
|
|
var o = this.world.contactMaterials;
|
|
for (e = o.length - 1; 0 <= e; e--) this.world.removeContactMaterial(o[e]);
|
|
this.world.off("beginContact", this.beginContactHandler, this), this.world.off("endContact", this.endContactHandler, this), this.postBroadphaseCallback = null, this.callbackContext = null, this.impactCallback = null, this.collisionGroups = [], this._toRemove = [], this.boundsCollidesWith = [], this.walls = { left: null, right: null, top: null, bottom: null }
|
|
},
|
|
destroy: function() { this.clear(), this.game = null },
|
|
addBody: function(t) { return !t.data.world && (this.world.addBody(t.data), this.onBodyAdded.dispatch(t), !0) },
|
|
removeBody: function(t) { return t.data.world === this.world && (this.world.removeBody(t.data), this.onBodyRemoved.dispatch(t)), t },
|
|
addSpring: function(t) { return t instanceof H.Physics.P2.Spring || t instanceof H.Physics.P2.RotationalSpring ? this.world.addSpring(t.data) : this.world.addSpring(t), this.onSpringAdded.dispatch(t), t },
|
|
removeSpring: function(t) { return t instanceof H.Physics.P2.Spring || t instanceof H.Physics.P2.RotationalSpring ? this.world.removeSpring(t.data) : this.world.removeSpring(t), this.onSpringRemoved.dispatch(t), t },
|
|
createDistanceConstraint: function(t, e, i, s, o, n) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addConstraint(new H.Physics.P2.DistanceConstraint(this, t, e, i, s, o, n)) },
|
|
createGearConstraint: function(t, e, i, s) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addConstraint(new H.Physics.P2.GearConstraint(this, t, e, i, s)) },
|
|
createRevoluteConstraint: function(t, e, i, s, o, n) { if (t = this.getBody(t), i = this.getBody(i), t && i) return this.addConstraint(new H.Physics.P2.RevoluteConstraint(this, t, e, i, s, o, n)) },
|
|
createLockConstraint: function(t, e, i, s, o) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addConstraint(new H.Physics.P2.LockConstraint(this, t, e, i, s, o)) },
|
|
createPrismaticConstraint: function(t, e, i, s, o, n, a) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addConstraint(new H.Physics.P2.PrismaticConstraint(this, t, e, i, s, o, n, a)) },
|
|
addConstraint: function(t) { return this.world.addConstraint(t), this.onConstraintAdded.dispatch(t), t },
|
|
removeConstraint: function(t) { return this.world.removeConstraint(t), this.onConstraintRemoved.dispatch(t), t },
|
|
addContactMaterial: function(t) { return this.world.addContactMaterial(t), this.onContactMaterialAdded.dispatch(t), t },
|
|
removeContactMaterial: function(t) { return this.world.removeContactMaterial(t), this.onContactMaterialRemoved.dispatch(t), t },
|
|
getContactMaterial: function(t, e) { return this.world.getContactMaterial(t, e) },
|
|
setMaterial: function(t, e) { for (var i = e.length; i--;) e[i].setMaterial(t) },
|
|
createMaterial: function(t, e) { t = t || ""; var i = new H.Physics.P2.Material(t); return this.materials.push(i), void 0 !== e && e.setMaterial(i), i },
|
|
createContactMaterial: function(t, e, i) { void 0 === t && (t = this.createMaterial()), void 0 === e && (e = this.createMaterial()); var s = new H.Physics.P2.ContactMaterial(t, e, i); return this.addContactMaterial(s) },
|
|
getBodies: function() { for (var t = [], e = this.world.bodies.length; e--;) t.push(this.world.bodies[e].parent); return t },
|
|
getBody: function(t) { return t instanceof p2.Body ? t : t instanceof H.Physics.P2.Body ? t.data : t.body && t.body.type === H.Physics.P2JS ? t.body.data : null },
|
|
getSprings: function() { for (var t = [], e = this.world.springs.length; e--;) t.push(this.world.springs[e].parent); return t },
|
|
getConstraints: function() { for (var t = [], e = this.world.constraints.length; e--;) t.push(this.world.constraints[e]); return t },
|
|
hitTest: function(t, e, i, s) { void 0 === e && (e = this.world.bodies), void 0 === i && (i = 5), void 0 === s && (s = !1); for (var o = [this.pxmi(t.x), this.pxmi(t.y)], n = [], a = e.length; a--;) e[a] instanceof H.Physics.P2.Body && (!s || e[a].data.type !== p2.Body.STATIC) ? n.push(e[a].data) : e[a] instanceof p2.Body && e[a].parent && (!s || e[a].type !== p2.Body.STATIC) ? n.push(e[a]) : e[a] instanceof H.Sprite && e[a].hasOwnProperty("body") && (!s || e[a].body.data.type !== p2.Body.STATIC) && n.push(e[a].body.data); return this.world.hitTest(o, n, i) },
|
|
toJSON: function() { return this.world.toJSON() },
|
|
createCollisionGroup: function(t) {
|
|
var e = Math.pow(2, this._collisionGroupID);
|
|
this.walls.left && (this.walls.left.shapes[0].collisionMask = this.walls.left.shapes[0].collisionMask | e), this.walls.right && (this.walls.right.shapes[0].collisionMask = this.walls.right.shapes[0].collisionMask | e), this.walls.top && (this.walls.top.shapes[0].collisionMask = this.walls.top.shapes[0].collisionMask | e), this.walls.bottom && (this.walls.bottom.shapes[0].collisionMask = this.walls.bottom.shapes[0].collisionMask | e), this._collisionGroupID++;
|
|
var i = new H.Physics.P2.CollisionGroup(e);
|
|
return this.collisionGroups.push(i), t && this.setCollisionGroup(t, i), i
|
|
},
|
|
setCollisionGroup: function(t, e) {
|
|
if (t instanceof H.Group)
|
|
for (var i = 0; i < t.total; i++) t.children[i].body && t.children[i].body.type === H.Physics.P2JS && t.children[i].body.setCollisionGroup(e);
|
|
else t.body.setCollisionGroup(e)
|
|
},
|
|
createSpring: function(t, e, i, s, o, n, a, r, h) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addSpring(new H.Physics.P2.Spring(this, t, e, i, s, o, n, a, r, h)) },
|
|
createRotationalSpring: function(t, e, i, s, o) { if (t = this.getBody(t), e = this.getBody(e), t && e) return this.addSpring(new H.Physics.P2.RotationalSpring(this, t, e, i, s, o)) },
|
|
createBody: function(t, e, i, s, o, n) { void 0 === s && (s = !1); var a = new H.Physics.P2.Body(this.game, null, t, e, i); if (n && !a.addPolygon(o, n)) return !1; return s && this.world.addBody(a.data), a },
|
|
createParticle: function(t, e, i, s, o, n) { void 0 === s && (s = !1); var a = new H.Physics.P2.Body(this.game, null, t, e, i); if (n && !a.addPolygon(o, n)) return !1; return s && this.world.addBody(a.data), a },
|
|
convertCollisionObjects: function(t, e, i) {
|
|
void 0 === i && (i = !0);
|
|
for (var s = [], o = 0, n = t.collision[e].length; o < n; o++) {
|
|
var a = t.collision[e][o],
|
|
r = this.createBody(a.x, a.y, 0, i, {}, a.polyline);
|
|
r && s.push(r)
|
|
}
|
|
return s
|
|
},
|
|
clearTilemapLayerBodies: function(t, e) {
|
|
e = t.getLayer(e);
|
|
for (var i = t.layers[e].bodies.length; i--;) t.layers[e].bodies[i].destroy();
|
|
t.layers[e].bodies.length = 0
|
|
},
|
|
convertTilemap: function(t, e, i, s) {
|
|
e = t.getLayer(e), void 0 === i && (i = !0), void 0 === s && (s = !0), this.clearTilemapLayerBodies(t, e);
|
|
for (var o = 0, n = 0, a = 0, r = 0, h = t.layers[e].height; r < h; r++)
|
|
for (var l = o = 0, c = t.layers[e].width; l < c; l++) {
|
|
var p = t.layers[e].data[r][l];
|
|
if (p && -1 < p.index && p.collides)
|
|
if (s) {
|
|
var u = t.getTileRight(e, l, r);
|
|
if (0 === o && (n = p.x * p.width, a = p.y * p.height, o = p.width), u && u.collides) o += p.width;
|
|
else(d = this.createBody(n, a, 0, !1)).addRectangle(o, p.height, o / 2, p.height / 2, 0), i && this.addBody(d), t.layers[e].bodies.push(d), o = 0
|
|
}
|
|
else {
|
|
var d;
|
|
(d = this.createBody(p.x * p.width, p.y * p.height, 0, !1)).addRectangle(p.width, p.height, p.width / 2, p.height / 2, 0), i && this.addBody(d), t.layers[e].bodies.push(d)
|
|
}
|
|
}
|
|
return t.layers[e].bodies
|
|
},
|
|
mpx: function(t) { return 20 * t },
|
|
pxm: function(t) { return .05 * t },
|
|
mpxi: function(t) { return -20 * t },
|
|
pxmi: function(t) { return -.05 * t }
|
|
}, Object.defineProperty(H.Physics.P2.prototype, "friction", { get: function() { return this.world.defaultContactMaterial.friction }, set: function(t) { this.world.defaultContactMaterial.friction = t } }), Object.defineProperty(H.Physics.P2.prototype, "restitution", { get: function() { return this.world.defaultContactMaterial.restitution }, set: function(t) { this.world.defaultContactMaterial.restitution = t } }), Object.defineProperty(H.Physics.P2.prototype, "contactMaterial", { get: function() { return this.world.defaultContactMaterial }, set: function(t) { this.world.defaultContactMaterial = t } }), Object.defineProperty(H.Physics.P2.prototype, "applySpringForces", { get: function() { return this.world.applySpringForces }, set: function(t) { this.world.applySpringForces = t } }), Object.defineProperty(H.Physics.P2.prototype, "applyDamping", { get: function() { return this.world.applyDamping }, set: function(t) { this.world.applyDamping = t } }), Object.defineProperty(H.Physics.P2.prototype, "applyGravity", { get: function() { return this.world.applyGravity }, set: function(t) { this.world.applyGravity = t } }), Object.defineProperty(H.Physics.P2.prototype, "solveConstraints", { get: function() { return this.world.solveConstraints }, set: function(t) { this.world.solveConstraints = t } }), Object.defineProperty(H.Physics.P2.prototype, "time", { get: function() { return this.world.time } }), Object.defineProperty(H.Physics.P2.prototype, "emitImpactEvent", { get: function() { return this.world.emitImpactEvent }, set: function(t) { this.world.emitImpactEvent = t } }), Object.defineProperty(H.Physics.P2.prototype, "sleepMode", { get: function() { return this.world.sleepMode }, set: function(t) { this.world.sleepMode = t } }), Object.defineProperty(H.Physics.P2.prototype, "total", { get: function() { return this.world.bodies.length } }), H.Physics.P2.FixtureList = function(t) { Array.isArray(t) || (t = [t]), this.rawList = t, this.init(), this.parse(this.rawList) }, H.Physics.P2.FixtureList.prototype = { init: function() { this.namedFixtures = {}, this.groupedFixtures = [], this.allFixtures = [] }, setCategory: function(e, t) { this.getFixtures(t).forEach(function(t) { t.collisionGroup = e }) }, setMask: function(e, t) { this.getFixtures(t).forEach(function(t) { t.collisionMask = e }) }, setSensor: function(e, t) { this.getFixtures(t).forEach(function(t) { t.sensor = e }) }, setMaterial: function(e, t) { this.getFixtures(t).forEach(function(t) { t.material = e }) }, getFixtures: function(t) { var e = []; if (t) { t instanceof Array || (t = [t]); var i = this; return t.forEach(function(t) { i.namedFixtures[t] && e.push(i.namedFixtures[t]) }), this.flatten(e) } return this.allFixtures }, getFixtureByKey: function(t) { return this.namedFixtures[t] }, getGroup: function(t) { return this.groupedFixtures[t] }, parse: function() { var t, e, i, s; for (t in s = [], i = this.rawList) e = i[t], isNaN(t - 0) ? this.namedFixtures[t] = this.flatten(e) : (this.groupedFixtures[t] = this.groupedFixtures[t] || [], this.groupedFixtures[t] = this.groupedFixtures[t].concat(e)), s.push(this.allFixtures = this.flatten(this.groupedFixtures)) }, flatten: function(t) { var e, i; return e = [], i = arguments.callee, t.forEach(function(t) { return Array.prototype.push.apply(e, Array.isArray(t) ? i(t) : [t]) }), e } }, H.Physics.P2.PointProxy = function(t, e) { this.world = t, this.destination = e }, H.Physics.P2.PointProxy.prototype.constructor = H.Physics.P2.PointProxy, Object.defineProperty(H.Physics.P2.PointProxy.prototype, "x", { get: function() { return this.world.mpx(this.destination[0]) }, set: function(t) { this.destination[0] = this.world.pxm(t) } }), Object.defineProperty(H.Physics.P2.PointProxy.prototype, "y", { get: function() { return this.world.mpx(this.destination[1]) }, set: function(t) { this.destination[1] = this.world.pxm(t) } }), Object.defineProperty(H.Physics.P2.PointProxy.prototype, "mx", { get: function() { return this.destination[0] }, set: function(t) { this.destination[0] = t } }), Object.defineProperty(H.Physics.P2.PointProxy.prototype, "my", { get: function() { return this.destination[1] }, set: function(t) { this.destination[1] = t } }), H.Physics.P2.InversePointProxy = function(t, e) { this.world = t, this.destination = e }, H.Physics.P2.InversePointProxy.prototype.constructor = H.Physics.P2.InversePointProxy, Object.defineProperty(H.Physics.P2.InversePointProxy.prototype, "x", { get: function() { return this.world.mpxi(this.destination[0]) }, set: function(t) { this.destination[0] = this.world.pxmi(t) } }), Object.defineProperty(H.Physics.P2.InversePointProxy.prototype, "y", { get: function() { return this.world.mpxi(this.destination[1]) }, set: function(t) { this.destination[1] = this.world.pxmi(t) } }), Object.defineProperty(H.Physics.P2.InversePointProxy.prototype, "mx", { get: function() { return this.destination[0] }, set: function(t) { this.destination[0] = -t } }), Object.defineProperty(H.Physics.P2.InversePointProxy.prototype, "my", { get: function() { return this.destination[1] }, set: function(t) { this.destination[1] = -t } }), H.Physics.P2.Body = function(t, e, i, s, o) { e = e || null, i = i || 0, s = s || 0, void 0 === o && (o = 1), this.game = t, this.world = t.physics.p2, this.sprite = e, this.type = H.Physics.P2JS, this.offset = new H.Point, this.data = new p2.Body({ position: [this.world.pxmi(i), this.world.pxmi(s)], mass: o }), (this.data.parent = this).velocity = new H.Physics.P2.InversePointProxy(this.world, this.data.velocity), this.force = new H.Physics.P2.InversePointProxy(this.world, this.data.force), this.gravity = new H.Point, this.onBeginContact = new H.Signal, this.onEndContact = new H.Signal, this.collidesWith = [], this.removeNextStep = !1, this.debugBody = null, this.dirty = !1, this._collideWorldBounds = !0, this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this._reset = !1, e && (this.setRectangleFromSprite(e), e.exists && this.game.physics.p2.addBody(this)) }, H.Physics.P2.Body.prototype = {
|
|
createBodyCallback: function(t, e, i) {
|
|
var s = -1;
|
|
t.id ? s = t.id : t.body && (s = t.body.id), -1 < s && (null === e ? (delete this._bodyCallbacks[s], delete this._bodyCallbackContext[s]) : (this._bodyCallbacks[s] = e, this._bodyCallbackContext[s] = i))
|
|
},
|
|
createGroupCallback: function(t, e, i) { null === e ? (delete this._groupCallbacks[t.mask], delete this._groupCallbackContext[t.mask]) : (this._groupCallbacks[t.mask] = e, this._groupCallbackContext[t.mask] = i) },
|
|
getCollisionMask: function() {
|
|
var t = 0;
|
|
this._collideWorldBounds && (t = this.game.physics.p2.boundsCollisionGroup.mask);
|
|
for (var e = 0; e < this.collidesWith.length; e++) t |= this.collidesWith[e].mask;
|
|
return t
|
|
},
|
|
updateCollisionMask: function(t) {
|
|
var e = this.getCollisionMask();
|
|
if (void 0 === t)
|
|
for (var i = this.data.shapes.length - 1; 0 <= i; i--) this.data.shapes[i].collisionMask = e;
|
|
else t.collisionMask = e
|
|
},
|
|
setCollisionGroup: function(t, e) {
|
|
var i = this.getCollisionMask();
|
|
if (void 0 === e)
|
|
for (var s = this.data.shapes.length - 1; 0 <= s; s--) this.data.shapes[s].collisionGroup = t.mask, this.data.shapes[s].collisionMask = i;
|
|
else e.collisionGroup = t.mask, e.collisionMask = i
|
|
},
|
|
clearCollision: function(t, e, i) {
|
|
if (void 0 === t && (t = !0), void 0 === e && (e = !0), void 0 === i)
|
|
for (var s = this.data.shapes.length - 1; 0 <= s; s--) t && (this.data.shapes[s].collisionGroup = null), e && (this.data.shapes[s].collisionMask = null);
|
|
else t && (i.collisionGroup = null), e && (i.collisionMask = null);
|
|
t && (this.collidesWith.length = 0)
|
|
},
|
|
removeCollisionGroup: function(t, e, i) {
|
|
var s;
|
|
if (void 0 === e && (e = !0), Array.isArray(t))
|
|
for (var o = 0; o < t.length; o++) - 1 < (s = this.collidesWith.indexOf(t[o])) && (this.collidesWith.splice(s, 1), e && (delete this._groupCallbacks[t.mask], delete this._groupCallbackContext[t.mask]));
|
|
else -1 < (s = this.collidesWith.indexOf(t)) && (this.collidesWith.splice(s, 1), e && (delete this._groupCallbacks[t.mask], delete this._groupCallbackContext[t.mask]));
|
|
var n = this.getCollisionMask();
|
|
if (void 0 === i)
|
|
for (o = this.data.shapes.length - 1; 0 <= o; o--) this.data.shapes[o].collisionMask = n;
|
|
else i.collisionMask = n
|
|
},
|
|
collides: function(t, e, i, s) {
|
|
if (Array.isArray(t))
|
|
for (var o = 0; o < t.length; o++) - 1 === this.collidesWith.indexOf(t[o]) && (this.collidesWith.push(t[o]), e && this.createGroupCallback(t[o], e, i));
|
|
else -1 === this.collidesWith.indexOf(t) && (this.collidesWith.push(t), e && this.createGroupCallback(t, e, i));
|
|
var n = this.getCollisionMask();
|
|
if (void 0 === s)
|
|
for (o = this.data.shapes.length - 1; 0 <= o; o--) this.data.shapes[o].collisionMask = n;
|
|
else s.collisionMask = n
|
|
},
|
|
adjustCenterOfMass: function() { this.data.adjustCenterOfMass(), this.shapeChanged() },
|
|
getVelocityAtPoint: function(t, e) { return this.data.getVelocityAtPoint(t, e) },
|
|
applyDamping: function(t) { this.data.applyDamping(t) },
|
|
applyImpulse: function(t, e, i) { this.data.applyImpulse(t, [this.world.pxmi(e), this.world.pxmi(i)]) },
|
|
applyImpulseLocal: function(t, e, i) { this.data.applyImpulseLocal(t, [this.world.pxmi(e), this.world.pxmi(i)]) },
|
|
applyForce: function(t, e, i) { this.data.applyForce(t, [this.world.pxmi(e), this.world.pxmi(i)]) },
|
|
setZeroForce: function() { this.data.setZeroForce() },
|
|
setZeroRotation: function() { this.data.angularVelocity = 0 },
|
|
setZeroVelocity: function() { this.data.velocity[0] = 0, this.data.velocity[1] = 0 },
|
|
setZeroDamping: function() { this.data.damping = 0, this.data.angularDamping = 0 },
|
|
toLocalFrame: function(t, e) { return this.data.toLocalFrame(t, e) },
|
|
toWorldFrame: function(t, e) { return this.data.toWorldFrame(t, e) },
|
|
rotateLeft: function(t) { this.data.angularVelocity = this.world.pxm(-t) },
|
|
rotateRight: function(t) { this.data.angularVelocity = this.world.pxm(t) },
|
|
moveForward: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle + Math.PI / 2;
|
|
this.data.velocity[0] = e * Math.cos(i), this.data.velocity[1] = e * Math.sin(i)
|
|
},
|
|
moveBackward: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle + Math.PI / 2;
|
|
this.data.velocity[0] = -e * Math.cos(i), this.data.velocity[1] = -e * Math.sin(i)
|
|
},
|
|
thrust: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle + Math.PI / 2;
|
|
this.data.force[0] += e * Math.cos(i), this.data.force[1] += e * Math.sin(i)
|
|
},
|
|
thrustLeft: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle;
|
|
this.data.force[0] += e * Math.cos(i), this.data.force[1] += e * Math.sin(i)
|
|
},
|
|
thrustRight: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle;
|
|
this.data.force[0] -= e * Math.cos(i), this.data.force[1] -= e * Math.sin(i)
|
|
},
|
|
reverse: function(t) {
|
|
var e = this.world.pxmi(-t),
|
|
i = this.data.angle + Math.PI / 2;
|
|
this.data.force[0] -= e * Math.cos(i), this.data.force[1] -= e * Math.sin(i)
|
|
},
|
|
moveLeft: function(t) { this.data.velocity[0] = this.world.pxmi(-t) },
|
|
moveRight: function(t) { this.data.velocity[0] = this.world.pxmi(t) },
|
|
moveUp: function(t) { this.data.velocity[1] = this.world.pxmi(-t) },
|
|
moveDown: function(t) { this.data.velocity[1] = this.world.pxmi(t) },
|
|
preUpdate: function() { this.dirty = !0, this.removeNextStep && (this.removeFromWorld(), this.removeNextStep = !1) },
|
|
postUpdate: function() { this.sprite.x = this.world.mpxi(this.data.position[0]) + this.offset.x, this.sprite.y = this.world.mpxi(this.data.position[1]) + this.offset.y, this.fixedRotation || (this.sprite.rotation = this.data.angle), this.debugBody && this.debugBody.updateSpriteTransform(), this.dirty = !1 },
|
|
reset: function(t, e, i, s) { void 0 === i && (i = !1), void 0 === s && (s = !1), this.setZeroForce(), this.setZeroVelocity(), this.setZeroRotation(), i && this.setZeroDamping(), s && (this.mass = 1), this.x = t, this.y = e },
|
|
addToWorld: function() {
|
|
if (this.game.physics.p2._toRemove)
|
|
for (var t = 0; t < this.game.physics.p2._toRemove.length; t++) this.game.physics.p2._toRemove[t] === this && this.game.physics.p2._toRemove.splice(t, 1);
|
|
this.data.world !== this.game.physics.p2.world && this.game.physics.p2.addBody(this)
|
|
},
|
|
removeFromWorld: function() { this.data.world === this.game.physics.p2.world && this.game.physics.p2.removeBodyNextStep(this) },
|
|
destroy: function() { this.removeFromWorld(), this.clearShapes(), this._bodyCallbacks = {}, this._bodyCallbackContext = {}, this._groupCallbacks = {}, this._groupCallbackContext = {}, this.debugBody && this.debugBody.destroy(!0, !0), this.debugBody = null, this.sprite && (this.sprite.body = null, this.sprite = null) },
|
|
clearShapes: function() {
|
|
for (var t = this.data.shapes.length; t--;) this.data.removeShape(this.data.shapes[t]);
|
|
this.shapeChanged()
|
|
},
|
|
addShape: function(t, e, i, s) { return void 0 === e && (e = 0), void 0 === i && (i = 0), void 0 === s && (s = 0), this.data.addShape(t, [this.world.pxmi(e), this.world.pxmi(i)], s), this.shapeChanged(), t },
|
|
addCircle: function(t, e, i, s) { var o = new p2.Circle({ radius: this.world.pxm(t) }); return this.addShape(o, e, i, s) },
|
|
addRectangle: function(t, e, i, s, o) { var n = new p2.Box({ width: this.world.pxm(t), height: this.world.pxm(e) }); return this.addShape(n, i, s, o) },
|
|
addPlane: function(t, e, i) { var s = new p2.Plane; return this.addShape(s, t, e, i) },
|
|
addParticle: function(t, e, i) { var s = new p2.Particle; return this.addShape(s, t, e, i) },
|
|
addLine: function(t, e, i, s) { var o = new p2.Line({ length: this.world.pxm(t) }); return this.addShape(o, e, i, s) },
|
|
addCapsule: function(t, e, i, s, o) { var n = new p2.Capsule({ length: this.world.pxm(t), radius: this.world.pxm(e) }); return this.addShape(n, i, s, o) },
|
|
addPolygon: function(t, e) {
|
|
t = t || {}, Array.isArray(e) || (e = Array.prototype.slice.call(arguments, 1));
|
|
var i = [];
|
|
if (1 === e.length && Array.isArray(e[0])) i = e[0].slice(0);
|
|
else if (Array.isArray(e[0])) i = e.slice();
|
|
else if ("number" == typeof e[0])
|
|
for (var s = 0, o = e.length; s < o; s += 2) i.push([e[s], e[s + 1]]);
|
|
var n = i.length - 1;
|
|
i[n][0] === i[0][0] && i[n][1] === i[0][1] && i.pop();
|
|
for (var a = 0; a < i.length; a++) i[a][0] = this.world.pxmi(i[a][0]), i[a][1] = this.world.pxmi(i[a][1]);
|
|
var r = this.data.fromPolygon(i, t);
|
|
return this.shapeChanged(), r
|
|
},
|
|
removeShape: function(t) { var e = this.data.removeShape(t); return this.shapeChanged(), e },
|
|
setCircle: function(t, e, i, s) { return this.clearShapes(), this.addCircle(t, e, i, s) },
|
|
setRectangle: function(t, e, i, s, o) { return void 0 === t && (t = 16), void 0 === e && (e = 16), this.clearShapes(), this.addRectangle(t, e, i, s, o) },
|
|
setRectangleFromSprite: function(t) { return void 0 === t && (t = this.sprite), this.clearShapes(), this.addRectangle(t.width, t.height, 0, 0, t.rotation) },
|
|
setMaterial: function(t, e) {
|
|
if (void 0 === e)
|
|
for (var i = this.data.shapes.length - 1; 0 <= i; i--) this.data.shapes[i].material = t;
|
|
else e.material = t
|
|
},
|
|
shapeChanged: function() { this.debugBody && this.debugBody.draw() },
|
|
addPhaserPolygon: function(t, e) {
|
|
for (var i = this.game.cache.getPhysicsData(t, e), s = [], o = 0; o < i.length; o++) {
|
|
var n = i[o],
|
|
a = this.addFixture(n);
|
|
s[n.filter.group] = s[n.filter.group] || [], s[n.filter.group] = s[n.filter.group].concat(a), n.fixtureKey && (s[n.fixtureKey] = a)
|
|
}
|
|
return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), s
|
|
},
|
|
addFixture: function(t) {
|
|
var e = [];
|
|
if (t.circle) {
|
|
(l = new p2.Circle({ radius: this.world.pxm(t.circle.radius) })).collisionGroup = t.filter.categoryBits, l.collisionMask = t.filter.maskBits, l.sensor = t.isSensor;
|
|
var i = p2.vec2.create();
|
|
i[0] = this.world.pxmi(t.circle.position[0] - this.sprite.width / 2), i[1] = this.world.pxmi(t.circle.position[1] - this.sprite.height / 2), this.data.addShape(l, i), e.push(l)
|
|
}
|
|
else
|
|
for (var s = t.polygons, o = p2.vec2.create(), n = 0; n < s.length; n++) {
|
|
for (var a = s[n], r = [], h = 0; h < a.length; h += 2) r.push([this.world.pxmi(a[h]), this.world.pxmi(a[h + 1])]);
|
|
for (var l = new p2.Convex({ vertices: r }), c = 0; c !== l.vertices.length; c++) {
|
|
var p = l.vertices[c];
|
|
p2.vec2.sub(p, p, l.centerOfMass)
|
|
}
|
|
p2.vec2.scale(o, l.centerOfMass, 1), o[0] -= this.world.pxmi(this.sprite.width / 2), o[1] -= this.world.pxmi(this.sprite.height / 2), l.updateTriangles(), l.updateCenterOfMass(), l.updateBoundingRadius(), l.collisionGroup = t.filter.categoryBits, l.collisionMask = t.filter.maskBits, l.sensor = t.isSensor, this.data.addShape(l, o), e.push(l)
|
|
}
|
|
return e
|
|
},
|
|
loadPolygon: function(t, e) {
|
|
if (null === t) var i = e;
|
|
else i = this.game.cache.getPhysicsData(t, e);
|
|
for (var s = p2.vec2.create(), o = 0; o < i.length; o++) {
|
|
for (var n = [], a = 0; a < i[o].shape.length; a += 2) n.push([this.world.pxmi(i[o].shape[a]), this.world.pxmi(i[o].shape[a + 1])]);
|
|
for (var r = new p2.Convex({ vertices: n }), h = 0; h !== r.vertices.length; h++) {
|
|
var l = r.vertices[h];
|
|
p2.vec2.sub(l, l, r.centerOfMass)
|
|
}
|
|
p2.vec2.scale(s, r.centerOfMass, 1), s[0] -= this.world.pxmi(this.sprite.width / 2), s[1] -= this.world.pxmi(this.sprite.height / 2), r.updateTriangles(), r.updateCenterOfMass(), r.updateBoundingRadius(), this.data.addShape(r, s)
|
|
}
|
|
return this.data.aabbNeedsUpdate = !0, this.shapeChanged(), !0
|
|
}
|
|
}, H.Physics.P2.Body.prototype.constructor = H.Physics.P2.Body, H.Physics.P2.Body.DYNAMIC = 1, H.Physics.P2.Body.STATIC = 2, H.Physics.P2.Body.KINEMATIC = 4, Object.defineProperty(H.Physics.P2.Body.prototype, "static", { get: function() { return this.data.type === H.Physics.P2.Body.STATIC }, set: function(t) { t && this.data.type !== H.Physics.P2.Body.STATIC ? (this.data.type = H.Physics.P2.Body.STATIC, this.mass = 0) : t || this.data.type !== H.Physics.P2.Body.STATIC || (this.data.type = H.Physics.P2.Body.DYNAMIC, this.mass = 1) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "dynamic", { get: function() { return this.data.type === H.Physics.P2.Body.DYNAMIC }, set: function(t) { t && this.data.type !== H.Physics.P2.Body.DYNAMIC ? (this.data.type = H.Physics.P2.Body.DYNAMIC, this.mass = 1) : t || this.data.type !== H.Physics.P2.Body.DYNAMIC || (this.data.type = H.Physics.P2.Body.STATIC, this.mass = 0) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "kinematic", { get: function() { return this.data.type === H.Physics.P2.Body.KINEMATIC }, set: function(t) { t && this.data.type !== H.Physics.P2.Body.KINEMATIC ? (this.data.type = H.Physics.P2.Body.KINEMATIC, this.mass = 4) : t || this.data.type !== H.Physics.P2.Body.KINEMATIC || (this.data.type = H.Physics.P2.Body.STATIC, this.mass = 0) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "allowSleep", { get: function() { return this.data.allowSleep }, set: function(t) { t !== this.data.allowSleep && (this.data.allowSleep = t) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "angle", { get: function() { return H.Math.wrapAngle(H.Math.radToDeg(this.data.angle)) }, set: function(t) { this.data.angle = H.Math.degToRad(H.Math.wrapAngle(t)) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "angularDamping", { get: function() { return this.data.angularDamping }, set: function(t) { this.data.angularDamping = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "angularForce", { get: function() { return this.data.angularForce }, set: function(t) { this.data.angularForce = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "angularVelocity", { get: function() { return this.data.angularVelocity }, set: function(t) { this.data.angularVelocity = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "damping", { get: function() { return this.data.damping }, set: function(t) { this.data.damping = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "fixedRotation", { get: function() { return this.data.fixedRotation }, set: function(t) { t !== this.data.fixedRotation && (this.data.fixedRotation = t) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "inertia", { get: function() { return this.data.inertia }, set: function(t) { this.data.inertia = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "mass", { get: function() { return this.data.mass }, set: function(t) { t !== this.data.mass && (this.data.mass = t, this.data.updateMassProperties()) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "motionState", { get: function() { return this.data.type }, set: function(t) { t !== this.data.type && (this.data.type = t) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "rotation", { get: function() { return this.data.angle }, set: function(t) { this.data.angle = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "sleepSpeedLimit", { get: function() { return this.data.sleepSpeedLimit }, set: function(t) { this.data.sleepSpeedLimit = t } }), Object.defineProperty(H.Physics.P2.Body.prototype, "x", { get: function() { return this.world.mpxi(this.data.position[0]) }, set: function(t) { this.data.position[0] = this.world.pxmi(t) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "y", { get: function() { return this.world.mpxi(this.data.position[1]) }, set: function(t) { this.data.position[1] = this.world.pxmi(t) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "id", { get: function() { return this.data.id } }), Object.defineProperty(H.Physics.P2.Body.prototype, "debug", { get: function() { return null !== this.debugBody }, set: function(t) { t && !this.debugBody ? this.debugBody = new H.Physics.P2.BodyDebug(this.game, this.data) : !t && this.debugBody && (this.debugBody.destroy(), this.debugBody = null) } }), Object.defineProperty(H.Physics.P2.Body.prototype, "collideWorldBounds", { get: function() { return this._collideWorldBounds }, set: function(t) { t && !this._collideWorldBounds ? (this._collideWorldBounds = !0, this.updateCollisionMask()) : !t && this._collideWorldBounds && (this._collideWorldBounds = !1, this.updateCollisionMask()) } }), H.Physics.P2.BodyDebug = function(t, e, i) {
|
|
H.Group.call(this, t);
|
|
var s = { pixelsPerLengthUnit: t.physics.p2.mpx(1), debugPolygons: !1, lineWidth: 1, alpha: .5 };
|
|
this.settings = H.Utils.extend(s, i), this.ppu = this.settings.pixelsPerLengthUnit, this.ppu = -1 * this.ppu, this.body = e, this.canvas = new H.Graphics(t), this.canvas.alpha = this.settings.alpha, this.add(this.canvas), this.draw(), this.updateSpriteTransform()
|
|
}, H.Physics.P2.BodyDebug.prototype = Object.create(H.Group.prototype), H.Physics.P2.BodyDebug.prototype.constructor = H.Physics.P2.BodyDebug, H.Utils.extend(H.Physics.P2.BodyDebug.prototype, {
|
|
updateSpriteTransform: function() { this.position.x = this.body.position[0] * this.ppu, this.position.y = this.body.position[1] * this.ppu, this.rotation = this.body.angle },
|
|
draw: function() {
|
|
var t, e, i, s, o, n, a, r, h, l, c, p, u, d, y;
|
|
if (r = this.body, (l = this.canvas).clear(), i = parseInt(this.randomPastelHex(), 16), n = 16711680, a = this.lineWidth, r instanceof p2.Body && r.shapes.length) {
|
|
var g = r.shapes.length;
|
|
for (s = 0; s !== g;) {
|
|
if (h = (e = r.shapes[s]).position || 0, t = e.angle || 0, e instanceof p2.Circle) this.drawCircle(l, h[0] * this.ppu, h[1] * this.ppu, t, e.radius * this.ppu, i, a);
|
|
else if (e instanceof p2.Capsule) this.drawCapsule(l, h[0] * this.ppu, h[1] * this.ppu, t, e.length * this.ppu, e.radius * this.ppu, n, i, a);
|
|
else if (e instanceof p2.Plane) this.drawPlane(l, h[0] * this.ppu, -h[1] * this.ppu, i, n, 5 * a, 10 * a, 10 * a, 100 * this.ppu, t);
|
|
else if (e instanceof p2.Line) this.drawLine(l, e.length * this.ppu, n, a);
|
|
else if (e instanceof p2.Box) this.drawRectangle(l, h[0] * this.ppu, h[1] * this.ppu, t, e.width * this.ppu, e.height * this.ppu, n, i, a);
|
|
else if (e instanceof p2.Convex) {
|
|
for (p = [], u = p2.vec2.create(), o = d = 0, y = e.vertices.length; 0 <= y ? d < y : y < d; o = 0 <= y ? ++d : --d) c = e.vertices[o], p2.vec2.rotate(u, c, t), p.push([(u[0] + h[0]) * this.ppu, -(u[1] + h[1]) * this.ppu]);
|
|
this.drawConvex(l, p, e.triangles, n, i, a, this.settings.debugPolygons, [h[0] * this.ppu, -h[1] * this.ppu])
|
|
}
|
|
s++
|
|
}
|
|
}
|
|
},
|
|
drawRectangle: function(t, e, i, s, o, n, a, r, h) { void 0 === h && (h = 1), void 0 === a && (a = 0), t.lineStyle(h, a, 1), t.beginFill(r), t.drawRect(e - o / 2, i - n / 2, o, n) },
|
|
drawCircle: function(t, e, i, s, o, n, a) { void 0 === a && (a = 1), void 0 === n && (n = 16777215), t.lineStyle(a, 0, 1), t.beginFill(n, 1), t.drawCircle(e, i, 2 * -o), t.endFill(), t.moveTo(e, i), t.lineTo(e + o * Math.cos(-s), i + o * Math.sin(-s)) },
|
|
drawLine: function(t, e, i, s) { void 0 === s && (s = 1), void 0 === i && (i = 0), t.lineStyle(5 * s, i, 1), t.moveTo(-e / 2, 0), t.lineTo(e / 2, 0) },
|
|
drawConvex: function(t, e, i, s, o, n, a, r) { var h, l, c, p, u, d, y, g, f, m, v; if (void 0 === n && (n = 1), void 0 === s && (s = 0), a) { for (h = [16711680, 65280, 255], l = 0; l !== e.length + 1;) p = e[l % e.length], u = e[(l + 1) % e.length], y = p[0], m = p[1], g = u[0], v = u[1], t.lineStyle(n, h[l % h.length], 1), t.moveTo(y, -m), t.lineTo(g, -v), t.drawCircle(y, -m, 2 * n), l++; return t.lineStyle(n, 0, 1), t.drawCircle(r[0], r[1], 2 * n) } for (t.lineStyle(n, s, 1), t.beginFill(o), l = 0; l !== e.length;) d = (c = e[l])[0], f = c[1], 0 === l ? t.moveTo(d, -f) : t.lineTo(d, -f), l++; if (t.endFill(), 2 < e.length) return t.moveTo(e[e.length - 1][0], -e[e.length - 1][1]), t.lineTo(e[0][0], -e[0][1]) },
|
|
drawPath: function(t, e, i, s, o) { var n, a, r, h, l, c, p, u, d, y, g; for (void 0 === o && (o = 1), void 0 === i && (i = 0), t.lineStyle(o, i, 1), "number" == typeof s && t.beginFill(s), r = a = null, n = 0; n < e.length;) y = (d = e[n])[0], g = d[1], y === a && g === r || (0 === n ? t.moveTo(y, g) : (h = a, l = r, c = y, p = g, u = e[(n + 1) % e.length][0], 0 !== (c - h) * (e[(n + 1) % e.length][1] - l) - (u - h) * (p - l) && t.lineTo(y, g)), a = y, r = g), n++; "number" == typeof s && t.endFill(), 2 < e.length && "number" == typeof s && (t.moveTo(e[e.length - 1][0], e[e.length - 1][1]), t.lineTo(e[0][0], e[0][1])) },
|
|
drawPlane: function(t, e, i, s, o, n, a, r, h, l) {
|
|
var c, p;
|
|
void 0 === n && (n = 1), void 0 === s && (s = 16777215), t.lineStyle(n, o, 11), t.beginFill(s), t.moveTo(e, -i), c = e + Math.cos(l) * this.game.width, p = i + Math.sin(l) * this.game.height, t.lineTo(c, -p), t.moveTo(e, -i), c = e + Math.cos(l) * -this.game.width, p = i + Math.sin(l) * -this.game.height, t.lineTo(c, -p)
|
|
},
|
|
drawCapsule: function(t, e, i, s, o, n, a, r, h) {
|
|
void 0 === h && (h = 1), void 0 === a && (a = 0), t.lineStyle(h, a, 1);
|
|
var l = Math.cos(s),
|
|
c = Math.sin(s);
|
|
t.beginFill(r, 1), t.drawCircle(-o / 2 * l + e, -o / 2 * c + i, 2 * -n), t.drawCircle(o / 2 * l + e, o / 2 * c + i, 2 * -n), t.endFill(), t.lineStyle(h, a, 0), t.beginFill(r, 1), t.moveTo(-o / 2 * l + n * c + e, -o / 2 * c + n * l + i), t.lineTo(o / 2 * l + n * c + e, o / 2 * c + n * l + i), t.lineTo(o / 2 * l - n * c + e, o / 2 * c - n * l + i), t.lineTo(-o / 2 * l - n * c + e, -o / 2 * c - n * l + i), t.endFill(), t.lineStyle(h, a, 1), t.moveTo(-o / 2 * l + n * c + e, -o / 2 * c + n * l + i), t.lineTo(o / 2 * l + n * c + e, o / 2 * c + n * l + i), t.moveTo(-o / 2 * l - n * c + e, -o / 2 * c - n * l + i), t.lineTo(o / 2 * l - n * c + e, o / 2 * c - n * l + i)
|
|
},
|
|
randomPastelHex: function() { var t, e, i, s; return i = [255, 255, 255], s = Math.floor(256 * Math.random()), e = Math.floor(256 * Math.random()), t = Math.floor(256 * Math.random()), s = Math.floor((s + 3 * i[0]) / 4), e = Math.floor((e + 3 * i[1]) / 4), t = Math.floor((t + 3 * i[2]) / 4), this.rgbToHex(s, e, t) },
|
|
rgbToHex: function(t, e, i) { return this.componentToHex(t) + this.componentToHex(e) + this.componentToHex(i) },
|
|
componentToHex: function(t) { var e; return 2 === (e = t.toString(16)).length ? e : e + "0" }
|
|
}), H.Physics.P2.Spring = function(t, e, i, s, o, n, a, r, h, l) {
|
|
this.game = t.game, void 0 === s && (s = 1), void 0 === o && (o = 100), void 0 === n && (n = 1);
|
|
var c = { restLength: s = (this.world = t).pxm(s), stiffness: o, damping: n };
|
|
null != a && (c.worldAnchorA = [t.pxm(a[0]), t.pxm(a[1])]), null != r && (c.worldAnchorB = [t.pxm(r[0]), t.pxm(r[1])]), null != h && (c.localAnchorA = [t.pxm(h[0]), t.pxm(h[1])]), null != l && (c.localAnchorB = [t.pxm(l[0]), t.pxm(l[1])]), this.data = new p2.LinearSpring(e, i, c), this.data.parent = this
|
|
}, H.Physics.P2.Spring.prototype.constructor = H.Physics.P2.Spring, H.Physics.P2.RotationalSpring = function(t, e, i, s, o, n) {
|
|
this.game = t.game, this.world = t, void 0 === s && (s = null), void 0 === o && (o = 100), void 0 === n && (n = 1), s && (s = t.pxm(s));
|
|
var a = { restAngle: s, stiffness: o, damping: n };
|
|
this.data = new p2.RotationalSpring(e, i, a), this.data.parent = this
|
|
}, H.Physics.P2.Spring.prototype.constructor = H.Physics.P2.Spring, H.Physics.P2.Material = function(t) { this.name = t, p2.Material.call(this) }, H.Physics.P2.Material.prototype = Object.create(p2.Material.prototype), H.Physics.P2.Material.prototype.constructor = H.Physics.P2.Material, H.Physics.P2.ContactMaterial = function(t, e, i) { p2.ContactMaterial.call(this, t, e, i) }, H.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype), H.Physics.P2.ContactMaterial.prototype.constructor = H.Physics.P2.ContactMaterial, H.Physics.P2.CollisionGroup = function(t) { this.mask = t }, H.Physics.P2.DistanceConstraint = function(t, e, i, s, o, n, a) {
|
|
void 0 === s && (s = 100), void 0 === o && (o = [0, 0]), void 0 === n && (n = [0, 0]), void 0 === a && (a = Number.MAX_VALUE), this.game = t.game;
|
|
var r = { distance: s = (this.world = t).pxm(s), localAnchorA: o = [t.pxmi(o[0]), t.pxmi(o[1])], localAnchorB: n = [t.pxmi(n[0]), t.pxmi(n[1])], maxForce: a };
|
|
p2.DistanceConstraint.call(this, e, i, r)
|
|
}, H.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype), H.Physics.P2.DistanceConstraint.prototype.constructor = H.Physics.P2.DistanceConstraint, H.Physics.P2.GearConstraint = function(t, e, i, s, o) {
|
|
void 0 === s && (s = 0), void 0 === o && (o = 1), this.game = t.game, this.world = t;
|
|
var n = { angle: s, ratio: o };
|
|
p2.GearConstraint.call(this, e, i, n)
|
|
}, H.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype), H.Physics.P2.GearConstraint.prototype.constructor = H.Physics.P2.GearConstraint, H.Physics.P2.LockConstraint = function(t, e, i, s, o, n) {
|
|
void 0 === s && (s = [0, 0]), void 0 === o && (o = 0), void 0 === n && (n = Number.MAX_VALUE), this.game = t.game;
|
|
var a = { localOffsetB: s = [(this.world = t).pxm(s[0]), t.pxm(s[1])], localAngleB: o, maxForce: n };
|
|
p2.LockConstraint.call(this, e, i, a)
|
|
}, H.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype), H.Physics.P2.LockConstraint.prototype.constructor = H.Physics.P2.LockConstraint, H.Physics.P2.PrismaticConstraint = function(t, e, i, s, o, n, a, r) {
|
|
void 0 === s && (s = !0), void 0 === o && (o = [0, 0]), void 0 === n && (n = [0, 0]), void 0 === a && (a = [0, 0]), void 0 === r && (r = Number.MAX_VALUE), this.game = t.game;
|
|
var h = { localAnchorA: o = [(this.world = t).pxmi(o[0]), t.pxmi(o[1])], localAnchorB: n = [t.pxmi(n[0]), t.pxmi(n[1])], localAxisA: a, maxForce: r, disableRotationalLock: !s };
|
|
p2.PrismaticConstraint.call(this, e, i, h)
|
|
}, H.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype), H.Physics.P2.PrismaticConstraint.prototype.constructor = H.Physics.P2.PrismaticConstraint, H.Physics.P2.RevoluteConstraint = function(t, e, i, s, o, n, a) {
|
|
void 0 === n && (n = Number.MAX_VALUE), void 0 === a && (a = null), this.game = t.game, i = [(this.world = t).pxmi(i[0]), t.pxmi(i[1])], o = [t.pxmi(o[0]), t.pxmi(o[1])], a && (a = [t.pxmi(a[0]), t.pxmi(a[1])]);
|
|
var r = { worldPivot: a, localPivotA: i, localPivotB: o, maxForce: n };
|
|
p2.RevoluteConstraint.call(this, e, s, r)
|
|
}, H.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype), H.Physics.P2.RevoluteConstraint.prototype.constructor = H.Physics.P2.RevoluteConstraint, H.ImageCollection = function(t, e, i, s, o, n, a) {
|
|
(void 0 === i || i <= 0) && (i = 32), (void 0 === s || s <= 0) && (s = 32), void 0 === o && (o = 0), void 0 === n && (n = 0), this.name = t, this.firstgid = 0 | e, this.imageWidth = 0 | i, this.imageHeight = 0 | s, this.imageMargin = 0 | o, this.imageSpacing = 0 | n, this.properties = a || {}, this.images = [], this.total = 0
|
|
}, H.ImageCollection.prototype = { containsImageIndex: function(t) { return t >= this.firstgid && t < this.firstgid + this.total }, addImage: function(t, e) { this.images.push({ gid: t, image: e }), this.total++ } }, H.ImageCollection.prototype.constructor = H.ImageCollection, H.Tile = function(t, e, i, s, o, n) { this.layer = t, this.index = e, this.x = i, this.y = s, this.rotation = 0, this.flipped = !1, this.worldX = i * o, this.worldY = s * n, this.width = o, this.height = n, this.centerX = Math.abs(o / 2), this.centerY = Math.abs(n / 2), this.alpha = 1, this.properties = {}, this.scanned = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1, this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.collisionCallback = null, this.collisionCallbackContext = this }, H.Tile.prototype = { containsPoint: function(t, e) { return !(t < this.worldX || e < this.worldY || t > this.right || e > this.bottom) }, intersects: function(t, e, i, s) { return !(i <= this.worldX) && (!(s <= this.worldY) && (!(t >= this.worldX + this.width) && !(e >= this.worldY + this.height))) }, setCollisionCallback: function(t, e) { this.collisionCallback = t, this.collisionCallbackContext = e }, destroy: function() { this.collisionCallback = null, this.collisionCallbackContext = null, this.properties = null }, setCollision: function(t, e, i, s) { this.collideLeft = t, this.collideRight = e, this.collideUp = i, this.collideDown = s, this.faceLeft = t, this.faceRight = e, this.faceTop = i, this.faceBottom = s }, resetCollision: function() { this.collideLeft = !1, this.collideRight = !1, this.collideUp = !1, this.collideDown = !1, this.faceTop = !1, this.faceBottom = !1, this.faceLeft = !1, this.faceRight = !1 }, isInteresting: function(t, e) { return t && e ? this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.faceTop || this.faceBottom || this.faceLeft || this.faceRight || this.collisionCallback : t ? this.collideLeft || this.collideRight || this.collideUp || this.collideDown : !!e && (this.faceTop || this.faceBottom || this.faceLeft || this.faceRight) }, copy: function(t) { this.index = t.index, this.alpha = t.alpha, this.properties = t.properties, this.collideUp = t.collideUp, this.collideDown = t.collideDown, this.collideLeft = t.collideLeft, this.collideRight = t.collideRight, this.collisionCallback = t.collisionCallback, this.collisionCallbackContext = t.collisionCallbackContext } }, H.Tile.prototype.constructor = H.Tile, Object.defineProperty(H.Tile.prototype, "collides", { get: function() { return this.collideLeft || this.collideRight || this.collideUp || this.collideDown } }), Object.defineProperty(H.Tile.prototype, "canCollide", { get: function() { return this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback } }), Object.defineProperty(H.Tile.prototype, "left", { get: function() { return this.worldX } }), Object.defineProperty(H.Tile.prototype, "right", { get: function() { return this.worldX + this.width } }), Object.defineProperty(H.Tile.prototype, "top", { get: function() { return this.worldY } }), Object.defineProperty(H.Tile.prototype, "bottom", { get: function() { return this.worldY + this.height } }), H.Tilemap = function(t, e, i, s, o, n) {
|
|
this.game = t, this.key = e;
|
|
var a = H.TilemapParser.parse(this.game, e, i, s, o, n);
|
|
null !== a && (this.width = a.width, this.height = a.height, this.tileWidth = a.tileWidth, this.tileHeight = a.tileHeight, this.orientation = a.orientation, this.format = a.format, this.version = a.version, this.properties = a.properties, this.widthInPixels = a.widthInPixels, this.heightInPixels = a.heightInPixels, this.layers = a.layers, this.tilesets = a.tilesets, this.imagecollections = a.imagecollections, this.tiles = a.tiles, this.objects = a.objects, this.collideIndexes = [], this.collision = a.collision, this.images = a.images, this.enableDebug = !1, this.currentLayer = 0, this.debugMap = [], this._results = [], this._tempA = 0, this._tempB = 0)
|
|
}, H.Tilemap.CSV = 0, H.Tilemap.TILED_JSON = 1, H.Tilemap.NORTH = 0, H.Tilemap.EAST = 1, H.Tilemap.SOUTH = 2, H.Tilemap.WEST = 3, H.Tilemap.prototype = {
|
|
create: function(t, e, i, s, o, n) { return void 0 === n && (n = this.game.world), this.width = e, this.height = i, this.setTileSize(s, o), this.layers.length = 0, this.createBlankLayer(t, e, i, s, o, n) },
|
|
setTileSize: function(t, e) { this.tileWidth = t, this.tileHeight = e, this.widthInPixels = this.width * t, this.heightInPixels = this.height * e },
|
|
addTilesetImage: function(t, e, i, s, o, n, a) {
|
|
if (void 0 === t) return null;
|
|
void 0 === i && (i = this.tileWidth), void 0 === s && (s = this.tileHeight), void 0 === o && (o = 0), void 0 === n && (n = 0), void 0 === a && (a = 0), 0 === i && (i = 32), 0 === s && (s = 32);
|
|
var r = null;
|
|
if (null == e && (e = t), e instanceof H.BitmapData) r = e.canvas;
|
|
else {
|
|
if (!this.game.cache.checkImageKey(e)) return null;
|
|
r = this.game.cache.getImage(e)
|
|
}
|
|
var h = this.getTilesetIndex(t);
|
|
if (null === h && this.format === H.Tilemap.TILED_JSON) return null;
|
|
if (this.tilesets[h]) return this.tilesets[h].setImage(r), this.tilesets[h];
|
|
var l = new H.Tileset(t, a, i, s, o, n, {});
|
|
l.setImage(r), this.tilesets.push(l);
|
|
for (var c = this.tilesets.length - 1, p = o, u = o, d = 0, y = 0, g = 0, f = a; f < a + l.total && (this.tiles[f] = [p, u, c], p += i + n, ++d !== l.total) && (++y !== l.columns || (p = o, u += s + n, y = 0, ++g !== l.rows)); f++);
|
|
return l
|
|
},
|
|
createFromObjects: function(t, e, i, s, o, n, a, r, h) {
|
|
if (void 0 === o && (o = !0), void 0 === n && (n = !1), void 0 === a && (a = this.game.world), void 0 === r && (r = H.Sprite), void 0 === h && (h = !0), this.objects[t])
|
|
for (var l = 0; l < this.objects[t].length; l++) {
|
|
var c = !1,
|
|
p = this.objects[t][l];
|
|
if (void 0 !== p.gid && "number" == typeof e && p.gid === e ? c = !0 : void 0 !== p.id && "number" == typeof e && p.id === e ? c = !0 : void 0 !== p.name && "string" == typeof e && p.name === e && (c = !0), c) { var u = new r(this.game, parseFloat(p.x, 10), parseFloat(p.y, 10), i, s); for (var d in u.name = p.name, u.visible = p.visible, u.autoCull = n, u.exists = o, p.width && (u.width = p.width), p.height && (u.height = p.height), p.rotation && (u.angle = p.rotation), h && (u.y -= u.height), a.add(u), p.properties) a.set(u, d, p.properties[d], !1, !1, 0, !0) }
|
|
}
|
|
},
|
|
createFromTiles: function(t, e, i, s, o, n) {
|
|
"number" == typeof t && (t = [t]), null == e ? e = [] : "number" == typeof e && (e = [e]), s = this.getLayer(s), void 0 === o && (o = this.game.world), void 0 === n && (n = {}), void 0 === n.customClass && (n.customClass = H.Sprite), void 0 === n.adjustY && (n.adjustY = !0);
|
|
var a = this.layers[s].width,
|
|
r = this.layers[s].height;
|
|
if (this.copy(0, 0, a, r, s), this._results.length < 2) return 0;
|
|
for (var h, l = 0, c = 1, p = this._results.length; c < p; c++)
|
|
if (-1 !== t.indexOf(this._results[c].index)) {
|
|
for (var u in h = new n.customClass(this.game, this._results[c].worldX, this._results[c].worldY, i), n) h[u] = n[u];
|
|
o.add(h), l++
|
|
}
|
|
if (1 === e.length)
|
|
for (c = 0; c < t.length; c++) this.replace(t[c], e[0], 0, 0, a, r, s);
|
|
else if (1 < e.length)
|
|
for (c = 0; c < t.length; c++) this.replace(t[c], e[c], 0, 0, a, r, s);
|
|
return l
|
|
},
|
|
createLayer: function(t, e, i, s) { void 0 === e && (e = this.game.width), void 0 === i && (i = this.game.height), void 0 === s && (s = this.game.world); var o = t; if ("string" == typeof t && (o = this.getLayerIndex(t)), !(null === o || o > this.layers.length)) { void 0 === e || e <= 0 ? e = Math.min(this.game.width, this.layers[o].widthInPixels) : e > this.game.width && (e = this.game.width), void 0 === i || i <= 0 ? i = Math.min(this.game.height, this.layers[o].heightInPixels) : i > this.game.height && (i = this.game.height), this.enableDebug; var n = s.add(new H.TilemapLayer(this.game, this, o, e, i)); return this.enableDebug, n } },
|
|
createBlankLayer: function(t, e, i, s, o, n) {
|
|
if (void 0 === n && (n = this.game.world), null === this.getLayerIndex(t)) {
|
|
for (var a, r = { name: t, x: 0, y: 0, width: e, height: i, widthInPixels: e * s, heightInPixels: i * o, alpha: 1, visible: !0, properties: {}, indexes: [], callbacks: [], bodies: [], data: null }, h = [], l = 0; l < i; l++) {
|
|
a = [];
|
|
for (var c = 0; c < e; c++) a.push(new H.Tile(r, -1, c, l, s, o));
|
|
h.push(a)
|
|
}
|
|
r.data = h, this.layers.push(r), this.currentLayer = this.layers.length - 1;
|
|
var p = r.widthInPixels,
|
|
u = r.heightInPixels;
|
|
return p > this.game.width && (p = this.game.width), u > this.game.height && (u = this.game.height), (h = new H.TilemapLayer(this.game, this, this.layers.length - 1, p, u)).name = t, n.add(h)
|
|
}
|
|
},
|
|
getIndex: function(t, e) {
|
|
for (var i = 0; i < t.length; i++)
|
|
if (t[i].name === e) return i;
|
|
return null
|
|
},
|
|
getLayerIndex: function(t) { return this.getIndex(this.layers, t) },
|
|
getTilesetIndex: function(t) { return this.getIndex(this.tilesets, t) },
|
|
getImageIndex: function(t) { return this.getIndex(this.images, t) },
|
|
setTileIndexCallback: function(t, e, i, s) {
|
|
if (s = this.getLayer(s), "number" == typeof t) this.layers[s].callbacks[t] = { callback: e, callbackContext: i };
|
|
else
|
|
for (var o = 0, n = t.length; o < n; o++) this.layers[s].callbacks[t[o]] = { callback: e, callbackContext: i }
|
|
},
|
|
setTileLocationCallback: function(t, e, i, s, o, n, a) {
|
|
if (a = this.getLayer(a), this.copy(t, e, i, s, a), !(this._results.length < 2))
|
|
for (var r = 1; r < this._results.length; r++) this._results[r].setCollisionCallback(o, n)
|
|
},
|
|
setCollision: function(t, e, i, s) {
|
|
if (void 0 === e && (e = !0), void 0 === s && (s = !0), i = this.getLayer(i), "number" == typeof t) return this.setCollisionByIndex(t, e, i, !0);
|
|
if (Array.isArray(t)) {
|
|
for (var o = 0; o < t.length; o++) this.setCollisionByIndex(t[o], e, i, !1);
|
|
s && this.calculateFaces(i)
|
|
}
|
|
},
|
|
setCollisionBetween: function(t, e, i, s, o) {
|
|
if (void 0 === i && (i = !0), void 0 === o && (o = !0), s = this.getLayer(s), !(e < t)) {
|
|
for (var n = t; n <= e; n++) this.setCollisionByIndex(n, i, s, !1);
|
|
o && this.calculateFaces(s)
|
|
}
|
|
},
|
|
setCollisionByExclusion: function(t, e, i, s) {
|
|
void 0 === e && (e = !0), void 0 === s && (s = !0), i = this.getLayer(i);
|
|
for (var o = 0, n = this.tiles.length; o < n; o++) - 1 === t.indexOf(o) && this.setCollisionByIndex(o, e, i, !1);
|
|
s && this.calculateFaces(i)
|
|
},
|
|
setCollisionByIndex: function(t, e, i, s) {
|
|
if (void 0 === e && (e = !0), void 0 === i && (i = this.currentLayer), void 0 === s && (s = !0), e) this.collideIndexes.push(t);
|
|
else { var o = this.collideIndexes.indexOf(t); - 1 < o && this.collideIndexes.splice(o, 1) }
|
|
for (var n = 0; n < this.layers[i].height; n++)
|
|
for (var a = 0; a < this.layers[i].width; a++) {
|
|
var r = this.layers[i].data[n][a];
|
|
r && r.index === t && (e ? r.setCollision(!0, !0, !0, !0) : r.resetCollision(), r.faceTop = e, r.faceBottom = e, r.faceLeft = e, r.faceRight = e)
|
|
}
|
|
return s && this.calculateFaces(i), i
|
|
},
|
|
getLayer: function(t) { return void 0 === t ? t = this.currentLayer : "string" == typeof t ? t = this.getLayerIndex(t) : t instanceof H.TilemapLayer && (t = t.index), t },
|
|
setPreventRecalculate: function(t) {
|
|
if (!0 === t && !0 !== this.preventingRecalculate && (this.preventingRecalculate = !0, this.needToRecalculate = {}), !1 === t && !0 === this.preventingRecalculate) {
|
|
for (var e in this.preventingRecalculate = !1, this.needToRecalculate) this.calculateFaces(e);
|
|
this.needToRecalculate = !1
|
|
}
|
|
},
|
|
calculateFaces: function(t) {
|
|
if (this.preventingRecalculate) this.needToRecalculate[t] = !0;
|
|
else
|
|
for (var e = null, i = null, s = null, o = null, n = 0, a = this.layers[t].height; n < a; n++)
|
|
for (var r = 0, h = this.layers[t].width; r < h; r++) {
|
|
var l = this.layers[t].data[n][r];
|
|
l && (e = this.getTileAbove(t, r, n), i = this.getTileBelow(t, r, n), s = this.getTileLeft(t, r, n), o = this.getTileRight(t, r, n), l.collides && (l.faceTop = !0, l.faceBottom = !0, l.faceLeft = !0, l.faceRight = !0), e && e.collides && (l.faceTop = !1), i && i.collides && (l.faceBottom = !1), s && s.collides && (l.faceLeft = !1), o && o.collides && (l.faceRight = !1))
|
|
}
|
|
},
|
|
getTileAbove: function(t, e, i) { return 0 < i ? this.layers[t].data[i - 1][e] : null },
|
|
getTileBelow: function(t, e, i) { return i < this.layers[t].height - 1 ? this.layers[t].data[i + 1][e] : null },
|
|
getTileLeft: function(t, e, i) { return 0 < e ? this.layers[t].data[i][e - 1] : null },
|
|
getTileRight: function(t, e, i) { return e < this.layers[t].width - 1 ? this.layers[t].data[i][e + 1] : null },
|
|
setLayer: function(t) { t = this.getLayer(t), this.layers[t] && (this.currentLayer = t) },
|
|
hasTile: function(t, e, i) { return i = this.getLayer(i), void 0 !== this.layers[i].data[e] && void 0 !== this.layers[i].data[e][t] && -1 < this.layers[i].data[e][t].index },
|
|
removeTile: function(t, e, i) { if (i = this.getLayer(i), 0 <= t && t < this.layers[i].width && 0 <= e && e < this.layers[i].height && this.hasTile(t, e, i)) { var s = this.layers[i].data[e][t]; return this.layers[i].data[e][t] = new H.Tile(this.layers[i], -1, t, e, this.tileWidth, this.tileHeight), this.layers[i].dirty = !0, this.calculateFaces(i), s } },
|
|
removeTileWorldXY: function(t, e, i, s, o) { return o = this.getLayer(o), t = this.game.math.snapToFloor(t, i) / i, e = this.game.math.snapToFloor(e, s) / s, this.removeTile(t, e, o) },
|
|
putTile: function(t, e, i, s) { return null === t ? this.removeTile(e, i, s) : (s = this.getLayer(s), 0 <= e && e < this.layers[s].width && 0 <= i && i < this.layers[s].height ? (t instanceof H.Tile ? (o = t.index, this.hasTile(e, i, s) ? this.layers[s].data[i][e].copy(t) : this.layers[s].data[i][e] = new H.Tile(s, o, e, i, t.width, t.height)) : (o = t, this.hasTile(e, i, s) ? this.layers[s].data[i][e].index = o : this.layers[s].data[i][e] = new H.Tile(this.layers[s], o, e, i, this.tileWidth, this.tileHeight)), -1 < this.collideIndexes.indexOf(o) ? this.layers[s].data[i][e].setCollision(!0, !0, !0, !0) : this.layers[s].data[i][e].resetCollision(), this.layers[s].dirty = !0, this.calculateFaces(s), this.layers[s].data[i][e]) : null); var o },
|
|
putTileWorldXY: function(t, e, i, s, o, n) { return n = this.getLayer(n), e = this.game.math.snapToFloor(e, s) / s, i = this.game.math.snapToFloor(i, o) / o, this.putTile(t, e, i, n) },
|
|
searchTileIndex: function(t, e, i, s) {
|
|
void 0 === e && (e = 0), void 0 === i && (i = !1), s = this.getLayer(s);
|
|
var o = 0;
|
|
if (i) {
|
|
for (var n = this.layers[s].height - 1; 0 <= n; n--)
|
|
for (var a = this.layers[s].width - 1; 0 <= a; a--)
|
|
if (this.layers[s].data[n][a].index === t) {
|
|
if (o === e) return this.layers[s].data[n][a];
|
|
o++
|
|
}
|
|
}
|
|
else
|
|
for (n = 0; n < this.layers[s].height; n++)
|
|
for (a = 0; a < this.layers[s].width; a++)
|
|
if (this.layers[s].data[n][a].index === t) {
|
|
if (o === e) return this.layers[s].data[n][a];
|
|
o++
|
|
} return null
|
|
},
|
|
getTile: function(t, e, i, s) { return void 0 === s && (s = !1), i = this.getLayer(i), 0 <= t && t < this.layers[i].width && 0 <= e && e < this.layers[i].height ? -1 === this.layers[i].data[e][t].index ? s ? this.layers[i].data[e][t] : null : this.layers[i].data[e][t] : null },
|
|
getTileWorldXY: function(t, e, i, s, o, n) { return void 0 === i && (i = this.tileWidth), void 0 === s && (s = this.tileHeight), o = this.getLayer(o), t = this.game.math.snapToFloor(t, i) / i, e = this.game.math.snapToFloor(e, s) / s, this.getTile(t, e, o, n) },
|
|
copy: function(t, e, i, s, o) {
|
|
if (o = this.getLayer(o), this.layers[o]) {
|
|
void 0 === t && (t = 0), void 0 === e && (e = 0), void 0 === i && (i = this.layers[o].width), void 0 === s && (s = this.layers[o].height), t < 0 && (t = 0), e < 0 && (e = 0), i > this.layers[o].width && (i = this.layers[o].width), s > this.layers[o].height && (s = this.layers[o].height), this._results.length = 0, this._results.push({ x: t, y: e, width: i, height: s, layer: o });
|
|
for (var n = e; n < e + s; n++)
|
|
for (var a = t; a < t + i; a++) this._results.push(this.layers[o].data[n][a]);
|
|
return this._results
|
|
}
|
|
this._results.length = 0
|
|
},
|
|
paste: function(t, e, i, s) {
|
|
if (void 0 === t && (t = 0), void 0 === e && (e = 0), s = this.getLayer(s), i && !(i.length < 2)) {
|
|
for (var o = t - i[1].x, n = e - i[1].y, a = 1; a < i.length; a++) this.layers[s].data[n + i[a].y][o + i[a].x].copy(i[a]);
|
|
this.layers[s].dirty = !0, this.calculateFaces(s)
|
|
}
|
|
},
|
|
swap: function(t, e, i, s, o, n, a) { a = this.getLayer(a), this.copy(i, s, o, n, a), this._results.length < 2 || (this._tempA = t, this._tempB = e, this._results.forEach(this.swapHandler, this), this.paste(i, s, this._results, a)) },
|
|
swapHandler: function(t) { t.index === this._tempA ? t.index = this._tempB : t.index === this._tempB && (t.index = this._tempA) },
|
|
forEach: function(t, e, i, s, o, n, a) { a = this.getLayer(a), this.copy(i, s, o, n, a), this._results.length < 2 || (this._results.forEach(t, e), this.paste(i, s, this._results, a)) },
|
|
replace: function(t, e, i, s, o, n, a) {
|
|
if (a = this.getLayer(a), this.copy(i, s, o, n, a), !(this._results.length < 2)) {
|
|
for (var r = 1; r < this._results.length; r++) this._results[r].index === t && (this._results[r].index = e);
|
|
this.paste(i, s, this._results, a)
|
|
}
|
|
},
|
|
random: function(t, e, i, s, o) {
|
|
if (o = this.getLayer(o), this.copy(t, e, i, s, o), !(this._results.length < 2)) {
|
|
for (var n = [], a = 1; a < this._results.length; a++)
|
|
if (this._results[a].index) { var r = this._results[a].index; - 1 === n.indexOf(r) && n.push(r) }
|
|
for (var h = 1; h < this._results.length; h++) this._results[h].index = this.game.rnd.pick(n);
|
|
this.paste(t, e, this._results, o)
|
|
}
|
|
},
|
|
shuffle: function(t, e, i, s, o) {
|
|
if (o = this.getLayer(o), this.copy(t, e, i, s, o), !(this._results.length < 2)) {
|
|
for (var n = [], a = 1; a < this._results.length; a++) this._results[a].index && n.push(this._results[a].index);
|
|
H.ArrayUtils.shuffle(n);
|
|
for (var r = 1; r < this._results.length; r++) this._results[r].index = n[r - 1];
|
|
this.paste(t, e, this._results, o)
|
|
}
|
|
},
|
|
fill: function(t, e, i, s, o, n) {
|
|
if (n = this.getLayer(n), this.copy(e, i, s, o, n), !(this._results.length < 2)) {
|
|
for (var a = 1; a < this._results.length; a++) this._results[a].index = t;
|
|
this.paste(e, i, this._results, n)
|
|
}
|
|
},
|
|
removeAllLayers: function() { this.layers.length = 0, this.currentLayer = 0 },
|
|
dump: function() {
|
|
for (var t = "", e = [""], i = 0; i < this.layers[this.currentLayer].height; i++) {
|
|
for (var s = 0; s < this.layers[this.currentLayer].width; s++) t += "%c ", 1 < this.layers[this.currentLayer].data[i][s] ? this.debugMap[this.layers[this.currentLayer].data[i][s]] ? e.push("background: " + this.debugMap[this.layers[this.currentLayer].data[i][s]]) : e.push("background: #ffffff") : e.push("background: rgb(0, 0, 0)");
|
|
t += "\n"
|
|
}
|
|
e[0] = t
|
|
},
|
|
destroy: function() { this.removeAllLayers(), this.data = [], this.game = null }
|
|
}, H.Tilemap.prototype.constructor = H.Tilemap, Object.defineProperty(H.Tilemap.prototype, "layer", { get: function() { return this.layers[this.currentLayer] }, set: function(t) { t !== this.currentLayer && this.setLayer(t) } }), H.TilemapLayer = function(t, e, i, s, o) { s |= 0, o |= 0, H.Sprite.call(this, t, 0, 0), this.map = e, this.index = i, this.layer = e.layers[i], this.canvas = PIXI.CanvasPool.create(this, s, o), this.context = this.canvas.getContext("2d"), this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas))), this.type = H.TILEMAPLAYER, this.physicsType = H.TILEMAPLAYER, this.renderSettings = { enableScrollDelta: !1, overdrawRatio: .2, copyCanvas: null }, this.debug = !1, this.exists = !0, this.debugSettings = { missingImageFill: "rgb(255,255,255)", debuggedTileOverfill: "rgba(0,255,0,0.4)", forceFullRedraw: !0, debugAlpha: .5, facingEdgeStroke: "rgba(0,255,0,1)", collidingTileOverfill: "rgba(0,255,0,0.2)" }, this.scrollFactorX = 1, this.scrollFactorY = 1, this.dirty = !0, this.rayStepRate = 4, this._wrap = !1, this._mc = { scrollX: 0, scrollY: 0, renderWidth: 0, renderHeight: 0, tileWidth: e.tileWidth, tileHeight: e.tileHeight, cw: e.tileWidth, ch: e.tileHeight, tilesets: [] }, this._scrollX = 0, this._scrollY = 0, this._results = [], t.device.canvasBitBltShift || (this.renderSettings.copyCanvas = H.TilemapLayer.ensureSharedCopyCanvas()), this.fixedToCamera = !0 }, H.TilemapLayer.prototype = Object.create(H.Sprite.prototype), H.TilemapLayer.prototype.constructor = H.TilemapLayer, H.TilemapLayer.prototype.preUpdateCore = H.Component.Core.preUpdate, H.TilemapLayer.sharedCopyCanvas = null, H.TilemapLayer.ensureSharedCopyCanvas = function() { return this.sharedCopyCanvas || (this.sharedCopyCanvas = PIXI.CanvasPool.create(this, 2, 2)), this.sharedCopyCanvas }, H.TilemapLayer.prototype.preUpdate = function() { return this.preUpdateCore() }, H.TilemapLayer.prototype.postUpdate = function() { this.fixedToCamera && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y), this._scrollX = this.game.camera.view.x * this.scrollFactorX / this.scale.x, this._scrollY = this.game.camera.view.y * this.scrollFactorY / this.scale.y }, H.TilemapLayer.prototype._renderCanvas = function(t) { this.fixedToCamera && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y), this._scrollX = this.game.camera.view.x * this.scrollFactorX / this.scale.x, this._scrollY = this.game.camera.view.y * this.scrollFactorY / this.scale.y, this.render(), PIXI.Sprite.prototype._renderCanvas.call(this, t) }, H.TilemapLayer.prototype._renderWebGL = function(t) { this.fixedToCamera && (this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x, this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y), this._scrollX = this.game.camera.view.x * this.scrollFactorX / this.scale.x, this._scrollY = this.game.camera.view.y * this.scrollFactorY / this.scale.y, this.render(), PIXI.Sprite.prototype._renderWebGL.call(this, t) }, H.TilemapLayer.prototype.destroy = function() { PIXI.CanvasPool.remove(this), H.Component.Destroy.prototype.destroy.call(this) }, H.TilemapLayer.prototype.resize = function(t, e) { this.canvas.width = t, this.canvas.height = e, this.texture.frame.resize(t, e), this.texture.width = t, this.texture.height = e, this.texture.crop.width = t, this.texture.crop.height = e, this.texture.baseTexture.width = t, this.texture.baseTexture.height = e, this.texture.baseTexture.dirty(), this.texture.requiresUpdate = !0, this.texture._updateUvs(), this.dirty = !0 }, H.TilemapLayer.prototype.resizeWorld = function() { this.game.world.setBounds(0, 0, this.layer.widthInPixels * this.scale.x, this.layer.heightInPixels * this.scale.y) }, H.TilemapLayer.prototype._fixX = function(t) { return 1 === this.scrollFactorX || 0 === this.scrollFactorX && 0 === this.position.x ? t : 0 === this.scrollFactorX && 0 !== this.position.x ? t - this.position.x : this._scrollX + (t - this._scrollX / this.scrollFactorX) }, H.TilemapLayer.prototype._unfixX = function(t) { return 1 === this.scrollFactorX ? t : this._scrollX / this.scrollFactorX + (t - this._scrollX) }, H.TilemapLayer.prototype._fixY = function(t) { return 1 === this.scrollFactorY || 0 === this.scrollFactorY && 0 === this.position.y ? t : 0 === this.scrollFactorY && 0 !== this.position.y ? t - this.position.y : this._scrollY + (t - this._scrollY / this.scrollFactorY) }, H.TilemapLayer.prototype._unfixY = function(t) { return 1 === this.scrollFactorY ? t : this._scrollY / this.scrollFactorY + (t - this._scrollY) }, H.TilemapLayer.prototype.getTileX = function(t) { return Math.floor(this._fixX(t) / this._mc.tileWidth) }, H.TilemapLayer.prototype.getTileY = function(t) { return Math.floor(this._fixY(t) / this._mc.tileHeight) }, H.TilemapLayer.prototype.getTileXY = function(t, e, i) { return i.x = this.getTileX(t), i.y = this.getTileY(e), i }, H.TilemapLayer.prototype.getRayCastTiles = function(t, e, i, s) {
|
|
e || (e = this.rayStepRate), void 0 === i && (i = !1), void 0 === s && (s = !1);
|
|
var o = this.getTiles(t.x, t.y, t.width, t.height, i, s);
|
|
if (0 === o.length) return [];
|
|
for (var n = t.coordinatesOnLine(e), a = [], r = 0; r < o.length; r++)
|
|
for (var h = 0; h < n.length; h++) {
|
|
var l = o[r],
|
|
c = n[h];
|
|
if (l.containsPoint(c[0], c[1])) { a.push(l); break }
|
|
}
|
|
return a
|
|
}, H.TilemapLayer.prototype.getTiles = function(t, e, i, s, o, n) {
|
|
void 0 === o && (o = !1), void 0 === n && (n = !1);
|
|
var a = !(o || n);
|
|
t = this._fixX(t), e = this._fixY(e);
|
|
for (var r = Math.floor(t / (this._mc.cw * this.scale.x)), h = Math.floor(e / (this._mc.ch * this.scale.y)), l = Math.ceil((t + i) / (this._mc.cw * this.scale.x)) - r, c = Math.ceil((e + s) / (this._mc.ch * this.scale.y)) - h; this._results.length;) this._results.pop();
|
|
for (var p = h; p < h + c; p++)
|
|
for (var u = r; u < r + l; u++) {
|
|
var d = this.layer.data[p];
|
|
d && d[u] && (a || d[u].isInteresting(o, n)) && this._results.push(d[u])
|
|
}
|
|
return this._results.slice()
|
|
}, H.TilemapLayer.prototype.resolveTileset = function(t) {
|
|
var e = this._mc.tilesets;
|
|
if (t < 2e3)
|
|
for (; e.length < t;) e.push(void 0);
|
|
var i = this.map.tiles[t] && this.map.tiles[t][2];
|
|
if (null !== i) { var s = this.map.tilesets[i]; if (s && s.containsTileIndex(t)) return e[t] = s }
|
|
return e[t] = null
|
|
}, H.TilemapLayer.prototype.resetTilesetCache = function() { for (var t = this._mc.tilesets; t.length;) t.pop() }, H.TilemapLayer.prototype.setScale = function(t, e) {
|
|
t = t || 1, e = e || t;
|
|
for (var i = 0; i < this.layer.data.length; i++)
|
|
for (var s = this.layer.data[i], o = 0; o < s.length; o++) {
|
|
var n = s[o];
|
|
n.width = this.map.tileWidth * t, n.height = this.map.tileHeight * e, n.worldX = n.x * n.width, n.worldY = n.y * n.height
|
|
}
|
|
this.scale.setTo(t, e)
|
|
}, H.TilemapLayer.prototype.shiftCanvas = function(t, e, i) {
|
|
var s = t.canvas,
|
|
o = s.width - Math.abs(e),
|
|
n = s.height - Math.abs(i),
|
|
a = 0,
|
|
r = 0,
|
|
h = e,
|
|
l = i;
|
|
e < 0 && (a = -e, h = 0), i < 0 && (r = -i, l = 0);
|
|
var c = this.renderSettings.copyCanvas;
|
|
if (c) {
|
|
(c.width < o || c.height < n) && (c.width = o, c.height = n);
|
|
var p = c.getContext("2d");
|
|
p.clearRect(0, 0, o, n), p.drawImage(s, a, r, o, n, 0, 0, o, n), t.clearRect(h, l, o, n), t.drawImage(c, 0, 0, o, n, h, l, o, n)
|
|
}
|
|
else t.save(), t.globalCompositeOperation = "copy", t.drawImage(s, a, r, o, n, h, l, o, n), t.restore()
|
|
}, H.TilemapLayer.prototype.renderRegion = function(t, e, i, s, o, n) {
|
|
var a = this.context,
|
|
r = this.layer.width,
|
|
h = this.layer.height,
|
|
l = this._mc.tileWidth,
|
|
c = this._mc.tileHeight,
|
|
p = this._mc.tilesets,
|
|
u = NaN;
|
|
this._wrap || (i <= o && (i = Math.max(0, i), o = Math.min(r - 1, o)), s <= n && (s = Math.max(0, s), n = Math.min(h - 1, n)));
|
|
var d, y, g, f, m, v, x = i * l - t,
|
|
b = (i + (1 << 20) * r) % r;
|
|
for (f = (s + (1 << 20) * h) % h, v = n - s, y = s * c - e; 0 <= v; f++, v--, y += c) {
|
|
h <= f && (f -= h);
|
|
var w = this.layer.data[f];
|
|
for (g = b, m = o - i, d = x; 0 <= m; g++, m--, d += l) {
|
|
r <= g && (g -= r);
|
|
var P = w[g];
|
|
if (P && !(P.index < 0)) {
|
|
var _ = P.index,
|
|
T = p[_];
|
|
void 0 === T && (T = this.resolveTileset(_)), P.alpha === u || this.debug || (a.globalAlpha = P.alpha, u = P.alpha), T ? P.rotation || P.flipped ? (a.save(), a.translate(d + P.centerX, y + P.centerY), a.rotate(P.rotation), P.flipped && a.scale(-1, 1), T.draw(a, -P.centerX, -P.centerY, _), a.restore()) : T.draw(a, d, y, _) : this.debugSettings.missingImageFill && (a.fillStyle = this.debugSettings.missingImageFill, a.fillRect(d, y, l, c)), P.debug && this.debugSettings.debuggedTileOverfill && (a.fillStyle = this.debugSettings.debuggedTileOverfill, a.fillRect(d, y, l, c))
|
|
}
|
|
}
|
|
}
|
|
}, H.TilemapLayer.prototype.renderDeltaScroll = function(t, e) {
|
|
var i = this._mc.scrollX,
|
|
s = this._mc.scrollY,
|
|
o = this.canvas.width,
|
|
n = this.canvas.height,
|
|
a = this._mc.tileWidth,
|
|
r = this._mc.tileHeight,
|
|
h = 0,
|
|
l = -a,
|
|
c = 0,
|
|
p = -r;
|
|
if (t < 0 ? (h = o + t, l = o - 1) : 0 < t && (l = t), e < 0 ? (c = n + e, p = n - 1) : 0 < e && (p = e), this.shiftCanvas(this.context, t, e), h = Math.floor((h + i) / a), l = Math.floor((l + i) / a), c = Math.floor((c + s) / r), p = Math.floor((p + s) / r), h <= l) {
|
|
this.context.clearRect(h * a - i, 0, (l - h + 1) * a, n);
|
|
var u = Math.floor((0 + s) / r),
|
|
d = Math.floor((n - 1 + s) / r);
|
|
this.renderRegion(i, s, h, u, l, d)
|
|
}
|
|
if (c <= p) {
|
|
this.context.clearRect(0, c * r - s, o, (p - c + 1) * r);
|
|
var y = Math.floor((0 + i) / a),
|
|
g = Math.floor((o - 1 + i) / a);
|
|
this.renderRegion(i, s, y, c, g, p)
|
|
}
|
|
}, H.TilemapLayer.prototype.renderFull = function() {
|
|
var t = this._mc.scrollX,
|
|
e = this._mc.scrollY,
|
|
i = this.canvas.width,
|
|
s = this.canvas.height,
|
|
o = this._mc.tileWidth,
|
|
n = this._mc.tileHeight,
|
|
a = Math.floor(t / o),
|
|
r = Math.floor((i - 1 + t) / o),
|
|
h = Math.floor(e / n),
|
|
l = Math.floor((s - 1 + e) / n);
|
|
this.context.clearRect(0, 0, i, s), this.renderRegion(t, e, a, h, r, l)
|
|
}, H.TilemapLayer.prototype.render = function() {
|
|
var t = !1;
|
|
if (this.visible) {
|
|
(this.dirty || this.layer.dirty) && (t = !(this.layer.dirty = !1));
|
|
var e = this.canvas.width,
|
|
i = this.canvas.height,
|
|
s = 0 | this._scrollX,
|
|
o = 0 | this._scrollY,
|
|
n = this._mc,
|
|
a = n.scrollX - s,
|
|
r = n.scrollY - o;
|
|
if (t || 0 !== a || 0 !== r || n.renderWidth !== e || n.renderHeight !== i) return this.context.save(), n.scrollX = s, n.scrollY = o, n.renderWidth === e && n.renderHeight === i || (n.renderWidth = e, n.renderHeight = i), this.debug && (this.context.globalAlpha = this.debugSettings.debugAlpha, this.debugSettings.forceFullRedraw && (t = !0)), !t && this.renderSettings.enableScrollDelta && Math.abs(a) + Math.abs(r) < Math.min(e, i) ? this.renderDeltaScroll(a, r) : this.renderFull(), this.debug && (this.context.globalAlpha = 1, this.renderDebug()), this.texture.baseTexture.dirty(), this.dirty = !1, this.context.restore(), !0
|
|
}
|
|
}, H.TilemapLayer.prototype.renderDebug = function() {
|
|
var t, e, i, s, o, n, a = this._mc.scrollX,
|
|
r = this._mc.scrollY,
|
|
h = this.context,
|
|
l = this.canvas.width,
|
|
c = this.canvas.height,
|
|
p = this.layer.width,
|
|
u = this.layer.height,
|
|
d = this._mc.tileWidth,
|
|
y = this._mc.tileHeight,
|
|
g = Math.floor(a / d),
|
|
f = Math.floor((l - 1 + a) / d),
|
|
m = Math.floor(r / y),
|
|
v = Math.floor((c - 1 + r) / y),
|
|
x = g * d - a,
|
|
b = m * y - r,
|
|
w = (g + (1 << 20) * p) % p,
|
|
P = (m + (1 << 20) * u) % u;
|
|
for (h.strokeStyle = this.debugSettings.facingEdgeStroke, s = P, n = v - m, e = b; 0 <= n; s++, n--, e += y) { u <= s && (s -= u); var _ = this.layer.data[s]; for (i = w, o = f - g, t = x; 0 <= o; i++, o--, t += d) { p <= i && (i -= p); var T = _[i];!T || T.index < 0 || !T.collides || (this.debugSettings.collidingTileOverfill && (h.fillStyle = this.debugSettings.collidingTileOverfill, h.fillRect(t, e, this._mc.cw, this._mc.ch)), this.debugSettings.facingEdgeStroke && (h.beginPath(), T.faceTop && (h.moveTo(t, e), h.lineTo(t + this._mc.cw, e)), T.faceBottom && (h.moveTo(t, e + this._mc.ch), h.lineTo(t + this._mc.cw, e + this._mc.ch)), T.faceLeft && (h.moveTo(t, e), h.lineTo(t, e + this._mc.ch)), T.faceRight && (h.moveTo(t + this._mc.cw, e), h.lineTo(t + this._mc.cw, e + this._mc.ch)), h.closePath(), h.stroke())) } }
|
|
}, Object.defineProperty(H.TilemapLayer.prototype, "wrap", { get: function() { return this._wrap }, set: function(t) { this._wrap = t, this.dirty = !0 } }), Object.defineProperty(H.TilemapLayer.prototype, "scrollX", { get: function() { return this._scrollX }, set: function(t) { this._scrollX = t } }), Object.defineProperty(H.TilemapLayer.prototype, "scrollY", { get: function() { return this._scrollY }, set: function(t) { this._scrollY = t } }), Object.defineProperty(H.TilemapLayer.prototype, "collisionWidth", { get: function() { return this._mc.cw }, set: function(t) { this._mc.cw = 0 | t, this.dirty = !0 } }), Object.defineProperty(H.TilemapLayer.prototype, "collisionHeight", { get: function() { return this._mc.ch }, set: function(t) { this._mc.ch = 0 | t, this.dirty = !0 } }), H.TilemapParser = {
|
|
INSERT_NULL: !1,
|
|
parse: function(t, e, i, s, o, n) { if (void 0 === i && (i = 32), void 0 === s && (s = 32), void 0 === o && (o = 10), void 0 === n && (n = 10), void 0 === e) return this.getEmptyData(); if (null === e) return this.getEmptyData(i, s, o, n); var a = t.cache.getTilemapData(e); if (a) { if (a.format === H.Tilemap.CSV) return this.parseCSV(e, a.data, i, s); if (!a.format || a.format === H.Tilemap.TILED_JSON) return this.parseTiledJSON(a.data) } },
|
|
parseCSV: function(t, e, i, s) {
|
|
for (var o = this.getEmptyData(), n = [], a = (e = e.trim()).split("\n"), r = a.length, h = 0, l = 0; l < a.length; l++) {
|
|
n[l] = [];
|
|
for (var c = a[l].split(","), p = 0; p < c.length; p++) n[l][p] = new H.Tile(o.layers[0], parseInt(c[p], 10), p, l, i, s);
|
|
0 === h && (h = c.length)
|
|
}
|
|
return o.format = H.Tilemap.CSV, o.name = t, o.width = h, o.height = r, o.tileWidth = i, o.tileHeight = s, o.widthInPixels = h * i, o.heightInPixels = r * s, o.layers[0].width = h, o.layers[0].height = r, o.layers[0].widthInPixels = o.widthInPixels, o.layers[0].heightInPixels = o.heightInPixels, o.layers[0].data = n, o
|
|
},
|
|
getEmptyData: function(t, e, i, s) { return { width: null != i ? i : 0, height: null != s ? s : 0, tileWidth: null != t ? t : 0, tileHeight: null != e ? e : 0, orientation: "orthogonal", version: "1", properties: {}, widthInPixels: 0, heightInPixels: 0, layers: [{ name: "layer", x: 0, y: 0, width: 0, height: 0, widthInPixels: 0, heightInPixels: 0, alpha: 1, visible: !0, properties: {}, indexes: [], callbacks: [], bodies: [], data: [] }], images: [], objects: {}, collision: {}, tilesets: [], tiles: [] } },
|
|
parseTiledJSON: function(t) {
|
|
if ("orthogonal" !== t.orientation) return null;
|
|
for (var e = { width: t.width, height: t.height, tileWidth: t.tilewidth, tileHeight: t.tileheight, orientation: t.orientation, format: H.Tilemap.TILED_JSON, version: t.version, properties: t.properties, widthInPixels: t.width * t.tilewidth, heightInPixels: t.height * t.tileheight }, i = [], s = 0; s < t.layers.length; s++)
|
|
if ("tilelayer" === t.layers[s].type) {
|
|
var o = t.layers[s];
|
|
if (!o.compression && o.encoding && "base64" === o.encoding) {
|
|
for (var n = window.atob(o.data), a = n.length, r = new Array(a), h = 0; h < a; h += 4) r[h / 4] = (n.charCodeAt(h) | n.charCodeAt(h + 1) << 8 | n.charCodeAt(h + 2) << 16 | n.charCodeAt(h + 3) << 24) >>> 0;
|
|
o.data = r, delete o.encoding
|
|
}
|
|
else if (o.compression) continue;
|
|
var l = { name: o.name, x: o.x, y: o.y, width: o.width, height: o.height, widthInPixels: o.width * t.tilewidth, heightInPixels: o.height * t.tileheight, alpha: o.opacity, visible: o.visible, properties: {}, indexes: [], callbacks: [], bodies: [] };
|
|
o.properties && (l.properties = o.properties);
|
|
var c, p, u, d = 0,
|
|
y = [],
|
|
g = [],
|
|
f = 0;
|
|
for (a = o.data.length; f < a; f++) {
|
|
if (p = !1, u = c = 0, 536870912 < (k = o.data[f])) switch (2147483648 < k && (k -= 2147483648, u += 4), 1073741824 < k && (k -= 1073741824, u += 2), 536870912 < k && (k -= 536870912, u += 1), u) {
|
|
case 5:
|
|
c = Math.PI / 2;
|
|
break;
|
|
case 6:
|
|
c = Math.PI;
|
|
break;
|
|
case 3:
|
|
c = 3 * Math.PI / 2;
|
|
break;
|
|
case 4:
|
|
p = !(c = 0);
|
|
break;
|
|
case 7:
|
|
c = Math.PI / 2, p = !0;
|
|
break;
|
|
case 2:
|
|
c = Math.PI, p = !0;
|
|
break;
|
|
case 1:
|
|
c = 3 * Math.PI / 2, p = !0
|
|
}
|
|
if (0 < k)(B = new H.Tile(l, k, d, g.length, t.tilewidth, t.tileheight)).rotation = c, B.flipped = p, 0 !== u && (B.flippedVal = u), y.push(B);
|
|
else H.TilemapParser.INSERT_NULL ? y.push(null) : y.push(new H.Tile(l, -1, d, g.length, t.tilewidth, t.tileheight));
|
|
++d === o.width && (g.push(y), d = 0, y = [])
|
|
}
|
|
l.data = g, i.push(l)
|
|
}
|
|
e.layers = i;
|
|
var m = [];
|
|
for (s = 0; s < t.layers.length; s++)
|
|
if ("imagelayer" === t.layers[s].type) {
|
|
var v = t.layers[s],
|
|
x = { name: v.name, image: v.image, x: v.x, y: v.y, alpha: v.opacity, visible: v.visible, properties: {} };
|
|
v.properties && (x.properties = v.properties), m.push(x)
|
|
}
|
|
e.images = m;
|
|
var b = [],
|
|
w = [],
|
|
P = null;
|
|
for (s = 0; s < t.tilesets.length; s++) {
|
|
if ((D = t.tilesets[s]).image) {
|
|
var _ = new H.Tileset(D.name, D.firstgid, D.tilewidth, D.tileheight, D.margin, D.spacing, D.properties);
|
|
D.tileproperties && (_.tileProperties = D.tileproperties), _.updateTileData(D.imagewidth, D.imageheight), b.push(_)
|
|
}
|
|
else {
|
|
var T = new H.ImageCollection(D.name, D.firstgid, D.tilewidth, D.tileheight, D.margin, D.spacing, D.properties);
|
|
for (var S in D.tiles) {
|
|
x = D.tiles[S].image;
|
|
var k = D.firstgid + parseInt(S, 10);
|
|
T.addImage(k, x)
|
|
}
|
|
w.push(T)
|
|
}
|
|
P && (P.lastgid = D.firstgid - 1), P = D
|
|
}
|
|
e.tilesets = b, e.imagecollections = w;
|
|
var B, A, C = {},
|
|
I = {};
|
|
|
|
function E(t, e) {
|
|
var i = {};
|
|
for (var s in e) {
|
|
var o = e[s];
|
|
void 0 !== t[o] && (i[o] = t[o])
|
|
}
|
|
return i
|
|
}
|
|
for (s = 0; s < t.layers.length; s++)
|
|
if ("objectgroup" === t.layers[s].type) {
|
|
var O = t.layers[s];
|
|
C[O.name] = [], I[O.name] = [];
|
|
var M = 0;
|
|
for (a = O.objects.length; M < a; M++)
|
|
if (O.objects[M].gid) {
|
|
var L = { gid: O.objects[M].gid, name: O.objects[M].name, type: O.objects[M].hasOwnProperty("type") ? O.objects[M].type : "", x: O.objects[M].x, y: O.objects[M].y, visible: O.objects[M].visible, properties: O.objects[M].properties };
|
|
O.objects[M].rotation && (L.rotation = O.objects[M].rotation), C[O.name].push(L)
|
|
}
|
|
else if (O.objects[M].polyline) {
|
|
L = { name: O.objects[M].name, type: O.objects[M].type, x: O.objects[M].x, y: O.objects[M].y, width: O.objects[M].width, height: O.objects[M].height, visible: O.objects[M].visible, properties: O.objects[M].properties };
|
|
O.objects[M].rotation && (L.rotation = O.objects[M].rotation), L.polyline = [];
|
|
for (var R = 0; R < O.objects[M].polyline.length; R++) L.polyline.push([O.objects[M].polyline[R].x, O.objects[M].polyline[R].y]);
|
|
I[O.name].push(L), C[O.name].push(L)
|
|
}
|
|
else if (O.objects[M].polygon) {
|
|
(L = E(O.objects[M], ["name", "type", "x", "y", "visible", "rotation", "properties"])).polygon = [];
|
|
for (R = 0; R < O.objects[M].polygon.length; R++) L.polygon.push([O.objects[M].polygon[R].x, O.objects[M].polygon[R].y]);
|
|
C[O.name].push(L)
|
|
}
|
|
else if (O.objects[M].ellipse) {
|
|
L = E(O.objects[M], ["name", "type", "ellipse", "x", "y", "width", "height", "visible", "rotation", "properties"]);
|
|
C[O.name].push(L)
|
|
}
|
|
else {
|
|
(L = E(O.objects[M], ["name", "type", "x", "y", "width", "height", "visible", "rotation", "properties"])).rectangle = !0, C[O.name].push(L)
|
|
}
|
|
}
|
|
e.objects = C, e.collision = I, e.tiles = [];
|
|
for (s = 0; s < e.tilesets.length; s++) {
|
|
d = (D = e.tilesets[s]).tileMargin;
|
|
var D, F = D.tileMargin,
|
|
U = 0,
|
|
G = 0,
|
|
N = 0;
|
|
for (f = D.firstgid; f < D.firstgid + D.total && (e.tiles[f] = [d, F, s], d += D.tileWidth + D.tileSpacing, ++U !== D.total) && (++G !== D.columns || (d = D.tileMargin, F += D.tileHeight + D.tileSpacing, G = 0, ++N !== D.rows)); f++);
|
|
}
|
|
for (s = 0; s < e.layers.length; s++) { l = e.layers[s], D = null; for (h = 0; h < l.data.length; h++) { y = l.data[h]; for (var V = 0; V < y.length; V++) null === (B = y[V]) || B.index < 0 || (A = e.tiles[B.index][2], (D = e.tilesets[A]).tileProperties && D.tileProperties[B.index - D.firstgid] && (B.properties = H.Utils.mixin(D.tileProperties[B.index - D.firstgid], B.properties))) } }
|
|
return e
|
|
}
|
|
}, H.Tileset = function(t, e, i, s, o, n, a) {
|
|
(void 0 === i || i <= 0) && (i = 32), (void 0 === s || s <= 0) && (s = 32), void 0 === o && (o = 0), void 0 === n && (n = 0), this.name = t, this.firstgid = 0 | e, this.tileWidth = 0 | i, this.tileHeight = 0 | s, this.tileMargin = 0 | o, this.tileSpacing = 0 | n, this.properties = a || {}, this.image = null, this.rows = 0, this.columns = 0, this.total = 0, this.drawCoords = []
|
|
}, H.Tileset.prototype = {
|
|
draw: function(t, e, i, s) {
|
|
var o = s - this.firstgid << 1;
|
|
0 <= o && o + 1 < this.drawCoords.length && t.drawImage(this.image, this.drawCoords[o], this.drawCoords[o + 1], this.tileWidth, this.tileHeight, e, i, this.tileWidth, this.tileHeight)
|
|
},
|
|
containsTileIndex: function(t) { return t >= this.firstgid && t < this.firstgid + this.total },
|
|
setImage: function(t) { this.image = t, this.updateTileData(t.width, t.height) },
|
|
setSpacing: function(t, e) { this.tileMargin = 0 | t, this.tileSpacing = 0 | e, this.image && this.updateTileData(this.image.width, this.image.height) },
|
|
updateTileData: function(t, e) {
|
|
var i = (e - 2 * this.tileMargin + this.tileSpacing) / (this.tileHeight + this.tileSpacing),
|
|
s = (t - 2 * this.tileMargin + this.tileSpacing) / (this.tileWidth + this.tileSpacing);
|
|
i = Math.floor(i), s = Math.floor(s), this.rows && this.rows !== i || this.columns && this.columns, this.rows = i, this.columns = s, this.total = i * s, this.drawCoords.length = 0;
|
|
for (var o = this.tileMargin, n = this.tileMargin, a = 0; a < this.rows; a++) {
|
|
for (var r = 0; r < this.columns; r++) this.drawCoords.push(o), this.drawCoords.push(n), o += this.tileWidth + this.tileSpacing;
|
|
o = this.tileMargin, n += this.tileHeight + this.tileSpacing
|
|
}
|
|
}
|
|
}, H.Tileset.prototype.constructor = H.Tileset, H.Particle = function(t, e, i, s, o) { H.Sprite.call(this, t, e, i, s, o), this.autoScale = !1, this.scaleData = null, this._s = 0, this.autoAlpha = !1, this.alphaData = null, this._a = 0 }, H.Particle.prototype = Object.create(H.Sprite.prototype), H.Particle.prototype.constructor = H.Particle, H.Particle.prototype.update = function() { this.autoScale && (this._s--, this._s ? this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y) : this.autoScale = !1), this.autoAlpha && (this._a--, this._a ? this.alpha = this.alphaData[this._a].v : this.autoAlpha = !1) }, H.Particle.prototype.onEmit = function() {}, H.Particle.prototype.setAlphaData = function(t) { this.alphaData = t, this._a = t.length - 1, this.alpha = this.alphaData[this._a].v, this.autoAlpha = !0 }, H.Particle.prototype.setScaleData = function(t) { this.scaleData = t, this._s = t.length - 1, this.scale.set(this.scaleData[this._s].x, this.scaleData[this._s].y), this.autoScale = !0 }, H.Particle.prototype.reset = function(t, e, i) { return H.Component.Reset.prototype.reset.call(this, t, e, i), this.alpha = 1, this.scale.set(1), this.autoScale = !1, this.autoAlpha = !1, this }, H.Particles = function(t) { this.game = t, this.emitters = {}, this.ID = 0 }, H.Particles.prototype = { add: function(t) { return this.emitters[t.name] = t }, remove: function(t) { delete this.emitters[t.name] }, update: function() { for (var t in this.emitters) this.emitters[t].exists && this.emitters[t].update() } }, H.Particles.prototype.constructor = H.Particles, H.Particles.Arcade = {}, H.Particles.Arcade.Emitter = function(t, e, i, s) { this.maxParticles = s || 50, H.Group.call(this, t), this.name = "emitter" + this.game.particles.ID++, this.type = H.EMITTER, this.physicsType = H.GROUP, this.area = new H.Rectangle(e, i, 1, 1), this.minParticleSpeed = new H.Point(-100, -100), this.maxParticleSpeed = new H.Point(100, 100), this.minParticleScale = 1, this.maxParticleScale = 1, this.scaleData = null, this.minRotation = -360, this.maxRotation = 360, this.minParticleAlpha = 1, this.maxParticleAlpha = 1, this.alphaData = null, this.gravity = 100, this.particleClass = H.Particle, this.particleDrag = new H.Point, this.angularDrag = 0, this.frequency = 100, this.lifespan = 2e3, this.bounce = new H.Point, this.on = !1, this.particleAnchor = new H.Point(.5, .5), this.blendMode = H.blendModes.NORMAL, this.emitX = e, this.emitY = i, this.autoScale = !1, this.autoAlpha = !1, this.particleBringToTop = !1, this.particleSendToBack = !1, this._minParticleScale = new H.Point(1, 1), this._maxParticleScale = new H.Point(1, 1), this._quantity = 0, this._timer = 0, this._counter = 0, this._flowQuantity = 0, this._flowTotal = 0, this._explode = !0, this._frames = null }, H.Particles.Arcade.Emitter.prototype = Object.create(H.Group.prototype), H.Particles.Arcade.Emitter.prototype.constructor = H.Particles.Arcade.Emitter, H.Particles.Arcade.Emitter.prototype.update = function() {
|
|
if (this.on && this.game.time.time >= this._timer)
|
|
if (this._timer = this.game.time.time + this.frequency * this.game.time.slowMotion, 0 !== this._flowTotal)
|
|
if (0 < this._flowQuantity) {
|
|
for (var t = 0; t < this._flowQuantity; t++)
|
|
if (this.emitParticle() && (this._counter++, -1 !== this._flowTotal && this._counter >= this._flowTotal)) { this.on = !1; break }
|
|
}
|
|
else this.emitParticle() && (this._counter++, -1 !== this._flowTotal && this._counter >= this._flowTotal && (this.on = !1));
|
|
else this.emitParticle() && (this._counter++, 0 < this._quantity && this._counter >= this._quantity && (this.on = !1));
|
|
for (t = this.children.length; t--;) this.children[t].exists && this.children[t].update()
|
|
}, H.Particles.Arcade.Emitter.prototype.makeParticles = function(t, e, i, s, o) {
|
|
var n;
|
|
void 0 === e && (e = 0), void 0 === i && (i = this.maxParticles), void 0 === s && (s = !1), void 0 === o && (o = !1);
|
|
var a = 0,
|
|
r = t,
|
|
h = e;
|
|
for (this._frames = e, i > this.maxParticles && (this.maxParticles = i); a < i;) Array.isArray(t) && (r = this.game.rnd.pick(t)), Array.isArray(e) && (h = this.game.rnd.pick(e)), n = new this.particleClass(this.game, 0, 0, r, h), this.game.physics.arcade.enable(n, !1), n.body.checkCollision.none = !s || !(n.body.checkCollision.any = !0), n.body.collideWorldBounds = o, n.body.skipQuadTree = !0, n.exists = !1, n.visible = !1, n.anchor.copyFrom(this.particleAnchor), this.add(n), a++;
|
|
return this
|
|
}, H.Particles.Arcade.Emitter.prototype.kill = function() { return this.on = !1, this.alive = !1, this.exists = !1, this }, H.Particles.Arcade.Emitter.prototype.revive = function() { return this.alive = !0, this.exists = !0, this }, H.Particles.Arcade.Emitter.prototype.explode = function(t, e) { return this._flowTotal = 0, this.start(!0, t, 0, e, !1), this }, H.Particles.Arcade.Emitter.prototype.flow = function(t, e, i, s, o) { return void 0 !== i && 0 !== i || (i = 1), void 0 === s && (s = -1), void 0 === o && (o = !0), i > this.maxParticles && (i = this.maxParticles), this._counter = 0, this._flowQuantity = i, this._flowTotal = s, o ? (this.start(!0, t, e, i), this._counter += i, this.on = !0, this._timer = this.game.time.time + e * this.game.time.slowMotion) : this.start(!1, t, e, i), this }, H.Particles.Arcade.Emitter.prototype.start = function(t, e, i, s, o) {
|
|
if (void 0 === t && (t = !0), void 0 === e && (e = 0), null == i && (i = 250), void 0 === s && (s = 0), void 0 === o && (o = !1), s > this.maxParticles && (s = this.maxParticles), this.revive(), this.visible = !0, this.lifespan = e, this.frequency = i, t || o)
|
|
for (var n = 0; n < s; n++) this.emitParticle();
|
|
else this.on = !0, this._quantity = s, this._counter = 0, this._timer = this.game.time.time + i * this.game.time.slowMotion;
|
|
return this
|
|
}, H.Particles.Arcade.Emitter.prototype.emitParticle = function(t, e, i, s) {
|
|
void 0 === t && (t = null), void 0 === e && (e = null);
|
|
var o = this.getFirstExists(!1);
|
|
if (null === o) return !1;
|
|
var n = this.game.rnd;
|
|
void 0 !== i && void 0 !== s ? o.loadTexture(i, s) : void 0 !== i && o.loadTexture(i);
|
|
var a = this.emitX,
|
|
r = this.emitY;
|
|
null !== t ? a = t : 1 < this.width && (a = n.between(this.left, this.right)), null !== e ? r = e : 1 < this.height && (r = n.between(this.top, this.bottom)), o.reset(a, r), o.angle = 0, o.lifespan = this.lifespan, this.particleBringToTop ? this.bringToTop(o) : this.particleSendToBack && this.sendToBack(o), this.autoScale ? o.setScaleData(this.scaleData) : 1 !== this.minParticleScale || 1 !== this.maxParticleScale ? o.scale.set(n.realInRange(this.minParticleScale, this.maxParticleScale)) : this._minParticleScale.x === this._maxParticleScale.x && this._minParticleScale.y === this._maxParticleScale.y || o.scale.set(n.realInRange(this._minParticleScale.x, this._maxParticleScale.x), n.realInRange(this._minParticleScale.y, this._maxParticleScale.y)), void 0 === s && (Array.isArray(this._frames) ? o.frame = this.game.rnd.pick(this._frames) : o.frame = this._frames), this.autoAlpha ? o.setAlphaData(this.alphaData) : o.alpha = n.realInRange(this.minParticleAlpha, this.maxParticleAlpha), o.blendMode = this.blendMode;
|
|
var h = o.body;
|
|
return h.updateBounds(), h.bounce.copyFrom(this.bounce), h.drag.copyFrom(this.particleDrag), h.velocity.x = n.between(this.minParticleSpeed.x, this.maxParticleSpeed.x), h.velocity.y = n.between(this.minParticleSpeed.y, this.maxParticleSpeed.y), h.angularVelocity = n.between(this.minRotation, this.maxRotation), h.gravity.y = this.gravity, h.angularDrag = this.angularDrag, o.onEmit(), !0
|
|
}, H.Particles.Arcade.Emitter.prototype.destroy = function() { this.game.particles.remove(this), H.Group.prototype.destroy.call(this, !0, !1) }, H.Particles.Arcade.Emitter.prototype.setSize = function(t, e) { return this.area.width = t, this.area.height = e, this }, H.Particles.Arcade.Emitter.prototype.setXSpeed = function(t, e) { return t = t || 0, e = e || 0, this.minParticleSpeed.x = t, this.maxParticleSpeed.x = e, this }, H.Particles.Arcade.Emitter.prototype.setYSpeed = function(t, e) { return t = t || 0, e = e || 0, this.minParticleSpeed.y = t, this.maxParticleSpeed.y = e, this }, H.Particles.Arcade.Emitter.prototype.setRotation = function(t, e) { return t = t || 0, e = e || 0, this.minRotation = t, this.maxRotation = e, this }, H.Particles.Arcade.Emitter.prototype.setAlpha = function(t, e, i, s, o) {
|
|
if (void 0 === t && (t = 1), void 0 === e && (e = 1), void 0 === i && (i = 0), void 0 === s && (s = H.Easing.Linear.None), void 0 === o && (o = !1), this.minParticleAlpha = t, this.maxParticleAlpha = e, this.autoAlpha = !1, 0 < i && t !== e) {
|
|
var n = { v: t },
|
|
a = this.game.make.tween(n).to({ v: e }, i, s);
|
|
a.yoyo(o), this.alphaData = a.generateData(60), this.alphaData.reverse(), this.autoAlpha = !0
|
|
}
|
|
return this
|
|
}, H.Particles.Arcade.Emitter.prototype.setScale = function(t, e, i, s, o, n, a) {
|
|
if (void 0 === t && (t = 1), void 0 === e && (e = 1), void 0 === i && (i = 1), void 0 === s && (s = 1), void 0 === o && (o = 0), void 0 === n && (n = H.Easing.Linear.None), void 0 === a && (a = !1), this.minParticleScale = 1, this.maxParticleScale = 1, this._minParticleScale.set(t, i), this._maxParticleScale.set(e, s), this.autoScale = !1, 0 < o && (t !== e || i !== s)) {
|
|
var r = { x: t, y: i },
|
|
h = this.game.make.tween(r).to({ x: e, y: s }, o, n);
|
|
h.yoyo(a), this.scaleData = h.generateData(60), this.scaleData.reverse(), this.autoScale = !0
|
|
}
|
|
return this
|
|
}, H.Particles.Arcade.Emitter.prototype.at = function(t) { return t.center ? (this.emitX = t.center.x, this.emitY = t.center.y) : (this.emitX = t.world.x + t.anchor.x * t.width, this.emitY = t.world.y + t.anchor.y * t.height), this }, Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "width", { get: function() { return this.area.width }, set: function(t) { this.area.width = t } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "height", { get: function() { return this.area.height }, set: function(t) { this.area.height = t } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "x", { get: function() { return this.emitX }, set: function(t) { this.emitX = t } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "y", { get: function() { return this.emitY }, set: function(t) { this.emitY = t } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "left", { get: function() { return Math.floor(this.x - this.area.width / 2) } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "right", { get: function() { return Math.floor(this.x + this.area.width / 2) } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "top", { get: function() { return Math.floor(this.y - this.area.height / 2) } }), Object.defineProperty(H.Particles.Arcade.Emitter.prototype, "bottom", { get: function() { return Math.floor(this.y + this.area.height / 2) } }), H.Weapon = function(t, e) { H.Plugin.call(this, t, e), this.bullets = null, this.autoExpandBulletsGroup = !1, this.autofire = !1, this.shots = 0, this.fireLimit = 0, this.fireRate = 100, this.fireRateVariance = 0, this.fireFrom = new H.Rectangle(0, 0, 1, 1), this.fireAngle = H.ANGLE_UP, this.bulletInheritSpriteSpeed = !1, this.bulletAnimation = "", this.bulletFrameRandom = !1, this.bulletFrameCycle = !1, this.bulletWorldWrap = !1, this.bulletWorldWrapPadding = 0, this.bulletAngleOffset = 0, this.bulletAngleVariance = 0, this.bulletSpeed = 200, this.bulletSpeedVariance = 0, this.bulletLifespan = 0, this.bulletKillDistance = 0, this.bulletGravity = new H.Point(0, 0), this.bulletRotateToVelocity = !1, this.bulletKey = "", this.bulletFrame = "", this._bulletClass = H.Bullet, this._bulletCollideWorldBounds = !1, this._bulletKillType = H.Weapon.KILL_WORLD_BOUNDS, this._data = { customBody: !1, width: 0, height: 0, offsetX: 0, offsetY: 0 }, this.bounds = new H.Rectangle, this.bulletBounds = t.world.bounds, this.bulletFrames = [], this.bulletFrameIndex = 0, this.anims = {}, this.onFire = new H.Signal, this.onKill = new H.Signal, this.onFireLimit = new H.Signal, this.trackedSprite = null, this.trackedPointer = null, this.trackRotation = !1, this.trackOffset = new H.Point, this._nextFire = 0, this._rotatedPoint = new H.Point }, H.Weapon.prototype = Object.create(H.Plugin.prototype), H.Weapon.prototype.constructor = H.Weapon, H.Weapon.KILL_NEVER = 0, H.Weapon.KILL_LIFESPAN = 1, H.Weapon.KILL_DISTANCE = 2, H.Weapon.KILL_WEAPON_BOUNDS = 3, H.Weapon.KILL_CAMERA_BOUNDS = 4, H.Weapon.KILL_WORLD_BOUNDS = 5, H.Weapon.KILL_STATIC_BOUNDS = 6, H.Weapon.prototype.createBullets = function(t, e, i, s) { return void 0 === t && (t = 1), void 0 === s && (s = this.game.world), this.bullets || (this.bullets = this.game.add.physicsGroup(H.Physics.ARCADE, s), this.bullets.classType = this._bulletClass), 0 !== t && (-1 === t && (this.autoExpandBulletsGroup = !0, t = 1), this.bullets.createMultiple(t, e, i), this.bullets.setAll("data.bulletManager", this), this.bulletKey = e, this.bulletFrame = i), this }, H.Weapon.prototype.forEach = function(t, e) { return this.bullets.forEachExists(t, e, arguments), this }, H.Weapon.prototype.pauseAll = function() { return this.bullets.setAll("body.enable", !1), this }, H.Weapon.prototype.resumeAll = function() { return this.bullets.setAll("body.enable", !0), this }, H.Weapon.prototype.killAll = function() { return this.bullets.callAllExists("kill", !0), this.bullets.setAll("body.enable", !0), this }, H.Weapon.prototype.resetShots = function(t) { return void(this.shots = 0) !== t && (this.fireLimit = t), this }, H.Weapon.prototype.destroy = function() { this.parent.remove(this, !1), this.bullets.destroy(), this.game = null, this.parent = null, this.active = !1, this.visible = !1 }, H.Weapon.prototype.update = function() { this._bulletKillType === H.Weapon.KILL_WEAPON_BOUNDS && (this.trackedSprite ? (this.trackedSprite.updateTransform(), this.bounds.centerOn(this.trackedSprite.worldPosition.x, this.trackedSprite.worldPosition.y)) : this.trackedPointer && this.bounds.centerOn(this.trackedPointer.worldX, this.trackedPointer.worldY)), this.autofire && this.fire() }, H.Weapon.prototype.trackSprite = function(t, e, i, s) { return void 0 === e && (e = 0), void 0 === i && (i = 0), void 0 === s && (s = !1), this.trackedPointer = null, this.trackedSprite = t, this.trackRotation = s, this.trackOffset.set(e, i), this }, H.Weapon.prototype.trackPointer = function(t, e, i) { return void 0 === t && (t = this.game.input.activePointer), void 0 === e && (e = 0), void 0 === i && (i = 0), this.trackedPointer = t, this.trackedSprite = null, this.trackRotation = !1, this.trackOffset.set(e, i), this }, H.Weapon.prototype.fire = function(t, e, i) {
|
|
if (this.game.time.now < this._nextFire || 0 < this.fireLimit && this.shots === this.fireLimit) return !1;
|
|
var s = this.bulletSpeed;
|
|
0 !== this.bulletSpeedVariance && (s += H.Math.between(-this.bulletSpeedVariance, this.bulletSpeedVariance)), t ? 1 < this.fireFrom.width ? this.fireFrom.centerOn(t.x, t.y) : (this.fireFrom.x = t.x, this.fireFrom.y = t.y) : this.trackedSprite ? (this.trackRotation ? (this._rotatedPoint.set(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y), this._rotatedPoint.rotate(this.trackedSprite.world.x, this.trackedSprite.world.y, this.trackedSprite.rotation), 1 < this.fireFrom.width ? this.fireFrom.centerOn(this._rotatedPoint.x, this._rotatedPoint.y) : (this.fireFrom.x = this._rotatedPoint.x, this.fireFrom.y = this._rotatedPoint.y)) : 1 < this.fireFrom.width ? this.fireFrom.centerOn(this.trackedSprite.world.x + this.trackOffset.x, this.trackedSprite.world.y + this.trackOffset.y) : (this.fireFrom.x = this.trackedSprite.world.x + this.trackOffset.x, this.fireFrom.y = this.trackedSprite.world.y + this.trackOffset.y), this.bulletInheritSpriteSpeed && (s += this.trackedSprite.body.speed)) : this.trackedPointer && (1 < this.fireFrom.width ? this.fireFrom.centerOn(this.trackedPointer.world.x + this.trackOffset.x, this.trackedPointer.world.y + this.trackOffset.y) : (this.fireFrom.x = this.trackedPointer.world.x + this.trackOffset.x, this.fireFrom.y = this.trackedPointer.world.y + this.trackOffset.y));
|
|
var o = 1 < this.fireFrom.width ? this.fireFrom.randomX : this.fireFrom.x,
|
|
n = 1 < this.fireFrom.height ? this.fireFrom.randomY : this.fireFrom.y,
|
|
a = this.trackRotation ? this.trackedSprite.angle : this.fireAngle;
|
|
void 0 !== e && void 0 !== i && (a = this.game.math.radToDeg(Math.atan2(i - n, e - o))), 0 !== this.bulletAngleVariance && (a += H.Math.between(-this.bulletAngleVariance, this.bulletAngleVariance));
|
|
var r = 0,
|
|
h = 0;
|
|
0 === a || 180 === a ? r = Math.cos(this.game.math.degToRad(a)) * s : h = (90 === a || 270 === a || (r = Math.cos(this.game.math.degToRad(a)) * s), Math.sin(this.game.math.degToRad(a)) * s);
|
|
var l = null;
|
|
if (this.autoExpandBulletsGroup ? (l = this.bullets.getFirstExists(!1, !0, o, n, this.bulletKey, this.bulletFrame)).data.bulletManager = this : l = this.bullets.getFirstExists(!1), l) {
|
|
if (l.reset(o, n), l.data.fromX = o, l.data.fromY = n, l.data.killType = this.bulletKillType, l.data.killDistance = this.bulletKillDistance, l.data.rotateToVelocity = this.bulletRotateToVelocity, this.bulletKillType === H.Weapon.KILL_LIFESPAN && (l.lifespan = this.bulletLifespan), l.angle = a + this.bulletAngleOffset, "" !== this.bulletAnimation) {
|
|
if (null === l.animations.getAnimation(this.bulletAnimation)) {
|
|
var c = this.anims[this.bulletAnimation];
|
|
l.animations.add(c.name, c.frames, c.frameRate, c.loop, c.useNumericIndex)
|
|
}
|
|
l.animations.play(this.bulletAnimation)
|
|
}
|
|
else this.bulletFrameCycle ? (l.frame = this.bulletFrames[this.bulletFrameIndex], this.bulletFrameIndex++, this.bulletFrameIndex >= this.bulletFrames.length && (this.bulletFrameIndex = 0)) : this.bulletFrameRandom && (l.frame = this.bulletFrames[Math.floor(Math.random() * this.bulletFrames.length)]);
|
|
if (l.data.bodyDirty && (this._data.customBody && l.body.setSize(this._data.width, this._data.height, this._data.offsetX, this._data.offsetY), l.body.collideWorldBounds = this.bulletCollideWorldBounds, l.data.bodyDirty = !1), l.body.velocity.set(r, h), l.body.gravity.set(this.bulletGravity.x, this.bulletGravity.y), 0 !== this.bulletSpeedVariance) {
|
|
var p = this.fireRate;
|
|
(p += H.Math.between(-this.fireRateVariance, this.fireRateVariance)) < 0 && (p = 0), this._nextFire = this.game.time.now + p
|
|
}
|
|
else this._nextFire = this.game.time.now + this.fireRate;
|
|
this.shots++, this.onFire.dispatch(l, this, s), 0 < this.fireLimit && this.shots === this.fireLimit && this.onFireLimit.dispatch(this, this.fireLimit)
|
|
}
|
|
return l
|
|
}, H.Weapon.prototype.fireAtPointer = function(t) { return void 0 === t && (t = this.game.input.activePointer), this.fire(null, t.worldX, t.worldY) }, H.Weapon.prototype.fireAtSprite = function(t) { return this.fire(null, t.world.x, t.world.y) }, H.Weapon.prototype.fireAtXY = function(t, e) { return this.fire(null, t, e) }, H.Weapon.prototype.setBulletBodyOffset = function(t, e, i, s) { return void 0 === i && (i = 0), void 0 === s && (s = 0), this._data.customBody = !0, this._data.width = t, this._data.height = e, this._data.offsetX = i, this._data.offsetY = s, this.bullets.callAll("body.setSize", "body", t, e, i, s), this.bullets.setAll("data.bodyDirty", !1), this }, H.Weapon.prototype.setBulletFrames = function(t, e, i, s) { return void 0 === i && (i = !0), void 0 === s && (s = !1), this.bulletFrames = H.ArrayUtils.numberArray(t, e), this.bulletFrameIndex = 0, this.bulletFrameCycle = i, this.bulletFrameRandom = s, this }, H.Weapon.prototype.addBulletAnimation = function(t, e, i, s, o) { return this.anims[t] = { name: t, frames: e, frameRate: i, loop: s, useNumericIndex: o }, this.bullets.callAll("animations.add", "animations", t, e, i, s, o), this.bulletAnimation = t, this }, H.Weapon.prototype.debug = function(t, e, i) { void 0 === t && (t = 16), void 0 === e && (e = 32), void 0 === i && (i = !1), this.game.debug.text("Weapon Plugin", t, e), this.game.debug.text("Bullets Alive: " + this.bullets.total + " - Total: " + this.bullets.length, t, e + 24), i && this.bullets.forEachExists(this.game.debug.body, this.game.debug, "rgba(255, 0, 255, 0.8)") }, Object.defineProperty(H.Weapon.prototype, "bulletClass", { get: function() { return this._bulletClass }, set: function(t) { this._bulletClass = t, this.bullets.classType = this._bulletClass } }), Object.defineProperty(H.Weapon.prototype, "bulletKillType", {
|
|
get: function() { return this._bulletKillType },
|
|
set: function(t) {
|
|
switch (t) {
|
|
case H.Weapon.KILL_STATIC_BOUNDS:
|
|
case H.Weapon.KILL_WEAPON_BOUNDS:
|
|
this.bulletBounds = this.bounds;
|
|
break;
|
|
case H.Weapon.KILL_CAMERA_BOUNDS:
|
|
this.bulletBounds = this.game.camera.view;
|
|
break;
|
|
case H.Weapon.KILL_WORLD_BOUNDS:
|
|
this.bulletBounds = this.game.world.bounds
|
|
}
|
|
this._bulletKillType = t
|
|
}
|
|
}), Object.defineProperty(H.Weapon.prototype, "bulletCollideWorldBounds", { get: function() { return this._bulletCollideWorldBounds }, set: function(t) { this._bulletCollideWorldBounds = t, this.bullets.setAll("body.collideWorldBounds", t), this.bullets.setAll("data.bodyDirty", !1) } }), Object.defineProperty(H.Weapon.prototype, "x", { get: function() { return this.fireFrom.x }, set: function(t) { this.fireFrom.x = t } }), Object.defineProperty(H.Weapon.prototype, "y", { get: function() { return this.fireFrom.y }, set: function(t) { this.fireFrom.y = t } }), H.Bullet = function(t, e, i, s, o) { H.Sprite.call(this, t, e, i, s, o), this.anchor.set(.5), this.data = { bulletManager: null, fromX: 0, fromY: 0, bodyDirty: !0, rotateToVelocity: !1, killType: 0, killDistance: 0 } }, H.Bullet.prototype = Object.create(H.Sprite.prototype), H.Bullet.prototype.constructor = H.Bullet, H.Bullet.prototype.kill = function() { return this.alive = !1, this.exists = !1, this.visible = !1, this.data.bulletManager.onKill.dispatch(this), this }, H.Bullet.prototype.update = function() { this.exists && (this.data.killType > H.Weapon.KILL_LIFESPAN && (this.data.killType === H.Weapon.KILL_DISTANCE ? this.game.physics.arcade.distanceToXY(this, this.data.fromX, this.data.fromY, !0) > this.data.killDistance && this.kill() : this.data.bulletManager.bulletBounds.intersects(this) || this.kill()), this.data.rotateToVelocity && (this.rotation = Math.atan2(this.body.velocity.y, this.body.velocity.x)), this.data.bulletManager.bulletWorldWrap && this.game.world.wrap(this, this.data.bulletManager.bulletWorldWrapPadding)) }, H.Video = function(t, e, i) {
|
|
if (void 0 === e && (e = null), void 0 === i && (i = null), this.game = t, this.key = e, this.width = 0, this.height = 0, this.type = H.VIDEO, this.disableTextureUpload = !1, this.touchLocked = !1, this.onPlay = new H.Signal, this.onChangeSource = new H.Signal, this.onComplete = new H.Signal, this.onAccess = new H.Signal, this.onError = new H.Signal, this.onTimeout = new H.Signal, this.timeout = 15e3, this._timeOutID = null, this.video = null, this.videoStream = null, this.isStreaming = !1, this.retryLimit = 20, this.retry = 0, this.retryInterval = 500, this._retryID = null, this._codeMuted = !1, this._muted = !1, this._codePaused = !1, this._paused = !1, this._pending = !1, this._autoplay = !1, this._endCallback = null, this._playCallback = null, e && this.game.cache.checkVideoKey(e)) {
|
|
var s = this.game.cache.getVideo(e);
|
|
s.isBlob ? this.createVideoFromBlob(s.data) : this.video = s.data, this.width = this.video.videoWidth, this.height = this.video.videoHeight
|
|
}
|
|
else i && this.createVideoFromURL(i, !1);
|
|
this.video && !i ? this.baseTexture = new PIXI.BaseTexture(this.video) : this.baseTexture = new PIXI.BaseTexture(H.Cache.DEFAULT.baseTexture.source), this.baseTexture.forceLoaded(this.width, this.height), this.texture = new PIXI.Texture(this.baseTexture), this.textureFrame = new H.Frame(0, 0, 0, this.width, this.height, "video"), this.texture.setFrame(this.textureFrame), this.texture.valid = !1, null !== e && this.video && (this.texture.valid = this.video.canplay), this.snapshot = null, H.BitmapData && (this.snapshot = new H.BitmapData(this.game, "", this.width, this.height)), !this.game.device.cocoonJS && (this.game.device.iOS || this.game.device.chrome) || window.PhaserGlobal && window.PhaserGlobal.fakeiOSTouchLock ? this.setTouchLock() : s && (s.locked = !1)
|
|
}, H.Video.prototype = {
|
|
connectToMediaStream: function(t, e) { return t && e && (this.video = t, this.videoStream = e, this.isStreaming = !0, this.baseTexture.source = this.video, this.updateTexture(null, this.video.videoWidth, this.video.videoHeight), this.onAccess.dispatch(this)), this },
|
|
startMediaStream: function(t, e, i) {
|
|
if (void 0 === t && (t = !1), void 0 === e && (e = null), void 0 === i && (i = null), !this.game.device.getUserMedia) return this.onError.dispatch(this, "No getUserMedia"), !1;
|
|
null !== this.videoStream && (this.videoStream.active ? this.videoStream.active = !1 : this.videoStream.stop()), this.removeVideoElement(), this.video = document.createElement("video"), this.video.setAttribute("autoplay", "autoplay"), null !== e && (this.video.width = e), null !== i && (this.video.height = i), this._timeOutID = window.setTimeout(this.getUserMediaTimeout.bind(this), this.timeout);
|
|
try { navigator.getUserMedia({ audio: t, video: !0 }, this.getUserMediaSuccess.bind(this), this.getUserMediaError.bind(this)) }
|
|
catch (t) { this.getUserMediaError(t) }
|
|
return this
|
|
},
|
|
getUserMediaTimeout: function() { clearTimeout(this._timeOutID), this.onTimeout.dispatch(this) },
|
|
getUserMediaError: function(t) { clearTimeout(this._timeOutID), this.onError.dispatch(this, t) },
|
|
getUserMediaSuccess: function(t) {
|
|
clearTimeout(this._timeOutID), this.videoStream = t, void 0 !== this.video.mozSrcObject ? this.video.mozSrcObject = t : this.video.src = window.URL && window.URL.createObjectURL(t) || t;
|
|
var o = this;
|
|
this.video.onloadeddata = function() {
|
|
var s = 10;
|
|
! function t() {
|
|
if (0 < s)
|
|
if (0 < o.video.videoWidth) {
|
|
var e = o.video.videoWidth,
|
|
i = o.video.videoHeight;
|
|
isNaN(o.video.videoHeight) && (i = e / (4 / 3)), o.video.play(), o.isStreaming = !0, o.baseTexture.source = o.video, o.updateTexture(null, e, i), o.onAccess.dispatch(o)
|
|
}
|
|
else window.setTimeout(t, 500);
|
|
s--
|
|
}()
|
|
}
|
|
},
|
|
createVideoFromBlob: function(t) { var e = this; return this.video = document.createElement("video"), this.video.controls = !1, this.video.setAttribute("autoplay", "autoplay"), this.video.addEventListener("loadeddata", function(t) { e.updateTexture(t) }, !0), this.video.src = window.URL.createObjectURL(t), this.video.canplay = !0, this },
|
|
createVideoFromURL: function(t, e) { return void 0 === e && (e = !1), this.texture && (this.texture.valid = !1), this.video = document.createElement("video"), this.video.controls = !1, e && this.video.setAttribute("autoplay", "autoplay"), this.video.src = t, this.video.canplay = !0, this.video.load(), this.retry = this.retryLimit, this._retryID = window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval), this.key = t, this },
|
|
updateTexture: function(t, e, i) {
|
|
var s = !1;
|
|
null == e && (e = this.video.videoWidth, s = !0), null == i && (i = this.video.videoHeight), this.width = e, this.height = i, this.baseTexture.source !== this.video && (this.baseTexture.source = this.video), this.baseTexture.forceLoaded(e, i), this.texture.frame.resize(e, i), this.texture.width = e, this.texture.height = i, this.texture.valid = !0, this.snapshot && this.snapshot.resize(e, i), s && null !== this.key && (this.onChangeSource.dispatch(this, e, i), this._autoplay && (this.video.play(), this.onPlay.dispatch(this, this.loop, this.playbackRate)))
|
|
},
|
|
complete: function() { this.onComplete.dispatch(this) },
|
|
play: function(t, e) { return void 0 === t && (t = !1), void 0 === e && (e = 1), this.game.sound.onMute && (this.game.sound.onMute.add(this.setMute, this), this.game.sound.onUnMute.add(this.unsetMute, this), this.game.sound.mute && this.setMute()), this.game.onPause.add(this.setPause, this), this.game.onResume.add(this.setResume, this), this._endCallback = this.complete.bind(this), this.video.addEventListener("ended", this._endCallback, !0), this.video.addEventListener("webkitendfullscreen", this._endCallback, !0), this.video.loop = t ? "loop" : "", this.video.playbackRate = e, this.touchLocked ? this._pending = !0 : (this._pending = !1, null !== this.key && (4 !== this.video.readyState ? (this.retry = this.retryLimit, this._retryID = window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval)) : (this._playCallback = this.playHandler.bind(this), this.video.addEventListener("playing", this._playCallback, !0))), this.video.play(), this.onPlay.dispatch(this, t, e)), this },
|
|
playHandler: function() { this.video.removeEventListener("playing", this._playCallback, !0), this.updateTexture() },
|
|
stop: function() { return this.game.sound.onMute && (this.game.sound.onMute.remove(this.setMute, this), this.game.sound.onUnMute.remove(this.unsetMute, this)), this.game.onPause.remove(this.setPause, this), this.game.onResume.remove(this.setResume, this), this.isStreaming ? (this.video.mozSrcObject ? (this.video.mozSrcObject.stop(), this.video.src = null) : (this.video.src = "", this.videoStream.active ? this.videoStream.active = !1 : this.videoStream.getTracks ? this.videoStream.getTracks().forEach(function(t) { t.stop() }) : this.videoStream.stop()), this.videoStream = null, this.isStreaming = !1) : (this.video.removeEventListener("ended", this._endCallback, !0), this.video.removeEventListener("webkitendfullscreen", this._endCallback, !0), this.video.removeEventListener("playing", this._playCallback, !0), this.touchLocked ? this._pending = !1 : this.video.pause()), this },
|
|
add: function(t) {
|
|
if (Array.isArray(t))
|
|
for (var e = 0; e < t.length; e++) t[e].loadTexture && t[e].loadTexture(this);
|
|
else t.loadTexture(this);
|
|
return this
|
|
},
|
|
addToWorld: function(t, e, i, s, o, n) { o = o || 1, n = n || 1; var a = this.game.add.image(t, e, this); return a.anchor.set(i, s), a.scale.set(o, n), a },
|
|
render: function() {!this.disableTextureUpload && this.playing && this.baseTexture.dirty() },
|
|
setMute: function() { this._muted || (this._muted = !0, this.video.muted = !0) },
|
|
unsetMute: function() { this._muted && !this._codeMuted && (this._muted = !1, this.video.muted = !1) },
|
|
setPause: function() { this._paused || this.touchLocked || (this._paused = !0, this.video.pause()) },
|
|
setResume: function() {!this._paused || this._codePaused || this.touchLocked || (this._paused = !1, this.video.ended || this.video.play()) },
|
|
changeSource: function(t, e) { return void 0 === e && (e = !0), this.texture.valid = !1, this.video.pause(), this.retry = this.retryLimit, this._retryID = window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval), this.video.src = t, this.video.load(), (this._autoplay = e) || (this.paused = !0), this },
|
|
checkVideoProgress: function() { 4 === this.video.readyState ? this.updateTexture() : (this.retry--, 0 < this.retry && (this._retryID = window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval))) },
|
|
setTouchLock: function() { this.game.input.touch.addTouchLockCallback(this.unlock, this), this.touchLocked = !0 },
|
|
unlock: function() {
|
|
if (this.touchLocked = !1, this.video.play(), this.onPlay.dispatch(this, this.loop, this.playbackRate), this.key) {
|
|
var t = this.game.cache.getVideo(this.key);
|
|
t && !t.isBlob && (t.locked = !1)
|
|
}
|
|
return !0
|
|
},
|
|
grab: function(t, e, i) { if (void 0 === t && (t = !1), void 0 === e && (e = 1), void 0 === i && (i = null), null !== this.snapshot) return t && this.snapshot.cls(), this.snapshot.copy(this.video, 0, 0, this.width, this.height, 0, 0, this.width, this.height, 0, 0, 0, 1, 1, e, i), this.snapshot },
|
|
removeVideoElement: function() {
|
|
if (this.video) {
|
|
for (this.video.parentNode && this.video.parentNode.removeChild(this.video); this.video.hasChildNodes();) this.video.removeChild(this.video.firstChild);
|
|
this.video.removeAttribute("autoplay"), this.video.removeAttribute("src"), this.video = null
|
|
}
|
|
},
|
|
destroy: function() { this.stop(), this.removeVideoElement(), this.touchLocked && this.game.input.touch.removeTouchLockCallback(this.unlock, this), this._retryID && window.clearTimeout(this._retryID) }
|
|
}, Object.defineProperty(H.Video.prototype, "currentTime", { get: function() { return this.video ? this.video.currentTime : 0 }, set: function(t) { this.video.currentTime = t } }), Object.defineProperty(H.Video.prototype, "duration", { get: function() { return this.video ? this.video.duration : 0 } }), Object.defineProperty(H.Video.prototype, "progress", { get: function() { return this.video ? this.video.currentTime / this.video.duration : 0 } }), Object.defineProperty(H.Video.prototype, "mute", {
|
|
get: function() { return this._muted },
|
|
set: function(t) {
|
|
if (t = t || null) {
|
|
if (this._muted) return;
|
|
this._codeMuted = !0, this.setMute()
|
|
}
|
|
else {
|
|
if (!this._muted) return;
|
|
this._codeMuted = !1, this.unsetMute()
|
|
}
|
|
}
|
|
}), Object.defineProperty(H.Video.prototype, "paused", {
|
|
get: function() { return this._paused },
|
|
set: function(t) {
|
|
if (t = t || null, !this.touchLocked)
|
|
if (t) {
|
|
if (this._paused) return;
|
|
this._codePaused = !0, this.setPause()
|
|
}
|
|
else {
|
|
if (!this._paused) return;
|
|
this._codePaused = !1, this.setResume()
|
|
}
|
|
}
|
|
}), Object.defineProperty(H.Video.prototype, "volume", { get: function() { return this.video ? this.video.volume : 1 }, set: function(t) { t < 0 ? t = 0 : 1 < t && (t = 1), this.video && (this.video.volume = t) } }), Object.defineProperty(H.Video.prototype, "playbackRate", { get: function() { return this.video ? this.video.playbackRate : 1 }, set: function(t) { this.video && (this.video.playbackRate = t) } }), Object.defineProperty(H.Video.prototype, "loop", { get: function() { return !!this.video && this.video.loop }, set: function(t) { t && this.video ? this.video.loop = "loop" : this.video && (this.video.loop = "") } }), Object.defineProperty(H.Video.prototype, "playing", { get: function() { return !(this.video.paused && this.video.ended) } }), H.Video.prototype.constructor = H.Video, void 0 === PIXI.blendModes && (PIXI.blendModes = H.blendModes), void 0 === PIXI.scaleModes && (PIXI.scaleModes = H.scaleModes), void 0 === PIXI.Texture.emptyTexture && (PIXI.Texture.emptyTexture = new PIXI.Texture(new PIXI.BaseTexture)), void 0 === PIXI.DisplayObject._tempMatrix && (PIXI.DisplayObject._tempMatrix = new PIXI.Matrix), void 0 === PIXI.RenderTexture.tempMatrix && (PIXI.RenderTexture.tempMatrix = new PIXI.Matrix), PIXI.Graphics && void 0 === PIXI.Graphics.POLY && (PIXI.Graphics.POLY = H.POLYGON, PIXI.Graphics.RECT = H.RECTANGLE, PIXI.Graphics.CIRC = H.CIRCLE, PIXI.Graphics.ELIP = H.ELLIPSE, PIXI.Graphics.RREC = H.ROUNDEDRECTANGLE), PIXI.TextureSilentFail = !0, "undefined" != typeof exports ? ("undefined" != typeof module && module.exports && (exports = module.exports = H), exports.Phaser = H) : "undefined" != typeof define && define.amd ? define("Phaser", t.Phaser = H) : t.Phaser = H, H
|
|
}.call(this);
|
|
var _gsScope = "undefined" != typeof module && module.exports && "undefined" != typeof global ? global : this || window;
|
|
(_gsScope._gsQueue || (_gsScope._gsQueue = [])).push(function() {
|
|
"use strict";
|
|
var _, w, P, T, m, i, v, S, x, b, d, y, f, t, e, h, l, s;
|
|
_gsScope._gsDefine("TweenMax", ["core.Animation", "core.SimpleTimeline", "TweenLite"], function(s, c, v) {
|
|
var f = function(t) {
|
|
var e, i = [],
|
|
s = t.length;
|
|
for (e = 0; e !== s; i.push(t[e++]));
|
|
return i
|
|
},
|
|
m = function(t, e, i) {
|
|
var s, o, n = t.cycle;
|
|
for (s in n) o = n[s], t[s] = "function" == typeof o ? o(i, e[i]) : o[i % o.length];
|
|
delete t.cycle
|
|
},
|
|
x = function(t, e, i) { v.call(this, t, e, i), this._cycle = 0, this._yoyo = !0 === this.vars.yoyo || !!this.vars.yoyoEase, this._repeat = this.vars.repeat || 0, this._repeatDelay = this.vars.repeatDelay || 0, this._repeat && this._uncache(!0), this.render = x.prototype.render },
|
|
b = 1e-10,
|
|
w = v._internals,
|
|
P = w.isSelector,
|
|
_ = w.isArray,
|
|
t = x.prototype = v.to({}, .1, {}),
|
|
T = [];
|
|
x.version = "1.20.5", t.constructor = x, t.kill()._gc = !1, x.killTweensOf = x.killDelayedCallsTo = v.killTweensOf, x.getTweensOf = v.getTweensOf, x.lagSmoothing = v.lagSmoothing, x.ticker = v.ticker, x.render = v.render, t.invalidate = function() { return this._yoyo = !0 === this.vars.yoyo || !!this.vars.yoyoEase, this._repeat = this.vars.repeat || 0, this._repeatDelay = this.vars.repeatDelay || 0, this._yoyoEase = null, this._uncache(!0), v.prototype.invalidate.call(this) }, t.updateTo = function(t, e) {
|
|
var i, s = this.ratio,
|
|
o = this.vars.immediateRender || t.immediateRender;
|
|
for (i in e && this._startTime < this._timeline._time && (this._startTime = this._timeline._time, this._uncache(!1), this._gc ? this._enabled(!0, !1) : this._timeline.insert(this, this._startTime - this._delay)), t) this.vars[i] = t[i];
|
|
if (this._initted || o)
|
|
if (e) this._initted = !1, o && this.render(0, !0, !0);
|
|
else if (this._gc && this._enabled(!0, !1), this._notifyPluginsOfEnabled && this._firstPT && v._onPluginEvent("_onDisable", this), .998 < this._time / this._duration) {
|
|
var n = this._totalTime;
|
|
this.render(0, !0, !1), this._initted = !1, this.render(n, !0, !1)
|
|
}
|
|
else if (this._initted = !1, this._init(), 0 < this._time || o)
|
|
for (var a, r = 1 / (1 - s), h = this._firstPT; h;) a = h.s + h.c, h.c *= r, h.s = a - h.c, h = h._next;
|
|
return this
|
|
}, t.render = function(t, e, i) {
|
|
this._initted || 0 === this._duration && this.vars.repeat && this.invalidate();
|
|
var s, o, n, a, r, h, l, c, p, u = this._dirty ? this.totalDuration() : this._totalDuration,
|
|
d = this._time,
|
|
y = this._totalTime,
|
|
g = this._cycle,
|
|
f = this._duration,
|
|
m = this._rawPrevTime;
|
|
if (u - 1e-7 <= t && 0 <= t ? (this._totalTime = u, this._cycle = this._repeat, this._yoyo && 0 != (1 & this._cycle) ? (this._time = 0, this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0) : (this._time = f, this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1), this._reversed || (s = !0, o = "onComplete", i = i || this._timeline.autoRemoveChildren), 0 === f && (this._initted || !this.vars.lazy || i) && (this._startTime === this._timeline._duration && (t = 0), (m < 0 || t <= 0 && -1e-7 <= t || m === b && "isPause" !== this.data) && m !== t && (i = !0, b < m && (o = "onReverseComplete")), this._rawPrevTime = c = !e || t || m === t ? t : b)) : t < 1e-7 ? (this._totalTime = this._time = this._cycle = 0, this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0, (0 !== y || 0 === f && 0 < m) && (o = "onReverseComplete", s = this._reversed), t < 0 && (this._active = !1, 0 === f && (this._initted || !this.vars.lazy || i) && (0 <= m && (i = !0), this._rawPrevTime = c = !e || t || m === t ? t : b)), this._initted || (i = !0)) : (this._totalTime = this._time = t, 0 !== this._repeat && (a = f + this._repeatDelay, this._cycle = this._totalTime / a >> 0, 0 !== this._cycle && this._cycle === this._totalTime / a && y <= t && this._cycle--, this._time = this._totalTime - this._cycle * a, this._yoyo && 0 != (1 & this._cycle) && (this._time = f - this._time, (p = this._yoyoEase || this.vars.yoyoEase) && (this._yoyoEase || (!0 !== p || this._initted ? this._yoyoEase = p = !0 === p ? this._ease : p instanceof Ease ? p : Ease.map[p] : (p = this.vars.ease, this._yoyoEase = p = p ? p instanceof Ease ? p : "function" == typeof p ? new Ease(p, this.vars.easeParams) : Ease.map[p] || v.defaultEase : v.defaultEase)), this.ratio = p ? 1 - p.getRatio((f - this._time) / f) : 0)), this._time > f ? this._time = f : this._time < 0 && (this._time = 0)), this._easeType && !p ? (r = this._time / f, (1 === (h = this._easeType) || 3 === h && .5 <= r) && (r = 1 - r), 3 === h && (r *= 2), 1 === (l = this._easePower) ? r *= r : 2 === l ? r *= r * r : 3 === l ? r *= r * r * r : 4 === l && (r *= r * r * r * r), 1 === h ? this.ratio = 1 - r : 2 === h ? this.ratio = r : this._time / f < .5 ? this.ratio = r / 2 : this.ratio = 1 - r / 2) : p || (this.ratio = this._ease.getRatio(this._time / f))), d !== this._time || i || g !== this._cycle) {
|
|
if (!this._initted) { if (this._init(), !this._initted || this._gc) return; if (!i && this._firstPT && (!1 !== this.vars.lazy && this._duration || this.vars.lazy && !this._duration)) return this._time = d, this._totalTime = y, this._rawPrevTime = m, this._cycle = g, w.lazyTweens.push(this), void(this._lazy = [t, e]);!this._time || s || p ? s && this._ease._calcEnd && !p && (this.ratio = this._ease.getRatio(0 === this._time ? 0 : 1)) : this.ratio = this._ease.getRatio(this._time / f) }
|
|
for (!1 !== this._lazy && (this._lazy = !1), this._active || !this._paused && this._time !== d && 0 <= t && (this._active = !0), 0 === y && (2 === this._initted && 0 < t && this._init(), this._startAt && (0 <= t ? this._startAt.render(t, !0, i) : o || (o = "_dummyGS")), this.vars.onStart && (0 === this._totalTime && 0 !== f || e || this._callback("onStart"))), n = this._firstPT; n;) n.f ? n.t[n.p](n.c * this.ratio + n.s) : n.t[n.p] = n.c * this.ratio + n.s, n = n._next;
|
|
this._onUpdate && (t < 0 && this._startAt && this._startTime && this._startAt.render(t, !0, i), e || (this._totalTime !== y || o) && this._callback("onUpdate")), this._cycle !== g && (e || this._gc || this.vars.onRepeat && this._callback("onRepeat")), o && (this._gc && !i || (t < 0 && this._startAt && !this._onUpdate && this._startTime && this._startAt.render(t, !0, i), s && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), !e && this.vars[o] && this._callback(o), 0 === f && this._rawPrevTime === b && c !== b && (this._rawPrevTime = 0)))
|
|
}
|
|
else y !== this._totalTime && this._onUpdate && (e || this._callback("onUpdate"))
|
|
}, x.to = function(t, e, i) { return new x(t, e, i) }, x.from = function(t, e, i) { return i.runBackwards = !0, i.immediateRender = 0 != i.immediateRender, new x(t, e, i) }, x.fromTo = function(t, e, i, s) { return s.startAt = i, s.immediateRender = 0 != s.immediateRender && 0 != i.immediateRender, new x(t, e, s) }, x.staggerTo = x.allTo = function(t, e, i, s, o, n, a) {
|
|
s = s || 0;
|
|
var r, h, l, c, p = 0,
|
|
u = [],
|
|
d = function() { i.onComplete && i.onComplete.apply(i.onCompleteScope || this, arguments), o.apply(a || i.callbackScope || this, n || T) },
|
|
y = i.cycle,
|
|
g = i.startAt && i.startAt.cycle;
|
|
for (_(t) || ("string" == typeof t && (t = v.selector(t) || t), P(t) && (t = f(t))), t = t || [], s < 0 && ((t = f(t)).reverse(), s *= -1), r = t.length - 1, l = 0; l <= r; l++) {
|
|
for (c in h = {}, i) h[c] = i[c];
|
|
if (y && (m(h, t, l), null != h.duration && (e = h.duration, delete h.duration)), g) {
|
|
for (c in g = h.startAt = {}, i.startAt) g[c] = i.startAt[c];
|
|
m(h.startAt, t, l)
|
|
}
|
|
h.delay = p + (h.delay || 0), l === r && o && (h.onComplete = d), u[l] = new x(t[l], e, h), p += s
|
|
}
|
|
return u
|
|
}, x.staggerFrom = x.allFrom = function(t, e, i, s, o, n, a) { return i.runBackwards = !0, i.immediateRender = 0 != i.immediateRender, x.staggerTo(t, e, i, s, o, n, a) }, x.staggerFromTo = x.allFromTo = function(t, e, i, s, o, n, a, r) { return s.startAt = i, s.immediateRender = 0 != s.immediateRender && 0 != i.immediateRender, x.staggerTo(t, e, s, o, n, a, r) }, x.delayedCall = function(t, e, i, s, o) { return new x(e, 0, { delay: t, onComplete: e, onCompleteParams: i, callbackScope: s, onReverseComplete: e, onReverseCompleteParams: i, immediateRender: !1, useFrames: o, overwrite: 0 }) }, x.set = function(t, e) { return new x(t, 0, e) }, x.isTweening = function(t) { return 0 < v.getTweensOf(t, !0).length };
|
|
var n = function(t, e) { for (var i = [], s = 0, o = t._first; o;) o instanceof v ? i[s++] = o : (e && (i[s++] = o), s = (i = i.concat(n(o, e))).length), o = o._next; return i },
|
|
p = x.getAllTweens = function(t) { return n(s._rootTimeline, t).concat(n(s._rootFramesTimeline, t)) };
|
|
x.killAll = function(t, e, i, s) {
|
|
null == e && (e = !0), null == i && (i = !0);
|
|
var o, n, a, r = p(0 != s),
|
|
h = r.length,
|
|
l = e && i && s;
|
|
for (a = 0; a < h; a++) n = r[a], (l || n instanceof c || (o = n.target === n.vars.onComplete) && i || e && !o) && (t ? n.totalTime(n._reversed ? 0 : n.totalDuration()) : n._enabled(!1, !1))
|
|
}, x.killChildTweensOf = function(t, e) {
|
|
if (null != t) {
|
|
var i, s, o, n, a, r = w.tweenLookup;
|
|
if ("string" == typeof t && (t = v.selector(t) || t), P(t) && (t = f(t)), _(t))
|
|
for (n = t.length; - 1 < --n;) x.killChildTweensOf(t[n], e);
|
|
else {
|
|
for (o in i = [], r)
|
|
for (s = r[o].target.parentNode; s;) s === t && (i = i.concat(r[o].tweens)), s = s.parentNode;
|
|
for (a = i.length, n = 0; n < a; n++) e && i[n].totalTime(i[n].totalDuration()), i[n]._enabled(!1, !1)
|
|
}
|
|
}
|
|
};
|
|
var o = function(t, e, i, s) { e = !1 !== e, i = !1 !== i; for (var o, n, a = p(s = !1 !== s), r = e && i && s, h = a.length; - 1 < --h;) n = a[h], (r || n instanceof c || (o = n.target === n.vars.onComplete) && i || e && !o) && n.paused(t) };
|
|
return x.pauseAll = function(t, e, i) { o(!0, t, e, i) }, x.resumeAll = function(t, e, i) { o(!1, t, e, i) }, x.globalTimeScale = function(t) {
|
|
var e = s._rootTimeline,
|
|
i = v.ticker.time;
|
|
return arguments.length ? (t = t || b, e._startTime = i - (i - e._startTime) * e._timeScale / t, e = s._rootFramesTimeline, i = v.ticker.frame, e._startTime = i - (i - e._startTime) * e._timeScale / t, e._timeScale = s._rootTimeline._timeScale = t, t) : e._timeScale
|
|
}, t.progress = function(t, e) { return arguments.length ? this.totalTime(this.duration() * (this._yoyo && 0 != (1 & this._cycle) ? 1 - t : t) + this._cycle * (this._duration + this._repeatDelay), e) : this._time / this.duration() }, t.totalProgress = function(t, e) { return arguments.length ? this.totalTime(this.totalDuration() * t, e) : this._totalTime / this.totalDuration() }, t.time = function(t, e) { return arguments.length ? (this._dirty && this.totalDuration(), t > this._duration && (t = this._duration), this._yoyo && 0 != (1 & this._cycle) ? t = this._duration - t + this._cycle * (this._duration + this._repeatDelay) : 0 !== this._repeat && (t += this._cycle * (this._duration + this._repeatDelay)), this.totalTime(t, e)) : this._time }, t.duration = function(t) { return arguments.length ? s.prototype.duration.call(this, t) : this._duration }, t.totalDuration = function(t) { return arguments.length ? -1 === this._repeat ? this : this.duration((t - this._repeat * this._repeatDelay) / (this._repeat + 1)) : (this._dirty && (this._totalDuration = -1 === this._repeat ? 999999999999 : this._duration * (this._repeat + 1) + this._repeatDelay * this._repeat, this._dirty = !1), this._totalDuration) }, t.repeat = function(t) { return arguments.length ? (this._repeat = t, this._uncache(!0)) : this._repeat }, t.repeatDelay = function(t) { return arguments.length ? (this._repeatDelay = t, this._uncache(!0)) : this._repeatDelay }, t.yoyo = function(t) { return arguments.length ? (this._yoyo = t, this) : this._yoyo }, x
|
|
}, !0), _gsScope._gsDefine("TimelineLite", ["core.Animation", "core.SimpleTimeline", "TweenLite"], function(c, p, u) {
|
|
var d = function(t) {
|
|
p.call(this, t), this._labels = {}, this.autoRemoveChildren = !0 === this.vars.autoRemoveChildren, this.smoothChildTiming = !0 === this.vars.smoothChildTiming, this._sortChildren = !0, this._onUpdate = this.vars.onUpdate;
|
|
var e, i, s = this.vars;
|
|
for (i in s) e = s[i], g(e) && -1 !== e.join("").indexOf("{self}") && (s[i] = this._swapSelfInParams(e));
|
|
g(s.tweens) && this.add(s.tweens, 0, s.align, s.stagger)
|
|
},
|
|
t = u._internals,
|
|
e = d._internals = {},
|
|
y = t.isSelector,
|
|
g = t.isArray,
|
|
f = t.lazyTweens,
|
|
m = t.lazyRender,
|
|
a = _gsScope._gsDefine.globals,
|
|
v = function(t) { var e, i = {}; for (e in t) i[e] = t[e]; return i },
|
|
x = function(t, e, i) {
|
|
var s, o, n = t.cycle;
|
|
for (s in n) o = n[s], t[s] = "function" == typeof o ? o(i, e[i]) : o[i % o.length];
|
|
delete t.cycle
|
|
},
|
|
n = e.pauseCallback = function() {},
|
|
b = function(t) {
|
|
var e, i = [],
|
|
s = t.length;
|
|
for (e = 0; e !== s; i.push(t[e++]));
|
|
return i
|
|
},
|
|
i = d.prototype = new p;
|
|
return d.version = "1.20.4", i.constructor = d, i.kill()._gc = i._forcingPlayhead = i._hasPause = !1, i.to = function(t, e, i, s) { var o = i.repeat && a.TweenMax || u; return e ? this.add(new o(t, e, i), s) : this.set(t, i, s) }, i.from = function(t, e, i, s) { return this.add((i.repeat && a.TweenMax || u).from(t, e, i), s) }, i.fromTo = function(t, e, i, s, o) { var n = s.repeat && a.TweenMax || u; return e ? this.add(n.fromTo(t, e, i, s), o) : this.set(t, s, o) }, i.staggerTo = function(t, e, i, s, o, n, a, r) {
|
|
var h, l, c = new d({ onComplete: n, onCompleteParams: a, callbackScope: r, smoothChildTiming: this.smoothChildTiming }),
|
|
p = i.cycle;
|
|
for ("string" == typeof t && (t = u.selector(t) || t), y(t = t || []) && (t = b(t)), (s = s || 0) < 0 && ((t = b(t)).reverse(), s *= -1), l = 0; l < t.length; l++)(h = v(i)).startAt && (h.startAt = v(h.startAt), h.startAt.cycle && x(h.startAt, t, l)), p && (x(h, t, l), null != h.duration && (e = h.duration, delete h.duration)), c.to(t[l], e, h, l * s);
|
|
return this.add(c, o)
|
|
}, i.staggerFrom = function(t, e, i, s, o, n, a, r) { return i.immediateRender = 0 != i.immediateRender, i.runBackwards = !0, this.staggerTo(t, e, i, s, o, n, a, r) }, i.staggerFromTo = function(t, e, i, s, o, n, a, r, h) { return s.startAt = i, s.immediateRender = 0 != s.immediateRender && 0 != i.immediateRender, this.staggerTo(t, e, s, o, n, a, r, h) }, i.call = function(t, e, i, s) { return this.add(u.delayedCall(0, t, e, i), s) }, i.set = function(t, e, i) { return i = this._parseTimeOrLabel(i, 0, !0), null == e.immediateRender && (e.immediateRender = i === this._time && !this._paused), this.add(new u(t, 0, e), i) }, d.exportRoot = function(t, e) {
|
|
null == (t = t || {}).smoothChildTiming && (t.smoothChildTiming = !0);
|
|
var i, s, o, n, a = new d(t),
|
|
r = a._timeline;
|
|
for (null == e && (e = !0), r._remove(a, !0), a._startTime = 0, a._rawPrevTime = a._time = a._totalTime = r._time, o = r._first; o;) n = o._next, e && o instanceof u && o.target === o.vars.onComplete || ((s = o._startTime - o._delay) < 0 && (i = 1), a.add(o, s)), o = n;
|
|
return r.add(a, 0), i && a.totalDuration(), a
|
|
}, i.add = function(t, e, i, s) {
|
|
var o, n, a, r, h, l;
|
|
if ("number" != typeof e && (e = this._parseTimeOrLabel(e, 0, !0, t)), !(t instanceof c)) {
|
|
if (t instanceof Array || t && t.push && g(t)) { for (i = i || "normal", s = s || 0, o = e, n = t.length, a = 0; a < n; a++) g(r = t[a]) && (r = new d({ tweens: r })), this.add(r, o), "string" != typeof r && "function" != typeof r && ("sequence" === i ? o = r._startTime + r.totalDuration() / r._timeScale : "start" === i && (r._startTime -= r.delay())), o += s; return this._uncache(!0) }
|
|
if ("string" == typeof t) return this.addLabel(t, e);
|
|
if ("function" != typeof t) throw "Cannot add " + t + " into the timeline; it is not a tween, timeline, function, or string.";
|
|
t = u.delayedCall(0, t)
|
|
}
|
|
if (p.prototype.add.call(this, t, e), t._time && t.render((this.rawTime() - t._startTime) * t._timeScale, !1, !1), (this._gc || this._time === this._duration) && !this._paused && this._duration < this.duration())
|
|
for (l = (h = this).rawTime() > t._startTime; h._timeline;) l && h._timeline.smoothChildTiming ? h.totalTime(h._totalTime, !0) : h._gc && h._enabled(!0, !1), h = h._timeline;
|
|
return this
|
|
}, i.remove = function(t) { if (t instanceof c) { this._remove(t, !1); var e = t._timeline = t.vars.useFrames ? c._rootFramesTimeline : c._rootTimeline; return t._startTime = (t._paused ? t._pauseTime : e._time) - (t._reversed ? t.totalDuration() - t._totalTime : t._totalTime) / t._timeScale, this } if (t instanceof Array || t && t.push && g(t)) { for (var i = t.length; - 1 < --i;) this.remove(t[i]); return this } return "string" == typeof t ? this.removeLabel(t) : this.kill(null, t) }, i._remove = function(t, e) { return p.prototype._remove.call(this, t, e), this._last ? this._time > this.duration() && (this._time = this._duration, this._totalTime = this._totalDuration) : this._time = this._totalTime = this._duration = this._totalDuration = 0, this }, i.append = function(t, e) { return this.add(t, this._parseTimeOrLabel(null, e, !0, t)) }, i.insert = i.insertMultiple = function(t, e, i, s) { return this.add(t, e || 0, i, s) }, i.appendMultiple = function(t, e, i, s) { return this.add(t, this._parseTimeOrLabel(null, e, !0, t), i, s) }, i.addLabel = function(t, e) { return this._labels[t] = this._parseTimeOrLabel(e), this }, i.addPause = function(t, e, i, s) { var o = u.delayedCall(0, n, i, s || this); return o.vars.onComplete = o.vars.onReverseComplete = e, o.data = "isPause", this._hasPause = !0, this.add(o, t) }, i.removeLabel = function(t) { return delete this._labels[t], this }, i.getLabelTime = function(t) { return null != this._labels[t] ? this._labels[t] : -1 }, i._parseTimeOrLabel = function(t, e, i, s) {
|
|
var o, n;
|
|
if (s instanceof c && s.timeline === this) this.remove(s);
|
|
else if (s && (s instanceof Array || s.push && g(s)))
|
|
for (n = s.length; - 1 < --n;) s[n] instanceof c && s[n].timeline === this && this.remove(s[n]);
|
|
if (o = "number" != typeof t || e ? 99999999999 < this.duration() ? this.recent().endTime(!1) : this._duration : 0, "string" == typeof e) return this._parseTimeOrLabel(e, i && "number" == typeof t && null == this._labels[e] ? t - o : 0, i);
|
|
if (e = e || 0, "string" != typeof t || !isNaN(t) && null == this._labels[t]) null == t && (t = o);
|
|
else {
|
|
if (-1 === (n = t.indexOf("="))) return null == this._labels[t] ? i ? this._labels[t] = o + e : e : this._labels[t] + e;
|
|
e = parseInt(t.charAt(n - 1) + "1", 10) * Number(t.substr(n + 1)), t = 1 < n ? this._parseTimeOrLabel(t.substr(0, n - 1), 0, i) : o
|
|
}
|
|
return Number(t) + e
|
|
}, i.seek = function(t, e) { return this.totalTime("number" == typeof t ? t : this._parseTimeOrLabel(t), !1 !== e) }, i.stop = function() { return this.paused(!0) }, i.gotoAndPlay = function(t, e) { return this.play(t, e) }, i.gotoAndStop = function(t, e) { return this.pause(t, e) }, i.render = function(t, e, i) {
|
|
this._gc && this._enabled(!0, !1);
|
|
var s, o, n, a, r, h, l, c = this._time,
|
|
p = this._dirty ? this.totalDuration() : this._totalDuration,
|
|
u = this._startTime,
|
|
d = this._timeScale,
|
|
y = this._paused;
|
|
if (c !== this._time && (t += this._time - c), p - 1e-7 <= t && 0 <= t) this._totalTime = this._time = p, this._reversed || this._hasPausedChild() || (o = !0, a = "onComplete", r = !!this._timeline.autoRemoveChildren, 0 === this._duration && (t <= 0 && -1e-7 <= t || this._rawPrevTime < 0 || 1e-10 === this._rawPrevTime) && this._rawPrevTime !== t && this._first && (r = !0, 1e-10 < this._rawPrevTime && (a = "onReverseComplete"))), this._rawPrevTime = this._duration || !e || t || this._rawPrevTime === t ? t : 1e-10, t = p + 1e-4;
|
|
else if (t < 1e-7)
|
|
if (this._totalTime = this._time = 0, (0 !== c || 0 === this._duration && 1e-10 !== this._rawPrevTime && (0 < this._rawPrevTime || t < 0 && 0 <= this._rawPrevTime)) && (a = "onReverseComplete", o = this._reversed), t < 0) this._active = !1, this._timeline.autoRemoveChildren && this._reversed ? (r = o = !0, a = "onReverseComplete") : 0 <= this._rawPrevTime && this._first && (r = !0), this._rawPrevTime = t;
|
|
else {
|
|
if (this._rawPrevTime = this._duration || !e || t || this._rawPrevTime === t ? t : 1e-10, 0 === t && o)
|
|
for (s = this._first; s && 0 === s._startTime;) s._duration || (o = !1), s = s._next;
|
|
t = 0, this._initted || (r = !0)
|
|
}
|
|
else {
|
|
if (this._hasPause && !this._forcingPlayhead && !e) {
|
|
if (c <= t)
|
|
for (s = this._first; s && s._startTime <= t && !h;) s._duration || "isPause" !== s.data || s.ratio || 0 === s._startTime && 0 === this._rawPrevTime || (h = s), s = s._next;
|
|
else
|
|
for (s = this._last; s && s._startTime >= t && !h;) s._duration || "isPause" === s.data && 0 < s._rawPrevTime && (h = s), s = s._prev;
|
|
h && (this._time = t = h._startTime, this._totalTime = t + this._cycle * (this._totalDuration + this._repeatDelay))
|
|
}
|
|
this._totalTime = this._time = this._rawPrevTime = t
|
|
}
|
|
if (this._time !== c && this._first || i || r || h) {
|
|
if (this._initted || (this._initted = !0), this._active || !this._paused && this._time !== c && 0 < t && (this._active = !0), 0 === c && this.vars.onStart && (0 === this._time && this._duration || e || this._callback("onStart")), c <= (l = this._time))
|
|
for (s = this._first; s && (n = s._next, l === this._time && (!this._paused || y));)(s._active || s._startTime <= l && !s._paused && !s._gc) && (h === s && this.pause(), s._reversed ? s.render((s._dirty ? s.totalDuration() : s._totalDuration) - (t - s._startTime) * s._timeScale, e, i) : s.render((t - s._startTime) * s._timeScale, e, i)), s = n;
|
|
else
|
|
for (s = this._last; s && (n = s._prev, l === this._time && (!this._paused || y));) {
|
|
if (s._active || s._startTime <= c && !s._paused && !s._gc) {
|
|
if (h === s) {
|
|
for (h = s._prev; h && h.endTime() > this._time;) h.render(h._reversed ? h.totalDuration() - (t - h._startTime) * h._timeScale : (t - h._startTime) * h._timeScale, e, i), h = h._prev;
|
|
h = null, this.pause()
|
|
}
|
|
s._reversed ? s.render((s._dirty ? s.totalDuration() : s._totalDuration) - (t - s._startTime) * s._timeScale, e, i) : s.render((t - s._startTime) * s._timeScale, e, i)
|
|
}
|
|
s = n
|
|
}
|
|
this._onUpdate && (e || (f.length && m(), this._callback("onUpdate"))), a && (this._gc || u !== this._startTime && d === this._timeScale || (0 === this._time || p >= this.totalDuration()) && (o && (f.length && m(), this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), !e && this.vars[a] && this._callback(a)))
|
|
}
|
|
}, i._hasPausedChild = function() {
|
|
for (var t = this._first; t;) {
|
|
if (t._paused || t instanceof d && t._hasPausedChild()) return !0;
|
|
t = t._next
|
|
}
|
|
return !1
|
|
}, i.getChildren = function(t, e, i, s) { s = s || -9999999999; for (var o = [], n = this._first, a = 0; n;) n._startTime < s || (n instanceof u ? !1 !== e && (o[a++] = n) : (!1 !== i && (o[a++] = n), !1 !== t && (a = (o = o.concat(n.getChildren(!0, e, i))).length))), n = n._next; return o }, i.getTweensOf = function(t, e) {
|
|
var i, s, o = this._gc,
|
|
n = [],
|
|
a = 0;
|
|
for (o && this._enabled(!0, !0), s = (i = u.getTweensOf(t)).length; - 1 < --s;)(i[s].timeline === this || e && this._contains(i[s])) && (n[a++] = i[s]);
|
|
return o && this._enabled(!1, !0), n
|
|
}, i.recent = function() { return this._recent }, i._contains = function(t) {
|
|
for (var e = t.timeline; e;) {
|
|
if (e === this) return !0;
|
|
e = e.timeline
|
|
}
|
|
return !1
|
|
}, i.shiftChildren = function(t, e, i) {
|
|
i = i || 0;
|
|
for (var s, o = this._first, n = this._labels; o;) o._startTime >= i && (o._startTime += t), o = o._next;
|
|
if (e)
|
|
for (s in n) n[s] >= i && (n[s] += t);
|
|
return this._uncache(!0)
|
|
}, i._kill = function(t, e) { if (!t && !e) return this._enabled(!1, !1); for (var i = e ? this.getTweensOf(e) : this.getChildren(!0, !0, !1), s = i.length, o = !1; - 1 < --s;) i[s]._kill(t, e) && (o = !0); return o }, i.clear = function(t) {
|
|
var e = this.getChildren(!1, !0, !0),
|
|
i = e.length;
|
|
for (this._time = this._totalTime = 0; - 1 < --i;) e[i]._enabled(!1, !1);
|
|
return !1 !== t && (this._labels = {}), this._uncache(!0)
|
|
}, i.invalidate = function() { for (var t = this._first; t;) t.invalidate(), t = t._next; return c.prototype.invalidate.call(this) }, i._enabled = function(t, e) {
|
|
if (t === this._gc)
|
|
for (var i = this._first; i;) i._enabled(t, !0), i = i._next;
|
|
return p.prototype._enabled.call(this, t, e)
|
|
}, i.totalTime = function(t, e, i) { this._forcingPlayhead = !0; var s = c.prototype.totalTime.apply(this, arguments); return this._forcingPlayhead = !1, s }, i.duration = function(t) { return arguments.length ? (0 !== this.duration() && 0 !== t && this.timeScale(this._duration / t), this) : (this._dirty && this.totalDuration(), this._duration) }, i.totalDuration = function(t) {
|
|
if (arguments.length) return t && this.totalDuration() ? this.timeScale(this._totalDuration / t) : this;
|
|
if (this._dirty) {
|
|
for (var e, i, s = 0, o = this._last, n = 999999999999; o;) e = o._prev, o._dirty && o.totalDuration(), o._startTime > n && this._sortChildren && !o._paused && !this._calculatingDuration ? (this._calculatingDuration = 1, this.add(o, o._startTime - o._delay), this._calculatingDuration = 0) : n = o._startTime, o._startTime < 0 && !o._paused && (s -= o._startTime, this._timeline.smoothChildTiming && (this._startTime += o._startTime / this._timeScale, this._time -= o._startTime, this._totalTime -= o._startTime, this._rawPrevTime -= o._startTime), this.shiftChildren(-o._startTime, !1, -9999999999), n = 0), s < (i = o._startTime + o._totalDuration / o._timeScale) && (s = i), o = e;
|
|
this._duration = this._totalDuration = s, this._dirty = !1
|
|
}
|
|
return this._totalDuration
|
|
}, i.paused = function(t) {
|
|
if (!t)
|
|
for (var e = this._first, i = this._time; e;) e._startTime === i && "isPause" === e.data && (e._rawPrevTime = 0), e = e._next;
|
|
return c.prototype.paused.apply(this, arguments)
|
|
}, i.usesFrames = function() { for (var t = this._timeline; t._timeline;) t = t._timeline; return t === c._rootFramesTimeline }, i.rawTime = function(t) { return t && (this._paused || this._repeat && 0 < this.time() && this.totalProgress() < 1) ? this._totalTime % (this._duration + this._repeatDelay) : this._paused ? this._totalTime : (this._timeline.rawTime(t) - this._startTime) * this._timeScale }, d
|
|
}, !0), _gsScope._gsDefine("TimelineMax", ["TimelineLite", "TweenLite", "easing.Ease"], function(e, r, t) {
|
|
var i = function(t) { e.call(this, t), this._repeat = this.vars.repeat || 0, this._repeatDelay = this.vars.repeatDelay || 0, this._cycle = 0, this._yoyo = !0 === this.vars.yoyo, this._dirty = !0 },
|
|
s = r._internals,
|
|
k = s.lazyTweens,
|
|
B = s.lazyRender,
|
|
h = _gsScope._gsDefine.globals,
|
|
l = new t(null, null, 1, 0),
|
|
o = i.prototype = new e;
|
|
return o.constructor = i, o.kill()._gc = !1, i.version = "1.20.4", o.invalidate = function() { return this._yoyo = !0 === this.vars.yoyo, this._repeat = this.vars.repeat || 0, this._repeatDelay = this.vars.repeatDelay || 0, this._uncache(!0), e.prototype.invalidate.call(this) }, o.addCallback = function(t, e, i, s) { return this.add(r.delayedCall(0, t, i, s), e) }, o.removeCallback = function(t, e) {
|
|
if (t)
|
|
if (null == e) this._kill(null, t);
|
|
else
|
|
for (var i = this.getTweensOf(t, !1), s = i.length, o = this._parseTimeOrLabel(e); - 1 < --s;) i[s]._startTime === o && i[s]._enabled(!1, !1);
|
|
return this
|
|
}, o.removePause = function(t) { return this.removeCallback(e._internals.pauseCallback, t) }, o.tweenTo = function(t, e) {
|
|
e = e || {};
|
|
var i, s, o, n = { ease: l, useFrames: this.usesFrames(), immediateRender: !1, lazy: !1 },
|
|
a = e.repeat && h.TweenMax || r;
|
|
for (s in e) n[s] = e[s];
|
|
return n.time = this._parseTimeOrLabel(t), i = Math.abs(Number(n.time) - this._time) / this._timeScale || .001, o = new a(this, i, n), n.onStart = function() { o.target.paused(!0), o.vars.time === o.target.time() || i !== o.duration() || o.isFromTo || o.duration(Math.abs(o.vars.time - o.target.time()) / o.target._timeScale).render(o.time(), !0, !0), e.onStart && e.onStart.apply(e.onStartScope || e.callbackScope || o, e.onStartParams || []) }, o
|
|
}, o.tweenFromTo = function(t, e, i) { i = i || {}, t = this._parseTimeOrLabel(t), i.startAt = { onComplete: this.seek, onCompleteParams: [t], callbackScope: this }, i.immediateRender = !1 !== i.immediateRender; var s = this.tweenTo(e, i); return s.isFromTo = 1, s.duration(Math.abs(s.vars.time - t) / this._timeScale || .001) }, o.render = function(t, e, i) {
|
|
this._gc && this._enabled(!0, !1);
|
|
var s, o, n, a, r, h, l, c, p = this._time,
|
|
u = this._dirty ? this.totalDuration() : this._totalDuration,
|
|
d = this._duration,
|
|
y = this._totalTime,
|
|
g = this._startTime,
|
|
f = this._timeScale,
|
|
m = this._rawPrevTime,
|
|
v = this._paused,
|
|
x = this._cycle;
|
|
if (p !== this._time && (t += this._time - p), u - 1e-7 <= t && 0 <= t) this._locked || (this._totalTime = u, this._cycle = this._repeat), this._reversed || this._hasPausedChild() || (o = !0, a = "onComplete", r = !!this._timeline.autoRemoveChildren, 0 === this._duration && (t <= 0 && -1e-7 <= t || m < 0 || 1e-10 === m) && m !== t && this._first && (r = !0, 1e-10 < m && (a = "onReverseComplete"))), this._rawPrevTime = this._duration || !e || t || this._rawPrevTime === t ? t : 1e-10, this._yoyo && 0 != (1 & this._cycle) ? this._time = t = 0 : t = (this._time = d) + 1e-4;
|
|
else if (t < 1e-7)
|
|
if (this._locked || (this._totalTime = this._cycle = 0), ((this._time = 0) !== p || 0 === d && 1e-10 !== m && (0 < m || t < 0 && 0 <= m) && !this._locked) && (a = "onReverseComplete", o = this._reversed), t < 0) this._active = !1, this._timeline.autoRemoveChildren && this._reversed ? (r = o = !0, a = "onReverseComplete") : 0 <= m && this._first && (r = !0), this._rawPrevTime = t;
|
|
else {
|
|
if (this._rawPrevTime = d || !e || t || this._rawPrevTime === t ? t : 1e-10, 0 === t && o)
|
|
for (s = this._first; s && 0 === s._startTime;) s._duration || (o = !1), s = s._next;
|
|
t = 0, this._initted || (r = !0)
|
|
}
|
|
else if (0 === d && m < 0 && (r = !0), this._time = this._rawPrevTime = t, this._locked || (this._totalTime = t, 0 !== this._repeat && (h = d + this._repeatDelay, this._cycle = this._totalTime / h >> 0, 0 !== this._cycle && this._cycle === this._totalTime / h && y <= t && this._cycle--, this._time = this._totalTime - this._cycle * h, this._yoyo && 0 != (1 & this._cycle) && (this._time = d - this._time), this._time > d ? t = (this._time = d) + 1e-4 : this._time < 0 ? this._time = t = 0 : t = this._time)), this._hasPause && !this._forcingPlayhead && !e) {
|
|
if (p <= (t = this._time) || this._repeat && x !== this._cycle)
|
|
for (s = this._first; s && s._startTime <= t && !l;) s._duration || "isPause" !== s.data || s.ratio || 0 === s._startTime && 0 === this._rawPrevTime || (l = s), s = s._next;
|
|
else
|
|
for (s = this._last; s && s._startTime >= t && !l;) s._duration || "isPause" === s.data && 0 < s._rawPrevTime && (l = s), s = s._prev;
|
|
l && l._startTime < d && (this._time = t = l._startTime, this._totalTime = t + this._cycle * (this._totalDuration + this._repeatDelay))
|
|
}
|
|
if (this._cycle !== x && !this._locked) {
|
|
var b = this._yoyo && 0 != (1 & x),
|
|
w = b === (this._yoyo && 0 != (1 & this._cycle)),
|
|
P = this._totalTime,
|
|
_ = this._cycle,
|
|
T = this._rawPrevTime,
|
|
S = this._time;
|
|
if (this._totalTime = x * d, this._cycle < x ? b = !b : this._totalTime += d, this._time = p, this._rawPrevTime = 0 === d ? m - 1e-4 : m, this._cycle = x, this._locked = !0, p = b ? 0 : d, this.render(p, e, 0 === d), e || this._gc || this.vars.onRepeat && (this._cycle = _, this._locked = !1, this._callback("onRepeat")), p !== this._time) return;
|
|
if (w && (this._cycle = x, this._locked = !0, p = b ? d + 1e-4 : -1e-4, this.render(p, !0, !1)), this._locked = !1, this._paused && !v) return;
|
|
this._time = S, this._totalTime = P, this._cycle = _, this._rawPrevTime = T
|
|
}
|
|
if (this._time !== p && this._first || i || r || l) {
|
|
if (this._initted || (this._initted = !0), this._active || !this._paused && this._totalTime !== y && 0 < t && (this._active = !0), 0 === y && this.vars.onStart && (0 === this._totalTime && this._totalDuration || e || this._callback("onStart")), p <= (c = this._time))
|
|
for (s = this._first; s && (n = s._next, c === this._time && (!this._paused || v));)(s._active || s._startTime <= this._time && !s._paused && !s._gc) && (l === s && this.pause(), s._reversed ? s.render((s._dirty ? s.totalDuration() : s._totalDuration) - (t - s._startTime) * s._timeScale, e, i) : s.render((t - s._startTime) * s._timeScale, e, i)), s = n;
|
|
else
|
|
for (s = this._last; s && (n = s._prev, c === this._time && (!this._paused || v));) {
|
|
if (s._active || s._startTime <= p && !s._paused && !s._gc) {
|
|
if (l === s) {
|
|
for (l = s._prev; l && l.endTime() > this._time;) l.render(l._reversed ? l.totalDuration() - (t - l._startTime) * l._timeScale : (t - l._startTime) * l._timeScale, e, i), l = l._prev;
|
|
l = null, this.pause()
|
|
}
|
|
s._reversed ? s.render((s._dirty ? s.totalDuration() : s._totalDuration) - (t - s._startTime) * s._timeScale, e, i) : s.render((t - s._startTime) * s._timeScale, e, i)
|
|
}
|
|
s = n
|
|
}
|
|
this._onUpdate && (e || (k.length && B(), this._callback("onUpdate"))), a && (this._locked || this._gc || g !== this._startTime && f === this._timeScale || (0 === this._time || u >= this.totalDuration()) && (o && (k.length && B(), this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), !e && this.vars[a] && this._callback(a)))
|
|
}
|
|
else y !== this._totalTime && this._onUpdate && (e || this._callback("onUpdate"))
|
|
}, o.getActive = function(t, e, i) {
|
|
null == t && (t = !0), null == e && (e = !0), null == i && (i = !1);
|
|
var s, o, n = [],
|
|
a = this.getChildren(t, e, i),
|
|
r = 0,
|
|
h = a.length;
|
|
for (s = 0; s < h; s++)(o = a[s]).isActive() && (n[r++] = o);
|
|
return n
|
|
}, o.getLabelAfter = function(t) {
|
|
t || 0 !== t && (t = this._time);
|
|
var e, i = this.getLabelsArray(),
|
|
s = i.length;
|
|
for (e = 0; e < s; e++)
|
|
if (i[e].time > t) return i[e].name;
|
|
return null
|
|
}, o.getLabelBefore = function(t) {
|
|
null == t && (t = this._time);
|
|
for (var e = this.getLabelsArray(), i = e.length; - 1 < --i;)
|
|
if (e[i].time < t) return e[i].name;
|
|
return null
|
|
}, o.getLabelsArray = function() {
|
|
var t, e = [],
|
|
i = 0;
|
|
for (t in this._labels) e[i++] = { time: this._labels[t], name: t };
|
|
return e.sort(function(t, e) { return t.time - e.time }), e
|
|
}, o.invalidate = function() { return this._locked = !1, e.prototype.invalidate.call(this) }, o.progress = function(t, e) { return arguments.length ? this.totalTime(this.duration() * (this._yoyo && 0 != (1 & this._cycle) ? 1 - t : t) + this._cycle * (this._duration + this._repeatDelay), e) : this._time / this.duration() || 0 }, o.totalProgress = function(t, e) { return arguments.length ? this.totalTime(this.totalDuration() * t, e) : this._totalTime / this.totalDuration() || 0 }, o.totalDuration = function(t) { return arguments.length ? -1 !== this._repeat && t ? this.timeScale(this.totalDuration() / t) : this : (this._dirty && (e.prototype.totalDuration.call(this), this._totalDuration = -1 === this._repeat ? 999999999999 : this._duration * (this._repeat + 1) + this._repeatDelay * this._repeat), this._totalDuration) }, o.time = function(t, e) { return arguments.length ? (this._dirty && this.totalDuration(), t > this._duration && (t = this._duration), this._yoyo && 0 != (1 & this._cycle) ? t = this._duration - t + this._cycle * (this._duration + this._repeatDelay) : 0 !== this._repeat && (t += this._cycle * (this._duration + this._repeatDelay)), this.totalTime(t, e)) : this._time }, o.repeat = function(t) { return arguments.length ? (this._repeat = t, this._uncache(!0)) : this._repeat }, o.repeatDelay = function(t) { return arguments.length ? (this._repeatDelay = t, this._uncache(!0)) : this._repeatDelay }, o.yoyo = function(t) { return arguments.length ? (this._yoyo = t, this) : this._yoyo }, o.currentLabel = function(t) { return arguments.length ? this.seek(t, !0) : this.getLabelBefore(this._time + 1e-8) }, i
|
|
}, !0), _ = 180 / Math.PI, w = [], P = [], T = [], m = {}, i = _gsScope._gsDefine.globals, v = function(t, e, i, s) { i === s && (i = s - (s - e) / 1e6), t === e && (e = t + (i - t) / 1e6), this.a = t, this.b = e, this.c = i, this.d = s, this.da = s - t, this.ca = i - t, this.ba = e - t }, S = function(t, e, i, s) {
|
|
var o = { a: t },
|
|
n = {},
|
|
a = {},
|
|
r = { c: s },
|
|
h = (t + e) / 2,
|
|
l = (e + i) / 2,
|
|
c = (i + s) / 2,
|
|
p = (h + l) / 2,
|
|
u = (l + c) / 2,
|
|
d = (u - p) / 8;
|
|
return o.b = h + (t - h) / 4, n.b = p + d, o.c = n.a = (o.b + n.b) / 2, n.c = a.a = (p + u) / 2, a.b = u - d, r.b = c + (s - c) / 4, a.c = r.a = (a.b + r.b) / 2, [o, n, a, r]
|
|
}, x = function(t, e, i, s, o) {
|
|
var n, a, r, h, l, c, p, u, d, y, g, f, m, v = t.length - 1,
|
|
x = 0,
|
|
b = t[0].a;
|
|
for (n = 0; n < v; n++) a = (l = t[x]).a, r = l.d, h = t[x + 1].d, u = o ? (g = w[n], m = ((f = P[n]) + g) * e * .25 / (s ? .5 : T[n] || .5), r - ((c = r - (r - a) * (s ? .5 * e : 0 !== g ? m / g : 0)) + (((p = r + (h - r) * (s ? .5 * e : 0 !== f ? m / f : 0)) - c) * (3 * g / (g + f) + .5) / 4 || 0))) : r - ((c = r - (r - a) * e * .5) + (p = r + (h - r) * e * .5)) / 2, c += u, p += u, l.c = d = c, l.b = 0 !== n ? b : b = l.a + .6 * (l.c - l.a), l.da = r - a, l.ca = d - a, l.ba = b - a, i ? (y = S(a, b, d, r), t.splice(x, 1, y[0], y[1], y[2], y[3]), x += 4) : x++, b = p;
|
|
(l = t[x]).b = b, l.c = b + .4 * (l.d - b), l.da = l.d - l.a, l.ca = l.c - l.a, l.ba = b - l.a, i && (y = S(l.a, b, l.c, l.d), t.splice(x, 1, y[0], y[1], y[2], y[3]))
|
|
}, b = function(t, e, i, s) {
|
|
var o, n, a, r, h, l, c = [];
|
|
if (s)
|
|
for (n = (t = [s].concat(t)).length; - 1 < --n;) "string" == typeof(l = t[n][e]) && "=" === l.charAt(1) && (t[n][e] = s[e] + Number(l.charAt(0) + l.substr(2)));
|
|
if ((o = t.length - 2) < 0) return c[0] = new v(t[0][e], 0, 0, t[0][e]), c;
|
|
for (n = 0; n < o; n++) a = t[n][e], r = t[n + 1][e], c[n] = new v(a, 0, 0, r), i && (h = t[n + 2][e], w[n] = (w[n] || 0) + (r - a) * (r - a), P[n] = (P[n] || 0) + (h - r) * (h - r));
|
|
return c[n] = new v(t[n][e], 0, 0, t[n + 1][e]), c
|
|
}, d = function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p, u, d, y = {},
|
|
g = [],
|
|
f = n || t[0];
|
|
for (r in o = "string" == typeof o ? "," + o + "," : ",x,y,z,left,top,right,bottom,marginTop,marginLeft,marginRight,marginBottom,paddingLeft,paddingTop,paddingRight,paddingBottom,backgroundPosition,backgroundPosition_y,", null == e && (e = 1), t[0]) g.push(r);
|
|
if (1 < t.length) {
|
|
for (d = t[t.length - 1], u = !0, a = g.length; - 1 < --a;)
|
|
if (r = g[a], .05 < Math.abs(f[r] - d[r])) { u = !1; break }
|
|
u && (t = t.concat(), n && t.unshift(n), t.push(t[1]), n = t[t.length - 3])
|
|
}
|
|
for (w.length = P.length = T.length = 0, a = g.length; - 1 < --a;) r = g[a], m[r] = -1 !== o.indexOf("," + r + ","), y[r] = b(t, r, m[r], n);
|
|
for (a = w.length; - 1 < --a;) w[a] = Math.sqrt(w[a]), P[a] = Math.sqrt(P[a]);
|
|
if (!s) {
|
|
for (a = g.length; - 1 < --a;)
|
|
if (m[r])
|
|
for (p = (h = y[g[a]]).length - 1, l = 0; l < p; l++) c = h[l + 1].da / P[l] + h[l].da / w[l] || 0, T[l] = (T[l] || 0) + c * c;
|
|
for (a = T.length; - 1 < --a;) T[a] = Math.sqrt(T[a])
|
|
}
|
|
for (a = g.length, l = i ? 4 : 1; - 1 < --a;) h = y[r = g[a]], x(h, e, i, s, m[r]), u && (h.splice(0, l), h.splice(h.length - l, l));
|
|
return y
|
|
}, y = function(t, e, i) {
|
|
for (var s, o, n, a, r, h, l, c, p, u, d, y = 1 / i, g = t.length; - 1 < --g;)
|
|
for (n = (u = t[g]).a, a = u.d - n, r = u.c - n, h = u.b - n, s = o = 0, c = 1; c <= i; c++) s = o - (o = ((l = y * c) * l * a + 3 * (p = 1 - l) * (l * r + p * h)) * l), e[d = g * i + c - 1] = (e[d] || 0) + s * s
|
|
}, f = _gsScope._gsDefine.plugin({
|
|
propName: "bezier",
|
|
priority: -1,
|
|
version: "1.3.8",
|
|
API: 2,
|
|
global: !0,
|
|
init: function(t, e, i) {
|
|
this._target = t, e instanceof Array && (e = { values: e }), this._func = {}, this._mod = {}, this._props = [], this._timeRes = null == e.timeResolution ? 6 : parseInt(e.timeResolution, 10);
|
|
var s, o, n, a, r, h = e.values || [],
|
|
l = {},
|
|
c = h[0],
|
|
p = e.autoRotate || i.vars.orientToBezier;
|
|
for (s in this._autoRotate = p ? p instanceof Array ? p : [
|
|
["x", "y", "rotation", !0 === p ? 0 : Number(p) || 0]
|
|
] : null, c) this._props.push(s);
|
|
for (n = this._props.length; - 1 < --n;) s = this._props[n], this._overwriteProps.push(s), o = this._func[s] = "function" == typeof t[s], l[s] = o ? t[s.indexOf("set") || "function" != typeof t["get" + s.substr(3)] ? s : "get" + s.substr(3)]() : parseFloat(t[s]), r || l[s] !== h[0][s] && (r = l);
|
|
if (this._beziers = "cubic" !== e.type && "quadratic" !== e.type && "soft" !== e.type ? d(h, isNaN(e.curviness) ? 1 : e.curviness, !1, "thruBasic" === e.type, e.correlate, r) : function(t, e, i) {
|
|
var s, o, n, a, r, h, l, c, p, u, d, y = {},
|
|
g = "cubic" === (e = e || "soft") ? 3 : 2,
|
|
f = "soft" === e,
|
|
m = [];
|
|
if (f && i && (t = [i].concat(t)), null == t || t.length < g + 1) throw "invalid Bezier data";
|
|
for (p in t[0]) m.push(p);
|
|
for (h = m.length; - 1 < --h;) {
|
|
for (y[p = m[h]] = r = [], u = 0, c = t.length, l = 0; l < c; l++) s = null == i ? t[l][p] : "string" == typeof(d = t[l][p]) && "=" === d.charAt(1) ? i[p] + Number(d.charAt(0) + d.substr(2)) : Number(d), f && 1 < l && l < c - 1 && (r[u++] = (s + r[u - 2]) / 2), r[u++] = s;
|
|
for (c = u - g + 1, l = u = 0; l < c; l += g) s = r[l], o = r[l + 1], n = r[l + 2], a = 2 === g ? 0 : r[l + 3], r[u++] = d = 3 === g ? new v(s, o, n, a) : new v(s, (2 * o + s) / 3, (2 * o + n) / 3, n);
|
|
r.length = u
|
|
}
|
|
return y
|
|
}(h, e.type, l), this._segCount = this._beziers[s].length, this._timeRes) {
|
|
var u = function(t, e) {
|
|
var i, s, o, n, a = [],
|
|
r = [],
|
|
h = 0,
|
|
l = 0,
|
|
c = (e = e >> 0 || 6) - 1,
|
|
p = [],
|
|
u = [];
|
|
for (i in t) y(t[i], a, e);
|
|
for (o = a.length, s = 0; s < o; s++) h += Math.sqrt(a[s]), u[n = s % e] = h, n === c && (l += h, p[n = s / e >> 0] = u, r[n] = l, h = 0, u = []);
|
|
return { length: l, lengths: r, segments: p }
|
|
}(this._beziers, this._timeRes);
|
|
this._length = u.length, this._lengths = u.lengths, this._segments = u.segments, this._l1 = this._li = this._s1 = this._si = 0, this._l2 = this._lengths[0], this._curSeg = this._segments[0], this._s2 = this._curSeg[0], this._prec = 1 / this._curSeg.length
|
|
}
|
|
if (p = this._autoRotate)
|
|
for (this._initialRotations = [], p[0] instanceof Array || (this._autoRotate = p = [p]), n = p.length; - 1 < --n;) {
|
|
for (a = 0; a < 3; a++) s = p[n][a], this._func[s] = "function" == typeof t[s] && t[s.indexOf("set") || "function" != typeof t["get" + s.substr(3)] ? s : "get" + s.substr(3)];
|
|
s = p[n][2], this._initialRotations[n] = (this._func[s] ? this._func[s].call(this._target) : this._target[s]) || 0, this._overwriteProps.push(s)
|
|
}
|
|
return this._startRatio = i.vars.runBackwards ? 1 : 0, !0
|
|
},
|
|
set: function(t) {
|
|
var e, i, s, o, n, a, r, h, l, c, p = this._segCount,
|
|
u = this._func,
|
|
d = this._target,
|
|
y = t !== this._startRatio;
|
|
if (this._timeRes) {
|
|
if (l = this._lengths, c = this._curSeg, t *= this._length, s = this._li, t > this._l2 && s < p - 1) {
|
|
for (h = p - 1; s < h && (this._l2 = l[++s]) <= t;);
|
|
this._l1 = l[s - 1], this._li = s, this._curSeg = c = this._segments[s], this._s2 = c[this._s1 = this._si = 0]
|
|
}
|
|
else if (t < this._l1 && 0 < s) {
|
|
for (; 0 < s && (this._l1 = l[--s]) >= t;);
|
|
0 === s && t < this._l1 ? this._l1 = 0 : s++, this._l2 = l[s], this._li = s, this._curSeg = c = this._segments[s], this._s1 = c[(this._si = c.length - 1) - 1] || 0, this._s2 = c[this._si]
|
|
}
|
|
if (e = s, t -= this._l1, s = this._si, t > this._s2 && s < c.length - 1) {
|
|
for (h = c.length - 1; s < h && (this._s2 = c[++s]) <= t;);
|
|
this._s1 = c[s - 1], this._si = s
|
|
}
|
|
else if (t < this._s1 && 0 < s) {
|
|
for (; 0 < s && (this._s1 = c[--s]) >= t;);
|
|
0 === s && t < this._s1 ? this._s1 = 0 : s++, this._s2 = c[s], this._si = s
|
|
}
|
|
a = (s + (t - this._s1) / (this._s2 - this._s1)) * this._prec || 0
|
|
}
|
|
else a = (t - (e = t < 0 ? 0 : 1 <= t ? p - 1 : p * t >> 0) * (1 / p)) * p;
|
|
for (i = 1 - a, s = this._props.length; - 1 < --s;) o = this._props[s], r = (a * a * (n = this._beziers[o][e]).da + 3 * i * (a * n.ca + i * n.ba)) * a + n.a, this._mod[o] && (r = this._mod[o](r, d)), u[o] ? d[o](r) : d[o] = r;
|
|
if (this._autoRotate) { var g, f, m, v, x, b, w, P = this._autoRotate; for (s = P.length; - 1 < --s;) o = P[s][2], b = P[s][3] || 0, w = !0 === P[s][4] ? 1 : _, n = this._beziers[P[s][0]], g = this._beziers[P[s][1]], n && g && (n = n[e], g = g[e], f = n.a + (n.b - n.a) * a, f += ((v = n.b + (n.c - n.b) * a) - f) * a, v += (n.c + (n.d - n.c) * a - v) * a, m = g.a + (g.b - g.a) * a, m += ((x = g.b + (g.c - g.b) * a) - m) * a, x += (g.c + (g.d - g.c) * a - x) * a, r = y ? Math.atan2(x - m, v - f) * w + b : this._initialRotations[s], this._mod[o] && (r = this._mod[o](r, d)), u[o] ? d[o](r) : d[o] = r) }
|
|
}
|
|
}), t = f.prototype, f.bezierThrough = d, f.cubicToQuadratic = S, f._autoCSS = !0, f.quadraticToCubic = function(t, e, i) { return new v(t, (2 * e + t) / 3, (2 * e + i) / 3, i) }, f._cssRegister = function() {
|
|
var t = i.CSSPlugin;
|
|
if (t) {
|
|
var e = t._internals,
|
|
d = e._parseToProxy,
|
|
y = e._setPluginRatio,
|
|
g = e.CSSPropTween;
|
|
e._registerComplexSpecialProp("bezier", {
|
|
parser: function(t, e, i, s, o, n) {
|
|
e instanceof Array && (e = { values: e }), n = new f;
|
|
var a, r, h, l = e.values,
|
|
c = l.length - 1,
|
|
p = [],
|
|
u = {};
|
|
if (c < 0) return o;
|
|
for (a = 0; a <= c; a++) h = d(t, l[a], s, o, n, c !== a), p[a] = h.end;
|
|
for (r in e) u[r] = e[r];
|
|
return u.values = p, (o = new g(t, "bezier", 0, 0, h.pt, 2)).data = h, o.plugin = n, o.setRatio = y, 0 === u.autoRotate && (u.autoRotate = !0), !u.autoRotate || u.autoRotate instanceof Array || (a = !0 === u.autoRotate ? 0 : Number(u.autoRotate), u.autoRotate = null != h.end.left ? [
|
|
["left", "top", "rotation", a, !1]
|
|
] : null != h.end.x && [
|
|
["x", "y", "rotation", a, !1]
|
|
]), u.autoRotate && (s._transform || s._enableTransforms(!1), h.autoRotate = s._target._gsTransform, h.proxy.rotation = h.autoRotate.rotation || 0, s._overwriteProps.push("rotation")), n._onInitTween(h.proxy, u, s._tween), o
|
|
}
|
|
})
|
|
}
|
|
}, t._mod = function(t) { for (var e, i = this._overwriteProps, s = i.length; - 1 < --s;)(e = t[i[s]]) && "function" == typeof e && (this._mod[i[s]] = e) }, t._kill = function(t) {
|
|
var e, i, s = this._props;
|
|
for (e in this._beziers)
|
|
if (e in t)
|
|
for (delete this._beziers[e], delete this._func[e], i = s.length; - 1 < --i;) s[i] === e && s.splice(i, 1);
|
|
if (s = this._autoRotate)
|
|
for (i = s.length; - 1 < --i;) t[s[i][2]] && s.splice(i, 1);
|
|
return this._super._kill.call(this, t)
|
|
}, _gsScope._gsDefine("plugins.CSSPlugin", ["plugins.TweenPlugin", "TweenLite"], function(n, N) {
|
|
var y, T, k, g, V = function() { n.call(this, "css"), this._overwriteProps.length = 0, this.setRatio = V.prototype.setRatio },
|
|
l = _gsScope._gsDefine.globals,
|
|
f = {},
|
|
t = V.prototype = new n("css");
|
|
(t.constructor = V).version = "1.20.5", V.API = 2, V.defaultTransformPerspective = 0, V.defaultSkewType = "compensated", V.defaultSmoothOrigin = !0, t = "px", V.suffixMap = { top: t, right: t, bottom: t, left: t, width: t, height: t, fontSize: t, padding: t, margin: t, perspective: t, lineHeight: "" };
|
|
var B, m, v, F, x, S, A, C, e, i, I = /(?:\-|\.|\b)(\d|\.|e\-)+/g,
|
|
E = /(?:\d|\-\d|\.\d|\-\.\d|\+=\d|\-=\d|\+=.\d|\-=\.\d)+/g,
|
|
b = /(?:\+=|\-=|\-|\b)[\d\-\.]+[a-zA-Z0-9]*(?:%|\b)/gi,
|
|
c = /(?![+-]?\d*\.?\d+|[+-]|e[+-]\d+)[^0-9]/g,
|
|
O = /(?:\d|\-|\+|=|#|\.)*/g,
|
|
M = /opacity *= *([^)]*)/i,
|
|
w = /opacity:([^;]*)/i,
|
|
a = /alpha\(opacity *=.+?\)/i,
|
|
P = /^(rgb|hsl)/,
|
|
r = /([A-Z])/g,
|
|
h = /-([a-z])/gi,
|
|
_ = /(^(?:url\(\"|url\())|(?:(\"\))$|\)$)/gi,
|
|
p = function(t, e) { return e.toUpperCase() },
|
|
d = /(?:Left|Right|Width)/i,
|
|
u = /(M11|M12|M21|M22)=[\d\-\.e]+/gi,
|
|
L = /progid\:DXImageTransform\.Microsoft\.Matrix\(.+?\)/i,
|
|
R = /,(?=[^\)]*(?:\(|$))/gi,
|
|
D = /[\s,\(]/i,
|
|
U = Math.PI / 180,
|
|
H = 180 / Math.PI,
|
|
G = {},
|
|
s = { style: {} },
|
|
z = _gsScope.document || { createElement: function() { return s } },
|
|
X = function(t, e) { return z.createElementNS ? z.createElementNS(e || "http://www.w3.org/1999/xhtml", t) : z.createElement(t) },
|
|
j = X("div"),
|
|
W = X("img"),
|
|
o = V._internals = { _specialProps: f },
|
|
q = (_gsScope.navigator || {}).userAgent || "",
|
|
Y = (e = q.indexOf("Android"), i = X("a"), v = -1 !== q.indexOf("Safari") && -1 === q.indexOf("Chrome") && (-1 === e || 3 < parseFloat(q.substr(e + 8, 2))), x = v && parseFloat(q.substr(q.indexOf("Version/") + 8, 2)) < 6, F = -1 !== q.indexOf("Firefox"), (/MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(q) || /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(q)) && (S = parseFloat(RegExp.$1)), !!i && (i.style.cssText = "top:1px;opacity:.55;", /^0.55/.test(i.style.opacity))),
|
|
K = function(t) { return M.test("string" == typeof t ? t : (t.currentStyle ? t.currentStyle.filter : t.style.filter) || "") ? parseFloat(RegExp.$1) / 100 : 1 },
|
|
Q = function(t) { _gsScope.console },
|
|
J = "",
|
|
Z = "",
|
|
$ = function(t, e) { var i, s, o = (e = e || j).style; if (void 0 !== o[t]) return t; for (t = t.charAt(0).toUpperCase() + t.substr(1), i = ["O", "Moz", "ms", "Ms", "Webkit"], s = 5; - 1 < --s && void 0 === o[i[s] + t];); return 0 <= s ? (J = "-" + (Z = 3 === s ? "ms" : i[s]).toLowerCase() + "-", Z + t) : null },
|
|
tt = ("undefined" != typeof window ? window : z.defaultView || { getComputedStyle: function() {} }).getComputedStyle,
|
|
et = V.getStyle = function(t, e, i, s, o) { var n; return Y || "opacity" !== e ? (!s && t.style[e] ? n = t.style[e] : (i = i || tt(t)) ? n = i[e] || i.getPropertyValue(e) || i.getPropertyValue(e.replace(r, "-$1").toLowerCase()) : t.currentStyle && (n = t.currentStyle[e]), null == o || n && "none" !== n && "auto" !== n && "auto auto" !== n ? n : o) : K(t) },
|
|
it = o.convertToPixels = function(t, e, i, s, o) {
|
|
if ("px" === s || !s && "lineHeight" !== e) return i;
|
|
if ("auto" === s || !i) return 0;
|
|
var n, a, r, h = d.test(e),
|
|
l = t,
|
|
c = j.style,
|
|
p = i < 0,
|
|
u = 1 === i;
|
|
if (p && (i = -i), u && (i *= 100), "lineHeight" !== e || s)
|
|
if ("%" === s && -1 !== e.indexOf("border")) n = i / 100 * (h ? t.clientWidth : t.clientHeight);
|
|
else {
|
|
if (c.cssText = "border:0 solid red;position:" + et(t, "position") + ";line-height:0;", "%" !== s && l.appendChild && "v" !== s.charAt(0) && "rem" !== s) c[h ? "borderLeftWidth" : "borderTopWidth"] = i + s;
|
|
else {
|
|
if (l = t.parentNode || z.body, -1 !== et(l, "display").indexOf("flex") && (c.position = "absolute"), a = l._gsCache, r = N.ticker.frame, a && h && a.time === r) return a.width * i / 100;
|
|
c[h ? "width" : "height"] = i + s
|
|
}
|
|
l.appendChild(j), n = parseFloat(j[h ? "offsetWidth" : "offsetHeight"]), l.removeChild(j), h && "%" === s && !1 !== V.cacheWidths && ((a = l._gsCache = l._gsCache || {}).time = r, a.width = n / i * 100), 0 !== n || o || (n = it(t, e, i, s, !0))
|
|
}
|
|
else a = tt(t).lineHeight, t.style.lineHeight = i, n = parseFloat(tt(t).lineHeight), t.style.lineHeight = a;
|
|
return u && (n /= 100), p ? -n : n
|
|
},
|
|
st = o.calculateOffset = function(t, e, i) {
|
|
if ("absolute" !== et(t, "position", i)) return 0;
|
|
var s = "left" === e ? "Left" : "Top",
|
|
o = et(t, "margin" + s, i);
|
|
return t["offset" + s] - (it(t, e, parseFloat(o), o.replace(O, "")) || 0)
|
|
},
|
|
ot = function(t, e) {
|
|
var i, s, o, n = {};
|
|
if (e = e || tt(t, null))
|
|
if (i = e.length)
|
|
for (; - 1 < --i;) - 1 !== (o = e[i]).indexOf("-transform") && Rt !== o || (n[o.replace(h, p)] = e.getPropertyValue(o));
|
|
else
|
|
for (i in e) - 1 !== i.indexOf("Transform") && Lt !== i || (n[i] = e[i]);
|
|
else if (e = t.currentStyle || t.style)
|
|
for (i in e) "string" == typeof i && void 0 === n[i] && (n[i.replace(h, p)] = e[i]);
|
|
return Y || (n.opacity = K(t)), s = Yt(t, e, !1), n.rotation = s.rotation, n.skewX = s.skewX, n.scaleX = s.scaleX, n.scaleY = s.scaleY, n.x = s.x, n.y = s.y, Ft && (n.z = s.z, n.rotationX = s.rotationX, n.rotationY = s.rotationY, n.scaleZ = s.scaleZ), n.filters && delete n.filters, n
|
|
},
|
|
nt = function(t, e, i, s, o) {
|
|
var n, a, r, h = {},
|
|
l = t.style;
|
|
for (a in i) "cssText" !== a && "length" !== a && isNaN(a) && (e[a] !== (n = i[a]) || o && o[a]) && -1 === a.indexOf("Origin") && ("number" != typeof n && "string" != typeof n || (h[a] = "auto" !== n || "left" !== a && "top" !== a ? "" !== n && "auto" !== n && "none" !== n || "string" != typeof e[a] || "" === e[a].replace(c, "") ? n : 0 : st(t, a), void 0 !== l[a] && (r = new bt(l, a, l[a], r))));
|
|
if (s)
|
|
for (a in s) "className" !== a && (h[a] = s[a]);
|
|
return { difs: h, firstMPT: r }
|
|
},
|
|
at = { width: ["Left", "Right"], height: ["Top", "Bottom"] },
|
|
rt = ["marginLeft", "marginRight", "marginTop", "marginBottom"],
|
|
ht = function(t, e, i) {
|
|
if ("svg" === (t.nodeName + "").toLowerCase()) return (i || tt(t))[e] || 0;
|
|
if (t.getCTM && jt(t)) return t.getBBox()[e] || 0;
|
|
var s = parseFloat("width" === e ? t.offsetWidth : t.offsetHeight),
|
|
o = at[e],
|
|
n = o.length;
|
|
for (i = i || tt(t, null); - 1 < --n;) s -= parseFloat(et(t, "padding" + o[n], i, !0)) || 0, s -= parseFloat(et(t, "border" + o[n] + "Width", i, !0)) || 0;
|
|
return s
|
|
},
|
|
lt = function(t, e) {
|
|
if ("contain" === t || "auto" === t || "auto auto" === t) return t + " ";
|
|
null != t && "" !== t || (t = "0 0");
|
|
var i, s = t.split(" "),
|
|
o = -1 !== t.indexOf("left") ? "0%" : -1 !== t.indexOf("right") ? "100%" : s[0],
|
|
n = -1 !== t.indexOf("top") ? "0%" : -1 !== t.indexOf("bottom") ? "100%" : s[1];
|
|
if (3 < s.length && !e) { for (s = t.split(", ").join(",").split(","), t = [], i = 0; i < s.length; i++) t.push(lt(s[i])); return t.join(",") }
|
|
return null == n ? n = "center" === o ? "50%" : "0" : "center" === n && (n = "50%"), ("center" === o || isNaN(parseFloat(o)) && -1 === (o + "").indexOf("=")) && (o = "50%"), t = o + " " + n + (2 < s.length ? " " + s[2] : ""), e && (e.oxp = -1 !== o.indexOf("%"), e.oyp = -1 !== n.indexOf("%"), e.oxr = "=" === o.charAt(1), e.oyr = "=" === n.charAt(1), e.ox = parseFloat(o.replace(c, "")), e.oy = parseFloat(n.replace(c, "")), e.v = t), e || t
|
|
},
|
|
ct = function(t, e) { return "function" == typeof t && (t = t(C, A)), "string" == typeof t && "=" === t.charAt(1) ? parseInt(t.charAt(0) + "1", 10) * parseFloat(t.substr(2)) : parseFloat(t) - parseFloat(e) || 0 },
|
|
pt = function(t, e) { return "function" == typeof t && (t = t(C, A)), null == t ? e : "string" == typeof t && "=" === t.charAt(1) ? parseInt(t.charAt(0) + "1", 10) * parseFloat(t.substr(2)) + e : parseFloat(t) || 0 },
|
|
ut = function(t, e, i, s) { var o, n, a, r; return "function" == typeof t && (t = t(C, A)), (a = null == t ? e : "number" == typeof t ? t : (360, o = t.split("_"), n = ((r = "=" === t.charAt(1)) ? parseInt(t.charAt(0) + "1", 10) * parseFloat(o[0].substr(2)) : parseFloat(o[0])) * (-1 === t.indexOf("rad") ? 1 : H) - (r ? 0 : e), o.length && (s && (s[i] = e + n), -1 !== t.indexOf("short") && (n %= 360) !== n % 180 && (n = n < 0 ? n + 360 : n - 360), -1 !== t.indexOf("_cw") && n < 0 ? n = (n + 3599999999640) % 360 - 360 * (n / 360 | 0) : -1 !== t.indexOf("ccw") && 0 < n && (n = (n - 3599999999640) % 360 - 360 * (n / 360 | 0))), e + n)) < 1e-6 && -1e-6 < a && (a = 0), a },
|
|
dt = { aqua: [0, 255, 255], lime: [0, 255, 0], silver: [192, 192, 192], black: [0, 0, 0], maroon: [128, 0, 0], teal: [0, 128, 128], blue: [0, 0, 255], navy: [0, 0, 128], white: [255, 255, 255], fuchsia: [255, 0, 255], olive: [128, 128, 0], yellow: [255, 255, 0], orange: [255, 165, 0], gray: [128, 128, 128], purple: [128, 0, 128], green: [0, 128, 0], red: [255, 0, 0], pink: [255, 192, 203], cyan: [0, 255, 255], transparent: [255, 255, 255, 0] },
|
|
yt = function(t, e, i) { return 255 * (6 * (t = t < 0 ? t + 1 : 1 < t ? t - 1 : t) < 1 ? e + (i - e) * t * 6 : t < .5 ? i : 3 * t < 2 ? e + (i - e) * (2 / 3 - t) * 6 : e) + .5 | 0 },
|
|
gt = V.parseColor = function(t, e) {
|
|
var i, s, o, n, a, r, h, l, c, p, u;
|
|
if (t)
|
|
if ("number" == typeof t) i = [t >> 16, t >> 8 & 255, 255 & t];
|
|
else {
|
|
if ("," === t.charAt(t.length - 1) && (t = t.substr(0, t.length - 1)), dt[t]) i = dt[t];
|
|
else if ("#" === t.charAt(0)) 4 === t.length && (t = "#" + (s = t.charAt(1)) + s + (o = t.charAt(2)) + o + (n = t.charAt(3)) + n), i = [(t = parseInt(t.substr(1), 16)) >> 16, t >> 8 & 255, 255 & t];
|
|
else if ("hsl" === t.substr(0, 3))
|
|
if (i = u = t.match(I), e) { if (-1 !== t.indexOf("=")) return t.match(E) }
|
|
else a = Number(i[0]) % 360 / 360, r = Number(i[1]) / 100, s = 2 * (h = Number(i[2]) / 100) - (o = h <= .5 ? h * (r + 1) : h + r - h * r), 3 < i.length && (i[3] = Number(i[3])), i[0] = yt(a + 1 / 3, s, o), i[1] = yt(a, s, o), i[2] = yt(a - 1 / 3, s, o);
|
|
else i = t.match(I) || dt.transparent;
|
|
i[0] = Number(i[0]), i[1] = Number(i[1]), i[2] = Number(i[2]), 3 < i.length && (i[3] = Number(i[3]))
|
|
}
|
|
else i = dt.black;
|
|
return e && !u && (s = i[0] / 255, o = i[1] / 255, n = i[2] / 255, h = ((l = Math.max(s, o, n)) + (c = Math.min(s, o, n))) / 2, l === c ? a = r = 0 : (p = l - c, r = .5 < h ? p / (2 - l - c) : p / (l + c), a = l === s ? (o - n) / p + (o < n ? 6 : 0) : l === o ? (n - s) / p + 2 : (s - o) / p + 4, a *= 60), i[0] = a + .5 | 0, i[1] = 100 * r + .5 | 0, i[2] = 100 * h + .5 | 0), i
|
|
},
|
|
ft = function(t, e) {
|
|
var i, s, o, n = t.match(mt) || [],
|
|
a = 0,
|
|
r = "";
|
|
if (!n.length) return t;
|
|
for (i = 0; i < n.length; i++) s = n[i], a += (o = t.substr(a, t.indexOf(s, a) - a)).length + s.length, 3 === (s = gt(s, e)).length && s.push(1), r += o + (e ? "hsla(" + s[0] + "," + s[1] + "%," + s[2] + "%," + s[3] : "rgba(" + s.join(",")) + ")";
|
|
return r + t.substr(a)
|
|
},
|
|
mt = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3}){1,2}\\b";
|
|
for (t in dt) mt += "|" + t + "\\b";
|
|
mt = new RegExp(mt + ")", "gi"), V.colorStringFilter = function(t) {
|
|
var e, i = t[0] + " " + t[1];
|
|
mt.test(i) && (e = -1 !== i.indexOf("hsl(") || -1 !== i.indexOf("hsla("), t[0] = ft(t[0], e), t[1] = ft(t[1], e)), mt.lastIndex = 0
|
|
}, N.defaultStringFilter || (N.defaultStringFilter = V.colorStringFilter);
|
|
var vt = function(t, e, n, a) {
|
|
if (null == t) return function(t) { return t };
|
|
var r, h = e ? (t.match(mt) || [""])[0] : "",
|
|
l = t.split(h).join("").match(b) || [],
|
|
c = t.substr(0, t.indexOf(l[0])),
|
|
p = ")" === t.charAt(t.length - 1) ? ")" : "",
|
|
u = -1 !== t.indexOf(" ") ? " " : ",",
|
|
d = l.length,
|
|
y = 0 < d ? l[0].replace(I, "") : "";
|
|
return d ? r = e ? function(t) {
|
|
var e, i, s, o;
|
|
if ("number" == typeof t) t += y;
|
|
else if (a && R.test(t)) { for (o = t.replace(R, "|").split("|"), s = 0; s < o.length; s++) o[s] = r(o[s]); return o.join(",") }
|
|
if (e = (t.match(mt) || [h])[0], s = (i = t.split(e).join("").match(b) || []).length, d > s--)
|
|
for (; ++s < d;) i[s] = n ? i[(s - 1) / 2 | 0] : l[s];
|
|
return c + i.join(u) + u + e + p + (-1 !== t.indexOf("inset") ? " inset" : "")
|
|
} : function(t) {
|
|
var e, i, s;
|
|
if ("number" == typeof t) t += y;
|
|
else if (a && R.test(t)) { for (i = t.replace(R, "|").split("|"), s = 0; s < i.length; s++) i[s] = r(i[s]); return i.join(",") }
|
|
if (s = (e = t.match(b) || []).length, d > s--)
|
|
for (; ++s < d;) e[s] = n ? e[(s - 1) / 2 | 0] : l[s];
|
|
return c + e.join(u) + p
|
|
} : function(t) { return t }
|
|
},
|
|
xt = function(l) {
|
|
return l = l.split(","),
|
|
function(t, e, i, s, o, n, a) { var r, h = (e + "").split(" "); for (a = {}, r = 0; r < 4; r++) a[l[r]] = h[r] = h[r] || h[(r - 1) / 2 >> 0]; return s.parse(t, a, o, n) }
|
|
},
|
|
bt = (o._setPluginRatio = function(t) {
|
|
this.plugin.setRatio(t);
|
|
for (var e, i, s, o, n, a = this.data, r = a.proxy, h = a.firstMPT; h;) e = r[h.v], h.r ? e = h.r(e) : e < 1e-6 && -1e-6 < e && (e = 0), h.t[h.p] = e, h = h._next;
|
|
if (a.autoRotate && (a.autoRotate.rotation = a.mod ? a.mod.call(this._tween, r.rotation, this.t, this._tween) : r.rotation), 1 === t || 0 === t)
|
|
for (h = a.firstMPT, n = 1 === t ? "e" : "b"; h;) {
|
|
if ((i = h.t).type) {
|
|
if (1 === i.type) {
|
|
for (o = i.xs0 + i.s + i.xs1, s = 1; s < i.l; s++) o += i["xn" + s] + i["xs" + (s + 1)];
|
|
i[n] = o
|
|
}
|
|
}
|
|
else i[n] = i.s + i.xs0;
|
|
h = h._next
|
|
}
|
|
}, function(t, e, i, s, o) { this.t = t, this.p = e, this.v = i, this.r = o, s && ((s._prev = this)._next = s) }),
|
|
wt = (o._parseToProxy = function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p = s,
|
|
u = {},
|
|
d = {},
|
|
y = i._transform,
|
|
g = G;
|
|
for (i._transform = null, G = e, s = c = i.parse(t, e, s, o), G = g, n && (i._transform = y, p && (p._prev = null, p._prev && (p._prev._next = null))); s && s !== p;) {
|
|
if (s.type <= 1 && (d[r = s.p] = s.s + s.c, u[r] = s.s, n || (l = new bt(s, "s", r, l, s.r), s.c = 0), 1 === s.type))
|
|
for (a = s.l; 0 < --a;) h = "xn" + a, d[r = s.p + "_" + h] = s.data[h], u[r] = s[h], n || (l = new bt(s, h, r, l, s.rxp[h]));
|
|
s = s._next
|
|
}
|
|
return { proxy: u, end: d, firstMPT: l, pt: c }
|
|
}, o.CSSPropTween = function(t, e, i, s, o, n, a, r, h, l, c) { this.t = t, this.p = e, this.s = i, this.c = s, this.n = a || e, t instanceof wt || g.push(this.n), this.r = r ? "function" == typeof r ? r : Math.round : r, this.type = n || 0, h && (this.pr = h, y = !0), this.b = void 0 === l ? i : l, this.e = void 0 === c ? i + s : c, o && ((this._next = o)._prev = this) }),
|
|
Pt = function(t, e, i, s, o, n) { var a = new wt(t, e, i, s - i, o, -1, n); return a.b = i, a.e = a.xs0 = s, a },
|
|
_t = V.parseComplex = function(t, e, i, s, o, n, a, r, h, l) {
|
|
i = i || n || "", "function" == typeof s && (s = s(C, A)), a = new wt(t, e, 0, 0, a, l ? 2 : 1, null, !1, r, i, s), s += "", o && mt.test(s + i) && (s = [i, s], V.colorStringFilter(s), i = s[0], s = s[1]);
|
|
var c, p, u, d, y, g, f, m, v, x, b, w, P, _ = i.split(", ").join(",").split(" "),
|
|
T = s.split(", ").join(",").split(" "),
|
|
S = _.length,
|
|
k = !1 !== B;
|
|
for (-1 === s.indexOf(",") && -1 === i.indexOf(",") || (T = -1 !== (s + i).indexOf("rgb") || -1 !== (s + i).indexOf("hsl") ? (_ = _.join(" ").replace(R, ", ").split(" "), T.join(" ").replace(R, ", ").split(" ")) : (_ = _.join(" ").split(",").join(", ").split(" "), T.join(" ").split(",").join(", ").split(" ")), S = _.length), S !== T.length && (S = (_ = (n || "").split(" ")).length), a.plugin = h, a.setRatio = l, c = mt.lastIndex = 0; c < S; c++)
|
|
if (d = _[c], y = T[c] + "", (m = parseFloat(d)) || 0 === m) a.appendXtra("", m, ct(y, m), y.replace(E, ""), !(!k || -1 === y.indexOf("px")) && Math.round, !0);
|
|
else if (o && mt.test(d)) w = ")" + ((w = y.indexOf(")") + 1) ? y.substr(w) : ""), P = -1 !== y.indexOf("hsl") && Y, x = y, d = gt(d, P), y = gt(y, P), (v = 6 < d.length + y.length) && !Y && 0 === y[3] ? (a["xs" + a.l] += a.l ? " transparent" : "transparent", a.e = a.e.split(T[c]).join("transparent")) : (Y || (v = !1), P ? a.appendXtra(x.substr(0, x.indexOf("hsl")) + (v ? "hsla(" : "hsl("), d[0], ct(y[0], d[0]), ",", !1, !0).appendXtra("", d[1], ct(y[1], d[1]), "%,", !1).appendXtra("", d[2], ct(y[2], d[2]), v ? "%," : "%" + w, !1) : a.appendXtra(x.substr(0, x.indexOf("rgb")) + (v ? "rgba(" : "rgb("), d[0], y[0] - d[0], ",", Math.round, !0).appendXtra("", d[1], y[1] - d[1], ",", Math.round).appendXtra("", d[2], y[2] - d[2], v ? "," : w, Math.round), v && (d = d.length < 4 ? 1 : d[3], a.appendXtra("", d, (y.length < 4 ? 1 : y[3]) - d, w, !1))), mt.lastIndex = 0;
|
|
else if (g = d.match(I)) {
|
|
if (!(f = y.match(E)) || f.length !== g.length) return a;
|
|
for (p = u = 0; p < g.length; p++) b = g[p], x = d.indexOf(b, u), a.appendXtra(d.substr(u, x - u), Number(b), ct(f[p], b), "", !(!k || "px" !== d.substr(x + b.length, 2)) && Math.round, 0 === p), u = x + b.length;
|
|
a["xs" + a.l] += d.substr(u)
|
|
}
|
|
else a["xs" + a.l] += a.l || a["xs" + a.l] ? " " + y : y;
|
|
if (-1 !== s.indexOf("=") && a.data) {
|
|
for (w = a.xs0 + a.data.s, c = 1; c < a.l; c++) w += a["xs" + c] + a.data["xn" + c];
|
|
a.e = w + a["xs" + c]
|
|
}
|
|
return a.l || (a.type = -1, a.xs0 = a.e), a.xfirst || a
|
|
},
|
|
Tt = 9;
|
|
for ((t = wt.prototype).l = t.pr = 0; 0 < --Tt;) t["xn" + Tt] = 0, t["xs" + Tt] = "";
|
|
t.xs0 = "", t._next = t._prev = t.xfirst = t.data = t.plugin = t.setRatio = t.rxp = null, t.appendXtra = function(t, e, i, s, o, n) {
|
|
var a = this,
|
|
r = a.l;
|
|
return a["xs" + r] += n && (r || a["xs" + r]) ? " " + t : t || "", i || 0 === r || a.plugin ? (a.l++, a.type = a.setRatio ? 2 : 1, a["xs" + a.l] = s || "", 0 < r ? (a.data["xn" + r] = e + i, a.rxp["xn" + r] = o, a["xn" + r] = e, a.plugin || (a.xfirst = new wt(a, "xn" + r, e, i, a.xfirst || a, 0, a.n, o, a.pr), a.xfirst.xs0 = 0)) : (a.data = { s: e + i }, a.rxp = {}, a.s = e, a.c = i, a.r = o), a) : (a["xs" + r] += e + (s || ""), a)
|
|
};
|
|
var St = function(t, e) { e = e || {}, this.p = e.prefix && $(t) || t, f[t] = f[this.p] = this, this.format = e.formatter || vt(e.defaultValue, e.color, e.collapsible, e.multi), e.parser && (this.parse = e.parser), this.clrs = e.color, this.multi = e.multi, this.keyword = e.keyword, this.dflt = e.defaultValue, this.pr = e.priority || 0 },
|
|
kt = o._registerComplexSpecialProp = function(t, e, i) {
|
|
"object" != typeof e && (e = { parser: i });
|
|
var s, o = t.split(","),
|
|
n = e.defaultValue;
|
|
for (i = i || [n], s = 0; s < o.length; s++) e.prefix = 0 === s && e.prefix, e.defaultValue = i[s] || n, new St(o[s], e)
|
|
},
|
|
Bt = o._registerPluginProp = function(t) {
|
|
if (!f[t]) {
|
|
var h = t.charAt(0).toUpperCase() + t.substr(1) + "Plugin";
|
|
kt(t, { parser: function(t, e, i, s, o, n, a) { var r = l.com.greensock.plugins[h]; return r ? (r._cssRegister(), f[i].parse(t, e, i, s, o, n, a)) : (Q(), o) } })
|
|
}
|
|
};
|
|
(t = St.prototype).parseComplex = function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p, u = this.keyword;
|
|
if (this.multi && (R.test(i) || R.test(e) ? (r = e.replace(R, "|").split("|"), h = i.replace(R, "|").split("|")) : u && (r = [e], h = [i])), h) {
|
|
for (l = h.length > r.length ? h.length : r.length, a = 0; a < l; a++) e = r[a] = r[a] || this.dflt, i = h[a] = h[a] || this.dflt, u && (c = e.indexOf(u)) !== (p = i.indexOf(u)) && (-1 === p ? r[a] = r[a].split(u).join("") : -1 === c && (r[a] += " " + u));
|
|
e = r.join(", "), i = h.join(", ")
|
|
}
|
|
return _t(t, this.p, e, i, this.clrs, this.dflt, s, this.pr, o, n)
|
|
}, t.parse = function(t, e, i, s, o, n, a) { return this.parseComplex(t.style, this.format(et(t, this.p, k, !1, this.dflt)), this.format(e), o, n) }, V.registerSpecialProp = function(t, h, l) { kt(t, { parser: function(t, e, i, s, o, n, a) { var r = new wt(t, i, 0, 0, o, 2, i, !1, l); return r.plugin = n, r.setRatio = h(t, e, s._tween, i), r }, priority: l }) }, V.useSVGTransformAttr = !0;
|
|
var At, Ct, It, Et, Ot, Mt = "scaleX,scaleY,scaleZ,x,y,z,skewX,skewY,rotation,rotationX,rotationY,perspective,xPercent,yPercent".split(","),
|
|
Lt = $("transform"),
|
|
Rt = J + "transform",
|
|
Dt = $("transformOrigin"),
|
|
Ft = null !== $("perspective"),
|
|
Ut = o.Transform = function() { this.perspective = parseFloat(V.defaultTransformPerspective) || 0, this.force3D = !(!1 === V.defaultForce3D || !Ft) && (V.defaultForce3D || "auto") },
|
|
Gt = _gsScope.SVGElement,
|
|
Nt = function(t, e, i) {
|
|
var s, o = z.createElementNS("http://www.w3.org/2000/svg", t),
|
|
n = /([a-z])([A-Z])/g;
|
|
for (s in i) o.setAttributeNS(null, s.replace(n, "$1-$2").toLowerCase(), i[s]);
|
|
return e.appendChild(o), o
|
|
},
|
|
Vt = z.documentElement || {},
|
|
Ht = (Ot = S || /Android/i.test(q) && !_gsScope.chrome, z.createElementNS && !Ot && (Ct = Nt("svg", Vt), Et = (It = Nt("rect", Ct, { width: 100, height: 50, x: 100 })).getBoundingClientRect().width, It.style[Dt] = "50% 50%", It.style[Lt] = "scaleX(0.5)", Ot = Et === It.getBoundingClientRect().width && !(F && Ft), Vt.removeChild(Ct)), Ot),
|
|
zt = function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p, u, d, y, g, f, m, v, x, b = t._gsTransform,
|
|
w = qt(t, !0);
|
|
b && (v = b.xOrigin, x = b.yOrigin), (!s || (a = s.split(" ")).length < 2) && (0 === (u = t.getBBox()).x && 0 === u.y && u.width + u.height === 0 && (u = { x: parseFloat(t.hasAttribute("x") ? t.getAttribute("x") : t.hasAttribute("cx") ? t.getAttribute("cx") : 0) || 0, y: parseFloat(t.hasAttribute("y") ? t.getAttribute("y") : t.hasAttribute("cy") ? t.getAttribute("cy") : 0) || 0, width: 0, height: 0 }), a = [(-1 !== (e = lt(e).split(" "))[0].indexOf("%") ? parseFloat(e[0]) / 100 * u.width : parseFloat(e[0])) + u.x, (-1 !== e[1].indexOf("%") ? parseFloat(e[1]) / 100 * u.height : parseFloat(e[1])) + u.y]), i.xOrigin = l = parseFloat(a[0]), i.yOrigin = c = parseFloat(a[1]), s && w !== Wt && (p = w[0], u = w[1], d = w[2], y = w[3], g = w[4], f = w[5], (m = p * y - u * d) && (r = l * (y / m) + c * (-d / m) + (d * f - y * g) / m, h = l * (-u / m) + c * (p / m) - (p * f - u * g) / m, l = i.xOrigin = a[0] = r, c = i.yOrigin = a[1] = h)), b && (n && (i.xOffset = b.xOffset, i.yOffset = b.yOffset, b = i), o || !1 !== o && !1 !== V.defaultSmoothOrigin ? (r = l - v, h = c - x, b.xOffset += r * w[0] + h * w[2] - r, b.yOffset += r * w[1] + h * w[3] - h) : b.xOffset = b.yOffset = 0), n || t.setAttribute("data-svg-origin", a.join(" "))
|
|
},
|
|
Xt = function(t) {
|
|
var e, i = X("svg", this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg"),
|
|
s = this.parentNode,
|
|
o = this.nextSibling,
|
|
n = this.style.cssText;
|
|
if (Vt.appendChild(i), i.appendChild(this), this.style.display = "block", t) try { e = this.getBBox(), this._originalGetBBox = this.getBBox, this.getBBox = Xt }
|
|
catch (t) {}
|
|
else this._originalGetBBox && (e = this._originalGetBBox());
|
|
return o ? s.insertBefore(this, o) : s.appendChild(this), Vt.removeChild(i), this.style.cssText = n, e
|
|
},
|
|
jt = function(t) { return !(!Gt || !t.getCTM || t.parentNode && !t.ownerSVGElement || ! function(e) { try { return e.getBBox() } catch (t) { return Xt.call(e, !0) } }(t)) },
|
|
Wt = [1, 0, 0, 1, 0, 0],
|
|
qt = function(t, e) {
|
|
var i, s, o, n, a, r, h = t._gsTransform || new Ut,
|
|
l = t.style;
|
|
if (Lt ? s = et(t, Rt, null, !0) : t.currentStyle && (s = (s = t.currentStyle.filter.match(u)) && 4 === s.length ? [s[0].substr(4), Number(s[2].substr(4)), Number(s[1].substr(4)), s[3].substr(4), h.x || 0, h.y || 0].join(",") : ""), i = !s || "none" === s || "matrix(1, 0, 0, 1, 0, 0)" === s, !Lt || !(r = !tt(t) || "none" === tt(t).display) && t.parentNode || (r && (n = l.display, l.display = "block"), t.parentNode || (a = 1, Vt.appendChild(t)), i = !(s = et(t, Rt, null, !0)) || "none" === s || "matrix(1, 0, 0, 1, 0, 0)" === s, n ? l.display = n : r && Zt(l, "display"), a && Vt.removeChild(t)), (h.svg || t.getCTM && jt(t)) && (i && -1 !== (l[Lt] + "").indexOf("matrix") && (s = l[Lt], i = 0), o = t.getAttribute("transform"), i && o && (s = "matrix(" + (o = t.transform.baseVal.consolidate().matrix).a + "," + o.b + "," + o.c + "," + o.d + "," + o.e + "," + o.f + ")", i = 0)), i) return Wt;
|
|
for (o = (s || "").match(I) || [], Tt = o.length; - 1 < --Tt;) n = Number(o[Tt]), o[Tt] = (a = n - (n |= 0)) ? (1e5 * a + (a < 0 ? -.5 : .5) | 0) / 1e5 + n : n;
|
|
return e && 6 < o.length ? [o[0], o[1], o[4], o[5], o[12], o[13]] : o
|
|
},
|
|
Yt = o.getTransform = function(t, e, i, s) {
|
|
if (t._gsTransform && i && !s) return t._gsTransform;
|
|
var o, n, a, r, h, l, c = i && t._gsTransform || new Ut,
|
|
p = c.scaleX < 0,
|
|
u = Ft && (parseFloat(et(t, Dt, e, !1, "0 0 0").split(" ")[2]) || c.zOrigin) || 0,
|
|
d = parseFloat(V.defaultTransformPerspective) || 0;
|
|
if (c.svg = !(!t.getCTM || !jt(t)), c.svg && (zt(t, et(t, Dt, e, !1, "50% 50%") + "", c, t.getAttribute("data-svg-origin")), At = V.useSVGTransformAttr || Ht), (o = qt(t)) !== Wt) {
|
|
if (16 === o.length) {
|
|
var y, g, f, m, v, x = o[0],
|
|
b = o[1],
|
|
w = o[2],
|
|
P = o[3],
|
|
_ = o[4],
|
|
T = o[5],
|
|
S = o[6],
|
|
k = o[7],
|
|
B = o[8],
|
|
A = o[9],
|
|
C = o[10],
|
|
I = o[12],
|
|
E = o[13],
|
|
O = o[14],
|
|
M = o[11],
|
|
L = Math.atan2(S, C);
|
|
c.zOrigin && (I = B * (O = -c.zOrigin) - o[12], E = A * O - o[13], O = C * O + c.zOrigin - o[14]), c.rotationX = L * H, L && (y = _ * (m = Math.cos(-L)) + B * (v = Math.sin(-L)), g = T * m + A * v, f = S * m + C * v, B = _ * -v + B * m, A = T * -v + A * m, C = S * -v + C * m, M = k * -v + M * m, _ = y, T = g, S = f), L = Math.atan2(-w, C), c.rotationY = L * H, L && (g = b * (m = Math.cos(-L)) - A * (v = Math.sin(-L)), f = w * m - C * v, A = b * v + A * m, C = w * v + C * m, M = P * v + M * m, x = y = x * m - B * v, b = g, w = f), L = Math.atan2(b, x), c.rotation = L * H, L && (y = x * (m = Math.cos(L)) + b * (v = Math.sin(L)), g = _ * m + T * v, f = B * m + A * v, b = b * m - x * v, T = T * m - _ * v, A = A * m - B * v, x = y, _ = g, B = f), c.rotationX && 359.9 < Math.abs(c.rotationX) + Math.abs(c.rotation) && (c.rotationX = c.rotation = 0, c.rotationY = 180 - c.rotationY), L = Math.atan2(_, T), c.scaleX = (1e5 * Math.sqrt(x * x + b * b + w * w) + .5 | 0) / 1e5, c.scaleY = (1e5 * Math.sqrt(T * T + S * S) + .5 | 0) / 1e5, c.scaleZ = (1e5 * Math.sqrt(B * B + A * A + C * C) + .5 | 0) / 1e5, x /= c.scaleX, _ /= c.scaleY, b /= c.scaleX, T /= c.scaleY, 2e-5 < Math.abs(L) ? (c.skewX = L * H, _ = 0, "simple" !== c.skewType && (c.scaleY *= 1 / Math.cos(L))) : c.skewX = 0, c.perspective = M ? 1 / (M < 0 ? -M : M) : 0, c.x = I, c.y = E, c.z = O, c.svg && (c.x -= c.xOrigin - (c.xOrigin * x - c.yOrigin * _), c.y -= c.yOrigin - (c.yOrigin * b - c.xOrigin * T))
|
|
}
|
|
else if (!Ft || s || !o.length || c.x !== o[4] || c.y !== o[5] || !c.rotationX && !c.rotationY) {
|
|
var R = 6 <= o.length,
|
|
D = R ? o[0] : 1,
|
|
F = o[1] || 0,
|
|
U = o[2] || 0,
|
|
G = R ? o[3] : 1;
|
|
c.x = o[4] || 0, c.y = o[5] || 0, a = Math.sqrt(D * D + F * F), r = Math.sqrt(G * G + U * U), h = D || F ? Math.atan2(F, D) * H : c.rotation || 0, l = U || G ? Math.atan2(U, G) * H + h : c.skewX || 0, c.scaleX = a, c.scaleY = r, c.rotation = h, c.skewX = l, Ft && (c.rotationX = c.rotationY = c.z = 0, c.perspective = d, c.scaleZ = 1), c.svg && (c.x -= c.xOrigin - (c.xOrigin * D + c.yOrigin * U), c.y -= c.yOrigin - (c.xOrigin * F + c.yOrigin * G))
|
|
}
|
|
for (n in 90 < Math.abs(c.skewX) && Math.abs(c.skewX) < 270 && (p ? (c.scaleX *= -1, c.skewX += c.rotation <= 0 ? 180 : -180, c.rotation += c.rotation <= 0 ? 180 : -180) : (c.scaleY *= -1, c.skewX += c.skewX <= 0 ? 180 : -180)), c.zOrigin = u, c) c[n] < 2e-5 && -2e-5 < c[n] && (c[n] = 0)
|
|
}
|
|
return i && (t._gsTransform = c).svg && (At && t.style[Lt] ? N.delayedCall(.001, function() { Zt(t.style, Lt) }) : !At && t.getAttribute("transform") && N.delayedCall(.001, function() { t.removeAttribute("transform") })), c
|
|
},
|
|
Kt = function(t) {
|
|
var e, i, s = this.data,
|
|
o = -s.rotation * U,
|
|
n = o + s.skewX * U,
|
|
a = (Math.cos(o) * s.scaleX * 1e5 | 0) / 1e5,
|
|
r = (Math.sin(o) * s.scaleX * 1e5 | 0) / 1e5,
|
|
h = (Math.sin(n) * -s.scaleY * 1e5 | 0) / 1e5,
|
|
l = (Math.cos(n) * s.scaleY * 1e5 | 0) / 1e5,
|
|
c = this.t.style,
|
|
p = this.t.currentStyle;
|
|
if (p) {
|
|
i = r, r = -h, h = -i, e = p.filter, c.filter = "";
|
|
var u, d, y = this.t.offsetWidth,
|
|
g = this.t.offsetHeight,
|
|
f = "absolute" !== p.position,
|
|
m = "progid:DXImageTransform.Microsoft.Matrix(M11=" + a + ", M12=" + r + ", M21=" + h + ", M22=" + l,
|
|
v = s.x + y * s.xPercent / 100,
|
|
x = s.y + g * s.yPercent / 100;
|
|
if (null != s.ox && (v += (u = (s.oxp ? y * s.ox * .01 : s.ox) - y / 2) - (u * a + (d = (s.oyp ? g * s.oy * .01 : s.oy) - g / 2) * r), x += d - (u * h + d * l)), m += f ? ", Dx=" + ((u = y / 2) - (u * a + (d = g / 2) * r) + v) + ", Dy=" + (d - (u * h + d * l) + x) + ")" : ", sizingMethod='auto expand')", -1 !== e.indexOf("DXImageTransform.Microsoft.Matrix(") ? c.filter = e.replace(L, m) : c.filter = m + " " + e, 0 !== t && 1 !== t || 1 === a && 0 === r && 0 === h && 1 === l && (f && -1 === m.indexOf("Dx=0, Dy=0") || M.test(e) && 100 !== parseFloat(RegExp.$1) || -1 === e.indexOf(e.indexOf("Alpha")) && c.removeAttribute("filter")), !f) { var b, w, P, _ = S < 8 ? 1 : -1; for (u = s.ieOffsetX || 0, d = s.ieOffsetY || 0, s.ieOffsetX = Math.round((y - ((a < 0 ? -a : a) * y + (r < 0 ? -r : r) * g)) / 2 + v), s.ieOffsetY = Math.round((g - ((l < 0 ? -l : l) * g + (h < 0 ? -h : h) * y)) / 2 + x), Tt = 0; Tt < 4; Tt++) P = (i = -1 !== (b = p[w = rt[Tt]]).indexOf("px") ? parseFloat(b) : it(this.t, w, parseFloat(b), b.replace(O, "")) || 0) !== s[w] ? Tt < 2 ? -s.ieOffsetX : -s.ieOffsetY : Tt < 2 ? u - s.ieOffsetX : d - s.ieOffsetY, c[w] = (s[w] = Math.round(i - P * (0 === Tt || 2 === Tt ? 1 : _))) + "px" }
|
|
}
|
|
},
|
|
Qt = o.set3DTransformRatio = o.setTransformRatio = function(t) {
|
|
var e, i, s, o, n, a, r, h, l, c, p, u, d, y, g, f, m, v, x, b, w = this.data,
|
|
P = this.t.style,
|
|
_ = w.rotation,
|
|
T = w.rotationX,
|
|
S = w.rotationY,
|
|
k = w.scaleX,
|
|
B = w.scaleY,
|
|
A = w.scaleZ,
|
|
C = w.x,
|
|
I = w.y,
|
|
E = w.z,
|
|
O = w.svg,
|
|
M = w.perspective,
|
|
L = w.force3D,
|
|
R = w.skewY,
|
|
D = w.skewX;
|
|
if (R && (D += R, _ += R), !((1 !== t && 0 !== t || "auto" !== L || this.tween._totalTime !== this.tween._totalDuration && this.tween._totalTime) && L || E || M || S || T || 1 !== A) || At && O || !Ft) _ || D || O ? (_ *= U, b = D * U, 1e5, i = Math.cos(_) * k, n = Math.sin(_) * k, s = Math.sin(_ - b) * -B, a = Math.cos(_ - b) * B, b && "simple" === w.skewType && (e = Math.tan(b - R * U), s *= e = Math.sqrt(1 + e * e), a *= e, R && (e = Math.tan(R * U), i *= e = Math.sqrt(1 + e * e), n *= e)), O && (C += w.xOrigin - (w.xOrigin * i + w.yOrigin * s) + w.xOffset, I += w.yOrigin - (w.xOrigin * n + w.yOrigin * a) + w.yOffset, At && (w.xPercent || w.yPercent) && (g = this.t.getBBox(), C += .01 * w.xPercent * g.width, I += .01 * w.yPercent * g.height), C < (g = 1e-6) && -g < C && (C = 0), I < g && -g < I && (I = 0)), x = (1e5 * i | 0) / 1e5 + "," + (1e5 * n | 0) / 1e5 + "," + (1e5 * s | 0) / 1e5 + "," + (1e5 * a | 0) / 1e5 + "," + C + "," + I + ")", O && At ? this.t.setAttribute("transform", "matrix(" + x) : P[Lt] = (w.xPercent || w.yPercent ? "translate(" + w.xPercent + "%," + w.yPercent + "%) matrix(" : "matrix(") + x) : P[Lt] = (w.xPercent || w.yPercent ? "translate(" + w.xPercent + "%," + w.yPercent + "%) matrix(" : "matrix(") + k + ",0,0," + B + "," + C + "," + I + ")";
|
|
else {
|
|
if (F && (k < (g = 1e-4) && -g < k && (k = A = 2e-5), B < g && -g < B && (B = A = 2e-5), !M || w.z || w.rotationX || w.rotationY || (M = 0)), _ || D) _ *= U, f = i = Math.cos(_), m = n = Math.sin(_), D && (_ -= D * U, f = Math.cos(_), m = Math.sin(_), "simple" === w.skewType && (e = Math.tan((D - R) * U), f *= e = Math.sqrt(1 + e * e), m *= e, w.skewY && (e = Math.tan(R * U), i *= e = Math.sqrt(1 + e * e), n *= e))), s = -m, a = f;
|
|
else {
|
|
if (!(S || T || 1 !== A || M || O)) return void(P[Lt] = (w.xPercent || w.yPercent ? "translate(" + w.xPercent + "%," + w.yPercent + "%) translate3d(" : "translate3d(") + C + "px," + I + "px," + E + "px)" + (1 !== k || 1 !== B ? " scale(" + k + "," + B + ")" : ""));
|
|
i = a = 1, s = n = 0
|
|
}
|
|
c = 1, o = r = h = l = p = u = 0, d = M ? -1 / M : 0, y = w.zOrigin, g = 1e-6, ",", "0", (_ = S * U) && (f = Math.cos(_), p = d * (h = -(m = Math.sin(_))), o = i * m, r = n * m, d *= c = f, i *= f, n *= f), (_ = T * U) && (e = s * (f = Math.cos(_)) + o * (m = Math.sin(_)), v = a * f + r * m, l = c * m, u = d * m, o = s * -m + o * f, r = a * -m + r * f, c *= f, d *= f, s = e, a = v), 1 !== A && (o *= A, r *= A, c *= A, d *= A), 1 !== B && (s *= B, a *= B, l *= B, u *= B), 1 !== k && (i *= k, n *= k, h *= k, p *= k), (y || O) && (y && (C += o * -y, I += r * -y, E += c * -y + y), O && (C += w.xOrigin - (w.xOrigin * i + w.yOrigin * s) + w.xOffset, I += w.yOrigin - (w.xOrigin * n + w.yOrigin * a) + w.yOffset), C < g && -g < C && (C = "0"), I < g && -g < I && (I = "0"), E < g && -g < E && (E = 0)), x = w.xPercent || w.yPercent ? "translate(" + w.xPercent + "%," + w.yPercent + "%) matrix3d(" : "matrix3d(", x += (i < g && -g < i ? "0" : i) + "," + (n < g && -g < n ? "0" : n) + "," + (h < g && -g < h ? "0" : h), x += "," + (p < g && -g < p ? "0" : p) + "," + (s < g && -g < s ? "0" : s) + "," + (a < g && -g < a ? "0" : a), T || S || 1 !== A ? (x += "," + (l < g && -g < l ? "0" : l) + "," + (u < g && -g < u ? "0" : u) + "," + (o < g && -g < o ? "0" : o), x += "," + (r < g && -g < r ? "0" : r) + "," + (c < g && -g < c ? "0" : c) + "," + (d < g && -g < d ? "0" : d) + ",") : x += ",0,0,0,0,1,0,", x += C + "," + I + "," + E + "," + (M ? 1 + -E / M : 1) + ")", P[Lt] = x
|
|
}
|
|
};
|
|
(t = Ut.prototype).x = t.y = t.z = t.skewX = t.skewY = t.rotation = t.rotationX = t.rotationY = t.zOrigin = t.xPercent = t.yPercent = t.xOffset = t.yOffset = 0, t.scaleX = t.scaleY = t.scaleZ = 1, kt("transform,scale,scaleX,scaleY,scaleZ,x,y,z,rotation,rotationX,rotationY,rotationZ,skewX,skewY,shortRotation,shortRotationX,shortRotationY,shortRotationZ,transformOrigin,svgOrigin,transformPerspective,directionalRotation,parseTransform,force3D,skewType,xPercent,yPercent,smoothOrigin", {
|
|
parser: function(t, e, i, s, o, n, a) {
|
|
if (s._lastParsedTransform === a) return o;
|
|
var r, h = (s._lastParsedTransform = a).scale && "function" == typeof a.scale ? a.scale : 0;
|
|
"function" == typeof a[i] && (r = a[i], a[i] = e), h && (a.scale = h(C, t));
|
|
var l, c, p, u, d, y, g, f, m, v = t._gsTransform,
|
|
x = t.style,
|
|
b = Mt.length,
|
|
w = a,
|
|
P = {},
|
|
_ = "transformOrigin",
|
|
T = Yt(t, k, !0, w.parseTransform),
|
|
S = w.transform && ("function" == typeof w.transform ? w.transform(C, A) : w.transform);
|
|
if (T.skewType = w.skewType || T.skewType || V.defaultSkewType, s._transform = T, S && "string" == typeof S && Lt)(c = j.style)[Lt] = S, c.display = "block", c.position = "absolute", -1 !== S.indexOf("%") && (c.width = et(t, "width"), c.height = et(t, "height")), z.body.appendChild(j), l = Yt(j, null, !1), "simple" === T.skewType && (l.scaleY *= Math.cos(l.skewX * U)), T.svg && (y = T.xOrigin, g = T.yOrigin, l.x -= T.xOffset, l.y -= T.yOffset, (w.transformOrigin || w.svgOrigin) && (S = {}, zt(t, lt(w.transformOrigin), S, w.svgOrigin, w.smoothOrigin, !0), y = S.xOrigin, g = S.yOrigin, l.x -= S.xOffset - T.xOffset, l.y -= S.yOffset - T.yOffset), (y || g) && (f = qt(j, !0), l.x -= y - (y * f[0] + g * f[2]), l.y -= g - (y * f[1] + g * f[3]))), z.body.removeChild(j), l.perspective || (l.perspective = T.perspective), null != w.xPercent && (l.xPercent = pt(w.xPercent, T.xPercent)), null != w.yPercent && (l.yPercent = pt(w.yPercent, T.yPercent));
|
|
else if ("object" == typeof w) {
|
|
if (l = { scaleX: pt(null != w.scaleX ? w.scaleX : w.scale, T.scaleX), scaleY: pt(null != w.scaleY ? w.scaleY : w.scale, T.scaleY), scaleZ: pt(w.scaleZ, T.scaleZ), x: pt(w.x, T.x), y: pt(w.y, T.y), z: pt(w.z, T.z), xPercent: pt(w.xPercent, T.xPercent), yPercent: pt(w.yPercent, T.yPercent), perspective: pt(w.transformPerspective, T.perspective) }, null != (d = w.directionalRotation))
|
|
if ("object" == typeof d)
|
|
for (c in d) w[c] = d[c];
|
|
else w.rotation = d;
|
|
"string" == typeof w.x && -1 !== w.x.indexOf("%") && (l.x = 0, l.xPercent = pt(w.x, T.xPercent)), "string" == typeof w.y && -1 !== w.y.indexOf("%") && (l.y = 0, l.yPercent = pt(w.y, T.yPercent)), l.rotation = ut("rotation" in w ? w.rotation : "shortRotation" in w ? w.shortRotation + "_short" : "rotationZ" in w ? w.rotationZ : T.rotation, T.rotation, "rotation", P), Ft && (l.rotationX = ut("rotationX" in w ? w.rotationX : "shortRotationX" in w ? w.shortRotationX + "_short" : T.rotationX || 0, T.rotationX, "rotationX", P), l.rotationY = ut("rotationY" in w ? w.rotationY : "shortRotationY" in w ? w.shortRotationY + "_short" : T.rotationY || 0, T.rotationY, "rotationY", P)), l.skewX = ut(w.skewX, T.skewX), l.skewY = ut(w.skewY, T.skewY)
|
|
}
|
|
for (Ft && null != w.force3D && (T.force3D = w.force3D, u = !0), (p = T.force3D || T.z || T.rotationX || T.rotationY || l.z || l.rotationX || l.rotationY || l.perspective) || null == w.scale || (l.scaleZ = 1); - 1 < --b;)(1e-6 < (S = l[m = Mt[b]] - T[m]) || S < -1e-6 || null != w[m] || null != G[m]) && (u = !0, o = new wt(T, m, T[m], S, o), m in P && (o.e = P[m]), o.xs0 = 0, o.plugin = n, s._overwriteProps.push(o.n));
|
|
return S = w.transformOrigin, T.svg && (S || w.svgOrigin) && (y = T.xOffset, g = T.yOffset, zt(t, lt(S), l, w.svgOrigin, w.smoothOrigin), o = Pt(T, "xOrigin", (v ? T : l).xOrigin, l.xOrigin, o, _), o = Pt(T, "yOrigin", (v ? T : l).yOrigin, l.yOrigin, o, _), y === T.xOffset && g === T.yOffset || (o = Pt(T, "xOffset", v ? y : T.xOffset, T.xOffset, o, _), o = Pt(T, "yOffset", v ? g : T.yOffset, T.yOffset, o, _)), S = "0px 0px"), (S || Ft && p && T.zOrigin) && (Lt ? (u = !0, m = Dt, S = (S || et(t, m, k, !1, "50% 50%")) + "", (o = new wt(x, m, 0, 0, o, -1, _)).b = x[m], o.plugin = n, o.xs0 = o.e = Ft ? (c = T.zOrigin, S = S.split(" "), T.zOrigin = (2 < S.length && (0 === c || "0px" !== S[2]) ? parseFloat(S[2]) : c) || 0, o.xs0 = o.e = S[0] + " " + (S[1] || "50%") + " 0px", (o = new wt(T, "zOrigin", 0, 0, o, -1, o.n)).b = c, T.zOrigin) : S) : lt(S + "", T)), u && (s._transformType = T.svg && At || !p && 3 !== this._transformType ? 2 : 3), r && (a[i] = r), h && (a.scale = h), o
|
|
},
|
|
prefix: !0
|
|
}), kt("boxShadow", { defaultValue: "0px 0px 0px 0px #999", prefix: !0, color: !0, multi: !0, keyword: "inset" }), kt("borderRadius", {
|
|
defaultValue: "0px",
|
|
parser: function(t, e, i, s, o, n) {
|
|
e = this.format(e);
|
|
var a, r, h, l, c, p, u, d, y, g, f, m, v, x, b, w, P = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomRightRadius", "borderBottomLeftRadius"],
|
|
_ = t.style;
|
|
for (y = parseFloat(t.offsetWidth), g = parseFloat(t.offsetHeight), a = e.split(" "), r = 0; r < P.length; r++) this.p.indexOf("border") && (P[r] = $(P[r])), -1 !== (c = l = et(t, P[r], k, !1, "0px")).indexOf(" ") && (c = (l = c.split(" "))[0], l = l[1]), p = h = a[r], u = parseFloat(c), m = c.substr((u + "").length), "" === (f = (v = "=" === p.charAt(1)) ? (d = parseInt(p.charAt(0) + "1", 10), p = p.substr(2), d *= parseFloat(p), p.substr((d + "").length - (d < 0 ? 1 : 0)) || "") : (d = parseFloat(p), p.substr((d + "").length))) && (f = T[i] || m), f !== m && (x = it(t, "borderLeft", u, m), b = it(t, "borderTop", u, m), l = "%" === f ? (c = x / y * 100 + "%", b / g * 100 + "%") : "em" === f ? (c = x / (w = it(t, "borderLeft", 1, "em")) + "em", b / w + "em") : (c = x + "px", b + "px"), v && (p = parseFloat(c) + d + f, h = parseFloat(l) + d + f)), o = _t(_, P[r], c + " " + l, p + " " + h, !1, "0px", o);
|
|
return o
|
|
},
|
|
prefix: !0,
|
|
formatter: vt("0px 0px 0px 0px", !1, !0)
|
|
}), kt("borderBottomLeftRadius,borderBottomRightRadius,borderTopLeftRadius,borderTopRightRadius", { defaultValue: "0px", parser: function(t, e, i, s, o, n) { return _t(t.style, i, this.format(et(t, i, k, !1, "0px 0px")), this.format(e), !1, "0px", o) }, prefix: !0, formatter: vt("0px 0px", !1, !0) }), kt("backgroundPosition", {
|
|
defaultValue: "0 0",
|
|
parser: function(t, e, i, s, o, n) {
|
|
var a, r, h, l, c, p, u = "background-position",
|
|
d = k || tt(t, null),
|
|
y = this.format((d ? S ? d.getPropertyValue(u + "-x") + " " + d.getPropertyValue(u + "-y") : d.getPropertyValue(u) : t.currentStyle.backgroundPositionX + " " + t.currentStyle.backgroundPositionY) || "0 0"),
|
|
g = this.format(e);
|
|
if (-1 !== y.indexOf("%") != (-1 !== g.indexOf("%")) && g.split(",").length < 2 && (p = et(t, "backgroundImage").replace(_, "")) && "none" !== p) {
|
|
for (a = y.split(" "), r = g.split(" "), W.setAttribute("src", p), h = 2; - 1 < --h;)(l = -1 !== (y = a[h]).indexOf("%")) !== (-1 !== r[h].indexOf("%")) && (c = 0 === h ? t.offsetWidth - W.width : t.offsetHeight - W.height, a[h] = l ? parseFloat(y) / 100 * c + "px" : parseFloat(y) / c * 100 + "%");
|
|
y = a.join(" ")
|
|
}
|
|
return this.parseComplex(t.style, y, g, o, n)
|
|
},
|
|
formatter: lt
|
|
}), kt("backgroundSize", { defaultValue: "0 0", formatter: function(t) { return "co" === (t += "").substr(0, 2) ? t : lt(-1 === t.indexOf(" ") ? t + " " + t : t) } }), kt("perspective", { defaultValue: "0px", prefix: !0 }), kt("perspectiveOrigin", { defaultValue: "50% 50%", prefix: !0 }), kt("transformStyle", { prefix: !0 }), kt("backfaceVisibility", { prefix: !0 }), kt("userSelect", { prefix: !0 }), kt("margin", { parser: xt("marginTop,marginRight,marginBottom,marginLeft") }), kt("padding", { parser: xt("paddingTop,paddingRight,paddingBottom,paddingLeft") }), kt("clip", { defaultValue: "rect(0px,0px,0px,0px)", parser: function(t, e, i, s, o, n) { var a, r, h; return e = S < 9 ? (r = t.currentStyle, h = S < 8 ? " " : ",", a = "rect(" + r.clipTop + h + r.clipRight + h + r.clipBottom + h + r.clipLeft + ")", this.format(e).split(",").join(h)) : (a = this.format(et(t, this.p, k, !1, this.dflt)), this.format(e)), this.parseComplex(t.style, a, e, o, n) } }), kt("textShadow", { defaultValue: "0px 0px 0px #999", color: !0, multi: !0 }), kt("autoRound,strictUnits", { parser: function(t, e, i, s, o) { return o } }), kt("border", {
|
|
defaultValue: "0px solid #000",
|
|
parser: function(t, e, i, s, o, n) {
|
|
var a = et(t, "borderTopWidth", k, !1, "0px"),
|
|
r = this.format(e).split(" "),
|
|
h = r[0].replace(O, "");
|
|
return "px" !== h && (a = parseFloat(a) / it(t, "borderTopWidth", 1, h) + h), this.parseComplex(t.style, this.format(a + " " + et(t, "borderTopStyle", k, !1, "solid") + " " + et(t, "borderTopColor", k, !1, "#000")), r.join(" "), o, n)
|
|
},
|
|
color: !0,
|
|
formatter: function(t) { var e = t.split(" "); return e[0] + " " + (e[1] || "solid") + " " + (t.match(mt) || ["#000"])[0] }
|
|
}), kt("borderWidth", { parser: xt("borderTopWidth,borderRightWidth,borderBottomWidth,borderLeftWidth") }), kt("float,cssFloat,styleFloat", {
|
|
parser: function(t, e, i, s, o, n) {
|
|
var a = t.style,
|
|
r = "cssFloat" in a ? "cssFloat" : "styleFloat";
|
|
return new wt(a, r, 0, 0, o, -1, i, !1, 0, a[r], e)
|
|
}
|
|
});
|
|
var Jt = function(t) {
|
|
var e, i = this.t,
|
|
s = i.filter || et(this.data, "filter") || "",
|
|
o = this.s + this.c * t | 0;
|
|
100 === o && (e = -1 === s.indexOf("atrix(") && -1 === s.indexOf("radient(") && -1 === s.indexOf("oader(") ? (i.removeAttribute("filter"), !et(this.data, "filter")) : (i.filter = s.replace(a, ""), !0)), e || (this.xn1 && (i.filter = s = s || "alpha(opacity=" + o + ")"), -1 === s.indexOf("pacity") ? 0 === o && this.xn1 || (i.filter = s + " alpha(opacity=" + o + ")") : i.filter = s.replace(M, "opacity=" + o))
|
|
};
|
|
kt("opacity,alpha,autoAlpha", {
|
|
defaultValue: "1",
|
|
parser: function(t, e, i, s, o, n) {
|
|
var a = parseFloat(et(t, "opacity", k, !1, "1")),
|
|
r = t.style,
|
|
h = "autoAlpha" === i;
|
|
return "string" == typeof e && "=" === e.charAt(1) && (e = ("-" === e.charAt(0) ? -1 : 1) * parseFloat(e.substr(2)) + a), h && 1 === a && "hidden" === et(t, "visibility", k) && 0 !== e && (a = 0), Y ? o = new wt(r, "opacity", a, e - a, o) : ((o = new wt(r, "opacity", 100 * a, 100 * (e - a), o)).xn1 = h ? 1 : 0, r.zoom = 1, o.type = 2, o.b = "alpha(opacity=" + o.s + ")", o.e = "alpha(opacity=" + (o.s + o.c) + ")", o.data = t, o.plugin = n, o.setRatio = Jt), h && ((o = new wt(r, "visibility", 0, 0, o, -1, null, !1, 0, 0 !== a ? "inherit" : "hidden", 0 === e ? "hidden" : "inherit")).xs0 = "inherit", s._overwriteProps.push(o.n), s._overwriteProps.push(i)), o
|
|
}
|
|
});
|
|
var Zt = function(t, e) { e && (t.removeProperty ? ("ms" !== e.substr(0, 2) && "webkit" !== e.substr(0, 6) || (e = "-" + e), t.removeProperty(e.replace(r, "-$1").toLowerCase())) : t.removeAttribute(e)) },
|
|
$t = function(t) {
|
|
if (this.t._gsClassPT = this, 1 === t || 0 === t) {
|
|
this.t.setAttribute("class", 0 === t ? this.b : this.e);
|
|
for (var e = this.data, i = this.t.style; e;) e.v ? i[e.p] = e.v : Zt(i, e.p), e = e._next;
|
|
1 === t && this.t._gsClassPT === this && (this.t._gsClassPT = null)
|
|
}
|
|
else this.t.getAttribute("class") !== this.e && this.t.setAttribute("class", this.e)
|
|
};
|
|
kt("className", {
|
|
parser: function(t, e, i, s, o, n, a) {
|
|
var r, h, l, c, p, u = t.getAttribute("class") || "",
|
|
d = t.style.cssText;
|
|
if ((o = s._classNamePT = new wt(t, i, 0, 0, o, 2)).setRatio = $t, o.pr = -11, y = !0, o.b = u, h = ot(t, k), l = t._gsClassPT) {
|
|
for (c = {}, p = l.data; p;) c[p.p] = 1, p = p._next;
|
|
l.setRatio(1)
|
|
}
|
|
return (t._gsClassPT = o).e = "=" !== e.charAt(1) ? e : u.replace(new RegExp("(?:\\s|^)" + e.substr(2) + "(?![\\w-])"), "") + ("+" === e.charAt(0) ? " " + e.substr(2) : ""), t.setAttribute("class", o.e), r = nt(t, h, ot(t), a, c), t.setAttribute("class", u), o.data = r.firstMPT, t.style.cssText = d, o = o.xfirst = s.parse(t, r.difs, o, n)
|
|
}
|
|
});
|
|
var te = function(t) {
|
|
if ((1 === t || 0 === t) && this.data._totalTime === this.data._totalDuration && "isFromStart" !== this.data.data) {
|
|
var e, i, s, o, n, a = this.t.style,
|
|
r = f.transform.parse;
|
|
if ("all" === this.e) o = !(a.cssText = "");
|
|
else
|
|
for (s = (e = this.e.split(" ").join("").split(",")).length; - 1 < --s;) i = e[s], f[i] && (f[i].parse === r ? o = !0 : i = "transformOrigin" === i ? Dt : f[i].p), Zt(a, i);
|
|
o && (Zt(a, Lt), (n = this.t._gsTransform) && (n.svg && (this.t.removeAttribute("data-svg-origin"), this.t.removeAttribute("transform")), delete this.t._gsTransform))
|
|
}
|
|
};
|
|
for (kt("clearProps", { parser: function(t, e, i, s, o) { return (o = new wt(t, i, 0, 0, o, 2)).setRatio = te, o.e = e, o.pr = -10, o.data = s._tween, y = !0, o } }), t = "bezier,throwProps,physicsProps,physics2D".split(","), Tt = t.length; Tt--;) Bt(t[Tt]);
|
|
(t = V.prototype)._firstPT = t._lastParsedTransform = t._transform = null, t._onInitTween = function(t, e, i, s) {
|
|
if (!t.nodeType) return !1;
|
|
this._target = A = t, this._tween = i, this._vars = e, C = s, B = e.autoRound, y = !1, T = e.suffixMap || V.suffixMap, k = tt(t, ""), g = this._overwriteProps;
|
|
var o, n, a, r, h, l, c, p, u, d = t.style;
|
|
if (m && "" === d.zIndex && ("auto" !== (o = et(t, "zIndex", k)) && "" !== o || this._addLazySet(d, "zIndex", 0)), "string" == typeof e && (r = d.cssText, o = ot(t, k), d.cssText = r + ";" + e, o = nt(t, o, ot(t)).difs, !Y && w.test(e) && (o.opacity = parseFloat(RegExp.$1)), e = o, d.cssText = r), e.className ? this._firstPT = n = f.className.parse(t, e.className, "className", this, null, null, e) : this._firstPT = n = this.parse(t, e, null), this._transformType) {
|
|
for (u = 3 === this._transformType, Lt ? v && (m = !0, "" === d.zIndex && ("auto" !== (c = et(t, "zIndex", k)) && "" !== c || this._addLazySet(d, "zIndex", 0)), x && this._addLazySet(d, "WebkitBackfaceVisibility", this._vars.WebkitBackfaceVisibility || (u ? "visible" : "hidden"))) : d.zoom = 1, a = n; a && a._next;) a = a._next;
|
|
p = new wt(t, "transform", 0, 0, null, 2), this._linkCSSP(p, null, a), p.setRatio = Lt ? Qt : Kt, p.data = this._transform || Yt(t, k, !0), p.tween = i, p.pr = -1, g.pop()
|
|
}
|
|
if (y) {
|
|
for (; n;) {
|
|
for (l = n._next, a = r; a && a.pr > n.pr;) a = a._next;
|
|
(n._prev = a ? a._prev : h) ? n._prev._next = n: r = n, (n._next = a) ? a._prev = n : h = n, n = l
|
|
}
|
|
this._firstPT = r
|
|
}
|
|
return !0
|
|
}, t.parse = function(t, e, i, s) {
|
|
var o, n, a, r, h, l, c, p, u, d, y = t.style;
|
|
for (o in e) {
|
|
if ("function" == typeof(l = e[o]) && (l = l(C, A)), n = f[o]) i = n.parse(t, l, o, this, i, s, e);
|
|
else { if ("--" === o.substr(0, 2)) { this._tween._propLookup[o] = this._addTween.call(this._tween, t.style, "setProperty", tt(t).getPropertyValue(o) + "", l + "", o, !1, o); continue } h = et(t, o, k) + "", u = "string" == typeof l, "color" === o || "fill" === o || "stroke" === o || -1 !== o.indexOf("Color") || u && P.test(l) ? (u || (l = (3 < (l = gt(l)).length ? "rgba(" : "rgb(") + l.join(",") + ")"), i = _t(y, o, h, l, !0, "transparent", i, 0, s)) : u && D.test(l) ? i = _t(y, o, h, l, !0, null, i, 0, s) : (c = (a = parseFloat(h)) || 0 === a ? h.substr((a + "").length) : "", "" !== h && "auto" !== h || (c = "width" === o || "height" === o ? (a = ht(t, o, k), "px") : "left" === o || "top" === o ? (a = st(t, o, k), "px") : (a = "opacity" !== o ? 0 : 1, "")), "" === (p = (d = u && "=" === l.charAt(1)) ? (r = parseInt(l.charAt(0) + "1", 10), l = l.substr(2), r *= parseFloat(l), l.replace(O, "")) : (r = parseFloat(l), u ? l.replace(O, "") : "")) && (p = o in T ? T[o] : c), l = r || 0 === r ? (d ? r + a : r) + p : e[o], c !== p && ("" === p && "lineHeight" !== o || (r || 0 === r) && a && (a = it(t, o, a, c), "%" === p ? (a /= it(t, o, 100, "%") / 100, !0 !== e.strictUnits && (h = a + "%")) : "em" === p || "rem" === p || "vw" === p || "vh" === p ? a /= it(t, o, 1, p) : "px" !== p && (r = it(t, o, r, p), p = "px"), d && (r || 0 === r) && (l = r + a + p))), d && (r += a), !a && 0 !== a || !r && 0 !== r ? void 0 !== y[o] && (l || l + "" != "NaN" && null != l) ? (i = new wt(y, o, r || a || 0, 0, i, -1, o, !1, 0, h, l)).xs0 = "none" !== l || "display" !== o && -1 === o.indexOf("Style") ? l : h : Q(e[o]) : (i = new wt(y, o, a, r - a, i, 0, o, !1 !== B && ("px" === p || "zIndex" === o), 0, h, l)).xs0 = p) } s && i && !i.plugin && (i.plugin = s)
|
|
}
|
|
return i
|
|
}, t.setRatio = function(t) {
|
|
var e, i, s, o = this._firstPT;
|
|
if (1 !== t || this._tween._time !== this._tween._duration && 0 !== this._tween._time)
|
|
if (t || this._tween._time !== this._tween._duration && 0 !== this._tween._time || -1e-6 === this._tween._rawPrevTime)
|
|
for (; o;) {
|
|
if (e = o.c * t + o.s, o.r ? e = o.r(e) : e < 1e-6 && -1e-6 < e && (e = 0), o.type)
|
|
if (1 === o.type)
|
|
if (2 === (s = o.l)) o.t[o.p] = o.xs0 + e + o.xs1 + o.xn1 + o.xs2;
|
|
else if (3 === s) o.t[o.p] = o.xs0 + e + o.xs1 + o.xn1 + o.xs2 + o.xn2 + o.xs3;
|
|
else if (4 === s) o.t[o.p] = o.xs0 + e + o.xs1 + o.xn1 + o.xs2 + o.xn2 + o.xs3 + o.xn3 + o.xs4;
|
|
else if (5 === s) o.t[o.p] = o.xs0 + e + o.xs1 + o.xn1 + o.xs2 + o.xn2 + o.xs3 + o.xn3 + o.xs4 + o.xn4 + o.xs5;
|
|
else {
|
|
for (i = o.xs0 + e + o.xs1, s = 1; s < o.l; s++) i += o["xn" + s] + o["xs" + (s + 1)];
|
|
o.t[o.p] = i
|
|
}
|
|
else -1 === o.type ? o.t[o.p] = o.xs0 : o.setRatio && o.setRatio(t);
|
|
else o.t[o.p] = e + o.xs0;
|
|
o = o._next
|
|
}
|
|
else
|
|
for (; o;) 2 !== o.type ? o.t[o.p] = o.b : o.setRatio(t), o = o._next;
|
|
else
|
|
for (; o;) {
|
|
if (2 !== o.type)
|
|
if (o.r && -1 !== o.type)
|
|
if (e = o.r(o.s + o.c), o.type) {
|
|
if (1 === o.type) {
|
|
for (s = o.l, i = o.xs0 + e + o.xs1, s = 1; s < o.l; s++) i += o["xn" + s] + o["xs" + (s + 1)];
|
|
o.t[o.p] = i
|
|
}
|
|
}
|
|
else o.t[o.p] = e + o.xs0;
|
|
else o.t[o.p] = o.e;
|
|
else o.setRatio(t);
|
|
o = o._next
|
|
}
|
|
}, t._enableTransforms = function(t) { this._transform = this._transform || Yt(this._target, k, !0), this._transformType = this._transform.svg && At || !t && 3 !== this._transformType ? 2 : 3 };
|
|
var ee = function(t) { this.t[this.p] = this.e, this.data._linkCSSP(this, this._next, null, !0) };
|
|
t._addLazySet = function(t, e, i) {
|
|
var s = this._firstPT = new wt(t, e, 0, 0, this._firstPT, 2);
|
|
s.e = i, s.setRatio = ee, s.data = this
|
|
}, t._linkCSSP = function(t, e, i, s) { return t && (e && (e._prev = t), t._next && (t._next._prev = t._prev), t._prev ? t._prev._next = t._next : this._firstPT === t && (this._firstPT = t._next, s = !0), i ? i._next = t : s || null !== this._firstPT || (this._firstPT = t), t._next = e, t._prev = i), t }, t._mod = function(t) { for (var e = this._firstPT; e;) "function" == typeof t[e.p] && (e.r = t[e.p]), e = e._next }, t._kill = function(t) {
|
|
var e, i, s, o = t;
|
|
if (t.autoAlpha || t.alpha) {
|
|
for (i in o = {}, t) o[i] = t[i];
|
|
o.opacity = 1, o.autoAlpha && (o.visibility = 1)
|
|
}
|
|
for (t.className && (e = this._classNamePT) && ((s = e.xfirst) && s._prev ? this._linkCSSP(s._prev, e._next, s._prev._prev) : s === this._firstPT && (this._firstPT = e._next), e._next && this._linkCSSP(e._next, e._next._next, s._prev), this._classNamePT = null), e = this._firstPT; e;) e.plugin && e.plugin !== i && e.plugin._kill && (e.plugin._kill(t), i = e.plugin), e = e._next;
|
|
return n.prototype._kill.call(this, o)
|
|
};
|
|
var ie = function(t, e, i) {
|
|
var s, o, n, a;
|
|
if (t.slice)
|
|
for (o = t.length; - 1 < --o;) ie(t[o], e, i);
|
|
else
|
|
for (o = (s = t.childNodes).length; - 1 < --o;) a = (n = s[o]).type, n.style && (e.push(ot(n)), i && i.push(n)), 1 !== a && 9 !== a && 11 !== a || !n.childNodes.length || ie(n, e, i)
|
|
};
|
|
return V.cascadeTo = function(t, e, i) {
|
|
var s, o, n, a, r = N.to(t, e, i),
|
|
h = [r],
|
|
l = [],
|
|
c = [],
|
|
p = [],
|
|
u = N._internals.reservedProps;
|
|
for (t = r._targets || r.target, ie(t, l, p), r.render(e, !0, !0), ie(t, c), r.render(0, !0, !0), r._enabled(!0), s = p.length; - 1 < --s;)
|
|
if ((o = nt(p[s], l[s], c[s])).firstMPT) {
|
|
for (n in o = o.difs, i) u[n] && (o[n] = i[n]);
|
|
for (n in a = {}, o) a[n] = l[s][n];
|
|
h.push(N.fromTo(p[s], e, a, o))
|
|
}
|
|
return h
|
|
}, n.activate([V]), V
|
|
}, !0), e = _gsScope._gsDefine.plugin({ propName: "roundProps", version: "1.7.0", priority: -1, API: 2, init: function(t, e, i) { return this._tween = i, !0 } }), h = function(e) { var i = e < 1 ? Math.pow(10, (e + "").length - 2) : 1; return function(t) { return (Math.round(t / e) * e * i | 0) / i } }, l = function(t, e) { for (; t;) t.f || t.blob || (t.m = e || Math.round), t = t._next }, (s = e.prototype)._onInitAllProps = function() {
|
|
var t, e, i, s, o = this._tween,
|
|
n = o.vars.roundProps,
|
|
a = {},
|
|
r = o._propLookup.roundProps;
|
|
if ("object" != typeof n || n.push)
|
|
for ("string" == typeof n && (n = n.split(",")), i = n.length; - 1 < --i;) a[n[i]] = Math.round;
|
|
else
|
|
for (s in n) a[s] = h(n[s]);
|
|
for (s in a)
|
|
for (t = o._firstPT; t;) e = t._next, t.pg ? t.t._mod(a) : t.n === s && (2 === t.f && t.t ? l(t.t._firstPT, a[s]) : (this._add(t.t, s, t.s, t.c, a[s]), e && (e._prev = t._prev), t._prev ? t._prev._next = e : o._firstPT === t && (o._firstPT = e), t._next = t._prev = null, o._propLookup[s] = r)), t = e;
|
|
return !1
|
|
}, s._add = function(t, e, i, s, o) { this._addTween(t, e, i, i + s, e, o || Math.round), this._overwriteProps.push(e) }, _gsScope._gsDefine.plugin({ propName: "attr", API: 2, version: "0.6.1", init: function(t, e, i, s) { var o, n; if ("function" != typeof t.setAttribute) return !1; for (o in e) "function" == typeof(n = e[o]) && (n = n(s, t)), this._addTween(t, "setAttribute", t.getAttribute(o) + "", n + "", o, !1, o), this._overwriteProps.push(o); return !0 } }), _gsScope._gsDefine.plugin({
|
|
propName: "directionalRotation",
|
|
version: "0.3.1",
|
|
API: 2,
|
|
init: function(t, e, i, s) { "object" != typeof e && (e = { rotation: e }), this.finals = {}; var o, n, a, r, h, l, c = !0 === e.useRadians ? 2 * Math.PI : 360; for (o in e) "useRadians" !== o && ("function" == typeof(r = e[o]) && (r = r(s, t)), n = (l = (r + "").split("_"))[0], a = parseFloat("function" != typeof t[o] ? t[o] : t[o.indexOf("set") || "function" != typeof t["get" + o.substr(3)] ? o : "get" + o.substr(3)]()), h = (r = this.finals[o] = "string" == typeof n && "=" === n.charAt(1) ? a + parseInt(n.charAt(0) + "1", 10) * Number(n.substr(2)) : Number(n) || 0) - a, l.length && (-1 !== (n = l.join("_")).indexOf("short") && (h %= c) !== h % (c / 2) && (h = h < 0 ? h + c : h - c), -1 !== n.indexOf("_cw") && h < 0 ? h = (h + 9999999999 * c) % c - (h / c | 0) * c : -1 !== n.indexOf("ccw") && 0 < h && (h = (h - 9999999999 * c) % c - (h / c | 0) * c)), (1e-6 < h || h < -1e-6) && (this._addTween(t, o, a, a + h, o), this._overwriteProps.push(o))); return !0 },
|
|
set: function(t) {
|
|
var e;
|
|
if (1 !== t) this._super.setRatio.call(this, t);
|
|
else
|
|
for (e = this._firstPT; e;) e.f ? e.t[e.p](this.finals[e.p]) : e.t[e.p] = this.finals[e.p], e = e._next
|
|
}
|
|
})._autoCSS = !0, _gsScope._gsDefine("easing.Back", ["easing.Ease"], function(f) {
|
|
var i, s, e, t, o = _gsScope.GreenSockGlobals || _gsScope,
|
|
n = o.com.greensock,
|
|
a = 2 * Math.PI,
|
|
r = Math.PI / 2,
|
|
h = n._class,
|
|
l = function(t, e) {
|
|
var i = h("easing." + t, function() {}, !0),
|
|
s = i.prototype = new f;
|
|
return s.constructor = i, s.getRatio = e, i
|
|
},
|
|
c = f.register || function() {},
|
|
p = function(t, e, i, s, o) { var n = h("easing." + t, { easeOut: new e, easeIn: new i, easeInOut: new s }, !0); return c(n, t), n },
|
|
m = function(t, e, i) { this.t = t, this.v = e, i && (((this.next = i).prev = this).c = i.v - e, this.gap = i.t - t) },
|
|
u = function(t, e) {
|
|
var i = h("easing." + t, function(t) { this._p1 = t || 0 === t ? t : 1.70158, this._p2 = 1.525 * this._p1 }, !0),
|
|
s = i.prototype = new f;
|
|
return s.constructor = i, s.getRatio = e, s.config = function(t) { return new i(t) }, i
|
|
},
|
|
d = p("Back", u("BackOut", function(t) { return (t -= 1) * t * ((this._p1 + 1) * t + this._p1) + 1 }), u("BackIn", function(t) { return t * t * ((this._p1 + 1) * t - this._p1) }), u("BackInOut", function(t) { return (t *= 2) < 1 ? .5 * t * t * ((this._p2 + 1) * t - this._p2) : .5 * ((t -= 2) * t * ((this._p2 + 1) * t + this._p2) + 2) })),
|
|
y = h("easing.SlowMo", function(t, e, i) { e = e || 0 === e ? e : .7, null == t ? t = .7 : 1 < t && (t = 1), this._p = 1 !== t ? e : 0, this._p1 = (1 - t) / 2, this._p2 = t, this._p3 = this._p1 + this._p2, this._calcEnd = !0 === i }, !0),
|
|
g = y.prototype = new f;
|
|
return g.constructor = y, g.getRatio = function(t) { var e = t + (.5 - t) * this._p; return t < this._p1 ? this._calcEnd ? 1 - (t = 1 - t / this._p1) * t : e - (t = 1 - t / this._p1) * t * t * t * e : t > this._p3 ? this._calcEnd ? 1 === t ? 0 : 1 - (t = (t - this._p3) / this._p1) * t : e + (t - e) * (t = (t - this._p3) / this._p1) * t * t * t : this._calcEnd ? 1 : e }, y.ease = new y(.7, .7), g.config = y.config = function(t, e, i) { return new y(t, e, i) }, (g = (i = h("easing.SteppedEase", function(t, e) { t = t || 1, this._p1 = 1 / t, this._p2 = t + (e ? 0 : 1), this._p3 = e ? 1 : 0 }, !0)).prototype = new f).constructor = i, g.getRatio = function(t) { return t < 0 ? t = 0 : 1 <= t && (t = .999999999), ((this._p2 * t | 0) + this._p3) * this._p1 }, g.config = i.config = function(t, e) { return new i(t, e) }, (g = (s = h("easing.ExpoScaleEase", function(t, e, i) { this._p1 = Math.log(e / t), this._p2 = e - t, this._p3 = t, this._ease = i }, !0)).prototype = new f).constructor = s, g.getRatio = function(t) { return this._ease && (t = this._ease.getRatio(t)), (this._p3 * Math.exp(this._p1 * t) - this._p3) / this._p2 }, g.config = s.config = function(t, e, i) { return new s(t, e, i) }, (g = (e = h("easing.RoughEase", function(t) {
|
|
for (var e, i, s, o, n, a, r = (t = t || {}).taper || "none", h = [], l = 0, c = 0 | (t.points || 20), p = c, u = !1 !== t.randomize, d = !0 === t.clamp, y = t.template instanceof f ? t.template : null, g = "number" == typeof t.strength ? .4 * t.strength : .4; - 1 < --p;) e = u ? Math.random() : 1 / c * p, i = y ? y.getRatio(e) : e, s = "none" === r ? g : "out" === r ? (o = 1 - e) * o * g : "in" === r ? e * e * g : e < .5 ? (o = 2 * e) * o * .5 * g : (o = 2 * (1 - e)) * o * .5 * g, u ? i += Math.random() * s - .5 * s : p % 2 ? i += .5 * s : i -= .5 * s, d && (1 < i ? i = 1 : i < 0 && (i = 0)), h[l++] = { x: e, y: i };
|
|
for (h.sort(function(t, e) { return t.x - e.x }), a = new m(1, 1, null), p = c; - 1 < --p;) n = h[p], a = new m(n.x, n.y, a);
|
|
this._prev = new m(0, 0, 0 !== a.t ? a : a.next)
|
|
}, !0)).prototype = new f).constructor = e, g.getRatio = function(t) {
|
|
var e = this._prev;
|
|
if (t > e.t) {
|
|
for (; e.next && t >= e.t;) e = e.next;
|
|
e = e.prev
|
|
}
|
|
else
|
|
for (; e.prev && t <= e.t;) e = e.prev;
|
|
return (this._prev = e).v + (t - e.t) / e.gap * e.c
|
|
}, g.config = function(t) { return new e(t) }, e.ease = new e, p("Bounce", l("BounceOut", function(t) { return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375 }), l("BounceIn", function(t) { return (t = 1 - t) < 1 / 2.75 ? 1 - 7.5625 * t * t : t < 2 / 2.75 ? 1 - (7.5625 * (t -= 1.5 / 2.75) * t + .75) : t < 2.5 / 2.75 ? 1 - (7.5625 * (t -= 2.25 / 2.75) * t + .9375) : 1 - (7.5625 * (t -= 2.625 / 2.75) * t + .984375) }), l("BounceInOut", function(t) { var e = t < .5; return (t = e ? 1 - 2 * t : 2 * t - 1) < 1 / 2.75 ? t *= 7.5625 * t : t = t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375, e ? .5 * (1 - t) : .5 * t + .5 })), p("Circ", l("CircOut", function(t) { return Math.sqrt(1 - (t -= 1) * t) }), l("CircIn", function(t) { return -(Math.sqrt(1 - t * t) - 1) }), l("CircInOut", function(t) { return (t *= 2) < 1 ? -.5 * (Math.sqrt(1 - t * t) - 1) : .5 * (Math.sqrt(1 - (t -= 2) * t) + 1) })), p("Elastic", (t = function(t, e, i) {
|
|
var s = h("easing." + t, function(t, e) { this._p1 = 1 <= t ? t : 1, this._p2 = (e || i) / (t < 1 ? t : 1), this._p3 = this._p2 / a * (Math.asin(1 / this._p1) || 0), this._p2 = a / this._p2 }, !0),
|
|
o = s.prototype = new f;
|
|
return o.constructor = s, o.getRatio = e, o.config = function(t, e) { return new s(t, e) }, s
|
|
})("ElasticOut", function(t) { return this._p1 * Math.pow(2, -10 * t) * Math.sin((t - this._p3) * this._p2) + 1 }, .3), t("ElasticIn", function(t) { return -this._p1 * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - this._p3) * this._p2) }, .3), t("ElasticInOut", function(t) { return (t *= 2) < 1 ? this._p1 * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - this._p3) * this._p2) * -.5 : this._p1 * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - this._p3) * this._p2) * .5 + 1 }, .45)), p("Expo", l("ExpoOut", function(t) { return 1 - Math.pow(2, -10 * t) }), l("ExpoIn", function(t) { return Math.pow(2, 10 * (t - 1)) - .001 }), l("ExpoInOut", function(t) { return (t *= 2) < 1 ? .5 * Math.pow(2, 10 * (t - 1)) : .5 * (2 - Math.pow(2, -10 * (t - 1))) })), p("Sine", l("SineOut", function(t) { return Math.sin(t * r) }), l("SineIn", function(t) { return 1 - Math.cos(t * r) }), l("SineInOut", function(t) { return -.5 * (Math.cos(Math.PI * t) - 1) })), h("easing.EaseLookup", { find: function(t) { return f.map[t] } }, !0), c(o.SlowMo, "SlowMo", "ease,"), c(e, "RoughEase", "ease,"), c(i, "SteppedEase", "ease,"), d
|
|
}, !0)
|
|
}), _gsScope._gsDefine && _gsScope._gsQueue.pop()(),
|
|
function(u, d) {
|
|
"use strict";
|
|
var y = {},
|
|
s = u.document,
|
|
g = u.GreenSockGlobals = u.GreenSockGlobals || u;
|
|
if (g.TweenLite) return g.TweenLite;
|
|
var t, e, i, f, m, o, n, v = function(t) {
|
|
var e, i = t.split("."),
|
|
s = g;
|
|
for (e = 0; e < i.length; e++) s[i[e]] = s = s[i[e]] || {};
|
|
return s
|
|
},
|
|
p = v("com.greensock"),
|
|
x = 1e-10,
|
|
h = function(t) {
|
|
var e, i = [],
|
|
s = t.length;
|
|
for (e = 0; e !== s; i.push(t[e++]));
|
|
return i
|
|
},
|
|
b = function() {},
|
|
w = (o = Object.prototype.toString, n = o.call([]), function(t) { return null != t && (t instanceof Array || "object" == typeof t && !!t.push && o.call(t) === n) }),
|
|
P = {},
|
|
_ = function(r, h, l, c) {
|
|
this.sc = P[r] ? P[r].sc : [], (P[r] = this).gsClass = null, this.func = l;
|
|
var p = [];
|
|
this.check = function(t) {
|
|
for (var e, i, s, o, n = h.length, a = n; - 1 < --n;)(e = P[h[n]] || new _(h[n], [])).gsClass ? (p[n] = e.gsClass, a--) : t && e.sc.push(this);
|
|
if (0 === a && l) {
|
|
if (s = (i = ("com.greensock." + r).split(".")).pop(), o = v(i.join("."))[s] = this.gsClass = l.apply(l, p), c)
|
|
if (g[s] = y[s] = o, "undefined" != typeof module && module.exports)
|
|
if (r === d)
|
|
for (n in module.exports = y[d] = o, y) o[n] = y[n];
|
|
else y[d] && (y[d][s] = o);
|
|
else "function" == typeof define && define.amd && define((u.GreenSockAMDPath ? u.GreenSockAMDPath + "/" : "") + r.split(".").pop(), [], function() { return o });
|
|
for (n = 0; n < this.sc.length; n++) this.sc[n].check()
|
|
}
|
|
}, this.check(!0)
|
|
},
|
|
a = u._gsDefine = function(t, e, i, s) { return new _(t, e, i, s) },
|
|
T = p._class = function(t, e, i) { return e = e || function() {}, a(t, [], function() { return e }, i), e };
|
|
a.globals = g;
|
|
var r = [0, 0, 1, 1],
|
|
S = T("easing.Ease", function(t, e, i, s) { this._func = t, this._type = i || 0, this._power = s || 0, this._params = e ? r.concat(e) : r }, !0),
|
|
k = S.map = {},
|
|
l = S.register = function(t, e, i, s) {
|
|
for (var o, n, a, r, h = e.split(","), l = h.length, c = (i || "easeIn,easeOut,easeInOut").split(","); - 1 < --l;)
|
|
for (n = h[l], o = s ? T("easing." + n, null, !0) : p.easing[n] || {}, a = c.length; - 1 < --a;) r = c[a], k[n + "." + r] = k[r + n] = o[r] = t.getRatio ? t : t[r] || new t
|
|
};
|
|
for ((i = S.prototype)._calcEnd = !1, i.getRatio = function(t) {
|
|
if (this._func) return this._params[0] = t, this._func.apply(null, this._params);
|
|
var e = this._type,
|
|
i = this._power,
|
|
s = 1 === e ? 1 - t : 2 === e ? t : t < .5 ? 2 * t : 2 * (1 - t);
|
|
return 1 === i ? s *= s : 2 === i ? s *= s * s : 3 === i ? s *= s * s * s : 4 === i && (s *= s * s * s * s), 1 === e ? 1 - s : 2 === e ? s : t < .5 ? s / 2 : 1 - s / 2
|
|
}, e = (t = ["Linear", "Quad", "Cubic", "Quart", "Quint,Strong"]).length; - 1 < --e;) i = t[e] + ",Power" + e, l(new S(null, null, 1, e), i, "easeOut", !0), l(new S(null, null, 2, e), i, "easeIn" + (0 === e ? ",easeNone" : "")), l(new S(null, null, 3, e), i, "easeInOut");
|
|
k.linear = p.easing.Linear.easeIn, k.swing = p.easing.Quad.easeInOut;
|
|
var B = T("events.EventDispatcher", function(t) { this._listeners = {}, this._eventTarget = t || this });
|
|
(i = B.prototype).addEventListener = function(t, e, i, s, o) {
|
|
o = o || 0;
|
|
var n, a, r = this._listeners[t],
|
|
h = 0;
|
|
for (this !== f || m || f.wake(), null == r && (this._listeners[t] = r = []), a = r.length; - 1 < --a;)(n = r[a]).c === e && n.s === i ? r.splice(a, 1) : 0 === h && n.pr < o && (h = a + 1);
|
|
r.splice(h, 0, { c: e, s: i, up: s, pr: o })
|
|
}, i.removeEventListener = function(t, e) {
|
|
var i, s = this._listeners[t];
|
|
if (s)
|
|
for (i = s.length; - 1 < --i;)
|
|
if (s[i].c === e) return void s.splice(i, 1)
|
|
}, i.dispatchEvent = function(t) {
|
|
var e, i, s, o = this._listeners[t];
|
|
if (o)
|
|
for (1 < (e = o.length) && (o = o.slice(0)), i = this._eventTarget; - 1 < --e;)(s = o[e]) && (s.up ? s.c.call(s.s || i, { type: t, target: i }) : s.c.call(s.s || i))
|
|
};
|
|
var A = u.requestAnimationFrame,
|
|
C = u.cancelAnimationFrame,
|
|
I = Date.now || function() { return (new Date).getTime() },
|
|
E = I();
|
|
for (e = (t = ["ms", "moz", "webkit", "o"]).length; - 1 < --e && !A;) A = u[t[e] + "RequestAnimationFrame"], C = u[t[e] + "CancelAnimationFrame"] || u[t[e] + "CancelRequestAnimationFrame"];
|
|
T("Ticker", function(t, e) {
|
|
var o, n, a, r, h, l = this,
|
|
c = I(),
|
|
i = !(!1 === e || !A) && "auto",
|
|
p = 500,
|
|
u = 33,
|
|
d = function(t) {
|
|
var e, i, s = I() - E;
|
|
p < s && (c += s - u), E += s, l.time = (E - c) / 1e3, e = l.time - h, (!o || 0 < e || !0 === t) && (l.frame++, h += e + (r <= e ? .004 : r - e), i = !0), !0 !== t && (a = n(d)), i && l.dispatchEvent("tick")
|
|
};
|
|
B.call(l), l.time = l.frame = 0, l.tick = function() { d(!0) }, l.lagSmoothing = function(t, e) {
|
|
if (!arguments.length) return p < 1e10;
|
|
p = t || 1e10, u = Math.min(e, p, 0)
|
|
}, l.sleep = function() { null != a && (i && C ? C(a) : clearTimeout(a), n = b, a = null, l === f && (m = !1)) }, l.wake = function(t) { null !== a ? l.sleep() : t ? c += -E + (E = I()) : 10 < l.frame && (E = I() - p + 5), n = 0 === o ? b : i && A ? A : function(t) { return setTimeout(t, 1e3 * (h - l.time) + 1 | 0) }, l === f && (m = !0), d(2) }, l.fps = function(t) {
|
|
if (!arguments.length) return o;
|
|
r = 1 / ((o = t) || 60), h = this.time + r, l.wake()
|
|
}, l.useRAF = function(t) {
|
|
if (!arguments.length) return i;
|
|
l.sleep(), i = t, l.fps(o)
|
|
}, l.fps(t), setTimeout(function() { "auto" === i && l.frame < 5 && "hidden" !== (s || {}).visibilityState && l.useRAF(!1) }, 1500)
|
|
}), (i = p.Ticker.prototype = new p.events.EventDispatcher).constructor = p.Ticker;
|
|
var c = T("core.Animation", function(t, e) {
|
|
if (this.vars = e = e || {}, this._duration = this._totalDuration = t || 0, this._delay = Number(e.delay) || 0, this._timeScale = 1, this._active = !0 === e.immediateRender, this.data = e.data, this._reversed = !0 === e.reversed, Q) {
|
|
m || f.wake();
|
|
var i = this.vars.useFrames ? K : Q;
|
|
i.add(this, i._time), this.vars.paused && this.paused(!0)
|
|
}
|
|
});
|
|
f = c.ticker = new p.Ticker, (i = c.prototype)._dirty = i._gc = i._initted = i._paused = !1, i._totalTime = i._time = 0, i._rawPrevTime = -1, i._next = i._last = i._onUpdate = i._timeline = i.timeline = null, i._paused = !1;
|
|
var O = function() {
|
|
m && 2e3 < I() - E && ("hidden" !== (s || {}).visibilityState || !f.lagSmoothing()) && f.wake();
|
|
var t = setTimeout(O, 2e3);
|
|
t.unref && t.unref()
|
|
};
|
|
O(), i.play = function(t, e) { return null != t && this.seek(t, e), this.reversed(!1).paused(!1) }, i.pause = function(t, e) { return null != t && this.seek(t, e), this.paused(!0) }, i.resume = function(t, e) { return null != t && this.seek(t, e), this.paused(!1) }, i.seek = function(t, e) { return this.totalTime(Number(t), !1 !== e) }, i.restart = function(t, e) { return this.reversed(!1).paused(!1).totalTime(t ? -this._delay : 0, !1 !== e, !0) }, i.reverse = function(t, e) { return null != t && this.seek(t || this.totalDuration(), e), this.reversed(!0).paused(!1) }, i.render = function(t, e, i) {}, i.invalidate = function() { return this._time = this._totalTime = 0, this._initted = this._gc = !1, this._rawPrevTime = -1, !this._gc && this.timeline || this._enabled(!0), this }, i.isActive = function() {
|
|
var t, e = this._timeline,
|
|
i = this._startTime;
|
|
return !e || !this._gc && !this._paused && e.isActive() && (t = e.rawTime(!0)) >= i && t < i + this.totalDuration() / this._timeScale - 1e-7
|
|
}, i._enabled = function(t, e) { return m || f.wake(), this._gc = !t, this._active = this.isActive(), !0 !== e && (t && !this.timeline ? this._timeline.add(this, this._startTime - this._delay) : !t && this.timeline && this._timeline._remove(this, !0)), !1 }, i._kill = function(t, e) { return this._enabled(!1, !1) }, i.kill = function(t, e) { return this._kill(t, e), this }, i._uncache = function(t) { for (var e = t ? this : this.timeline; e;) e._dirty = !0, e = e.timeline; return this }, i._swapSelfInParams = function(t) { for (var e = t.length, i = t.concat(); - 1 < --e;) "{self}" === t[e] && (i[e] = this); return i }, i._callback = function(t) {
|
|
var e = this.vars,
|
|
i = e[t],
|
|
s = e[t + "Params"],
|
|
o = e[t + "Scope"] || e.callbackScope || this;
|
|
switch (s ? s.length : 0) {
|
|
case 0:
|
|
i.call(o);
|
|
break;
|
|
case 1:
|
|
i.call(o, s[0]);
|
|
break;
|
|
case 2:
|
|
i.call(o, s[0], s[1]);
|
|
break;
|
|
default:
|
|
i.apply(o, s)
|
|
}
|
|
}, i.eventCallback = function(t, e, i, s) {
|
|
if ("on" === (t || "").substr(0, 2)) {
|
|
var o = this.vars;
|
|
if (1 === arguments.length) return o[t];
|
|
null == e ? delete o[t] : (o[t] = e, o[t + "Params"] = w(i) && -1 !== i.join("").indexOf("{self}") ? this._swapSelfInParams(i) : i, o[t + "Scope"] = s), "onUpdate" === t && (this._onUpdate = e)
|
|
}
|
|
return this
|
|
}, i.delay = function(t) { return arguments.length ? (this._timeline.smoothChildTiming && this.startTime(this._startTime + t - this._delay), this._delay = t, this) : this._delay }, i.duration = function(t) { return arguments.length ? (this._duration = this._totalDuration = t, this._uncache(!0), this._timeline.smoothChildTiming && 0 < this._time && this._time < this._duration && 0 !== t && this.totalTime(this._totalTime * (t / this._duration), !0), this) : (this._dirty = !1, this._duration) }, i.totalDuration = function(t) { return this._dirty = !1, arguments.length ? this.duration(t) : this._totalDuration }, i.time = function(t, e) { return arguments.length ? (this._dirty && this.totalDuration(), this.totalTime(t > this._duration ? this._duration : t, e)) : this._time }, i.totalTime = function(t, e, i) {
|
|
if (m || f.wake(), !arguments.length) return this._totalTime;
|
|
if (this._timeline) {
|
|
if (t < 0 && !i && (t += this.totalDuration()), this._timeline.smoothChildTiming) {
|
|
this._dirty && this.totalDuration();
|
|
var s = this._totalDuration,
|
|
o = this._timeline;
|
|
if (s < t && !i && (t = s), this._startTime = (this._paused ? this._pauseTime : o._time) - (this._reversed ? s - t : t) / this._timeScale, o._dirty || this._uncache(!1), o._timeline)
|
|
for (; o._timeline;) o._timeline._time !== (o._startTime + o._totalTime) / o._timeScale && o.totalTime(o._totalTime, !0), o = o._timeline
|
|
}
|
|
this._gc && this._enabled(!0, !1), this._totalTime === t && 0 !== this._duration || (D.length && Z(), this.render(t, e, !1), D.length && Z())
|
|
}
|
|
return this
|
|
}, i.progress = i.totalProgress = function(t, e) { var i = this.duration(); return arguments.length ? this.totalTime(i * t, e) : i ? this._time / i : this.ratio }, i.startTime = function(t) { return arguments.length ? (t !== this._startTime && (this._startTime = t, this.timeline && this.timeline._sortChildren && this.timeline.add(this, t - this._delay)), this) : this._startTime }, i.endTime = function(t) { return this._startTime + (0 != t ? this.totalDuration() : this.duration()) / this._timeScale }, i.timeScale = function(t) { if (!arguments.length) return this._timeScale; var e, i; for (t = t || x, this._timeline && this._timeline.smoothChildTiming && (i = (e = this._pauseTime) || 0 === e ? e : this._timeline.totalTime(), this._startTime = i - (i - this._startTime) * this._timeScale / t), this._timeScale = t, i = this.timeline; i && i.timeline;) i._dirty = !0, i.totalDuration(), i = i.timeline; return this }, i.reversed = function(t) { return arguments.length ? (t != this._reversed && (this._reversed = t, this.totalTime(this._timeline && !this._timeline.smoothChildTiming ? this.totalDuration() - this._totalTime : this._totalTime, !0)), this) : this._reversed }, i.paused = function(t) { if (!arguments.length) return this._paused; var e, i, s = this._timeline; return t != this._paused && s && (m || t || f.wake(), i = (e = s.rawTime()) - this._pauseTime, !t && s.smoothChildTiming && (this._startTime += i, this._uncache(!1)), this._pauseTime = t ? e : null, this._paused = t, this._active = this.isActive(), !t && 0 !== i && this._initted && this.duration() && (e = s.smoothChildTiming ? this._totalTime : (e - this._startTime) / this._timeScale, this.render(e, e === this._totalTime, !0))), this._gc && !t && this._enabled(!0, !1), this };
|
|
var M = T("core.SimpleTimeline", function(t) { c.call(this, 0, t), this.autoRemoveChildren = this.smoothChildTiming = !0 });
|
|
(i = M.prototype = new c).constructor = M, i.kill()._gc = !1, i._first = i._last = i._recent = null, i._sortChildren = !1, i.add = i.insert = function(t, e, i, s) {
|
|
var o, n;
|
|
if (t._startTime = Number(e || 0) + t._delay, t._paused && this !== t._timeline && (t._pauseTime = this.rawTime() - (t._timeline.rawTime() - t._pauseTime)), t.timeline && t.timeline._remove(t, !0), t.timeline = t._timeline = this, t._gc && t._enabled(!0, !0), o = this._last, this._sortChildren)
|
|
for (n = t._startTime; o && o._startTime > n;) o = o._prev;
|
|
return o ? (t._next = o._next, o._next = t) : (t._next = this._first, this._first = t), t._next ? t._next._prev = t : this._last = t, t._prev = o, this._recent = t, this._timeline && this._uncache(!0), this
|
|
}, i._remove = function(t, e) { return t.timeline === this && (e || t._enabled(!1, !0), t._prev ? t._prev._next = t._next : this._first === t && (this._first = t._next), t._next ? t._next._prev = t._prev : this._last === t && (this._last = t._prev), t._next = t._prev = t.timeline = null, t === this._recent && (this._recent = this._last), this._timeline && this._uncache(!0)), this }, i.render = function(t, e, i) { var s, o = this._first; for (this._totalTime = this._time = this._rawPrevTime = t; o;) s = o._next, (o._active || t >= o._startTime && !o._paused && !o._gc) && (o._reversed ? o.render((o._dirty ? o.totalDuration() : o._totalDuration) - (t - o._startTime) * o._timeScale, e, i) : o.render((t - o._startTime) * o._timeScale, e, i)), o = s }, i.rawTime = function() { return m || f.wake(), this._totalTime };
|
|
var L = T("TweenLite", function(t, e, i) {
|
|
if (c.call(this, e, i), this.render = L.prototype.render, null == t) throw "Cannot tween a null target.";
|
|
this.target = t = "string" != typeof t ? t : L.selector(t) || t;
|
|
var s, o, n, a = t.jquery || t.length && t !== u && t[0] && (t[0] === u || t[0].nodeType && t[0].style && !t.nodeType),
|
|
r = this.vars.overwrite;
|
|
if (this._overwrite = r = null == r ? Y[L.defaultOverwrite] : "number" == typeof r ? r >> 0 : Y[r], (a || t instanceof Array || t.push && w(t)) && "number" != typeof t[0])
|
|
for (this._targets = n = h(t), this._propLookup = [], this._siblings = [], s = 0; s < n.length; s++)(o = n[s]) ? "string" != typeof o ? o.length && o !== u && o[0] && (o[0] === u || o[0].nodeType && o[0].style && !o.nodeType) ? (n.splice(s--, 1), this._targets = n = n.concat(h(o))) : (this._siblings[s] = $(o, this, !1), 1 === r && 1 < this._siblings[s].length && et(o, this, null, 1, this._siblings[s])) : "string" == typeof(o = n[s--] = L.selector(o)) && n.splice(s + 1, 1) : n.splice(s--, 1);
|
|
else this._propLookup = {}, this._siblings = $(t, this, !1), 1 === r && 1 < this._siblings.length && et(t, this, null, 1, this._siblings);
|
|
(this.vars.immediateRender || 0 === e && 0 === this._delay && !1 !== this.vars.immediateRender) && (this._time = -x, this.render(Math.min(0, -this._delay)))
|
|
}, !0),
|
|
R = function(t) { return t && t.length && t !== u && t[0] && (t[0] === u || t[0].nodeType && t[0].style && !t.nodeType) };
|
|
(i = L.prototype = new c).constructor = L, i.kill()._gc = !1, i.ratio = 0, i._firstPT = i._targets = i._overwrittenProps = i._startAt = null, i._notifyPluginsOfEnabled = i._lazy = !1, L.version = "1.20.5", L.defaultEase = i._ease = new S(null, null, 1, 1), L.defaultOverwrite = "auto", L.ticker = f, L.autoSleep = 120, L.lagSmoothing = function(t, e) { f.lagSmoothing(t, e) }, L.selector = u.$ || u.jQuery || function(t) { var e = u.$ || u.jQuery; return e ? (L.selector = e)(t) : (s || (s = u.document), s ? s.querySelectorAll ? s.querySelectorAll(t) : s.getElementById("#" === t.charAt(0) ? t.substr(1) : t) : t) };
|
|
var D = [],
|
|
F = {},
|
|
U = /(?:(-|-=|\+=)?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,
|
|
G = /[\+-]=-?[\.\d]/,
|
|
N = function(t) { for (var e, i = this._firstPT; i;) e = i.blob ? 1 === t && null != this.end ? this.end : t ? this.join("") : this.start : i.c * t + i.s, i.m ? e = i.m.call(this._tween, e, this._target || i.t, this._tween) : e < 1e-6 && -1e-6 < e && !i.blob && (e = 0), i.f ? i.fp ? i.t[i.p](i.fp, e) : i.t[i.p](e) : i.t[i.p] = e, i = i._next },
|
|
V = function(t, e, i, s) {
|
|
var o, n, a, r, h, l, c, p = [],
|
|
u = 0,
|
|
d = "",
|
|
y = 0;
|
|
for (p.start = t, p.end = e, t = p[0] = t + "", e = p[1] = e + "", i && (i(p), t = p[0], e = p[1]), p.length = 0, o = t.match(U) || [], n = e.match(U) || [], s && (s._next = null, s.blob = 1, p._firstPT = p._applyPT = s), h = n.length, r = 0; r < h; r++) c = n[r], d += (l = e.substr(u, e.indexOf(c, u) - u)) || !r ? l : ",", u += l.length, y ? y = (y + 1) % 5 : "rgba(" === l.substr(-5) && (y = 1), c === o[r] || o.length <= r ? d += c : (d && (p.push(d), d = ""), a = parseFloat(o[r]), p.push(a), p._firstPT = { _next: p._firstPT, t: p, p: p.length - 1, s: a, c: ("=" === c.charAt(1) ? parseInt(c.charAt(0) + "1", 10) * parseFloat(c.substr(2)) : parseFloat(c) - a) || 0, f: 0, m: y && y < 4 ? Math.round : 0 }), u += c.length;
|
|
return (d += e.substr(u)) && p.push(d), p.setRatio = N, G.test(e) && (p.end = null), p
|
|
},
|
|
H = function(t, e, i, s, o, n, a, r, h) {
|
|
"function" == typeof s && (s = s(h || 0, t));
|
|
var l = typeof t[e],
|
|
c = "function" !== l ? "" : e.indexOf("set") || "function" != typeof t["get" + e.substr(3)] ? e : "get" + e.substr(3),
|
|
p = "get" !== i ? i : c ? a ? t[c](a) : t[c]() : t[e],
|
|
u = "string" == typeof s && "=" === s.charAt(1),
|
|
d = { t: t, p: e, s: p, f: "function" === l, pg: 0, n: o || e, m: n ? "function" == typeof n ? n : Math.round : 0, pr: 0, c: u ? parseInt(s.charAt(0) + "1", 10) * parseFloat(s.substr(2)) : parseFloat(s) - p || 0 };
|
|
if (("number" != typeof p || "number" != typeof s && !u) && (a || isNaN(p) || !u && isNaN(s) || "boolean" == typeof p || "boolean" == typeof s ? (d.fp = a, d = { t: V(p, u ? parseFloat(d.s) + d.c + (d.s + "").replace(/[0-9\-\.]/g, "") : s, r || L.defaultStringFilter, d), p: "setRatio", s: 0, c: 1, f: 2, pg: 0, n: o || e, pr: 0, m: 0 }) : (d.s = parseFloat(p), u || (d.c = parseFloat(s) - d.s || 0))), d.c) return (d._next = this._firstPT) && (d._next._prev = d), this._firstPT = d
|
|
},
|
|
z = L._internals = { isArray: w, isSelector: R, lazyTweens: D, blobDif: V },
|
|
X = L._plugins = {},
|
|
j = z.tweenLookup = {},
|
|
W = 0,
|
|
q = z.reservedProps = { ease: 1, delay: 1, overwrite: 1, onComplete: 1, onCompleteParams: 1, onCompleteScope: 1, useFrames: 1, runBackwards: 1, startAt: 1, onUpdate: 1, onUpdateParams: 1, onUpdateScope: 1, onStart: 1, onStartParams: 1, onStartScope: 1, onReverseComplete: 1, onReverseCompleteParams: 1, onReverseCompleteScope: 1, onRepeat: 1, onRepeatParams: 1, onRepeatScope: 1, easeParams: 1, yoyo: 1, immediateRender: 1, repeat: 1, repeatDelay: 1, data: 1, paused: 1, reversed: 1, autoCSS: 1, lazy: 1, onOverwrite: 1, callbackScope: 1, stringFilter: 1, id: 1, yoyoEase: 1 },
|
|
Y = { none: 0, all: 1, auto: 2, concurrent: 3, allOnStart: 4, preexisting: 5, true: 1, false: 0 },
|
|
K = c._rootFramesTimeline = new M,
|
|
Q = c._rootTimeline = new M,
|
|
J = 30,
|
|
Z = z.lazyRender = function() {
|
|
var t, e = D.length;
|
|
for (F = {}; - 1 < --e;)(t = D[e]) && !1 !== t._lazy && (t.render(t._lazy[0], t._lazy[1], !0), t._lazy = !1);
|
|
D.length = 0
|
|
};
|
|
Q._startTime = f.time, K._startTime = f.frame, Q._active = K._active = !0, setTimeout(Z, 1), c._updateRoot = L.render = function() {
|
|
var t, e, i;
|
|
if (D.length && Z(), Q.render((f.time - Q._startTime) * Q._timeScale, !1, !1), K.render((f.frame - K._startTime) * K._timeScale, !1, !1), D.length && Z(), f.frame >= J) {
|
|
for (i in J = f.frame + (parseInt(L.autoSleep, 10) || 120), j) {
|
|
for (t = (e = j[i].tweens).length; - 1 < --t;) e[t]._gc && e.splice(t, 1);
|
|
0 === e.length && delete j[i]
|
|
}
|
|
if ((!(i = Q._first) || i._paused) && L.autoSleep && !K._first && 1 === f._listeners.tick.length) {
|
|
for (; i && i._paused;) i = i._next;
|
|
i || f.sleep()
|
|
}
|
|
}
|
|
}, f.addEventListener("tick", c._updateRoot);
|
|
var $ = function(t, e, i) {
|
|
var s, o, n = t._gsTweenID;
|
|
if (j[n || (t._gsTweenID = n = "t" + W++)] || (j[n] = { target: t, tweens: [] }), e && ((s = j[n].tweens)[o = s.length] = e, i))
|
|
for (; - 1 < --o;) s[o] === e && s.splice(o, 1);
|
|
return j[n].tweens
|
|
},
|
|
tt = function(t, e, i, s) { var o, n, a = t.vars.onOverwrite; return a && (o = a(t, e, i, s)), (a = L.onOverwrite) && (n = a(t, e, i, s)), !1 !== o && !1 !== n },
|
|
et = function(t, e, i, s, o) {
|
|
var n, a, r, h;
|
|
if (1 === s || 4 <= s) {
|
|
for (h = o.length, n = 0; n < h; n++)
|
|
if ((r = o[n]) !== e) r._gc || r._kill(null, t, e) && (a = !0);
|
|
else if (5 === s) break;
|
|
return a
|
|
}
|
|
var l, c = e._startTime + x,
|
|
p = [],
|
|
u = 0,
|
|
d = 0 === e._duration;
|
|
for (n = o.length; - 1 < --n;)(r = o[n]) === e || r._gc || r._paused || (r._timeline !== e._timeline ? (l = l || it(e, 0, d), 0 === it(r, l, d) && (p[u++] = r)) : r._startTime <= c && r._startTime + r.totalDuration() / r._timeScale > c && ((d || !r._initted) && c - r._startTime <= 2e-10 || (p[u++] = r)));
|
|
for (n = u; - 1 < --n;)
|
|
if (r = p[n], 2 === s && r._kill(i, t, e) && (a = !0), 2 !== s || !r._firstPT && r._initted) {
|
|
if (2 !== s && !tt(r, e)) continue;
|
|
r._enabled(!1, !1) && (a = !0)
|
|
}
|
|
return a
|
|
},
|
|
it = function(t, e, i) {
|
|
for (var s = t._timeline, o = s._timeScale, n = t._startTime; s._timeline;) {
|
|
if (n += s._startTime, o *= s._timeScale, s._paused) return -100;
|
|
s = s._timeline
|
|
}
|
|
return e < (n /= o) ? n - e : i && n === e || !t._initted && n - e < 2e-10 ? x : (n += t.totalDuration() / t._timeScale / o) > e + x ? 0 : n - e - x
|
|
};
|
|
i._init = function() {
|
|
var t, e, i, s, o, n, a = this.vars,
|
|
r = this._overwrittenProps,
|
|
h = this._duration,
|
|
l = !!a.immediateRender,
|
|
c = a.ease;
|
|
if (a.startAt) {
|
|
for (s in this._startAt && (this._startAt.render(-1, !0), this._startAt.kill()), o = {}, a.startAt) o[s] = a.startAt[s];
|
|
if (o.data = "isStart", o.overwrite = !1, o.immediateRender = !0, o.lazy = l && !1 !== a.lazy, o.startAt = o.delay = null, o.onUpdate = a.onUpdate, o.onUpdateParams = a.onUpdateParams, o.onUpdateScope = a.onUpdateScope || a.callbackScope || this, this._startAt = L.to(this.target || {}, 0, o), l)
|
|
if (0 < this._time) this._startAt = null;
|
|
else if (0 !== h) return
|
|
}
|
|
else if (a.runBackwards && 0 !== h)
|
|
if (this._startAt) this._startAt.render(-1, !0), this._startAt.kill(), this._startAt = null;
|
|
else { for (s in 0 !== this._time && (l = !1), i = {}, a) q[s] && "autoCSS" !== s || (i[s] = a[s]); if (i.overwrite = 0, i.data = "isFromStart", i.lazy = l && !1 !== a.lazy, i.immediateRender = l, this._startAt = L.to(this.target, 0, i), l) { if (0 === this._time) return } else this._startAt._init(), this._startAt._enabled(!1), this.vars.immediateRender && (this._startAt = null) }
|
|
if (this._ease = c = c ? c instanceof S ? c : "function" == typeof c ? new S(c, a.easeParams) : k[c] || L.defaultEase : L.defaultEase, a.easeParams instanceof Array && c.config && (this._ease = c.config.apply(c, a.easeParams)), this._easeType = this._ease._type, this._easePower = this._ease._power, this._firstPT = null, this._targets)
|
|
for (n = this._targets.length, t = 0; t < n; t++) this._initProps(this._targets[t], this._propLookup[t] = {}, this._siblings[t], r ? r[t] : null, t) && (e = !0);
|
|
else e = this._initProps(this.target, this._propLookup, this._siblings, r, 0);
|
|
if (e && L._onPluginEvent("_onInitAllProps", this), r && (this._firstPT || "function" != typeof this.target && this._enabled(!1, !1)), a.runBackwards)
|
|
for (i = this._firstPT; i;) i.s += i.c, i.c = -i.c, i = i._next;
|
|
this._onUpdate = a.onUpdate, this._initted = !0
|
|
}, i._initProps = function(t, e, i, s, o) {
|
|
var n, a, r, h, l, c;
|
|
if (null == t) return !1;
|
|
for (n in F[t._gsTweenID] && Z(), this.vars.css || t.style && t !== u && t.nodeType && X.css && !1 !== this.vars.autoCSS && function(t, e) {
|
|
var i, s = {};
|
|
for (i in t) q[i] || i in e && "transform" !== i && "x" !== i && "y" !== i && "width" !== i && "height" !== i && "className" !== i && "border" !== i || !(!X[i] || X[i] && X[i]._autoCSS) || (s[i] = t[i], delete t[i]);
|
|
t.css = s
|
|
}(this.vars, t), this.vars)
|
|
if (c = this.vars[n], q[n]) c && (c instanceof Array || c.push && w(c)) && -1 !== c.join("").indexOf("{self}") && (this.vars[n] = c = this._swapSelfInParams(c, this));
|
|
else if (X[n] && (h = new X[n])._onInitTween(t, this.vars[n], this, o)) {
|
|
for (this._firstPT = l = { _next: this._firstPT, t: h, p: "setRatio", s: 0, c: 1, f: 1, n: n, pg: 1, pr: h._priority, m: 0 }, a = h._overwriteProps.length; - 1 < --a;) e[h._overwriteProps[a]] = this._firstPT;
|
|
(h._priority || h._onInitAllProps) && (r = !0), (h._onDisable || h._onEnable) && (this._notifyPluginsOfEnabled = !0), l._next && (l._next._prev = l)
|
|
}
|
|
else e[n] = H.call(this, t, n, "get", c, n, 0, null, this.vars.stringFilter, o);
|
|
return s && this._kill(s, t) ? this._initProps(t, e, i, s, o) : 1 < this._overwrite && this._firstPT && 1 < i.length && et(t, this, e, this._overwrite, i) ? (this._kill(e, t), this._initProps(t, e, i, s, o)) : (this._firstPT && (!1 !== this.vars.lazy && this._duration || this.vars.lazy && !this._duration) && (F[t._gsTweenID] = !0), r)
|
|
}, i.render = function(t, e, i) {
|
|
var s, o, n, a, r = this._time,
|
|
h = this._duration,
|
|
l = this._rawPrevTime;
|
|
if (h - 1e-7 <= t && 0 <= t) this._totalTime = this._time = h, this.ratio = this._ease._calcEnd ? this._ease.getRatio(1) : 1, this._reversed || (s = !0, o = "onComplete", i = i || this._timeline.autoRemoveChildren), 0 === h && (this._initted || !this.vars.lazy || i) && (this._startTime === this._timeline._duration && (t = 0), (l < 0 || t <= 0 && -1e-7 <= t || l === x && "isPause" !== this.data) && l !== t && (i = !0, x < l && (o = "onReverseComplete")), this._rawPrevTime = a = !e || t || l === t ? t : x);
|
|
else if (t < 1e-7) this._totalTime = this._time = 0, this.ratio = this._ease._calcEnd ? this._ease.getRatio(0) : 0, (0 !== r || 0 === h && 0 < l) && (o = "onReverseComplete", s = this._reversed), t < 0 && (this._active = !1, 0 === h && (this._initted || !this.vars.lazy || i) && (0 <= l && (l !== x || "isPause" !== this.data) && (i = !0), this._rawPrevTime = a = !e || t || l === t ? t : x)), (!this._initted || this._startAt && this._startAt.progress()) && (i = !0);
|
|
else if (this._totalTime = this._time = t, this._easeType) {
|
|
var c = t / h,
|
|
p = this._easeType,
|
|
u = this._easePower;
|
|
(1 === p || 3 === p && .5 <= c) && (c = 1 - c), 3 === p && (c *= 2), 1 === u ? c *= c : 2 === u ? c *= c * c : 3 === u ? c *= c * c * c : 4 === u && (c *= c * c * c * c), this.ratio = 1 === p ? 1 - c : 2 === p ? c : t / h < .5 ? c / 2 : 1 - c / 2
|
|
}
|
|
else this.ratio = this._ease.getRatio(t / h);
|
|
if (this._time !== r || i) {
|
|
if (!this._initted) {
|
|
if (this._init(), !this._initted || this._gc) return;
|
|
if (!i && this._firstPT && (!1 !== this.vars.lazy && this._duration || this.vars.lazy && !this._duration)) return this._time = this._totalTime = r, this._rawPrevTime = l, D.push(this), void(this._lazy = [t, e]);
|
|
this._time && !s ? this.ratio = this._ease.getRatio(this._time / h) : s && this._ease._calcEnd && (this.ratio = this._ease.getRatio(0 === this._time ? 0 : 1))
|
|
}
|
|
for (!1 !== this._lazy && (this._lazy = !1), this._active || !this._paused && this._time !== r && 0 <= t && (this._active = !0), 0 === r && (this._startAt && (0 <= t ? this._startAt.render(t, !0, i) : o || (o = "_dummyGS")), this.vars.onStart && (0 === this._time && 0 !== h || e || this._callback("onStart"))), n = this._firstPT; n;) n.f ? n.t[n.p](n.c * this.ratio + n.s) : n.t[n.p] = n.c * this.ratio + n.s, n = n._next;
|
|
this._onUpdate && (t < 0 && this._startAt && -1e-4 !== t && this._startAt.render(t, !0, i), e || (this._time !== r || s || i) && this._callback("onUpdate")), o && (this._gc && !i || (t < 0 && this._startAt && !this._onUpdate && -1e-4 !== t && this._startAt.render(t, !0, i), s && (this._timeline.autoRemoveChildren && this._enabled(!1, !1), this._active = !1), !e && this.vars[o] && this._callback(o), 0 === h && this._rawPrevTime === x && a !== x && (this._rawPrevTime = 0)))
|
|
}
|
|
}, i._kill = function(t, e, i) {
|
|
if ("all" === t && (t = null), null == t && (null == e || e === this.target)) return this._lazy = !1, this._enabled(!1, !1);
|
|
e = "string" != typeof e ? e || this._targets || this.target : L.selector(e) || e;
|
|
var s, o, n, a, r, h, l, c, p, u = i && this._time && i._startTime === this._startTime && this._timeline === i._timeline;
|
|
if ((w(e) || R(e)) && "number" != typeof e[0])
|
|
for (s = e.length; - 1 < --s;) this._kill(t, e[s], i) && (h = !0);
|
|
else {
|
|
if (this._targets) {
|
|
for (s = this._targets.length; - 1 < --s;)
|
|
if (e === this._targets[s]) { r = this._propLookup[s] || {}, this._overwrittenProps = this._overwrittenProps || [], o = this._overwrittenProps[s] = t ? this._overwrittenProps[s] || {} : "all"; break }
|
|
}
|
|
else {
|
|
if (e !== this.target) return !1;
|
|
r = this._propLookup, o = this._overwrittenProps = t ? this._overwrittenProps || {} : "all"
|
|
}
|
|
if (r) { if (l = t || r, c = t !== o && "all" !== o && t !== r && ("object" != typeof t || !t._tempKill), i && (L.onOverwrite || this.vars.onOverwrite)) { for (n in l) r[n] && (p || (p = []), p.push(n)); if ((p || !t) && !tt(this, i, e, p)) return !1 } for (n in l)(a = r[n]) && (u && (a.f ? a.t[a.p](a.s) : a.t[a.p] = a.s, h = !0), a.pg && a.t._kill(l) && (h = !0), a.pg && 0 !== a.t._overwriteProps.length || (a._prev ? a._prev._next = a._next : a === this._firstPT && (this._firstPT = a._next), a._next && (a._next._prev = a._prev), a._next = a._prev = null), delete r[n]), c && (o[n] = 1);!this._firstPT && this._initted && this._enabled(!1, !1) }
|
|
}
|
|
return h
|
|
}, i.invalidate = function() { return this._notifyPluginsOfEnabled && L._onPluginEvent("_onDisable", this), this._firstPT = this._overwrittenProps = this._startAt = this._onUpdate = null, this._notifyPluginsOfEnabled = this._active = this._lazy = !1, this._propLookup = this._targets ? {} : [], c.prototype.invalidate.call(this), this.vars.immediateRender && (this._time = -x, this.render(Math.min(0, -this._delay))), this }, i._enabled = function(t, e) {
|
|
if (m || f.wake(), t && this._gc) {
|
|
var i, s = this._targets;
|
|
if (s)
|
|
for (i = s.length; - 1 < --i;) this._siblings[i] = $(s[i], this, !0);
|
|
else this._siblings = $(this.target, this, !0)
|
|
}
|
|
return c.prototype._enabled.call(this, t, e), !(!this._notifyPluginsOfEnabled || !this._firstPT) && L._onPluginEvent(t ? "_onEnable" : "_onDisable", this)
|
|
}, L.to = function(t, e, i) { return new L(t, e, i) }, L.from = function(t, e, i) { return i.runBackwards = !0, i.immediateRender = 0 != i.immediateRender, new L(t, e, i) }, L.fromTo = function(t, e, i, s) { return s.startAt = i, s.immediateRender = 0 != s.immediateRender && 0 != i.immediateRender, new L(t, e, s) }, L.delayedCall = function(t, e, i, s, o) { return new L(e, 0, { delay: t, onComplete: e, onCompleteParams: i, callbackScope: s, onReverseComplete: e, onReverseCompleteParams: i, immediateRender: !1, lazy: !1, useFrames: o, overwrite: 0 }) }, L.set = function(t, e) { return new L(t, 0, e) }, L.getTweensOf = function(t, e) {
|
|
if (null == t) return [];
|
|
var i, s, o, n;
|
|
if (t = "string" != typeof t ? t : L.selector(t) || t, (w(t) || R(t)) && "number" != typeof t[0]) {
|
|
for (i = t.length, s = []; - 1 < --i;) s = s.concat(L.getTweensOf(t[i], e));
|
|
for (i = s.length; - 1 < --i;)
|
|
for (n = s[i], o = i; - 1 < --o;) n === s[o] && s.splice(i, 1)
|
|
}
|
|
else if (t._gsTweenID)
|
|
for (i = (s = $(t).concat()).length; - 1 < --i;)(s[i]._gc || e && !s[i].isActive()) && s.splice(i, 1);
|
|
return s || []
|
|
}, L.killTweensOf = L.killDelayedCallsTo = function(t, e, i) { "object" == typeof e && (i = e, e = !1); for (var s = L.getTweensOf(t, e), o = s.length; - 1 < --o;) s[o]._kill(i, t) };
|
|
var st = T("plugins.TweenPlugin", function(t, e) { this._overwriteProps = (t || "").split(","), this._propName = this._overwriteProps[0], this._priority = e || 0, this._super = st.prototype }, !0);
|
|
if (i = st.prototype, st.version = "1.19.0", st.API = 2, i._firstPT = null, i._addTween = H, i.setRatio = N, i._kill = function(t) {
|
|
var e, i = this._overwriteProps,
|
|
s = this._firstPT;
|
|
if (null != t[this._propName]) this._overwriteProps = [];
|
|
else
|
|
for (e = i.length; - 1 < --e;) null != t[i[e]] && i.splice(e, 1);
|
|
for (; s;) null != t[s.n] && (s._next && (s._next._prev = s._prev), s._prev ? (s._prev._next = s._next, s._prev = null) : this._firstPT === s && (this._firstPT = s._next)), s = s._next;
|
|
return !1
|
|
}, i._mod = i._roundProps = function(t) { for (var e, i = this._firstPT; i;)(e = t[this._propName] || null != i.n && t[i.n.split(this._propName + "_").join("")]) && "function" == typeof e && (2 === i.f ? i.t._applyPT.m = e : i.m = e), i = i._next }, L._onPluginEvent = function(t, e) {
|
|
var i, s, o, n, a, r = e._firstPT;
|
|
if ("_onInitAllProps" === t) {
|
|
for (; r;) {
|
|
for (a = r._next, s = o; s && s.pr > r.pr;) s = s._next;
|
|
(r._prev = s ? s._prev : n) ? r._prev._next = r: o = r, (r._next = s) ? s._prev = r : n = r, r = a
|
|
}
|
|
r = e._firstPT = o
|
|
}
|
|
for (; r;) r.pg && "function" == typeof r.t[t] && r.t[t]() && (i = !0), r = r._next;
|
|
return i
|
|
}, st.activate = function(t) { for (var e = t.length; - 1 < --e;) t[e].API === st.API && (X[(new t[e])._propName] = t[e]); return !0 }, a.plugin = function(t) {
|
|
if (!(t && t.propName && t.init && t.API)) throw "illegal plugin definition.";
|
|
var e, i = t.propName,
|
|
s = t.priority || 0,
|
|
o = t.overwriteProps,
|
|
n = { init: "_onInitTween", set: "setRatio", kill: "_kill", round: "_mod", mod: "_mod", initAll: "_onInitAllProps" },
|
|
a = T("plugins." + i.charAt(0).toUpperCase() + i.substr(1) + "Plugin", function() { st.call(this, i, s), this._overwriteProps = o || [] }, !0 === t.global),
|
|
r = a.prototype = new st(i);
|
|
for (e in (r.constructor = a).API = t.API, n) "function" == typeof t[e] && (r[n[e]] = t[e]);
|
|
return a.version = t.version, st.activate([a]), a
|
|
}, t = u._gsQueue) { for (e = 0; e < t.length; e++) t[e](); for (i in P) P[i].func || u.console.log("GSAP encountered missing dependency: " + i) } m = !1
|
|
}("undefined" != typeof module && module.exports && "undefined" != typeof global ? global : this || window, "TweenMax");
|
|
var PhaserNineSlice, __extends = this && this.__extends || function() {
|
|
var s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, e) { t.__proto__ = e } || function(t, e) { for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]) };
|
|
return function(t, e) {
|
|
function i() { this.constructor = t } s(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i)
|
|
}
|
|
}();
|
|
! function(t) {
|
|
var e = function(l) {
|
|
function t(t, e, i, s, o, n, a, r) { var h = l.call(this, t, e, i, s, o) || this; return h.baseTexture = h.texture.baseTexture, h.baseFrame = h.texture.frame, null === o || r ? r || (r = t.cache.getNineSlice(s)) : r = t.cache.getNineSlice(o), void 0 === r || (h.topSize = r.top, r.left ? h.leftSize = r.left : h.leftSize = h.topSize, r.right ? h.rightSize = r.right : h.rightSize = h.leftSize, r.bottom ? h.bottomSize = r.bottom : h.bottomSize = h.topSize, h.loadTexture(new Phaser.RenderTexture(h.game, h.localWidth, h.localHeight)), h.resize(n, a)), h }
|
|
return __extends(t, l), t.prototype.renderTexture = function() {
|
|
this.texture.resize(this.localWidth, this.localHeight, !0);
|
|
var t = [0, this.leftSize, this.baseFrame.width - this.rightSize, this.baseFrame.width],
|
|
e = [0, this.topSize, this.baseFrame.height - this.bottomSize, this.baseFrame.height],
|
|
i = [0, this.leftSize, this.localWidth - this.rightSize, this.localWidth],
|
|
s = [0, this.topSize, this.localHeight - this.bottomSize, this.localHeight];
|
|
this.texture.clear();
|
|
for (var o = 0; o < 3; o++)
|
|
for (var n = 0; n < 3; n++) {
|
|
var a = this.createTexturePart(t[n], e[o], t[n + 1] - t[n], e[o + 1] - e[o]);
|
|
a.width = i[n + 1] - i[n], a.height = s[o + 1] - s[o], this.texture.renderXY(a, i[n], s[o])
|
|
}
|
|
}, t.prototype.resize = function(t, e) { this.localWidth = t, this.localHeight = e, this.renderTexture() }, t.prototype.destroy = function() {
|
|
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
|
|
l.prototype.destroy.call(this, t[0]), this.texture.destroy(!0), this.texture = null, this.baseTexture = null, this.baseFrame = null
|
|
}, t.prototype.createTexturePart = function(t, e, i, s) { var o = new PIXI.Rectangle(this.baseFrame.x + this.texture.frame.x + t, this.baseFrame.y + this.texture.frame.y + e, Math.max(i, 1), Math.max(s, 1)); return new Phaser.Sprite(this.game, 0, 0, new PIXI.Texture(this.baseTexture, o)) }, t
|
|
}(Phaser.Sprite);
|
|
t.NineSlice = e
|
|
}(PhaserNineSlice || (PhaserNineSlice = {})),
|
|
function(h) {
|
|
var t = function(s) {
|
|
function t(t, e) { var i = s.call(this, t, e) || this; return i.addNineSliceCache(), i.addNineSliceFactory(), i.addNineSliceLoader(), i }
|
|
return __extends(t, s), t.prototype.addNineSliceLoader = function() {
|
|
Phaser.Loader.prototype.nineSlice = function(t, e, i, s, o, n) {
|
|
var a = { top: i };
|
|
s && (a.left = s), o && (a.right = o), n && (a.bottom = n), this.addToFileList("image", t, e), this.game.cache.addNineSlice(t, a)
|
|
}
|
|
}, t.prototype.addNineSliceFactory = function() { Phaser.GameObjectFactory.prototype.nineSlice = function(t, e, i, s, o, n, a) { void 0 === a && (a = this.world); var r = new h.NineSlice(this.game, t, e, i, s, o, n); return a.add(r) }, Phaser.GameObjectCreator.prototype.nineSlice = function(t, e, i, s, o, n) { return new h.NineSlice(this.game, t, e, i, s, o, n) } }, t.prototype.addNineSliceCache = function() { Phaser.Cache.prototype.nineSlice = {}, Phaser.Cache.prototype.addNineSlice = function(t, e) { this.nineSlice[t] = e }, Phaser.Cache.prototype.getNineSlice = function(t) { var e = this.nineSlice[t]; return e } }, t
|
|
}(Phaser.Plugin);
|
|
h.Plugin = t
|
|
}(PhaserNineSlice || (PhaserNineSlice = {}));
|
|
var Ph2;
|
|
__extends = this && this.__extends || function() {
|
|
var s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, e) { t.__proto__ = e } || function(t, e) { for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]) };
|
|
return function(t, e) {
|
|
function i() { this.constructor = t } s(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i)
|
|
}
|
|
}();
|
|
|
|
function x() {
|
|
function h(t, e) { this.x = t || 0, this.y = e || 0 }
|
|
|
|
function t(t, e) { this.pos = t || new h, this.r = e || 0 }
|
|
|
|
function s(t, e) { this.pos = t || new h, this.angle = 0, this.offset = new h, this.u(e || []) }
|
|
|
|
function l(t, e, i) { this.pos = t || new h, this.w = e || 0, this.h = i || 0 }
|
|
|
|
function e() { this.b = this.a = null, this.overlapN = new h, this.overlapV = new h, this.clear() }
|
|
|
|
function c(t, e, i) {
|
|
for (var s = Number.MAX_VALUE, o = -Number.MAX_VALUE, n = t.length, a = 0; a < n; a++) {
|
|
var r = t[a].f(e);
|
|
r < s && (s = r), o < r && (o = r)
|
|
}
|
|
i[0] = s, i[1] = o
|
|
}
|
|
|
|
function p(t, e, i, s, o, n) {
|
|
var a = u.pop(),
|
|
r = u.pop();
|
|
return e = (t = m.pop().c(e).sub(t)).f(o), c(i, o, a), c(s, o, r), r[0] += e, r[1] += e, a[0] > r[1] || r[0] > a[1] ? (m.push(t), u.push(a), u.push(r), !0) : (n && (a[0] < r[0] ? (n.aInB = !1, a[1] < r[1] ? (i = a[1] - r[0], n.bInA = !1) : i = (i = a[1] - r[0]) < (s = r[1] - a[0]) ? i : -s) : (n.bInA = !1, a[1] > r[1] ? (i = a[0] - r[1], n.aInB = !1) : i = (i = a[1] - r[0]) < (s = r[1] - a[0]) ? i : -s), (s = Math.abs(i)) < n.overlap && (n.overlap = s, n.overlapN.c(o), i < 0 && n.overlapN.reverse())), m.push(t), u.push(a), u.push(r), !1)
|
|
}
|
|
|
|
function f(t, e) {
|
|
var i = t.g(),
|
|
s = e.f(t);
|
|
return s < 0 ? -1 : i < s ? 1 : 0
|
|
}
|
|
|
|
function o(t, e, i) {
|
|
for (var s = m.pop().c(e.pos).sub(t.pos), o = e.r, n = o * o, a = t.calcPoints, r = a.length, h = m.pop(), l = m.pop(), c = 0; c < r; c++) {
|
|
var p = c === r - 1 ? 0 : c + 1,
|
|
u = 0 === c ? r - 1 : c - 1,
|
|
d = 0,
|
|
y = null;
|
|
h.c(t.edges[c]), l.c(s).sub(a[c]), i && l.g() > n && (i.aInB = !1);
|
|
var g = f(h, l);
|
|
if (-1 === g) {
|
|
if (h.c(t.edges[u]), 1 === (g = f(h, p = m.pop().c(s).sub(a[u])))) {
|
|
if (o < (g = l.j())) return m.push(s), m.push(h), m.push(l), m.push(p), !1;
|
|
i && (i.bInA = !1, y = l.normalize(), d = o - g)
|
|
}
|
|
m.push(p)
|
|
}
|
|
else if (1 === g) {
|
|
if (h.c(t.edges[p]), l.c(s).sub(a[p]), -1 === (g = f(h, l))) {
|
|
if (o < (g = l.j())) return m.push(s), m.push(h), m.push(l), !1;
|
|
i && (i.bInA = !1, y = l.normalize(), d = o - g)
|
|
}
|
|
}
|
|
else {
|
|
if (p = h.m().normalize(), g = l.f(p), u = Math.abs(g), 0 < g && o < u) return m.push(s), m.push(p), m.push(l), !1;
|
|
i && (y = p, d = o - g, 0 <= g || d < 2 * o) && (i.bInA = !1)
|
|
}
|
|
y && i && Math.abs(d) < Math.abs(i.overlap) && (i.overlap = d, i.overlapN.c(y))
|
|
}
|
|
return i && (i.a = t, i.b = e, i.overlapV.c(i.overlapN).scale(i.overlap)), m.push(s), m.push(h), m.push(l), !0
|
|
}
|
|
|
|
function n(t, e, i) {
|
|
for (var s = t.calcPoints, o = s.length, n = e.calcPoints, a = n.length, r = 0; r < o; r++)
|
|
if (p(t.pos, e.pos, s, n, t.normals[r], i)) return !1;
|
|
for (r = 0; r < a; r++)
|
|
if (p(t.pos, e.pos, s, n, e.normals[r], i)) return !1;
|
|
return i && (i.a = t, i.b = e, i.overlapV.c(i.overlapN).scale(i.overlap)), !0
|
|
}
|
|
var i = {};
|
|
i.Vector = h, (i.V = h).prototype.copy = h.prototype.c = function(t) { return this.x = t.x, this.y = t.y, this }, h.prototype.clone = h.prototype.clone = function() { return new h(this.x, this.y) }, h.prototype.perp = h.prototype.m = function() { var t = this.x; return this.x = this.y, this.y = -t, this }, h.prototype.rotate = h.prototype.rotate = function(t) {
|
|
var e = this.x,
|
|
i = this.y;
|
|
return this.x = e * Math.cos(t) - i * Math.sin(t), this.y = e * Math.sin(t) + i * Math.cos(t), this
|
|
}, h.prototype.reverse = h.prototype.reverse = function() { return this.x = -this.x, this.y = -this.y, this }, h.prototype.normalize = h.prototype.normalize = function() { var t = this.j(); return 0 < t && (this.x /= t, this.y /= t), this }, h.prototype.add = h.prototype.add = function(t) { return this.x += t.x, this.y += t.y, this }, h.prototype.sub = h.prototype.sub = function(t) { return this.x -= t.x, this.y -= t.y, this }, h.prototype.scale = h.prototype.scale = function(t, e) { return this.x *= t, this.y *= e || t, this }, h.prototype.project = h.prototype.o = function(t) { var e = this.f(t) / t.g(); return this.x = e * t.x, this.y = e * t.y, this }, h.prototype.projectN = h.prototype.s = function(t) { var e = this.f(t); return this.x = e * t.x, this.y = e * t.y, this }, h.prototype.reflect = function(t) {
|
|
var e = this.x,
|
|
i = this.y;
|
|
return this.o(t).scale(2), this.x -= e, this.y -= i, this
|
|
}, h.prototype.reflectN = function(t) {
|
|
var e = this.x,
|
|
i = this.y;
|
|
return this.s(t).scale(2), this.x -= e, this.y -= i, this
|
|
}, h.prototype.dot = h.prototype.f = function(t) { return this.x * t.x + this.y * t.y }, h.prototype.len2 = h.prototype.g = function() { return this.f(this) }, h.prototype.len = h.prototype.j = function() { return Math.sqrt(this.g()) }, (i.Circle = t).prototype.getAABB = function() { var t = this.r; return new l(this.pos.clone().sub(new h(t, t)), 2 * t, 2 * t).l() }, (i.Polygon = s).prototype.setPoints = s.prototype.u = function(t) {
|
|
if (!this.points || this.points.length !== t.length) {
|
|
var e, i = this.calcPoints = [],
|
|
s = this.edges = [],
|
|
o = this.normals = [];
|
|
for (e = 0; e < t.length; e++) i.push(new h), s.push(new h), o.push(new h)
|
|
}
|
|
return this.points = t, this.i(), this
|
|
}, s.prototype.setAngle = function(t) { return this.angle = t, this.i(), this }, s.prototype.setOffset = function(t) { return this.offset = t, this.i(), this }, s.prototype.rotate = s.prototype.rotate = function(t) { for (var e = this.points, i = e.length, s = 0; s < i; s++) e[s].rotate(t); return this.i(), this }, s.prototype.translate = s.prototype.translate = function(t, e) { for (var i = this.points, s = i.length, o = 0; o < s; o++) i[o].x += t, i[o].y += e; return this.i(), this }, s.prototype.i = function() {
|
|
var t, e = this.calcPoints,
|
|
i = this.edges,
|
|
s = this.normals,
|
|
o = this.points,
|
|
n = this.offset,
|
|
a = this.angle,
|
|
r = o.length;
|
|
for (t = 0; t < r; t++) {
|
|
var h = e[t].c(o[t]);
|
|
h.x += n.x, h.y += n.y, 0 !== a && h.rotate(a)
|
|
}
|
|
for (t = 0; t < r; t++) o = e[t], o = i[t].c(t < r - 1 ? e[t + 1] : e[0]).sub(o), s[t].c(o).m().normalize()
|
|
}, s.prototype.getAABB = function() {
|
|
for (var t = this.calcPoints, e = t.length, i = t[0].x, s = t[0].y, o = t[0].x, n = t[0].y, a = 1; a < e; a++) {
|
|
var r = t[a];
|
|
r.x < i ? i = r.x : r.x > o && (o = r.x), r.y < s ? s = r.y : r.y > n && (n = r.y)
|
|
}
|
|
return new l(this.pos.clone().add(new h(i, s)), o - i, n - s).l()
|
|
}, (i.Box = l).prototype.toPolygon = l.prototype.l = function() {
|
|
var t = this.pos,
|
|
e = this.w,
|
|
i = this.h;
|
|
return new s(new h(t.x, t.y), [new h, new h(e, 0), new h(e, i), new h(0, i)])
|
|
}, (i.Response = e).prototype.clear = e.prototype.clear = function() { return this.bInA = this.aInB = !0, this.overlap = Number.MAX_VALUE, this };
|
|
for (var m = [], a = 0; a < 10; a++) m.push(new h);
|
|
var u = [];
|
|
for (a = 0; a < 5; a++) u.push([]);
|
|
var r = new e,
|
|
d = new l(new h, 1e-6, 1e-6).l();
|
|
return i.isSeparatingAxis = p, i.pointInCircle = function(t, e) {
|
|
var i = m.pop().c(t).sub(e.pos),
|
|
s = e.r * e.r,
|
|
o = i.g();
|
|
return m.push(i), o <= s
|
|
}, i.pointInPolygon = function(t, e) { d.pos.c(t), r.clear(); var i = n(d, e, r); return i && (i = r.aInB), i }, i.testCircleCircle = function(t, e, i) {
|
|
var s = m.pop().c(e.pos).sub(t.pos),
|
|
o = t.r + e.r,
|
|
n = s.g();
|
|
return o * o < n ? (m.push(s), !1) : (i && (n = Math.sqrt(n), i.a = t, i.b = e, i.overlap = o - n, i.overlapN.c(s.normalize()), i.overlapV.c(s).scale(i.overlap), i.aInB = t.r <= e.r && n <= e.r - t.r, i.bInA = e.r <= t.r && n <= t.r - e.r), m.push(s), !0)
|
|
}, i.testPolygonCircle = o, i.testCirclePolygon = function(t, e, i) {
|
|
if ((t = o(e, t, i)) && i) {
|
|
e = i.a;
|
|
var s = i.aInB;
|
|
i.overlapN.reverse(), i.overlapV.reverse(), i.a = i.b, i.b = e, i.aInB = i.bInA, i.bInA = s
|
|
}
|
|
return t
|
|
}, i.testPolygonPolygon = n, i
|
|
}! function(t) {
|
|
var o, e;
|
|
(e = o = t.AnimationStatus || (t.AnimationStatus = {}))[e.STOPPED = 0] = "STOPPED", e[e.PLAYING = 1] = "PLAYING", e[e.PAUSED = 2] = "PAUSED", e[e.AUTO_PAUSED = 3] = "AUTO_PAUSED", e[e.BATCH_PAUSED = 4] = "BATCH_PAUSED";
|
|
var i = function() {
|
|
function t(t, e, i, s) { this.initValues = [], this.name = t, this.speed = e, this.parent = i, this.loop = s, this.status = o.STOPPED, this.loopCount = 0, this.onComplete = new Phaser.Signal, this.onLoop = new Phaser.Signal, this.onStart = new Phaser.Signal, this.onEvent = new Phaser.Signal, this.timeline = new TimelineMax({ paused: !0, autoRemoveChildren: !1 }), this.timeline.eventCallback("onComplete", this.onCompleteCallback, null, this), this.timeline.eventCallback("onRepeat", this.onLoopCallback, null, this), this.timeline.eventCallback("onStart", this.onStartCallback, null, this) }
|
|
return t.prototype.onCompleteCallback = function() { this.status = o.STOPPED, this.onComplete.dispatch(this.parent, this) }, t.prototype.onStartCallback = function() { this.onStart.dispatch(this.parent, this) }, t.prototype.onLoopCallback = function() { this.loopCount++, this.onLoop.dispatch(this.parent, this) }, t.prototype.onEventCallback = function(t) { this.onEvent.dispatch(t, this.parent, this) }, t.prototype.addTimelineChild = function(t) { this.timeline.add(t, 0), t.resume() }, t.prototype.play = function(t, e) {
|
|
if (this.timeline.invalidate(), this.initValues)
|
|
for (var i = 0; i < this.initValues.length; i++) {
|
|
var s = this.initValues[i];
|
|
s.target[s.property] = s.value
|
|
}
|
|
return t = void 0 !== t ? t : 1, void 0 === e && (e = this.loop), e ? (this.loopCount = 0, this.timeline.repeat(-1)) : this.timeline.repeat(0), this.timeline.timeScale(t), this.timeline.seek(this.timeline.duration()), this.timeline.play(0), this.status = o.PLAYING, this
|
|
}, t.prototype.stop = function(t, e) {
|
|
var i = !1;
|
|
void 0 !== e && (i = !e), void 0 !== t ? t ? this.timeline.pause(this.timeline.duration(), i) : this.timeline.pause(null, i) : this.timeline.pause(this.timeline.duration(), i), this.removeListeners(), this.status = o.STOPPED
|
|
}, t.prototype.isPlaying = function() { return this.status === o.PLAYING }, t.prototype.isStopped = function() { return this.status === o.STOPPED }, t.prototype.isPaused = function() { return this.status === o.PAUSED }, t.prototype.pause = function() { this.status !== o.PAUSED && (this.status = o.PAUSED, this.timeline.pause()) }, t.prototype.resume = function() { this.status !== o.PAUSED && this.status !== o.BATCH_PAUSED || (this.status = o.PLAYING, this.timeline.play()) }, t.prototype.autoPause = function() { this.status === o.PLAYING && (this.status = o.AUTO_PAUSED, this.timeline.pause()) }, t.prototype.autoResume = function() { this.status === o.AUTO_PAUSED && (this.status = o.PLAYING, this.timeline.play()) }, t.prototype.batchPause = function() { this.status === o.PLAYING && (this.status = o.BATCH_PAUSED, this.timeline.pause()) }, t.prototype.batchResume = function() { this.status === o.BATCH_PAUSED && (this.status = o.PLAYING, this.timeline.play()) }, t.prototype.addEvent = function(t) { this.timeline.addCallback(this.onEventCallback, t.frame / 1e3, [t.name], this) }, t.prototype.removeListeners = function() { this.onLoop.removeAll(), this.onEvent.removeAll(), this.onStart.removeAll(), this.onComplete.removeAll() }, t.prototype.changeFrame = function(t, e) { t.frameName = e }, t.prototype.checkTimelineDuration = function() { 0 === this.timeline.duration() && this.timeline.addCallback(function() {}, "+=0.0001") }, t.prototype.getTimelineMax = function() { return this.timeline }, t.prototype.addInitValue = function(t, e, i) { this.initValues.push({ target: t, property: e, value: i }) }, t.prototype.destroy = function() { this.removeListeners(), this.timeline.eventCallback("onComplete", null), this.timeline.eventCallback("onRepeat", null), this.timeline.eventCallback("onStart", null), this.initValues.length = 0, this.initValues = null, this.timeline.kill(), this.timeline = null }, t
|
|
}();
|
|
t.Animation = i
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(m) {
|
|
var t = function() {
|
|
function t(t) { this.game = t, this.cache = new m.AnimationCache(this.game), this.scale = 1, this.pauseAllSignal = new Phaser.Signal, this.resumeAllSignal = new Phaser.Signal, this.stopAllSignal = new Phaser.Signal }
|
|
return t.prototype.setGameScale = function(t) { this.scale = t }, Object.defineProperty(t.prototype, "gameScale", { get: function() { return this.scale }, enumerable: !0, configurable: !0 }), t.prototype.pauseAll = function() { this.pauseAllSignal.dispatch() }, t.prototype.resumeAll = function() { this.resumeAllSignal.dispatch() }, t.prototype.stopAll = function() { this.stopAllSignal.dispatch() }, t.prototype.getAnimationData = function(t) { var e = this.game.ph2AnimationManager.cache.getAnimationData(t); return e || (e = this.getAnimationDataFromJSON(t)) && this.cache.saveAnimationData(t, e), e }, t.prototype.getAnimationObject = function(t, e) { var i = this.getAnimationData(t); return this.createTree(i.hierarchy, e, null) }, t.prototype.getAnimationDataFromJSON = function(t) { var e = this.game.cache.getJSON(t); return e ? this.generateAnimationData(e) : null }, t.prototype.generateAnimationData = function(t) {
|
|
var e = t.hierarchy,
|
|
i = t.properties,
|
|
s = this.createCacheAnimationDataTree(e, i, null, null);
|
|
return new m.AnimationData(s)
|
|
}, t.prototype.createCacheAnimationDataTree = function(t, e, i, s) {
|
|
var o = null;
|
|
if (t) {
|
|
var n = t.name;
|
|
if (o = this.createCacheNode(t, e, t.animations, i, s), t.children) {
|
|
s = null !== s ? 0 === s.length ? n : s + "/" + n : "";
|
|
for (var a = t.children, r = 0; r < a.length; r++) {
|
|
var h = this.createCacheAnimationDataTree(a[r], e, o, s);
|
|
h && o.addChild(h)
|
|
}
|
|
}
|
|
}
|
|
return o
|
|
}, t.prototype.createCacheNode = function(t, e, i, s, o) {
|
|
var n = t.name,
|
|
a = n;
|
|
o && (a = o + "/" + n);
|
|
var r = null;
|
|
if (null === s)(r = new m.CacheAnimationElementGroup).name = n;
|
|
else {
|
|
var h = e[a],
|
|
l = h.type;
|
|
"sprite" === l ? ((r = new m.CacheAnimationElementSprite).name = n, r.textureName = h.file, void 0 !== h.anchor && (r.anchor.x = h.anchor.x, r.anchor.y = h.anchor.y), void 0 !== h.angle && (r.angle = h.angle), void 0 !== h.scale && (r.scale.x = h.scale.x, r.scale.y = h.scale.y), void 0 !== h.color && (r.tint = Phaser.Color.hexToRGB(h.color)), void 0 !== h.alpha && (r.alpha = h.alpha), void 0 !== h.position && (r.position.x = h.position.x, r.position.y = h.position.y)) : "container" === l ? ((r = new m.CacheAnimationElementGroup).name = n, void 0 !== h.position && (r.position.x = h.position.x, r.position.y = h.position.y), void 0 !== h.angle && (r.angle = h.angle), void 0 !== h.scale && (r.scale.x = h.scale.x, r.scale.y = h.scale.y), void 0 !== h.alpha && (r.alpha = h.alpha)) : "text" === l && ((r = new m.CacheAnimationElementText).name = n, void 0 !== h.anchor && (r.anchor.x = h.anchor.x, r.anchor.y = h.anchor.y), void 0 !== h.angle && (r.angle = h.angle), void 0 !== h.scale && (r.scale.x = h.scale.x, r.scale.y = h.scale.y), void 0 !== h.color && (r.tint = h.color), void 0 !== h.alpha && (r.alpha = h.alpha), void 0 !== h.position && (r.position.x = h.position.x, r.position.y = h.position.y), void 0 !== h.font && (r.fontName = h.font.name, r.fontSize = h.font.fontSize), void 0 !== h.text && (r.text = h.text), void 0 !== h.align && (r.align = h.align), void 0 !== h.stroke && (r.stroke = h.stroke), void 0 !== h.strokeThickness && (r.strokeThickness = h.strokeThickness))
|
|
}
|
|
if (i)
|
|
for (var c = 0; c < i.length; c++) this.addCacheAnimation(r, i[c]);
|
|
return r
|
|
}, t.prototype.addCacheAnimation = function(t, e) {
|
|
var i = this.game.cache.getJSON(e);
|
|
if (i) {
|
|
var s = void 0 !== i.speed ? i.speed : 1,
|
|
o = void 0 !== i.mode ? i.mode : null,
|
|
n = i.data,
|
|
a = i.events,
|
|
r = m.AnimationMode.NORMAL;
|
|
o && "loop" === o.toLowerCase() && (r = m.AnimationMode.LOOP), t.addAnimation(this.createCacheTimelineForAnimation(e, n, s, r, a))
|
|
}
|
|
}, t.prototype.createCacheTimelineForAnimation = function(t, e, i, s, o) {
|
|
var n = new m.CacheAnimation(t, i);
|
|
n.mode = s;
|
|
for (var a = Object.keys(e), r = 0; r < a.length; r++)
|
|
for (var h = a[r], l = e[h], c = Object.keys(l), p = 0; p < c.length; p++) {
|
|
var u = c[p],
|
|
d = l[u],
|
|
y = this.createCacheTimelineForProperty(h, u, d);
|
|
n.addTimeline(y)
|
|
}
|
|
if (o && 0 < o.length)
|
|
for (r = 0; r < o.length; r++) {
|
|
var g = new m.CacheEvent;
|
|
g.frame = o[r].frame, g.name = o[r].name, n.addEvent(g)
|
|
}
|
|
return n
|
|
}, t.prototype.createCacheTimelineForProperty = function(t, e, i) {
|
|
for (var s = new m.CacheTimeline(t, e), o = 0; o < i.length; o++) {
|
|
var n = new m.CacheFrame;
|
|
n.frame = i[o].frame, n.value = i[o].value, s.addFrame(n)
|
|
}
|
|
return s
|
|
}, t.prototype.createTree = function(t, e, i) {
|
|
var s = null;
|
|
if (t) {
|
|
if (s = this.createNode(t, e, i), t.children)
|
|
for (var o = t.children, n = 0; n < o.length; n++) {
|
|
var a = this.createTree(o[n], e, s);
|
|
a && s.addChild(a)
|
|
}
|
|
if (t.animations && 0 < t.animations.length)
|
|
for (var r = t.animations, h = 0; h < r.length; h++) this.addAnimationToNode(s, r[h])
|
|
}
|
|
return s
|
|
}, t.prototype.createNode = function(t, e, i) {
|
|
var s = t.name,
|
|
o = null;
|
|
return null === i ? (o = new m.AnimationGroup(this.game)).name = s : t instanceof m.CacheAnimationElementSprite ? ((o = new m.AnimationSprite(this.game, e, t.textureName)).name = s, o.anchor.x = t.anchor.x, o.anchor.y = t.anchor.y, o.angle = t.angle, o.scale.x = t.scale.x, o.scale.y = t.scale.y, o.alpha = t.alpha, o.tint = t.tint, o.x = t.position.x * this.gameScale, o.y = t.position.y * this.gameScale) : t instanceof m.CacheAnimationElementGroup ? ((o = new m.AnimationGroup(this.game)).name = s, o.x = t.position.x * this.gameScale, o.y = t.position.y * this.gameScale, o.angle = t.angle, o.scale.x = t.scale.x, o.scale.y = t.scale.y, o.alpha = t.alpha) : t instanceof m.CacheAnimationElementText && ((o = new m.AnimationText(this.game, t.position.x * this.gameScale, t.position.y * this.gameScale, t.text, { font: t.fontSize * this.gameScale + "px " + t.fontName, fill: t.tint, align: t.align, stroke: t.stroke, strokeThickness: t.strokeThickness * this.gameScale })).name = t.name, o.angle = t.angle, o.anchor.x = t.anchor.x, o.anchor.y = t.anchor.y, o.scale.x = t.scale.x, o.scale.y = t.scale.y, o.alpha = t.alpha), o
|
|
}, t.prototype.addAnimationToNode = function(t, e) {
|
|
for (var i = e.mode === m.AnimationMode.LOOP, s = new m.Animation(e.name, e.speed, t, i), o = null, n = null, a = 0; a < e.timelines.length; a++) {
|
|
var r = e.timelines[a],
|
|
h = r.target;
|
|
h !== o && (n = "__this__" === h ? t : m.AnimationSystem.findObject(h, t));
|
|
var l = new TimelineMax({ paused: !0, autoRemoveChildren: !1 }),
|
|
c = 0,
|
|
p = n.key;
|
|
p && t.game.cache.getFrameData(p);
|
|
for (var u = 0; u < r.frames.length; u++) {
|
|
var d = r.frames[u],
|
|
y = d.frame / 1e3,
|
|
g = y - c,
|
|
f = d.value;
|
|
switch (r.property) {
|
|
case "scaleX":
|
|
0 === g ? (s.addInitValue(n, "scaleX", f), l.set(n, { scaleX: f }, 0)) : l.to(n, g, { scaleX: f });
|
|
break;
|
|
case "scaleY":
|
|
0 === g ? (s.addInitValue(n, "scaleY", f), l.set(n, { scaleY: f }, 0)) : l.to(n, g, { scaleY: f });
|
|
break;
|
|
case "angle":
|
|
0 === g ? (s.addInitValue(n, "angle", f), l.set(n, { angle: f }, 0)) : l.to(n, g, { angle: f });
|
|
break;
|
|
case "alpha":
|
|
0 === g ? (s.addInitValue(n, "alpha", f), l.set(n, { alpha: f }, 0)) : l.to(n, g, { alpha: f });
|
|
break;
|
|
case "position":
|
|
0 === g ? (s.addInitValue(n, "x", f[0] * this.gameScale), s.addInitValue(n, "y", f[1] * this.gameScale), l.set(n, { x: f[0] * this.gameScale, y: f[1] * this.gameScale }, 0)) : l.to(n, g, { x: f[0] * this.gameScale, y: f[1] * this.gameScale });
|
|
break;
|
|
case "x":
|
|
0 === g ? (s.addInitValue(n, "x", f * this.gameScale), l.set(n, { x: f * this.gameScale }, 0)) : l.to(n, g, { x: f * this.gameScale });
|
|
break;
|
|
case "y":
|
|
0 === g ? (s.addInitValue(n, "y", f * this.gameScale), l.set(n, { y: f * this.gameScale }, 0)) : l.to(n, g, { y: f * this.gameScale });
|
|
break;
|
|
case "frameName":
|
|
0 === g && s.addInitValue(n, "frameName", f), l.addCallback(s.changeFrame, y, [n, f], this)
|
|
}
|
|
c = y
|
|
}
|
|
s.addTimelineChild(l), o = h
|
|
}
|
|
if (s.checkTimelineDuration(), e.events && 0 < e.events.length)
|
|
for (a = 0; a < e.events.length; a++) s.addEvent(e.events[a]);
|
|
t.ph2Animations.add(s)
|
|
}, t.findObject = function(t, e) {
|
|
for (var i = e, s = "/" !== t[0] ? 0 : 1, o = t.split("/"), n = s; n < o.length; n++) {
|
|
var a = o[n],
|
|
r = i.children;
|
|
i = null;
|
|
for (var h = 0, l = r.length; h < l; ++h) { var c = r[h]; if (c.name === a) { i = c; break } }
|
|
if (!i) return null
|
|
}
|
|
return i
|
|
}, t
|
|
}();
|
|
m.AnimationSystem = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e = function() {
|
|
function t(t) { this.game = t, this.animationData = {} }
|
|
return t.prototype.getAnimationData = function(t) { return this.animationData[t] || null }, t.prototype.saveAnimationData = function(t, e) { this.animationData[t] = e }, t
|
|
}();
|
|
t.AnimationCache = e
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e = function() {
|
|
function t() { this.animations = [], this.children = [] }
|
|
return t.prototype.addChild = function(t) { this.children.push(t) }, t.prototype.addAnimation = function(t) { this.animations.push(t) }, t
|
|
}(),
|
|
i = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.anchor = new Phaser.Point(.5, .5), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.tint = 16777215, t.alpha = 1, t.position = new Phaser.Point(0, 0), t }
|
|
return __extends(t, e), t
|
|
}(t.CacheAnimationElement = e);
|
|
t.CacheAnimationElementSprite = i;
|
|
var s = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.position = new Phaser.Point(0, 0), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.alpha = 1, t }
|
|
return __extends(t, e), t
|
|
}(e);
|
|
t.CacheAnimationElementGroup = s;
|
|
var o = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.anchor = new Phaser.Point(.5, .5), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.tint = "#FFFFFF", t.alpha = 1, t.position = new Phaser.Point(0, 0), t.text = "", t.fontName = "Arial", t.fontSize = 24, t.align = "center", t.stroke = "black", t.strokeThickness = 0, t }
|
|
return __extends(t, e), t
|
|
}(e);
|
|
t.CacheAnimationElementText = o;
|
|
var n = function() {
|
|
function t(t, e) { this.name = t, this.timelines = [], this.speed = e, this.events = [] }
|
|
return t.prototype.addTimeline = function(t) { this.timelines.push(t) }, t.prototype.addEvent = function(t) { this.events.push(t) }, t
|
|
}();
|
|
t.CacheAnimation = n;
|
|
var a = function() {
|
|
function t(t, e) { this.target = t, this.property = e, this.frames = [] }
|
|
return t.prototype.addFrame = function(t) { this.frames.push(t) }, t
|
|
}();
|
|
t.CacheTimeline = a;
|
|
var r = function() {};
|
|
t.CacheFrame = r;
|
|
var h = function() {};
|
|
t.CacheEvent = h;
|
|
var l, c = function(t) { this.hierarchy = t };
|
|
t.AnimationData = c, (l = t.AnimationMode || (t.AnimationMode = {}))[l.NORMAL = 0] = "NORMAL", l[l.LOOP = 1] = "LOOP"
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(r) {
|
|
var s = function(t, e) { this.key = t, this.value = e };
|
|
r.CacheOrientationProperty = s;
|
|
var o = function() {
|
|
function t() { this.backup = [], this.portrait = [], this.landscape = [] }
|
|
return t.prototype.addProperty = function(t, e, i) { null === i ? this.backup.push(new s(t, e)) : i === r.AlignmentScope.LANDSCAPE ? this.landscape.push(new s(t, e)) : i === r.AlignmentScope.PORTRAIT && this.portrait.push(new s(t, e)) }, t
|
|
}();
|
|
r.CacheOrientationProperties = o;
|
|
var t = function() {
|
|
function t() { this.children = [], this.orientationVisibility = r.OrientationType.BOTH, this.platformVisibility = r.PlatformType.BOTH }
|
|
return t.prototype.addChild = function(t) { this.children.push(t) }, t.prototype.addAlignment = function(t, e, i, s, o, n) {
|
|
var a = new h;
|
|
a.type = t, a.offset.x = e, a.offset.y = i, a.isAbsoluteX = s, a.isAbsoluteY = o, n === r.AlignmentScope.ALL ? this.alignment = a : n === r.AlignmentScope.PORTRAIT ? this.portraitAlignment = a : n === r.AlignmentScope.LANDSCAPE && (this.landscapeAlignment = a)
|
|
}, t.prototype.addOrientationProperty = function(t, e, i) { this.orientationProperties || (this.orientationProperties = new o), void 0 !== e && this.orientationProperties.addProperty(t, e, i) }, t.prototype.setOrientationVisibility = function(t) { this.orientationVisibility = t }, t.prototype.setPlatformVisibility = function(t) { this.platformVisibility = t }, t
|
|
}();
|
|
r.CacheUIElement = t;
|
|
var h = function() { this.offset = new Phaser.Point(0, 0), this.isAbsoluteX = !0, this.isAbsoluteY = !0 };
|
|
r.CacheAlignment = h;
|
|
var a = function(t, e, i, s) { this.top = t, this.bottom = e, this.left = i, this.right = s };
|
|
r.CacheSliceData = a;
|
|
var i = function(t, e) { this.width = t, this.height = e };
|
|
r.CacheTiledData = i;
|
|
var e = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.anchor = new Phaser.Point(.5, .5), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.tint = 16777215, t.alpha = 1, t.position = new Phaser.Point(0, 0), t.imageType = "SIMPLE", t }
|
|
return __extends(t, e), t.prototype.addSliceData = function(t, e, i, s, o, n) { this.sliceData = new a(t, e, i, s), this.sliceData.width = o, this.sliceData.height = n }, t.prototype.addTiledData = function(t, e) { this.tiledData = new i(t, e) }, t
|
|
}(t);
|
|
r.CacheUISprite = e;
|
|
var n = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.designResolution = new Phaser.Rectangle(0, 0, 0, 0), t }
|
|
return __extends(t, e), t.prototype.setSafeZone = function(t, e) { this.safeZone = new Phaser.Rectangle(0, 0, t, e) }, t
|
|
}(t);
|
|
r.CacheUICanvas = n;
|
|
var l = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.position = new Phaser.Point(0, 0), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.alpha = 1, t }
|
|
return __extends(t, e), t.prototype.addSize = function(t, e) { this.size = new Phaser.Rectangle(0, 0, t, e) }, t
|
|
}(t);
|
|
r.CacheUIGroup = l;
|
|
var c = function(t, e, i) { this.normal = t, this.pressed = e, this.hover = i };
|
|
r.CacheUIButtonStates = c;
|
|
var p = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.anchor = new Phaser.Point(.5, .5), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.tint = 16777215, t.alpha = 1, t.position = new Phaser.Point(0, 0), t.imageType = "SIMPLE", t }
|
|
return __extends(t, e), t.prototype.addSliceData = function(t, e, i, s, o, n) { this.sliceData = new a(t, e, i, s), this.sliceData.width = o, this.sliceData.height = n }, t.prototype.addStates = function(t, e, i) { this.statesData = new c(t, e, i) }, t
|
|
}(t);
|
|
r.CacheUIButton = p;
|
|
var u = function(e) {
|
|
function t() { var t = e.call(this) || this; return t.anchor = new Phaser.Point(.5, .5), t.angle = 0, t.scale = new Phaser.Point(1, 1), t.tint = "#FFFFFF", t.alpha = 1, t.position = new Phaser.Point(0, 0), t.text = "", t.fontName = "Arial", t.fontSize = 24, t.lineHeight = 24, t.align = "center", t.stroke = "black", t.strokeThickness = 0, t }
|
|
return __extends(t, e), t
|
|
}(t);
|
|
r.CacheUIText = u;
|
|
var d = function(t) {
|
|
function e() { return t.call(this) || this }
|
|
return __extends(e, t), e
|
|
}(t);
|
|
r.CacheUINode = d;
|
|
var y = function(t) { this.hierarchy = t };
|
|
r.UIData = y
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(s) {
|
|
var t = function(i) {
|
|
function t(t) { var e = i.call(this, t, 0, 0, null) || this; return e.ph2Animations = new s.AnimationManager(t), e }
|
|
return __extends(t, i), Object.defineProperty(t.prototype, "scaleX", { get: function() { return this.scale.x }, set: function(t) { this.scale.x = t }, enumerable: !0, configurable: !0 }), Object.defineProperty(t.prototype, "scaleY", { get: function() { return this.scale.y }, set: function(t) { this.scale.y = t }, enumerable: !0, configurable: !0 }), t
|
|
}(Phaser.Sprite);
|
|
s.AnimationGroup = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(n) {
|
|
var t = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, 0, 0, e, i) || this; return s.ph2Animations = new n.AnimationManager(t), s }
|
|
return __extends(t, o), Object.defineProperty(t.prototype, "scaleX", { get: function() { return this.scale.x }, set: function(t) { this.scale.x = t }, enumerable: !0, configurable: !0 }), Object.defineProperty(t.prototype, "scaleY", { get: function() { return this.scale.y }, set: function(t) { this.scale.y = t }, enumerable: !0, configurable: !0 }), t
|
|
}(Phaser.Sprite);
|
|
n.AnimationSprite = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(r) {
|
|
var t = function(a) {
|
|
function t(t, e, i, s, o) { var n = a.call(this, t, e, i, s, o) || this; return n.ph2Animations = new r.AnimationManager(t), n }
|
|
return __extends(t, a), t
|
|
}(Phaser.Text);
|
|
r.AnimationText = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e, i, s, o;
|
|
(e = t.OrientationType || (t.OrientationType = {}))[e.PORTRAIT = 0] = "PORTRAIT", e[e.LANDSCAPE = 1] = "LANDSCAPE", e[e.BOTH = 2] = "BOTH", e[e.NONE = 3] = "NONE", (i = t.PlatformType || (t.PlatformType = {}))[i.DESKTOP = 0] = "DESKTOP", i[i.MOBILE = 1] = "MOBILE", i[i.BOTH = 2] = "BOTH", (s = t.AlignTargetType || (t.AlignTargetType = {}))[s.PARENT = 0] = "PARENT", s[s.WORLD = 1] = "WORLD", (o = t.AlignmentScope || (t.AlignmentScope = {}))[o.ALL = 0] = "ALL", o[o.PORTRAIT = 1] = "PORTRAIT", o[o.LANDSCAPE = 2] = "LANDSCAPE"
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var e = function() {
|
|
function t() {}
|
|
return t.prototype.getOffset = function(t) { return this.isAbsolute ? this.offset : this.offset * t }, t
|
|
}();
|
|
i.AlignmentOffset = e;
|
|
var s = function() {
|
|
function t() { this.offsetX = new e, this.offsetY = new e }
|
|
return t.prototype.getType = function() {
|
|
switch (this.type) {
|
|
case "TOP_LEFT":
|
|
return Phaser.TOP_LEFT;
|
|
case "TOP_CENTER":
|
|
return Phaser.TOP_CENTER;
|
|
case "TOP_RIGHT":
|
|
return Phaser.TOP_RIGHT;
|
|
case "LEFT_TOP":
|
|
return Phaser.LEFT_TOP;
|
|
case "LEFT_CENTER":
|
|
return Phaser.LEFT_CENTER;
|
|
case "LEFT_BOTTOM":
|
|
return Phaser.LEFT_BOTTOM;
|
|
case "CENTER":
|
|
return Phaser.CENTER;
|
|
case "RIGHT_TOP":
|
|
return Phaser.RIGHT_TOP;
|
|
case "RIGHT_CENTER":
|
|
return Phaser.RIGHT_CENTER;
|
|
case "RIGHT_BOTTOM":
|
|
return Phaser.RIGHT_BOTTOM;
|
|
case "BOTTOM_LEFT":
|
|
return Phaser.BOTTOM_LEFT;
|
|
case "BOTTOM_CENTER":
|
|
return Phaser.BOTTOM_CENTER;
|
|
case "BOTTOM_RIGHT":
|
|
return Phaser.BOTTOM_RIGHT;
|
|
default:
|
|
return Phaser.CENTER
|
|
}
|
|
}, t
|
|
}();
|
|
i.Alignment = s;
|
|
var t = function() {
|
|
function t(t) { this.game = t, this.landscapeAlignment = new s, this.portraitAlignment = new s }
|
|
return t.prototype.setAlignTarget = function(t) { this.alignTargetType = t }, t.prototype.setLandscapeAlignment = function(t, e, i, s, o) { this.landscapeAlignment.type = t, this.landscapeAlignment.offsetX.offset = e * (i ? this.game.ph2UIManager.gameScale : 1), this.landscapeAlignment.offsetX.isAbsolute = i, this.landscapeAlignment.offsetY.offset = s * (o ? this.game.ph2UIManager.gameScale : 1), this.landscapeAlignment.offsetY.isAbsolute = o }, t.prototype.setPortraitAlignment = function(t, e, i, s, o) { this.portraitAlignment.type = t, this.portraitAlignment.offsetX.offset = e * (i ? this.game.ph2UIManager.gameScale : 1), this.portraitAlignment.offsetX.isAbsolute = i, this.portraitAlignment.offsetY.offset = s * (o ? this.game.ph2UIManager.gameScale : 1), this.portraitAlignment.offsetY.isAbsolute = o }, t.prototype.getCurrentAlignment = function() { return this.game.ph2UIManager.alignmentManager.getCurrentOrientation() === i.Orientation.LANDSCAPE ? this.landscapeAlignment : this.portraitAlignment }, t.prototype.applyAlignment = function(t) {
|
|
var e = this.getCurrentAlignment();
|
|
this.alignTargetType === i.AlignTargetType.WORLD ? t.alignIn(this.game.ph2UIManager.alignmentManager.alignBounds, e.getType(), e.offsetX.getOffset(this.game.ph2UIManager.alignmentManager.alignBounds.width), e.offsetY.getOffset(this.game.ph2UIManager.alignmentManager.alignBounds.height)) : this.alignTargetType === i.AlignTargetType.PARENT && i.AlignmentSystem.alignInParent(t, e.getType(), e.offsetX.getOffset(t.parent.width), e.offsetY.getOffset(t.parent.height))
|
|
}, t.prototype.destroy = function() { this.game = null, this.alignTargetType = null, this.landscapeAlignment = null, this.portraitAlignment = null }, t
|
|
}();
|
|
i.UIAlignment = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(e) {
|
|
var t = function() {
|
|
function t(t, e) { this.game = t, this.enabled = this.game.ph2UIManager.enableVisibilityAndOrientationComponent, this.elementProperties = {}, this.landscapeProperties = {}, this.portraitProperties = {} }
|
|
return t.prototype.enable = function(t) { this.enabled = t }, t.prototype.backupOriginalProperty = function(t, e) { this.elementProperties[t] = e }, t.prototype.addPortraitProperty = function(t, e) { this.portraitProperties[t] = e }, t.prototype.addLandscapePortrait = function(t, e) { this.landscapeProperties[t] = e }, t.prototype.applyOriginalProperties = function(t) {
|
|
for (var e = Object.keys(this.elementProperties), i = 0; i < e.length; i++) {
|
|
var s = e[i];
|
|
t[s] = this.elementProperties[s]
|
|
}
|
|
}, t.prototype.applyPortraitProperties = function(t) {
|
|
this.applyOriginalProperties(t);
|
|
for (var e = Object.keys(this.portraitProperties), i = 0; i < e.length; i++) {
|
|
var s = e[i];
|
|
t[s] = this.portraitProperties[s]
|
|
}
|
|
}, t.prototype.applyLandscapeProperties = function(t) {
|
|
this.applyOriginalProperties(t);
|
|
for (var e = Object.keys(this.landscapeProperties), i = 0; i < e.length; i++) {
|
|
var s = e[i];
|
|
t[s] = this.landscapeProperties[s]
|
|
}
|
|
}, t.prototype.apply = function(t) { this.enabled && (this.game.ph2UIManager.alignmentManager.getCurrentOrientation() === e.Orientation.PORTRAIT ? this.applyPortraitProperties(t) : this.game.ph2UIManager.alignmentManager.getCurrentOrientation() === e.Orientation.LANDSCAPE && this.applyLandscapeProperties(t)) }, t
|
|
}();
|
|
e.UIOrientationProperties = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(s) {
|
|
var t = function() {
|
|
function t(t) { this.game = t, this.enabled = this.game.ph2UIManager.enableVisibilityAndOrientationComponent, this.orientationType = s.OrientationType.BOTH, this.platformType = s.PlatformType.BOTH }
|
|
return t.prototype.setOrientationVisible = function(t) { this.orientationType = t }, t.prototype.setPlatformVisible = function(t) { this.platformType = t }, t.prototype.enable = function(t) { this.enabled = t }, t.prototype.applyVisibility = function(t) {
|
|
if (this.enabled) {
|
|
var e = this.platformType === s.PlatformType.BOTH || this.platformType === s.PlatformType.DESKTOP && "desktop" === this.game.ph2UIManager.currentPlatform || this.platformType === s.PlatformType.MOBILE && "mobile" === this.game.ph2UIManager.currentPlatform,
|
|
i = this.orientationType === s.OrientationType.BOTH || this.orientationType === s.OrientationType.LANDSCAPE && this.game.ph2UIManager.alignmentManager.getCurrentOrientation() === s.Orientation.LANDSCAPE || this.orientationType === s.OrientationType.PORTRAIT && this.game.ph2UIManager.alignmentManager.getCurrentOrientation() === s.Orientation.PORTRAIT;
|
|
return t.visible = e && i, t.visible
|
|
}
|
|
}, t
|
|
}();
|
|
s.UIVisibility = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(n) {
|
|
var t = function() {
|
|
function t() {}
|
|
return t.UICanvas = function(t, e) { var i = new n.CacheUICanvas; return i.name = t, void 0 !== e.design && (i.designResolution.width = e.design.width, i.designResolution.height = e.design.height), void 0 !== e.safeZone && i.setSafeZone(e.safeZone.width, e.safeZone.height), i }, t.UISprite = function(t, e) {
|
|
var i = new n.CacheUISprite;
|
|
if (i.name = t, i.textureName = e.file, n.CacheFactory.addAnchorProperty(i, e), n.CacheFactory.addAngleProperty(i, e), n.CacheFactory.addScaleProperty(i, e), n.CacheFactory.addColorProperty(i, e), n.CacheFactory.addPositionProperty(i, e), n.CacheFactory.addAlignmentProperty(i, e, n.AlignmentScope.ALL), n.CacheFactory.addOrientationProperty(i, e), n.CacheFactory.addPlatformVisibilityProperty(i, e), void 0 !== e.image) {
|
|
var s = e.image;
|
|
if ("SLICED" === (i.imageType = s)) {
|
|
var o = e.slice;
|
|
i.addSliceData(o.top, o.bottom, o.left, o.right, e.size.width, e.size.height)
|
|
}
|
|
else "TILED" === s && i.addTiledData(e.size.width, e.size.height)
|
|
}
|
|
else i.imageType = "NORMAL";
|
|
return i
|
|
}, t.UIGroup = function(t, e) { var i = new n.CacheUIGroup; return i.name = t, n.CacheFactory.addPositionProperty(i, e), n.CacheFactory.addAngleProperty(i, e), n.CacheFactory.addScaleProperty(i, e), n.CacheFactory.addAlphaProperty(i, e), n.CacheFactory.addAlignmentProperty(i, e, n.AlignmentScope.ALL), n.CacheFactory.addPlatformVisibilityProperty(i, e), n.CacheFactory.addOrientationProperty(i, e), void 0 !== e.size && i.addSize(e.size.width, e.size.height), i }, t.UIButton = function(t, e) {
|
|
var i = new n.CacheUIButton;
|
|
if (i.name = t, i.textureName = e.file, n.CacheFactory.addAnchorProperty(i, e), n.CacheFactory.addAngleProperty(i, e), n.CacheFactory.addScaleProperty(i, e), n.CacheFactory.addColorProperty(i, e), n.CacheFactory.addAlphaProperty(i, e), n.CacheFactory.addPositionProperty(i, e), n.CacheFactory.addAlignmentProperty(i, e, n.AlignmentScope.ALL), n.CacheFactory.addPlatformVisibilityProperty(i, e), n.CacheFactory.addOrientationProperty(i, e), void 0 !== e.image) {
|
|
var s = e.image;
|
|
if ("SLICED" === (i.imageType = s)) {
|
|
var o = e.slice;
|
|
i.addSliceData(o.top, o.bottom, o.left, o.right, e.size.width, e.size.height)
|
|
}
|
|
}
|
|
else i.imageType = "NORMAL";
|
|
return void 0 !== e.transitionMode && (i.transitionMode = e.transitionMode, "image" === i.transitionMode ? i.addStates(e.transition.normal, e.transition.pressed, e.transition.hover) : "color" === i.transitionMode ? i.addStates(e.transition.normal, e.transition.pressed, e.transition.hover) : "scale" === i.transitionMode && i.addStates(e.transition.normal, e.transition.pressed, e.transition.hover)), i
|
|
}, t.UIText = function(t, e) { var i = new n.CacheUIText; return i.name = t, n.CacheFactory.addAnchorProperty(i, e), n.CacheFactory.addAngleProperty(i, e), n.CacheFactory.addScaleProperty(i, e), n.CacheFactory.addColorProperty(i, e, !0), n.CacheFactory.addAlphaProperty(i, e), n.CacheFactory.addPositionProperty(i, e), n.CacheFactory.addPlatformVisibilityProperty(i, e), n.CacheFactory.addAlignmentProperty(i, e, n.AlignmentScope.ALL), n.CacheFactory.addOrientationProperty(i, e), void 0 !== e.font && (i.fontName = e.font.name, i.fontSize = e.font.fontSize, i.lineHeight = e.font.lineHeight), void 0 !== e.text && (i.text = e.text), void 0 !== e.align && (i.align = e.align), void 0 !== e.stroke && (i.stroke = e.stroke), void 0 !== e.strokeThickness && (i.strokeThickness = e.strokeThickness), i }, t.addAnchorProperty = function(t, e) { void 0 !== e.anchor && (t.anchor.x = e.anchor.x, t.anchor.y = e.anchor.y) }, t.addAngleProperty = function(t, e) { void 0 !== e.angle && (t.angle = e.angle) }, t.addScaleProperty = function(t, e) { void 0 !== e.scale && (t.scale.x = e.scale.x, t.scale.y = e.scale.y) }, t.addColorProperty = function(t, e, i) { void 0 !== e.color && (t.tint = i ? e.color : Phaser.Color.hexToRGB(e.color)) }, t.addAlphaProperty = function(t, e) { void 0 !== e.alpha && (t.alpha = e.alpha) }, t.addPositionProperty = function(t, e) { void 0 !== e.position && (t.position.x = e.position.x, t.position.y = e.position.y) }, t.addAlignmentProperty = function(t, e, i) {
|
|
if (void 0 !== e.alignment) {
|
|
var s = 0,
|
|
o = 0,
|
|
n = !0,
|
|
a = !0;
|
|
void 0 !== e.alignment.offset && (s = e.alignment.offset.x, o = e.alignment.offset.y, "string" == typeof s && (n = !1, s = Number(s.split("%")[0]) / 100), "string" == typeof o && (a = !1, o = Number(o.split("%")[0]) / 100)), t.addAlignment(e.alignment.type, s, o, n, a, i)
|
|
}
|
|
}, t.addOrientationProperty = function(t, e) {
|
|
var i = n.OrientationType.BOTH;
|
|
if (void 0 !== e.orientation && ((void 0 !== e.orientation.landscape && void 0 !== e.orientation.landscape.properties || void 0 !== e.orientation.portrait && void 0 !== e.orientation.portrait.properties) && (t.addOrientationProperty("scale", t.scale, null), t.addOrientationProperty("angle", t.angle, null), t.addOrientationProperty("anchor", t.anchor, null), t.addOrientationProperty("alpha", t.alpha, null), t.addOrientationProperty("position", t.position, null)), void 0 !== e.orientation.landscape && (void 0 !== e.orientation.landscape.alignment && (s = e.orientation.landscape, n.CacheFactory.addAlignmentProperty(t, s, n.AlignmentScope.LANDSCAPE)), void 0 !== e.orientation.landscape.properties && n.CacheFactory.addOrientationPropertyForOrientation(t, e.orientation.landscape.properties, n.AlignmentScope.LANDSCAPE), void 0 !== e.orientation.landscape.hide && e.orientation.landscape.hide && (i = n.OrientationType.PORTRAIT)), void 0 !== e.orientation.portrait)) {
|
|
if (void 0 !== e.orientation.portrait.alignment) {
|
|
var s = e.orientation.portrait;
|
|
n.CacheFactory.addAlignmentProperty(t, s, n.AlignmentScope.PORTRAIT)
|
|
}
|
|
void 0 !== e.orientation.portrait.properties && n.CacheFactory.addOrientationPropertyForOrientation(t, e.orientation.portrait.properties, n.AlignmentScope.PORTRAIT), void 0 !== e.orientation.portrait.hide && e.orientation.portrait.hide && (i === n.OrientationType.PORTRAIT ? i = n.OrientationType.NONE : i === n.OrientationType.BOTH && (i = n.OrientationType.LANDSCAPE))
|
|
}
|
|
t.setOrientationVisibility(i)
|
|
}, t.addOrientationPropertyForOrientation = function(t, e, i) { void 0 !== e.scale && t.addOrientationProperty("scale", new Phaser.Point(e.scale.x, e.scale.y), i), void 0 !== e.angle && t.addOrientationProperty("angle", e.angle, i), void 0 !== e.anchor && t.addOrientationProperty("anchor", new Phaser.Point(e.anchor.x, e.anchor.y), i), void 0 !== e.alpha && t.addOrientationProperty("alpha", e.alpha, i), void 0 !== e.position && t.addOrientationProperty("position", new Phaser.Point(e.position.x, e.position.y), i) }, t.addPlatformVisibilityProperty = function(t, e) {
|
|
var i = n.PlatformType.BOTH;
|
|
void 0 !== e.visibility && (i = "desktop" === e.visibility ? n.PlatformType.DESKTOP : "mobile" === e.visibility ? n.PlatformType.MOBILE : n.PlatformType.BOTH), t.setPlatformVisibility(i)
|
|
}, t
|
|
}();
|
|
n.CacheFactory = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(r) {
|
|
var t = function() {
|
|
function t() {}
|
|
return t.UICanvas = function(t, e) { var i = new r.UI(t, e.designResolution.width, e.designResolution.height); return i.name = e.name, e.safeZone && i.setSafeZone(e.safeZone.width * t.ph2UIManager.gameScale, e.safeZone.height * t.ph2UIManager.gameScale), i }, t.UISprite = function(t, e, i, s) { var o; if (e.sliceData ? (o = new r.UISlicedSprite(t, e.position.x * t.ph2UIManager.gameScale, e.position.y * t.ph2UIManager.gameScale, i, e.textureName, e.sliceData.width * t.ph2UIManager.gameScale, e.sliceData.height * t.ph2UIManager.gameScale, { top: e.sliceData.top * t.ph2UIManager.gameScale, bottom: e.sliceData.bottom * t.ph2UIManager.gameScale, left: e.sliceData.left * t.ph2UIManager.gameScale, right: e.sliceData.right * t.ph2UIManager.gameScale })).name = e.name : e.tiledData ? (o = new r.UITiledSprite(t, 0, 0, e.tiledData.width * t.ph2UIManager.gameScale, e.tiledData.height * t.ph2UIManager.gameScale, i, e.textureName)).name = e.name : (o = new r.UISprite(t, 0, 0, i, e.textureName)).name = e.name, o.anchor.x = e.anchor.x, o.anchor.y = e.anchor.y, o.angle = e.angle, o.scale.x = e.scale.x, o.scale.y = e.scale.y, o.alpha = e.alpha, o.tint = e.tint, o.x = e.position.x * t.ph2UIManager.gameScale, o.y = e.position.y * t.ph2UIManager.gameScale, e.alignment && (o.enableAlignment(), o.alignment.setLandscapeAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), o.alignment.setPortraitAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), s instanceof r.UI ? o.alignment.setAlignTarget(r.AlignTargetType.WORLD) : o.alignment.setAlignTarget(r.AlignTargetType.PARENT)), e.portraitAlignment && (o.alignment || o.enableAlignment(), o.alignment.setPortraitAlignment(e.portraitAlignment.type, e.portraitAlignment.offset.x, e.portraitAlignment.isAbsoluteX, e.portraitAlignment.offset.y, e.portraitAlignment.isAbsoluteY)), e.landscapeAlignment && (o.alignment || o.enableAlignment(), o.alignment.setLandscapeAlignment(e.landscapeAlignment.type, e.landscapeAlignment.offset.x, e.landscapeAlignment.isAbsoluteX, e.landscapeAlignment.offset.y, e.landscapeAlignment.isAbsoluteY)), e.orientationProperties) { for (o.enableOrientationProperties(), n = 0; n < e.orientationProperties.backup.length; n++) "position" === (a = e.orientationProperties.backup[n]).key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.backupOriginalProperty(a.key, a.value); for (n = 0; n < e.orientationProperties.portrait.length; n++) "position" === (a = e.orientationProperties.portrait[n]).key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.addPortraitProperty(a.key, a.value); for (var n = 0; n < e.orientationProperties.landscape.length; n++) { var a = e.orientationProperties.landscape[n]; "position" === a.key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.addLandscapePortrait(a.key, a.value) } } return o.enableVisibility(e.platformVisibility, e.orientationVisibility), o }, t.UIGroup = function(t, e, i) { var s = new r.UIGroup(t); if (s.name = e.name, s.x = e.position.x * t.ph2UIManager.gameScale, s.y = e.position.y * t.ph2UIManager.gameScale, s.angle = e.angle, s.scale.x = e.scale.x, s.scale.y = e.scale.y, s.alpha = e.alpha, e.alignment && (s.enableAlignment(), s.alignment.setLandscapeAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), s.alignment.setPortraitAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), i instanceof r.UI ? s.alignment.setAlignTarget(r.AlignTargetType.WORLD) : s.alignment.setAlignTarget(r.AlignTargetType.PARENT)), e.portraitAlignment && (s.alignment || s.enableAlignment(), s.alignment.setPortraitAlignment(e.portraitAlignment.type, e.portraitAlignment.offset.x, e.portraitAlignment.isAbsoluteX, e.portraitAlignment.offset.y, e.portraitAlignment.isAbsoluteY)), e.landscapeAlignment && (s.alignment || s.enableAlignment(), s.alignment.setLandscapeAlignment(e.landscapeAlignment.type, e.landscapeAlignment.offset.x, e.landscapeAlignment.isAbsoluteX, e.landscapeAlignment.offset.y, e.landscapeAlignment.isAbsoluteY)), e.orientationProperties) { for (s.enableOrientationProperties(), o = 0; o < e.orientationProperties.backup.length; o++) "position" === (n = e.orientationProperties.backup[o]).key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.backupOriginalProperty(n.key, n.value); for (o = 0; o < e.orientationProperties.portrait.length; o++) "position" === (n = e.orientationProperties.portrait[o]).key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.addPortraitProperty(n.key, n.value); for (var o = 0; o < e.orientationProperties.landscape.length; o++) { var n = e.orientationProperties.landscape[o]; "position" === n.key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.addLandscapePortrait(n.key, n.value) } } return s.enableVisibility(e.platformVisibility, e.orientationVisibility), s }, t.UIText = function(t, e, i) { var s = new r.UIText(t, e.position.x * t.ph2UIManager.gameScale, e.position.y * t.ph2UIManager.gameScale, e.text, { font: e.fontSize * t.ph2UIManager.gameScale + "px " + e.fontName, fill: e.tint, align: e.align, stroke: e.stroke, strokeThickness: e.strokeThickness * t.ph2UIManager.gameScale }); if (s.name = e.name, s.angle = e.angle, s.anchor.x = e.anchor.x, s.anchor.y = e.anchor.y, s.scale.x = e.scale.x, s.scale.y = e.scale.y, s.alpha = e.alpha, e.alignment && (s.enableAlignment(), s.alignment.setLandscapeAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), s.alignment.setPortraitAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), i instanceof r.UI ? s.alignment.setAlignTarget(r.AlignTargetType.WORLD) : s.alignment.setAlignTarget(r.AlignTargetType.PARENT)), e.portraitAlignment && (s.alignment || s.enableAlignment(), s.alignment.setPortraitAlignment(e.portraitAlignment.type, e.portraitAlignment.offset.x, e.portraitAlignment.isAbsoluteX, e.portraitAlignment.offset.y, e.portraitAlignment.isAbsoluteY)), e.landscapeAlignment && (s.alignment || s.enableAlignment(), s.alignment.setLandscapeAlignment(e.landscapeAlignment.type, e.landscapeAlignment.offset.x, e.landscapeAlignment.isAbsoluteX, e.landscapeAlignment.offset.y, e.landscapeAlignment.isAbsoluteY)), e.orientationProperties) { for (s.enableOrientationProperties(), o = 0; o < e.orientationProperties.backup.length; o++) "position" === (n = e.orientationProperties.backup[o]).key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.backupOriginalProperty(n.key, n.value); for (o = 0; o < e.orientationProperties.portrait.length; o++) "position" === (n = e.orientationProperties.portrait[o]).key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.addPortraitProperty(n.key, n.value); for (var o = 0; o < e.orientationProperties.landscape.length; o++) { var n = e.orientationProperties.landscape[o]; "position" === n.key && (n.value.x = n.value.x * t.ph2UIManager.gameScale, n.value.y = n.value.y * t.ph2UIManager.gameScale), s.orientationProperties.addLandscapePortrait(n.key, n.value) } } return s.enableVisibility(e.platformVisibility, e.orientationVisibility), s }, t.UIButton = function(t, e, i, s) { var o; if (e.sliceData ? ((o = new r.UISlicedButton(t, e.position.x * t.ph2UIManager.gameScale, e.position.y * t.ph2UIManager.gameScale, i, e.textureName, e.sliceData.width * t.ph2UIManager.gameScale, e.sliceData.height * t.ph2UIManager.gameScale, { top: e.sliceData.top * t.ph2UIManager.gameScale, bottom: e.sliceData.bottom * t.ph2UIManager.gameScale, left: e.sliceData.left * t.ph2UIManager.gameScale, right: e.sliceData.right * t.ph2UIManager.gameScale })).name = e.name, o.anchor.x = e.anchor.x, o.anchor.y = e.anchor.y, o.angle = e.angle, o.scale.x = e.scale.x, o.scale.y = e.scale.y, o.alpha = e.alpha, o.tint = e.tint, o.x = e.position.x * t.ph2UIManager.gameScale, o.y = e.position.y * t.ph2UIManager.gameScale, e.statesData && "color" === e.transitionMode && o.setTransitionColor(e.statesData.normal, e.statesData.pressed, e.statesData.hover)) : (o = new r.UIButton(t, i), e.statesData ? "image" === e.transitionMode && o.setFrames(e.statesData.hover, e.statesData.normal, e.statesData.pressed, e.statesData.normal) : o.setFrames(e.textureName, e.textureName, e.textureName, e.textureName), o.name = e.name, o.anchor.x = e.anchor.x, o.anchor.y = e.anchor.y, o.angle = e.angle, o.scale.x = e.scale.x, o.scale.y = e.scale.y, o.alpha = e.alpha, o.tint = e.tint, o.x = e.position.x * t.ph2UIManager.gameScale, o.y = e.position.y * t.ph2UIManager.gameScale), e.alignment && (o.enableAlignment(), o.alignment.setLandscapeAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), o.alignment.setPortraitAlignment(e.alignment.type, e.alignment.offset.x, e.alignment.isAbsoluteX, e.alignment.offset.y, e.alignment.isAbsoluteY), s instanceof r.UI ? o.alignment.setAlignTarget(r.AlignTargetType.WORLD) : o.alignment.setAlignTarget(r.AlignTargetType.PARENT)), e.portraitAlignment && (o.alignment || o.enableAlignment(), o.alignment.setPortraitAlignment(e.portraitAlignment.type, e.portraitAlignment.offset.x, e.portraitAlignment.isAbsoluteX, e.portraitAlignment.offset.y, e.portraitAlignment.isAbsoluteY)), e.landscapeAlignment && (o.alignment || o.enableAlignment(), o.alignment.setLandscapeAlignment(e.landscapeAlignment.type, e.landscapeAlignment.offset.x, e.landscapeAlignment.isAbsoluteX, e.landscapeAlignment.offset.y, e.landscapeAlignment.isAbsoluteY)), e.orientationProperties) { for (o.enableOrientationProperties(), n = 0; n < e.orientationProperties.backup.length; n++) "position" === (a = e.orientationProperties.backup[n]).key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.backupOriginalProperty(a.key, a.value); for (n = 0; n < e.orientationProperties.portrait.length; n++) "position" === (a = e.orientationProperties.portrait[n]).key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.addPortraitProperty(a.key, a.value); for (var n = 0; n < e.orientationProperties.landscape.length; n++) { var a = e.orientationProperties.landscape[n]; "position" === a.key && (a.value.x = a.value.x * t.ph2UIManager.gameScale, a.value.y = a.value.y * t.ph2UIManager.gameScale), o.orientationProperties.addLandscapePortrait(a.key, a.value) } } return o.enableVisibility(e.platformVisibility, e.orientationVisibility), o }, t
|
|
}();
|
|
r.UIFactory = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.designResolution = new Phaser.Rectangle(0, 0, e, i), s.safeZone = new Phaser.Rectangle(0, 0, e, i), t.ph2UIManager.events.gameSizeChanged.add(s.onGameSizeChanged, s), s }
|
|
return __extends(t, o), t.prototype.onGameSizeChanged = function() { this.windowSizeChanged() }, t.prototype.setSafeZone = function(t, e) { this.safeZone.width = t, this.safeZone.height = e }, t.prototype.setDesignResolution = function(t, e) { this.designResolution.width = t, this.designResolution.height = e }, t.prototype.getDesignResolution = function() { return this.designResolution }, t.prototype.getSafeZone = function() { return this.safeZone }, t.prototype.enableAlignment = function() {}, t.prototype.enableOrientationProperties = function() {}, t.prototype.windowSizeChanged = function() { for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t, e) { o.prototype.destroy.call(this, t, e), this.safeZone = null, this.designResolution = null }, t
|
|
}(Phaser.Group);
|
|
t.UI = e
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(s) {
|
|
function t(t, e) { var i = s.call(this, t, 0, 0, e) || this; return i.forceOut = !0, i }
|
|
return __extends(t, s), t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t) { s.prototype.destroy.call(this, t), this.alignment && (this.alignment.destroy(), this.alignment = null) }, t
|
|
}(Phaser.Button);
|
|
i.UIButton = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(s) {
|
|
var t = function(i) {
|
|
function t(t) { return i.call(this, t) || this }
|
|
return __extends(t, i), t.prototype.enableAlignment = function() { this.alignment = new s.UIAlignment(this.game) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new s.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new s.UIOrientationProperties(this.game, this) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t, e) { i.prototype.destroy.call(this, t, e), this.alignment && (this.alignment.destroy(), this.alignment = null) }, t
|
|
}(Phaser.Group);
|
|
s.UIGroup = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(l) {
|
|
function t(t, e, i, s, o, n, a, r) { var h = l.call(this, t, e, i, s, o, n, a, r) || this; return h.inputEnabled = !0, h.input.start(0, !0), h.input.useHandCursor = !0, h.events.onInputOver.add(h.onInputOverHandler, h), h.events.onInputOut.add(h.onInputOutHandler, h), h.events.onInputDown.add(h.onInputDownHandler, h), h.events.onInputUp.add(h.onInputUpHandler, h), h.justReleasedPreventsOver = Phaser.PointerMode.CURSOR, h.onOverMouseOnly = !0, h.onInputOver = new Phaser.Signal, h.onInputOut = new Phaser.Signal, h.onInputDown = new Phaser.Signal, h.onInputUp = new Phaser.Signal, h.freezeFrames = !1, h.forceOut = !0, h.hoverColor = "#FFFFFF", h.normalColor = "#FFFFFF", h.pressedColor = "#FFFFFF", h }
|
|
return __extends(t, l), t.prototype.onInputOverHandler = function(t, e) { e.justReleased() && (this.justReleasedPreventsOver & e.pointerMode) === e.pointerMode || this.onOverMouseOnly && !e.isMouse || this.onInputOver && this.onInputOver.dispatch(this, e) }, t.prototype.onInputOutHandler = function(t, e) { this.onInputOut && this.onInputOut.dispatch(this, e) }, t.prototype.onInputDownHandler = function(t, e) { this.onInputDown && this.onInputDown.dispatch(this, e) }, t.prototype.onInputUpHandler = function(t, e, i) { this.onInputUp && this.onInputUp.dispatch(this, e, i) }, t.prototype.setTransitionColor = function(t, e, i) { this.normalColor = t, this.pressedColor = e, this.hoverColor = i }, t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function() {
|
|
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
|
|
l.prototype.destroy.call(this, t), this.onInputOver.dispose(), this.onInputOut.dispose(), this.onInputDown.dispose(), this.onInputUp.dispose()
|
|
}, t
|
|
}(PhaserNineSlice.NineSlice);
|
|
i.UISlicedButton = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(h) {
|
|
function t(t, e, i, s, o, n, a, r) { return h.call(this, t, e, i, s, o, n, a, r) || this }
|
|
return __extends(t, h), t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function() {
|
|
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
|
|
h.prototype.destroy.call(this, t), this.alignment && (this.alignment.destroy(), this.alignment = null)
|
|
}, t
|
|
}(PhaserNineSlice.NineSlice);
|
|
i.UISlicedSprite = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(n) {
|
|
function t(t, e, i, s, o) { return n.call(this, t, e, i, s, o) || this }
|
|
return __extends(t, n), t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t) { n.prototype.destroy.call(this, t), this.alignment && (this.alignment.destroy(), this.alignment = null) }, t
|
|
}(Phaser.Sprite);
|
|
i.UISprite = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(n) {
|
|
function t(t, e, i, s, o) { return n.call(this, t, e, i, s, o) || this }
|
|
return __extends(t, n), t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) void 0 !== this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t) { n.prototype.destroy.call(this, t), this.alignment && (this.alignment.destroy(), this.alignment = null) }, t
|
|
}(Phaser.Text);
|
|
i.UIText = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t = function(r) {
|
|
function t(t, e, i, s, o, n, a) { return r.call(this, t, e, i, s, o, n, a) || this }
|
|
return __extends(t, r), t.prototype.enableAlignment = function() { this.alignment = new i.UIAlignment(this.game) }, t.prototype.enableOrientationProperties = function() { this.orientationProperties = new i.UIOrientationProperties(this.game, this) }, t.prototype.enableVisibility = function(t, e) { this.visibility = new i.UIVisibility(this.game), this.visibility.setPlatformVisible(t), this.visibility.setOrientationVisible(e) }, t.prototype.windowSizeChanged = function() { this.visibility && this.visibility.applyVisibility(this), this.orientationProperties && this.orientationProperties.apply(this), this.alignment && this.alignment.applyAlignment(this); for (var t = 0; t < this.children.length; t++) "function" == typeof this.children[t].windowSizeChanged && this.children[t].windowSizeChanged() }, t.prototype.destroy = function(t) { r.prototype.destroy.call(this, t), this.alignment && (this.alignment.destroy(), this.alignment = null) }, t
|
|
}(Phaser.TileSprite);
|
|
i.UITiledSprite = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e = function() {
|
|
function t(t) { this.animations = {}, this.game = t, this.game.onPause.add(this.onPause, this), this.game.onResume.add(this.onResume, this), this.game.ph2AnimationManager.pauseAllSignal.add(this.pauseAll, this), this.game.ph2AnimationManager.resumeAllSignal.add(this.resumeAll, this), this.game.ph2AnimationManager.stopAllSignal.add(this.stopAll, this) }
|
|
return t.prototype.play = function(t, e, i) { return this.animations[t] ? this.currentAnim ? this.currentAnim.name === t ? this.currentAnim.isPlaying() ? this.currentAnim : this.currentAnim.play(e, i) : (this.currentAnim.isPlaying() && this.currentAnim.stop(), this.currentAnim = this.animations[t], this.currentAnim.play(e, i)) : (this.currentAnim = this.animations[t], this.currentAnim.play(e, i)) : null }, t.prototype.stop = function(t, e, i) { this.currentAnim && (t ? this.currentAnim.name === t && this.currentAnim.stop(e, i) : this.currentAnim.stop(e, i)) }, t.prototype.pause = function(t) { this.currentAnim && (t ? this.currentAnim.name === t && this.currentAnim.pause() : this.currentAnim.pause()) }, t.prototype.resume = function(t) { this.currentAnim && (t ? this.currentAnim.name === t && this.currentAnim.resume() : this.currentAnim.resume()) }, t.prototype.add = function(t) { this.animations[t.name] = t }, t.prototype.onPause = function() { this.currentAnim && this.currentAnim.autoPause() }, t.prototype.onResume = function() { this.currentAnim && this.currentAnim.autoResume() }, t.prototype.getAnimations = function() { return this.animations }, t.prototype.getCurrentAnimation = function() { return this.currentAnim }, t.prototype.removeListeners = function(t) {
|
|
var e = this.animations[t];
|
|
e && e.removeListeners()
|
|
}, t.prototype.pauseAll = function() { this.currentAnim && this.currentAnim.batchPause() }, t.prototype.resumeAll = function() { this.currentAnim && this.currentAnim.batchResume() }, t.prototype.stopAll = function() { this.currentAnim && !this.currentAnim.isStopped() && this.currentAnim.stop() }, t.prototype.destroy = function() { this.currentAnim && this.currentAnim.stop(), this.game.onPause.remove(this.onPause, this), this.game.onResume.remove(this.onResume, this), this.game.ph2AnimationManager.pauseAllSignal.remove(this.pauseAll, this), this.game.ph2AnimationManager.resumeAllSignal.remove(this.resumeAll, this), this.game.ph2AnimationManager.stopAllSignal.remove(this.stopAll, this); for (var t = Object.keys(this.animations), e = 0; e < t.length; e++) this.animations[t[e]].destroy() }, t
|
|
}();
|
|
t.AnimationManager = e
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(t) {
|
|
var e = function() {
|
|
function t(t) { this.game = t, this.alignBounds = new Phaser.Rectangle(0, 0, this.game.width, this.game.height) }
|
|
return t.prototype.changeOrientation = function(t) { this.currentOrientation = t }, t.prototype.getCurrentOrientation = function() { return this.currentOrientation }, t.alignInParent = function(t, e, i, s) {
|
|
if ("__world" !== t.parent.name) {
|
|
var o = t.parent.scale;
|
|
t.parent.scale.setTo(1), t.alignIn(t.parent, e, i, s), t.left -= t.parent.left + t.parent.width * t.parent.anchor.x, t.top -= t.parent.top + t.parent.height * t.parent.anchor.y, t.parent.scale = o
|
|
}
|
|
}, t
|
|
}();
|
|
t.AlignmentSystem = e
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(i) {
|
|
var t;
|
|
(t = i.Orientation || (i.Orientation = {}))[t.LANDSCAPE = 0] = "LANDSCAPE", t[t.PORTRAIT = 1] = "PORTRAIT";
|
|
var e = function() {
|
|
function t(t) { this.game = t, this.gameSizeChanged = new Phaser.Signal, this.orientationChanged = new Phaser.Signal }
|
|
return t.prototype.onGameResize = function(t, e) { this.game.ph2UIManager.alignmentManager.alignBounds.width = t, (this.game.ph2UIManager.alignmentManager.alignBounds.height = e) < t ? this.game.ph2UIManager.alignmentManager.changeOrientation(i.Orientation.LANDSCAPE) : this.game.ph2UIManager.alignmentManager.changeOrientation(i.Orientation.PORTRAIT), this.gameSizeChanged.dispatch(t, e) }, t
|
|
}();
|
|
i.UIEventManager = e
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(e) {
|
|
var t = function(s) {
|
|
function t(t, e) { var i = s.call(this, t, e) || this; return TweenLite.defaultEase = Linear.easeNone, i.addAnimationManager(), i.addAnimationFactory(), i }
|
|
return __extends(t, s), t.prototype.addAnimationManager = function() { Phaser.Game.prototype.ph2AnimationManager = new e.AnimationSystem(this.game), Phaser.Game.prototype.ph2UIManager = new e.UISystem(this.game) }, t.prototype.addAnimationFactory = function() { Phaser.GameObjectFactory.prototype.ph2AnimationObject = function(t, e, i, s, o) { void 0 === o && (o = this.world); var n = this.game.ph2AnimationManager.getAnimationObject(i, s); return n.x = t, n.y = e, o.add(n), n }, Phaser.GameObjectCreator.prototype.ph2AnimationObject = function(t, e, i, s) { var o = this.game.ph2AnimationManager.getAnimationObject(i, s); return o.x = t, o.y = e, o }, Phaser.GameObjectFactory.prototype.ph2UI = function(t, e, i) { void 0 === i && (i = this.world); var s = this.game.ph2UIManager.getUI(t, e); return i.add(s), s }, Phaser.GameObjectCreator.prototype.ph2UI = function(t, e) { return this.game.ph2UIManager.getUI(t, e) } }, t
|
|
}(Phaser.Plugin);
|
|
e.AnimationPlugin = t
|
|
}(Ph2 || (Ph2 = {})),
|
|
function(c) {
|
|
var t = function() {
|
|
function t(t) { this.game = t, this.events = new c.UIEventManager(this.game), this.alignmentManager = new c.AlignmentSystem(this.game), this.scale = 1, this.enableVisibilityAndOrientationComponent = !0 }
|
|
return t.prototype.setCurrentPlatform = function(t) { this.currentPlatform = t }, t.prototype.setGameScale = function(t) { this.scale = t }, Object.defineProperty(t.prototype, "gameScale", { get: function() { return this.scale }, enumerable: !0, configurable: !0 }), t.prototype.createCacheUINode = function(t, e, i, s, o) {
|
|
var n = t.name,
|
|
a = n;
|
|
o && (a = o + "/" + n);
|
|
var r = null,
|
|
h = e[a];
|
|
if (null === s) r = c.CacheFactory.UICanvas(n, h);
|
|
else { var l = h.type; "sprite" === l ? r = c.CacheFactory.UISprite(n, h) : "container" === l ? r = c.CacheFactory.UIGroup(n, h) : "button" === l ? r = c.CacheFactory.UIButton(n, h) : "text" === l && (r = c.CacheFactory.UIText(n, h)) }
|
|
return r
|
|
}, t.prototype.createCacheUIDataTree = function(t, e, i, s) {
|
|
var o = null;
|
|
if (t) {
|
|
var n = t.name;
|
|
if (o = this.createCacheUINode(t, e, t.animations, i, s), t.children) {
|
|
s = null !== s ? 0 === s.length ? n : s + "/" + n : "";
|
|
for (var a = t.children, r = 0; r < a.length; r++) {
|
|
var h = this.createCacheUIDataTree(a[r], e, o, s);
|
|
h && o.addChild(h)
|
|
}
|
|
}
|
|
}
|
|
return o
|
|
}, t.prototype.generateUIData = function(t) {
|
|
var e = t.hierarchy,
|
|
i = t.properties,
|
|
s = this.createCacheUIDataTree(e, i, null, null);
|
|
return new c.UIData(s)
|
|
}, t.prototype.getUIDataFromJSON = function(t) { var e = this.game.cache.getJSON(t); return e ? this.generateUIData(e) : null }, t.prototype.getUIData = function(t) { return this.getUIDataFromJSON(t) }, t.prototype.getUI = function(t, e) {
|
|
var i = this.getUIData(t),
|
|
s = this.createTree(i.hierarchy, e, null);
|
|
return s.windowSizeChanged(), s
|
|
}, t.prototype.createTree = function(t, e, i) {
|
|
var s = null;
|
|
if (t && (s = this.createNode(t, e, i), t.children))
|
|
for (var o = t.children, n = 0; n < o.length; n++) {
|
|
var a = this.createTree(o[n], e, s);
|
|
a && s.addChild(a)
|
|
}
|
|
return s
|
|
}, t.prototype.createNode = function(t, e, i) { var s = null; return null === i ? s = c.UIFactory.UICanvas(this.game, t) : t instanceof c.CacheUISprite ? s = c.UIFactory.UISprite(this.game, t, e, i) : t instanceof c.CacheUIGroup ? s = c.UIFactory.UIGroup(this.game, t, i) : t instanceof c.CacheUIButton ? s = c.UIFactory.UIButton(this.game, t, e, i) : t instanceof c.CacheUIText && (s = c.UIFactory.UIText(this.game, t, i)), s }, t.findObject = function(t, e) {
|
|
for (var i = e, s = "/" !== t[0] ? 0 : 1, o = t.split("/"), n = s; n < o.length; n++) {
|
|
var a = o[n],
|
|
r = i.children;
|
|
i = null;
|
|
for (var h = 0, l = r.length; h < l; ++h) { var c = r[h]; if (c.name === a) { i = c; break } }
|
|
if (!i) return null
|
|
}
|
|
return i
|
|
}, t
|
|
}();
|
|
c.UISystem = t
|
|
}(Ph2 || (Ph2 = {})), "function" == typeof define && define.amd ? define(x) : "object" == typeof exports ? module.exports = x() : this.SAT = x(),
|
|
function() {
|
|
function s(t, e, i) { return t.call.apply(t.bind, arguments) }
|
|
|
|
function o(e, i, t) { if (!e) throw Error(); if (2 < arguments.length) { var s = Array.prototype.slice.call(arguments, 2); return function() { var t = Array.prototype.slice.call(arguments); return Array.prototype.unshift.apply(t, s), e.apply(i, t) } } return function() { return e.apply(i, arguments) } }
|
|
|
|
function y(t, e, i) { return (y = Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? s : o).apply(null, arguments) }
|
|
var r = Date.now || function() { return +new Date };
|
|
|
|
function e(t, e) { this.a = t, this.o = e || t, this.c = this.o.document }
|
|
var h = !!window.FontFace;
|
|
|
|
function l(t, e, i, s) {
|
|
if (e = t.c.createElement(e), i)
|
|
for (var o in i) i.hasOwnProperty(o) && ("style" == o ? e.style.cssText = i[o] : e.setAttribute(o, i[o]));
|
|
return s && e.appendChild(t.c.createTextNode(s)), e
|
|
}
|
|
|
|
function c(t, e, i) {
|
|
(t = t.c.getElementsByTagName(e)[0]) || (t = document.documentElement), t.insertBefore(i, t.lastChild)
|
|
}
|
|
|
|
function i(t) { t.parentNode && t.parentNode.removeChild(t) }
|
|
|
|
function g(t, e, i) {
|
|
e = e || [], i = i || [];
|
|
for (var s = t.className.split(/\s+/), o = 0; o < e.length; o += 1) {
|
|
for (var n = !1, a = 0; a < s.length; a += 1)
|
|
if (e[o] === s[a]) { n = !0; break }
|
|
n || s.push(e[o])
|
|
}
|
|
for (e = [], o = 0; o < s.length; o += 1) {
|
|
for (n = !1, a = 0; a < i.length; a += 1)
|
|
if (s[o] === i[a]) { n = !0; break }
|
|
n || e.push(s[o])
|
|
}
|
|
t.className = e.join(" ").replace(/\s+/g, " ").replace(/^\s+|\s+$/, "")
|
|
}
|
|
|
|
function n(t, e) {
|
|
for (var i = t.className.split(/\s+/), s = 0, o = i.length; s < o; s++)
|
|
if (i[s] == e) return !0;
|
|
return !1
|
|
}
|
|
|
|
function p(t, e, i) {
|
|
function s() { a && o && (a(n), a = null) } e = l(t, "link", { rel: "stylesheet", href: e, media: "all" });
|
|
var o = !1,
|
|
n = null,
|
|
a = i || null;
|
|
h ? (e.onload = function() { o = !0, s() }, e.onerror = function() { o = !0, n = Error("Stylesheet failed to load"), s() }) : setTimeout(function() { o = !0, s() }, 0), c(t, "head", e)
|
|
}
|
|
|
|
function u(t, e, i, s) {
|
|
var o = t.c.getElementsByTagName("head")[0];
|
|
if (o) {
|
|
var n = l(t, "script", { src: e }),
|
|
a = !1;
|
|
return n.onload = n.onreadystatechange = function() { a || this.readyState && "loaded" != this.readyState && "complete" != this.readyState || (a = !0, i && i(null), n.onload = n.onreadystatechange = null, "HEAD" == n.parentNode.tagName && o.removeChild(n)) }, o.appendChild(n), setTimeout(function() { a || (a = !0, i && i(Error("Script load timeout"))) }, s || 5e3), n
|
|
}
|
|
return null
|
|
}
|
|
|
|
function d() { this.a = 0, this.c = null }
|
|
|
|
function f(t) {
|
|
return t.a++,
|
|
function() { t.a--, a(t) }
|
|
}
|
|
|
|
function m(t, e) { t.c = e, a(t) }
|
|
|
|
function a(t) { 0 == t.a && t.c && (t.c(), t.c = null) }
|
|
|
|
function v(t) { this.a = t || "-" }
|
|
|
|
function x(t, e) {
|
|
this.c = t, this.f = 4, this.a = "n";
|
|
var i = (e || "n4").match(/^([nio])([1-9])$/i);
|
|
i && (this.a = i[1], this.f = parseInt(i[2], 10))
|
|
}
|
|
|
|
function b(t) {
|
|
var e = [];
|
|
t = t.split(/,\s*/);
|
|
for (var i = 0; i < t.length; i++) { var s = t[i].replace(/['"]/g, ""); - 1 != s.indexOf(" ") || /^\d/.test(s) ? e.push("'" + s + "'") : e.push(s) }
|
|
return e.join(",")
|
|
}
|
|
|
|
function w(t) { return t.a + t.f }
|
|
|
|
function P(t) { var e = "normal"; return "o" === t.a ? e = "oblique" : "i" === t.a && (e = "italic"), e }
|
|
|
|
function _(t, e) { this.c = t, this.f = t.o.document.documentElement, this.h = e, this.a = new v("-"), this.j = !1 !== e.events, this.g = !1 !== e.classes }
|
|
|
|
function T(t) {
|
|
if (t.g) {
|
|
var e = n(t.f, t.a.c("wf", "active")),
|
|
i = [],
|
|
s = [t.a.c("wf", "loading")];
|
|
e || i.push(t.a.c("wf", "inactive")), g(t.f, i, s)
|
|
}
|
|
S(t, "inactive")
|
|
}
|
|
|
|
function S(t, e, i) { t.j && t.h[e] && (i ? t.h[e](i.c, w(i)) : t.h[e]()) }
|
|
|
|
function k() { this.c = {} }
|
|
|
|
function B(t, e) { this.c = t, this.f = e, this.a = l(this.c, "span", { "aria-hidden": "true" }, this.f) }
|
|
|
|
function A(t) { c(t.c, "body", t.a) }
|
|
|
|
function C(t) { return "display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:" + b(t.c) + ";font-style:" + P(t) + ";font-weight:" + t.f + "00;" }
|
|
|
|
function I(t, e, i, s, o, n) { this.g = t, this.j = e, this.a = s, this.c = i, this.f = o || 3e3, this.h = n || void 0 }
|
|
|
|
function E(t, e, i, s, o, n, a) { this.v = t, this.B = e, this.c = i, this.a = s, this.s = a || "BESbswy", this.f = {}, this.w = o || 3e3, this.u = n || null, this.m = this.j = this.h = this.g = null, this.g = new B(this.c, this.s), this.h = new B(this.c, this.s), this.j = new B(this.c, this.s), this.m = new B(this.c, this.s), t = C(t = new x(this.a.c + ",serif", w(this.a))), this.g.a.style.cssText = t, t = C(t = new x(this.a.c + ",sans-serif", w(this.a))), this.h.a.style.cssText = t, t = C(t = new x("serif", w(this.a))), this.j.a.style.cssText = t, t = C(t = new x("sans-serif", w(this.a))), this.m.a.style.cssText = t, A(this.g), A(this.h), A(this.j), A(this.m) } v.prototype.c = function(t) { for (var e = [], i = 0; i < arguments.length; i++) e.push(arguments[i].replace(/[\W_]+/g, "").toLowerCase()); return e.join(this.a) }, I.prototype.start = function() {
|
|
var o = this.c.o.document,
|
|
n = this,
|
|
a = r(),
|
|
t = new Promise(function(i, s) {
|
|
! function e() {
|
|
var t;
|
|
r() - a >= n.f ? s() : o.fonts.load((t = n.a, P(t) + " " + t.f + "00 300px " + b(t.c)), n.h).then(function(t) { 1 <= t.length ? i() : setTimeout(e, 25) }, function() { s() })
|
|
}()
|
|
}),
|
|
i = null,
|
|
e = new Promise(function(t, e) { i = setTimeout(e, n.f) });
|
|
Promise.race([e, t]).then(function() { i && (clearTimeout(i), i = null), n.g(n.a) }, function() { n.j(n.a) })
|
|
};
|
|
var O = { D: "serif", C: "sans-serif" },
|
|
M = null;
|
|
|
|
function L() {
|
|
if (null === M) {
|
|
var t = /AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);
|
|
M = !!t && (parseInt(t[1], 10) < 536 || 536 === parseInt(t[1], 10) && parseInt(t[2], 10) <= 11)
|
|
}
|
|
return M
|
|
}
|
|
|
|
function R(t, e, i) {
|
|
for (var s in O)
|
|
if (O.hasOwnProperty(s) && e === t.f[O[s]] && i === t.f[O[s]]) return !0;
|
|
return !1
|
|
}
|
|
|
|
function D(t) {
|
|
var e, i = t.g.a.offsetWidth,
|
|
s = t.h.a.offsetWidth;
|
|
(e = i === t.f.serif && s === t.f["sans-serif"]) || (e = L() && R(t, i, s)), e ? r() - t.A >= t.w ? L() && R(t, i, s) && (null === t.u || t.u.hasOwnProperty(t.a.c)) ? F(t, t.v) : F(t, t.B) : setTimeout(y(function() { D(this) }, t), 50) : F(t, t.v)
|
|
}
|
|
|
|
function F(t, e) { setTimeout(y(function() { i(this.g.a), i(this.h.a), i(this.j.a), i(this.m.a), e(this.a) }, t), 0) }
|
|
|
|
function U(t, e, i) { this.c = t, this.a = e, this.f = 0, this.m = this.j = !1, this.s = i } E.prototype.start = function() { this.f.serif = this.j.a.offsetWidth, this.f["sans-serif"] = this.m.a.offsetWidth, this.A = r(), D(this) };
|
|
var G = null;
|
|
|
|
function N(t) { 0 == --t.f && t.j && (t.m ? ((t = t.a).g && g(t.f, [t.a.c("wf", "active")], [t.a.c("wf", "loading"), t.a.c("wf", "inactive")]), S(t, "active")) : T(t.a)) }
|
|
|
|
function t(t) { this.j = t, this.a = new k, this.h = 0, this.f = this.g = !0 }
|
|
|
|
function V(t, e) { this.c = t, this.a = e }
|
|
|
|
function H(t, e) { this.c = t, this.a = e }
|
|
|
|
function z(t, e) { this.c = t || "https://fonts.googleapis.com/css", this.a = [], this.f = [], this.g = e || "" } U.prototype.g = function(t) {
|
|
var e = this.a;
|
|
e.g && g(e.f, [e.a.c("wf", t.c, w(t).toString(), "active")], [e.a.c("wf", t.c, w(t).toString(), "loading"), e.a.c("wf", t.c, w(t).toString(), "inactive")]), S(e, "fontactive", t), this.m = !0, N(this)
|
|
}, U.prototype.h = function(t) {
|
|
var e = this.a;
|
|
if (e.g) {
|
|
var i = n(e.f, e.a.c("wf", t.c, w(t).toString(), "active")),
|
|
s = [],
|
|
o = [e.a.c("wf", t.c, w(t).toString(), "loading")];
|
|
i || s.push(e.a.c("wf", t.c, w(t).toString(), "inactive")), g(e.f, s, o)
|
|
}
|
|
S(e, "fontinactive", t), N(this)
|
|
}, t.prototype.load = function(t) {
|
|
this.c = new e(this.j, t.context || this.j), this.g = !1 !== t.events, this.f = !1 !== t.classes,
|
|
function(o, t, e) {
|
|
var i = [],
|
|
s = e.timeout;
|
|
n = t, n.g && g(n.f, [n.a.c("wf", "loading")]), S(n, "loading");
|
|
var n;
|
|
var i = function(t, e, i) {
|
|
var s, o = [];
|
|
for (s in e)
|
|
if (e.hasOwnProperty(s)) {
|
|
var n = t.c[s];
|
|
n && o.push(n(e[s], i))
|
|
}
|
|
return o
|
|
}(o.a, e, o.c),
|
|
a = new U(o.c, t, s);
|
|
for (o.h = i.length, t = 0, e = i.length; t < e; t++) i[t].load(function(t, e, i) {
|
|
var s, l, c, p, u, d;
|
|
l = a, c = t, p = e, u = i, d = 0 == --(s = o).h, (s.f || s.g) && setTimeout(function() {
|
|
var t = u || null,
|
|
e = p || {};
|
|
if (0 === c.length && d) T(l.a);
|
|
else {
|
|
l.f += c.length, d && (l.j = d);
|
|
var i, s = [];
|
|
for (i = 0; i < c.length; i++) {
|
|
var o = c[i],
|
|
n = e[o.c],
|
|
a = l.a,
|
|
r = o;
|
|
if (a.g && g(a.f, [a.a.c("wf", r.c, w(r).toString(), "loading")]), S(a, "fontloading", r), (a = null) === G)
|
|
if (window.FontFace) {
|
|
var r = /Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),
|
|
h = /OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) && /Apple/.exec(window.navigator.vendor);
|
|
G = r ? 42 < parseInt(r[1], 10) : !h
|
|
}
|
|
else G = !1;
|
|
a = G ? new I(y(l.g, l), y(l.h, l), l.c, o, l.s, n) : new E(y(l.g, l), y(l.h, l), l.c, o, l.s, t, n), s.push(a)
|
|
}
|
|
for (i = 0; i < s.length; i++) s[i].start()
|
|
}
|
|
}, 0)
|
|
})
|
|
}(this, new _(this.c, t), t)
|
|
}, V.prototype.load = function(a) {
|
|
var e = this,
|
|
r = e.a.projectId,
|
|
t = e.a.version;
|
|
if (r) {
|
|
var h = e.c.o;
|
|
u(this.c, (e.a.api || "https://fast.fonts.net/jsapi") + "/" + r + ".js" + (t ? "?v=" + t : ""), function(t) {
|
|
t ? a([]) : (h["__MonotypeConfiguration__" + r] = function() { return e.a }, function t() {
|
|
if (h["__mti_fntLst" + r]) {
|
|
var e, i = h["__mti_fntLst" + r](),
|
|
s = [];
|
|
if (i)
|
|
for (var o = 0; o < i.length; o++) {
|
|
var n = i[o].fontfamily;
|
|
null != i[o].fontStyle && null != i[o].fontWeight ? (e = i[o].fontStyle + i[o].fontWeight, s.push(new x(n, e))) : s.push(new x(n))
|
|
}
|
|
a(s)
|
|
}
|
|
else setTimeout(function() { t() }, 50)
|
|
}())
|
|
}).id = "__MonotypeAPIScript__" + r
|
|
}
|
|
else a([])
|
|
}, H.prototype.load = function(t) {
|
|
var e, i, s = this.a.urls || [],
|
|
o = this.a.families || [],
|
|
n = this.a.testStrings || {},
|
|
a = new d;
|
|
for (e = 0, i = s.length; e < i; e++) p(this.c, s[e], f(a));
|
|
var r = [];
|
|
for (e = 0, i = o.length; e < i; e++)
|
|
if ((s = o[e].split(":"))[1])
|
|
for (var h = s[1].split(","), l = 0; l < h.length; l += 1) r.push(new x(s[0], h[l]));
|
|
else r.push(new x(s[0]));
|
|
m(a, function() { t(r, n) })
|
|
};
|
|
|
|
function X(t) { this.f = t, this.a = [], this.c = {} }
|
|
var j = { latin: "BESbswy", "latin-ext": "çöüğş", cyrillic: "йяЖ", greek: "αβΣ", khmer: "កខគ", Hanuman: "កខគ" },
|
|
W = { thin: "1", extralight: "2", "extra-light": "2", ultralight: "2", "ultra-light": "2", light: "3", regular: "4", book: "4", medium: "5", "semi-bold": "6", semibold: "6", "demi-bold": "6", demibold: "6", bold: "7", "extra-bold": "8", extrabold: "8", "ultra-bold": "8", ultrabold: "8", black: "9", heavy: "9", l: "3", r: "4", b: "7" },
|
|
q = { i: "i", italic: "i", n: "n", normal: "n" },
|
|
Y = /^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;
|
|
|
|
function K(t, e) { this.c = t, this.a = e }
|
|
var Q = { Arimo: !0, Cousine: !0, Tinos: !0 };
|
|
|
|
function J(t, e) { this.c = t, this.a = e }
|
|
|
|
function Z(t, e) { this.c = t, this.f = e, this.a = [] } K.prototype.load = function(t) {
|
|
var e = new d,
|
|
i = this.c,
|
|
s = new z(this.a.api, this.a.text),
|
|
o = this.a.families;
|
|
! function(t, e) {
|
|
for (var i = e.length, s = 0; s < i; s++) {
|
|
var o = e[s].split(":");
|
|
3 == o.length && t.f.push(o.pop());
|
|
var n = "";
|
|
2 == o.length && "" != o[1] && (n = ":"), t.a.push(o.join(n))
|
|
}
|
|
}(s, o);
|
|
var n = new X(o);
|
|
! function(t) {
|
|
for (var e = t.f.length, i = 0; i < e; i++) {
|
|
var s = t.f[i].split(":"),
|
|
o = s[0].replace(/\+/g, " "),
|
|
n = ["n4"];
|
|
if (2 <= s.length) {
|
|
var a;
|
|
if (a = [], r = s[1])
|
|
for (var r, h = (r = r.split(",")).length, l = 0; l < h; l++) {
|
|
var c;
|
|
if ((c = r[l]).match(/^[\w-]+$/))
|
|
if (null == (u = Y.exec(c.toLowerCase()))) c = "";
|
|
else {
|
|
if (c = null == (c = u[2]) || "" == c ? "n" : q[c], null == (u = u[1]) || "" == u) u = "4";
|
|
else var p = W[u],
|
|
u = p || (isNaN(u) ? "4" : u.substr(0, 1));
|
|
c = [c, u].join("")
|
|
}
|
|
else c = "";
|
|
c && a.push(c)
|
|
}
|
|
0 < a.length && (n = a), 3 == s.length && (a = [], 0 < (s = (s = s[2]) ? s.split(",") : a).length && (s = j[s[0]]) && (t.c[o] = s))
|
|
}
|
|
for (t.c[o] || (s = j[o]) && (t.c[o] = s), s = 0; s < n.length; s += 1) t.a.push(new x(o, n[s]))
|
|
}
|
|
}(n), p(i, function(t) { if (0 == t.a.length) throw Error("No fonts to load!"); if (-1 != t.c.indexOf("kit=")) return t.c; for (var e = t.a.length, i = [], s = 0; s < e; s++) i.push(t.a[s].replace(/ /g, "+")); return e = t.c + "?family=" + i.join("%7C"), 0 < t.f.length && (e += "&subset=" + t.f.join(",")), 0 < t.g.length && (e += "&text=" + encodeURIComponent(t.g)), e }(s), f(e)), m(e, function() { t(n.a, n.c, Q) })
|
|
}, J.prototype.load = function(a) {
|
|
var t = this.a.id,
|
|
r = this.c.o;
|
|
t ? u(this.c, (this.a.api || "https://use.typekit.net") + "/" + t + ".js", function(t) {
|
|
if (t) a([]);
|
|
else if (r.Typekit && r.Typekit.config && r.Typekit.config.fn) {
|
|
t = r.Typekit.config.fn;
|
|
for (var e = [], i = 0; i < t.length; i += 2)
|
|
for (var s = t[i], o = t[i + 1], n = 0; n < o.length; n++) e.push(new x(s, o[n]));
|
|
try { r.Typekit.load({ events: !1, classes: !1, async: !0 }) }
|
|
catch (t) {} a(e)
|
|
}
|
|
}, 2e3) : a([])
|
|
}, Z.prototype.load = function(l) {
|
|
var t, e = this.f.id,
|
|
i = this.c.o,
|
|
c = this;
|
|
e ? (i.__webfontfontdeckmodule__ || (i.__webfontfontdeckmodule__ = {}), i.__webfontfontdeckmodule__[e] = function(t, e) {
|
|
for (var i = 0, s = e.fonts.length; i < s; ++i) {
|
|
var o = e.fonts[i];
|
|
c.a.push(new x(o.name, (n = "font-weight:" + o.weight + ";font-style:" + o.style, h = r = a = void 0, a = 4, r = "n", h = null, n && ((h = n.match(/(normal|oblique|italic)/i)) && h[1] && (r = h[1].substr(0, 1).toLowerCase()), (h = n.match(/([1-9]00|normal|bold)/i)) && h[1] && (/bold/i.test(h[1]) ? a = 7 : /[1-9]00/.test(h[1]) && (a = parseInt(h[1].substr(0, 1), 10)))), r + a)))
|
|
}
|
|
var n, a, r, h;
|
|
l(c.a)
|
|
}, u(this.c, (this.f.api || "https://f.fontdeck.com/s/css/js/") + ((t = this.c).o.location.hostname || t.a.location.hostname) + "/" + e + ".js", function(t) { t && l([]) })) : l([])
|
|
};
|
|
var $ = new t(window);
|
|
$.a.c.custom = function(t, e) { return new H(e, t) }, $.a.c.fontdeck = function(t, e) { return new Z(e, t) }, $.a.c.monotype = function(t, e) { return new V(e, t) }, $.a.c.typekit = function(t, e) { return new J(e, t) }, $.a.c.google = function(t, e) { return new K(e, t) };
|
|
var tt = { load: y($.load, $) };
|
|
"function" == typeof define && define.amd ? define(function() { return tt }) : "undefined" != typeof module && module.exports ? module.exports = tt : (window.WebFont = tt, window.WebFontConfig && $.load(window.WebFontConfig))
|
|
}();
|
|
__extends = this && this.__extends || function() {
|
|
var s = function(t, e) { return (s = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, e) { t.__proto__ = e } || function(t, e) { for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]) })(t, e) };
|
|
return function(t, e) {
|
|
function i() { this.constructor = t } s(t, e), t.prototype = null === e ? Object.create(e) : (i.prototype = e.prototype, new i)
|
|
}
|
|
}();
|
|
var ActState, Entity = function() {
|
|
function t(t) { this.main = t }
|
|
return t.prototype.destroy = function() { this.main = null }, t.prototype.reset = function() {}, t.prototype.resetLevel = function() { this.xPos = this.startX, this.yPos = this.startY }, t
|
|
}(),
|
|
Particle = function(h) {
|
|
function t(t, e, i, s, o, n, a) { var r = h.call(this, t) || this; return r.fadeAfter = 150, r.size = s, r.hitBox = new SAT.Box(new SAT.Vector(0, 0), s, s), r.collide = o, r.alive = !1, r.fadeAfter = a, r.liquid = n, r }
|
|
return __extends(t, h), t.prototype.spawnBase = function(t, e, i, s) { this.xPos = t, this.yPos = e, this.xVelocity = i, this.yVelocity = s, this.hitBox.pos.x = t - .5 * this.size, this.hitBox.pos.y = e - .5 * this.size, this.hitBoxPolygon = this.hitBox.toPolygon(), this.fadeTime = 0, this.alive = !0, this.water = !1, this.onIce = !1 }, t.prototype.destroy = function(t) { void 0 === t && (t = !1), this.hitBoxPolygon = null, this.hitBox = null, t ? this.main.particleUINum-- : this.main.particleNum--, this.alive = !1 }, t.prototype.multAlpha = function(t) {}, t.prototype.update = function() { this.alive && (this.getWater(), this.water ? (this.xPos += .1 * this.xVelocity * this.main.gameSpeed, this.yPos += .5 * this.yVelocity * this.main.gameSpeed, this.liquid && (this.yPos += .5 * this.yVelocity * this.main.gameSpeed, -1 < this.yVelocity && (this.yVelocity -= .05 * this.main.gameSpeed))) : (this.xPos += this.xVelocity * this.main.gameSpeed, this.yPos += this.yVelocity * this.main.gameSpeed), this.collide && this.yVelocity < 12 && (this.water ? this.liquid || (this.yVelocity += .25 * this.main.gravity * this.main.gameSpeed) : this.yVelocity += this.main.gravity * this.main.gameSpeed), 1 <= this.main.gameSpeed && (this.water || this.onIce ? this.xVelocity *= .99 : this.xVelocity *= .95), Math.abs(this.xVelocity) < .1 && (this.xVelocity = 0), this.collide && this.runCollisions()) }, t.prototype.runCollisions = function() {
|
|
for (var t = 0; t < this.main.blocks.length; t++) {
|
|
var e = this.main.blocks[t];
|
|
if (e.alive)
|
|
if (SAT.testPolygonPolygon(this.hitBoxPolygon, e.topBoundPolygon)) {
|
|
if (4 <= this.yVelocity ? this.yVelocity *= -.25 : 1 <= this.yVelocity && (this.yVelocity = 0), this.yPos = e.topEdge - .5 * this.size, this.xPos += e.xVelocity, "speed" === e.blockType) {
|
|
var i = e;
|
|
this.xVelocity += i.speedInc
|
|
}
|
|
"ice" === e.blockType && (this.onIce = !0)
|
|
}
|
|
else if (SAT.testPolygonPolygon(this.hitBoxPolygon, e.bottomBoundPolygon) && this.yVelocity < 0) this.yVelocity *= -.5, this.yPos = e.bottomEdge, 0 < this.xVelocity ? this.xVelocity -= .1 : this.xVelocity < 0 && (this.xVelocity += .1), this.yPos += this.yVelocity;
|
|
else if (SAT.testPolygonPolygon(this.hitBoxPolygon, e.leftBoundPolygon)) this.xVelocity *= -.5, this.xPos = e.leftEdge - .5 * this.size, this.xPos += this.xVelocity;
|
|
else if (SAT.testPolygonPolygon(this.hitBoxPolygon, e.rightBoundPolygon)) this.xVelocity *= -.5, this.xPos = e.rightEdge + .5 * this.size, this.xPos += this.xVelocity;
|
|
else {
|
|
for (var s = 0, o = this.main.pools; s < o.length; s++) {
|
|
var n = o[s];
|
|
if (SAT.testPolygonPolygon(this.hitBoxPolygon, n.totalPolygon)) {
|
|
if (this.liquid && !this.water) return void this.destroy(this.isUI);
|
|
this.water || (this.yVelocity = 0), this.water = !0
|
|
}
|
|
}
|
|
if (this.liquid && !this.water) return void this.destroy(this.isUI)
|
|
}
|
|
}
|
|
}, t.prototype.getWater = function() { this.water = !1; for (var t = 0, e = this.main.pools; t < e.length; t++) { var i = e[t]; if (SAT.testPolygonPolygon(this.hitBoxPolygon, i.totalPolygon)) { this.water = !0; break } } }, t
|
|
}(Entity),
|
|
Sounds = function() {
|
|
function t(t, e) {
|
|
var i;
|
|
this.main = t, this.nextMusicNormalIndex = 0, this.nextMusicHardIndex = 0, this.muted = !1, this.connectHang = e.add.audio("connectHang"), this.fall = e.add.audio("fall", .2), this.downgrade = e.add.audio("downgrade", .7), this.poleSwing = e.add.audio("poleSwing", .7), this.splash1 = e.add.audio("splash1", .7), this.ziplineFull = e.add.audio("ziplineFull", .7), this.cannonEnter = e.add.audio("cannonEnter", .7), this.wallSlide = e.add.audio("wallSlide", .7), this.connectSlide = e.add.audio("connect", .7), this.land = e.add.audio("land", .5), this.slide = e.add.audio("slide", .7), this.death1 = e.add.audio("death1", .7), this.death2 = e.add.audio("death2", .7), this.electricity = e.add.audio("electricity", .5), this.poleWoosh = e.add.audio("poleWoosh", .7), this.bounce1 = e.add.audio("bounce1", .7), this.cannonFire = e.add.audio("cannonFire", .7), this.glassSmash = e.add.audio("glassSmash", .7), this.fallingBlock = e.add.audio("fallingBlock", .7), this.blockDestroy = e.add.audio("blockDestroy", .7), this.buttonClick = e.add.audio("buttonClick", .7), this.achievementUnlocked = e.add.audio("achievementUnlocked", .7), this.footstep = e.add.audio("footstep", .7), this.laserFire = e.add.audio("laserFire", .7), this.ding = e.add.audio("ding", .7), this.kickBlock = e.add.audio("kickBlock", .7), this.starPickup = e.add.audio("starPickup", .7), this.menuSong = e.add.audio("vexSong1", .7, !0), this.vexationSong = e.add.audio("vexSong2", .7, !0), this.challengeSong = e.add.audio("vexSong12", .7, !0), this.songs = [], this.vexSongNormal = [], this.vexSongHard = [], i = e.add.audio("vexSong3", .7, !0), this.vexSongNormal.push(i), this.songs.push(i), i = e.add.audio("vexSong4", .7, !0), this.vexSongNormal.push(i), this.songs.push(i), i = e.add.audio("vexSong5", .7, !0), this.vexSongNormal.push(i), this.songs.push(i), i = e.add.audio("vexSong6", .7, !0), this.vexSongNormal.push(i), this.songs.push(i), i = e.add.audio("vexSong7", .7, !0), this.vexSongNormal.push(i), this.songs.push(i), i = e.add.audio("vexSong8", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong9", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong10", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong11", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong12", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong13", .7, !0), this.vexSongHard.push(i), this.songs.push(i), i = e.add.audio("vexSong14", .7, !0), this.vexSongHard.push(i), this.songs.push(i)
|
|
}
|
|
return t.prototype.playSound = function(t) { Constants.muted || this[t].play(null, null, .6 * this.main.options.effectVolume) }, t.prototype.playRandomMusic = function() {
|
|
for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.menuSong.stop();
|
|
var i = Math.floor(Math.random() * this.songs.length),
|
|
s = this.songs[i];
|
|
s.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = s
|
|
}, t.prototype.playMenuSong = function() { if (this.currentMusic !== this.menuSong) { for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.vexationSong.stop(), this.challengeSong.stop(), this.menuSong.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = this.menuSong } }, t.prototype.playChallengeSong = function() { if (this.currentMusic !== this.challengeSong) { for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.menuSong.stop(), this.vexationSong.stop(), this.challengeSong.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = this.challengeSong } }, t.prototype.playVexationgSong = function() { for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.menuSong.stop(), this.challengeSong.stop(), this.vexationSong.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = this.vexationSong }, t.prototype.playMusicNormal = function() {
|
|
for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.vexationSong.stop(), this.menuSong.stop(), this.challengeSong.stop();
|
|
var i = this.vexSongNormal[this.nextMusicNormalIndex];
|
|
i.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = i, this.nextMusicNormalIndex = 5 <= this.nextMusicNormalIndex + 1 ? 0 : this.nextMusicNormalIndex + 1
|
|
}, t.prototype.playMusicHard = function() {
|
|
for (var t = 0, e = this.songs; t < e.length; t++) { e[t].stop() } this.vexationSong.stop(), this.menuSong.stop(), this.challengeSong.stop();
|
|
var i = this.vexSongHard[this.nextMusicHardIndex];
|
|
i.play(null, null, .6 * this.main.options.musicVolume, !0), this.currentMusic = i, this.nextMusicHardIndex = 5 <= this.nextMusicHardIndex + 1 ? 0 : this.nextMusicHardIndex + 1
|
|
}, t.prototype.stopAllSounds = function() {}, t
|
|
}(),
|
|
ColorParticle = function(c) {
|
|
function t(t, e, i, s, o, n, a, r, h) { var l = c.call(this, t, e, i, o, n, a, r) || this; return l.scaleOut = h, l.size = o, l.graphics = new Phaser.Graphics(e, 0, 0), i.addChild(l.graphics), l.graphics.beginFill(s), l.graphics.drawRect(-o / 2, -o / 2, o, o), l.graphics.endFill(), l.fadeAfter = r, l.isUI = !1, l }
|
|
return __extends(t, c), t.prototype.spawn = function(t, e, i, s) { c.prototype.spawnBase.call(this, t, e, i, s), this.graphics.position.set(t, e), this.fadeTime = 0 }, t.prototype.destroy = function(t) { this.alive && (this.graphics.destroy(), this.graphics = null, this.alive = !1, c.prototype.destroy.call(this, t)) }, t.prototype.multAlpha = function(t) { this.graphics.alpha *= t }, t.prototype.update = function() {
|
|
if (this.alive) {
|
|
if (this.fadeTime >= this.fadeAfter) { if (this.graphics.alpha -= .1 * this.main.gameSpeed, this.scaleOut && (this.graphics.scale.x *= .8, this.graphics.scale.y = this.graphics.scale.x), this.graphics.alpha <= 0) return void this.destroy(this.isUI) }
|
|
else this.fadeTime++;
|
|
var t = this.xPos,
|
|
e = this.yPos;
|
|
c.prototype.update.call(this), this.alive && (t == this.xPos && e == this.yPos || (this.graphics.position.set(this.xPos, this.yPos), this.hitBoxPolygon.pos.x = this.xPos - .5 * this.size, this.hitBoxPolygon.pos.y = this.yPos - .5 * this.size))
|
|
}
|
|
}, t
|
|
}(Particle),
|
|
DeathText = function() {
|
|
function t(t, e) { this.text = t.add.bitmapText(0, 0, "grobred32", "", 18), this.text.visible = !1, this.text.anchor.set(.5, .5), e.add(this.text), this.alive = !1 }
|
|
return t.prototype.show = function(t, e, i) { this.xPos = t, this.yPos = e, this.text.position.set(t, e), this.text.setText(i), this.text.visible = !0, this.text.scale.set(.75, .75), this.tarY = e + 30, this.alive = !0 }, t.prototype.update = function() { this.alive && (this.text.scale.x < 1.3 ? (this.text.scale.x -= .05 * (this.text.scale.x - 1.3), this.text.scale.y = this.text.scale.x, 1.3 - this.text.scale.x < .01 && this.text.scale.set(1.3, 1.3)) : (this.text.alpha -= .15 * this.text.alpha, this.text.alpha && (this.alive = !1, this.text.visible = !1)), this.yPos--, this.text.position.y = this.yPos) }, t
|
|
}(),
|
|
SimpleTransition = function() {
|
|
function t(t, e, i) { this.main = t, this.game = e, this.scaleX = e.width / 640, this.scaleY = e.height / 560, this.topHalf = i.create(0, 0, "simpleTransition"), this.topHalf.scale.set(this.scaleX, this.scaleY), this.bottomHalf = i.create(0, 0, "simpleTransition"), this.bottomHalf.anchor.set(1, 1), this.bottomHalf.scale.set(-this.scaleX, -this.scaleY), this.topHalf.fixedToCamera = !0, this.bottomHalf.fixedToCamera = !0, this.topHalf.visible = !1, this.bottomHalf.visible = !1, this.state = 0 }
|
|
return t.prototype.beginTransition = function(t, e, i) { this.state = 1, this.isHub = i, this.topHalf.cameraOffset.set(0, 0), this.topHalf.anchor.set(0, 0), this.bottomHalf.cameraOffset.set(0, 0), this.bottomHalf.anchor.set(1, 1), this.topHalf.rotation = -90, this.bottomHalf.rotation = 90, this.callback = t, e && this.main.options.blend ? (this.topHalf.filters = [e], this.bottomHalf.filters = [e]) : (this.topHalf.filters = null, this.bottomHalf.filters = null), this.topHalf.visible = !0, this.bottomHalf.visible = !0 }, t.prototype.update = function() {
|
|
var t = this;
|
|
if (1 === this.state) {
|
|
var e = this.topHalf.angle - 0;
|
|
this.topHalf.angle -= e / 10, Math.abs(e) < .5 && (this.topHalf.rotation = 0, this.bottomHalf.rotation = 0, this.topHalf.cameraOffset.set(this.game.width, this.game.height), this.bottomHalf.cameraOffset.set(this.game.width, this.game.height), this.topHalf.anchor.set(1, 1), this.bottomHalf.anchor.set(0, 0), !this.isHub && Fabrique.Utils.isOnDevice(this.game) ? (this.state = 0, Fabrique.LoaderHelper.show(), Fabrique.AdHandler.getInstance(this.game).showAd(function() { Fabrique.LoaderHelper.hide(), t.state = 2, t.callback() }, function() { Fabrique.LoaderHelper.hide() }, "start")) : (this.state = 2, this.callback())), this.bottomHalf.rotation = -this.topHalf.rotation
|
|
}
|
|
else if (2 === this.state) {
|
|
e = this.topHalf.angle - 60;
|
|
this.topHalf.angle -= e / 10, Math.abs(e) < .5 && (this.topHalf.rotation = 90, this.bottomHalf.rotation = -this.topHalf.rotation, this.state = 0, this.topHalf.visible = !1, this.bottomHalf.visible = !1), this.bottomHalf.rotation = -this.topHalf.rotation
|
|
}
|
|
}, t.prototype.resizeStage = function(t, e) { this.scaleX = t / 640, this.scaleY = e / 560, this.topHalf.scale.set(this.scaleX, this.scaleY), this.bottomHalf.anchor.set(1, 1), this.bottomHalf.scale.set(-this.scaleX, -this.scaleY) }, t
|
|
}(),
|
|
TextFade = function() {
|
|
function t(t, e, i, s) { this.appearDistSq = 22500, this.disappearDistSq = 28900, this.reappearTime = 30, this.main = t, this.game = e, this.sprite = i.create(0, 0, s), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5) }
|
|
return t.prototype.spawn = function(t, e, i) { "textFade29" == this.sprite.key ? e -= 8 : "textFade13" === this.sprite.key && (this.game.device.desktop || this.sprite.loadTexture("textFade13Mobile")), this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.rotation = i * Math.PI / 180, this.sprite.scale.x = .5, this.sprite.scale.y = .5, this.sprite.alpha = 0, this.reappear = 0 }, t.prototype.update = function() {
|
|
var t = Math.pow(this.main.player.xPos - this.xPos, 2) + Math.pow(this.main.player.yPos - this.yPos, 2);
|
|
t < this.appearDistSq ? (this.sprite.alpha -= .25 * (this.sprite.alpha - 1), this.sprite.scale.x -= .25 * (this.sprite.scale.x - 1), this.sprite.scale.y = this.sprite.scale.x, this.reappear = 0) : t > this.disappearDistSq && (this.reappear >= this.reappearTime ? (this.sprite.alpha -= .25 * this.sprite.alpha, this.sprite.scale.x -= .25 * this.sprite.scale.x, this.sprite.scale.y = this.sprite.scale.x) : this.reappear++)
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.main = null }, t
|
|
}(),
|
|
PlayerGib = function(r) {
|
|
function t(t, e, i, s, o, n) { var a = r.call(this, t, e, i, o, n, !1, 150) || this; return a.sprite = i.create(0, 0, s), a.sprite.autoCull = !0, a.sprite.anchor.set(.5, .5), a }
|
|
return __extends(t, r), t.prototype.spawn = function(t, e, i, s, o, n) { r.prototype.spawnBase.call(this, t, e, i, s), this.rotation = o, this.rotSpeed = n, this.sprite.position.set(t, e), this.sprite.rotation = o }, t.prototype.update = function() {
|
|
if (this.alive) {
|
|
if (this.fadeTime >= this.fadeAfter) { if (this.sprite.alpha -= .1 * this.main.gameSpeed, this.sprite.alpha <= 0) return void this.destroy() }
|
|
else this.fadeTime++;
|
|
var t = this.xPos,
|
|
e = this.yPos;
|
|
r.prototype.update.call(this), this.alive && (this.rotation += this.rotSpeed, 0 < this.rotSpeed ? this.rotSpeed -= .5 : this.rotSpeed < 0 && (this.rotSpeed += .5), Math.abs(this.rotSpeed) < .6 && (this.rotSpeed = 0), t == this.xPos && e == this.yPos || (this.sprite.position.set(this.xPos, this.yPos), this.sprite.rotation = this.rotation, this.hitBox.pos.x = this.xPos - .5 * this.size, this.hitBox.pos.y = this.yPos - .5 * this.size, this.hitBoxPolygon = this.hitBox.toPolygon()))
|
|
}
|
|
}, t.prototype.destroy = function() { this.alive && (this.sprite && (this.sprite.destroy(), this.sprite = null), r.prototype.destroy.call(this)) }, t
|
|
}(Particle),
|
|
Block = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.scalable = !0, s.hangable = !0, s.main = t, s.game = e, s.layer = i, s.passable = !1, s }
|
|
return __extends(t, o), t.prototype.update = function() { this.landed && this.specificLand() }, t.prototype.specificLand = function() {}, t.prototype.levelStart = function() {}, t.prototype.destroy = function() { this.topBound = null, this.topBoundPolygon = null, this.bottomBound = null, this.bottomBoundPolygon = null, this.leftBound = null, this.leftBoundPolygon = null, this.rightBound = null, this.rightBoundPolygon = null, this.lhBound = null, this.lhBoundPolygon = null, this.rhBound = null, this.rhBoundPolygon = null, this.totalBound = null, this.totalBoundPolygon = null, this.game = null, this.layer = null, o.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { this.landed = null }, t.prototype.reset = function() { this.landed = null }, t
|
|
}(Entity),
|
|
BasicBlock = function(o) {
|
|
function a(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "basicBlockColors"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(a, o), a.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / this.sprite.width, s / this.sprite.height), this.sprite.anchor.set(.5, .5), this.sprite.frame = parseInt(this.main.currentLevelID), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, a.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, a.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, a.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, a.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - a.TOP_BOUND_HEIGHT))
|
|
}, a.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, a.prototype.update = function() { this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, a.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, a.prototype.reset = function() {}, a.TOP_BOUND_HEIGHT = 12, a
|
|
}(Block),
|
|
LeftSlope = function(n) {
|
|
function t(t, e, i, s) { void 0 === s && (s = !1); var o = n.call(this, t) || this; return o.game = e, o.layer = i, o.right = s, o.sprite = i.create(0, 0, "leftSlopeColors"), o.sprite.autoCull = !0, o.alive = !1, o }
|
|
return __extends(t, n), t.prototype.spawn = function(t, e, i, s, o) {
|
|
this.xPos = t, this.yPos = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.right && (this.sprite.scale.x = -this.sprite.scale.x), this.sprite.anchor.set(.5, .5), this.sprite.rotation = o * Math.PI / 180;
|
|
var n = parseInt(this.main.currentLevelID);
|
|
n < 8 && (this.sprite.frame = n), this.alive = !0, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.wallPoly = new SAT.Box(new SAT.Vector(t, e), 10, s - 20).toPolygon(), this.bottomPoly = new SAT.Box(new SAT.Vector(t, e), i, 10).toPolygon(), this.right ? this.wallPoly.setOffset(new SAT.Vector(-i / 2, -s / 2 + 20)) : this.wallPoly.setOffset(new SAT.Vector(i / 2, -s / 2 + 20)), this.bottomPoly.setOffset(new SAT.Vector(i / 2, s / 2))
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, n.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
VerticalUpBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.maxMoveDist = 100, s.sprite = i.create(0, 0, "verticalUpBlock"), s.sprite.autoCull = !0, s.sprite.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = -2, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.alive = !0, this.attachmentOffsets = [], this.attachments = [];
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.levelStart = function() {
|
|
for (var t = new SAT.Box(new SAT.Vector(this.leftEdge, this.topEdge - 10), this.width, this.height + 20).toPolygon(), e = 0; e < this.main.obstacles.length; e++) {
|
|
var i = this.main.obstacles[e];
|
|
if ("spike" === i.obstacleType) {
|
|
var s = i;
|
|
SAT.testPolygonPolygon(t, s.deathBoxPolygon) && (this.attachments.push(s), this.attachmentOffsets.push(new Phaser.Point(s.xPos - this.xPos, s.yPos - this.yPos)))
|
|
}
|
|
else if ("quadrant" === i.obstacleType) {
|
|
var o = i;
|
|
SAT.testPolygonPolygon(t, o.attachHitBoxPolygon) && (this.attachments.push(i), this.attachmentOffsets.push(new Phaser.Point(i.xPos - this.xPos, i.yPos - this.yPos)))
|
|
}
|
|
}
|
|
}, t.prototype.updatePosition = function() {
|
|
this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos, this.sprite.y = this.yPos;
|
|
for (var t = 0; t < this.attachments.length; t++) {
|
|
var e = this.attachments[t],
|
|
i = this.attachmentOffsets[t];
|
|
e.xPos = this.xPos + i.x, e.yPos = this.yPos + i.y, e.updatePosition()
|
|
}
|
|
}, t.prototype.update = function() { this.prevY = this.yPos, this.yVelocity < 0 ? this.yPos < this.startY - this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()) : this.yPos > this.startY + this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()), this.yPos += this.yVelocity, this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.attachments = null, this.attachmentOffsets = null, o.prototype.destroy.call(this) }, t
|
|
}(Block),
|
|
VerticalDownBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.maxMoveDist = 100, s.sprite = i.create(0, 0, "verticalDownBlock"), s.sprite.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.levelStart = function() {
|
|
for (var t = new SAT.Box(new SAT.Vector(this.leftEdge, this.topEdge - 10), this.width, this.height + 20).toPolygon(), e = 0; e < this.main.obstacles.length; e++) {
|
|
var i = this.main.obstacles[e];
|
|
if ("spike" === i.obstacleType) {
|
|
var s = i;
|
|
SAT.testPolygonPolygon(t, s.deathBoxPolygon) && (this.attachments.push(s), this.attachmentOffsets.push(new Phaser.Point(s.xPos - this.xPos, s.yPos - this.yPos)))
|
|
}
|
|
else if ("quadrant" === i.obstacleType) {
|
|
var o = i;
|
|
SAT.testPolygonPolygon(t, o.attachHitBoxPolygon) && (this.attachments.push(i), this.attachmentOffsets.push(new Phaser.Point(i.xPos - this.xPos, i.yPos - this.yPos)))
|
|
}
|
|
}
|
|
}, t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 2, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.alive = !0, this.attachmentOffsets = [], this.attachments = [];
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() {
|
|
this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos, this.sprite.y = this.yPos;
|
|
for (var t = 0; t < this.attachments.length; t++) {
|
|
var e = this.attachments[t],
|
|
i = this.attachmentOffsets[t];
|
|
e.xPos = this.xPos + i.x, e.yPos = this.yPos + i.y, e.updatePosition()
|
|
}
|
|
}, t.prototype.update = function() { this.prevY = this.yPos, 0 < this.yVelocity ? this.yPos > this.startY + this.maxMoveDist && (this.yVelocity = -this.yVelocity) : this.yPos < this.startY - this.maxMoveDist && (this.yVelocity = -this.yVelocity), this.yPos += this.yVelocity, this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.attachments = null, this.attachmentOffsets = null, o.prototype.destroy.call(this) }, t
|
|
}(Block),
|
|
Obstacle = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.levelStart = function() {}, t.prototype.update = function() {}, t.prototype.destroy = function() { this.main = null, this.game = null, this.layer = null, o.prototype.destroy.call(this) }, t.prototype.updatePosition = function() {}, t
|
|
}(Entity),
|
|
Spike = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.obstacleType = "spike", s.init(), s }
|
|
return __extends(t, o), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "spike"), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5), this.graphics = this.game.add.graphics(0, 0, this.layer), this.graphics.visible = !1, this.width = 7.5, this.height = 11.75, this.spikeNum = 1 }, t.prototype.levelStart = function() {
|
|
for (var t = 0, e = this.main.pools; t < e.length; t++) {
|
|
var i = e[t];
|
|
SAT.testPolygonPolygon(this.deathBoxPolygon, i.totalPolygon) && this.main.underPoolLayer.addChild(this.sprite)
|
|
}
|
|
}, t.prototype.spawn = function(t, e, i) {
|
|
this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.alive = !0, this.sprite.visible = !0;
|
|
var s = .5 * this.width,
|
|
o = .5 * this.height,
|
|
n = i * Math.PI / 180;
|
|
this.rad = n, this.sprite.rotation = n;
|
|
var a = new Phaser.Point(-s * Math.cos(this.rad) - -o * Math.sin(this.rad), -s * Math.sin(this.rad) + -o * Math.cos(this.rad)),
|
|
r = new Phaser.Point(s * Math.cos(this.rad) - -o * Math.sin(this.rad), s * Math.sin(this.rad) + -o * Math.cos(this.rad)),
|
|
h = new Phaser.Point(-s * Math.cos(this.rad) - o * Math.sin(this.rad), -s * Math.sin(this.rad) + o * Math.cos(this.rad)),
|
|
l = new Phaser.Point(s * Math.cos(this.rad) - o * Math.sin(this.rad), s * Math.sin(this.rad) + o * Math.cos(this.rad));
|
|
this.deathBoxPolygon = new SAT.Polygon(new SAT.Vector(t, e), [new SAT.Vector(a.x, a.y), new SAT.Vector(r.x, r.y), new SAT.Vector(l.x, l.y), new SAT.Vector(h.x, h.y)]), this.graphics.beginFill(16711680, .5), this.graphics.moveTo(this.deathBoxPolygon.points[0].x, this.deathBoxPolygon.points[0].y), this.graphics.lineTo(this.deathBoxPolygon.points[1].x, this.deathBoxPolygon.points[1].y), this.graphics.lineTo(this.deathBoxPolygon.points[2].x, this.deathBoxPolygon.points[2].y), this.graphics.lineTo(this.deathBoxPolygon.points[3].x, this.deathBoxPolygon.points[3].y), this.graphics.endFill(), this.graphics.position.set(t, e)
|
|
}, t.prototype.update = function() {}, t.prototype.updatePosition = function() {
|
|
this.sprite.position.set(this.xPos, this.yPos);
|
|
var t = .5 * this.width,
|
|
e = .5 * this.height,
|
|
i = new Phaser.Point(-t * Math.cos(this.rad) - -e * Math.sin(this.rad), -t * Math.sin(this.rad) + -e * Math.cos(this.rad)),
|
|
s = new Phaser.Point(t * Math.cos(this.rad) - -e * Math.sin(this.rad), t * Math.sin(this.rad) + -e * Math.cos(this.rad)),
|
|
o = new Phaser.Point(-t * Math.cos(this.rad) - e * Math.sin(this.rad), -t * Math.sin(this.rad) + e * Math.cos(this.rad)),
|
|
n = new Phaser.Point(t * Math.cos(this.rad) - e * Math.sin(this.rad), t * Math.sin(this.rad) + e * Math.cos(this.rad));
|
|
this.deathBoxPolygon = new SAT.Polygon(new SAT.Vector(this.xPos, this.yPos), [new SAT.Vector(i.x, i.y), new SAT.Vector(s.x, s.y), new SAT.Vector(n.x, n.y), new SAT.Vector(o.x, o.y)]), this.graphics.clear(), this.graphics.beginFill(16711680, .5), this.graphics.moveTo(this.deathBoxPolygon.points[0].x, this.deathBoxPolygon.points[0].y), this.graphics.lineTo(this.deathBoxPolygon.points[1].x, this.deathBoxPolygon.points[1].y), this.graphics.lineTo(this.deathBoxPolygon.points[2].x, this.deathBoxPolygon.points[2].y), this.graphics.lineTo(this.deathBoxPolygon.points[3].x, this.deathBoxPolygon.points[3].y), this.graphics.endFill(), this.graphics.position.set(this.xPos, this.yPos)
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.deathBoxPolygon = null, this.graphics.destroy(), this.graphics = null }, t
|
|
}(Obstacle),
|
|
HorizontalBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.maxMoveDist = 100, s.sprite = i.create(0, 0, "horizontalBlock"), s.sprite.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s, o) {
|
|
void 0 === o && (o = -2), this.xPos = t, this.yPos = e, this.startX = t, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = o, this.startXVelocity = o, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.attachmentOffsets = [], this.attachments = [], this.landed = null, this.alive = !0;
|
|
var n = .5 * this.width,
|
|
a = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), n, BasicBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), n, BasicBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), n, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), n, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-n, a - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.levelStart = function() {
|
|
for (var t = new SAT.Box(new SAT.Vector(this.leftEdge, this.topEdge), this.width, this.height + 10).toPolygon(), e = 0; e < this.main.obstacles.length; e++) {
|
|
var i = this.main.obstacles[e];
|
|
if ("spike" === i.obstacleType) {
|
|
var s = i;
|
|
if (1 != s.spikeNum) continue;
|
|
SAT.testPolygonPolygon(t, s.deathBoxPolygon) && (this.attachments.push(s), this.attachmentOffsets.push(new Phaser.Point(s.xPos - this.xPos, s.yPos - this.yPos)))
|
|
}
|
|
}
|
|
}, t.prototype.updatePosition = function() {
|
|
this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos, this.sprite.x = this.xPos;
|
|
for (var t = 0; t < this.attachments.length; t++) {
|
|
var e = this.attachments[t],
|
|
i = this.attachmentOffsets[t];
|
|
e.xPos = this.xPos + i.x, e.yPos = this.yPos + i.y, e.updatePosition()
|
|
}
|
|
}, t.prototype.update = function() {
|
|
var t = this.xPos;
|
|
if (0 < this.xVelocity ? this.xPos > this.startX + this.maxMoveDist && (this.xVelocity = -this.xVelocity) : this.xPos < this.startX - this.maxMoveDist && (this.xVelocity = -this.xVelocity), this.xPos += this.xVelocity, this.xPos != t && this.updatePosition(), this.landed) {
|
|
var e = this.main.player.xPos - t - this.landed.x;
|
|
this.landed.x += e, this.main.player.xPos = this.xPos + this.landed.x, this.main.player.updatePositions()
|
|
}
|
|
}, t.prototype.reset = function() { o.prototype.reset.call(this), this.xPos = this.startX, this.xVelocity = this.startXVelocity }, t.prototype.resetLevel = function() { this.reset() }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.attachments = null, this.attachmentOffsets = null }, t
|
|
}(Block),
|
|
BounceBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.bounceStr = 4, s.container = s.game.add.group(i), s.sprite = s.container.create(0, 0, "bounceBlock"), s.sprite.autoCull = !0, s.arrowAnimation = s.container.create(0, 0, "arrowAnimation"), s.arrowAnimation.autoCull = !0, s.sprite.anchor.set(.5, .5), s.arrowAnimation.anchor.set(.5, .5), s.alive = !1, s.hangable = !0, s.scalable = !0, s.blockType = "bounce", s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startY = e, this.spriteYOff = 0, this.width = i, this.height = s, this.container.position.set(t, e), this.container.scale.set(i / 100, s / 100), this.arrowMask = this.game.add.graphics(0, 0, this.container), this.main.options.blend ? (this.arrowMask.beginFill(0), this.arrowMask.drawRect(-50, -50, 100, 100), this.arrowMask.endFill(), this.arrowAnimation.mask = this.arrowMask, this.arrowAnimation.animations.add("arrow"), this.arrowAnimation.play("arrow", 60 * this.main.gameSpeed, !0)) : this.arrowAnimation.loadTexture("arrowStatic"), this.startScaleX = i / 100, this.startScaleY = s / 100, this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.bouncing = !1, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height,
|
|
a = t - o,
|
|
r = e - n;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(a, r), i, s), this.topBound = new SAT.Box(new SAT.Vector(a, r), i, BasicBlock.TOP_BOUND_HEIGHT), this.lhBound = new SAT.Box(new SAT.Vector(a, r), o, BasicBlock.TOP_BOUND_HEIGHT), this.rhBound = new SAT.Box(new SAT.Vector(t, r), o, BasicBlock.TOP_BOUND_HEIGHT), this.leftBound = new SAT.Box(new SAT.Vector(a, r), o, s), this.rightBound = new SAT.Box(new SAT.Vector(t, r), o, s), this.bottomBound = new SAT.Box(new SAT.Vector(a, e + n - BasicBlock.TOP_BOUND_HEIGHT), i, BasicBlock.TOP_BOUND_HEIGHT), this.totalBoundPolygon = this.totalBound.toPolygon(), this.topBoundPolygon = this.topBound.toPolygon(), this.lhBoundPolygon = this.lhBound.toPolygon(), this.rhBoundPolygon = this.rhBound.toPolygon(), this.leftBoundPolygon = this.leftBound.toPolygon(), this.rightBoundPolygon = this.rightBound.toPolygon(), this.bottomBoundPolygon = this.bottomBound.toPolygon()
|
|
}, t.prototype.updatePosition = function() {
|
|
this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height;
|
|
var t = .5 * this.width,
|
|
e = .5 * this.height,
|
|
i = this.xPos - t,
|
|
s = this.yPos - e;
|
|
this.totalBound.pos.x = i, this.totalBound.pos.y = s, this.topBound.pos.x = i, this.topBound.pos.y = s, this.lhBound.pos.x = i, this.lhBound.pos.y = s, this.rhBound.pos.x = this.xPos, this.rhBound.pos.y = s, this.leftBound.pos.x = i, this.leftBound.pos.y = s, this.rightBound.pos.x = this.xPos, this.rightBound.pos.y = s, this.bottomBound.pos.x = i, this.bottomBound.pos.y = this.yPos + this.height - BasicBlock.TOP_BOUND_HEIGHT, this.topBoundPolygon = this.topBound.toPolygon(), this.lhBoundPolygon = this.lhBound.toPolygon(), this.rhBoundPolygon = this.rhBound.toPolygon(), this.leftBoundPolygon = this.leftBound.toPolygon(), this.rightBoundPolygon = this.rightBound.toPolygon(), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.container.y = this.yPos
|
|
}, t.prototype.update = function() { this.landed ? this.specificLand() : 1 == this.container.scale.x && 1 == this.container.scale.y || (this.container.scale.y -= (this.container.scale.y - this.startScaleY) * (.15 * this.main.gameSpeed), this.container.scale.x -= (this.container.scale.x - this.startScaleX) * (.15 * this.main.gameSpeed), this.spriteYOff = (this.startScaleY - this.container.scale.y) * this.height * .5), this.container.position.y = this.yPos + 2 * this.spriteYOff }, t.prototype.specificLand = function() { this.container.scale.x += .01 * this.bounceStr * this.main.gameSpeed, this.container.scale.y -= .01 * this.bounceStr * this.main.gameSpeed, this.spriteYOff = (this.startScaleY - this.container.scale.y) * this.height * .5, this.bouncing ? (this.main.player.xPos = this.lockX, this.main.player.spriteYOff = 2 * this.spriteYOff + 5, this.main.player.updatePositions()) : (this.lockX = this.main.player.xPos, this.main.player.setCrouch(), this.main.player.bouncing = !0, this.bouncing = !0), this.container.scale.y < .25 && (this.main.player.yPos -= .5 * this.height, this.main.player.xPos = this.lockX, this.main.player.jump(-35 * this.height * .01), this.main.player.bouncing = !1, this.main.player.spriteYOff = 0, this.bouncing = !1, this.main.sounds.playSound("bounce1")) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.arrowAnimation.destroy(), this.arrowAnimation = null, this.arrowMask && (this.arrowMask.destroy(), this.arrowMask = null), this.container.destroy(), this.container = null, o.prototype.destroy.call(this) }, t
|
|
}(Block),
|
|
FallingBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.container = s.game.add.group(i), s.sprite = s.container.create(0, 0, "fallingBlock"), s.sprite.autoCull = !0, s.arrowAnimation = s.container.create(0, 0, "arrowAnimation"), s.arrowAnimation.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s.container.visible = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startY = e, this.width = i, this.height = s, this.container.position.set(t, e), this.container.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.arrowAnimation.anchor.set(.5, .5), this.arrowAnimation.scale.set(1, -1), this.main.options.blend ? (this.arrowMask = this.game.add.graphics(0, 0, this.container), this.arrowMask.beginFill(0), this.arrowMask.drawRect(-50, -50, 100, 100), this.arrowMask.endFill(), this.arrowAnimation.mask = this.arrowMask, this.arrowAnimation.animations.add("arrow"), this.arrowAnimation.play("arrow", 60 * this.main.gameSpeed, !0)) : this.arrowAnimation.loadTexture("arrowStatic"), this.container.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.falling = !1, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, BasicBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, BasicBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos, this.container.position.y = this.yPos }, t.prototype.update = function() {
|
|
if (!this.alive) {
|
|
if (SAT.testPolygonPolygon(this.totalBoundPolygon, this.main.player.bodyPolygon)) return;
|
|
this.alive = !0
|
|
}
|
|
this.prevY = this.yPos, this.falling ? (this.yVelocity += this.main.gravity * this.main.gameSpeed, this.container.alpha -= .01 * this.main.gameSpeed, 20 <= this.yVelocity && (this.main.sounds.playSound("blockDestroy"), this.alive = !1, this.container.alpha = 0, this.yPos = this.startY, this.yVelocity = 0, this.falling = !1)) : this.landed ? (this.falling = !0, this.yVelocity = -2, this.main.sounds.playSound("fallingBlock")) : this.container.alpha < 1 && (this.container.alpha += .02), this.yPos += this.yVelocity * this.main.gameSpeed, this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition()
|
|
}, t.prototype.reset = function() { this.yPos = this.startY, this.yVelocity = 0, this.falling = !1, this.alive = !0, this.container.alpha = 1, this.updatePosition(), o.prototype.reset.call(this) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.arrowAnimation.destroy(), this.arrowAnimation = null, this.arrowMask && (this.arrowMask.destroy(), this.arrowMask = null), this.container.destroy(), this.container = null, o.prototype.destroy.call(this) }, t
|
|
}(Block),
|
|
PushBlock = function(o) {
|
|
function a(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "pushBlock"), s.sprite.autoCull = !0, s.alive = !1, s.blockType = "push", s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(a, o), a.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.pushingRight = !1, this.pushingLeft = !1, this.pushed = !1, this.inWater = !1, this.onIce = !1, this.stuckLeft = !1, this.stuckRight = !1, this.land = !1, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, a.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, a.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, a.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, a.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - a.TOP_BOUND_HEIGHT))
|
|
}, a.prototype.checkBlockCollisions = function() {
|
|
this.land = !1, this.onIce = !1;
|
|
for (var t = 0; t < this.main.blocks.length; t++) {
|
|
var e = this.main.blocks[t];
|
|
if (e.alive)
|
|
if (SAT.testPolygonPolygon(e.topBoundPolygon, this.bottomBoundPolygon)) {
|
|
if (this.yVelocity, "ice" === e.blockType && (this.onIce = !0), this.yVelocity = e.yVelocity, this.inWater ? (this.yVelocity *= -1, this.yPos = e.topEdge - .5 * this.height) : 0 < this.yVelocity ? this.yPos = e.topEdge - .5 * this.height + this.yVelocity : this.yPos = e.topEdge - .5 * this.height + 1, this.land = !0, this.updatePositions(), "speed" === e.blockType) {
|
|
var i = e;
|
|
this.xVelocity += .4 * i.speedInc
|
|
}
|
|
else if ("falling" === e.blockType) {
|
|
var s = e;
|
|
s.falling || (s.falling = !0, s.yVelocity = -2)
|
|
}
|
|
}
|
|
else(this.yVelocity < 0 || 0 < e.yVelocity) && SAT.testPolygonPolygon(this.topBoundPolygon, e.bottomBoundPolygon) ? (this.yVelocity < 0 && (this.yVelocity *= .5), this.yPos = e.bottomEdge + .5 * this.height) : this.xVelocity - e.xVelocity < 0 && SAT.testPolygonPolygon(this.leftBoundPolygon, e.rightBoundPolygon) ? (this.xVelocity = 0, this.xPos = e.rightEdge + .5 * this.width) : 0 < this.xVelocity - e.xVelocity && SAT.testPolygonPolygon(this.rightBoundPolygon, e.leftBoundPolygon) && (this.xVelocity = 0, this.xPos = e.leftEdge - .5 * this.width)
|
|
}
|
|
}, a.prototype.checkWaterCollisions = function() {
|
|
var t = this.inWater;
|
|
this.inWater = !1;
|
|
for (var e = 0; e < this.main.pools.length; e++) {
|
|
var i = this.main.pools[e];
|
|
SAT.testPolygonPolygon(this.totalBoundPolygon, i.totalPolygon) && (this.main.underPoolLayer.addChild(this.sprite), this.yPos > i.yPos - .5 * i.height && (!t && this.yVelocity, this.yVelocity -= this.main.gameSpeed, this.yVelocity < -3 && (this.yVelocity = -3), this.inWater = !0))
|
|
}
|
|
}, a.prototype.checkTrapped = function() { for (var t = new SAT.Vector(this.leftEdge - 5, this.topEdge + 10), e = new SAT.Vector(this.rightEdge + 5, this.topEdge + 10), i = 0; i < this.main.blocks.length; i++) { var s = this.main.blocks[i]; if (s.alive) { if (SAT.pointInPolygon(t, s.totalBoundPolygon)) return this.stuckLeft = !0, "left"; if (SAT.pointInPolygon(e, s.totalBoundPolygon)) return this.stuckRight = !0, "right" } } return "not trapped" }, a.prototype.update = function() { this.land || (this.yVelocity += this.main.gravity * this.main.gameSpeed), this.xPos += this.xVelocity, this.yPos += this.yVelocity, this.landed && (this.main.player.xPos += this.xVelocity, this.main.player.updatePositions()), this.onIce ? this.xVelocity -= .01 * this.xVelocity : this.xVelocity -= .25 * this.xVelocity, this.checkBlockCollisions(), this.checkWaterCollisions(), this.updatePositions() }, a.prototype.updatePositions = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, a.prototype.reset = function() { this.main.levelLayer.addChild(this.sprite), this.xPos = this.startX, this.yPos = this.startY, this.pushed = !1, this.pushingLeft = !1, this.pushingRight = !1, this.updatePositions(), o.prototype.reset.call(this) }, a.prototype.resetLevel = function() { this.reset() }, a.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, a.TOP_BOUND_HEIGHT = 12, a
|
|
}(Block),
|
|
IceBlock = function(o) {
|
|
function r(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "iceBlock"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s.blockType = "ice", s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(r, o), r.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startX = t, this.startY = e, this.width = i, this.height = s, this.startHeight = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.startXScale = i / 100, this.startYScale = s / 100, this.sprite.anchor.set(.5, .5), this.sprite.visible = !0, this.main.options.blend && (this.maskGraphic = this.game.add.graphics(0, 0, this.layer), this.maskGraphic.beginFill(0), this.maskGraphic.drawRect(.5 * -i, .5 * -s, i, s), this.maskGraphic.endFill(), this.maskGraphic.position.set(t, e), this.sprite.mask = this.maskGraphic), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.depletionRate = .001, this.meltScale = 1, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, r.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, r.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, r.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, r.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - r.TOP_BOUND_HEIGHT)), this.hitGraphics = this.game.add.graphics(0, 0), this.hitGraphics.visible = !1, this.layer.add(this.hitGraphics), this.hitGraphics.clear(), this.hitGraphics.beginFill(16711680, .5), this.hitGraphics.moveTo(this.xPos + this.rhBoundPolygon.calcPoints[0].x, this.yPos + this.rhBoundPolygon.calcPoints[0].y);
|
|
for (var a = 1; a < 4; a++) this.hitGraphics.lineTo(this.xPos + this.rhBoundPolygon.calcPoints[a].x, this.yPos + this.rhBoundPolygon.calcPoints[a].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.rhBoundPolygon.calcPoints[0].x, this.yPos + this.rhBoundPolygon.calcPoints[0].y), this.hitGraphics.endFill()
|
|
}, r.prototype.update = function() {
|
|
if (this.alive) {
|
|
if (this.melted, this.rightEdge < this.game.camera.x || this.leftEdge > this.game.camera.x + 640 || this.bottomEdge < this.game.camera.y || this.topEdge > this.game.camera.y + 560) return;
|
|
this.meltScale -= this.depletionRate, this.maskGraphic ? (this.maskGraphic.scale.y = this.meltScale, this.maskGraphic.y -= this.depletionRate * this.startHeight / 2) : (this.sprite.scale.y = this.height / 100 * this.meltScale, this.sprite.position.y = this.yPos - this.height / 2 * (1 - this.meltScale));
|
|
var t = .5 * this.width,
|
|
e = .5 * this.height,
|
|
i = (this.width, this.height),
|
|
s = this.xPos,
|
|
o = this.yPos;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(this.xPos, this.yPos), this.width, this.height * this.meltScale), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-t, -e)), this.leftBound = new SAT.Box(new SAT.Vector(s, o), t, i * this.meltScale), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-t, -e)), this.rightBound = new SAT.Box(new SAT.Vector(s, o), t, i * this.meltScale), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -e)), this.bottomBoundPolygon.setOffset(new SAT.Vector(-t, this.meltScale * e - r.TOP_BOUND_HEIGHT)), this.meltScale <= 0 && (this.melted = !0, this.alive = !1, this.sprite.visible = !1)
|
|
}
|
|
}, r.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.maskGraphic && (this.maskGraphic.destroy(), this.maskGraphic = null), this.hitGraphics.destroy(), delete this.hitGraphics, o.prototype.destroy.call(this) }, r.prototype.resetLevel = function() { this.reset() }, r.prototype.reset = function() { this.meltScale = 1, this.maskGraphic && (this.maskGraphic.scale.y = 1, this.maskGraphic.y = this.startY), this.sprite.scale.set(this.startXScale, this.startYScale), this.sprite.visible = !0, this.alive = !0, this.melted = !1, o.prototype.reset.call(this) }, r.TOP_BOUND_HEIGHT = 12, r
|
|
}(Block),
|
|
GlassBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "glassBlock"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s.blockType = "glass", s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, IceBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, IceBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, IceBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, IceBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - IceBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.smash = function() {
|
|
this.sprite.visible = !1, this.main.sounds.playSound("glassSmash");
|
|
for (var t = 0; t < .25 * this.width; t++) {
|
|
var e = this.xPos - this.width / 2 + Math.random() * this.width,
|
|
i = this.yPos - .5 * this.height + Math.random() * this.height;
|
|
this.main.createColorParticle(e, i, 5 * Math.random() - 2.5, this.main.player.yVelocity * Math.random(), 12185594, 8), this.alive = !1, 10 < this.main.player.yVelocity && (this.main.player.yVelocity = 10)
|
|
}
|
|
}, t.prototype.resetLevel = function() { this.reset() }, t.prototype.reset = function() { this.alive = !0, this.sprite.visible = !0, o.prototype.reset.call(this) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null }, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
SpeedBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.container = e.add.group(i), s.sprite = s.container.create(0, 0, "speedBlock"), s.sprite.anchor.set(.5, .5), s.sprite.autoCull = !0, s.arrowAnimation = s.container.create(0, 0, "arrowAnimation"), s.arrowAnimation.animations.add("arrow"), s.arrowAnimation.anchor.set(.5, .5), s.arrowAnimation.autoCull = !0, s.alive = !1, s.blockType = "speed", s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s, o) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.speedInc = o, this.container.position.set(t, e), this.container.scale.set(i / 100, s / 100), this.main.options.blend ? (this.arrowMask = this.game.add.graphics(0, 0, this.container), this.arrowMask.beginFill(0), this.arrowMask.drawRect(-50, -50, 100, 100), this.arrowMask.endFill(), this.arrowAnimation.mask = this.arrowMask, this.arrowAnimation.play("arrow", null, !0)) : this.arrowAnimation.loadTexture("arrowStatic"), 0 < this.speedInc ? this.arrowAnimation.rotation = Math.PI / 2 : this.arrowAnimation.rotation = -Math.PI / 2, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var n = .5 * this.width,
|
|
a = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), n, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), n, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), n, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), n, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-n, a - PushBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.container.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.landed && this.land(), this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.land = function() {
|
|
(0 < this.speedInc && this.main.player.xVelocity < 5 * this.speedInc || this.speedInc < 0 && this.main.player.xVelocity > 5 * this.speedInc) && (this.main.player.xVelocity += this.speedInc, this.main.player.xVelocity === this.speedInc && (this.main.player.xVelocity += .75 * this.speedInc))
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.arrowMask && (this.arrowMask.destroy(), this.arrowMask = null), this.container.destroy(), this.container = null, o.prototype.destroy.call(this) }, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
LB = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "lockBlock"), s.sprite.autoCull = !0, s.alive = !1, s.blockType = "lock", s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - PushBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.unlock = function() { this.unlocked = !0, this.passable = !0, this.alive = !1, this.sprite.visible = !1 }, t.prototype.update = function() {}, t.prototype.updatePositions = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.reset = function() {}, t.prototype.resetLevel = function() { this.alive = !0, this.unlocked = !1, this.passable = !1, this.sprite.visible = !0 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
InvisBlock = function(o) {
|
|
function i(t, e, i) { var s = o.call(this, t, e, i) || this; return s.init(), s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(i, o), i.prototype.init = function() { this.sprite = this.layer.create(0, 0, "invisBlock"), this.sprite.autoCull = !0, this.alive = !1 }, i.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.startX = t, this.startY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - PushBlock.TOP_BOUND_HEIGHT))
|
|
}, i.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, i.prototype.update = function() {
|
|
if (this.alive) {
|
|
var t = this.main.player,
|
|
e = Math.sqrt(Math.pow(t.xPos - this.xPos, 2) + Math.pow(t.yPos - this.yPos, 2));
|
|
this.sprite.alpha = i.RANGE < e ? 1 : e < .5 * i.RANGE ? 0 : (e - .5 * i.RANGE) / (.5 * i.RANGE) * 1, this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition(), this.prevX = this.xPos, this.prevY = this.yPos
|
|
}
|
|
}, i.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, i.prototype.reset = function() {}, i.TOP_BOUND_HEIGHT = 12, i.RANGE = 200, i
|
|
}(Block),
|
|
SparkBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "sparkBlock"), s.sprite.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s.spark = new Spark(t, e, i, s), s.main.obstacles.push(s.spark), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - PushBlock.TOP_BOUND_HEIGHT)), this.spark.spawn()
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { o.prototype.resetLevel.call(this) }, t.prototype.reset = function() { o.prototype.reset.call(this) }, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
SolarBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "solarBlock"), s.sprite.autoCull = !0, s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - PushBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.goDark = function() { this.alive = !1, this.sprite.visible = !1 }, t.prototype.goLight = function() { this.alive = !0, this.sprite.visible = !0 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t.prototype.reset = function() {}, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
InvisBlockUp = function(o) {
|
|
function t() { var t = null !== o && o.apply(this, arguments) || this; return t.maxMoveDist = 100, t }
|
|
return __extends(t, o), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "invisBlockUp"), this.sprite.autoCull = !0, this.alive = !1 }, t.prototype.levelStart = function() {
|
|
this.attachments = [], this.attachmentOffsets = [];
|
|
for (var t = new SAT.Box(new SAT.Vector(this.leftEdge, this.topEdge - 10), this.width, this.height + 20).toPolygon(), e = 0; e < this.main.obstacles.length; e++) {
|
|
var i = this.main.obstacles[e];
|
|
if ("spike" === i.obstacleType) {
|
|
var s = i;
|
|
SAT.testPolygonPolygon(t, s.deathBoxPolygon) && (this.attachments.push(s), this.attachmentOffsets.push(new Phaser.Point(s.xPos - this.xPos, s.yPos - this.yPos)))
|
|
}
|
|
else if ("buzzsaw" === i.obstacleType) {
|
|
var o = i;
|
|
SAT.testCirclePolygon(o.deathCircle, t) && (this.attachments.push(o), this.attachmentOffsets.push(new Phaser.Point(o.xPos - this.xPos, o.yPos - this.yPos)))
|
|
}
|
|
}
|
|
}, t.prototype.spawn = function(t, e, i, s) { o.prototype.spawn.call(this, t, e, i, s), this.yVelocity = -2 }, t.prototype.update = function() {
|
|
this.yVelocity < 0 ? this.yPos < this.startY - this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()) : this.yPos > this.startY + this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()), this.yPos += this.yVelocity;
|
|
for (var t = 0; t < this.attachments.length; t++) {
|
|
var e = this.attachments[t],
|
|
i = this.attachmentOffsets[t];
|
|
e.xPos = this.xPos + i.x, e.yPos = this.yPos + i.y, e.updatePosition()
|
|
}
|
|
o.prototype.update.call(this)
|
|
}, t
|
|
}(InvisBlock),
|
|
InvisBlockDown = function(o) {
|
|
function t() { var t = null !== o && o.apply(this, arguments) || this; return t.maxMoveDist = 100, t }
|
|
return __extends(t, o), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "invisBlockDown"), this.sprite.autoCull = !0, this.alive = !1 }, t.prototype.levelStart = function() {
|
|
this.attachments = [], this.attachmentOffsets = [];
|
|
for (var t = new SAT.Box(new SAT.Vector(this.leftEdge, this.topEdge - 10), this.width, this.height + 20).toPolygon(), e = 0; e < this.main.obstacles.length; e++) {
|
|
var i = this.main.obstacles[e];
|
|
if ("spike" === i.obstacleType) {
|
|
var s = i;
|
|
SAT.testPolygonPolygon(t, s.deathBoxPolygon) && (this.attachments.push(s), this.attachmentOffsets.push(new Phaser.Point(s.xPos - this.xPos, s.yPos - this.yPos)))
|
|
}
|
|
else if ("buzzsaw" === i.obstacleType) {
|
|
var o = i;
|
|
SAT.testCirclePolygon(o.deathCircle, t) && (this.attachments.push(o), this.attachmentOffsets.push(new Phaser.Point(o.xPos - this.xPos, o.yPos - this.yPos)))
|
|
}
|
|
}
|
|
}, t.prototype.spawn = function(t, e, i, s) { o.prototype.spawn.call(this, t, e, i, s), this.yVelocity = 2 }, t.prototype.update = function() {
|
|
this.yVelocity < 0 ? this.yPos < this.startY - this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()) : this.yPos > this.startY + this.maxMoveDist && (this.yVelocity = -this.yVelocity, this.landed && (this.main.player.yPos += 2 * this.yVelocity), this.main.player.updatePositions()), this.yPos += this.yVelocity;
|
|
for (var t = 0; t < this.attachments.length; t++) {
|
|
var e = this.attachments[t],
|
|
i = this.attachmentOffsets[t];
|
|
e.xPos = this.xPos + i.x, e.yPos = this.yPos + i.y, e.updatePosition()
|
|
}
|
|
o.prototype.update.call(this)
|
|
}, t
|
|
}(InvisBlock),
|
|
ExplosiveBlock = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "explosiveBlock"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s.explodingOverlay = e.add.graphics(0, 0, s.layer), s.sprite.addChild(s.explodingOverlay), s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 100, s / 100), this.sprite.anchor.set(.5, .5), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.explodingOverlay.beginFill(16777215, 1), this.explodingOverlay.drawRect(0, 0, i, s), this.explodingOverlay.visible = !0, this.explodingOverlay.position.set(-this.width / 2, -this.height / 2), this.explodingOverlay.alpha = 0, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var o = .5 * this.width,
|
|
n = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), o, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-o, -n)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), o, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -n)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-o, n - PushBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.exploding && (this.sprite.scale.x -= .1 * (this.sprite.scale.x - 1.5), this.sprite.scale.y = this.sprite.scale.x, this.explodingOverlay.alpha += .05, 1 <= this.explodingOverlay.alpha && (this.main.exploding || this.main.explode())), this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.explodingOverlay.destroy(), this.explodingOverlay = null, o.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { this.explodingOverlay.visible = !1, this.exploding = !1, this.explodingOverlay.scale.set(1, 1), this.explodingOverlay.alpha = 1, this.sprite.scale.set(1, 1) }, t.prototype.reset = function() {}, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
BlockedWall = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "blockedWall"), s.sprite.animations.add("blockedwall"), s.sprite.animations.play("blockedwall", null, !0), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s.hangable = !0, s.scalable = !0, s.hangable = !1, s.scalable = !1, s.blockType = "wall", s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s, o, n, a) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.levelNum = a, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.angle = o, this.sprite.anchor.set(.5, .5), this.sprite.frame = parseInt(this.main.currentLevelID), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * i, this.rightEdge = t + .5 * i, this.topEdge = e - .5 * s, this.bottomEdge = e + .5 * s, this.xVelocity = 0, this.yVelocity = 0, n.colorFilter && this.main.options.blend ? this.sprite.filters = [n.colorFilter] : this.sprite.filters = null, this.landed = null, this.alive = !0;
|
|
var r = .5 * this.width,
|
|
h = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), i, s), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-r, -h)), this.topBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-r, -h)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), r, PushBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-r, -h)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), r, PushBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -h)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), r, s), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-r, -h)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), r, s), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -h)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), i, PushBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-r, h - PushBlock.TOP_BOUND_HEIGHT)), -1 !== n.topTime && (this.alive = !1, this.sprite.visible = !1)
|
|
}, t.prototype.redrawHitBoxes = function() {
|
|
this.hitGraphic.clear(), this.hitGraphic.beginFill(16711680, .5), this.hitGraphic.moveTo(this.xPos + this.totalBoundPolygon.calcPoints[0].x, this.yPos + this.totalBoundPolygon.calcPoints[0].y);
|
|
for (var t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.totalBoundPolygon.calcPoints[t].x, this.yPos + this.totalBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.totalBoundPolygon.calcPoints[0].x, this.yPos + this.totalBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(65280, .5), this.hitGraphic.moveTo(this.xPos + this.topBoundPolygon.calcPoints[0].x, this.yPos + this.topBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.topBoundPolygon.calcPoints[t].x, this.yPos + this.topBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.topBoundPolygon.calcPoints[0].x, this.yPos + this.topBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(255, .5), this.hitGraphic.moveTo(this.xPos + this.lhBoundPolygon.calcPoints[0].x, this.yPos + this.lhBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.lhBoundPolygon.calcPoints[t].x, this.yPos + this.lhBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.lhBoundPolygon.calcPoints[0].x, this.yPos + this.lhBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(6710784, .5), this.hitGraphic.moveTo(this.xPos + this.rhBoundPolygon.calcPoints[0].x, this.yPos + this.rhBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.rhBoundPolygon.calcPoints[t].x, this.yPos + this.rhBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.rhBoundPolygon.calcPoints[0].x, this.yPos + this.rhBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(26214, .5), this.hitGraphic.moveTo(this.xPos + this.leftBoundPolygon.calcPoints[0].x, this.yPos + this.leftBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.leftBoundPolygon.calcPoints[t].x, this.yPos + this.leftBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.leftBoundPolygon.calcPoints[0].x, this.yPos + this.leftBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(6684774, .5), this.hitGraphic.moveTo(this.xPos + this.rightBoundPolygon.calcPoints[0].x, this.yPos + this.rightBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.rightBoundPolygon.calcPoints[t].x, this.yPos + this.rightBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.rightBoundPolygon.calcPoints[0].x, this.yPos + this.rightBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill(), this.hitGraphic.beginFill(16773120, .5), this.hitGraphic.moveTo(this.xPos + this.bottomBoundPolygon.calcPoints[0].x, this.yPos + this.bottomBoundPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphic.lineTo(this.xPos + this.bottomBoundPolygon.calcPoints[t].x, this.yPos + this.bottomBoundPolygon.calcPoints[t].y);
|
|
this.hitGraphic.lineTo(this.xPos + this.bottomBoundPolygon.calcPoints[0].x, this.yPos + this.bottomBoundPolygon.calcPoints[0].y), this.hitGraphic.endFill()
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.xPos == this.prevX && this.yPos == this.prevY || (this.updatePosition(), this.redrawHitBoxes()) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t.prototype.reset = function() {}, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block);
|
|
! function(t) { t[t.Locked = 0] = "Locked", t[t.NotPlayed = 1] = "NotPlayed", t[t.Played = 2] = "Played", t[t.Challenge = 3] = "Challenge" }(ActState || (ActState = {}));
|
|
var Fabrique, ActBlock = function(l) {
|
|
function o(t, e, i, s, o, n) {
|
|
var a, r = l.call(this, t, e, i) || this;
|
|
if (r.hellEnabled = !1, r.level = o, r.levelNum = s, r.container = e.add.group(i, "container" + s), r.sprite = r.container.create(0, 0, "actBlock" + s), r.sprite.visible = !1, r.sprite.autoCull = !0, r.isHell = n, a = r.main.levels.levels[s].name, r.titleText = new Phaser.Text(r.game, 0, 0, a), r.titleText.font = "milocha", r.titleText.fontSize = r.isHell ? 24 : 28, r.titleText.fill = "#ffffff", r.titleText.setShadow(1, 2, "rgba(0, 0, 0, 0.5)", 0), r.titleText.anchor.set(.5, .5), r.titleText.visible = !1, r.titleText.align = "center", r.isHell) {
|
|
var h = Game.LocalizationManager.getInstance(r.game).getSringForKey("act_select_hard");
|
|
r.titleHardText = new Phaser.Text(r.game, 18, 0, h), r.titleHardText.font = "milocha", r.titleHardText.fontSize = 16, r.titleHardText.fill = "#ffffff", r.titleHardText.setShadow(1, 2, "rgba(0, 0, 0, 0.5)", 0), r.titleHardText.anchor.set(.5, .5), r.titleHardText.visible = !1, r.container.addChild(r.titleHardText)
|
|
}
|
|
if (r.isChallenge = "11" === r.level.id, r.isChallenge && (r.titleText.fontSize = 22, r.titleText.lineSpacing = -10, r.titleText.wordWrap = !0, r.titleText.wordWrapWidth = 100, r.challengeIcon = new Phaser.Sprite(r.game, 0, 20, "atlas_gameplay", "challenge_room_icon.png"), r.challengeIcon.anchor.set(.5, .5), r.container.addChild(r.challengeIcon)), r.checkBg = new Phaser.Sprite(r.game, 0, 0, "atlas_gameplay", "act-check-base.png"), r.checkBg.x = r.sprite.width / 2 - r.checkBg.width / 2 - 10, r.checkBg.y = r.sprite.height / 2 - r.checkBg.height / 2 - 10, r.checkBg.anchor.set(.5, .5), r.check = new Phaser.Sprite(r.game, 0, 0, "atlas_gameplay", "act-check.png"), r.check.x = r.sprite.width / 2 - r.checkBg.width / 2 - 10, r.check.y = r.sprite.height / 2 - r.checkBg.height / 2 - 10, r.check.anchor.set(.5, .5), r.container.addChild(r.checkBg), r.container.addChild(r.check), r.container.addChild(r.titleText), r.enterStage = r.container.create(0, 0, "enterLevelText"), r.enterStage.anchor.set(.5, 0), r.enterStage.visible = !1, r.downArrow = r.container.create(0, 0, "actDownArrow"), r.downArrow.visible = !1, r.alive = !1, r.blockType = "act", r.hellEnabled = r.checkEnableMode(), r.hangable = !0, r.scalable = !0, !r.hellEnabled && r.isHell) {
|
|
h = Game.LocalizationManager.getInstance(r.game).getSringForKey("hell_locked");
|
|
r.titleLocked = new Phaser.Text(r.game, 0, 10, h), r.titleLocked.font = "milocha", r.titleLocked.fontSize = 20, r.titleLocked.fill = "#ffffff", r.titleLocked.setShadow(1, 2, "rgba(0, 0, 0, 0.5)", 0), r.titleLocked.anchor.set(.5, .5), r.titleLocked.visible = !0, r.container.addChild(r.titleLocked)
|
|
}
|
|
return r
|
|
}
|
|
return __extends(o, l), o.prototype.toggleTickBox = function() {}, o.prototype.spawn = function(t, e) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = 140, this.height = 140, this.container.position.set(t, e), 10 == this.levelNum ? (this.width = 160, this.height = 160) : (this.width = 140, this.height = 140), this.sprite.anchor.set(.5, .5), this.sprite.visible = !0, this.titleText.position.set(0, -25), this.titleText.visible = !0, this.isHell && (this.hellEnabled ? (this.titleHardText.visible = !0, this.titleHardText.position.set(0, this.titleText.position.y + 18)) : (this.checkBg.visible = !1, this.enterStage.alpha = 0, this.downArrow.alpha = 0, this.titleText.position.set(0, -35), this.titleHardText.visible = !0, this.titleHardText.position.set(0, this.titleText.position.y + 18), this.titleLocked.position.set(0, this.titleHardText.position.y + 40))), this.enterStage.position.set(0, -25.5), this.enterStage.visible = !0, this.downArrow.visible = !0, this.downArrow.position.set(-7, 14), this.check.visible = -1 != this.level.topTime && !this.isHell || this.level.challengeCompleted && this.isHell, this.isChallenge && (this.titleText.position.y = -40), -1 != this.level.topTime ? (Constants.actFinishTime = -1, this.state = ActState.Played) : (this.state = ActState.NotPlayed, this.downArrow.visible = !0), this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - .5 * this.width, this.rightEdge = t + .5 * this.width, this.topEdge = e - .5 * this.height, this.bottomEdge = e + .5 * this.height, this.alive = !0, this.prevLand = !1;
|
|
var i = .5 * this.width,
|
|
s = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), this.width, this.height), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.topBound = new SAT.Box(new SAT.Vector(t, e), this.width, o.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), i, o.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), i, o.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), i, this.height), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), i, this.height), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), this.width, o.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-i, s - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, o.prototype.playerOffBlock = function() {
|
|
if ((!this.isHell || this.hellEnabled) && (0 < this.enterStage.alpha && (this.enterStage.alpha -= .1), this.enterStage.alpha <= 0)) {
|
|
if (!this.isChallenge) {
|
|
var t = this.isHell ? -5 - this.titleText.position.y : 0 - this.titleText.position.y;
|
|
this.titleText.position.y = this.titleText.position.y + t / 10, this.isHell && (this.titleHardText.y = this.titleText.position.y + 18)
|
|
}
|
|
this.downArrow.alpha = this.enterStage.alpha, this.isChallenge && (this.downArrow.alpha < 0 && (this.downArrow.alpha = 0), this.challengeIcon.alpha = 1 - this.downArrow.alpha)
|
|
}
|
|
}, o.prototype.playerOnBlock = function() {
|
|
if (!this.isHell || this.hellEnabled)
|
|
if (this.isChallenge) this.titleText.position.y = -40, this.enterStage.alpha < 1 && (this.enterStage.alpha += .1), this.downArrow.alpha = this.enterStage.alpha, this.challengeIcon.alpha = 1 - this.downArrow.alpha;
|
|
else {
|
|
var t = -50 - this.titleText.position.y;
|
|
Math.abs(t) < 1 ? this.titleText.position.y = -50 : this.titleText.position.y = this.titleText.position.y + t / 8, this.isHell && (this.titleHardText.position.y = this.titleText.position.y + 18), 0 === t && (this.enterStage.alpha < 1 && (this.enterStage.alpha += .1), this.downArrow.alpha = this.enterStage.alpha)
|
|
}
|
|
}, o.prototype.checkEnableMode = function() { return !this.isHell || (this.isHell ? this.level.gotGold() : void 0) }, o.prototype.update = function() { this.landed ? (this.playerOnBlock(), this.prevLand || (11 !== this.levelNum ? this.main.gameplayUI.showInfoLevel(this.level) : this.main.gameplayUI.showInfoChallenge(this.level))) : (this.playerOffBlock(), this.prevLand && this.main.gameplayUI.hideInfoLevel()), this.prevLand = !!this.landed }, o.prototype.destroy = function() { this.titleText.destroy(), this.titleText = null, this.isHell && (this.titleHardText.destroy(), this.titleHardText = null), this.enterStage.destroy(), this.enterStage = null, this.downArrow.destroy(), this.downArrow = null, this.sprite.destroy(!1), this.sprite = null, this.container.destroy(), this.container = null }, o.TOP_BOUND_HEIGHT = 12, o
|
|
}(Block),
|
|
SwimmingPool = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "swimmingPool"), s.sprite.anchor.set(.5, .5), s.sprite.alpha = .6, s.topMask = e.add.graphics(0, 0, s.layer), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) { this.xPos = t, this.yPos = e, this.width = i, this.height = s, this.sprite.position.set(t, e), this.sprite.scale.set(i / 250, s / 250), this.electric = !1, this.prevElec = !1, this.totalPolygon = new SAT.Box(new SAT.Vector(t - i / 2, e - s / 2), i, s).toPolygon(), this.topPolygon = new SAT.Box(new SAT.Vector(t - i / 2, e - s / 2), i, 12).toPolygon(), this.topMask.beginFill(16776960, .5), this.topMask.drawRect(0, 0, i, s), this.topMask.endFill(), this.topMask.position.set(t - this.width / 2, e - this.height / 2) }, t.prototype.update = function() { this.electric ? (this.topMask.visible = !0, this.prevElec = !0) : (this.topMask.visible = !1, this.prevElec = !1), this.electric = !1 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.topMask.destroy(), this.topMask = null, this.game = null, this.layer = null, this.totalPolygon = null, this.topPolygon = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Constants = function() {
|
|
function s() {}
|
|
return s.getInterstialAd = function(t, e) {
|
|
var i;
|
|
switch (t) {
|
|
case "start":
|
|
i = e ? s.iOS_AD_ID_StartInterstitial : s.Google_AD_ID_StartInterstitial;
|
|
break;
|
|
case "level":
|
|
i = e ? s.iOS_AD_ID_LevelInterstitial : s.Google_AD_ID_LevelInterstitial
|
|
}
|
|
return i
|
|
}, s.calcCurrentTime = function(t) {
|
|
var e = new Date(Date.now()),
|
|
i = new Date(t);
|
|
return i.setTime(i.getTime()), e - i
|
|
}, s.isAnHour = function(t) { return 1 == Math.floor(t / 1e3 / 60 / 60) }, s.overrideSplash = function(t) { return Fabrique.Utils.getBrandingDomain() != Fabrique.BrandingDomain.Bild || !!Fabrique.Branding.isContracted(t) }, s.GOOGLE_ID = "UA-114327842-49", s.GOOGLE_APP_NAME = "Vex 4", s.GAME_KEY = "3843c21517b3190e5f535eecbaa7971d", s.SECRET_KEY = "d4db62062535a5e78ac1a6494ad5f1ef13403bb6", s.GAME_TITLE = "vex-4", s.AdID = 201, s.iOS_AD_ID = "ca-app-pub-1394495769473752~2756650820", s.iOS_AD_ID_StartInterstitial = "ca-app-pub-1394495769473752/7186850421", s.iOS_AD_ID_LevelInterstitial = "ca-app-pub-1394495769473752/4233384021", s.Google_AD_ID = "ca-app-pub-1394495769473752~9384838844", s.Google_AD_ID_StartInterstitial = "ca-app-pub-1394495769473752/4934743354", s.Google_AD_ID_LevelInterstitial = "ca-app-pub-1394495769473752/4934743354", s.tutorialURL = "http://kizi.com/videos/u/vex-3", s.AUTO_FULLSCREEN_ENABLED = !1, s.totalDeaths = 0, s.timePlayed = 0, s.autoReset = !1, s.particleLimit = 30, s.oldControls = !1, s.blend = !0, s.waves = !0, s.parallax = !0, s.musicVolume = 1, s.effectVolume = .5, s.muted = !1, s.mutedMusic = !1, s.userRatio = 1.35, s.gameWidth = 960, s.gameHeight = 640, s.wireSparkSpeed = .15, s.levelsResetCheckPoints = [], s.gotStar = !1, s.challengeCompleted = !1, s.latestCompleted = 0, s.latestChallengeStep = 0, s.currentLevel = 1, s.actFinishTime = -1, s.pausedActTime = null, s.pausedMapTime = null, s.isPaused = !1, s.minSizeView = 640, s.zoom = 1, s.achievements = { act1: !1, act2: !1, act3: !1, act4: !1, act5: !1, act6: !1, act7: !1, act8: !1, act9: !1, star1: !1, star2: !1, star3: !1, star4: !1, star5: !1, star6: !1, star7: !1, star8: !1, star9: !1, star10: !1, challenge1: !1, challenge2: !1, challenge3: !1, challenge4: !1, challenge5: !1, challenge6: !1, challenge7: !1, challenge8: !1, challenge9: !1, perfect: !1, caretaker: !1, gasping: !1, timeflies: !1, headsup: !1, deathtycoon: !1, olympian: !1, perfectionist: !1, astronomer: !1, winner: !1, vexation: !1 }, s
|
|
}(),
|
|
Achievement = function(t, e, i, s) { this.spriteKey = t, this.type = e, this.name = i, this.description = s, this.completed = !1 },
|
|
Achievements = function() {
|
|
function t(t, e) {
|
|
this.game = e, this.main = t, this.achievements = {}, this.standardActs = [], this.hardcore = [], this.awesome = [], this.completion = [], this.standardGot = 0, this.hardcoreGot = 0, this.awesomeGot = 0, this.completionGot = 0, this.totalGot = 0, this.allMax = 0;
|
|
for (var i = 1, s = 1; s < 11; s++) this.addAchievement("act" + s, "trop_act" + s, 0, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++;
|
|
for (s = 1; s < 11; s++) this.addAchievement("star" + s, "trop_star" + s, 1, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++;
|
|
for (s = 1; s < 10; s++) this.addAchievement("challenge" + s, "trop_hard_mode" + s, 1, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++;
|
|
this.addAchievement("perfect", "trop_stuff1", 2, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("gasping", "trop_stuff3", 2, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("timeflies", "trop_stuff4", 2, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("headsup", "trop_stuff5", 2, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("deathtycoon", "trop_stuff6", 2, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("olympian", "trop_completion1", 3, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("perfectionist", "trop_completion2", 3, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("astronomer", "trop_completion3", 3, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("winner", "trop_completion4", 3, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.addAchievement("challengeRoom", "trop_completion4", 3, "ui_trophie_name_" + i, "ui_trophie_description_" + i), i++, this.tryLoadAchievements()
|
|
}
|
|
return t.prototype.addAchievement = function(t, e, i, s, o) {
|
|
var n = new Achievement(e, i, s, o);
|
|
switch (this.achievements[t] = n, i) {
|
|
case 0:
|
|
this.standardActs.push(n);
|
|
break;
|
|
case 1:
|
|
this.hardcore.push(n);
|
|
break;
|
|
case 2:
|
|
this.awesome.push(n);
|
|
break;
|
|
case 3:
|
|
this.completion.push(n)
|
|
}
|
|
this.allMax++
|
|
}, t.prototype.gotAchievement = function(t) {
|
|
var e = this.achievements[t];
|
|
if (e && !e.completed) {
|
|
switch (e.completed = !0, this.main.gameplayUI.showAchievement(e), Fabrique.Utils.isOnDevice(this.game) && SocialServicesHandler.submitAchievement(this.game, t), this.saveAchievements(), e.type) {
|
|
case 0:
|
|
this.standardGot++;
|
|
break;
|
|
case 1:
|
|
this.hardcoreGot++;
|
|
break;
|
|
case 2:
|
|
this.awesomeGot++;
|
|
break;
|
|
case 3:
|
|
this.completionGot++
|
|
}
|
|
this.totalGot++, this.main.gameplayUI.updateProgress(this.getTotalProgress())
|
|
}
|
|
}, t.prototype.saveAchievements = function() {
|
|
var t = {};
|
|
for (var e in this.achievements) {
|
|
var i = this.achievements[e];
|
|
t[e] = i.completed
|
|
}
|
|
SaveGame.getInstance().saveAchievements(t)
|
|
}, t.prototype.clearSavedData = function() { for (var t in this.achievements) { this.achievements[t].completed = !1 } SaveGame.getInstance().resetAchievements(), this.totalGot = 0, this.standardGot = 0, this.awesomeGot = 0, this.hardcoreGot = 0, this.completionGot = 0 }, t.prototype.tryLoadAchievements = function() {
|
|
var t = SaveGame.getInstance().getAchievements();
|
|
if (t) try {
|
|
var e = t;
|
|
for (var i in e) {
|
|
var s = e[i],
|
|
o = this.achievements[i];
|
|
if (void 0 === s || !o) return;
|
|
if (o.completed = s) switch (this.totalGot++, o.type) {
|
|
case 0:
|
|
this.standardGot++;
|
|
break;
|
|
case 1:
|
|
this.hardcoreGot++;
|
|
break;
|
|
case 2:
|
|
this.awesomeGot++;
|
|
break;
|
|
case 3:
|
|
this.completionGot++
|
|
}
|
|
}
|
|
}
|
|
catch (t) { return }
|
|
}, t.prototype.getStandardActsProgress = function() { return this.standardGot / this.standardActs.length }, t.prototype.getHardcoreProgress = function() { return this.hardcoreGot / this.hardcore.length }, t.prototype.getAwesomeProgress = function() { return this.awesomeGot / this.awesome.length }, t.prototype.getCompletionProgress = function() { return this.main.levels ? (this.hardcoreGot + this.main.levels.getGoldNumber() + this.main.levels.getPerfectNumber()) / (this.hardcore.length + 20) : 0 }, t.prototype.getTotalProgress = function() { return this.totalGot / this.allMax }, t
|
|
}(),
|
|
SocialServicesData = function() {
|
|
function t() {}
|
|
return t.convertTime = function(t, e) { return t.device.android ? e : 100 * Math.floor(e / 1e3) }, t.getActName = function(t, e) {
|
|
var i;
|
|
switch (t) {
|
|
case "act":
|
|
i = "10" === e ? "vexation" : t + e;
|
|
break;
|
|
case "challenge":
|
|
i = "hardcore" + e
|
|
}
|
|
return i
|
|
}, t.getSocialServiceID = function(t, e, i) { var s = e[i]; return t.device.android ? s.android : t.device.iOS ? s.ios : void 0 }, t.ACH_ACT_1 = "CgkIvqGw-MQdEAIQFQ", t.ACH_ACT_2 = "CgkIvqGw-MQdEAIQFg", t.ACH_ACT_3 = "CgkIvqGw-MQdEAIQFw", t.ACH_ACT_4 = "CgkIvqGw-MQdEAIQGA", t.ACH_ACT_5 = "CgkIvqGw-MQdEAIQGQ", t.ACH_ACT_6 = "CgkIvqGw-MQdEAIQGg", t.ACH_ACT_7 = "CgkIvqGw-MQdEAIQGw", t.ACH_ACT_8 = "CgkIvqGw-MQdEAIQHA", t.ACH_ACT_9 = "CgkIvqGw-MQdEAIQHQ", t.ACH_VEXATION = "CgkIvqGw-MQdEAIQHg", t.ACH_MINE_ = "CgkIvqGw-MQdEAIQHw", t.ACH_THANKS_BOX_ = "CgkIvqGw-MQdEAIQIA", t.ACH_ITS_THE_CLIMB_ = "CgkIvqGw-MQdEAIQIQ", t.ACH_BETWEEN_A_SAW = "CgkIvqGw-MQdEAIQIg", t.ACH_LEAP_OF_FAITH = "CgkIvqGw-MQdEAIQIw", t.ACH_KEYCHAIN = "CgkIvqGw-MQdEAIQJA", t.ACH_TAKE_THE_PLUNGE = "CgkIvqGw-MQdEAIQJQ", t.ACH_LIGHTS_OUT_ = "CgkIvqGw-MQdEAIQJg", t.ACH_OUTSIDE_THE_BOX = "CgkIvqGw-MQdEAIQJw", t.ACH_INSIDE_THE_BOX = "CgkIvqGw-MQdEAIQKA", t.ACH_ONE_STEP_AT_A_TIME = "CgkIvqGw-MQdEAIQKQ", t.ACH_DOUBLE_DOWN = "CgkIvqGw-MQdEAIQKg", t.ACH_THIRDS_THE_CHARM = "CgkIvqGw-MQdEAIQKw", t.ACH_FANTASTIC_FOUR = "CgkIvqGw-MQdEAIQLA", t.ACH_HIGH_FIVE = "CgkIvqGw-MQdEAIQLQ", t.ACH_DEMON = "CgkIvqGw-MQdEAIQLg", t.ACH_YOURE_LUCKY = "CgkIvqGw-MQdEAIQLw", t.ACH_EIGHT_TIMES_THE_CHAMP = "CgkIvqGw-MQdEAIQMA", t.ACH_NINE_LIVES = "CgkIvqGw-MQdEAIQMQ", t.ACH_PERFECT_ = "CgkIvqGw-MQdEAIQMg", t.ACH_CARETAKER = "CgkIvqGw-MQdEAIQMw", t.ACH_GASPING = "CgkIvqGw-MQdEAIQNA", t.ACH_TIME_FLIES_V20 = "CgkIvqGw-MQdEAIQNQ", t.ACH_HEADS_UP = "CgkIvqGw-MQdEAIQNg", t.ACH_DEATH_TYCOON = "CgkIvqGw-MQdEAIQNw", t.ACH_OLYMPIAN = "CgkIvqGw-MQdEAIQOA", t.ACH_PERFECTIONIST = "CgkIvqGw-MQdEAIQOQ", t.ACH_ASTRONOMER = "CgkIvqGw-MQdEAIQOg", t.ACH_WINNER = "CgkIvqGw-MQdEAIQOw", t.LEAD_ACT_1 = "CgkIvqGw-MQdEAIQAg", t.LEAD_ACT_2 = "CgkIvqGw-MQdEAIQAw", t.LEAD_ACT_3 = "CgkIvqGw-MQdEAIQBA", t.LEAD_ACT_4 = "CgkIvqGw-MQdEAIQBQ", t.LEAD_ACT_5 = "CgkIvqGw-MQdEAIQBg", t.LEAD_ACT_6 = "CgkIvqGw-MQdEAIQBw", t.LEAD_ACT_7 = "CgkIvqGw-MQdEAIQCA", t.LEAD_ACT_8 = "CgkIvqGw-MQdEAIQCQ", t.LEAD_ACT_9 = "CgkIvqGw-MQdEAIQCg", t.LEAD_ACT_1__HARDCORE = "CgkIvqGw-MQdEAIQCw", t.LEAD_ACT_2__HARDCORE = "CgkIvqGw-MQdEAIQDA", t.LEAD_ACT_3__HARDCORE = "CgkIvqGw-MQdEAIQDQ", t.LEAD_ACT_4__HARDCORE = "CgkIvqGw-MQdEAIQDg", t.LEAD_ACT_5__HARDCORE = "CgkIvqGw-MQdEAIQDw", t.LEAD_ACT_6__HARDCORE = "CgkIvqGw-MQdEAIQEA", t.LEAD_ACT_7__HARDCORE = "CgkIvqGw-MQdEAIQEQ", t.LEAD_ACT_8__HARDCORE = "CgkIvqGw-MQdEAIQEg", t.LEAD_ACT_9__HARDCORE = "CgkIvqGw-MQdEAIQEw", t.LEAD_VEXATION = "CgkIvqGw-MQdEAIQFA", t.AchToSocialID = { act1: { android: t.ACH_ACT_1, ios: "act1" }, act2: { android: t.ACH_ACT_2, ios: "act2" }, act3: { android: t.ACH_ACT_3, ios: "act3" }, act4: { android: t.ACH_ACT_4, ios: "act4" }, act5: { android: t.ACH_ACT_5, ios: "act5" }, act6: { android: t.ACH_ACT_6, ios: "act6" }, act7: { android: t.ACH_ACT_7, ios: "act7" }, act8: { android: t.ACH_ACT_8, ios: "act8" }, act9: { android: t.ACH_ACT_9, ios: "act9" }, act10: { android: t.ACH_VEXATION, ios: "vexation" }, star1: { android: t.ACH_MINE_, ios: "mine" }, star2: { android: t.ACH_THANKS_BOX_, ios: "thanks_box" }, star3: { android: t.ACH_ITS_THE_CLIMB_, ios: "its_the_climb" }, star4: { android: t.ACH_BETWEEN_A_SAW, ios: "between_a_saw" }, star5: { android: t.ACH_LEAP_OF_FAITH, ios: "leap_of_faith" }, star6: { android: t.ACH_KEYCHAIN, ios: "keychain" }, star7: { android: t.ACH_TAKE_THE_PLUNGE, ios: "take_the_plunge" }, star8: { android: t.ACH_LIGHTS_OUT_, ios: "lights_out" }, star9: { android: t.ACH_OUTSIDE_THE_BOX, ios: "outside_the_box" }, star10: { android: t.ACH_INSIDE_THE_BOX, ios: "inside_the_box" }, challenge1: { android: t.ACH_ONE_STEP_AT_A_TIME, ios: "one_step_at_a_time" }, challenge2: { android: t.ACH_DOUBLE_DOWN, ios: "double_down" }, challenge3: { android: t.ACH_THIRDS_THE_CHARM, ios: "thirds_the_charm" }, challenge4: { android: t.ACH_FANTASTIC_FOUR, ios: "fantastic_four" }, challenge5: { android: t.ACH_HIGH_FIVE, ios: "high_five" }, challenge6: { android: t.ACH_DEMON, ios: "demon" }, challenge7: { android: t.ACH_YOURE_LUCKY, ios: "youre_lucky" }, challenge8: { android: t.ACH_EIGHT_TIMES_THE_CHAMP, ios: "eight_times_the_champ" }, challenge9: { android: t.ACH_NINE_LIVES, ios: "nine_lives" }, perfect: { android: t.ACH_PERFECT_, ios: "perfect" }, caretaker: { android: t.ACH_CARETAKER, ios: "caretaker" }, gasping: { android: t.ACH_GASPING, ios: "gasping" }, timeflies: { android: t.ACH_TIME_FLIES_V20, ios: "time_flies" }, headsup: { android: t.ACH_HEADS_UP, ios: "heads_up" }, deathtycoon: { android: t.ACH_DEATH_TYCOON, ios: "death_tycoon" }, olympian: { android: t.ACH_OLYMPIAN, ios: "olympian" }, perfectionist: { android: t.ACH_PERFECT_, ios: "perfectionist" }, astronomer: { android: t.ACH_ASTRONOMER, ios: "astronomer" }, winner: { android: t.ACH_WINNER, ios: "winner" } }, t.LeaderBoardToSocialID = { act1: { android: t.LEAD_ACT_1, ios: "act1" }, act2: { android: t.LEAD_ACT_2, ios: "act2" }, act3: { android: t.LEAD_ACT_3, ios: "act3" }, act4: { android: t.LEAD_ACT_4, ios: "act4" }, act5: { android: t.LEAD_ACT_5, ios: "act5" }, act6: { android: t.LEAD_ACT_6, ios: "act6" }, act7: { android: t.LEAD_ACT_7, ios: "act7" }, act8: { android: t.LEAD_ACT_8, ios: "act8" }, act9: { android: t.LEAD_ACT_9, ios: "act9" }, hardcore1: { android: t.LEAD_ACT_1__HARDCORE, ios: "act1_hardcore" }, hardcore2: { android: t.LEAD_ACT_2__HARDCORE, ios: "act2_hardcore" }, hardcore3: { android: t.LEAD_ACT_3__HARDCORE, ios: "act3_hardcore" }, hardcore4: { android: t.LEAD_ACT_4__HARDCORE, ios: "act4_hardcore" }, hardcore5: { android: t.LEAD_ACT_5__HARDCORE, ios: "act5_hardcore" }, hardcore6: { android: t.LEAD_ACT_6__HARDCORE, ios: "act6_hardcore" }, hardcore7: { android: t.LEAD_ACT_7__HARDCORE, ios: "act7_hardcore" }, hardcore8: { android: t.LEAD_ACT_8__HARDCORE, ios: "act8_hardcore" }, hardcore9: { android: t.LEAD_ACT_9__HARDCORE, ios: "act9_hardcore" }, vexation: { android: t.LEAD_VEXATION, ios: "vexation" } }, t
|
|
}();
|
|
! function(t) {
|
|
var e = function() {
|
|
function t() {}
|
|
return t.show = function() {
|
|
var t = document.getElementById("loader");
|
|
t && (t.style.display = "block")
|
|
}, t.hide = function() {
|
|
var t = document.getElementById("loader");
|
|
t && (t.style.display = "none")
|
|
}, t
|
|
}();
|
|
t.LoaderHelper = e
|
|
}(Fabrique || (Fabrique = {})),
|
|
function(t) {
|
|
var e = function(e) {
|
|
function i() { var t = null !== e && e.apply(this, arguments) || this; return t.name = i.Name, t }
|
|
return __extends(i, e), i.prototype.create = function() { this.game.analytics.google.sendScreenView(this.name) }, i.Name = "default", i
|
|
}(Phaser.State);
|
|
t.State = e
|
|
}(Fabrique || (Fabrique = {})),
|
|
function(o) {
|
|
var t = function() {
|
|
function e(t) { this.game = t }
|
|
return e.prototype.initAdProvider = function() {
|
|
var t = new PhaserAds.AdProvider.GameDistributionAds(this.game, "80e6a5ae477f4d4fbcd1ea293d10087d");
|
|
if (this.game.ads.setAdProvider(t), o.Utils.isOnDevice(this.game)) {
|
|
var e = Constants.getInterstialAd("start", this.game.device.iOS);
|
|
this.game.ads.preloadAd(PhaserAds.AdType.interstitial, e)
|
|
}
|
|
}, e.prototype.showAd = function(e, t, i) {
|
|
var s = this;
|
|
this.game.ads.onContentPaused.addOnce(function() { s.game.analytics.google.sendScreenView("advertisement"), t && t.call(s) }), this.game.ads.onContentResumed.addOnce(function() {
|
|
if (o.Utils.isOnDevice(s.game) && i) {
|
|
var t = Constants.getInterstialAd(i, s.game.device.iOS);
|
|
s.game.ads.preloadAd(PhaserAds.AdType.interstitial, t)
|
|
}
|
|
e && e.call(s), s.game.ads.onContentPaused.removeAll(), s.game.ads.onContentResumed.removeAll()
|
|
}), o.Utils.isOnDevice(this.game) ? this.game.ads.showAd(PhaserAds.AdType.interstitial) : this.game.ads.showAd()
|
|
}, e.getInstance = function(t) { return null === e.instance && (e.instance = new e(t)), e.instance }, e.instance = null, e
|
|
}();
|
|
o.AdHandler = t
|
|
}(Fabrique || (Fabrique = {})),
|
|
function(i) {
|
|
var t = function() {
|
|
function e(t) { this.game = t }
|
|
return e.prototype.initAnalytics = function() {
|
|
var t = this;
|
|
this.game.analytics.game.setup(Constants.GAME_KEY, Constants.SECRET_KEY, version, this.game.analytics.game.createUser());
|
|
var e = Date.now();
|
|
window.addEventListener("beforeunload", function() { t.game.analytics.game.addEvent(new GA.Events.SessionEnd((Date.now() - e) / 1e3)), t.game.analytics.game.sendEvents() }), i.Utils.isOnDevice(this.game) ? this.game.analytics.google.setup(Constants.GOOGLE_ID, Constants.GOOGLE_APP_NAME, version, { storage: "none" }) : this.game.analytics.google.setup(Constants.GOOGLE_ID, Constants.GOOGLE_APP_NAME, version), this.game.analytics.game.setup(Constants.GAME_KEY, Constants.SECRET_KEY, version, new GA.User)
|
|
}, e.getInstance = function(t) { return null === e.instance && (e.instance = new e(t)), e.instance }, e.instance = null, e
|
|
}();
|
|
i.AnalyticsHandler = t
|
|
}(Fabrique || (Fabrique = {}));
|
|
var SaveGame = function() {
|
|
function e(t) { this.levels = [], this.achievements = Constants.achievements, this.game = t }
|
|
return e.getInstance = function(t) { return e.instance || (e.instance = new e(t)), e.instance }, e.prototype.init = function() {
|
|
var e = this;
|
|
this.game.storage.setNamespace("v4"), this.game.storage.getItem("sg").then(function(t) { null == t ? (e.clearAll(), e.save()) : e.restore() })
|
|
}, e.prototype.getAllValues = function() { return { options: this.getOptions(), stats: this.getStats(), latestCompleted: Constants.latestCompleted, latestChallengeStep: Constants.latestChallengeStep, levels: this.getAllLevels(), achievements: this.getAchievements(), challengeData: this.getChallengeData() } }, e.prototype.setAllValues = function(t) { this.setOptions(t.options), this.setStats(t.stats), this.setLastLevel(t.latestCompleted), this.setLastChallengeStep(t.latestChallengeStep), this.setAllLevels(t.levels), this.setAchievements(t.achievements), this.setChallengeData(t.challengeData) }, e.prototype.getOptions = function() { return { mv: Constants.musicVolume, efxv: Constants.effectVolume, ar: Constants.autoReset, pl: Constants.particleLimit, nc: Constants.oldControls, bl: Constants.blend, wv: Constants.waves, plx: Constants.parallax, mt: Constants.muted, mtm: Constants.mutedMusic } }, e.prototype.setOptions = function(t) { Constants.musicVolume = t.mv, Constants.effectVolume = t.efxv, Constants.autoReset = t.ar, Constants.particleLimit = t.pl, Constants.oldControls = t.nc, Constants.blend = t.bl, Constants.waves = t.wv, Constants.parallax = t.plx, Constants.muted = t.mt, Constants.mutedMusic = t.mtm }, e.prototype.getStats = function() { return { td: Constants.totalDeaths, tp: Constants.timePlayed } }, e.prototype.setStats = function(t) { Constants.totalDeaths = t.td, Constants.timePlayed = t.tp }, e.prototype.setLastLevel = function(t) { 11 !== t && (Constants.latestCompleted = t) }, e.prototype.setLastChallengeStep = function(t) { t > Constants.latestChallengeStep && (Constants.latestChallengeStep = t) }, e.prototype.getAllLevels = function() { return this.levels }, e.prototype.setLevel = function(t, e) {
|
|
var i = t - 1,
|
|
s = this.levels[i];
|
|
(s = e).id = t, this.levels[i] = s
|
|
}, e.prototype.setAllLevels = function(t) { this.levels = [], this.levels = t }, e.prototype.getLevel = function(t) { return this.levels[t] }, e.prototype.getAchievements = function() { return this.achievements }, e.prototype.getChallengeData = function() { return this.challengeData }, e.prototype.setAchievements = function(t) { this.achievements = t }, e.prototype.setChallengeData = function(t) { this.challengeData = t }, e.prototype.clearOptions = function() { Constants.musicVolume = 1, Constants.effectVolume = .5, Constants.autoReset = !1, Constants.particleLimit = 30, Constants.oldControls = !1, Constants.blend = !0, Constants.waves = !0, Constants.parallax = !0, Constants.muted = !1, Constants.mutedMusic = !1, this.game.device.desktop || (Constants.particleLimit = 0, Constants.blend = !1, Constants.waves = !1, Constants.parallax = !1) }, e.prototype.clearStats = function() { Constants.totalDeaths = 0, Constants.timePlayed = 0 }, e.prototype.clearLevel = function() { return { tt: -1, br: 4, gs: !1, cc: !1, fn: !1 } }, e.prototype.clearAllLevels = function() {
|
|
this.levels = [];
|
|
for (var t = 0; t <= 10; t++) {
|
|
var e = this.clearLevel();
|
|
e.id = t + 1, this.levels.push(e)
|
|
}
|
|
this.latestCompleted = Constants.latestCompleted
|
|
}, e.prototype.clearChallengeData = function() { this.challengeData = { deaths: 0, time: 0, floor: 0 } }, e.prototype.clearAchievements = function() { this.achievements = Constants.achievements }, e.prototype.saveOptions = function(t) { this.save() }, e.prototype.resetOptions = function() { this.clearOptions(), this.save() }, e.prototype.saveStats = function(t) { this.save() }, e.prototype.resetStats = function() { this.clearStats(), this.save() }, e.prototype.saveLevels = function(t, e) { this.setLevel(t, e), this.setLastLevel(t), this.save() }, e.prototype.saveChallengeStep = function(t) { this.setLastChallengeStep(t), this.save() }, e.prototype.resetLevels = function() { this.clearAllLevels(), this.setLastLevel(0), this.save() }, e.prototype.saveAchievements = function(t) { this.setAchievements(t), this.save() }, e.prototype.resetAchievements = function() { this.clearAchievements(), this.save() }, e.prototype.setChallengeStep = function(t) { this.setChallengeData(t), this.save() }, e.prototype.clearAll = function() { this.clearOptions(), this.clearStats(), this.clearAllLevels(), this.clearChallengeData(), this.save() }, e.prototype.save = function() {
|
|
var t = JSON.stringify(this.getAllValues()),
|
|
e = this.hash([t.options, t.stats, t.latestCompleted, t.latestChallengeStep, t.levels, t.achievements, t.challengeData].join("-"));
|
|
this.game.storage.setItem("sg", t), this.game.storage.setItem("h", e)
|
|
}, e.prototype.restore = function() {
|
|
var e = this;
|
|
this.game.storage.getItem("sg").then(function(t) { e.setAllValues(JSON.parse(t)) })
|
|
}, e.prototype.load = function() { return this.game.storage.getItem("sg") }, e.prototype.hash = function(t) { var e, i, s = 0; if (0 === t.length) return s.toString(); for (e = 0, i = t.length; e < i; e++) s = (s << 5) - s + t.charCodeAt(e), s |= 0; return s.toString() }, e.prototype.checkStoredHash = function() {
|
|
var e = this,
|
|
i = this.getAllValues();
|
|
this.game.storage.getItem("h").then(function(t) { e.hash([i.options, i.stats, i.latestCompleted, i.latestChallengeStep, i.levels, i.achievements].join("-")) })
|
|
}, e
|
|
}(),
|
|
SocialServicesHandler = function() {
|
|
function t() {}
|
|
return t.init = function(t) { socialService = this.getSocialInterface(t) }, t.getSocialInterface = function(t) { return t.device.android ? (Cocoon.Social.GooglePlayGames.init({}), Cocoon.Social.GooglePlayGames.getSocialInterface()) : t.device.iOS ? (Cocoon.Social.GameCenter.init({}), Cocoon.Social.GameCenter.getSocialInterface()) : void 0 }, t.login = function(t) { socialService.login(function(t, e) {}) }, t.submitAchievement = function(t, e) {
|
|
var i = SocialServicesData.getSocialServiceID(t, SocialServicesData.AchToSocialID, e);
|
|
socialService.submitAchievement(i, function(t) {})
|
|
}, t.submitScore = function(t, e, i, s) {
|
|
var o = SocialServicesData.convertTime(t, e),
|
|
n = SocialServicesData.getActName(i, s),
|
|
a = SocialServicesData.getSocialServiceID(t, SocialServicesData.LeaderBoardToSocialID, n);
|
|
socialService.submitScore(o, function(t) {}, { leaderboardID: a })
|
|
}, t.showAchievements = function(t) { socialService.showAchievements(function(t) {}) }, t.showLeaderboards = function(t) { socialService.showLeaderboard(function(t) {}) }, t
|
|
}(),
|
|
Zipline = function(a) {
|
|
function t(t, e, i, s, o) { var n = a.call(this, t) || this; return s.y < o.y ? (n.startPos = s, n.endPos = o, n.topEdge = s.y, n.bottomEdge = o.y) : (n.startPos = o, n.endPos = s, n.topEdge = o.y, n.bottomEdge = s.y), n.startPos.x < n.endPos.x ? (n.direction = "right", n.leftEdge = n.startPos.x, n.rightEdge = n.endPos.x) : (n.direction = "left", n.leftEdge = n.endPos.x, n.rightEdge = n.startPos.x), n.width = Math.abs(n.endPos.x - n.startPos.x), n.height = Math.abs(n.endPos.y - n.startPos.y), n.scope = n.height / n.width, n.wire = e.add.graphics(0, 0, i), n.wire.lineStyle(2, 16737792), n.wire.moveTo(n.startPos.x, n.startPos.y), n.wire.lineTo(n.endPos.x, n.endPos.y), n.hitPolygon = new SAT.Polygon(new SAT.Vector(n.startPos.x, n.startPos.y), [new SAT.Vector(0, 5), new SAT.Vector(n.endPos.x - n.startPos.x, n.endPos.y - n.startPos.y + 5), new SAT.Vector(n.endPos.x - n.startPos.x, n.endPos.y - n.startPos.y - 5), new SAT.Vector(0, -5)]), n }
|
|
return __extends(t, a), t.prototype.destroy = function() { this.wire.destroy(), this.wire = null, this.hitPolygon = null, this.startPos = null, this.endPos = null, a.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Vector = SAT.Vector,
|
|
ZiplinePole = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "ziplinePole"), s.sprite.autoCull = !0, s.sprite.anchor.set(3 / 9.8, 29.2 / 64.25), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e) }, t.prototype.attach = function(t) { return ((this.attachedZiplinePole = t).attachedZiplinePole = this).zipline = new Zipline(this.main, this.game, this.layer, new Point(this.xPos, this.yPos - 25), new Point(t.xPos, t.yPos - 25)), t.zipline = this.zipline, this.zipline }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.game = null, this.layer = null, this.attachedZiplinePole = null, this.zipline = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Checkpoint = function(n) {
|
|
function t(t, e, i, s) { var o = n.call(this, t) || this; return o.game = e, o.layer = i, o.container = e.add.group(o.layer), (o.floating = s) ? (o.sprite = o.container.create(0, 0, "checkpointSwimming"), o.sprite.anchor.set(.5, .5)) : (o.sprite = o.container.create(0, 0, "checkpoint"), o.sprite.anchor.set(8 / 21.15, 17 / 55)), o.sprite.autoCull = !0, o }
|
|
return __extends(t, n), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.startY = e, this.container.position.set(t, e), this.boxPolygon = new SAT.Box(new SAT.Vector(t - 60, e - 40), 120, 80).toPolygon(), this.state = 0, this.floatRad = 0 }, t.prototype.trigger = function() {
|
|
this.sprite.frame = 1, this.state = 1;
|
|
for (var t = 0; t < 10; t++) this.main.createColorParticle(this.xPos, this.yPos, 10 * Math.random() - 5, -6 - 4 * Math.random(), 65280);
|
|
this.main.checkpointText.spawn(this.xPos, this.yPos - 30), this.main.dark && this.main.goLight(), this.main.sounds.playSound("ding"), this.main.checkpointTriggered(this)
|
|
}, t.prototype.gray = function() { this.sprite.frame = 2, this.state = 2 }, t.prototype.resetLevel = function() { this.sprite.frame = 0, this.state = 0 }, t.prototype.update = function() { this.floating && (this.floatRad += .1, this.floatRad %= 8 * Math.PI, this.sprite.position.y = 25 + 10 * Math.sin(this.floatRad / 4), this.sprite.rotation = Math.cos(this.floatRad / 4) * Math.PI / 8) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.boxPolygon = null, this.container.destroy(), this.container = null, n.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
CheckPointText = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.alive = !1, s.sprite = i.create(0, 0, "checkpointText"), s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.alive = !0, this.displayTime = 60, this.moveDist = 0 }, t.prototype.update = function() { this.alive && 0 < this.displayTime && (-30 < this.moveDist && (this.moveDist -= 2), this.sprite.position.y = this.yPos + this.moveDist, this.displayTime--, this.displayTime <= 0 && (this.sprite.visible = !1, this.alive = !1)) }, t
|
|
}(Entity),
|
|
Pole = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "pole"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.redSection = i.create(0, 0, "poleRedSection"), s.redSection.anchor.set(0, .5), s.redSection.autoCull = !0, s.redSection.visible = !1, s.sprite.anchor.set(.5, .5), s.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 10, 10).toPolygon(), s.hitBoxPolygon.setOffset(new SAT.Vector(-5, -5)), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.redSection.position.set(t, e), this.redSection.alpha = 0, this.redSection.visible = !0, this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e }, t.prototype.update = function() { this.main.player.currentPole != this && (this.redSection.alpha -= .5 * this.redSection.alpha) }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.redSection.destroy(), this.redSection = null, this.hitBoxPolygon = null, this.game = null, this.layer = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Star = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "star"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 40, 40).toPolygon(), s.hitBoxPolygon.setOffset(new SAT.Vector(-20, -20)), s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.main.currentLevel.gotStar || (this.xPos = t, this.yPos = e, this.sprite.visible = !0, this.sprite.position.set(t, e), this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e, this.alive = !0) }, t.prototype.getStar = function() { this.main.currentLevel.gotStar = !0, this.main.achievements.gotAchievement("star" + this.main.currentLevelID), this.main.levels.checkAstronomer() && this.main.achievements.gotAchievement("astronomer"), this.main.sounds.playSound("starPickup"), this.main.currentLevel.saveLevel(), this.die() }, t.prototype.die = function() { this.alive = !1, this.sprite.visible = !1 }, t.prototype.reset = function() {}, t.prototype.resetLevel = function() {}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.hitBoxPolygon = null, this.game, this.layer, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Key = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.init(), s.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 20, 40).toPolygon(), s.hitBoxPolygon.setOffset(new SAT.Vector(-10, -20)), s.alive = !1, s.lineColor = 16763904, s }
|
|
return __extends(t, o), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "key"), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5), this.lineGraphic = this.game.add.graphics(0, 0, this.layer) }, t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.xVelocity = 0, this.yVelocity = 0, this.sprite.position.set(t, e), this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e, this.alive = !0, this.used = !1, this.keyNum = 0, this.saveUse = !1, this.following = !1, this.rad = 0 }, t.prototype.useKey = function() { this.used = !0, this.lineGraphic.clear(), this.sprite.visible = !1, this.alive = !1 }, t.prototype.followPlayer = function() {
|
|
var t, e, i = 10 * (this.keyNum - 1);
|
|
this.rad = -4 * this.player.xVelocity * Math.PI / 180, this.yVelocity < 0 && (this.yVelocity += .5), this.yPos += this.yVelocity, e = this.player.swimming ? (t = this.player.xPos, this.player.yPos - i) : (t = "right" === this.player.facing ? this.player.xPos - 30 : this.player.xPos + 30, this.player.yPos - 6 - i);
|
|
var s = t - this.xPos,
|
|
o = e - this.yPos;
|
|
this.xPos += s / 5, this.yPos += o / 5, Math.abs(s) < 1 && (this.xPos = t), Math.abs(o) < 1 && (this.yPos = e), this.hitBoxPolygon.pos.x = this.xPos, this.hitBoxPolygon.pos.y = this.yPos
|
|
}, t.prototype.runCollisions = function() { for (var t = 0, e = this.main.blocks; t < e.length; t++) { var i = e[t]; if (i.alive) { if (SAT.testPolygonPolygon(i.topBoundPolygon, this.hitBoxPolygon)) { this.player.xVelocity < 5 ? this.yVelocity = this.player.xVelocity * this.player.xVelocity * -.2 : this.yVelocity = -5, this.yPos = i.topEdge - 20, this.hitBoxPolygon.pos.y = this.yPos; continue } if (SAT.testPolygonPolygon(i.rightBoundPolygon, this.hitBoxPolygon)) { this.xPos = i.rightEdge + 11; continue } if (SAT.testPolygonPolygon(i.leftBoundPolygon, this.hitBoxPolygon)) { this.xPos = i.leftEdge - 11; continue } SAT.testPolygonPolygon(i.bottomBoundPolygon, this.hitBoxPolygon) && (this.yVelocity *= -1, this.yPos = i.bottomEdge + 21) } } }, t.prototype.drawLineToPlayer = function() { this.lineGraphic.clear(), this.lineGraphic.lineStyle(2, this.lineColor), this.lineGraphic.moveTo(this.xPos, this.yPos), this.player.currentPole ? this.lineGraphic.lineTo(this.player.xPos, this.player.yPos - 31) : this.player.crouching ? this.lineGraphic.lineTo(this.player.xPos, this.player.yPos - 6) : this.lineGraphic.lineTo(this.player.xPos, this.player.yPos - 16) }, t.prototype.follow = function() { this.following = !0 }, t.prototype.update = function() { this.alive && (this.player = this.main.player, this.used ? .1 < this.sprite.scale.x ? (this.sprite.scale.x -= .1, this.sprite.scale.y = this.sprite.scale.x, this.rad -= 5 * Math.PI / 180, this.sprite.rotation = this.rad) : (this.alive = !1, this.sprite.visible = !1) : this.following && (this.followPlayer(), this.runCollisions(), this.drawLineToPlayer(), this.updatePositions())) }, t.prototype.die = function() { this.alive = !1, this.sprite.visible = !1 }, t.prototype.reset = function() { this.used || (this.xPos = this.startX, this.yPos = this.startY, this.updatePositions(), this.following && (this.following = !1, this.lineGraphic.clear())) }, t.prototype.resetLevel = function() { this.xPos = this.startX, this.yPos = this.startY, this.updatePositions(), this.sprite.scale.set(1, 1), this.used = !1, this.alive = !0, this.sprite.visible = !0, this.following = !1 }, t.prototype.updatePositions = function() { this.sprite.position.set(this.xPos, this.yPos), this.hitBoxPolygon.pos.x = this.xPos, this.hitBoxPolygon.pos.y = this.yPos }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.hitBoxPolygon = null, this.lineGraphic.destroy(), this.lineGraphic = null, this.game = null, this.layer = null, this.player = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
WindBlaster = function(h) {
|
|
function t(t, e, i) {
|
|
var s = h.call(this, t) || this;
|
|
s.game = e, s.layer = i, s.container = e.add.group(i), s.windGraphics = [];
|
|
var o = e.make.graphics(0, 0);
|
|
o.lineStyle(1, 2236962), o.moveTo(0, 0), o.lineTo(27, 0);
|
|
var n = o.generateTexture();
|
|
o.destroy();
|
|
for (var a = 0; a < 6; a++) {
|
|
var r = s.game.add.sprite(0, 0, n, null, s.container);
|
|
r.visible = !1, s.windGraphics.push(r)
|
|
}
|
|
return s.sprite = s.container.create(0, 0, "windBlaster"), s.sprite.autoCull = !0, s.sprite.anchor.set(0, .5), s.fanSprite = e.add.sprite(0, 0, "windFan"), s.fanSprite.anchor.set(0, .5), s.fanSprite.animations.add("fan"), s.fanSprite.play("fan", null, !0), s.sprite.addChild(s.fanSprite), s.fanMask = new SAT.Box(new SAT.Vector(0, 0), 180, 50).toPolygon(), s.fanMask.setOffset(new SAT.Vector(0, -25)), s.alive = !1, s
|
|
}
|
|
return __extends(t, h), t.prototype.spawn = function(t, e, i) {
|
|
this.xPos = t, this.yPos = e, this.container.position.set(t, e), this.container.angle = i, this.rotation = i, this.fanMask.pos.x = t, this.fanMask.pos.y = e, this.fanMask.setAngle(i * Math.PI / 180), this.alive = !0;
|
|
for (var s = this.inc = 0, o = this.windGraphics; s < o.length; s++) {
|
|
var n = o[s];
|
|
n.position.set(130 * Math.random(), 46 * Math.random() - 23), n.visible = !0
|
|
}
|
|
}, t.prototype.update = function() {
|
|
var t = this.main.player;
|
|
if (t && t.alive)
|
|
if (SAT.testPolygonPolygon(this.fanMask, this.main.player.totalPolygon)) {
|
|
var e = this.rotation * Math.PI / 180,
|
|
i = .15 * Math.sin(e);
|
|
i < -.12 && (this.inc = Math.max(2, this.inc)), this.main.player.yVelocity += .25 * Math.sin(e) * this.inc, this.main.player.xVelocity += .25 * Math.cos(e) * this.inc, i < -.12 && this.main.player.yPos > this.yPos - 5 && (this.main.player.yPos = this.yPos - 5, this.main.player.yVelocity = -4, this.main.player.updateHitBoxesPos(), this.main.player.falling = !0), this.inc < 2.5 ? this.inc += .25 : this.inc = 2.5
|
|
}
|
|
else this.inc -= .25, this.inc < 0 && (this.inc = 0);
|
|
for (var s = 0, o = this.windGraphics; s < o.length; s++) {
|
|
var n = o[s];
|
|
n.position.x += 6, n.alpha -= .05, 130 < n.position.x && (n.position.x = 0, n.position.y = 46 * Math.random() - 23, n.alpha = 1)
|
|
}
|
|
}, t.prototype.die = function() { this.alive = !1, this.container.visible = !1 }, t.prototype.destroy = function() { this.container.destroy(), this.container = null, this.fanSprite.destroy(), this.fanSprite = null; for (var t = 0, e = this.windGraphics; t < e.length; t++) { e[t].destroy(!0, !0) } h.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
FinishPortal = function(o) {
|
|
function n(t, e, i) { var s = o.call(this, t) || this; return s.particleSpawnRate = 3, s.game = e, s.layer = i, s.sprite = i.create(0, 0, "finishPortal"), s.sprite.autoCull = !0, s.sprite.animations.add("animate"), s.sprite.animations.play("animate", 30, !0), s.sprite.anchor.set(.5, .5), s.main.options.blend && (n.BlurFilterX || ((n.BlurFilterX = e.add.filter("BlurX")).blur = 20), n.BlurFilterY || ((n.BlurFilterY = e.add.filter("BlurY")).blur = 20), s.sprite.filters = [n.BlurFilterX, n.BlurFilterY]), s.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 60, 60).toPolygon(), s.hitBoxPolygon.setOffset(new SAT.Vector(-30, -30)), s }
|
|
return __extends(n, o), n.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e, this.particleTimer = 0 }, n.prototype.update = function() {
|
|
this.particleTimer++, this.particleTimer > this.particleSpawnRate && (this.main.createColorParticle(this.xPos - 80 + 160 * Math.random(), this.yPos - 80 + 160 * Math.random(), 0, 0, 4649252, 4, !1), this.particleTimer = 0);
|
|
for (var t = 0, e = this.main.particles; t < e.length; t++) {
|
|
var i = e[t];
|
|
if (!i.alive) return;
|
|
var s = Math.pow(i.xPos - this.xPos, 2) + Math.pow(i.yPos - this.yPos, 2);
|
|
s < 62500 && (s < 2500 && (i.fadeTime = 150, i.multAlpha(.5)), i.yPos < this.yPos ? i.yVelocity += .75 : i.yPos > this.yPos && (i.yVelocity -= .75), i.xPos < this.xPos ? i.xVelocity += .75 : i.xPos > this.xPos && (i.xVelocity -= .75))
|
|
}
|
|
}, n.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.hitBoxPolygon = null, o.prototype.destroy.call(this) }, n
|
|
}(Entity),
|
|
HazardStrips = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "hazardStrips"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.alive = !0 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
TimedKey = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.lineColor = 16711680, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { o.prototype.spawn.call(this, t, e), this.timer = 0 }, t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "timedKey"), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5), this.lineGraphic = this.game.add.graphics(0, 0, this.layer) }, t.prototype.follow = function() { this.following = !0, this.timer = 0 }, t.prototype.update = function() { this.following && !this.used && (this.timer >= t.TIMER_MAX ? (this.main.player.loseKey(this), this.reset()) : this.timer++), o.prototype.update.call(this) }, t.TIMER_MAX = 180, t
|
|
}(Key),
|
|
CircularCannon = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.container = e.add.group(i), s.baseSprite = s.container.create(0, 0, "cannonBase"), s.baseSprite.autoCull = !0, s.baseSprite.anchor.set(.5, .5), s.tubeSprite = s.container.create(0, 0, "cannonTube"), s.tubeSprite.autoCull = !0, s.tubeSprite.anchor.set(3 / 37, .5), s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.container.position.set(t, e), this.alive = !0, this.rad = 0, this.cannonSpeed = 4 * Math.PI / 180, this.firing = !1, this.power = 15 }, t.prototype.fire = function() {
|
|
var t = this.main.player;
|
|
t.currentCannon = null;
|
|
var e = Math.cos(this.rad) * this.power,
|
|
i = Math.sin(this.rad) * this.power;
|
|
t.swimming ? t.xVelocity = e : t.forcedXVelocity = e, t.yVelocity = i, t.xPos = this.xPos + 80 * Math.cos(this.rad), t.yPos = this.yPos + 80 * Math.sin(this.rad), t.rotationDest = 0, this.main.sounds.playSound("cannonFire");
|
|
for (var s = 0; s < 10; s++) this.main.createColorParticle(t.xPos, t.yPos, e * (Math.random() + .25), i * (Math.random() + .25), 16759552, 4);
|
|
t.swimming || (t.falling = !0, t.setJump()), t.container.parent.removeChild(t.container), this.main.playerUnderLayer.addChild(t.container), t.updateHitBoxesPos(), this.firing = !1
|
|
}, t.prototype.update = function() {
|
|
var t = this.main.player;
|
|
this.firing ? (this.tubeSprite.scale.x -= .15 * (this.tubeSprite.scale.x - .75), this.tubeSprite.scale.y -= .15 * (this.tubeSprite.scale.y - 1.35), this.tubeSprite.scale.x < .9 && this.fire()) : (this.tubeSprite.scale.x -= .3 * (this.tubeSprite.scale.x - 1), this.tubeSprite.scale.y -= .3 * (this.tubeSprite.scale.y - 1), t.currentCannon !== this ? this.rad = Math.atan2(t.yPos - this.yPos, t.xPos - this.xPos) : (this.rad += this.cannonSpeed, this.rad %= 360), this.tubeSprite.rotation = this.rad)
|
|
}, t.prototype.die = function() { this.alive = !1, this.container.visible = !1 }, t.prototype.destroy = function() { this.baseSprite.destroy(), this.baseSprite = null, this.tubeSprite.destroy(), this.tubeSprite = null, this.container.destroy(), this.container = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
BreatheBlaster = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "breatheBlaster"), s.sprite.anchor.set(1, .5), s.sprite.autoCull = !0, s.sprite.visible = !1, s.sprite.scale.set(1, .5), s.alive = !1, s.hitPoly = new SAT.Box(new SAT.Vector(0, 0), 100, 50).toPolygon(), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.angle = i, this.sprite.visible = !0, this.alive = !0, this.rad = i * Math.PI / 180, this.hitPoly.pos.x = t, this.hitPoly.pos.y = e, this.hitPoly.setAngle(i * Math.PI / 180) }, t.prototype.update = function() {
|
|
if (Math.random() < .25) {
|
|
var t = 4 * Math.random(),
|
|
e = this.rad - 2 + 4 * Math.random();
|
|
this.main.createColorParticle(this.xPos, this.yPos, Math.cos(e) * t, Math.sin(e) * t, 3394815, 4, !0, !0, 100)
|
|
}
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this), this.game = null, this.layer = null }, t
|
|
}(Entity),
|
|
LightSwitch = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "lightSwitch"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 20, 20).toPolygon(), s.hitBoxPolygon.setOffset(new SAT.Vector(-10, -10)), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Wire = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "wire"), s.sprite.autoCull = !0, s.sprite.visible = !1, s.sprite.anchor.set(1, .5), s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) { this.xPos = t, this.yPos = e, this.rad = (i - 90) * Math.PI / 180, this.sprite.position.set(t + 25 * Math.cos(this.rad), e + 25 * Math.sin(this.rad)), this.sprite.rotation = this.rad, this.sprite.visible = !0, this.alive = !0 }, t.prototype.resetLevel = function() { this.sprite.scale.x = 1 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.game = null, this.layer = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
Cable = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t) || this; return s.game = e, s.layer = i, s.sprite = new Phaser.TileSprite(s.game, 0, 0, 4, 0, "cable"), i.add(s.sprite), s.sprite.anchor.x = .5, s.sprite.autoCull = !0, s.sprite.visible = !1, s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) { this.xPos = t, this.yPos = e, this.sprite.height = i, this.sprite.position.set(t, e), this.sprite.visible = !0, this.alive = !0 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t
|
|
}(Entity),
|
|
PressDown = function() {
|
|
function t(t) { this.parentGroup = t, this.blinkingImg = this.parentGroup.create(0, -50, "pressDown"), this.blinkingImg.anchor.set(.5, .5), this.blinkingImg.visible = !1, this.pressDownTimer = 60, this.showPressDown = !1 }
|
|
return t.prototype.blink = function() { this.showPressDown ? (this.pressDownTimer <= 0 ? (this.blinkingImg.visible = !this.blinkingImg.visible, this.pressDownTimer = 15) : this.pressDownTimer--, this.parentGroup.scale.x < 0 ? this.blinkingImg.scale.x = -1 : this.blinkingImg.scale.x = 1) : (this.blinkingImg.visible = !1, this.pressDownTimer = 60) }, t
|
|
}(),
|
|
hubArrows = [],
|
|
levelData = { levelhub: [{ type: "spawnPoint", x: 579.45, y: 1932.75 }, { type: "spike10x", x: 3005.65, y: 1273.95, rotation: 90 }, { type: "spike", x: 2843.25, y: 1332.8, rotation: 180 }, { type: "spike", x: 2854.3, y: 1332.8, rotation: 180 }, { type: "spike", x: 2865.3, y: 1332.8, rotation: 180 }, { type: "checkpoint", x: 3110.7, y: 1324.3 }, { type: "spike10x", x: 3185.6, y: 1354, rotation: 0 }, { type: "basicBlock", x: 3104.35, y: 1411.9, width: 681.9, height: 100 }, { type: "buzzsawOnStick", x: 2921.4, y: 1198.8, rotation: -90 }, { type: "spike30x", x: 2912.7, y: 1003.85, rotation: 0 }, { type: "basicBlock", x: 2904.55, y: 1056.2, width: 358.4, height: 89 }, { type: "basicBlock", x: 2737.55, y: 1026.4, width: 81.8, height: 308.3 }, { type: "basicBlock", x: 2737.55, y: 1792.3, width: 81.8, height: 1091.6 }, { type: "spike30x", x: 3156.65, y: 1095.35, rotation: 90 }, { type: "spike10x", x: 3282.8, y: 878.9, rotation: 180 }, { type: "spike10x", x: 3099.35, y: 827.75, rotation: 180 }, { type: "spike10x", x: 3098.3, y: 941.6, rotation: 0 }, { type: "spike10x", x: 3279.75, y: 987.75, rotation: 0 }, { type: "blockedWall", x: 2009.55, y: 649.25, width: 443.65, height: 63.65, rotation: 90, actnum: 9 }, { type: "bouncingBuzzsaw", x: 1551.65, y: 735.35, width: 54.7 }, { type: "bouncingBuzzsaw", x: 1414.6, y: 751.35, width: 54.7 }, { type: "blockedWall", x: 1815, y: 502.75, width: 63.65, height: 443.65, rotation: 0, actnum: 8 }, { type: "basicBlock", x: 1812.55, y: 735, width: 100, height: 281 }, { type: "blockedWall", x: 970.7, y: 525.45, width: 63.65, height: 443.65, rotation: 0, actnum: 7 }, { type: "buzzsaw", x: 721.95, y: 556.95, width: 101, height: 102.2 }, { type: "checkpoint", x: 760.5, y: 834 }, { type: "buzzsawHorizontal", x: 894.95, y: 1001.4 }, { type: "blockedWall", x: 872, y: 916.25, width: 443.65, height: 63.65, rotation: -90, actnum: 6 }, { type: "basicBlock", x: 515.05, y: 922, width: 500, height: 100 }, { type: "lockBlock", x: 976, y: 1171, width: 100.05, height: 100 }, { type: "blockedWall", x: 1127.6, y: 1078.55, width: 63.65, height: 443.65, rotation: 0, actnum: 5 }, { type: "basicBlock", x: 1651.25, y: 922, width: 1252.6, height: 100 }, { type: "spike", x: 1902.4, y: 1170, rotation: 90 }, { type: "spike", x: 1902.35, y: 1158.9, rotation: 90 }, { type: "spike", x: 1902.35, y: 1148, rotation: 90 }, { type: "spike", x: 1902.35, y: 1136.9, rotation: 90 }, { type: "spike", x: 1902.35, y: 1191.05, rotation: 90 }, { type: "spike", x: 1902.35, y: 1180.05, rotation: 90 }, { type: "spike", x: 2165.5, y: 1233.9, rotation: -90 }, { type: "spike", x: 2165.5, y: 1244.95, rotation: -90 }, { type: "spike", x: 2165.5, y: 1255.95, rotation: -90 }, { type: "spike", x: 2165.5, y: 1267, rotation: -90 }, { type: "spike", x: 2165.5, y: 1212.85, rotation: -90 }, { type: "spike", x: 2165.5, y: 1223.9, rotation: -90 }, { type: "spike30x", x: 1457.25, y: 1707.05, rotation: 0 }, { type: "buzzsaw", x: 2270.55, y: 1172.5, width: 101, height: 102.2 }, { type: "fallingSpike", x: 2230.9, y: 1280.55, rotation: 180 }, { type: "fallingSpike", x: 2241.95, y: 1280.55, rotation: 180 }, { type: "fallingSpike", x: 2252.95, y: 1280.55, rotation: 180 }, { type: "fallingSpike", x: 2264, y: 1280.55, rotation: 180 }, { type: "shurikanSpawner", x: 2120.3, y: 1400, rotation: 89.99563598632812 }, { type: "pushBlock", x: 2018.15, y: 1487.25, width: 70, height: 69.9 }, { type: "checkpoint", x: 1925, y: 1516.35 }, { type: "ziplinePole", x: 1591.3, y: 1097.55 }, { type: "ziplinePole", x: 1186.7, y: 1186.9 }, { type: "bounceBlock", x: 2168.85, y: 2305.4, width: 50, height: 50 }, { type: "basicBlock", x: 1754.85, y: 2282.45, width: 100, height: 100 }, { type: "horizontalBlock", x: 2208.25, y: 1964.85, width: 45.9, height: 45.9 }, { type: "buzzsaw", x: 1607.75, y: 2069.95, width: 93, height: 94.15 }, { type: "buzzsaw", x: 1811.65, y: 1960.3, width: 93, height: 94.15 }, { type: "blockedWall", x: 1849.65, y: 1390.25, width: 63.65, height: 443.65, rotation: 0, actnum: 4 }, { type: "blockedWall", x: 2018.75, y: 1783, width: 63.65, height: 443.65, rotation: 0, actnum: 3 }, { type: "basicBlock", x: 2057.35, y: 1604.4, width: 499, height: 100 }, { type: "checkpoint", x: 1968.2, y: 1776.95 }, { type: "spike10x", x: 1301.6, y: 1764.95, rotation: -90 }, { type: "spike10x", x: 1262.9, y: 1763.55, rotation: 90 }, { type: "basicBlock", x: 1456.15, y: 1764.95, width: 295, height: 100.05 }, { type: "fallingBlock", x: 634, y: 2216.25, width: 50, height: 50 }, { type: "fallingBlock", x: 1036, y: 2216.25, width: 50, height: 50 }, { type: "buzzsaw", x: 634.2, y: 2331.35, width: 101, height: 102.2 }, { type: "buzzsaw", x: 710, y: 2331.35, width: 101, height: 102.2 }, { type: "buzzsaw", x: 788.6, y: 2331.35, width: 101, height: 102.2 }, { type: "buzzsaw", x: 864.4, y: 2331.35, width: 101, height: 102.2 }, { type: "buzzsaw", x: 949, y: 2331.35, width: 101, height: 102.2 }, { type: "buzzsaw", x: 1024.8, y: 2331.35, width: 101, height: 102.2 }, { type: "ziplinePole", x: 1650.8, y: 1620.3 }, { type: "ziplinePole", x: 1246.2, y: 1557.45 }, { type: "checkpoint", x: 1045.2, y: 1555.35 }, { type: "basicBlock", x: 235, y: 1170.45, width: 470, height: 2340.9 }, { type: "blockedWall", x: 1204.05, y: 1479.8, width: 63.65, height: 443.65, rotation: 0, actnum: 2 }, { type: "blockedWall", x: 988.95, y: 1469.15, width: 63.65, height: 443.65, rotation: 0, actnum: 1 }, { type: "bounceBlock", x: 1130.5, y: 2166.25, width: 75, height: 75 }, { type: "basicBlock", x: 705.05, y: 1642.3, width: 190, height: 100 }, { type: "basicBlock", x: 585, y: 2001.35, width: 232, height: 100.05 }, { type: "basicBlock", x: 2488.75, y: 1605.35, width: 437.8, height: 1466.2 }, { type: "buzzsaw", x: 520.55, y: 418.5, width: 101, height: 102.2 }, { type: "basicBlock", x: 1370, y: 209.05, width: 2432, height: 420.6 }, { type: "basicBlock", x: 875, y: 1951.25, width: 150, height: 200.1 }, { type: "basicBlock", x: 1e3, y: 1822.4, width: 102, height: 458 }, { type: "basicBlock", x: 849, y: 1692.35, width: 100, height: 200 }, { type: "basicBlock", x: 750, y: 2026.4, width: 100, height: 50 }, { type: "spike10x", x: 749.6, y: 1993.5, rotation: 0 }, { type: "basicBlock", x: 1205, y: 1893, width: 100, height: 602 }, { type: "basicBlock", x: 1158, y: 2261.45, width: 195, height: 140 }, { type: "fallingBlock", x: 835, y: 2216.25, width: 50, height: 50 }, { type: "basicBlock", x: 1397.55, y: 2579.05, width: 2761.8, height: 497.3 }, { type: "checkpoint", x: 1070.5, y: 2153.25 }, { type: "basicBlock", x: 1652.7, y: 1734.95, width: 100, height: 160 }, { type: "actBlock", actNum: "1", x: 540, y: 1623.35 }, { type: "actBlock", actNum: "2", x: 539.95, y: 2262.35 }, { type: "rightSlope", x: 1781.7, y: 1734.95, width: 160, height: 160, rotation: 0 }, { type: "actBlock", actNum: "3", x: 1326, y: 2010 }, { type: "basicBlock", x: 1811.7, y: 1864.25, width: 100, height: 100 }, { type: "basicBlock", x: 1444.05, y: 2088.5, width: 100, height: 299 }, { type: "basicBlock", x: 1739, y: 2188, width: 508, height: 100 }, { type: "basicBlock", x: 1999, y: 2026, width: 100, height: 424 }, { type: "actBlock", actNum: "4", x: 1875.25, y: 2400 }, { type: "swimmingPool", x: 1721.7, y: 2048.45, width: 455.5, height: 179.1 }, { type: "basicBlock", x: 1981.75, y: 1380.4, width: 373.7, height: 100 }, { type: "basicBlock", x: 1843.85, y: 1280.9, width: 100, height: 299 }, { type: "basicBlock", x: 2097.8, y: 1964.25, width: 100, height: 100 }, { type: "basicBlock", x: 2235.6, y: 2167.75, width: 71.95, height: 100 }, { type: "classicLaser", x: 2230.3, y: 2058.3 }, { type: "checkpoint", x: 1988.85, y: 2292 }, { type: "actBlock", actNum: "5", x: 1726, y: 1203 }, { type: "basicBlock", x: 1604.9, y: 1181.4, width: 100, height: 100 }, { type: "basicBlock", x: 2223.4, y: 1222.4, width: 100, height: 100 }, { type: "checkpoint", x: 1956.2, y: 1292.4 }, { type: "pole", x: 1975.9, y: 1190.3 }, { type: "pole", x: 2170.2, y: 1057.6 }, { type: "pole", x: 1974.9, y: 1057.6 }, { type: "actBlock", actNum: "6", x: 541, y: 1153 }, { type: "basicBlock", x: 659, y: 1151, width: 100, height: 141 }, { type: "basicBlock", x: 976, y: 908.75, width: 100, height: 427.7 }, { type: "key", x: 1062.15, y: 1108.4 }, { type: "basicBlock", x: 814, y: 1019.5, width: 100, height: 295 }, { type: "actBlock", actNum: "7", x: 540, y: 614.8 }, { type: "checkpoint", x: 901.1, y: 1183.05 }, { type: "basicBlock", x: 862.4, y: 1270.35, width: 785.2, height: 100.05 }, { type: "circularCannon", x: 702.15, y: 762.9 }, { type: "basicBlock", x: 538, y: 778.2, width: 140, height: 190.8 }, { type: "basicBlock", x: 790, y: 513.75, width: 140, height: 190.8 }, { type: "leftSlope", x: 1074.95, y: 644.9, width: 100, height: 100, rotation: 0 }, { type: "basicBlock", x: 1074.95, y: 783.5, width: 100, height: 178.05 }, { type: "iceBlock", x: 1374.95, y: 644.9, width: 500, height: 100.05 }, { type: "actBlock", actNum: "8", x: 1195, y: 903.05 }, { type: "reaper", x: 1374.8, y: 594.95, width: 352.1, rotation: 0 }, { type: "basicBlock", x: 2110.35, y: 644.9, width: 330, height: 100 }, { type: "windBlaster", x: 1706, y: 872, rotation: -90 }, { type: "checkpoint", x: 1021.75, y: 657.5 }, { type: "actBlock", actNum: "9", x: 2202, y: 625.5 }, { type: "basicBlock", x: 2524.15, y: 346.25, width: 508.6, height: 697.9 }, { type: "checkpoint", x: 1772.65, y: 556.5 }, { type: "checkpoint", x: 2621.3, y: 834.25 }, { type: "ziplinePole", x: 2748.75, y: 836.95 }, { type: "ziplinePole", x: 3474.95, y: 984.65 }, { type: "spike30x", x: 3422.65, y: 956.35, rotation: -90 }, { type: "basicBlock", x: 3684.85, y: 959.2, width: 508.6, height: 1466.2 }, { type: "basicBlock", x: 3282.8, y: 731.35, width: 100, height: 281 }, { type: "basicBlock", x: 3098.75, y: 679.35, width: 100, height: 281 }, { type: "basicBlock", x: 3280.55, y: 1140.4, width: 100, height: 289 }, { type: "basicBlock", x: 3098.75, y: 1096.55, width: 100, height: 295.1 }, { type: "glassBlock", x: 3380.55, y: 1151.95, width: 100, height: 100 }, { type: "classicLaser", x: 2884.65, y: 743.5 }, { type: "classicLaser", x: 2961.65, y: 919.15 }, { type: "actBlock", actNum: "10", x: 2917.75, y: 1244.3 }, { type: "quadrantRight", x: 2725.95, y: 1216.3, rotation: 0, width: 179.5 }, { type: "shurikanDispenser", x: 2041.85, y: 508.95 }], level1: [{ type: "basicBlock", x: 9.9, y: 50, width: 300.7, height: 100.05 }, { type: "leftSlope", x: 97, y: 147.85, width: 100, height: 100, rotation: -90 }, { type: "leftSlope", x: -427.1, y: 149.85, width: 100, height: 102, rotation: 180 }, { type: "basicBlock", x: 295.1, y: -90.95, width: 116, height: 100 }, { type: "spike30x", x: -417.1, y: -8.05, rotation: 0 }, { type: "spike30x", x: 5, y: -8.05, rotation: 0 }, { type: "spike10x", x: -263.1, y: 49.85, rotation: 90 }, { type: "spike10x", x: -149.1, y: 50, rotation: -90 }, { type: "basicBlock", x: -423.5, y: 49.85, width: 304.7, height: 100.05 }, { type: "spike10x", x: 137.1, y: -92.35, rotation: -90 }, { type: "basicBlock", x: 820, y: 670, width: 220, height: 100.05 }, { type: "textFade", textNum: "15", x: -588.025, y: 352.75, rotation: 179.99913024902344 }, { type: "textFade", textNum: "15", x: 493.775, y: 246.7, rotation: 0 }, { type: "textFade", textNum: "16", x: 643.375, y: 591.65, rotation: 179.99913024902344 }, { type: "textFade", textNum: "17", x: 62.25, y: 500.225, rotation: -90.00175476074219 }, { type: "textFade", textNum: "17", x: -906.95, y: 261.825, rotation: -90.00175476074219 }, { type: "textFade", textNum: "15", x: 842.75, y: 207.42499999999998, rotation: 90 }, { type: "textFade", textNum: "15", x: -625.075, y: -276.55, rotation: -.0008697509765625 }, { type: "spike", x: -782.55, y: -150.35, rotation: 180 }, { type: "spike", x: -771.55, y: -150.35, rotation: 180 }, { type: "spike", x: -760.55, y: -150.35, rotation: 180 }, { type: "spike", x: -749.55, y: -150.35, rotation: 180 }, { type: "horizontalBlock", x: -765.55, y: -182.85, width: 50, height: 50 }, { type: "spike", x: -877.6, y: -150.35, rotation: 180 }, { type: "spike", x: -866.6, y: -150.35, rotation: 180 }, { type: "spike", x: -855.6, y: -150.35, rotation: 180 }, { type: "spike", x: -844.6, y: -150.35, rotation: 180 }, { type: "horizontalBlock", x: -860.6, y: -182.85, width: 50, height: 50 }, { type: "spike", x: -689.55, y: -150.35, rotation: 180 }, { type: "spike", x: -678.55, y: -150.35, rotation: 180 }, { type: "spike", x: -667.55, y: -150.35, rotation: 180 }, { type: "spike", x: -656.55, y: -150.35, rotation: 180 }, { type: "horizontalBlock", x: -672.55, y: -182.85, width: 50, height: 50 }, { type: "checkpoint", x: -812.7, y: 61.85 }, { type: "spike", x: -910.95, y: 181.45, rotation: 180 }, { type: "spike", x: -899.95, y: 181.45, rotation: 180 }, { type: "spike", x: -888.95, y: 181.45, rotation: 180 }, { type: "spike", x: -877.95, y: 181.45, rotation: 180 }, { type: "horizontalBlock", x: -893.95, y: 148.95, width: 50, height: 50 }, { type: "bounceBlock", x: -903.95, y: 355, width: 50, height: 50 }, { type: "buzzsawVerticalUp", x: -729.8, y: 426.8 }, { type: "checkpoint", x: -494.8, y: 342.55 }, { type: "buzzsaw", x: 478.45, y: 319.4 }, { type: "buzzsaw", x: 587.45, y: 319.4 }, { type: "spike10x", x: 689.3, y: 203.85, rotation: -90 }, { type: "basicBlock", x: 722.2, y: 149.55, width: 50, height: 207.1 }, { type: "basicBlock", x: 620, y: 0, width: 780, height: 100.05 }, { type: "basicBlock", x: 360, y: 320, width: 230, height: 100.05 }, { type: "textFade", textNum: "10", x: 357.525, y: 318.475, rotation: 0 }, { type: "textFade", textNum: "8", x: 360.5, y: 178.89999999999998, rotation: 0 }, { type: "spawnPoint", x: 349.85, y: 260.45 }, { type: "basicBlock", x: 195, y: 188.7, width: 100, height: 659.3 }, { type: "basicBlock", x: 700, y: 320, width: 220, height: 100.05 }, { type: "textFade", textNum: "11", x: 699.9, y: 319.1, rotation: 0 }, { type: "basicBlock", x: 760, y: 445.05, width: 100, height: 150 }, { type: "basicBlock", x: 960, y: 484.75, width: 100, height: 871.5 }, { type: "verticalDownBlock", x: 885, y: 345.05, width: 50, height: 50 }, { type: "verticalUpBlock", x: 835, y: 495, width: 50, height: 50 }, { type: "textFade", textNum: "12", x: 831.875, y: 670.925, rotation: 0 }, { type: "checkpoint", x: 777.85, y: 582.2 }, { type: "fallingBlock", x: 685, y: 645, width: 50, height: 50 }, { type: "fallingBlock", x: 635, y: 645, width: 50, height: 50 }, { type: "basicBlock", x: 150, y: 670, width: 220, height: 100.05 }, { type: "checkpoint", x: 192.05, y: 582.2 }, { type: "textFade", textNum: "14", x: 148.7, y: 675.425, rotation: 0 }, { type: "bounceBlock", x: 65, y: 595.2, width: 50, height: 50 }, { type: "basicBlock", x: -10, y: 612, width: 100, height: 584 }, { type: "ziplinePole", x: -12.95, y: 285.05 }, { type: "ziplinePole", x: -428.9, y: 345.55 }, { type: "basicBlock", x: -464.95, y: 641.1, width: 100, height: 522.1 }, { type: "basicBlock", x: -737.55, y: 150, width: 186, height: 100.05 }, { type: "basicBlock", x: -572, y: 430, width: 116.05, height: 100.05 }, { type: "basicBlock", x: -1e3, y: -155.45, width: 100, height: 523.2 }, { type: "bounceBlock", x: -755.55, y: 75, width: 50, height: 50 }, { type: "basicBlock", x: -538.7, y: -179.55, width: 217.6, height: 100.05 }, { type: "ziplinePole", x: 193.05, y: -176.05 }, { type: "ziplinePole", x: -442.95, y: -264.55 }, { type: "finishPortal", x: 289, y: -170.85 }, { type: "basicBlock", x: 391.45, y: -274.9, width: 100, height: 467.1 }, { type: "basicBlock", x: -354.25, y: -458.45, width: 1391.6, height: 100.05 }, { type: "buzzsawVerticalUp", x: -254.15, y: -260.9 }, { type: "basicBlock", x: -1e3, y: 497.9, width: 100, height: 785.2 }, { type: "textFade", textNum: "18", x: -516.5250000000001, y: 280.5, rotation: 0 }, { type: "basicBlock", x: -892, y: 430, width: 116.05, height: 100.05 }, { type: "basicBlock", x: -562, y: 34, width: 171, height: 332.1 }, { type: "star", x: -206.05, y: 50.05 }, { type: "textFade", textNum: "41", x: -826.85, y: -3.575000000000003, rotation: 0 }, { type: "fallingBlock", x: 585, y: 645.2, width: 50, height: 50 }, { type: "fallingBlock", x: 535, y: 645.2, width: 50, height: 50 }, { type: "fallingBlock", x: 485, y: 645.2, width: 50, height: 50 }, { type: "fallingBlock", x: 435, y: 645.2, width: 50, height: 50 }, { type: "fallingBlock", x: 385, y: 645, width: 50, height: 50 }, { type: "fallingBlock", x: 335, y: 645, width: 50, height: 50 }, { type: "fallingBlock", x: 285, y: 645, width: 50, height: 50 }], level2: [{ type: "shurikanSpawner", x: 1231.5, y: -471.35, rotation: 90.0052490234375 }, { type: "shurikanSpawner", x: 1085.85, y: -250, rotation: -89.9947509765625 }, { type: "shurikanSpawner", x: 990.45, y: -471.35, rotation: 90.0052490234375 }, { type: "basicBlock", x: 1085.3, y: -200, width: 460.2, height: 100 }, { type: "checkpoint", x: 1355.1, y: -111 }, { type: "verticalUpBlock", x: 1137.3, y: 25, width: 356.1, height: 100 }, { type: "verticalDownBlock", x: 1137.3, y: 225.05, width: 358, height: 100 }, { type: "basicBlock", x: 739.35, y: 175, width: 48.2, height: 100 }, { type: "ziplinePole", x: 1043.95, y: 530.05 }, { type: "shurikanSpawner", x: 794, y: 820, rotation: -89.9947509765625 }, { type: "shurikanSpawner", x: 795.9, y: 254.95, rotation: 180 }, { type: "basicBlock", x: 809.25, y: 24.7, width: 100, height: 1323 }, { type: "checkpoint", x: 562.35, y: -66 }, { type: "spike10x", x: 265.1, y: 14, rotation: 0 }, { type: "spike10x", x: 361.6, y: 14, rotation: 0 }, { type: "spike10x", x: 457.6, y: 14, rotation: 0 }, { type: "textFade", textNum: "17", x: -87.52499999999999, y: 222.55, rotation: -15.002182006835938 }, { type: "checkpoint", x: -107.8, y: 291.75 }, { type: "textFade", textNum: "20", x: 326.15, y: 487.17499999999995, rotation: 0 }, { type: "spike10x", x: 83.6, y: 461.15, rotation: 180 }, { type: "spike10x", x: 83.6, y: 588.4, rotation: 0 }, { type: "basicBlock", x: 449, y: 320, width: 230, height: 100.05 }, { type: "spawnPoint", x: 348.85, y: 260.45 }, { type: "basicBlock", x: 611, y: 470, width: 94, height: 800 }, { type: "basicBlock", x: 84.05, y: 261.7, width: 100, height: 383.1 }, { type: "basicBlock", x: 195.55, y: 647.05, width: 737.5, height: 100.05 }, { type: "basicBlock", x: -121, y: 464.75, width: 100, height: 272.1 }, { type: "swimmingPool", x: 246, y: 472, width: 636, height: 250 }, { type: "textFade", textNum: "17", x: 269.9, y: 275.025, rotation: 90 }, { type: "basicBlock", x: 254.95, y: 46.8, width: 442.1, height: 50 }, { type: "basicBlock", x: 10, y: 252.7, width: 50, height: 50 }, { type: "basicBlock", x: -221, y: 308.05, width: 100, height: 778 }, { type: "basicBlock", x: 89.5, y: -3, width: 254, height: 50 }, { type: "spike", x: -104, y: 28.8, rotation: 180 }, { type: "spike", x: -115.5, y: 28.8, rotation: 180 }, { type: "spike", x: -115, y: -37.4, rotation: 0 }, { type: "spike", x: -103.5, y: -37.4, rotation: 0 }, { type: "verticalDownBlock", x: -109, y: -4, width: 25, height: 50 }, { type: "checkpoint", x: 45.5, y: -66 }, { type: "basicBlock", x: -121.55, y: 147.65, width: 100, height: 50 }, { type: "basicBlock", x: 591.6, y: 22, width: 235.1, height: 99.5 }, { type: "pushBlock", x: 165, y: -120, width: 50, height: 49.9 }, { type: "basicBlock", x: 295.3, y: -235.55, width: 929.6, height: 100.05 }, { type: "star", x: -223.95, y: -209.95 }, { type: "pushBlock", x: 734.25, y: -2.05, width: 50, height: 49.9 }, { type: "basicBlock", x: 682.2, y: 300, width: 50, height: 50 }, { type: "textFade", textNum: "17", x: 347.975, y: -62.55, rotation: -.00262451171875 }, { type: "basicBlock", x: 735.25, y: 428, width: 50, height: 100 }, { type: "basicBlock", x: 807.45, y: 820, width: 300, height: 100.05 }, { type: "basicBlock", x: 1007.45, y: 716.85, width: 100, height: 305.95 }, { type: "checkpoint", x: 978.1, y: 525.9 }, { type: "swimmingPool", x: 807.95, y: 677.5, width: 299.9, height: 185 }, { type: "textFade", textNum: "21", x: 124.25, y: 16.700000000000003, rotation: 0 }, { type: "textFade", textNum: "22", x: 603.325, y: 48.900000000000006, rotation: 0 }, { type: "ziplinePole", x: 1396.9, y: 576.55 }, { type: "basicBlock", x: 1395.9, y: 761, width: 100, height: 305.05 }, { type: "shurikanSpawner", x: 1210.5, y: 682.5, rotation: -89.9947509765625 }, { type: "basicBlock", x: 1545.9, y: 658.5, width: 200, height: 100 }, { type: "bounceBlock", x: 1538.9, y: 576.5, width: 65, height: 65 }, { type: "checkpoint", x: 1380.1, y: 87 }, { type: "basicBlock", x: 1365.35, y: 175, width: 100, height: 100 }, { type: "basicBlock", x: 909, y: 175, width: 100, height: 100 }, { type: "basicBlock", x: 883.1, y: 75, width: 48.2, height: 100 }, { type: "basicBlock", x: 1365.35, y: -25, width: 100, height: 100 }, { type: "basicBlock", x: 1465.35, y: -112, width: 100, height: 274.1 }, { type: "pushBlock", x: 1273.3, y: -338.6, width: 50, height: 49.9 }, { type: "basicBlock", x: 883.25, y: -336.55, width: 50, height: 175.05 }, { type: "finishPortal", x: 883.25, y: -453.55 }, { type: "basicBlock", x: -146, y: 45.15, width: 50, height: 50 }], level3: [{ type: "checkpoint", x: 616.25, y: 420.1 }, { type: "bounceBlock", x: 1587.4, y: 286.1, width: 46, height: 55 }, { type: "buzzsaw", x: -30, y: 213.1 }, { type: "ziplinePole", x: 26.95, y: -86.85 }, { type: "checkpoint", x: -34.1, y: -89.8 }, { type: "basicBlock", x: -7.9, y: 252.7, width: 100, height: 611 }, { type: "spike30x", x: -749.75, y: 368.35, rotation: 180 }, { type: "spike30x", x: -697.7, y: 549.3, rotation: 0 }, { type: "spike30x", x: -456.65, y: 368.35, rotation: 180 }, { type: "spike30x", x: -406.6, y: 549.3, rotation: 0 }, { type: "buzzsaw", x: -188.05, y: 10.95 }, { type: "bounceBlock", x: 987.15, y: 5.1, width: 45, height: 45 }, { type: "checkpoint", x: -107.35, y: 420.1 }, { type: "spike30x", x: 216.7, y: -61.15, rotation: 0 }, { type: "shurikanSpawner", x: 1436.75, y: 216.65, rotation: -90 }, { type: "spike10x", x: 1249.1, y: 77.1, rotation: 90 }, { type: "buzzsaw", x: 201.25, y: 205.45 }, { type: "spike10x", x: 933, y: 79.1, rotation: -90 }, { type: "spike30x", x: 1090.45, y: 134, rotation: 180 }, { type: "basicBlock", x: 1091.05, y: 77.1, width: 300, height: 100.05 }, { type: "checkpoint", x: 1357.55, y: 120.95 }, { type: "checkpoint", x: 815.7, y: 120.95 }, { type: "basicBlock", x: 516.05, y: 208.1, width: 40, height: 40 }, { type: "checkpoint", x: 322.75, y: 120.95 }, { type: "textFade", textNum: "17", x: 175.275, y: 133.25, rotation: 0 }, { type: "bounceBlock", x: 97.05, y: 433.1, width: 50, height: 50 }, { type: "basicBlock", x: 717, y: 707.1, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: 716, y: 537.075, rotation: -90 }, { type: "spawnPoint", x: 721, y: 643.1 }, { type: "basicBlock", x: 617.05, y: 607.1, width: 100, height: 300 }, { type: "basicBlock", x: 817, y: 457.1, width: 100, height: 600 }, { type: "buzzsawOnStick", x: 721.9, y: 705.8, rotation: -90 }, { type: "pole", x: 413.1, y: 393.1 }, { type: "basicBlock", x: 192.1, y: 607.6, width: 100, height: 299 }, { type: "textFade", textNum: "23", x: 412.15, y: 325.975, rotation: 0 }, { type: "textFade", textNum: "24", x: 412.175, y: 499.97499999999997, rotation: 0 }, { type: "basicBlock", x: -60, y: 508.1, width: 404.1, height: 100.05 }, { type: "pole", x: 90.3, y: 100.95 }, { type: "basicBlock", x: 317.05, y: 208.1, width: 100, height: 100.05 }, { type: "textFade", textNum: "25", x: -7.149999999999999, y: 179.075, rotation: 0 }, { type: "fallingBlock", x: 417.05, y: 208.1, width: 100, height: 100 }, { type: "basicBlock", x: 617.05, y: 208.1, width: 100, height: 100 }, { type: "buzzsawOnStick", x: 516.4, y: 203.7, rotation: -90 }, { type: "iceBlock", x: 1087.05, y: 233.1, width: 440, height: 150.05 }, { type: "basicBlock", x: 1357.05, y: 408.1, width: 100, height: 500 }, { type: "textFade", textNum: "26", x: 951.5250000000001, y: 188.64999999999998, rotation: 0 }, { type: "basicBlock", x: 1531.05, y: 213.1, width: 78, height: 200 }, { type: "ziplinePole", x: 853.2, y: -232 }, { type: "basicBlock", x: 891.05, y: -147.95, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: 1152.3249999999998, y: 4.35, rotation: 180 }, { type: "basicBlock", x: -7.9, y: -350.1, width: 100, height: 400 }, { type: "glassBlock", x: -107.9, y: 10.95, width: 100, height: 100.05 }, { type: "basicBlock", x: -208, y: -172.5, width: 100, height: 1065.3 }, { type: "textFade", textNum: "27", x: -208.75, y: -57.9, rotation: 0 }, { type: "glassBlock", x: -107.9, y: 210.95, width: 100, height: 100.05 }, { type: "glassBlock", x: -107.9, y: 408.95, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: -109.6, y: -151.425, rotation: 90 }, { type: "basicBlock", x: 202.2, y: -2.8, width: 321, height: 100.05 }, { type: "basicBlock", x: -600.2, y: 309.95, width: 685.1, height: 100.05 }, { type: "basicBlock", x: -550.3, y: 607, width: 785.3, height: 100.05 }, { type: "basicBlock", x: -892.9, y: 563.35, width: 100, height: 607.1 }, { type: "finishPortal", x: -810.2, y: 470.15 }, { type: "pole", x: -340.1, y: 463.1 }, { type: "pole", x: -551.15, y: 463.1 }, { type: "pole", x: -740.2, y: 463.1 }, { type: "shurikanSpawner", x: -727.4, y: 382.85, rotation: 45 }, { type: "fallingBlock", x: 67.1, y: -525.1, width: 50, height: 50 }, { type: "fallingBlock", x: 219.1, y: -549.1, width: 50, height: 50 }, { type: "fallingBlock", x: 378.75, y: -567.1, width: 50, height: 50 }, { type: "fallingBlock", x: 530.75, y: -591.1, width: 50, height: 50 }, { type: "buzzsawOnStick", x: 142.9, y: -543.1, rotation: -90 }, { type: "buzzsawOnStick", x: 304.75, y: -549.05, rotation: 90 }, { type: "buzzsawOnStick", x: 452.25, y: -581.2, rotation: -90 }, { type: "buzzsawOnStick", x: 614.1, y: -587.15, rotation: 90 }, { type: "star", x: 616.15, y: -678.15 }, { type: "basicBlock", x: 1657.05, y: 102.1, width: 100, height: 422 }, { type: "basicBlock", x: 1073.7, y: -393.9, width: 100, height: 592 }, { type: "basicBlock", x: 1572.6, y: -147.95, width: 269.1, height: 100.05 }, { type: "pushBlock", x: 1581.35, y: 87.9, width: 50, height: 49.9 }, { type: "pole", x: 1448.35, y: -57.85 }], level4: [{ type: "fallingSpike", x: -350.65, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -329.15, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -393.75, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -372.25, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -436.75, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -415.25, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -479.85, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -458.35, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -522.9, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -501.4, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -566, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -544.5, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -609, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -587.5, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -652.1, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -630.6, y: -571.35, rotation: 180 }, { type: "spike10x", x: -615.05, y: -465.7, rotation: 0 }, { type: "basicBlock", x: -770.2, y: -567.4, width: 100, height: 225.2 }, { type: "spike30x", x: 200.45, y: -167.85, rotation: 0 }, { type: "spike10x", x: 8.05, y: -168.1, rotation: 0 }, { type: "spike10x", x: -87.45, y: -168.1, rotation: 0 }, { type: "shurikanSpawner", x: 648.7, y: -236.5, rotation: 0 }, { type: "textFade", textNum: "5", x: 37.05, y: 342.975, rotation: -90 }, { type: "textFade", textNum: "4", x: 617.5, y: -5.225000000000001, rotation: 0 }, { type: "spike10x", x: 952.2, y: -167.1, rotation: 0 }, { type: "windBlaster", x: 1249.1, y: 70.95, rotation: -90 }, { type: "buzzsaw", x: 1044.4, y: 340.25 }, { type: "buzzsawHorizontal", x: 1043.95, y: 470.6 }, { type: "glassBlock", x: 943.95, y: 143.65, width: 100, height: 100 }, { type: "basicBlock", x: 1043.95, y: 90.85, width: 100, height: 500 }, { type: "basicBlock", x: 666.85, y: 44.75, width: 50, height: 100 }, { type: "buzzsawHorizontal", x: 423.95, y: 0 }, { type: "spike10x", x: 187.1, y: 318.25, rotation: -90.00175476074219 }, { type: "spike10x", x: 183.05, y: 485.85, rotation: 89.99824523925781 }, { type: "shurikanSpawner", x: 555.4, y: 311.8, rotation: 90 }, { type: "speedBlock", x: 545, y: 320, width: 300, height: 100.05 }, { type: "basicBlock", x: 345, y: 320, width: 100, height: 100.05 }, { type: "spawnPoint", x: 348.85, y: 260.45 }, { type: "basicBlock", x: 345, y: 615.35, width: 100, height: 291.2 }, { type: "basicBlock", x: 956.05, y: 520, width: 522.1, height: 100.05 }, { type: "speedBlockLeft", x: 545, y: 520, width: 300, height: 100.05 }, { type: "checkpoint", x: 347.3, y: 432 }, { type: "basicBlock", x: 844, y: 418, width: 100, height: 696 }, { type: "basicBlock", x: 245, y: 219.85, width: 100, height: 300 }, { type: "textFade", textNum: "5", x: 469.42499999999995, y: 236.05, rotation: 0 }, { type: "basicBlock", x: 87.3, y: 486.85, width: 176.7, height: 100.05 }, { type: "basicBlock", x: 545.05, y: 119.85, width: 500.1, height: 100.05 }, { type: "basicBlock", x: -50, y: 300.9, width: 100, height: 921.7 }, { type: "classicLaser", x: 154.05, y: 240.6 }, { type: "checkpoint", x: 252.35, y: 32 }, { type: "verticalUpBlock", x: 90, y: 194.05, width: 50, height: 100 }, { type: "basicBlock", x: 90, y: 343.1, width: 50, height: 100 }, { type: "textFade", textNum: "28", x: 332.4, y: 323.725, rotation: 0 }, { type: "basicBlock", x: 250, y: -109.75, width: 500.1, height: 100.05 }, { type: "buzzsawVerticalUp", x: 571.9, y: -76 }, { type: "basicBlock", x: 940.9, y: -109, width: 402.1, height: 100.05 }, { type: "star", x: 450.95, y: -204.95 }, { type: "basicBlock", x: 350.05, y: -258.55, width: 100, height: 200 }, { type: "basicBlock", x: 473.05, y: -309, width: 346, height: 100.05 }, { type: "basicBlock", x: 691.85, y: -209, width: 100, height: 300 }, { type: "checkpoint", x: 839.4, y: 32 }, { type: "basicBlock", x: 1249.1, y: 423.1, width: 100, height: 706.3 }, { type: "checkpoint", x: 1081.8, y: -196.95 }, { type: "windBlaster", x: 789.85, y: -157.95, rotation: -90 }, { type: "windBlaster", x: 954.25, y: -341, rotation: 90 }, { type: "basicBlock", x: 948.85, y: -391, width: 198, height: 100.05 }, { type: "checkpoint", x: 401.35, y: -397.05 }, { type: "textFade", textNum: "5", x: 777.125, y: -393.65, rotation: 180 }, { type: "iceBlock", x: 99.55, y: -309, width: 401, height: 100.05 }, { type: "basicBlock", x: -150, y: 202, width: 100, height: 1122 }, { type: "buzzsawOnStick", x: 210.65, y: -299.35, rotation: 90 }, { type: "checkpoint", x: -255.85, y: -496.2 }, { type: "basicBlock", x: -459.9, y: -408.2, width: 720.6, height: 100.05 }, { type: "basicBlock", x: -459.25, y: -630, width: 720.6, height: 100.05 }, { type: "finishPortal", x: -690.05, y: -487.2 }, { type: "buzzsawOnStick", x: -21.199999999999996, y: -309, rotation: -90 }, { type: "textFade", textNum: "5", x: 248.175, y: 425.8, rotation: -165.00189208984375 }, { type: "swimmingPool", x: 1046.95, y: 331.8, width: 306, height: 276.3 }], level5: [{ type: "laserPoint", x: 543.75, y: 565 }, { type: "laserPoint", x: 1269.1, y: 565 }, { type: "laserPoint", x: 122, y: 146.55 }, { type: "laserPoint", x: 231, y: 146.55 }, { type: "textFade", textNum: "15", x: 65.025, y: 753.4, rotation: .0008697509765625 }, { type: "bounceBlock", x: 1439.4, y: 808.7, width: 50, height: 50 }, { type: "glassBlock", x: 390, y: 157.5, width: 126, height: 100 }, { type: "spike30x", x: -180.55, y: 465.85, rotation: -90 }, { type: "classicLaser", x: 150, y: 54.4 }, { type: "textFade", textNum: "15", x: 386, y: 219.525, rotation: 90.00175476074219 }, { type: "spike10x", x: 135.4, y: 462.45, rotation: 90 }, { type: "checkpoint", x: -95.8, y: 54.65 }, { type: "glassBlock", x: 389, y: -105.3, width: 122, height: 100 }, { type: "quadrantLeft", x: 730.1, y: -192.5, rotation: 0 }, { type: "quadrantLeft", x: 1006.85, y: -192.5, rotation: 0 }, { type: "textFade", textNum: "15", x: 1367.1, y: -10.025000000000006, rotation: -104.99729919433594 }, { type: "bounceBlock", x: 1396, y: 115, width: 50, height: 50 }, { type: "checkpoint", x: 1314.2, y: 102.65 }, { type: "basicBlock", x: 714.1, y: 390.1, width: 100, height: 199.9 }, { type: "spawnPoint", x: 713.45, y: 264.15 }, { type: "finishPortal", x: 1514.6, y: 552.25 }, { type: "basicBlock", x: 914.1, y: 365, width: 100, height: 250.1 }, { type: "basicBlock", x: 1114.1, y: 340.05, width: 100, height: 300 }, { type: "basicBlock", x: 1314.1, y: 387.3, width: 100, height: 495.3 }, { type: "bouncingBuzzsaw", x: 914.1, y: 0 }, { type: "bouncingBuzzsaw", x: 1114.1, y: 0 }, { type: "basicBlock", x: 1414.1, y: 190, width: 100, height: 100 }, { type: "quadrantLeft", x: 1373, y: -83, rotation: 0 }, { type: "basicBlock", x: 1232.85, y: -142.5, width: 100.1, height: 100 }, { type: "textFade", textNum: "15", x: 804.125, y: 230, rotation: -14.99810791015625 }, { type: "checkpoint", x: 1234.6, y: -230.5 }, { type: "iceBlock", x: 905.3, y: -142.5, width: 556.9, height: 100.05 }, { type: "basicBlock", x: 573.8, y: -142.5, width: 106.1, height: 100 }, { type: "checkpoint", x: 578.55, y: -230.5 }, { type: "basicBlock", x: 1514, y: 87.2, width: 100, height: 806.1 }, { type: "basicBlock", x: 497.75, y: 210.55, width: 100, height: 806.1 }, { type: "basicBlock", x: 277, y: 252.95, width: 100, height: 291 }, { type: "basicBlock", x: 226.7, y: 562, width: 200, height: 100 }, { type: "pushBlock", x: 470.15, y: -279.05, width: 50, height: 49.9 }, { type: "basicBlock", x: 26.95, y: 454, width: 200.1, height: 316.05 }, { type: "basicBlock", x: 77, y: -49.65, width: 100, height: 488.1 }, { type: "basicBlock", x: 177.55, y: -225.05, width: 301, height: 462.9 }, { type: "pole", x: 384.1, y: 439.65 }, { type: "rightSlope", x: -22.9, y: 247.55, width: 100, height: 100, rotation: 0 }, { type: "ziplinePole", x: -156.3, y: 58 }, { type: "ziplinePole", x: -599.15, y: 119.2 }, { type: "spike30x", x: -538.25, y: 195.6, rotation: 90 }, { type: "ziplinePole", x: -154.05, y: 379.25 }, { type: "classicLaser", x: -206.3, y: 202.7 }, { type: "ziplinePole", x: -599.15, y: 292.7 }, { type: "ziplinePole", x: -154.05, y: 414.3 }, { type: "ziplinePole", x: -599.15, y: 524.95 }, { type: "classicLaser", x: -512.65, y: 417.9 }, { type: "ziplinePole", x: -599.15, y: 575.95 }, { type: "ziplinePole", x: -135.05, y: 746.15 }, { type: "checkpoint", x: -63.55, y: 743.2 }, { type: "basicBlock", x: -123.1, y: 352, width: 100, height: 520 }, { type: "spike10x", x: -538.25, y: 595.35, rotation: 90 }, { type: "basicBlock", x: -596.15, y: 349.85, width: 100, height: 600.2 }, { type: "buzzsaw", x: 386.1, y: 560.4, width: 121.2, height: 122.65 }, { type: "buzzsaw", x: -271.2, y: 377.8, width: 66.25, height: 67.05 }, { type: "buzzsaw", x: -390.25, y: 550.8, width: 66.25, height: 67.05 }, { type: "quadrantRight", x: 158.25, y: 749.65, rotation: 0 }, { type: "pole", x: 158.05, y: 749.2 }, { type: "quadrantRight", x: 350.3, y: 749.65, rotation: 45 }, { type: "pole", x: 350.1, y: 749.2 }, { type: "quadrantRight", x: 534.3, y: 749.65, rotation: 0 }, { type: "pole", x: 534.1, y: 749.2 }, { type: "basicBlock", x: 725, y: 831, width: 100, height: 100 }, { type: "checkpoint", x: 730.65, y: 743.25 }, { type: "basicBlock", x: -96.45, y: 831, width: 153, height: 100 }, { type: "hazardStrips", x: 538.75, y: 513.9 }, { type: "hazardStrips", x: 1264.1, y: 535.25 }, { type: "hazardStrips", x: 117, y: 93.65 }, { type: "hazardStrips", x: 227, y: 107.45 }, { type: "basicBlock", x: 1216.55, y: 856, width: 503.3, height: 50 }, { type: "basicBlock", x: 1167.3, y: 808.7, width: 236.1, height: 50 }, { type: "basicBlock", x: 1374.35, y: 808.7, width: 80.1, height: 50 }, { type: "basicBlock", x: 1514, y: 731.1, width: 100, height: 298.9 }, { type: "buzzsawHorizontalFast", x: 1310.3, y: 732.7 }, { type: "buzzsawHorizontalFast", x: 1004.25, y: 732.7 }, { type: "fallingBlock", x: 387.95, y: 346, width: 100, height: 100 }, { type: "star", x: -271.05, y: 435.1 }], level6: [{ type: "spike10x", x: 672.1, y: -499.25, rotation: -90.00175476074219 }, { type: "checkpoint", x: 311.95, y: -388.05 }, { type: "quadrantRight", x: 385.05, y: -737.25, rotation: 0, width: 179.5 }, { type: "spike10x", x: 28.6, y: 308.75, rotation: 180 }, { type: "spike10x", x: -270.4, y: 207.9, rotation: 180 }, { type: "textFade", textNum: "5", x: 752.425, y: -131, rotation: .0008697509765625 }, { type: "bounceBlock", x: 232, y: -74.5, width: 50, height: 50 }, { type: "lockBlock", x: 230, y: 750, width: 100.05, height: 100 }, { type: "checkpoint", x: 26.85, y: -338 }, { type: "quadrantRight", x: -44, y: -76.5, rotation: 0, width: 211.5 }, { type: "checkpoint", x: 402.8, y: 163.25 }, { type: "quadrantLeft", x: 680.2, y: 401.1, rotation: 0, width: 201.5 }, { type: "key", x: 675.1, y: 403.2 }, { type: "basicBlock", x: 380, y: 300, width: 200, height: 200 }, { type: "spawnPoint", x: 329.35, y: 173.9 }, { type: "finishPortal", x: 424.05, y: 470.2 }, { type: "lockBlock", x: 230, y: 250, width: 100.05, height: 100 }, { type: "lockBlock", x: 230, y: 349.95, width: 100.05, height: 100 }, { type: "lockBlock", x: 230, y: 449.95, width: 100.05, height: 100 }, { type: "lockBlock", x: 330, y: 450, width: 100.05, height: 100 }, { type: "basicBlock", x: 530, y: 398.5, width: 100, height: 397.1 }, { type: "basicBlock", x: 130, y: 550, width: 100, height: 700 }, { type: "basicBlock", x: 630, y: 200, width: 100, height: 200 }, { type: "basicBlock", x: 30, y: 200, width: 100, height: 200 }, { type: "textFade", textNum: "31", x: 336.07500000000005, y: 92.625, rotation: 0 }, { type: "textFade", textNum: "32", x: 333.9, y: 253.325, rotation: 0 }, { type: "basicBlock", x: 630, y: -50, width: 100, height: 100 }, { type: "basicBlock", x: 30, y: -150, width: 100, height: 300.1 }, { type: "basicBlock", x: 330, y: 0, width: 300, height: 100 }, { type: "basicBlock", x: 830, y: 300, width: 100, height: 600 }, { type: "checkpoint", x: 630.3, y: 62 }, { type: "checkpoint", x: 26.85, y: 62 }, { type: "swimmingPool", x: 680, y: 400, width: 200, height: 200 }, { type: "basicBlock", x: -170, y: -125, width: 100, height: 350 }, { type: "basicBlock", x: -169, y: 150, width: 300, height: 100 }, { type: "basicBlock", x: 330, y: 700, width: 100, height: 400 }, { type: "star", x: 230, y: 750.05 }, { type: "basicBlock", x: 580, y: 550, width: 400, height: 100 }, { type: "basicBlock", x: -95, y: 25, width: 50, height: 50 }, { type: "basicBlock", x: -45, y: -75, width: 50, height: 50 }, { type: "key", x: -106.1, y: -174.55 }, { type: "basicBlock", x: -70, y: -250, width: 100, height: 100 }, { type: "basicBlock", x: 330, y: -200, width: 100, height: 300.1 }, { type: "textFade", textNum: "5", x: 128.05, y: 61.975, rotation: -90 }, { type: "textFade", textNum: "5", x: 532.15, y: 56.575, rotation: -90 }, { type: "checkpoint", x: 640.5, y: -138 }, { type: "speedBlock", x: 929.95, y: -49.95, width: 499.9, height: 100 }, { type: "basicBlock", x: 1230, y: -50, width: 100, height: 100 }, { type: "buzzsawOnStick", x: 1004.1, y: -55, rotation: -90 }, { type: "speedBlockLeft", x: 929.95, y: -280, width: 499.9, height: 100 }, { type: "buzzsawOnStick", x: 814.8, y: -274.45, rotation: 90 }, { type: "key", x: 725.05, y: -369.55 }, { type: "bounceBlock", x: 1230.3, y: -124.95, width: 50, height: 50 }, { type: "glassBlock", x: 231, y: 550, width: 100, height: 100 }, { type: "lockBlock", x: 230, y: 650, width: 100.05, height: 100 }, { type: "basicBlock", x: 230, y: 850, width: 100, height: 100 }, { type: "ziplinePole", x: -182.05, y: -335.1 }, { type: "ziplinePole", x: -749.2, y: -185.1 }, { type: "key", x: -504.2, y: -311.95 }, { type: "basicBlock", x: -750, y: -50, width: 100, height: 200 }, { type: "ziplinePole", x: -656.15, y: -84.55 }, { type: "ziplinePole", x: -259.05, y: 64.95 }, { type: "basicBlock", x: -650, y: 0, width: 100, height: 100 }, { type: "classicLaser", x: -249.1, y: -152.75 }, { type: "buzzsaw", x: -504.1, y: -157.75, width: 101, height: 102.2 }, { type: "basicBlock", x: -850, y: -175, width: 100, height: 450 }, { type: "textFade", textNum: "5", x: 732.05, y: 203.125, rotation: 90.00175476074219 }, { type: "textFade", textNum: "5", x: 172.775, y: -317.3, rotation: -179.99913024902344 }, { type: "windBlaster", x: 330, y: -350.05, rotation: -90 }, { type: "fallingBlock", x: 381, y: -548, width: 50, height: 50 }, { type: "fallingBlock", x: 291, y: -640, width: 50, height: 50 }, { type: "fallingBlock", x: 385, y: -734, width: 50, height: 50 }, { type: "fallingBlock", x: 291, y: -821, width: 50, height: 50 }, { type: "key", x: 345.5, y: -916.4 }, { type: "bounceBlock", x: -270, y: 650, width: 70, height: 70 }, { type: "key", x: 31.95, y: 569.3 }, { type: "bounceBlock", x: -116.95, y: 650, width: 70, height: 70 }, { type: "bounceBlock", x: 30, y: 650, width: 70, height: 70 }, { type: "buzzsaw", x: -439.7, y: -13.65, width: 101, height: 102.2 }, { type: "spike10x", x: 730.6, y: -557.55, rotation: 0 }, { type: "spike10x", x: 828, y: -557.55, rotation: 0 }, { type: "basicBlock", x: 780, y: -499.65, width: 200, height: 100 }], level7: [{ type: "basicBlock", x: -173, y: 183.6, width: 150, height: 115 }, { type: "buzzsawOnStick", x: 101.19999999999999, y: -297.4, rotation: 90 }, { type: "buzzsawOnStick", x: 102.8, y: -306.6, rotation: -90 }, { type: "quadrantRight", x: 798.2, y: 896.2, rotation: 0, width: 179.5 }, { type: "quadrantRight", x: 584.15, y: 896.2, rotation: 0, width: 179.5 }, { type: "basicBlock", x: 251, y: 367, width: 100, height: 1733 }, { type: "basicBlock", x: 754.2, y: 995.75, width: 906.1, height: 100 }, { type: "checkpoint", x: 364.5, y: 894.2 }, { type: "breatheBlaster", x: 356.85, y: 926.1, rotation: -90 }, { type: "textFade", textNum: "5", x: 714.8, y: 508.67499999999995, rotation: 90.00175476074219 }, { type: "circularCannon", x: 392.15, y: 382.25 }, { type: "spike", x: 860, y: -581.35, rotation: 180 }, { type: "spike", x: 871, y: -581.35, rotation: 180 }, { type: "spike", x: 883, y: -581.35, rotation: 180 }, { type: "spike", x: 894, y: -581.35, rotation: 180 }, { type: "spike10x", x: 643.9, y: -581.65, rotation: 180 }, { type: "basicBlock", x: 643.9, y: -703.5, width: 100, height: 230 }, { type: "spike30x", x: 546.6, y: -507.7, rotation: 0 }, { type: "spike10x", x: 793.1, y: -654.1, rotation: -90 }, { type: "spike10x", x: 792.1, y: -500.2, rotation: -90 }, { type: "fallingSpike", x: -418.05, y: -49.25, rotation: 180 }, { type: "fallingSpike", x: -439.55, y: -49.25, rotation: 180 }, { type: "fallingSpike", x: -396.55, y: -49.25, rotation: 180 }, { type: "textFade", textNum: "5", x: 141.02499999999998, y: -436.525, rotation: -59.99946594238281 }, { type: "bounceBlock", x: 171.05, y: 216.05, width: 60, height: 60 }, { type: "bounceBlock", x: 31, y: 216.05, width: 60, height: 60 }, { type: "spike10x", x: -272.15, y: 376.65, rotation: 90 }, { type: "windBlaster", x: -281.05, y: 477.05, rotation: 0 }, { type: "windBlaster", x: -135.1, y: 380.1, rotation: 180 }, { type: "spike10x", x: -144, y: 480.5, rotation: -90 }, { type: "textFade", textNum: "5", x: 94.8, y: 441.17499999999995, rotation: -89.99824523925781 }, { type: "fallingSpike", x: -319.3, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -361.3, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -340.8, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -297.8, y: 12.45, rotation: 180 }, { type: "basicBlock", x: -355.15, y: 109.95, width: 150, height: 115 }, { type: "star", x: -28.45, y: 1185.8 }, { type: "classicLaser", x: -31.05, y: 969.55 }, { type: "buzzsawHorizontal", x: 78.05, y: 615.2, width: 184.8 }, { type: "basicBlock", x: -65.4, y: 665.65, width: 438.1, height: 100 }, { type: "spike", x: -438.15, y: 58, rotation: -90 }, { type: "spike", x: -438.15, y: 68.5, rotation: -90 }, { type: "spike", x: -438.15, y: 78.5, rotation: -90 }, { type: "basicBlock", x: -330.15, y: -32.3, width: 100, height: 73.5 }, { type: "textFade", textNum: "5", x: -770.2, y: 627.125, rotation: 90.00175476074219 }, { type: "buzzsaw", x: -802.6, y: 759.25, width: 76.55, height: 77.5 }, { type: "buzzsaw", x: -736.6, y: 911.3, width: 76.55, height: 77.5 }, { type: "buzzsaw", x: -632, y: 1222.3, width: 77.5, height: 76.55 }, { type: "buzzsaw", x: -479.95, y: 1124.3, width: 77.5, height: 76.55 }, { type: "textFade", textNum: "5", x: -770.2, y: 188.075, rotation: 90.00175476074219 }, { type: "buzzsaw", x: -736.6, y: 442.2, width: 76.55, height: 77.5 }, { type: "buzzsaw", x: -639.35, y: 708.65, width: 184.8, height: 187.05 }, { type: "buzzsaw", x: -639.35, y: 509.6, width: 184.8, height: 187.05 }, { type: "basicBlock", x: -638.2, y: 127, width: 200, height: 768.3 }, { type: "basicBlock", x: -380.15, y: 706.65, width: 200, height: 1087.9 }, { type: "basicBlock", x: -1e3, y: 55, width: 200, height: 300 }, { type: "basicBlock", x: 1400, y: 56, width: 200, height: 300 }, { type: "finishPortal", x: 1236.25, y: 133.95 }, { type: "basicBlock", x: -950, y: 875, width: 300, height: 1425.1 }, { type: "basicBlock", x: 200, y: 1403, width: 2000.2, height: 370 }, { type: "basicBlock", x: 1350.1, y: 875.45, width: 300, height: 1425.1 }, { type: "basicBlock", x: 1200, y: -157.15, width: 600, height: 200 }, { type: "basicBlock", x: -638.2, y: 927.9, width: 200, height: 437.8 }, { type: "checkpoint", x: 230.85, y: -536.8 }, { type: "circularCannon", x: 102, y: -302 }, { type: "checkpoint", x: -469.95, y: 125.65 }, { type: "checkpointSwimming", x: 105.2, y: 182.2 }, { type: "basicBlock", x: -279.35, y: -157.15, width: 520, height: 200 }, { type: "basicBlock", x: -67, y: -104, width: 138, height: 1268.4 }, { type: "basicBlock", x: 351, y: -449, width: 100, height: 100 }, { type: "pushBlock", x: 348.9, y: -561.95, width: 50, height: 50 }, { type: "speedBlock", x: 601, y: -449, width: 400, height: 100 }, { type: "basicBlock", x: 850, y: -473.8, width: 100, height: 150 }, { type: "basicBlock", x: 332.85, y: -782.7, width: 938.4, height: 100 }, { type: "checkpoint", x: 959.1, y: -295.15 }, { type: "basicBlock", x: 850, y: -711.2, width: 100, height: 243.05 }, { type: "classicLaser", x: 746.15, y: -698.9 }, { type: "basicBlock", x: 1069.25, y: -542.8, width: 100, height: 573.1 }, { type: "basicBlock", x: 350.4, y: -207.15, width: 100, height: 100 }, { type: "basicBlock", x: 500, y: 27.85, width: 100, height: 570.7 }, { type: "hazardStrips", x: 540, y: -257.25 }, { type: "hazardStrips", x: 899.1, y: -257.25 }, { type: "classicLaser", x: 726.4, y: -136.3 }, { type: "laserPoint", x: 545, y: -207.25 }, { type: "laserPoint", x: 904.1, y: -207.25 }, { type: "checkpointSwimming", x: 383.25, y: 182.2 }, { type: "textFade", textNum: "5", x: 969.25, y: -475.575, rotation: 90.00175476074219 }, { type: "textFade", textNum: "5", x: 426.1, y: -146.525, rotation: 90.00175476074219 }, { type: "pole", x: 823.2, y: -339.5 }, { type: "pole", x: 642.15, y: -339.5 }, { type: "spawnPoint", x: -849.85, y: 122.6 }, { type: "basicBlock", x: 475.9, y: 539.5, width: 350, height: 100 }, { type: "reaper", x: 647.4, y: 389.05, width: 161.3, rotation: -90 }, { type: "basicBlock", x: 819.2, y: 460, width: 100, height: 750 }, { type: "basicBlock", x: 594.2, y: 785, width: 350, height: 100 }, { type: "reaper", x: 383.95, y: 662.35, width: 126.35, rotation: -90 }, { type: "textFade", textNum: "34", x: 357.25, y: 995.2750000000001, rotation: 0 }, { type: "checkpoint", x: 1042.45, y: 894.2 }, { type: "breatheBlaster", x: 1034.8, y: 926.1, rotation: -90 }, { type: "textFade", textNum: "5", x: 1028.55, y: 777.625, rotation: -89.99824523925781 }, { type: "reaper", x: 1034.15, y: 439.3, width: 276.85, rotation: -90 }, { type: "reaper", x: 1034.15, y: 439.3, width: 130.45, rotation: 180 }, { type: "checkpoint", x: -187.5, y: 88.1 }, { type: "swimmingPool", x: 200, y: 721, width: 2e3, height: 994 }], level8: [{ type: "textFade", textNum: "5", x: 38, y: 999.4250000000001, rotation: 90 }, { type: "shurikanSpawner", x: 1783.55, y: 512.7, rotation: 180 }, { type: "basicBlock", x: 1294, y: 383, width: 112, height: 100 }, { type: "basicBlock", x: 738, y: 233.5, width: 100, height: 201 }, { type: "buzzsaw", x: 929.2, y: 338.05, width: 85, height: 86 }, { type: "buzzsaw", x: 929.2, y: 227.05, width: 85, height: 86 }, { type: "textFade", textNum: "5", x: 1589.65, y: 558.275, rotation: -90 }, { type: "textFade", textNum: "5", x: 1693.55, y: 938.775, rotation: -90 }, { type: "checkpoint", x: 481.85, y: 1099.65 }, { type: "laserPoint", x: 532.7, y: 970 }, { type: "laserPoint", x: 952, y: 970 }, { type: "textFade", textNum: "5", x: 190.025, y: 1101.1, rotation: 0 }, { type: "basicBlock", x: 263, y: 691.55, width: 100, height: 100.9 }, { type: "basicBlock", x: 1189.95, y: 884.6, width: 120.1, height: 249.2 }, { type: "finishPortal", x: 835.4, y: 303.25 }, { type: "basicBlock", x: 625.15, y: 383, width: 692.8, height: 100 }, { type: "spawnPoint", x: 335.75, y: 518.5 }, { type: "basicBlock", x: 114, y: 385, width: 330, height: 550 }, { type: "basicBlock", x: 444, y: 610, width: 330, height: 100 }, { type: "sparkBlock", x: 785, y: 610, width: 100, height: 100 }, { type: "basicBlock", x: 1e3, y: 688.6, width: 100, height: 257.4 }, { type: "checkpoint", x: 1046.65, y: 871.2 }, { type: "textFade", textNum: "35", x: 488.22499999999997, y: 615.1, rotation: 0 }, { type: "textFade", textNum: "5", x: 658.025, y: 524.8, rotation: 0 }, { type: "basicBlock", x: 1190, y: 496.45, width: 120, height: 326.8 }, { type: "hazardStrips", x: 599, y: 560.15 }, { type: "hazardStrips", x: 950, y: 560.15 }, { type: "laserPoint", x: 603.85, y: 610.4 }, { type: "laserPoint", x: 955, y: 610 }, { type: "textFade", textNum: "5", x: 1102.1, y: 558.275, rotation: 90 }, { type: "sparkBlock", x: 1190, y: 710, width: 120, height: 120 }, { type: "checkpoint", x: 415.2, y: 899.45 }, { type: "key", x: 1348.9, y: 783.25 }, { type: "ziplinePole", x: 963.5, y: 875.4 }, { type: "ziplinePole", x: 485.8, y: 902.4 }, { type: "basicBlock", x: 1223.25, y: 959.2, width: 553.4, height: 100 }, { type: "basicBlock", x: 320.25, y: 987.45, width: 435.2, height: 100 }, { type: "reaper", x: 719.5, y: 864.25, width: 150.6, rotation: -90 }, { type: "basicBlock", x: 263, y: 937.45, width: 100, height: 200 }, { type: "solarBlock", x: 263, y: 1087.45, width: 100, height: 111.55 }, { type: "lightSwitch", x: 354.7, y: 899.8 }, { type: "checkpoint", x: 147.2, y: 899.45 }, { type: "lightSwitch", x: 73.05, y: 1039.9 }, { type: "sparkBlock", x: 36.7, y: 1167.4, width: 134, height: 134 }, { type: "sparkBlock", x: 263, y: 1187.45, width: 100, height: 100 }, { type: "sparkBlock", x: 396, y: 1173.55, width: 74, height: 74 }, { type: "basicBlock", x: 483, y: 1287, width: 100, height: 300 }, { type: "solarBlock", x: 263, y: 792, width: 100, height: 111.55 }, { type: "basicBlock", x: 263, y: 1387.45, width: 100, height: 300 }, { type: "hazardStrips", x: 527.85, y: 937.75 }, { type: "hazardStrips", x: 946.5, y: 909.5 }, { type: "basicBlock", x: 1400, y: 546.3, width: 100, height: 100 }, { type: "basicBlock", x: 1500, y: 734.3, width: 100, height: 549.8 }, { type: "swimmingPool", x: 1350.5, y: 784.85, width: 201, height: 250 }, { type: "checkpoint", x: 1501.6, y: 421.4 }, { type: "speedBlock", x: 1040.65, y: 1187.15, width: 1015.3, height: 100 }, { type: "quadrantLeft", x: 709.15, y: 1188.25, rotation: 0 }, { type: "quadrantLeft", x: 930.2, y: 1188.25, rotation: 45 }, { type: "quadrantLeft", x: 1137.25, y: 1188.25, rotation: 0 }, { type: "quadrantLeft", x: 1358.3, y: 1188.25, rotation: 45 }, { type: "checkpoint", x: 1598.6, y: 1098.65 }, { type: "basicBlock", x: 1749.5, y: 1187, width: 205, height: 100.9 }, { type: "lockBlock", x: 163, y: 1387.15, width: 100.05, height: 100 }, { type: "basicBlock", x: 163, y: 1487.15, width: 100, height: 100 }, { type: "star", x: 163.05, y: 1388 }, { type: "key", x: 1700.3, y: 1030.4 }, { type: "lightSwitch", x: 1640, y: 1105 }, { type: "bounceBlock", x: 1699.95, y: 1106.55, width: 60, height: 60 }, { type: "shurikanSpawner", x: 1560.9, y: 902.8, rotation: 0 }, { type: "shurikanSpawner", x: 1783.55, y: 855.8, rotation: 180 }, { type: "lockBlock", x: 1700, y: 746.75, width: 100.05, height: 100 }, { type: "basicBlock", x: 1600, y: 747.2, width: 100, height: 100.9 }, { type: "basicBlock", x: 1800, y: 436.75, width: 100, height: 720.2 }, { type: "basicBlock", x: 1598, y: 1286.65, width: 100, height: 300 }, { type: "bounceBlock", x: 1597.4, y: 671.75, width: 50, height: 50 }, { type: "textFade", textNum: "36", x: 402.775, y: 985.625, rotation: 0 }, { type: "textFade", textNum: "37", x: 1451, y: 538.5, rotation: 0 }, { type: "textFade", textNum: "5", x: 619.925, y: 1100.95, rotation: 0 }, { type: "lockBlock", x: 1300, y: 283, width: 100.05, height: 100 }, { type: "textFade", textNum: "5", x: 1394.3, y: 363.625, rotation: -90 }, { type: "basicBlock", x: 1900, y: 968.65, width: 100, height: 537.9 }, { type: "basicBlock", x: 1240, y: 183, width: 219.8, height: 100 }, { type: "basicBlock", x: -101, y: 946, width: 100, height: 1672 }, { type: "checkpoint", x: 1189.85, y: 295 }, { type: "circularCannon", x: 1051.05, y: 286 }, { type: "basicBlock", x: 879.4, y: 183, width: 184.8, height: 100 }], level9: [{ type: "buzzsawVerticalUp", x: 1225.1, y: 425.9 }, { type: "buzzsaw", x: 1322.1, y: 459.9, width: 101, height: 102.2 }, { type: "buzzsawVerticalUp", x: 776.15, y: 325.9 }, { type: "buzzsawHorizontal", x: 1053.9, y: 573.95 }, { type: "buzzsaw", x: -265.4, y: -199.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: -26.35, y: -225.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: 29.7, y: -225.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: -119.4, y: -195.95, width: 51, height: 51.6 }, { type: "spike30x", x: -133.85, y: -47.9, rotation: 0 }, { type: "spike30x", x: 415.8, y: -47.9, rotation: 0 }, { type: "spike30x", x: 124.75, y: -47.9, rotation: 0 }, { type: "timedKey", x: 1054.8, y: 115.85 }, { type: "timedKey", x: 1054.8, y: 571.05 }, { type: "fallingBlock", x: 830.95, y: 155.55, width: 50, height: 50 }, { type: "fallingBlock", x: 1054.15, y: 185, width: 50, height: 50 }, { type: "fallingBlock", x: 1232.9, y: 155.55, width: 50, height: 50 }, { type: "bouncingBuzzsaw", x: 592.15, y: 308.35, width: 51 }, { type: "fallingSpike", x: 574.3, y: 564.9, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 542.9, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 521.4, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 499.4, rotation: 90 }, { type: "fallingSpike", x: 659, y: 609.4, rotation: -90 }, { type: "fallingSpike", x: 659, y: 631.4, rotation: -90 }, { type: "fallingSpike", x: 659, y: 652.9, rotation: -90 }, { type: "fallingSpike", x: 659, y: 674.9, rotation: -90 }, { type: "shurikanDispenser", x: 187.9, y: 300 }, { type: "shurikanDispenser", x: 187.9, y: 540 }, { type: "shurikanDispenser", x: 428, y: 542.95 }, { type: "shurikanDispenser", x: 428, y: 816.95 }, { type: "basicBlock", x: 368, y: 401.65, width: 200, height: 100 }, { type: "basicBlock", x: 246.9, y: 646.6, width: 200, height: 100 }, { type: "basicBlock", x: 91.4, y: 10, width: 750, height: 100 }, { type: "fallingSpike", x: 181.35, y: 126.55, rotation: 180 }, { type: "fallingSpike", x: 203.35, y: 126.55, rotation: 180 }, { type: "fallingSpike", x: -64.45, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -86.45, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -107.95, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -129.95, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: 79.55, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: 57.55, y: 152.1, rotation: 0 }, { type: "basicBlock", x: -8.1, y: 210, width: 750, height: 100 }, { type: "basicBlock", x: -118.1, y: 610, width: 330, height: 100 }, { type: "shurikanDispenser", x: -158.3, y: 403.55 }, { type: "shurikanDispenser", x: -1.05, y: 506.05 }, { type: "basicBlock", x: -333.1, y: 510, width: 100, height: 300 }, { type: "basicBlock", x: -233.1, y: 410, width: 100, height: 100 }, { type: "basicBlock", x: 96.9, y: 560.8, width: 100, height: 800 }, { type: "basicBlock", x: -80.1, y: 462, width: 50, height: 50 }, { type: "checkpoint", x: -243.25, y: 322 }, { type: "basicBlock", x: -208.1, y: 489.05, width: 50, height: 58 }, { type: "pole", x: -517.1, y: 304.55 }, { type: "pole", x: -649.1, y: 249.55 }, { type: "pole", x: -489.3, y: 200.55 }, { type: "shurikanDispenser", x: -597.4, y: 172.75 }, { type: "checkpoint", x: -322.6, y: 122 }, { type: "textFade", textNum: "5", x: -167.075, y: 537.3, rotation: .004364013671875 }, { type: "textFade", textNum: "5", x: -421.1, y: 298.17499999999995, rotation: -89.99563598632812 }, { type: "basicBlock", x: -750.05, y: 291.35, width: 100, height: 934.6 }, { type: "fallingSpike", x: -223.65, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -201.65, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -180.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -158.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -36.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -14.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: 7.35, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: 29.35, y: 67.9, rotation: 180 }, { type: "basicBlock", x: 196.9, y: 40, width: 100, height: 159.95 }, { type: "checkpoint", x: 316.35, y: 122.15 }, { type: "textFade", textNum: "5", x: 416.1, y: 249.575, rotation: 90.00436401367188 }, { type: "solarBlock", x: 416.9, y: 210, width: 100, height: 100 }, { type: "basicBlock", x: 516.4, y: 360.05, width: 100, height: 800 }, { type: "solarBlock", x: 616.4, y: 210, width: 100, height: 100 }, { type: "basicBlock", x: 406.9, y: 911, width: 520, height: 100 }, { type: "basicBlock", x: 716.4, y: 561, width: 100, height: 800 }, { type: "checkpoint", x: 741.5, y: 123 }, { type: "lightSwitch", x: 415.15, y: 120.55 }, { type: "swimmingPool", x: 406.9, y: 560.55, width: 520, height: 600.9 }, { type: "basicBlock", x: 1046, y: 676.45, width: 560.1, height: 100 }, { type: "basicBlock", x: 1424, y: -108.1, width: 200, height: 330.1 }, { type: "basicBlock", x: 1574, y: 231.95, width: 300, height: 150 }, { type: "lockBlock", x: 1474, y: 106.95, width: 100.05, height: 100 }, { type: "basicBlock", x: 1374, y: 441.6, width: 100.1, height: 570 }, { type: "bounceBlock", x: 1664.65, y: 126.95, width: 60, height: 60 }, { type: "textFade", textNum: "5", x: 1601.95, y: -1.9749999999999943, rotation: -104.99484252929688 }, { type: "ziplinePole", x: 1341, y: -308.1 }, { type: "ziplinePole", x: 517.1, y: -255 }, { type: "checkpoint", x: 420.15, y: -258 }, { type: "textFade", textNum: "5", x: 645.075, y: 132.6, rotation: .004364013671875 }, { type: "shurikanDispenser", x: 1125.55, y: -315.25 }, { type: "shurikanDispenser", x: 712.95, y: -287.8 }, { type: "basicBlock", x: 516.4, y: -124.8, width: 100, height: 190.25 }, { type: "basicBlock", x: 414.65, y: -169.9, width: 105.1, height: 100 }, { type: "checkpoint", x: 1463.85, y: -310.8 }, { type: "invisBlock", x: 196.9, y: -169.9, width: 100, height: 100 }, { type: "textFade", textNum: "39", x: 464.725, y: -165.175, rotation: 0 }, { type: "textFade", textNum: "40", x: 682.875, y: 61.625, rotation: 0 }, { type: "invisBlockUp", x: -.35, y: -225.95, width: 52, height: 52 }, { type: "invisBlockDown", x: -145.4, y: -195.95, width: 52, height: 52 }, { type: "invisBlockUp", x: -265.4, y: -225.95, width: 52, height: 52 }, { type: "invisBlockDown", x: -391.45, y: -285.95, width: 52, height: 52 }, { type: "invisBlockUp", x: -513.45, y: -193.95, width: 52, height: 52 }, { type: "finishPortal", x: -751.2, y: -205.55 }, { type: "star", x: 1053.25, y: 765.25 }, { type: "invisBlock", x: 1499, y: 751.6, width: 50, height: 50 }, { type: "invisBlock", x: 1449.05, y: 864.95, width: 50, height: 50 }, { type: "lockBlock", x: 1374, y: 106.95, width: 100.05, height: 100 }, { type: "invisBlock", x: 1351.05, y: 804.5, width: 50, height: 50 }, { type: "invisBlock", x: 1255.6, y: 864.95, width: 50, height: 50 }, { type: "invisBlock", x: 1149.6, y: 804.5, width: 50, height: 50 }, { type: "invisBlock", x: 1054.15, y: 864.95, width: 50, height: 50 }, { type: "invisBlock", x: 1556.05, y: 604.1, width: 50, height: 50 }, { type: "basicBlock", x: 923.9, y: 404, width: 100, height: 300 }, { type: "basicBlock", x: 1176.6, y: 404.55, width: 100, height: 300 }, { type: "swimmingPool", x: 1045, y: 410, width: 558, height: 432.9 }, { type: "spawnPoint", x: -258.25, y: 505.15 }, { type: "textFade", textNum: "5", x: 1679.375, y: 357.55, rotation: -179.9947509765625 }, { type: "textFade", textNum: "5", x: 1499.55, y: 647.975, rotation: 97.76797485351562 }, { type: "textFade", textNum: "5", x: 1335.3249999999998, y: 759.95, rotation: 180 }], level10: [{ type: "basicBlock", x: 143.1, y: 146.7, width: 56, height: 61 }, { type: "basicBlock", x: 604, y: -164.95, width: 224.1, height: 100 }, { type: "speedBlock", x: 266.95, y: -664.75, width: 50, height: 50 }, { type: "spike10x", x: 283.6, y: -590.15, rotation: -90 }, { type: "buzzsawHorizontal", x: 239, y: -493.95 }, { type: "speedBlock", x: 268.95, y: -518.5, width: 50, height: 50 }, { type: "spike10x", x: 184.05, y: -344.75, rotation: 90 }, { type: "speedBlockLeft", x: 200.15, y: -417.2, width: 50, height: 50 }, { type: "spike10x", x: 184.05, y: -489.75, rotation: 90 }, { type: "speedBlockLeft", x: 266.95, y: -173.15, width: 50, height: 50 }, { type: "bounceBlock", x: 266.95, y: 61.8, width: 50, height: 35 }, { type: "textFade", textNum: "5", x: -1026.25, y: 148.02499999999998, rotation: -74.99945068359375 }, { type: "spike10x", x: -323.25, y: -489.15, rotation: 90 }, { type: "spike10x", x: 67.85, y: -301.8, rotation: -90 }, { type: "reaper", x: -933.45, y: -363.45, width: 459, rotation: 0 }, { type: "reaper", x: -933.5, y: -362.55, width: 135.25, rotation: -45.001312255859375 }, { type: "reaper", x: -933.8, y: -362.05, width: 316.45, rotation: -89.99824523925781 }, { type: "bouncingBuzzsaw", x: -1122.5, y: 530.65, width: 57 }, { type: "bouncingBuzzsaw", x: -1218.35, y: 530.6, width: 56.95 }, { type: "basicBlock", x: -1307, y: -14, width: 100, height: 698 }, { type: "timedKey", x: -792.3, y: 774.25 }, { type: "bouncingBuzzsaw", x: -886.7, y: 598.3, width: 57 }, { type: "bouncingBuzzsaw", x: -708.1, y: 597.05, width: 57 }, { type: "bouncingBuzzsaw", x: -743.55, y: 530.65, width: 57 }, { type: "bouncingBuzzsaw", x: -839.4, y: 530.6, width: 56.95 }, { type: "checkpoint", x: -419.9, y: 593.55 }, { type: "spike30x", x: 159.2, y: 337.25, rotation: -90 }, { type: "spike10x", x: -38.15, y: 322.35, rotation: 0 }, { type: "fallingSpike", x: -104.2, y: 197.05, rotation: -90 }, { type: "fallingSpike", x: -104.2, y: 172.55, rotation: -90 }, { type: "fallingSpike", x: -104.2, y: 185.05, rotation: -90 }, { type: "basicBlock", x: -71, y: 141.4, width: 51, height: 122.65 }, { type: "ziplinePole", x: -445, y: 195.7 }, { type: "spike30x", x: -813.3, y: 259.85, rotation: 0 }, { type: "spike10x", x: -619.1, y: 259.85, rotation: 0 }, { type: "wire", x: 410.9, y: 30.05, rotation: -90 }, { type: "wire", x: 360.9, y: 30.05, rotation: -90 }, { type: "wire", x: 310.9, y: 30.05, rotation: -90 }, { type: "wire", x: 260.9, y: 30.05, rotation: -90 }, { type: "wire", x: 210.9, y: 30.05, rotation: -90 }, { type: "wire", x: 160.9, y: 30.05, rotation: -90 }, { type: "wire", x: 110.9, y: 30.05, rotation: -90 }, { type: "wire", x: 60.9, y: 30.05, rotation: -90 }, { type: "wire", x: 10.9, y: 30.05, rotation: -90 }, { type: "wire", x: -39.1, y: 30.05, rotation: -90 }, { type: "wire", x: -89.1, y: 30.05, rotation: -90 }, { type: "wire", x: -139.1, y: 30.05, rotation: -90 }, { type: "wire", x: -160.1, y: 59.05, rotation: 180 }, { type: "wire", x: -160.1, y: 109.05, rotation: 180 }, { type: "wire", x: -189.1, y: 130.05, rotation: -90 }, { type: "wire", x: -239.1, y: 130.05, rotation: -90 }, { type: "wire", x: -289.1, y: 130.05, rotation: -90 }, { type: "wire", x: -339.1, y: 130.05, rotation: -90 }, { type: "wire", x: -389.1, y: 130.05, rotation: -90 }, { type: "wire", x: -439.1, y: 130.05, rotation: -90 }, { type: "wire", x: -489.1, y: 130.05, rotation: -90 }, { type: "wire", x: -539.1, y: 130.05, rotation: -90 }, { type: "wire", x: -589.1, y: 130.05, rotation: -90 }, { type: "wire", x: -639.1, y: 130.05, rotation: -90 }, { type: "wire", x: -689.1, y: 130.05, rotation: -90 }, { type: "wire", x: -739.1, y: 130.05, rotation: -90 }, { type: "wire", x: -789.1, y: 130.05, rotation: -90 }, { type: "wire", x: -839.1, y: 130.05, rotation: -90 }, { type: "wire", x: -889.1, y: 130.05, rotation: -90 }, { type: "wire", x: -939.1, y: 130.05, rotation: -90 }, { type: "wire", x: -989.1, y: 130.05, rotation: -90 }, { type: "wire", x: -1039.1, y: 130.05, rotation: -90 }, { type: "wire", x: -1089.1, y: 130.05, rotation: -90 }, { type: "wire", x: -1110.1, y: 159.05, rotation: 180 }, { type: "basicBlock", x: 381.05, y: 127.3, width: 330, height: 100 }, { type: "finishPortal", x: 484.9, y: -51.75 }, { type: "explosiveBlock", x: 485.05, y: 27.3, width: 100, height: 100 }, { type: "basicBlock", x: -1222, y: 284, width: 329.9, height: 100 }, { type: "enlargingBuzzsaw", x: -782.2, y: 130.3, width: 124.7 }, { type: "basicBlock", x: -531.15, y: 279.75, width: 200, height: 100 }, { type: "invisBlock", x: -895.3, y: 229.65, width: 50, height: 50 }, { type: "invisBlockUp", x: -946.35, y: 109.65, width: 50, height: 50 }, { type: "basicBlock", x: -895.3, y: -9.25, width: 50, height: 50 }, { type: "basicBlock", x: -683.7, y: -9.25, width: 50, height: 50 }, { type: "checkpoint", x: -513.9, y: 191.75 }, { type: "basicBlock", x: -908, y: -313, width: 700, height: 100 }, { type: "basicBlock", x: -1008.95, y: 531, width: 100, height: 593.2 }, { type: "basicBlock", x: -794.9, y: 317.75, width: 335.9, height: 100 }, { type: "basicBlock", x: -381.15, y: -242, width: 100, height: 597.1 }, { type: "ziplinePole", x: -17.85, y: 294.7 }, { type: "basicBlock", x: -16.55, y: 379.75, width: 60, height: 100 }, { type: "fallingSpike", x: -82.05, y: 286.55, rotation: 0 }, { type: "fallingSpike", x: -57.55, y: 286.55, rotation: 0 }, { type: "fallingSpike", x: -70.05, y: 286.55, rotation: 0 }, { type: "basicBlock", x: -69.3, y: 393.1, width: 51, height: 197.8 }, { type: "ziplinePole", x: 65.75, y: 532.25 }, { type: "basicBlock", x: 113.05, y: 617.3, width: 110, height: 100 }, { type: "basicBlock", x: 193.05, y: 391.75, width: 50, height: 551.1 }, { type: "basicBlock", x: 10.7, y: 127.3, width: 214.8, height: 100 }, { type: "textFade", textNum: "5", x: 93.5, y: 269.275, rotation: 90.00175476074219 }, { type: "ziplinePole", x: -351.95, y: 596.5 }, { type: "basicBlock", x: -440.1, y: 680.55, width: 200, height: 100 }, { type: "basicBlock", x: -581.15, y: 338.35, width: 100, height: 217 }, { type: "buzzsawOnStick", x: -226.2, y: 552.5, rotation: -90 }, { type: "buzzsawOnStick", x: -90.95000000000002, y: 540.3, rotation: 90 }, { type: "laserPoint", x: -436.1, y: 315.1 }, { type: "laserPoint", x: -90.5, y: 315.1 }, { type: "hazardStrips", x: -94.8, y: 294.45 }, { type: "hazardStrips", x: -441.15, y: 229.75 }, { type: "basicBlock", x: -581.15, y: 784.4, width: 100, height: 486.9 }, { type: "lightSwitch", x: -499.1, y: 581.15 }, { type: "basicBlock", x: -958.75, y: 978.2, width: 656.2, height: 100 }, { type: "solarBlock", x: -1009.15, y: 878.2, width: 100, height: 100 }, { type: "basicBlock", x: -1337.15, y: 810, width: 100, height: 436.8 }, { type: "checkpoint", x: -1439.1, y: 554.65 }, { type: "lockBlock", x: -1337.15, y: 542, width: 100.05, height: 100 }, { type: "basicBlock", x: -1337, y: 412.8, width: 100, height: 158.5 }, { type: "basicBlock", x: -1475.65, y: 641.5, width: 178.9, height: 100 }, { type: "bounceBlock", x: -1540.1, y: 566.8, width: 50, height: 50 }, { type: "circularCannon", x: -1535.25, y: 236.3 }, { type: "shurikanDispenser", x: -1425.15, y: 142.65 }, { type: "shurikanDispenser", x: -1644.2, y: 142.65 }, { type: "shurikanDispenser", x: -1425.15, y: 329.7 }, { type: "shurikanDispenser", x: -1644.2, y: 329.7 }, { type: "circularCannon", x: -1535.25, y: -76.75 }, { type: "shurikanDispenser", x: -1425.15, y: -170.4 }, { type: "shurikanDispenser", x: -1644.2, y: -170.4 }, { type: "shurikanDispenser", x: -1425.15, y: 16.65 }, { type: "shurikanDispenser", x: -1644.2, y: 16.65 }, { type: "checkpoint", x: -1307.25, y: -401.35 }, { type: "basicBlock", x: -1756.4, y: 346.75, width: 100, height: 1224.1 }, { type: "textFade", textNum: "5", x: -1540.35, y: 448.07500000000005, rotation: -89.99824523925781 }, { type: "pushBlock", x: -1203.3, y: -427.15, width: 50, height: 49.9 }, { type: "checkpoint", x: -380.65, y: -578.55 }, { type: "shurikanSpawner", x: -263.15, y: -279.5, rotation: -90 }, { type: "shurikanSpawner", x: 29.2, y: -514.7, rotation: 90 }, { type: "shurikanSpawner", x: -153.05, y: -514.7, rotation: 90 }, { type: "iceBlock", x: -181.15, y: -490.55, width: 300, height: 100.05 }, { type: "iceBlock", x: -73.85, y: -303.2, width: 300, height: 100.05 }, { type: "iceBlock", x: -181.15, y: -98.15, width: 300, height: 100.05 }, { type: "shurikanSpawner", x: -301.1, y: -269.7, rotation: 0 }, { type: "shurikanSpawner", x: -80.9, y: -159.6, rotation: 180 }, { type: "shurikanSpawner", x: -318.6, y: -427.4, rotation: 0 }, { type: "spawnPoint", x: -1231.25, y: 209.9 }, { type: "swimmingPool", x: -959.2, y: 767.2, width: 656, height: 322.1 }, { type: "basicBlock", x: 341.95, y: 59.8, width: 100, height: 38 }, { type: "speedBlock", x: 201.15, y: -70.2, width: 50, height: 50 }, { type: "checkpoint", x: 169.25, y: 78.3 }, { type: "spike10x", x: 284.05, y: -97, rotation: -90 }, { type: "basicBlock", x: 341.95, y: -362.55, width: 100, height: 761.1 }, { type: "spike10x", x: 184.05, y: -246.75, rotation: 90 }, { type: "pole", x: 226, y: -342.45 }, { type: "checkpoint", x: 343.15, y: -781.1 }, { type: "basicBlock", x: 763.05, y: -85.8, width: 100, height: 528.8 }, { type: "textFade", textNum: "4", x: -544.8, y: -458.625, rotation: 0 }, { type: "textFade", textNum: "5", x: 254.55, y: -28.025, rotation: -90 }, { type: "basicBlock", x: 415.95, y: -718.1, width: 50, height: 50 }, { type: "basicBlock", x: 466.95, y: -565.25, width: 50, height: 147 }, { type: "basicBlock", x: 416.95, y: -418.35, width: 50, height: 50 }, { type: "lockBlock", x: 441.95, y: -164.95, width: 100.05, height: 100 }, { type: "timedKey", x: 683.85, y: -248.85 }, { type: "fallingBlock", x: 466.95, y: -418.35, width: 50, height: 50 }, { type: "fallingBlock", x: 516.95, y: -418.35, width: 50, height: 50 }, { type: "fallingBlock", x: 566.95, y: -418.35, width: 50, height: 50 }, { type: "fallingBlock", x: 616.95, y: -418.35, width: 50, height: 50 }, { type: "basicBlock", x: 516.95, y: -277.45, width: 50, height: 124.95 }, { type: "classicLaser", x: 423.95, y: -352.7 }, { type: "textFade", textNum: "42", x: -1166.65, y: 287.3, rotation: 0 }, { type: "basicBlock", x: 688.65, y: -324.65, width: 50, height: 50 }, { type: "basicBlock", x: 126, y: -448.8, width: 100, height: 807 }, { type: "lockBlock", x: 763.05, y: -400.4, width: 100.05, height: 100 }, { type: "basicBlock", x: 763.65, y: -714.5, width: 100, height: 528.8 }, { type: "basicBlock", x: 924.1, y: -300.65, width: 224.1, height: 100 }, { type: "timedKey", x: 993.65, y: -398.65 }, { type: "star", x: 942.25, y: -400.05 }, { type: "basicBlock", x: 925.7, y: -500.4, width: 224.1, height: 100 }, { type: "classicLaser", x: 1061.7, y: -404.65 }], level1c: [{ type: "spike10x", x: 45.9, y: 477.6, rotation: 90 }, { type: "spike10x", x: 145.05, y: 524.4, rotation: 180 }, { type: "spike10x", x: 41.05, y: 416.25, rotation: 180 }, { type: "textFade", textNum: "16", x: 643.375, y: 591.65, rotation: 179.99913024902344 }, { type: "reaper", x: 507.7, y: 552.35, width: 207.1, rotation: 0 }, { type: "leftSlope", x: 97, y: 147.85, width: 100, height: 100, rotation: -90 }, { type: "leftSlope", x: -427.1, y: 149.85, width: 100, height: 102, rotation: 180 }, { type: "basicBlock", x: 295.1, y: -90.95, width: 116, height: 100 }, { type: "spike30x", x: -417.1, y: -8.05, rotation: 0 }, { type: "spike30x", x: 5, y: -8.05, rotation: 0 }, { type: "spike10x", x: -263.1, y: 49.85, rotation: 90 }, { type: "spike10x", x: -149.1, y: 50, rotation: -90 }, { type: "basicBlock", x: -423.5, y: 49.85, width: 304.7, height: 100.05 }, { type: "basicBlock", x: 9.9, y: 50, width: 300.7, height: 100.05 }, { type: "spike10x", x: 137.1, y: -92.35, rotation: -90 }, { type: "basicBlock", x: 820, y: 670, width: 220, height: 100.05 }, { type: "textFade", textNum: "15", x: -588.025, y: 352.75, rotation: 179.99913024902344 }, { type: "textFade", textNum: "15", x: 493.775, y: 246.7, rotation: 0 }, { type: "textFade", textNum: "17", x: 62.25, y: 500.225, rotation: -90.00175476074219 }, { type: "textFade", textNum: "17", x: -906.95, y: 261.825, rotation: -90.00175476074219 }, { type: "textFade", textNum: "15", x: 842.75, y: 207.42499999999998, rotation: 90 }, { type: "textFade", textNum: "15", x: -625.075, y: -276.55, rotation: -.0008697509765625 }, { type: "checkpoint", x: -812.7, y: 61.85 }, { type: "bounceBlock", x: -903.95, y: 355, width: 50, height: 50 }, { type: "buzzsawVerticalUp", x: -787.9, y: 426.8 }, { type: "checkpoint", x: -494.8, y: 342.55 }, { type: "buzzsaw", x: 478.45, y: 319.4, width: 101, height: 102.2 }, { type: "buzzsaw", x: 587.45, y: 319.4, width: 101, height: 102.2 }, { type: "spike10x", x: 689.3, y: 201.85, rotation: -90 }, { type: "basicBlock", x: 722.2, y: 148.5, width: 50, height: 205.1 }, { type: "basicBlock", x: 620, y: 0, width: 780, height: 100.05 }, { type: "basicBlock", x: 360, y: 320, width: 230, height: 100.05 }, { type: "textFade", textNum: "10", x: 357.525, y: 318.475, rotation: 0 }, { type: "textFade", textNum: "8", x: 360.5, y: 178.89999999999998, rotation: 0 }, { type: "spawnPoint", x: 349.85, y: 260.45 }, { type: "basicBlock", x: 195, y: 188.7, width: 100, height: 659.3 }, { type: "basicBlock", x: 700, y: 320, width: 220, height: 100.05 }, { type: "textFade", textNum: "11", x: 699.9, y: 319.1, rotation: 0 }, { type: "basicBlock", x: 760, y: 445.05, width: 100, height: 150 }, { type: "basicBlock", x: 960, y: 484.75, width: 100, height: 871.5 }, { type: "verticalDownBlock", x: 885, y: 345.05, width: 50, height: 50 }, { type: "verticalUpBlock", x: 835, y: 495, width: 50, height: 50 }, { type: "textFade", textNum: "12", x: 831.875, y: 670.925, rotation: 0 }, { type: "checkpoint", x: 777.85, y: 582.2 }, { type: "fallingBlock", x: 685, y: 645, width: 50, height: 50 }, { type: "fallingBlock", x: 635, y: 645, width: 50, height: 50 }, { type: "basicBlock", x: 150, y: 670, width: 220, height: 100.05 }, { type: "checkpoint", x: 192.05, y: 582.2 }, { type: "textFade", textNum: "14", x: 148.7, y: 675.425, rotation: 0 }, { type: "bounceBlock", x: 65, y: 595.2, width: 50, height: 50 }, { type: "basicBlock", x: -10, y: 612, width: 100, height: 584 }, { type: "ziplinePole", x: -12.95, y: 285.05 }, { type: "ziplinePole", x: -428.9, y: 345.55 }, { type: "basicBlock", x: -464.95, y: 641.1, width: 100, height: 522.1 }, { type: "basicBlock", x: -737.55, y: 150, width: 186, height: 100.05 }, { type: "basicBlock", x: -572, y: 430, width: 116.05, height: 100.05 }, { type: "basicBlock", x: -1e3, y: -155.45, width: 100, height: 523.2 }, { type: "bounceBlock", x: -755.55, y: 75, width: 50, height: 50 }, { type: "basicBlock", x: -538.7, y: -179.55, width: 217.6, height: 100.05 }, { type: "ziplinePole", x: 193.05, y: -176.05 }, { type: "ziplinePole", x: -442.95, y: -264.55 }, { type: "finishPortal", x: 289, y: -170.85 }, { type: "basicBlock", x: 391.45, y: -274.9, width: 100, height: 467.1 }, { type: "basicBlock", x: -354.25, y: -458.45, width: 1391.6, height: 100.05 }, { type: "buzzsawVerticalUp", x: -309.3, y: -266.1 }, { type: "basicBlock", x: -1e3, y: 497.9, width: 100, height: 785.2 }, { type: "textFade", textNum: "18", x: -516.5250000000001, y: 280.5, rotation: 0 }, { type: "basicBlock", x: -892, y: 430, width: 116.05, height: 100.05 }, { type: "basicBlock", x: -562, y: 34, width: 171, height: 332.1 }, { type: "star", x: -206.05, y: 50.05 }, { type: "textFade", textNum: "41", x: -826.85, y: -3.575000000000003, rotation: 0 }, { type: "bouncingBuzzsaw", x: 886.5, y: 497.5, width: 39.6 }, { type: "circularCannon", x: 505.9, y: 552.8 }, { type: "basicBlock", x: 65, y: 384.95, width: 50, height: 50 }, { type: "basicBlock", x: 120, y: 493.35, width: 50, height: 50 }, { type: "buzzsawVerticalDown", x: -676.75, y: 426.8 }, { type: "classicLaser", x: -885.35, y: 147.5 }, { type: "classicLaser", x: -897.35, y: -212.7 }, { type: "classicLaser", x: -801.25, y: -212.7 }, { type: "classicLaser", x: -707.1, y: -212.7 }, { type: "buzzsawVerticalDown", x: -121.05, y: -243.05 }, { type: "buzzsawVerticalUp", x: 56.25, y: -218 }], level2c: [{ type: "shurikanSpawner", x: 918.55, y: -293.8, rotation: .0052490234375 }, { type: "shurikanDispenser", x: 1135.6, y: 141.2 }, { type: "spike30x", x: 1464, y: 232.9, rotation: 180 }, { type: "spike10x", x: 1658.2, y: 232.9, rotation: 180 }, { type: "buzzsaw", x: 716.25, y: 428, width: 71.25, height: 72.1 }, { type: "buzzsaw", x: 707.2, y: 300, width: 49.5, height: 50.1 }, { type: "buzzsaw", x: 715.25, y: 175, width: 71.25, height: 72.1 }, { type: "quadrantRight", x: 537.8, y: 489.7, rotation: 0 }, { type: "spike10x", x: -170.1, y: 77.7, rotation: 180 }, { type: "spike10x", x: -171.55, y: 114.6, rotation: 0 }, { type: "windBlaster", x: 82.2, y: 597.3, rotation: -90 }, { type: "shurikanSpawner", x: 1231.5, y: -471.35, rotation: 90.0052490234375 }, { type: "shurikanSpawner", x: 1085.85, y: -250, rotation: -89.9947509765625 }, { type: "shurikanSpawner", x: 990.45, y: -471.35, rotation: 90.0052490234375 }, { type: "basicBlock", x: 1085.3, y: -200, width: 460.2, height: 100 }, { type: "verticalUpBlock", x: 1137.3, y: -.05, width: 356.1, height: 150.1 }, { type: "verticalDownBlock", x: 1137.3, y: 225.05, width: 358, height: 100 }, { type: "basicBlock", x: 739.35, y: 175, width: 48.2, height: 100 }, { type: "ziplinePole", x: 1043.95, y: 530.05 }, { type: "shurikanSpawner", x: 795.9, y: 254.95, rotation: 180 }, { type: "basicBlock", x: 809.25, y: -128.65, width: 100, height: 1015.2 }, { type: "checkpoint", x: 562.35, y: -66 }, { type: "spike10x", x: 265.1, y: 14, rotation: 0 }, { type: "spike10x", x: 361.6, y: 14, rotation: 0 }, { type: "spike10x", x: 457.6, y: 14, rotation: 0 }, { type: "textFade", textNum: "17", x: -87.52499999999999, y: 222.55, rotation: -15.002182006835938 }, { type: "checkpoint", x: -107.8, y: 291.75 }, { type: "textFade", textNum: "20", x: 326.15, y: 487.17499999999995, rotation: 0 }, { type: "spike10x", x: 83.6, y: 461.15, rotation: 180 }, { type: "spike10x", x: 83.6, y: 588.4, rotation: 0 }, { type: "basicBlock", x: 449, y: 320, width: 230, height: 100.05 }, { type: "spawnPoint", x: 385.9, y: 245 }, { type: "basicBlock", x: 611, y: 470, width: 94, height: 800 }, { type: "basicBlock", x: 84.05, y: 261.7, width: 100, height: 383.1 }, { type: "basicBlock", x: 195.55, y: 647.05, width: 737.5, height: 100.05 }, { type: "basicBlock", x: -118.5, y: 464.75, width: 107, height: 272.1 }, { type: "textFade", textNum: "17", x: 269.9, y: 275.025, rotation: 90 }, { type: "basicBlock", x: 254.95, y: 46.8, width: 442.1, height: 50 }, { type: "basicBlock", x: 10, y: 252.7, width: 50, height: 50 }, { type: "basicBlock", x: -221, y: 308.05, width: 100, height: 778 }, { type: "basicBlock", x: 89.5, y: -3, width: 254, height: 50 }, { type: "spike", x: -104, y: 28.8, rotation: 180 }, { type: "spike", x: -115.5, y: 28.8, rotation: 180 }, { type: "spike", x: -115, y: -37.4, rotation: 0 }, { type: "spike", x: -103.5, y: -37.4, rotation: 0 }, { type: "verticalDownBlock", x: -109, y: -4, width: 25, height: 50 }, { type: "checkpoint", x: 45.5, y: -66 }, { type: "basicBlock", x: -121.55, y: 147.65, width: 100, height: 50 }, { type: "basicBlock", x: 591.6, y: 22, width: 235.1, height: 99.5 }, { type: "pushBlock", x: 165, y: -120, width: 50, height: 49.9 }, { type: "basicBlock", x: 295.3, y: -235.55, width: 929.6, height: 100.05 }, { type: "star", x: -223.95, y: -209.95 }, { type: "pushBlock", x: 734.25, y: -2.05, width: 50, height: 49.9 }, { type: "basicBlock", x: 682.2, y: 300, width: 50, height: 50 }, { type: "textFade", textNum: "17", x: 347.975, y: -62.55, rotation: -.00262451171875 }, { type: "basicBlock", x: 735.25, y: 428, width: 50, height: 100 }, { type: "sparkBlock", x: 809.1, y: 482.1, width: 100, height: 208.2 }, { type: "basicBlock", x: 1007.45, y: 716.85, width: 100, height: 305.95 }, { type: "checkpoint", x: 978.1, y: 525.9 }, { type: "textFade", textNum: "21", x: 124.25, y: 16.700000000000003, rotation: 0 }, { type: "textFade", textNum: "22", x: 603.325, y: 48.900000000000006, rotation: 0 }, { type: "ziplinePole", x: 1396.9, y: 576.55 }, { type: "basicBlock", x: 1395.9, y: 761, width: 100, height: 305.05 }, { type: "shurikanSpawner", x: 1183.45, y: 682.5, rotation: -89.9947509765625 }, { type: "basicBlock", x: 1544.9, y: 658.5, width: 200, height: 100 }, { type: "bounceBlock", x: 1538.9, y: 582.5, width: 52, height: 52 }, { type: "checkpoint", x: 1380.1, y: 87 }, { type: "basicBlock", x: 1516.45, y: 175, width: 400.1, height: 100 }, { type: "basicBlock", x: 909, y: 175, width: 100, height: 100 }, { type: "basicBlock", x: 883.1, y: 75, width: 48.2, height: 100 }, { type: "basicBlock", x: 1365.35, y: -25, width: 100, height: 100 }, { type: "basicBlock", x: 1465.35, y: -112, width: 100, height: 274.1 }, { type: "pushBlock", x: 1273.3, y: -338.6, width: 50, height: 49.9 }, { type: "basicBlock", x: 883.25, y: -336.55, width: 50, height: 175.05 }, { type: "finishPortal", x: 883.25, y: -453.55 }, { type: "basicBlock", x: 811, y: 819, width: 306.9, height: 100.05 }, { type: "spike", x: -55.5, y: 179.85, rotation: 180 }, { type: "spike", x: -67, y: 179.85, rotation: 180 }, { type: "spike", x: -66.5, y: 113.65, rotation: 0 }, { type: "spike", x: -55, y: 113.65, rotation: 0 }, { type: "verticalUpBlock", x: -60.5, y: 147.05, width: 25, height: 50 }, { type: "lockBlock", x: -15, y: 378.7, width: 100.05, height: 100 }, { type: "timedKey", x: 538.85, y: 489.55 }, { type: "swimmingPool", x: 249.25, y: 472.3, width: 630.5, height: 250 }, { type: "basicBlock", x: 809.1, y: 635.2, width: 100, height: 100 }, { type: "swimmingPool", x: 807.95, y: 677.5, width: 299.9, height: 185 }, { type: "bouncingBuzzsaw", x: 374.85, y: -145.6, width: 69.35 }, { type: "shurikanSpawner", x: 1125.15, y: 460.2, rotation: 90.0052490234375 }, { type: "shurikanSpawner", x: 1312.4, y: 460.2, rotation: 90.0052490234375 }, { type: "basicBlock", x: 1774.65, y: 346, width: 100, height: 100 }, { type: "checkpoint", x: 1445.15, y: 570.5 }, { type: "basicBlock", x: 1653.7, y: 610.05, width: 146.2, height: 196.9 }, { type: "spike10x", x: 1572.7, y: 560.2, rotation: -90 }, { type: "basicBlock", x: 1874.65, y: 296, width: 100, height: 200 }, { type: "checkpoint", x: 1352.15, y: -113 }, { type: "basicBlock", x: -146, y: 45.15, width: 50, height: 50 }], level3c: [{ type: "shurikanSpawner", x: 1604.95, y: 59.4, rotation: 180 }, { type: "textFade", textNum: "17", x: 175.275, y: 133.25, rotation: 0 }, { type: "buzzsawHorizontal", x: -108, y: 11.05 }, { type: "glassBlock", x: -107.9, y: 10.95, width: 100, height: 100.05 }, { type: "glassBlock", x: -107.9, y: 210.95, width: 100, height: 100.05 }, { type: "basicBlock", x: 715.55, y: 409.4, width: 40, height: 40 }, { type: "checkpoint", x: 616.25, y: 420.1 }, { type: "bounceBlock", x: 1587.4, y: 286.1, width: 46, height: 55 }, { type: "ziplinePole", x: 26.95, y: -86.85 }, { type: "checkpoint", x: -34.1, y: -89.8 }, { type: "basicBlock", x: -7.9, y: 252.7, width: 100, height: 611 }, { type: "spike30x", x: -749.75, y: 368.35, rotation: 180 }, { type: "spike30x", x: -697.7, y: 549.3, rotation: 0 }, { type: "spike30x", x: -456.65, y: 368.35, rotation: 180 }, { type: "spike30x", x: -406.6, y: 549.3, rotation: 0 }, { type: "bounceBlock", x: 987.15, y: 5.1, width: 45, height: 45 }, { type: "checkpoint", x: -107.35, y: 420.1 }, { type: "spike30x", x: 216.7, y: -61.15, rotation: 0 }, { type: "shurikanSpawner", x: 1436.75, y: 216.65, rotation: -90 }, { type: "spike10x", x: 1249.1, y: 77.1, rotation: 90 }, { type: "spike10x", x: 933, y: 79.1, rotation: -90 }, { type: "spike30x", x: 1090.45, y: 134, rotation: 180 }, { type: "basicBlock", x: 1091.05, y: 77.1, width: 300, height: 100.05 }, { type: "checkpoint", x: 1328.55, y: 120.95 }, { type: "basicBlock", x: 516.05, y: 208.1, width: 40, height: 40 }, { type: "checkpoint", x: 322.75, y: 120.95 }, { type: "bounceBlock", x: 97.05, y: 433.1, width: 50, height: 50 }, { type: "fallingBlock", x: 717, y: 707.1, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: 716, y: 537.075, rotation: -90 }, { type: "spawnPoint", x: 721, y: 643.1 }, { type: "basicBlock", x: 617.05, y: 607.1, width: 100, height: 300 }, { type: "basicBlock", x: 817, y: 457.1, width: 100, height: 600 }, { type: "buzzsawOnStick", x: 717.9, y: 705.8, rotation: -90 }, { type: "pole", x: 413.1, y: 393.1 }, { type: "basicBlock", x: 192.1, y: 607.6, width: 100, height: 299 }, { type: "textFade", textNum: "23", x: 412.15, y: 325.975, rotation: 0 }, { type: "textFade", textNum: "24", x: 412.175, y: 499.97499999999997, rotation: 0 }, { type: "basicBlock", x: -60, y: 508.1, width: 404.1, height: 100.05 }, { type: "pole", x: 90.3, y: 100.95 }, { type: "basicBlock", x: 317.05, y: 208.1, width: 100, height: 100.05 }, { type: "textFade", textNum: "25", x: -7.149999999999999, y: 179.075, rotation: 0 }, { type: "fallingBlock", x: 417.05, y: 208.1, width: 100, height: 100 }, { type: "fallingBlock", x: 617.05, y: 208.1, width: 100, height: 100 }, { type: "buzzsawOnStick", x: 516.4, y: 203.7, rotation: -90 }, { type: "iceBlock", x: 1087.05, y: 233.1, width: 440, height: 150.05 }, { type: "basicBlock", x: 1357.05, y: 408.1, width: 100, height: 500 }, { type: "textFade", textNum: "26", x: 951.5250000000001, y: 188.64999999999998, rotation: 0 }, { type: "basicBlock", x: 1531.05, y: 213.1, width: 78, height: 200 }, { type: "ziplinePole", x: 853.2, y: -232 }, { type: "basicBlock", x: 891.05, y: -147.95, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: 1152.3249999999998, y: 4.35, rotation: 180 }, { type: "basicBlock", x: -7.9, y: -350.1, width: 100, height: 400 }, { type: "basicBlock", x: -208, y: -172.5, width: 100, height: 1065.3 }, { type: "textFade", textNum: "27", x: -208.75, y: -57.9, rotation: 0 }, { type: "glassBlock", x: -107.9, y: 408.95, width: 100, height: 100.05 }, { type: "textFade", textNum: "17", x: -109.6, y: -151.425, rotation: 90 }, { type: "basicBlock", x: 202.2, y: -2.8, width: 321, height: 100.05 }, { type: "basicBlock", x: -600.2, y: 309.95, width: 685.1, height: 100.05 }, { type: "basicBlock", x: -550.3, y: 607, width: 785.3, height: 100.05 }, { type: "basicBlock", x: -892.9, y: 563.35, width: 100, height: 607.1 }, { type: "finishPortal", x: -810.2, y: 470.15 }, { type: "pole", x: -340.1, y: 463.1 }, { type: "pole", x: -551.15, y: 463.1 }, { type: "pole", x: -740.2, y: 463.1 }, { type: "shurikanSpawner", x: -727.4, y: 382.85, rotation: 45 }, { type: "fallingBlock", x: 67.1, y: -525.1, width: 50, height: 50 }, { type: "fallingBlock", x: 219.1, y: -549.1, width: 50, height: 50 }, { type: "fallingBlock", x: 378.75, y: -567.1, width: 50, height: 50 }, { type: "fallingBlock", x: 530.75, y: -591.1, width: 50, height: 50 }, { type: "buzzsawOnStick", x: 142.9, y: -543.1, rotation: -90 }, { type: "buzzsawOnStick", x: 304.75, y: -549.05, rotation: 90 }, { type: "buzzsawOnStick", x: 452.25, y: -581.2, rotation: -90 }, { type: "buzzsawOnStick", x: 614.1, y: -587.15, rotation: 90 }, { type: "star", x: 616.15, y: -678.15 }, { type: "basicBlock", x: 1657.05, y: 102.1, width: 100, height: 422 }, { type: "basicBlock", x: 1073.7, y: -393.9, width: 100, height: 592 }, { type: "basicBlock", x: 1572.6, y: -147.95, width: 269.1, height: 100.05 }, { type: "pushBlock", x: 1581.35, y: 87.9, width: 50, height: 49.9 }, { type: "pole", x: 1448.35, y: -57.85 }, { type: "buzzsawOnStick", x: 715.7, y: 414, rotation: 90 }, { type: "shurikanSpawner", x: -397.6, y: 540.5, rotation: -135 }, { type: "classicLaser", x: 414.55, y: 566.15 }, { type: "timedKey", x: 1384.8, y: 133.1 }, { type: "lockBlock", x: 1191.05, y: -22.9, width: 100.05, height: 100 }, { type: "basicBlock", x: 1135.75, y: -147.95, width: 26.3, height: 100.05 }, { type: "basicBlock", x: 1191.05, y: -135.4, width: 100, height: 125 }], level4c: [{ type: "fallingSpike", x: -587.55, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -609.05, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -501.45, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -522.95, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -415.3, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -436.8, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -329.2, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: -350.7, y: -466.45, rotation: 0 }, { type: "fallingSpike", x: 842.7, y: -369.6, rotation: -90 }, { type: "fallingSpike", x: 842.7, y: -348.1, rotation: -90 }, { type: "fallingSpike", x: 842.7, y: -412.7, rotation: -90 }, { type: "fallingSpike", x: 842.7, y: -391.2, rotation: -90 }, { type: "fallingSpike", x: 842.7, y: -434.2, rotation: -90 }, { type: "fallingSpike", x: 932.15, y: -167.85, rotation: 0 }, { type: "fallingSpike", x: 910.65, y: -167.85, rotation: 0 }, { type: "fallingSpike", x: 975.25, y: -167.85, rotation: 0 }, { type: "fallingSpike", x: 953.75, y: -167.85, rotation: 0 }, { type: "fallingSpike", x: 996.75, y: -167.85, rotation: 0 }, { type: "quadrantLeft", x: 944.25, y: 342.6, rotation: 0 }, { type: "verticalUpBlock", x: 943.25, y: 339.6, width: 32, height: 100 }, { type: "quadrantLeft", x: 1146.3, y: 342.6, rotation: 0 }, { type: "verticalDownBlock", x: 1145.3, y: 339.6, width: 32, height: 100 }, { type: "quadrantLeft", x: 91, y: 197.05, rotation: 0 }, { type: "spike10x", x: 703.05, y: 320, rotation: 89.99824523925781 }, { type: "spike10x", x: 746.5, y: 461.85, rotation: -.0008697509765625 }, { type: "spike10x", x: 786.1, y: 321.4, rotation: -90.00175476074219 }, { type: "fallingSpike", x: -393.75, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -372.25, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -479.85, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -458.35, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -566, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -544.5, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -652.1, y: -571.35, rotation: 180 }, { type: "fallingSpike", x: -630.6, y: -571.35, rotation: 180 }, { type: "basicBlock", x: -770.2, y: -567.4, width: 100, height: 225.2 }, { type: "spike30x", x: 200.45, y: -167.85, rotation: 0 }, { type: "spike10x", x: 8.05, y: -168.1, rotation: 0 }, { type: "spike10x", x: -87.45, y: -168.1, rotation: 0 }, { type: "textFade", textNum: "5", x: 37.05, y: 342.975, rotation: -90 }, { type: "textFade", textNum: "4", x: 617.5, y: -5.225000000000001, rotation: 0 }, { type: "windBlaster", x: 1249.1, y: 70.95, rotation: -90 }, { type: "buzzsaw", x: 1044.4, y: 340.25, width: 101, height: 102.2 }, { type: "glassBlock", x: 943.95, y: 143.65, width: 100, height: 100 }, { type: "basicBlock", x: 1043.95, y: 90.85, width: 100, height: 500 }, { type: "basicBlock", x: 666.85, y: 44.75, width: 50, height: 100 }, { type: "spike10x", x: 187.1, y: 318.25, rotation: -90.00175476074219 }, { type: "spike10x", x: 183.05, y: 485.85, rotation: 89.99824523925781 }, { type: "shurikanSpawner", x: 555.4, y: 311.8, rotation: 90 }, { type: "speedBlock", x: 545, y: 320, width: 300, height: 100.05 }, { type: "basicBlock", x: 345, y: 320, width: 100, height: 100.05 }, { type: "spawnPoint", x: 331.9, y: 240.55 }, { type: "basicBlock", x: 345, y: 615.35, width: 100, height: 291.2 }, { type: "basicBlock", x: 956.05, y: 520, width: 522.1, height: 100.05 }, { type: "speedBlockLeft", x: 545, y: 520, width: 300, height: 100.05 }, { type: "checkpoint", x: 347.3, y: 432 }, { type: "basicBlock", x: 844, y: 418, width: 100, height: 696 }, { type: "basicBlock", x: 245, y: 219.85, width: 100, height: 300 }, { type: "textFade", textNum: "5", x: 469.42499999999995, y: 236.05, rotation: 0 }, { type: "basicBlock", x: 87.3, y: 486.85, width: 176.7, height: 100.05 }, { type: "basicBlock", x: 545.05, y: 119.85, width: 500.1, height: 100.05 }, { type: "basicBlock", x: -50, y: 300.9, width: 100, height: 921.7 }, { type: "classicLaser", x: 154.05, y: 240.6 }, { type: "checkpoint", x: 252.35, y: 32 }, { type: "verticalUpBlock", x: 90, y: 194.05, width: 50, height: 100 }, { type: "basicBlock", x: 90, y: 343.1, width: 50, height: 100 }, { type: "textFade", textNum: "28", x: 332.4, y: 323.725, rotation: 0 }, { type: "basicBlock", x: 250, y: -109.75, width: 500.1, height: 100.05 }, { type: "bouncingBuzzsaw", x: 571.75, y: -75.8, width: 69 }, { type: "basicBlock", x: 940.9, y: -109, width: 402.1, height: 100.05 }, { type: "star", x: 450.95, y: -204.95 }, { type: "basicBlock", x: 350.05, y: -258.55, width: 100, height: 200 }, { type: "basicBlock", x: 473.05, y: -309, width: 346, height: 100.05 }, { type: "basicBlock", x: 691.85, y: -209, width: 100, height: 300 }, { type: "checkpoint", x: 839.4, y: 32 }, { type: "basicBlock", x: 1249.1, y: 423.1, width: 100, height: 706.3 }, { type: "checkpoint", x: 1081.8, y: -196.95 }, { type: "windBlaster", x: 789.85, y: -157.95, rotation: -90 }, { type: "windBlaster", x: 954.25, y: -341, rotation: 90 }, { type: "basicBlock", x: 948.85, y: -391, width: 198, height: 100.05 }, { type: "checkpoint", x: 401.35, y: -397.05 }, { type: "textFade", textNum: "5", x: 777.125, y: -393.65, rotation: 180 }, { type: "basicBlock", x: -150, y: 202, width: 100, height: 1122 }, { type: "buzzsawOnStick", x: 210.65, y: -299.35, rotation: 90 }, { type: "checkpoint", x: -255.85, y: -496.2 }, { type: "basicBlock", x: -459.9, y: -408.2, width: 720.6, height: 100.05 }, { type: "basicBlock", x: -459.25, y: -630, width: 720.6, height: 100.05 }, { type: "finishPortal", x: -690.05, y: -487.2 }, { type: "buzzsawOnStick", x: -21.199999999999996, y: -309, rotation: -90 }, { type: "textFade", textNum: "5", x: 248.175, y: 425.8, rotation: -165.00189208984375 }, { type: "swimmingPool", x: 1046.95, y: 331.8, width: 306, height: 276.3 }, { type: "iceBlock", x: 511.95, y: -396.8, width: 75, height: 75.05 }, { type: "basicBlock", x: 511.95, y: -500.3, width: 75, height: 132 }, { type: "spike30x", x: 46.4, y: -367.2, rotation: 0 }, { type: "iceBlock", x: 99.55, y: -309, width: 401, height: 100.05 }, { type: "pushBlock", x: 326.1, y: -418.15, width: 50, height: 49.9 }], level5c: [{ type: "laserPoint", x: 543.75, y: 565 }, { type: "laserPoint", x: 1269.1, y: 565 }, { type: "laserPoint", x: 122, y: 146.55 }, { type: "laserPoint", x: 231, y: 146.55 }, { type: "buzzsawOnStick", x: 349.95, y: 800.1, rotation: 90 }, { type: "buzzsawOnStick", x: 534.3, y: 791.4, rotation: -90 }, { type: "buzzsawOnStick", x: 157.9, y: 792.1, rotation: -90 }, { type: "quadrantLeft", x: 730.1, y: -192.5, rotation: 0 }, { type: "quadrantLeft", x: 1006.85, y: -192.5, rotation: 0 }, { type: "bounceBlock", x: 1439.4, y: 808.7, width: 50, height: 50 }, { type: "glassBlock", x: 390, y: 157.5, width: 126, height: 100 }, { type: "spike30x", x: -180.55, y: 465.85, rotation: -90 }, { type: "classicLaser", x: 275.15, y: 54.4 }, { type: "textFade", textNum: "15", x: 386, y: 219.525, rotation: 90.00175476074219 }, { type: "spike10x", x: 135.4, y: 462.45, rotation: 90 }, { type: "checkpoint", x: -95.8, y: 54.65 }, { type: "glassBlock", x: 389, y: -105.3, width: 122, height: 100 }, { type: "quadrantRight", x: 730.1, y: -192.5, rotation: 0 }, { type: "quadrantRight", x: 1006.85, y: -192.5, rotation: 0 }, { type: "textFade", textNum: "15", x: 1367.1, y: -10.025000000000006, rotation: -104.99729919433594 }, { type: "bounceBlock", x: 1396, y: 115, width: 50, height: 50 }, { type: "checkpoint", x: 1314.2, y: 102.65 }, { type: "spawnPoint", x: 715.8, y: 258 }, { type: "finishPortal", x: 1514.6, y: 552.25 }, { type: "basicBlock", x: 1314.1, y: 387.3, width: 100, height: 495.3 }, { type: "bouncingBuzzsaw", x: 914.1, y: 0, width: 101 }, { type: "bouncingBuzzsaw", x: 1114.1, y: 0, width: 101 }, { type: "basicBlock", x: 1414.1, y: 190, width: 100, height: 100 }, { type: "quadrantLeft", x: 1373, y: -83, rotation: 0 }, { type: "basicBlock", x: 1232.85, y: -142.5, width: 100.1, height: 100 }, { type: "textFade", textNum: "15", x: 804.125, y: 230, rotation: -14.99810791015625 }, { type: "checkpoint", x: 1234.6, y: -230.5 }, { type: "iceBlock", x: 905.3, y: -142.5, width: 556.9, height: 100.05 }, { type: "basicBlock", x: 573.8, y: -142.5, width: 106.1, height: 100 }, { type: "checkpoint", x: 578.55, y: -230.5 }, { type: "basicBlock", x: 1514, y: -35.35, width: 100, height: 1051.2 }, { type: "basicBlock", x: 497.75, y: 210.55, width: 100, height: 806.1 }, { type: "basicBlock", x: 277, y: 252.95, width: 100, height: 291 }, { type: "basicBlock", x: 226.7, y: 562, width: 200, height: 100 }, { type: "pushBlock", x: 470.15, y: -279.05, width: 50, height: 49.9 }, { type: "basicBlock", x: 26.95, y: 454, width: 200.1, height: 316.05 }, { type: "basicBlock", x: 77, y: -49.65, width: 100, height: 488.1 }, { type: "basicBlock", x: 177.55, y: -225.05, width: 301, height: 462.9 }, { type: "pole", x: 384.1, y: 439.65 }, { type: "rightSlope", x: -22.9, y: 247.55, width: 100, height: 100, rotation: 0 }, { type: "ziplinePole", x: -156.3, y: 58 }, { type: "ziplinePole", x: -599.15, y: 119.2 }, { type: "spike30x", x: -538.25, y: 195.6, rotation: 90 }, { type: "ziplinePole", x: -154.05, y: 379.25 }, { type: "classicLaser", x: -206.3, y: 202.7 }, { type: "ziplinePole", x: -599.15, y: 292.7 }, { type: "ziplinePole", x: -154.05, y: 414.3 }, { type: "ziplinePole", x: -599.15, y: 524.95 }, { type: "classicLaser", x: -512.65, y: 417.9 }, { type: "ziplinePole", x: -599.15, y: 575.95 }, { type: "ziplinePole", x: -135.05, y: 746.15 }, { type: "checkpoint", x: -63.55, y: 743.2 }, { type: "basicBlock", x: -123.1, y: 352, width: 100, height: 520 }, { type: "spike10x", x: -538.25, y: 595.35, rotation: 90 }, { type: "basicBlock", x: -596.15, y: 349.85, width: 100, height: 600.2 }, { type: "buzzsaw", x: 386.1, y: 560.4, width: 121.2, height: 122.65 }, { type: "buzzsawHorizontal", x: -320.25, y: 377.8 }, { type: "pole", x: 158.05, y: 796.25 }, { type: "pole", x: 350.1, y: 796.25 }, { type: "pole", x: 534.1, y: 796.25 }, { type: "basicBlock", x: 725, y: 831, width: 100, height: 100 }, { type: "checkpoint", x: 730.65, y: 743.25 }, { type: "basicBlock", x: -96.45, y: 831, width: 153, height: 100 }, { type: "hazardStrips", x: 538.75, y: 513.9 }, { type: "hazardStrips", x: 1264.1, y: 535.25 }, { type: "hazardStrips", x: 117, y: 93.65 }, { type: "hazardStrips", x: 227, y: 107.45 }, { type: "basicBlock", x: 1216.55, y: 856, width: 503.3, height: 50 }, { type: "basicBlock", x: 1167.3, y: 808.7, width: 236.1, height: 50 }, { type: "basicBlock", x: 1374.35, y: 808.7, width: 80.1, height: 50 }, { type: "basicBlock", x: 1514, y: 731.1, width: 100, height: 298.9 }, { type: "fallingBlock", x: 387.95, y: 346, width: 100, height: 100 }, { type: "star", x: -271.05, y: 435.1 }, { type: "bouncingBuzzsaw", x: 1210.35, y: 666.8, width: 65.5 }, { type: "quadrantLeft", x: 1373, y: -83, rotation: 45 }, { type: "fallingBlock", x: 714.1, y: 340.1, width: 100, height: 100 }, { type: "fallingBlock", x: 914.1, y: 289.95, width: 100, height: 100 }, { type: "fallingBlock", x: 1114.1, y: 240.15, width: 100, height: 100 }, { type: "basicBlock", x: 901.55, y: -331.8, width: 761.6, height: 100 }, { type: "classicLaser", x: -223.4, y: 548.25 }, { type: "classicLaser", x: -505.75, y: 202.7 }], level6c: [{ type: "quadrantRight", x: 290.8, y: -852.25, rotation: 0, width: 179.5 }, { type: "quadrantLeft", x: -44, y: -76.5, rotation: 44.99913024902344, width: 211.5 }, { type: "checkpoint", x: 311.95, y: -388.05 }, { type: "quadrantRight", x: 385.05, y: -737.25, rotation: 0, width: 179.5 }, { type: "spike10x", x: 28.6, y: 308.75, rotation: 180 }, { type: "spike30x", x: -171.4, y: 207.9, rotation: 180 }, { type: "textFade", textNum: "5", x: 752.425, y: -131, rotation: .0008697509765625 }, { type: "bounceBlock", x: 232, y: -74.5, width: 50, height: 50 }, { type: "checkpoint", x: 26.85, y: -338 }, { type: "quadrantRight", x: -44, y: -76.5, rotation: 0, width: 211.5 }, { type: "checkpoint", x: 402.8, y: 163.25 }, { type: "quadrantLeft", x: 680.2, y: 401.1, rotation: 0, width: 201.5 }, { type: "key", x: 675.1, y: 403.2 }, { type: "basicBlock", x: 380, y: 350, width: 200, height: 300 }, { type: "spawnPoint", x: 329.35, y: 173.9 }, { type: "finishPortal", x: 225.45, y: 770.5 }, { type: "lockBlock", x: 230, y: 250, width: 100.05, height: 100 }, { type: "lockBlock", x: 230, y: 350, width: 100.05, height: 100 }, { type: "lockBlock", x: 230, y: 450, width: 100.05, height: 100 }, { type: "lockBlock", x: 230, y: 550, width: 100.05, height: 100 }, { type: "basicBlock", x: 530, y: 398.5, width: 100, height: 397.1 }, { type: "basicBlock", x: 130, y: 550, width: 100, height: 700 }, { type: "basicBlock", x: 630, y: 150, width: 100, height: 100 }, { type: "basicBlock", x: 30, y: 200, width: 100, height: 200 }, { type: "textFade", textNum: "31", x: 336.07500000000005, y: 92.625, rotation: 0 }, { type: "textFade", textNum: "32", x: 333.9, y: 253.325, rotation: 0 }, { type: "basicBlock", x: 630, y: -50, width: 100, height: 100 }, { type: "basicBlock", x: 30, y: -150, width: 100, height: 300.1 }, { type: "basicBlock", x: 330, y: 0, width: 300, height: 100 }, { type: "basicBlock", x: 830, y: 300, width: 100, height: 600 }, { type: "checkpoint", x: 630.3, y: 62 }, { type: "checkpoint", x: 26.85, y: 62 }, { type: "swimmingPool", x: 680, y: 400, width: 200, height: 200 }, { type: "basicBlock", x: -170, y: -125, width: 100, height: 350 }, { type: "basicBlock", x: -169, y: 150, width: 300, height: 100 }, { type: "basicBlock", x: 330, y: 700, width: 100, height: 400 }, { type: "basicBlock", x: 580, y: 550, width: 400, height: 100 }, { type: "basicBlock", x: -95, y: 25, width: 50, height: 50 }, { type: "basicBlock", x: -45, y: -75, width: 50, height: 50 }, { type: "key", x: -106.1, y: -174.55 }, { type: "basicBlock", x: -70, y: -250, width: 100, height: 100 }, { type: "basicBlock", x: 330, y: -200, width: 100, height: 300.1 }, { type: "textFade", textNum: "5", x: 128.05, y: 61.975, rotation: -90 }, { type: "textFade", textNum: "5", x: 532.15, y: 56.575, rotation: -90 }, { type: "checkpoint", x: 640.5, y: -138 }, { type: "basicBlock", x: 1230, y: -50, width: 100, height: 100 }, { type: "buzzsawOnStick", x: 1004.1, y: -55, rotation: -90 }, { type: "buzzsawOnStick", x: 814.8, y: -274.45, rotation: 90 }, { type: "key", x: 816, y: -369.55 }, { type: "bounceBlock", x: 1230.3, y: -124.95, width: 50, height: 50 }, { type: "lockBlock", x: 230, y: 650, width: 100.05, height: 100 }, { type: "basicBlock", x: 230, y: 850, width: 100, height: 100 }, { type: "ziplinePole", x: -182.05, y: -335.1 }, { type: "ziplinePole", x: -749.2, y: -185.1 }, { type: "key", x: -504.2, y: -311.95 }, { type: "basicBlock", x: -750, y: -50, width: 100, height: 200 }, { type: "ziplinePole", x: -656.15, y: -84.55 }, { type: "ziplinePole", x: -259.05, y: 64.95 }, { type: "basicBlock", x: -650, y: 0, width: 100, height: 100 }, { type: "classicLaser", x: -249.1, y: -152.75 }, { type: "enlargingBuzzsaw", x: -437.1, y: -140.75, width: 101 }, { type: "basicBlock", x: -850, y: -175, width: 100, height: 450 }, { type: "textFade", textNum: "5", x: 732.05, y: 203.125, rotation: 90.00175476074219 }, { type: "textFade", textNum: "5", x: 172.775, y: -317.3, rotation: -179.99913024902344 }, { type: "windBlaster", x: 330, y: -350.05, rotation: -90 }, { type: "fallingBlock", x: 381, y: -548, width: 50, height: 50 }, { type: "fallingBlock", x: 291, y: -640, width: 50, height: 50 }, { type: "fallingBlock", x: 385, y: -734, width: 50, height: 50 }, { type: "fallingBlock", x: 291, y: -852, width: 50, height: 50 }, { type: "key", x: 345.5, y: -947.4 }, { type: "bounceBlock", x: -270, y: 650, width: 70, height: 70 }, { type: "key", x: 31.95, y: 569.3 }, { type: "bounceBlock", x: 30, y: 650, width: 70, height: 70 }, { type: "sparkBlock", x: 630, y: 250, width: 100, height: 100 }, { type: "speedBlock", x: 780, y: -50, width: 200, height: 100 }, { type: "shurikanDispenser", x: -117.05, y: 454.95 }, { type: "classicLaser", x: -634.05, y: -152.75 }, { type: "spike10x", x: 755.9, y: -499.7, rotation: -90.00175476074219 }, { type: "spike10x", x: 814.4, y: -558, rotation: 0 }, { type: "spike10x", x: 911.8, y: -558, rotation: 0 }, { type: "basicBlock", x: 863.8, y: -500.1, width: 200, height: 100 }, { type: "speedBlockLeft", x: 1080, y: -283.05, width: 200, height: 100 }], level7c: [{ type: "quadrantLeft", x: 692.15, y: 896.2, rotation: 45 }, { type: "reaper", x: 677.55, y: 654.45, width: 161.3, rotation: -90 }, { type: "horizontalBlockFast", x: 645.3, y: -494.6, width: 100, height: 100 }, { type: "buzzsawOnStick", x: 97.4, y: -302.8, rotation: -180 }, { type: "buzzsawOnStick", x: 106.6, y: -301.2, rotation: 0 }, { type: "fallingSpike", x: -529.8, y: 23.45, rotation: 90 }, { type: "buzzsawVerticalUp", x: -801, y: 1124.3 }, { type: "buzzsawVerticalUp", x: -537.55, y: 911.3 }, { type: "buzzsawVerticalUp", x: -537.55, y: 442.2 }, { type: "basicBlock", x: -173, y: 183.6, width: 150, height: 115 }, { type: "buzzsawOnStick", x: 101.19999999999999, y: -297.4, rotation: 90 }, { type: "buzzsawOnStick", x: 102.8, y: -306.6, rotation: -90 }, { type: "quadrantLeft", x: 798.2, y: 896.2, rotation: 89.99824523925781 }, { type: "quadrantLeft", x: 584.15, y: 896.2, rotation: 0 }, { type: "basicBlock", x: 251, y: 367, width: 100, height: 1733 }, { type: "basicBlock", x: 754.2, y: 995.75, width: 906.1, height: 100 }, { type: "checkpoint", x: 364.5, y: 894.2 }, { type: "breatheBlaster", x: 356.85, y: 926.1, rotation: -90 }, { type: "textFade", textNum: "5", x: 714.8, y: 508.67499999999995, rotation: 90.00175476074219 }, { type: "circularCannon", x: 392.15, y: 382.25 }, { type: "spike", x: 860, y: -581.35, rotation: 180 }, { type: "spike", x: 871, y: -581.35, rotation: 180 }, { type: "spike", x: 883, y: -581.35, rotation: 180 }, { type: "spike", x: 894, y: -581.35, rotation: 180 }, { type: "spike10x", x: 643.9, y: -581.65, rotation: 180 }, { type: "basicBlock", x: 643.9, y: -703.5, width: 100, height: 230 }, { type: "spike30x", x: 546.6, y: -507.7, rotation: 0 }, { type: "spike10x", x: 793.1, y: -654.1, rotation: -90 }, { type: "fallingSpike", x: -418.05, y: -49.25, rotation: 180 }, { type: "fallingSpike", x: -439.55, y: -49.25, rotation: 180 }, { type: "fallingSpike", x: -396.55, y: -49.25, rotation: 180 }, { type: "textFade", textNum: "5", x: 141.02499999999998, y: -436.525, rotation: -59.99946594238281 }, { type: "bounceBlock", x: 171.05, y: 216.05, width: 60, height: 60 }, { type: "bounceBlock", x: 31, y: 216.05, width: 60, height: 60 }, { type: "spike10x", x: -272.15, y: 376.65, rotation: 90 }, { type: "windBlaster", x: -135.1, y: 380.1, rotation: 180 }, { type: "spike10x", x: -144, y: 480.5, rotation: -90 }, { type: "textFade", textNum: "5", x: 94.8, y: 441.17499999999995, rotation: -89.99824523925781 }, { type: "fallingSpike", x: -319.3, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -361.3, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -340.8, y: 12.45, rotation: 180 }, { type: "fallingSpike", x: -297.8, y: 12.45, rotation: 180 }, { type: "basicBlock", x: -355.15, y: 109.95, width: 150, height: 115 }, { type: "buzzsawHorizontal", x: 78.05, y: 615.6 }, { type: "basicBlock", x: -41.1, y: 665.65, width: 486.9, height: 100 }, { type: "fallingSpike", x: -438.15, y: 58, rotation: -90 }, { type: "fallingSpike", x: -438.15, y: 78.5, rotation: -90 }, { type: "basicBlock", x: -330.15, y: -32.3, width: 100, height: 73.5 }, { type: "textFade", textNum: "5", x: -770.2, y: 627.125, rotation: 90.00175476074219 }, { type: "buzzsawVerticalUp", x: -736.6, y: 911.3 }, { type: "buzzsawVerticalUp", x: -479.95, y: 1124.3 }, { type: "textFade", textNum: "5", x: -770.2, y: 188.075, rotation: 90.00175476074219 }, { type: "buzzsawVerticalUp", x: -736.6, y: 442.2 }, { type: "basicBlock", x: -638.2, y: 127, width: 200, height: 768.3 }, { type: "basicBlock", x: -380.15, y: 706.65, width: 200, height: 1087.9 }, { type: "basicBlock", x: -1e3, y: 55, width: 200, height: 300 }, { type: "basicBlock", x: 1400, y: 56, width: 200, height: 300 }, { type: "finishPortal", x: 1236.25, y: 133.95 }, { type: "basicBlock", x: -950, y: 875, width: 300, height: 1425.1 }, { type: "basicBlock", x: 200, y: 1403, width: 2000.2, height: 370 }, { type: "basicBlock", x: 1350.1, y: 875.45, width: 300, height: 1425.1 }, { type: "basicBlock", x: 1200, y: -157.15, width: 600, height: 200 }, { type: "basicBlock", x: -638.2, y: 828.3, width: 200, height: 637.4 }, { type: "checkpoint", x: 230.85, y: -536.8 }, { type: "circularCannon", x: 102, y: -302 }, { type: "checkpoint", x: -469.95, y: 125.65 }, { type: "checkpointSwimming", x: 105.2, y: 182.2 }, { type: "basicBlock", x: -279.35, y: -157.15, width: 520, height: 200 }, { type: "basicBlock", x: -67, y: -104, width: 138, height: 1268.4 }, { type: "basicBlock", x: 351, y: -449, width: 100, height: 100 }, { type: "speedBlock", x: 601, y: -449, width: 400, height: 100 }, { type: "basicBlock", x: 850, y: -473.8, width: 100, height: 150 }, { type: "basicBlock", x: 332.85, y: -782.7, width: 938.4, height: 100 }, { type: "checkpoint", x: 959.1, y: -295.15 }, { type: "basicBlock", x: 850, y: -711.2, width: 100, height: 243.05 }, { type: "classicLaser", x: 746.15, y: -698.9 }, { type: "basicBlock", x: 1069.25, y: -542.8, width: 100, height: 573.1 }, { type: "basicBlock", x: 350.4, y: -207.15, width: 100, height: 100 }, { type: "basicBlock", x: 500, y: 27.85, width: 100, height: 570.7 }, { type: "hazardStrips", x: 540, y: -257.25 }, { type: "hazardStrips", x: 899.1, y: -257.25 }, { type: "classicLaser", x: 726.4, y: -136.3 }, { type: "laserPoint", x: 545, y: -207.25 }, { type: "laserPoint", x: 904.1, y: -207.25 }, { type: "checkpointSwimming", x: 383.25, y: 182.2 }, { type: "textFade", textNum: "5", x: 969.25, y: -475.575, rotation: 90.00175476074219 }, { type: "textFade", textNum: "5", x: 426.1, y: -146.525, rotation: 90.00175476074219 }, { type: "pole", x: 823.2, y: -339.5 }, { type: "pole", x: 642.15, y: -339.5 }, { type: "spawnPoint", x: -856.95, y: 127.35 }, { type: "basicBlock", x: 475.9, y: 539.5, width: 350, height: 100 }, { type: "reaper", x: 647.4, y: 389.05, width: 161.3, rotation: -90 }, { type: "basicBlock", x: 819.2, y: 465.65, width: 100, height: 760.9 }, { type: "basicBlock", x: 584.75, y: 785, width: 368.8, height: 100 }, { type: "reaper", x: 383.95, y: 662.35, width: 126.35, rotation: -90 }, { type: "textFade", textNum: "34", x: 357.25, y: 995.2750000000001, rotation: 0 }, { type: "textFade", textNum: "5", x: 1028.55, y: 777.625, rotation: -89.99824523925781 }, { type: "checkpoint", x: -187.5, y: 88.1 }, { type: "bouncingBuzzsaw", x: -239.6, y: 379.4, width: 47 }, { type: "bouncingBuzzsaw", x: 100.55, y: 285.55, width: 47 }, { type: "enlargingBuzzsaw", x: 735.15, y: -324.1, width: 73 }, { type: "solarBlock", x: 350.4, y: 785, width: 100, height: 100 }, { type: "lightSwitch", x: 381.1, y: 290.1 }, { type: "lightSwitch", x: 434.95, y: 902.7 }, { type: "solarBlock", x: 818.4, y: 896.2, width: 100, height: 100 }, { type: "swimmingPool", x: 200, y: 721.4, width: 2e3, height: 994 }], level8c: [{ type: "bounceBlock", x: 1692.95, y: 1120, width: 60, height: 60 }, { type: "speedBlock", x: 825.25, y: 1188.75, width: 325, height: 100 }, { type: "speedBlock", x: 1249.7, y: 1188, width: 325, height: 100 }, { type: "textFade", textNum: "5", x: 38, y: 999.4250000000001, rotation: 90 }, { type: "shurikanSpawner", x: 1783.55, y: 512.7, rotation: 180 }, { type: "basicBlock", x: 1294, y: 383.05, width: 112, height: 100 }, { type: "basicBlock", x: 738, y: 233.5, width: 100, height: 201 }, { type: "buzzsaw", x: 929.2, y: 338.05, width: 85, height: 86 }, { type: "buzzsaw", x: 929.2, y: 227.05, width: 85, height: 86 }, { type: "textFade", textNum: "5", x: 1589.65, y: 558.275, rotation: -90 }, { type: "textFade", textNum: "5", x: 1693.55, y: 938.775, rotation: -90 }, { type: "checkpoint", x: 481.85, y: 1099.65 }, { type: "laserPoint", x: 532.7, y: 970 }, { type: "laserPoint", x: 952, y: 970 }, { type: "textFade", textNum: "5", x: 190.025, y: 1101.1, rotation: 0 }, { type: "basicBlock", x: 263, y: 691.55, width: 100, height: 100.9 }, { type: "basicBlock", x: 1189.95, y: 884.6, width: 120.1, height: 249.2 }, { type: "finishPortal", x: 835.4, y: 303.25 }, { type: "basicBlock", x: 625.15, y: 383, width: 692.8, height: 100 }, { type: "spawnPoint", x: 315.95, y: 538.55 }, { type: "basicBlock", x: 114, y: 385, width: 330, height: 550 }, { type: "basicBlock", x: 444, y: 610, width: 330, height: 100 }, { type: "sparkBlock", x: 785, y: 610, width: 100, height: 100 }, { type: "basicBlock", x: 1e3, y: 688.6, width: 100, height: 257.4 }, { type: "checkpoint", x: 1046.65, y: 871.2 }, { type: "textFade", textNum: "35", x: 488.22499999999997, y: 615.1, rotation: 0 }, { type: "textFade", textNum: "5", x: 658.025, y: 524.8, rotation: 0 }, { type: "basicBlock", x: 1190, y: 496.45, width: 120, height: 326.8 }, { type: "hazardStrips", x: 599, y: 560.15 }, { type: "hazardStrips", x: 950, y: 560.15 }, { type: "laserPoint", x: 603.85, y: 610.4 }, { type: "laserPoint", x: 955, y: 610 }, { type: "textFade", textNum: "5", x: 1102.1, y: 558.275, rotation: 90 }, { type: "sparkBlock", x: 1190, y: 710, width: 120, height: 120 }, { type: "checkpoint", x: 415.2, y: 899.45 }, { type: "timedKey", x: 1348.9, y: 783.25 }, { type: "ziplinePole", x: 963.5, y: 875.4 }, { type: "ziplinePole", x: 485.8, y: 902.4 }, { type: "basicBlock", x: 1223.25, y: 959.2, width: 553.4, height: 100 }, { type: "basicBlock", x: 320.25, y: 987.45, width: 435.2, height: 100 }, { type: "reaper", x: 815.5, y: 857.25, width: 133.05, rotation: -90 }, { type: "basicBlock", x: 263, y: 937.45, width: 100, height: 200 }, { type: "solarBlock", x: 263, y: 1087.45, width: 100, height: 100 }, { type: "lightSwitch", x: 354.7, y: 899.8 }, { type: "checkpoint", x: 147.2, y: 899.45 }, { type: "lightSwitch", x: 73.05, y: 1039.9 }, { type: "sparkBlock", x: 36.7, y: 1167.4, width: 134, height: 134 }, { type: "sparkBlock", x: 263, y: 1187.45, width: 100, height: 100 }, { type: "sparkBlock", x: 396, y: 1173.55, width: 74, height: 74 }, { type: "basicBlock", x: 483, y: 1287, width: 100, height: 300 }, { type: "solarBlock", x: 263, y: 792, width: 100, height: 100 }, { type: "basicBlock", x: 263, y: 1387.45, width: 100, height: 300 }, { type: "hazardStrips", x: 527.85, y: 937.75 }, { type: "hazardStrips", x: 946.5, y: 909.5 }, { type: "basicBlock", x: 1400, y: 546.3, width: 100, height: 100 }, { type: "basicBlock", x: 1500, y: 734.3, width: 100, height: 549.8 }, { type: "swimmingPool", x: 1350.5, y: 784.85, width: 201, height: 250 }, { type: "checkpoint", x: 1501.6, y: 421.4 }, { type: "quadrantLeft", x: 709.15, y: 1188.25, rotation: 0 }, { type: "quadrantLeft", x: 930.2, y: 1188.25, rotation: 45 }, { type: "quadrantLeft", x: 1137.25, y: 1188.25, rotation: 0 }, { type: "quadrantLeft", x: 1358.3, y: 1188.25, rotation: 45 }, { type: "checkpoint", x: 1598.6, y: 1098.65 }, { type: "basicBlock", x: 1690.95, y: 1187, width: 88, height: 100.9 }, { type: "basicBlock", x: 79.95, y: 1487.15, width: 266.1, height: 100 }, { type: "timedKey", x: 1820.35, y: 1030.4 }, { type: "lightSwitch", x: 1640, y: 1105 }, { type: "bounceBlock", x: 1820, y: 1207.6, width: 60, height: 60 }, { type: "shurikanSpawner", x: 1560.9, y: 902.8, rotation: 0 }, { type: "shurikanSpawner", x: 1838.55, y: 855.8, rotation: 180 }, { type: "lockBlock", x: 1700, y: 746.75, width: 100.05, height: 100 }, { type: "basicBlock", x: 1600, y: 747.2, width: 100, height: 100.9 }, { type: "basicBlock", x: 1800, y: 436.75, width: 100, height: 720.2 }, { type: "basicBlock", x: 1598, y: 1286.65, width: 100, height: 300 }, { type: "bounceBlock", x: 1597.4, y: 671.75, width: 50, height: 50 }, { type: "textFade", textNum: "36", x: 402.775, y: 985.625, rotation: 0 }, { type: "textFade", textNum: "37", x: 1451, y: 538.5, rotation: 0 }, { type: "textFade", textNum: "5", x: 619.925, y: 1100.95, rotation: 0 }, { type: "lockBlock", x: 1300, y: 283, width: 100.05, height: 100 }, { type: "textFade", textNum: "5", x: 1394.3, y: 363.625, rotation: -90 }, { type: "basicBlock", x: 1900, y: 968.65, width: 100, height: 537.9 }, { type: "basicBlock", x: 1240.2, y: 183, width: 219.8, height: 100 }, { type: "basicBlock", x: -101, y: 946, width: 100, height: 1672 }, { type: "checkpoint", x: 1189.85, y: 295 }, { type: "circularCannon", x: 1051.05, y: 286 }, { type: "basicBlock", x: 879.4, y: 183, width: 184.8, height: 100 }, { type: "reaper", x: 625.85, y: 869.35, width: 133.05, rotation: -90 }, { type: "bounceBlock", x: 190.5, y: 1414.15, width: 45, height: 45 }, { type: "basicBlock", x: 127.65, y: 1134.4, width: 50, height: 200 }, { type: "shurikanDispenser", x: 41.95, y: 1337.3 }, { type: "shurikanSpawner", x: 1838.55, y: 992.8, rotation: 180 }], level9c: [{ type: "buzzsaw", x: -540.5, y: -193.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: -484.45, y: -193.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: -292.45, y: -225.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: -236.4, y: -225.95, width: 51, height: 51.6 }, { type: "enlargingBuzzsaw", x: -391.45, y: -285.95, width: 32.95 }, { type: "windBlaster", x: -194.9, y: 160, rotation: -90 }, { type: "windBlaster", x: -94.9, y: 59, rotation: 90 }, { type: "windBlaster", x: -6.6, y: 160, rotation: -90 }, { type: "windBlaster", x: 93.4, y: 59, rotation: 90 }, { type: "buzzsawVerticalUp", x: 1225.1, y: 425.9 }, { type: "buzzsaw", x: 1322.1, y: 459.9, width: 101, height: 102.2 }, { type: "buzzsawVerticalUp", x: 776.15, y: 325.9 }, { type: "enlargingBuzzsaw", x: 1053.9, y: 573.95, width: 101 }, { type: "buzzsaw", x: -26.35, y: -225.95, width: 51, height: 51.6 }, { type: "buzzsaw", x: 29.7, y: -225.95, width: 51, height: 51.6 }, { type: "enlargingBuzzsaw", x: -145.4, y: -195.95, width: 32.95 }, { type: "spike30x", x: -133.85, y: -47.9, rotation: 0 }, { type: "spike30x", x: 415.8, y: -47.9, rotation: 0 }, { type: "spike30x", x: 124.75, y: -47.9, rotation: 0 }, { type: "timedKey", x: 924.75, y: 590 }, { type: "timedKey", x: 1174.85, y: 590 }, { type: "bouncingBuzzsaw", x: 592.15, y: 308.35, width: 51 }, { type: "fallingSpike", x: 574.3, y: 564.9, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 542.9, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 521.4, rotation: 90 }, { type: "fallingSpike", x: 574.3, y: 499.4, rotation: 90 }, { type: "fallingSpike", x: 659, y: 609.4, rotation: -90 }, { type: "fallingSpike", x: 659, y: 631.4, rotation: -90 }, { type: "fallingSpike", x: 659, y: 652.9, rotation: -90 }, { type: "fallingSpike", x: 659, y: 674.9, rotation: -90 }, { type: "shurikanDispenser", x: 187.9, y: 300 }, { type: "shurikanDispenser", x: 187.9, y: 540 }, { type: "shurikanDispenser", x: 428, y: 542.95 }, { type: "shurikanDispenser", x: 428, y: 816.95 }, { type: "basicBlock", x: 366.4, y: 401.65, width: 200, height: 100 }, { type: "basicBlock", x: 246.9, y: 646.6, width: 200, height: 100 }, { type: "basicBlock", x: 91.4, y: 10, width: 750, height: 100 }, { type: "fallingSpike", x: 181.35, y: 126.55, rotation: 180 }, { type: "fallingSpike", x: 203.35, y: 126.55, rotation: 180 }, { type: "fallingSpike", x: -64.45, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -86.45, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -107.95, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: -129.95, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: 79.55, y: 152.1, rotation: 0 }, { type: "fallingSpike", x: 57.55, y: 152.1, rotation: 0 }, { type: "basicBlock", x: -8.1, y: 210, width: 750, height: 100 }, { type: "basicBlock", x: -118.1, y: 610, width: 330, height: 100 }, { type: "shurikanDispenser", x: -158.3, y: 403.55 }, { type: "shurikanDispenser", x: -1.05, y: 506.05 }, { type: "basicBlock", x: -333.1, y: 510, width: 100, height: 300 }, { type: "basicBlock", x: -233.1, y: 410, width: 100, height: 100 }, { type: "basicBlock", x: 96.9, y: 560.8, width: 100, height: 800 }, { type: "fallingBlock", x: -80.1, y: 462, width: 50, height: 50 }, { type: "checkpoint", x: -243.25, y: 322 }, { type: "basicBlock", x: -208.1, y: 489.05, width: 50, height: 58 }, { type: "pole", x: -534.1, y: 289.75 }, { type: "pole", x: -597.85, y: 90.75 }, { type: "shurikanDispenser", x: -597.4, y: 172.75 }, { type: "checkpoint", x: -322.6, y: 122 }, { type: "textFade", textNum: "5", x: -167.075, y: 537.3, rotation: .004364013671875 }, { type: "textFade", textNum: "5", x: -421.1, y: 298.17499999999995, rotation: -89.99563598632812 }, { type: "basicBlock", x: -750.05, y: 291.35, width: 100, height: 934.6 }, { type: "fallingSpike", x: -223.65, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -201.65, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -180.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -158.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -36.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: -14.15, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: 7.35, y: 67.9, rotation: 180 }, { type: "fallingSpike", x: 29.35, y: 67.9, rotation: 180 }, { type: "basicBlock", x: 196.9, y: 40, width: 100, height: 159.95 }, { type: "checkpoint", x: 316.35, y: 122.15 }, { type: "textFade", textNum: "5", x: 416.1, y: 249.575, rotation: 90.00436401367188 }, { type: "solarBlock", x: 416.9, y: 210, width: 100, height: 100 }, { type: "basicBlock", x: 516.4, y: 360.05, width: 100, height: 800 }, { type: "solarBlock", x: 616.4, y: 210, width: 100, height: 100 }, { type: "basicBlock", x: 406.9, y: 911, width: 520, height: 100 }, { type: "basicBlock", x: 716.4, y: 561, width: 100, height: 800 }, { type: "checkpoint", x: 741.5, y: 123 }, { type: "lightSwitch", x: 415.15, y: 120.55 }, { type: "swimmingPool", x: 406.9, y: 560.55, width: 520, height: 600.9 }, { type: "basicBlock", x: 1046, y: 676.45, width: 560.1, height: 100 }, { type: "basicBlock", x: 1424, y: -108.1, width: 200, height: 330.1 }, { type: "basicBlock", x: 1574, y: 231.95, width: 300, height: 150 }, { type: "lockBlock", x: 1474, y: 106.95, width: 100.05, height: 100 }, { type: "basicBlock", x: 1374, y: 441.6, width: 100.1, height: 570 }, { type: "bounceBlock", x: 1664.65, y: 126.95, width: 60, height: 60 }, { type: "textFade", textNum: "5", x: 1601.95, y: -1.9749999999999943, rotation: -104.99484252929688 }, { type: "ziplinePole", x: 1341, y: -308.1 }, { type: "ziplinePole", x: 938.25, y: -286 }, { type: "checkpoint", x: 420.15, y: -258 }, { type: "textFade", textNum: "5", x: 645.075, y: 132.6, rotation: .004364013671875 }, { type: "shurikanDispenser", x: 1125.55, y: -315.25 }, { type: "shurikanDispenser", x: 712.95, y: -287.8 }, { type: "basicBlock", x: 516.4, y: -124.8, width: 100, height: 190.25 }, { type: "basicBlock", x: 414.65, y: -169.9, width: 105.1, height: 100 }, { type: "checkpoint", x: 1463.85, y: -310.8 }, { type: "invisBlock", x: 196.9, y: -169.9, width: 100, height: 100 }, { type: "textFade", textNum: "39", x: 464.725, y: -165.175, rotation: 0 }, { type: "textFade", textNum: "40", x: 682.875, y: 61.625, rotation: 0 }, { type: "invisBlockUp", x: -.35, y: -225.95, width: 52, height: 52 }, { type: "invisBlockDown", x: -145.4, y: -195.95, width: 52, height: 52 }, { type: "invisBlockUp", x: -265.4, y: -225.95, width: 52, height: 52 }, { type: "invisBlockDown", x: -391.45, y: -285.95, width: 52, height: 52 }, { type: "invisBlockUp", x: -513.45, y: -193.95, width: 52, height: 52 }, { type: "finishPortal", x: -751.2, y: -205.55 }, { type: "star", x: 1053.25, y: 765.25 }, { type: "invisBlock", x: 1499, y: 751.6, width: 50, height: 50 }, { type: "invisBlock", x: 1449.05, y: 864.95, width: 50, height: 50 }, { type: "lockBlock", x: 1374, y: 106.95, width: 100.05, height: 100 }, { type: "invisBlock", x: 1351.05, y: 804.5, width: 50, height: 50 }, { type: "invisBlock", x: 1255.6, y: 864.95, width: 50, height: 50 }, { type: "invisBlock", x: 1149.6, y: 804.5, width: 50, height: 50 }, { type: "invisBlock", x: 1054.15, y: 864.95, width: 50, height: 50 }, { type: "invisBlock", x: 1556.05, y: 604.1, width: 50, height: 50 }, { type: "basicBlock", x: 923.9, y: 404, width: 100, height: 300 }, { type: "basicBlock", x: 1176.6, y: 404.55, width: 100, height: 300 }, { type: "spawnPoint", x: -258.55, y: 505.35 }, { type: "basicBlock", x: -675.05, y: 229, width: 50, height: 50 }, { type: "swimmingPool", x: 1045, y: 410, width: 558, height: 432.9 }, { type: "ziplinePole", x: 921.9, y: -284.1 }, { type: "ziplinePole", x: 519.15, y: -255 }, { type: "sparkBlock", x: 930.05, y: -230.95, width: 44, height: 44 }], level11: [], level12: [{ type: "basicBlock", x: 401, y: 123, width: 3e3, height: 99 }, { type: "verticalUpBlock", x: 397, y: -78, width: 100, height: 100 }, { type: "verticalDownBlock", x: 556, y: -78, width: 100, height: 100 }, { type: "horizontalBlock", x: 712, y: -86, width: 100, height: 100 }, { type: "horizontalBlockFast", x: 848, y: -83, width: 100, height: 100 }, { type: "fallingBlock", x: 1012, y: -88, width: 100, height: 100 }, { type: "bounceBlock", x: 1212, y: -99, width: 100, height: 100 }, { type: "pushBlock", x: 1340, y: 26, width: 106, height: 104 }, { type: "classicLaser", x: 1497, y: -188 }, { type: "textFade", x: 1816, y: 122, rotation: 0, textNum: 32 }, { type: "buzzsaw", x: 1574, y: 31, width: 101 }, { type: "ziplinePole", x: 1188, y: -184 }, { type: "ziplinePole", x: 1871, y: 24 }, { type: "finishPortal", x: 1893, y: 41 }, { type: "spawnPoint", x: 1023, y: 50 }] },
|
|
WireTrail = function() {
|
|
function t(t, e) { this.sparkSpeed = Constants.wireSparkSpeed, this.main = t, this.wires = e, this.spark = new Spark(t, t.game, t.topObstacleLayer, null), this.currentInd = e.length, this.spark.spawn(0, 0), this.nextWire(), this.main.obstacles.push(this.spark), this.burning = !1 }
|
|
return t.prototype.nextWire = function() {
|
|
if (0 === this.currentInd) return this.main.explosiveBlock.exploding = !0, void(this.burning = !1);
|
|
this.currentInd--, this.currentWire = this.wires[this.currentInd], this.spark.xPos = this.currentWire.xPos - 25 * Math.cos(this.currentWire.rad), this.spark.yPos = this.currentWire.yPos - 25 * Math.sin(this.currentWire.rad), this.sparkXSpeed = Math.cos(this.currentWire.rad) * this.sparkSpeed, this.sparkYSpeed = Math.sin(this.currentWire.rad) * this.sparkSpeed
|
|
}, t.prototype.update = function() {
|
|
if (this.burning) {
|
|
this.spark.xPos += this.sparkXSpeed, this.spark.yPos += this.sparkYSpeed, this.currentWire.sprite.scale.x -= this.sparkSpeed / 50, this.currentWire.sprite.scale.x <= 0 && (this.currentWire.sprite.scale.x = 0, this.nextWire());
|
|
var t = this.getpercent();
|
|
this.main.gameplayUI.updateProgressTnt(t)
|
|
}
|
|
}, t.prototype.getpercent = function() { for (var t = 0, e = this.wires.length, i = 0, s = this.wires; i < s.length; i++) { t += s[i].sprite.scale.x } return t / e }, t.prototype.startFollow = function() { this.followInd = 0, this.followWire = this.wires[this.followInd], this.followDist = 0, this.followX = this.followWire.xPos + 25 * Math.cos(this.followWire.rad) - this.main.game.width / 2, this.followY = this.followWire.yPos + 25 * Math.sin(this.followWire.rad) - this.main.game.height / 2, this.followXSpeed = -8 * Math.cos(this.followWire.rad), this.followYSpeed = -8 * Math.sin(this.followWire.rad) }, t.prototype.followTick = function() {
|
|
if (this.followX += this.followXSpeed, this.followY += this.followYSpeed, this.followDist += 8, 50 <= this.followDist) {
|
|
if (this.followInd++, this.followInd >= this.wires.length - 4) return !0;
|
|
this.followWire = this.wires[this.followInd], this.followDist = 0, this.followX = this.followWire.xPos + 25 * Math.cos(this.followWire.rad) - this.main.game.width / 2, this.followY = this.followWire.yPos + 25 * Math.sin(this.followWire.rad) - this.main.game.height / 2, this.followXSpeed = -8 * Math.cos(this.followWire.rad), this.followYSpeed = -8 * Math.sin(this.followWire.rad)
|
|
}
|
|
return this.main.game.camera.x = this.followX, this.main.game.camera.y = this.followY, !1
|
|
}, t.prototype.destroy = function() {
|
|
var t = this.main.obstacles.indexOf(this.spark);
|
|
this.main.obstacles.splice(t, 1), this.spark.destroy(), this.burning = !1, this.main = null, this.wires = null, this.spark = null
|
|
}, t.prototype.resetLevel = function() { for (var t = 0, e = this.wires; t < e.length; t++) { e[t].sprite.scale.set(1, 1) } this.currentInd = this.wires.length, this.nextWire() }, t
|
|
}(),
|
|
Bullet = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.game = e, s.layer = i, s.obstacleType = "bullet", s.sprite = s.layer.create(0, 0, "bullet"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s.deathBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 8, 8).toPolygon(), s.deathBoxPolygon.setOffset(new SAT.Vector(-4, -4)), s.graphics = s.game.add.graphics(0, 0, s.layer), s.graphics.visible = !0, s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s, o) { this.xPos = t, this.yPos = e, this.xVelocity = i, this.yVelocity = s, this.rad = o, this.sprite.position.set(t, e), this.sprite.rotation = o, this.deathBoxPolygon.pos.x = t, this.deathBoxPolygon.pos.y = e, this.deathBoxPolygon.setAngle(o), this.alive = !0, this.sprite.visible = !0 }, t.prototype.update = function() {
|
|
if (this.alive) {
|
|
this.xPos += this.xVelocity * this.main.gameSpeed, this.yPos += this.yVelocity * this.main.gameSpeed, this.updatePositions();
|
|
for (var t = 0, e = this.main.blocks; t < e.length; t++) {
|
|
var i = e[t];
|
|
if (SAT.testPolygonPolygon(i.totalBoundPolygon, this.deathBoxPolygon)) {
|
|
for (var s = 0; s < 10; s++) this.main.createColorParticle(this.xPos, this.yPos, 16 * Math.random() - 8, 16 * Math.random() - 8, 16711680);
|
|
this.die()
|
|
}
|
|
}
|
|
SAT.testPolygonPolygon(this.deathBoxPolygon, this.main.player.totalPolygon) && (this.main.player.kill(14), this.die())
|
|
}
|
|
}, t.prototype.updatePositions = function() { this.sprite.position.set(this.xPos, this.yPos), this.deathBoxPolygon.pos.x = this.xPos, this.deathBoxPolygon.pos.y = this.yPos }, t.prototype.die = function() { this.alive = !1, this.sprite.visible = !1 }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.deathBoxPolygon = null, this.graphics.destroy(), this.graphics = null }, t.prototype.resetLevel = function() { this.die() }, t
|
|
}(Obstacle),
|
|
Buzzsaw = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "buzzsaw"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s.deathCircle = new SAT.Circle(new SAT.Vector(0, 0), 44), s.obstacleType = "buzzsaw", s.killValue = 2, s }
|
|
return __extends(t, o), t.prototype.levelStart = function() {
|
|
for (var t = 0, e = this.main.pools; t < e.length; t++) {
|
|
var i = e[t];
|
|
SAT.testCirclePolygon(this.deathCircle, i.totalPolygon) && this.main.underPoolLayer.addChild(this.sprite)
|
|
}
|
|
}, t.prototype.spawn = function(t, e, i) { void 0 === i && (i = 1), this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.deathCircle.pos.x = t, this.deathCircle.pos.y = e, this.alive = !0, 1 != i && (this.sprite.scale.set(i, i), this.deathCircle.r = 44 * i) }, t.prototype.update = function() { this.sprite.rotation += 4 * Math.PI / 180 }, t.prototype.updatePosition = function() { this.sprite.position.set(this.xPos, this.yPos), this.deathCircle.pos.x = this.xPos, this.deathCircle.pos.y = this.yPos }, t.prototype.destroy = function() { this.sprite.destroy(), this.deathCircle = null, o.prototype.destroy.call(this) }, t
|
|
}(Obstacle),
|
|
BuzzsawVerticalUp = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.maxMoveDist = 100, s.obstacleType = "buzzsaw", s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) { void 0 === i && (i = -2), this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.yVelocity = i, this.startY = e, this.deathCircle.pos.x = t, this.deathCircle.pos.y = e, this.alive = !0 }, t.prototype.update = function() {
|
|
o.prototype.update.call(this);
|
|
var t = this.yPos;
|
|
this.yVelocity < 0 ? this.yPos < this.startY - this.maxMoveDist && (this.yVelocity = -this.yVelocity) : this.yPos > this.startY + this.maxMoveDist && (this.yVelocity = -this.yVelocity), this.yPos += this.yVelocity, this.yPos != t && this.updatePosition()
|
|
}, t.prototype.updatePosition = function() { this.sprite.position.set(this.xPos, this.yPos), this.deathCircle.pos.y = this.yPos }, t.prototype.reset = function() { this.yVelocity = -2, this.updatePosition() }, t.prototype.resetLevel = function() { this.reset() }, t
|
|
}(Buzzsaw),
|
|
BuzzsawHorizontal = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.maxMoveDist = 100, s.obstacleType = "buzzsaw", s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) { void 0 === s && (s = 1), this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.xVelocity = -i, this.startSpeed = i, this.startX = t, this.startY = e, this.deathCircle.pos.x = t, this.deathCircle.pos.y = e, this.alive = !0, 1 != s && (this.sprite.scale.set(s, s), this.deathCircle.r = 45 * s) }, t.prototype.update = function() {
|
|
o.prototype.update.call(this);
|
|
var t = this.xPos;
|
|
0 < this.xVelocity ? this.xPos > this.startX + this.maxMoveDist && (this.xVelocity = -this.xVelocity) : this.xPos < this.startX - this.maxMoveDist && (this.xVelocity = -this.xVelocity), this.xPos += this.xVelocity, this.xPos != t && (this.sprite.position.x = this.xPos, this.deathCircle.pos.x = this.xPos)
|
|
}, t.prototype.reset = function() { this.xVelocity = -this.startSpeed, this.xPos = this.startX, this.yPos = this.startY, this.updatePosition() }, t.prototype.resetLevel = function() { this.reset() }, t
|
|
}(Buzzsaw),
|
|
BouncingBuzzsaw = function(s) {
|
|
function t(t, e, i) { return s.call(this, t, e, i) || this }
|
|
return __extends(t, s), t.prototype.spawn = function(t, e, i) { void 0 === i && (i = 1), s.prototype.spawn.call(this, t, e, i), this.yVelocity = 0, this.speedUp = -1 }, t.prototype.update = function() { this.alive && (this.yVelocity += this.main.gravity * this.main.gameSpeed, this.yPos += this.yVelocity, this.updatePosition(), this.checkBlockCollisions()), s.prototype.update.call(this) }, t.prototype.checkBlockCollisions = function() {
|
|
for (var t = 0, e = this.main.blocks; t < e.length; t++) {
|
|
var i = e[t];
|
|
i.alive && (SAT.testPolygonCircle(i.topBoundPolygon, this.deathCircle) && void 0 === i.falling && (-1 === this.speedUp ? this.speedUp = Math.abs(this.yVelocity) : this.yVelocity = this.speedUp, this.yVelocity *= -1, this.yPos = i.yPos - i.height / 2 - this.deathCircle.r))
|
|
}
|
|
}, t.prototype.reset = function() { this.yPos = this.startY, this.yVelocity = 0, this.updatePosition() }, t.prototype.resetLevel = function() { this.reset(), s.prototype.resetLevel.call(this) }, t
|
|
}(Buzzsaw),
|
|
EnlargingBuzzsaw = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.obstacleType = "buzzsaw", s.alive = !1, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) { void 0 === i && (i = 1), this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.visible = !0, this.enlarging = !0, this.deathCircle.pos.x = t, this.deathCircle.pos.y = e, this.scaleXStart = i, this.scaleYStart = i, this.scale = i, this.alive = !0 }, t.prototype.update = function() { this.enlarging ? (this.scale += .02 * this.scaleXStart * this.main.gameSpeed, this.scale > 2.5 * this.scaleXStart && (this.scale = 2.5 * this.scaleXStart, this.enlarging = !1)) : (this.scale -= .02 * this.scaleXStart * this.main.gameSpeed, this.scale < .5 * this.scaleXStart && (this.scale = .5 * this.scaleXStart, this.enlarging = !0)), o.prototype.update.call(this), this.updatePosition() }, t.prototype.updatePosition = function() { this.sprite.scale.set(this.scale, this.scale), this.sprite.position.set(this.xPos, this.yPos), this.deathCircle.pos.y = this.yPos, this.deathCircle.r = 42 * this.scale }, t.prototype.resetLevel = function() {}, t
|
|
}(Buzzsaw),
|
|
BuzzsawOnStick = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "buzzsawOnStick"), s.sprite.autoCull = !0, s.sprite.anchor.set(.1, .5), s.sprite.visible = !1, s.obstacleType = "misc", s.buzzsaw = new Buzzsaw(s.main, s.game, s.layer), s.main.obstacles.push(s.buzzsaw), s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i) {
|
|
this.xPos = t, this.yPos = e, this.rotation = i, this.startRotation = i, this.sprite.position.set(t, e), this.sprite.rotation = i, this.sprite.visible = !0, this.alive = !0;
|
|
var s = this.rotation * Math.PI / 180;
|
|
this.buzzsaw.spawn(this.xPos + 130 * Math.cos(s), this.yPos + 130 * Math.sin(s), .5)
|
|
}, t.prototype.update = function() { this.rotation += 8, this.updatePosition() }, t.prototype.updatePosition = function() {
|
|
var t = this.rotation * Math.PI / 180;
|
|
this.sprite.rotation = t, this.buzzsaw.xPos = this.xPos + 130 * Math.cos(t), this.buzzsaw.yPos = this.yPos + 130 * Math.sin(t), this.buzzsaw.updatePosition()
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.buzzsaw = null }, t.prototype.resetLevel = function() { this.rotation = this.startRotation, this.updatePosition() }, t
|
|
}(Obstacle),
|
|
Spike10x = function(s) {
|
|
function t(t, e, i) { return s.call(this, t, e, i) || this }
|
|
return __extends(t, s), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "spike10x"), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5), this.sprite.visible = !1, this.graphics = this.game.add.graphics(0, 0, this.layer), this.graphics.visible = !1, this.width = 97.2, this.height = 14.6 }, t
|
|
}(Spike),
|
|
Spike30x = function(s) {
|
|
function t(t, e, i) { return s.call(this, t, e, i) || this }
|
|
return __extends(t, s), t.prototype.init = function() { this.sprite = this.layer.create(0, 0, "spike30x"), this.sprite.autoCull = !0, this.sprite.anchor.set(.5, .5), this.sprite.visible = !1, this.graphics = this.game.add.graphics(0, 0, this.layer), this.graphics.visible = !1, this.width = 291.2, this.height = 11.75, this.spikeNum = 30 }, t
|
|
}(Spike),
|
|
FallingSpike = function(r) {
|
|
function t(t, e, i, s) {
|
|
void 0 === s && (s = !1);
|
|
var o = r.call(this, t, e, i) || this;
|
|
o.game = e, o.layer = i, o.obstacleType = "spike", o.sprite = o.layer.create(0, 0, "fallingSpike"), o.sprite.autoCull = !0, o.sprite.anchor.set(.5, .5), o.sprite.visible = !1, o.alive = !1, o.dispenser = s, o.graphics = o.game.add.graphics(0, 0, o.layer), o.graphics.visible = !0, o.width = 7.5, o.height = 14.75, o.deathBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), o.width, o.height).toPolygon();
|
|
var n = .5 * o.width,
|
|
a = .5 * o.height;
|
|
return o.deathBoxPolygon.setOffset(new SAT.Vector(-n, -a)), o
|
|
}
|
|
return __extends(t, r), t.prototype.spawn = function(t, e, i) { this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.rotation = i, this.rad = i * Math.PI / 180, this.xVelocity = 0, this.yVelocity = 0, this.sprite.position.set(t, e), this.sprite.angle = i, this.dispenser || (this.sprite.visible = !0), this.alive = !0, this.deathBoxPolygon.pos.x = t, this.deathBoxPolygon.pos.y = e, this.falling = !1, this.fallDist = 0, this.speed = 0 }, t.prototype.levelStart = function() {
|
|
this.range = 350;
|
|
for (var t = this.rotation * Math.PI / 180, e = 0, i = 10; i <= this.range;) {
|
|
for (var s = new SAT.Polygon(new SAT.Vector(this.xPos, this.yPos), [new SAT.Vector(0, 0), new SAT.Vector(Math.cos(t) * i, Math.sin(t) * i)]), o = 0, n = this.main.blocks; o < n.length; o++) {
|
|
var a = n[o],
|
|
r = new SAT.Response;
|
|
SAT.testPolygonPolygon(s, a.totalBoundPolygon, r) && Math.abs(r.overlap) > e && (e = Math.abs(r.overlap))
|
|
}
|
|
if (0 < e) { i -= e; break }
|
|
if (i === this.range) break;
|
|
(i += 20) > this.range && (i = this.range)
|
|
}
|
|
this.hitDist = i, this.searchHitBox = new SAT.Box(new SAT.Vector(this.xPos, this.yPos), this.hitDist, 16).toPolygon(), this.searchHitBox.offset = new SAT.Vector(0, -8), this.searchHitBox.setAngle(t)
|
|
}, t.prototype.update = function() {
|
|
if (this.alive)
|
|
if (this.falling) this.xVelocity += Math.cos(this.rad) * this.main.gravity, this.yVelocity += Math.sin(this.rad) * this.main.gravity, this.speed += this.main.gravity, this.xPos += this.xVelocity, this.yPos += this.yVelocity, this.fallDist += this.speed, this.updatePositions(), this.fallDist > this.hitDist && this.reset();
|
|
else {
|
|
if (this.xPos != this.startX || this.yPos != this.startY) {
|
|
var t = this.startX - this.xPos,
|
|
e = this.startY - this.yPos;
|
|
Math.abs(t) < 1 ? this.xPos = this.startX : this.xPos += t / 5, Math.abs(e) < 1 ? this.yPos = this.startY : this.yPos += (this.startY - this.yPos) / 5, this.updatePositions()
|
|
}
|
|
var i = this.main.player;
|
|
SAT.testPolygonPolygon(this.searchHitBox, i.totalPolygon) && (this.falling = !0)
|
|
}
|
|
}, t.prototype.updatePositions = function() { this.sprite.position.set(this.xPos, this.yPos), this.deathBoxPolygon.pos.x = this.xPos, this.deathBoxPolygon.pos.y = this.yPos }, t.prototype.reset = function() { this.dispenser ? this.die() : (this.falling = !1, this.xPos = this.startX - 15 * Math.cos(this.rad), this.yPos = this.startY - 15 * Math.sin(this.rad), this.xVelocity = 0, this.yVelocity = 0, this.sprite.position.set(this.xPos, this.yPos), this.deathBoxPolygon.pos.x = this.xPos, this.deathBoxPolygon.pos.y = this.yPos, this.fallDist = 0, this.speed = 0) }, t.prototype.dispenserFire = function() { this.falling = !0, this.alive = !0, this.xPos = this.startX + 15 * Math.cos(this.rad), this.yPos = this.startY + 15 * Math.sin(this.rad), this.xVelocity = 0, this.yVelocity = 0, this.sprite.position.set(this.xPos, this.yPos), this.sprite.visible = !0, this.deathBoxPolygon.pos.x = this.xPos, this.deathBoxPolygon.pos.y = this.yPos, this.fallDist = 0, this.speed = 0 }, t.prototype.die = function() { this.sprite.visible = !1, this.alive = !1 }, t.prototype.destroy = function() { this.sprite.destroy(), this.searchHitBox = null, this.deathBoxPolygon = null, this.graphics.destroy(), r.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { this.reset() }, t
|
|
}(Obstacle),
|
|
ShurikanHorizontal = function(n) {
|
|
function t(t, e, i, s) { var o = n.call(this, t, e, i) || this; return o.spawner = s, o.sprite = i.create(0, 0, "shurikanHorizontal"), o.sprite.autoCull = !0, o.sprite.anchor.set(.5, .5), o.sprite.visible = !1, o.obstacleType = "shurikan", o.alive = !1, o.hitBoxPoly = new SAT.Box(new Vector(-3001, 0), 20, 20).toPolygon(), o.hitBoxPoly.setOffset(new SAT.Vector(-10, -10)), o }
|
|
return __extends(t, n), t.prototype.spawn = function(t, e, i, s, o) { void 0 === o && (o = 0), this.xPos = t, this.yPos = e, this.xVelocity = i, this.yVelocity = s, this.speed = Math.sqrt(i * i + s * s), this.dist = 0, this.sprite.position.set(t, e), this.sprite.scale.set(1, 1), this.sprite.frame = o, this.sprite.visible = !0, this.alive = !0, this.rotation = 0 }, t.prototype.update = function() {
|
|
if (this.alive) {
|
|
if (this.rotation += 15 * this.main.gameSpeed, 200 < this.dist) {
|
|
if (this.sprite.scale.x -= .1 * this.main.gameSpeed, this.sprite.scale.y = this.sprite.scale.x, this.sprite.scale.x <= .1) {
|
|
this.alive = !1, this.sprite.visible = !1;
|
|
var t = this.spawner.shurikanActivePool.indexOf(this);
|
|
this.spawner.shurikanActivePool.splice(t, 1), this.spawner.shurikanPool.push(this), this.spawner.spawned--
|
|
}
|
|
}
|
|
else this.xPos += this.xVelocity, this.yPos += this.yVelocity, this.dist += this.speed;
|
|
this.sprite.position.set(this.xPos, this.yPos), this.hitBoxPoly.pos.x = this.xPos, this.hitBoxPoly.pos.y = this.yPos, this.sprite.rotation = this.rotation * Math.PI / 180
|
|
}
|
|
}, t.prototype.resetLevel = function() {
|
|
this.sprite.visible = !1;
|
|
var t = this.spawner.shurikanActivePool.indexOf(this);
|
|
this.spawner.shurikanActivePool.splice(t, 1), this.spawner.shurikanPool.push(this)
|
|
}, t.prototype.destroy = function() { this.alive = !1, this.sprite.destroy(), this.hitBoxPoly = null, n.prototype.destroy.call(this) }, t
|
|
}(Obstacle),
|
|
ShurikanSpawner = function(a) {
|
|
function o(t, e, i) {
|
|
var s = a.call(this, t, e, i) || this;
|
|
s.sprite = i.create(0, 0, "shurikanSpawner"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.obstacleType = "spawner", s.alive = !1, s.shurikanActivePool = [], s.shurikanPool = [];
|
|
for (var o = 0; o < 3; o++) {
|
|
var n = new ShurikanHorizontal(s.main, s.game, s.layer, s);
|
|
s.shurikanPool.push(n), s.main.obstacles.push(n)
|
|
}
|
|
return s
|
|
}
|
|
return __extends(o, a), o.prototype.spawn = function(t, e, i) { for (this.xPos = t, this.yPos = e, this.rotation = i, this.sprite.position.set(t, e), this.sprite.rotation = i * Math.PI / 180, this.cooldown = 0, this.spawned = 0, this.alive = !0; 0 < this.shurikanActivePool.length;) this.shurikanActivePool[0].resetLevel() }, o.prototype.update = function() {
|
|
if (this.alive && this.spawned < 3 && (this.cooldown += this.main.gameSpeed, this.cooldown > o.fireTimer)) {
|
|
this.cooldown = 0;
|
|
var t = this.shurikanPool.pop();
|
|
if (!t) return;
|
|
var e = 1.3 * Math.cos(this.rotation * Math.PI / 180),
|
|
i = 1.3 * Math.sin(this.rotation * Math.PI / 180),
|
|
s = 0;
|
|
90 == this.rotation || -90 == this.rotation ? s = 1 : 0 != this.rotation && -180 != this.rotation && 180 != this.rotation && (s = 2), this.shurikanActivePool.push(t), t.spawn(this.xPos, this.yPos, e, i, s), this.spawned++, 3 === this.spawned && (this.cooldown = -60)
|
|
}
|
|
}, o.prototype.resetLevel = function() { this.spawned = 0, this.cooldown = 0 }, o.prototype.destroy = function() {
|
|
for (; 0 < this.shurikanActivePool.length;) this.shurikanActivePool[0].resetLevel();
|
|
for (var t = 0; t < 3; t++) this.shurikanPool[t].destroy();
|
|
this.shurikanPool = null, this.sprite.destroy(), this.sprite = null, this.shurikanPool = null, a.prototype.destroy.call(this)
|
|
}, o.fireTimer = 30, o
|
|
}(Obstacle),
|
|
ClassicLaser = function(o) {
|
|
function h(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "classicLaser"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.bullet = new Bullet(t, e, t.obstacleLayer), s.main.obstacles.push(s.bullet), s.alive = !1, s }
|
|
return __extends(h, o), h.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.rad = Math.PI / 2, this.sprite.position.set(t, e), this.sprite.rotation = this.rad, this.spinDest = Math.PI / 2, this.shootTimer = 0 }, h.prototype.levelStart = function() { this.storeNearbyPlatforms() }, h.prototype.storeNearbyPlatforms = function() {
|
|
this.platforms = [];
|
|
for (var t = new SAT.Circle(new SAT.Vector(this.xPos, this.yPos), 250), e = 0, i = this.main.blocks; e < i.length; e++) {
|
|
var s = i[e];
|
|
SAT.testCirclePolygon(t, s.totalBoundPolygon) && this.platforms.push(s)
|
|
}
|
|
}, h.prototype.update = function() {
|
|
var t = this.main.player;
|
|
if (t && t.alive) {
|
|
var e = !0;
|
|
if (Math.pow(this.xPos - t.xPos, 2) + Math.pow(this.yPos - t.yPos, 2) <= h.RANGE_SQ) { for (var i = new SAT.Polygon(new Vector(0, 0), [new SAT.Vector(this.xPos, this.yPos), new SAT.Vector(t.xPos, t.yPos)]), s = new SAT.Polygon(new Vector(0, 0), [new SAT.Vector(this.xPos, this.yPos), new SAT.Vector(t.xPos, t.yPos - t.height)]), o = 0, n = this.platforms; o < n.length; o++) { var a = n[o]; if (SAT.testPolygonPolygon(i, a.totalBoundPolygon) && SAT.testPolygonPolygon(s, a.totalBoundPolygon)) { e = !1; break } } e && (this.spinDest = Math.atan2(t.yPos - this.yPos, t.xPos - this.xPos), this.shootTimer++, this.shootTimer >= h.FIRE_RATE && (this.shootTimer = 0, this.bullet.spawn(this.xPos, this.yPos, 25 * Math.cos(this.rad), 25 * Math.sin(this.rad), this.rad), this.main.sounds.playSound("laserFire"))) }
|
|
else this.spinDest = Math.PI / 2;
|
|
var r = this.rad - this.spinDest;
|
|
Math.abs(r) < .5 * Math.PI / 180 ? this.rad = this.spinDest : r > 200 * Math.PI / 180 ? this.rad = this.spinDest : this.rad -= .25 * r, this.sprite.rotation = this.rad
|
|
}
|
|
}, h.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, h.prototype.reset = function() { this.shootTimer = 0 }, h.prototype.resetLevel = function() { this.reset(), this.rad = Math.PI / 2, this.spinDest = Math.PI / 2 }, h.FIRE_RATE = 40, h.RANGE_SQ = 62500, h
|
|
}(Obstacle),
|
|
Quadrant = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "quadrant"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s.obstacleType = "quadrant", s.deathHitBoxPolygons = [], s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s, o) {
|
|
var n;
|
|
void 0 === o && (o = 1), this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.rad = i * Math.PI / 180, this.startRad = this.rad, this.rotSpeed = s, this.sprite.position.set(t, e), this.sprite.visible = !0, this.sprite.scale.set(o, o), this.alive = !0, this.attachHitBoxPolygon = new SAT.Box(new SAT.Vector(t, e), 10, 10).toPolygon(), this.attachHitBoxPolygon.setOffset(new SAT.Vector(-5, -5)), (n = new SAT.Box(new SAT.Vector(0, 0), 10 * o, 10 * o).toPolygon()).setOffset(new SAT.Vector(75 * o, 0)), this.deathHitBoxPolygons.push(n), (n = new SAT.Box(new SAT.Vector(0, 0), 10 * o, 10 * o).toPolygon()).setOffset(new SAT.Vector(0, 75 * o)), this.deathHitBoxPolygons.push(n), (n = new SAT.Box(new SAT.Vector(0, 0), 10 * o, 10 * o).toPolygon()).setOffset(new SAT.Vector(-75 * o, 0)), this.deathHitBoxPolygons.push(n), (n = new SAT.Box(new SAT.Vector(0, 0), 10 * o, 10 * o).toPolygon()).setOffset(new SAT.Vector(0, -75 * o)), this.deathHitBoxPolygons.push(n)
|
|
}, t.prototype.update = function() { this.rad += this.rotSpeed, this.updatePosition() }, t.prototype.updatePosition = function() {
|
|
this.sprite.position.set(this.xPos, this.yPos), this.sprite.rotation = this.rad;
|
|
for (var t = 0, e = this.deathHitBoxPolygons; t < e.length; t++) {
|
|
var i = e[t];
|
|
i.pos.x = this.xPos, i.pos.y = this.yPos, i.setAngle(this.rad)
|
|
}
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.deathHitBoxPolygons = null, o.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { this.rad = this.startRad, this.updatePosition() }, t
|
|
}(Obstacle),
|
|
LaserPoint = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.laserGraphic = e.add.graphics(0, 0, i), s.obstacleType = "laser", s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) { this.xPos = t, this.yPos = e, this.xLength = i - t, this.yLength = s - e, this.alive = !0, this.deathHitBoxPolygon = new SAT.Polygon(new SAT.Vector(this.xPos, this.yPos), [new SAT.Vector(0, 0), new SAT.Vector(i - t, s - e)]), this.laserGraphic.position.set(this.xPos, this.yPos), this.laserGraphic.lineStyle(2, 16724787), this.laserGraphic.moveTo(0, 0), this.laserGraphic.lineTo(i - t, s - e) }, t.prototype.update = function() {
|
|
if (Math.random() < .05) {
|
|
var t = Math.random(),
|
|
e = this.xPos + this.xLength * t,
|
|
i = this.yPos + this.yLength * t;
|
|
this.main.createColorParticle(e, i, 10 * Math.random() - 5, -5 * Math.random(), 16711680, 4, !1, !1, 10, !0)
|
|
}
|
|
}, t.prototype.destroy = function() { this.game = null, this.layer = null, this.laserGraphic.destroy(), this.laserGraphic = null, o.prototype.destroy.call(this) }, t
|
|
}(Obstacle),
|
|
Reaper = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.sprite = i.create(0, 0, "reaper"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.visible = !1, s.obstacleType = "reaper", s.killValue = 2, s.deathHitBoxes = [], s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e, i, s) {
|
|
void 0 === s && (s = 1), this.xPos = t, this.yPos = e, this.startX = t, this.startY = e, this.rad = i * Math.PI / 180, this.startRad = this.rad, this.sprite.position.set(t, e), this.sprite.scale.set(s / 2, s / 2), this.sprite.visible = !0, this.alive = !0;
|
|
var o = new SAT.Box(new SAT.Vector(t, e), 13.4 * s, 8.6 * s).toPolygon();
|
|
o.setOffset(new SAT.Vector(-13.4 * s, -75 * s)), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 6.35 * s, 6.3 * s).toPolygon()).setOffset(new SAT.Vector(-42 * s, -65 * s)), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 2.9 * s, 2.9 * s).toPolygon()).setOffset(new SAT.Vector(-59 * s, -46 * s)), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 1.5 * s, 1.5 * s).toPolygon()).setOffset(new SAT.Vector(-66 * s, -26 * s)), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 13.4 * s, 8.6 * s).toPolygon()).setOffset(new SAT.Vector(-13.4 * s, -75 * s)), o.setAngle(Math.PI), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 6.35 * s, 6.3 * s).toPolygon()).setOffset(new SAT.Vector(-42 * s, -65 * s)), o.setAngle(Math.PI), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 2.9 * s, 2.9 * s).toPolygon()).setOffset(new SAT.Vector(-59 * s, -46 * s)), o.setAngle(Math.PI), this.deathHitBoxes.push(o), (o = new SAT.Box(new SAT.Vector(t, e), 1.5 * s, 1.5 * s).toPolygon()).setOffset(new SAT.Vector(-66 * s, -26 * s)), o.setAngle(Math.PI), this.deathHitBoxes.push(o)
|
|
}, t.prototype.update = function() { this.rad += -5 * Math.PI / 180, this.updatePositions() }, t.prototype.updatePositions = function() {
|
|
this.sprite.position.set(this.xPos, this.yPos), this.sprite.rotation = this.rad;
|
|
for (var t = 0; t < this.deathHitBoxes.length; t++) {
|
|
var e = this.deathHitBoxes[t];
|
|
t < 4 ? e.setAngle(this.rad) : e.setAngle(this.rad + Math.PI)
|
|
}
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.deathHitBoxes = null, o.prototype.destroy.call(this) }, t.prototype.resetLevel = function() { this.rad = this.startRad }, t
|
|
}(Obstacle),
|
|
Spark = function(n) {
|
|
function t(t, e, i, s) { var o = n.call(this, t, e, i) || this; return o.sparkBlock = s, o.obstacleType = "spark", o.sprite = o.layer.create(0, 0, "spark"), o.sprite.autoCull = !0, o.sprite.anchor.set(.5, .5), o.sprite.visible = !1, o.deathBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 16, 16).toPolygon(), o.deathBoxPolygon.setOffset(new SAT.Vector(-8, -8)), o }
|
|
return __extends(t, n), t.prototype.spawn = function(t, e) { this.sparkBlock && (t = this.sparkBlock.leftEdge, e = this.sparkBlock.topEdge, this.direction = "right"), this.xPos = t, this.yPos = e, this.alive = !0, this.sprite.visible = !0, this.updatePositions() }, t.prototype.update = function() {
|
|
if (this.sparkBlock) switch (this.direction) {
|
|
case "right":
|
|
this.xPos += 5 * this.main.gameSpeed, this.xPos > this.sparkBlock.rightEdge && (this.xPos = this.sparkBlock.rightEdge, this.direction = "down");
|
|
break;
|
|
case "down":
|
|
this.yPos += 5 * this.main.gameSpeed, this.yPos > this.sparkBlock.bottomEdge && (this.yPos = this.sparkBlock.bottomEdge, this.direction = "left");
|
|
break;
|
|
case "left":
|
|
this.xPos -= 5 * this.main.gameSpeed, this.xPos < this.sparkBlock.leftEdge && (this.xPos = this.sparkBlock.leftEdge, this.direction = "up");
|
|
break;
|
|
case "up":
|
|
this.yPos -= 5 * this.main.gameSpeed, this.yPos < this.sparkBlock.topEdge && (this.yPos = this.sparkBlock.topEdge, this.direction = "right")
|
|
}
|
|
Math.random() < .2 && this.main.createColorParticle(this.xPos, this.yPos, 10 * Math.random() - 5, 5 * Math.random(), 16763904, 4, !1, !1, 10, !0), this.updatePositions();
|
|
for (var t = 0, e = this.main.pools; t < e.length; t++) {
|
|
var i = e[t];
|
|
SAT.testPolygonPolygon(this.deathBoxPolygon, i.totalPolygon) && (i.electric = !0)
|
|
}
|
|
}, t.prototype.updatePositions = function() { this.sprite.position.set(this.xPos, this.yPos), this.deathBoxPolygon.pos.x = this.xPos, this.deathBoxPolygon.pos.y = this.yPos }, t.prototype.resetLevel = function() {
|
|
if (this.sparkBlock) {
|
|
var t = this.sparkBlock.leftEdge,
|
|
e = this.sparkBlock.topEdge;
|
|
this.direction = "right", this.xPos = t, this.yPos = e
|
|
}
|
|
this.updatePositions()
|
|
}, t.prototype.destroy = function() { null !== this.sprite && (this.sprite.destroy(), this.sprite = null, this.deathBoxPolygon = null) }, t
|
|
}(Obstacle),
|
|
ShurikanDispenser = function(a) {
|
|
function r(t, e, i) {
|
|
var s = a.call(this, t, e, i) || this;
|
|
s.sprite = i.create(0, 0, "shurikanDispenser"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.sprite.animations.add("spawn"), s.sprite.visible = !1, s.obstacleType = "shurikan", s.alive = !1, s.hitBoxPoly = new SAT.Box(new Vector(0, 0), 20, 20).toPolygon(), s.hitBoxPoly.setOffset(new SAT.Vector(-10, -10)), s.spikes = [];
|
|
for (var o = 0; o < 4; o++) {
|
|
var n = new FallingSpike(t, e, s.layer, !0);
|
|
s.spikes[o] = n, s.main.obstacles.push(n)
|
|
}
|
|
return s
|
|
}
|
|
return __extends(r, a), r.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.sprite.scale.set(1, 1), this.sprite.visible = !0, this.alive = !0, this.charge = r.CHARGE_TIME; for (var i = 0; i < 4; i++) { this.spikes[i].spawn(t, e, 90 * i) } this.hitBoxPoly.pos.x = this.xPos, this.hitBoxPoly.pos.y = this.yPos }, r.prototype.levelStart = function() { this.storeNearbyPlatforms() }, r.prototype.storeNearbyPlatforms = function() {
|
|
this.platforms = [];
|
|
for (var t = new SAT.Circle(new SAT.Vector(this.xPos, this.yPos), 250), e = 0, i = this.main.blocks; e < i.length; e++) {
|
|
var s = i[e];
|
|
SAT.testCirclePolygon(t, s.totalBoundPolygon) && this.platforms.push(s)
|
|
}
|
|
}, r.prototype.fireSpikes = function() { for (var t = 0; t < 4; t++) { this.spikes[t].dispenserFire() } this.sprite.animations.stop("spawn", !0), this.sprite.animations.play("spawn", null, !1) }, r.prototype.update = function() {
|
|
var t = this.main.player,
|
|
e = !0;
|
|
if (t && t.alive) { var i = new SAT.Polygon(new Vector(0, 0), [new SAT.Vector(this.xPos, this.yPos), new SAT.Vector(t.xPos, t.yPos - 15)]); if (Math.pow(this.xPos - t.xPos - 15, 2) + Math.pow(this.yPos - t.yPos, 2) <= 62500) { for (var s = 0, o = this.platforms; s < o.length; s++) { var n = o[s]; if (SAT.testPolygonPolygon(i, n.totalBoundPolygon)) { e = !1; break } } e && this.charge >= r.CHARGE_TIME && (this.fireSpikes(), this.charge = 0, this.rad = 0) } } this.charge < r.CHARGE_TIME && (this.charge += this.main.gameSpeed, this.rad += Math.PI / r.CHARGE_TIME), this.sprite.rotation = this.rad
|
|
}, r.prototype.destroy = function() {
|
|
for (var t = 0; t < 4; t++) this.spikes[t].destroy();
|
|
this.spikes = null, this.sprite.destroy(), this.sprite = null
|
|
}, r.prototype.resetLevel = function() { this.charge = 0 }, r.CHARGE_TIME = 35, r
|
|
}(Obstacle),
|
|
VexBoot = function() {
|
|
function i(t) {}
|
|
return i.prototype.init = function() {
|
|
var e = this;
|
|
this.input.maxPointers = 2, window.hasOwnProperty("fbrqSA") && !0 === window.fbrqSA && (Fabrique.Utils.ASSET_LOCATION = "assets/"), Fabrique.AnalyticsHandler.getInstance(this.game).initAnalytics(), Fabrique.AdHandler.getInstance(this.game).initAdProvider(), SaveGame.getInstance(this.game).init(), Fabrique.Utils.isOnDevice(this.game) && SocialServicesHandler.init(this.game), this.game.canvas.oncontextmenu = function(t) { t.preventDefault() }, this.game.analytics.google.sendScreenView("boot"), this.game.load.cacheBuster = "undefined" == typeof version ? null : version, this.game.device.desktop ? (this.scale.scaleMode = Phaser.ScaleManager.RESIZE, this.scale.supportsFullScreen = !0, this.scale.setMinMax(640, 300, 2e3, 1120), this.scale.pageAlignHorizontally = !0, this.scale.pageAlignVertically = !0) : (this.scale.scaleMode = Phaser.ScaleManager.USER_SCALE, this.scale.fullScreenScaleMode = Phaser.ScaleManager.USER_SCALE, this.game.scale.fullScreenTarget = document.getElementById("content"), this.game.state.onStateChange.add(function(t) { return i.initFullScreenListener(e.game) }), this.game.scale.pageAlignHorizontally = !0, this.game.scale.pageAlignVertically = !0, this.game.scale.windowConstraints.right = "layout", this.game.scale.windowConstraints.bottom = "visual", window.addEventListener("resize", function(t) { return i.resizeCallback(e.game.scale) }), i.resizeCallback(this.game.scale))
|
|
}, i.initFullScreenListener = function(e) { e.input.onTap.add(function(t) { return i.startFullScreen(e) }) }, i.startFullScreen = function(t) { Constants.AUTO_FULLSCREEN_ENABLED && t.device.android && (t.scale.isFullScreen || t.scale.startFullScreen(!1), i.resizeCallback(t.scale)) }, i.resizeCallback = function(t) {
|
|
var e = 1;
|
|
1 < t.game.device.pixelRatio && (e = .85);
|
|
var i = Constants.gameWidth,
|
|
s = Constants.gameHeight,
|
|
o = window.innerWidth,
|
|
n = window.innerHeight;
|
|
e /= n < o ? n / s : n / i, Constants.userRatio = e, t.width === window.innerWidth * e && t.height === window.innerHeight * e || (t.setGameSize(window.innerWidth * e, window.innerHeight * e), t.setUserScale(1 / e, 1 / e))
|
|
}, i.prototype.create = function() {
|
|
var t = this;
|
|
Fabrique.LoaderHelper.hide(), this.game.ph2UIManager.enableVisibilityAndOrientationComponent = !1, this.loadWebFonts(), this.game.state.start(Fabrique.SplashScreen.Preloader.Name, !0, !1, { nextState: "Game", showPlayButton: !window.hasOwnProperty("playBtn") || window.playBtn, mobilePlayClickhandler: function() { Fabrique.Utils.isOnDevice(t.game) ? t.game.state.start("Game") : (Fabrique.LoaderHelper.show(), Fabrique.AdHandler.getInstance(t.game).showAd(function() { Fabrique.LoaderHelper.hide(), t.game.state.start("Game") }, function() { Fabrique.LoaderHelper.hide() }, "start")) }, preloadHandler: function() { t.game.analytics.google.sendScreenView("splash"), Fabrique.Branding.preloadImages(t.game), Fabrique.MoreGames.Menu.preloadImages(t.game), t.game.stage.disableVisibilityChange = !1, t.game.device.iOS ? (t.game.load.audio("connectHang", ["assets/sounds/connect-hang.m4a"], !1), t.game.load.audio("fall", ["assets/sounds/fall.m4a"], !1), t.game.load.audio("downgrade", ["assets/sounds/downgrade.m4a"], !1), t.game.load.audio("poleSwing", ["assets/sounds/pole-swing.m4a"], !1), t.game.load.audio("splash1", ["assets/sounds/splash1.m4a"], !1), t.game.load.audio("ziplineFull", ["assets/sounds/zipline-full.m4a"], !1), t.game.load.audio("cannonEnter", ["assets/sounds/cannon-enter.m4a"], !1), t.game.load.audio("wallSlide", ["assets/sounds/wall-slide.m4a"], !1), t.game.load.audio("connect", ["assets/sounds/connect.m4a"], !1), t.game.load.audio("land", ["assets/sounds/land.m4a"], !1), t.game.load.audio("slide", ["assets/sounds/slide.m4a"], !1), t.game.load.audio("death1", ["assets/sounds/slide.m4a"], !1), t.game.load.audio("death2", ["assets/sounds/death2.m4a"], !1), t.game.load.audio("electricity", ["assets/sounds/electricity.m4a"], !1), t.game.load.audio("poleWoosh", ["assets/sounds/pole-woosh.m4a"], !1), t.game.load.audio("bounce1", ["assets/sounds/bounce1.m4a"], !1), t.game.load.audio("cannonFire", ["assets/sounds/cannon-fire.m4a"], !1), t.game.load.audio("glassSmash", ["assets/sounds/glass-smash.m4a"], !1), t.game.load.audio("fallingBlock", ["assets/sounds/falling-block.m4a"], !1), t.game.load.audio("blockDestroy", ["assets/sounds/block-destroy.m4a"], !1), t.game.load.audio("menuSong", ["assets/sounds/menu-song.m4a"], !1), t.game.load.audio("vexSong1", ["assets/sounds/vex-song-1.m4a"], !1), t.game.load.audio("vexSong2", ["assets/sounds/vex-song-2.m4a"], !1), t.game.load.audio("vexSong3", ["assets/sounds/vex-song-3.m4a"], !1), t.game.load.audio("vexSong4", ["assets/sounds/vex-song-4.m4a"], !1), t.game.load.audio("vexSong5", ["assets/sounds/vex-song-5.m4a"], !1), t.game.load.audio("vexSong6", ["assets/sounds/vex-song-6.m4a"], !1), t.game.load.audio("vexSong7", ["assets/sounds/vex-song-7.m4a"], !1), t.game.load.audio("vexSong8", ["assets/sounds/vex-song-8.m4a"], !1), t.game.load.audio("vexSong9", ["assets/sounds/vex-song-9.m4a"], !1), t.game.load.audio("vexSong10", ["assets/sounds/vex-song-10.m4a"], !1), t.game.load.audio("vexSong11", ["assets/sounds/vex-song-11.m4a"], !1), t.game.load.audio("vexSong12", ["assets/sounds/vex-song-12.m4a"], !1), t.game.load.audio("vexSong13", ["assets/sounds/vex-song-13.m4a"], !1), t.game.load.audio("vexSong14", ["assets/sounds/vex-song-14.m4a"], !1), t.game.load.audio("buttonClick", ["assets/sounds/button-click.m4a"], !1), t.game.load.audio("achievementUnlocked", ["assets/sounds/achievement-unlocked.m4a"], !1), t.game.load.audio("footstep", ["assets/sounds/footstep.m4a"], !1), t.game.load.audio("laserFire", ["assets/sounds/laser-fire.m4a"], !1), t.game.load.audio("ding", ["assets/sounds/ding.m4a"], !1), t.game.load.audio("kickBlock", ["assets/sounds/kick-block.m4a"], !1), t.game.load.audio("starPickup", ["assets/sounds/star-pickup.m4a"], !1)) : (t.game.load.audio("connectHang", ["assets/sounds/connect-hang.ogg"], ["assets/sounds/connect-hang.mp3"], !1), t.game.load.audio("fall", ["assets/sounds/fall.ogg"], ["assets/sounds/fall.wav"], !1), t.game.load.audio("downgrade", ["assets/sounds/downgrade.ogg"], ["assets/sounds/downgrade.mp3"], !1), t.game.load.audio("poleSwing", ["assets/sounds/pole-swing.ogg"], ["assets/sounds/pole-swing.mp3"], !1), t.game.load.audio("splash1", ["assets/sounds/splash1.ogg"], ["assets/sounds/splash1.mp3"], !1), t.game.load.audio("ziplineFull", ["assets/sounds/zipline-full.ogg"], ["assets/sounds/zipline-full.mp3"], !1), t.game.load.audio("cannonEnter", ["assets/sounds/cannon-enter.ogg"], ["assets/sounds/cannon-enter.mp3"], !1), t.game.load.audio("wallSlide", ["assets/sounds/wall-slide.ogg"], ["assets/sounds/wall-slide.mp3"], !1), t.game.load.audio("connect", ["assets/sounds/connect.ogg"], ["assets/sounds/connect.mp3"], !1), t.game.load.audio("land", ["assets/sounds/land.ogg"], ["assets/sounds/land.mp3"], !1), t.game.load.audio("slide", ["assets/sounds/slide.ogg"], ["assets/sounds/slide.mp3"], !1), t.game.load.audio("death1", ["assets/sounds/slide.ogg"], ["assets/sounds/slide.mp3"], !1), t.game.load.audio("death2", ["assets/sounds/death2.ogg"], ["assets/sounds/death2.mp3"], !1), t.game.load.audio("electricity", ["assets/sounds/electricity.ogg"], ["assets/sounds/electricity.mp3"], !1), t.game.load.audio("poleWoosh", ["assets/sounds/pole-woosh.ogg"], ["assets/sounds/pole-woosh.mp3"], !1), t.game.load.audio("bounce1", ["assets/sounds/bounce1.ogg"], ["assets/sounds/bounce1.mp3"], !1), t.game.load.audio("cannonFire", ["assets/sounds/cannon-fire.ogg"], ["assets/sounds/cannon-fire.mp3"], !1), t.game.load.audio("glassSmash", ["assets/sounds/glass-smash.ogg"], ["assets/sounds/glass-smash.mp3"], !1), t.game.load.audio("fallingBlock", ["assets/sounds/falling-block.ogg"], ["assets/sounds/falling-block.mp3"], !1), t.game.load.audio("blockDestroy", ["assets/sounds/block-destroy.ogg"], ["assets/sounds/block-destroy.mp3"], !1), t.game.load.audio("menuSong", ["assets/sounds/menu-song.ogg"], ["assets/sounds/menu-song.mp3"], !1), t.game.load.audio("vexSong1", ["assets/sounds/vex-song-1.ogg"], ["assets/sounds/vex-song-1.mp3"], !1), t.game.load.audio("vexSong2", ["assets/sounds/vex-song-2.ogg"], ["assets/sounds/vex-song-2.mp3"], !1), t.game.load.audio("vexSong3", ["assets/sounds/vex-song-3.ogg"], ["assets/sounds/vex-song-3.mp3"], !1), t.game.load.audio("vexSong4", ["assets/sounds/vex-song-4.ogg"], ["assets/sounds/vex-song-4.mp3"], !1), t.game.load.audio("vexSong5", ["assets/sounds/vex-song-5.ogg"], ["assets/sounds/vex-song-5.mp3"], !1), t.game.load.audio("vexSong6", ["assets/sounds/vex-song-6.ogg"], ["assets/sounds/vex-song-6.mp3"], !1), t.game.load.audio("vexSong7", ["assets/sounds/vex-song-7.ogg"], ["assets/sounds/vex-song-7.mp3"], !1), t.game.load.audio("vexSong8", ["assets/sounds/vex-song-8.ogg"], ["assets/sounds/vex-song-8.mp3"], !1), t.game.load.audio("vexSong9", ["assets/sounds/vex-song-9.ogg"], ["assets/sounds/vex-song-9.mp3"], !1), t.game.load.audio("vexSong10", ["assets/sounds/vex-song-10.ogg"], ["assets/sounds/vex-song-10.mp3"], !1), t.game.load.audio("vexSong11", ["assets/sounds/vex-song-11.ogg"], ["assets/sounds/vex-song-11.mp3"], !1), t.game.load.audio("vexSong12", ["assets/sounds/vex-song-12.ogg"], ["assets/sounds/vex-song-12.mp3"], !1), t.game.load.audio("vexSong13", ["assets/sounds/vex-song-13.ogg"], ["assets/sounds/vex-song-13.mp3"], !1), t.game.load.audio("vexSong14", ["assets/sounds/vex-song-14.ogg"], ["assets/sounds/vex-song-14.mp3"], !1), t.game.load.audio("buttonClick", ["assets/sounds/button-click.ogg"], ["assets/sounds/button-click.mp3"], !1), t.game.load.audio("achievementUnlocked", ["assets/sounds/achievement-unlocked.ogg"], ["assets/sounds/achievement-unlocked.mp3"], !1), t.game.load.audio("footstep", ["assets/sounds/footstep.ogg"], ["assets/sounds/footstep.mp3"], !1), t.game.load.audio("laserFire", ["assets/sounds/laser-fire.ogg"], ["assets/sounds/laser-fire.mp3"], !1), t.game.load.audio("ding", ["assets/sounds/ding.ogg"], ["assets/sounds/ding.mp3"], !1), t.game.load.audio("kickBlock", ["assets/sounds/kick-block.ogg"], ["assets/sounds/kick-block.mp3"], !1), t.game.load.audio("starPickup", ["assets/sounds/star-pickup.ogg"], ["assets/sounds/star-pickup.mp3"], !1)), t.game.load.script("colorMatrixFilter", "assets/filters/ColorMatrixFilter.js"), t.game.load.script("blurX", "assets/filters/BlurX.js"), t.game.load.script("blurY", "assets/filters/BlurY.js"), t.game.load.script("gray", "assets/filters/Gray.js"), t.game.load.bitmapFont("grobred32", "assets/fonts/grobred32.png", "assets/fonts/grobred32.fnt"), t.game.load.image("circleButton", "assets/images/circle-button.png"), t.game.load.image("circleLrButton", "assets/images/L_R-circle-button.png"), t.game.load.image("btnNonePressed", "assets/images/btnNonePressed.png"), t.game.load.image("btnLeftPressed", "assets/images/btnLeftPressed.png"), t.game.load.image("btnRightPressed", "assets/images/btnRightPressed.png"), t.game.load.image("btnBothPressed", "assets/images/btnBothPressed.png"), t.game.load.image("jumpButton", "assets/images/jump-button.png"), t.game.load.image("crouchButton", "assets/images/crouch-button.png"), t.game.load.image("crouchPressed", "assets/images/crouchPressed.png"), t.game.load.image("jumpPressed", "assets/images/jumpPressed.png"), t.game.load.image("cPromoImage", "assets/images/cpromo-icon.png"), t.game.load.image("parallaxBackground", "assets/images/parallaxBackground.png"), t.game.load.image("basicBlock", "assets/images/blocks/block-basic.png"), t.game.load.spritesheet("basicBlockColors", "assets/images/blocks/basic-block-colors.png", 99, 99, 12, 0, 2), t.game.load.image("leftSlope", "assets/images/blocks/left-slope.png"), t.game.load.spritesheet("leftSlopeColors", "assets/images/blocks/slope-colors.png", 99, 99, 8, 0, 2), t.game.load.image("verticalUpBlock", "assets/images/blocks/vertical-up-block.png"), t.game.load.image("verticalDownBlock", "assets/images/blocks/vertical-down-block.png"), t.game.load.image("horizontalBlock", "assets/images/blocks/horizontal-block.png"), t.game.load.image("fallingBlock", "assets/images/blocks/falling-block.png"), t.game.load.image("bounceBlock", "assets/images/blocks/bounce-block.png"), t.game.load.image("pushBlock", "assets/images/blocks/push-block.png"), t.game.load.image("iceBlock", "assets/images/blocks/ice-block.png"), t.game.load.image("glassBlock", "assets/images/blocks/glass-block.png"), t.game.load.image("speedBlock", "assets/images/blocks/speed-block.png"), t.game.load.image("lockBlock", "assets/images/blocks/lock-block.png"), t.game.load.image("sparkBlock", "assets/images/blocks/spark-block.png"), t.game.load.image("solarBlock", "assets/images/blocks/solar-block.png"), t.game.load.image("invisBlock", "assets/images/blocks/invis-block.png"), t.game.load.image("invisBlockUp", "assets/images/blocks/invis-block-up.png"), t.game.load.image("invisBlockDown", "assets/images/blocks/invis-block-down.png"), t.game.load.image("explosiveBlock", "assets/images/blocks/explosive-block.png"), t.game.load.spritesheet("blockedWall", "assets/images/blocks/blocked-wall.png", 65, 444, 120, 0, 1), t.game.load.image("actBlock1", "assets/images/blocks/act-block-1.png"), t.game.load.image("actBlock2", "assets/images/blocks/act-block-2.png"), t.game.load.image("actBlock3", "assets/images/blocks/act-block-3.png"), t.game.load.image("actBlock4", "assets/images/blocks/act-block-4.png"), t.game.load.image("actBlock5", "assets/images/blocks/act-block-5.png"), t.game.load.image("actBlock6", "assets/images/blocks/act-block-6.png"), t.game.load.image("actBlock7", "assets/images/blocks/act-block-7.png"), t.game.load.image("actBlock8", "assets/images/blocks/act-block-8.png"), t.game.load.image("actBlock9", "assets/images/blocks/act-block-9.png"), t.game.load.image("actBlock10", "assets/images/blocks/act-block-10.png"), t.game.load.image("actBlock11", "assets/images/blocks/act-block-challenge.png"), t.game.load.image("swimmingPool", "assets/images/blocks/swimming-pool.png"), t.game.load.image("leftSlope", "assets/images/blocks/left-slope.png"), t.game.load.spritesheet("slope-colors", "assets/images/blocks/slope-colors.png", 100, 100, 8), t.game.load.spritesheet("arrowAnimation", "assets/images/blocks/arrow-animation.png", 100, 292, 30), t.game.load.image("arrowStatic", "assets/images/blocks/arrow-static.png"), t.game.load.image("cable", "assets/images/blocks/cable.png"), t.game.load.image("elevatorUp", "assets/images/blocks/elevator_up.png"), t.game.load.image("elevatorDown", "assets/images/blocks/elevator_down.png"), t.game.load.atlas("checkpoint", "assets/atlas/checkpoint.png", "assets/atlas/checkpoint.json"), t.game.load.spritesheet("checkpointSwimming", "assets/images/items/checkpoint-swimming.png", 51, 62, 3, 1), t.game.load.image("checkpointText", "assets/images/items/checkpoint-text.png"), t.game.load.spritesheet("finishPortal", "assets/images/items/finish-portal.png", 52, 60, 60), t.game.load.image("ziplinePole", "assets/images/items/zipline-pole.png"), t.game.load.image("pole", "assets/images/items/pole.png"), t.game.load.image("poleRedSection", "assets/images/items/pole-red-section.png"), t.game.load.image("star", "assets/images/items/star.png"), t.game.load.image("hazardStrips", "assets/images/items/hazard-strips.png"), t.game.load.image("breatheBlaster", "assets/images/items/breathe-blaster.png"), t.game.load.image("windBlaster", "assets/images/items/wind-blaster.png"), t.game.load.spritesheet("windFan", "assets/images/items/wind-fan.png", 13, 53, 6), t.game.load.image("key", "assets/images/items/key.png"), t.game.load.image("timedKey", "assets/images/items/timed-key.png"), t.game.load.image("cannonBase", "assets/images/items/cannon-base.png"), t.game.load.image("cannonTube", "assets/images/items/cannon-tube.png"), t.game.load.image("lightSwitch", "assets/images/items/light-switch.png"), t.game.load.image("wire", "assets/images/items/wire.png"), t.game.load.image("portal", "assets/images/items/portal.png"), t.game.load.image("buzzsaw", "assets/images/obstacles/buzzsaw.png"), t.game.load.image("buzzsawOnStick", "assets/images/obstacles/buzzsaw-on-stick.png"), t.game.load.image("spike", "assets/images/obstacles/spike.png"), t.game.load.image("spike10x", "assets/images/obstacles/spike10x.png"), t.game.load.image("spike30x", "assets/images/obstacles/spike30x.png"), t.game.load.image("fallingSpike", "assets/images/obstacles/falling-spike.png"), t.game.load.image("shurikanSpawner", "assets/images/obstacles/shurikan-spawner.png"), t.game.load.spritesheet("shurikanHorizontal", "assets/images/obstacles/shurikan-horizontal.png", 22, 22, 3), t.game.load.spritesheet("shurikanHorizontal", "assets/images/obstacles/shurikan-horizontal.png", 22, 22, 3), t.game.load.spritesheet("shurikanDispenser", "assets/images/obstacles/shurikan-dispenser.png", 46, 46, 25), t.game.load.image("classicLaser", "assets/images/obstacles/classic-laser.png"), t.game.load.image("bullet", "assets/images/obstacles/laser-bullet.png"), t.game.load.image("quadrant", "assets/images/obstacles/quadrant.png"), t.game.load.image("reaper", "assets/images/obstacles/reaper.png"), t.game.load.image("spark", "assets/images/obstacles/spark.png"), t.game.load.image("pressDown", "assets/images/press-down.png"), t.game.load.image("playerStand", "assets/images/player/player-stand.png"), t.game.load.spritesheet("playerSlide", "assets/images/player/player-slide.png", 37, 36, 16), t.game.load.atlas("playerCrouch", "assets/images/player/player-crouch.png", "assets/images/player/player-crouch.json"), t.game.load.atlas("playerRun", "assets/images/player/player-run.png", "assets/images/player/player-run.json"), t.game.load.atlas("playerJump", "assets/images/player/player-jump.png", "assets/images/player/player-jump.json"), t.game.load.atlas("playerJumpDown", "assets/images/player/player-jump-down.png", "assets/images/player/player-jump-down.json"), t.game.load.atlas("playerFallFloor", "assets/images/player/player-fall-floor.png", "assets/images/player/player-fall-floor.json"), t.game.load.atlas("playerSwimTop", "assets/images/player/player-swim-top.png", "assets/images/player/player-swim-top.json"), t.game.load.atlas("playerSwimStop", "assets/images/player/player-stop-swim.png", "assets/images/player/player-stop-swim.json"), t.game.load.spritesheet("playerJumpFrontFlip", "assets/images/player/player-jump-front-flip.png", 35, 43, 19), t.game.load.spritesheet("playerJumpBackFlip", "assets/images/player/player-jump-back-flip.png", 36, 41, 22), t.game.load.spritesheet("playerFall", "assets/images/player/player-fall.png", 23, 37, 23), t.game.load.spritesheet("playerScale", "assets/images/player/player-scale.png", 20, 39, 4), t.game.load.spritesheet("playerHang", "assets/images/player/player-hang.png", 22, 36, 1), t.game.load.spritesheet("playerPulley", "assets/images/player/player-pulley.png", 43, 39, 35), t.game.load.spritesheet("playerSwing", "assets/images/player/player-swing.png", 61, 72, 35), t.game.load.spritesheet("playerPush", "assets/images/player/player-push.png", 28, 33, 31), t.game.load.spritesheet("playerKick", "assets/images/player/player-kick.png", 36, 41, 28), t.game.load.spritesheet("playerSwimBottom", "assets/images/player/player-swim-bottom.png", 16, 20, 28), t.game.load.spritesheet("playerSpawn", "assets/images/player/player-spawn.png", 16, 40, 60), t.game.load.image("playerHead", "assets/images/player/parts/player-head.png"), t.game.load.image("playerBody", "assets/images/player/parts/player-body.png"), t.game.load.image("playerArm", "assets/images/player/parts/player-arm.png"), t.game.load.image("playerLeg", "assets/images/player/parts/player-leg.png"), t.game.load.image("breatheBlock", "assets/images/breathe-block.png"), t.game.load.image("enterLevelText", "assets/images/text/act-block/enter-level-text.png"), t.game.load.image("actDownArrow", "assets/images/text/act-block/act-down-arrow.png"), t.game.load.image("textFade1", "assets/images/text/text-fade-1.png"), t.game.load.image("textFade2", "assets/images/text/text-fade-2.png"), t.game.load.image("textFade4", "assets/images/text/text-fade-4.png"), t.game.load.image("textFade5", "assets/images/text/text-fade-5.png"), t.game.load.image("textFade6", "assets/images/text/text-fade-6.png"), t.game.load.image("textFade7", "assets/images/text/text-fade-7.png"), t.game.load.image("textFade8", "assets/images/text/text-fade-8.png"), t.game.load.image("textFade10", "assets/images/text/text-fade-10.png"), t.game.load.image("textFade11", "assets/images/text/text-fade-11.png"), t.game.load.image("textFade12", "assets/images/text/text-fade-12.png"), t.game.load.image("textFade13", "assets/images/text/text-fade-13.png"), t.game.load.image("textFade13Mobile", "assets/images/text/text-fade-13-mobile.png"), t.game.load.image("textFade14", "assets/images/text/text-fade-14.png"), t.game.load.image("textFade15", "assets/images/text/text-fade-15.png"), t.game.load.image("textFade16", "assets/images/text/text-fade-16.png"), t.game.load.image("textFade17", "assets/images/text/text-fade-17.png"), t.game.load.image("textFade18", "assets/images/text/text-fade-18.png"), t.game.load.image("textFade19", "assets/images/text/text-fade-19.png"), t.game.load.image("textFade20", "assets/images/text/text-fade-20.png"), t.game.load.image("textFade21", "assets/images/text/text-fade-21.png"), t.game.load.image("textFade22", "assets/images/text/text-fade-22.png"), t.game.load.image("textFade23", "assets/images/text/text-fade-23.png"), t.game.load.image("textFade24", "assets/images/text/text-fade-24.png"), t.game.load.image("textFade25", "assets/images/text/text-fade-25.png"), t.game.load.image("textFade26", "assets/images/text/text-fade-26.png"), t.game.load.image("textFade27", "assets/images/text/text-fade-27.png"), t.game.load.image("textFade28", "assets/images/text/text-fade-28.png"), t.game.load.image("textFade29", "assets/images/text/text-fade-29.png"), t.game.load.image("textFade30", "assets/images/text/text-fade-30.png"), t.game.load.image("textFade31", "assets/images/text/text-fade-31.png"), t.game.load.image("textFade32", "assets/images/text/text-fade-32.png"), t.game.load.image("textFade33", "assets/images/text/text-fade-33.png"), t.game.load.image("textFade34", "assets/images/text/text-fade-34.png"), t.game.load.image("textFade35", "assets/images/text/text-fade-35.png"), t.game.load.image("textFade36", "assets/images/text/text-fade-36.png"), t.game.load.image("textFade37", "assets/images/text/text-fade-37.png"), t.game.load.image("textFade38", "assets/images/text/text-fade-38.png"), t.game.load.image("textFade39", "assets/images/text/text-fade-39.png"), t.game.load.image("textFade40", "assets/images/text/text-fade-40.png"), t.game.load.image("textFade41", "assets/images/text/text-fade-41.png"), t.game.load.image("textFade42", "assets/images/text/text-fade-42.png"), t.game.load.image("textFade43", "assets/images/text/text-fade-43.png"), t.game.load.image("textFade44", "assets/images/text/text-fade-44.png"), t.game.load.image("textFade45", "assets/images/text/text-fade-45.png"), t.game.load.spritesheet("darkOverlay", "assets/images/dark-overlay.png", 520, 520, 30), t.game.load.json("levelsConfig", "assets/balance/levelsConfig.json"), t.game.load.json("objectConfig", "assets/balance/objectConfig.json"), t.game.load.json("hubArrows", "assets/balance/levels/hubArrows.json"), t.game.load.atlas("atlas_gameplay", "assets/atlas/atlas_gameplay.png", "assets/atlas/atlas_gameplay.json"), t.game.load.atlas("atlas_portals", "assets/atlas/atlas_portals.png", "assets/atlas/atlas_portals.json"), t.game.load.json("localization", "assets/balance/localization.json"), t.game.load.atlas("atlas_main_menu", "assets/atlas/atlas_ui_main_menu.png", "assets/atlas/atlas_ui_main_menu.json"), t.game.load.json("ui_main_menu", "assets/ui/ui_main_menu.json"), t.game.load.atlas("atlas_trophies", "assets/atlas/atlas_ui_trophies.png", "assets/atlas/atlas_ui_trophies.json"), t.game.load.json("ui_trophies", "assets/ui/ui_trophies.json"), t.game.load.atlas("atlas_options", "assets/atlas/atlas_ui_options.png", "assets/atlas/atlas_ui_options.json"), t.game.load.json("ui_options", "assets/ui/ui_options.json"), t.game.load.atlas("atlas_ui_gameplay", "assets/atlas/atlas_ui_gameplay.png", "assets/atlas/atlas_ui_gameplay.json"), t.game.load.json("ui_gameplay", "assets/ui/ui_gameplay.json"), t.game.load.atlas("atlas_pause", "assets/atlas/atlas_ui_pause.png", "assets/atlas/atlas_ui_pause.json"), t.game.load.json("ui_pause", "assets/ui/ui_pause.json"), t.game.load.atlas("atlas_level_complete", "assets/atlas/atlas_ui_level_complete.png", "assets/atlas/atlas_ui_level_complete.json"), t.game.load.json("ui_level_complete", "assets/ui/ui_level_complete.json"), t.game.load.atlas("atlas_act_select", "assets/atlas/atlas_ui_act_select.png", "assets/atlas/atlas_ui_act_select.json"), t.game.load.json("ui_act_select", "assets/ui/ui_act_select.json"), t.game.load.atlas("atlas_transition", "assets/atlas/atlas_transition.png", "assets/atlas/atlas_transition.json"), t.game.load.atlas("atlas_transition", "assets/atlas/atlas_transition.png", "assets/atlas/atlas_transition.json"), t.game.load.json("transition_in", "assets/coco/transition/transition_in.json"), t.game.load.json("transition_stand", "assets/coco/transition/transition_stand.json"), t.game.load.json("transition_out", "assets/coco/transition/transition_out.json"), t.game.load.json("transition", "assets/coco/transition.json") } })
|
|
}, i.prototype.loadWebFonts = function() {
|
|
var t = this,
|
|
e = function() { t.recursiveUpdateText(t.stage) };
|
|
WebFont.load({ custom: { families: ["milocha"], urls: ["assets/css/milocha.css"] }, active: e, inactive: e })
|
|
}, i.prototype.recursiveUpdateText = function(t) {
|
|
var e = this;
|
|
t instanceof Phaser.Text && (t.dirty = !0), t.children && 0 < t.children.length && t.children.forEach(function(t) { e.recursiveUpdateText(t) })
|
|
}, i
|
|
}(),
|
|
ControllerStick = function() {
|
|
function t(t, e, i, s, o) { this.game = t, this.sprite = t.add.sprite(e, i, s), this.sprite.alpha = .5, this.sprite.anchor.set(.5, .5), this.sprite.scale.set(1.35, 1.35), this.sprite.hitArea = new Phaser.Rectangle(-this.sprite.width / 2, -this.sprite.height / 1.4, 1.2 * this.sprite.width, 1.35 * this.sprite.height), this.sprite.fixedToCamera = !0, this.sprite.inputEnabled = !0, this.sprite.events.onInputDown.add(this.onDown, this), this.sprite.events.onInputUp.add(this.onUp, this), this.pressedDown = new Phaser.Signal, this.isDown = !1, this.upDd = !1, this.downDd = !1, this.leftDd = !1, this.oneStick = o }
|
|
return t.prototype.onDown = function(t, e) { this.pointer = e, this.isDown = !0 }, t.prototype.onUp = function() { this.isDown && this.pressedDown.dispatch(), this.isDown = !1, this.upDd = !1, this.downDd = !1, this.leftDd = !1, this.rightDd = !1 }, t.prototype.hide = function() { this.sprite.visible = !1 }, t.prototype.show = function() { this.sprite.visible = !0 }, t.prototype.upIsDown = function() { return this.upDd }, t.prototype.downIsDown = function() { return this.downDd }, t.prototype.leftIsDown = function() { return this.leftDd }, t.prototype.rightIsDown = function() { return this.rightDd }, t.prototype.update = function() {
|
|
if (this.isDown)
|
|
if (this.oneStick) {
|
|
var t = this.sprite.x - this.game.camera.x;
|
|
this.pointer.position.x < t ? (this.leftDd = !0, this.leftIsDown(), this.sprite.loadTexture("btnLeftPressed"), this.rightDd = !1) : (this.rightDd = !0, this.rightIsDown(), this.sprite.loadTexture("btnRightPressed"), this.leftDd = !1)
|
|
}
|
|
else {
|
|
var e = this.sprite.position.x - this.game.camera.x,
|
|
i = this.sprite.position.y - this.game.camera.y;
|
|
if (Math.pow(this.pointer.position.x - e, 2) + Math.pow(this.pointer.position.y - i, 2) < 400) return this.upDd = !1, this.downDd = !1, this.leftDd = !1, void(this.rightDd = !1);
|
|
if (this.pointer.position.x < e) {
|
|
this.rightDd = !1;
|
|
var s = (this.pointer.y - i) / (this.pointer.position.x - e);
|
|
this.downDd = 1 < s ? (this.upDd = !0, this.leftDd = !1) : s < -1 ? (this.upDd = !1, !(this.leftDd = !1)) : (this.upDd = !1, !(this.leftDd = !0))
|
|
}
|
|
else {
|
|
this.leftDd = !1;
|
|
s = (this.pointer.y - i) / (this.pointer.position.x - e);
|
|
this.downDd = 1 < s ? (this.upDd = !1, !(this.rightDd = !1)) : (this.rightDd = s < -1 ? !(this.upDd = !0) : !(this.upDd = !1), !1)
|
|
}
|
|
}
|
|
else this.sprite.loadTexture("btnNonePressed")
|
|
}, t
|
|
}(),
|
|
GameKey = function() {
|
|
function t(t) { this.keys = t, this.buttonDown = !1, this.calls = [] }
|
|
return t.prototype.isDown = function() { for (var t = 0, e = this.calls; t < e.length; t++) { if ((0, e[t])()) return !0 } for (var i = 0, s = this.keys; i < s.length; i++) { if (s[i].isDown) return !0 } return !1 }, t.prototype.pressed = function() { return this.isDown() && !this.prev }, t.prototype.update = function() { this.isDown() ? this.prev = !0 : this.prev = !1 }, t.prototype.resetStateOfKeys = function() { for (var t = 0, e = this.keys; t < e.length; t++) { e[t].isDown = !1 } }, t
|
|
}(),
|
|
BREAK_X_1 = 560,
|
|
BREAK_X_2 = 360,
|
|
VexGameState = function() {
|
|
function t(t) {}
|
|
return t.prototype.init = function() { document.body.style.backgroundColor = "#ffffff" }, t.prototype.preload = function() {
|
|
var t = this.game.cache.getJSON("levelsConfig");
|
|
for (var e in t)
|
|
if (t.hasOwnProperty(e)) {
|
|
var i = t[e].file;
|
|
if (t[e].fileChallengeName) {
|
|
var s = t[e].fileChallengeName;
|
|
this.game.load.json(s, "assets/balance/levels/" + s + ".json")
|
|
}
|
|
this.game.load.json(i, "assets/balance/levels/" + i + ".json")
|
|
}
|
|
for (var o = this.game.cache.getJSON("hubArrows"), n = 0, a = o.length; n < a; n++) hubArrows[n] = o[n];
|
|
var r = this.game.cache.getJSON("objectConfig");
|
|
ElevatorGenerator.TimeNewElevator = r.TimeNewElevator, ElevatorGenerator.SpeedElevator = r.SpeedElevator, Portal.TimeCooldown = r.TimeCooldown, Level.ChallengeSteps = r.ChallegeSteps, Constants.minSizeView = r.minSizeView, Constants.wireSparkSpeed = r.wireSparkSpeed, Constants.levelsResetCheckPoints = r.LevelsResetCheckPoints
|
|
}, t.prototype.create = function() {
|
|
var s = this;
|
|
Fabrique.Utils.isOnDevice(this.game) && SocialServicesHandler.login(this.game);
|
|
var t = this.game.input.keyboard.addKey(Phaser.Keyboard.UP),
|
|
e = this.game.input.keyboard.addKey(Phaser.Keyboard.W),
|
|
i = this.game.input.keyboard.addKey(Phaser.Keyboard.DOWN),
|
|
o = this.game.input.keyboard.addKey(Phaser.Keyboard.S),
|
|
n = this.game.input.keyboard.addKey(Phaser.Keyboard.LEFT),
|
|
a = this.game.input.keyboard.addKey(Phaser.Keyboard.A),
|
|
r = this.game.input.keyboard.addKey(Phaser.Keyboard.RIGHT),
|
|
h = this.game.input.keyboard.addKey(Phaser.Keyboard.D),
|
|
l = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR),
|
|
c = this.game.input.keyboard.addKey(Phaser.Keyboard.R);
|
|
this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.UP), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.W), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.DOWN), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.S), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.LEFT), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.A), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.RIGHT), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.D), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.SPACEBAR), this.game.input.keyboard.addKeyCapture(Phaser.Keyboard.R);
|
|
var p = new GameKey([t, e]),
|
|
u = new GameKey([i, o]),
|
|
d = new GameKey([n, a]),
|
|
y = new GameKey([r, h]),
|
|
g = new GameKey([l]),
|
|
f = new GameKey([c]);
|
|
this.circleMovement = new ControllerStick(this.game, 150, 400, "btnNonePressed", !0), d.calls.push(this.circleMovement.leftIsDown.bind(this.circleMovement)), y.calls.push(this.circleMovement.rightIsDown.bind(this.circleMovement)), this.buttonJump = new ControllerButton(this.game, 400, 500, "jumpButton", "jumpPressed", !1), p.calls.push(this.buttonJump.buttonPressed.bind(this.buttonJump)), this.buttonCrouch = new ControllerButton(this.game, 400, 400, "crouchButton", "crouchPressed", !1), u.calls.push(this.buttonCrouch.buttonPressed.bind(this.buttonCrouch));
|
|
var m = this.circleMovement,
|
|
v = this.buttonJump,
|
|
x = this.buttonCrouch;
|
|
this.circle1 = new ControllerStick(this.game, 150, 400, "circleButton", !1), this.circle2 = new ControllerStick(this.game, this.game.width - 150, 400, "circleButton", !1);
|
|
var b = this.circle1,
|
|
w = this.circle2;
|
|
p.calls.push(this.circle1.upIsDown.bind(this.circle1)), p.calls.push(this.circle2.upIsDown.bind(this.circle2)), u.calls.push(this.circle1.downIsDown.bind(this.circle1)), u.calls.push(this.circle2.downIsDown.bind(this.circle2)), d.calls.push(this.circle1.leftIsDown.bind(this.circle1)), d.calls.push(this.circle2.leftIsDown.bind(this.circle2)), y.calls.push(this.circle1.rightIsDown.bind(this.circle1)), y.calls.push(this.circle2.rightIsDown.bind(this.circle2));
|
|
var P = this.game;
|
|
this.keys = { up: p, down: u, left: d, right: y, reset: f, space: g, show: function() { P.device.desktop || (Constants.oldControls ? (b.show(), w.show()) : (m.show(), v.show(), x.show())) }, hide: function() { m.hide(), v.hide(), x.hide(), b.hide(), w.hide() }, isScreenButtonDown: function() { return !!m.isDown || (!!v.isDown || (!!x.isDown || (!!b.isDown || !!w.isDown))) }, setAlpha: function(t) { m.sprite.alpha = t, v.sprite.alpha = t, x.sprite.alpha = t, b.sprite.alpha = t, w.sprite.alpha = t } }, this.keys.hide(), this.game.stage.backgroundColor = "#FFFFFF", this.game.world.setBounds(-3e3, -3e3, 9e3, 6e3), this.game.device.desktop ? (this.stage.disableVisibilityChange = !0, this.game.onBlur.add(function(t) { s.game.sound.mute = !0 }), this.game.onFocus.add(function(t) { s.game.sound.mute = !1 })) : (this.stage.disableVisibilityChange = !1, this.game.onPause.add(function(t) { s.game.sound.mute = !0 }), this.game.onResume.add(function(t) { s.game.sound.mute = !1 })), this.main = new Main(this.game, this.keys), this.main, this.game.scale.onSizeChange.add(function(t, e, i) { s.game.device.desktop || (e *= Constants.userRatio, i *= Constants.userRatio), s.resizeStage(t, e, i) }), this.resizeStage(null, this.game.width, this.game.height);
|
|
var _ = this.game.add.group();
|
|
_.add(this.circleMovement.sprite), _.add(this.buttonJump.sprite), _.add(this.buttonCrouch.sprite), _.add(this.circle1.sprite), _.add(this.circle2.sprite);
|
|
var T = function() { s.main.mobilePressedDown(), s.main.mobilePressedDown() };
|
|
this.circle1.pressedDown.add(T), this.circle2.pressedDown.add(T), this.circleMovement.pressedDown.add(T), this.buttonJump.pressedDown.add(T), this.buttonCrouch.pressedDown.add(T)
|
|
}, t.prototype.resizeStage = function(t, e, i) {
|
|
var s, o;
|
|
if (this.main.resizeStage(e, i), o = this.game.device.desktop ? (s = window.innerWidth, window.innerHeight) : (s = window.innerWidth * Constants.userRatio, window.innerHeight * Constants.userRatio), this.game.ph2UIManager.events.onGameResize(s, o), this.circleMovement.sprite.cameraOffset.x = 130, this.circleMovement.sprite.scale.set(1.25), this.buttonJump.sprite.cameraOffset.x = e - 130, this.buttonCrouch.sprite.cameraOffset.x = e - 270, this.buttonJump.sprite.scale.set(.75), this.buttonCrouch.sprite.scale.set(.75), this.game.width < 670) {
|
|
var n = this.game.width / 670;
|
|
this.circleMovement.sprite.scale.set(1.25 * n), this.buttonJump.sprite.scale.set(.75 * n), this.buttonCrouch.sprite.scale.set(.75 * n), this.buttonJump.sprite.cameraOffset.x = e - 130 * n, this.buttonCrouch.sprite.cameraOffset.x = e - 270 * n, this.circleMovement.sprite.cameraOffset.x = 130 * n, this.circleMovement.sprite.cameraOffset.y = i - 220, this.buttonJump.sprite.cameraOffset.y = i - 220, this.buttonCrouch.sprite.cameraOffset.y = i - 150
|
|
}
|
|
else 960 < this.game.width ? (this.buttonJump.sprite.cameraOffset.x = e - 162.5, this.buttonCrouch.sprite.cameraOffset.x = e - 337.5, this.circleMovement.sprite.cameraOffset.x = 130, this.circleMovement.sprite.scale.set(1.25), this.buttonJump.sprite.scale.set(1), this.buttonCrouch.sprite.scale.set(1)) : (this.buttonJump.sprite.cameraOffset.x = e - 130, this.buttonCrouch.sprite.cameraOffset.x = e - 270, this.circleMovement.sprite.cameraOffset.x = 130, this.circleMovement.sprite.scale.set(1.25), this.buttonJump.sprite.scale.set(.75), this.buttonCrouch.sprite.scale.set(.75)), this.circleMovement.sprite.cameraOffset.y = i - 220, this.buttonJump.sprite.cameraOffset.y = i - 220, this.buttonCrouch.sprite.cameraOffset.y = i - 150
|
|
}, t.prototype.update = function() {
|
|
for (var t in this.main.update(), this.keys) "function" != typeof this.keys[t] && this.keys[t].update();
|
|
Constants.oldControls ? (this.circle1.update(), this.circle2.update()) : this.circleMovement.update()
|
|
}, t.prototype.quitGame = function() {}, t
|
|
}();
|
|
|
|
function timeDecorator(t) {
|
|
var e = Math.floor(t / 100 % 10),
|
|
i = e.toString();
|
|
e < 10 && (i = "0" + e);
|
|
var s = Math.floor(t / 1e3 % 60),
|
|
o = s.toString();
|
|
s < 10 && (o = "0" + o);
|
|
var n = Math.floor(t / 1e3 / 60 % 60),
|
|
a = n.toString();
|
|
return n < 10 && (a = "0" + a), a + ":" + o + ":" + i
|
|
}
|
|
|
|
function timeDecoratorHub(t) {
|
|
Math.floor(t / 100);
|
|
var e = Math.floor(t / 1e3 % 60),
|
|
i = e.toString();
|
|
e < 10 && (i = "0" + i);
|
|
var s = Math.floor(t / 1e3 / 60 % 60),
|
|
o = s.toString();
|
|
s < 10 && (o = "0" + o);
|
|
var n = Math.floor(t / 1e3 / 60 / 60 | 0),
|
|
a = n.toString();
|
|
return n < 10 && (a = "0" + a), a + ":" + o + ":" + i
|
|
}
|
|
|
|
function timeDecoratorActBlock(t) {
|
|
var e = Math.floor(t / 1e3 % 60),
|
|
i = e.toString();
|
|
e < 10 && (i = "0" + i);
|
|
var s = Math.floor(t / 1e3 / 60 % 60),
|
|
o = s.toString();
|
|
return s < 10 && (o = "0" + o), o + ":" + i
|
|
}
|
|
|
|
function floorDecorator(t, e) { return t + "/" + e }
|
|
|
|
function getDeathText(t) {
|
|
var e, i = "";
|
|
switch (t) {
|
|
case 1:
|
|
i = Math.random() < .5 ? "Splattered!" : "Hard landing!";
|
|
break;
|
|
case 2:
|
|
i = (e = Math.random()) < .33 ? "Shredded!" : e < .66 ? "Buzzkill!" : "Sawed to bits!";
|
|
break;
|
|
case 3:
|
|
i = (e = Math.random()) < .33 ? "Crushed!" : e < .66 ? "Squashed!" : "Too compressed!";
|
|
break;
|
|
case 4:
|
|
i = (e = Math.random()) < .33 ? "Lungs collapsed!" : e < .66 ? "Drowned!" : "Sleeping with no fishes...!";
|
|
break;
|
|
case 5:
|
|
i = (e = Math.random()) < .33 ? "Fell out the world!" : e < .66 ? "Straight to hell.!" : "Fell too far!";
|
|
break;
|
|
case 6:
|
|
i = "No entry!";
|
|
break;
|
|
case 7:
|
|
i = (e = Math.random()) < .33 ? "Squished." : e < .66 ? "Squashed." : "Crushed.";
|
|
break;
|
|
case 8:
|
|
i = (e = Math.random()) < .25 ? "Reaped." : e < .5 ? "Scythed." : e < .75 ? "Grim death." : "Decapitated.";
|
|
break;
|
|
case 9:
|
|
i = (e = Math.random()) < .33 ? "tried shurikenjutsu!" : e < .66 ? "Bad ninja!" : "Sliced and diced!";
|
|
break;
|
|
case 10:
|
|
i = Math.random() < .5 ? "Death four-ways!" : "Sliced and diced!";
|
|
break;
|
|
case 11:
|
|
i = (e = Math.random()) < .33 ? "Electrocuted!" : e < .66 ? "Sparked out!" : "Shocking.";
|
|
break;
|
|
case 12:
|
|
i = (e = Math.random()) < .33 ? "Crushed!" : e < .66 ? "Squashed!" : "Too compressed!";
|
|
break;
|
|
case 13:
|
|
i = (e = Math.random()) < .33 ? "Swiped." : e < .66 ? "Rushed off your feet." : "Ripped to bits";
|
|
break;
|
|
case 14:
|
|
i = (e = Math.random()) < .33 ? "Obliterated!" : e < .66 ? "Splasered!" : "Fried vexman!";
|
|
break;
|
|
case 15:
|
|
i = Math.random() < .5 ? "Surprised spiked!" : "Penetrated!";
|
|
break;
|
|
default:
|
|
i = Math.random() < .5 ? "Spiked!" : "Popped!"
|
|
}
|
|
return i
|
|
}
|
|
var Vex4, VexWindow = function() {
|
|
function t(t, e, i) { this.main = t, this.game = e, this.layer = i, this.container = e.add.group(i) }
|
|
return t.prototype.init = function() {
|
|
var t = this;
|
|
this.closeButton = this.game.add.sprite(100, -100, "closeButton"), this.closeButton.inputEnabled = !0, this.closeButton.anchor.set(.5, .5), this.closeButton.events.onInputUp.add(function() { t.main.sounds.playSound("buttonClick"), t.hide() }, this), this.container.position.set(this.game.width / 2, -400), this.frame.anchor.set(.5, .5), this.container.addChild(this.frame), this.container.addChild(this.closeButton), this.container.visible = !1, this.showing = !1
|
|
}, t.prototype.show = function() { this.main.state !== GameStates.Playing && this.main.state !== GameStates.MainMenu || (this.container.position.y = -800, this.container.visible = !0, this.showing = !0, this.main.openWindow()) }, t.prototype.hide = function() { this.showing = !1, this.main.closeWindow() }, t.prototype.update = function() {
|
|
if (this.showing) { var t = this.game.height / 2; - 2 < (e = this.container.position.y - t) ? this.container.position.y = t : this.container.position.y -= e / 4 }
|
|
else {
|
|
t = this.game.height + 800;
|
|
var e = this.container.y - t;
|
|
this.container.position.y > this.game.height + 500 ? (this.container.position.y = 900, this.container.visible = !1) : this.container.position.y -= e / 4
|
|
}
|
|
}, t.prototype.resizeStage = function(t, e) { this.container.x = t / 2 }, t
|
|
}();
|
|
! function(t) {
|
|
var e = function(t) {
|
|
function e() { var e = t.call(this, { enableDebug: !1, width: 960, height: 840, renderer: Phaser.AUTO, parent: "content", transparent: !0, antialias: !0, preserveDrawingBuffer: !1, physicsConfig: null, seed: "", state: null, forceSetTimeOut: !1 }) || this; return e.clearBeforeRender = !1, Phaser.Device.whenReady(function() { e.stage.disableVisibilityChange = !0, document.getElementById("content").addEventListener("touchstart", function(t) { e.gameResumed(t) }), document.getElementById("content").addEventListener("click", function(t) { e.gameResumed(t), document.getElementById("content").children[0].focus() }) }), e.state.add("preGame", { create: e.stateCreator.bind(e), preload: e.statePreloader.bind(e) }, !0), e }
|
|
return __extends(e, t), e.prototype.statePreloader = function() {
|
|
var e = this;
|
|
window.hasOwnProperty("cordova") || libs.forEach(function(t) { e.load.script(t, t) })
|
|
}, e.prototype.stateCreator = function() { this.plugins.add(Fabrique.Plugins.GameEvents), this.plugins.add(Fabrique.Plugins.GoogleAnalytics), this.plugins.add(Fabrique.Plugins.GameAnalytics), this.plugins.add(PhaserSpine.SpinePlugin), this.plugins.add(PhaserAds.AdManager), this.plugins.add(PhaserCachebuster.CacheBuster), this.plugins.add(PhaserSuperStorage.StoragePlugin), this.plugins.add(PhaserInput.Plugin), this.plugins.add(Ph2.AnimationPlugin), this.storage.forcePromises = !0, Fabrique.Utils.isOnDevice(this) && void 0 !== window.NativeStorage && this.storage.setAdapter(new PhaserSuperStorage.StorageAdapters.CordovaStorage), this.state.add(Fabrique.SplashScreen.Preloader.Name, Fabrique.SplashScreen.Preloader, !1), this.state.add("Boot", VexBoot), this.state.add("Game", VexGameState), this.state.start("Boot"), this.state.remove("preGame") }, e
|
|
}(Phaser.Game);
|
|
t.Game = e
|
|
}(Vex4 || (Vex4 = {}));
|
|
var VIEWTYPE, RANKTYPE, UIGPELEMENTS, ControllerButton = function() {
|
|
function t(t, e, i, s, o, n) { this.isDown = !1, this.game = t, this.sprite = t.add.sprite(e, i, s), this.sprite.alpha = .5, this.sprite.anchor.set(.5, .5), this.sprite.scale.set(1.35, 1.35), this.sprite.fixedToCamera = !0, this.sprite.inputEnabled = !0, this.originalSprite = this.sprite.key.toString(), this.downSprite = t.add.sprite(e, i, o), this.downSprite.visible = !1, n && (this.sprite.events.onInputOver.add(this.onDown, this), this.sprite.events.onInputOut.add(this.onUp, this)), this.sprite.events.onInputDown.add(this.onDown, this), this.sprite.events.onInputUp.add(this.onUp, this), this.pressedDown = new Phaser.Signal, this.isDown = !1, this.isPressed = !1 }
|
|
return t.prototype.onDown = function(t, e) { this.pointer = e, this.isDown = !0, this.isPressed = !0, this.sprite.loadTexture(this.downSprite.key) }, t.prototype.onUp = function() { this.isDown && this.pressedDown.dispatch(), this.isDown = !1, this.isPressed = !1, this.sprite.loadTexture(this.originalSprite) }, t.prototype.hide = function() { this.sprite.visible = !1 }, t.prototype.show = function() { this.sprite.visible = !0 }, t.prototype.buttonPressed = function() { return this.isDown }, t
|
|
}(),
|
|
Options = function() {
|
|
function t(t) {
|
|
this.autoReset = !1, this.particleLimit = 30, this.controllerSelect = !1, this.blend = !0, this.waves = !0, this.parallax = !0, this.musicVolume = 1, this.effectVolume = .5, this.muted = !1, this.game = t;
|
|
var e = SaveGame.getInstance(this.game).getAllValues();
|
|
this.loadOptions(e.options)
|
|
}
|
|
return t.prototype.loadOptions = function(t) { this.musicVolume = t.mv, this.effectVolume = t.efxv, this.autoReset = t.ar, this.particleLimit = t.pl, this.controllerSelect = t.nc, this.blend = t.bl, this.waves = t.wv, this.parallax = t.plx, this.muted = t.mt }, t.prototype.saveOptions = function() {
|
|
var t = { mv: this.musicVolume, efxv: this.effectVolume, ar: this.autoReset, pl: this.particleLimit, nc: this.controllerSelect, bl: this.blend, wv: this.waves, plx: this.parallax, mt: this.muted };
|
|
SaveGame.getInstance().saveOptions(t)
|
|
}, t.prototype.clearSavedData = function() {
|
|
SaveGame.getInstance().resetOptions();
|
|
var t = SaveGame.getInstance().getOptions();
|
|
this.loadOptions(JSON.parse(t))
|
|
}, t
|
|
}(),
|
|
allunlocked = !1,
|
|
Level = function() {
|
|
function t(t, e, i, s, o, n, a, r, h) { this.levels = t, this.id = e, this.data = i, this.name = s, this.topTime = o, this.goldTime = 1e3 * n, this.silverTime = 1e3 * a, this.bronzeTime = 1e3 * r, this.gotStar = !1, this.found = !1, this.challengeCompleted = !1, (this.hue = h) && (this.colorFilter = new PIXI.ColorMatrixFilter, this.colorFilter.hue(h)), allunlocked && -1 === this.topTime && (this.topTime = 5), -1 < this.topTime && (this.topTime < this.goldTime ? this.bestRank = 0 : this.topTime < this.silverTime ? this.bestRank = 2 : this.topTime < this.bronzeTime ? this.bestRank = 3 : this.bestRank = 4), "hub" !== this.id && "edit" !== this.id && this.loadLevel() }
|
|
return t.prototype.setBestTime = function(t, e) { var i = 6; - 1 < t && (i = t < this.goldTime ? 0 === e ? 0 : 1 : t < this.silverTime ? 2 : t < this.bronzeTime ? 3 : 4), -1 !== this.topTime && i > this.bestRank || (this.topTime = t, this.topTime > t && (this.topTime = t), this.bestRank = i, this.saveLevel()) }, t.prototype.gotGold = function() { return -1 !== this.topTime && this.topTime <= this.goldTime }, t.prototype.loadLevel = function() {
|
|
var t = parseInt(this.id),
|
|
e = SaveGame.getInstance().getLevel(t - 1);
|
|
this.topTime = e.tt, this.bestRank = e.br, this.gotStar = e.gs, this.challengeCompleted = e.cc
|
|
}, t.prototype.saveLevel = function() {
|
|
var t = { tt: this.topTime, br: this.bestRank, gs: this.gotStar, cc: this.challengeCompleted, fn: this.found };
|
|
SaveGame.getInstance().saveLevels(parseInt(this.id), t)
|
|
}, t.prototype.clearSavedData = function() { SaveGame.getInstance().resetLevels() }, t.ChallengeSteps = 0, t
|
|
}(),
|
|
Levels = function() {
|
|
function t(t, e) {
|
|
this.levels = {}, this.game = t, this.totalLoad = 0, this.loadedNum = 0, this.doneCallback = e, this.latestCompleted = Constants.latestCompleted;
|
|
var i = this.game.cache.getJSON("levelsConfig");
|
|
for (var s in i)
|
|
if (i.hasOwnProperty(s)) {
|
|
var o = i[s].file,
|
|
n = this.game.cache.getJSON(o);
|
|
levelData[o] = n;
|
|
var a = i[s].name,
|
|
r = i[s].nameHard,
|
|
h = i[s].hue;
|
|
if ("hub" === s) this.loadLevel(s, o, a, -1, -1, -1);
|
|
else if ("11" === s) this.loadLevel(s, o, a, -1, -1, -1, 130);
|
|
else {
|
|
var l = i[s].goldTime,
|
|
c = i[s].silverTime,
|
|
p = i[s].bronzeTime,
|
|
u = parseInt(s),
|
|
d = SaveGame.getInstance().getLevel(u - 1);
|
|
if ("edit" !== s)
|
|
if (d || SaveGame.getInstance().saveLevels(u, SaveGame.getInstance().clearLevel()), i[s].fileChallengeName) {
|
|
var y = i[s].fileChallengeName;
|
|
n = this.game.cache.getJSON(y), levelData[y] = n, this.loadLevel(s, o, a, l, c, p, h, y, r)
|
|
}
|
|
else this.loadLevel(s, o, a, l, c, p, h);
|
|
else this.loadLevel(s, o, a, -1, -1, -1, h)
|
|
}
|
|
}
|
|
allunlocked && (this.latestCompleted = 10), e()
|
|
}
|
|
return t.prototype.getGoldNumber = function() { var t = 0; for (var e in this.levels) { var i = this.levels[e]; "hub" != e && (i.gotGold() && t++) } return t }, t.prototype.getPerfectNumber = function() { var t = 0; for (var e in this.levels) { var i = this.levels[e]; "hub" != e && (0 == i.bestRank && t++) } return t }, t.prototype.checkOlympian = function() { for (var t in this.levels) { var e = this.levels[t]; if ("hub" != t && !e.gotGold()) return !1 } return !0 }, t.prototype.checkPerfection = function() { for (var t in this.levels) { var e = this.levels[t]; if ("hub" != t && 0 !== e.bestRank) return !1 } return !0 }, t.prototype.checkAstronomer = function() { for (var t in this.levels) { var e = this.levels[t]; if ("hub" != t && !e.gotStar) return !1 } return !0 }, t.prototype.checkWinner = function() { for (var t in this.levels) { var e = this.levels[t]; if ("hub" != t && "10" != t && !e.challengeCompleted) return !1 } return !0 }, t.prototype.clearAllLevelData = function() { for (var t in this.levels) { this.levels[t].clearSavedData() } this.latestCompleted = 0 }, t.prototype.loadLevel = function(t, e, i, s, o, n, a, r, h) { void 0 === a && (a = 0), this.levels[t] = new Level(this, t, levelData[e], i, -1, s, o, n, a), this.levels[t].challengeData = levelData[r], this.levels[t].challengeName = h }, t
|
|
}(),
|
|
Transition = function(i) {
|
|
function t(t) { var e = i.call(this, t) || this; return e.anim = e.game.add.ph2AnimationObject(0, 0, "transition", "atlas_transition"), e.anim.ph2Animations.getAnimations().transition_in.onComplete.add(e.onInitEnd, e), e.add(e.anim), e.fixedToCamera = !0, e }
|
|
return __extends(t, i), t.prototype.beginTransition = function(t, e, i, s) { this.callback = t, this.isHub = s, this.context = e, this.anim.ph2Animations.play("transition_in") }, t.prototype.onInitEnd = function() { var t = this;!this.isHub && Fabrique.Utils.isOnDevice(this.game) ? (Fabrique.LoaderHelper.show(), this.anim.ph2Animations.play("transition_stand", 1, !0), Fabrique.AdHandler.getInstance(this.game).showAd(function() { Fabrique.LoaderHelper.hide(), t.callback.call(t.context), t.endTransition() }, function() { Fabrique.LoaderHelper.hide() }, "start")) : (this.callback.call(this.context), this.endTransition()) }, t.prototype.endTransition = function() { this.anim.ph2Animations.play("transition_out", 1, !1) }, t.prototype.resizeStage = function(t, e) {
|
|
this.anim.x = this.game.width / 2, this.anim.y = this.game.height / 2;
|
|
var i = this.game.width / 960,
|
|
s = this.game.height / 640,
|
|
o = s < i ? i : s;
|
|
this.anim.scale.x = o, this.anim.scale.y = o
|
|
}, t
|
|
}(Phaser.Group),
|
|
Portal = function(a) {
|
|
function r(t, e, i, s) { var o, n = a.call(this, t) || this; return n.colors = [0, 180, 80, 630], n.game = e, n.layer = i, n.colorIndex = s, n.sprite = i.create(0, 0, "atlas_portals"), n.sprite.autoCull = !0, n.sprite.anchor.set(.5, .5), o = Phaser.Animation.generateFrameNames("portal_blue", 0, 13, ".png", 0), n.sprite.animations.add("animate", o), o = Phaser.Animation.generateFrameNames("portal_blue_disabled", 0, 13, ".png", 0), n.sprite.animations.add("animateDisabled", o), n.sprite.animations.play("animate", 30, !0), n.colorFilter = new PIXI.ColorMatrixFilter, n.colorFilter.hue(n.colors[s]), n.main.options.blend ? (r.BlurFilterX || ((r.BlurFilterX = e.add.filter("BlurX")).blur = 10), r.BlurFilterY || ((r.BlurFilterY = e.add.filter("BlurY")).blur = 10), n.sprite.filters = [r.BlurFilterX, r.BlurFilterY, n.colorFilter]) : n.sprite.filters = [n.colorFilter], n.isEnable = !0, n.cooldown = 0, n.hitBoxPolygon = new SAT.Box(new SAT.Vector(0, 0), 10, 32).toPolygon(), n.hitBoxPolygon.setOffset(new SAT.Vector(-5, -16)), n }
|
|
return __extends(r, a), Object.defineProperty(r.prototype, "portalAttach", { get: function() { return this.portalAttached }, enumerable: !0, configurable: !0 }), Object.defineProperty(r.prototype, "enabled", { get: function() { return this.isEnable }, enumerable: !0, configurable: !0 }), r.prototype.disablePortal = function() {
|
|
this.isEnable = !1;
|
|
var t = this.sprite.animations.frame;
|
|
this.sprite.animations.play("animateDisabled", 30, !0), this.sprite.animations.frame = t, this.cooldown = r.TimeCooldown, this.colorFilter.blackAndWhite(!0)
|
|
}, r.prototype.attachPortal = function(t) { this.portalAttached = t }, r.prototype.getAttachPortal = function() { return this.portalAttached }, r.prototype.getTeleportPoint = function() { if (!this.isEnable) return null; var t = { x: 0, y: 0 }; return this.portalAttached ? (t.x = this.portalAttached.xPos, t.y = this.portalAttached.yPos, t) : null }, r.prototype.update = function() {
|
|
if (!this.isEnable && (this.cooldown -= this.main.gameSpeed, this.cooldown <= 0)) {
|
|
this.isEnable = !0;
|
|
var t = this.sprite.animations.frame;
|
|
this.sprite.animations.play("animate", 30, !0), this.sprite.animations.frame = t, this.colorFilter.hue(this.colors[this.colorIndex])
|
|
}
|
|
}, r.prototype.spawn = function(t, e) { this.xPos = t, this.yPos = e, this.sprite.position.set(t, e), this.hitBoxPolygon.pos.x = t, this.hitBoxPolygon.pos.y = e }, r.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, this.portalAttached = null, a.prototype.destroy.call(this) }, r
|
|
}(Entity),
|
|
ElevatorGenerator = function(n) {
|
|
function a(t, e, i, s) { var o = n.call(this, t, e, i) || this; return o.game = e, o.layer = i, o.sprite = i.create(0, 0, "basicBlockColors"), o.sprite.autoCull = !0, o.sprite.anchor.set(.5, .5), o.sprite.scale.set(150 / o.sprite.width, 40 / o.sprite.height), o.isDown = s, o.alive = !1, o.hangable = !0, o.scalable = !0, o.timeNextPlatform = a.TimeNewElevator, o.delayNextPlatform = a.TimeNewElevator, o.elevators = [], o.cable = new Cable(o.main, o.game, o.main.obstacleLayer), o }
|
|
return __extends(a, n), a.prototype.spawnCable = function() {
|
|
for (var t = 0, e = this.main.elevatorEliminator; t < e.length; t++) {
|
|
var i = e[t];
|
|
if (i.xPos + i.width / 2 >= this.xPos && i.xPos - i.width / 2 <= this.xPos) {
|
|
if (this.isDown && i.yPos >= this.yPos) {
|
|
var s = i.yPos - this.yPos;
|
|
this.cable.spawn(this.xPos, this.yPos, s);
|
|
break
|
|
}
|
|
if (!this.isDown && i.yPos <= this.yPos) {
|
|
s = i.yPos - this.yPos;
|
|
this.cable.spawn(this.xPos, this.yPos, s);
|
|
break
|
|
}
|
|
this.cable.spawn(this.xPos, this.yPos, 0)
|
|
}
|
|
else this.cable.spawn(this.xPos, this.yPos, 0)
|
|
}
|
|
}, a.prototype.spawn = function(t, e) {
|
|
this.destroyAllPlatforms();
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.spawnCable(), this.width = 150, this.height = 60, this.sprite.position.set(t, e), this.sprite.width = 150, this.sprite.height = 60, this.sprite.anchor.set(.5, .5), this.sprite.frame = parseInt(this.main.currentLevelID), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - 75, this.rightEdge = t + 75, this.topEdge = e - 30, this.bottomEdge = e + 30, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var i = .5 * this.width,
|
|
s = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), 150, 60), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.topBound = new SAT.Box(new SAT.Vector(t, e), 150, BasicBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), i, 60), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), i, 60), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), 150, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-i, s - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, a.prototype.destroy = function() { this.destroyAllPlatforms(), this.cable.destroy(), this.sprite.destroy(), this.sprite = null, n.prototype.destroy.call(this) }, a.prototype.update = function() {
|
|
if (0 < this.elevators.length)
|
|
for (var t = 0, e = this.elevators; t < e.length; t++) { e[t].update() } this.timeNextPlatform -= this.main.gameSpeed, this.timeNextPlatform <= 0 && (this.createElevator(), this.timeNextPlatform = this.delayNextPlatform), this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition()
|
|
}, a.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, a.prototype.createElevator = function() {
|
|
var t = new Elevator(this.main, this.game, this.main.obstacleLayer, this),
|
|
e = this.isDown ? a.SpeedElevator : -a.SpeedElevator;
|
|
t.spawn(this.xPos, this.yPos, 0, e), this.main.blocks.push(t), this.elevators.push(t)
|
|
}, a.prototype.deletedElevator = function(t) {
|
|
var e;
|
|
e = this.main.blocks.indexOf(t), this.main.blocks.splice(e, 1), e = this.elevators.indexOf(t), this.elevators.splice(e, 1), t.destroy()
|
|
}, a.prototype.destroyAllPlatforms = function() { for (; 0 < this.elevators.length;) this.deletedElevator(this.elevators[0]) }, a.prototype.resetLevel = function() { n.prototype.resetLevel.call(this), this.destroyAllPlatforms() }, a.TOP_BOUND_HEIGHT = 12, a
|
|
}(Block),
|
|
Elevator = function(n) {
|
|
function t(t, e, i, s) { var o = n.call(this, t, e, i) || this; return o.sprite = i.create(0, 0, "elevatorUp"), o.sprite.autoCull = !0, o.sprite.visible = !1, o.alive = !1, o.generator = s, o.hangable = !0, o.scalable = !0, o }
|
|
return __extends(t, n), t.prototype.spawn = function(t, e, i, s) {
|
|
this.xPos = t, this.yPos = e, this.xVelocity = i;
|
|
var o = (this.yVelocity = s) < 0 ? "elevatorUp" : "elevatorDown";
|
|
this.sprite.loadTexture(o), this.prevX = t, this.prevY = e, this.width = this.sprite.width, this.height = this.sprite.height, this.sprite.position.set(t, e), this.sprite.scale.set(this.width / this.sprite.width, this.height / this.sprite.height), this.sprite.anchor.set(.5, .5), this.sprite.frame = parseInt(this.main.currentLevelID), this.sprite.visible = !0, this.leftEdge = t - .5 * this.width, this.rightEdge = t + .5 * this.width, this.topEdge = e - .5 * this.height, this.bottomEdge = e + .5 * this.height, this.landed = null, this.alive = !0;
|
|
var n = .5 * this.width,
|
|
a = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), this.width, this.height), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.topBound = new SAT.Box(new SAT.Vector(t, e), this.width, BasicBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), n, BasicBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), n, BasicBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), n, this.height), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-n, -a)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), n, this.height), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -a)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), this.width, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-n, a - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.xPos += this.xVelocity, this.yPos += this.yVelocity, this.updatePosition(); for (var t = 0, e = this.main.elevatorEliminator; t < e.length; t++) { var i = e[t]; if (this.yVelocity < 0 && SAT.testPolygonPolygon(this.bottomBoundPolygon, i.totalBoundPolygon) || 0 < this.yVelocity && SAT.testPolygonPolygon(this.topBoundPolygon, i.totalBoundPolygon)) { this.generator.deletedElevator(this); break } } }, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, n.prototype.destroy.call(this) }, t.prototype.reset = function() {}, t
|
|
}(Block),
|
|
ElevatorEliminator = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.game = e, s.layer = i, s.sprite = i.create(0, 0, "basicBlockColors"), s.sprite.autoCull = !0, s.sprite.anchor.set(.5, .5), s.alive = !1, s.hangable = !0, s.scalable = !0, s }
|
|
return __extends(t, o), t.prototype.spawn = function(t, e) {
|
|
this.xPos = t, this.yPos = e, this.prevX = t, this.prevY = e, this.width = 150, this.height = 60, this.sprite.position.set(t, e), this.sprite.width = 150, this.sprite.height = 60, this.sprite.anchor.set(.5, .5), this.sprite.frame = parseInt(this.main.currentLevelID), this.sprite.visible = !0, this.xVelocity = 0, this.yVelocity = 0, this.leftEdge = t - 75, this.rightEdge = t + 75, this.topEdge = e - 30, this.bottomEdge = e + 30, this.xVelocity = 0, this.yVelocity = 0, this.landed = null, this.alive = !0;
|
|
var i = .5 * this.width,
|
|
s = .5 * this.height;
|
|
this.totalBound = new SAT.Box(new SAT.Vector(t, e), 150, 60), this.totalBoundPolygon = this.totalBound.toPolygon(), this.totalBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.topBound = new SAT.Box(new SAT.Vector(t, e), 150, BasicBlock.TOP_BOUND_HEIGHT), this.topBoundPolygon = this.topBound.toPolygon(), this.topBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.lhBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.lhBoundPolygon = this.lhBound.toPolygon(), this.lhBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rhBound = new SAT.Box(new SAT.Vector(t, e), i, BasicBlock.TOP_BOUND_HEIGHT), this.rhBoundPolygon = this.rhBound.toPolygon(), this.rhBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.leftBound = new SAT.Box(new SAT.Vector(t, e), i, 60), this.leftBoundPolygon = this.leftBound.toPolygon(), this.leftBoundPolygon.setOffset(new SAT.Vector(-i, -s)), this.rightBound = new SAT.Box(new SAT.Vector(t, e), i, 60), this.rightBoundPolygon = this.rightBound.toPolygon(), this.rightBoundPolygon.setOffset(new SAT.Vector(0, -s)), this.bottomBound = new SAT.Box(new SAT.Vector(t, e), 150, BasicBlock.TOP_BOUND_HEIGHT), this.bottomBoundPolygon = this.bottomBound.toPolygon(), this.bottomBoundPolygon.setOffset(new SAT.Vector(-i, s - BasicBlock.TOP_BOUND_HEIGHT))
|
|
}, t.prototype.destroy = function() { this.sprite.destroy(), this.sprite = null, o.prototype.destroy.call(this) }, t.prototype.updatePosition = function() { this.leftEdge = this.xPos - .5 * this.width, this.rightEdge = this.xPos + .5 * this.width, this.topEdge = this.yPos - .5 * this.height, this.bottomEdge = this.yPos + .5 * this.height, this.sprite.position.set(this.xPos, this.yPos), this.totalBoundPolygon.pos.x = this.xPos, this.totalBoundPolygon.pos.y = this.yPos, this.topBoundPolygon.pos.x = this.xPos, this.topBoundPolygon.pos.y = this.yPos, this.lhBoundPolygon.pos.x = this.xPos, this.lhBoundPolygon.pos.y = this.yPos, this.rhBoundPolygon.pos.x = this.xPos, this.rhBoundPolygon.pos.y = this.yPos, this.leftBoundPolygon.pos.x = this.xPos, this.leftBoundPolygon.pos.y = this.yPos, this.rightBoundPolygon.pos.x = this.xPos, this.rightBoundPolygon.pos.y = this.yPos, this.bottomBoundPolygon.pos.x = this.xPos, this.bottomBoundPolygon.pos.y = this.yPos }, t.prototype.update = function() { this.xPos == this.prevX && this.yPos == this.prevY || this.updatePosition() }, t.prototype.resetLevel = function() { o.prototype.resetLevel.call(this) }, t.prototype.reset = function() { o.prototype.reset.call(this) }, t.TOP_BOUND_HEIGHT = 12, t
|
|
}(Block),
|
|
MainMenuUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.isWeb = !0, t.analytics.google.sendScreenView("menu"), i.main = e, i.ui = i.game.add.ph2UI("ui_main_menu", "atlas_main_menu"), i.add(i.ui), i.brandLogo = Fabrique.Branding.getLogoWithLink(t, "vex-4"), i.add(i.brandLogo), i.brandLogo.y = i.game.height - i.brandLogo.height - 100, i.brandLogo.scale.set(.6, .6), i.addTouchCallback(), i.localization(), i.game.device.cordova && (i.isWeb = !1), i.isWeb && (i.promoButton = i.game.add.button(0, 0, "cPromoImage", i.crossPromo), i.add(i.promoButton), i.promoButton.anchor.set(.55, .65)), i }
|
|
return __extends(t, s), t.prototype.addTouchCallback = function() {
|
|
if (Game.Util.addTouchCallbackToButton("play", this.ui, this.goToHub, this), Game.Util.addTouchCallbackToButton("trophies", this.ui, this.showAchievements, this), Game.Util.addTouchCallbackToButton("highscores", this.ui, this.showHighscores, this), Game.Util.addTouchCallbackToButton("settings", this.ui, this.showSettings, this), Game.Util.addTouchCallbackToButton("challenge_room", this.ui, this.goToChallenge, this), !Fabrique.Utils.isOnDevice(this.game)) {
|
|
var t = Ph2.UISystem.findObject("highscores", this.ui);
|
|
t.visible = !1, (t = Ph2.UISystem.findObject("challenge_room", this.ui)).alignment.setLandscapeAlignment("BOTTOM_CENTER", 0, !0, -.15, !1), t.alignment.setPortraitAlignment("BOTTOM_CENTER", 0, !0, -.15, !1)
|
|
}
|
|
}, t.prototype.goToHub = function() { this.main.state === GameStates.MainMenu && this.main.changeLevel("hub", -1) }, t.prototype.showAchievements = function() { Fabrique.Utils.isOnDevice(this.game) ? SocialServicesHandler.showAchievements(this.game) : this.main.state === GameStates.MainMenu && this.main.trophiesUI.show() }, t.prototype.showSettings = function() { this.main.state === GameStates.MainMenu && this.main.optionsUI.show() }, t.prototype.showHighscores = function() { SocialServicesHandler.showLeaderboards() }, t.prototype.goToChallenge = function() { this.main.state === GameStates.MainMenu && this.main.changeLevel("11", -1, !1, 0) }, t.prototype.localization = function() { Game.LocalizationManager.getInstance(this.game).localizeText("play/play_text", this.ui, "ui_mm_start") }, t.prototype.crossPromo = function() { this.game.analytics.google.sendGenericEvent("crosspromotion", "v4_app_btn_click"), window.open("https://play.google.com/store/apps/details?id=com.kizi.vex4", "_blank") }, t.prototype.resize = function() { this.brandLogo.y = this.game.height - this.brandLogo.height - .1 * this.game.height; for (var t = 960 < this.game.width ? 1 : this.game.width / 960, e = 640 < this.game.height ? 1 : this.game.height / 640, i = t < e ? t : e, s = 0, o = this.ui.children; s < o.length; s++) { o[s].scale.set(i, i) } this.isWeb && (this.promoButton.scale.set(i, i), this.game.width > this.game.height ? (this.promoButton.x = this.game.width - this.promoButton.width / 2, this.promoButton.y = this.centerY, this.game.device.iPad && (this.promoButton.y -= 25)) : (this.promoButton.x = this.game.width / 2, this.promoButton.y = this.centerY - this.promoButton.height / 2, this.game.device.iPad && (this.promoButton.y += 50))) }, t
|
|
}(Phaser.Group),
|
|
TrophiesUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.main = e, i.ui = i.game.add.ph2UI("ui_trophies", "atlas_trophies"), i.createOverlay(), i.add(i.ui), i.getTrophiesSprites(), i.addTouchCallback(), i.setPage(0), i.setUI(), i.localization(), i.hideDescription(), i.hide(), i }
|
|
return __extends(t, s), t.prototype.createOverlay = function() { this.darkGraphics = this.game.add.graphics(0, 0, this), this.darkGraphics.alpha = .4, this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill(), this.darkGraphics.inputEnabled = !0, this.darkGraphics.input.useHandCursor = !1 }, t.prototype.getTrophiesSprites = function() {
|
|
this.allTrophies = [];
|
|
for (var o = [], t = 1; t < 11; t++) o.push("container/container1/act" + t);
|
|
for (t = 1; t < 11; t++) o.push("container/container1/star" + t);
|
|
for (t = 1; t < 10; t++) o.push("container/container1/hardcore" + t);
|
|
for (t = 1; t < 6; t++) o.push("container/container2/stuff" + t);
|
|
for (t = 1; t < 6; t++) o.push("container/container2/completion" + t);
|
|
var n, e = this.main.achievements.standardActs,
|
|
i = this.main.achievements.hardcore,
|
|
s = this.main.achievements.awesome,
|
|
a = this.main.achievements.completion,
|
|
r = [];
|
|
r = (r = (r = (r = r.concat(e)).concat(i)).concat(s)).concat(a);
|
|
for (var h = function(t, e) {
|
|
var i = r[t].name,
|
|
s = r[t].description;
|
|
(n = Ph2.UISystem.findObject(o[t], l.ui)).inputEnabled = !0, n.events.onInputDown.add(function() { this.showTrophieDescription(i, s) }, l), n.events.onInputOver.add(function() { this.showTrophieDescription(i, s) }, l), n.input.useHandCursor = !0, n.events.onInputOut.add(l.hideDescription, l), l.allTrophies.push(n)
|
|
}, l = this, c = (t = 0, o.length); t < c; t++) h(t)
|
|
}, t.prototype.showTrophieDescription = function(t, e) {
|
|
var i = Game.LocalizationManager.getInstance(this.game),
|
|
s = i.getSringForKey(t),
|
|
o = i.getSringForKey(e);
|
|
i.localizeText("container/description", this.ui, s + " - " + o, !0), Ph2.UISystem.findObject("container/description", this.ui).visible = !0
|
|
}, t.prototype.hideDescription = function() { Ph2.UISystem.findObject("container/description", this.ui).visible = !1 }, t.prototype.addTouchCallback = function() { Game.Util.addTouchCallbackToButton("container/close", this.ui, this.hide, this), Game.Util.addTouchCallbackToButton("container/back_arrow", this.ui, function() { this.setPage(0) }, this), Game.Util.addTouchCallbackToButton("container/next_arrow", this.ui, function() { this.setPage(1) }, this), Game.Util.addTouchCallbackToSprite("container/1_2", this.ui, function() { this.setPage(0) }, this), Game.Util.addTouchCallbackToSprite("container/2_2", this.ui, function() { this.setPage(1) }, this) }, t.prototype.setPage = function(t) {
|
|
var e = Ph2.UISystem.findObject("container/container1", this.ui),
|
|
i = Ph2.UISystem.findObject("container/container2", this.ui),
|
|
s = Ph2.UISystem.findObject("container/back_arrow", this.ui),
|
|
o = Ph2.UISystem.findObject("container/next_arrow", this.ui),
|
|
n = Ph2.UISystem.findObject("container/1_2", this.ui),
|
|
a = Ph2.UISystem.findObject("container/2_2", this.ui);
|
|
e.visible = !1, i.visible = !1, 0 === t ? (i.visible = !1, e.visible = !0, Game.Util.disableTouch("container/back_arrow", this.ui), Game.Util.enableTouch("container/next_arrow", this.ui), s.setFrames("trop_arrow_left_press.png", "trop_arrow_left_press.png", "trop_arrow_left_press.png", "trop_arrow_left_press.png"), o.setFrames("trop_arrow_right.png", "trop_arrow_right.png", "trop_arrow_right.png", "trop_arrow_right.png"), n.addColor("#ffffff", 0), a.addColor("#2786e1", 0)) : (e.visible = !1, i.visible = !0, Game.Util.disableTouch("container/next_arrow", this.ui), Game.Util.enableTouch("container/back_arrow", this.ui), s.setFrames("trop_arrow_left.png", "trop_arrow_left.png", "trop_arrow_left.png", "trop_arrow_left.png"), o.setFrames("trop_arrow_right_press.png", "trop_arrow_right_press.png", "trop_arrow_right_press.png", "trop_arrow_right_press.png"), n.addColor("#2786e1", 0), a.addColor("#ffffff", 0))
|
|
}, t.prototype.setUI = function() {
|
|
var t, e = Ph2.UISystem.findObject("container/container1/standar_acts_bar_bg/standar_acts_bar", this.ui),
|
|
i = Ph2.UISystem.findObject("container/container1/hardcore_bar_bg/hardcore_bar", this.ui),
|
|
s = Ph2.UISystem.findObject("container/container2/standar_acts_bar_bg/standar_acts_bar", this.ui),
|
|
o = Ph2.UISystem.findObject("container/container2/hardcore_bar_bg/hardcore_bar", this.ui),
|
|
n = Ph2.UISystem.findObject("container/container1/standar_acts_percentage", this.ui),
|
|
a = Ph2.UISystem.findObject("container/container1/hardcore_percentage", this.ui),
|
|
r = Ph2.UISystem.findObject("container/container2/standar_acts_percentage", this.ui),
|
|
h = Ph2.UISystem.findObject("container/container2/hardcore_percentage", this.ui);
|
|
t = Math.floor(100 * this.main.achievements.getStandardActsProgress()), n.setText(String(t) + "%"), e.scale.x = t / 100, t = Math.floor(100 * this.main.achievements.getHardcoreProgress()), a.setText(String(t) + "%"), i.scale.x = t / 100, t = Math.floor(100 * this.main.achievements.getAwesomeProgress()), r.setText(String(t) + "%"), s.scale.x = t / 100, t = Math.floor(100 * this.main.achievements.getCompletionProgress()), h.setText(String(t) + "%"), o.scale.x = t / 100;
|
|
var l = this.main.achievements.standardActs,
|
|
c = this.main.achievements.hardcore,
|
|
p = this.main.achievements.awesome,
|
|
u = this.main.achievements.completion,
|
|
d = [];
|
|
d = (d = (d = (d = d.concat(l)).concat(c)).concat(p)).concat(u);
|
|
for (var y = 0; y < this.allTrophies.length; y++) {
|
|
var g = d[y].completed,
|
|
f = d[y].spriteKey,
|
|
m = g ? "_unlock" : "_lock";
|
|
this.allTrophies[y].frameName = f + m + ".png"
|
|
}
|
|
}, t.prototype.localization = function() { Game.LocalizationManager.getInstance(this.game).localizeText("container/container1/standar_acts_text", this.ui, "ui_trophie_section1_title"), Game.LocalizationManager.getInstance(this.game).localizeText("container/container1/hardcore_text", this.ui, "ui_trophie_section2_title"), Game.LocalizationManager.getInstance(this.game).localizeText("container/container2/standar_acts_text", this.ui, "ui_trophie_section3_title"), Game.LocalizationManager.getInstance(this.game).localizeText("container/container2/hardcore_text", this.ui, "ui_trophie_section4_title") }, t.prototype.show = function() { this.game.analytics.google.sendScreenView("trophies"), this.visible = !0 }, t.prototype.hide = function() { this.visible = !1, this.setPage(0), this.hideDescription() }, t.prototype.resize = function() {
|
|
var t = 960 < this.game.width ? 1 : this.game.width / 960,
|
|
e = 640 < this.game.height ? 1 : this.game.height / 640,
|
|
i = t < e ? t : e;
|
|
Ph2.UISystem.findObject("container", this.ui).scale.set(i, i), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill()
|
|
}, t
|
|
}(Phaser.Group),
|
|
OptionsUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.main = e, i.ui = i.game.add.ph2UI("ui_options", "atlas_options"), i.createOverlay(), i.add(i.ui), i.initUI(), i.addTouchCallback(), i.localization(), i.hide(), i }
|
|
return __extends(t, s), t.prototype.initUI = function() { this.setFrameSfx(), this.setFrameMusic(), this.setFrameAutoReset() }, t.prototype.createOverlay = function() { this.darkGraphics = this.game.add.graphics(0, 0, this), this.darkGraphics.alpha = .4, this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill(), this.darkGraphics.inputEnabled = !0, this.darkGraphics.input.useHandCursor = !1 }, t.prototype.addTouchCallback = function() { Game.Util.addTouchCallbackToButton("container/close", this.ui, this.hide, this), Game.Util.addTouchCallbackToButton("container/sfx_button", this.ui, this.switchSfx, this), Game.Util.addTouchCallbackToButton("container/music_button", this.ui, this.switchMusic, this), Game.Util.addTouchCallbackToSprite("container/check_box", this.ui, this.switchAutoReset, this) }, t.prototype.localization = function() {
|
|
var t = Game.LocalizationManager.getInstance(this.game);
|
|
t.localizeText("container/title", this.ui, "ui_options_title"), t.localizeText("container/sfx_title", this.ui, "ui_options_sound"), t.localizeText("container/music_title", this.ui, "ui_options_music"), t.localizeText("container/auto_save_text", this.ui, "ui_options_auto_save")
|
|
}, t.prototype.show = function() { this.visible = !0, this.setFrameSfx() }, t.prototype.hide = function() { this.visible = !1 }, t.prototype.resize = function() {
|
|
var t = 960 < this.game.width ? 1 : this.game.width / 960,
|
|
e = 640 < this.game.height ? 1 : this.game.height / 640,
|
|
i = t < e ? t : e;
|
|
Ph2.UISystem.findObject("container", this.ui).scale.set(i, i), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill()
|
|
}, t.prototype.switchSfx = function() { Constants.muted = !Constants.muted, this.main.correctSoundValues(), this.setFrameSfx() }, t.prototype.setFrameSfx = function() {
|
|
var t, e = Ph2.UISystem.findObject("container/sfx_button", this.ui);
|
|
t = Constants.muted ? "pa_off_button.png" : "pa_on_button.png", e.setFrames(t, t, t, t);
|
|
var i = Constants.muted ? "ui_options_disable" : "ui_options_enable";
|
|
Game.LocalizationManager.getInstance(this.game).localizeText("container/sfx_button/sfx_text", this.ui, i)
|
|
}, t.prototype.switchMusic = function() { Constants.mutedMusic = !Constants.mutedMusic, this.main.correctSoundValues(), this.setFrameMusic() }, t.prototype.setFrameMusic = function() {
|
|
var t, e = Ph2.UISystem.findObject("container/music_button", this.ui);
|
|
t = Constants.mutedMusic ? "pa_off_button.png" : "pa_on_button.png", e.setFrames(t, t, t, t);
|
|
var i = Constants.mutedMusic ? "ui_options_disable" : "ui_options_enable";
|
|
Game.LocalizationManager.getInstance(this.game).localizeText("container/music_button/music_text", this.ui, i)
|
|
}, t.prototype.switchAutoReset = function() { Constants.autoReset = !Constants.autoReset, this.setFrameAutoReset() }, t.prototype.setFrameAutoReset = function() { Ph2.UISystem.findObject("container/check", this.ui).visible = Constants.autoReset }, t
|
|
}(Phaser.Group),
|
|
PauseUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.main = e, i.ui = i.game.add.ph2UI("ui_pause", "atlas_pause"), i.createOverlay(), i.add(i.ui), i.initUI(), i.addTouchCallback(), i.localization(), i.visible = !1, i }
|
|
return __extends(t, s), t.prototype.initUI = function() { this.setFrameSfx(), this.setFrameMusic(), this.setFrameAutoReset() }, t.prototype.createOverlay = function() { this.darkGraphics = this.game.add.graphics(0, 0, this), this.darkGraphics.alpha = .4, this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill(), this.darkGraphics.inputEnabled = !0, this.darkGraphics.input.useHandCursor = !1 }, t.prototype.addTouchCallback = function() {
|
|
var t = this;
|
|
Game.Util.addTouchCallbackToButton("container/close", this.ui, function() { return t.hide(!1) }, this), Game.Util.addTouchCallbackToButton("container/play", this.ui, function() { return t.hide(!1) }, this), Game.Util.addTouchCallbackToButton("container/home", this.ui, this.goBack, this), Game.Util.addTouchCallbackToButton("container/trophies", this.ui, this.showTrophie, this), Game.Util.addTouchCallbackToButton("container/reload", this.ui, function() { "hub" === this.main.currentLevelID ? this.showActSelect() : this.resetlevel() }, this), Game.Util.addTouchCallbackToButton("container/sfx_button", this.ui, this.switchSfx, this), Game.Util.addTouchCallbackToButton("container/music_button", this.ui, this.switchMusic, this), Game.Util.addTouchCallbackToSprite("container/check_box", this.ui, this.switchAutoReset, this)
|
|
}, t.prototype.localization = function() {
|
|
var t = Game.LocalizationManager.getInstance(this.game);
|
|
t.localizeText("container/title", this.ui, "ui_options_title"), t.localizeText("container/sfx_title", this.ui, "ui_options_sound"), t.localizeText("container/music_title", this.ui, "ui_options_music"), t.localizeText("container/auto_save_text", this.ui, "ui_options_auto_save")
|
|
}, t.prototype.goBack = function() {
|
|
var t = this;
|
|
this.hide(!1, function() { t.main.exitLevel() })
|
|
}, t.prototype.showTrophie = function() { this.main.trophiesUI.show() }, t.prototype.showActSelect = function() { this.main.actSelectUI.show() }, t.prototype.resetlevel = function() { this.hide(!0) }, t.prototype.show = function() {
|
|
Constants.pausedMapTime = Date.now(), Constants.pausedActTime = Date.now();
|
|
var t, e = Ph2.UISystem.findObject("container/reload", this.ui);
|
|
t = "hub" === this.main.currentLevelID ? "pa_act_select_button.png" : "pa_reload_button.png", e.setFrames(t, t, t, t), this.main.player.pause(), this.main.keys.hide(), this.main.state = GameStates.Window, this.visible = !0
|
|
}, t.prototype.hide = function(i, s) {
|
|
var o = this;
|
|
if (void 0 === i && (i = !1), Fabrique.Utils.isOnDevice(this.game)) {
|
|
var t = Date.now() - Constants.pausedMapTime;
|
|
if (Constants.levelMapStartTime += t, null !== Constants.actStartTime) {
|
|
var e = Date.now() - Constants.pausedActTime;
|
|
Constants.actStartTime += e
|
|
}
|
|
this.main.state = GameStates.Playing, this.visible = !1, this.main.player.resume(), this.main.keys.show()
|
|
}
|
|
else Fabrique.LoaderHelper.show(), Fabrique.AdHandler.getInstance(this.game).showAd(function() {
|
|
Fabrique.LoaderHelper.hide();
|
|
var t = Date.now() - Constants.pausedMapTime;
|
|
if (Constants.levelMapStartTime += t, null !== Constants.actStartTime && !i) {
|
|
var e = Date.now() - Constants.pausedActTime;
|
|
Constants.actStartTime += e
|
|
}
|
|
o.main.state = GameStates.Playing, o.visible = !1, o.main.player.resume(), o.main.keys.show(), i && o.main.resetLevel(), "function" == typeof s && s()
|
|
}, function() { Fabrique.LoaderHelper.hide() }, "level"), this.main.keys.show()
|
|
}, t.prototype.resize = function() {
|
|
var t = 960 < this.game.width ? 1 : this.game.width / 960,
|
|
e = 640 < this.game.height ? 1 : this.game.height / 640,
|
|
i = t < e ? t : e;
|
|
Ph2.UISystem.findObject("container", this.ui).scale.set(i, i), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill()
|
|
}, t.prototype.switchSfx = function() { Constants.muted = !Constants.muted, this.main.correctSoundValues(), this.setFrameSfx() }, t.prototype.setFrameSfx = function() {
|
|
var t, e = Ph2.UISystem.findObject("container/sfx_button", this.ui);
|
|
t = Constants.muted ? "pa_off_button.png" : "pa_on_button.png", e.setFrames(t, t, t, t);
|
|
var i = Constants.muted ? "ui_options_disable" : "ui_options_enable";
|
|
Game.LocalizationManager.getInstance(this.game).localizeText("container/sfx_button/sfx_text", this.ui, i)
|
|
}, t.prototype.switchMusic = function() { Constants.mutedMusic = !Constants.mutedMusic, this.main.correctSoundValues(), this.setFrameMusic() }, t.prototype.setFrameMusic = function() {
|
|
var t, e = Ph2.UISystem.findObject("container/music_button", this.ui);
|
|
t = Constants.mutedMusic ? "pa_off_button.png" : "pa_on_button.png", e.setFrames(t, t, t, t);
|
|
var i = Constants.mutedMusic ? "ui_options_disable" : "ui_options_enable";
|
|
Game.LocalizationManager.getInstance(this.game).localizeText("container/music_button/music_text", this.ui, i)
|
|
}, t.prototype.switchAutoReset = function() { Constants.autoReset = !Constants.autoReset, this.setFrameAutoReset() }, t.prototype.setFrameAutoReset = function() { Ph2.UISystem.findObject("container/check", this.ui).visible = Constants.autoReset }, t
|
|
}(Phaser.Group);
|
|
! function(t) { t[t.hub = 0] = "hub", t[t.act = 1] = "act", t[t.challenge = 2] = "challenge", t[t.mainmenu = 3] = "mainmenu", t[t.vex = 4] = "vex" }(VIEWTYPE || (VIEWTYPE = {})),
|
|
function(t) { t[t.perfect = 0] = "perfect", t[t.gold = 1] = "gold", t[t.silver = 2] = "silver", t[t.bronza = 3] = "bronza", t[t.none = 4] = "none" }(RANKTYPE || (RANKTYPE = {})),
|
|
function(t) { t[t.levelHubContainer = 0] = "levelHubContainer", t[t.levelHubLvlName = 1] = "levelHubLvlName", t[t.levelHubLvlTime = 2] = "levelHubLvlTime", t[t.levelHubLvlGold = 3] = "levelHubLvlGold", t[t.levelHubLvlSilver = 4] = "levelHubLvlSilver", t[t.levelHubLvlBronze = 5] = "levelHubLvlBronze", t[t.levelHubLvlTrophy = 6] = "levelHubLvlTrophy", t[t.levelHubLvlStar = 7] = "levelHubLvlStar", t[t.levelHubLvlChallenge = 8] = "levelHubLvlChallenge", t[t.levelProgress = 9] = "levelProgress", t[t.levelProgressBar = 10] = "levelProgressBar", t[t.levelTime = 11] = "levelTime", t[t.levelDeaths = 12] = "levelDeaths", t[t.levelRank = 13] = "levelRank", t[t.levelFloor = 14] = "levelFloor", t[t.levelChallengeContainer = 15] = "levelChallengeContainer", t[t.levelChallengeName = 16] = "levelChallengeName", t[t.levelChallengeFloor = 17] = "levelChallengeFloor", t[t.levelChallengeTime = 18] = "levelChallengeTime", t[t.levelChallengeTrophy = 19] = "levelChallengeTrophy", t[t.achievementContainer = 20] = "achievementContainer", t[t.achievementIcon = 21] = "achievementIcon", t[t.achievementText = 22] = "achievementText", t[t.levelHubLvlChallengeback = 23] = "levelHubLvlChallengeback", t[t.tntContainer = 24] = "tntContainer", t[t.tntProgress = 25] = "tntProgress", t[t.tntProgressBar = 26] = "tntProgressBar" }(UIGPELEMENTS || (UIGPELEMENTS = {}));
|
|
var Game, GameplayUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.localization = Game.LocalizationManager.getInstance(i.game), i.main = e, i.ui = i.game.add.ph2UI("ui_gameplay", "atlas_ui_gameplay"), i.add(i.ui), i.saveUIElementRef(), i.initUI(), i.initAchievement(), i.addTouchCallback(), i.localizationUI(), i.rankType = RANKTYPE.perfect, i.hide(), i.inGame = !1, i }
|
|
return __extends(t, s), t.prototype.initAchievement = function() { this.showingAchievement = !1, this.uiElements[UIGPELEMENTS.achievementText].wordWrap = !0, this.uiElements[UIGPELEMENTS.achievementText].wordWrapWidth = 66 }, t.prototype.saveUIElementRef = function() { this.uiElements = [], this.uiElements[UIGPELEMENTS.levelHubContainer] = Ph2.UISystem.findObject("level_hub_container", this.ui), this.uiElements[UIGPELEMENTS.achievementContainer] = Ph2.UISystem.findObject("achievement_container", this.ui), this.uiElements[UIGPELEMENTS.levelChallengeContainer] = Ph2.UISystem.findObject("challenge_room_container", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlName] = Ph2.UISystem.findObject("level_hub_container/act", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlTime] = Ph2.UISystem.findObject("level_hub_container/your_time", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlGold] = Ph2.UISystem.findObject("level_hub_container/gold_time", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlSilver] = Ph2.UISystem.findObject("level_hub_container/silver_time", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlBronze] = Ph2.UISystem.findObject("level_hub_container/bronze_time", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlTrophy] = Ph2.UISystem.findObject("level_hub_container/trophy_unlock", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlStar] = Ph2.UISystem.findObject("level_hub_container/star_unlock", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlChallenge] = Ph2.UISystem.findObject("level_hub_container/hardcore_unlock", this.ui), this.uiElements[UIGPELEMENTS.levelProgress] = Ph2.UISystem.findObject("time_container/progress_container/progress_percentage", this.ui), this.uiElements[UIGPELEMENTS.levelProgressBar] = Ph2.UISystem.findObject("time_container/progress_container/progress_bar_bg/progress_bar", this.ui), this.uiElements[UIGPELEMENTS.levelTime] = Ph2.UISystem.findObject("time_container/time", this.ui), this.uiElements[UIGPELEMENTS.levelRank] = Ph2.UISystem.findObject("time_container/progress_container/ranking", this.ui), this.uiElements[UIGPELEMENTS.levelFloor] = Ph2.UISystem.findObject("floor_container/floor_text", this.ui), this.uiElements[UIGPELEMENTS.levelChallengeFloor] = Ph2.UISystem.findObject("challenge_room_container/floors", this.ui), this.uiElements[UIGPELEMENTS.levelChallengeTime] = Ph2.UISystem.findObject("challenge_room_container/your_time", this.ui), this.uiElements[UIGPELEMENTS.levelChallengeTrophy] = Ph2.UISystem.findObject("challenge_room_container/trophy_unlock", this.ui), this.uiElements[UIGPELEMENTS.levelChallengeName] = Ph2.UISystem.findObject("challenge_room_container/title", this.ui), this.uiElements[UIGPELEMENTS.achievementIcon] = Ph2.UISystem.findObject("achievement_container/image", this.ui), this.uiElements[UIGPELEMENTS.achievementText] = Ph2.UISystem.findObject("achievement_container/description", this.ui), this.uiElements[UIGPELEMENTS.levelHubLvlChallengeback] = Ph2.UISystem.findObject("level_hub_container/hardcore_lock", this.ui), this.uiElements[UIGPELEMENTS.tntContainer] = Ph2.UISystem.findObject("tnt_container", this.ui), this.uiElements[UIGPELEMENTS.tntProgress] = Ph2.UISystem.findObject("tnt_container/tnt_text", this.ui), this.uiElements[UIGPELEMENTS.tntProgressBar] = Ph2.UISystem.findObject("tnt_container/bar", this.ui), this.sparkSprite = new Phaser.Sprite(this.game, 0, 0, "spark"), this.sparkSprite.anchor.set(.5, .5), this.uiElements[UIGPELEMENTS.tntContainer].addChild(this.sparkSprite) }, t.prototype.initUI = function() { this.uiElements[UIGPELEMENTS.achievementContainer].visible = !1 }, t.prototype.addTouchCallback = function() { Game.Util.addTouchCallbackToButton("time_container/pause", this.ui, this.showPause, this) }, t.prototype.localizationUI = function() { this.localization.localizeText("level_hub_container/your_time_text", this.ui, "ui_gp_hub_name_title"), this.localization.localizeText("level_hub_container/gold_time_text", this.ui, "ui_gp_rank_gold"), this.localization.localizeText("level_hub_container/silver_time_text", this.ui, "ui_gp_rank_silver"), this.localization.localizeText("level_hub_container/bronze_time_text", this.ui, "ui_gp_rank_bronze"), this.localization.localizeText("floor_container/title", this.ui, "ui_gp_challenge_floor"), this.localization.localizeText("challenge_room_container/floors_text", this.ui, "ui_gp_challenge_floors"), this.localization.localizeText("challenge_room_container/your_time_text", this.ui, "ui_gp_challenge_time"), this.localization.localizeText("achievement_container/title", this.ui, "ui_achievement_title") }, t.prototype.setUI = function(t) {
|
|
var e, i = Ph2.UISystem.findObject("floor_container", this.ui),
|
|
s = Ph2.UISystem.findObject("level_container", this.ui),
|
|
o = Ph2.UISystem.findObject("challenge_container", this.ui),
|
|
n = Ph2.UISystem.findObject("time_container", this.ui),
|
|
a = Ph2.UISystem.findObject("time_container/progress_container/ranking", this.ui),
|
|
r = Ph2.UISystem.findObject("time_container/progress_container/progress_bar_bg", this.ui),
|
|
h = Ph2.UISystem.findObject("time_container/progress_container/progress_percentage", this.ui),
|
|
l = Ph2.UISystem.findObject("time_container/progress_container", this.ui);
|
|
switch (e = this.main.levels.levels[this.main.currentLevelID].name, n.visible = !0, this.sparkSprite.visible = !1, this.showType = t) {
|
|
case VIEWTYPE.act:
|
|
s.visible = !0, i.visible = !1, this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1, this.uiElements[UIGPELEMENTS.tntContainer].visible = !1, o.visible = !1, a.visible = !0, r.visible = !1, h.visible = !1, l.visible = !0, this.localization.localizeText("level_container/level", this.ui, e, !0), this.uiElements[UIGPELEMENTS.levelDeaths] = Ph2.UISystem.findObject("level_container/total_deaths", this.ui);
|
|
break;
|
|
case VIEWTYPE.vex:
|
|
this.sparkSprite.visible = !0, this.updateProgressTnt(1), s.visible = !0, i.visible = !1, this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1, this.uiElements[UIGPELEMENTS.tntContainer].visible = !0, o.visible = !1, a.visible = !0, r.visible = !1, h.visible = !1, l.visible = !0, this.localization.localizeText("level_container/level", this.ui, e, !0), this.uiElements[UIGPELEMENTS.levelDeaths] = Ph2.UISystem.findObject("level_container/total_deaths", this.ui);
|
|
break;
|
|
case VIEWTYPE.challenge:
|
|
s.visible = !1, i.visible = !0, this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1, this.uiElements[UIGPELEMENTS.tntContainer].visible = !1, o.visible = !0, l.visible = !1, this.localization.localizeText("challenge_container/level", this.ui, e, !0), this.uiElements[UIGPELEMENTS.levelDeaths] = Ph2.UISystem.findObject("challenge_container/total_deaths", this.ui);
|
|
break;
|
|
case VIEWTYPE.hub:
|
|
s.visible = !0, i.visible = !1, this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1, this.uiElements[UIGPELEMENTS.tntContainer].visible = !1, o.visible = !1, a.visible = !1, r.visible = !0, h.visible = !0, l.visible = !0, this.localization.localizeText("level_container/level", this.ui, e, !0), this.uiElements[UIGPELEMENTS.levelDeaths] = Ph2.UISystem.findObject("level_container/total_deaths", this.ui);
|
|
break;
|
|
case VIEWTYPE.mainmenu:
|
|
this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1, this.uiElements[UIGPELEMENTS.achievementContainer].visible = !1, this.uiElements[UIGPELEMENTS.tntContainer].visible = !1, s.visible = !1, i.visible = !1, o.visible = !1, n.visible = !1;
|
|
break;
|
|
default:
|
|
this.hide()
|
|
}
|
|
}, t.prototype.showInfoLevel = function(t) { this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !0, this.uiElements[UIGPELEMENTS.levelHubLvlName].setText(t.name), -1 < t.topTime ? this.uiElements[UIGPELEMENTS.levelHubLvlTime].setText(timeDecoratorActBlock(t.topTime)) : this.uiElements[UIGPELEMENTS.levelHubLvlTime].setText(timeDecoratorActBlock(0)), this.uiElements[UIGPELEMENTS.levelHubLvlChallengeback].visible = "10" !== t.id, this.uiElements[UIGPELEMENTS.levelHubLvlGold].setText(timeDecoratorActBlock(t.goldTime)), this.uiElements[UIGPELEMENTS.levelHubLvlSilver].setText(timeDecoratorActBlock(t.silverTime)), this.uiElements[UIGPELEMENTS.levelHubLvlBronze].setText(timeDecoratorActBlock(t.bronzeTime)), this.uiElements[UIGPELEMENTS.levelHubLvlTrophy].visible = t.gotGold(), this.uiElements[UIGPELEMENTS.levelHubLvlStar].visible = t.gotStar, this.uiElements[UIGPELEMENTS.levelHubLvlChallenge].visible = t.challengeCompleted }, t.prototype.showInfoChallenge = function(t) { this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !0, this.uiElements[UIGPELEMENTS.levelChallengeName].setText(t.name.toUpperCase()), -1 < t.topTime ? this.uiElements[UIGPELEMENTS.levelChallengeTime].setText(timeDecoratorActBlock(t.topTime)) : this.uiElements[UIGPELEMENTS.levelChallengeTime].setText(timeDecoratorActBlock(0)), this.uiElements[UIGPELEMENTS.levelChallengeFloor].setText(floorDecorator(Constants.latestChallengeStep, Level.ChallengeSteps)), this.uiElements[UIGPELEMENTS.levelChallengeTrophy].visible = -1 < t.topTime }, t.prototype.hideInfoLevel = function() { this.uiElements[UIGPELEMENTS.levelHubContainer].visible = !1, this.uiElements[UIGPELEMENTS.levelChallengeContainer].visible = !1 }, t.prototype.showPause = function() { this.main.pauseUI.show() }, t.prototype.showAchievement = function(t) {
|
|
this.uiElements[UIGPELEMENTS.achievementContainer].visible = !0, this.showingAchievement = !0, this.showTimeAchievement = 120;
|
|
var e = t.spriteKey + "_unlock.png";
|
|
this.uiElements[UIGPELEMENTS.achievementIcon].frameName = e;
|
|
var i = this.localization.getSringForKey(t.name);
|
|
this.uiElements[UIGPELEMENTS.achievementText].setText(i)
|
|
}, t.prototype.show = function() {
|
|
var t;
|
|
switch (this.visible = !0, this.main.currentLevelID) {
|
|
case "hub":
|
|
t = VIEWTYPE.hub;
|
|
break;
|
|
case "11":
|
|
t = VIEWTYPE.challenge;
|
|
break;
|
|
case "10":
|
|
t = VIEWTYPE.vex;
|
|
break;
|
|
default:
|
|
t = VIEWTYPE.act
|
|
}
|
|
this.setUI(t)
|
|
}, t.prototype.updateProgressTnt = function(t) { this.uiElements[UIGPELEMENTS.tntProgress].setText(Math.floor(100 * t) + "%"), this.uiElements[UIGPELEMENTS.tntProgressBar].scale.x = t, this.sparkSprite.x = this.uiElements[UIGPELEMENTS.tntProgressBar].x - this.uiElements[UIGPELEMENTS.tntProgressBar].width, this.sparkSprite.y = this.uiElements[UIGPELEMENTS.tntProgressBar].y, Math.random() < .2 && this.main.createColorParticleUI(0, 0, this.sparkSprite, -5 * Math.random(), 10 * Math.random() - 5, 16763904, 4, !1, !1, 10, !0) }, t.prototype.hide = function() { this.visible = !1 }, t.prototype.enterLevel = function(t, e, i) { void 0 === i && (i = 0), this.currentLevel = t, this.showType !== VIEWTYPE.challenge && (this.rankType = RANKTYPE.perfect, this.setrankingText()), !0 === e ? this.uiElements[UIGPELEMENTS.levelTime].setText(timeDecorator(Date.now() - Constants.actStartTime)) : this.uiElements[UIGPELEMENTS.levelTime].setText("00:00:00"), this.inGame = !0, this.updateDeaths(0) }, t.prototype.resetLevel = function() { this.rankType = RANKTYPE.perfect, this.setrankingText() }, t.prototype.exitLevel = function() { this.inGame = !1 }, t.prototype.updateProgress = function(t) { this.uiElements[UIGPELEMENTS.levelProgress].setText(Math.floor(100 * t) + "%"), this.uiElements[UIGPELEMENTS.levelProgressBar].scale.x = t }, t.prototype.updateDeaths = function(t) {
|
|
if (this.inGame) {
|
|
var e = this.localization.getSringForKey("ui_gp_deaths", t);
|
|
this.uiElements[UIGPELEMENTS.levelDeaths].setText(e), this.rankType === RANKTYPE.perfect && 0 < t && (this.rankType = RANKTYPE.gold, this.setrankingText())
|
|
}
|
|
else {
|
|
e = this.localization.getSringForKey("ui_gp_deaths_hub", t);
|
|
this.uiElements[UIGPELEMENTS.levelDeaths].setText(e)
|
|
}
|
|
}, t.prototype.updateTime = function() {
|
|
if (this.inGame) {
|
|
this.uiElements[UIGPELEMENTS.levelTime].setText(timeDecorator(Date.now() - Constants.actStartTime));
|
|
var t = Date.now() - Constants.actStartTime;
|
|
if (this.showType !== VIEWTYPE.challenge) switch (this.rankType) {
|
|
case RANKTYPE.perfect:
|
|
case RANKTYPE.gold:
|
|
t > this.currentLevel.goldTime && (this.main.sounds.playSound("downgrade"), this.rankType = RANKTYPE.silver, this.setrankingText());
|
|
break;
|
|
case RANKTYPE.silver:
|
|
t > this.currentLevel.silverTime && (this.main.sounds.playSound("downgrade"), this.rankType = RANKTYPE.bronza, this.setrankingText());
|
|
break;
|
|
case RANKTYPE.bronza:
|
|
t > this.currentLevel.bronzeTime && (this.main.sounds.playSound("downgrade"), this.rankType = RANKTYPE.none, this.setrankingText())
|
|
}
|
|
}
|
|
else this.uiElements[UIGPELEMENTS.levelTime].setText(timeDecoratorHub(Date.now() - Constants.levelMapStartTime))
|
|
}, t.prototype.updateAchievment = function() { if (this.showingAchievement && (this.showTimeAchievement--, this.showTimeAchievement <= 0)) return this.uiElements[UIGPELEMENTS.achievementContainer].visible = !1, void(this.showingAchievement = !1) }, t.prototype.setrankingText = function() {
|
|
switch (this.rankType) {
|
|
case RANKTYPE.perfect:
|
|
this.uiElements[UIGPELEMENTS.levelRank].frameName = "gp_perfect_text.png";
|
|
break;
|
|
case RANKTYPE.gold:
|
|
this.uiElements[UIGPELEMENTS.levelRank].frameName = "gp_gold_text.png";
|
|
break;
|
|
case RANKTYPE.silver:
|
|
this.uiElements[UIGPELEMENTS.levelRank].frameName = "gp_silver_text.png";
|
|
break;
|
|
case RANKTYPE.bronza:
|
|
this.uiElements[UIGPELEMENTS.levelRank].frameName = "gp_bronze_text.png";
|
|
break;
|
|
case RANKTYPE.none:
|
|
this.uiElements[UIGPELEMENTS.levelRank].frameName = "gp_none_text.png"
|
|
}
|
|
}, t.prototype.updateFloor = function(t) { this.uiElements[UIGPELEMENTS.levelFloor].setText(t + "/" + Level.ChallengeSteps) }, t.prototype.getRank = function() { return this.rankType }, t.prototype.getTime = function() { return this.uiElements[UIGPELEMENTS.levelTime].text }, t
|
|
}(Phaser.Group),
|
|
ActSelectUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.main = e, i.ui = i.game.add.ph2UI("ui_act_select", "atlas_act_select"), i.createOverlay(), i.add(i.ui), i.initUI(), i.addTouchCallback(), i.localization(), i.hide(), i }
|
|
return __extends(t, s), t.prototype.initUI = function() {
|
|
var t;
|
|
this.buttons = [];
|
|
for (var e = 1; e < 11; e++) t = Ph2.UISystem.findObject("container/act" + e, this.ui), this.buttons.push(t)
|
|
}, t.prototype.createOverlay = function() { this.darkGraphics = this.game.add.graphics(0, 0, this), this.darkGraphics.alpha = .4, this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill(), this.darkGraphics.inputEnabled = !0, this.darkGraphics.input.useHandCursor = !1 }, t.prototype.addTouchCallback = function() {
|
|
for (var t = function(t, e) { Game.Util.addTouchCallbackToSprite("container/act" + t, i.ui, function() { this.goToActSelect(t) }, i) }, i = this, e = 1; e < 11; e++) t(e);
|
|
Game.Util.addTouchCallbackToSprite("container/close", this.ui, this.hide, this)
|
|
}, t.prototype.localization = function() { Game.LocalizationManager.getInstance(this.game).localizeText("container/title", this.ui, "ui_act_select_title") }, t.prototype.setUI = function() {
|
|
for (var t = 0; t < 10; t++) {
|
|
var e = this.main.levels.levels[t + 1],
|
|
i = this.buttons[t]; - 1 !== e.topTime ? (i.visible = !0, t < 9 && (Ph2.UISystem.findObject("empty_container/hardcore_unlock", this.buttons[t]).visible = e.challengeCompleted), Ph2.UISystem.findObject("empty_container/star_unlock", this.buttons[t]).visible = e.gotStar, Ph2.UISystem.findObject("empty_container/trophy_unlock", this.buttons[t]).visible = e.gotGold()) : i.visible = !1
|
|
}
|
|
}, t.prototype.goToActSelect = function(t) { this.hide(), this.main.pauseUI.hide(), this.main.portToActBlock(t) }, t.prototype.show = function() { this.setUI(), this.visible = !0 }, t.prototype.hide = function() { this.visible = !1 }, t.prototype.resize = function() {
|
|
var t = 960 < this.game.width ? 1 : this.game.width / 960,
|
|
e = 640 < this.game.height ? 1 : this.game.height / 640,
|
|
i = t < e ? t : e;
|
|
Ph2.UISystem.findObject("container", this.ui).scale.set(i, i), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill()
|
|
}, t
|
|
}(Phaser.Group);
|
|
! function(t) {
|
|
var e = function() {
|
|
function t() {}
|
|
return t.addTouchCallbackToButton = function(t, e, i, s, o) { void 0 === o && (o = 0); for (var n, a = [], r = 5; r < arguments.length; r++) a[r - 5] = arguments[r]; return (n = Ph2.UISystem.findObject(t, e)).onInputUp.add(i, s, o, a), n.input.useHandCursor = !0, n }, t.addTouchCallbackToText = function(t, e, i, s) { var o; return (o = Ph2.UISystem.findObject(t, e)).inputEnabled = !0, o.input.useHandCursor = !0, o.events.onInputUp.add(i, s), o }, t.addTouchCallbackToSprite = function(t, e, i, s) { var o; return (o = Ph2.UISystem.findObject(t, e)).inputEnabled = !0, o.input.useHandCursor = !0, o.events.onInputUp.add(i, s), o }, t.addTouchCallbackToSpriteAnimation = function(t, e, i, s) { var o; return (o = Ph2.AnimationSystem.findObject(t, e)).inputEnabled = !0, o.input.useHandCursor = !0, o.events.onInputUp.add(i, s), o }, t.addInputToPreventPropagation = function(t, e) {
|
|
var i;
|
|
(i = Ph2.UISystem.findObject(t, e)).inputEnabled = !0, i.input.useHandCursor = !1
|
|
}, t.disableTouch = function(t, e) { Ph2.UISystem.findObject(t, e).inputEnabled = !1 }, t.enableTouch = function(t, e) {
|
|
var i;
|
|
(i = Ph2.UISystem.findObject(t, e)).inputEnabled = !0, i.input.useHandCursor = !0
|
|
}, t.disableTouchAnimation = function(t, e) { Ph2.AnimationSystem.findObject(t, e).inputEnabled = !1 }, t.enableTouchAnimation = function(t, e) {
|
|
var i;
|
|
(i = Ph2.AnimationSystem.findObject(t, e)).inputEnabled = !0, i.input.useHandCursor = !0
|
|
}, t
|
|
}();
|
|
t.Util = e
|
|
}(Game || (Game = {})),
|
|
function(t) {
|
|
var e = function() {
|
|
function e(t, e) { void 0 === e && (e = "us"), this.game = t, this.language = e, this.jsonKey = "localization", this.localizationData = this.game.cache.getJSON(this.jsonKey), this.charInitArg = "{", this.charEndArg = "}", this.defaulString = "*", this.showDefault = !1 }
|
|
return e.getInstance = function(t) { return e.instance || (e.instance = new e(t)), e.instance }, e.prototype.setLanguage = function(t) { return void 0 === t && (t = "us"), t === this.language || (this.jsonKey = "localization_" + t, this.game.cache.getJSON(this.jsonKey) ? (this.language = t, this.localizationData = this.game.cache.getJSON(this.jsonKey), !0) : (this.jsonKey = "localization_" + this.language, !1)) }, e.prototype.getLanguage = function() { return this.language }, e.prototype.getLocalizationData = function() { return this.localizationData }, e.prototype.localizeText = function(t, e, i, s, o) {
|
|
var n, a;
|
|
if (void 0 === s && (s = !1), void 0 === o && (o = !1), n = Ph2.UISystem.findObject(t, e), a = i, !s) {
|
|
if (void 0 === this.localizationData[i]) return n;
|
|
a = this.localizationData[i]
|
|
}
|
|
return !0 === this.showDefault && (a = this.defaulString), n.text = o ? a.toUpperCase() : a, n
|
|
}, e.prototype.getSringForKey = function(t) {
|
|
for (var e = [], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i];
|
|
var s = this.localizationData[t];
|
|
if (void 0 === this.localizationData[t]) return "";
|
|
for (var o = s.indexOf(this.charInitArg) + 1, n = s.indexOf(this.charEndArg), a = 0, r = s.substring(o, n);
|
|
"" !== r && a < e.length;) s = s.split(this.charInitArg + r + this.charEndArg).join(e[a]), a++, o = s.indexOf(this.charInitArg) + 1, n = s.indexOf(this.charEndArg), r = s.substring(o, n);
|
|
return !0 === this.showDefault && (s = this.defaulString), s
|
|
}, e.prototype.addSpriteTo = function(t) {
|
|
for (var e = [], i = 1; i < arguments.length; i++) e[i - 1] = arguments[i];
|
|
for (var s = this.localizationData[t], o = s.indexOf(this.charInitArg) + 1, n = s.indexOf(this.charEndArg), a = 0, r = s.substring(o, n);
|
|
"" !== r && a < e.length;) s = s.split(this.charInitArg + r + this.charEndArg).join(e[a]), a++, o = s.indexOf(this.charInitArg) + 1, n = s.indexOf(this.charEndArg), r = s.substring(o, n);
|
|
return s
|
|
}, e.prototype.fitFontSizeUI = function(t, e, i, s, o, n) {
|
|
var a;
|
|
void 0 === s && (s = -1), void 0 === o && (o = -1), void 0 === n && (n = 10), a = Ph2.UISystem.findObject(t, e), this.fitFontSizeText(a, i, s, o, n)
|
|
}, e.prototype.fitFontSizeText = function(t, e, i, s, o) { var n, a, r, h; for (void 0 === i && (i = -1), void 0 === s && (s = -1), void 0 === o && (o = 10), 0 < s && (t.fontSize = s), a = t.width, r = t.height, h = t.fontSize; e < a || i < r && -1 !== i;) { if ((n = parseInt(h.toString().replace("px", ""), 10) - 1) < o) { h = n = o, t.setStyle({ fontSize: h }, !0); break } h = n, t.fontSize = h, a = t.width, r = t.height } }, e
|
|
}();
|
|
t.LocalizationManager = e
|
|
}(Game || (Game = {}));
|
|
var GameStates, LevelCompleteUI = function(s) {
|
|
function t(t, e) { var i = s.call(this, t) || this; return i.main = e, i.ui = i.game.add.ph2UI("ui_level_complete", "atlas_level_complete"), i.createOverlay(), i.add(i.ui), i.addTouchCallback(), i.localization(), i.visible = !1, i }
|
|
return __extends(t, s), t.prototype.createOverlay = function() { this.darkGraphics = this.game.add.graphics(0, 0, this), this.darkGraphics.alpha = .4, this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill(), this.darkGraphics.inputEnabled = !0, this.darkGraphics.input.useHandCursor = !1 }, t.prototype.addTouchCallback = function() { Game.Util.addTouchCallbackToButton("container/close", this.ui, this.hide, this), Game.Util.addTouchCallbackToButton("container/play", this.ui, this.hide, this), Game.Util.addTouchCallbackToButton("container/trophies", this.ui, this.showTrophie, this), Game.Util.addTouchCallbackToButton("container/reload", this.ui, this.resetlevel, this) }, t.prototype.localization = function() { Game.LocalizationManager.getInstance(this.game).localizeText("container/title", this.ui, "ui_level_complete_title") }, t.prototype.goBack = function() { this.hide(), this.main.exitLevel() }, t.prototype.showTrophie = function() { this.main.trophiesUI.show() }, t.prototype.resetlevel = function() { this.hide(!0) }, t.prototype.show = function() {
|
|
Constants.pausedMapTime = Date.now(), Constants.pausedActTime = Date.now();
|
|
var t = "lc_reload_button.png";
|
|
Ph2.UISystem.findObject("container/reload", this.ui).setFrames(t, t, t, t), this.main.player.pause(), this.main.keys.hide(), this.main.state = GameStates.Window, this.visible = !0
|
|
}, t.prototype.hide = function(i) {
|
|
var s = this;
|
|
void 0 === i && (i = !1), Fabrique.LoaderHelper.show(), Fabrique.AdHandler.getInstance(this.game).showAd(function() {
|
|
Fabrique.LoaderHelper.hide();
|
|
var t = Date.now() - Constants.pausedMapTime;
|
|
if (Constants.levelMapStartTime += t, null !== Constants.actStartTime && !i) {
|
|
var e = Date.now() - Constants.pausedActTime;
|
|
Constants.actStartTime += e
|
|
}
|
|
s.main.state = GameStates.Playing, s.visible = !1, s.main.player.resume(), s.main.keys.show(), !0 === i ? (s.main.firstSpawn = !0, s.main.resumeOnReset(), s.main.resetLevel(), s.main.player.respawn()) : "11" === s.main.currentLevelID ? s.main.nextChallenge() : s.main.resumeOnFinish()
|
|
}, function() { Fabrique.LoaderHelper.hide() }, "level")
|
|
}, t.prototype.updateData = function(t, e) {
|
|
Ph2.UISystem.findObject("container/time", this.ui).setText(t);
|
|
var i = Ph2.UISystem.findObject("container/rank", this.ui);
|
|
switch (e) {
|
|
case RANKTYPE.perfect:
|
|
i.frameName = "lc_perfect_text.png";
|
|
break;
|
|
case RANKTYPE.gold:
|
|
i.frameName = "lc_gold_text.png";
|
|
break;
|
|
case RANKTYPE.silver:
|
|
i.frameName = "lc_silver_text.png";
|
|
break;
|
|
case RANKTYPE.bronza:
|
|
i.frameName = "lc_bronze_text.png";
|
|
break;
|
|
case RANKTYPE.none:
|
|
i.frameName = "lc_clear_text.png"
|
|
}
|
|
}, t.prototype.resize = function() {
|
|
var t = 960 < this.game.width ? 1 : this.game.width / 960,
|
|
e = 640 < this.game.height ? 1 : this.game.height / 640,
|
|
i = t < e ? t : e;
|
|
Ph2.UISystem.findObject("container", this.ui).scale.set(i, i), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(0, 0, this.game.width, this.game.height), this.darkGraphics.endFill()
|
|
}, t
|
|
}(Phaser.Group);
|
|
! function(t) { t[t.Loading = 0] = "Loading", t[t.Playing = 1] = "Playing", t[t.Window = 2] = "Window", t[t.MainMenu = 3] = "MainMenu" }(GameStates || (GameStates = {}));
|
|
var PlayerState, HitAreas, Main = function() {
|
|
function t(t, e) {
|
|
var i = this;
|
|
this.colorPortalEnable = [0, 0, 1, 1, 2, 2, 3, 3], this.gameSpeed = 1, this.gravity = .5, this.tint = 16720418, this.skipMenu = !1, this.enableHellButton = !1, this.challengeStep = 0, this.finished = !1, this.time = 0, this.timeCheck = Date.now(), this.game = t, this.keys = e, this.allowSpace = !1, this.yKey = t.input.keyboard.addKey(Phaser.Keyboard.Y), this.hKey = t.input.keyboard.addKey(Phaser.Keyboard.H), t.time.desiredFps = 30, this.sounds = new Sounds(this, t), this.background = t.add.group(), this.background.create(-200, -400, "parallaxBackground"), this.background.alpha = .5, this.background.fixedToCamera = !1, this.underPoolLayer = t.add.group(), this.playerUnderLayer = t.add.group(), this.poolLayer = t.add.group(), this.obstacleLayer = t.add.group(), this.levelLayer = t.add.group(), this.topObstacleLayer = t.add.group(), this.particleLayer = t.add.group(), this.topPoolLayer = t.add.group(), this.textLayer = t.add.group(), this.playerLayer = t.add.group(), this.overlayLayer = t.add.group(), this.resizeGroup = t.add.group(), this.resizeGroup.add(this.background), this.resizeGroup.add(this.underPoolLayer), this.resizeGroup.add(this.playerUnderLayer), this.resizeGroup.add(this.poolLayer), this.resizeGroup.add(this.obstacleLayer), this.resizeGroup.add(this.levelLayer), this.resizeGroup.add(this.topObstacleLayer), this.resizeGroup.add(this.particleLayer), this.resizeGroup.add(this.topPoolLayer), this.resizeGroup.add(this.textLayer), this.resizeGroup.add(this.playerLayer), this.resizeGroup.add(this.overlayLayer), this.guiLayer = t.add.group(), this.guiLayer.fixedToCamera = !0, this.mainMenuLayer = t.add.group(), this.windowLayer = t.add.group(), this.windowLayer.fixedToCamera = !0, this.transitionLayer = t.add.group(), this.mainMenuUI = new MainMenuUI(this.game, this), this.mainMenuLayer.add(this.mainMenuUI), this.darkOverlay = this.overlayLayer.create(0, 0, "darkOverlay"), this.darkOverlay.anchor.set(.5, .5), this.darkOverlay.animations.add("dark"), this.darkOverlay.visible = !1, this.darkGraphics = this.game.add.graphics(0, 0, this.overlayLayer), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t.width, -t.height - 259, 2 * t.width, t.height), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(259, -259 - t.height, t.width, 2 * t.height), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t.width - 259, 259, 2 * t.width, t.height), this.darkGraphics.endFill(), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t.width - 259, -259 - t.height, t.width, 2 * t.height), this.darkGraphics.endFill(), this.darkGraphics.visible = !1, this.windowOverlay = this.game.add.graphics(0, 0, this.overlayLayer), this.windowOverlay.beginFill(0, .35), this.windowOverlay.drawRect(-10, -10, t.width + 20, t.height + 20), this.windowOverlay.endFill(), this.windowOverlay.fixedToCamera = !0, this.windowOverlay.visible = !1, this.flashOverlay = t.add.graphics(0, 0, this.overlayLayer), this.flashOverlay.fixedToCamera = !0, this.flashOverlay.beginFill(16777215), this.flashOverlay.drawRect(-10, 10, t.width + 10, t.height + 10), this.flashOverlay.endFill(), this.flashOverlay.visible = !1, this.exploding = !1, this.deathText = new DeathText(t, this.overlayLayer), this.state = GameStates.Loading, this.player = new Player(this, t, this.playerLayer), this.checkpointText = new CheckPointText(this, t, this.particleLayer), this.destroying = !1, this.options = new Options(t), this.achievements = new Achievements(this, this.game), this.gameplayUI = new GameplayUI(this.game, this), this.guiLayer.add(this.gameplayUI), this.pauseUI = new PauseUI(this.game, this), this.guiLayer.add(this.pauseUI), this.levelCompleteUI = new LevelCompleteUI(this.game, this), this.guiLayer.add(this.levelCompleteUI), this.trophiesUI = new TrophiesUI(this.game, this), this.windowLayer.add(this.trophiesUI), this.actSelectUI = new ActSelectUI(this.game, this), this.windowLayer.add(this.actSelectUI), this.optionsUI = new OptionsUI(this.game, this), this.windowLayer.add(this.optionsUI), this.currentLevelID = "mainmenu", this.firstSpawn = !1, this.transition = new Transition(t), this.transitionLayer.add(this.transition), this.levels = new Levels(t, function() {}), this.game.onBlur.add(function() { i.state === GameStates.Playing && i.pauseUI.show() }), this.game.onPause.add(function() { i.state === GameStates.Playing && i.pauseUI.show() }, this), this.game.onFocus.add(function() {}), this.keys.hide(), this.state = GameStates.MainMenu, this.sounds.playMenuSong(), this.skipMenu && this.changeLevel("hub", -1), this.correctSoundValues(), this.setCameraZoom()
|
|
}
|
|
return t.prototype.mobilePressedDown = function() { Fabrique.Utils.isOnDevice(this.game), this.correctSoundValues(), this.player.enterActBlock() }, t.prototype.gotoMainMenu = function() {
|
|
var t = this;
|
|
this.transition.beginTransition(function() { t.prevLevel = t.currentLevelID, t.destroying = !0, t.state = GameStates.Loading, t.currentLevel = t.levels.levels[t.currentLevelID], t.destroyLevel(), t.timerLive = !1, t.gameplayUI.hide(), t.state = GameStates.MainMenu, t.mainMenuLayer.visible = !0, t.keys.hide(), t.currentLevelID = "mainmenu", t.game.camera.x = 0, t.game.camera.y = 0, t.background.position.set(0, 0) }, this, null, !1), this.state = GameStates.Loading
|
|
}, t.prototype.gotoMainMenuForCompletedChallenge = function() {
|
|
var e = this;
|
|
this.transition.beginTransition(function() {
|
|
e.prevLevel = e.currentLevelID, e.destroying = !0, e.state = GameStates.Loading, e.currentLevel = e.levels.levels[e.currentLevelID], e.destroyLevel(), e.timerLive = !1, e.gameplayUI.setUI(VIEWTYPE.mainmenu), e.state = GameStates.MainMenu, e.mainMenuLayer.visible = !0, e.keys.hide(), e.currentLevelID = "mainmenu", e.game.camera.x = 0, e.game.camera.y = 0, e.background.position.set(0, 0), e.achievements.gotAchievement("challengeRoom"), e.levels.levels[e.prevLevel].setBestTime(Constants.actFinishTime, e.currentDeaths), 0 === e.levels.levels[e.prevLevel].bestRank && (e.achievements.gotAchievement("perfect"), e.levels.checkPerfection() && e.achievements.gotAchievement("perfectionist")), e.levels.levels[e.prevLevel].bestRank <= 1 && e.levels.checkOlympian() && e.achievements.gotAchievement("olympian");
|
|
var t = parseInt(e.prevLevel);
|
|
t > e.levels.latestCompleted && t < 11 && (e.levels.latestCompleted = t, Constants.latestCompleted = t)
|
|
}, this, null, !1), this.state = GameStates.Loading
|
|
}, t.prototype.changeLevel = function(n, a, r, t, h) {
|
|
var l = this;
|
|
void 0 === r && (r = !1), void 0 === t && (t = -1), void 0 === h && (h = 0), this.challengeStep = t, Constants.levelMapStartTime || (Constants.levelMapStartTime = Date.now());
|
|
var c = !1,
|
|
p = 0;
|
|
if (0 === t) {
|
|
var e = SaveGame.getInstance().getChallengeData();
|
|
0 < e.time && (this.currentDeaths = e.deaths, h = e.deaths, p = Date.now() - e.time, this.challengeStep = e.floor, this.state === GameStates.MainMenu && (c = !0))
|
|
}
|
|
SaveGame.getInstance(this.game).saveStats(), this.state === GameStates.MainMenu ? this.prevLevel = "mainmenu" : -1 === this.challengeStep ? this.prevLevel = this.currentLevelID : "hub" !== this.currentLevelID && "mainmenu" === this.prevLevel || (this.prevLevel = this.currentLevelID);
|
|
var i = this.currentLevelID;
|
|
this.transition.beginTransition(function() {
|
|
if ("mainmenu" !== l.prevLevel ? (l.prevLevel = l.currentLevelID, l.isPreLevelChallenge = l.isCurrentChallenge) : l.mainMenuLayer.visible = !1, l.destroying = !0, l.currentLevelID = "" + n, l.isCurrentChallenge = r, l.currentLevel = l.levels.levels[l.currentLevelID], "hub" === l.currentLevelID ? l.sounds.playMenuSong() : "10" === l.currentLevelID ? l.sounds.playVexationgSong() : r ? l.sounds.playMusicHard() : "11" === l.currentLevelID ? l.sounds.playChallengeSong() : l.sounds.playMusicNormal(), "11" === l.currentLevelID && l.gameplayUI.updateFloor(l.challengeStep + 1), l.flashOverlay.visible = !1, "hub" === l.currentLevelID && -1 !== a) {
|
|
if (l.currentChallenge) {
|
|
Fabrique.Utils.isOnDevice(l.game) && SocialServicesHandler.submitScore(l.game, Constants.actFinishTime, "challenge", l.prevLevel), l.achievements.gotAchievement("challenge" + l.prevLevel);
|
|
var t = l.levels.levels[l.prevLevel];
|
|
t.challengeCompleted = !0, l.levels.checkWinner() && l.achievements.gotAchievement("winner"), t.saveLevel()
|
|
}
|
|
else "11" === l.prevLevel ? l.achievements.gotAchievement("challengeRoom") : (l.achievements.gotAchievement("act" + l.prevLevel), l.elapsedTime = Date.now() - Constants.actStartTime, Fabrique.Utils.isOnDevice(l.game) && SocialServicesHandler.submitScore(l.game, Constants.actFinishTime, "act", l.prevLevel));
|
|
l.levels.levels[l.prevLevel].setBestTime(Constants.actFinishTime, l.currentDeaths), 0 === l.levels.levels[l.prevLevel].bestRank && (l.achievements.gotAchievement("perfect"), l.levels.checkPerfection() && l.achievements.gotAchievement("perfectionist")), l.levels.levels[l.prevLevel].bestRank <= 1 && l.levels.checkOlympian() && l.achievements.gotAchievement("olympian");
|
|
var e = parseInt(l.prevLevel);
|
|
e > l.levels.latestCompleted && e < 11 && (l.levels.latestCompleted = e, Constants.latestCompleted = e)
|
|
}
|
|
if (("mainmenu" !== l.prevLevel || 0 < l.challengeStep && !c) && l.destroyLevel(), r ? l.createLevel(l.currentLevel.challengeData, l.game) : l.createLevel(l.currentLevel.data, l.game), l.firstSpawn = !0, l.timerLive = !1, l.currentTime = null, l.currentDeaths = h, l.gameplayUI.show(), "hub" !== l.currentLevelID) {
|
|
l.game.analytics.google.sendScreenView("gameplay"), l.allowSpace = !1, l.correctSoundValues();
|
|
var i = "Act",
|
|
s = l.currentLevelID;
|
|
if (r && (i = "HardMode"), "11" === l.currentLevelID && (i = "Challenge", s = l.challengeStep.toString()), l.game.analytics.game.addEvent(new GA.Events.Progression("Start:" + i + ":" + s)), ("11" !== l.currentLevelID || "11" === l.currentLevelID && 0 === l.challengeStep) && (Constants.actStartTime = Date.now()), "11" === l.currentLevelID && 0 < l.challengeStep) {
|
|
var o = Date.now() - Constants.pausedActTime;
|
|
Constants.actStartTime += o, 0 < p && (Constants.actStartTime = p), l.gameplayUI.enterLevel(l.currentLevel, !0, l.challengeStep), l.gameplayUI.updateDeaths(l.currentDeaths)
|
|
}
|
|
else l.gameplayUI.enterLevel(l.currentLevel, !1);
|
|
Constants.blend ? l.background.filters = [l.currentLevel.colorFilter] : l.background.filters = null
|
|
}
|
|
else l.game.analytics.google.sendScreenView("level_select"), l.gameplayUI.exitLevel(), l.background.filters = null, l.gameplayUI.updateDeaths(Constants.totalDeaths), l.gameplayUI.updateProgress(l.achievements.getTotalProgress());
|
|
"10" == l.currentLevelID ? (l.followingWire = !0, l.wireTrail.startFollow()) : l.followingWire = !1, l.currentChallenge = r, l.state = GameStates.Playing, l.keys.show(), 0 == l.levels.latestCompleted ? l.keys.setAlpha(.5) : 1 == l.levels.latestCompleted ? l.keys.setAlpha(.2) : l.keys.setAlpha(.15)
|
|
}, this, this.levels.levels[n].colorFilter, "hub" === i || "mainmenu" === i), this.state = GameStates.Loading
|
|
}, t.prototype.finishLevel = function() {
|
|
if (!this.finished) {
|
|
this.finished = !0, this.enableHellButton = !1, (Constants.actFinishTime < this.levels.levels.hub.topTime || -1 === this.levels.levels.hub.topTime) && (this.levels.levels.hub.topTime = Constants.actFinishTime);
|
|
var t = "Act",
|
|
e = this.currentLevelID;
|
|
if (this.isCurrentChallenge && (t = "HardMode"), "11" === this.currentLevelID && (t = "Challenge", e = this.challengeStep.toString()), this.game.analytics.game.addEvent(new GA.Events.Progression("Complete:" + t + ":" + e, this.currentDeaths, Math.round((Date.now() - Constants.actStartTime) / 1e3))), "11" === this.currentLevelID)
|
|
if (SaveGame.getInstance().saveChallengeStep(this.challengeStep + 1), this.challengeStep + 1 < Level.ChallengeSteps) {
|
|
var i = { deaths: this.currentDeaths, floor: this.challengeStep + 1, time: Date.now() - Constants.actStartTime };
|
|
SaveGame.getInstance().setChallengeStep(i)
|
|
}
|
|
else SaveGame.getInstance().clearChallengeData();
|
|
this.levelCompleteUI.updateData(this.gameplayUI.getTime(), this.gameplayUI.getRank()), this.levelCompleteUI.show()
|
|
}
|
|
}, t.prototype.nextChallenge = function() {
|
|
var t = this.currentTime;
|
|
Constants.pausedActTime = Constants.actFinishTime + Constants.actStartTime, this.game.paused = !1, this.challengeStep++, this.changeLevel("11", t, !1, this.challengeStep, this.currentDeaths), this.keys.show(), this.player.resume(), this.finished = !1, this.correctSoundValues()
|
|
}, t.prototype.resumeOnFinish = function() {
|
|
var t = this.currentTime;
|
|
this.game.paused = !1, this.changeLevel("hub", t), this.keys.show(), this.player.resume(), this.finished = !1, this.correctSoundValues()
|
|
}, t.prototype.resumeOnFinishChallenge = function() { this.finished = !1, this.gotoMainMenuForCompletedChallenge() }, t.prototype.destroyLevel = function() {
|
|
for (var t = 0, e = this.blocks; t < e.length; t++) { e[t].destroy() } this.blocks = null;
|
|
for (var i = 0, s = this.obstacles; i < s.length; i++) { s[i].destroy() }
|
|
for (var o = 0, n = this.ziplines; o < n.length; o++) { n[o].destroy() } this.ziplines = null;
|
|
for (var a = 0, r = this.checkpoints; a < r.length; a++) { r[a].destroy() } this.checkpoints = null;
|
|
for (var h = 0, l = this.textFades; h < l.length; h++) { l[h].destroy() } this.textFades = null;
|
|
for (var c = 0, p = this.pools; c < p.length; c++) { p[c].destroy() } this.pools = null;
|
|
for (var u = 0, d = this.poles; u < d.length; u++) { d[u].destroy() } this.poles = null;
|
|
for (var y = 0, g = this.stars; y < g.length; y++) { g[y].destroy() } this.stars = null;
|
|
for (var f = 0, m = this.fans; f < m.length; f++) { m[f].destroy() } this.fans = null;
|
|
for (var v = 0, x = this.keyObjs; v < x.length; v++) { x[v].destroy() } this.keyObjs = null;
|
|
for (var b = 0, w = this.cannons; b < w.length; b++) { w[b].destroy() } this.cannons = null;
|
|
for (var P = 0, _ = this.slopes; P < _.length; P++) { _[P].destroy() } this.slopes = null;
|
|
for (var T = 0, S = this.breatheBlasters; T < S.length; T++) { S[T].destroy() } this.breatheBlasters = null;
|
|
for (var k = 0, B = this.wires; k < B.length; k++) { B[k].destroy() } this.wires = null;
|
|
for (var A = 0, C = this.lightSwitches; A < C.length; A++) { C[A].destroy() }
|
|
var I;
|
|
this.lightSwitches = null;
|
|
for (var E = 0, O = this.portals; E < O.length; E++) {
|
|
var M = O[E];
|
|
M.destroy(), I = M.colorIndex, this.colorPortalEnable.push(I)
|
|
}
|
|
this.portals = null, this.elevatorGenerator = null, this.elevatorEliminator = null;
|
|
for (var L = 0, R = this.misc; L < R.length; L++) { R[L].destroy() } this.misc = null;
|
|
for (var D = 0, F = this.particles; D < F.length; D++) { F[D].destroy() }
|
|
for (var U = 0, G = this.particlesUI; U < G.length; U++) { G[U].destroy(!0) } this.wireTrail && this.wireTrail.destroy(), this.finishPortal = null, this.player.hide()
|
|
}, t.prototype.createLevel = function(t, e) {
|
|
var i = 0,
|
|
s = 0;
|
|
this.dark = !1, this.darkOverlay.visible = !1, this.darkGraphics.visible = !1, this.blocks = [], this.solarBlocks = [], this.slopes = [], this.obstacles = [], this.ziplines = [], this.checkpoints = [], this.poles = [], this.particles = [], this.particlesUI = [], this.textFades = [], this.pools = [], this.stars = [], this.fans = [], this.keyObjs = [], this.wires = [], this.elevatorGenerator = [], this.elevatorEliminator = [], this.misc = [], this.cannons = [], this.lightSwitches = [], this.portals = [], this.breatheBlasters = [], this.actBlocks = {}, this.actBlocksHard = {}, this.explosiveBlock = null, this.wireTrail = null, this.particleNum = 0;
|
|
var o = null,
|
|
n = null,
|
|
a = null,
|
|
r = [],
|
|
h = this.particleUINum = 0,
|
|
l = t.slice();
|
|
if ("11" === this.currentLevelID) {
|
|
for (var c = 0; c < l.length; c++) l[c].challengeStep > this.challengeStep ? (l.splice(c, 1), c--) : "finishPortal" === l[c].type && (r.push(l[c]), l[c].challengeStep > r[h].challengeStep && (h = r.length - 1));
|
|
r.splice(h, 1);
|
|
c = 0;
|
|
for (var p = r.length; c < p; c++) l.splice(l.indexOf(r[c]), 1)
|
|
}
|
|
for (c = 0; c < l.length; c++) {
|
|
switch ((X = l[c]).type) {
|
|
case "spawnPoint":
|
|
i = X.x, s = X.y;
|
|
break;
|
|
case "basicBlock":
|
|
(d = new BasicBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "verticalUpBlock":
|
|
(d = new VerticalUpBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "verticalDownBlock":
|
|
(d = new VerticalDownBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "horizontalBlock":
|
|
(d = new HorizontalBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "horizontalBlockFast":
|
|
(d = new HorizontalBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height, -5), this.blocks.push(d);
|
|
break;
|
|
case "fallingBlock":
|
|
(d = new FallingBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "bounceBlock":
|
|
(d = new BounceBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "pushBlock":
|
|
(d = new PushBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "iceBlock":
|
|
(d = new IceBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "glassBlock":
|
|
(d = new GlassBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "speedBlock":
|
|
(d = new SpeedBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height, 2.5), this.blocks.push(d);
|
|
break;
|
|
case "speedBlockLeft":
|
|
(d = new SpeedBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height, -2.5), this.blocks.push(d);
|
|
break;
|
|
case "lockBlock":
|
|
if (6 <= this.levels.latestCompleted && "hub" == this.currentLevelID || "6" === this.prevLevel) break;
|
|
(d = new LB(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "sparkBlock":
|
|
(d = new SparkBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "solarBlock":
|
|
(d = new SolarBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d), this.solarBlocks.push(d);
|
|
break;
|
|
case "invisBlock":
|
|
(d = new InvisBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "invisBlockUp":
|
|
(d = new InvisBlockUp(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "invisBlockDown":
|
|
(d = new InvisBlockDown(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d);
|
|
break;
|
|
case "explosiveBlock":
|
|
(d = new ExplosiveBlock(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height), this.blocks.push(d), this.explosiveBlock = d;
|
|
break;
|
|
case "blockedWall":
|
|
(d = new BlockedWall(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height, X.rotation, this.levels.levels[X.actNum]), this.blocks.push(d);
|
|
break;
|
|
case "actBlock":
|
|
(d = new ActBlock(this, e, this.levelLayer, X.actNum, this.levels.levels[X.actNum], !1)).spawn(X.x, X.y), this.blocks.push(d), this.actBlocks[X.actNum] = d;
|
|
break;
|
|
case "actBlockHard":
|
|
if ((d = new ActBlock(this, e, this.levelLayer, X.actNum, this.levels.levels[X.actNum], !0)).spawn(X.x, X.y), this.blocks.push(d), !(this.actBlocksHard[X.actNum] = d).hellEnabled)
|
|
for (var u = 0; u < 14; u++) {
|
|
(T = new Spike(this, e, this.obstacleLayer)).spawn(X.x - 65 + 10 * u, X.y - 79, 0), this.obstacles.push(T)
|
|
}
|
|
break;
|
|
case "actChallenge":
|
|
(d = new ActBlock(this, e, this.levelLayer, 11, this.levels.levels[11], !1)).spawn(X.x, X.y), this.blocks.push(d), this.actBlocks[11] = d;
|
|
break;
|
|
case "swimmingPool":
|
|
var d = void 0;
|
|
(d = "7" == this.currentLevelID ? new SwimmingPool(this, e, this.topPoolLayer) : new SwimmingPool(this, e, this.poolLayer)).spawn(X.x, X.y, X.width, X.height), this.pools.push(d);
|
|
break;
|
|
case "leftSlope":
|
|
(d = new LeftSlope(this, e, this.levelLayer)).spawn(X.x, X.y, X.width, X.height, X.rotation), this.slopes.push(d);
|
|
break;
|
|
case "rightSlope":
|
|
(d = new LeftSlope(this, e, this.levelLayer, !0)).spawn(X.x, X.y, X.width, X.height, X.rotation), this.slopes.push(d);
|
|
break;
|
|
case "ziplinePole":
|
|
var y = new ZiplinePole(this, e, this.obstacleLayer);
|
|
y.spawn(X.x, X.y), o = o ? (this.ziplines.push(o.attach(y)), null) : y, this.misc.push(y);
|
|
break;
|
|
case "pole":
|
|
var g = new Pole(this, e, this.topObstacleLayer);
|
|
g.spawn(X.x, X.y), this.poles.push(g);
|
|
break;
|
|
case "checkpoint":
|
|
(f = new Checkpoint(this, e, this.obstacleLayer, !1)).spawn(X.x, X.y), this.checkpoints.push(f);
|
|
break;
|
|
case "checkpointSwimming":
|
|
var f;
|
|
(f = new Checkpoint(this, e, this.obstacleLayer, !0)).spawn(X.x, X.y), this.checkpoints.push(f);
|
|
break;
|
|
case "star":
|
|
var m = new Star(this, e, this.topObstacleLayer);
|
|
m.spawn(X.x, X.y), this.stars.push(m);
|
|
break;
|
|
case "windBlaster":
|
|
var v = new WindBlaster(this, e, this.obstacleLayer);
|
|
v.spawn(X.x, X.y, X.rotation), this.fans.push(v);
|
|
break;
|
|
case "finishPortal":
|
|
var x = new FinishPortal(this, e, this.obstacleLayer);
|
|
x.spawn(X.x, X.y), this.misc.push(x), this.finishPortal = x;
|
|
break;
|
|
case "key":
|
|
if (6 <= this.levels.latestCompleted && "hub" === this.currentLevelID || "6" === this.prevLevel) break;
|
|
(D = new Key(this, e, this.obstacleLayer)).spawn(X.x, X.y), this.keyObjs.push(D);
|
|
break;
|
|
case "timedKey":
|
|
(D = new TimedKey(this, e, this.obstacleLayer)).spawn(X.x, X.y), this.keyObjs.push(D);
|
|
break;
|
|
case "circularCannon":
|
|
var b = new CircularCannon(this, e, this.topObstacleLayer);
|
|
b.spawn(X.x, X.y), this.cannons.push(b);
|
|
break;
|
|
case "lightSwitch":
|
|
var w = new LightSwitch(this, e, this.topObstacleLayer);
|
|
w.spawn(X.x, X.y), this.lightSwitches.push(w);
|
|
break;
|
|
case "wire":
|
|
var P = new Wire(this, e, this.topObstacleLayer);
|
|
P.spawn(X.x, X.y, X.rotation), this.wires.push(P);
|
|
break;
|
|
case "buzzsaw":
|
|
var _ = new Buzzsaw(this, e, this.obstacleLayer);
|
|
X.width ? _.spawn(X.x, X.y, Math.round(X.width) / 101) : _.spawn(X.x, X.y), this.obstacles.push(_);
|
|
break;
|
|
case "buzzsawVerticalUp":
|
|
(_ = new BuzzsawVerticalUp(this, e, this.obstacleLayer)).spawn(X.x, X.y), this.obstacles.push(_);
|
|
break;
|
|
case "buzzsawVerticalDown":
|
|
(_ = new BuzzsawVerticalUp(this, e, this.obstacleLayer)).spawn(X.x, X.y, 2), this.obstacles.push(_);
|
|
break;
|
|
case "buzzsawHorizontal":
|
|
_ = new BuzzsawHorizontal(this, e, this.obstacleLayer);
|
|
X.width ? _.spawn(X.x, X.y, 2, Math.round(X.width) / 101) : _.spawn(X.x, X.y, 2), this.obstacles.push(_);
|
|
break;
|
|
case "buzzsawHorizontalFast":
|
|
(_ = new BuzzsawHorizontal(this, e, this.obstacleLayer)).spawn(X.x, X.y, 5), this.obstacles.push(_);
|
|
break;
|
|
case "bouncingBuzzsaw":
|
|
_ = new BouncingBuzzsaw(this, e, this.obstacleLayer);
|
|
X.width ? _.spawn(X.x, X.y, Math.round(X.width) / 101) : _.spawn(X.x, X.y), this.obstacles.push(_);
|
|
break;
|
|
case "enlargingBuzzsaw":
|
|
_ = new EnlargingBuzzsaw(this, e, this.obstacleLayer);
|
|
X.width ? _.spawn(X.x, X.y, Math.round(X.width) / 101) : _.spawn(X.x, X.y), this.obstacles.push(_);
|
|
break;
|
|
case "buzzsawOnStick":
|
|
if (10 <= this.levels.latestCompleted && "hub" === this.currentLevelID && 4828 === X.x && 633 === X.y) break;
|
|
_ = void 0;
|
|
(_ = "hub" === this.currentLevelID ? new BuzzsawOnStick(this, e, this.obstacleLayer) : new BuzzsawOnStick(this, e, this.topObstacleLayer)).spawn(X.x, X.y, X.rotation), this.obstacles.push(_);
|
|
break;
|
|
case "spike":
|
|
(T = new Spike(this, e, this.obstacleLayer)).spawn(X.x, X.y, X.rotation), this.obstacles.push(T);
|
|
break;
|
|
case "spike10x":
|
|
(T = new Spike10x(this, e, this.obstacleLayer)).spawn(X.x, X.y, X.rotation), this.obstacles.push(T);
|
|
break;
|
|
case "spike30x":
|
|
(T = new Spike30x(this, e, this.obstacleLayer)).spawn(X.x, X.y, X.rotation), this.obstacles.push(T);
|
|
break;
|
|
case "fallingSpike":
|
|
(T = new FallingSpike(this, e, this.obstacleLayer)).spawn(X.x, X.y, X.rotation - 90), this.obstacles.push(T);
|
|
break;
|
|
case "shurikanSpawner":
|
|
if (this.levels.levels[5].challengeCompleted && "hub" === this.currentLevelID && 2272 === X.x && 1001 === X.y) break;
|
|
var T;
|
|
(T = new ShurikanSpawner(this, e, this.obstacleLayer)).spawn(X.x, X.y, X.rotation), this.obstacles.push(T);
|
|
break;
|
|
case "classicLaser":
|
|
var S = new ClassicLaser(this, e, this.topObstacleLayer);
|
|
S.spawn(X.x, X.y), this.obstacles.push(S);
|
|
break;
|
|
case "quadrantRight":
|
|
var k = new Quadrant(this, e, this.obstacleLayer);
|
|
X.width ? k.spawn(X.x, X.y, X.rotation, 2 * Math.PI / 180, X.width / 180) : k.spawn(X.x, X.y, X.rotation, 2 * Math.PI / 180), this.obstacles.push(k);
|
|
break;
|
|
case "quadrantLeft":
|
|
k = new Quadrant(this, e, this.obstacleLayer);
|
|
X.width ? k.spawn(X.x, X.y, X.rotation, -2 * Math.PI / 180, X.width / 180) : k.spawn(X.x, X.y, X.rotation, -2 * Math.PI / 180), this.obstacles.push(k);
|
|
break;
|
|
case "laserPoint":
|
|
if (n) {
|
|
var B = new LaserPoint(this, e, this.obstacleLayer);
|
|
B.spawn(n.x, n.y, X.x, X.y), this.obstacles.push(B), n = null
|
|
}
|
|
else n = new Phaser.Point(X.x, X.y);
|
|
break;
|
|
case "reaper":
|
|
var A = new Reaper(this, e, this.obstacleLayer);
|
|
X.width ? A.spawn(X.x, X.y, X.rotation, Math.round(X.width) / 133) : A.spawn(X.x, X.y, X.rotation), this.obstacles.push(A);
|
|
break;
|
|
case "shurikanDispenser":
|
|
var C = new ShurikanDispenser(this, e, this.obstacleLayer);
|
|
C.spawn(X.x, X.y), this.obstacles.push(C);
|
|
break;
|
|
case "hazardStrips":
|
|
var I = new HazardStrips(this, e, this.topObstacleLayer);
|
|
I.spawn(X.x, X.y), this.misc.push(I);
|
|
break;
|
|
case "breatheBlaster":
|
|
var E = new BreatheBlaster(this, e, this.obstacleLayer);
|
|
E.spawn(X.x, X.y, X.rotation), this.breatheBlasters.push(E);
|
|
break;
|
|
case "textFade":
|
|
(j = new TextFade(this, e, this.textLayer, "textFade" + X.textNum)).spawn(X.x, X.y, X.rotation), this.textFades.push(j);
|
|
break;
|
|
case "portal":
|
|
var O = new Portal(this, e, this.topObstacleLayer, this.colorPortalEnable[0]);
|
|
O.spawn(X.x, X.y), this.colorPortalEnable.splice(0, 1), a = a ? (O.attachPortal(a), a.attachPortal(O), null) : O, this.portals.push(O);
|
|
break;
|
|
case "elevatorGeneratorUp":
|
|
(R = new ElevatorGenerator(this, e, this.topObstacleLayer, !1)).spawn(X.x, X.y), this.elevatorGenerator.push(R), this.blocks.push(R);
|
|
break;
|
|
case "elevatorGeneratorDown":
|
|
(R = new ElevatorGenerator(this, e, this.topObstacleLayer, !0)).spawn(X.x, X.y), this.elevatorGenerator.push(R), this.blocks.push(R);
|
|
break;
|
|
case "elevatorEliminator":
|
|
(R = new ElevatorEliminator(this, e, this.topObstacleLayer)).spawn(X.x, X.y), this.elevatorEliminator.push(R), this.blocks.push(R)
|
|
}
|
|
}
|
|
for (var M = 0, L = this.elevatorGenerator; M < L.length; M++) {
|
|
var R;
|
|
(R = L[M]).spawnCable()
|
|
}
|
|
for (var D in this.blocks) {
|
|
(d = this.blocks[D]).levelStart()
|
|
}
|
|
for (var F = 0, U = this.obstacles; F < U.length; F++) { U[F].levelStart() }
|
|
if ("10" === this.currentLevelID && (this.wireTrail = new WireTrail(this, this.wires)), "hub" == this.currentLevelID) {
|
|
null === this.levels.latestCompleted && (this.levels.latestCompleted = 0);
|
|
var G = hubArrows[this.levels.latestCompleted];
|
|
if (G)
|
|
for (var N = 0, V = G; N < V.length; N++) { if ("textFade" === (X = V[N]).type)(j = new TextFade(this, e, this.textLayer, "textFade" + X.textNum)).spawn(X.x, X.y, X.rotation), this.textFades.push(j) }
|
|
if (!this.achievements.hardcore[10].completed)
|
|
for (var H = 0, z = G = hubArrows[12]; H < z.length; H++) { var X, j; if ("textFade" === (X = z[H]).type)(j = new TextFade(this, e, this.textLayer, "textFade" + X.textNum)).spawn(X.x, X.y, X.rotation), this.textFades.push(j) } this.prevLevel && "mainmenu" != this.prevLevel ? this.isPreLevelChallenge ? this.player.spawn(this.actBlocksHard[this.prevLevel].xPos, this.actBlocksHard[this.prevLevel].topEdge) : this.player.spawn(this.actBlocks[this.prevLevel].xPos, this.actBlocks[this.prevLevel].topEdge) : 0 < this.levels.latestCompleted ? this.player.spawn(this.actBlocks[this.levels.latestCompleted].xPos, this.actBlocks[this.levels.latestCompleted].topEdge) : this.player.spawn(i, s)
|
|
}
|
|
else this.player.spawn(i, s);
|
|
this.spawnX = i, this.spawnY = s, this.state = GameStates.Playing
|
|
}, t.prototype.correctSoundValues = function() {!1 === Constants.muted ? this.options.effectVolume = Constants.effectVolume : this.options.effectVolume = 0, !1 === Constants.mutedMusic ? (this.options.musicVolume = Constants.musicVolume, this.sounds.currentMusic && (this.sounds.currentMusic.volume = Constants.musicVolume)) : (this.options.musicVolume = 0, this.sounds.currentMusic && (this.sounds.currentMusic.volume = 0)), SaveGame.getInstance().saveOptions() }, t.prototype.createColorParticle = function(t, e, i, s, o, n, a, r, h, l) {
|
|
if (void 0 === o && (o = 0), void 0 === n && (n = 4), void 0 === a && (a = !0), void 0 === r && (r = !1), void 0 === h && (h = 140), void 0 === l && (l = !1), 0 !== Constants.particleLimit) {
|
|
var c = new ColorParticle(this, this.game, this.particleLayer, o, n, a, r, h, l);
|
|
if (c.spawn(t, e, i, s), this.particleNum++, this.particles.push(c), this.particleNum >= Constants.particleLimit)
|
|
for (var p = 0, u = this.particles; p < u.length; p++) { var d = u[p]; if (d.alive) { d.destroy(); break } }
|
|
}
|
|
}, t.prototype.createColorParticleUI = function(t, e, i, s, o, n, a, r, h, l, c) {
|
|
if (void 0 === n && (n = 0), void 0 === a && (a = 4), void 0 === r && (r = !0), void 0 === h && (h = !1), void 0 === l && (l = 140), void 0 === c && (c = !1), 0 !== Constants.particleLimit) {
|
|
var p = new ColorParticle(this, this.game, i, n, a, r, h, l, c);
|
|
if (p.spawn(t, e, s, o), p.isUI = !0, this.particleUINum++, this.particlesUI.push(p), this.particleUINum >= Constants.particleLimit)
|
|
for (var u = 0, d = this.particlesUI; u < d.length; u++) { var y = d[u]; if (y.alive) { y.destroy(!0); break } }
|
|
}
|
|
}, t.prototype.createPlayerGib = function(t, e, i, s, o, n, a, r, h, l, c) {
|
|
void 0 === n && (n = 0), void 0 === a && (a = 0), void 0 === r && (r = 4), void 0 === h && (h = !0), void 0 === l && (l = !1), void 0 === c && (c = 0);
|
|
var p = new PlayerGib(this, this.game, this.particleLayer, o, r, h);
|
|
if (p.spawn(t, e, i, s, n, a), this.particleNum++, this.particles.push(p), this.particleNum >= Constants.particleLimit)
|
|
for (var u = 0, d = this.particles; u < d.length; u++) { var y = d[u]; if (y.alive) { y.destroy(); break } }
|
|
}, t.prototype.teleportPortal = function(t) {
|
|
var e = t.getTeleportPoint();
|
|
e && (t.portalAttach.disablePortal(), t.disablePortal(), this.player.setPosition(e.x, e.y + 20))
|
|
}, t.prototype.goDark = function() { var t = this; if (!this.dark) { this.dark = !0, this.darkOverlay.visible = !0, setTimeout(function() { return t.darkOverlay.animations.play("dark", 30, !1, !1) }, 100), this.darkGraphics.visible = !0, this.flashOverlay.visible = !1; for (var e = 0, i = this.solarBlocks; e < i.length; e++) { i[e].goDark() } } }, t.prototype.goLight = function() { this.dark && (this.flashOverlay.visible = !0, this.flashOverlay.alpha = 1), this.dark = !1, this.darkOverlay.visible = !1, this.darkOverlay.animations.stop("dark", !0), this.darkGraphics.visible = !1; for (var t = 0, e = this.solarBlocks; t < e.length; t++) { e[t].goLight() } }, t.prototype.explode = function() { this.exploding = !0, this.flashOverlay.visible = !0, this.flashOverlay.alpha = 0 }, t.prototype.checkpointTriggered = function(t) { for (var e = 0, i = this.checkpoints; e < i.length; e++) { var s = i[e]; if (s !== t && 1 === s.state) { var o = -1 != Constants.levelsResetCheckPoints.indexOf(parseInt(this.currentLevelID)); "hub" == this.currentLevelID || o ? s.resetLevel() : s.gray() } } }, t.prototype.portToActBlock = function(t) { this.player.currentPole = null, this.player.xPos = this.actBlocks[t].xPos, this.player.yPos = this.actBlocks[t].topEdge, this.player.yVelocity = 0, this.player.xVelocity = 0, this.player.forcedXVelocity = 0, this.player.setIdle(), this.player.updateHitBoxesPos(), this.player.updatePositions(), this.game.camera.x = this.player.xPos - 320, this.game.camera.y = this.player.yPos - 280 }, t.prototype.playerDeath = function() {
|
|
if (this.currentDeaths++, Constants.totalDeaths++, "hub" !== this.currentLevelID) {
|
|
var t = "Act",
|
|
e = this.currentLevelID;
|
|
this.isCurrentChallenge && (t = "HardMode"), "11" === this.currentLevelID && (t = "Challenge", e = this.challengeStep.toString()), this.game.analytics.game.addEvent(new GA.Events.Progression("Fail:" + t + ":" + e, this.currentDeaths, Math.round((Date.now() - Constants.actStartTime) / 1e3)))
|
|
}
|
|
100 < Constants.totalDeaths && this.achievements.gotAchievement("deathtycoon"), "hub" === this.currentLevelID ? this.gameplayUI.updateDeaths(Constants.totalDeaths) : this.gameplayUI.updateDeaths(this.currentDeaths), SaveGame.getInstance(this.game).saveStats()
|
|
}, t.prototype.exitLevel = function() { "hub" === this.currentLevelID || "11" === this.currentLevelID && "mainmenu" === this.prevLevel ? this.gotoMainMenu() : (this.changeLevel("hub", -1), this.enableHellButton = !1) }, t.prototype.openWindow = function() { this.state = GameStates.Window, "mainmenu" !== this.currentLevelID && (this.windowOverlay.visible = !0), this.keys.hide(), this.player.pause() }, t.prototype.closeWindow = function() { "mainmenu" === this.currentLevelID ? (this.state = GameStates.MainMenu, this.game.analytics.google.sendScreenView("menu")) : (this.state = GameStates.Playing, this.keys.show(), this.player.resume()), this.windowOverlay.visible = !1, this.sounds.currentMusic.resume() }, t.prototype.update = function() {
|
|
var t = Date.now();
|
|
switch (t - this.timeCheck < 34 && (this.time += t - this.timeCheck, this.timeCheck = Date.now()), this.transition.update(), this.state) {
|
|
case GameStates.Playing:
|
|
for (var e = 0, i = this.cannons; e < i.length; e++) { i[e].update() }
|
|
for (var s = 0, o = this.portals; s < o.length; s++) { o[s].update() }
|
|
if (this.player.update(), this.state !== GameStates.Playing) return;
|
|
for (var n in this.blocks) { this.blocks[n].update() }
|
|
for (var n in this.wireTrail && (this.followingWire && this.wireTrail.followTick() && (this.followingWire = !1, this.wireTrail.burning = !0, this.timerLive = !0), this.wireTrail.update()), this.obstacles) { this.obstacles[n].update() }
|
|
for (var a = 0, r = this.pools; a < r.length; a++) { r[a].update() }
|
|
for (var h = 0; h < this.particles.length; h++) {
|
|
(l = this.particles[h]).alive ? l.update() : (this.particles.splice(h, 1), h--)
|
|
}
|
|
for (h = 0; h < this.particlesUI.length; h++) {
|
|
var l;
|
|
(l = this.particlesUI[h]).alive ? l.update() : (this.particlesUI.splice(h, 1), h--)
|
|
}
|
|
for (var n in this.poles) { this.poles[n].update() }
|
|
for (var n in this.checkpoints) { this.checkpoints[n].update() }
|
|
for (var n in this.textFades) { this.textFades[n].update() }
|
|
for (var c = 0, p = this.fans; c < p.length; c++) { p[c].update() }
|
|
for (var u = 0, d = this.keyObjs; u < d.length; u++) {
|
|
(n = d[u]).update()
|
|
}
|
|
for (var y = 0, g = this.breatheBlasters; y < g.length; y++) { g[y].update() } this.finishPortal && this.finishPortal.update(), this.deathText && this.deathText.update(), this.checkpointText && this.checkpointText.update(), this.exploding ? (this.flashOverlay.alpha += .05, 1 <= this.flashOverlay.alpha && (this.exploding = !1, this.changeLevel("hub", -1))) : this.dark ? (this.darkGraphics.position.set(this.player.xPos, this.player.yPos), this.darkOverlay.position.set(this.player.xPos, this.player.yPos)) : this.flashOverlay.visible && (this.flashOverlay.alpha -= .03, this.flashOverlay.alpha <= 0 && (this.flashOverlay.visible = !1)), Constants.timePlayed++, Constants.isAnHour(Date.now() - Constants.levelMapStartTime) && this.achievements.gotAchievement("timeflies"), "hub" == this.currentLevelID ? this.gameplayUI.updateTime() : (this.timerLive && (this.currentTime = Constants.actStartTime, this.gameplayUI.updateTime()), this.keys.reset.pressed() && this.resetLevel(), Constants.autoReset && -1 !== this.currentLevel.topTime && Math.round(Date.now() - Constants.actStartTime) > this.currentLevel.topTime && this.resetLevel(!0, !0)), Constants.parallax ? (this.background.x = this.game.camera.x + this.game.camera.x / 10 % 140, this.background.y = this.game.camera.y + this.game.camera.y / 10 % 140) : (this.background.x = this.game.camera.x, this.background.y = this.game.camera.y);
|
|
break;
|
|
case GameStates.Window:
|
|
break;
|
|
case GameStates.MainMenu:
|
|
Constants.parallax && (this.background.x += 1, this.background.y += 1, this.background.x = this.background.x % 140, this.background.y = this.background.y % 140)
|
|
}
|
|
this.trophiesUI && this.trophiesUI.setUI(), this.gameplayUI.updateAchievment()
|
|
}, t.prototype.resetDeath = function() { this.resumeOnReset() }, t.prototype.pauseOnLevelEnd = function() { this.game.paused = !0, this.keys.hide(), this.player.pause() }, t.prototype.resumeOnReset = function() {
|
|
this.finished = !1, this.correctSoundValues();
|
|
var t = Date.now();
|
|
this.currentTime = t, this.game.paused = !1;
|
|
for (var e = 0, i = this.blocks; e < i.length; e++) { i[e].reset() }
|
|
for (var s = 0, o = this.obstacles; s < o.length; s++) { o[s].reset() }
|
|
for (var n = 0, a = this.keyObjs; n < a.length; n++) { a[n].reset() } this.goLight(), this.keys.show(), this.player.resume()
|
|
}, t.prototype.resetLevel = function(t, e) { void 0 === t && (t = !0), void 0 === e && (e = !1), this.dark && this.goLight(); for (var i = 0, s = this.obstacles; i < s.length; i++) { s[i].resetLevel() } for (var o = 0, n = this.checkpoints; o < n.length; o++) { n[o].resetLevel() } for (var a = 0, r = this.wires; a < r.length; a++) { r[a].resetLevel() } for (var h = 0, l = this.elevatorGenerator; h < l.length; h++) { l[h].resetLevel() } for (var c = 0, p = this.elevatorEliminator; c < p.length; c++) { p[c].resetLevel() } this.wireTrail && this.wireTrail.resetLevel(); for (var u = 0, d = this.blocks; u < d.length; u++) { d[u].resetLevel() } for (var y = 0, g = this.keyObjs; y < g.length; y++) { g[y].resetLevel() } this.player.spawn(this.spawnX, this.spawnY), "11" !== this.currentLevelID ? (this.gameplayUI.resetLevel(), this.currentTime = null, this.currentDeaths = 0, this.gameplayUI.updateDeaths(this.currentDeaths), t && (Constants.actStartTime = Date.now())) : e && (this.challengeStep = 0, this.changeLevel("11", 0, !1, 0, 0)) }, t.prototype.resizeStage = function(t, e) { this.transition.resizeStage(t, e), this.trophiesUI.resize(), this.mainMenuUI.resize(), this.optionsUI.resize(), this.pauseUI.resize(), this.levelCompleteUI.resize(), this.actSelectUI.resize(), this.darkGraphics.clear(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t, -e - 259, 2 * t, e), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(259, -259 - e, t, 3 * e), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t - 259, 259, 2 * t, e), this.darkGraphics.endFill(), this.darkGraphics.endFill(), this.darkGraphics.beginFill(0), this.darkGraphics.drawRect(-t - 259, -259 - e, t, 3 * e), this.darkGraphics.endFill(), this.windowOverlay.clear(), this.windowOverlay.beginFill(0, .35), this.windowOverlay.drawRect(-10, -10, t + 20, e + 20), this.windowOverlay.endFill(), this.flashOverlay.clear(), this.flashOverlay.beginFill(16777215), this.flashOverlay.drawRect(-10, 10, this.game.width + 10, this.game.height + 10), this.flashOverlay.endFill(), this.setCameraZoom() }, t.prototype.setCameraZoom = function() {
|
|
var t = this.game.width > Constants.minSizeView ? 1 : Constants.minSizeView / this.game.width,
|
|
e = this.game.height > Constants.minSizeView ? 1 : Constants.minSizeView / this.game.height,
|
|
i = e < t ? t : e;
|
|
this.resizeGroup.scale.x = 1 / i, this.resizeGroup.scale.y = 1 / i, Constants.zoom = i
|
|
}, t.prototype.clearAllSavedData = function() { this.levels.clearAllLevelData(), SaveGame.getInstance().clearAll(), this.achievements.clearSavedData(), this.keys.show(), this.sounds.playMenuSong(), this.levels = new Levels(this.game, function() {}), this.correctSoundValues() }, t
|
|
}(),
|
|
Point = Phaser.Point,
|
|
HitBoxInfo = function(t, e, i, s) { this.xOff = t, this.yOff = e, this.width = i, this.height = s };
|
|
! function(t) { t[t.Idle = 0] = "Idle", t[t.Running = 1] = "Running", t[t.Jumping = 2] = "Jumping", t[t.Falling = 3] = "Falling", t[t.Sliding = 4] = "Sliding", t[t.Crouching = 5] = "Crouching", t[t.Scaling = 6] = "Scaling", t[t.Hanging = 7] = "Hanging", t[t.Zipping = 8] = "Zipping", t[t.Swinging = 9] = "Swinging", t[t.Pushing = 10] = "Pushing", t[t.Kicking = 11] = "Kicking", t[t.Spawning = 12] = "Spawning", t[t.Swimming = 13] = "Swimming", t[t.JumpDown = 14] = "JumpDown", t[t.JumpFrontFlip = 15] = "JumpFrontFlip", t[t.JumpBackFlip = 16] = "JumpBackFlip", t[t.Fall = 17] = "Fall", t[t.SwimmingStand = 18] = "SwimmingStand" }(PlayerState || (PlayerState = {})),
|
|
function(t) { t[t.Head = 0] = "Head", t[t.Body = 1] = "Body", t[t.Hands = 2] = "Hands", t[t.Feet = 3] = "Feet" }(HitAreas || (HitAreas = {}));
|
|
var Player = function(l) {
|
|
function t(t, e, i) {
|
|
var s, o = l.call(this, t) || this;
|
|
o.maxVelocity = 6, o.acc = 1, o.fallingMax = 20, o.startWidth = 18, o.maxScaleTime = 45, o.maxHangCoolDown = 10, o.maxBreathe = 600, o.scoreUpdated = !1, o.god = !1, o.game = e, o.portalUsed = null, o.container = e.add.group(), i.add(o.container), o.stateSprites = {};
|
|
var n = o.container.create(0, 0, "playerStand");
|
|
n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Idle] = n, n = o.container.create(0, 0, "playerRun", "player_run0000.png"), s = Phaser.Animation.generateFrameNames("player_run", 0, 18, ".png", 4), n.animations.add("run", s), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Running] = n, n = o.container.create(0, 0, "playerJump", "jump0000.png"), s = Phaser.Animation.generateFrameNames("jump", 0, 8, ".png", 4), n.animations.add("jump", s), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Jumping] = n, n = o.container.create(0, 0, "playerJumpDown", "falldown0009.png"), s = Phaser.Animation.generateFrameNames("falldown", 0, 9, ".png", 4), n.animations.add("jump", s), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.JumpDown] = n, (n = o.container.create(0, 0, "playerJumpFrontFlip")).animations.add("jump"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.JumpFrontFlip] = n, (n = o.container.create(0, 0, "playerJumpBackFlip")).animations.add("jump"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.JumpBackFlip] = n, (n = o.container.create(0, 0, "playerSlide")).animations.add("slide"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Sliding] = n, n = o.container.create(0, 0, "playerCrouch", "player_crouch0000.png"), s = Phaser.Animation.generateFrameNames("player_crouch", 0, 14, ".png", 4), n.animations.add("crouch", s), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Crouching] = n, (n = o.container.create(0, 0, "playerHang")).animations.add("hang"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Hanging] = n, o.stateSprites[PlayerState.Scaling] = n, (n = o.container.create(0, 0, "playerPulley")).animations.add("zip"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Zipping] = n, (n = o.container.create(0, 0, "playerSwing")).animations.add("swing"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Swinging] = n, (n = o.container.create(0, 0, "playerPush")).animations.add("push"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Pushing] = n, (n = o.container.create(0, 0, "playerKick")).animations.add("kick"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Kicking] = n, (n = o.container.create(0, 0, "playerFall")).animations.add("fall"), n.anchor.set(.5, .8), n.visible = !1, o.stateSprites[PlayerState.Falling] = n, n = o.container.create(0, 0, "playerSwimTop"), s = Phaser.Animation.generateFrameNames("swim", 0, 12, ".png", 4), n.animations.add("swimBack", s, 10, !0), s = Phaser.Animation.generateFrameNames("swimxpo", 0, 12, ".png", 4), n.animations.add("swim", s, 10, !0), n.anchor.set(.5, .5), n.y = -10, n.visible = !1, o.stateSprites[PlayerState.Swimming] = n, n = o.container.create(0, 0, "playerSwimStop"), s = Phaser.Animation.generateFrameNames("player_stop_swim", 0, 34, ".png", 4), n.animations.add("swimStop", s, 10, !0), n.anchor.set(.5, .5), n.y = -10, n.visible = !1, o.stateSprites[PlayerState.SwimmingStand] = n, (n = o.container.create(0, 0, "playerSpawn")).animations.add("spawn"), n.anchor.set(.5, 1), n.visible = !1, o.stateSprites[PlayerState.Spawning] = n, n = o.container.create(0, 0, "playerFallFloor"), s = Phaser.Animation.generateFrameNames("fall", 0, 4, ".png", 4), n.animations.add("fall", s, 10, !1), n.animations.getAnimation("fall"), n.anchor.set(.5, .9), n.visible = !1, o.stateSprites[PlayerState.Fall] = n, o.stateInfos = {};
|
|
var a = {};
|
|
a[HitAreas.Head] = new HitBoxInfo(-3.75, -32.75, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-5.75, -23.5, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(1.4, -19.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9.75), o.makeTotalBounds(a), o.stateInfos[PlayerState.Idle] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -33, 7.55, 18.1), a[HitAreas.Body] = new HitBoxInfo(-12.55, -30, 24.1, 26.95), a[HitAreas.Hands] = new HitBoxInfo(1.4, -19.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9.75), o.makeTotalBounds(a), o.stateInfos[PlayerState.Running] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -32.45, 7.55, 16.9), a[HitAreas.Body] = new HitBoxInfo(-5.05, -23, 12, 17.3), a[HitAreas.Hands] = new HitBoxInfo(1.05, -34.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-5.75, -6.25, 8, 9), o.makeTotalBounds(a), o.stateInfos[PlayerState.Jumping] = a, o.stateInfos[PlayerState.JumpDown] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-16.25, -10.35, 7.55, 7.2), a[HitAreas.Body] = new HitBoxInfo(-13, -11.5, 18.25, 9.75), a[HitAreas.Hands] = new HitBoxInfo(.45, -11.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 10.5), o.makeTotalBounds(a), o.stateInfos[PlayerState.Sliding] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -19, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-4.75, -11.25, 11.5, 9.75), a[HitAreas.Hands] = new HitBoxInfo(.45, -14.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9.75), o.makeTotalBounds(a), o.stateInfos[PlayerState.Crouching] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -33.25, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-6.1, -23.85, 15, 17.3), a[HitAreas.Hands] = new HitBoxInfo(3.95, -36.65, 7.55, 14.45), a[HitAreas.Feet] = new HitBoxInfo(-5.6, -6.6, 7, 6.25), o.makeTotalBounds(a), o.stateInfos[PlayerState.Scaling] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -32.75, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-6.25, -23.5, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(.35, -40.15, 9.75, 15.65), a[HitAreas.Feet] = new HitBoxInfo(-9.2, -6.25, 13, 5.25), o.makeTotalBounds(a), o.stateInfos[PlayerState.Hanging] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -32.45, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-4.8, -23, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(-1.2, -35.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9), o.makeTotalBounds(a), o.stateInfos[PlayerState.Zipping] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -32.45, 7.55, 16.9), a[HitAreas.Body] = new HitBoxInfo(-4.8, -23, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(-1.2, -35.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9), o.makeTotalBounds(a), o.stateInfos[PlayerState.Swinging] = a, (a = {})[HitAreas.Head] = new HitBoxInfo(-3.85, -32.45, 7.55, 16.9), a[HitAreas.Body] = new HitBoxInfo(-4.8, -23, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(-1.8, -25.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, -6.25, 13, 9), o.makeTotalBounds(a), o.stateInfos[PlayerState.Pushing] = a;
|
|
(a = {})[HitAreas.Head] = new HitBoxInfo(-3.75, -17.75, 7.55, 9.5), a[HitAreas.Body] = new HitBoxInfo(-5.75, -8.5, 11.5, 17.3), a[HitAreas.Hands] = new HitBoxInfo(1.4, -4.5, 7.55, 9.5), a[HitAreas.Feet] = new HitBoxInfo(-6.5, 8.75, 13, 9.75), o.makeTotalBounds(a), o.stateInfos[PlayerState.Swimming] = a, o.stateInfos[PlayerState.SwimmingStand] = o.stateInfos[PlayerState.Swimming], o.stateInfos[PlayerState.Falling] = o.stateInfos[PlayerState.Jumping], o.stateInfos[PlayerState.Spawning] = o.stateInfos[PlayerState.Idle], o.stateInfos[PlayerState.Kicking] = o.stateInfos[PlayerState.Idle], o.stateInfos[PlayerState.Fall] = o.stateInfos[PlayerState.Idle], o.head = new SAT.Box(new SAT.Vector(0, 0), 13, 9.75), o.headInfo = new HitBoxInfo(-3.75, -32.75, 7.55, 9.5), o.body = new SAT.Box(new SAT.Vector(0, 0), 13, 9.75), o.bodyInfo = new HitBoxInfo(-5.75, -23.5, 11.5, 17.3), o.hands = new SAT.Box(new SAT.Vector(0, 0), 13, 9.75), o.handsInfo = new HitBoxInfo(-.75, -19.5, 7.55, 9.5), o.feetInfo = new HitBoxInfo(-20.2, -6.25, 30.05, 10.75), o.feet = new SAT.Box(new SAT.Vector(0, 0), 13, 9.75), o.pressDown = new PressDown(o.container), o.breatheGroup = e.add.group(o.container), o.breatheBlocks = [];
|
|
for (var r = 0; r < 10; r++) {
|
|
var h = o.breatheGroup.create(10 * (r - 5), -65, "breatheBlock");
|
|
o.breatheBlocks.push(h)
|
|
}
|
|
return o.aniCont = !1, o.keys = t.keys, o.alive = !1, o.deaths = 0, o.lookingAround = !1, e.input.addMoveCallback(function() { o.main.keys.isScreenButtonDown() || o.state !== PlayerState.Idle && o.state !== PlayerState.Swimming && o.state !== PlayerState.Hanging || (o.lookingAround = !0) }, o), o
|
|
}
|
|
return __extends(t, l), t.prototype.makeTotalBounds = function(t) { t.leftEdgeOff = Math.min(t[HitAreas.Hands].xOff, Math.min(t[HitAreas.Feet].xOff, Math.min(t[HitAreas.Head].xOff, t[HitAreas.Body].xOff))), t.topEdgeOff = Math.min(t[HitAreas.Hands].yOff, Math.min(t[HitAreas.Feet].yOff, Math.min(t[HitAreas.Head].yOff, t[HitAreas.Body].yOff))), t.rightEdgeOff = Math.max(t[HitAreas.Hands].xOff + t[HitAreas.Hands].width, Math.max(t[HitAreas.Feet].xOff + t[HitAreas.Feet].width, Math.max(t[HitAreas.Head].xOff + t[HitAreas.Head].width, t[HitAreas.Body].xOff + t[HitAreas.Body].width))), t.bottomEdgeOff = Math.max(t[HitAreas.Hands].yOff + t[HitAreas.Hands].height, Math.max(t[HitAreas.Feet].yOff + t[HitAreas.Feet].height, Math.max(t[HitAreas.Head].yOff + t[HitAreas.Head].height, t[HitAreas.Body].yOff + t[HitAreas.Body].height))) }, t.prototype.setPosition = function(t, e) { this.xVelocity = 0, this.yVelocity = 0, this.forcedXVelocity = 0, this.xPos = t, this.yPos = e, this.rotation = 0, this.rotationDest = 0 }, t.prototype.spawn = function(t, e) { this.xVelocity = 0, this.yVelocity = 0, this.forcedXVelocity = 0, this.xPos = t, this.yPos = e, this.rotation = 0, this.rotationDest = 0, this.checkpoint = new Phaser.Point(t, e), this.resetpoint = new Phaser.Point(t, e), this.container.scale.set(1, 1), this.container.visible = !0, this.spriteYOff = 0, this.falling = !1, this.crouching = !1, this.scaling = !1, this.kicking = !1, this.hanging = !1, this.pushing = !1, this.swimming = !1, this.bouncing = !1, this.currentHang = null, this.hangTime = 10, this.scaleHistory = 4e3, this.scaleTime = 0, this.currentZipline = null, this.lastZipline = null, this.lastPool = null, this.currentPole = null, this.poleTimer = 0, this.currentCannon = null, this.onIce = !1, this.onSpeedBlock = !1, this.porting = !1, this.breathe = this.maxBreathe, this.poolCoolDown = 0, this.swimmingLegs = [], this.keysObtained = 0, this.heldKeys = [], this.alive = !0, this.hitGraphics = this.game.add.graphics(0, 0), this.setSpawn(), this.faceRight(), this.updatePositions(), this.resetHitBoxes(), this.scoreUpdated = !1 }, t.prototype.resetHitBoxes = function(t) {
|
|
var e, i, s, o;
|
|
void 0 === t && (t = !1), o = "right" === this.facing ? (e = this.headInfo.xOff, i = this.handsInfo.xOff, s = this.bodyInfo.xOff, this.feetInfo.xOff) : (e = -this.headInfo.xOff - this.headInfo.width, i = -this.handsInfo.xOff - this.handsInfo.width, s = -this.bodyInfo.xOff - this.bodyInfo.width, -this.feetInfo.xOff - this.feetInfo.width);
|
|
var n = t ? this.rotation * Math.PI / 180 + this.sprite.rotation : this.rotation * Math.PI / 180;
|
|
this.head.pos.x = this.xPos, this.head.pos.y = this.yPos, this.head.w = this.headInfo.width, this.head.h = this.headInfo.height, this.headPolygon = this.head.toPolygon(), this.headPolygon.setOffset(new SAT.Vector(e, this.headInfo.yOff)), this.headPolygon.setAngle(n), this.hands.pos.x = this.xPos, this.hands.pos.y = this.yPos, this.hands.w = this.handsInfo.width, this.hands.h = this.handsInfo.height, this.handsPolygon = this.hands.toPolygon(), this.handsPolygon.setOffset(new SAT.Vector(i, this.handsInfo.yOff)), this.handsPolygon.setAngle(n), this.body.pos.x = this.xPos, this.body.pos.y = this.yPos, this.body.w = this.bodyInfo.width, this.body.h = this.bodyInfo.height, this.bodyPolygon = this.body.toPolygon(), this.bodyPolygon.setOffset(new SAT.Vector(s, this.bodyInfo.yOff)), this.bodyPolygon.setAngle(n), this.feet.pos.x = this.xPos, this.feet.pos.y = this.yPos, this.feet.w = this.feetInfo.width, this.feet.h = this.feetInfo.height, this.feetPolygon = this.feet.toPolygon(), this.feetPolygon.setOffset(new SAT.Vector(o, this.feetInfo.yOff)), this.feetPolygon.setAngle(n), this.width = this.stateInfos[this.state].rightEdgeOff - this.stateInfos[this.state].leftEdgeOff, this.height = this.stateInfos[this.state].bottomEdgeOff - this.stateInfos[this.state].topEdgeOff;
|
|
var a = new SAT.Box(new SAT.Vector(this.xPos, this.yPos), this.width, this.height);
|
|
this.totalPolygon = a.toPolygon(), this.totalPolygon.setOffset(new SAT.Vector(this.stateInfos[this.state].leftEdgeOff, this.stateInfos[this.state].topEdgeOff))
|
|
}, t.prototype.updateHitBoxesPos = function() {
|
|
this.head.pos.y = this.yPos, this.feet.pos.y = this.yPos, this.hands.pos.y = this.yPos, this.body.pos.y = this.yPos, this.headPolygon.pos.x = this.xPos, this.headPolygon.pos.y = this.yPos, this.bodyPolygon.pos.x = this.xPos, this.bodyPolygon.pos.y = this.yPos, this.handsPolygon.pos.x = this.xPos, this.handsPolygon.pos.y = this.yPos, this.feetPolygon.pos.x = this.xPos, this.feetPolygon.pos.y = this.yPos, this.totalPolygon.pos.x = this.xPos, this.totalPolygon.pos.y = this.yPos;
|
|
var t = this.swimming ? this.rotation * Math.PI / 180 + this.sprite.rotation : this.rotation * Math.PI / 180;
|
|
this.headPolygon.setAngle(t), this.bodyPolygon.setAngle(t), this.handsPolygon.setAngle(t), this.feetPolygon.setAngle(t), this.totalPolygon.setAngle(t)
|
|
}, t.prototype.redrawHitBoxes = function() {
|
|
this.hitGraphics.clear(), this.hitGraphics.beginFill(16711680, .5), this.hitGraphics.moveTo(this.xPos + this.bodyPolygon.calcPoints[0].x, this.yPos + this.bodyPolygon.calcPoints[0].y);
|
|
for (var t = 1; t < 4; t++) this.hitGraphics.lineTo(this.xPos + this.bodyPolygon.calcPoints[t].x, this.yPos + this.bodyPolygon.calcPoints[t].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.bodyPolygon.calcPoints[0].x, this.yPos + this.bodyPolygon.calcPoints[0].y), this.hitGraphics.endFill(), this.hitGraphics.beginFill(65280, .5), this.hitGraphics.moveTo(this.xPos + this.headPolygon.calcPoints[0].x, this.yPos + this.headPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphics.lineTo(this.xPos + this.headPolygon.calcPoints[t].x, this.yPos + this.headPolygon.calcPoints[t].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.headPolygon.calcPoints[0].x, this.yPos + this.headPolygon.calcPoints[0].y), this.hitGraphics.endFill(), this.hitGraphics.beginFill(255, .5), this.hitGraphics.moveTo(this.xPos + this.handsPolygon.calcPoints[0].x, this.yPos + this.handsPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphics.lineTo(this.xPos + this.handsPolygon.calcPoints[t].x, this.yPos + this.handsPolygon.calcPoints[t].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.handsPolygon.calcPoints[0].x, this.yPos + this.handsPolygon.calcPoints[0].y), this.hitGraphics.endFill(), this.hitGraphics.beginFill(16776960, .5), this.hitGraphics.moveTo(this.xPos + this.feetPolygon.calcPoints[0].x, this.yPos + this.feetPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphics.lineTo(this.xPos + this.feetPolygon.calcPoints[t].x, this.yPos + this.feetPolygon.calcPoints[t].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.feetPolygon.calcPoints[0].x, this.yPos + this.feetPolygon.calcPoints[0].y), this.hitGraphics.endFill(), this.hitGraphics.beginFill(65535, .2), this.hitGraphics.moveTo(this.xPos + this.totalPolygon.calcPoints[0].x, this.yPos + this.totalPolygon.calcPoints[0].y);
|
|
for (t = 1; t < 4; t++) this.hitGraphics.lineTo(this.xPos + this.totalPolygon.calcPoints[t].x, this.yPos + this.totalPolygon.calcPoints[t].y);
|
|
this.hitGraphics.lineTo(this.xPos + this.totalPolygon.calcPoints[0].x, this.yPos + this.totalPolygon.calcPoints[0].y), this.hitGraphics.endFill()
|
|
}, t.prototype.setIdle = function() {
|
|
if (this.state === PlayerState.Jumping) {
|
|
this.state = PlayerState.Fall, this.sprite && (this.sprite.visible = !1), this.prevFrame = 0, this.sprite = this.stateSprites[PlayerState.Fall], this.sprite.visible = !0;
|
|
var t = this.sprite.animations.play("fall");
|
|
t.onComplete.removeAll(this), t.onComplete.addOnce(this.setIdle, this)
|
|
}
|
|
else this.state = PlayerState.Idle, this.sprite && (this.sprite.visible = !1), this.prevFrame = 0, this.sprite = this.stateSprites[PlayerState.Idle], this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes()
|
|
}, t.prototype.setRun = function() { this.state = PlayerState.Running, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Running], this.sprite.animations.play("run", 25 * this.main.gameSpeed, !0), this.sprite.animations.frame = 0, this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setJump = function(t, e) { void 0 === t && (t = !0), void 0 === e && (e = null), (this.state !== PlayerState.Jumping || e) && (this.state = PlayerState.Jumping, t && (this.sprite && (this.sprite.visible = !1), this.jumpState = e ? (this.sprite = this.stateSprites[e], e) : (this.sprite = this.stateSprites[PlayerState.Jumping], PlayerState.Jumping), this.sprite.animations.currentAnim.stop(!0), this.sprite.animations.play("jump", 60 * this.main.gameSpeed, !1), this.sprite.animations.frame = 0, this.prevFrame = 0, this.sprite.visible = !0), this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.height = this.stateInfos[this.state].height, this.resetHitBoxes()) }, t.prototype.setSlide = function() { this.state !== PlayerState.Sliding && (this.state = PlayerState.Sliding, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Sliding], this.sprite.animations.stop("slide", !0), this.sprite.animations.play("slide", null, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes()) }, t.prototype.setCrouch = function() { this.state = PlayerState.Crouching, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Crouching], this.sprite.animations.stop("crouch", !0), this.sprite.animations.paused = !1, this.sprite.animations.play("crouch", null, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setScale = function() { this.state !== PlayerState.Scaling && (this.state = PlayerState.Scaling, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Scaling], this.sprite.animations.currentAnim.stop(!0), this.sprite.animations.play("scale", null, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes()) }, t.prototype.setHang = function() { this.state = PlayerState.Hanging, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Hanging], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("scale", 60 * this.main.gameSpeed, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setZip = function() { this.state = PlayerState.Zipping, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Zipping], this.sprite.frame = 0, this.sprite.animations.stop("zip", !0), this.sprite.animations.refreshFrame(), this.sprite.animations.paused = !1, this.sprite.animations.play("zip", null, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setSwing = function() { this.state = PlayerState.Swinging, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Swinging], this.sprite.animations.stop("swing", !0), this.sprite.animations.paused = !1, this.sprite.animations.play("swing", null, !0), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setPush = function() { this.state = PlayerState.Pushing, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Pushing], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("push", 60 * this.main.gameSpeed, !0), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setKick = function() { this.state = PlayerState.Kicking, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Kicking], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("kick", 60 * this.main.gameSpeed, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setFall = function() { this.state = PlayerState.Falling, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Falling], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("fall", 60 * this.main.gameSpeed, !1), this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setSwim = function() { this.state = PlayerState.Swimming, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Swimming], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("swim", 10, !0), this.isSwimingStop = !1, this.sprite.rotation = 0, this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.setSpawn = function() { this.state = PlayerState.Spawning, this.sprite && (this.sprite.visible = !1), this.sprite = this.stateSprites[PlayerState.Spawning], this.sprite.animations.stop("spawn", !0), this.sprite.animations.refreshFrame(), this.sprite.animations.play("spawn", 90, !1), this.stateTime = 20, this.prevFrame = 0, this.sprite.visible = !0, this.headInfo = this.stateInfos[this.state][HitAreas.Head], this.bodyInfo = this.stateInfos[this.state][HitAreas.Body], this.handsInfo = this.stateInfos[this.state][HitAreas.Hands], this.feetInfo = this.stateInfos[this.state][HitAreas.Feet], this.resetHitBoxes() }, t.prototype.faceLeft = function() { "left" !== this.facing && (this.facing = "left", 0 < this.container.scale.x && (this.container.scale.x *= -1), this.resetHitBoxes()) }, t.prototype.faceRight = function() { "right" !== this.facing && (this.facing = "right", this.container.scale.x < 0 && (this.container.scale.x *= -1), this.resetHitBoxes()) }, t.prototype.enterActBlock = function() { this.actBlock && this.crouching && this.actBlock.checkEnableMode() && (this.actBlock.isHell ? this.main.changeLevel(this.actBlock.levelNum, -1, !0) : this.actBlock.isChallenge ? this.main.changeLevel(this.actBlock.levelNum, -1, !1, 0) : this.main.changeLevel(this.actBlock.levelNum, -1), this.actBlock = null) }, t.prototype.jump = function(t, e, i) { void 0 === e && (e = !0), void 0 === i && (i = null), this.yVelocity = t, this.falling = !0, this.scaling = !1, this.swimming = !1, this.actBlock = null, this.hanging && (this.hanging = !1, this.hangTime = 0, this.currentHang = null), this.currentPole && (0 <= this.sprite.frame && this.sprite.frame <= 14 ? (this.poleTimer = 0, this.currentPole = null, this.setJump(!0, PlayerState.JumpBackFlip), "right" === this.facing ? (this.xVelocity = 5, this.xPos += 10) : (this.xVelocity = -5, this.xPos -= 10), 4 <= this.sprite.frame && this.sprite.frame <= 10 && ("right" === this.facing ? this.xVelocity = 9 : this.xVelocity = -9), this.main.sounds.playSound("poleSwing"), this.yVelocity -= .2, this.updatePositions()) : (this.poleTimer = 0, this.currentPole = null, this.yVelocity = 0)), this.currentZipline = null, this.setJump(e, i), this.acc = 1, this.updateHitBoxesPos() }, t.prototype.land = function(t) {
|
|
if (this.yVelocity = 0, this.forcedXVelocity *= .8, this.yPos = t.yPos - .5 * t.height + t.yVelocity, this.onIce = !1, this.onSpeedBlock = !1, "ice" === t.blockType ? this.onIce = !0 : "speed" === t.blockType && (this.onSpeedBlock = !0), this.rotationDest = 0, this.state !== PlayerState.Jumping && this.state !== PlayerState.Scaling && this.state !== PlayerState.Hanging || (this.main.sounds.playSound("land"), this.keys.left.isDown() || this.keys.right.isDown() ? this.setRun() : this.setIdle()), this.falling = !1, this.scaling = !1, this.hanging = !1, this.scaleHistory = 4e3, this.currentHang = null, this.lastPool = null, this.actBlock = null, t.landed = new Phaser.Point(this.xPos - t.xPos, this.yPos - t.xPos), "push" === t.blockType && this.crouching && !this.kicking) {
|
|
if ("not trapped" === t.checkTrapped()) return;
|
|
this.kicking = !0, this.kickBlock = t, this.xVelocity = this.forcedXVelocity = 0, this.setKick(), this.sprite.animations.paused = !0, this.stateTime = 10, t.stuckRight ? (this.faceLeft(), this.tarKickX = t.rightEdge - .5 * this.width) : (this.tarKickX = t.leftEdge + .5 * this.width, this.faceRight())
|
|
}
|
|
else if ("act" === t.blockType) {
|
|
var e = t;
|
|
this.actBlock = e, this.game.device.desktop && this.enterActBlock(), this.pressDown.showPressDown = !0
|
|
}
|
|
}, t.prototype.scale = function(t, e) { void 0 === e && (e = !0), this.scaling ? (this.lastPool = null, 1 < this.yVelocity && (this.yVelocity *= .8), this.scaleTime += this.main.gameSpeed, this.scaleTime > this.maxScaleTime && (this.scaling = !1, this.falling = !0, this.setJump(), this.lastScaled = !1), this.xVelocity = this.forcedXVelocity = 0) : (e && this.scaleHistory != t.rightEdge || !e && this.scaleHistory !== t.leftEdge) && (this.scaleTime = 0, this.scaling = !0, this.falling = !1, this.diving = !1, this.rotation = 0, this.rotationDest = 0, 5 < this.yVelocity ? this.main.sounds.playSound("wallSlide") : this.main.sounds.playSound("connectSlide"), this.yVelocity < 0 && (this.yVelocity = 0), this.scaleHistory = e ? t.rightEdge : t.leftEdge, this.setScale(), this.lastScaled = !0, this.xVelocity = this.forcedXVelocity = 0) }, t.prototype.hang = function(t, e) { void 0 === e && (e = !0), this.state !== PlayerState.Hanging && this.setHang(), this.yVelocity = 0, this.yPos = t.topEdge - this.handsInfo.yOff - 4, this.xPos = e ? t.leftEdge - this.handsInfo.xOff - this.handsInfo.width + 4 : t.rightEdge - this.handsInfo.xOff + this.handsInfo.width - 4, this.hanging || (this.main.sounds.playSound("connectHang"), this.rotation = 0, this.rotationDest = 0), this.hanging = !0, this.falling = !1, this.currentHang = t, this.lastPool = null, this.scaleHistory = 4e3, this.lastZipline = !1 }, t.prototype.unhang = function() { this.hanging = !1, this.falling = !0, this.hangTime = 0, this.currentHang = null }, t.prototype.checkForBlock = function(t, e) { for (var i = 0; i < this.main.blocks.length; i++) { var s = this.main.blocks[i]; if (s.alive && SAT.pointInPolygon(new SAT.Vector(t, e), s.totalBoundPolygon)) return !0 } return !1 }, t.prototype.checkBlocks = function() {
|
|
if (!this.bouncing) {
|
|
var t = !1,
|
|
e = !1,
|
|
i = !1,
|
|
s = !1,
|
|
o = !1,
|
|
n = !1;
|
|
this.pressDown.showPressDown = !1;
|
|
for (var a = 0; a < this.main.blocks.length; a++) {
|
|
var r = this.main.blocks[a];
|
|
if (r.alive)
|
|
if (r.rightEdge < this.xPos - 40 || r.leftEdge > this.xPos + 40 || r.topEdge > this.yPos + 80 || r.bottomEdge < this.yPos - 80) r.landed = null;
|
|
else {
|
|
if (0, this.yVelocity > this.fallingMax && SAT.testPolygonPolygon(this.totalPolygon, r.topBoundPolygon)) { if ("bounce" === r.blockType && SAT.testPolygonPolygon(this.totalPolygon, r.topBoundPolygon)) { this.land(r); continue } return void this.kill(1) }
|
|
if (0 < this.keysObtained && "lock" === r.blockType) { var h = r; if (!h.unlocked && SAT.testPolygonPolygon(this.totalPolygon, r.totalBoundPolygon)) { h.unlock(), this.heldKeys.pop().useKey(), this.keysObtained--; continue } }
|
|
if ((0 <= this.yVelocity || r.yVelocity < 0) && -2 <= this.yVelocity - r.yVelocity && SAT.testPolygonPolygon(this.feetPolygon, r.topBoundPolygon)) { if (this.falling && this.keys.down.isDown() && "glass" === r.blockType) { r.smash(); continue } this.xPos > r.xPos - .5 * r.width && this.xPos < r.xPos + .5 * r.width && this.land(r), t = n = e = !0 }
|
|
else {
|
|
if (r.landed = null, SAT.testPolygonPolygon(this.headPolygon, r.bottomBoundPolygon)) { if (this.xPos < r.leftEdge) continue; if (this.xPos > r.rightEdge) continue; if (this.hanging || this.yVelocity - r.yVelocity <= .5) { this.scaling || this.hanging ? (this.setJump(), this.scaling = !1, this.scaleTime = 0, this.hanging = !1, this.hangTime = 0, this.currentHang = null, this.yVelocity = 2, this.falling = !0, this.scaleHistory = 4e3, this.lastZipline = !1) : this.yVelocity *= -.5, "ice" === r.blockType ? this.yPos = r.yPos + .5 * r.height + r.yVelocity + this.height + 2 : this.yPos = r.yPos + .5 * r.height + 4 * r.yVelocity + this.height + 1, 0 != r.yVelocity && (this.yPos += 20, this.yVelocity = 0), this.updateHitBoxesPos(), i = !0, "push" === r.blockType && (n = !0); continue } }
|
|
if (!this.currentHang && this.poolCoolDown <= 0 && !this.swimming) { if (r.hangable && this.falling && this.hangTime >= this.maxHangCoolDown && (0 <= this.yVelocity || r.yVelocity < 0)) { if (SAT.testPolygonPolygon(this.handsPolygon, r.lhBoundPolygon) && !this.checkForBlock(r.leftEdge + 3, r.topEdge - 5) && !this.checkForBlock(r.leftEdge - 3, r.topEdge - 5)) { this.hang(r), o = t = !0; continue } if (SAT.testPolygonPolygon(this.handsPolygon, r.rhBoundPolygon) && !this.checkForBlock(r.rightEdge + 3, r.topEdge - 5) && !this.checkForBlock(r.rightEdge + -3, r.topEdge - 5)) { this.hang(r, !1), s = t = !0; continue } } }
|
|
else { if ("right" === this.facing && this.currentHang === r) { this.hang(this.currentHang), o = !0; continue } if ("left" === this.facing && this.currentHang === r) { this.hang(this.currentHang, !1), s = !0; continue } t = !0 }
|
|
if (this.xPos > r.rightEdge || this.xPos < r.leftEdge)
|
|
if ("right" === this.facing) { if (r.scalable && (this.falling || this.scaling) && -3 <= this.yVelocity && SAT.testPolygonPolygon(this.handsPolygon, r.leftBoundPolygon)) { this.scale(r, !1), this.xPos = r.xPos - .5 * r.width + this.handsInfo.xOff - this.handsInfo.width + 1, o = t = !0; continue } }
|
|
else if (r.scalable && (this.falling || this.scaling) && -3 <= this.yVelocity && SAT.testPolygonPolygon(this.handsPolygon, r.rightBoundPolygon)) { this.scale(r, !0), this.xPos = r.xPos + .5 * r.width + this.handsInfo.xOff - 1, s = t = !0; continue }
|
|
if (!this.scaling && (0 <= this.xVelocity + this.forcedXVelocity || this.currentHang) && SAT.testPolygonPolygon(this.bodyPolygon, r.leftBoundPolygon)) {
|
|
if (this.hanging && "right" === this.facing && this.unhang(), "push" !== r.blockType || this.falling || this.crouching || "right" !== this.facing) { this.xVelocity = this.forcedXVelocity = 0, this.xPos = r.xPos - r.width / 2 - this.bodyInfo.xOff - this.bodyInfo.width + 2, o = !0; continue } r.xVelocity < this.xVelocity && (r.xVelocity = this.xVelocity);
|
|
var l = r;
|
|
this.xPos = r.leftEdge - this.width / 2 + this.xVelocity, l.pushingRight = !0, l.pushed = !0, this.state !== PlayerState.Pushing && this.setPush()
|
|
}
|
|
else if ((!this.scaling && this.xVelocity + this.forcedXVelocity <= 0 || this.currentHang) && SAT.testPolygonPolygon(this.bodyPolygon, r.rightBoundPolygon)) {
|
|
if (this.hanging && "left" === this.facing && this.unhang(), "push" !== r.blockType || this.crouching || this.falling || "left" !== this.facing) { this.xVelocity = this.forcedXVelocity = 0, this.falling ? this.xPos = r.rightEdge + 4 : this.xPos = r.xPos + r.width / 2 - this.bodyInfo.xOff - 2, this.updatePositions(), s = !0; continue } r.xVelocity > this.xVelocity && (r.xVelocity = this.xVelocity);
|
|
l = r;
|
|
this.xPos = r.rightEdge + this.width / 2 + this.xVelocity, l.pushingLeft = !0, l.pushed = !0, this.state !== PlayerState.Pushing && this.setPush()
|
|
}
|
|
else;
|
|
}
|
|
}
|
|
}
|
|
if (s && o || e && i) return n && this.main.achievements.gotAchievement("headsup"), void this.kill(3);
|
|
t || e && this.state !== PlayerState.Pushing || this.currentSlope || this.currentHang || (this.falling = !0, !this.diving && this.yVelocity <= this.fallingMax && (this.rotationDest = 0), this.state === PlayerState.Running || this.state === PlayerState.Idle || this.state === PlayerState.Pushing ? this.setJump() : this.crouching ? (this.setJump(), this.crouching = !1) : (this.scaling || this.hanging) && (this.setJump(), this.scaling = !1, this.scaleTime = 0, this.hanging = !1, this.hangTime = 0))
|
|
}
|
|
}, t.prototype.checkSlopeCollisions = function() {
|
|
this.currentSlope = null;
|
|
for (var t = 0, e = this.main.slopes; t < e.length; t++) {
|
|
var i = e[t];
|
|
if (i.alive) {
|
|
if ("left" !== this.facing || i.right) { if ("right" === this.facing && i.right && (this.falling || this.scaling) && this.yPos - .5 * this.height < i.bottomEdge && 0 < this.yVelocity && SAT.testPolygonPolygon(this.handsPolygon, i.wallPoly)) { this.currentSlope = i, this.xPos = i.leftEdge - .5 * this.width - 1; continue } }
|
|
else if ((this.falling || this.scaling) && this.yPos - .5 * this.height < i.bottomEdge && 0 < this.yVelocity && SAT.testPolygonPolygon(this.handsPolygon, i.wallPoly)) { this.currentSlope = i, this.xPos = i.rightEdge + .5 * this.width + 1; continue }
|
|
if (!this.hanging && !this.scaling)
|
|
if (!i.right && this.xVelocity < 0) { if (SAT.testPolygonPolygon(this.bodyPolygon, i.wallPoly)) { this.xPos = i.rightEdge + .5 * this.width + 7, this.xVelocity = this.forcedXVelocity = 0; continue } }
|
|
else if (i.right && 0 < this.xVelocity && SAT.testPolygonPolygon(this.bodyPolygon, i.wallPoly)) { this.xPos = i.leftEdge - .5 * this.width - 7, this.xVelocity = this.forcedXVelocity = 0; continue }
|
|
if (this.xPos > i.leftEdge && this.xPos < i.rightEdge && SAT.testPolygonPolygon(this.headPolygon, i.bottomPoly) && this.yPos >= i.bottomEdge + .5 * this.height && this.yVelocity < 0 && (this.yPos = i.bottomEdge + this.height, this.yVelocity *= -.5, this.yPos += this.yVelocity, this.updatePositions(), this.scaleHistory = 4e3, this.currentZipline = null), this.xPos > i.leftEdge && this.xPos < i.rightEdge && this.yPos > i.topEdge && this.yPos < i.bottomEdge)
|
|
if (i.right) {
|
|
s = 1 - (this.xPos - i.leftEdge) / i.width;
|
|
if (this.yPos >= i.bottomEdge - i.height * s) {
|
|
o = i.height / i.width;
|
|
if (this.yVelocity > -5 - o) {
|
|
if (20 <= this.yVelocity) return void this.kill(3);
|
|
this.state !== PlayerState.Crouching && (1 < Math.abs(this.xVelocity) ? this.state !== PlayerState.Running && this.setRun() : this.setIdle()), this.yVelocity = 0, this.rotationDest = 45 * o, this.yPos = i.bottomEdge - i.height * s + 2, this.yPos < i.height && (this.yPos = i.height), this.currentSlope = i, this.scaleHistory = 4e3, this.currentZipline = !1, this.falling = !1, this.scaling = !1, this.hanging = !1
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
var s = (this.xPos - i.leftEdge) / i.width;
|
|
if (this.yPos >= i.bottomEdge - i.height * s) {
|
|
var o = i.height / i.width;
|
|
if (this.yVelocity > -5 - o) {
|
|
if (20 <= this.yVelocity) return void this.kill(3);
|
|
1 < this.yVelocity && (this.xVelocity = -this.yVelocity), this.state !== PlayerState.Crouching && (1 < Math.abs(this.xVelocity) ? this.state !== PlayerState.Running && this.setRun() : this.setIdle()), this.yVelocity = 0, this.rotationDest = -45 * o, this.yPos = i.bottomEdge - i.height * s + 2, this.currentSlope = i, this.scaleHistory = 4e3, this.currentZipline = !1, this.falling = !1, this.scaling = !1, this.hanging = !1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, t.prototype.checkCheckpoint = function() { for (var t = 0; t < this.main.checkpoints.length; t++) { var e = this.main.checkpoints[t]; if (SAT.testPolygonPolygon(this.bodyPolygon, e.boxPolygon) && 0 === e.state) return e.trigger(), void this.checkpoint.set(e.xPos, e.yPos) } }, t.prototype.checkKeyObj = function() {
|
|
for (var t = 0, e = this.main.keyObjs; t < e.length; t++) {
|
|
var i = e[t];
|
|
i.alive && (i.following || SAT.testPolygonPolygon(this.bodyPolygon, i.hitBoxPolygon) && (this.heldKeys.push(i), this.keysObtained++, 4 === this.keysObtained && this.main.achievements.gotAchievement("caretaker"), i.follow()))
|
|
}
|
|
}, t.prototype.checkKeyboard = function() { this.bouncing || (this.currentZipline || this.crouching || this.scaling || this.hanging || (this.keys.left.isDown() ? (this.xVelocity > -this.maxVelocity ? (this.xVelocity -= this.acc, 0 < this.xVelocity && (this.xVelocity *= .5)) : this.onIce ? this.xVelocity += .025 * this.acc * this.main.gameSpeed : this.xVelocity += .2 * this.acc, "right" === this.facing && (this.state === PlayerState.Pushing && this.setRun(), this.faceLeft()), this.state === PlayerState.Idle && this.setRun(), this.keys.left.isDown() && this.keys.right.isDown() && (this.xVelocity = 0, this.sprite.animations.frame = 0, this.setIdle())) : this.keys.right.isDown() ? (this.xVelocity < this.maxVelocity && (this.xVelocity += this.acc, this.xVelocity < 0 ? this.xVelocity *= .5 : this.onIce ? this.xVelocity -= .025 * this.acc * this.main.gameSpeed : this.xVelocity -= .2 * this.acc), "left" === this.facing && (this.state === PlayerState.Pushing && this.setRun(), this.faceRight()), this.state === PlayerState.Idle && this.setRun(), this.keys.right.isDown() && this.keys.left.isDown() && (this.xVelocity = 0, this.sprite.animations.frame = 0, "left" === this.facing && this.faceRight(), this.setIdle())) : (this.state !== PlayerState.Running && this.state !== PlayerState.Pushing || this.setIdle(), this.falling ? this.xVelocity *= .75 : this.onIce ? this.xVelocity *= .9 : 0 < this.xVelocity ? (this.xVelocity -= 2 * this.acc, this.xVelocity < 1 && (this.xVelocity = this.forcedXVelocity = 0)) : this.xVelocity < 0 && (this.xVelocity += 2 * this.acc, -1 < this.xVelocity && (this.xVelocity = this.forcedXVelocity = 0)))), this.forcedXVelocity *= .98, !this.keys.up.pressed() || this.crouching || this.falling ? this.keys.up.pressed() && this.falling && !this.crouching && this.jumpState === PlayerState.Jumping && this.setJump(!0, PlayerState.JumpFrontFlip) : this.jump(-8)) }, t.prototype.checkCrouch = function() {
|
|
if (!this.bouncing) {
|
|
if (!this.keys.down.pressed() || !this.falling || this.lastPool || this.diving || this.currentPole || this.state !== PlayerState.Falling && (this.setJump(!0, PlayerState.JumpDown), this.yVelocity < 0 && (this.yVelocity *= .5 * this.main.gameSpeed), this.yPos += .75 * this.yVelocity), !this.keys.down.isDown() && this.falling && this.state === PlayerState.Jumping && this.jumpState === PlayerState.JumpDown && this.setJump(!0, PlayerState.Jumping), !(this.swimming || this.falling || this.scaling || this.hanging || this.kicking))
|
|
if (this.keys.down.isDown()) {
|
|
if (this.currentZipline) return this.falling = !0, this.setJump(), this.lastZipline = this.currentZipline, void(this.currentZipline = null);
|
|
if (this.currentPole) return this.setJump(), this.currentPole = null, void(this.poleTimer = 0);
|
|
this.crouching ? this.xVelocity < 1 && -1 < this.xVelocity ? (this.state === PlayerState.Sliding && (this.sprite.animations.frame < 8 ? (this.sprite.animations.frame = 8, this.sprite.animations.paused = !1) : this.sprite.animations.currentAnim.isFinished && this.setCrouch()), this.crouching = !0, this.xVelocity = this.forcedXVelocity = 0) : !this.onSpeedBlock || this.keys.left.isDown() || this.keys.right.isDown() ? this.onIce ? this.xVelocity *= .99 : this.xVelocity *= .97 : ((8 < this.sprite.animations.currentAnim.frame || this.sprite.animations.currentAnim !== this.sprite.animations.getAnimation("crouch")) && this.setCrouch(), this.crouching = !0, this.xVelocity = this.forcedXVelocity = 0) : this.xVelocity < 2 && -2 < this.xVelocity ? (this.setCrouch(), this.crouching = !0, this.xVelocity = this.forcedXVelocity = 0) : (this.currentSlope ? this.keys.down.isDown() ? (this.setCrouch(), this.crouching = !0, this.xVelocity = this.forcedXVelocity = 0) : this.crouching = !0 : this.state != PlayerState.Sliding && (this.main.sounds.playSound("slide"), this.setSlide()), this.crouching = !0)
|
|
}
|
|
else if ((this.state === PlayerState.Sliding || this.state === PlayerState.Crouching) && (7 === this.sprite.animations.frame && (this.sprite.animations.frame = 8, this.sprite.animations.paused = !1), this.sprite.animations.currentAnim.isFinished)) {
|
|
this.setIdle(), this.crouching = !1, this.updateHitBoxesPos();
|
|
for (var t = 0, e = this.main.blocks; t < e.length; t++) {
|
|
var i = e[t];
|
|
SAT.testPolygonPolygon(this.bodyPolygon, i.rightBoundPolygon) ? this.xPos = i.rightEdge + 7 : SAT.testPolygonPolygon(this.bodyPolygon, i.leftBoundPolygon) && (this.xPos = i.leftEdge - 7)
|
|
}
|
|
}(this.scaling || this.hanging) && this.keys.down.isDown() && (this.scaling = !1, this.unhang(), this.setJump())
|
|
}
|
|
}, t.prototype.checkZipline = function() {
|
|
this.currentZipline = null;
|
|
for (var t = 0; t < this.main.ziplines.length; t++) {
|
|
var e = this.main.ziplines[t];
|
|
if (e !== this.lastZipline && (!(this.xPos - 40 > e.rightEdge || this.xPos + 40 < e.leftEdge || this.yPos - 80 > e.bottomEdge || this.yPos + 80 < e.topEdge) && SAT.testPolygonPolygon(this.handsPolygon, e.hitPolygon)))
|
|
if ("left" == e.direction) {
|
|
var i = (e.startPos.x - this.xPos) * e.scope + e.startPos.y + 25;
|
|
this.currentZipline || (this.yVelocity = 0), this.xVelocity, this.yVelocity += 1, this.xVelocity -= 1.5 * e.scope, this.xVelocity < 0 && "right" === this.facing && this.faceLeft(), this.state != PlayerState.Zipping && (this.setZip(), this.main.sounds.playSound("ziplineFull")), this.yPos = i + 5, this.currentZipline = e, this.scaleHistory = 4e3, this.lastZipline = null, this.falling = !1
|
|
}
|
|
else {
|
|
i = (this.xPos - e.startPos.x) * e.scope + e.startPos.y + this.height;
|
|
this.currentZipline || (this.yVelocity = 0), this.xVelocity < 8 && (this.yVelocity += 1, this.xVelocity += 1.3 * e.scope), 0 < this.xVelocity && "left" === this.facing && this.faceRight(), this.state != PlayerState.Zipping && (this.setZip(), this.main.sounds.playSound("ziplineFull")), this.yPos = i - 4, this.currentZipline = e, this.scaleHistory = 4e3, this.lastZipline = null, this.falling = !1
|
|
}
|
|
}
|
|
}, t.prototype.checkPoleCollisions = function() {
|
|
if (10 <= this.poleTimer++)
|
|
for (var t = 0; t < this.main.poles.length; t++) {
|
|
var e = this.main.poles[t];
|
|
SAT.testPolygonPolygon(this.handsPolygon, e.hitBoxPolygon) ? this.currentPole || (this.xVelocity = this.forcedXVelocity = 0, this.yVelocity = 0, this.currentPole = e, this.falling = !1, this.rotation = 0, this.xPos = this.currentPole.xPos - 2, this.yPos = this.currentPole.yPos + 30) : SAT.testPolygonPolygon(this.bodyPolygon, e.hitBoxPolygon) && (0 < this.xVelocity ? (this.xVelocity = this.forcedXVelocity = 0, this.xPos = e.xPos - 5) : this.xVelocity < 0 && (this.xVelocity = this.forcedXVelocity = 0, this.xPos = e.xPos + 5))
|
|
}
|
|
}, t.prototype.performSwing = function() { this.xPos = this.currentPole.xPos, this.yPos = this.currentPole.yPos + 30, this.xVelocity = this.forcedXVelocity = 0, this.yVelocity = 0, this.rotationDest = 0, this.falling = !1, this.state !== PlayerState.Swinging && this.setSwing(), this.currentPole.redSection.alpha -= .15 * (this.currentPole.redSection.alpha - 1), "right" === this.facing ? this.currentPole.redSection.rotation = 30 * Math.PI / 180 : this.currentPole.redSection.rotation = 150 * Math.PI / 180, this.scaleHistory = 4e3, this.lastZipline = null }, t.prototype.checkDeath = function() {
|
|
this.updateHitBoxesPos();
|
|
for (var t = 0; t < this.main.obstacles.length; t++) {
|
|
var e = this.main.obstacles[t];
|
|
if (e.alive) switch (e.obstacleType) {
|
|
case "spike":
|
|
var i = e;
|
|
(SAT.testPolygonPolygon(this.bodyPolygon, i.deathBoxPolygon) || SAT.testPolygonPolygon(this.headPolygon, i.deathBoxPolygon)) && this.kill();
|
|
break;
|
|
case "buzzsaw":
|
|
var s = e;
|
|
(SAT.testCirclePolygon(s.deathCircle, this.bodyPolygon) || SAT.testCirclePolygon(s.deathCircle, this.headPolygon)) && this.kill(s.killValue);
|
|
break;
|
|
case "shurikan":
|
|
var o = e;
|
|
(SAT.testPolygonPolygon(this.bodyPolygon, o.hitBoxPoly) || SAT.testPolygonPolygon(this.headPolygon, o.hitBoxPoly)) && this.kill(9);
|
|
break;
|
|
case "quadrant":
|
|
for (var n = 0, a = e.deathHitBoxPolygons; n < a.length; n++) {
|
|
var r = a[n];
|
|
(SAT.testPolygonPolygon(this.bodyPolygon, r) || SAT.testPolygonPolygon(this.headPolygon, r)) && this.kill(10)
|
|
}
|
|
break;
|
|
case "laser":
|
|
var h = e;
|
|
(SAT.testPolygonPolygon(this.bodyPolygon, h.deathHitBoxPolygon) || SAT.testPolygonPolygon(this.headPolygon, h.deathHitBoxPolygon)) && this.kill(14);
|
|
break;
|
|
case "reaper":
|
|
for (var l = 0, c = e.deathHitBoxes; l < c.length; l++) {
|
|
var p = c[l];
|
|
(SAT.testPolygonPolygon(this.bodyPolygon, p) || SAT.testPolygonPolygon(this.headPolygon, p)) && this.kill(8)
|
|
}
|
|
break;
|
|
case "spark":
|
|
var u = e;
|
|
(SAT.testPolygonPolygon(this.totalPolygon, u.deathBoxPolygon) || SAT.testPolygonPolygon(this.headPolygon, u.deathBoxPolygon)) && this.kill(11, !0)
|
|
}
|
|
}
|
|
}, t.prototype.performKick = function() { this.kickBlock.stuckRight ? (this.kickBlock.xVelocity = -15, this.xPos -= 10) : (this.kickBlock.xVelocity = 15, this.xPos += 10), this.kickBlock.stuckLeft = this.kickBlock.stuckRight = !1, this.kickBlock.xPos += this.kickBlock.xVelocity, this.kicking = !1, this.kickBlock = null, this.tarKickX = 0, this.crouching = !1, this.main.sounds.playSound("kickBlock"), this.jump(-5, !1) }, t.prototype.updateGravity = function() { this.yVelocity += this.main.gravity * this.main.gameSpeed, this.yVelocity > this.fallingMax ? (this.state != PlayerState.Falling && (this.setFall(), this.diving = !1), this.rotationDest += -this.container.scale.x * this.yVelocity * .25 * this.main.gameSpeed, (this.rotation < -150 || 150 < this.rotation) && (this.kill(5), this.main.sounds.fall.play())) : this.falling && this.yVelocity, this.state !== PlayerState.Zipping || this.currentZipline || (this.setJump(), this.falling = !0) }, t.prototype.checkPoolCollisions = function() {
|
|
for (var t = !1, e = 0; e < this.main.pools.length; e++) {
|
|
var i = this.main.pools[e];
|
|
if (SAT.testPolygonPolygon(this.bodyPolygon, i.totalPolygon)) {
|
|
if (t = !0, i.prevElec) return void this.kill(12, !0);
|
|
if (this.state !== PlayerState.Swimming && 0 <= this.yVelocity) {
|
|
this.main.sounds.playSound("splash1");
|
|
for (var s = 0; s < 5; s++) this.main.createColorParticle(this.xPos + 10 * Math.random() - 5, this.yPos - this.height / 2, 10 * Math.random() - 5, -10 * Math.random(), 56814, 4, !0, !0);
|
|
this.currentPool = i, this.swimming = !0, this.swimminBack = !0, this.lastSwimmingBack = !1, this.scaling = !1, this.hanging = !1, this.falling = !1, this.crouching = !1, this.diving = !1, this.faceRight(), this.setSwim(), this.main.playerUnderLayer.addChild(this.container), this.rotation = 0, this.scaleHistory = 4e3, this.lastZipline = null, this.rotationDest = 0
|
|
}
|
|
}
|
|
if (this.yVelocity < 0 && SAT.testPolygonPolygon(this.feetPolygon, i.topPolygon)) {
|
|
this.main.sounds.playSound("splash1"), this.lastPool = i, this.state === PlayerState.Swimming && (this.jump(-6), this.poolCoolDown = 15, this.main.playerLayer.addChild(this.container));
|
|
for (var o = this.rotation = 0; o < 5; o++) this.main.createColorParticle(this.xPos + 10 * Math.random() - 5, this.yPos - this.height / 2, 10 * Math.random() - 5, -10 * Math.random(), 56814, 4, !0, !0);
|
|
this.breathe < 90 && this.main.achievements.gotAchievement("gasping")
|
|
}
|
|
}
|
|
t || (this.swimming = !1, this.state === PlayerState.Swimming && (this.setJump(), this.falling = !0), this.currentPool = null, 0 < this.poolCoolDown && this.poolCoolDown--)
|
|
}, t.prototype.getSwim = function() {
|
|
if (this.state == PlayerState.Swimming) {
|
|
if (this.keys.up.isDown() || this.keys.down.isDown() || (this.xVelocity *= .85, this.yVelocity *= .85, this.xVelocity < 1 && -1 < this.xVelocity && (this.xVelocity = this.forcedXVelocity = 0), this.yVelocity < 1 && -1 < this.yVelocity && (this.yVelocity = 0)), this.currentCannon || (this.keys.left.isDown() ? (this.sprite.rotation -= 7 * Math.PI / 180, this.resetHitBoxes()) : this.keys.right.isDown() && (this.sprite.rotation += 7 * Math.PI / 180, this.resetHitBoxes()), this.swimmingLegs.push(this.sprite.rotation), this.swimmingLegs.length), !this.currentCannon && this.keys.up.isDown()) {
|
|
this.swimminBack = !1;
|
|
var t = this.sprite.rotation - Math.PI / 2,
|
|
e = Math.cos(t),
|
|
i = Math.sin(t),
|
|
s = 3;
|
|
this.xVelocity += e, this.yVelocity += i, 0 < e && this.xVelocity > e * s ? this.xVelocity = e * s : e < 0 && this.xVelocity < e * s && (this.xVelocity = e * s), 0 < i && this.yVelocity > i * s ? this.yVelocity = i * s : i < 0 && this.yVelocity < i * s && (this.yVelocity = i * s), Math.random() < .3 && this.main.createColorParticle(this.xPos + 10 * Math.random() - 5, this.yPos - .5 * this.height + 10 * Math.random() - 5, -this.xVelocity / 2 + Math.random(), -this.yVelocity / 2 + Math.random(), 56814, 4, !0, !0)
|
|
}
|
|
if (!this.currentCannon && this.keys.down.isDown()) {
|
|
this.swimminBack = !0;
|
|
t = this.sprite.rotation - Math.PI / 2, e = -Math.cos(t), i = -Math.sin(t), s = 2;
|
|
this.xVelocity += e, this.yVelocity += i, 0 < e && this.xVelocity > e * s ? this.xVelocity = e * s : e < 0 && this.xVelocity < e * s && (this.xVelocity = e * s), 0 < i && this.yVelocity > i * s ? this.yVelocity = i * s : i < 0 && this.yVelocity < i * s && (this.yVelocity = i * s)
|
|
}
|
|
this.xPos += this.xVelocity, this.yPos += this.yVelocity
|
|
}
|
|
}, t.prototype.checkSwimBlockCollisions = function() { for (var t = 0; t < this.main.blocks.length; t++) { var e = this.main.blocks[t]; if (e.alive && !(e.rightEdge < this.xPos - 40 || e.leftEdge > this.xPos + 40 || e.topEdge > this.yPos + 80 || e.bottomEdge < this.yPos - 80)) { if (0 < this.keysObtained && "lock" === e.blockType) { var i = e; if (!i.unlocked && SAT.testPolygonPolygon(this.totalPolygon, e.totalBoundPolygon)) { i.unlock(), this.heldKeys.pop().useKey(), this.keysObtained--; continue } } SAT.testPolygonPolygon(this.totalPolygon, e.topBoundPolygon) ? (this.yPos = e.topEdge - 20, this.yVelocity *= -1, !0) : SAT.testPolygonPolygon(this.totalPolygon, e.bottomBoundPolygon) ? (this.yVelocity *= -1, this.yPos = e.bottomEdge + 20) : SAT.testPolygonPolygon(this.totalPolygon, e.leftBoundPolygon) ? (this.xVelocity *= -1, this.xPos = e.leftEdge - 20) : SAT.testPolygonPolygon(this.totalPolygon, e.rightBoundPolygon) && (this.xVelocity *= -1, this.xPos = e.rightEdge + 20) } } }, t.prototype.cannonLogic = function() {
|
|
this.swimming ? (this.sprite.rotation = this.currentCannon.rad + 90, 360 < this.sprite.rotation && (this.sprite.rotation -= 360)) : (this.rotation = 180 * this.currentCannon.rad / Math.PI + 90, this.rotationDest = this.rotation, 360 < this.rotation && (this.rotation -= 360), 360 < this.rotationDest && (this.rotationDest -= 360)), this.falling = !1, this.yVelocity = this.xVelocity = this.forcedXVelocity = 0;
|
|
this.xPos = this.currentCannon.xPos + 50 * Math.cos(this.currentCannon.rad), this.yPos = this.currentCannon.yPos + 50 * Math.sin(this.currentCannon.rad), this.swimming || this.setIdle(), this.keys.up.pressed() && (this.currentCannon.firing = !0)
|
|
}, t.prototype.checkCannonCollisions = function() { for (var t = 0, e = this.main.cannons; t < e.length; t++) { var i = e[t]; if (!i.alive) return; if (Math.pow(i.xPos - this.xPos, 2) + Math.pow(i.yPos - this.yPos, 2) < 7225) { this.currentCannon || (this.container.parent.removeChild(this.container), this.main.playerUnderLayer.addChild(this.container)), this.main.sounds.playSound("cannonEnter"), this.currentCannon = i; break } } }, t.prototype.respawn = function() { this.main.resetDeath(), this.xVelocity = this.forcedXVelocity = 0, this.yVelocity = 0, this.spriteYOff = 0, this.xPos = this.checkpoint.x, this.yPos = this.checkpoint.y, this.container.scale.set(1, 1), this.rotation = 0, this.rotationDest = 0, this.falling = !0, this.hanging = !1, this.scaling = !1, this.crouching = !1, this.bouncing = !1, this.swimming = !1, this.kicking = !1, this.diving = !1, this.currentHang = null, this.lastPool = null, this.currentPole = null, this.poleTimer = 0, this.currentCannon = null, this.scaleHistory = 4e3, this.lastZipline = null, this.breathe = this.maxBreathe, this.container.visible = !0, this.faceRight(), this.setSpawn(), this.alive = !1; for (var t = 0, e = this.main.blocks; t < e.length; t++) { var i = e[t]; "bounce" === i.blockType && (i.landed = null) } }, t.prototype.kill = function(t, e) {
|
|
if (void 0 === t && (t = 0), void 0 === e && (e = !1), !this.god) {
|
|
this.currentZipline = null;
|
|
e ? this.main.sounds.playSound("electricity") : Math.random() < .5 ? this.main.sounds.playSound("death1") : this.main.sounds.playSound("death2"), this.main.playerDeath();
|
|
for (var i = 0; i < 5; i++) this.main.createColorParticle(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), 16711680);
|
|
this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerHead"), this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerBody", 2 * Math.random() * Math.PI, 8 * Math.random() - 4), this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerArm", 2 * Math.random() * Math.PI, 8 * Math.random() - 4), this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerArm", 2 * Math.random() * Math.PI, 8 * Math.random() - 4), this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerLeg", 2 * Math.random() * Math.PI, 8 * Math.random() - 4), this.main.createPlayerGib(this.xPos + 10 * Math.random() - 5, this.yPos - this.height * Math.random(), 10 * Math.random() - 5, -10 * Math.random(), "playerLeg", 2 * Math.random() * Math.PI, 8 * Math.random() - 4), this.container.visible = !1, this.keysObtained = 0, this.heldKeys = [], this.respawn(), this.main.deathText.show(this.xPos, this.yPos, getDeathText(t))
|
|
}
|
|
}, t.prototype.checkStar = function() { for (var t = 0; t < this.main.stars.length; t++) { var e = this.main.stars[t]; if (!e.alive) return; if (SAT.testPolygonPolygon(this.totalPolygon, e.hitBoxPolygon)) { e.getStar(); for (var i = 0; i < 15; i++) this.main.createColorParticle(e.xPos, e.yPos, 10 * Math.random() - 5, -10 * Math.random(), 16763904) } } }, t.prototype.animationTick = function() {
|
|
switch (this.state) {
|
|
case PlayerState.Running:
|
|
5 <= this.sprite.animations.frame && this.prevFrame < 5 && this.main.sounds.playSound("footstep"), 11 <= this.sprite.animations.frame && this.prevFrame < 11 && this.main.sounds.playSound("footstep"), 17 <= this.sprite.animations.frame && this.prevFrame < 17 && this.main.sounds.playSound("footstep");
|
|
break;
|
|
case PlayerState.Sliding:
|
|
7 <= this.sprite.animations.frame && this.prevFrame < 7 && (this.sprite.animations.paused = !0, this.sprite.animations.frame = 7);
|
|
break;
|
|
case PlayerState.Crouching:
|
|
7 <= this.sprite.frame && this.prevFrame < 7 && (this.sprite.animations.paused = !0, this.sprite.animations.frame = 7);
|
|
break;
|
|
case PlayerState.Spawning:
|
|
this.stateTime <= 0 ? (this.setIdle(), this.alive = !0, this.main.firstSpawn && (this.main.firstSpawn = !1, this.main.followingWire || (this.main.timerLive = !0))) : this.stateTime--;
|
|
break;
|
|
case PlayerState.Kicking:
|
|
if (this.stateTime <= 0) this.performKick(), this.sprite.animations.paused = !1;
|
|
else {
|
|
var t = this.tarKickX - this.xPos;
|
|
this.xPos += t / 5, Math.abs(t) < .5 && (this.xPos = this.tarKickX), this.stateTime--
|
|
}
|
|
break;
|
|
case PlayerState.Swinging:
|
|
32 <= this.sprite.frame && this.sprite.animations.currentAnim.setFrame(2), 4 <= this.sprite.frame && this.prevFrame < 4 && this.main.sounds.playSound("poleWoosh");
|
|
break;
|
|
case PlayerState.Swimming:
|
|
var e = 0 === this.xVelocity && 0 === this.yVelocity;
|
|
!this.isSwimingStop && e ? (this.isSwimingStop = !0, this.sprite && (this.sprite.visible = !1), this.stateSprites[PlayerState.SwimmingStand].rotation = this.stateSprites[PlayerState.Swimming].rotation, this.sprite = this.stateSprites[PlayerState.SwimmingStand], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.sprite.animations.play("swimStop", 10, !0), this.prevFrame = 0, this.sprite.visible = !0) : this.isSwimingStop && !e ? (this.isSwimingStop = !1, this.sprite && (this.sprite.visible = !1), this.stateSprites[PlayerState.Swimming].rotation = this.stateSprites[PlayerState.SwimmingStand].rotation, this.sprite = this.stateSprites[PlayerState.Swimming], this.sprite.animations.frame = 0, this.sprite.animations.refreshFrame(), this.swimminBack ? this.sprite.animations.play("swimBack", 10, !0) : this.sprite.animations.play("swim", 10, !0), this.prevFrame = 0, this.sprite.visible = !0) : this.isSwimingStop || e || (this.lastSwimmingBack !== this.swimminBack && (this.lastSwimmingBack = this.swimminBack, this.swimminBack ? this.sprite.animations.play("swimBack", 10, !0) : this.sprite.animations.play("swim", 10, !0)), this.sprite.animations.currentAnim.isPlaying || this.sprite.animations.play("swim", 10, !0))
|
|
}
|
|
this.prevFrame = this.sprite.frame
|
|
}, t.prototype.cameraLogic = function() {
|
|
Constants.zoom;
|
|
if (this.alive || !this.alive) {
|
|
var t = this.game.width / 2,
|
|
e = this.game.height / 2;
|
|
if (this.lookingAround)
|
|
if (this.state !== PlayerState.Idle && this.state !== PlayerState.Swimming && this.state !== PlayerState.Hanging && (this.lookingAround = !1), this.main.keys.isScreenButtonDown()) this.lookingAround = !1;
|
|
else {
|
|
var i = this.game.width > Constants.minSizeView ? 200 : 1 / Constants.zoom * 200,
|
|
s = this.game.height > Constants.minSizeView ? 200 : 1 / Constants.zoom * 200;
|
|
n = (this.game.input.activePointer.position.x - t) / t * i + this.xPos * (1 / Constants.zoom), a = (this.game.input.activePointer.position.y - e) / e * s + this.yPos * (1 / Constants.zoom), h = n - this.game.camera.x - t, l = a - this.game.camera.y - e;
|
|
(r = Math.sqrt(Math.pow(this.game.camera.y - a, 2) + Math.pow(this.game.camera.x - n, 2))) < .5 ? (this.game.camera.x = n, this.game.camera.y = a) : (this.game.camera.x += h / 15, this.game.camera.y += l / 15)
|
|
}
|
|
else {
|
|
var o = 0;
|
|
10 < this.yVelocity && (o = Math.random() * this.yVelocity * 2);
|
|
var n = this.xPos * (1 / Constants.zoom) - t + o,
|
|
a = this.yPos * (1 / Constants.zoom) - e + o,
|
|
r = Math.sqrt(Math.pow(this.game.camera.y - a, 2) + Math.pow(this.game.camera.x - n, 2)),
|
|
h = n - this.game.camera.x,
|
|
l = a - this.game.camera.y;
|
|
r < .5 ? (this.game.camera.x = n, this.game.camera.y = a) : (this.game.camera.x += h / 4, this.game.camera.y += l / 4)
|
|
}
|
|
}
|
|
}, t.prototype.getRotation = function() {
|
|
var t = 5 + Math.abs(this.xVelocity);
|
|
this.rotationDest = this.rotationDest % 360, this.rotation = this.rotation % 360, Math.abs(this.rotationDest - this.rotation) <= t && (this.rotation = this.rotationDest), 180 < Math.abs(this.rotationDest - this.rotation) && (this.rotationDest < this.rotation ? this.rotationDest += 360 : this.rotationDest -= 360), this.rotationDest > this.rotation ? this.rotation += t + (this.rotationDest - this.rotation) / 3 : this.rotationDest < this.rotation && (this.rotation -= t - (this.rotationDest - this.rotation) / 3)
|
|
}, t.prototype.incVelocities = function() { this.currentCannon || (this.xPos += (this.xVelocity + this.forcedXVelocity) * this.main.gameSpeed, this.yPos += this.yVelocity * this.main.gameSpeed, this.currentSlope && (this.currentSlope.right ? this.yPos += this.xVelocity * this.main.gameSpeed + 1 : this.yPos -= this.xVelocity * this.main.gameSpeed + 1)) }, t.prototype.loseKey = function(t) {
|
|
var e = this.heldKeys.indexOf(t);
|
|
this.heldKeys.splice(e, 1), this.keysObtained--
|
|
}, t.prototype.update = function() {
|
|
var t = this.xPos,
|
|
e = this.yPos,
|
|
i = this.rotation;
|
|
if (this.animationTick(), this.alive) {
|
|
if (this.porting) {
|
|
var s = this.main.finishPortal.xPos - this.xPos,
|
|
o = this.main.finishPortal.yPos - this.yPos;
|
|
this.xPos += s / 10, this.yPos += o / 10, this.container.rotation += 8 - this.container.scale.x, this.container.scale.x *= .95, this.container.scale.y *= .95, Math.abs(this.container.scale.x) < .3 && this.main.finishLevel(), this.updatePositions()
|
|
}
|
|
else if (this.main.finishPortal && SAT.testPolygonPolygon(this.totalPolygon, this.main.finishPortal.hitBoxPolygon)) this.porting = !0, this.main.timerLive = !1, this.setFall(), this.scoreUpdated || (Constants.actFinishTime = Date.now() - Constants.actStartTime, this.scoreUpdated = !0);
|
|
else if (this.state === PlayerState.Spawning);
|
|
else {
|
|
this.swimming || this.kicking || this.currentCannon || this.main.followingWire || this.checkKeyboard(), this.checkCrouch(), this.swimming || this.currentCannon || this.updateGravity(), this.incVelocities(), this.hangTime < this.maxHangCoolDown && this.hangTime++, this.checkPoolCollisions(), this.swimming ? (this.getSwim(), this.checkSwimBlockCollisions(), this.breathe -= this.main.gameSpeed, this.breathe <= 0 && this.kill(4)) : (this.currentCannon || (this.checkBlocks(), this.checkSlopeCollisions(), this.currentPole ? this.performSwing() : this.checkPoleCollisions()), (this.falling || this.currentZipline) && 0 < this.yVelocity && this.checkZipline(), this.breathe < this.maxBreathe ? this.breathe += 4 * this.main.gameSpeed : this.breathe = this.maxBreathe), this.currentCannon ? this.cannonLogic() : this.checkCannonCollisions(), this.checkKeyObj(), this.checkCheckpoint(), this.checkDeath(), this.checkStar();
|
|
for (var n = 0, a = this.main.lightSwitches; n < a.length; n++) {
|
|
var r = a[n];
|
|
SAT.testPolygonPolygon(this.totalPolygon, r.hitBoxPolygon) && this.main.goDark()
|
|
}
|
|
if (this.portalUsed) SAT.testPolygonPolygon(this.totalPolygon, this.portalUsed.hitBoxPolygon) || (this.portalUsed = null);
|
|
else
|
|
for (var h = 0, l = this.main.portals; h < l.length; h++) { var c = l[h]; if (SAT.testPolygonPolygon(this.totalPolygon, c.hitBoxPolygon)) { c.enabled ? (this.portalUsed = c.getAttachPortal(), this.main.teleportPortal(c)) : this.portalUsed = c; break } } this.swimming ? this.rotation = 0 : this.getRotation(), this.xPos === t && this.yPos === e && this.rotation === i || this.updatePositions(), this.swimming ? this.sprite.position.y = 0 : this.sprite.position.y = this.spriteYOff, !this.currentZipline && this.main.sounds.ziplineFull.isPlaying && this.main.sounds.ziplineFull.stop()
|
|
}
|
|
for (var p = 0, u = this.main.breatheBlasters; p < u.length; p++) {
|
|
var d = u[p];
|
|
SAT.testPolygonPolygon(this.totalPolygon, d.hitPoly) && (this.breathe += 5, this.breathe > this.maxBreathe && (this.breathe = this.maxBreathe))
|
|
}
|
|
this.breatheBar(), this.game.device.desktop && this.pressDown.blink()
|
|
}
|
|
this.main.followingWire || this.cameraLogic()
|
|
}, t.prototype.breatheBar = function() {
|
|
if (this.swimming) {
|
|
this.breatheGroup.visible = !0, this.breatheGroup.rotation = -this.container.rotation, this.breatheGroup.scale.x < 1 && (this.breatheGroup.scale.x += -.1, 1 < this.breatheGroup.scale.x && (this.breatheGroup.scale.x = 1), this.breatheGroup.scale.y = this.breatheGroup.scale.x, this.breatheGroup.alpha = this.breatheGroup.scale.x);
|
|
for (var t = Math.floor(this.breathe / 60), e = 0; e < 10; e++) {
|
|
var i = this.breatheBlocks[e];
|
|
t < e ? 0 < i.alpha && (i.alpha -= .1, i.y -= .5, i.alpha < 0 && (i.alpha = 0, i.y = -85)) : i.alpha < 1 && (i.alpha += .1, i.y = -65, 1 < i.alpha && (i.alpha = 1, i.y = -65))
|
|
}
|
|
}
|
|
else this.breatheGroup.visible = !1
|
|
}, t.prototype.pause = function() { this.sprite && this.sprite.animations && this.sprite.animations.currentAnim && (this.sprite.animations.paused = !0) }, t.prototype.resume = function() { this.sprite.animations.currentAnim && (this.sprite.animations.paused = !1), this.keys.left.resetStateOfKeys(), this.keys.right.resetStateOfKeys(), this.keys.up.resetStateOfKeys(), this.keys.down.resetStateOfKeys(), this.xVelocity = 0 }, t.prototype.hide = function() { this.container.visible = !1, this.alive = !1 }, t.prototype.updatePositions = function() { this.container.x = this.xPos, this.container.y = this.yPos, this.container.rotation = this.rotation * Math.PI / 180, this.updateHitBoxesPos() }, t
|
|
}(Entity),
|
|
OrientationWindow = function(o) {
|
|
function t(t, e, i) { var s = o.call(this, t, e, i) || this; return s.frame = i.create(0, 0, "orientationWindow"), s.showY = 170, s.init(), s.closeButton.position.set(450, -30), s }
|
|
return __extends(t, o), t
|
|
}(VexWindow); |