Sei sulla pagina 1di 889

// ==UserScript==

// @name REAL WORKING HACK


// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://*/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Your code here...


})();// ==UserScript==
// @name REAL WORKING HACK
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://*/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Your code here...


})();!function(t) {
function e(n) {
if (i[n])
return i[n].exports;
var s = i[n] = {
i: n,
l: !1,
exports: {}
};
return t[n].call(s.exports, s, s.exports, e),
s.l = !0,
s.exports
}
var i = {};
e.m = t,
e.c = i,
e.i = function(t) {
return t
}
,
e.d = function(t, i, n) {
e.o(t, i) || Object.defineProperty(t, i, {
configurable: !1,
enumerable: !0,
get: n
})
}
,
e.n = function(t) {
var i = t && t.__esModule ? function() {
return t.default
}
: function() {
return t
}
;
return e.d(i, "a", i),
i
}
,
e.o = function(t, e) {
return Object.prototype.hasOwnProperty.call(t, e)
}
,
e.p = "",
e(e.s = 197)
}([function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(7)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {}
,
e.prototype.update = function(t) {}
,
e.prototype.destroy = function() {}
,
e
}(s.EventEmitter);
e.Component = o;
var r = function(t) {
function e(e, i, n) {
var s = t.call(this) || this;
return s._components = [],
s.components = {},
s.world = e,
s.id = i,
s.parentId = n,
s
}
return n(e, t),
e.prototype.addComponent = function(t) {
if (this._components.push(t),
t.id)
if (this.components[t.id]) {
for (var e = 1; this.components.hasOwnProperty(t.id + "_" +
e.toString()); )
e++;
this.components[t.id + "_" + e.toString()] = t
} else
this.components[t.id] = t;
return t.entity = this,
t.world = this.world,
t.start(),
t
}
,
e.prototype.update = function(t) {
for (var e = 0, i = this._components; e < i.length; e++) {
i[e].update(t)
}
}
,
e.prototype.destroy = function() {
for (; this._components.length > 0; )
this._components.pop().destroy();
this.components = {}
}
,
e.prototype.isLocalPlayer = function() {
return this.id === this.world.id
}
,
e
}(s.EventEmitter);
e.Entity = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(7)
, o = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.world = e,
i
}
return n(e, t),
e.prototype.update = function(t) {}
,
e.prototype.cleanup = function() {}
,
e.prototype.destroy = function() {}
,
e
}(s.EventEmitter);
e.Service = o;
var r = function() {
function t() {
this.services = []
}
return t.prototype.registerService = function(t) {
this.services.push(t)
}
,
t.prototype.getService = function(t) {
for (var e = 0, i = this.services; e < i.length; e++) {
var n = i[e];
if (n instanceof t)
return n
}
return null
}
,
t.prototype.update = function(t) {
for (var e = 0, i = this.services; e < i.length; e++) {
i[e].update(t)
}
}
,
t.prototype.cleanup = function() {
for (var t = 0, e = this.services; t < e.length; t++) {
e[t].cleanup()
}
}
,
t.prototype.destroy = function() {
for (var t = 0, e = this.services; t < e.length; t++) {
e[t].destroy()
}
this.services = []
}
,
t
}();
e.ServiceManager = r
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
!function(t) {
var e = function() {
function t() {}
return t.getName = function() {
return "frontend_crash"
}
,
t.getPNG = function() {
return i(73)
}
,
t
}();
t.FrontendCrash = e;
var n = function() {
function t() {}
return t.getName = function() {
return "frontend_discord-logo"
}
,
t.getSVG = function() {
return i(74)
}
,
t
}();
t.FrontendDiscordLogo = n;
var s = function() {
function t() {}
return t.getName = function() {
return "frontend_favicon"
}
,
t.getICO = function() {
return i(75)
}
,
t
}();
t.FrontendFavicon = s;
var o = function() {
function t() {}
return t.getName = function() {
return "frontend_load"
}
,
t.getGIF = function() {
return i(76)
}
,
t
}();
t.FrontendLoad = o;
var r = function() {
function t() {}
return t.getName = function() {
return "frontend_reddit-logo"
}
,
t.getSVG = function() {
return i(77)
}
,
t
}();
t.FrontendRedditLogo = r;
var a = function() {
function t() {}
return t.getName = function() {
return "images_background_template"
}
,
t.getPNG = function() {
return i(78)
}
,
t
}();
t.ImagesBackgroundTemplate = a;
var h = function() {
function t() {}
return t.getName = function() {
return "images_bannertopleft"
}
,
t.getPNG = function() {
return i(79)
}
,
t
}();
t.ImagesBannertopleft = h;
var l = function() {
function t() {}
return t.getName = function() {
return "images_box"
}
,
t.getPNG = function() {
return i(80)
}
,
t
}();
t.ImagesBox = l;
var c = function() {
function t() {}
return t.getName = function() {
return "images_brownbearhat"
}
,
t.getPNG = function() {
return i(81)
}
,
t
}();
t.ImagesBrownbearhat = c;
var u = function() {
function t() {}
return t.getName = function() {
return "images_brownbearhaticon"
}
,
t.getPNG = function() {
return i(82)
}
,
t
}();
t.ImagesBrownbearhaticon = u;
var d = function() {
function t() {}
return t.getName = function() {
return "images_build"
}
,
t.getPNG = function() {
return i(83)
}
,
t
}();
t.ImagesBuild = d;
var p = function() {
function t() {}
return t.getName = function() {
return "images_builderhat"
}
,
t.getPNG = function() {
return i(84)
}
,
t
}();
t.ImagesBuilderhat = p;
var f = function() {
function t() {}
return t.getName = function() {
return "images_builderhaticon"
}
,
t.getPNG = function() {
return i(85)
}
,
t
}();
t.ImagesBuilderhaticon = f;
var m = function() {
function t() {}
return t.getName = function() {
return "images_carrot"
}
,
t.getPNG = function() {
return i(86)
}
,
t
}();
t.ImagesCarrot = m;
var g = function() {
function t() {}
return t.getName = function() {
return "images_carwolf"
}
,
t.getPNG = function() {
return i(87)
}
,
t
}();
t.ImagesCarwolf = g;
var y = function() {
function t() {}
return t.getName = function() {
return "images_chesshat"
}
,
t.getPNG = function() {
return i(88)
}
,
t
}();
t.ImagesChesshat = y;
var v = function() {
function t() {}
return t.getName = function() {
return "images_chesshaticon"
}
,
t.getPNG = function() {
return i(89)
}
,
t
}();
t.ImagesChesshaticon = v;
var b = function() {
function t() {}
return t.getName = function() {
return "images_chesshatrot"
}
,
t.getPNG = function() {
return i(90)
}
,
t
}();
t.ImagesChesshatrot = b;
var w = function() {
function t() {}
return t.getName = function() {
return "images_chickenhat"
}
,
t.getPNG = function() {
return i(91)
}
,
t
}();
t.ImagesChickenhat = w;
var x = function() {
function t() {}
return t.getName = function() {
return "images_chickenhaticon"
}
,
t.getPNG = function() {
return i(92)
}
,
t
}();
t.ImagesChickenhaticon = x;
var _ = function() {
function t() {}
return t.getName = function() {
return "images_coin"
}
,
t.getPNG = function() {
return i(93)
}
,
t
}();
t.ImagesCoin = _;
var P = function() {
function t() {}
return t.getName = function() {
return "images_cowboyhat"
}
,
t.getPNG = function() {
return i(94)
}
,
t
}();
t.ImagesCowboyhat = P;
var T = function() {
function t() {}
return t.getName = function() {
return "images_cowboyhaticon"
}
,
t.getPNG = function() {
return i(95)
}
,
t
}();
t.ImagesCowboyhaticon = T;
var C = function() {
function t() {}
return t.getName = function() {
return "images_crown"
}
,
t.getPNG = function() {
return i(96)
}
,
t
}();
t.ImagesCrown = C;
var S = function() {
function t() {}
return t.getName = function() {
return "images_darkdoor"
}
,
t.getPNG = function() {
return i(97)
}
,
t
}();
t.ImagesDarkdoor = S;
var A = function() {
function t() {}
return t.getName = function() {
return "images_darkguard"
}
,
t.getPNG = function() {
return i(98)
}
,
t
}();
t.ImagesDarkguard = A;
var k = function() {
function t() {}
return t.getName = function() {
return "images_darkstonewall"
}
,
t.getPNG = function() {
return i(99)
}
,
t
}();
t.ImagesDarkstonewall = k;
var E = function() {
function t() {}
return t.getName = function() {
return "images_door"
}
,
t.getPNG = function() {
return i(100)
}
,
t
}();
t.ImagesDoor = E;
var I = function() {
function t() {}
return t.getName = function() {
return "images_druidhat"
}
,
t.getPNG = function() {
return i(101)
}
,
t
}();
t.ImagesDruidhat = I;
var M = function() {
function t() {}
return t.getName = function() {
return "images_druidhaticon"
}
,
t.getPNG = function() {
return i(102)
}
,
t
}();
t.ImagesDruidhaticon = M;
var O = function() {
function t() {}
return t.getName = function() {
return "images_egg"
}
,
t.getPNG = function() {
return i(103)
}
,
t
}();
t.ImagesEgg = O;
var B = function() {
function t() {}
return t.getName = function() {
return "images_follower"
}
,
t.getPNG = function() {
return i(104)
}
,
t
}();
t.ImagesFollower = B;
var R = function() {
function t() {}
return t.getName = function() {
return "images_foodcrate"
}
,
t.getPNG = function() {
return i(105)
}
,
t
}();
t.ImagesFoodcrate = R;
var L = function() {
function t() {}
return t.getName = function() {
return "images_foodgenerator"
}
,
t.getPNG = function() {
return i(106)
}
,
t
}();
t.ImagesFoodgenerator = L;
var D = function() {
function t() {}
return t.getName = function() {
return "images_foxhat"
}
,
t.getPNG = function() {
return i(107)
}
,
t
}();
t.ImagesFoxhat = D;
var F = function() {
function t() {}
return t.getName = function() {
return "images_foxhaticon"
}
,
t.getPNG = function() {
return i(108)
}
,
t
}();
t.ImagesFoxhaticon = F;
var N = function() {
function t() {}
return t.getName = function() {
return "images_garden"
}
,
t.getPNG = function() {
return i(109)
}
,
t
}();
t.ImagesGarden = N;
var G = function() {
function t() {}
return t.getName = function() {
return "images_gardener"
}
,
t.getPNG = function() {
return i(110)
}
,
t
}();
t.ImagesGardener = G;
var U = function() {
function t() {}
return t.getName = function() {
return "images_guard"
}
,
t.getPNG = function() {
return i(111)
}
,
t
}();
t.ImagesGuard = U;
var W = function() {
function t() {}
return t.getName = function() {
return "images_heartstone"
}
,
t.getPNG = function() {
return i(112)
}
,
t
}();
t.ImagesHeartstone = W;
var j = function() {
function t() {}
return t.getName = function() {
return "images_hockeyhat"
}
,
t.getPNG = function() {
return i(113)
}
,
t
}();
t.ImagesHockeyhat = j;
var H = function() {
function t() {}
return t.getName = function() {
return "images_hockeyhaticon"
}
,
t.getPNG = function() {
return i(114)
}
,
t
}();
t.ImagesHockeyhaticon = H;
var X = function() {
function t() {}
return t.getName = function() {
return "images_icehat"
}
,
t.getPNG = function() {
return i(115)
}
,
t
}();
t.ImagesIcehat = X;
var q = function() {
function t() {}
return t.getName = function() {
return "images_icehaticon"
}
,
t.getPNG = function() {
return i(116)
}
,
t
}();
t.ImagesIcehaticon = q;
var V = function() {
function t() {}
return t.getName = function() {
return "images_knight"
}
,
t.getPNG = function() {
return i(117)
}
,
t
}();
t.ImagesKnight = V;
var Y = function() {
function t() {}
return t.getName = function() {
return "images_mannequin"
}
,
t.getPNG = function() {
return i(118)
}
,
t
}();
t.ImagesMannequin = Y;
var z = function() {
function t() {}
return t.getName = function() {
return "images_meat"
}
,
t.getPNG = function() {
return i(119)
}
,
t
}();
t.ImagesMeat = z;
var K = function() {
function t() {}
return t.getName = function() {
return "images_minimapwalker"
}
,
t.getPNG = function() {
return i(120)
}
,
t
}();
t.ImagesMinimapwalker = K;
var J = function() {
function t() {}
return t.getName = function() {
return "images_minimapwinner"
}
,
t.getPNG = function() {
return i(121)
}
,
t
}();
t.ImagesMinimapwinner = J;
var Z = function() {
function t() {}
return t.getName = function() {
return "images_pickupbot"
}
,
t.getPNG = function() {
return i(122)
}
,
t
}();
t.ImagesPickupbot = Z;
var Q = function() {
function t() {}
return t.getName = function() {
return "images_portal"
}
,
t.getPNG = function() {
return i(123)
}
,
t
}();
t.ImagesPortal = Q;
var $ = function() {
function t() {}
return t.getName = function() {
return "images_rideablebear"
}
,
t.getPNG = function() {
return i(124)
}
,
t
}();
t.ImagesRideablebear = $;
var tt = function() {
function t() {}
return t.getName = function() {
return "images_soccerball"
}
,
t.getPNG = function() {
return i(125)
}
,
t
}();
t.ImagesSoccerball = tt;
var et = function() {
function t() {}
return t.getName = function() {
return "images_sociallogo"
}
,
t.getPNG = function() {
return i(126)
}
,
t
}();
t.ImagesSociallogo = et;
var it = function() {
function t() {}
return t.getName = function() {
return "images_soul"
}
,
t.getPNG = function() {
return i(127)
}
,
t
}();
t.ImagesSoul = it;
var nt = function() {
function t() {}
return t.getName = function() {
return "images_stonecrate"
}
,
t.getPNG = function() {
return i(128)
}
,
t
}();
t.ImagesStonecrate = nt;
var st = function() {
function t() {}
return t.getName = function() {
return "images_stonegenerator"
}
,
t.getPNG = function() {
return i(129)
}
,
t
}();
t.ImagesStonegenerator = st;
var ot = function() {
function t() {}
return t.getName = function() {
return "images_stonewall"
}
,
t.getPNG = function() {
return i(130)
}
,
t
}();
t.ImagesStonewall = ot;
var rt = function() {
function t() {}
return t.getName = function() {
return "images_tankhat"
}
,
t.getPNG = function() {
return i(131)
}
,
t
}();
t.ImagesTankhat = rt;
var at = function() {
function t() {}
return t.getName = function() {
return "images_tankhaticon"
}
,
t.getPNG = function() {
return i(132)
}
,
t
}();
t.ImagesTankhaticon = at;
var ht = function() {
function t() {}
return t.getName = function() {
return "images_team"
}
,
t.getPNG = function() {
return i(133)
}
,
t
}();
t.ImagesTeam = ht;
var lt = function() {
function t() {}
return t.getName = function() {
return "images_tower"
}
,
t.getPNG = function() {
return i(134)
}
,
t
}();
t.ImagesTower = lt;
var ct = function() {
function t() {}
return t.getName = function() {
return "images_unmount"
}
,
t.getPNG = function() {
return i(135)
}
,
t
}();
t.ImagesUnmount = ct;
var ut = function() {
function t() {}
return t.getName = function() {
return "images_vikinghat"
}
,
t.getPNG = function() {
return i(136)
}
,
t
}();
t.ImagesVikinghat = ut;
var dt = function() {
function t() {}
return t.getName = function() {
return "images_vikinghaticon"
}
,
t.getPNG = function() {
return i(137)
}
,
t
}();
t.ImagesVikinghaticon = dt;
var pt = function() {
function t() {}
return t.getName = function() {
return "images_whitebearhat"
}
,
t.getPNG = function() {
return i(138)
}
,
t
}();
t.ImagesWhitebearhat = pt;
var ft = function() {
function t() {}
return t.getName = function() {
return "images_whitebearhaticon"
}
,
t.getPNG = function() {
return i(139)
}
,
t
}();
t.ImagesWhitebearhaticon = ft;
var mt = function() {
function t() {}
return t.getName = function() {
return "images_winterfloor"
}
,
t.getPNG = function() {
return i(140)
}
,
t
}();
t.ImagesWinterfloor = mt;
var gt = function() {
function t() {}
return t.getName = function() {
return "images_winterstonegenerator"
}
,
t.getPNG = function() {
return i(141)
}
,
t
}();
t.ImagesWinterstonegenerator = gt;
var yt = function() {
function t() {}
return t.getName = function() {
return "images_wintertower"
}
,
t.getPNG = function() {
return i(142)
}
,
t
}();
t.ImagesWintertower = yt;
var vt = function() {
function t() {}
return t.getName = function() {
return "images_winterwall"
}
,
t.getPNG = function() {
return i(143)
}
,
t
}();
t.ImagesWinterwall = vt;
var bt = function() {
function t() {}
return t.getName = function() {
return "images_winterwoodgenerator"
}
,
t.getPNG = function() {
return i(144)
}
,
t
}();
t.ImagesWinterwoodgenerator = bt;
var wt = function() {
function t() {}
return t.getName = function() {
return "images_woodcrate"
}
,
t.getPNG = function() {
return i(145)
}
,
t
}();
t.ImagesWoodcrate = wt;
var xt = function() {
function t() {}
return t.getName = function() {
return "images_woodgenerator"
}
,
t.getPNG = function() {
return i(146)
}
,
t
}();
t.ImagesWoodgenerator = xt;
var _t = function() {
function t() {}
return t.getName = function() {
return "images_woodspikes"
}
,
t.getPNG = function() {
return i(147)
}
,
t
}();
t.ImagesWoodspikes = _t;
var Pt = function() {
function t() {}
return t.getName = function() {
return "images_woodwall"
}
,
t.getPNG = function() {
return i(148)
}
,
t
}();
t.ImagesWoodwall = Pt
}(e.Images || (e.Images = {}));
!function(t) {
var e;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(e || (e = {}));
var n = function() {
function t() {}
return t.getName = function() {
return "atlases_bear"
}
,
t.getJSONHash = function() {
return i(38)
}
,
t.getPNG = function() {
return i(39)
}
,
t
}();
n.Frames = e,
t.AtlasesBear = n;
var s;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(s || (s = {}));
var o = function() {
function t() {}
return t.getName = function() {
return "atlases_carpig"
}
,
t.getJSONHash = function() {
return i(40)
}
,
t.getPNG = function() {
return i(41)
}
,
t
}();
o.Frames = s,
t.AtlasesCarpig = o;
var r;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(r || (r = {}));
var a = function() {
function t() {}
return t.getName = function() {
return "atlases_carwolf"
}
,
t.getJSONHash = function() {
return i(42)
}
,
t.getPNG = function() {
return i(43)
}
,
t
}();
a.Frames = r,
t.AtlasesCarwolf = a;
var h;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(h || (h = {}));
var l = function() {
function t() {}
return t.getName = function() {
return "atlases_chicken"
}
,
t.getJSONHash = function() {
return i(44)
}
,
t.getPNG = function() {
return i(45)
}
,
t
}();
l.Frames = h,
t.AtlasesChicken = l;
var c;
!function(t) {
t[t.DoorClose = "door_close.png"] = "DoorClose",
t[t.DoorOpen = "door_open.png"] = "DoorOpen"
}(c || (c = {}));
var u = function() {
function t() {}
return t.getName = function() {
return "atlases_darkdoor"
}
,
t.getJSONHash = function() {
return i(46)
}
,
t.getPNG = function() {
return i(47)
}
,
t
}();
u.Frames = c,
t.AtlasesDarkdoor = u;
var d;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Hit9 = "hit9.png"] = "Hit9",
t[t.Hit10 = "hit10.png"] = "Hit10",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(d || (d = {}));
var p = function() {
function t() {}
return t.getName = function() {
return "atlases_darkguard"
}
,
t.getJSONHash = function() {
return i(48)
}
,
t.getPNG = function() {
return i(49)
}
,
t
}();
p.Frames = d,
t.AtlasesDarkguard = p;
var f;
!function(t) {
t[t.DoorClose = "door_close.png"] = "DoorClose",
t[t.DoorOpen = "door_open.png"] = "DoorOpen"
}(f || (f = {}));
var m = function() {
function t() {}
return t.getName = function() {
return "atlases_door"
}
,
t.getJSONHash = function() {
return i(50)
}
,
t.getPNG = function() {
return i(51)
}
,
t
}();
m.Frames = f,
t.AtlasesDoor = m;
var g;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Hit9 = "hit9.png"] = "Hit9",
t[t.Hit10 = "hit10.png"] = "Hit10",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(g || (g = {}));
var y = function() {
function t() {}
return t.getName = function() {
return "atlases_follower"
}
,
t.getJSONHash = function() {
return i(52)
}
,
t.getPNG = function() {
return i(53)
}
,
t
}();
y.Frames = g,
t.AtlasesFollower = y;
var v;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Hit9 = "hit9.png"] = "Hit9",
t[t.Hit10 = "hit10.png"] = "Hit10",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(v || (v = {}));
var b = function() {
function t() {}
return t.getName = function() {
return "atlases_gardener"
}
,
t.getJSONHash = function() {
return i(54)
}
,
t.getPNG = function() {
return i(55)
}
,
t
}();
b.Frames = v,
t.AtlasesGardener = b;
var w;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Hit9 = "hit9.png"] = "Hit9",
t[t.Hit10 = "hit10.png"] = "Hit10",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(w || (w = {}));
var x = function() {
function t() {}
return t.getName = function() {
return "atlases_guard"
}
,
t.getJSONHash = function() {
return i(56)
}
,
t.getPNG = function() {
return i(57)
}
,
t
}();
x.Frames = w,
t.AtlasesGuard = x;
var _;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Hit9 = "hit9.png"] = "Hit9",
t[t.Hit10 = "hit10.png"] = "Hit10",
t[t.Onpig = "onpig.png"] = "Onpig",
t[t.Pighit1 = "pighit1.png"] = "Pighit1",
t[t.Pighit2 = "pighit2.png"] = "Pighit2",
t[t.Pighit3 = "pighit3.png"] = "Pighit3",
t[t.Pighit4 = "pighit4.png"] = "Pighit4",
t[t.Pighit5 = "pighit5.png"] = "Pighit5",
t[t.Pighit6 = "pighit6.png"] = "Pighit6",
t[t.Pighit7 = "pighit7.png"] = "Pighit7",
t[t.Pighit8 = "pighit8.png"] = "Pighit8",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(_ || (_ = {}));
var P = function() {
function t() {}
return t.getName = function() {
return "atlases_knight"
}
,
t.getJSONHash = function() {
return i(58)
}
,
t.getPNG = function() {
return i(59)
}
,
t
}();
P.Frames = _,
t.AtlasesKnight = P;
var T;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(T || (T = {}));
var C = function() {
function t() {}
return t.getName = function() {
return "atlases_pickupbot"
}
,
t.getJSONHash = function() {
return i(60)
}
,
t.getPNG = function() {
return i(61)
}
,
t
}();
C.Frames = T,
t.AtlasesPickupbot = C;
var S;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(S || (S = {}));
var A = function() {
function t() {}
return t.getName = function() {
return "atlases_pig"
}
,
t.getJSONHash = function() {
return i(62)
}
,
t.getPNG = function() {
return i(63)
}
,
t
}();
A.Frames = S,
t.AtlasesPig = A;
var k;
!function(t) {
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(k || (k = {}));
var E = function() {
function t() {}
return t.getName = function() {
return "atlases_rideablebear"
}
,
t.getJSONHash = function() {
return i(64)
}
,
t.getPNG = function() {
return i(65)
}
,
t
}();
E.Frames = k,
t.AtlasesRideablebear = E;
var I;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(I || (I = {}));
var M = function() {
function t() {}
return t.getName = function() {
return "atlases_whitebear"
}
,
t.getJSONHash = function() {
return i(66)
}
,
t.getPNG = function() {
return i(67)
}
,
t
}();
M.Frames = I,
t.AtlasesWhitebear = M;
var O;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8",
t[t.Walk9 = "walk9.png"] = "Walk9",
t[t.Walk10 = "walk10.png"] = "Walk10",
t[t.Walk11 = "walk11.png"] = "Walk11",
t[t.Walk12 = "walk12.png"] = "Walk12",
t[t.Walk13 = "walk13.png"] = "Walk13",
t[t.Walk14 = "walk14.png"] = "Walk14",
t[t.Walk15 = "walk15.png"] = "Walk15",
t[t.Walk16 = "walk16.png"] = "Walk16"
}(O || (O = {}));
var B = function() {
function t() {}
return t.getName = function() {
return "atlases_whitewalker"
}
,
t.getJSONHash = function() {
return i(68)
}
,
t.getPNG = function() {
return i(69)
}
,
t
}();
B.Frames = O,
t.AtlasesWhitewalker = B;
var R;
!function(t) {
t[t.Hit1 = "hit1.png"] = "Hit1",
t[t.Hit2 = "hit2.png"] = "Hit2",
t[t.Hit3 = "hit3.png"] = "Hit3",
t[t.Hit4 = "hit4.png"] = "Hit4",
t[t.Hit5 = "hit5.png"] = "Hit5",
t[t.Hit6 = "hit6.png"] = "Hit6",
t[t.Hit7 = "hit7.png"] = "Hit7",
t[t.Hit8 = "hit8.png"] = "Hit8",
t[t.Walk1 = "walk1.png"] = "Walk1",
t[t.Walk2 = "walk2.png"] = "Walk2",
t[t.Walk3 = "walk3.png"] = "Walk3",
t[t.Walk4 = "walk4.png"] = "Walk4",
t[t.Walk5 = "walk5.png"] = "Walk5",
t[t.Walk6 = "walk6.png"] = "Walk6",
t[t.Walk7 = "walk7.png"] = "Walk7",
t[t.Walk8 = "walk8.png"] = "Walk8"
}(R || (R = {}));
var L = function() {
function t() {}
return t.getName = function() {
return "atlases_wolf"
}
,
t.getJSONHash = function() {
return i(70)
}
,
t.getPNG = function() {
return i(71)
}
,
t
}();
L.Frames = R,
t.AtlasesWolf = L;
var D;
D || (D = {});
var F = function() {
function t() {}
return t.getName = function() {
return "map_map"
}
,
t.getJSONHash = function() {
return i(149)
}
,
t.getPNG = function() {
return i(150)
}
,
t
}();
F.Frames = D,
t.MapMap = F
}(e.Atlases || (e.Atlases = {}));
!function(t) {
var e = function() {
function t() {}
return t.getName = function() {
return "whoosh_1"
}
,
t.getWAV = function() {
return i(151)
}
,
t
}();
t.SfxWhoosh1 = e
}(e.Audio || (e.Audio = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.Audiosprites || (e.Audiosprites = {}));
!function(t) {
t.RobotoMono = "Roboto Mono"
}(e.GoogleWebFonts || (e.GoogleWebFonts = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.CustomWebFonts || (e.CustomWebFonts = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.BitmapFonts || (e.BitmapFonts = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.JSON || (e.JSON = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.XML || (e.XML = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.Text || (e.Text = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.Scripts || (e.Scripts = {}));
!function(t) {
!function() {
function t() {}
}()
}(e.Shaders || (e.Shaders = {}));
!function(t) {
var e = function() {
function t() {}
return t.getName = function() {
return "style"
}
,
t.getCSS = function() {
return i(72)
}
,
t
}();
t.CssStyle = e
}(e.Misc || (e.Misc = {}))
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(18);
!function(t) {
function e(t) {
return h[l[t]]
}
function s(t) {
return l[h[t]]
}
function o(t) {
var e = t.toLowerCase();
return "food" === e ? c.Food : "wood" === e ? c.Wood : "stone" === e ?
c.Stone : "gold" === e ? c.Gold : "soul" === e ? c.Soul : c.Food
}
function r(e) {
if (e.length > 0) {
var i = e[0]
, n = u[i];
if (null != n) {
var s = e.slice(1, e.length)
, o = void 0;
if (p.hasOwnProperty(n) ? o = p[n] : (o =
t.ProtobufRoot.lookupType(n),
p[n] = o),
null != o)
return new d(i,o.decode(s))
}
}
return null
}
function a(e, i) {
var n = u[e]
, s = t.ProtobufRoot.lookupType(n)
, o = s.encode(i).finish()
, r = new Uint8Array(o.length + 1);
return r[0] = e,
r.set(o, 1),
r
}
t.ProtobufRoot = n.Root.fromJSON(i(36));
var h;
!function(t) {
t[t.Spectator = 0] = "Spectator",
t[t.Player = 1] = "Player",
t[t.WoodGenerator = 2] = "WoodGenerator",
t[t.StoneGenerator = 3] = "StoneGenerator",
t[t.Pig = 4] = "Pig",
t[t.Wolf = 5] = "Wolf",
t[t.Chicken = 6] = "Chicken",
t[t.Bear = 7] = "Bear",
t[t.RideablePig = 8] = "RideablePig",
t[t.RideableWolf = 9] = "RideableWolf",
t[t.WoodBlock = 10] = "WoodBlock",
t[t.StoneBlock = 11] = "StoneBlock",
t[t.Door = 12] = "Door",
t[t.FoodCrate = 13] = "FoodCrate",
t[t.WoodCrate = 14] = "WoodCrate",
t[t.StoneCrate = 15] = "StoneCrate",
t[t.Tower = 16] = "Tower",
t[t.Mannequin = 17] = "Mannequin",
t[t.Heartstone = 18] = "Heartstone",
t[t.Garden = 19] = "Garden",
t[t.PigSpawner = 20] = "PigSpawner",
t[t.ChickenSpawner = 21] = "ChickenSpawner",
t[t.WolfSpawner = 22] = "WolfSpawner",
t[t.BearSpawner = 23] = "BearSpawner",
t[t.EggPickup = 24] = "EggPickup",
t[t.PigMeatPickup = 25] = "PigMeatPickup",
t[t.BearMeatPickup = 26] = "BearMeatPickup",
t[t.CarrotPickup = 27] = "CarrotPickup",
t[t.BoxPickup = 28] = "BoxPickup",
t[t.FollowerBot = 29] = "FollowerBot",
t[t.GuardBot = 30] = "GuardBot",
t[t.FarmerBot = 31] = "FarmerBot",
t[t.GardenBot = 32] = "GardenBot",
t[t.WhiteBear = 33] = "WhiteBear",
t[t.WinterWoodGenerator = 34] = "WinterWoodGenerator",
t[t.WinterStoneGenerator = 35] = "WinterStoneGenerator",
t[t.WhiteBearSpawner = 36] = "WhiteBearSpawner",
t[t.SoccerBall = 37] = "SoccerBall",
t[t.FireballBullet = 38] = "FireballBullet",
t[t.NightmareBoss = 39] = "NightmareBoss",
t[t.WhiteWalker = 40] = "WhiteWalker",
t[t.WhiteWalkerSpawner = 41] = "WhiteWalkerSpawner",
t[t.WinterWall = 42] = "WinterWall",
t[t.WinterFloor = 43] = "WinterFloor",
t[t.WinterTower = 44] = "WinterTower",
t[t.WhiteBearHat = 45] = "WhiteBearHat",
t[t.BrownBearHat = 46] = "BrownBearHat",
t[t.ChessHat = 47] = "ChessHat",
t[t.CowboyHat = 48] = "CowboyHat",
t[t.HiddenHat = 49] = "HiddenHat",
t[t.CatHat = 50] = "CatHat",
t[t.CoinPickup = 51] = "CoinPickup",
t[t.ChickenHat = 52] = "ChickenHat",
t[t.WoodSpikes = 53] = "WoodSpikes",
t[t.Portal = 54] = "Portal",
t[t.BuilderHat = 55] = "BuilderHat",
t[t.FoxHat = 56] = "FoxHat",
t[t.VikingHat = 57] = "VikingHat",
t[t.HockeyHat = 58] = "HockeyHat",
t[t.SoulPickup = 59] = "SoulPickup",
t[t.SoulCrate = 60] = "SoulCrate",
t[t.DarkStoneBlock = 61] = "DarkStoneBlock",
t[t.DarkDoor = 62] = "DarkDoor",
t[t.RideableBear = 63] = "RideableBear",
t[t.DarkGuardBot = 64] = "DarkGuardBot",
t[t.TankHat = 65] = "TankHat",
t[t.DruidHat = 66] = "DruidHat",
t[t.IceHat = 67] = "IceHat"
}(h = t.EntityType || (t.EntityType = {}));
!function(t) {
t[t.WhiteBearHat = 0] = "WhiteBearHat",
t[t.BrownBearHat = 1] = "BrownBearHat",
t[t.ChessHat = 2] = "ChessHat",
t[t.CowboyHat = 3] = "CowboyHat",
t[t.HiddenHat = 4] = "HiddenHat",
t[t.CatHat = 5] = "CatHat",
t[t.ChickenHat = 6] = "ChickenHat",
t[t.BuilderHat = 7] = "BuilderHat",
t[t.FoxHat = 8] = "FoxHat",
t[t.HockeyHat = 9] = "HockeyHat",
t[t.VikingHat = 10] = "VikingHat",
t[t.TankHat = 11] = "TankHat",
t[t.DruidHat = 12] = "DruidHat",
t[t.IceHat = 13] = "IceHat"
}(t.HatType || (t.HatType = {}));
var l;
!function(t) {
t[t.WoodBlock = 0] = "WoodBlock",
t[t.StoneBlock = 1] = "StoneBlock",
t[t.Door = 2] = "Door",
t[t.FarmerBot = 3] = "FarmerBot",
t[t.GuardBot = 4] = "GuardBot",
t[t.FollowerBot = 5] = "FollowerBot",
t[t.Garden = 6] = "Garden",
t[t.Heartstone = 7] = "Heartstone",
t[t.Tower = 8] = "Tower",
t[t.FoodCrate = 9] = "FoodCrate",
t[t.WoodCrate = 10] = "WoodCrate",
t[t.StoneCrate = 11] = "StoneCrate",
t[t.Mannequin = 12] = "Mannequin",
t[t.RideableWolf = 13] = "RideableWolf",
t[t.GardenBot = 14] = "GardenBot",
t[t.SoccerBall = 15] = "SoccerBall",
t[t.WoodSpikes = 16] = "WoodSpikes",
t[t.Portal = 17] = "Portal",
t[t.SoulCrate = 18] = "SoulCrate",
t[t.DarkStoneBlock = 19] = "DarkStoneBlock",
t[t.DarkDoor = 20] = "DarkDoor",
t[t.RideableBear = 21] = "RideableBear",
t[t.DarkGuardBot = 22] = "DarkGuardBot"
}(l = t.BuildingType || (t.BuildingType = {})),
t.BuildingTypeToEntityType = e,
t.EntityTypeToBuildingType = s;
var c;
!function(t) {
t[t.Food = 0] = "Food",
t[t.Wood = 1] = "Wood",
t[t.Stone = 2] = "Stone",
t[t.Gold = 3] = "Gold",
t[t.Soul = 4] = "Soul"
}(c = t.ResourceType || (t.ResourceType = {})),
t.ParseResourceType = o;
var u;
!function(t) {
t[t.SyncObject = 0] = "SyncObject",
t[t.SyncObjectDelete = 1] = "SyncObjectDelete",
t[t.PlayerSpawnRequest = 2] = "PlayerSpawnRequest",
t[t.PlayerInput = 3] = "PlayerInput",
t[t.PlayerAction = 4] = "PlayerAction",
t[t.PlayerBuildRequest = 5] = "PlayerBuildRequest",
t[t.PlayerBuildResponse = 6] = "PlayerBuildResponse",
t[t.PlayerChatRequest = 7] = "PlayerChatRequest",
t[t.ObjectSendDamage = 8] = "ObjectSendDamage",
t[t.ObjectReceiveDamage = 9] = "ObjectReceiveDamage",
t[t.SyncBackpack = 10] = "SyncBackpack",
t[t.Ping = 11] = "Ping",
t[t.RequestServerInfo = 12] = "RequestServerInfo",
t[t.ResponseServerInfo = 13] = "ResponseServerInfo",
t[t.Assign = 14] = "Assign",
t[t.FloatResources = 15] = "FloatResources",
t[t.SyncChild = 16] = "SyncChild",
t[t.SyncChildDelete = 17] = "SyncChildDelete",
t[t.MapMessage = 18] = "MapMessage",
t[t.LeaderboardMessage = 19] = "LeaderboardMessage",
t[t.ChatMessage = 20] = "ChatMessage",
t[t.PlayerUnmountRequest = 21] = "PlayerUnmountRequest",
t[t.PlayerCheat = 22] = "PlayerCheat",
t[t.ForceDisconnect = 23] = "ForceDisconnect",
t[t.PlayerSetViewportSize = 24] = "PlayerSetViewportSize",
t[t.PackedMessage = 25] = "PackedMessage",
t[t.LeaderboardMessagePlayer = 26] = "LeaderboardMessagePlayer",
t[t.PlayerCreateTeam = 27] = "PlayerCreateTeam",
t[t.PlayerJoinTeam = 28] = "PlayerJoinTeam",
t[t.PlayerApproveRequest = 29] = "PlayerApproveRequest",
t[t.PlayerDeclineRequest = 30] = "PlayerDeclineRequest",
t[t.PlayerLeaveTeam = 31] = "PlayerLeaveTeam",
t[t.PlayerKickRequest = 32] = "PlayerKickRequest",
t[t.PlayerTeamMembersRequest = 33] = "PlayerTeamMembersRequest",
t[t.PlayerTeamMembersResponse = 34] = "PlayerTeamMembersResponse",
t[t.PlayerTeamListRequest = 35] = "PlayerTeamListRequest",
t[t.PlayerTeamListResponse = 36] = "PlayerTeamListResponse",
t[t.NotifyTeamCreated = 37] = "NotifyTeamCreated",
t[t.NotifyTeamRemoved = 38] = "NotifyTeamRemoved",
t[t.NotifyJoinRequestCreated = 39] = "NotifyJoinRequestCreated",
t[t.NotifyJoinRequestRemoved = 40] = "NotifyJoinRequestRemoved",
t[t.NotifyMemberJoin = 41] = "NotifyMemberJoin",
t[t.NotifyMemberLeave = 42] = "NotifyMemberLeave",
t[t.DayTimeMessage = 43] = "DayTimeMessage",
t[t.PlayerTeamPingRequest = 44] = "PlayerTeamPingRequest",
t[t.PlayerTeamPingResponse = 45] = "PlayerTeamPingResponse",
t[t.PlayerRequestDaytime = 46] = "PlayerRequestDaytime",
t[t.SyncHats = 47] = "SyncHats",
t[t.PlayerSelectHat = 48] = "PlayerSelectHat",
t[t.ServerVersion = 49] = "ServerVersion"
}(u = t.MessageType || (t.MessageType = {}));
var d = function() {
function t(t, e) {
this.type = t,
this.content = e
}
return t
}();
t.Message = d;
var p = {};
t.decode = r,
t.encode = a
}(e.Protocol || (e.Protocol = {}))
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(31)
, r = function() {
function t() {
this.serverRotation = 0,
this.clientRotation = 0,
this.updateTime = 0,
this.interpolationTime = .1
}
return t.prototype.updateFrame = function(t, e, i) {
this.serverRotation = e,
this.clientRotation = t,
this.updateTime = i
}
,
t.interpolateAngle = function(t, e, i, n) {
void 0 === n && (n = !0);
var s = n ? Math.PI : 180;
Math.abs(e - t) > s && (e > t ? t += 2 * s : e += 2 * s);
var o = t + (e - t) * i;
return o >= 0 && o <= 2 * s ? o : o % (2 * s)
}
,
t.prototype.interpolate = function(e, i) {
var n = e - this.updateTime
, s = n / (this.interpolationTime + i / 2);
return s = Phaser.Math.clamp(s, 0, 1),
t.interpolateAngle(this.clientRotation, this.serverRotation, s)
}
,
t
}();
e.RotationInterpolator = r;
var a = function() {
function t() {
this.serverPosition = new Phaser.Point,
this.clientPosition = new Phaser.Point,
this.updateTime = 0,
this.forceTeleportDistance = 500,
this.interpolationTime = .1
}
return t.prototype.updateFrame = function(t, e, i) {
this.serverPosition.copyFrom(e),
this.clientPosition.copyFrom(t),
this.updateTime = i
}
,
t.prototype.interpolate = function(t, e, i) {
if (this.clientPosition.distance(this.serverPosition) <
this.forceTeleportDistance) {
var n = e - this.updateTime
, s = n / (this.interpolationTime + i / 2);
s = Phaser.Math.clamp(s, 0, 1),
Phaser.Point.interpolate(this.clientPosition, this.serverPosition,
s, t)
} else
t.set(this.serverPosition.x, this.serverPosition.y)
}
,
t
}();
e.PositionInterpolator = a;
var h = function(t) {
function e(e, i) {
void 0 === e && (e = !0),
void 0 === i && (i = !0);
var n = t.call(this) || this;
return n.id = "networktransform",
n.rotationInterpolator = new r,
n.positionInterpolator = new a,
n.tmpNetworkPoint = new Phaser.Point,
n.interpolateRotation = !0,
n.interpolatePosition = !0,
n.interpolateRotation = i,
n.interpolatePosition = e,
n
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.cachedTransform = this.entity.components.transform,
this.cachedPingService = this.world.services.getService(o.default),
this.entity.on("networksync", this.onNetworkSync.bind(this))
}
,
e.prototype.onNetworkSync = function(t) {
t.hasOwnProperty("x") && this.interpolatePosition &&
(this.tmpNetworkPoint.set(t.x, t.y),
this.positionInterpolator.updateFrame(this.cachedTransform.position,
this.tmpNetworkPoint, this.world.game.time.totalElapsedSeconds())),
t.hasOwnProperty("rotation") && this.interpolateRotation &&
this.rotationInterpolator.updateFrame(this.cachedTransform.rotation, t.rotation,
this.world.game.time.totalElapsedSeconds())
}
,
e.prototype.update = function(t) {
this.interpolatePosition &&
this.positionInterpolator.interpolate(this.cachedTransform.position,
this.world.game.time.totalElapsedSeconds(),
this.cachedPingService.getAveragePing()),
this.interpolateRotation && (this.cachedTransform.rotation =
this.rotationInterpolator.interpolate(this.world.game.time.totalElapsedSeconds(),
this.cachedPingService.getAveragePing()))
}
,
e
}(s.Component);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e(e, i) {
var n = t.call(this) || this;
return n.position = new Phaser.Point,
n.rotation = 0,
n.id = "transform",
n.previousPosition = new Phaser.Point,
n.stayTime = 0,
e && n.position.copyFrom(e),
i && (n.rotation = i),
n
}
return n(e, t),
e.prototype.update = function(t) {
this.position.equals(this.previousPosition) ? this.stayTime += t :
this.stayTime = 0,
this.previousPosition.copyFrom(this.position)
}
,
e.prototype.isMoving = function() {
return this.stayTime < .2
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e(e, i, n) {
var s = t.call(this) || this;
return s.sync = !0,
s.id = "sprite",
s.color = 16777215,
s.sprite = e.create(0, 0, i),
s.sprite.anchor.copyFrom(n),
s.sprite.smoothed = !0,
s
}
return n(e, t),
e.prototype.start = function() {
this.cachedTransform = this.entity.components.transform
}
,
e.prototype.update = function(t) {
this.sync &&
(this.sprite.position.copyFrom(this.cachedTransform.position),
this.sprite.rotation = this.cachedTransform.rotation)
}
,
e.prototype.destroy = function() {
this.sprite.destroy()
}
,
e.prototype.jump = function(t) {
this.sync = !1,
this.sprite.position.y -= t;
var e = this.world.game.add.tween(this.sprite);
e.to({
y: this.sprite.position.y + 10
}, 250),
e.onComplete.add(this.onJumpTweenComplete, this),
e.start()
}
,
e.prototype.setColor = function(t) {
this.color = t,
this.sprite.tint = this.color
}
,
e.prototype.flashRed = function() {
this.sprite && (this.sprite.tint = 16751001,
this.world.game.time.events.add(.2 * Phaser.Timer.SECOND, function() {
this.sprite && (this.sprite.tint = this.color)
}, this))
}
,
e.prototype.onJumpTweenComplete = function() {
this.sync = !0
}
,
e
}(s.Component);
e.default = o
}
, function(t, e) {
function i() {
this._events = this._events || {},
this._maxListeners = this._maxListeners || void 0
}
function n(t) {
return "function" == typeof t
}
function s(t) {
return "number" == typeof t
}
function o(t) {
return "object" == typeof t && null !== t
}
function r(t) {
return void 0 === t
}
t.exports = i,
i.EventEmitter = i,
i.prototype._events = void 0,
i.prototype._maxListeners = void 0,
i.defaultMaxListeners = 10,
i.prototype.setMaxListeners = function(t) {
if (!s(t) || t < 0 || isNaN(t))
throw TypeError("n must be a positive number");
return this._maxListeners = t,
this
}
,
i.prototype.emit = function(t) {
var e, i, s, a, h, l;
if (this._events || (this._events = {}),
"error" === t && (!this._events.error || o(this._events.error) && !
this._events.error.length)) {
if ((e = arguments[1])instanceof Error)
throw e;
var c = new Error('Uncaught, unspecified "error" event. (' + e + ")");
throw c.context = e,
c
}
if (i = this._events[t],
r(i))
return !1;
if (n(i))
switch (arguments.length) {
case 1:
i.call(this);
break;
case 2:
i.call(this, arguments[1]);
break;
case 3:
i.call(this, arguments[1], arguments[2]);
break;
default:
a = Array.prototype.slice.call(arguments, 1),
i.apply(this, a)
}
else if (o(i))
for (a = Array.prototype.slice.call(arguments, 1),
l = i.slice(),
s = l.length,
h = 0; h < s; h++)
l[h].apply(this, a);
return !0
}
,
i.prototype.addListener = function(t, e) {
var s;
if (!n(e))
throw TypeError("listener must be a function");
return this._events || (this._events = {}),
this._events.newListener && this.emit("newListener", t, n(e.listener) ?
e.listener : e),
this._events[t] ? o(this._events[t]) ? this._events[t].push(e) :
this._events[t] = [this._events[t], e] : this._events[t] = e,
o(this._events[t]) && !this._events[t].warned && (s = r(this._maxListeners)
? i.defaultMaxListeners : this._maxListeners) && s > 0 && this._events[t].length >
s && (this._events[t].warned = !0,
console.error("(node) warning: possible EventEmitter memory leak detected.
%d listeners added. Use emitter.setMaxListeners() to increase limit.",
this._events[t].length),
"function" == typeof console.trace && console.trace()),
this
}
,
i.prototype.on = i.prototype.addListener,
i.prototype.once = function(t, e) {
function i() {
this.removeListener(t, i),
s || (s = !0,
e.apply(this, arguments))
}
if (!n(e))
throw TypeError("listener must be a function");
var s = !1;
return i.listener = e,
this.on(t, i),
this
}
,
i.prototype.removeListener = function(t, e) {
var i, s, r, a;
if (!n(e))
throw TypeError("listener must be a function");
if (!this._events || !this._events[t])
return this;
if (i = this._events[t],
r = i.length,
s = -1,
i === e || n(i.listener) && i.listener === e)
delete this._events[t],
this._events.removeListener && this.emit("removeListener", t, e);
else if (o(i)) {
for (a = r; a-- > 0; )
if (i[a] === e || i[a].listener && i[a].listener === e) {
s = a;
break
}
if (s < 0)
return this;
1 === i.length ? (i.length = 0,
delete this._events[t]) : i.splice(s, 1),
this._events.removeListener && this.emit("removeListener", t, e)
}
return this
}
,
i.prototype.removeAllListeners = function(t) {
var e, i;
if (!this._events)
return this;
if (!this._events.removeListener)
return 0 === arguments.length ? this._events = {} : this._events[t] &&
delete this._events[t],
this;
if (0 === arguments.length) {
for (e in this._events)
"removeListener" !== e && this.removeAllListeners(e);
return this.removeAllListeners("removeListener"),
this._events = {},
this
}
if (i = this._events[t],
n(i))
this.removeListener(t, i);
else if (i)
for (; i.length; )
this.removeListener(t, i[i.length - 1]);
return delete this._events[t],
this
}
,
i.prototype.listeners = function(t) {
return this._events && this._events[t] ? n(this._events[t]) ?
[this._events[t]] : this._events[t].slice() : []
}
,
i.prototype.listenerCount = function(t) {
if (this._events) {
var e = this._events[t];
if (n(e))
return 1;
if (e)
return e.length
}
return 0
}
,
i.listenerCount = function(t, e) {
return t.listenerCount(e)
}
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e() {
var e = t.call(this) || this;
return e.id = "animator",
e
}
return n(e, t),
e.prototype.start = function() {
this.cachedSpriteComponent = this.entity.components.sprite,
this.cachedTransform = this.entity.components.transform
}
,
e.prototype.addAnimation = function(t, e, i, n) {
return void 0 === n && (n = !1),
this.cachedSpriteComponent.sprite.animations.add(t, e, i, n)
}
,
e.prototype.play = function(t) {
this.cachedSpriteComponent.sprite.animations.play(t)
}
,
e.prototype.getCurrentName = function() {
return this.cachedSpriteComponent.sprite.animations.name
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.EntityTypeToBuildingType
, a = i(10)
, h = function() {
function t(t, e, i) {
this.id = t,
this.objectType = e,
this.position = i
}
return t
}()
, l = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.childs = [],
i.typeCounts = {},
i
}
return n(e, t),
e.prototype.onCreateChild = function(t) {
var e = t.content.objectType;
this.childs.push(new h(t.content.id,e,new
Phaser.Point(t.content.x,t.content.y))),
this.typeCounts.hasOwnProperty(e) ? this.typeCounts[e]++ :
this.typeCounts[e] = 1,
this.world.services.getService(a.CraftMenuService).updateLimit(r(e),
this.typeCounts[e])
}
,
e.prototype.onRemoveChild = function(t) {
for (var e = t.content.id, i = t.content.objectType, n = 0; n <
this.childs.length; n++)
if (this.childs[n].id === e) {
this.typeCounts[i]--,
this.childs.splice(n, 1);
break
}
this.world.services.getService(a.CraftMenuService).updateLimit(r(i),
this.typeCounts[i])
}
,
e.prototype.getCountForType = function(t) {
return this.typeCounts.hasOwnProperty(t.toString()) ?
this.typeCounts[t] : 0
}
,
e.prototype.cleanup = function() {
this.childs = [],
this.typeCounts = {},
this.world.services.getService(a.CraftMenuService).updateAllLimits()
}
,
e
}(s.Service);
e.default = l
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(2)
, r = i(15)
, a = i(3)
, h = a.Protocol.BuildingType
, l = i(9)
, c = a.Protocol.BuildingTypeToEntityType
, u = function() {
function t(t, e) {
this.name = t,
this.element = document.createElement("div"),
this.element.className = "item",
this.element.onclick = this.onClick.bind(this),
this.element.id = t,
e && (this.key =
Phaser.GAMES[0].input.keyboard.addKey(Phaser.Keyboard[e]),
this.key.onDown.add(this.onClick, this))
}
return t.prototype.action = function() {}
,
t.prototype.onClick = function() {
this.action()
}
,
t.prototype.destroy = function() {
this.key && (this.key.onDown.remove(this.onClick, this),
this.key = null),
this.element = null
}
,
t.prototype.updateAvailability = function(t) {
this.element && (this.element.classList.remove("available"),
this.element.classList.remove("unavailable"),
this.element.classList.add(t ? "available" : "unavailable"))
}
,
t
}();
e.MenuItem = u;
var d = function() {
function t() {
this.items = []
}
return t.prototype.appendChild = function(t) {
this.element.appendChild(t.element),
this.items.push(t)
}
,
t.prototype.destroy = function() {
for (var t = 0, e = this.items; t < e.length; t++) {
e[t].destroy()
}
this.items = []
}
,
t
}();
e.MenuContainer = d;
var p = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.element = document.getElementById("bottom-panel"),
i
}
return n(e, t),
e.prototype.appendMany = function(t, e) {
for (var i = [], n = 0, s = e; n < s.length; n++) {
var o = s[n]
, r = new
g(t,o.img,o.name,o.hotKey,o.hotKeyDisplay,o.tooltip,o.maxLimit);
this.appendChild(r),
i.push(r)
}
return i
}
,
e
}(d)
, f = function(t) {
function e(e, i) {
var n = t.call(this) || this;
return n.world = i,
n.element = document.getElementById("left-panel"),
n
}
return n(e, t),
e.prototype.appendMany = function(t, e) {
for (var i = [], n = 0, s = e; n < s.length; n++) {
var o = s[n]
, r = new
m(t,o.img,o.name,o.hotKey,o.hotKeyDisplay,o.tooltip,o.maxLimit);
this.appendChild(r),
i.push(r)
}
return i
}
,
e.prototype.pushRecently = function(t) {
for (var e = this.world.services.getService(l.default), i = 0; i <
this.items.length; i++)
if (this.items[i].name === t.name)
return;
for (var i = 0; i < this.items.length; i++) {
var n = void 0;
n = i === this.items.length - 1 ? t : this.items[i + 1],
this.items[i].reInit(n.getImage(), n.name,
this.items[i].getHotKey(),
Phaser.GAMES[0].state.getCurrentState().services.getService(b).getTooltipFor(n.name
),
Phaser.GAMES[0].state.getCurrentState().services.getService(b).getMaxLimit(n.name))
,
this.items[i].updateLimit(e.getCountForType(c(n.name)))
}
}
,
e
}(d)
, m = function(t) {
function e(e, i, n, s, o, r, a) {
var h = t.call(this, n, s) || this;
return h.img = i,
h.hotKey = s,
h.world = e,
h.maxLimit = a,
h.element.className = "ui-tooltip item",
h.element.innerHTML = '\n <div class="ui-tooltip-content ui-
tooltip-right">\n ' + r + '\n </div>\n <img
src="' + i + '" />\n <div class="hotkey" id="' + n + ':hotkey">' + o +
"</div>\n ",
h.limit = document.createElement("div"),
h.limit.className = "limit",
h.limit.innerHTML = "0/" + a,
h.element.appendChild(h.limit),
h
}
return n(e, t),
e.prototype.getImage = function() {
return this.img
}
,
e.prototype.getHotKey = function() {
return this.hotKey
}
,
e.prototype.reInit = function(t, e, i, n, s) {
this.name = e,
this.img = t,
this.maxLimit = s,
this.element.className = "ui-tooltip item",
this.element.innerHTML = '\n <div class="ui-tooltip-content
ui-tooltip-right">\n ' + n + '\n </div>\n <img
src="' + t + '" />\n <div class="hotkey" id="' + e + ':hotkey">' + i +
"</div>\n ",
this.limit = document.createElement("div"),
this.limit.className = "limit",
this.limit.innerHTML = "0/" + s,
this.element.appendChild(this.limit)
}
,
e.prototype.updateLimit = function(t) {
this.limit.innerText = t + "/" + this.maxLimit
}
,
e.prototype.onClick = function() {
t.prototype.onClick.call(this)
}
,
e.prototype.action = function() {
this.world.services.getService(r.default).requestWork(this.name)
}
,
e
}(u)
, g = function(t) {
function e(e, i, n, s, o, r, a) {
var h = t.call(this, n, s) || this;
return h.world = e,
h.maxLimit = a,
h.element.className = "ui-tooltip item",
h.element.innerHTML = '\n <div class="ui-tooltip-content ui-
tooltip-up">\n ' + r + '\n </div>\n <img
src="' + i + '" />\n <div class="hotkey" id="' + n + ':hotkey">' + o +
"</div>\n ",
h.limit = document.createElement("div"),
h.limit.className = "limit",
h.limit.innerHTML = "0/" + a,
h.element.appendChild(h.limit),
h
}
return n(e, t),
e.prototype.updateLimit = function(t) {
this.limit.innerText = t + "/" + this.maxLimit
}
,
e.prototype.onClick = function() {
t.prototype.onClick.call(this)
}
,
e.prototype.action = function() {
this.world.services.getService(r.default).requestWork(this.name)
}
,
e
}(u)
, y = function(t) {
function e(e, i, n, s, o, r, a, h, l) {
var c = t.call(this, n, s) || this;
return c.img = i,
c.world = e,
c.maxLimit = r,
c.element.className = "shop-item",
c.element.innerHTML = '\n <div class="price">' + l +
'</div>\n <div class="icon">\n <img width="48px"
height="48px" src="' + i + '"/>\n </div>\n <div
class="content">\n <div class="content-name">' + a + ' <span id="n' + n
+ '_building_price">0/' + r + '</span></div>\n <div class="content-
description">' + h + "</div>\n </div>\n ",
c
}
return n(e, t),
e.prototype.getImage = function() {
return this.img
}
,
e.prototype.updateLimit = function(t) {
this.limit || (this.limit = document.getElementById("n" + this.name +
"_building_price")),
this.limit.innerText = t + "/" + this.maxLimit
}
,
e.prototype.onClick = function() {
t.prototype.onClick.call(this)
}
,
e.prototype.action = function() {
this.world.services.getService(r.default).requestWork(this.name),
this.world.services.getService(b).recentlyUsed(this)
}
,
e
}(u)
, v = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.parentElement = document.getElementById("shop"),
i.element = document.getElementById("shop-list"),
i.key = Phaser.GAMES[0].input.keyboard.addKey(Phaser.KeyCode.ESC),
i.key.onDown.add(i.hide, i),
document.addEventListener("click", function(t) {
"block" === this.parentElement.style.display && (t.target ===
this.element || "shop-show" === t.target.id || t.target.parentElement && "shop-
show" === t.target.parentElement.id || this.hide())
}
.bind(i)),
i.hide(),
i
}
return n(e, t),
e.prototype.appendMany = function(t, e) {
for (var i = [], n = 0, s = e; n < s.length; n++) {
var o = s[n]
, r = new
y(t.world,o.img,o.name,o.hotKey,o.hotKeyDisplay,t.getMaxLimit(o.name),t.getDisplayN
ameFor(o.name),t.getDisplayDescription(o.name),t.getDisplayPriceFor(o.name));
this.appendChild(r),
i.push(r)
}
return $("shop-list").scrollTop(0),
i
}
,
e.prototype.toggle = function() {
"block" === this.parentElement.style.display ? this.hide() :
this.show()
}
,
e.prototype.show = function() {
this.parentElement.style.display = "block"
}
,
e.prototype.hide = function() {
this.parentElement.style.display = "none"
}
,
e.prototype.destroy = function() {
t.prototype.destroy.call(this),
this.key.onDown.remove(this.hide, this),
this.key = null
}
,
e
}(d)
, b = function(t) {
function e(e) {
var i = t.call(this, e) || this;
i.menuItems = [],
i.bottomMenu = new p("bottom-panel"),
i.menuItems = i.bottomMenu.appendMany(i.world, [{
img: o.Images.ImagesWoodwall.getPNG(),
name: h.WoodBlock,
hotKey: "ONE",
hotKeyDisplay: "1",
tooltip: i.getTooltipFor(h.WoodBlock),
maxLimit: Config.buildings[h[h.WoodBlock].toLowerCase()].limit
}, {
img: o.Images.ImagesStonewall.getPNG(),
name: h.StoneBlock,
hotKey: "TWO",
hotKeyDisplay: "2",
tooltip: i.getTooltipFor(h.StoneBlock),
maxLimit: Config.buildings[h[h.StoneBlock].toLowerCase()].limit
}, {
img: o.Images.ImagesDoor.getPNG(),
name: h.Door,
hotKey: "THREE",
hotKeyDisplay: "3",
tooltip: i.getTooltipFor(h.Door),
maxLimit: Config.buildings[h[h.Door].toLowerCase()].limit
}, {
img: o.Images.ImagesGardener.getPNG(),
name: h.FarmerBot,
hotKey: "FOUR",
hotKeyDisplay: "4",
tooltip: i.getTooltipFor(h.FarmerBot),
maxLimit: Config.buildings[h[h.FarmerBot].toLowerCase()].limit
}, {
img: o.Images.ImagesGarden.getPNG(),
name: h.Garden,
hotKey: "FIVE",
hotKeyDisplay: "5",
tooltip: i.getTooltipFor(h.Garden),
maxLimit: Config.buildings[h[h.Garden].toLowerCase()].limit
}, {
img: o.Images.ImagesGuard.getPNG(),
name: h.GuardBot,
hotKey: "SIX",
hotKeyDisplay: "6",
tooltip: i.getTooltipFor(h.GuardBot),
maxLimit: Config.buildings[h[h.GuardBot].toLowerCase()].limit
}, {
img: o.Images.ImagesFollower.getPNG(),
name: h.FollowerBot,
hotKey: "SEVEN",
hotKeyDisplay: "7",
tooltip: i.getTooltipFor(h.FollowerBot),
maxLimit: Config.buildings[h[h.FollowerBot].toLowerCase()].limit
}, {
img: o.Images.ImagesHeartstone.getPNG(),
name: h.Heartstone,
hotKey: "EIGHT",
hotKeyDisplay: "8",
tooltip: i.getTooltipFor(h.Heartstone),
maxLimit: Config.buildings[h[h.Heartstone].toLowerCase()].limit
}, {
img: o.Images.ImagesTower.getPNG(),
name: h.Tower,
hotKey: "NINE",
hotKeyDisplay: "9",
tooltip: i.getTooltipFor(h.Tower),
maxLimit: Config.buildings[h[h.Tower].toLowerCase()].limit
}]),
i.recentlyMenu = new f("left-panel",i.world);
var n = i.recentlyMenu.appendMany(i.world, [{
img: o.Images.ImagesFoodcrate.getPNG(),
name: h.FoodCrate,
hotKey: "Z",
hotKeyDisplay: "Z",
tooltip: i.getTooltipFor(h.FoodCrate),
maxLimit: Config.buildings[h[h.FoodCrate].toLowerCase()].limit
}, {
img: o.Images.ImagesWoodcrate.getPNG(),
name: h.WoodCrate,
hotKey: "X",
hotKeyDisplay: "X",
tooltip: i.getTooltipFor(h.WoodCrate),
maxLimit: Config.buildings[h[h.WoodCrate].toLowerCase()].limit
}, {
img: o.Images.ImagesStonecrate.getPNG(),
name: h.StoneCrate,
hotKey: "C",
hotKeyDisplay: "C",
tooltip: i.getTooltipFor(h.StoneCrate),
maxLimit: Config.buildings[h[h.StoneCrate].toLowerCase()].limit
}]);
i.shopMenu = new v("shop");
var s = i.shopMenu.appendMany(i, [{
img: o.Images.ImagesFoodcrate.getPNG(),
name: h.FoodCrate,
tooltip: i.getTooltipFor(h.FoodCrate),
maxLimit: Config.buildings[h[h.FoodCrate].toLowerCase()].limit
}, {
img: o.Images.ImagesWoodcrate.getPNG(),
name: h.WoodCrate,
tooltip: i.getTooltipFor(h.WoodCrate),
maxLimit: Config.buildings[h[h.WoodCrate].toLowerCase()].limit
}, {
img: o.Images.ImagesStonecrate.getPNG(),
name: h.StoneCrate,
tooltip: i.getTooltipFor(h.StoneCrate),
maxLimit: Config.buildings[h[h.StoneCrate].toLowerCase()].limit
}, {
img: o.Images.ImagesWoodspikes.getPNG(),
name: h.WoodSpikes,
tooltip: i.getTooltipFor(h.WoodSpikes),
maxLimit: Config.buildings[h[h.WoodSpikes].toLowerCase()].limit
}, {
img: o.Images.ImagesCarwolf.getPNG(),
name: h.RideableWolf,
tooltip: i.getTooltipFor(h.RideableWolf),
maxLimit: Config.buildings[h[h.RideableWolf].toLowerCase()].limit
}, {
img: o.Images.ImagesPickupbot.getPNG(),
name: h.GardenBot,
tooltip: i.getTooltipFor(h.GardenBot),
maxLimit: Config.buildings[h[h.GardenBot].toLowerCase()].limit
}, {
img: o.Images.ImagesMannequin.getPNG(),
name: h.Mannequin,
tooltip: i.getTooltipFor(h.Mannequin),
maxLimit: Config.buildings[h[h.Mannequin].toLowerCase()].limit
}, {
img: o.Images.ImagesRideablebear.getPNG(),
name: h.RideableBear,
tooltip: i.getTooltipFor(h.RideableBear),
maxLimit: Config.buildings[h[h.RideableBear].toLowerCase()].limit
}, {
img: o.Images.ImagesSoccerball.getPNG(),
name: h.SoccerBall,
tooltip: i.getTooltipFor(h.SoccerBall),
maxLimit: Config.buildings[h[h.SoccerBall].toLowerCase()].limit
}]);
return i.menuItems = i.menuItems.concat(n),
i.menuItems = i.menuItems.concat(s),
i.updateAvailability(),
i
}
return n(e, t),
e.prototype.getTooltipFor = function(t) {
for (var e = "", i = Config.buildings[h[t].toLowerCase()], n = 0, s =
Object.keys(i.price); n < s.length; n++) {
var o = s[n];
e += '<div class="ui-tooltip-costs"><span>' +
(o.charAt(0).toUpperCase() + o.slice(1)) + ": </span><span>" + i.price[o] +
"</span></div>"
}
return '\n <div class="ui-tooltip-header">' + i.name +
"</div>\n <span>" + i.description + "</span>\n " + e + "\n
"
}
,
e.prototype.getDisplayPriceFor = function(t) {
for (var e = "", i = Config.buildings[h[t].toLowerCase()], n = 0, s =
Object.keys(i.price); n < s.length; n++) {
var o = s[n];
e += "<div>" + (o.charAt(0).toUpperCase() + o.slice(1)) + ": " +
i.price[o] + "</div>"
}
return e
}
,
e.prototype.getMaxLimit = function(t) {
return Config.buildings[h[t].toLowerCase()].limit
}
,
e.prototype.getDisplayNameFor = function(t) {
return Config.buildings[h[t].toLowerCase()].name
}
,
e.prototype.getDisplayDescription = function(t) {
return Config.buildings[h[t].toLowerCase()].description
}
,
e.prototype.recentlyUsed = function(t) {
this.shopMenu.hide(),
this.recentlyMenu.pushRecently(t)
}
,
e.prototype.updateAvailability = function() {
for (var t = this.world.services.getService(r.default), e = 0, i =
this.menuItems; e < i.length; e++) {
var n = i[e];
n.updateAvailability(t.canBuild(n.name))
}
}
,
e.prototype.updateLimit = function(t, e) {
for (var i = this.world.services.getService(r.default), n = 0, s =
this.menuItems; n < s.length; n++) {
var o = s[n];
o.name === t && (o.updateLimit(e),
o.updateAvailability(i.canBuild(o.name)))
}
}
,
e.prototype.updateAllLimits = function() {
for (var t = this.world.services.getService(l.default), e = 0, i =
this.menuItems; e < i.length; e++) {
var n = i[e];
n.updateLimit(t.getCountForType(c(n.name)))
}
}
,
e.prototype.cleanup = function() {
this.updateAvailability()
}
,
e
}(s.Service);
e.CraftMenuService = b
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function() {
function t(t, e, i, n) {
this.width = 120,
this.height = 10,
this.borderwidth = 1,
this.borderheight = 1,
this.bgcolor = "#ffffff",
this.fgcolor = "#aa0000",
this.offset = 10,
this.alpha = .5,
this.game = t,
this.group = e;
var s = this.game.add.bitmapData(this.width, this.height);
s.ctx.beginPath(),
s.ctx.rect(0, 0, this.width, this.height),
s.ctx.fillStyle = this.bgcolor,
s.ctx.fill(),
this.bitmap1 = s,
this.total = e.create(i, n, s),
this.total.alpha = this.alpha,
this.total.anchor.set(.5, .5),
s = this.game.add.bitmapData(this.width - 2 * this.borderwidth,
this.height - 2 * this.borderheight),
s.ctx.beginPath(),
s.ctx.rect(0, 0, this.width - 2 * this.borderwidth, this.height - 2 *
this.borderheight),
s.ctx.fillStyle = this.fgcolor,
s.ctx.fill(),
this.bitmap2 = s,
this.current = e.create(i, n, s),
this.current.alpha = this.alpha,
this.current.anchor.set(0, .5),
this.croprect = new Phaser.Rectangle(0,0,s.width,s.height),
this.totalcrop = s.width,
this.current.cropRect = this.croprect
}
return t.prototype.setposition = function(t, e) {
this.current.position.x = t - this.totalcrop / 2,
this.current.position.y = e + this.height / 2 + this.offset,
this.total.position.x = t,
this.total.position.y = e + this.height / 2 + this.offset
}
,
t.prototype.fill = function(t) {
this.croprect.width = t * this.totalcrop,
this.current.updateCrop()
}
,
t.prototype.destroy = function() {
this.current.destroy(),
this.total.destroy(),
this.bitmap1.destroy(),
this.bitmap2.destroy()
}
,
t
}();
e.Healthbar = o;
var r = function(t) {
function e(e) {
void 0 === e && (e = 0);
var i = t.call(this) || this;
return i.health = 1,
i.maxHealth = 1,
i.offset = e,
i
}
return n(e, t),
e.prototype.start = function() {
this.cachedTransform = this.entity.components.transform,
this.cachedSprite = this.entity.components.sprite,
this.bar = new
o(this.world.game,this.world.LAYER_UI,this.cachedTransform.position.x,this.cachedTr
ansform.position.y),
this.bar.fill(1),
this.entity.on("networksync", this.onNetworkSync.bind(this))
}
,
e.prototype.onNetworkSync = function(t) {
t.hasOwnProperty("health") && (this.health = t.health),
t.hasOwnProperty("maxHealth") && (this.maxHealth = t.maxHealth),
this.bar.fill(this.health / this.maxHealth)
}
,
e.prototype.update = function(t) {
var e = this.cachedTransform.position.x
, i = this.cachedTransform.position.y - this.offset +
this.cachedSprite.sprite.height / 2;
this.bar.setposition(e, i)
}
,
e.prototype.destroy = function() {
this.bar.destroy()
}
,
e
}(s.Component);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(8)
, o = function(t) {
function e() {
var e = t.call(this) || this;
return e.transportId = -1,
e
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.entity.on("networksync", this.onNetworkSync.bind(this)),
this.entity.on("senddamage", this.onSendDamage.bind(this)),
this.addAnimation("walk", Phaser.Animation.generateFrameNames("walk",
1, 16, ".png", 0), 30, !0),
this.addAnimation("pigwalk", ["onpig.png"], 15, !0),
this.addAnimation("punch", Phaser.Animation.generateFrameNames("hit",
1, 10, ".png", 0), 40, !1).onComplete.add(function() {
this.walk()
}
.bind(this)),
this.addAnimation("pigpunch",
Phaser.Animation.generateFrameNames("pighit", 1, 8, ".png", 0), 30, !
1).onComplete.add(function() {
this.walk()
}
.bind(this)),
this.walk()
}
,
e.prototype.onNetworkSync = function(t) {
t.hasOwnProperty("transportId") && (this.transportId = t.transportId)
}
,
e.prototype.walk = function() {
this.transportId > -1 ? this.play("pigwalk") : this.play("walk")
}
,
e.prototype.onSendDamage = function(t) {
this.transportId > -1 ? this.play("pigpunch") : this.play("punch")
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
"punch" !== this.getCurrentName() && "pigpunch" !==
this.getCurrentName() && (this.cachedTransform.isMoving() ? this.walk() :
this.cachedSpriteComponent.sprite.animations.stop())
}
,
e.prototype.destroy = function() {}
,
e
}(s.default);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {
this.cachedSpriteComponent = this.entity.components.sprite,
this.entity.on("receivedamage", this.onReceiveDamage.bind(this))
}
,
e.prototype.onReceiveDamage = function(t) {
this.cachedSpriteComponent.flashRed()
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(35)
, s = i(189)
, o = function() {
function t() {}
return t.init = function(e) {
s.default.call("/ip", function(i) {
t.IP = i.ip,
t.PORT = i.port,
e()
})
}
,
t.getHostAddress = function() {
var e = n.UrlParse.getUrlParameterByName("ip");
return e ? "ws://" + e : "ws://" + t.IP + ":" + t.PORT
}
,
t.getHostAddressRaw = function() {
var e = n.UrlParse.getUrlParameterByName("ip");
return e ? "" + e : t.IP + ":" + t.PORT
}
,
t.getNearestServer = function() {
return new Promise(function(e, i) {
$.ajax("http://status.glor.io").done(function(n) {
for (var s = {}, o = 0, r = n; o < r.length; o++) {
var a = r[o];
if (a.status) {
var h = a.name.split("-")[0];
h = h.charAt(0).toUpperCase() + h.slice(1),
s.hasOwnProperty(h) || (s[h] = []),
s[h].push(a.host)
}
}
for (var l = [], c = 0, u = Object.keys(s); c < u.length; c++)
{
var h = u[c];
if (s[h].length > 0) {
var d = t.ping("http://" + s[h][0] + "/ip", h, .3);
l.push(d)
}
}
t.successRace(l).then(function(t) {
console.log("Nearest server in " + t.city + " with ping " +
t.delta + "ms");
var i = s[t.city]
, n = i[Math.floor(Math.random() * i.length)];
e(n)
}).catch(function(t) {
i("All promises unresolved")
})
}).fail(function() {
i("Can't connect to status.glor.io")
})
}
)
}
,
t.successRace = function(t) {
return Promise.all(t.map(function(t) {
return t.then(function(t) {
return Promise.reject(t)
}, function(t) {
return Promise.resolve(t)
})
})).then(function(t) {
return Promise.reject(t)
}, function(t) {
return Promise.resolve(t)
})
}
,
t.request_image = function(t) {
return new Promise(function(e, i) {
var n = new Image;
n.onload = function() {
e(n)
}
,
n.onerror = function() {
i(t)
}
,
n.src = t + "?random-no-cache=" + Math.floor(65536 * (1 +
Math.random())).toString(16)
}
)
}
,
t.ping = function(e, i, n) {
return new Promise(function(s, o) {
var r = (new Date).getTime()
, a = function() {
var t = (new Date).getTime() - r;
t *= n || 1,
s({
city: i,
delta: t
})
};
t.request_image(e).then(a).catch(a),
setTimeout(function() {
o(Error("Timeout"))
}, 3e3)
}
)
}
,
t
}();
o.IP = "127.0.0.1",
o.PORT = "5000",
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(2)
, r = i(32)
, a = i(9)
, h = i(3)
, l = h.Protocol.BuildingType
, c = h.Protocol.BuildingTypeToEntityType
, u = i(29)
, d = h.Protocol.MessageType;
e.BuildingDefinitions = {
WoodBlock: {
icon: o.Images.ImagesWoodwall.getPNG(),
spriteName: o.Images.ImagesWoodwall.getName(),
scale: 1
},
StoneBlock: {
icon: o.Images.ImagesStonewall.getPNG(),
spriteName: o.Images.ImagesStonewall.getName(),
scale: 1
},
DarkStoneBlock: {
icon: o.Images.ImagesDarkstonewall.getPNG(),
spriteName: o.Images.ImagesDarkstonewall.getName(),
scale: 1
},
Garden: {
icon: o.Images.ImagesGarden.getPNG(),
spriteName: o.Images.ImagesGarden.getName(),
scale: 1
},
Tower: {
icon: o.Images.ImagesTower.getPNG(),
spriteName: o.Images.ImagesTower.getName(),
scale: 1
},
Heartstone: {
icon: o.Images.ImagesHeartstone.getPNG(),
spriteName: o.Images.ImagesHeartstone.getName(),
scale: 1
},
GuardBot: {
icon: o.Images.ImagesGuard.getPNG(),
spriteName: o.Images.ImagesGuard.getName(),
scale: .7
},
DarkGuardBot: {
icon: o.Images.ImagesDarkguard.getPNG(),
spriteName: o.Images.ImagesDarkguard.getName(),
scale: .7
},
FollowerBot: {
icon: o.Images.ImagesFollower.getPNG(),
spriteName: o.Images.ImagesFollower.getName(),
scale: .7
},
FarmerBot: {
icon: o.Images.ImagesGardener.getPNG(),
spriteName: o.Images.ImagesGardener.getName(),
scale: .7
},
GardenBot: {
icon: o.Images.ImagesPickupbot.getPNG(),
spriteName: o.Images.ImagesPickupbot.getName(),
scale: .7
},
Door: {
icon: o.Images.ImagesDoor.getPNG(),
spriteName: o.Images.ImagesDoor.getName(),
scale: 1
},
DarkDoor: {
icon: o.Images.ImagesDarkdoor.getPNG(),
spriteName: o.Images.ImagesDarkdoor.getName(),
scale: 1
},
FoodCrate: {
icon: o.Images.ImagesFoodcrate.getPNG(),
spriteName: o.Images.ImagesFoodcrate.getName(),
scale: 1
},
WoodCrate: {
icon: o.Images.ImagesWoodcrate.getPNG(),
spriteName: o.Images.ImagesWoodcrate.getName(),
scale: 1
},
StoneCrate: {
icon: o.Images.ImagesStonecrate.getPNG(),
spriteName: o.Images.ImagesStonecrate.getName(),
scale: 1
},
RideableWolf: {
icon: o.Images.ImagesCarwolf.getPNG(),
spriteName: o.Images.ImagesCarwolf.getName(),
scale: 1
},
RideableBear: {
icon: o.Images.ImagesRideablebear.getPNG(),
spriteName: o.Images.ImagesRideablebear.getName(),
scale: 1
},
Mannequin: {
icon: o.Images.ImagesMannequin.getPNG(),
spriteName: o.Images.ImagesMannequin.getName(),
scale: 1
},
SoccerBall: {
icon: o.Images.ImagesSoccerball.getPNG(),
spriteName: o.Images.ImagesSoccerball.getName(),
scale: 1
},
WoodSpikes: {
icon: o.Images.ImagesWoodspikes.getPNG(),
spriteName: o.Images.ImagesWoodspikes.getName(),
scale: 1
},
Portal: {
icon: o.Images.ImagesPortal.getPNG(),
spriteName: o.Images.ImagesPortal.getName(),
scale: 1
}
};
var p = function(t) {
function i(e) {
var i = t.call(this, e) || this;
return i.currentBuildingId = null,
i.currentBuildingSprite = null,
i.world.game.input.onDown.add(i.onMouseDown, i),
i.currentBuildingPosition = new Phaser.Point(0,0),
i.escapeKey = i.world.game.input.keyboard.addKey(Phaser.Keyboard.ESC),
i
}
return n(i, t),
i.prototype.inProgress = function() {
return null != this.currentBuildingSprite
}
,
i.prototype.onMouseDown = function(t) {
if (this.inProgress()) {
var e = this.world.game.input.activePointer.leftButton.isDown
, i = this.world.game.input.activePointer.rightButton.isDown;
e ? this.commitBuild() : i && this.cancelBuild()
}
}
,
i.prototype.requestWork = function(t) {
this.inProgress() ? this.cancelBuild() : this.canBuild(t) &&
this.startBuild(t)
}
,
i.prototype.startBuild = function(t) {
this.currentBuildingId = t,
this.currentBuildingSprite =
this.world.LAYER_FOREGROUND_0.create(this.world.game.input.activePointer.worldX,
this.world.game.input.activePointer.worldY,
e.BuildingDefinitions[l[t]].spriteName);
var i = e.BuildingDefinitions[l[t]].scale;
this.currentBuildingSprite.scale.set(i, i),
this.currentBuildingSprite.tint = 16751001,
this.currentBuildingSprite.anchor.set(.5, .5)
}
,
i.prototype.canBuild = function(t) {
var e = l[t].toLowerCase()
, i = Config.buildings[e].price
, n = Config.buildings[e].limit
, s = this.world.services.getService(r.default)
, o = this.world.services.getService(a.default);
return s.hasResources(i) && o.getCountForType(c(t)) < n
}
,
i.prototype.update = function(t) {
if (this.inProgress()) {
var e = this.world.assignedObject.components.transform.position;
this.currentBuildingPosition.x =
this.world.game.input.activePointer.worldX,
this.currentBuildingPosition.y =
this.world.game.input.activePointer.worldY,
this.currentBuildingPosition.x = this.currentBuildingPosition.x -
e.x,
this.currentBuildingPosition.y = this.currentBuildingPosition.y -
e.y;
var i = this.currentBuildingPosition.getMagnitude();
i > Config.client.build_radius && (i = Config.client.build_radius),
this.currentBuildingPosition.normalize(),
this.currentBuildingPosition.multiply(i, i),
this.currentBuildingPosition.add(e.x, e.y);
var n = this.world.services.getService(u.default).tileWidth
, s = this.world.services.getService(u.default).tileHeight
, o = n / 2
, r = s / 2;
Config.buildings[l[this.currentBuildingId].toLowerCase()].radius ||
Config.buildings[l[this.currentBuildingId].toLowerCase()].subtile ?
(this.currentBuildingPosition.x = Math.floor(this.currentBuildingPosition.x / o) *
o,
this.currentBuildingPosition.y =
Math.floor(this.currentBuildingPosition.y / r) * r) :
(this.currentBuildingPosition.x = Math.floor(this.currentBuildingPosition.x / n) *
n + o,
this.currentBuildingPosition.y =
Math.floor(this.currentBuildingPosition.y / s) * s + r),

this.currentBuildingSprite.position.copyFrom(this.currentBuildingPosition),
this.escapeKey.isDown && this.cancelBuild()
}
}
,
i.prototype.commitBuild = function() {
this.world.socket.sendMessage(d.PlayerBuildRequest, {
buildingType: this.currentBuildingId,
x: this.currentBuildingPosition.x,
y: this.currentBuildingPosition.y
}),
this.world.assignedObject &&
this.world.assignedObject.components.networkinput &&
this.world.assignedObject.components.networkinput.lockPunchUntilMouseUp()
}
,
i.prototype.cancelBuild = function() {
this.currentBuildingSprite && (this.currentBuildingSprite.destroy(),
this.currentBuildingSprite = null)
}
,
i.prototype.onBuildResponse = function(t) {
t.success && this.commitBuild()
}
,
i.prototype.destroy = function() {
this.cancelBuild(),
this.world.game.input.onDown.remove(this.onMouseDown, this)
}
,
i
}(s.Service);
e.default = p
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.MessageType
, a = i(7)
, h = o.Protocol.HatType
, l = i(2)
, c = i(17)
, u = function(t) {
function e(i, n) {
var s = t.call(this) || this;
return s.hatType = i,
s.element = document.createElement("div"),
s.element.className = n ? "ui-hat-list-item is-active" : "ui-hat-list-
item is-aviable",
s.element.innerHTML = '\n <div class="ui-hat-image">\n
<img src="' + e.getHatSprite(i) + '" />\n </div>\n ',
n || (s.element.onclick = function() {
this.emit("wear")
}
.bind(s)),
s
}
return n(e, t),
e.getHatSprite = function(t) {
return t === h.WhiteBearHat ?
l.Images.ImagesWhitebearhaticon.getPNG() : t === h.BrownBearHat ?
l.Images.ImagesBrownbearhaticon.getPNG() : t === h.ChessHat ?
l.Images.ImagesChesshaticon.getPNG() : t === h.CowboyHat ?
l.Images.ImagesCowboyhaticon.getPNG() : t === h.ChickenHat ?
l.Images.ImagesChickenhaticon.getPNG() : t === h.FoxHat ?
l.Images.ImagesFoxhaticon.getPNG() : t === h.VikingHat ?
l.Images.ImagesVikinghaticon.getPNG() : t === h.BuilderHat ?
l.Images.ImagesBuilderhaticon.getPNG() : t === h.HockeyHat ?
l.Images.ImagesHockeyhaticon.getPNG() : t === h.TankHat ?
l.Images.ImagesTankhaticon.getPNG() : t === h.DruidHat ?
l.Images.ImagesDruidhaticon.getPNG() : t === h.IceHat ?
l.Images.ImagesIcehaticon.getPNG() : l.Images.ImagesKnight.getPNG()
}
,
e
}(a.EventEmitter)
, d = function() {
function t(t, e) {
this.listContainer = e,
this.world = t
}
return t.prototype.cleanup = function() {
this.elements = [],
this.listContainer.innerHTML = ""
}
,
t.prototype.updateHats = function(t, e) {
this.cleanup();
for (var i = function(i) {
var s = t[i]
, o = new u(s,s === e);
o.on("wear", function() {
this.world.socket.sendMessage(r.PlayerSelectHat, {
hatType: s
}),
this.world.services.getService(p).toggle()
}
.bind(n)),
n.listContainer.appendChild(o.element)
}, n = this, s = 0; s < t.length; s++)
i(s);
var o = -1
, a = new u(o,o === e);
a.on("wear", function() {
this.world.socket.sendMessage(r.PlayerSelectHat, {
hatType: o
}),
this.world.services.getService(p).toggle()
}
.bind(this)),
this.listContainer.appendChild(a.element)
}
,
t
}()
, p = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.isEnabled = !1,
i.world.socket.onMessage(r.SyncHats, i.onSyncHats.bind(i)),
i.container = document.getElementById("ui-hat-list-container"),
document.getElementById("ui-hat-list-close").onclick = function() {
this.toggle()
}
.bind(i),
document.getElementById("ui-hat-close-button").onclick = function() {
this.toggle()
}
.bind(i),
i.hatList = new d(e,document.getElementById("ui-hat-list-content")),
i
}
return n(e, t),
e.prototype.onSyncHats = function(t) {
var e = t.content.hatTypes
, i = t.content.currentHat;
this.hatList.updateHats(e, i)
}
,
e.prototype.hide = function() {
this.isEnabled && this.toggle()
}
,
e.prototype.toggle = function() {
this.isEnabled = !this.isEnabled,
this.isEnabled && this.world.services.getService(c.default).hide(),
this.container.style.display = this.isEnabled ? "block" : "none"
}
,
e.prototype.destroy = function() {
this.isEnabled && this.toggle()
}
,
e
}(s.Service);
e.default = p
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.MessageType
, a = i(7)
, h = i(16)
, l = function() {
function t(t, e) {
this.teamId = t,
this.teamName = e
}
return t
}()
, c = function() {
function t(t, e, i) {
this.id = t,
this.teamId = e,
this.memberName = i
}
return t
}()
, u = function() {
function t(t, e, i) {
this.id = t,
this.teamId = e,
this.memberName = i
}
return t
}()
, d = function(t) {
function e(e, i) {
var n = t.call(this) || this;
return n.requestId = e,
n.element = document.createElement("div"),
n.element.className = "join-request-content",
n.element.innerHTML = "\n " + i + '<br /> ask for join\n
<div class="join-request-buttons">\n <span class="approve">\n
<i class="fa fa-thumbs-o-up approve fa-2x" aria-hidden="true"></i>\n
</span>\n <span class="decline">\n <i class="fa
fa-thumbs-o-down decline fa-2x" aria-hidden="true"></i>\n </span>\n
</div>\n ',
$(".approve", n.element).on("click", function() {
this.emit("approve", e)
}
.bind(n)),
$(".decline", n.element).on("click", function() {
this.emit("decline", e)
}
.bind(n)),
n
}
return n(e, t),
e
}(a.EventEmitter)
, p = function() {
function t(t, e) {
this.requests = {},
this.world = t,
this.container = e
}
return t.prototype.clear = function() {
for (var t = Object.keys(this.requests), e = 0, i = t; e < i.length; e+
+) {
var n = i[e];
this.removeJoinRequest(parseInt(n))
}
}
,
t.prototype.addJoinRequest = function(t) {
this.requests[t.id] = t,
this.currentElement || this.show(t.id)
}
,
t.prototype.removeJoinRequest = function(t) {
delete this.requests[t],
this.currentElement && this.currentElement.requestId === t &&
(this.hide(),
Object.keys(this.requests).length > 0 &&
this.show(Object.keys(this.requests)[0]))
}
,
t.prototype.show = function(t) {
this.requests[t] && (this.currentElement = new
d(t,this.requests[t].memberName),
this.currentElement.on("approve", function(t) {
this.world.services.getService(v).requestApprove(t),
this.removeJoinRequest(t)
}
.bind(this)),
this.currentElement.on("decline", function(t) {
this.world.services.getService(v).requestDecline(t),
this.removeJoinRequest(t)
}
.bind(this)),
this.container.appendChild(this.currentElement.element),
this.container.style.visibility = "visible")
}
,
t.prototype.hide = function() {
this.currentElement &&
(this.container.removeChild(this.currentElement.element),
this.currentElement = null,
this.container.style.visibility = "hidden")
}
,
t
}()
, f = function(t) {
function e(e, i) {
var n = t.call(this) || this;
return n.element = document.createElement("div"),
n.element.className = "ui-team-list-item",
n.element.innerHTML = '\n <div class="ui-join-button">\n
JOIN\n </div>\n <div class="ui-team-name">\n '
+ i + "\n </div>\n ",
n.joinButton = $(".ui-join-button", n.element).get(0),
n.joinButton.onclick = function() {
this.emit("join-request", e)
}
.bind(n),
n
}
return n(e, t),
e.prototype.setJoinStatus = function(t) {
t ? (this.joinButton.classList.add("loading"),
this.joinButton.innerHTML = '<i class="fa fa-spin fa-spinner" aria-
hidden="true"></i> REQUESTED') : (this.joinButton.classList.remove("loading"),
this.joinButton.innerHTML = "JOIN")
}
,
e
}(a.EventEmitter)
, m = function() {
function t(t, e, i) {
this.elements = {},
this.listContainer = i,
this.container = e,
this.world = t
}
return t.prototype.addTeam = function(t) {
var e = new f(t.teamId,t.teamName);
this.listContainer.appendChild(e.element),
this.elements[t.teamId] = e,
e.on("join-request", function(t) {
this.world.services.getService(v).requestJoin(t)
}
.bind(this))
}
,
t.prototype.removeTeam = function(t) {
this.elements[t] &&
(this.elements[t].element.parentNode.removeChild(this.elements[t].element),
delete this.elements[t])
}
,
t.prototype.setJoinStatus = function(t, e) {
this.elements[t] && this.elements[t].setJoinStatus(e)
}
,
t.prototype.toggle = function(t) {
this.container.style.visibility = t ? "visible" : "hidden"
}
,
t
}()
, g = function(t) {
function e(e, i, n) {
var s = t.call(this) || this;
return s.element = document.createElement("div"),
s.element.className = "ui-member-list-item",
s.element.innerHTML = "\n " + (e.isAdmin && i !==
e.networkId ? '<div class="ui-kick-button">KICK</div>' : "") + '\n <div
class="ui-team-name">\n ' + n + "\n </div>\n ",
e.isAdmin && i !== e.networkId && (s.element.childNodes[1].onclick =
function() {
this.emit("kick-request", i)
}
.bind(s)),
s
}
return n(e, t),
e.prototype.setJoinStatus = function(t) {
t ? this.element.childNodes[1].classList.add("loading") :
this.element.childNodes[1].classList.remove("loading")
}
,
e
}(a.EventEmitter)
, y = function() {
function t(t, e, i) {
this.elements = {},
this.container = e,
this.content = i,
this.world = t
}
return t.prototype.addMember = function(t) {
var e = new g(this.world,t.id,t.memberName);
this.content.appendChild(e.element),
this.elements[t.id] = e,
e.on("kick-request", function(t) {
this.world.services.getService(v).requestKick(t)
}
.bind(this))
}
,
t.prototype.removeMember = function(t) {
this.elements[t] &&
(this.elements[t].element.parentNode.removeChild(this.elements[t].element),
delete this.elements[t])
}
,
t.prototype.toggle = function(t) {
this.container.style.visibility = t ? "visible" : "hidden"
}
,
t
}()
, v = function(t) {
function e(e) {
var i = t.call(this, e) || this;
i.teams = {},
i.joins = {},
i.members = {},
i.enabled = !1,
i.teamList = new m(e,document.getElementById("ui-team-list-
container"),document.getElementById("ui-team-list-content")),
i.memberList = new y(e,document.getElementById("ui-member-list-
container"),document.getElementById("ui-member-list-content")),
i.joinRequestList = new p(e,document.getElementById("ui-join-request-
list")),
i.world.socket.onMessage(r.PlayerTeamListResponse,
i.onTeamListResponse.bind(i)),
i.world.socket.onMessage(r.PlayerTeamMembersResponse,
i.onMemberListResponse.bind(i)),
i.world.socket.onMessage(r.NotifyTeamCreated, i.onTeamCreated.bind(i)),
i.world.socket.onMessage(r.NotifyTeamRemoved, i.onTeamRemoved.bind(i)),
i.world.socket.onMessage(r.NotifyJoinRequestCreated,
i.onJoinRequestCreated.bind(i)),
i.world.socket.onMessage(r.NotifyJoinRequestRemoved,
i.onJoinRequestRemoved.bind(i)),
i.world.socket.onMessage(r.NotifyMemberJoin, i.onMemberJoin.bind(i)),
i.world.socket.onMessage(r.NotifyMemberLeave, i.onMemberLeave.bind(i)),
i.requestTeamList(),
window.addEventListener("keydown", i.onKeyDown.bind(i), !1),
document.getElementById("ui-create-team-button").onclick = function() {
this.requestCreateTeam(document.getElementById("ui-input-team-
name").value)
}
.bind(i),
document.getElementById("ui-leave-team-button").onclick = function() {
this.requestLeave()
}
.bind(i);
for (var n = document.getElementsByClassName("ui-team-list-close"), s =
0; s < n.length; s++)
n.item(s).onclick = function() {
this.toggle()
}
.bind(i);
return i
}
return n(e, t),
e.prototype.onKeyDown = function(t) {
this.enabled && 27 === t.keyCode && this.toggle()
}
,
e.prototype.onJoinRequestCreated = function(t) {
var e = new c(t.content.id,t.content.teamId,t.content.fromName);
this.joins[e.id] = e,
this.teamList.setJoinStatus(e.teamId, !0),
this.world.isAdmin && e.teamId === this.world.teamId &&
this.joinRequestList.addJoinRequest(e)
}
,
e.prototype.onJoinRequestRemoved = function(t) {
var e = t.content.id;
this.joins[e] && (this.teamList.setJoinStatus(this.joins[e].teamId, !
1),
delete this.joins[e]),
this.joinRequestList.removeJoinRequest(e)
}
,
e.prototype.onTeamListResponse = function(t) {
for (var e = t.content.teamId, i = t.content.teamName, n =
t.content.memberCount, s = 0; s < e.length; s++)
this.addTeam(e[s], i[s], n[s])
}
,
e.prototype.onMemberListResponse = function(t) {
for (var e = t.content.teamId, i = t.content.networkId, n =
t.content.name, s = 0; s < i.length; s++)
this.addMember(e, i[s], n[s])
}
,
e.prototype.onTeamCreated = function(t) {
this.addTeam(t.content.teamId, t.content.teamName, 0)
}
,
e.prototype.onTeamRemoved = function(t) {
this.removeTeam(t.content.teamId)
}
,
e.prototype.onMemberJoin = function(t) {
var e = t.content.teamId
, i = t.content.memberId
, n = t.content.memberName;
this.addMember(e, i, n)
}
,
e.prototype.onMemberLeave = function(t) {
var e = (t.content.teamId,
t.content.memberId);
this.removeMember(e)
}
,
e.prototype.onTeamSwitch = function(t) {
if (this.cleanupMembers(),
this.world.isAdmin)
for (var e in this.joins)
this.joins[e].teamId === this.world.teamId &&
this.joinRequestList.addJoinRequest(this.joins[e]);
else
this.joinRequestList.clear();
for (var i in this.teams)
this.teamList.setJoinStatus(i, !1);
t > -1 && this.requestMemberList(t),
this.requestTeamList(),
this.teamList.toggle(this.enabled && this.world.teamId < 0),
this.memberList.toggle(this.enabled && this.world.teamId > -1)
}
,
e.prototype.removeTeam = function(t) {
this.teams[t] && (delete this.teams[t],
this.teamList.removeTeam(t))
}
,
e.prototype.addTeam = function(t, e, i) {
this.teams[t] || (this.teams[t] = new l(t,e),
this.teamList.addTeam(this.teams[t]))
}
,
e.prototype.cleanupMembers = function() {
for (var t = Object.keys(this.members), e = 0, i = t; e < i.length; e+
+) {
var n = i[e];
this.removeMember(n)
}
}
,
e.prototype.addMember = function(t, e, i) {
this.members[e] || (this.members[e] = new u(e,t,i),
this.memberList.addMember(this.members[e]))
}
,
e.prototype.removeMember = function(t) {
this.members[t] && (this.memberList.removeMember(t),
delete this.members[t])
}
,
e.prototype.requestJoin = function(t) {
this.world.socket.sendMessage(r.PlayerJoinTeam, {
teamId: t
})
}
,
e.prototype.requestKick = function(t) {
this.world.socket.sendMessage(r.PlayerKickRequest, {
networkId: t
})
}
,
e.prototype.requestCreateTeam = function(t) {
this.world.socket.sendMessage(r.PlayerCreateTeam, {
name: t
})
}
,
e.prototype.requestLeave = function() {
this.world.socket.sendMessage(r.PlayerLeaveTeam, {})
}
,
e.prototype.requestApprove = function(t) {
this.world.socket.sendMessage(r.PlayerApproveRequest, {
requestId: t
})
}
,
e.prototype.requestDecline = function(t) {
this.world.socket.sendMessage(r.PlayerDeclineRequest, {
requestId: t
})
}
,
e.prototype.requestTeamList = function() {
this.world.socket.sendMessage(r.PlayerTeamListRequest, {})
}
,
e.prototype.requestMemberList = function(t) {
this.world.socket.sendMessage(r.PlayerTeamMembersRequest, {
teamId: t
})
}
,
e.prototype.hide = function() {
this.enabled && this.toggle()
}
,
e.prototype.toggle = function() {
this.enabled = !this.enabled,
this.enabled && this.world.services.getService(h.default).hide(),
this.teamList.toggle(this.enabled && this.world.teamId < 0),
this.memberList.toggle(this.enabled && this.world.teamId > -1),
this.world.game.input.keyboard.enabled = !this.enabled,
this.world.game.input.keyboard.reset(!1)
}
,
e
}(s.Service);
e.default = v
}
, function(module, exports, __webpack_require__) {
(function(module) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;
/*!
* protobuf.js v6.6.5 (c) 2016, Daniel Wirtz
* Compiled Thu, 02 Mar 2017 18:54:44 UTC
* Licensed under the BSD-3-Clause License
* see: https://github.com/dcodeIO/protobuf.js for details
*/
!function(e, t) {
"use strict";
!function(t, i, n) {
function s(e) {
var n = i[e];
return n || t[e][0].call(n = i[e] = {
exports: {}
}, s, n, n.exports),
n.exports
}
var o = e.protobuf = s(n[0]);
__webpack_require__(192) && (__WEBPACK_AMD_DEFINE_ARRAY__ =
[__webpack_require__(152)],
void 0 !== (__WEBPACK_AMD_DEFINE_RESULT__ = function(t) {
return o.util.Long = t,
o.configure(),
o
}
.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) && (module.exports =
__WEBPACK_AMD_DEFINE_RESULT__)),
"object" == typeof module && module && module.exports &&
(module.exports = o)
}({
1: [function(t, e) {
function i(t, e) {
for (var i = [], n = 2; n < arguments.length; )
i.push(arguments[n++]);
var s = !0;
return new Promise(function(n, o) {
i.push(function(t) {
if (s)
if (s = !1,
t)
o(t);
else {
for (var e = [], i = 1; i <
arguments.length; )
e.push(arguments[i++]);
n.apply(null, e)
}
});
try {
t.apply(e || this, i)
} catch (t) {
s && (s = !1,
o(t))
}
}
)
}
e.exports = i
}
, {}],
2: [function(e, i, n) {
var s = n;
s.length = function(t) {
var e = t.length;
if (!e)
return 0;
for (var i = 0; --e % 4 > 1 && "=" === t.charAt(e); )
++i;
return Math.ceil(3 * t.length) / 4 - i
}
;
for (var o = Array(64), r = Array(123), a = 0; a < 64; )
r[o[a] = a < 26 ? a + 65 : a < 52 ? a + 71 : a < 62 ? a - 4
: a - 59 | 43] = a++;
s.encode = function(t, e, i) {
for (var n, s = [], r = 0, a = 0; e < i; ) {
var h = t[e++];
switch (a) {
case 0:
s[r++] = o[h >> 2],
n = (3 & h) << 4,
a = 1;
break;
case 1:
s[r++] = o[n | h >> 4],
n = (15 & h) << 2,
a = 2;
break;
case 2:
s[r++] = o[n | h >> 6],
s[r++] = o[63 & h],
a = 0
}
}
return a && (s[r++] = o[n],
s[r] = 61,
1 === a && (s[r + 1] = 61)),
String.fromCharCode.apply(String, s)
}
;
var h = "invalid encoding";
s.decode = function(e, i, n) {
for (var s, o = n, a = 0, l = 0; l < e.length; ) {
var c = e.charCodeAt(l++);
if (61 === c && a > 1)
break;
if ((c = r[c]) === t)
throw Error(h);
switch (a) {
case 0:
s = c,
a = 1;
break;
case 1:
i[n++] = s << 2 | (48 & c) >> 4,
s = c,
a = 2;
break;
case 2:
i[n++] = (15 & s) << 4 | (60 & c) >> 2,
s = c,
a = 3;
break;
case 3:
i[n++] = (3 & s) << 6 | c,
a = 0
}
}
if (1 === a)
throw Error(h);
return n - o
}
,
s.test = function(t) {
return /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-
Za-z0-9+\/]{3}=)?$/.test(t)
}
}
, {}],
3: [function(e, i) {
function n() {
function e() {
for (var t = [], i = 0; i < arguments.length; )
t.push(arguments[i++]);
var n = s.apply(null, t)
, c = p;
if (d.length) {
var u = d[d.length - 1];
o.test(u) ? c = ++p : h.test(u) && ++c,
a.test(u) && !a.test(n) ? (c = ++p,
f = !0) : f && l.test(u) && (c = --p,
f = !1),
r.test(n) && (c = --p)
}
for (i = 0; i < c; ++i)
n = "\t" + n;
return d.push(n),
e
}
function i(t) {
return "function" + (t ? " " + t.replace(/[^\w_$]/g,
"_") : "") + "(" + u.join(",") + ") {\n" + d.join("\n") + "\n}"
}
function c(i, s) {
"object" == typeof i && (s = i,
i = t);
var o = e.str(i);
n.verbose && console.log("--- codegen ---\n" +
o.replace(/^/gm, "> ").replace(/\t/g, " "));
var r = Object.keys(s || (s = {}));
return Function.apply(null, r.concat("return " +
o)).apply(null, r.map(function(t) {
return s[t]
}))
}
for (var u = [], d = [], p = 1, f = !1, m = 0; m <
arguments.length; )
u.push(arguments[m++]);
return e.str = i,
e.eof = c,
e
}
function s(t) {
for (var e = [], i = 1; i < arguments.length; )
e.push(arguments[i++]);
if (i = 0,
t = t.replace(/%([dfjs])/g, function(t, n) {
switch (n) {
case "d":
return Math.floor(e[i++]);
case "f":
return +e[i++];
case "j":
return JSON.stringify(e[i++]);
default:
return e[i++]
}
}),
i !== e.length)
throw Error("argument count mismatch");
return t
}
i.exports = n;
var o = /[{[]$/
, r = /^[}\]]/
, a = /:$/
, h = /^\s*(?:if|}?else if|while|for)\b|\b(?:else)\s*$/
, l = /\b(?:break|continue)(?: \w+)?;?$|^\s*return\b/;
n.sprintf = s,
n.supported = !1;
try {
n.supported = 1 === n("a", "b")("return a-b").eof()(2, 1)
} catch (e) {}
n.verbose = !1
}
, {}],
4: [function(e, i) {
function n() {
this.a = {}
}
i.exports = n,
n.prototype.on = function(t, e, i) {
return (this.a[t] || (this.a[t] = [])).push({
fn: e,
ctx: i || this
}),
this
}
,
n.prototype.off = function(e, i) {
if (e === t)
this.a = {};
else if (i === t)
this.a[e] = [];
else
for (var n = this.a[e], s = 0; s < n.length; )
n[s].fn === i ? n.splice(s, 1) : ++s;
return this
}
,
n.prototype.emit = function(t) {
var e = this.a[t];
if (e) {
for (var i = [], n = 1; n < arguments.length; )
i.push(arguments[n++]);
for (n = 0; n < e.length; )
e[n].fn.apply(e[n++].ctx, i)
}
return this
}
}
, {}],
5: [function(e, i) {
function n(t, e, i) {
return "function" == typeof e ? (i = e,
e = {}) : e || (e = {}),
i ? !e.xhr && r && r.readFile ? r.readFile(t, function(s,
o) {
return s && "undefined" != typeof XMLHttpRequest ?
n.xhr(t, e, i) : s ? i(s) : i(null, e.binary ? o : o.toString("utf8"))
}) : n.xhr(t, e, i) : s(n, this, t, e)
}
i.exports = n;
var s = e(1)
, o = e(6)
, r = o("fs");
n.xhr = function(e, i, n) {
var s = new XMLHttpRequest;
s.onreadystatechange = function() {
if (4 !== s.readyState)
return t;
if (0 !== s.status && 200 !== s.status)
return n(Error("status " + s.status));
if (i.binary) {
var e = s.response;
if (!e) {
e = [];
for (var o = 0; o < s.responseText.length; ++o)
e.push(255 & s.responseText.charCodeAt(o))
}
return n(null, "undefined" != typeof Uint8Array ?
new Uint8Array(e) : e)
}
return n(null, s.responseText)
}
,
i.binary && ("overrideMimeType"in s &&
s.overrideMimeType("text/plain; charset=x-user-defined"),
s.responseType = "arraybuffer"),
s.open("GET", e),
s.send()
}
}
, {
1: 1,
6: 6
}],
6: [function(e, t, r) {
function n(e) {
try {
var t = eval("quire".replace(/^/, "re"))(e);
if (t && (t.length || Object.keys(t).length))
return t
} catch (e) {}
return null
}
t.exports = n
}
, {}],
7: [function(t, e, i) {
var n = i
, s = n.isAbsolute = function(t) {
return /^(?:\/|\w+:)/.test(t)
}
, o = n.normalize = function(t) {
t = t.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
var e = t.split("/")
, i = s(t)
, n = "";
i && (n = e.shift() + "/");
for (var o = 0; o < e.length; )
".." === e[o] ? o > 0 && ".." !== e[o - 1] ?
e.splice(--o, 2) : i ? e.splice(o, 1) : ++o : "." === e[o] ? e.splice(o, 1) : ++o;
return n + e.join("/")
}
;
n.resolve = function(t, e, i) {
return i || (e = o(e)),
s(e) ? e : (i || (t = o(t)),
(t = t.replace(/(?:\/|^)[^\/]+$/, "")).length ? o(t + "/" +
e) : e)
}
}
, {}],
8: [function(t, e) {
function i(t, e, i) {
var n = i || 8192
, s = n >>> 1
, o = null
, r = n;
return function(i) {
if (i < 1 || i > s)
return t(i);
r + i > n && (o = t(n),
r = 0);
var a = e.call(o, r, r += i);
return 7 & r && (r = 1 + (7 | r)),
a
}
}
e.exports = i
}
, {}],
9: [function(t, e, i) {
var n = i;
n.length = function(t) {
for (var e = 0, i = 0, n = 0; n < t.length; ++n)
i = t.charCodeAt(n),
i < 128 ? e += 1 : i < 2048 ? e += 2 : 55296 == (64512
& i) && 56320 == (64512 & t.charCodeAt(n + 1)) ? (++n,
e += 4) : e += 3;
return e
}
,
n.read = function(t, e, i) {
if (i - e < 1)
return "";
for (var n, s = null, o = [], r = 0; e < i; )
n = t[e++],
n < 128 ? o[r++] = n : n > 191 && n < 224 ? o[r++] =
(31 & n) << 6 | 63 & t[e++] : n > 239 && n < 365 ? (n = ((7 & n) << 18 | (63 & t[e+
+]) << 12 | (63 & t[e++]) << 6 | 63 & t[e++]) - 65536,
o[r++] = 55296 + (n >> 10),
o[r++] = 56320 + (1023 & n)) : o[r++] = (15 & n) << 12
| (63 & t[e++]) << 6 | 63 & t[e++],
r > 8191 && ((s || (s =
[])).push(String.fromCharCode.apply(String, o)),
r = 0);
return s ? (r && s.push(String.fromCharCode.apply(String,
o.slice(0, r))),
s.join("")) : String.fromCharCode.apply(String, o.slice(0,
r))
}
,
n.write = function(t, e, i) {
for (var n, s, o = i, r = 0; r < t.length; ++r)
n = t.charCodeAt(r),
n < 128 ? e[i++] = n : n < 2048 ? (e[i++] = n >> 6 |
192,
e[i++] = 63 & n | 128) : 55296 == (64512 & n) && 56320
== (64512 & (s = t.charCodeAt(r + 1))) ? (n = 65536 + ((1023 & n) << 10) + (1023 &
s),
++r,
e[i++] = n >> 18 | 240,
e[i++] = n >> 12 & 63 | 128,
e[i++] = n >> 6 & 63 | 128,
e[i++] = 63 & n | 128) : (e[i++] = n >> 12 | 224,
e[i++] = n >> 6 & 63 | 128,
e[i++] = 63 & n | 128);
return i - o
}
}
, {}],
10: [function(t, e) {
function i(e, r) {
if (n || (n = t(34)),
!(e instanceof n))
throw TypeError("type must be a Type");
if (r) {
if ("function" != typeof r)
throw TypeError("ctor must be a function")
} else
r = o.codegen("p")("return c.call(this,p)").eof(e.name,
{
c: s
});
r.constructor = i,
(r.prototype = new s).constructor = r,
o.merge(r, s, !0),
r.$type = e,
r.prototype.$type = e;
for (var a = 0; a < e.fieldsArray.length; ++a)
r.prototype[e.b[a].name] =
Array.isArray(e.b[a].resolve().defaultValue) ? o.emptyArray :
o.isObject(e.b[a].defaultValue) && !e.b[a].long ? o.emptyObject :
e.b[a].defaultValue;
var h = {};
for (a = 0; a < e.oneofsArray.length; ++a)
h[e.d[a].resolve().name] = {
get: o.oneOfGetter(e.d[a].oneof),
set: o.oneOfSetter(e.d[a].oneof)
};
return a && Object.defineProperties(r.prototype, h),
e.ctor = r,
r.prototype
}
e.exports = i;
var n, s = t(21), o = t(36);
i.create = i,
i.prototype = s
}
, {
21: 21,
34: 34,
36: 36
}],
11: [function(t, e) {
function i(t, e) {
/\/|\./.test(t) || (t = "google/protobuf/" + t + ".proto",
e = {
nested: {
google: {
nested: {
protobuf: {
nested: e
}
}
}
}
}),
i[t] = e
}
e.exports = i,
i("any", {
Any: {
fields: {
type_url: {
type: "string",
id: 1
},
value: {
type: "bytes",
id: 2
}
}
}
});
var n;
i("duration", {
Duration: n = {
fields: {
seconds: {
type: "int64",
id: 1
},
nanos: {
type: "int32",
id: 2
}
}
}
}),
i("timestamp", {
Timestamp: n
}),
i("empty", {
Empty: {
fields: {}
}
}),
i("struct", {
Struct: {
fields: {
fields: {
keyType: "string",
type: "Value",
id: 1
}
}
},
Value: {
oneofs: {
kind: {
oneof: ["nullValue", "numberValue",
"stringValue", "boolValue", "structValue", "listValue"]
}
},
fields: {
nullValue: {
type: "NullValue",
id: 1
},
numberValue: {
type: "double",
id: 2
},
stringValue: {
type: "string",
id: 3
},
boolValue: {
type: "bool",
id: 4
},
structValue: {
type: "Struct",
id: 5
},
listValue: {
type: "ListValue",
id: 6
}
}
},
NullValue: {
values: {
NULL_VALUE: 0
}
},
ListValue: {
fields: {
values: {
rule: "repeated",
type: "Value",
id: 1
}
}
}
}),
i("wrappers", {
DoubleValue: {
fields: {
value: {
type: "double",
id: 1
}
}
},
FloatValue: {
fields: {
value: {
type: "float",
id: 1
}
}
},
Int64Value: {
fields: {
value: {
type: "int64",
id: 1
}
}
},
UInt64Value: {
fields: {
value: {
type: "uint64",
id: 1
}
}
},
Int32Value: {
fields: {
value: {
type: "int32",
id: 1
}
}
},
UInt32Value: {
fields: {
value: {
type: "uint32",
id: 1
}
}
},
BoolValue: {
fields: {
value: {
type: "bool",
id: 1
}
}
},
StringValue: {
fields: {
value: {
type: "string",
id: 1
}
}
},
BytesValue: {
fields: {
value: {
type: "bytes",
id: 1
}
}
}
})
}
, {}],
12: [function(t, e, i) {
function n(t, e, i, n) {
if (e.resolvedType)
if (e.resolvedType instanceof r) {
t("switch(d%s){", n);
for (var s = e.resolvedType.values, o =
Object.keys(s), a = 0; a < o.length; ++a)
e.repeated && s[o[a]] === e.typeDefault &&
t("default:"),
t("case%j:", o[a])("case %j:", s[o[a]])("m%s=
%j", n, s[o[a]])("break");
t("}")
} else
t('if(typeof d%s!=="object")', n)("throw
TypeError(%j)", e.fullName + ": object expected")("m%s=types[%d].fromObject(d%s)",
n, i, n);
else {
var h = !1;
switch (e.type) {
case "double":
case "float":
t("m%s=Number(d%s)", n, n);
break;
case "uint32":
case "fixed32":
t("m%s=d%s>>>0", n, n);
break;
case "int32":
case "sint32":
case "sfixed32":
t("m%s=d%s|0", n, n);
break;
case "uint64":
h = !0;
case "int64":
case "sint64":
case "fixed64":
case "sfixed64":
t("if(util.Long)")("(m%s=util.Long.fromValue(d
%s)).unsigned=%j", n, n, h)('else if(typeof d%s==="string")', n)("m%s=parseInt(d
%s,10)", n, n)('else if(typeof d%s==="number")', n)("m%s=d%s", n, n)('else
if(typeof d%s==="object")', n)("m%s=new util.LongBits(d%s.low>>>0,d
%s.high>>>0).toNumber(%s)", n, n, n, h ? "true" : "");
break;
case "bytes":
t('if(typeof d%s==="string")', n)
("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)", n, n, n)
("else if(d%s.length)", n)("m%s=d%s", n, n);
break;
case "string":
t("m%s=String(d%s)", n, n);
break;
case "bool":
t("m%s=Boolean(d%s)", n, n)
}
}
return t
}
function s(t, e, i, n) {
if (e.resolvedType)
e.resolvedType instanceof r ? t("d%s=o.enums===String?
types[%d].values[m%s]:m%s", n, i, n, n) : t("d%s=types[%d].toObject(m%s,o)", n, i,
n);
else {
var s = !1;
switch (e.type) {
case "uint64":
s = !0;
case "int64":
case "sint64":
case "fixed64":
case "sfixed64":
t('if(typeof m%s==="number")', n)("d
%s=o.longs===String?String(m%s):m%s", n, n, n)("else")("d%s=o.longs===String?
util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m
%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s", n, n, n, n, s ? "true" : "", n);
break;
case "bytes":
t("d%s=o.bytes===String?util.base64.encode(m%s,0,m
%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s", n, n, n, n, n);
break;
default:
t("d%s=m%s", n, n)
}
}
return t
}
var o = i
, r = t(15)
, a = t(36);
o.fromObject = function(t) {
var e = t.fieldsArray
, i = a.codegen("d")("if(d instanceof this.ctor)")
("return d");
if (!e.length)
return i("return new this.ctor");
i("var m=new this.ctor");
for (var s = 0; s < e.length; ++s) {
var o = e[s].resolve()
, h = a.safeProp(o.name);
o.map ? (i("if(d%s){", h)('if(typeof d%s!=="object")',
h)("throw TypeError(%j)", o.fullName + ": object expected")("m%s={}", h)("for(var
ks=Object.keys(d%s),i=0;i<ks.length;++i){", h),
n(i, o, s, h + "[ks[i]]")("}")("}")) : o.repeated ?
(i("if(d%s){", h)("if(!Array.isArray(d%s))", h)("throw TypeError(%j)", o.fullName +
": array expected")("m%s=[]", h)("for(var i=0;i<d%s.length;++i){", h),
n(i, o, s, h + "[i]")("}")("}")) : (o.resolvedType
instanceof r || i("if(d%s!==undefined&&d%s!==null){", h, h),
n(i, o, s, h),
o.resolvedType instanceof r || i("}"))
}
return i("return m")
}
,
o.toObject = function(t) {
var e = t.fieldsArray;
if (!e.length)
return a.codegen()("return {}");
for (var i = a.codegen("m", "o")("if(!o)")("o={}")("var
d={}"), n = [], o = [], h = [], l = 0; l < e.length; ++l)
e[l].resolve().repeated ? n.push(e[l]) : e[l].map ?
o.push(e[l]) : h.push(e[l]);
if (n.length) {
for (i("if(o.arrays||o.defaults){"),
l = 0; l < n.length; ++l)
i("d%s=[]", a.safeProp(n[l].name));
i("}")
}
if (o.length) {
for (i("if(o.objects||o.defaults){"),
l = 0; l < o.length; ++l)
i("d%s={}", a.safeProp(o[l].name));
i("}")
}
if (h.length) {
for (i("if(o.defaults){"),
l = 0,
c; l < h.length; ++l) {
var c = h[l]
, u = a.safeProp(c.name);
c.resolvedType instanceof r ? i("d
%s=o.enums===String?%j:%j", u, c.resolvedType.valuesById[c.typeDefault],
c.typeDefault) : c.long ? i("if(util.Long){")("var n=new util.Long(%d,%d,%j)",
c.typeDefault.low, c.typeDefault.high, c.typeDefault.unsigned)("d
%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n", u)("}else")("d
%s=o.longs===String?%j:%d", u, "" + c.typeDefault, c.typeDefault.toNumber()) :
c.bytes ? i("d%s=o.bytes===String?%j:%s", u, String.fromCharCode.apply(String,
c.typeDefault), "[" + Array.prototype.slice.call(c.typeDefault).join(",") + "]") :
i("d%s=%j", u, c.typeDefault)
}
i("}")
}
for (l = 0,
c; l < e.length; ++l) {
var c = e[l]
, u = a.safeProp(c.name);
i("if(m%s!==undefined&&m%s!
==null&&m.hasOwnProperty(%j)){", u, u, c.name),
c.map ? (i("d%s={}", u)("for(var ks2=Object.keys(m
%s),j=0;j<ks2.length;++j){", u),
s(i, c, l, u + "[ks2[j]]")("}")) : c.repeated ? (i("d
%s=[]", u)("for(var j=0;j<m%s.length;++j){", u),
s(i, c, l, u + "[j]")("}")) : s(i, c, l, u),
i("}")
}
return i("return d")
}
}
, {
15: 15,
36: 36
}],
13: [function(e, i) {
function n(e) {
var i = r.codegen("r", "l")("if(!(r instanceof Reader))")
("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor")
("while(r.pos<c){")("var t=r.uint32()");
e.group && i("if((t&7)===4)")("break"),
i("switch(t>>>3){");
for (var a = 0; a < e.fieldsArray.length; ++a) {
var h = e.b[a].resolve()
, l = h.resolvedType instanceof s ? "uint32" : h.type
, c = "m" + r.safeProp(h.name);
i("case %d:", h.id),
h.map ? (i("r.skip().pos++")
("if(%s===util.emptyObject)", c)("%s={}", c)("var k=r.%s()", h.keyType)("r.pos++"),
o.basic[l] === t ? i('%s[typeof k==="object"?
util.longToHash(k):k]=types[%d].decode(r,r.uint32())', c, a) : i('%s[typeof
k==="object"?util.longToHash(k):k]=r.%s()', c, l)) : h.repeated ? (i("if(!(%s&&
%s.length))", c, c)("%s=[]", c),
(n.compat || h.packed) && o.packed[l] !== t &&
i("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.
%s())", c, l)("}else"),
o.basic[l] === t ? i(h.resolvedType.group ?
"%s.push(types[%d].decode(r))" : "%s.push(types[%d].decode(r,r.uint32()))", c, a) :
i("%s.push(r.%s())", c, l)) : o.basic[l] === t ? i(h.resolvedType.group ?
"%s=types[%d].decode(r)" : "%s=types[%d].decode(r,r.uint32())", c, a) : i("%s=r.
%s()", c, l),
i("break")
}
return i("default:")("r.skipType(t&7)")("break")("}")("}")
("return m")
}
i.exports = n,
n.compat = !0;
var s = e(15)
, o = e(35)
, r = e(36)
}
, {
15: 15,
35: 35,
36: 36
}],
14: [function(e, i) {
function n(t, e, i, n) {
return e.resolvedType.group ?
t("types[%d].encode(%s,w.uint32(%d)).uint32(%d)", i, n, (e.id << 3 | 3) >>> 0,
(e.id << 3 | 4) >>> 0) : t("types[%d].encode(%s,w.uint32(%d).fork()).ldelim()", i,
n, (e.id << 3 | 2) >>> 0)
}
function s(e) {
for (var i, s, h = a.codegen("m", "w")("if(!w)")
("w=Writer.create()"), i = 0; i < e.fieldsArray.length; ++i) {
var l = e.b[i].resolve();
if (!l.partOf) {
var c = l.resolvedType instanceof o ? "uint32" :
l.type
, u = r.basic[c];
s = "m" + a.safeProp(l.name),
l.map ? (h("if(%s&&m.hasOwnProperty(%j)){", s,
l.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){", s)
("w.uint32(%d).fork().uint32(%d).%s(ks[i])", (l.id << 3 | 2) >>> 0, 8 |
r.mapKey[l.keyType], l.keyType),
u === t ?
h("types[%d].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", i, s) :
h(".uint32(%d).%s(%s[ks[i]]).ldelim()", 16 | u, c, s),
h("}")("}")) : l.repeated ? l.packed && r.packed[c]
!== t ? h("if(%s&&%s.length&&m.hasOwnProperty(%j)){", s, s, l.name)
("w.uint32(%d).fork()", (l.id << 3 | 2) >>> 0)("for(var i=0;i<%s.length;++i)", s)
("w.%s(%s[i])", c, s)("w.ldelim()")("}") : (h("if(%s!
==undefined&&m.hasOwnProperty(%j)){", s, l.name)("for(var i=0;i<%s.length;++i)",
s),
u === t ? n(h, l, i, s + "[i]") : h("w.uint32(%d).
%s(%s[i])", (l.id << 3 | u) >>> 0, c, s),
h("}")) : (l.required || (l.long ? h("if(%s!
==undefined&&%s!==null&&m.hasOwnProperty(%j))", s, s, l.name) : l.bytes ||
l.resolvedType && !(l.resolvedType instanceof o) ?
h("if(%s&&m.hasOwnProperty(%j))", s, l.name) : h("if(%s!
==undefined&&m.hasOwnProperty(%j))", s, l.name)),
u === t ? n(h, l, i, s) : h("w.uint32(%d).%s(%s)",
(l.id << 3 | u) >>> 0, c, s))
}
}
for (var i = 0; i < e.oneofsArray.length; ++i) {
var d = e.d[i];
h("switch(%s){", "m" + a.safeProp(d.name));
for (var p = 0; p < d.fieldsArray.length; ++p) {
var l = d.fieldsArray[p]
, c = l.resolvedType instanceof o ? "uint32" :
l.type
, u = r.basic[c];
s = "m" + a.safeProp(l.name),
h("case%j:", l.name),
u === t ? n(h, l, e.b.indexOf(l), s) :
h("w.uint32(%d).%s(%s)", (l.id << 3 | u) >>> 0, c, s),
h("break")
}
h("}")
}
return h("return w")
}
i.exports = s;
var o = e(15)
, r = e(35)
, a = e(36)
}
, {
15: 15,
35: 35,
36: 36
}],
15: [function(e, i) {
function n(t, e, i) {
if (s.call(this, t, i),
e && "object" != typeof e)
throw TypeError("values must be an object");
if (this.valuesById = {},
this.values = Object.create(this.valuesById),
this.comments = {},
e)
for (var n = Object.keys(e), o = 0; o < n.length; ++o)
this.valuesById[this.values[n[o]] = e[n[o]]] = n[o]
}
i.exports = n;
var s = e(24);
((n.prototype = Object.create(s.prototype)).constructor =
n).className = "Enum";
var o = e(36);
n.fromJSON = function(t, e) {
return new n(t,e.values,e.options)
}
,
n.prototype.toJSON = function() {
return {
options: this.options,
values: this.values
}
}
,
n.prototype.add = function(e, i, n) {
if (!o.isString(e))
throw TypeError("name must be a string");
if (!o.isInteger(i))
throw TypeError("id must be an integer");
if (this.values[e] !== t)
throw Error("duplicate name");
if (this.valuesById[i] !== t) {
if (!this.options || !this.options.allow_alias)
throw Error("duplicate id");
this.values[e] = i
} else
this.valuesById[this.values[e] = i] = e;
return this.comments[e] = n || null,
this
}
,
n.prototype.remove = function(e) {
if (!o.isString(e))
throw TypeError("name must be a string");
var i = this.values[e];
if (i === t)
throw Error("name does not exist");
return delete this.valuesById[i],
delete this.values[e],
delete this.comments[e],
this
}
}
, {
24: 24,
36: 36
}],
16: [function(e, i) {
function n(e, i, n, o, r, l) {
if (h.isObject(o) ? (l = o,
o = r = t) : h.isObject(r) && (l = r,
r = t),
s.call(this, e, l),
!h.isInteger(i) || i < 0)
throw TypeError("id must be a non-negative integer");
if (!h.isString(n))
throw TypeError("type must be a string");
if (o !== t && !/^required|optional|repeated$/.test(o = (""
+ o).toLowerCase()))
throw TypeError("rule must be a string rule");
if (r !== t && !h.isString(r))
throw TypeError("extend must be a string");
this.rule = o && "optional" !== o ? o : t,
this.type = n,
this.id = i,
this.extend = r || t,
this.required = "required" === o,
this.optional = !this.required,
this.repeated = "repeated" === o,
this.map = !1,
this.message = null,
this.partOf = null,
this.typeDefault = null,
this.defaultValue = null,
this.long = !!h.Long && a.long[n] !== t,
this.bytes = "bytes" === n,
this.resolvedType = null,
this.extensionField = null,
this.declaringField = null,
this.e = null
}
i.exports = n;
var s = e(24);
((n.prototype = Object.create(s.prototype)).constructor =
n).className = "Field";
var o, r = e(15), a = e(35), h = e(36);
Object.defineProperty(n.prototype, "packed", {
get: function() {
return null === this.e && (this.e = !1 !==
this.getOption("packed")),
this.e
}
}),
n.prototype.setOption = function(t, e, i) {
return "packed" === t && (this.e = null),
s.prototype.setOption.call(this, t, e, i)
}
,
n.fromJSON = function(t, e) {
return new n(t,e.id,e.type,e.rule,e.extend,e.options)
}
,
n.prototype.toJSON = function() {
return {
rule: "optional" !== this.rule && this.rule || t,
type: this.type,
id: this.id,
extend: this.extend,
options: this.options
}
}
,
n.prototype.resolve = function() {
if (this.resolved)
return this;
if ((this.typeDefault = a.defaults[this.type]) === t) {
o || (o = e(34));
var i = this.declaringField ?
this.declaringField.parent : this.parent;
if (this.resolvedType = i.lookup(this.type, o))
this.typeDefault = null;
else {
if (!(this.resolvedType = i.lookup(this.type, r)))
throw Error("unresolvable field type: " +
this.type + " in " + i);
this.typeDefault =
this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]
}
}
if (this.options && this.options.default !== t &&
(this.typeDefault = this.options.default,
this.resolvedType instanceof r && "string" == typeof
this.typeDefault && (this.typeDefault =
this.resolvedType.values[this.typeDefault])),
!this.options || this.options.packed === t || !
this.resolvedType || this.resolvedType instanceof r || delete this.options.packed,
this.long)
this.typeDefault = h.Long.fromNumber(this.typeDefault,
"u" === this.type.charAt(0)),
Object.freeze && Object.freeze(this.typeDefault);
else if (this.bytes && "string" == typeof this.typeDefault)
{
var n;
h.base64.test(this.typeDefault) ?
h.base64.decode(this.typeDefault, n =
h.newBuffer(h.base64.length(this.typeDefault)), 0) : h.utf8.write(this.typeDefault,
n = h.newBuffer(h.utf8.length(this.typeDefault)), 0),
this.typeDefault = n
}
return this.map ? this.defaultValue = h.emptyObject :
this.repeated ? this.defaultValue = h.emptyArray : this.defaultValue =
this.typeDefault,
s.prototype.resolve.call(this)
}
}
, {
15: 15,
24: 24,
34: 34,
35: 35,
36: 36
}],
17: [function(t, e) {
function i(t, e, i) {
return "function" == typeof e ? (i = e,
e = new s.Root) : e || (e = new s.Root),
e.load(t, i)
}
function n(t, e) {
return e || (e = new s.Root),
e.loadSync(t)
}
var s = e.exports = t(18);
s.build = "light",
s.load = i,
s.loadSync = n,
s.encoder = t(14),
s.decoder = t(13),
s.verifier = t(39),
s.converter = t(12),
s.ReflectionObject = t(24),
s.Namespace = t(23),
s.Root = t(29),
s.Enum = t(15),
s.Type = t(34),
s.Field = t(16),
s.OneOf = t(25),
s.MapField = t(20),
s.Service = t(32),
s.Method = t(22),
s.Class = t(10),
s.Message = t(21),
s.types = t(35),
s.util = t(36),
s.ReflectionObject.f(s.Root),
s.Namespace.f(s.Type, s.Service),
s.Root.f(s.Type)
}
, {
10: 10,
12: 12,
13: 13,
14: 14,
15: 15,
16: 16,
18: 18,
20: 20,
21: 21,
22: 22,
23: 23,
24: 24,
25: 25,
29: 29,
32: 32,
34: 34,
35: 35,
36: 36,
39: 39
}],
18: [function(t, e, i) {
function n() {
s.Reader.f(s.BufferReader),
s.util.f()
}
var s = i;
s.build = "minimal",
s.roots = {},
s.Writer = t(40),
s.BufferWriter = t(41),
s.Reader = t(27),
s.BufferReader = t(28),
s.util = t(38),
s.rpc = t(30),
s.configure = n,
s.Writer.f(s.BufferWriter),
n()
}
, {
27: 27,
28: 28,
30: 30,
38: 38,
40: 40,
41: 41
}],
19: [function(t, e) {
var i = e.exports = t(17);
i.build = "full",
i.tokenize = t(33),
i.parse = t(26),
i.common = t(11),
i.Root.f(i.Type, i.parse, i.common)
}
, {
11: 11,
17: 17,
26: 26,
33: 33
}],
20: [function(e, i) {
function n(t, e, i, n, o) {
if (s.call(this, t, e, n, o),
!r.isString(i))
throw TypeError("keyType must be a string");
this.keyType = i,
this.resolvedKeyType = null,
this.map = !0
}
i.exports = n;
var s = e(16);
((n.prototype = Object.create(s.prototype)).constructor =
n).className = "MapField";
var o = e(35)
, r = e(36);
n.fromJSON = function(t, e) {
return new n(t,e.id,e.keyType,e.type,e.options)
}
,
n.prototype.toJSON = function() {
return {
keyType: this.keyType,
type: this.type,
id: this.id,
extend: this.extend,
options: this.options
}
}
,
n.prototype.resolve = function() {
if (this.resolved)
return this;
if (o.mapKey[this.keyType] === t)
throw Error("invalid key type: " + this.keyType);
return s.prototype.resolve.call(this)
}
}
, {
16: 16,
35: 35,
36: 36
}],
21: [function(t, e) {
function i(t) {
if (t)
for (var e = Object.keys(t), i = 0; i < e.length; ++i)
this[e[i]] = t[e[i]]
}
e.exports = i;
var n = t(36);
i.encode = function(t, e) {
return this.$type.encode(t, e)
}
,
i.encodeDelimited = function(t, e) {
return this.$type.encodeDelimited(t, e)
}
,
i.decode = function(t) {
return this.$type.decode(t)
}
,
i.decodeDelimited = function(t) {
return this.$type.decodeDelimited(t)
}
,
i.verify = function(t) {
return this.$type.verify(t)
}
,
i.fromObject = function(t) {
return this.$type.fromObject(t)
}
,
i.from = i.fromObject,
i.toObject = function(t, e) {
return this.$type.toObject(t, e)
}
,
i.prototype.toObject = function(t) {
return this.$type.toObject(this, t)
}
,
i.prototype.toJSON = function() {
return this.$type.toObject(this, n.toJSONOptions)
}
}
, {
36: 36
}],
22: [function(e, i) {
function n(e, i, n, r, a, h, l) {
if (o.isObject(a) ? (l = a,
a = h = t) : o.isObject(h) && (l = h,
h = t),
i !== t && !o.isString(i))
throw TypeError("type must be a string");
if (!o.isString(n))
throw TypeError("requestType must be a string");
if (!o.isString(r))
throw TypeError("responseType must be a string");
s.call(this, e, l),
this.type = i || "rpc",
this.requestType = n,
this.requestStream = !!a || t,
this.responseType = r,
this.responseStream = !!h || t,
this.resolvedRequestType = null,
this.resolvedResponseType = null
}
i.exports = n;
var s = e(24);
((n.prototype = Object.create(s.prototype)).constructor =
n).className = "Method";
var o = e(36);
n.fromJSON = function(t, e) {
return new
n(t,e.type,e.requestType,e.responseType,e.requestStream,e.responseStream,e.options)
}
,
n.prototype.toJSON = function() {
return {
type: "rpc" !== this.type && this.type || t,
requestType: this.requestType,
requestStream: this.requestStream,
responseType: this.responseType,
responseStream: this.responseStream,
options: this.options
}
}
,
n.prototype.resolve = function() {
return this.resolved ? this : (this.resolvedRequestType =
this.parent.lookupType(this.requestType),
this.resolvedResponseType =
this.parent.lookupType(this.responseType),
s.prototype.resolve.call(this))
}
}
, {
24: 24,
36: 36
}],
23: [function(e, i) {
function n(e) {
if (!e || !e.length)
return t;
for (var i = {}, n = 0; n < e.length; ++n)
i[e[n].name] = e[n].toJSON();
return i
}
function s(e, i) {
r.call(this, e, i),
this.nested = t,
this.g = null
}
function o(t) {
return t.g = null,
t
}
i.exports = s;
var r = e(24);
((s.prototype = Object.create(r.prototype)).constructor =
s).className = "Namespace";
var a, h, l = e(15), c = e(16), u = e(36);
s.fromJSON = function(t, e) {
return new s(t,e.options).addJSON(e.nested)
}
,
s.arrayToJSON = n,
Object.defineProperty(s.prototype, "nestedArray", {
get: function() {
return this.g || (this.g = u.toArray(this.nested))
}
}),
s.prototype.toJSON = function() {
return {
options: this.options,
nested: n(this.nestedArray)
}
}
,
s.prototype.addJSON = function(e) {
var i = this;
if (e)
for (var n, o = Object.keys(e), r = 0; r < o.length; +
+r)
n = e[o[r]],
i.add((n.fields !== t ? a.fromJSON : n.values !== t
? l.fromJSON : n.methods !== t ? h.fromJSON : n.id !== t ? c.fromJSON : s.fromJSON)
(o[r], n));
return this
}
,
s.prototype.get = function(t) {
return this.nested && this.nested[t] || null
}
,
s.prototype.getEnum = function(t) {
if (this.nested && this.nested[t]instanceof l)
return this.nested[t].values;
throw Error("no such enum")
}
,
s.prototype.add = function(e) {
if (!(e instanceof c && e.extend !== t || e instanceof a ||
e instanceof l || e instanceof h || e instanceof s))
throw TypeError("object must be a valid nested
object");
if (this.nested) {
var i = this.get(e.name);
if (i) {
if (!(i instanceof s && e instanceof s) || i
instanceof a || i instanceof h)
throw Error("duplicate name '" + e.name + "' in
" + this);
for (var n = i.nestedArray, r = 0; r < n.length; +
+r)
e.add(n[r]);
this.remove(i),
this.nested || (this.nested = {}),
e.setOptions(i.options, !0)
}
} else
this.nested = {};
return this.nested[e.name] = e,
e.onAdd(this),
o(this)
}
,
s.prototype.remove = function(e) {
if (!(e instanceof r))
throw TypeError("object must be a ReflectionObject");
if (e.parent !== this)
throw Error(e + " is not a member of " + this);
return delete this.nested[e.name],
Object.keys(this.nested).length || (this.nested = t),
e.onRemove(this),
o(this)
}
,
s.prototype.define = function(t, e) {
if (u.isString(t))
t = t.split(".");
else if (!Array.isArray(t))
throw TypeError("illegal path");
if (t && t.length && "" === t[0])
throw Error("path must be relative");
for (var i = this; t.length > 0; ) {
var n = t.shift();
if (i.nested && i.nested[n]) {
if (!((i = i.nested[n])instanceof s))
throw Error("path conflicts with non-namespace
objects")
} else
i.add(i = new s(n))
}
return e && i.addJSON(e),
i
}
,
s.prototype.resolveAll = function() {
for (var t = this.nestedArray, e = 0; e < t.length; )
t[e]instanceof s ? t[e++].resolveAll() : t[e+
+].resolve();
return this.resolve()
}
,
s.prototype.lookup = function(e, i, n) {
if ("boolean" == typeof i && (n = i,
i = t),
u.isString(e) && e.length) {
if ("." === e)
return this.root;
e = e.split(".")
} else if (!e.length)
return this;
if ("" === e[0])
return this.root.lookup(e.slice(1), i);
var o = this.get(e[0]);
if (o)
if (1 === e.length) {
if (!i || o instanceof i)
return o
} else if (o instanceof s && (o = o.lookup(e.slice(1),
i, !0)))
return o;
return null === this.parent || n ? null :
this.parent.lookup(e, i)
}
,
s.prototype.lookupType = function(t) {
var e = this.lookup(t, a);
if (!e)
throw Error("no such type");
return e
}
,
s.prototype.lookupService = function(t) {
var e = this.lookup(t, h);
if (!e)
throw Error("no such service");
return e
}
,
s.prototype.lookupEnum = function(t) {
var e = this.lookup(t, l);
if (!e)
throw Error("no such enum");
return e.values
}
,
s.f = function(t, e) {
a = t,
h = e
}
}
, {
15: 15,
16: 16,
24: 24,
36: 36
}],
24: [function(e, i) {
function n(t, e) {
if (!o.isString(t))
throw TypeError("name must be a string");
if (e && !o.isObject(e))
throw TypeError("options must be an object");
this.options = e,
this.name = t,
this.parent = null,
this.resolved = !1,
this.comment = null,
this.filename = null
}
i.exports = n,
n.className = "ReflectionObject";
var s, o = e(36);
Object.defineProperties(n.prototype, {
root: {
get: function() {
for (var t = this; null !== t.parent; )
t = t.parent;
return t
}
},
fullName: {
get: function() {
for (var t = [this.name], e = this.parent; e; )
t.unshift(e.name),
e = e.parent;
return t.join(".")
}
}
}),
n.prototype.toJSON = function() {
throw Error()
}
,
n.prototype.onAdd = function(t) {
this.parent && this.parent !== t &&
this.parent.remove(this),
this.parent = t,
this.resolved = !1;
var e = t.root;
e instanceof s && e.h(this)
}
,
n.prototype.onRemove = function(t) {
var e = t.root;
e instanceof s && e.i(this),
this.parent = null,
this.resolved = !1
}
,
n.prototype.resolve = function() {
return this.resolved ? this : (this.root instanceof s &&
(this.resolved = !0),
this)
}
,
n.prototype.getOption = function(e) {
return this.options ? this.options[e] : t
}
,
n.prototype.setOption = function(e, i, n) {
return n && this.options && this.options[e] !== t ||
((this.options || (this.options = {}))[e] = i),
this
}
,
n.prototype.setOptions = function(t, e) {
if (t)
for (var i = Object.keys(t), n = 0; n < i.length; ++n)
this.setOption(i[n], t[i[n]], e);
return this
}
,
n.prototype.toString = function() {
var t = this.constructor.className
, e = this.fullName;
return e.length ? t + " " + e : t
}
,
n.f = function(t) {
s = t
}
}
, {
36: 36
}],
25: [function(e, i) {
function n(e, i, n) {
if (Array.isArray(i) || (n = i,
i = t),
o.call(this, e, n),
i !== t && !Array.isArray(i))
throw TypeError("fieldNames must be an Array");
this.oneof = i || [],
this.fieldsArray = []
}
function s(t) {
if (t.parent)
for (var e = 0; e < t.fieldsArray.length; ++e)
t.fieldsArray[e].parent ||
t.parent.add(t.fieldsArray[e])
}
i.exports = n;
var o = e(24);
((n.prototype = Object.create(o.prototype)).constructor =
n).className = "OneOf";
var r = e(16);
n.fromJSON = function(t, e) {
return new n(t,e.oneof,e.options)
}
,
n.prototype.toJSON = function() {
return {
oneof: this.oneof,
options: this.options
}
}
,
n.prototype.add = function(t) {
if (!(t instanceof r))
throw TypeError("field must be a Field");
return t.parent && t.parent !== this.parent &&
t.parent.remove(t),
this.oneof.push(t.name),
this.fieldsArray.push(t),
t.partOf = this,
s(this),
this
}
,
n.prototype.remove = function(t) {
if (!(t instanceof r))
throw TypeError("field must be a Field");
var e = this.fieldsArray.indexOf(t);
if (e < 0)
throw Error(t + " is not a member of " + this);
return this.fieldsArray.splice(e, 1),
e = this.oneof.indexOf(t.name),
e > -1 && this.oneof.splice(e, 1),
t.partOf = null,
this
}
,
n.prototype.onAdd = function(t) {
o.prototype.onAdd.call(this, t);
for (var e = this, i = 0; i < this.oneof.length; ++i) {
var n = t.get(this.oneof[i]);
n && !n.partOf && (n.partOf = e,
e.fieldsArray.push(n))
}
s(this)
}
,
n.prototype.onRemove = function(t) {
for (var e, i = 0; i < this.fieldsArray.length; ++i)
(e = this.fieldsArray[i]).parent && e.parent.remove(e);
o.prototype.onRemove.call(this, t)
}
}
, {
16: 16,
24: 24
}],
26: [function(e, i) {
function n(t) {
return /^[a-zA-Z_][a-zA-Z_0-9]*$/.test(t)
}
function s(t) {
return /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)+$/.test(t)
}
function o(t) {
return /^(?:\.[a-zA-Z][a-zA-Z_0-9]*)+$/.test(t)
}
function r(t) {
return null === t ? null : t.toLowerCase()
}
function a(t) {
return t.substring(0, 1) + t.substring(1).replace(/_([a-z])
(?=[a-z]|$)/g, function(t, e) {
return e.toUpperCase()
})
}
function h(e, i, w) {
function x(t, e, i) {
var n = h.filename;
return i || (h.filename = null),
Error("illegal " + (e || "token") + " '" + t + "' (" +
(n ? n + ", " : "") + "line " + J.line() + ")")
}
function _() {
var t, e = [];
do {
if ('"' !== (t = Z()) && "'" !== t)
throw x(t);
e.push(Z()),
tt(t),
t = $()
} while ('"' === t || "'" === t);return e.join("")
}
function P(t) {
var e = Z();
switch (r(e)) {
case "'":
case '"':
return Q(e),
_();
case "true":
return !0;
case "false":
return !1
}
try {
return C(e, !0)
} catch (i) {
if (t && s(e))
return e;
throw x(e, "value")
}
}
function T(t, e) {
var i, n;
do {
!e || '"' !== (i = $()) && "'" !== i ? t.push([n =
S(Z()), tt("to", !0) ? S(Z()) : n]) : t.push(_())
} while (tt(",", !0));tt(";")
}
function C(t, e) {
var i = 1;
"-" === t.charAt(0) && (i = -1,
t = t.substring(1));
var n = r(t);
switch (n) {
case "inf":
return i * (1 / 0);
case "nan":
return NaN;
case "0":
return 0
}
if (/^[1-9][0-9]*$/.test(t))
return i * parseInt(t, 10);
if (/^0[x][0-9a-f]+$/.test(n))
return i * parseInt(t, 16);
if (/^0[0-7]+$/.test(t))
return i * parseInt(t, 8);
if (/^(?!e)[0-9]*(?:\.[0-9]*)?(?:[e][+-]?[0-9]+)?
$/.test(n))
return i * parseFloat(t);
throw x(t, "number", e)
}
function S(t, e) {
var i = r(t);
switch (i) {
case "max":
return 536870911;
case "0":
return 0
}
if ("-" === t.charAt(0) && !e)
throw x(t, "id");
if (/^-?[1-9][0-9]*$/.test(t))
return parseInt(t, 10);
if (/^-?0[x][0-9a-f]+$/.test(i))
return parseInt(t, 16);
if (/^-?0[0-7]+$/.test(t))
return parseInt(t, 8);
throw x(t, "id")
}
function A() {
if (q !== t)
throw x("package");
if (q = Z(),
!s(q))
throw x(q, "name");
st = st.define(q),
tt(";")
}
function k() {
var t, e = $();
switch (e) {
case "weak":
t = Y || (Y = []),
Z();
break;
case "public":
Z();
default:
t = V || (V = [])
}
e = _(),
tt(";"),
t.push(e)
}
function E() {
if (tt("="),
z = r(_()),
!(nt = "proto3" === z) && "proto2" !== z)
throw x(z, "syntax");
tt(";")
}
function I(t, e) {
switch (e) {
case "option":
return N(t, e),
tt(";"),
!0;
case "message":
return M(t, e),
!0;
case "enum":
return D(t, e),
!0;
case "service":
return j(t, e),
!0;
case "extend":
return X(t, e),
!0
}
return !1
}
function M(t, e) {
var i = Z();
if (!n(i))
throw x(i, "type name");
var o = new u(i);
if (o.comment = et(),
o.filename = h.filename,
tt("{", !0)) {
for (; "}" !== (e = Z()); ) {
var a = r(e);
if (!I(o, e))
switch (a) {
case "map":
R(o, a);
break;
case "required":
case "optional":
case "repeated":
O(o, a);
break;
case "oneof":
L(o, a);
break;
case "extensions":
T(o.extensions || (o.extensions = []));
break;
case "reserved":
T(o.reserved || (o.reserved = []), !0);
break;
default:
if (!nt || !s(e))
throw x(e);
Q(e),
O(o, "optional")
}
}
tt(";", !0)
} else
tt(";");
t.add(o)
}
function O(e, i, o) {
var r = Z();
if ("group" === r)
return B(e, i),
t;
if (!s(r))
throw x(r, "type");
var a = Z();
if (!n(a))
throw x(a, "name");
a = ot(a),
tt("=");
var l = new d(a,S(Z()),r,i,o)
, c = J.line();
l.comment = et(),
l.filename = h.filename,
W(l),
l.comment || (l.comment = et(c)),
!nt && l.repeated && l.setOption("packed", !1, !0),
e.add(l)
}
function B(t, e) {
var i = Z();
if (!n(i))
throw x(i, "name");
var s = b.lcFirst(i);
i === s && (i = b.ucFirst(i)),
tt("=");
var o = S(Z())
, a = new u(i);
a.group = !0,
a.comment = et();
var l = new d(s,o,i,e);
for (a.filename = l.filename = h.filename,
tt("{"); "}" !== (K = Z()); )
switch (K = r(K)) {
case "option":
N(a, K),
tt(";");
break;
case "required":
case "optional":
case "repeated":
O(a, K);
break;
default:
throw x(K)
}
tt(";", !0),
t.add(a).add(l)
}
function R(e) {
tt("<");
var i = Z();
if (v.mapKey[i] === t)
throw x(i, "type");
tt(",");
var o = Z();
if (!s(o))
throw x(o, "type");
tt(">");
var r = Z();
if (!n(r))
throw x(r, "name");
r = ot(r),
tt("=");
var a = new p(r,S(Z()),i,o)
, l = J.line();
a.comment = et(),
a.filename = h.filename,
W(a),
a.comment || (a.comment = et(l)),
e.add(a)
}
function L(t, e) {
var i = Z();
if (!n(i))
throw x(i, "name");
i = ot(i);
var s = new f(i)
, o = J.line();
if (s.comment = et(),
s.filename = h.filename,
tt("{", !0)) {
for (; "}" !== (e = Z()); )
"option" === e ? (N(s, e),
tt(";")) : (Q(e),
O(s, "optional"));
tt(";", !0)
} else
tt(";"),
s.comment || (s.comment = et(o));
t.add(s)
}
function D(t, e) {
var i = Z();
if (!n(i))
throw x(i, "name");
var s = new m(i);
if (s.comment = et(),
s.filename = h.filename,
tt("{", !0)) {
for (; "}" !== (e = Z()); )
"option" === r(e) ? (N(s, e),
tt(";")) : F(s, e);
tt(";", !0)
} else
tt(";");
t.add(s)
}
function F(t, e) {
if (!n(e))
throw x(e, "name");
var i = e;
tt("=");
var s = S(Z(), !0)
, o = J.line();
t.add(i, s, et()),
W({}),
t.comments[i] || (t.comments[i] = et(o))
}
function N(t, e) {
var i = tt("(", !0)
, n = Z();
if (!s(n))
throw x(n, "name");
i && (tt(")"),
n = "(" + n + ")",
e = $(),
o(e) && (n += e,
Z())),
tt("="),
G(t, n)
}
function G(t, e) {
if (tt("{", !0))
do {
if (!n(K = Z()))
throw x(K, "name");
"{" === $() ? G(t, e + "." + K) : (tt(":"),
U(t, e + "." + K, P(!0)))
} while (!tt("}", !0));
else
U(t, e, P(!0))
}
function U(t, e, i) {
t.setOption && t.setOption(e, i)
}
function W(t) {
if (tt("[", !0)) {
do {
N(t, "option")
} while (tt(",", !0));tt("]")
}
return tt(";"),
t
}
function j(t, e) {
if (e = Z(),
!n(e))
throw x(e, "service name");
var i = e
, s = new g(i);
if (s.comment = et(),
s.filename = h.filename,
tt("{", !0)) {
for (; "}" !== (e = Z()); ) {
var o = r(e);
switch (o) {
case "option":
N(s, o),
tt(";");
break;
case "rpc":
H(s, o);
break;
default:
throw x(e)
}
}
tt(";", !0)
} else
tt(";");
t.add(s)
}
function H(t, e) {
var i = e
, o = Z();
if (!n(o))
throw x(o, "name");
var a, l, c, u;
if (tt("("),
tt("stream", !0) && (l = !0),
!s(e = Z()))
throw x(e);
if (a = e,
tt(")"),
tt("returns"),
tt("("),
tt("stream", !0) && (u = !0),
!s(e = Z()))
throw x(e);
c = e,
tt(")");
var d = new y(o,i,a,c,l,u)
, p = J.line();
if (d.comment = et(),
d.filename = h.filename,
tt("{", !0)) {
for (; "}" !== (e = Z()); ) {
var f = r(e);
switch (f) {
case "option":
N(d, f),
tt(";");
break;
default:
throw x(e)
}
}
tt(";", !0)
} else
tt(";"),
d.comment || (d.comment = et(p));
t.add(d)
}
function X(t, e) {
var i = Z();
if (!s(i))
throw x(i, "reference");
if (tt("{", !0)) {
for (; "}" !== (e = Z()); ) {
var n = r(e);
switch (n) {
case "required":
case "repeated":
case "optional":
O(t, n, i);
break;
default:
if (!nt || !s(e))
throw x(e);
Q(e),
O(t, "optional", i)
}
}
tt(";", !0)
} else
tt(";")
}
i instanceof c || (w = i,
i = new c),
w || (w = h.defaults);
for (var q, V, Y, z, K, J = l(e), Z = J.next, Q = J.push, $
= J.peek, tt = J.skip, et = J.cmnt, it = !0, nt = !1, st = i, ot = w.keepCase ?
function(t) {
return t
}
: a; null !== (K = Z()); ) {
switch (r(K)) {
case "package":
if (!it)
throw x(K);
A();
break;
case "import":
if (!it)
throw x(K);
k();
break;
case "syntax":
if (!it)
throw x(K);
E();
break;
case "option":
if (!it)
throw x(K);
N(st, K),
tt(";");
break;
default:
if (I(st, K)) {
it = !1;
continue
}
throw x(K)
}
}
return h.filename = null,
{
package: q,
imports: V,
weakImports: Y,
syntax: z,
root: i
}
}
i.exports = h,
h.filename = null,
h.defaults = {
keepCase: !1
};
var l = e(33)
, c = e(29)
, u = e(34)
, d = e(16)
, p = e(20)
, f = e(25)
, m = e(15)
, g = e(32)
, y = e(22)
, v = e(35)
, b = e(36)
}
, {
15: 15,
16: 16,
20: 20,
22: 22,
25: 25,
29: 29,
32: 32,
33: 33,
34: 34,
35: 35,
36: 36
}],
27: [function(t, e) {
function i(t, e) {
return RangeError("index out of range: " + t.pos + " + " +
(e || 1) + " > " + t.len)
}
function n(t) {
this.buf = t,
this.pos = 0,
this.len = t.length
}
function s() {
var t = new b(0,0)
, e = 0;
if (!(this.len - this.pos > 4)) {
for (; e < 3; ++e) {
if (this.pos >= this.len)
throw i(this);
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7
* e) >>> 0,
this.buf[this.pos++] < 128)
return t
}
return t.lo = (t.lo | (127 & this.buf[this.pos++]) << 7
* e) >>> 0,
t
}
for (; e < 4; ++e)
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7 * e)
>>> 0,
this.buf[this.pos++] < 128)
return t;
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 28) >>> 0,
t.hi = (t.hi | (127 & this.buf[this.pos]) >> 4) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (e = 0,
this.len - this.pos > 4) {
for (; e < 5; ++e)
if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7
* e + 3) >>> 0,
this.buf[this.pos++] < 128)
return t
} else
for (; e < 5; ++e) {
if (this.pos >= this.len)
throw i(this);
if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7
* e + 3) >>> 0,
this.buf[this.pos++] < 128)
return t
}
throw Error("invalid varint encoding")
}
function o() {
return s.call(this).toLong()
}
function r() {
return s.call(this).toNumber()
}
function a() {
return s.call(this).toLong(!0)
}
function h() {
return s.call(this).toNumber(!0)
}
function l() {
return s.call(this).zzDecode().toLong()
}
function c() {
return s.call(this).zzDecode().toNumber()
}
function u(t, e) {
return (t[e - 4] | t[e - 3] << 8 | t[e - 2] << 16 | t[e -
1] << 24) >>> 0
}
function d() {
if (this.pos + 8 > this.len)
throw i(this, 8);
return new b(u(this.buf, this.pos += 4),u(this.buf,
this.pos += 4))
}
function p() {
return d.call(this).toLong(!0)
}
function f() {
return d.call(this).toNumber(!0)
}
function m() {
return d.call(this).toLong(!1)
}
function g() {
return d.call(this).toNumber(!1)
}
e.exports = n;
var y, v = t(38), b = v.LongBits, w = v.utf8;
n.create = v.Buffer ? function(t) {
return (n.create = function(t) {
return v.Buffer.isBuffer(t) ? new y(t) : new n(t)
}
)(t)
}
: function(t) {
return new n(t)
}
,
n.prototype.j = v.Array.prototype.subarray ||
v.Array.prototype.slice,
n.prototype.uint32 = function() {
var t = 4294967295;
return function() {
if (t = (127 & this.buf[this.pos]) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (t = (t | (127 & this.buf[this.pos]) << 7) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (t = (t | (127 & this.buf[this.pos]) << 14) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (t = (t | (127 & this.buf[this.pos]) << 21) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (t = (t | (15 & this.buf[this.pos]) << 28) >>> 0,
this.buf[this.pos++] < 128)
return t;
if ((this.pos += 5) > this.len)
throw this.pos = this.len,
i(this, 10);
return t
}
}(),
n.prototype.int32 = function() {
return 0 | this.uint32()
}
,
n.prototype.sint32 = function() {
var t = this.uint32();
return t >>> 1 ^ -(1 & t) | 0
}
,
n.prototype.bool = function() {
return 0 !== this.uint32()
}
,
n.prototype.fixed32 = function() {
if (this.pos + 4 > this.len)
throw i(this, 4);
return u(this.buf, this.pos += 4)
}
,
n.prototype.sfixed32 = function() {
if (this.pos + 4 > this.len)
throw i(this, 4);
return 0 | u(this.buf, this.pos += 4)
}
;
var x = "undefined" != typeof Float32Array ? function() {
var t = new Float32Array(1)
, e = new Uint8Array(t.buffer);
return t[0] = -0,
e[3] ? function(i, n) {
return e[0] = i[n],
e[1] = i[n + 1],
e[2] = i[n + 2],
e[3] = i[n + 3],
t[0]
}
: function(i, n) {
return e[3] = i[n],
e[2] = i[n + 1],
e[1] = i[n + 2],
e[0] = i[n + 3],
t[0]
}
}() : function(t, e) {
var i = u(t, e + 4)
, n = 2 * (i >> 31) + 1
, s = i >>> 23 & 255
, o = 8388607 & i;
return 255 === s ? o ? NaN : n * (1 / 0) : 0 === s ?
1.401298464324817e-45 * n * o : n * Math.pow(2, s - 150) * (o + 8388608)
}
;
n.prototype.float = function() {
if (this.pos + 4 > this.len)
throw i(this, 4);
var t = x(this.buf, this.pos);
return this.pos += 4,
t
}
;
var _ = "undefined" != typeof Float64Array ? function() {
var t = new Float64Array(1)
, e = new Uint8Array(t.buffer);
return t[0] = -0,
e[7] ? function(i, n) {
return e[0] = i[n],
e[1] = i[n + 1],
e[2] = i[n + 2],
e[3] = i[n + 3],
e[4] = i[n + 4],
e[5] = i[n + 5],
e[6] = i[n + 6],
e[7] = i[n + 7],
t[0]
}
: function(i, n) {
return e[7] = i[n],
e[6] = i[n + 1],
e[5] = i[n + 2],
e[4] = i[n + 3],
e[3] = i[n + 4],
e[2] = i[n + 5],
e[1] = i[n + 6],
e[0] = i[n + 7],
t[0]
}
}() : function(t, e) {
var i = u(t, e + 4)
, n = u(t, e + 8)
, s = 2 * (n >> 31) + 1
, o = n >>> 20 & 2047
, r = 4294967296 * (1048575 & n) + i;
return 2047 === o ? r ? NaN : s * (1 / 0) : 0 === o ? 5e-
324 * s * r : s * Math.pow(2, o - 1075) * (r + 4503599627370496)
}
;
n.prototype.double = function() {
if (this.pos + 8 > this.len)
throw i(this, 4);
var t = _(this.buf, this.pos);
return this.pos += 8,
t
}
,
n.prototype.bytes = function() {
var t = this.uint32()
, e = this.pos
, n = this.pos + t;
if (n > this.len)
throw i(this, t);
return this.pos += t,
e === n ? new this.buf.constructor(0) :
this.j.call(this.buf, e, n)
}
,
n.prototype.string = function() {
var t = this.bytes();
return w.read(t, 0, t.length)
}
,
n.prototype.skip = function(t) {
if ("number" == typeof t) {
if (this.pos + t > this.len)
throw i(this, t);
this.pos += t
} else
do {
if (this.pos >= this.len)
throw i(this)
} while (128 & this.buf[this.pos++]);return this
}
,
n.prototype.skipType = function(t) {
switch (t) {
case 0:
this.skip();
break;
case 1:
this.skip(8);
break;
case 2:
this.skip(this.uint32());
break;
case 3:
for (; 4 != (t = 7 & this.uint32()); )
this.skipType(t);
break;
case 5:
this.skip(4);
break;
default:
throw Error("invalid wire type " + t + " at offset " +
this.pos)
}
return this
}
,
n.f = function(t) {
y = t,
v.Long ? (n.prototype.int64 = o,
n.prototype.uint64 = a,
n.prototype.sint64 = l,
n.prototype.fixed64 = p,
n.prototype.sfixed64 = m) : (n.prototype.int64 = r,
n.prototype.uint64 = h,
n.prototype.sint64 = c,
n.prototype.fixed64 = f,
n.prototype.sfixed64 = g)
}
}
, {
38: 38
}],
28: [function(t, e) {
function i(t) {
n.call(this, t)
}
e.exports = i;
var n = t(27);
(i.prototype = Object.create(n.prototype)).constructor = i;
var s = t(38);
s.Buffer && (i.prototype.j = s.Buffer.prototype.slice),
i.prototype.string = function() {
var t = this.uint32();
return this.buf.utf8Slice(this.pos, this.pos =
Math.min(this.pos + t, this.len))
}
}
, {
27: 27,
38: 38
}],
29: [function(e, i) {
function n(t) {
r.call(this, "", t),
this.deferred = [],
this.files = []
}
function s() {}
function o(e, i) {
var n = i.parent.lookup(i.extend);
if (n) {
var s = new
c(i.fullName,i.id,i.type,i.rule,t,i.options);
return s.declaringField = i,
i.extensionField = s,
n.add(s),
!0
}
return !1
}
i.exports = n;
var r = e(23);
((n.prototype = Object.create(r.prototype)).constructor =
n).className = "Root";
var a, h, l, c = e(16), u = e(15), d = e(36);
n.fromJSON = function(t, e) {
return e || (e = new n),
t.options && e.setOptions(t.options),
e.addJSON(t.nested)
}
,
n.prototype.resolvePath = d.path.resolve,
n.prototype.load = function e(i, n, o) {
function r(t, e) {
if (o) {
var i = o;
if (o = null,
p)
throw t;
i(t, e)
}
}
function a(t, e) {
try {
if (d.isString(e) && "{" === e.charAt(0) && (e =
JSON.parse(e)),
d.isString(e)) {
h.filename = t;
var i, s = h(e, u, n), o = 0;
if (s.imports)
for (; o < s.imports.length; ++o)
(i = u.resolvePath(t, s.imports[o])) &&
c(i);
if (s.weakImports)
for (o = 0; o < s.weakImports.length; ++o)
(i = u.resolvePath(t,
s.weakImports[o])) && c(i, !0)
} else
u.setOptions(e.options).addJSON(e.nested)
} catch (t) {
r(t)
}
p || f || r(null, u)
}
function c(e, i) {
var n = e.lastIndexOf("google/protobuf/");
if (n > -1) {
var s = e.substring(n);
s in l && (e = s)
}
if (!(u.files.indexOf(e) > -1)) {
if (u.files.push(e),
e in l)
return p ? a(e, l[e]) : (++f,
setTimeout(function() {
--f,
a(e, l[e])
})),
t;
if (p) {
var h;
try {
h = d.fs.readFileSync(e).toString("utf8")
} catch (e) {
return i || r(e),
t
}
a(e, h)
} else
++f,
d.fetch(e, function(n, s) {
if (--f,
o)
return n ? (i ? f || r(null, u) : r(n),
t) : (a(e, s),
t)
})
}
}
"function" == typeof n && (o = n,
n = t);
var u = this;
if (!o)
return d.asPromise(e, u, i);
var p = o === s
, f = 0;
d.isString(i) && (i = [i]);
for (var m, g = 0; g < i.length; ++g)
(m = u.resolvePath("", i[g])) && c(m);
return p ? u : (f || r(null, u),
t)
}
,
n.prototype.loadSync = function(t, e) {
if (!d.isNode)
throw Error("not supported");
return this.load(t, e, s)
}
,
n.prototype.resolveAll = function() {
if (this.deferred.length)
throw Error("unresolvable extensions: " +
this.deferred.map(function(t) {
return "'extend " + t.extend + "' in " +
t.parent.fullName
}).join(", "));
return r.prototype.resolveAll.call(this)
}
;
var p = /^[A-Z]/;
n.prototype.h = function(e) {
if (e instanceof c)
e.extend === t || e.extensionField || o(this, e) ||
this.deferred.push(e);
else if (e instanceof u)
p.test(e.name) && (e.parent[e.name] = e.values);
else {
if (e instanceof a)
for (var i = 0; i < this.deferred.length; )
o(this, this.deferred[i]) ?
this.deferred.splice(i, 1) : ++i;
for (var n = 0; n < e.nestedArray.length; ++n)
this.h(e.g[n]);
p.test(e.name) && (e.parent[e.name] = e)
}
}
,
n.prototype.i = function(e) {
if (e instanceof c) {
if (e.extend !== t)
if (e.extensionField)

e.extensionField.parent.remove(e.extensionField),
e.extensionField = null;
else {
var i = this.deferred.indexOf(e);
i > -1 && this.deferred.splice(i, 1)
}
} else if (e instanceof u)
p.test(e.name) && delete e.parent[e.name];
else if (e instanceof r) {
for (var n = 0; n < e.nestedArray.length; ++n)
this.i(e.g[n]);
p.test(e.name) && delete e.parent[e.name]
}
}
,
n.f = function(t, e, i) {
a = t,
h = e,
l = i
}
}
, {
15: 15,
16: 16,
23: 23,
36: 36
}],
30: [function(t, e, i) {
i.Service = t(31)
}
, {
31: 31
}],
31: [function(e, i) {
function n(t, e, i) {
if ("function" != typeof t)
throw TypeError("rpcImpl must be a function");
s.EventEmitter.call(this),
this.rpcImpl = t,
this.requestDelimited = !!e,
this.responseDelimited = !!i
}
i.exports = n;
var s = e(38);
(n.prototype =
Object.create(s.EventEmitter.prototype)).constructor = n,
n.prototype.rpcCall = function e(i, n, o, r, a) {
if (!r)
throw TypeError("request must be specified");
var h = this;
if (!a)
return s.asPromise(e, h, i, n, o, r);
if (!h.rpcImpl)
return setTimeout(function() {
a(Error("already ended"))
}, 0),
t;
try {
return h.rpcImpl(i, n[h.requestDelimited ?
"encodeDelimited" : "encode"](r).finish(), function(e, n) {
if (e)
return h.emit("error", e, i),
a(e);
if (null === n)
return h.end(!0),
t;
if (!(n instanceof o))
try {
n = o[h.responseDelimited ?
"decodeDelimited" : "decode"](n)
} catch (e) {
return h.emit("error", e, i),
a(e)
}
return h.emit("data", n, i),
a(null, n)
})
} catch (e) {
return h.emit("error", e, i),
setTimeout(function() {
a(e)
}, 0),
t
}
}
,
n.prototype.end = function(t) {
return this.rpcImpl && (t || this.rpcImpl(null, null,
null),
this.rpcImpl = null,
this.emit("end").off()),
this
}
}
, {
38: 38
}],
32: [function(e, i) {
function n(t, e) {
o.call(this, t, e),
this.methods = {},
this.k = null
}
function s(t) {
return t.k = null,
t
}
i.exports = n;
var o = e(23);
((n.prototype = Object.create(o.prototype)).constructor =
n).className = "Service";
var r = e(22)
, a = e(36)
, h = e(30);
n.fromJSON = function(t, e) {
var i = new n(t,e.options);
if (e.methods)
for (var s = Object.keys(e.methods), o = 0; o <
s.length; ++o)
i.add(r.fromJSON(s[o], e.methods[s[o]]));
return i
}
,
Object.defineProperty(n.prototype, "methodsArray", {
get: function() {
return this.k || (this.k = a.toArray(this.methods))
}
}),
n.prototype.toJSON = function() {
var e = o.prototype.toJSON.call(this);
return {
options: e && e.options || t,
methods: o.arrayToJSON(this.methodsArray) || {},
nested: e && e.nested || t
}
}
,
n.prototype.get = function(t) {
return this.methods[t] || o.prototype.get.call(this, t)
}
,
n.prototype.resolveAll = function() {
for (var t = this.methodsArray, e = 0; e < t.length; ++e)
t[e].resolve();
return o.prototype.resolve.call(this)
}
,
n.prototype.add = function(t) {
if (this.get(t.name))
throw Error("duplicate name '" + t.name + "' in " +
this);
return t instanceof r ? (this.methods[t.name] = t,
t.parent = this,
s(this)) : o.prototype.add.call(this, t)
}
,
n.prototype.remove = function(t) {
if (t instanceof r) {
if (this.methods[t.name] !== t)
throw Error(t + " is not a member of " + this);
return delete this.methods[t.name],
t.parent = null,
s(this)
}
return o.prototype.remove.call(this, t)
}
,
n.prototype.create = function(t, e, i) {
for (var n = new h.Service(t,e,i), s = 0; s <
this.methodsArray.length; ++s)
n[a.lcFirst(this.k[s].resolve().name)] = a.codegen("r",
"c")("return this.rpcCall(m,q,s,r,c)").eof(a.lcFirst(this.k[s].name), {
m: this.k[s],
q: this.k[s].resolvedRequestType.ctor,
s: this.k[s].resolvedResponseType.ctor
});
return n
}
}
, {
22: 22,
23: 23,
30: 30,
36: 36
}],
33: [function(e, i) {
function n(t) {
return t.replace(/\\(.?)/g, function(t, e) {
switch (e) {
case "\\":
case "":
return e;
default:
return n.map[e] || ""
}
})
}
function s(e) {
function i(t) {
return Error("illegal " + t + " (line " + g + ")")
}
function s() {
var t = "'" === x ? a : r;
t.lastIndex = f - 1;
var s = t.exec(e);
if (!s)
throw i("string");
return f = t.lastIndex,
u(x),
x = null,
n(s[1])
}
function h(t) {
return e.charAt(t)
}
function l(t, i) {
y = e.charAt(t++),
b = g;
for (var n = e.substring(t, i).split(/\n/g), s = 0; s <
n.length; ++s)
n[s] = n[s].replace(/^ *[*\/]+ */, "").trim();
v = n.join("\n").trim()
}
function c() {
if (w.length > 0)
return w.shift();
if (x)
return s();
var t, n, r, a, c;
do {
if (f === m)
return null;
for (t = !1; /\s/.test(r = h(f)); )
if ("\n" === r && ++g,
++f === m)
return null;
if ("/" === h(f)) {
if (++f === m)
throw i("comment");
if ("/" === h(f)) {
for (c = "/" === h(a = f + 1); "\n" !== h(+
+f); )
if (f === m)
return null;
++f,
c && l(a, f - 1),
++g,
t = !0
} else {
if ("*" !== (r = h(f)))
return "/";
c = "*" === h(a = f + 1);
do {
if ("\n" === r && ++g,
++f === m)
throw i("comment");
n = r,
r = h(f)
} while ("*" !== n || "/" !== r);++f,
c && l(a, f - 2),
t = !0
}
}
} while (t);var u = f;
if (o.lastIndex = 0,
!o.test(h(u++)))
for (; u < m && !o.test(h(u)); )
++u;
var d = e.substring(f, f = u);
return '"' !== d && "'" !== d || (x = d),
d
}
function u(t) {
w.push(t)
}
function d() {
if (!w.length) {
var t = c();
if (null === t)
return null;
u(t)
}
return w[0]
}
function p(t, e) {
var n = d();
if (n === t)
return c(),
!0;
if (!e)
throw i("token '" + n + "', '" + t + "' expected");
return !1
}
e = "" + e;
var f = 0
, m = e.length
, g = 1
, y = null
, v = null
, b = 0
, w = []
, x = null;
return {
next: c,
peek: d,
push: u,
skip: p,
line: function() {
return g
},
cmnt: function(e) {
var i;
return e === t ? i = b === g - 1 && v || null : (v
|| d(),
i = b === e && "/" === y && v || null),
i && (y = v = null,
b = 0),
i
}
}
}
i.exports = s;
var o = /[\s{}=;:[\],'"()<>]/g
, r = /(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g
, a = /(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g;
n.map = {
0: "\0",
r: "\r",
n: "\n",
t: "\t"
},
s.unescape = n
}
, {}],
34: [function(e, i) {
function n(e, i) {
o.call(this, e, i),
this.fields = {},
this.oneofs = t,
this.extensions = t,
this.reserved = t,
this.group = t,
this.l = null,
this.b = null,
this.d = null,
this.o = null
}
function s(t) {
return t.l = t.b = t.d = t.o = null,
delete t.encode,
delete t.decode,
delete t.verify,
t
}
i.exports = n;
var o = e(23);
((n.prototype = Object.create(o.prototype)).constructor =
n).className = "Type";
var r = e(15)
, a = e(25)
, h = e(16)
, l = e(20)
, c = e(32)
, u = e(10)
, d = e(21)
, p = e(27)
, f = e(40)
, m = e(36)
, g = e(14)
, y = e(13)
, v = e(39)
, b = e(12);
n.fromJSON = function(e, i) {
var s = new n(e,i.options);
s.extensions = i.extensions,
s.reserved = i.reserved;
for (var u = Object.keys(i.fields), d = 0; d < u.length; +
+d)
s.add((t !== i.fields[u[d]].keyType ? l.fromJSON :
h.fromJSON)(u[d], i.fields[u[d]]));
if (i.oneofs)
for (u = Object.keys(i.oneofs),
d = 0; d < u.length; ++d)
s.add(a.fromJSON(u[d], i.oneofs[u[d]]));
if (i.nested)
for (u = Object.keys(i.nested),
d = 0; d < u.length; ++d) {
var p = i.nested[u[d]];
s.add((p.id !== t ? h.fromJSON : p.fields !== t ?
n.fromJSON : p.values !== t ? r.fromJSON : p.methods !== t ? c.fromJSON :
o.fromJSON)(u[d], p))
}
return i.extensions && i.extensions.length && (s.extensions
= i.extensions),
i.reserved && i.reserved.length && (s.reserved =
i.reserved),
i.group && (s.group = !0),
s
}
,
Object.defineProperties(n.prototype, {
fieldsById: {
get: function() {
if (this.l)
return this.l;
this.l = {};
for (var t = Object.keys(this.fields), e = 0; e <
t.length; ++e) {
var i = this.fields[t[e]]
, n = i.id;
if (this.l[n])
throw Error("duplicate id " + n + " in " +
this);
this.l[n] = i
}
return this.l
}
},
fieldsArray: {
get: function() {
return this.b || (this.b = m.toArray(this.fields))
}
},
oneofsArray: {
get: function() {
return this.d || (this.d = m.toArray(this.oneofs))
}
},
ctor: {
get: function() {
return this.o || (this.o = u(this).constructor)
},
set: function(t) {
if (t && !(t.prototype instanceof d))
throw TypeError("ctor must be a Message
constructor");
t.from || (t.from = d.from),
this.o = t
}
}
}),
n.prototype.toJSON = function() {
var e = o.prototype.toJSON.call(this);
return {
options: e && e.options || t,
oneofs: o.arrayToJSON(this.oneofsArray),
fields:
o.arrayToJSON(this.fieldsArray.filter(function(t) {
return !t.declaringField
})) || {},
extensions: this.extensions && this.extensions.length ?
this.extensions : t,
reserved: this.reserved && this.reserved.length ?
this.reserved : t,
group: this.group || t,
nested: e && e.nested || t
}
}
,
n.prototype.resolveAll = function() {
for (var t = this.fieldsArray, e = 0; e < t.length; )
t[e++].resolve();
var i = this.oneofsArray;
for (e = 0; e < i.length; )
i[e++].resolve();
return o.prototype.resolve.call(this)
}
,
n.prototype.get = function(t) {
return this.fields[t] || this.oneofs && this.oneofs[t] ||
this.nested && this.nested[t] || null
}
,
n.prototype.add = function(e) {
if (this.get(e.name))
throw Error("duplicate name '" + e.name + "' in " +
this);
if (e instanceof h && e.extend === t) {
if (this.l ? this.l[e.id] : this.fieldsById[e.id])
throw Error("duplicate id " + e.id + " in " +
this);
if (this.isReservedId(e.id))
throw Error("id " + e.id + " is reserved in " +
this);
if (this.isReservedName(e.name))
throw Error("name '" + e.name + "' is reserved in "
+ this);
return e.parent && e.parent.remove(e),
this.fields[e.name] = e,
e.message = this,
e.onAdd(this),
s(this)
}
return e instanceof a ? (this.oneofs || (this.oneofs = {}),
this.oneofs[e.name] = e,
e.onAdd(this),
s(this)) : o.prototype.add.call(this, e)
}
,
n.prototype.remove = function(e) {
if (e instanceof h && e.extend === t) {
if (!this.fields || this.fields[e.name] !== e)
throw Error(e + " is not a member of " + this);
return delete this.fields[e.name],
e.parent = null,
e.onRemove(this),
s(this)
}
if (e instanceof a) {
if (!this.oneofs || this.oneofs[e.name] !== e)
throw Error(e + " is not a member of " + this);
return delete this.oneofs[e.name],
e.parent = null,
e.onRemove(this),
s(this)
}
return o.prototype.remove.call(this, e)
}
,
n.prototype.isReservedId = function(t) {
if (this.reserved)
for (var e = 0; e < this.reserved.length; ++e)
if ("string" != typeof this.reserved[e] &&
this.reserved[e][0] <= t && this.reserved[e][1] >= t)
return !0;
return !1
}
,
n.prototype.isReservedName = function(t) {
if (this.reserved)
for (var e = 0; e < this.reserved.length; ++e)
if (this.reserved[e] === t)
return !0;
return !1
}
,
n.prototype.create = function(t) {
return new this.ctor(t)
}
,
n.prototype.setup = function() {
for (var t = this.fullName, e = [], i = 0; i <
this.fieldsArray.length; ++i)
e.push(this.b[i].resolve().resolvedType);
return this.encode = g(this).eof(t + "$encode", {
Writer: f,
types: e,
util: m
}),
this.decode = y(this).eof(t + "$decode", {
Reader: p,
types: e,
util: m
}),
this.verify = v(this).eof(t + "$verify", {
types: e,
util: m
}),
this.fromObject = this.from = b.fromObject(this).eof(t +
"$fromObject", {
types: e,
util: m
}),
this.toObject = b.toObject(this).eof(t + "$toObject", {
types: e,
util: m
}),
this
}
,
n.prototype.encode = function(t, e) {
return this.setup().encode(t, e)
}
,
n.prototype.encodeDelimited = function(t, e) {
return this.encode(t, e && e.len ? e.fork() : e).ldelim()
}
,
n.prototype.decode = function(t, e) {
return this.setup().decode(t, e)
}
,
n.prototype.decodeDelimited = function(t) {
return t instanceof p || (t = p.create(t)),
this.decode(t, t.uint32())
}
,
n.prototype.verify = function(t) {
return this.setup().verify(t)
}
,
n.prototype.fromObject = function(t) {
return this.setup().fromObject(t)
}
,
n.prototype.from = n.prototype.fromObject,
n.prototype.toObject = function(t, e) {
return this.setup().toObject(t, e)
}
}
, {
10: 10,
12: 12,
13: 13,
14: 14,
15: 15,
16: 16,
20: 20,
21: 21,
23: 23,
25: 25,
27: 27,
32: 32,
36: 36,
39: 39,
40: 40
}],
35: [function(t, e, i) {
function n(t, e) {
var i = 0
, n = {};
for (e |= 0; i < t.length; )
n[r[i + e]] = t[i++];
return n
}
var s = i
, o = t(36)
, r = ["double", "float", "int32", "uint32", "sint32",
"fixed32", "sfixed32", "int64", "uint64", "sint64", "fixed64", "sfixed64", "bool",
"string", "bytes"];
s.basic = n([1, 5, 0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0, 2, 2]),
s.defaults = n([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, !1, "",
o.emptyArray, null]),
s.long = n([0, 0, 0, 1, 1], 7),
s.mapKey = n([0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0, 2], 2),
s.packed = n([1, 5, 0, 0, 0, 5, 5, 0, 0, 0, 1, 1, 0])
}
, {
36: 36
}],
36: [function(t, e) {
var i = e.exports = t(38);
i.codegen = t(3),
i.fetch = t(5),
i.path = t(7),
i.fs = i.inquire("fs"),
i.toArray = function(t) {
var e = [];
if (t)
for (var i = Object.keys(t), n = 0; n < i.length; ++n)
e.push(t[i[n]]);
return e
}
,
i.safeProp = function(t) {
return '["' + t.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
+ '"]'
}
,
i.ucFirst = function(t) {
return t.charAt(0).toUpperCase() + t.substring(1)
}
}
, {
3: 3,
38: 38,
5: 5,
7: 7
}],
37: [function(t, e) {
function i(t, e) {
this.lo = t >>> 0,
this.hi = e >>> 0
}
e.exports = i;
var n = t(38)
, s = i.zero = new i(0,0);
s.toNumber = function() {
return 0
}
,
s.zzEncode = s.zzDecode = function() {
return this
}
,
s.length = function() {
return 1
}
;
var o = i.zeroHash = "\0\0\0\0\0\0\0\0";
i.fromNumber = function(t) {
if (0 === t)
return s;
var e = t < 0;
e && (t = -t);
var n = t >>> 0
, o = (t - n) / 4294967296 >>> 0;
return e && (o = ~o >>> 0,
n = ~n >>> 0,
++n > 4294967295 && (n = 0,
++o > 4294967295 && (o = 0))),
new i(n,o)
}
,
i.from = function(t) {
if ("number" == typeof t)
return i.fromNumber(t);
if (n.isString(t)) {
if (!n.Long)
return i.fromNumber(parseInt(t, 10));
t = n.Long.fromString(t)
}
return t.low || t.high ? new i(t.low >>> 0,t.high >>> 0) :
s
}
,
i.prototype.toNumber = function(t) {
if (!t && this.hi >>> 31) {
var e = 1 + ~this.lo >>> 0
, i = ~this.hi >>> 0;
return e || (i = i + 1 >>> 0),
-(e + 4294967296 * i)
}
return this.lo + 4294967296 * this.hi
}
,
i.prototype.toLong = function(t) {
return n.Long ? new n.Long(0 | this.lo,0 | this.hi,!!t) : {
low: 0 | this.lo,
high: 0 | this.hi,
unsigned: !!t
}
}
;
var r = String.prototype.charCodeAt;
i.fromHash = function(t) {
return t === o ? s : new i((r.call(t, 0) | r.call(t, 1) <<
8 | r.call(t, 2) << 16 | r.call(t, 3) << 24) >>> 0,(r.call(t, 4) | r.call(t, 5) <<
8 | r.call(t, 6) << 16 | r.call(t, 7) << 24) >>> 0)
}
,
i.prototype.toHash = function() {
return String.fromCharCode(255 & this.lo, this.lo >>> 8 &
255, this.lo >>> 16 & 255, this.lo >>> 24, 255 & this.hi, this.hi >>> 8 & 255,
this.hi >>> 16 & 255, this.hi >>> 24)
}
,
i.prototype.zzEncode = function() {
var t = this.hi >> 31;
return this.hi = ((this.hi << 1 | this.lo >>> 31) ^ t) >>>
0,
this.lo = (this.lo << 1 ^ t) >>> 0,
this
}
,
i.prototype.zzDecode = function() {
var t = -(1 & this.lo);
return this.lo = ((this.lo >>> 1 | this.hi << 31) ^ t) >>>
0,
this.hi = (this.hi >>> 1 ^ t) >>> 0,
this
}
,
i.prototype.length = function() {
var t = this.lo
, e = (this.lo >>> 28 | this.hi << 4) >>> 0
, i = this.hi >>> 24;
return 0 === i ? 0 === e ? t < 16384 ? t < 128 ? 1 : 2 : t
< 2097152 ? 3 : 4 : e < 16384 ? e < 128 ? 5 : 6 : e < 2097152 ? 7 : 8 : i < 128 ? 9
: 10
}
}
, {
38: 38
}],
38: [function(i, n, s) {
var o = s;
o.asPromise = i(1),
o.base64 = i(2),
o.EventEmitter = i(4),
o.inquire = i(6),
o.utf8 = i(9),
o.pool = i(8),
o.LongBits = i(37),
o.emptyArray = Object.freeze ? Object.freeze([]) : [],
o.emptyObject = Object.freeze ? Object.freeze({}) : {},
o.isNode = !!(e.process && e.process.versions &&
e.process.versions.node),
o.isInteger = Number.isInteger || function(t) {
return "number" == typeof t && isFinite(t) && Math.floor(t)
=== t
}
,
o.isString = function(t) {
return "string" == typeof t || t instanceof String
}
,
o.isObject = function(t) {
return t && "object" == typeof t
}
,
o.Buffer = function() {
try {
var t = o.inquire("buffer").Buffer;
return t.prototype.utf8Write ? t : null
} catch (t) {
return null
}
}(),
o.p = null,
o.u = null,
o.newBuffer = function(t) {
return "number" == typeof t ? o.Buffer ? o.u(t) : new
o.Array(t) : o.Buffer ? o.p(t) : "undefined" == typeof Uint8Array ? t : new
Uint8Array(t)
}
,
o.Array = "undefined" != typeof Uint8Array ? Uint8Array :
Array,
o.Long = e.dcodeIO && e.dcodeIO.Long || o.inquire("long"),
o.longToHash = function(t) {
return t ? o.LongBits.from(t).toHash() :
o.LongBits.zeroHash
}
,
o.longFromHash = function(t, e) {
var i = o.LongBits.fromHash(t);
return o.Long ? o.Long.fromBits(i.lo, i.hi, e) :
i.toNumber(!!e)
}
,
o.merge = function(e, i, n) {
for (var s = Object.keys(i), o = 0; o < s.length; ++o)
e[s[o]] !== t && n || (e[s[o]] = i[s[o]]);
return e
}
,
o.lcFirst = function(t) {
return t.charAt(0).toLowerCase() + t.substring(1)
}
,
o.oneOfGetter = function(e) {
for (var i = {}, n = 0; n < e.length; ++n)
i[e[n]] = 1;
return function() {
for (var e = Object.keys(this), n = e.length - 1; n >
-1; --n)
if (1 === i[e[n]] && this[e[n]] !== t && null !==
this[e[n]])
return e[n]
}
}
,
o.oneOfSetter = function(t) {
return function(e) {
for (var i = 0; i < t.length; ++i)
t[i] !== e && delete this[t[i]]
}
}
,
o.lazyResolve = function(t, e) {
for (var i = 0; i < e.length; ++i)
for (var n = Object.keys(e[i]), s = 0; s < n.length; +
+s) {
for (var o = e[i][n[s]].split("."), r = t;
o.length; )
r = r[o.shift()];
e[i][n[s]] = r
}
}
,
o.toJSONOptions = {
longs: String,
enums: String,
bytes: String
},
o.f = function() {
var e = o.Buffer;
return e ? (o.p = e.from !== Uint8Array.from && e.from ||
function(t, i) {
return new e(t,i)
}
,
o.u = e.allocUnsafe || function(t) {
return new e(t)
}
,
t) : (o.p = o.u = null,
t)
}
}
, {
1: 1,
2: 2,
37: 37,
4: 4,
6: 6,
8: 8,
9: 9
}],
39: [function(t, e) {
function i(t, e) {
return t.name + ": " + e + (t.repeated && "array" !== e ?
"[]" : t.map && "object" !== e ? "{k:" + t.keyType + "}" : "") + " expected"
}
function n(t, e, n, s) {
if (e.resolvedType)
if (e.resolvedType instanceof r) {
t("switch(%s){", s)("default:")("return%j", i(e,
"enum value"));
for (var o = Object.keys(e.resolvedType.values), a
= 0; a < o.length; ++a)
t("case %d:", e.resolvedType.values[o[a]]);
t("break")("}")
} else
t("var e=types[%d].verify(%s);", n, s)("if(e)")
("return%j+e", e.name + ".");
else
switch (e.type) {
case "int32":
case "uint32":
case "sint32":
case "fixed32":
case "sfixed32":
t("if(!util.isInteger(%s))", s)("return%j", i(e,
"integer"));
break;
case "int64":
case "uint64":
case "sint64":
case "fixed64":
case "sfixed64":
t("if(!util.isInteger(%s)&&!
(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))", s, s, s, s)("return%j",
i(e, "integer|Long"));
break;
case "float":
case "double":
t('if(typeof %s!=="number")', s)("return%j", i(e,
"number"));
break;
case "bool":
t('if(typeof %s!=="boolean")', s)("return%j", i(e,
"boolean"));
break;
case "string":
t("if(!util.isString(%s))", s)("return%j", i(e,
"string"));
break;
case "bytes":
t('if(!(%s&&typeof %s.length==="number"||
util.isString(%s)))', s, s, s)("return%j", i(e, "buffer"))
}
return t
}
function s(t, e, n) {
switch (e.keyType) {
case "int32":
case "uint32":
case "sint32":
case "fixed32":
case "sfixed32":
t("if(!/^-?(?:0|[1-9][0-9]*)$/.test(%s))", n)("return
%j", i(e, "integer key"));
break;
case "int64":
case "uint64":
case "sint64":
case "fixed64":
case "sfixed64":
t("if(!/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))
$/.test(%s))", n)("return%j", i(e, "integer|Long key"));
break;
case "bool":
t("if(!/^true|false|0|1$/.test(%s))", n)("return%j",
i(e, "boolean key"))
}
return t
}
function o(t) {
for (var e = a.codegen("m")('if(typeof m!=="object"||
m===null)')("return%j", "object expected"), o = 0; o < t.fieldsArray.length; ++o) {
var h = t.b[o].resolve()
, l = "m" + a.safeProp(h.name);
h.map ? (e("if(%s!==undefined){", l)("if(!
util.isObject(%s))", l)("return%j", i(h, "object"))("var k=Object.keys(%s)", l)
("for(var i=0;i<k.length;++i){"),
s(e, h, "k[i]"),
n(e, h, o, l + "[k[i]]")("}")("}")) : h.repeated ?
(e("if(%s!==undefined){", l)("if(!Array.isArray(%s))", l)("return%j", i(h,
"array"))("for(var i=0;i<%s.length;++i){", l),
n(e, h, o, l + "[i]")("}")("}")) : (h.required || (!
h.resolvedType || h.resolvedType instanceof r ? e("if(%s!==undefined){", l) :
e("if(%s!==undefined&&%s!==null){", l, l)),
n(e, h, o, l),
h.required || e("}"))
}
return e("return null")
}
e.exports = o;
var r = t(15)
, a = t(36)
}
, {
15: 15,
36: 36
}],
40: [function(e, i) {
function n(e, i, n) {
this.fn = e,
this.len = i,
this.next = t,
this.val = n
}
function s() {}
function o(t) {
this.head = t.head,
this.tail = t.tail,
this.len = t.len,
this.next = t.states
}
function r() {
this.len = 0,
this.head = new n(s,0,0),
this.tail = this.head,
this.states = null
}
function a(t, e, i) {
e[i] = 255 & t
}
function h(t, e, i) {
for (; t > 127; )
e[i++] = 127 & t | 128,
t >>>= 7;
e[i] = t
}
function l(e, i) {
this.len = e,
this.next = t,
this.val = i
}
function c(t, e, i) {
for (; t.hi; )
e[i++] = 127 & t.lo | 128,
t.lo = (t.lo >>> 7 | t.hi << 25) >>> 0,
t.hi >>>= 7;
for (; t.lo > 127; )
e[i++] = 127 & t.lo | 128,
t.lo = t.lo >>> 7;
e[i++] = t.lo
}
function u(t, e, i) {
e[i++] = 255 & t,
e[i++] = t >>> 8 & 255,
e[i++] = t >>> 16 & 255,
e[i] = t >>> 24
}
i.exports = r;
var d, p = e(38), f = p.LongBits, m = p.base64, g = p.utf8;
r.create = p.Buffer ? function() {
return (r.create = function() {
return new d
}
)()
}
: function() {
return new r
}
,
r.alloc = function(t) {
return new p.Array(t)
}
,
p.Array !== Array && (r.alloc = p.pool(r.alloc,
p.Array.prototype.subarray)),
r.prototype.push = function(t, e, i) {
return this.tail = this.tail.next = new n(t,e,i),
this.len += e,
this
}
,
l.prototype = Object.create(n.prototype),
l.prototype.fn = h,
r.prototype.uint32 = function(t) {
return this.len += (this.tail = this.tail.next = new l((t
>>>= 0) < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 :
5,t)).len,
this
}
,
r.prototype.int32 = function(t) {
return t < 0 ? this.push(c, 10, f.fromNumber(t)) :
this.uint32(t)
}
,
r.prototype.sint32 = function(t) {
return this.uint32((t << 1 ^ t >> 31) >>> 0)
}
,
r.prototype.uint64 = function(t) {
var e = f.from(t);
return this.push(c, e.length(), e)
}
,
r.prototype.int64 = r.prototype.uint64,
r.prototype.sint64 = function(t) {
var e = f.from(t).zzEncode();
return this.push(c, e.length(), e)
}
,
r.prototype.bool = function(t) {
return this.push(a, 1, t ? 1 : 0)
}
,
r.prototype.fixed32 = function(t) {
return this.push(u, 4, t >>> 0)
}
,
r.prototype.sfixed32 = r.prototype.fixed32,
r.prototype.fixed64 = function(t) {
var e = f.from(t);
return this.push(u, 4, e.lo).push(u, 4, e.hi)
}
,
r.prototype.sfixed64 = r.prototype.fixed64;
var y = "undefined" != typeof Float32Array ? function() {
var t = new Float32Array(1)
, e = new Uint8Array(t.buffer);
return t[0] = -0,
e[3] ? function(i, n, s) {
t[0] = i,
n[s++] = e[0],
n[s++] = e[1],
n[s++] = e[2],
n[s] = e[3]
}
: function(i, n, s) {
t[0] = i,
n[s++] = e[3],
n[s++] = e[2],
n[s++] = e[1],
n[s] = e[0]
}
}() : function(t, e, i) {
var n = t < 0 ? 1 : 0;
if (n && (t = -t),
0 === t)
u(1 / t > 0 ? 0 : 2147483648, e, i);
else if (isNaN(t))
u(2147483647, e, i);
else if (t > 3.4028234663852886e38)
u((n << 31 | 2139095040) >>> 0, e, i);
else if (t < 1.1754943508222875e-38)
u((n << 31 | Math.round(t / 1.401298464324817e-45)) >>>
0, e, i);
else {
var s = Math.floor(Math.log(t) / Math.LN2)
, o = 8388607 & Math.round(t * Math.pow(2, -s) *
8388608);
u((n << 31 | s + 127 << 23 | o) >>> 0, e, i)
}
}
;
r.prototype.float = function(t) {
return this.push(y, 4, t)
}
;
var v = "undefined" != typeof Float64Array ? function() {
var t = new Float64Array(1)
, e = new Uint8Array(t.buffer);
return t[0] = -0,
e[7] ? function(i, n, s) {
t[0] = i,
n[s++] = e[0],
n[s++] = e[1],
n[s++] = e[2],
n[s++] = e[3],
n[s++] = e[4],
n[s++] = e[5],
n[s++] = e[6],
n[s] = e[7]
}
: function(i, n, s) {
t[0] = i,
n[s++] = e[7],
n[s++] = e[6],
n[s++] = e[5],
n[s++] = e[4],
n[s++] = e[3],
n[s++] = e[2],
n[s++] = e[1],
n[s] = e[0]
}
}() : function(t, e, i) {
var n = t < 0 ? 1 : 0;
if (n && (t = -t),
0 === t)
u(0, e, i),
u(1 / t > 0 ? 0 : 2147483648, e, i + 4);
else if (isNaN(t))
u(4294967295, e, i),
u(2147483647, e, i + 4);
else if (t > 1.7976931348623157e308)
u(0, e, i),
u((n << 31 | 2146435072) >>> 0, e, i + 4);
else {
var s;
if (t < 2.2250738585072014e-308)
s = t / 5e-324,
u(s >>> 0, e, i),
u((n << 31 | s / 4294967296) >>> 0, e, i + 4);
else {
var o = Math.floor(Math.log(t) / Math.LN2);
1024 === o && (o = 1023),
s = t * Math.pow(2, -o),
u(4503599627370496 * s >>> 0, e, i),
u((n << 31 | o + 1023 << 20 | 1048576 * s &
1048575) >>> 0, e, i + 4)
}
}
}
;
r.prototype.double = function(t) {
return this.push(v, 8, t)
}
;
var b = p.Array.prototype.set ? function(t, e, i) {
e.set(t, i)
}
: function(t, e, i) {
for (var n = 0; n < t.length; ++n)
e[i + n] = t[n]
}
;
r.prototype.bytes = function(t) {
var e = t.length >>> 0;
if (!e)
return this.push(a, 1, 0);
if (p.isString(t)) {
var i = r.alloc(e = m.length(t));
m.decode(t, i, 0),
t = i
}
return this.uint32(e).push(b, e, t)
}
,
r.prototype.string = function(t) {
var e = g.length(t);
return e ? this.uint32(e).push(g.write, e, t) :
this.push(a, 1, 0)
}
,
r.prototype.fork = function() {
return this.states = new o(this),
this.head = this.tail = new n(s,0,0),
this.len = 0,
this
}
,
r.prototype.reset = function() {
return this.states ? (this.head = this.states.head,
this.tail = this.states.tail,
this.len = this.states.len,
this.states = this.states.next) : (this.head = this.tail =
new n(s,0,0),
this.len = 0),
this
}
,
r.prototype.ldelim = function() {
var t = this.head
, e = this.tail
, i = this.len;
return this.reset().uint32(i),
i && (this.tail.next = t.next,
this.tail = e,
this.len += i),
this
}
,
r.prototype.finish = function() {
for (var t = this.head.next, e =
this.constructor.alloc(this.len), i = 0; t; )
t.fn(t.val, e, i),
i += t.len,
t = t.next;
return e
}
,
r.f = function(t) {
d = t
}
}
, {
38: 38
}],
41: [function(t, e) {
function i() {
s.call(this)
}
function n(t, e, i) {
t.length < 40 ? o.utf8.write(t, e, i) : e.utf8Write(t, i)
}
e.exports = i;
var s = t(40);
(i.prototype = Object.create(s.prototype)).constructor = i;
var o = t(38)
, r = o.Buffer;
i.alloc = function(t) {
return (i.alloc = o.u)(t)
}
;
var a = r && r.prototype instanceof Uint8Array && "set" ===
r.prototype.set.name ? function(t, e, i) {
e.set(t, i)
}
: function(t, e, i) {
if (t.copy)
t.copy(e, i, 0, t.length);
else
for (var n = 0; n < t.length; )
e[i++] = t[n++]
}
;
i.prototype.bytes = function(t) {
o.isString(t) && (t = o.p(t, "base64"));
var e = t.length >>> 0;
return this.uint32(e),
e && this.push(a, e, t),
this
}
,
i.prototype.string = function(t) {
var e = r.byteLength(t);
return this.uint32(e),
e && this.push(n, e, t),
this
}
}
, {
38: 38,
40: 40
}]
}, {}, [19])
}("object" == typeof window && window || "object" == typeof self && self ||
this)
}
).call(exports, __webpack_require__(194)(module))
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(33)
, s = function() {
function t() {}
return t.increase_start_count = function() {
t.set_start_count(t.get_start_count() + 1)
}
,
t.get_start_count = function() {
return parseInt(n.default.read("ad_start")) || 1
}
,
t.set_start_count = function(t) {
n.default.write("ad_start", t)
}
,
t.increase_end_count = function() {
t.set_end_count(t.get_end_count() + 1)
}
,
t.get_end_count = function() {
return parseInt(n.default.read("ad_end")) || 1
}
,
t.set_end_count = function(t) {
n.default.write("ad_end", t)
}
,
t.drop_counts = function() {
t.set_start_count(1),
t.set_end_count(1)
}
,
t.check_integrity = function() {
return !(t.get_start_count() > t.get_end_count())
}
,
t.is_need_play_ad = function() {
if (!t.check_integrity())
return t.drop_counts(),
t.set_start_count(2),
t.set_end_count(2),
!0;
var e = t.get_start_count();
return 2 === e || (e - 2) % 5 == 0
}
,
t.play = function(e) {
window.adplayer && t.is_need_play_ad() ? (window.adplayer.onadcompleted
= function() {
t.increase_end_count(),
e()
}
,
t.increase_start_count(),
window.adplayer.startPreRoll()) : (t.increase_start_count(),
t.increase_end_count(),
e())
}
,
t
}();
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {
this.cachedSpriteComponent = this.entity.components.sprite,
this.entity.on("receivedamage", this.onReceiveDamage.bind(this))
}
,
e.prototype.onReceiveDamage = function(t) {
this.cachedSpriteComponent.jump(10)
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(28)
, r = function(t) {
function e() {
var e = t.call(this) || this;
return e.id = "level",
e.currentLevel = 0,
e
}
return n(e, t),
e.prototype.start = function() {
this.entity.on("networksync", this.onNetworkSync.bind(this)),
this.updateLevel(0),
this.levelService = this.world.services.getService(o.default)
}
,
e.prototype.onNetworkSync = function(t) {
t.hasOwnProperty("level") && (this.updateLevel(t.level),
this.entity.isLocalPlayer() && this.levelService.setLevel(t.level)),
t.hasOwnProperty("exp") && this.entity.isLocalPlayer() &&
this.levelService.setProgress(t.exp)
}
,
e.prototype.updateLevel = function(t) {
this.currentLevel = t;
var e = Phaser.Math.clamp(.6 + t / 50, .6, 1.2);
this.entity.components.sprite.sprite.scale.set(e, e);
var i = this.entity.components.hat;
i && i.setScale(e)
}
,
e
}(s.Component);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.id = "label",
i.labelColor = "#ffffff",
i.offset = e,
i
}
return n(e, t),
e.prototype.start = function() {
this.entity.on("networksync", this.onNetworkSync.bind(this)),
this.cachedTransform = this.entity.components.transform,
this.cachedSprite = this.entity.components.sprite,
this.label = this.world.game.add.text(this.cachedTransform.position.x,
this.cachedTransform.position.y + this.offset - this.cachedSprite.sprite.height /
2, "", {
fontSize: "18px",
font: "Roboto Mono"
}),
this.label.anchor.set(.5, 1),
this.label.stroke = "rgba(0,0,0,0.7)",
this.label.strokeThickness = 3,
this.label.fill = this.labelColor
}
,
e.prototype.setPlayerName = function(t) {
this.playerName = t,
this.level > 0 ? this.label.setText(this.playerName + " (" +
(this.level + 1) + ")") : this.label.setText("" + this.playerName)
}
,
e.prototype.setColor = function(t) {
this.labelColor = t,
this.label.fill = this.labelColor
}
,
e.prototype.align = function() {
var t = this.cachedTransform.position.x
, e = this.cachedTransform.position.y + this.offset -
this.cachedSprite.sprite.height / 2;
this.label.position.set(t, e)
}
,
e.prototype.onNetworkSync = function(t) {
var e = !1;
t.hasOwnProperty("level") && (this.level = t.level,
e = !0),
t.hasOwnProperty("playerName") && t.playerName && (this.playerName =
t.playerName,
e = !0),
e && (this.level > 0 ? this.label.setText(this.playerName + " (" +
(this.level + 1) + ")") : this.label.setText("" + this.playerName))
}
,
e.prototype.update = function(t) {
this.align()
}
,
e.prototype.destroy = function() {
this.label.destroy()
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function(t) {
function e() {
var e = t.call(this) || this;
return e.id = "teamcomponent",
e.isAdmin = !1,
e
}
return n(e, t),
e.prototype.start = function() {
this.cachedSpriteComponent = this.entity.components.sprite,
this.cachedLabelComponent = this.entity.components.label,
this.cachedLabelTeamComponent = this.entity.components.teamlabel,
this.cachedHatComponent = this.entity.components.hat,
this.entity.on("networksync", this.onNetworkSync.bind(this)),
this.entity.on("hostspawn", this.updateTeamBehavior.bind(this)),
this.entity.on("hostteamchanged", this.updateTeamBehavior.bind(this))
}
,
e.prototype.onNetworkSync = function(t) {
var e = !1;
t.hasOwnProperty("networkId") && (this.networkId = t.networkId,
e = !0),
t.hasOwnProperty("teamId") && (this.teamId = t.teamId,
e = !0),
t.hasOwnProperty("teamName") && (this.teamName = t.teamName,
e = !0),
t.hasOwnProperty("isTeamAdmin") && (this.isAdmin = t.isTeamAdmin,
e = !0),
e && this.updateTeamBehavior()
}
,
e.prototype.isFriend = function(t, e) {
return t === this.world.networkId || e > -1 && e === this.world.teamId
}
,
e.prototype.updateTeamBehavior = function() {
var t = this.isFriend(this.networkId, this.teamId);
this.cachedSpriteComponent && this.cachedSpriteComponent.setColor(t ?
16777215 : 16755370),
this.cachedLabelComponent && this.cachedLabelComponent.setColor(t ?
"#ffffff" : "#ff9999"),
this.cachedLabelTeamComponent &&
this.cachedLabelTeamComponent.setColor(t ? "#ffffff" : "#ff9999"),
this.cachedHatComponent && this.cachedHatComponent.setColor(t ?
16777215 : 16772846)
}
,
e
}(s.Component);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(168)
, h = i(6)
, l = i(12)
, c = i(21)
, u = i(2)
, d = i(11)
, p = i(162)
, f = i(163)
, m = i(22)
, g = i(13)
, y = i(23)
, v = i(167)
, b = i(169)
, w = i(166)
, x = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default(!0,!0)),
s.addComponent(new
h.default(e.LAYER_MIDDLE_1,u.Atlases.AtlasesKnight.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new l.default),
s.addComponent(new c.default),
s.addComponent(new d.default(50)),
s.addComponent(new p.default(50)),
s.addComponent(new m.default(50)),
s.addComponent(new b.default(25)),
s.addComponent(new g.default),
s.isLocalPlayer() && (s.components.networktransform.interpolateRotation
= !1,
s.addComponent(new v.default),
s.addComponent(new a.default),
s.addComponent(new f.default(50))),
s.addComponent(new w.default(e.LAYER_FOREGROUND_0)),
s.addComponent(new y.default),
s
}
return n(e, t),
e
}(s.Entity);
e.default = x
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s
}
return n(e, t),
e
}(s.Entity);
e.default = a
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.MessageType
, a = i(30)
, h = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.hour = 12,
i.latestDarkness = 0,
i.world.socket.onMessage(r.DayTimeMessage, i.onDayTimeMessage.bind(i)),
i.filter = new Phaser.Filter(i.world.game,null,"\n precision
mediump float;\n \n varying vec2 vTextureCoord;\n
varying vec4 vColor;\n uniform sampler2D uSampler;\n
uniform vec3 tint;\n \n void main(void) {\n
gl_FragColor = texture2D(uSampler, vTextureCoord);\n
gl_FragColor.rgb = vec3(gl_FragColor.r * tint.r, gl_FragColor.g * tint.g,
gl_FragColor.b * tint.b);\n }\n "),
i.filter.uniforms.tint = {
type: "3f",
value: {
x: .5,
y: .5,
z: .7
}
},
i.world.game.world.filters = [i.filter],
i.world.socket.sendMessage(r.PlayerRequestDaytime, {}),
i
}
return n(e, t),
e.prototype.isNight = function() {
return this.hour >= 23 || this.hour <= 4
}
,
e.prototype.getDarknessValue = function(t) {
var e = 0;
return t > 22 && t < 23 || t > 4 && t < 5 ? e = .5 : (t >= 23 || t <=
4) && (e = 1),
e
}
,
e.prototype.update = function(t) {
var e = this.getDarknessValue(this.hour);
e = Phaser.Math.linear(this.latestDarkness, e, t),
this.latestDarkness = e,
this.latestDarkness = Phaser.Math.clamp(this.latestDarkness, 0, 1);
var i = {
x: Phaser.Math.linear(1, .6, e),
y: Phaser.Math.linear(1, .6, e),
z: Phaser.Math.linear(1, .8, e)
};
this.filter.uniforms.tint.value = {
x: i.x,
y: i.y,
z: i.z
}
}
,
e.prototype.onDayTimeMessage = function(t) {
var e = this.hour;
this.hour = Math.round(t.content.hour),
21 === e && 22 === this.hour &&
this.world.services.getService(a.default).enqueue(45, "Night is coming..")
}
,
e
}(s.Service);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(34)
, r = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.topId = -1,
i.container = document.getElementById("leaderboard"),
i
}
return n(e, t),
e.prototype.onScoreMessagePlayer = function(t) {
this.currentName = t.content.name,
this.currentRank = t.content.rank,
this.currentScore = t.content.score
}
,
e.prototype.onScoreMessage = function(t) {
this.latestLeaderboardMessage = t.content;
var e = []
, i = t.content.scoreData
, n = t.content.nameData
, s = t.content.idData
, o = t.content.teamData;
s.length > 0 && (this.topId = s[0]);
for (var r = 0; r < i.length; r++)
e.push(this.format(r + 1, n[r], i[r], s[r] === this.world.id, o[r]
> -1 && o[r] === this.world.teamId));
this.currentRank > 9 && e.push(this.format(this.currentRank + 1,
this.currentName, this.currentScore, !0, !0)),
this.container.innerHTML = '\n <div class="ui-leaderboard-player
is-header">\n <span class="player-rank">Rank</span>\n <span
class="player-name">Name</span>\n <span class="player-
score">Score</span>\n </div> \n ' + e.join(""),
this.toggle(i.length > 0)
}
,
e.prototype.toggle = function(t) {
this.container.style.visibility = t ? "visible" : "hidden"
}
,
e.prototype.format = function(t, e, i, n, s) {
return '\n <div class="ui-leaderboard-player ' + (n ? "is-
active" : s ? "is-ally" : "") + '">\n <span class="player-rank">#' + t +
'</span>\n <span class="player-name">' + o.escapeHtml(e) + '</span>\n
<span class="player-score">' + i + "</span>\n </div>\n "
}
,
e
}(s.Service);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.levelText = document.getElementById("ui-stats-level-text"),
i.levelText.innerText = "Level 1",
i.levelProgressBody = document.getElementById("ui-level-bar"),
i
}
return n(e, t),
e.prototype.setLevel = function(t) {
this.levelText.innerText = "Level " + (t + 1)
}
,
e.prototype.setProgress = function(t) {
var e = Math.round(100 * t);
e > 100 && (e = 100),
this.levelProgressBody.style.width = e + "%"
}
,
e.prototype.destroy = function() {
t.prototype.destroy.call(this)
}
,
e
}(s.Service);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = function(t) {
function e(e) {
var i = t.call(this, e) || this
, n = i.world.game.add.tilemap("mapdata");
i.tileWidth = n.tileWidth,
i.tileHeight = n.tileHeight,
i.tileWidthCount = n.width,
i.tileHeightCount = n.height,
n.addTilesetImage("map", "mapimage");
var s = n.createLayer("Ground");
return s.resizeWorld(),
i.world.game.scale.onSizeChange.add(function() {
s.resize(this.world.game.width, this.world.game.height)
}, i),
i.world.LAYER_BACKGROUND_0.add(s),
i
}
return n(e, t),
e
}(s.Service);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = function() {
function t(t, e) {
this.timeout = t,
this.text = e
}
return t
}()
, r = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.queue = [],
i.label = i.world.game.make.text(0, 0, "", {
fontSize: "18px",
font: "Roboto Mono"
}),
i.label.anchor.set(0, 1),
i.label.stroke = "rgba(0,0,0,0.7)",
i.label.strokeThickness = 3,
i.label.fill = "#fff",
i.label.fixedToCamera = !0,
i
}
return n(e, t),
e.prototype.enqueue = function(t, e) {
this.queue.push(new o(t,e))
}
,
e.prototype.update = function(t) {
this.currentMessage ? (this.world.game.scale.scaleMode ===
Phaser.ScaleManager.USER_SCALE ? this.label.cameraOffset.setTo(20 +
this.world.game.screenOffsetWidth * this.world.game.scale.scaleFactor.x,
this.world.game.height - 180 - this.world.game.screenOffsetHeight *
this.world.scale.scaleFactor.y) : this.world.game.scale.scaleMode ===
Phaser.ScaleManager.RESIZE && this.label.cameraOffset.setTo(20,
this.world.game.height - 180),
this.currentMessage.timeout > 1 && this.label.alpha < 1 ?
this.label.alpha += t : this.currentMessage.timeout < 1 && (this.label.alpha =
this.currentMessage.timeout),
this.currentMessage.timeout -= t,
this.currentMessage.timeout < 0 && (this.currentMessage = null,
this.label.parent.removeChild(this.label))) : this.queue.length > 0 &&
(this.currentMessage = this.queue.shift(),
this.label.setText(this.currentMessage.text),
this.label.alpha = 0,
this.world.LAYER_UI.add(this.label))
}
,
e.prototype.destroy = function() {
this.label.destroy()
}
,
e
}(s.Service);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.MessageType
, a = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.MAX_TIMEOUT = 1,
i.currentTimeout = 1,
i.container = document.getElementById("ping-container"),
i.toggle(!0),
i
}
return n(e, t),
e.prototype.update = function(t) {
this.currentTimeout -= t,
this.currentTimeout <= 0 && (this.currentTimeout = this.MAX_TIMEOUT,
this.world.socket.sendMessage(r.Ping, {
time: this.world.game.time.totalElapsedSeconds()
}))
}
,
e.prototype.getAveragePing = function() {
return .2
}
,
e.prototype.onPingReply = function(t) {
var e = this.world.game.time.totalElapsedSeconds() - t.content.time;
e = Math.round(1e3 * e),
this.container.innerText = e + " ms"
}
,
e.prototype.toggle = function(t) {
this.container.style.display = t ? "block" : "none"
}
,
e.prototype.destroy = function() {
this.toggle(!1)
}
,
e
}(s.Service);
e.default = a
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.ResourceType
, a = o.Protocol.ParseResourceType
, h = i(10)
, l = function(t) {
function e(e) {
var i = t.call(this, e) || this;
i.currentResources = [0, 0, 0, 0],
i.elements = [],
i.container = document.getElementById("ui-stats-resources");
for (var n in r)
if (isNaN(parseInt(n)) && "soul" !== n.toLowerCase()) {
var s = document.createElement("div");
s.innerText = "0",
s.className = "ui-stats-" + n.toLowerCase(),
i.elements.push(s),
i.container.appendChild(s)
}
return i.toggle(!0),
i
}
return n(e, t),
e.prototype.toggle = function(t) {
this.container.style.display = t ? "block" : "none"
}
,
e.prototype.sync = function(t) {
this.currentResources = t;
for (var e in this.elements)
this.elements[e].innerText = "" + t[e];
this.world.services.getService(h.CraftMenuService).updateAvailability()
}
,
e.prototype.hasResources = function(t) {
for (var e = 0, i = Object.keys(t); e < i.length; e++) {
var n = i[e]
, s = a(n);
if (this.currentResources[s] < t[n])
return !1
}
return !0
}
,
e.prototype.destroy = function() {
this.container.innerHTML = ""
}
,
e
}(s.Service);
e.default = l
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = function() {
function t() {}
return t.read = function(t) {
for (var e = t + "=", i = document.cookie.split(";"), n = 0; n <
i.length; n++) {
for (var s = i[n]; " " === s.charAt(0); )
s = s.substring(1, s.length);
if (0 === s.indexOf(e))
return decodeURIComponent(s.substring(e.length, s.length))
}
return null
}
,
t.write = function(t, e) {
var i = new Date((new Date).getTime() + 2592e6)
, n = [encodeURIComponent(t) + "=" + encodeURIComponent(e),
"domain=." + window.location.hostname, "path=/", "expires=" + i.toUTCString()];
document.cookie = n.join("; ")
}
,
t
}();
e.default = n
}
, function(t, e, i) {
"use strict";
function n(t) {
return String(t).replace(/[&<>"'\/]/g, function(t) {
return s[t]
})
}
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;",
"/": "&#x2F;"
};
e.escapeHtml = n
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
!function(t) {
function e(t) {
var e = window.location.href
, i = t.replace(/[\[\]]/g, "\\$&")
, n = new RegExp("[?&]" + i + "(=([^&#]*)|&|#|$)")
, s = n.exec(e);
return s ? s[2] ? decodeURIComponent(s[2].replace(/\+/g, " ")) : "" :
null
}
t.getUrlParameterByName = e
}(e.UrlParse || (e.UrlParse = {}))
}
, function(t, e) {
t.exports = {
nested: {
Assign: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
}
}
},
SyncObject: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
objectType: {
type: "uint32",
id: 2
},
x: {
type: "float",
id: 3
},
y: {
type: "float",
id: 4
},
rotation: {
type: "float",
id: 5
},
health: {
type: "float",
id: 6
},
maxHealth: {
type: "float",
id: 7
},
level: {
type: "uint32",
id: 8
},
exp: {
type: "float",
id: 9
},
networkId: {
type: "uint32",
id: 10
},
playerName: {
type: "string",
id: 11
},
transportId: {
type: "int32",
id: 12
},
isOpened: {
type: "bool",
id: 13
},
parentId: {
type: "int32",
id: 14
},
teamId: {
type: "int32",
id: 15
},
teamName: {
type: "string",
id: 16
},
isTeamAdmin: {
type: "bool",
id: 17
},
hatId: {
type: "int32",
id: 18
}
}
},
SyncObjectDelete: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
}
}
},
SyncChild: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
x: {
rule: "required",
type: "float",
id: 2
},
y: {
rule: "required",
type: "float",
id: 3
},
objectType: {
rule: "required",
type: "uint32",
id: 4
}
}
},
SyncChildDelete: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
objectType: {
rule: "required",
type: "uint32",
id: 4
}
}
},
ObjectSendDamage: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
directionX: {
type: "float",
id: 2
},
directionY: {
type: "float",
id: 3
}
}
},
ObjectReceiveDamage: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
}
}
},
ChatMessage: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
message: {
rule: "required",
type: "string",
id: 2
}
}
},
SyncBackpack: {
fields: {
counts: {
rule: "repeated",
type: "int32",
id: 1,
options: {
packed: !1
}
}
}
},
SyncHats: {
fields: {
hatTypes: {
rule: "repeated",
type: "int32",
id: 1,
options: {
packed: !1
}
},
currentHat: {
rule: "required",
type: "int32",
id: 2
}
}
},
Ping: {
fields: {
time: {
rule: "required",
type: "float",
id: 1
}
}
},
RequestServerInfo: {
fields: {}
},
ResponseServerInfo: {
fields: {
clientCount: {
rule: "required",
type: "int32",
id: 1
},
health: {
rule: "required",
type: "int32",
id: 2
}
}
},
FloatResources: {
fields: {
id: {
rule: "required",
type: "int32",
id: 1
},
counts: {
rule: "repeated",
type: "int32",
id: 2,
options: {
packed: !1
}
}
}
},
MapMessage: {
fields: {
data: {
rule: "repeated",
type: "int32",
id: 1,
options: {
packed: !1
}
},
teamIdData: {
rule: "repeated",
type: "int32",
id: 2,
options: {
packed: !1
}
}
}
},
LeaderboardMessage: {
fields: {
scoreData: {
rule: "repeated",
type: "int32",
id: 1,
options: {
packed: !1
}
},
nameData: {
rule: "repeated",
type: "string",
id: 2,
options: {
packed: !1
}
},
idData: {
rule: "repeated",
type: "int32",
id: 3,
options: {
packed: !1
}
},
teamData: {
rule: "repeated",
type: "int32",
id: 4,
options: {
packed: !1
}
},
teamNameData: {
rule: "repeated",
type: "string",
id: 5,
options: {
packed: !1
}
}
}
},
LeaderboardMessagePlayer: {
fields: {
score: {
rule: "required",
type: "int32",
id: 1
},
name: {
rule: "required",
type: "string",
id: 2
},
id: {
rule: "required",
type: "int32",
id: 3
},
rank: {
rule: "required",
type: "int32",
id: 4
}
}
},
ForceDisconnect: {
fields: {
reason: {
rule: "required",
type: "int32",
id: 1
}
}
},
PackedMessage: {
fields: {
sizes: {
rule: "repeated",
type: "uint32",
id: 1,
options: {
packed: !1
}
},
message: {
type: "bytes",
id: 2
}
}
},
DayTimeMessage: {
fields: {
hour: {
rule: "required",
type: "float",
id: 1
}
}
},
ServerVersion: {
fields: {
version: {
rule: "required",
type: "int32",
id: 1
}
}
},
PlayerInput: {
fields: {
x: {
rule: "required",
type: "float",
id: 1
},
y: {
rule: "required",
type: "float",
id: 2
},
rotation: {
rule: "required",
type: "float",
id: 3
}
}
},
PlayerCheat: {
fields: {
cheatType: {
rule: "required",
type: "uint32",
id: 1
},
password: {
rule: "required",
type: "string",
id: 2
}
}
},
PlayerAction: {
fields: {
x: {
rule: "required",
type: "float",
id: 1
},
y: {
rule: "required",
type: "float",
id: 2
},
action: {
rule: "required",
type: "uint32",
id: 3
}
}
},
PlayerSpawnRequest: {
fields: {
name: {
type: "string",
id: 1
}
}
},
PlayerBuildRequest: {
fields: {
x: {
rule: "required",
type: "float",
id: 1
},
y: {
rule: "required",
type: "float",
id: 2
},
buildingType: {
rule: "required",
type: "uint32",
id: 3
}
}
},
PlayerBuildResponse: {
fields: {
success: {
rule: "required",
type: "bool",
id: 1
}
}
},
PlayerChatRequest: {
fields: {
message: {
rule: "required",
type: "string",
id: 1
}
}
},
PlayerUnmountRequest: {
fields: {}
},
PlayerSetViewportSize: {
fields: {
width: {
rule: "required",
type: "int32",
id: 1
},
height: {
rule: "required",
type: "int32",
id: 2
}
}
},
PlayerTeamPingRequest: {
fields: {}
},
PlayerTeamPingResponse: {
fields: {
playerId: {
rule: "required",
type: "int32",
id: 1
},
playerName: {
rule: "required",
type: "string",
id: 2
},
x: {
rule: "required",
type: "float",
id: 3
},
y: {
rule: "required",
type: "float",
id: 4
}
}
},
PlayerRequestDaytime: {
fields: {}
},
PlayerSelectHat: {
fields: {
hatType: {
rule: "required",
type: "int32",
id: 1
}
}
},
PlayerCreateTeam: {
fields: {
name: {
rule: "required",
type: "string",
id: 1
}
}
},
PlayerJoinTeam: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
}
}
},
PlayerApproveRequest: {
fields: {
requestId: {
rule: "required",
type: "uint32",
id: 1
}
}
},
PlayerDeclineRequest: {
fields: {
requestId: {
rule: "required",
type: "uint32",
id: 1
}
}
},
PlayerLeaveTeam: {
fields: {}
},
PlayerKickRequest: {
fields: {
networkId: {
rule: "required",
type: "uint32",
id: 2
}
}
},
PlayerTeamMembersRequest: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
}
}
},
PlayerTeamMembersResponse: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
},
networkId: {
rule: "repeated",
type: "uint32",
id: 2,
options: {
packed: !1
}
},
name: {
rule: "repeated",
type: "string",
id: 3,
options: {
packed: !1
}
}
}
},
PlayerTeamListRequest: {
fields: {}
},
PlayerTeamListResponse: {
fields: {
teamId: {
rule: "repeated",
type: "uint32",
id: 1,
options: {
packed: !1
}
},
teamName: {
rule: "repeated",
type: "string",
id: 2,
options: {
packed: !1
}
},
memberCount: {
rule: "repeated",
type: "uint32",
id: 3,
options: {
packed: !1
}
}
}
},
NotifyTeamCreated: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
},
teamName: {
rule: "required",
type: "string",
id: 2
}
}
},
NotifyTeamRemoved: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
}
}
},
NotifyJoinRequestCreated: {
fields: {
id: {
rule: "required",
type: "uint32",
id: 1
},
teamId: {
rule: "required",
type: "uint32",
id: 2
},
fromName: {
rule: "required",
type: "string",
id: 3
}
}
},
NotifyJoinRequestRemoved: {
fields: {
id: {
rule: "required",
type: "uint32",
id: 1
}
}
},
NotifyMemberJoin: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
},
memberId: {
rule: "required",
type: "uint32",
id: 2
},
memberName: {
rule: "required",
type: "string",
id: 3
}
}
},
NotifyMemberLeave: {
fields: {
teamId: {
rule: "required",
type: "uint32",
id: 1
},
memberId: {
rule: "required",
type: "uint32",
id: 2
}
}
}
}
}
}
, function(t, e, i) {
"use strict";
(function(t) {
function n() {
var t = 1920
, e = 1080
, i = {
width: t,
height: e,
renderer: Phaser.AUTO,
antialias: !0,
resolution: 1,
parent: "gamecanvas"
};
new m(i)
}
var s = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
}),
t.Config = i(195),
t.p2 = i(153),
t.PIXI = i(155),
t.Phaser = i(154);
var o = (i(196),
i(18));
t.Protocol = o.Root.fromJSON(i(36));
var r = i(191)
, a = i(182)
, h = i(188)
, l = i(183)
, c = i(186)
, u = i(184)
, d = i(185)
, p = i(187)
, f = i(2)
, m = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.state.add("boot", a.default),
i.state.add("preloader", h.default),
i.state.add("connection", l.default),
i.state.add("game", c.default),
i.state.add("crash", u.default),
i.state.add("full", d.default),
i.state.add("kicked", p.default),
i.state.start("boot"),
i
}
return s(e, t),
e
}(Phaser.Game);
window.onload = function() {
var t = null
, e = ["Roboto Mono"];
if (e.length > 0 && (t = t || {},
t.google = {
families: e
}),
Object.keys(f.CustomWebFonts).length > 0) {
t = t || {},
t.custom = {
families: [],
urls: []
};
for (var i in f.CustomWebFonts)
t.custom.families.push(f.CustomWebFonts[i].getFamily()),
t.custom.urls.push(f.CustomWebFonts[i].getCSS())
}
var s = ["UCxwNOfyNeepb-ltHx4zPAdA", "UC64R30QVnhyM1DNaXdzrHxQ",
"UCMf65CSde0GZulPmD7nU4bg", "UC-wxm3EEFILAjkLLcckvIIA", "UCmSUz2Xqyw2Xfb5rSIOgNwQ",
"UCVLo9brXBWrCttMaGzvm0-Q", "UCH0-0_0XNqkg8dTLYtFaWRg"]
, o = ['If you are a Youtuber, simply follow "For Youtubers" link at
the bottom of the page!', "If you have any suggestions or ideas regarding the game,
please let us know!", "Finding a pig with a saddle is a great luck!", "You need to
build more towers to stay on top of the leaderboard!", 'Invite your friends using
"Create party link" at the bottom of the page in order to play together!', "Nothing
ventured, nothing gained.", "Are you going to attack the enemy? Don't forget to
leave guards in the castle!", "If you need a lot of food, make beds as soon as
possible!", "You can block enemy doors by building your walls nearby.", "The number
of wall blocks is limited, but you can save some by building a castle near the
border of the world.", "When attacking the enemy, you can create your guards next
to him.", "If your mercenaries are killed during the battle, you can instantly
create new ones. Make sure you always have enough food for it.", "Take good care of
your peasants since higher-level units extract more resources.", "The stone of life
saves you life, but you lose all the resources you have collected.", "If you died
and used the stone of life, do not forget to build a new one!", "After defeating
your enemy, you will get a quarter of all his resources, including gold.",
"Sometimes the best defense is a good offense!", "The battle for glory has begun!"]
, a = s[Math.floor(Math.random() * s.length)]
, h = document.createElement("div");
h.innerHTML = '<div class="g-ytsubscribe" id="ytbutton" data-
channelid="' + a + '" data-layout="full" data-theme="dark" data-
count="default"></div>',
document.getElementById("featuredyoutuber").appendChild(h);
var l = document.createElement("script");
l.src = "https://apis.google.com/js/platform.js",
document.body.appendChild(l);
var c = document.getElementById("motd")
, u = document.getElementById("motdcontent")
, d = o[Math.floor(Math.random() * o.length)];
d && (u.innerText = d,
c.style.display = "block"),
null === t ? n() : (t.active = n,
r.load(t))
}
}
).call(e, i(193))
}
, function(t, e, i) {
t.exports = i.p + "assets/04cfa01d0b487388ebd2674a5a92183e.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/78412f712a525b074f7c96819d17c111.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/c6b497e2e9cadcaec69b5bc0bc5e6e49.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/d014f0796d7b5fc13d46971342767bf0.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/710baca51270254428007b79eb60ea41.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/b6d19bc47bca29636b58790fd2f6c768.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d2fc29a9afdea6132ae619af652bc780.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/3dd171292492cedbc602e9165d35916f.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5dec327b1f38e3543ecf9e459c5a3a64.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/cc3c15f640fabc73629a8519200182f8.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/3467cbad4bbd372d8ee215c6cfbb1451.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/02e4edf826b6bf0d6280e5edd42fa2da.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5dec327b1f38e3543ecf9e459c5a3a64.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/c0bf0d728f3d771bbe4de0537e7d7a54.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/224de2321b8e55bd9b19f2410807edef.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/6c6631b4b0070d945cdfd1b7676c7e35.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/e49770e37e01c2f08c7a982392556ebb.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/964384689b4b21b115dd46f820e0d645.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/3467cbad4bbd372d8ee215c6cfbb1451.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/299630cc6145bf089f78890bf5f7ccb0.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/e1975518c58f74bc3a96662c26f7e74a.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/0e69eb5e72046ef62b863421ae74c764.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/356caac78b794a7b6fcfb6fbc13749bc.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/b726e7c72b8fabbcf638102be434f3bd.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/9d4fa9b58ab5aff4cde2f46437691acf.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/634db99d32bdf1ce63dca2a2302286a2.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ab4922f341ae50b7024c5e0cadca13b7.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/7df9f61d2f009f1542da878be0f39e19.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5634ed94258b632c2ec5319565ac71ac.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/1af438cd1979d002aef688ce2e07417e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/fb37484eb074a2ff89226ffba7ff4a61.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/c0f94c260f1c238d5c3bb3fe492f4497.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/cb98f3fa3e3228025f78a337119c2406.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/1e4b321a51e1f970b601da216a85fed6.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5d6a5b24a4921fcec7fdda6ce5452af7.css"
}
, function(t, e, i) {
t.exports = i.p + "assets/cd5bcd18e8ff4b5e33d406654f883e7b.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/192cb9459cbc0f9e73e2591b700f1857.svg"
}
, function(t, e, i) {
t.exports = i.p + "assets/57010b43d6e298672a1e1604bfca3826.ico"
}
, function(t, e, i) {
t.exports = i.p + "assets/0c9899ea14e4e6fa4218da8c116a942d.gif"
}
, function(t, e, i) {
t.exports = i.p + "assets/27b90c0157963b55807e27afd375624d.svg"
}
, function(t, e, i) {
t.exports = i.p + "assets/a83bae3e0b6add5a5c0a6f3753e70f5a.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/553fd41d991bbca46f46fbc149fe3d46.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/a7c22672f97b2d68c71b648f9a5db412.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/eadc3c489a20f831b7093562a1563ead.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ee0419002e3f148747e3a47d11a28e93.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5162a275548350b68d5c041e7102ae6a.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/93164d8ad1e1347ab45987e05217ca0e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/f1b1d04dcd0218af1bb0362ec1781848.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/767d23349a7c43027ac9cb9a44f204df.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/6dd2d20af5e192eaff662a99db9cee74.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/864635eac39a36a803da65201603db27.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d251ba12560c7f150c91c1c10b144728.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/1489b604ae91d1210326f5900bf28a93.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/c262a6163ecb162955f0ced4ba51bda4.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/6567a2c61cf4ff0a806f9064da7533bf.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5ce7b79dc3f396543b16f5e0d02523af.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/c0e012c15f789095232de0be082a6260.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/846bbad0068e48346dda41cf829876b4.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/053cb4e508e5b8d01e937abecd6b8e47.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/368fa1f4e8ff30d426f38db081404433.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/04482872bd7974ffe609ca787f0818bc.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d22067b701a535e847c308fa12b20ad3.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/13963d7105e6045da30baf20003cad00.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d772918a5bace372ea7f46234d92405e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/7dc078b7c9c3d76ceb239c8a2e2bd218.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/9e1ffabe36149bb7cb52053cc398b7ba.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d1f207afa97f4a71f7bd3f883eebc306.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/8f21a1a804e3095ee1674090f07f691e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ff1e93ec37bc12bb21366695bdb2ccb5.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/b7417e4d05911cfc0693f95bec098f7e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/4a18be23ef2f121bc532d83d9f17468f.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/8530b8fe3a2f941f6d41819c57e6b34d.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/769068f65f2c9b8e0c5dd8fe7bcced53.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/21b49cf98cc5a66ed9927bdd7b956e8d.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/5840c7c6caa1e940384812ce77586bd6.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/c1d99ae4a1bd0f6c6f7313f20721c958.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/fa6672d125f2cf279ab4849a54dbab93.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/4b05e327929edd6d3e9d10ecfd3bc77a.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ff3b7cdf575f812d7ec02316563ad881.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/664d43fd30e91b92145afd8310cd8c99.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/d44015fb7be9ef4e16fb3ddeb48a1e35.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/44b835f9b24dc8ffe92595c5b079f18c.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ec7196ce7e356728ae87d783b2627d56.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/185e62f2cb1aea41d18846a2d1d82b2a.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/f23e5c71d5f08d545d7935fdd2718989.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/27317d6d1c8c4592fe5be1400970caf5.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/4660fed94ba4a8fd9374a800e34aefdf.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/27317d6d1c8c4592fe5be1400970caf5.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/17f8da00f7249a55b8913d22dfde4179.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/f1fcc7123efb2433cb604cb5c7835d6f.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/acbc2bcf2a3be49cf0b3bd4965f943d5.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/b6a0de7e757a80a76267887ae855cb04.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/13bd3d4531615fd03f843de3b4f1203f.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/ef5f5fa34ab46ef4857129eecfe68986.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/8a925bf7f3a540920bee07e337c7a7ee.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/40df9a40f20d7a4d8b62eb3fdfc81b4b.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/31f8af06090c180e2f092f760fb5c3da.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/54cc12793220036ec8d384ed1bc2d304.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/816fe90f2d641b24f6314cc3a915382d.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/7b46e2f072b1b93124f2f4ae3b5dc3d4.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/854fff3dc92b0e28c005cdaeaf67d324.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/aaa5a76af5f494c100c5c5490db9a68e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/2d9a50c6d9a16a801c3e2cef8965c44e.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/55e5f5b023b6a94c90fdd60fe3724fe5.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/4a7c8a1293089dff508f71ca547f9fb6.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/19c485055f217667bf7d77ea8fec3c1f.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/271db0f086205bf8d2c2ef8dfaf25bfe.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/9bcc6e44516e29d033f747cab990c48b.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/6fa8813a38d00950374dc6a0c0bad03a.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/58c71e98729004c0c69ca81df4d1d9e7.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/0eb9046109fd6c33212bce8e480e8b57.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/198d8df9361a80b8c793a7524c96ca87.json"
}
, function(t, e, i) {
t.exports = i.p + "assets/3baf1be783f3628b507e72e4ddcf3146.png"
}
, function(t, e, i) {
t.exports = i.p + "assets/e2177030752e51af870d02ff561e391d.wav"
}
, function(t, e, i) {
var n, s, o;
/**
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/long.js for details
*/
!function(i, r) {
s = [],
n = r,
void 0 !== (o = "function" == typeof n ? n.apply(e, s) : n) && (t.exports =
o)
}(0, function() {
"use strict";
function t(t, e, i) {
this.low = 0 | t,
this.high = 0 | e,
this.unsigned = !!i
}
function e(t) {
return !0 === (t && t.__isLong__)
}
function i(t, e) {
var i, n, o;
return e ? (t >>>= 0,
(o = 0 <= t && t < 256) && (n = h[t]) ? n : (i = s(t, (0 | t) < 0 ?
-1 : 0, !0),
o && (h[t] = i),
i)) : (t |= 0,
(o = -128 <= t && t < 128) && (n = a[t]) ? n : (i = s(t, t < 0 ? -1 :
0, !1),
o && (a[t] = i),
i))
}
function n(t, e) {
if (isNaN(t) || !isFinite(t))
return e ? y : g;
if (e) {
if (t < 0)
return y;
if (t >= p)
return _
} else {
if (t <= -f)
return P;
if (t + 1 >= f)
return x
}
return t < 0 ? n(-t, e).neg() : s(t % d | 0, t / d | 0, e)
}
function s(e, i, n) {
return new t(e,i,n)
}
function o(t, e, i) {
if (0 === t.length)
throw Error("empty string");
if ("NaN" === t || "Infinity" === t || "+Infinity" === t || "-Infinity"
=== t)
return g;
if ("number" == typeof e ? (i = e,
e = !1) : e = !!e,
(i = i || 10) < 2 || 36 < i)
throw RangeError("radix");
var s;
if ((s = t.indexOf("-")) > 0)
throw Error("interior hyphen");
if (0 === s)
return o(t.substring(1), e, i).neg();
for (var r = n(l(i, 8)), a = g, h = 0; h < t.length; h += 8) {
var c = Math.min(8, t.length - h)
, u = parseInt(t.substring(h, h + c), i);
if (c < 8) {
var d = n(l(i, c));
a = a.mul(d).add(n(u))
} else
a = a.mul(r),
a = a.add(n(u))
}
return a.unsigned = e,
a
}
function r(e) {
return e instanceof t ? e : "number" == typeof e ? n(e) : "string" ==
typeof e ? o(e) : s(e.low, e.high, e.unsigned)
}
t.prototype.__isLong__,
Object.defineProperty(t.prototype, "__isLong__", {
value: !0,
enumerable: !1,
configurable: !1
}),
t.isLong = e;
var a = {}
, h = {};
t.fromInt = i,
t.fromNumber = n,
t.fromBits = s;
var l = Math.pow;
t.fromString = o,
t.fromValue = r;
var c = 65536
, u = 1 << 24
, d = c * c
, p = d * d
, f = p / 2
, m = i(u)
, g = i(0);
t.ZERO = g;
var y = i(0, !0);
t.UZERO = y;
var v = i(1);
t.ONE = v;
var b = i(1, !0);
t.UONE = b;
var w = i(-1);
t.NEG_ONE = w;
var x = s(-1, 2147483647, !1);
t.MAX_VALUE = x;
var _ = s(-1, -1, !0);
t.MAX_UNSIGNED_VALUE = _;
var P = s(0, -2147483648, !1);
t.MIN_VALUE = P;
var T = t.prototype;
return T.toInt = function() {
return this.unsigned ? this.low >>> 0 : this.low
}
,
T.toNumber = function() {
return this.unsigned ? (this.high >>> 0) * d + (this.low >>> 0) :
this.high * d + (this.low >>> 0)
}
,
T.toString = function(t) {
if ((t = t || 10) < 2 || 36 < t)
throw RangeError("radix");
if (this.isZero())
return "0";
if (this.isNegative()) {
if (this.eq(P)) {
var e = n(t)
, i = this.div(e)
, s = i.mul(e).sub(this);
return i.toString(t) + s.toInt().toString(t)
}
return "-" + this.neg().toString(t)
}
for (var o = n(l(t, 6), this.unsigned), r = this, a = ""; ; ) {
var h = r.div(o)
, c = r.sub(h.mul(o)).toInt() >>> 0
, u = c.toString(t);
if (r = h,
r.isZero())
return u + a;
for (; u.length < 6; )
u = "0" + u;
a = "" + u + a
}
}
,
T.getHighBits = function() {
return this.high
}
,
T.getHighBitsUnsigned = function() {
return this.high >>> 0
}
,
T.getLowBits = function() {
return this.low
}
,
T.getLowBitsUnsigned = function() {
return this.low >>> 0
}
,
T.getNumBitsAbs = function() {
if (this.isNegative())
return this.eq(P) ? 64 : this.neg().getNumBitsAbs();
for (var t = 0 != this.high ? this.high : this.low, e = 31; e > 0 && 0
== (t & 1 << e); e--)
;
return 0 != this.high ? e + 33 : e + 1
}
,
T.isZero = function() {
return 0 === this.high && 0 === this.low
}
,
T.isNegative = function() {
return !this.unsigned && this.high < 0
}
,
T.isPositive = function() {
return this.unsigned || this.high >= 0
}
,
T.isOdd = function() {
return 1 == (1 & this.low)
}
,
T.isEven = function() {
return 0 == (1 & this.low)
}
,
T.equals = function(t) {
return e(t) || (t = r(t)),
(this.unsigned === t.unsigned || this.high >>> 31 != 1 || t.high >>> 31
!= 1) && (this.high === t.high && this.low === t.low)
}
,
T.eq = T.equals,
T.notEquals = function(t) {
return !this.eq(t)
}
,
T.neq = T.notEquals,
T.lessThan = function(t) {
return this.comp(t) < 0
}
,
T.lt = T.lessThan,
T.lessThanOrEqual = function(t) {
return this.comp(t) <= 0
}
,
T.lte = T.lessThanOrEqual,
T.greaterThan = function(t) {
return this.comp(t) > 0
}
,
T.gt = T.greaterThan,
T.greaterThanOrEqual = function(t) {
return this.comp(t) >= 0
}
,
T.gte = T.greaterThanOrEqual,
T.compare = function(t) {
if (e(t) || (t = r(t)),
this.eq(t))
return 0;
var i = this.isNegative()
, n = t.isNegative();
return i && !n ? -1 : !i && n ? 1 : this.unsigned ? t.high >>> 0 >
this.high >>> 0 || t.high === this.high && t.low >>> 0 > this.low >>> 0 ? -1 : 1 :
this.sub(t).isNegative() ? -1 : 1
}
,
T.comp = T.compare,
T.negate = function() {
return !this.unsigned && this.eq(P) ? P : this.not().add(v)
}
,
T.neg = T.negate,
T.add = function(t) {
e(t) || (t = r(t));
var i = this.high >>> 16
, n = 65535 & this.high
, o = this.low >>> 16
, a = 65535 & this.low
, h = t.high >>> 16
, l = 65535 & t.high
, c = t.low >>> 16
, u = 65535 & t.low
, d = 0
, p = 0
, f = 0
, m = 0;
return m += a + u,
f += m >>> 16,
m &= 65535,
f += o + c,
p += f >>> 16,
f &= 65535,
p += n + l,
d += p >>> 16,
p &= 65535,
d += i + h,
d &= 65535,
s(f << 16 | m, d << 16 | p, this.unsigned)
}
,
T.subtract = function(t) {
return e(t) || (t = r(t)),
this.add(t.neg())
}
,
T.sub = T.subtract,
T.multiply = function(t) {
if (this.isZero())
return g;
if (e(t) || (t = r(t)),
t.isZero())
return g;
if (this.eq(P))
return t.isOdd() ? P : g;
if (t.eq(P))
return this.isOdd() ? P : g;
if (this.isNegative())
return t.isNegative() ? this.neg().mul(t.neg()) :
this.neg().mul(t).neg();
if (t.isNegative())
return this.mul(t.neg()).neg();
if (this.lt(m) && t.lt(m))
return n(this.toNumber() * t.toNumber(), this.unsigned);
var i = this.high >>> 16
, o = 65535 & this.high
, a = this.low >>> 16
, h = 65535 & this.low
, l = t.high >>> 16
, c = 65535 & t.high
, u = t.low >>> 16
, d = 65535 & t.low
, p = 0
, f = 0
, y = 0
, v = 0;
return v += h * d,
y += v >>> 16,
v &= 65535,
y += a * d,
f += y >>> 16,
y &= 65535,
y += h * u,
f += y >>> 16,
y &= 65535,
f += o * d,
p += f >>> 16,
f &= 65535,
f += a * u,
p += f >>> 16,
f &= 65535,
f += h * c,
p += f >>> 16,
f &= 65535,
p += i * d + o * u + a * c + h * l,
p &= 65535,
s(y << 16 | v, p << 16 | f, this.unsigned)
}
,
T.mul = T.multiply,
T.divide = function(t) {
if (e(t) || (t = r(t)),
t.isZero())
throw Error("division by zero");
if (this.isZero())
return this.unsigned ? y : g;
var i, s, o;
if (this.unsigned) {
if (t.unsigned || (t = t.toUnsigned()),
t.gt(this))
return y;
if (t.gt(this.shru(1)))
return b;
o = y
} else {
if (this.eq(P)) {
if (t.eq(v) || t.eq(w))
return P;
if (t.eq(P))
return v;
return i = this.shr(1).div(t).shl(1),
i.eq(g) ? t.isNegative() ? v : w : (s = this.sub(t.mul(i)),
o = i.add(s.div(t)))
}
if (t.eq(P))
return this.unsigned ? y : g;
if (this.isNegative())
return t.isNegative() ? this.neg().div(t.neg()) :
this.neg().div(t).neg();
if (t.isNegative())
return this.div(t.neg()).neg();
o = g
}
for (s = this; s.gte(t); ) {
i = Math.max(1, Math.floor(s.toNumber() / t.toNumber()));
for (var a = Math.ceil(Math.log(i) / Math.LN2), h = a <= 48 ? 1 :
l(2, a - 48), c = n(i), u = c.mul(t); u.isNegative() || u.gt(s); )
i -= h,
c = n(i, this.unsigned),
u = c.mul(t);
c.isZero() && (c = v),
o = o.add(c),
s = s.sub(u)
}
return o
}
,
T.div = T.divide,
T.modulo = function(t) {
return e(t) || (t = r(t)),
this.sub(this.div(t).mul(t))
}
,
T.mod = T.modulo,
T.not = function() {
return s(~this.low, ~this.high, this.unsigned)
}
,
T.and = function(t) {
return e(t) || (t = r(t)),
s(this.low & t.low, this.high & t.high, this.unsigned)
}
,
T.or = function(t) {
return e(t) || (t = r(t)),
s(this.low | t.low, this.high | t.high, this.unsigned)
}
,
T.xor = function(t) {
return e(t) || (t = r(t)),
s(this.low ^ t.low, this.high ^ t.high, this.unsigned)
}
,
T.shiftLeft = function(t) {
return e(t) && (t = t.toInt()),
0 == (t &= 63) ? this : t < 32 ? s(this.low << t, this.high << t |
this.low >>> 32 - t, this.unsigned) : s(0, this.low << t - 32, this.unsigned)
}
,
T.shl = T.shiftLeft,
T.shiftRight = function(t) {
return e(t) && (t = t.toInt()),
0 == (t &= 63) ? this : t < 32 ? s(this.low >>> t | this.high << 32 -
t, this.high >> t, this.unsigned) : s(this.high >> t - 32, this.high >= 0 ? 0 : -1,
this.unsigned)
}
,
T.shr = T.shiftRight,
T.shiftRightUnsigned = function(t) {
if (e(t) && (t = t.toInt()),
0 === (t &= 63))
return this;
var i = this.high;
if (t < 32) {
return s(this.low >>> t | i << 32 - t, i >>> t, this.unsigned)
}
return 32 === t ? s(i, 0, this.unsigned) : s(i >>> t - 32, 0,
this.unsigned)
}
,
T.shru = T.shiftRightUnsigned,
T.toSigned = function() {
return this.unsigned ? s(this.low, this.high, !1) : this
}
,
T.toUnsigned = function() {
return this.unsigned ? this : s(this.low, this.high, !0)
}
,
T.toBytes = function(t) {
return t ? this.toBytesLE() : this.toBytesBE()
}
,
T.toBytesLE = function() {
var t = this.high
, e = this.low;
return [255 & e, e >>> 8 & 255, e >>> 16 & 255, e >>> 24 & 255, 255 &
t, t >>> 8 & 255, t >>> 16 & 255, t >>> 24 & 255]
}
,
T.toBytesBE = function() {
var t = this.high
, e = this.low;
return [t >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, 255 & t, e >>>
24 & 255, e >>> 16 & 255, e >>> 8 & 255, 255 & e]
}
,
t
})
}
, function(t, e) {
!function(i) {
if ("object" == typeof e)
t.exports = i();
else {
var n;
"undefined" != typeof window ? n = window : "undefined" != typeof
global ? n = global : "undefined" != typeof self && (n = self),
n.p2 = i()
}
}(function() {
return function t(e, i, n) {
function s(r, a) {
if (!i[r]) {
if (!e[r]) {
var h = "function" == typeof require && require;
if (!a && h)
return h(r, !0);
if (o)
return o(r, !0);
throw new Error("Cannot find module '" + r + "'")
}
var l = i[r] = {
exports: {}
};
e[r][0].call(l.exports, function(t) {
var i = e[r][1][t];
return s(i || t)
}, l, l.exports, t, e, i, n)
}
return i[r].exports
}
for (var o = "function" == typeof require && require, r = 0; r <
n.length; r++)
s(n[r]);
return s
}({
1: [function(t, e, i) {
function n() {}
var s = t("./Scalar");
e.exports = n,
n.lineInt = function(t, e, i) {
i = i || 0;
var n, o, r, a, h, l, c, u = [0, 0];
return n = t[1][1] - t[0][1],
o = t[0][0] - t[1][0],
r = n * t[0][0] + o * t[0][1],
a = e[1][1] - e[0][1],
h = e[0][0] - e[1][0],
l = a * e[0][0] + h * e[0][1],
c = n * h - a * o,
s.eq(c, 0, i) || (u[0] = (h * r - o * l) / c,
u[1] = (n * l - a * r) / c),
u
}
,
n.segmentsIntersect = function(t, e, i, n) {
var s = e[0] - t[0]
, o = e[1] - t[1]
, r = n[0] - i[0]
, a = n[1] - i[1];
if (r * o - a * s == 0)
return !1;
var h = (s * (i[1] - t[1]) + o * (t[0] - i[0])) / (r * o - a *
s)
, l = (r * (t[1] - i[1]) + a * (i[0] - t[0])) / (a * s - r *
o);
return h >= 0 && h <= 1 && l >= 0 && l <= 1
}
}
, {
"./Scalar": 4
}],
2: [function(t, e, i) {
function n() {}
e.exports = n,
n.area = function(t, e, i) {
return (e[0] - t[0]) * (i[1] - t[1]) - (i[0] - t[0]) * (e[1] -
t[1])
}
,
n.left = function(t, e, i) {
return n.area(t, e, i) > 0
}
,
n.leftOn = function(t, e, i) {
return n.area(t, e, i) >= 0
}
,
n.right = function(t, e, i) {
return n.area(t, e, i) < 0
}
,
n.rightOn = function(t, e, i) {
return n.area(t, e, i) <= 0
}
;
var s = []
, o = [];
n.collinear = function(t, e, i, r) {
if (r) {
var a = s
, h = o;
a[0] = e[0] - t[0],
a[1] = e[1] - t[1],
h[0] = i[0] - e[0],
h[1] = i[1] - e[1];
var l = a[0] * h[0] + a[1] * h[1]
, c = Math.sqrt(a[0] * a[0] + a[1] * a[1])
, u = Math.sqrt(h[0] * h[0] + h[1] * h[1]);
return Math.acos(l / (c * u)) < r
}
return 0 == n.area(t, e, i)
}
,
n.sqdist = function(t, e) {
var i = e[0] - t[0]
, n = e[1] - t[1];
return i * i + n * n
}
}
, {}],
3: [function(t, e, i) {
function n() {
this.vertices = []
}
function s(t, e, i, n, s) {
s = s || 0;
var o = e[1] - t[1]
, r = t[0] - e[0]
, h = o * t[0] + r * t[1]
, l = n[1] - i[1]
, c = i[0] - n[0]
, u = l * i[0] + c * i[1]
, d = o * c - l * r;
return a.eq(d, 0, s) ? [0, 0] : [(c * h - r * u) / d, (o * u -
l * h) / d]
}
var o = t("./Line")
, r = t("./Point")
, a = t("./Scalar");
e.exports = n,
n.prototype.at = function(t) {
var e = this.vertices
, i = e.length;
return e[t < 0 ? t % i + i : t % i]
}
,
n.prototype.first = function() {
return this.vertices[0]
}
,
n.prototype.last = function() {
return this.vertices[this.vertices.length - 1]
}
,
n.prototype.clear = function() {
this.vertices.length = 0
}
,
n.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 n = e; n < i; n++)
this.vertices.push(t.vertices[n])
}
,
n.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);
r.left(this.at(t - 1), this.at(t), this.at(t + 1)) ||
this.reverse()
}
,
n.prototype.reverse = function() {
for (var t = [], e = 0, i = this.vertices.length; e !== i; e++)
t.push(this.vertices.pop());
this.vertices = t
}
,
n.prototype.isReflex = function(t) {
return r.right(this.at(t - 1), this.at(t), this.at(t + 1))
}
;
var h = []
, l = [];
n.prototype.canSee = function(t, e) {
var i, n, s = h, a = l;
if (r.leftOn(this.at(t + 1), this.at(t), this.at(e)) &&
r.rightOn(this.at(t - 1), this.at(t), this.at(e)))
return !1;
n = r.sqdist(this.at(t), this.at(e));
for (var c = 0; c !== this.vertices.length; ++c)
if ((c + 1) % this.vertices.length !== t && c !== t &&
r.leftOn(this.at(t), this.at(e), this.at(c + 1)) && r.rightOn(this.at(t),
this.at(e), this.at(c)) && (s[0] = this.at(t),
s[1] = this.at(e),
a[0] = this.at(c),
a[1] = this.at(c + 1),
i = o.lineInt(s, a),
r.sqdist(this.at(t), i) < n))
return !1;
return !0
}
,
n.prototype.copy = function(t, e, i) {
var s = i || new n;
if (s.clear(),
t < e)
for (var o = t; o <= e; o++)
s.vertices.push(this.vertices[o]);
else {
for (var o = 0; o <= e; o++)
s.vertices.push(this.vertices[o]);
for (var o = t; o < this.vertices.length; o++)
s.vertices.push(this.vertices[o])
}
return s
}
,
n.prototype.getCutEdges = function() {
for (var t = [], e = [], i = [], s = new n, o =
Number.MAX_VALUE, r = 0; r < this.vertices.length; ++r)
if (this.isReflex(r))
for (var a = 0; a < this.vertices.length; ++a)
if (this.canSee(r, a)) {
e = this.copy(r, a, s).getCutEdges(),
i = this.copy(a, r, s).getCutEdges();
for (var h = 0; h < i.length; h++)
e.push(i[h]);
e.length < o && (t = e,
o = e.length,
t.push([this.at(r), this.at(a)]))
}
return t
}
,
n.prototype.decomp = function() {
var t = this.getCutEdges();
return t.length > 0 ? this.slice(t) : [this]
}
,
n.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 n = t[i], s = 0; s < e.length; s++) {
var o = e[s]
, r = o.slice(n);
if (r) {
e.splice(s, 1),
e.push(r[0], r[1]);
break
}
}
return e
}
var n = t
, i = this.vertices.indexOf(n[0])
, s = this.vertices.indexOf(n[1]);
return -1 != i && -1 != s && [this.copy(i, s), this.copy(s, i)]
}
,
n.prototype.isSimple = function() {
for (var t = this.vertices, e = 0; e < t.length - 1; e++)
for (var i = 0; i < e - 1; i++)
if (o.segmentsIntersect(t[e], t[e + 1], t[i], t[i +
1]))
return !1;
for (var e = 1; e < t.length - 2; e++)
if (o.segmentsIntersect(t[0], t[t.length - 1], t[e], t[e +
1]))
return !1;
return !0
}
,
n.prototype.quickDecomp = function(t, e, i, o, a, h) {
a = a || 100,
h = h || 0,
o = o || 25,
t = void 0 !== t ? t : [],
e = e || [],
i = i || [];
var l = [0, 0]
, c = [0, 0]
, u = [0, 0]
, d = 0
, p = 0
, f = 0
, m = 0
, g = 0
, y = 0
, v = 0
, b = new n
, w = new n
, x = this
, _ = this.vertices;
if (_.length < 3)
return t;
if (++h > a)
return console.warn("quickDecomp: max level (" + a + ")
reached."),
t;
for (var P = 0; P < this.vertices.length; ++P)
if (x.isReflex(P)) {
e.push(x.vertices[P]),
d = p = Number.MAX_VALUE;
for (var T = 0; T < this.vertices.length; ++T)
r.left(x.at(P - 1), x.at(P), x.at(T)) &&
r.rightOn(x.at(P - 1), x.at(P), x.at(T - 1)) && (u = s(x.at(P - 1), x.at(P),
x.at(T), x.at(T - 1)),
r.right(x.at(P + 1), x.at(P), u) && (f =
r.sqdist(x.vertices[P], u)) < p && (p = f,
c = u,
y = T)),
r.left(x.at(P + 1), x.at(P), x.at(T + 1)) &&
r.rightOn(x.at(P + 1), x.at(P), x.at(T)) && (u = s(x.at(P + 1), x.at(P), x.at(T),
x.at(T + 1)),
r.left(x.at(P - 1), x.at(P), u) && (f =
r.sqdist(x.vertices[P], u)) < d && (d = f,
l = u,
g = T));
if (y == (g + 1) % this.vertices.length)
u[0] = (c[0] + l[0]) / 2,
u[1] = (c[1] + l[1]) / 2,
i.push(u),
P < g ? (b.append(x, P, g + 1),
b.vertices.push(u),
w.vertices.push(u),
0 != y && w.append(x, y, x.vertices.length),
w.append(x, 0, P + 1)) : (0 != P && b.append(x, P,
x.vertices.length),
b.append(x, 0, g + 1),
b.vertices.push(u),
w.vertices.push(u),
w.append(x, y, P + 1));
else {
if (y > g && (g += this.vertices.length),
m = Number.MAX_VALUE,
g < y)
return t;
for (var T = y; T <= g; ++T)
r.leftOn(x.at(P - 1), x.at(P), x.at(T)) &&
r.rightOn(x.at(P + 1), x.at(P), x.at(T)) && (f = r.sqdist(x.at(P), x.at(T))) < m &&
(m = f,
v = T % this.vertices.length);
P < v ? (b.append(x, P, v + 1),
0 != v && w.append(x, v, _.length),
w.append(x, 0, P + 1)) : (0 != P && b.append(x, P,
_.length),
b.append(x, 0, v + 1),
w.append(x, v, P + 1))
}
return b.vertices.length < w.vertices.length ?
(b.quickDecomp(t, e, i, o, a, h),
w.quickDecomp(t, e, i, o, a, h)) : (w.quickDecomp(t, e,
i, o, a, h),
b.quickDecomp(t, e, i, o, a, h)),
t
}
return t.push(this),
t
}
,
n.prototype.removeCollinearPoints = function(t) {
for (var e = 0, i = this.vertices.length - 1;
this.vertices.length > 3 && i >= 0; --i)
r.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 n() {}
e.exports = n,
n.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.1",
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.1"
}
}
}
, {}],
7: [function(t, e, i) {
function n(t) {
this.lowerBound = s.create(),
t && t.lowerBound && s.copy(this.lowerBound, t.lowerBound),
this.upperBound = s.create(),
t && t.upperBound && s.copy(this.upperBound, t.upperBound)
}
var s = t("../math/vec2");
t("../utils/Utils");
e.exports = n;
var o = s.create();
n.prototype.setFromPoints = function(t, e, i, n) {
var r = this.lowerBound
, a = this.upperBound;
"number" != typeof i && (i = 0),
0 !== i ? s.rotate(r, t[0], i) : s.copy(r, t[0]),
s.copy(a, r);
for (var h = Math.cos(i), l = Math.sin(i), c = 1; c < t.length;
c++) {
var u = t[c];
if (0 !== i) {
var d = u[0]
, p = u[1];
o[0] = h * d - l * p,
o[1] = l * d + h * p,
u = o
}
for (var f = 0; f < 2; f++)
u[f] > a[f] && (a[f] = u[f]),
u[f] < r[f] && (r[f] = u[f])
}
e && (s.add(this.lowerBound, this.lowerBound, e),
s.add(this.upperBound, this.upperBound, e)),
n && (this.lowerBound[0] -= n,
this.lowerBound[1] -= n,
this.upperBound[0] += n,
this.upperBound[1] += n)
}
,
n.prototype.copy = function(t) {
s.copy(this.lowerBound, t.lowerBound),
s.copy(this.upperBound, t.upperBound)
}
,
n.prototype.extend = function(t) {
for (var e = 2; e--; ) {
var i = t.lowerBound[e];
this.lowerBound[e] > i && (this.lowerBound[e] = i);
var n = t.upperBound[e];
this.upperBound[e] < n && (this.upperBound[e] = n)
}
}
,
n.prototype.overlaps = function(t) {
var e = this.lowerBound
, i = this.upperBound
, n = t.lowerBound
, s = t.upperBound;
return (n[0] <= i[0] && i[0] <= s[0] || e[0] <= s[0] && s[0] <=
i[0]) && (n[1] <= i[1] && i[1] <= s[1] || e[1] <= s[1] && s[1] <= i[1])
}
,
n.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]
}
,
n.prototype.overlapsRay = function(t) {
var e = 1 / t.direction[0]
, i = 1 / t.direction[1]
, n = (this.lowerBound[0] - t.from[0]) * e
, s = (this.upperBound[0] - t.from[0]) * e
, o = (this.lowerBound[1] - t.from[1]) * i
, r = (this.upperBound[1] - t.from[1]) * i
, a = Math.max(Math.max(Math.min(n, s), Math.min(o, r)))
, h = Math.min(Math.min(Math.max(n, s), Math.max(o, r)));
return h < 0 ? -1 : a > h ? -1 : a
}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57
}],
8: [function(t, e, i) {
function n(t) {
this.type = t,
this.result = [],
this.world = null,
this.boundingVolumeType = n.AABB
}
var s = t("../math/vec2")
, o = t("../objects/Body");
e.exports = n,
n.AABB = 1,
n.BOUNDING_CIRCLE = 2,
n.prototype.setWorld = function(t) {
this.world = t
}
,
n.prototype.getCollisionPairs = function(t) {}
;
var r = s.create();
n.boundingRadiusCheck = function(t, e) {
s.sub(r, t.position, e.position);
var i = s.squaredLength(r)
, n = t.boundingRadius + e.boundingRadius;
return i <= n * n
}
,
n.aabbCheck = function(t, e) {
return t.getAABB().overlaps(e.getAABB())
}
,
n.prototype.boundingVolumeCheck = function(t, e) {
var i;
switch (this.boundingVolumeType) {
case n.BOUNDING_CIRCLE:
i = n.boundingRadiusCheck(t, e);
break;
case n.AABB:
i = n.aabbCheck(t, e);
break;
default:
throw new Error("Bounding volume type not recognized: " +
this.boundingVolumeType)
}
return i
}
,
n.canCollide = function(t, e) {
var i = o.KINEMATIC
, n = o.STATIC;
return (t.type !== n || e.type !== n) && (!(t.type === i &&
e.type === n || t.type === n && e.type === i) && ((t.type !== i || e.type !== i) &&
((t.sleepState !== o.SLEEPING || e.sleepState !== o.SLEEPING) && !(t.sleepState ===
o.SLEEPING && e.type === n || e.sleepState === o.SLEEPING && t.type === n))))
}
,
n.NAIVE = 1,
n.SAP = 2
}
, {
"../math/vec2": 30,
"../objects/Body": 31
}],
9: [function(t, e, i) {
function n() {
s.call(this, s.NAIVE)
}
var s = (t("../shapes/Circle"),
t("../shapes/Plane"),
t("../shapes/Shape"),
t("../shapes/Particle"),
t("../collision/Broadphase"));
t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.getCollisionPairs = function(t) {
var e = t.bodies
, i = this.result;
i.length = 0;
for (var n = 0, o = e.length; n !== o; n++)
for (var r = e[n], a = 0; a < n; a++) {
var h = e[a];
s.canCollide(r, h) && this.boundingVolumeCheck(r, h) &&
i.push(r, h)
}
return i
}
,
n.prototype.aabbQuery = function(t, e, i) {
i = i || [];
for (var n = t.bodies, s = 0; s < n.length; s++) {
var o = n[s];
o.aabbNeedsUpdate && o.updateAABB(),
o.aabb.overlaps(e) && i.push(o)
}
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) {
function n() {
this.contactEquations = [],
this.frictionEquations = [],
this.enableFriction = !0,
this.enabledEquations = !0,
this.slipForce = 10,
this.frictionCoefficient = .3,
this.surfaceVelocity = 0,
this.contactEquationPool = new c({
size: 32
}),
this.frictionEquationPool = new u({
size: 64
}),
this.restitution = 0,
this.stiffness = p.DEFAULT_STIFFNESS,
this.relaxation = p.DEFAULT_RELAXATION,
this.frictionStiffness = p.DEFAULT_STIFFNESS,
this.frictionRelaxation = p.DEFAULT_RELAXATION,
this.enableFrictionReduction = !0,
this.collidingBodiesLastStep = new d,
this.contactSkinSize = .01
}
function s(t, e) {
r.set(t.vertices[0], .5 * -e.length, -e.radius),
r.set(t.vertices[1], .5 * e.length, -e.radius),
r.set(t.vertices[2], .5 * e.length, e.radius),
r.set(t.vertices[3], .5 * -e.length, e.radius)
}
function o(t, e, i, n) {
for (var s = q, o = V, l = Y, c = z, u = t, d = e.vertices, p =
null, f = 0; f !== d.length + 1; f++) {
var m = d[f % d.length]
, g = d[(f + 1) % d.length];
r.rotate(s, m, n),
r.rotate(o, g, n),
h(s, s, i),
h(o, o, i),
a(l, s, u),
a(c, o, u);
var y = r.crossLength(l, c);
if (null === p && (p = y),
y * p <= 0)
return !1;
p = y
}
return !0
}
var r = t("../math/vec2")
, a = r.sub
, h = r.add
, l = r.dot
, c = (t("../utils/Utils"),
t("../utils/ContactEquationPool"))
, u = t("../utils/FrictionEquationPool")
, d = t("../utils/TupleDictionary")
, p = t("../equations/Equation")
, f = (t("../equations/ContactEquation"),
t("../equations/FrictionEquation"),
t("../shapes/Circle"))
, m = t("../shapes/Convex")
, g = t("../shapes/Shape")
, y = (t("../objects/Body"),
t("../shapes/Box"));
e.exports = n;
var v = r.fromValues(0, 1)
, b = r.fromValues(0, 0)
, w = r.fromValues(0, 0)
, x = r.fromValues(0, 0)
, _ = r.fromValues(0, 0)
, P = r.fromValues(0, 0)
, T = r.fromValues(0, 0)
, C = r.fromValues(0, 0)
, S = r.fromValues(0, 0)
, A = r.fromValues(0, 0)
, k = r.fromValues(0, 0)
, E = r.fromValues(0, 0)
, I = r.fromValues(0, 0)
, M = r.fromValues(0, 0)
, O = r.fromValues(0, 0)
, B = r.fromValues(0, 0)
, R = r.fromValues(0, 0)
, L = r.fromValues(0, 0)
, D = r.fromValues(0, 0)
, F = []
, N = r.create()
, G = r.create();
n.prototype.bodiesOverlap = function(t, e) {
for (var i = N, n = G, s = 0, o = t.shapes.length; s !== o; s+
+) {
var r = t.shapes[s];
t.toWorldFrame(i, r.position);
for (var a = 0, h = e.shapes.length; a !== h; a++) {
var l = e.shapes[a];
if (e.toWorldFrame(n, l.position),
this[r.type | l.type](t, r, i, r.angle + t.angle, e, l,
n, l.angle + e.angle, !0))
return !0
}
}
return !1
}
,
n.prototype.collidedLastStep = function(t, e) {
var i = 0 | t.id
, n = 0 | e.id;
return !!this.collidingBodiesLastStep.get(i, n)
}
,
n.prototype.reset = function() {
this.collidingBodiesLastStep.reset();
for (var t = this.contactEquations, e = t.length; e--; ) {
var i = t[e]
, n = i.bodyA.id
, s = i.bodyB.id;
this.collidingBodiesLastStep.set(n, s, !0)
}
for (var o = this.contactEquations, r = this.frictionEquations,
a = 0; a < o.length; a++)
this.contactEquationPool.release(o[a]);
for (var a = 0; a < r.length; a++)
this.frictionEquationPool.release(r[a]);
this.contactEquations.length = this.frictionEquations.length =
0
}
,
n.prototype.createContactEquation = function(t, e, i, n) {
var s = this.contactEquationPool.get();
return s.bodyA = t,
s.bodyB = e,
s.shapeA = i,
s.shapeB = n,
s.restitution = this.restitution,
s.firstImpact = !this.collidedLastStep(t, e),
s.stiffness = this.stiffness,
s.relaxation = this.relaxation,
s.needsUpdate = !0,
s.enabled = this.enabledEquations,
s.offset = this.contactSkinSize,
s
}
,
n.prototype.createFrictionEquation = function(t, e, i, n) {
var s = this.frictionEquationPool.get();
return s.bodyA = t,
s.bodyB = e,
s.shapeA = i,
s.shapeB = n,
s.setSlipForce(this.slipForce),
s.frictionCoefficient = this.frictionCoefficient,
s.relativeVelocity = this.surfaceVelocity,
s.enabled = this.enabledEquations,
s.needsUpdate = !0,
s.stiffness = this.frictionStiffness,
s.relaxation = this.frictionRelaxation,
s.contactEquations.length = 0,
s
}
,
n.prototype.createFrictionFromContact = function(t) {
var e = this.createFrictionEquation(t.bodyA, t.bodyB, t.shapeA,
t.shapeB);
return r.copy(e.contactPointA, t.contactPointA),
r.copy(e.contactPointB, t.contactPointB),
r.rotate90cw(e.t, t.normalA),
e.contactEquations.push(t),
e
}
,
n.prototype.createFrictionFromAverage = function(t) {
var e = this.contactEquations[this.contactEquations.length - 1]
, i = this.createFrictionEquation(e.bodyA, e.bodyB, e.shapeA,
e.shapeB)
, n = e.bodyA;
e.bodyB;
r.set(i.contactPointA, 0, 0),
r.set(i.contactPointB, 0, 0),
r.set(i.t, 0, 0);
for (var s = 0; s !== t; s++)
e = this.contactEquations[this.contactEquations.length - 1
- s],
e.bodyA === n ? (r.add(i.t, i.t, e.normalA),
r.add(i.contactPointA, i.contactPointA, e.contactPointA),
r.add(i.contactPointB, i.contactPointB, e.contactPointB)) :
(r.sub(i.t, i.t, e.normalA),
r.add(i.contactPointA, i.contactPointA, e.contactPointB),
r.add(i.contactPointB, i.contactPointB, e.contactPointA)),
i.contactEquations.push(e);
var o = 1 / t;
return r.scale(i.contactPointA, i.contactPointA, o),
r.scale(i.contactPointB, i.contactPointB, o),
r.normalize(i.t, i.t),
r.rotate90cw(i.t, i.t),
i
}
,
n.prototype[g.LINE | g.CONVEX] = n.prototype.convexLine =
function(t, e, i, n, s, o, r, a, h) {
return !h && 0
}
,
n.prototype[g.LINE | g.BOX] = n.prototype.lineBox = function(t, e,
i, n, s, o, r, a, h) {
return !h && 0
}
;
var U = new y({
width: 1,
height: 1
})
, W = r.create();
n.prototype[g.CAPSULE | g.CONVEX] = n.prototype[g.CAPSULE | g.BOX]
= n.prototype.convexCapsule = function(t, e, i, n, o, a, h, l, c) {
var u = W;
r.set(u, a.length / 2, 0),
r.rotate(u, u, l),
r.add(u, u, h);
var d = this.circleConvex(o, a, u, l, t, e, i, n, c, a.radius);
r.set(u, -a.length / 2, 0),
r.rotate(u, u, l),
r.add(u, u, h);
var p = this.circleConvex(o, a, u, l, t, e, i, n, c, a.radius);
if (c && (d || p))
return !0;
var f = U;
return s(f, a),
this.convexConvex(t, e, i, n, o, f, h, l, c) + d + p
}
,
n.prototype[g.CAPSULE | g.LINE] = n.prototype.lineCapsule =
function(t, e, i, n, s, o, r, a, h) {
return !h && 0
}
;
var j = r.create()
, H = r.create()
, X = new y({
width: 1,
height: 1
});
n.prototype[g.CAPSULE | g.CAPSULE] = n.prototype.capsuleCapsule =
function(t, e, i, n, o, a, h, l, c) {
for (var u, d = j, p = H, f = 0, m = 0; m < 2; m++) {
r.set(d, (0 === m ? -1 : 1) * e.length / 2, 0),
r.rotate(d, d, n),
r.add(d, d, i);
for (var g = 0; g < 2; g++) {
r.set(p, (0 === g ? -1 : 1) * a.length / 2, 0),
r.rotate(p, p, l),
r.add(p, p, h),
this.enableFrictionReduction && (u =
this.enableFriction,
this.enableFriction = !1);
var y = this.circleCircle(t, e, d, n, o, a, p, l, c,
e.radius, a.radius);
if (this.enableFrictionReduction &&
(this.enableFriction = u),
c && y)
return !0;
f += y
}
}
this.enableFrictionReduction && (u = this.enableFriction,
this.enableFriction = !1);
var v = X;
s(v, e);
var b = this.convexCapsule(t, v, i, n, o, a, h, l, c);
if (this.enableFrictionReduction && (this.enableFriction = u),
c && b)
return !0;
if (f += b,
this.enableFrictionReduction) {
var u = this.enableFriction;
this.enableFriction = !1
}
s(v, a);
var w = this.convexCapsule(o, v, h, l, t, e, i, n, c);
return this.enableFrictionReduction && (this.enableFriction =
u),
!(!c || !w) || (f += w,
this.enableFrictionReduction && f && this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromAverage(f)),
f)
}
,
n.prototype[g.LINE | g.LINE] = n.prototype.lineLine = function(t,
e, i, n, s, o, r, a, h) {
return !h && 0
}
,
n.prototype[g.PLANE | g.LINE] = n.prototype.planeLine = function(t,
e, i, n, s, o, c, u, d) {
var p = b
, f = w
, m = x
, g = _
, y = P
, k = T
, E = C
, I = S
, M = A
, O = F
, B = 0;
r.set(p, -o.length / 2, 0),
r.set(f, o.length / 2, 0),
r.rotate(m, p, u),
r.rotate(g, f, u),
h(m, m, c),
h(g, g, c),
r.copy(p, m),
r.copy(f, g),
a(y, f, p),
r.normalize(k, y),
r.rotate90cw(M, k),
r.rotate(I, v, n),
O[0] = p,
O[1] = f;
for (var R = 0; R < O.length; R++) {
var L = O[R];
a(E, L, i);
var D = l(E, I);
if (D < 0) {
if (d)
return !0;
var N = this.createContactEquation(t, s, e, o);
B++,
r.copy(N.normalA, I),
r.normalize(N.normalA, N.normalA),
r.scale(E, I, D),
a(N.contactPointA, L, E),
a(N.contactPointA, N.contactPointA, t.position),
a(N.contactPointB, L, c),
h(N.contactPointB, N.contactPointB, c),
a(N.contactPointB, N.contactPointB, s.position),
this.contactEquations.push(N),
this.enableFrictionReduction || this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(N))
}
}
return !d && (this.enableFrictionReduction || B &&
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromAverage(B)),
B)
}
,
n.prototype[g.PARTICLE | g.CAPSULE] = n.prototype.particleCapsule =
function(t, e, i, n, s, o, r, a, h) {
return this.circleLine(t, e, i, n, s, o, r, a, h, o.radius, 0)
}
,
n.prototype[g.CIRCLE | g.LINE] = n.prototype.circleLine =
function(t, e, i, n, s, o, c, u, d, p, f) {
var p = p || 0
, f = void 0 !== f ? f : e.radius
, m = b
, g = w
, y = x
, v = _
, B = P
, R = T
, L = C
, D = S
, N = A
, G = k
, U = E
, W = I
, j = M
, H = O
, X = F;
r.set(D, -o.length / 2, 0),
r.set(N, o.length / 2, 0),
r.rotate(G, D, u),
r.rotate(U, N, u),
h(G, G, c),
h(U, U, c),
r.copy(D, G),
r.copy(N, U),
a(R, N, D),
r.normalize(L, R),
r.rotate90cw(B, L),
a(W, i, D);
var q = l(W, B);
a(v, D, c),
a(j, i, c);
var V = f + p;
if (Math.abs(q) < V) {
r.scale(m, B, q),
a(y, i, m),
r.scale(g, B, l(B, j)),
r.normalize(g, g),
r.scale(g, g, p),
h(y, y, g);
var Y = l(L, y)
, z = l(L, D)
, K = l(L, N);
if (Y > z && Y < K) {
if (d)
return !0;
var J = this.createContactEquation(t, s, e, o);
return r.scale(J.normalA, m, -1),
r.normalize(J.normalA, J.normalA),
r.scale(J.contactPointA, J.normalA, f),
h(J.contactPointA, J.contactPointA, i),
a(J.contactPointA, J.contactPointA, t.position),
a(J.contactPointB, y, c),
h(J.contactPointB, J.contactPointB, c),
a(J.contactPointB, J.contactPointB, s.position),
this.contactEquations.push(J),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(J)),
1
}
}
X[0] = D,
X[1] = N;
for (var Z = 0; Z < X.length; Z++) {
var Q = X[Z];
if (a(W, Q, i),
r.squaredLength(W) < Math.pow(V, 2)) {
if (d)
return !0;
var J = this.createContactEquation(t, s, e, o);
return r.copy(J.normalA, W),
r.normalize(J.normalA, J.normalA),
r.scale(J.contactPointA, J.normalA, f),
h(J.contactPointA, J.contactPointA, i),
a(J.contactPointA, J.contactPointA, t.position),
a(J.contactPointB, Q, c),
r.scale(H, J.normalA, -p),
h(J.contactPointB, J.contactPointB, H),
h(J.contactPointB, J.contactPointB, c),
a(J.contactPointB, J.contactPointB, s.position),
this.contactEquations.push(J),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(J)),
1
}
}
return 0
}
,
n.prototype[g.CIRCLE | g.CAPSULE] = n.prototype.circleCapsule =
function(t, e, i, n, s, o, r, a, h) {
return this.circleLine(t, e, i, n, s, o, r, a, h, o.radius)
}
,
n.prototype[g.CIRCLE | g.CONVEX] = n.prototype[g.CIRCLE | g.BOX] =
n.prototype.circleConvex = function(t, e, i, n, s, l, c, u, d, p) {
for (var p = "number" == typeof p ? p : e.radius, f = b, m = w,
g = x, y = _, v = P, T = k, C = E, S = M, A = O, I = B, L = R, D = !1, F =
Number.MAX_VALUE, N = l.vertices, G = 0; G !== N.length + 1; G++) {
var U = N[G % N.length]
, W = N[(G + 1) % N.length];
if (r.rotate(f, U, u),
r.rotate(m, W, u),
h(f, f, c),
h(m, m, c),
a(g, m, f),
r.normalize(y, g),
r.rotate90cw(v, y),
r.scale(A, v, -e.radius),
h(A, A, i),
o(A, l, c, u)) {
r.sub(I, f, A);
var j = Math.abs(r.dot(I, v));
j < F && (r.copy(L, A),
F = j,
r.scale(S, v, j),
r.add(S, S, A),
D = !0)
}
}
if (D) {
if (d)
return !0;
var H = this.createContactEquation(t, s, e, l);
return r.sub(H.normalA, L, i),
r.normalize(H.normalA, H.normalA),
r.scale(H.contactPointA, H.normalA, p),
h(H.contactPointA, H.contactPointA, i),
a(H.contactPointA, H.contactPointA, t.position),
a(H.contactPointB, S, c),
h(H.contactPointB, H.contactPointB, c),
a(H.contactPointB, H.contactPointB, s.position),
this.contactEquations.push(H),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(H)),
1
}
if (p > 0)
for (var G = 0; G < N.length; G++) {
var X = N[G];
if (r.rotate(C, X, u),
h(C, C, c),
a(T, C, i),
r.squaredLength(T) < Math.pow(p, 2)) {
if (d)
return !0;
var H = this.createContactEquation(t, s, e, l);
return r.copy(H.normalA, T),
r.normalize(H.normalA, H.normalA),
r.scale(H.contactPointA, H.normalA, p),
h(H.contactPointA, H.contactPointA, i),
a(H.contactPointA, H.contactPointA, t.position),
a(H.contactPointB, C, c),
h(H.contactPointB, H.contactPointB, c),
a(H.contactPointB, H.contactPointB, s.position),
this.contactEquations.push(H),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(H)),
1
}
}
return 0
}
;
var q = r.create()
, V = r.create()
, Y = r.create()
, z = r.create();
n.prototype[g.PARTICLE | g.CONVEX] = n.prototype[g.PARTICLE |
g.BOX] = n.prototype.particleConvex = function(t, e, i, n, s, c, u, d, p) {
var f = b
, m = w
, g = x
, y = _
, v = P
, S = T
, A = C
, E = k
, I = M
, O = L
, B = D
, R = Number.MAX_VALUE
, F = !1
, N = c.vertices;
if (!o(i, c, u, d))
return 0;
if (p)
return !0;
for (var G = 0; G !== N.length + 1; G++) {
var U = N[G % N.length]
, W = N[(G + 1) % N.length];
r.rotate(f, U, d),
r.rotate(m, W, d),
h(f, f, u),
h(m, m, u),
a(g, m, f),
r.normalize(y, g),
r.rotate90cw(v, y),
a(E, i, f);
l(E, v);
a(S, f, u),
a(A, i, u),
r.sub(O, f, i);
var j = Math.abs(r.dot(O, v));
j < R && (R = j,
r.scale(I, v, j),
r.add(I, I, i),
r.copy(B, v),
F = !0)
}
if (F) {
var H = this.createContactEquation(t, s, e, c);
return r.scale(H.normalA, B, -1),
r.normalize(H.normalA, H.normalA),
r.set(H.contactPointA, 0, 0),
h(H.contactPointA, H.contactPointA, i),
a(H.contactPointA, H.contactPointA, t.position),
a(H.contactPointB, I, u),
h(H.contactPointB, H.contactPointB, u),
a(H.contactPointB, H.contactPointB, s.position),
this.contactEquations.push(H),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(H)),
1
}
return 0
}
,
n.prototype[g.CIRCLE] = n.prototype.circleCircle = function(t, e,
i, n, s, o, l, c, u, d, p) {
var f = b
, d = d || e.radius
, p = p || o.radius;
a(f, i, l);
var m = d + p;
if (r.squaredLength(f) > Math.pow(m, 2))
return 0;
if (u)
return !0;
var g = this.createContactEquation(t, s, e, o);
return a(g.normalA, l, i),
r.normalize(g.normalA, g.normalA),
r.scale(g.contactPointA, g.normalA, d),
r.scale(g.contactPointB, g.normalA, -p),
h(g.contactPointA, g.contactPointA, i),
a(g.contactPointA, g.contactPointA, t.position),
h(g.contactPointB, g.contactPointB, l),
a(g.contactPointB, g.contactPointB, s.position),
this.contactEquations.push(g),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(g)),
1
}
,
n.prototype[g.PLANE | g.CONVEX] = n.prototype[g.PLANE | g.BOX] =
n.prototype.planeConvex = function(t, e, i, n, s, o, c, u, d) {
var p = b
, f = w
, m = x
, g = 0;
r.rotate(f, v, n);
for (var y = 0; y !== o.vertices.length; y++) {
var _ = o.vertices[y];
if (r.rotate(p, _, u),
h(p, p, c),
a(m, p, i),
l(m, f) <= 0) {
if (d)
return !0;
g++;
var P = this.createContactEquation(t, s, e, o);
a(m, p, i),
r.copy(P.normalA, f);
var T = l(m, P.normalA);
r.scale(m, P.normalA, T),
a(P.contactPointB, p, s.position),
a(P.contactPointA, p, m),
a(P.contactPointA, P.contactPointA, t.position),
this.contactEquations.push(P),
this.enableFrictionReduction || this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(P))
}
}
return this.enableFrictionReduction && this.enableFriction && g
&& this.frictionEquations.push(this.createFrictionFromAverage(g)),
g
}
,
n.prototype[g.PARTICLE | g.PLANE] = n.prototype.particlePlane =
function(t, e, i, n, s, o, h, c, u) {
var d = b
, p = w;
c = c || 0,
a(d, i, h),
r.rotate(p, v, c);
var f = l(d, p);
if (f > 0)
return 0;
if (u)
return !0;
var m = this.createContactEquation(s, t, o, e);
return r.copy(m.normalA, p),
r.scale(d, m.normalA, f),
a(m.contactPointA, i, d),
a(m.contactPointA, m.contactPointA, s.position),
a(m.contactPointB, i, t.position),
this.contactEquations.push(m),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(m)),
1
}
,
n.prototype[g.CIRCLE | g.PARTICLE] = n.prototype.circleParticle =
function(t, e, i, n, s, o, l, c, u) {
var d = b;
if (a(d, l, i),
r.squaredLength(d) > Math.pow(e.radius, 2))
return 0;
if (u)
return !0;
var p = this.createContactEquation(t, s, e, o);
return r.copy(p.normalA, d),
r.normalize(p.normalA, p.normalA),
r.scale(p.contactPointA, p.normalA, e.radius),
h(p.contactPointA, p.contactPointA, i),
a(p.contactPointA, p.contactPointA, t.position),
a(p.contactPointB, l, s.position),
this.contactEquations.push(p),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(p)),
1
}
;
var K = new f({
radius: 1
})
, J = r.create()
, Z = r.create();
r.create();
n.prototype[g.PLANE | g.CAPSULE] = n.prototype.planeCapsule =
function(t, e, i, n, s, o, a, l, c) {
var u = J
, d = Z
, p = K;
r.set(u, -o.length / 2, 0),
r.rotate(u, u, l),
h(u, u, a),
r.set(d, o.length / 2, 0),
r.rotate(d, d, l),
h(d, d, a),
p.radius = o.radius;
var f;
this.enableFrictionReduction && (f = this.enableFriction,
this.enableFriction = !1);
var m = this.circlePlane(s, p, u, 0, t, e, i, n, c)
, g = this.circlePlane(s, p, d, 0, t, e, i, n, c);
if (this.enableFrictionReduction && (this.enableFriction = f),
c)
return m || g;
var y = m + g;
return this.enableFrictionReduction && y &&
this.frictionEquations.push(this.createFrictionFromAverage(y)),
y
}
,
n.prototype[g.CIRCLE | g.PLANE] = n.prototype.circlePlane =
function(t, e, i, n, s, o, c, u, d) {
var p = t
, f = e
, m = i
, g = s
, y = c
, _ = u;
_ = _ || 0;
var P = b
, T = w
, C = x;
a(P, m, y),
r.rotate(T, v, _);
var S = l(T, P);
if (S > f.radius)
return 0;
if (d)
return !0;
var A = this.createContactEquation(g, p, o, e);
return r.copy(A.normalA, T),
r.scale(A.contactPointB, A.normalA, -f.radius),
h(A.contactPointB, A.contactPointB, m),
a(A.contactPointB, A.contactPointB, p.position),
r.scale(C, A.normalA, S),
a(A.contactPointA, P, C),
h(A.contactPointA, A.contactPointA, y),
a(A.contactPointA, A.contactPointA, g.position),
this.contactEquations.push(A),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(A)),
1
}
,
n.prototype[g.CONVEX] = n.prototype[g.CONVEX | g.BOX] =
n.prototype[g.BOX] = n.prototype.convexConvex = function(t, e, i, s, o, c, u, d, p,
f) {
var m = b
, g = w
, y = x
, v = _
, T = P
, k = C
, E = S
, I = A
, M = 0
, f = "number" == typeof f ? f : 0;
if (!n.findSeparatingAxis(e, i, s, c, u, d, m))
return 0;
a(E, u, i),
l(m, E) > 0 && r.scale(m, m, -1);
var O = n.getClosestEdge(e, s, m, !0)
, B = n.getClosestEdge(c, d, m);
if (-1 === O || -1 === B)
return 0;
for (var R = 0; R < 2; R++) {
var L = O
, D = B
, F = e
, N = c
, G = i
, U = u
, W = s
, j = d
, H = t
, X = o;
if (0 === R) {
var q;
q = L,
L = D,
D = q,
q = F,
F = N,
N = q,
q = G,
G = U,
U = q,
q = W,
W = j,
j = q,
q = H,
H = X,
X = q
}
for (var V = D; V < D + 2; V++) {
var Y = N.vertices[(V + N.vertices.length) %
N.vertices.length];
r.rotate(g, Y, j),
h(g, g, U);
for (var z = 0, K = L - 1; K < L + 2; K++) {
var J = F.vertices[(K + F.vertices.length) %
F.vertices.length]
, Z = F.vertices[(K + 1 + F.vertices.length) %
F.vertices.length];
r.rotate(y, J, W),
r.rotate(v, Z, W),
h(y, y, G),
h(v, v, G),
a(T, v, y),
r.rotate90cw(I, T),
r.normalize(I, I),
a(E, g, y);
var Q = l(I, E);
(K === L && Q <= f || K !== L && Q <= 0) && z++
}
if (z >= 3) {
if (p)
return !0;
var $ = this.createContactEquation(H, X, F, N);
M++;
var J = F.vertices[L % F.vertices.length]
, Z = F.vertices[(L + 1) % F.vertices.length];
r.rotate(y, J, W),
r.rotate(v, Z, W),
h(y, y, G),
h(v, v, G),
a(T, v, y),
r.rotate90cw($.normalA, T),
r.normalize($.normalA, $.normalA),
a(E, g, y);
var Q = l($.normalA, E);
r.scale(k, $.normalA, Q),
a($.contactPointA, g, G),
a($.contactPointA, $.contactPointA, k),
h($.contactPointA, $.contactPointA, G),
a($.contactPointA, $.contactPointA, H.position),
a($.contactPointB, g, U),
h($.contactPointB, $.contactPointB, U),
a($.contactPointB, $.contactPointB, X.position),
this.contactEquations.push($),
this.enableFrictionReduction || this.enableFriction
&& this.frictionEquations.push(this.createFrictionFromContact($))
}
}
}
return this.enableFrictionReduction && this.enableFriction && M
&& this.frictionEquations.push(this.createFrictionFromAverage(M)),
M
}
;
var Q = r.fromValues(0, 0);
n.projectConvexOntoAxis = function(t, e, i, n, s) {
var o, a, h = null, c = null, u = Q;
r.rotate(u, n, -i);
for (var d = 0; d < t.vertices.length; d++)
o = t.vertices[d],
a = l(o, u),
(null === h || a > h) && (h = a),
(null === c || a < c) && (c = a);
if (c > h) {
var p = c;
c = h,
h = p
}
var f = l(e, n);
r.set(s, c + f, h + f)
}
;
var $ = r.fromValues(0, 0)
, tt = r.fromValues(0, 0)
, et = r.fromValues(0, 0)
, it = r.fromValues(0, 0)
, nt = r.fromValues(0, 0)
, st = r.fromValues(0, 0);
n.findSeparatingAxis = function(t, e, i, s, o, h, l) {
var c = null
, u = !1
, d = !1
, p = $
, f = tt
, m = et
, g = it
, v = nt
, b = st;
if (t instanceof y && s instanceof y)
for (var w = 0; 2 !== w; w++) {
var x = t
, _ = i;
1 === w && (x = s,
_ = h);
for (var P = 0; 2 !== P; P++) {
0 === P ? r.set(g, 0, 1) : 1 === P && r.set(g, 1,
0),
0 !== _ && r.rotate(g, g, _),
n.projectConvexOntoAxis(t, e, i, g, v),
n.projectConvexOntoAxis(s, o, h, g, b);
var T = v
, C = b;
v[0] > b[0] && (C = v,
T = b,
!0);
var S = C[0] - T[1];
u = S <= 0,
(null === c || S > c) && (r.copy(l, g),
c = S,
d = u)
}
}
else
for (var w = 0; 2 !== w; w++) {
var x = t
, _ = i;
1 === w && (x = s,
_ = h);
for (var P = 0; P !== x.vertices.length; P++) {
r.rotate(f, x.vertices[P], _),
r.rotate(m, x.vertices[(P + 1) %
x.vertices.length], _),
a(p, m, f),
r.rotate90cw(g, p),
r.normalize(g, g),
n.projectConvexOntoAxis(t, e, i, g, v),
n.projectConvexOntoAxis(s, o, h, g, b);
var T = v
, C = b;
v[0] > b[0] && (C = v,
T = b,
!0);
var S = C[0] - T[1];
u = S <= 0,
(null === c || S > c) && (r.copy(l, g),
c = S,
d = u)
}
}
return d
}
;
var ot = r.fromValues(0, 0)
, rt = r.fromValues(0, 0)
, at = r.fromValues(0, 0);
n.getClosestEdge = function(t, e, i, n) {
var s = ot
, o = rt
, h = at;
r.rotate(s, i, -e),
n && r.scale(s, s, -1);
for (var c = -1, u = t.vertices.length, d = -1, p = 0; p !== u;
p++) {
a(o, t.vertices[(p + 1) % u], t.vertices[p % u]),
r.rotate90cw(h, o),
r.normalize(h, h);
var f = l(h, s);
(-1 === c || f > d) && (c = p % u,
d = f)
}
return c
}
;
var ht = r.create()
, lt = r.create()
, ct = r.create()
, ut = r.create()
, dt = r.create()
, pt = r.create()
, ft = r.create();
n.prototype[g.CIRCLE | g.HEIGHTFIELD] =
n.prototype.circleHeightfield = function(t, e, i, n, s, o, l, c, u, d) {
var p = o.heights
, d = d || e.radius
, f = o.elementWidth
, m = lt
, g = ht
, y = dt
, v = ft
, b = pt
, w = ct
, x = ut
, _ = Math.floor((i[0] - d - l[0]) / f)
, P = Math.ceil((i[0] + d - l[0]) / f);
_ < 0 && (_ = 0),
P >= p.length && (P = p.length - 1);
for (var T = p[_], C = p[P], S = _; S < P; S++)
p[S] < C && (C = p[S]),
p[S] > T && (T = p[S]);
if (i[1] - d > T)
return !u && 0;
for (var A = !1, S = _; S < P; S++) {
r.set(w, S * f, p[S]),
r.set(x, (S + 1) * f, p[S + 1]),
r.add(w, w, l),
r.add(x, x, l),
r.sub(b, x, w),
r.rotate(b, b, Math.PI / 2),
r.normalize(b, b),
r.scale(g, b, -d),
r.add(g, g, i),
r.sub(m, g, w);
var k = r.dot(m, b);
if (g[0] >= w[0] && g[0] < x[0] && k <= 0) {
if (u)
return !0;
A = !0,
r.scale(m, b, -k),
r.add(y, g, m),
r.copy(v, b);
var E = this.createContactEquation(s, t, o, e);
r.copy(E.normalA, v),
r.scale(E.contactPointB, E.normalA, -d),
h(E.contactPointB, E.contactPointB, i),
a(E.contactPointB, E.contactPointB, t.position),
r.copy(E.contactPointA, y),
r.sub(E.contactPointA, E.contactPointA, s.position),
this.contactEquations.push(E),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(E))
}
}
if (A = !1,
d > 0)
for (var S = _; S <= P; S++)
if (r.set(w, S * f, p[S]),
r.add(w, w, l),
r.sub(m, i, w),
r.squaredLength(m) < Math.pow(d, 2)) {
if (u)
return !0;
A = !0;
var E = this.createContactEquation(s, t, o, e);
r.copy(E.normalA, m),
r.normalize(E.normalA, E.normalA),
r.scale(E.contactPointB, E.normalA, -d),
h(E.contactPointB, E.contactPointB, i),
a(E.contactPointB, E.contactPointB, t.position),
a(E.contactPointA, w, l),
h(E.contactPointA, E.contactPointA, l),
a(E.contactPointA, E.contactPointA, s.position),
this.contactEquations.push(E),
this.enableFriction &&
this.frictionEquations.push(this.createFrictionFromContact(E))
}
return A ? 1 : 0
}
;
var mt = r.create()
, gt = r.create()
, yt = r.create()
, vt = new m({
vertices: [r.create(), r.create(), r.create(), r.create()]
});
n.prototype[g.BOX | g.HEIGHTFIELD] = n.prototype[g.CONVEX |
g.HEIGHTFIELD] = n.prototype.convexHeightfield = function(t, e, i, n, s, o, a, h,
l) {
var c = o.heights
, u = o.elementWidth
, d = mt
, p = gt
, f = yt
, m = vt
, g = Math.floor((t.aabb.lowerBound[0] - a[0]) / u)
, y = Math.ceil((t.aabb.upperBound[0] - a[0]) / u);
g < 0 && (g = 0),
y >= c.length && (y = c.length - 1);
for (var v = c[g], b = c[y], w = g; w < y; w++)
c[w] < b && (b = c[w]),
c[w] > v && (v = c[w]);
if (t.aabb.lowerBound[1] > v)
return !l && 0;
for (var x = 0, w = g; w < y; w++) {
r.set(d, w * u, c[w]),
r.set(p, (w + 1) * u, c[w + 1]),
r.add(d, d, a),
r.add(p, p, a);
var _ = 100;
r.set(f, .5 * (p[0] + d[0]), .5 * (p[1] + d[1] - _)),
r.sub(m.vertices[0], p, f),
r.sub(m.vertices[1], d, f),
r.copy(m.vertices[2], m.vertices[1]),
r.copy(m.vertices[3], m.vertices[0]),
m.vertices[2][1] -= _,
m.vertices[3][1] -= _,
x += this.convexConvex(t, e, i, n, s, m, f, 0, l)
}
return x
}
}
, {
"../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) {
function n(t) {
t = t || {},
this.from = t.from ? o.fromValues(t.from[0], t.from[1]) :
o.create(),
this.to = t.to ? o.fromValues(t.to[0], t.to[1]) : o.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 : n.ANY,
this.callback = t.callback || function(t) {}
,
this.direction = o.create(),
this.length = 1,
this.update()
}
function s(t, e, i) {
o.sub(a, i, t);
var n = o.dot(a, e);
return o.scale(h, e, n),
o.add(h, h, t),
o.squaredDistance(i, h)
}
e.exports = n;
var o = t("../math/vec2");
t("../collision/RaycastResult"),
t("../shapes/Shape"),
t("../collision/AABB");
n.prototype.constructor = n,
n.CLOSEST = 1,
n.ANY = 2,
n.ALL = 4,
n.prototype.update = function() {
var t = this.direction;
o.sub(t, this.to, this.from),
this.length = o.length(t),
o.normalize(t, t)
}
,
n.prototype.intersectBodies = function(t, e) {
for (var i = 0, n = e.length; !t.shouldStop(this) && i < n; i+
+) {
var s = e[i]
, o = s.getAABB();
(o.overlapsRay(this) >= 0 || o.containsPoint(this.from)) &&
this.intersectBody(t, s)
}
}
;
var r = o.create();
n.prototype.intersectBody = function(t, e) {
var i = this.checkCollisionResponse;
if (!i || e.collisionResponse)
for (var n = r, s = 0, a = e.shapes.length; s < a; s++) {
var h = e.shapes[s];
if ((!i || h.collisionResponse) && (0 !=
(this.collisionGroup & h.collisionMask) && 0 != (h.collisionGroup &
this.collisionMask))) {
o.rotate(n, h.position, e.angle),
o.add(n, n, e.position);
var l = h.angle + e.angle;
if (this.intersectShape(t, h, l, n, e),
t.shouldStop(this))
break
}
}
}
,
n.prototype.intersectShape = function(t, e, i, n, o) {
s(this.from, this.direction, n) > e.boundingRadius *
e.boundingRadius || (this._currentBody = o,
this._currentShape = e,
e.raycast(t, this, n, i),
this._currentBody = this._currentShape = null)
}
,
n.prototype.getAABB = function(t) {
var e = this.to
, i = this.from;
o.set(t.lowerBound, Math.min(e[0], i[0]), Math.min(e[1],
i[1])),
o.set(t.upperBound, Math.max(e[0], i[0]), Math.max(e[1], i[1]))
}
;
o.create();
n.prototype.reportIntersection = function(t, e, i, s) {
var r = (this.from,
this.to,
this._currentShape)
, a = this._currentBody;
if (!(this.skipBackfaces && o.dot(i, this.direction) > 0))
switch (this.mode) {
case n.ALL:
t.set(i, r, a, e, s),
this.callback(t);
break;
case n.CLOSEST:
(e < t.fraction || !t.hasHit()) && t.set(i, r, a, e,
s);
break;
case n.ANY:
t.set(i, r, a, e, s)
}
}
;
var a = o.create()
, h = o.create()
}
, {
"../collision/AABB": 7,
"../collision/RaycastResult": 12,
"../math/vec2": 30,
"../shapes/Shape": 45
}],
12: [function(t, e, i) {
function n() {
this.normal = s.create(),
this.shape = null,
this.body = null,
this.faceIndex = -1,
this.fraction = -1,
this.isStopped = !1
}
var s = t("../math/vec2")
, o = t("../collision/Ray");
e.exports = n,
n.prototype.reset = function() {
s.set(this.normal, 0, 0),
this.shape = null,
this.body = null,
this.faceIndex = -1,
this.fraction = -1,
this.isStopped = !1
}
,
n.prototype.getHitDistance = function(t) {
return s.distance(t.from, t.to) * this.fraction
}
,
n.prototype.hasHit = function() {
return -1 !== this.fraction
}
,
n.prototype.getHitPoint = function(t, e) {
s.lerp(t, e.from, e.to, this.fraction)
}
,
n.prototype.stop = function() {
this.isStopped = !0
}
,
n.prototype.shouldStop = function(t) {
return this.isStopped || -1 !== this.fraction && t.mode ===
o.ANY
}
,
n.prototype.set = function(t, e, i, n, o) {
s.copy(this.normal, t),
this.shape = e,
this.body = i,
this.fraction = n,
this.faceIndex = o
}
}
, {
"../collision/Ray": 11,
"../math/vec2": 30
}],
13: [function(t, e, i) {
function n() {
o.call(this, o.SAP),
this.axisList = [],
this.axisIndex = 0;
var t = this;
this._addBodyHandler = function(e) {
t.axisList.push(e.body)
}
,
this._removeBodyHandler = function(e) {
var i = t.axisList.indexOf(e.body);
-1 !== i && t.axisList.splice(i, 1)
}
}
var s = t("../utils/Utils")
, o = t("../collision/Broadphase");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
n.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
}
,
n.sortAxisList = function(t, e) {
e |= 0;
for (var i = 1, n = t.length; i < n; i++) {
for (var s = t[i], o = i - 1; o >= 0 && !
(t[o].aabb.lowerBound[e] <= s.aabb.lowerBound[e]); o--)
t[o + 1] = t[o];
t[o + 1] = s
}
return t
}
,
n.prototype.sortList = function() {
var t = this.axisList
, e = this.axisIndex;
n.sortAxisList(t, e)
}
,
n.prototype.getCollisionPairs = function(t) {
var e = this.axisList
, i = this.result
, n = this.axisIndex;
i.length = 0;
for (var s = e.length; s--; ) {
var r = e[s];
r.aabbNeedsUpdate && r.updateAABB()
}
this.sortList();
for (var a = 0, h = 0 | e.length; a !== h; a++)
for (var l = e[a], c = a + 1; c < h; c++) {
var u = e[c]
, d = u.aabb.lowerBound[n] <= l.aabb.upperBound[n];
if (!d)
break;
o.canCollide(l, u) && this.boundingVolumeCheck(l, u) &&
i.push(l, u)
}
return i
}
,
n.prototype.aabbQuery = function(t, e, i) {
i = i || [],
this.sortList();
var n = this.axisIndex
, s = "x";
1 === n && (s = "y"),
2 === n && (s = "z");
for (var o = this.axisList, r = (e.lowerBound[s],
e.upperBound[s],
0); r < o.length; r++) {
var a = o[r];
a.aabbNeedsUpdate && a.updateAABB(),
a.aabb.overlaps(e) && i.push(a)
}
return i
}
}
, {
"../collision/Broadphase": 8,
"../utils/Utils": 57
}],
14: [function(t, e, i) {
function n(t, e, i, n) {
this.type = i,
n = s.defaults(n, {
collideConnected: !0,
wakeUpBodies: !0
}),
this.equations = [],
this.bodyA = t,
this.bodyB = e,
this.collideConnected = n.collideConnected,
n.wakeUpBodies && (t && t.wakeUp(),
e && e.wakeUp())
}
e.exports = n;
var s = t("../utils/Utils");
n.prototype.update = function() {
throw new Error("method update() not implmemented in this
Constraint subclass!")
}
,
n.DISTANCE = 1,
n.GEAR = 2,
n.LOCK = 3,
n.PRISMATIC = 4,
n.REVOLUTE = 5,
n.prototype.setStiffness = function(t) {
for (var e = this.equations, i = 0; i !== e.length; i++) {
var n = e[i];
n.stiffness = t,
n.needsUpdate = !0
}
}
,
n.prototype.setRelaxation = function(t) {
for (var e = this.equations, i = 0; i !== e.length; i++) {
var n = e[i];
n.relaxation = t,
n.needsUpdate = !0
}
}
}
, {
"../utils/Utils": 57
}],
15: [function(t, e, i) {
function n(t, e, i) {
i = a.defaults(i, {
localAnchorA: [0, 0],
localAnchorB: [0, 0]
}),
s.call(this, t, e, s.DISTANCE, i),
this.localAnchorA = r.fromValues(i.localAnchorA[0],
i.localAnchorA[1]),
this.localAnchorB = r.fromValues(i.localAnchorB[0],
i.localAnchorB[1]);
var n = this.localAnchorA
, h = this.localAnchorB;
if (this.distance = 0,
"number" == typeof i.distance)
this.distance = i.distance;
else {
var l = r.create()
, c = r.create()
, u = r.create();
r.rotate(l, n, t.angle),
r.rotate(c, h, e.angle),
r.add(u, e.position, c),
r.sub(u, u, l),
r.sub(u, u, t.position),
this.distance = r.length(u)
}
var d;
d = void 0 === i.maxForce ? Number.MAX_VALUE : i.maxForce;
var p = new o(t,e,-d,d);
this.equations = [p],
this.maxForce = d;
var u = r.create()
, f = r.create()
, m = r.create()
, g = this;
p.computeGq = function() {
var t = this.bodyA
, e = this.bodyB
, i = t.position
, s = e.position;
return r.rotate(f, n, t.angle),
r.rotate(m, h, e.angle),
r.add(u, s, m),
r.sub(u, u, f),
r.sub(u, u, i),
r.length(u) - g.distance
}
,
this.setMaxForce(d),
this.upperLimitEnabled = !1,
this.upperLimit = 1,
this.lowerLimitEnabled = !1,
this.lowerLimit = 0,
this.position = 0
}
var s = t("./Constraint")
, o = t("../equations/Equation")
, r = t("../math/vec2")
, a = t("../utils/Utils");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n;
var h = r.create()
, l = r.create()
, c = r.create();
n.prototype.update = function() {
var t = this.equations[0]
, e = this.bodyA
, i = this.bodyB
, n = (this.distance,
e.position)
, s = i.position
, o = this.equations[0]
, a = t.G;
r.rotate(l, this.localAnchorA, e.angle),
r.rotate(c, this.localAnchorB, i.angle),
r.add(h, s, c),
r.sub(h, h, l),
r.sub(h, h, n),
this.position = r.length(h);
var u = !1;
if (this.upperLimitEnabled && this.position > this.upperLimit
&& (o.maxForce = 0,
o.minForce = -this.maxForce,
this.distance = this.upperLimit,
u = !0),
this.lowerLimitEnabled && this.position < this.lowerLimit &&
(o.maxForce = this.maxForce,
o.minForce = 0,
this.distance = this.lowerLimit,
u = !0),
(this.lowerLimitEnabled || this.upperLimitEnabled) && !u)
return void (o.enabled = !1);
o.enabled = !0,
r.normalize(h, h);
var d = r.crossLength(l, h)
, p = r.crossLength(c, h);
a[0] = -h[0],
a[1] = -h[1],
a[2] = -d,
a[3] = h[0],
a[4] = h[1],
a[5] = p
}
,
n.prototype.setMaxForce = function(t) {
var e = this.equations[0];
e.minForce = -t,
e.maxForce = t
}
,
n.prototype.getMaxForce = function() {
return this.equations[0].maxForce
}
}
, {
"../equations/Equation": 22,
"../math/vec2": 30,
"../utils/Utils": 57,
"./Constraint": 14
}],
16: [function(t, e, i) {
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)
}
var s = t("./Constraint")
, o = (t("../equations/Equation"),
t("../equations/AngleLockEquation"));
t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
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) {
function n(t, e, i) {
i = i || {},
s.call(this, t, e, s.LOCK, i);
var n = void 0 === i.maxForce ? Number.MAX_VALUE : i.maxForce
, a = (i.localAngleB,
new r(t,e,-n,n))
, h = new r(t,e,-n,n)
, l = new r(t,e,-n,n)
, c = o.create()
, u = o.create()
, d = this;
a.computeGq = function() {
return o.rotate(c, d.localOffsetB, t.angle),
o.sub(u, e.position, t.position),
o.sub(u, u, c),
u[0]
}
,
h.computeGq = function() {
return o.rotate(c, d.localOffsetB, t.angle),
o.sub(u, e.position, t.position),
o.sub(u, u, c),
u[1]
}
;
var p = o.create()
, f = o.create();
l.computeGq = function() {
return o.rotate(p, d.localOffsetB, e.angle -
d.localAngleB),
o.scale(p, p, -1),
o.sub(u, t.position, e.position),
o.add(u, u, p),
o.rotate(f, p, -Math.PI / 2),
o.normalize(f, f),
o.dot(u, f)
}
,
this.localOffsetB = o.create(),
i.localOffsetB ? o.copy(this.localOffsetB, i.localOffsetB) :
(o.sub(this.localOffsetB, e.position, t.position),
o.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(a, h, l),
this.setMaxForce(n)
}
var s = t("./Constraint")
, o = t("../math/vec2")
, r = t("../equations/Equation");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.setMaxForce = function(t) {
for (var e = this.equations, i = 0; i < this.equations.length;
i++)
e[i].maxForce = t,
e[i].minForce = -t
}
,
n.prototype.getMaxForce = function() {
return this.equations[0].maxForce
}
;
var a = o.create()
, h = o.create()
, l = o.create()
, c = o.fromValues(1, 0)
, u = o.fromValues(0, 1);
n.prototype.update = function() {
var t = this.equations[0]
, e = this.equations[1]
, i = this.equations[2]
, n = this.bodyA
, s = this.bodyB;
o.rotate(a, this.localOffsetB, n.angle),
o.rotate(h, this.localOffsetB, s.angle - this.localAngleB),
o.scale(h, h, -1),
o.rotate(l, h, Math.PI / 2),
o.normalize(l, l),
t.G[0] = -1,
t.G[1] = 0,
t.G[2] = -o.crossLength(a, c),
t.G[3] = 1,
e.G[0] = 0,
e.G[1] = -1,
e.G[2] = -o.crossLength(a, u),
e.G[4] = 1,
i.G[0] = -l[0],
i.G[1] = -l[1],
i.G[3] = l[0],
i.G[4] = l[1],
i.G[5] = o.crossLength(h, l)
}
}
, {
"../equations/Equation": 22,
"../math/vec2": 30,
"./Constraint": 14
}],
18: [function(t, e, i) {
function n(t, e, i) {
i = i || {},
s.call(this, t, e, s.PRISMATIC, i);
var n = a.fromValues(0, 0)
, l = a.fromValues(1, 0)
, c = a.fromValues(0, 0);
i.localAnchorA && a.copy(n, i.localAnchorA),
i.localAxisA && a.copy(l, i.localAxisA),
i.localAnchorB && a.copy(c, i.localAnchorB),
this.localAnchorA = n,
this.localAnchorB = c,
this.localAxisA = l;
var u = this.maxForce = void 0 !== i.maxForce ? i.maxForce :
Number.MAX_VALUE
, d = new r(t,e,-u,u)
, p = new a.create
, f = new a.create
, m = new a.create
, g = new a.create;
if (d.computeGq = function() {
return a.dot(m, g)
}
,
d.updateJacobian = function() {
var i = this.G
, s = t.position
, o = e.position;
a.rotate(p, n, t.angle),
a.rotate(f, c, e.angle),
a.add(m, o, f),
a.sub(m, m, s),
a.sub(m, m, p),
a.rotate(g, l, t.angle + Math.PI / 2),
i[0] = -g[0],
i[1] = -g[1],
i[2] = -a.crossLength(p, g) + a.crossLength(g, m),
i[3] = g[0],
i[4] = g[1],
i[5] = a.crossLength(f, g)
}
,
this.equations.push(d),
!i.disableRotationalLock) {
var y = new h(t,e,-u,u);
this.equations.push(y)
}
this.position = 0,
this.velocity = 0,
this.lowerLimitEnabled = void 0 !== i.lowerLimit,
this.upperLimitEnabled = void 0 !== i.upperLimit,
this.lowerLimit = void 0 !== i.lowerLimit ? i.lowerLimit : 0,
this.upperLimit = void 0 !== i.upperLimit ? i.upperLimit : 1,
this.upperLimitEquation = new o(t,e),
this.lowerLimitEquation = new o(t,e),
this.upperLimitEquation.minForce =
this.lowerLimitEquation.minForce = 0,
this.upperLimitEquation.maxForce =
this.lowerLimitEquation.maxForce = u,
this.motorEquation = new r(t,e),
this.motorEnabled = !1,
this.motorSpeed = 0;
var v = this
, b = this.motorEquation;
b.computeGW;
b.computeGq = function() {
return 0
}
,
b.computeGW = function() {
var t = this.G
, e = this.bodyA
, i = this.bodyB
, n = e.velocity
, s = i.velocity
, o = e.angularVelocity
, r = i.angularVelocity;
return this.gmult(t, n, o, s, r) + v.motorSpeed
}
}
var s = t("./Constraint")
, o = t("../equations/ContactEquation")
, r = t("../equations/Equation")
, a = t("../math/vec2")
, h = t("../equations/RotationalLockEquation");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n;
var l = a.create()
, c = a.create()
, u = a.create()
, d = a.create()
, p = a.create()
, f = a.create();
n.prototype.update = function() {
var t = this.equations
, e = t[0]
, i = this.upperLimit
, n = this.lowerLimit
, s = this.upperLimitEquation
, o = this.lowerLimitEquation
, r = this.bodyA
, h = this.bodyB
, m = this.localAxisA
, g = this.localAnchorA
, y = this.localAnchorB;
e.updateJacobian(),
a.rotate(l, m, r.angle),
a.rotate(d, g, r.angle),
a.add(c, d, r.position),
a.rotate(p, y, h.angle),
a.add(u, p, h.position);
var v = this.position = a.dot(u, l) - a.dot(c, l);
if (this.motorEnabled) {
var b = this.motorEquation.G;
b[0] = l[0],
b[1] = l[1],
b[2] = a.crossLength(l, p),
b[3] = -l[0],
b[4] = -l[1],
b[5] = -a.crossLength(l, d)
}
if (this.upperLimitEnabled && v > i)
a.scale(s.normalA, l, -1),
a.sub(s.contactPointA, c, r.position),
a.sub(s.contactPointB, u, h.position),
a.scale(f, l, i),
a.add(s.contactPointA, s.contactPointA, f),
-1 === t.indexOf(s) && t.push(s);
else {
var w = t.indexOf(s);
-1 !== w && t.splice(w, 1)
}
if (this.lowerLimitEnabled && v < n)
a.scale(o.normalA, l, 1),
a.sub(o.contactPointA, c, r.position),
a.sub(o.contactPointB, u, h.position),
a.scale(f, l, n),
a.sub(o.contactPointB, o.contactPointB, f),
-1 === t.indexOf(o) && t.push(o);
else {
var w = t.indexOf(o);
-1 !== w && t.splice(w, 1)
}
}
,
n.prototype.enableMotor = function() {
this.motorEnabled || (this.equations.push(this.motorEquation),
this.motorEnabled = !0)
}
,
n.prototype.disableMotor = function() {
if (this.motorEnabled) {
var t = this.equations.indexOf(this.motorEquation);
this.equations.splice(t, 1),
this.motorEnabled = !1
}
}
,
n.prototype.setLimits = function(t, e) {
"number" == typeof t ? (this.lowerLimit = t,
this.lowerLimitEnabled = !0) : (this.lowerLimit = t,
this.lowerLimitEnabled = !1),
"number" == typeof e ? (this.upperLimit = e,
this.upperLimitEnabled = !0) : (this.upperLimit = e,
this.upperLimitEnabled = !1)
}
}
, {
"../equations/ContactEquation": 21,
"../equations/Equation": 22,
"../equations/RotationalLockEquation": 24,
"../math/vec2": 30,
"./Constraint": 14
}],
19: [function(t, e, i) {
function n(t, e, i) {
i = i || {},
s.call(this, t, e, s.REVOLUTE, i);
var n = this.maxForce = void 0 !== i.maxForce ? i.maxForce :
Number.MAX_VALUE;
this.pivotA = h.create(),
this.pivotB = h.create(),
i.worldPivot ? (h.sub(this.pivotA, i.worldPivot, t.position),
h.sub(this.pivotB, i.worldPivot, e.position),
h.rotate(this.pivotA, this.pivotA, -t.angle),
h.rotate(this.pivotB, this.pivotB, -e.angle)) :
(h.copy(this.pivotA, i.localPivotA),
h.copy(this.pivotB, i.localPivotB));
var f = this.equations = [new o(t,e,-n,n), new o(t,e,-n,n)]
, m = f[0]
, g = f[1]
, y = this;
m.computeGq = function() {
return h.rotate(l, y.pivotA, t.angle),
h.rotate(c, y.pivotB, e.angle),
h.add(p, e.position, c),
h.sub(p, p, t.position),
h.sub(p, p, l),
h.dot(p, u)
}
,
g.computeGq = function() {
return h.rotate(l, y.pivotA, t.angle),
h.rotate(c, y.pivotB, e.angle),
h.add(p, e.position, c),
h.sub(p, p, t.position),
h.sub(p, p, l),
h.dot(p, d)
}
,
g.minForce = m.minForce = -n,
g.maxForce = m.maxForce = n,
this.motorEquation = new r(t,e),
this.motorEnabled = !1,
this.angle = 0,
this.lowerLimitEnabled = !1,
this.upperLimitEnabled = !1,
this.lowerLimit = 0,
this.upperLimit = 0,
this.upperLimitEquation = new a(t,e),
this.lowerLimitEquation = new a(t,e),
this.upperLimitEquation.minForce = 0,
this.lowerLimitEquation.maxForce = 0
}
var s = t("./Constraint")
, o = t("../equations/Equation")
, r = t("../equations/RotationalVelocityEquation")
, a = t("../equations/RotationalLockEquation")
, h = t("../math/vec2");
e.exports = n;
var l = h.create()
, c = h.create()
, u = h.fromValues(1, 0)
, d = h.fromValues(0, 1)
, p = h.create();
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.setLimits = function(t, e) {
"number" == typeof t ? (this.lowerLimit = t,
this.lowerLimitEnabled = !0) : (this.lowerLimit = t,
this.lowerLimitEnabled = !1),
"number" == typeof e ? (this.upperLimit = e,
this.upperLimitEnabled = !0) : (this.upperLimit = e,
this.upperLimitEnabled = !1)
}
,
n.prototype.update = function() {
var t = this.bodyA
, e = this.bodyB
, i = this.pivotA
, n = this.pivotB
, s = this.equations
, o = (s[0],
s[1],
s[0])
, r = s[1]
, a = this.upperLimit
, p = this.lowerLimit
, f = this.upperLimitEquation
, m = this.lowerLimitEquation
, g = this.angle = e.angle - t.angle;
if (this.upperLimitEnabled && g > a)
f.angle = a,
-1 === s.indexOf(f) && s.push(f);
else {
var y = s.indexOf(f);
-1 !== y && s.splice(y, 1)
}
if (this.lowerLimitEnabled && g < p)
m.angle = p,
-1 === s.indexOf(m) && s.push(m);
else {
var y = s.indexOf(m);
-1 !== y && s.splice(y, 1)
}
h.rotate(l, i, t.angle),
h.rotate(c, n, e.angle),
o.G[0] = -1,
o.G[1] = 0,
o.G[2] = -h.crossLength(l, u),
o.G[3] = 1,
o.G[4] = 0,
o.G[5] = h.crossLength(c, u),
r.G[0] = 0,
r.G[1] = -1,
r.G[2] = -h.crossLength(l, d),
r.G[3] = 0,
r.G[4] = 1,
r.G[5] = h.crossLength(c, d)
}
,
n.prototype.enableMotor = function() {
this.motorEnabled || (this.equations.push(this.motorEquation),
this.motorEnabled = !0)
}
,
n.prototype.disableMotor = function() {
if (this.motorEnabled) {
var t = this.equations.indexOf(this.motorEquation);
this.equations.splice(t, 1),
this.motorEnabled = !1
}
}
,
n.prototype.motorIsEnabled = function() {
return !!this.motorEnabled
}
,
n.prototype.setMotorSpeed = function(t) {
if (this.motorEnabled) {
var e = this.equations.indexOf(this.motorEquation);
this.equations[e].relativeVelocity = t
}
}
,
n.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) {
function n(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)
}
var s = t("./Equation");
t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeGq = function() {
return this.ratio * this.bodyA.angle - this.bodyB.angle +
this.angle
}
,
n.prototype.setRatio = function(t) {
var e = this.G;
e[2] = t,
e[5] = -1,
this.ratio = t
}
,
n.prototype.setMaxTorque = function(t) {
this.maxForce = t,
this.minForce = -t
}
}
, {
"../math/vec2": 30,
"./Equation": 22
}],
21: [function(t, e, i) {
function n(t, e) {
s.call(this, t, e, 0, Number.MAX_VALUE),
this.contactPointA = o.create(),
this.penetrationVec = o.create(),
this.contactPointB = o.create(),
this.normalA = o.create(),
this.restitution = 0,
this.firstImpact = !1,
this.shapeA = null,
this.shapeB = null
}
var s = t("./Equation")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeB = function(t, e, i) {
var n = this.bodyA
, s = this.bodyB
, r = this.contactPointA
, a = this.contactPointB
, h = n.position
, l = s.position
, c = this.penetrationVec
, u = this.normalA
, d = this.G
, p = o.crossLength(r, u)
, f = o.crossLength(a, u);
d[0] = -u[0],
d[1] = -u[1],
d[2] = -p,
d[3] = u[0],
d[4] = u[1],
d[5] = f,
o.add(c, l, a),
o.sub(c, c, h),
o.sub(c, c, r);
var m, g;
return this.firstImpact && 0 !== this.restitution ? (g = 0,
m = 1 / e * (1 + this.restitution) * this.computeGW()) : (g =
o.dot(u, c) + this.offset,
m = this.computeGW()),
-g * t - m * e - i * this.computeGiMf()
}
;
var r = o.create()
, a = o.create()
, h = o.create();
n.prototype.getVelocityAlongNormal = function() {
return this.bodyA.getVelocityAtPoint(r, this.contactPointA),
this.bodyB.getVelocityAtPoint(a, this.contactPointB),
o.subtract(h, r, a),
o.dot(this.normalA, h)
}
}
, {
"../math/vec2": 30,
"./Equation": 22
}],
22: [function(t, e, i) {
function n(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 = n.DEFAULT_STIFFNESS,
this.relaxation = n.DEFAULT_RELAXATION,
this.G = new o.ARRAY_TYPE(6);
for (var r = 0; r < 6; r++)
this.G[r] = 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
}
e.exports = n;
var s = t("../math/vec2")
, o = t("../utils/Utils");
t("../objects/Body");
n.prototype.constructor = n,
n.DEFAULT_STIFFNESS = 1e6,
n.DEFAULT_RELAXATION = 4,
n.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
}
,
n.prototype.gmult = function(t, e, i, n, s) {
return t[0] * e[0] + t[1] * e[1] + t[2] * i + t[3] * n[0] +
t[4] * n[1] + t[5] * s
}
,
n.prototype.computeB = function(t, e, i) {
var n = this.computeGW();
return -this.computeGq() * t - n * e - this.computeGiMf() * i
}
;
var r = s.create()
, a = s.create();
n.prototype.computeGq = function() {
var t = this.G
, e = this.bodyA
, i = this.bodyB
, n = (e.position,
i.position,
e.angle)
, s = i.angle;
return this.gmult(t, r, n, a, s) + this.offset
}
,
n.prototype.computeGW = function() {
var t = this.G
, e = this.bodyA
, i = this.bodyB
, n = e.velocity
, s = i.velocity
, o = e.angularVelocity
, r = i.angularVelocity;
return this.gmult(t, n, o, s, r) + this.relativeVelocity
}
,
n.prototype.computeGWlambda = function() {
var t = this.G
, e = this.bodyA
, i = this.bodyB
, n = e.vlambda
, s = i.vlambda
, o = e.wlambda
, r = i.wlambda;
return this.gmult(t, n, o, s, r)
}
;
var h = s.create()
, l = s.create();
n.prototype.computeGiMf = function() {
var t = this.bodyA
, e = this.bodyB
, i = t.force
, n = t.angularForce
, o = e.force
, r = e.angularForce
, a = t.invMassSolve
, c = e.invMassSolve
, u = t.invInertiaSolve
, d = e.invInertiaSolve
, p = this.G;
return s.scale(h, i, a),
s.multiply(h, t.massMultiplier, h),
s.scale(l, o, c),
s.multiply(l, e.massMultiplier, l),
this.gmult(p, h, n * u, l, r * d)
}
,
n.prototype.computeGiMGt = function() {
var t = this.bodyA
, e = this.bodyB
, i = t.invMassSolve
, n = e.invMassSolve
, s = t.invInertiaSolve
, o = e.invInertiaSolve
, r = this.G;
return r[0] * r[0] * i * t.massMultiplier[0] + r[1] * r[1] * i
* t.massMultiplier[1] + r[2] * r[2] * s + r[3] * r[3] * n * e.massMultiplier[0] +
r[4] * r[4] * n * e.massMultiplier[1] + r[5] * r[5] * o
}
;
var c = s.create()
, u = s.create()
, d = s.create();
s.create(),
s.create(),
s.create();
n.prototype.addToWlambda = function(t) {
var e = this.bodyA
, i = this.bodyB
, n = c
, o = u
, r = d
, a = e.invMassSolve
, h = i.invMassSolve
, l = e.invInertiaSolve
, p = i.invInertiaSolve
, f = this.G;
o[0] = f[0],
o[1] = f[1],
r[0] = f[3],
r[1] = f[4],
s.scale(n, o, a * t),
s.multiply(n, n, e.massMultiplier),
s.add(e.vlambda, e.vlambda, n),
e.wlambda += l * f[2] * t,
s.scale(n, r, h * t),
s.multiply(n, n, i.massMultiplier),
s.add(i.vlambda, i.vlambda, n),
i.wlambda += p * f[5] * t
}
,
n.prototype.computeInvC = function(t) {
return 1 / (this.computeGiMGt() + t)
}
}
, {
"../math/vec2": 30,
"../objects/Body": 31,
"../utils/Utils": 57
}],
23: [function(t, e, i) {
function n(t, e, i) {
o.call(this, t, e, -i, i),
this.contactPointA = s.create(),
this.contactPointB = s.create(),
this.t = s.create(),
this.contactEquations = [],
this.shapeA = null,
this.shapeB = null,
this.frictionCoefficient = .3
}
var s = t("../math/vec2")
, o = t("./Equation");
t("../utils/Utils");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
n.prototype.setSlipForce = function(t) {
this.maxForce = t,
this.minForce = -t
}
,
n.prototype.getSlipForce = function() {
return this.maxForce
}
,
n.prototype.computeB = function(t, e, i) {
var n = (this.bodyA,
this.bodyB,
this.contactPointA)
, o = this.contactPointB
, r = this.t
, a = this.G;
return a[0] = -r[0],
a[1] = -r[1],
a[2] = -s.crossLength(n, r),
a[3] = r[0],
a[4] = r[1],
a[5] = s.crossLength(o, r),
-this.computeGW() * e - i * this.computeGiMf()
}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57,
"./Equation": 22
}],
24: [function(t, e, i) {
function n(t, e, i) {
i = i || {},
s.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE),
this.angle = i.angle || 0;
var n = this.G;
n[2] = 1,
n[5] = -1
}
var s = t("./Equation")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n;
var r = o.create()
, a = o.create()
, h = o.fromValues(1, 0)
, l = o.fromValues(0, 1);
n.prototype.computeGq = function() {
return o.rotate(r, h, this.bodyA.angle + this.angle),
o.rotate(a, l, this.bodyB.angle),
o.dot(r, a)
}
}
, {
"../math/vec2": 30,
"./Equation": 22
}],
25: [function(t, e, i) {
function n(t, e) {
s.call(this, t, e, -Number.MAX_VALUE, Number.MAX_VALUE),
this.relativeVelocity = 1,
this.ratio = 1
}
var s = t("./Equation");
t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeB = function(t, e, i) {
var n = this.G;
n[2] = -1,
n[5] = this.ratio;
var s = this.computeGiMf();
return -this.computeGW() * e - i * s
}
}
, {
"../math/vec2": 30,
"./Equation": 22
}],
26: [function(t, e, i) {
var n = function() {};
e.exports = n,
n.prototype = {
constructor: n,
on: function(t, e, i) {
e.context = i || this,
void 0 === this._listeners && (this._listeners = {});
var n = this._listeners;
return void 0 === n[t] && (n[t] = []),
-1 === n[t].indexOf(e) && n[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
, n = i[t].indexOf(e);
return -1 !== n && i[t].splice(n, 1),
this
},
emit: function(t) {
if (void 0 === this._listeners)
return this;
var e = this._listeners
, i = e[t.type];
if (void 0 !== i) {
t.target = this;
for (var n = 0, s = i.length; n < s; n++) {
var o = i[n];
o.call(o.context, t)
}
}
return this
}
}
}
, {}],
27: [function(t, e, i) {
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
}
var s = t("./Material")
, o = t("../equations/Equation");
e.exports = n,
n.idCounter = 0
}
, {
"../equations/Equation": 22,
"./Material": 28
}],
28: [function(t, e, i) {
function n(t) {
this.id = t || n.idCounter++
}
e.exports = n,
n.idCounter = 0
}
, {}],
29: [function(t, e, i) {
var n = {};
n.GetArea = function(t) {
if (t.length < 6)
return 0;
for (var e = t.length - 2, i = 0, n = 0; n < e; n += 2)
i += (t[n + 2] - t[n]) * (t[n + 1] + t[n + 3]);
return .5 * -(i += (t[0] - t[e]) * (t[e + 1] + t[1]))
}
,
n.Triangulate = function(t) {
var e = t.length >> 1;
if (e < 3)
return [];
for (var i = [], s = [], o = 0; o < e; o++)
s.push(o);
for (var o = 0, r = e; r > 3; ) {
var a = s[(o + 0) % r]
, h = s[(o + 1) % r]
, l = s[(o + 2) % r]
, c = t[2 * a]
, u = t[2 * a + 1]
, d = t[2 * h]
, p = t[2 * h + 1]
, f = t[2 * l]
, m = t[2 * l + 1]
, g = !1;
if (n._convex(c, u, d, p, f, m)) {
g = !0;
for (var y = 0; y < r; y++) {
var v = s[y];
if (v != a && v != h && v != l &&
n._PointInTriangle(t[2 * v], t[2 * v + 1], c, u, d, p, f, m)) {
g = !1;
break
}
}
}
if (g)
i.push(a, h, l),
s.splice((o + 1) % r, 1),
r--,
o = 0;
else if (o++ > 3 * r)
break
}
return i.push(s[0], s[1], s[2]),
i
}
,
n._PointInTriangle = function(t, e, i, n, s, o, r, a) {
var h = r - i
, l = a - n
, c = s - i
, u = o - n
, d = t - i
, p = e - n
, f = h * h + l * l
, m = h * c + l * u
, g = h * d + l * p
, y = c * c + u * u
, v = c * d + u * p
, b = 1 / (f * y - m * m)
, w = (y * g - m * v) * b
, x = (f * v - m * g) * b;
return w >= 0 && x >= 0 && w + x < 1
}
,
n._convex = function(t, e, i, n, s, o) {
return (e - n) * (s - i) + (i - t) * (o - n) >= 0
}
,
e.exports = n
}
, {}],
30: [function(t, e, i) {
var n = e.exports = {}
, s = t("../utils/Utils");
n.crossLength = function(t, e) {
return t[0] * e[1] - t[1] * e[0]
}
,
n.crossVZ = function(t, e, i) {
return n.rotate(t, e, -Math.PI / 2),
n.scale(t, t, i),
t
}
,
n.crossZV = function(t, e, i) {
return n.rotate(t, i, Math.PI / 2),
n.scale(t, t, e),
t
}
,
n.rotate = function(t, e, i) {
if (0 !== i) {
var n = Math.cos(i)
, s = Math.sin(i)
, o = e[0]
, r = e[1];
t[0] = n * o - s * r,
t[1] = s * o + n * r
} else
t[0] = e[0],
t[1] = e[1]
}
,
n.rotate90cw = function(t, e) {
var i = e[0]
, n = e[1];
t[0] = n,
t[1] = -i
}
,
n.toLocalFrame = function(t, e, i, s) {
n.copy(t, e),
n.sub(t, t, i),
n.rotate(t, t, -s)
}
,
n.toGlobalFrame = function(t, e, i, s) {
n.copy(t, e),
n.rotate(t, t, s),
n.add(t, t, i)
}
,
n.vectorToLocalFrame = function(t, e, i) {
n.rotate(t, e, -i)
}
,
n.vectorToGlobalFrame = function(t, e, i) {
n.rotate(t, e, i)
}
,
n.centroid = function(t, e, i, s) {
return n.add(t, e, i),
n.add(t, t, s),
n.scale(t, t, 1 / 3),
t
}
,
n.create = function() {
var t = new s.ARRAY_TYPE(2);
return t[0] = 0,
t[1] = 0,
t
}
,
n.clone = function(t) {
var e = new s.ARRAY_TYPE(2);
return e[0] = t[0],
e[1] = t[1],
e
}
,
n.fromValues = function(t, e) {
var i = new s.ARRAY_TYPE(2);
return i[0] = t,
i[1] = e,
i
}
,
n.copy = function(t, e) {
return t[0] = e[0],
t[1] = e[1],
t
}
,
n.set = function(t, e, i) {
return t[0] = e,
t[1] = i,
t
}
,
n.add = function(t, e, i) {
return t[0] = e[0] + i[0],
t[1] = e[1] + i[1],
t
}
,
n.subtract = function(t, e, i) {
return t[0] = e[0] - i[0],
t[1] = e[1] - i[1],
t
}
,
n.sub = n.subtract,
n.multiply = function(t, e, i) {
return t[0] = e[0] * i[0],
t[1] = e[1] * i[1],
t
}
,
n.mul = n.multiply,
n.divide = function(t, e, i) {
return t[0] = e[0] / i[0],
t[1] = e[1] / i[1],
t
}
,
n.div = n.divide,
n.scale = function(t, e, i) {
return t[0] = e[0] * i,
t[1] = e[1] * i,
t
}
,
n.distance = function(t, e) {
var i = e[0] - t[0]
, n = e[1] - t[1];
return Math.sqrt(i * i + n * n)
}
,
n.dist = n.distance,
n.squaredDistance = function(t, e) {
var i = e[0] - t[0]
, n = e[1] - t[1];
return i * i + n * n
}
,
n.sqrDist = n.squaredDistance,
n.length = function(t) {
var e = t[0]
, i = t[1];
return Math.sqrt(e * e + i * i)
}
,
n.len = n.length,
n.squaredLength = function(t) {
var e = t[0]
, i = t[1];
return e * e + i * i
}
,
n.sqrLen = n.squaredLength,
n.negate = function(t, e) {
return t[0] = -e[0],
t[1] = -e[1],
t
}
,
n.normalize = function(t, e) {
var i = e[0]
, n = e[1]
, s = i * i + n * n;
return s > 0 && (s = 1 / Math.sqrt(s),
t[0] = e[0] * s,
t[1] = e[1] * s),
t
}
,
n.dot = function(t, e) {
return t[0] * e[0] + t[1] * e[1]
}
,
n.str = function(t) {
return "vec2(" + t[0] + ", " + t[1] + ")"
}
,
n.lerp = function(t, e, i, n) {
var s = e[0]
, o = e[1];
return t[0] = s + n * (i[0] - s),
t[1] = o + n * (i[1] - o),
t
}
,
n.reflect = function(t, e, i) {
var n = e[0] * i[0] + e[1] * i[1];
t[0] = e[0] - 2 * i[0] * n,
t[1] = e[1] - 2 * i[1] * n
}
,
n.getLineSegmentsIntersection = function(t, e, i, s, o) {
var r = n.getLineSegmentsIntersectionFraction(e, i, s, o);
return !(r < 0) && (t[0] = e[0] + r * (i[0] - e[0]),
t[1] = e[1] + r * (i[1] - e[1]),
!0)
}
,
n.getLineSegmentsIntersectionFraction = function(t, e, i, n) {
var s, o, r = e[0] - t[0], a = e[1] - t[1], h = n[0] - i[0], l
= n[1] - i[1];
return s = (-a * (t[0] - i[0]) + r * (t[1] - i[1])) / (-h * a +
r * l),
o = (h * (t[1] - i[1]) - l * (t[0] - i[0])) / (-h * a + r * l),
s >= 0 && s <= 1 && o >= 0 && o <= 1 ? o : -1
}
}
, {
"../utils/Utils": 57
}],
31: [function(t, e, i) {
function n(t) {
t = t || {},
c.call(this),
this.id = t.id || ++n._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 = s.create(),
this.position = s.fromValues(0, 0),
t.position && s.copy(this.position, t.position),
this.interpolatedPosition = s.fromValues(0, 0),
this.interpolatedAngle = 0,
this.previousPosition = s.fromValues(0, 0),
this.previousAngle = 0,
this.velocity = s.fromValues(0, 0),
t.velocity && s.copy(this.velocity, t.velocity),
this.vlambda = s.fromValues(0, 0),
this.wlambda = 0,
this.angle = t.angle || 0,
this.angularVelocity = t.angularVelocity || 0,
this.force = s.create(),
t.force && s.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 = n.STATIC,
void 0 !== t.type ? this.type = t.type : t.mass ? this.type =
n.DYNAMIC : this.type = n.STATIC,
this.boundingRadius = 0,
this.aabb = new l,
this.aabbNeedsUpdate = !0,
this.allowSleep = void 0 === t.allowSleep || t.allowSleep,
this.wantsToSleep = !1,
this.sleepState = n.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()
}
var s = t("../math/vec2")
, o = t("poly-decomp")
, r = t("../shapes/Convex")
, a = t("../collision/RaycastResult")
, h = t("../collision/Ray")
, l = t("../collision/AABB")
, c = t("../events/EventEmitter");
e.exports = n,
n.prototype = new c,
n.prototype.constructor = n,
n._idCounter = 0,
n.prototype.updateSolveMassProperties = function() {
this.sleepState === n.SLEEPING || this.type === n.KINEMATIC ?
(this.invMassSolve = 0,
this.invInertiaSolve = 0) : (this.invMassSolve = this.invMass,
this.invInertiaSolve = this.invInertia)
}
,
n.prototype.setDensity = function(t) {
var e = this.getArea();
this.mass = e * t,
this.updateMassProperties()
}
,
n.prototype.getArea = function() {
for (var t = 0, e = 0; e < this.shapes.length; e++)
t += this.shapes[e].area;
return t
}
,
n.prototype.getAABB = function() {
return this.aabbNeedsUpdate && this.updateAABB(),
this.aabb
}
;
var u = new l
, d = s.create();
n.prototype.updateAABB = function() {
for (var t = this.shapes, e = t.length, i = d, n = this.angle,
o = 0; o !== e; o++) {
var r = t[o]
, a = r.angle + n;
s.rotate(i, r.position, n),
s.add(i, i, this.position),
r.computeAABB(u, i, a),
0 === o ? this.aabb.copy(u) : this.aabb.extend(u)
}
this.aabbNeedsUpdate = !1
}
,
n.prototype.updateBoundingRadius = function() {
for (var t = this.shapes, e = t.length, i = 0, n = 0; n !== e;
n++) {
var o = t[n]
, r = s.length(o.position)
, a = o.boundingRadius;
r + a > i && (i = r + a)
}
this.boundingRadius = i
}
,
n.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 ? s.copy(t.position, e) : s.set(t.position, 0, 0),
t.angle = i || 0,
this.shapes.push(t),
this.updateMassProperties(),
this.updateBoundingRadius(),
this.aabbNeedsUpdate = !0
}
,
n.prototype.removeShape = function(t) {
var e = this.shapes.indexOf(t);
return -1 !== e && (this.shapes.splice(e, 1),
this.aabbNeedsUpdate = !0,
t.body = null,
!0)
}
,
n.prototype.updateMassProperties = function() {
if (this.type === n.STATIC || this.type === n.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
, o = 0;
if (this.fixedRotation)
this.inertia = Number.MAX_VALUE,
this.invInertia = 0;
else {
for (var r = 0; r < e; r++) {
var a = t[r]
, h = s.squaredLength(a.position);
o += a.computeMomentOfInertia(i) + i * h
}
this.inertia = o,
this.invInertia = o > 0 ? 1 / o : 0
}
this.invMass = 1 / this.mass,
s.set(this.massMultiplier, this.fixedX ? 0 : 1, this.fixedY
? 0 : 1)
}
}
;
s.create();
n.prototype.applyForce = function(t, e) {
if (s.add(this.force, this.force, t),
e) {
var i = s.crossLength(e, t);
this.angularForce += i
}
}
;
var p = s.create()
, f = s.create()
, m = s.create();
n.prototype.applyForceLocal = function(t, e) {
e = e || m;
var i = p
, n = f;
this.vectorToWorldFrame(i, t),
this.vectorToWorldFrame(n, e),
this.applyForce(i, n)
}
;
var g = s.create();
n.prototype.applyImpulse = function(t, e) {
if (this.type === n.DYNAMIC) {
var i = g;
if (s.scale(i, t, this.invMass),
s.multiply(i, this.massMultiplier, i),
s.add(this.velocity, i, this.velocity),
e) {
var o = s.crossLength(e, t);
o *= this.invInertia,
this.angularVelocity += o
}
}
}
;
var y = s.create()
, v = s.create()
, b = s.create();
n.prototype.applyImpulseLocal = function(t, e) {
e = e || b;
var i = y
, n = v;
this.vectorToWorldFrame(i, t),
this.vectorToWorldFrame(n, e),
this.applyImpulse(i, n)
}
,
n.prototype.toLocalFrame = function(t, e) {
s.toLocalFrame(t, e, this.position, this.angle)
}
,
n.prototype.toWorldFrame = function(t, e) {
s.toGlobalFrame(t, e, this.position, this.angle)
}
,
n.prototype.vectorToLocalFrame = function(t, e) {
s.vectorToLocalFrame(t, e, this.angle)
}
,
n.prototype.vectorToWorldFrame = function(t, e) {
s.vectorToGlobalFrame(t, e, this.angle)
}
,
n.prototype.fromPolygon = function(t, e) {
e = e || {};
for (var i = this.shapes.length; i >= 0; --i)
this.removeShape(this.shapes[i]);
var n = new o.Polygon;
if (n.vertices = t,
n.makeCCW(),
"number" == typeof e.removeCollinearPoints &&
n.removeCollinearPoints(e.removeCollinearPoints),
void 0 === e.skipSimpleCheck && !n.isSimple())
return !1;
this.concavePath = n.vertices.slice(0);
for (var i = 0; i < this.concavePath.length; i++) {
var a = [0, 0];
s.copy(a, this.concavePath[i]),
this.concavePath[i] = a
}
var h;
h = e.optimalDecomp ? n.decomp() : n.quickDecomp();
for (var l = s.create(), i = 0; i !== h.length; i++) {
for (var c = new r({
vertices: h[i].vertices
}), u = 0; u !== c.vertices.length; u++) {
var a = c.vertices[u];
s.sub(a, a, c.centerOfMass)
}
s.scale(l, c.centerOfMass, 1),
c.updateTriangles(),
c.updateCenterOfMass(),
c.updateBoundingRadius(),
this.addShape(c, l)
}
return this.adjustCenterOfMass(),
this.aabbNeedsUpdate = !0,
!0
}
;
var w = (s.fromValues(0, 0),
s.fromValues(0, 0))
, x = s.fromValues(0, 0)
, _ = s.fromValues(0, 0);
n.prototype.adjustCenterOfMass = function() {
var t = w
, e = x
, i = _
, n = 0;
s.set(e, 0, 0);
for (var o = 0; o !== this.shapes.length; o++) {
var r = this.shapes[o];
s.scale(t, r.position, r.area),
s.add(e, e, t),
n += r.area
}
s.scale(i, e, 1 / n);
for (var o = 0; o !== this.shapes.length; o++) {
var r = this.shapes[o];
s.sub(r.position, r.position, i)
}
s.add(this.position, this.position, i);
for (var o = 0; this.concavePath && o <
this.concavePath.length; o++)
s.sub(this.concavePath[o], this.concavePath[o], i);
this.updateMassProperties(),
this.updateBoundingRadius()
}
,
n.prototype.setZeroForce = function() {
s.set(this.force, 0, 0),
this.angularForce = 0
}
,
n.prototype.resetConstraintVelocity = function() {
var t = this
, e = t.vlambda;
s.set(e, 0, 0),
t.wlambda = 0
}
,
n.prototype.addConstraintVelocity = function() {
var t = this
, e = t.velocity;
s.add(e, e, t.vlambda),
t.angularVelocity += t.wlambda
}
,
n.prototype.applyDamping = function(t) {
if (this.type === n.DYNAMIC) {
var e = this.velocity;
s.scale(e, e, Math.pow(1 - this.damping, t)),
this.angularVelocity *= Math.pow(1 - this.angularDamping,
t)
}
}
,
n.prototype.wakeUp = function() {
var t = this.sleepState;
this.sleepState = n.AWAKE,
this.idleTime = 0,
t !== n.AWAKE && this.emit(n.wakeUpEvent)
}
,
n.prototype.sleep = function() {
this.sleepState = n.SLEEPING,
this.angularVelocity = 0,
this.angularForce = 0,
s.set(this.velocity, 0, 0),
s.set(this.force, 0, 0),
this.emit(n.sleepEvent)
}
,
n.prototype.sleepTick = function(t, e, i) {
if (this.allowSleep && this.type !== n.SLEEPING) {
this.wantsToSleep = !1;
this.sleepState;
s.squaredLength(this.velocity) +
Math.pow(this.angularVelocity, 2) >= Math.pow(this.sleepSpeedLimit, 2) ?
(this.idleTime = 0,
this.sleepState = n.AWAKE) : (this.idleTime += i,
this.sleepState = n.SLEEPY),
this.idleTime > this.sleepTimeLimit && (e ?
this.wantsToSleep = !0 : this.sleep())
}
}
,
n.prototype.overlaps = function(t) {
return this.world.overlapKeeper.bodiesAreOverlapping(this, t)
}
;
var P = s.create()
, T = s.create();
n.prototype.integrate = function(t) {
var e = this.invMass
, i = this.force
, n = this.position
, o = this.velocity;
s.copy(this.previousPosition, this.position),
this.previousAngle = this.angle,
this.fixedRotation || (this.angularVelocity +=
this.angularForce * this.invInertia * t),
s.scale(P, i, t * e),
s.multiply(P, this.massMultiplier, P),
s.add(o, P, o),
this.integrateToTimeOfImpact(t) || (s.scale(T, o, t),
s.add(n, n, T),
this.fixedRotation || (this.angle += this.angularVelocity *
t)),
this.aabbNeedsUpdate = !0
}
;
var C = new a
, S = new h({
mode: h.ALL
})
, A = s.create()
, k = s.create()
, E = s.create()
, I = s.create();
n.prototype.integrateToTimeOfImpact = function(t) {
if (this.ccdSpeedThreshold < 0 ||
s.squaredLength(this.velocity) < Math.pow(this.ccdSpeedThreshold, 2))
return !1;
s.normalize(A, this.velocity),
s.scale(k, this.velocity, t),
s.add(k, k, this.position),
s.sub(E, k, this.position);
var e, i = this.angularVelocity * t, n = s.length(E), o = 1, r
= this;
if (C.reset(),
S.callback = function(t) {
t.body !== r && (e = t.body,
t.getHitPoint(k, S),
s.sub(E, k, r.position),
o = s.length(E) / n,
t.stop())
}
,
s.copy(S.from, this.position),
s.copy(S.to, k),
S.update(),
this.world.raycast(C, S),
!e)
return !1;
var a = this.angle;
s.copy(I, this.position);
for (var h = 0, l = 0, c = 0, u = o; u >= l && h <
this.ccdIterations; ) {
h++,
c = (u - l) / 2,
s.scale(T, E, o),
s.add(this.position, I, T),
this.angle = a + i * o,
this.updateAABB();
this.aabb.overlaps(e.aabb) &&
this.world.narrowphase.bodiesOverlap(this, e) ? l = c : u = c
}
return o = c,
s.copy(this.position, I),
this.angle = a,
s.scale(T, E, o),
s.add(this.position, this.position, T),
this.fixedRotation || (this.angle += i * o),
!0
}
,
n.prototype.getVelocityAtPoint = function(t, e) {
return s.crossVZ(t, e, this.angularVelocity),
s.subtract(t, this.velocity, t),
t
}
,
n.sleepyEvent = {
type: "sleepy"
},
n.sleepEvent = {
type: "sleep"
},
n.wakeUpEvent = {
type: "wakeup"
},
n.DYNAMIC = 1,
n.STATIC = 2,
n.KINEMATIC = 4,
n.AWAKE = 0,
n.SLEEPY = 1,
n.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) {
function n(t, e, i) {
i = i || {},
o.call(this, t, e, i),
this.localAnchorA = s.fromValues(0, 0),
this.localAnchorB = s.fromValues(0, 0),
i.localAnchorA && s.copy(this.localAnchorA, i.localAnchorA),
i.localAnchorB && s.copy(this.localAnchorB, i.localAnchorB),
i.worldAnchorA && this.setWorldAnchorA(i.worldAnchorA),
i.worldAnchorB && this.setWorldAnchorB(i.worldAnchorB);
var n = s.create()
, r = s.create();
this.getWorldAnchorA(n),
this.getWorldAnchorB(r);
var a = s.distance(n, r);
this.restLength = "number" == typeof i.restLength ?
i.restLength : a
}
var s = t("../math/vec2")
, o = t("./Spring");
t("../utils/Utils");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
n.prototype.setWorldAnchorA = function(t) {
this.bodyA.toLocalFrame(this.localAnchorA, t)
}
,
n.prototype.setWorldAnchorB = function(t) {
this.bodyB.toLocalFrame(this.localAnchorB, t)
}
,
n.prototype.getWorldAnchorA = function(t) {
this.bodyA.toWorldFrame(t, this.localAnchorA)
}
,
n.prototype.getWorldAnchorB = function(t) {
this.bodyB.toWorldFrame(t, this.localAnchorB)
}
;
var r = s.create()
, a = s.create()
, h = s.create()
, l = s.create()
, c = s.create()
, u = s.create()
, d = s.create()
, p = s.create()
, f = s.create();
n.prototype.applyForce = function() {
var t = this.stiffness
, e = this.damping
, i = this.restLength
, n = this.bodyA
, o = this.bodyB
, m = r
, g = a
, y = h
, v = l
, b = f
, w = c
, x = u
, _ = d
, P = p;
this.getWorldAnchorA(w),
this.getWorldAnchorB(x),
s.sub(_, w, n.position),
s.sub(P, x, o.position),
s.sub(m, x, w);
var T = s.len(m);
s.normalize(g, m),
s.sub(y, o.velocity, n.velocity),
s.crossZV(b, o.angularVelocity, P),
s.add(y, y, b),
s.crossZV(b, n.angularVelocity, _),
s.sub(y, y, b),
s.scale(v, g, -t * (T - i) - e * s.dot(y, g)),
s.sub(n.force, n.force, v),
s.add(o.force, o.force, v);
var C = s.crossLength(_, v)
, S = s.crossLength(P, v);
n.angularForce -= C,
o.angularForce += S
}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57,
"./Spring": 34
}],
33: [function(t, e, i) {
function n(t, e, i) {
i = i || {},
s.call(this, t, e, i),
this.restAngle = "number" == typeof i.restAngle ? i.restAngle :
e.angle - t.angle
}
var s = (t("../math/vec2"),
t("./Spring"));
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.applyForce = function() {
var t = this.stiffness
, e = this.damping
, i = this.restAngle
, n = this.bodyA
, s = this.bodyB
, o = s.angle - n.angle
, r = s.angularVelocity - n.angularVelocity
, a = -t * (o - i) - e * r * 0;
n.angularForce -= a,
s.angularForce += a
}
}
, {
"../math/vec2": 30,
"./Spring": 34
}],
34: [function(t, e, i) {
function n(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
}
var s = (t("../math/vec2"),
t("../utils/Utils"));
e.exports = n,
n.prototype.applyForce = function() {}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57
}],
35: [function(t, e, i) {
function n(t, e) {
e = e || {},
this.chassisBody = t,
this.wheels = [],
this.groundBody = new h({
mass: 0
}),
this.world = null;
var i = this;
this.preStepCallback = function() {
i.update()
}
}
function s(t, e) {
e = e || {},
this.vehicle = t,
this.forwardEquation = new a(t.chassisBody,t.groundBody),
this.sideEquation = new a(t.chassisBody,t.groundBody),
this.steerValue = 0,
this.engineForce = 0,
this.setSideFriction(void 0 !== e.sideFriction ? e.sideFriction
: 5),
this.localForwardVector = o.fromValues(0, 1),
e.localForwardVector && o.copy(this.localForwardVector,
e.localForwardVector),
this.localPosition = o.fromValues(0, 0),
e.localPosition && o.copy(this.localPosition, e.localPosition),
r.apply(this, t.chassisBody, t.groundBody),
this.equations.push(this.forwardEquation, this.sideEquation),
this.setBrakeForce(0)
}
var o = t("../math/vec2")
, r = (t("../utils/Utils"),
t("../constraints/Constraint"))
, a = t("../equations/FrictionEquation")
, h = t("../objects/Body");
e.exports = n,
n.prototype.addToWorld = function(t) {
this.world = t,
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)
}
}
,
n.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
}
,
n.prototype.addWheel = function(t) {
var e = new s(this,t);
return this.wheels.push(e),
e
}
,
n.prototype.update = function() {
for (var t = 0; t < this.wheels.length; t++)
this.wheels[t].update()
}
,
s.prototype = new r,
s.prototype.setBrakeForce = function(t) {
this.forwardEquation.setSlipForce(t)
}
,
s.prototype.setSideFriction = function(t) {
this.sideEquation.setSlipForce(t)
}
;
var l = o.create()
, c = o.create();
s.prototype.getSpeed = function() {
return this.vehicle.chassisBody.vectorToWorldFrame(c,
this.localForwardVector),
this.vehicle.chassisBody.getVelocityAtPoint(l, c),
o.dot(l, c)
}
;
var u = o.create();
s.prototype.update = function() {

this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,
this.localForwardVector),
o.rotate(this.sideEquation.t, this.localForwardVector,
Math.PI / 2),

this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,
this.sideEquation.t),
o.rotate(this.forwardEquation.t, this.forwardEquation.t,
this.steerValue),
o.rotate(this.sideEquation.t, this.sideEquation.t,
this.steerValue),

this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,
this.localPosition),
o.copy(this.sideEquation.contactPointB,
this.forwardEquation.contactPointB),

this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,
this.localPosition),
o.copy(this.sideEquation.contactPointA,
this.forwardEquation.contactPointA),
o.normalize(u, this.forwardEquation.t),
o.scale(u, u, this.engineForce),
this.vehicle.chassisBody.applyForce(u,
this.forwardEquation.contactPointA)
}
}
, {
"../constraints/Constraint": 14,
"../equations/FrictionEquation": 23,
"../math/vec2": 30,
"../objects/Body": 31,
"../utils/Utils": 57
}],
36: [function(t, e, i) {
var n = 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(n, "Rectangle", {
get: function() {
return console.warn("The Rectangle class has been renamed
to Box."),
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) {
function n(t) {
"number" == typeof arguments[0] && "number" == typeof
arguments[1] && (t = {
width: arguments[0],
height: arguments[1]
},
console.warn("The Rectangle has been renamed to Box and its
constructor signature has changed. Please use the following format: new
Box({ width: 1, height: 1, ... })")),
t = t || {};
var e = this.width = t.width || 1
, i = this.height = t.height || 1
, n = [s.fromValues(-e / 2, -i / 2), s.fromValues(e / 2, -i /
2), s.fromValues(e / 2, i / 2), s.fromValues(-e / 2, i / 2)]
, a = [s.fromValues(1, 0), s.fromValues(0, 1)];
t.vertices = n,
t.axes = a,
t.type = o.BOX,
r.call(this, t)
}
var s = t("../math/vec2")
, o = t("./Shape")
, r = t("./Convex");
e.exports = n,
n.prototype = new r,
n.prototype.constructor = n,
n.prototype.computeMomentOfInertia = function(t) {
var e = this.width
, i = this.height;
return t * (i * i + e * e) / 12
}
,
n.prototype.updateBoundingRadius = function() {
var t = this.width
, e = this.height;
this.boundingRadius = Math.sqrt(t * t + e * e) / 2
}
;
s.create(),
s.create(),
s.create(),
s.create();
n.prototype.computeAABB = function(t, e, i) {
t.setFromPoints(this.vertices, e, i, 0)
}
,
n.prototype.updateArea = function() {
this.area = this.width * this.height
}
}
, {
"../math/vec2": 30,
"./Convex": 40,
"./Shape": 45
}],
38: [function(t, e, i) {
function n(t) {
"number" == typeof arguments[0] && "number" == typeof
arguments[1] && (t = {
length: arguments[0],
radius: arguments[1]
},
console.warn("The Capsule constructor signature has changed.
Please use the following format: new Capsule({ radius: 1, length: 1 })")),
t = t || {},
this.length = t.length || 1,
this.radius = t.radius || 1,
t.type = s.CAPSULE,
s.call(this, t)
}
var s = t("./Shape")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeMomentOfInertia = function(t) {
var e = this.radius
, i = this.length + e
, n = 2 * e;
return t * (n * n + i * i) / 12
}
,
n.prototype.updateBoundingRadius = function() {
this.boundingRadius = this.radius + this.length / 2
}
,
n.prototype.updateArea = function() {
this.area = Math.PI * this.radius * this.radius + 2 *
this.radius * this.length
}
;
var r = o.create();
n.prototype.computeAABB = function(t, e, i) {
var n = this.radius;
o.set(r, this.length / 2, 0),
0 !== i && o.rotate(r, r, i),
o.set(t.upperBound, Math.max(r[0] + n, -r[0] + n),
Math.max(r[1] + n, -r[1] + n)),
o.set(t.lowerBound, Math.min(r[0] - n, -r[0] - n),
Math.min(r[1] - n, -r[1] - n)),
o.add(t.lowerBound, t.lowerBound, e),
o.add(t.upperBound, t.upperBound, e)
}
;
var a = o.create()
, h = o.create()
, l = o.create()
, c = o.create()
, u = o.fromValues(0, 1);
n.prototype.raycast = function(t, e, i, n) {
for (var s = e.from, r = e.to, d = (e.direction,
a), p = h, f = l, m = c, g = this.length / 2, y = 0; y < 2; y+
+) {
var v = this.radius * (2 * y - 1);
o.set(f, -g, v),
o.set(m, g, v),
o.toGlobalFrame(f, f, i, n),
o.toGlobalFrame(m, m, i, n);
var b = o.getLineSegmentsIntersectionFraction(s, r, f, m);
if (b >= 0 && (o.rotate(p, u, n),
o.scale(p, p, 2 * y - 1),
e.reportIntersection(t, b, p, -1),
t.shouldStop(e)))
return
}
for (var w = Math.pow(this.radius, 2) + Math.pow(g, 2), y = 0;
y < 2; y++) {
o.set(f, g * (2 * y - 1), 0),
o.toGlobalFrame(f, f, i, n);
var x = Math.pow(r[0] - s[0], 2) + Math.pow(r[1] - s[1], 2)
, _ = 2 * ((r[0] - s[0]) * (s[0] - f[0]) + (r[1] - s[1])
* (s[1] - f[1]))
, P = Math.pow(s[0] - f[0], 2) + Math.pow(s[1] - f[1], 2)
- Math.pow(this.radius, 2)
, b = Math.pow(_, 2) - 4 * x * P;
if (!(b < 0))
if (0 === b) {
if (o.lerp(d, s, r, b),
o.squaredDistance(d, i) > w && (o.sub(p, d, f),
o.normalize(p, p),
e.reportIntersection(t, b, p, -1),
t.shouldStop(e)))
return
} else {
var T = Math.sqrt(b)
, C = 1 / (2 * x)
, S = (-_ - T) * C
, A = (-_ + T) * C;
if (S >= 0 && S <= 1 && (o.lerp(d, s, r, S),
o.squaredDistance(d, i) > w && (o.sub(p, d, f),
o.normalize(p, p),
e.reportIntersection(t, S, p, -1),
t.shouldStop(e))))
return;
if (A >= 0 && A <= 1 && (o.lerp(d, s, r, A),
o.squaredDistance(d, i) > w && (o.sub(p, d, f),
o.normalize(p, p),
e.reportIntersection(t, A, p, -1),
t.shouldStop(e))))
return
}
}
}
}
, {
"../math/vec2": 30,
"./Shape": 45
}],
39: [function(t, e, i) {
function n(t) {
"number" == typeof arguments[0] && (t = {
radius: arguments[0]
},
console.warn("The Circle constructor signature has changed.
Please use the following format: new Circle({ radius: 1 })")),
t = t || {},
this.radius = t.radius || 1,
t.type = s.CIRCLE,
s.call(this, t)
}
var s = t("./Shape")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeMomentOfInertia = function(t) {
var e = this.radius;
return t * e * e / 2
}
,
n.prototype.updateBoundingRadius = function() {
this.boundingRadius = this.radius
}
,
n.prototype.updateArea = function() {
this.area = Math.PI * this.radius * this.radius
}
,
n.prototype.computeAABB = function(t, e, i) {
var n = this.radius;
o.set(t.upperBound, n, n),
o.set(t.lowerBound, -n, -n),
e && (o.add(t.lowerBound, t.lowerBound, e),
o.add(t.upperBound, t.upperBound, e))
}
;
var r = o.create()
, a = o.create();
n.prototype.raycast = function(t, e, i, n) {
var s = e.from
, h = e.to
, l = this.radius
, c = Math.pow(h[0] - s[0], 2) + Math.pow(h[1] - s[1], 2)
, u = 2 * ((h[0] - s[0]) * (s[0] - i[0]) + (h[1] - s[1]) *
(s[1] - i[1]))
, d = Math.pow(s[0] - i[0], 2) + Math.pow(s[1] - i[1], 2) -
Math.pow(l, 2)
, p = Math.pow(u, 2) - 4 * c * d
, f = r
, m = a;
if (!(p < 0))
if (0 === p)
o.lerp(f, s, h, p),
o.sub(m, f, i),
o.normalize(m, m),
e.reportIntersection(t, p, m, -1);
else {
var g = Math.sqrt(p)
, y = 1 / (2 * c)
, v = (-u - g) * y
, b = (-u + g) * y;
if (v >= 0 && v <= 1 && (o.lerp(f, s, h, v),
o.sub(m, f, i),
o.normalize(m, m),
e.reportIntersection(t, v, m, -1),
t.shouldStop(e)))
return;
b >= 0 && b <= 1 && (o.lerp(f, s, h, b),
o.sub(m, f, i),
o.normalize(m, m),
e.reportIntersection(t, b, m, -1))
}
}
}
, {
"../math/vec2": 30,
"./Shape": 45
}],
40: [function(t, e, i) {
function n(t) {
Array.isArray(arguments[0]) && (t = {
vertices: arguments[0],
axes: arguments[1]
},
console.warn("The Convex constructor signature has changed.
Please use the following format: new Convex({ vertices: [...], ... })")),
t = t || {},
this.vertices = [];
for (var e = void 0 !== t.vertices ? t.vertices : [], i = 0; i
< e.length; i++) {
var n = o.create();
o.copy(n, e[i]),
this.vertices.push(n)
}
if (this.axes = [],
t.axes)
for (var i = 0; i < t.axes.length; i++) {
var r = o.create();
o.copy(r, t.axes[i]),
this.axes.push(r)
}
else
for (var i = 0; i < this.vertices.length; i++) {
var a = this.vertices[i]
, h = this.vertices[(i + 1) % this.vertices.length]
, l = o.create();
o.sub(l, h, a),
o.rotate90cw(l, l),
o.normalize(l, l),
this.axes.push(l)
}
if (this.centerOfMass = o.fromValues(0, 0),
this.triangles = [],
this.vertices.length && (this.updateTriangles(),
this.updateCenterOfMass()),
this.boundingRadius = 0,
t.type = s.CONVEX,
s.call(this, t),
this.updateBoundingRadius(),
this.updateArea(),
this.area < 0)
throw new Error("Convex vertices must be given in conter-
clockwise winding.")
}
var s = t("./Shape")
, o = t("../math/vec2")
, r = t("../math/polyk");
t("poly-decomp");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n;
var a = o.create()
, h = o.create();
n.prototype.projectOntoLocalAxis = function(t, e) {
for (var i, n, s = null, r = null, t = a, h = 0; h <
this.vertices.length; h++)
i = this.vertices[h],
n = o.dot(i, t),
(null === s || n > s) && (s = n),
(null === r || n < r) && (r = n);
if (r > s) {
var l = r;
r = s,
s = l
}
o.set(e, r, s)
}
,
n.prototype.projectOntoWorldAxis = function(t, e, i, n) {
var s = h;
this.projectOntoLocalAxis(t, n),
0 !== i ? o.rotate(s, t, i) : s = t;
var r = o.dot(e, s);
o.set(n, n[0] + r, n[1] + r)
}
,
n.prototype.updateTriangles = function() {
this.triangles.length = 0;
for (var t = [], e = 0; e < this.vertices.length; e++) {
var i = this.vertices[e];
t.push(i[0], i[1])
}
for (var n = r.Triangulate(t), e = 0; e < n.length; e += 3) {
var s = n[e]
, o = n[e + 1]
, a = n[e + 2];
this.triangles.push([s, o, a])
}
}
;
var l = o.create()
, c = o.create()
, u = o.create()
, d = o.create()
, p = o.create();
o.create(),
o.create(),
o.create(),
o.create();
n.prototype.updateCenterOfMass = function() {
var t = this.triangles
, e = this.vertices
, i = this.centerOfMass
, s = l
, r = u
, a = d
, h = p
, f = c;
o.set(i, 0, 0);
for (var m = 0, g = 0; g !== t.length; g++) {
var y = t[g]
, r = e[y[0]]
, a = e[y[1]]
, h = e[y[2]];
o.centroid(s, r, a, h);
var v = n.triangleArea(r, a, h);
m += v,
o.scale(f, s, v),
o.add(i, i, f)
}
o.scale(i, i, 1 / m)
}
,
n.prototype.computeMomentOfInertia = function(t) {
for (var e = 0, i = 0, n = this.vertices.length, s = n - 1, r =
0; r < n; s = r,
r++) {
var a = this.vertices[s]
, h = this.vertices[r]
, l = Math.abs(o.crossLength(a, h));
e += l * (o.dot(h, h) + o.dot(h, a) + o.dot(a, a)),
i += l
}
return t / 6 * (e / i)
}
,
n.prototype.updateBoundingRadius = function() {
for (var t = this.vertices, e = 0, i = 0; i !== t.length; i++)
{
var n = o.squaredLength(t[i]);
n > e && (e = n)
}
this.boundingRadius = Math.sqrt(e)
}
,
n.triangleArea = function(t, e, i) {
return .5 * ((e[0] - t[0]) * (i[1] - t[1]) - (i[0] - t[0]) *
(e[1] - t[1]))
}
,
n.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]]
, r = e[s[1]]
, a = e[s[2]]
, h = n.triangleArea(o, r, a);
this.area += h
}
}
,
n.prototype.computeAABB = function(t, e, i) {
t.setFromPoints(this.vertices, e, i, 0)
}
;
var f = o.create()
, m = o.create()
, g = o.create();
n.prototype.raycast = function(t, e, i, n) {
var s = f
, r = m
, a = g
, h = this.vertices;
o.toLocalFrame(s, e.from, i, n),
o.toLocalFrame(r, e.to, i, n);
for (var l = h.length, c = 0; c < l && !t.shouldStop(e); c++) {
var u = h[c]
, d = h[(c + 1) % l]
, p = o.getLineSegmentsIntersectionFraction(s, r, u, d);
p >= 0 && (o.sub(a, d, u),
o.rotate(a, a, -Math.PI / 2 + n),
o.normalize(a, a),
e.reportIntersection(t, p, a, c))
}
}
}
, {
"../math/polyk": 29,
"../math/vec2": 30,
"./Shape": 45,
"poly-decomp": 5
}],
41: [function(t, e, i) {
function n(t) {
if (Array.isArray(arguments[0])) {
if (t = {
heights: arguments[0]
},
"object" == typeof arguments[1])
for (var e in arguments[1])
t[e] = arguments[1][e];
console.warn("The Heightfield constructor signature has
changed. Please use the following format: new Heightfield({ heights:
[...], ... })")
}
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)
}
var s = t("./Shape")
, o = t("../math/vec2");
t("../utils/Utils");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.updateMaxMinValues = function() {
for (var t = this.heights, e = t[0], i = t[0], n = 0; n !==
t.length; n++) {
var s = t[n];
s > e && (e = s),
s < i && (i = s)
}
this.maxValue = e,
this.minValue = i
}
,
n.prototype.computeMomentOfInertia = function(t) {
return Number.MAX_VALUE
}
,
n.prototype.updateBoundingRadius = function() {
this.boundingRadius = Number.MAX_VALUE
}
,
n.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 r = [o.create(), o.create(), o.create(), o.create()];
n.prototype.computeAABB = function(t, e, i) {
o.set(r[0], 0, this.maxValue),
o.set(r[1], this.elementWidth * this.heights.length,
this.maxValue),
o.set(r[2], this.elementWidth * this.heights.length,
this.minValue),
o.set(r[3], 0, this.minValue),
t.setFromPoints(r, e, i)
}
,
n.prototype.getLineSegment = function(t, e, i) {
var n = this.heights
, s = this.elementWidth;
o.set(t, i * s, n[i]),
o.set(e, (i + 1) * s, n[i + 1])
}
,
n.prototype.getSegmentIndex = function(t) {
return Math.floor(t[0] / this.elementWidth)
}
,
n.prototype.getClampedSegmentIndex = function(t) {
var e = this.getSegmentIndex(t);
return e = Math.min(this.heights.length, Math.max(e, 0))
}
;
var a = (o.create(),
o.create())
, h = o.create()
, l = o.create()
, c = o.create()
, u = o.create();
o.fromValues(0, 1);
n.prototype.raycast = function(t, e, i, n) {
var s = e.from
, r = e.to
, d = (e.direction,
a)
, p = h
, f = l
, m = c
, g = u;
o.toLocalFrame(m, s, i, n),
o.toLocalFrame(g, r, i, n);
var y = this.getClampedSegmentIndex(m)
, v = this.getClampedSegmentIndex(g);
if (y > v) {
var b = y;
y = v,
v = b
}
for (var w = 0; w < this.heights.length - 1; w++) {
this.getLineSegment(p, f, w);
var x = o.getLineSegmentsIntersectionFraction(m, g, p, f);
if (x >= 0 && (o.sub(d, f, p),
o.rotate(d, d, n + Math.PI / 2),
o.normalize(d, d),
e.reportIntersection(t, x, d, -1),
t.shouldStop(e)))
return
}
}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57,
"./Shape": 45
}],
42: [function(t, e, i) {
function n(t) {
"number" == typeof arguments[0] && (t = {
length: arguments[0]
},
console.warn("The Line constructor signature has changed.
Please use the following format: new Line({ length: 1, ... })")),
t = t || {},
this.length = t.length || 1,
t.type = s.LINE,
s.call(this, t)
}
var s = t("./Shape")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeMomentOfInertia = function(t) {
return t * Math.pow(this.length, 2) / 12
}
,
n.prototype.updateBoundingRadius = function() {
this.boundingRadius = this.length / 2
}
;
var r = [o.create(), o.create()];
n.prototype.computeAABB = function(t, e, i) {
var n = this.length / 2;
o.set(r[0], -n, 0),
o.set(r[1], n, 0),
t.setFromPoints(r, e, i, 0)
}
;
var a = (o.create(),
o.create())
, h = o.create()
, l = o.create()
, c = o.fromValues(0, 1);
n.prototype.raycast = function(t, e, i, n) {
var s = e.from
, r = e.to
, u = h
, d = l
, p = this.length / 2;
o.set(u, -p, 0),
o.set(d, p, 0),
o.toGlobalFrame(u, u, i, n),
o.toGlobalFrame(d, d, i, n);
var f = o.getLineSegmentsIntersectionFraction(u, d, s, r);
if (f >= 0) {
var m = a;
o.rotate(m, c, n),
e.reportIntersection(t, f, m, -1)
}
}
}
, {
"../math/vec2": 30,
"./Shape": 45
}],
43: [function(t, e, i) {
function n(t) {
t = t || {},
t.type = s.PARTICLE,
s.call(this, t)
}
var s = t("./Shape")
, o = t("../math/vec2");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
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) {
function n(t) {
t = t || {},
t.type = s.PLANE,
s.call(this, t)
}
var s = t("./Shape")
, o = t("../math/vec2");
t("../utils/Utils");
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.computeMomentOfInertia = function(t) {
return 0
}
,
n.prototype.updateBoundingRadius = function() {
this.boundingRadius = Number.MAX_VALUE
}
,
n.prototype.computeAABB = function(t, e, i) {
var n = i % (2 * Math.PI)
, s = o.set
, r = 1e7
, a = t.lowerBound
, h = t.upperBound;
s(a, -r, -r),
s(h, r, r),
0 === n ? h[1] = 0 : n === Math.PI / 2 ? a[0] = 0 : n ===
Math.PI ? a[1] = 0 : n === 3 * Math.PI / 2 && (h[0] = 0)
}
,
n.prototype.updateArea = function() {
this.area = Number.MAX_VALUE
}
;
var r = o.create()
, a = (o.create(),
o.create(),
o.create())
, h = o.create();
n.prototype.raycast = function(t, e, i, n) {
var s = e.from
, l = e.to
, c = e.direction
, u = r
, d = a
, p = h;
o.set(d, 0, 1),
o.rotate(d, d, n),
o.sub(p, s, i);
var f = o.dot(p, d);
if (o.sub(p, l, i),
!(f * o.dot(p, d) > 0 || o.squaredDistance(s, l) < f * f)) {
var m = o.dot(d, c);
o.sub(u, s, i);
var g = -o.dot(d, u) / m / e.length;
e.reportIntersection(t, g, d, -1)
}
}
}
, {
"../math/vec2": 30,
"../utils/Utils": 57,
"./Shape": 45
}],
45: [function(t, e, i) {
function n(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 = n.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()
}
e.exports = n;
var s = t("../math/vec2");
n.idCounter = 0,
n.CIRCLE = 1,
n.PARTICLE = 2,
n.PLANE = 4,
n.CONVEX = 8,
n.LINE = 16,
n.BOX = 32,
Object.defineProperty(n, "RECTANGLE", {
get: function() {
return console.warn("Shape.RECTANGLE is deprecated, use
Shape.BOX instead."),
n.BOX
}
}),
n.CAPSULE = 64,
n.HEIGHTFIELD = 128,
n.prototype.computeMomentOfInertia = function(t) {}
,
n.prototype.updateBoundingRadius = function() {}
,
n.prototype.updateArea = function() {}
,
n.prototype.computeAABB = function(t, e, i) {}
,
n.prototype.raycast = function(t, e, i, n) {}
}
, {
"../math/vec2": 30
}],
46: [function(t, e, i) {
function n(t) {
r.call(this, t, r.GS),
t = t || {},
this.iterations = t.iterations || 10,
this.tolerance = t.tolerance || 1e-7,
this.arrayStep = 30,
this.lambda = new a.ARRAY_TYPE(this.arrayStep),
this.Bs = new a.ARRAY_TYPE(this.arrayStep),
this.invCs = new a.ARRAY_TYPE(this.arrayStep),
this.useZeroRHS = !1,
this.frictionIterations = void 0 !== t.frictionIterations ? 0 :
t.frictionIterations,
this.usedIterations = 0
}
function s(t) {
for (var e = t.length; e--; )
t[e] = 0
}
var o = t("../math/vec2")
, r = t("./Solver")
, a = t("../utils/Utils")
, h = t("../equations/FrictionEquation");
e.exports = n,
n.prototype = new r,
n.prototype.constructor = n,
n.prototype.solve = function(t, e) {
this.sortEquations();
var i = 0
, r = this.iterations
, l = this.frictionIterations
, c = this.equations
, u = c.length
, d = Math.pow(this.tolerance * u, 2)
, p = e.bodies
, f = e.bodies.length
, m = (o.add,
o.set,
this.useZeroRHS)
, g = this.lambda;
if (this.usedIterations = 0,
u)
for (var y = 0; y !== f; y++) {
var v = p[y];
v.updateSolveMassProperties()
}
g.length < u && (g = this.lambda = new a.ARRAY_TYPE(u +
this.arrayStep),
this.Bs = new a.ARRAY_TYPE(u + this.arrayStep),
this.invCs = new a.ARRAY_TYPE(u + this.arrayStep)),
s(g);
for (var b = this.invCs, w = this.Bs, g = this.lambda, y = 0; y
!== c.length; y++) {
var x = c[y];
(x.timeStep !== t || x.needsUpdate) && (x.timeStep = t,
x.update()),
w[y] = x.computeB(x.a, x.b, t),
b[y] = x.computeInvC(x.epsilon)
}
var x, _, y, P;
if (0 !== u) {
for (y = 0; y !== f; y++) {
var v = p[y];
v.resetConstraintVelocity()
}
if (l) {
for (i = 0; i !== l; i++) {
for (_ = 0,
P = 0; P !== u; P++) {
x = c[P];
var T = n.iterateEquation(P, x, x.epsilon, w,
b, g, m, t, i);
_ += Math.abs(T)
}
if (this.usedIterations++,
_ * _ <= d)
break
}
for (n.updateMultipliers(c, g, 1 / t),
P = 0; P !== u; P++) {
var C = c[P];
if (C instanceof h) {
for (var S = 0, A = 0; A !==
C.contactEquations.length; A++)
S += C.contactEquations[A].multiplier;
S *= C.frictionCoefficient /
C.contactEquations.length,
C.maxForce = S,
C.minForce = -S
}
}
}
for (i = 0; i !== r; i++) {
for (_ = 0,
P = 0; P !== u; P++) {
x = c[P];
var T = n.iterateEquation(P, x, x.epsilon, w, b, g,
m, t, i);
_ += Math.abs(T)
}
if (this.usedIterations++,
_ * _ <= d)
break
}
for (y = 0; y !== f; y++)
p[y].addConstraintVelocity();
n.updateMultipliers(c, g, 1 / t)
}
}
,
n.updateMultipliers = function(t, e, i) {
for (var n = t.length; n--; )
t[n].multiplier = e[n] * i
}
,
n.iterateEquation = function(t, e, i, n, s, o, r, a, h) {
var l = n[t]
, c = s[t]
, u = o[t]
, d = e.computeGWlambda()
, p = e.maxForce
, f = e.minForce;
r && (l = 0);
var m = c * (l - d - i * u)
, g = u + m;
return g < f * a ? m = f * a - u : g > p * a && (m = p * a -
u),
o[t] += m,
e.addToWlambda(m),
m
}
}
, {
"../equations/FrictionEquation": 23,
"../math/vec2": 30,
"../utils/Utils": 57,
"./Solver": 47
}],
47: [function(t, e, i) {
function n(t, e) {
t = t || {},
s.call(this),
this.type = e,
this.equations = [],
this.equationSortFunction = t.equationSortFunction || !1
}
var s = (t("../utils/Utils"),
t("../events/EventEmitter"));
e.exports = n,
n.prototype = new s,
n.prototype.constructor = n,
n.prototype.solve = function(t, e) {
throw new Error("Solver.solve should be implemented by
subclasses!")
}
;
var o = {
bodies: []
};
n.prototype.solveIsland = function(t, e) {
this.removeAllEquations(),
e.equations.length && (this.addEquations(e.equations),
o.bodies.length = 0,
e.getBodies(o.bodies),
o.bodies.length && this.solve(t, o))
}
,
n.prototype.sortEquations = function() {
this.equationSortFunction &&
this.equations.sort(this.equationSortFunction)
}
,
n.prototype.addEquation = function(t) {
t.enabled && this.equations.push(t)
}
,
n.prototype.addEquations = function(t) {
for (var e = 0, i = t.length; e !== i; e++) {
var n = t[e];
n.enabled && this.equations.push(n)
}
}
,
n.prototype.removeEquation = function(t) {
var e = this.equations.indexOf(t);
-1 !== e && this.equations.splice(e, 1)
}
,
n.prototype.removeAllEquations = function() {
this.equations.length = 0
}
,
n.GS = 1,
n.ISLAND = 2
}
, {
"../events/EventEmitter": 26,
"../utils/Utils": 57
}],
48: [function(t, e, i) {
function n() {
o.apply(this, arguments)
}
var s = t("../equations/ContactEquation")
, o = t("./Pool");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
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) {
function n() {
o.apply(this, arguments)
}
var s = t("../equations/FrictionEquation")
, o = t("./Pool");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
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) {
function n() {
o.apply(this, arguments)
}
var s = t("../world/IslandNode")
, o = t("./Pool");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
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) {
function n() {
o.apply(this, arguments)
}
var s = t("../world/Island")
, o = t("./Pool");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
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) {
function n() {
this.overlappingShapesLastState = new s,
this.overlappingShapesCurrentState = new s,
this.recordPool = new o({
size: 16
}),
this.tmpDict = new s,
this.tmpArray1 = []
}
var s = t("./TupleDictionary")
, o = (t("./OverlapKeeperRecord"),
t("./OverlapKeeperRecordPool"));
t("./Utils");
e.exports = n,
n.prototype.tick = function() {
for (var t = this.overlappingShapesLastState, e =
this.overlappingShapesCurrentState, i = t.keys.length; i--; ) {
var n = t.keys[i]
, s = t.getByKey(n);
e.getByKey(n);
s && this.recordPool.release(s)
}
t.reset(),
t.copy(e),
e.reset()
}
,
n.prototype.setOverlapping = function(t, e, i, n) {
var s = (this.overlappingShapesLastState,
this.overlappingShapesCurrentState);
if (!s.get(e.id, n.id)) {
var o = this.recordPool.get();
o.set(t, e, i, n),
s.set(e.id, n.id, o)
}
}
,
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, n =
i.keys.length; n--; ) {
var s = i.keys[n]
, o = i.data[s];
if (o.bodyA === t && o.bodyB === e || o.bodyA === e &&
o.bodyB === t)
return !0
}
return !1
}
,
n.prototype.getDiff = function(t, e, i) {
var i = i || []
, n = t
, s = e;
i.length = 0;
for (var o = s.keys.length; o--; ) {
var r = s.keys[o]
, a = s.data[r];
if (!a)
throw new Error("Key " + r + " had no data!");
n.data[r] || i.push(a)
}
return i
}
,
n.prototype.isNewOverlap = function(t, e) {
var i = 0 | t.id
, n = 0 | e.id
, s = this.overlappingShapesLastState
, o = this.overlappingShapesCurrentState;
return !s.get(i, n) && !!o.get(i, n)
}
,
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, n = t.length; n--; ) {
var s = t[n];
i.set(0 | s.bodyA.id, 0 | s.bodyB.id, s)
}
for (n = i.keys.length; n--; ) {
var s = i.getByKey(i.keys[n]);
s && e.push(s.bodyA, s.bodyB)
}
return i.reset(),
e
}
}
, {
"./OverlapKeeperRecord": 53,
"./OverlapKeeperRecordPool": 54,
"./TupleDictionary": 56,
"./Utils": 57
}],
53: [function(t, e, i) {
function n(t, e, i, n) {
this.shapeA = e,
this.shapeB = n,
this.bodyA = t,
this.bodyB = i
}
e.exports = n,
n.prototype.set = function(t, e, i, s) {
n.call(this, t, e, i, s)
}
}
, {}],
54: [function(t, e, i) {
function n() {
o.apply(this, arguments)
}
var s = t("./OverlapKeeperRecord")
, o = t("./Pool");
e.exports = n,
n.prototype = new o,
n.prototype.constructor = n,
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 n(t) {
t = t || {},
this.objects = [],
void 0 !== t.size && this.resize(t.size)
}
e.exports = n,
n.prototype.resize = function(t) {
for (var e = this.objects; e.length > t; )
e.pop();
for (; e.length < t; )
e.push(this.create());
return this
}
,
n.prototype.get = function() {
var t = this.objects;
return t.length ? t.pop() : this.create()
}
,
n.prototype.release = function(t) {
return this.destroy(t),
this.objects.push(t),
this
}
}
, {}],
56: [function(t, e, i) {
function n() {
this.data = {},
this.keys = []
}
var s = t("./Utils");
e.exports = n,
n.prototype.getKey = function(t, e) {
return t |= 0,
e |= 0,
(0 | t) == (0 | e) ? -1 : 0 | ((0 | t) > (0 | e) ? t << 16 |
65535 & e : e << 16 | 65535 & t)
}
,
n.prototype.getByKey = function(t) {
return t |= 0,
this.data[t]
}
,
n.prototype.get = function(t, e) {
return this.data[this.getKey(t, e)]
}
,
n.prototype.set = function(t, e, i) {
if (!i)
throw new Error("No data!");
var n = this.getKey(t, e);
return this.data[n] || this.keys.push(n),
this.data[n] = i,
n
}
,
n.prototype.reset = function() {
for (var t = this.data, e = this.keys, i = e.length; i--; )
delete t[e[i]];
e.length = 0
}
,
n.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 n() {}
e.exports = n,
n.appendArray = function(t, e) {
if (e.length < 15e4)
t.push.apply(t, e);
else
for (var i = 0, n = e.length; i !== n; ++i)
t.push(e[i])
}
,
n.splice = function(t, e, i) {
i = i || 1;
for (var n = e, s = t.length - i; n < s; n++)
t[n] = t[n + i];
t.length = s
}
,
"undefined" != typeof P2_ARRAY_TYPE ? n.ARRAY_TYPE =
P2_ARRAY_TYPE : "undefined" != typeof Float32Array ? n.ARRAY_TYPE = Float32Array :
n.ARRAY_TYPE = Array,
n.extend = function(t, e) {
for (var i in e)
t[i] = e[i]
}
,
n.defaults = function(t, e) {
t = t || {};
for (var i in e)
i in t || (t[i] = e[i]);
return t
}
}
, {}],
58: [function(t, e, i) {
function n() {
this.equations = [],
this.bodies = []
}
var s = t("../objects/Body");
e.exports = n,
n.prototype.reset = function() {
this.equations.length = this.bodies.length = 0
}
;
var o = [];
n.prototype.getBodies = function(t) {
var e = t || []
, i = this.equations;
o.length = 0;
for (var n = 0; n !== i.length; n++) {
var s = i[n];
-1 === o.indexOf(s.bodyA.id) && (e.push(s.bodyA),
o.push(s.bodyA.id)),
-1 === o.indexOf(s.bodyB.id) && (e.push(s.bodyB),
o.push(s.bodyB.id))
}
return e
}
,
n.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
}
,
n.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) {
function n(t) {
this.nodePool = new s({
size: 16
}),
this.islandPool = new o({
size: 8
}),
this.equations = [],
this.islands = [],
this.nodes = [],
this.queue = []
}
var s = (t("../math/vec2"),
t("./Island"),
t("./IslandNode"),
t("./../utils/IslandNodePool"))
, o = t("./../utils/IslandPool")
, r = t("../objects/Body");
e.exports = n,
n.getUnvisitedNode = function(t) {
for (var e = t.length, i = 0; i !== e; i++) {
var n = t[i];
if (!n.visited && n.body.type === r.DYNAMIC)
return n
}
return !1
}
,
n.prototype.visit = function(t, e, i) {
e.push(t.body);
for (var n = t.equations.length, s = 0; s !== n; s++) {
var o = t.equations[s];
-1 === i.indexOf(o) && i.push(o)
}
}
,
n.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, a = s.pop(); o =
n.getUnvisitedNode(a.neighbors); )
o.visited = !0,
this.visit(o, e, i),
o.body.type === r.DYNAMIC && s.push(o)
}
,
n.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 r = this.nodePool.get();
r.body = e[o],
i.push(r)
}
for (var a = 0; a !== s.length; a++) {
var h = s[a]
, o = e.indexOf(h.bodyA)
, l = e.indexOf(h.bodyB)
, c = i[o]
, u = i[l];
c.neighbors.push(u),
u.neighbors.push(c),
c.equations.push(h),
u.equations.push(h)
}
for (var d = this.islands, o = 0; o < d.length; o++)
this.islandPool.release(d[o]);
d.length = 0;
for (var p; p = n.getUnvisitedNode(i); ) {
var f = this.islandPool.get();
this.bfs(p, f.bodies, f.equations),
d.push(f)
}
return d
}
}
, {
"../math/vec2": 30,
"../objects/Body": 31,
"./../utils/IslandNodePool": 50,
"./../utils/IslandPool": 51,
"./Island": 58,
"./IslandNode": 60
}],
60: [function(t, e, i) {
function n(t) {
this.body = t,
this.neighbors = [],
this.equations = [],
this.visited = !1
}
e.exports = n,
n.prototype.reset = function() {
this.equations.length = 0,
this.neighbors.length = 0,
this.visited = !1,
this.body = null
}
}
, {}],
61: [function(t, e, i) {
function n(t) {
u.apply(this),
t = t || {},
this.springs = [],
this.bodies = [],
this.disabledBodyCollisionPairs = [],
this.solver = t.solver || new s,
this.narrowphase = new y(this),
this.islandManager = new w,
this.gravity = o.fromValues(0, -9.78),
t.gravity && o.copy(this.gravity, t.gravity),
this.frictionGravity = o.length(this.gravity) || 10,
this.useWorldGravityAsFrictionGravity = !0,
this.useFrictionGravityOnZeroGravity = !0,
this.broadphase = t.broadphase || new g,
this.broadphase.setWorld(this),
this.constraints = [],
this.defaultMaterial = new p,
this.defaultContactMaterial = new
f(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 = n.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 b
}
var s = t("../solver/GSSolver")
, o = (t("../solver/Solver"),
t("../collision/Ray"),
t("../math/vec2"))
, r = t("../shapes/Circle")
, a = t("../shapes/Convex")
, h = (t("../shapes/Line"),
t("../shapes/Plane"))
, l = t("../shapes/Capsule")
, c = t("../shapes/Particle")
, u = t("../events/EventEmitter")
, d = t("../objects/Body")
, p = (t("../shapes/Shape"),
t("../objects/LinearSpring"),
t("../material/Material"))
, f = t("../material/ContactMaterial")
, m = (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"))
, g = t("../collision/SAPBroadphase")
, y = t("../collision/Narrowphase")
, v = t("../utils/Utils")
, b = t("../utils/OverlapKeeper")
, w = t("./IslandManager");
t("../objects/RotationalSpring");
e.exports = n,
n.prototype = new Object(u.prototype),
n.prototype.constructor = n,
n.NO_SLEEPING = 1,
n.BODY_SLEEPING = 2,
n.ISLAND_SLEEPING = 4,
n.prototype.addConstraint = function(t) {
this.constraints.push(t)
}
,
n.prototype.addContactMaterial = function(t) {
this.contactMaterials.push(t)
}
,
n.prototype.removeContactMaterial = function(t) {
var e = this.contactMaterials.indexOf(t);
-1 !== e && v.splice(this.contactMaterials, e, 1)
}
,
n.prototype.getContactMaterial = function(t, e) {
for (var i = this.contactMaterials, n = 0, s = i.length; n !==
s; n++) {
var o = i[n];
if (o.materialA.id === t.id && o.materialB.id === e.id ||
o.materialA.id === e.id && o.materialB.id === t.id)
return o
}
return !1
}
,
n.prototype.removeConstraint = function(t) {
var e = this.constraints.indexOf(t);
-1 !== e && v.splice(this.constraints, e, 1)
}
;
var x = (o.create(),
o.create(),
o.create(),
o.create(),
o.create(),
o.create(),
o.create())
, _ = o.fromValues(0, 0)
, P = o.fromValues(0, 0);
o.fromValues(0, 0),
o.fromValues(0, 0);
n.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 n = 0; this.accumulator >= t && n < i; )
this.internalStep(t),
this.time += t,
this.accumulator -= t,
n++;
for (var s = this.accumulator % t / t, r = 0; r !==
this.bodies.length; r++) {
var a = this.bodies[r];
o.lerp(a.interpolatedPosition, a.previousPosition,
a.position, s),
a.interpolatedAngle = a.previousAngle + s * (a.angle -
a.previousAngle)
}
}
}
;
var T = [];
n.prototype.internalStep = function(t) {
this.stepping = !0;
var e = this.springs.length
, i = this.springs
, s = this.bodies
, r = this.gravity
, a = this.solver
, h = this.bodies.length
, l = this.broadphase
, c = this.narrowphase
, u = this.constraints
, p = x
, f = (o.scale,
o.add)
, m = (o.rotate,
this.islandManager);
if (this.overlapKeeper.tick(),
this.lastTimeStep = t,
this.useWorldGravityAsFrictionGravity) {
var g = o.length(this.gravity);
0 === g && this.useFrictionGravityOnZeroGravity ||
(this.frictionGravity = g)
}
if (this.applyGravity)
for (var y = 0; y !== h; y++) {
var b = s[y]
, w = b.force;
b.type === d.DYNAMIC && b.sleepState !== d.SLEEPING &&
(o.scale(p, r, b.mass * b.gravityScale),
f(w, w, p))
}
if (this.applySpringForces)
for (var y = 0; y !== e; y++) {
var _ = i[y];
_.applyForce()
}
if (this.applyDamping)
for (var y = 0; y !== h; y++) {
var b = s[y];
b.type === d.DYNAMIC && b.applyDamping(t)
}
for (var P = l.getCollisionPairs(this), C =
this.disabledBodyCollisionPairs, y = C.length - 2; y >= 0; y -= 2)
for (var S = P.length - 2; S >= 0; S -= 2)
(C[y] === P[S] && C[y + 1] === P[S + 1] || C[y + 1] ===
P[S] && C[y] === P[S + 1]) && P.splice(S, 2);
var A = u.length;
for (y = 0; y !== A; y++) {
var k = u[y];
if (!k.collideConnected)
for (var S = P.length - 2; S >= 0; S -= 2)
(k.bodyA === P[S] && k.bodyB === P[S + 1] ||
k.bodyB === P[S] && k.bodyA === P[S + 1]) && P.splice(S, 2)
}
this.postBroadphaseEvent.pairs = P,
this.emit(this.postBroadphaseEvent),
this.postBroadphaseEvent.pairs = null,
c.reset(this);
for (var y = 0, E = P.length; y !== E; y += 2)
for (var I = P[y], M = P[y + 1], O = 0, B =
I.shapes.length; O !== B; O++)
for (var R = I.shapes[O], L = R.position, D = R.angle,
F = 0, N = M.shapes.length; F !== N; F++) {
var G = M.shapes[F]
, U = G.position
, W = G.angle
, j = this.defaultContactMaterial;
if (R.material && G.material) {
var H = this.getContactMaterial(R.material,
G.material);
H && (j = H)
}
this.runNarrowphase(c, I, R, L, D, M, G, U, W, j,
this.frictionGravity)
}
for (var y = 0; y !== h; y++) {
var X = s[y];
X._wakeUpAfterNarrowphase && (X.wakeUp(),
X._wakeUpAfterNarrowphase = !1)
}
if (this.has("endContact")) {
this.overlapKeeper.getEndOverlaps(T);
for (var q = this.endContactEvent, F = T.length; F--; ) {
var V = T[F];
q.shapeA = V.shapeA,
q.shapeB = V.shapeB,
q.bodyA = V.bodyA,
q.bodyB = V.bodyB,
this.emit(q)
}
T.length = 0
}
var Y = this.preSolveEvent;
Y.contactEquations = c.contactEquations,
Y.frictionEquations = c.frictionEquations,
this.emit(Y),
Y.contactEquations = Y.frictionEquations = null;
var A = u.length;
for (y = 0; y !== A; y++)
u[y].update();
if (c.contactEquations.length || c.frictionEquations.length ||
A)
if (this.islandSplit) {
for (m.equations.length = 0,
v.appendArray(m.equations, c.contactEquations),
v.appendArray(m.equations, c.frictionEquations),
y = 0; y !== A; y++)
v.appendArray(m.equations, u[y].equations);
m.split(this);
for (var y = 0; y !== m.islands.length; y++) {
var z = m.islands[y];
z.equations.length && a.solveIsland(t, z)
}
} else {
for (a.addEquations(c.contactEquations),
a.addEquations(c.frictionEquations),
y = 0; y !== A; y++)
a.addEquations(u[y].equations);
this.solveConstraints && a.solve(t, this),
a.removeAllEquations()
}
for (var y = 0; y !== h; y++) {
var X = s[y];
X.integrate(t)
}
for (var y = 0; y !== h; y++)
s[y].setZeroForce();
if (this.emitImpactEvent && this.has("impact"))
for (var K = this.impactEvent, y = 0; y !==
c.contactEquations.length; y++) {
var J = c.contactEquations[y];
J.firstImpact && (K.bodyA = J.bodyA,
K.bodyB = J.bodyB,
K.shapeA = J.shapeA,
K.shapeB = J.shapeB,
K.contactEquation = J,
this.emit(K))
}
if (this.sleepMode === n.BODY_SLEEPING)
for (y = 0; y !== h; y++)
s[y].sleepTick(this.time, !1, t);
else if (this.sleepMode === n.ISLAND_SLEEPING &&
this.islandSplit) {
for (y = 0; y !== h; y++)
s[y].sleepTick(this.time, !0, t);
for (var y = 0; y < this.islandManager.islands.length; y++)
{
var z = this.islandManager.islands[y];
z.wantsToSleep() && z.sleep()
}
}
this.stepping = !1;
for (var Z = this.bodiesToBeRemoved, y = 0; y !== Z.length; y+
+)
this.removeBody(Z[y]);
Z.length = 0,
this.emit(this.postStepEvent)
}
,
n.prototype.runNarrowphase = function(t, e, i, n, s, r, a, h, l, c,
u) {
if (0 != (i.collisionGroup & a.collisionMask) && 0 !=
(a.collisionGroup & i.collisionMask)) {
o.rotate(_, n, e.angle),
o.rotate(P, h, r.angle),
o.add(_, _, e.position),
o.add(P, P, r.position);
var p = s + e.angle
, f = l + r.angle;
t.enableFriction = c.friction > 0,
t.frictionCoefficient = c.friction;
var m;
m = e.type === d.STATIC || e.type === d.KINEMATIC ?
r.mass : r.type === d.STATIC || r.type === d.KINEMATIC ? e.mass : e.mass * r.mass /
(e.mass + r.mass),
t.slipForce = c.friction * u * m,
t.restitution = c.restitution,
t.surfaceVelocity = c.surfaceVelocity,
t.frictionStiffness = c.frictionStiffness,
t.frictionRelaxation = c.frictionRelaxation,
t.stiffness = c.stiffness,
t.relaxation = c.relaxation,
t.contactSkinSize = c.contactSkinSize,
t.enabledEquations = e.collisionResponse &&
r.collisionResponse && i.collisionResponse && a.collisionResponse;
var g = t[i.type | a.type]
, y = 0;
if (g) {
var v = i.sensor || a.sensor
, b = t.frictionEquations.length;
y = i.type < a.type ? g.call(t, e, i, _, p, r, a, P, f,
v) : g.call(t, r, a, P, f, e, i, _, p, v);
var w = t.frictionEquations.length - b;
if (y) {
if (e.allowSleep && e.type === d.DYNAMIC &&
e.sleepState === d.SLEEPING && r.sleepState === d.AWAKE && r.type !== d.STATIC) {
o.squaredLength(r.velocity) +
Math.pow(r.angularVelocity, 2) >= 2 * Math.pow(r.sleepSpeedLimit, 2) &&
(e._wakeUpAfterNarrowphase = !0)
}
if (r.allowSleep && r.type === d.DYNAMIC &&
r.sleepState === d.SLEEPING && e.sleepState === d.AWAKE && e.type !== d.STATIC) {
o.squaredLength(e.velocity) +
Math.pow(e.angularVelocity, 2) >= 2 * Math.pow(e.sleepSpeedLimit, 2) &&
(r._wakeUpAfterNarrowphase = !0)
}
if (this.overlapKeeper.setOverlapping(e, i, r, a),
this.has("beginContact") &&
this.overlapKeeper.isNewOverlap(i, a)) {
var x = this.beginContactEvent;
if (x.shapeA = i,
x.shapeB = a,
x.bodyA = e,
x.bodyB = r,
x.contactEquations.length = 0,
"number" == typeof y)
for (var T = t.contactEquations.length - y;
T < t.contactEquations.length; T++)

x.contactEquations.push(t.contactEquations[T]);
this.emit(x)
}
if ("number" == typeof y && w > 1)
for (var T = t.frictionEquations.length - w; T
< t.frictionEquations.length; T++) {
var C = t.frictionEquations[T];
C.setSlipForce(C.getSlipForce() / w)
}
}
}
}
}
,
n.prototype.addSpring = function(t) {
this.springs.push(t);
var e = this.addSpringEvent;
e.spring = t,
this.emit(e),
e.spring = null
}
,
n.prototype.removeSpring = function(t) {
var e = this.springs.indexOf(t);
-1 !== e && v.splice(this.springs, e, 1)
}
,
n.prototype.addBody = function(t) {
if (-1 === this.bodies.indexOf(t)) {
this.bodies.push(t),
t.world = this;
var e = this.addBodyEvent;
e.body = t,
this.emit(e),
e.body = null
}
}
,
n.prototype.removeBody = function(t) {
if (this.stepping)
this.bodiesToBeRemoved.push(t);
else {
t.world = null;
var e = this.bodies.indexOf(t);
-1 !== e && (v.splice(this.bodies, e, 1),
this.removeBodyEvent.body = t,
t.resetConstraintVelocity(),
this.emit(this.removeBodyEvent),
this.removeBodyEvent.body = null)
}
}
,
n.prototype.getBodyById = function(t) {
for (var e = this.bodies, i = 0; i < e.length; i++) {
var n = e[i];
if (n.id === t)
return n
}
return !1
}
,
n.prototype.disableBodyCollision = function(t, e) {
this.disabledBodyCollisionPairs.push(t, e)
}
,
n.prototype.enableBodyCollision = function(t, e) {
for (var i = this.disabledBodyCollisionPairs, n = 0; n <
i.length; n += 2)
if (i[n] === t && i[n + 1] === e || i[n + 1] === t && i[n]
=== e)
return void i.splice(n, 2)
}
,
n.prototype.clear = function() {
this.time = 0,
this.solver && this.solver.equations.length &&
this.solver.removeAllEquations();
for (var t = this.constraints, e = t.length - 1; e >= 0; e--)
this.removeConstraint(t[e]);
for (var i = this.bodies, e = i.length - 1; e >= 0; e--)
this.removeBody(i[e]);
for (var s = this.springs, e = s.length - 1; e >= 0; e--)
this.removeSpring(s[e]);
for (var o = this.contactMaterials, e = o.length - 1; e >= 0;
e--)
this.removeContactMaterial(o[e]);
n.apply(this)
}
;
var C = o.create()
, S = (o.fromValues(0, 0),
o.fromValues(0, 0));
n.prototype.hitTest = function(t, e, i) {
i = i || 0;
var n = new d({
position: t
})
, s = new c
, u = t
, p = 0
, f = C
, m = S;
n.addShape(s);
for (var g = this.narrowphase, y = [], v = 0, b = e.length; v !
== b; v++)
for (var w = e[v], x = 0, _ = w.shapes.length; x !== _; x+
+) {
var P = w.shapes[x];
o.rotate(f, P.position, w.angle),
o.add(f, f, w.position);
var T = P.angle + w.angle;
(P instanceof r && g.circleParticle(w, P, f, T, n, s,
u, p, !0) || P instanceof a && g.particleConvex(n, s, u, p, w, P, f, T, !0) || P
instanceof h && g.particlePlane(n, s, u, p, w, P, f, T, !0) || P instanceof l &&
g.particleCapsule(n, s, u, p, w, P, f, T, !0) || P instanceof c &&
o.squaredLength(o.sub(m, f, t)) < i * i) && y.push(w)
}
return y
}
,
n.prototype.setGlobalStiffness = function(t) {
for (var e = this.constraints, i = 0; i !== e.length; i++)
for (var n = e[i], s = 0; s !== n.equations.length; s++) {
var o = n.equations[s];
o.stiffness = t,
o.needsUpdate = !0
}
for (var r = this.contactMaterials, i = 0; i !== r.length; i++)
{
var n = r[i];
n.stiffness = n.frictionStiffness = t
}
var n = this.defaultContactMaterial;
n.stiffness = n.frictionStiffness = t
}
,
n.prototype.setGlobalRelaxation = function(t) {
for (var e = 0; e !== this.constraints.length; e++)
for (var i = this.constraints[e], n = 0; n !==
i.equations.length; n++) {
var s = i.equations[n];
s.relaxation = t,
s.needsUpdate = !0
}
for (var e = 0; e !== this.contactMaterials.length; e++) {
var i = this.contactMaterials[e];
i.relaxation = i.frictionRelaxation = t
}
var i = this.defaultContactMaterial;
i.relaxation = i.frictionRelaxation = t
}
;
var A = new m
, k = [];
n.prototype.raycast = function(t, e) {
return e.getAABB(A),
this.broadphase.aabbQuery(this, A, k),
e.intersectBodies(t, k),
k.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(t, e) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*
* @overview
*
* Phaser - http://phaser.io
*
* v2.7.3 "2017-01-09" - Built: Mon Jan 09 2017 13:26:34
*
* By Richard Davey http://www.photonstorm.com @photonstorm
*
* Phaser is a fun, free and fast 2D game framework for making HTML5 games
* for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
*
* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com
@Doormat23
* Phaser uses p2.js for full-body physics, created by Stefan Hedman
https://github.com/schteppe/p2.js @schteppe
* Phaser contains a port of N+ Physics, converted by Richard Davey, original by
http://www.metanetsoftware.com
*
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from which both
Phaser and my love of framework development originate.
*
* Follow development at http://phaser.io and on our forum
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
* -- Albert Einstein
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
(function() {
function i(t, e) {
this._scaleFactor = t,
this._deltaMode = e,
this.originalEvent = null
}
var n = this
, s = s || {
VERSION: "2.7.3",
GAMES: [],
AUTO: 0,
CANVAS: 1,
WEBGL: 2,
HEADLESS: 3,
WEBGL_MULTI: 4,
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 || {},
_UID: 0
};
if (/**
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
Math.trunc || (Math.trunc = function(t) {
return t < 0 ? Math.ceil(t) : Math.floor(t)
}
),
Function.prototype.bind || (Function.prototype.bind = function() {
var t = Array.prototype.slice;
return function(e) {
function i() {
var o = s.concat(t.call(arguments));
n.apply(this instanceof i ? this : e, o)
}
var n = this
, s = t.call(arguments, 1);
if ("function" != typeof n)
throw new TypeError;
return i.prototype = function t(e) {
if (e && (t.prototype = e),
!(this instanceof t))
return new t
}(n.prototype),
i
}
}()),
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 (void 0 === this || null === this)
throw new TypeError;
var e = Object(this)
, i = e.length >>> 0;
if ("function" != typeof t)
throw new TypeError;
for (var n = arguments.length >= 2 ? arguments[1] : void 0, s = 0; s <
i; s++)
s in e && t.call(n, e[s], s, e)
}
),
"function" != typeof window.Uint32Array && "object" != typeof
window.Uint32Array) {
var o = 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 (var e = 0; e < this.length; e++)
this[e] = t[e]
}
}
,
window[t].prototype = e,
window[t].constructor = window[t]
};
o("Float32Array"),
o("Uint32Array"),
o("Uint16Array"),
o("Int16Array"),
o("ArrayBuffer")
}
window.console || (window.console = {},
window.console.log = window.console.assert = function() {}
,
window.console.warn = window.console.assert = function() {}
),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Utils = {
reverseString: function(t) {
return t.split("").reverse().join("")
},
getProperty: function(t, e) {
for (var i = e.split("."), n = i.pop(), s = i.length, o = 1, r =
i[0]; o < s && (t = t[r]); )
r = i[o],
o++;
return t ? t[n] : null
},
setProperty: function(t, e, i) {
for (var n = e.split("."), s = n.pop(), o = n.length, r = 1, a =
n[0]; r < o && (t = t[a]); )
a = n[r],
r++;
return t && (t[s] = i),
t
},
chanceRoll: function(t) {
return void 0 === t && (t = 50),
t > 0 && 100 * Math.random() <= t
},
randomChoice: function(t, e) {
return Math.random() < .5 ? t : e
},
parseDimension: function(t, e) {
var i = 0
, n = 0;
return "string" == typeof t ? "%" === t.substr(-1) ? (i =
parseInt(t, 10) / 100,
n = 0 === e ? window.innerWidth * i : window.innerHeight * i) : n =
parseInt(t, 10) : n = t,
n
},
pad: function(t, e, i, n) {
if (void 0 === e)
var e = 0;
if (void 0 === i)
var i = " ";
if (void 0 === n)
var n = 3;
t = t.toString();
var s = 0;
if (e + 1 >= t.length)
switch (n) {
case 1:
t = new Array(e + 1 - t.length).join(i) + t;
break;
case 3:
var o = Math.ceil((s = e - t.length) / 2)
, r = s - o;
t = new Array(r + 1).join(i) + t + new Array(o +
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, n, o, r, a = arguments[0] || {}, h = 1, l =
arguments.length, c = !1;
for ("boolean" == typeof a && (c = a,
a = arguments[1] || {},
h = 2),
l === h && (a = this,
--h); h < l; h++)
if (null != (t = arguments[h]))
for (e in t)
i = a[e],
n = t[e],
a !== n && (c && n && (s.Utils.isPlainObject(n) || (o =
Array.isArray(n))) ? (o ? (o = !1,
r = i && Array.isArray(i) ? i : []) : r = i &&
s.Utils.isPlainObject(i) ? i : {},
a[e] = s.Utils.extend(c, r, n)) : void 0 !== n && (a[e]
= n));
return a
},
mixinPrototype: function(t, e, i) {
void 0 === i && (i = !1);
for (var n = Object.keys(e), s = 0; s < n.length; s++) {
var o = n[s]
, r = e[o];
!i && o in t || (!r || "function" != typeof r.get && "function"
!= typeof r.set ? t[o] = r : "function" == typeof r.clone ? t[o] = r.clone() :
Object.defineProperty(t, o, r))
}
},
mixin: function(t, e) {
if (!t || "object" != typeof t)
return e;
for (var i in t) {
var n = t[i];
if (!n.childNodes && !n.cloneNode) {
var o = typeof t[i];
t[i] && "object" === o ? typeof e[i] === o ? e[i] =
s.Utils.mixin(t[i], e[i]) : e[i] = s.Utils.mixin(t[i], new n.constructor) : e[i] =
t[i]
}
}
return e
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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 > 0 && (this._radius = .5 * i),
this.type = s.CIRCLE
}
,
s.Circle.prototype = {
circumference: function() {
return Math.PI * this._radius * 2
},
random: function(t) {
void 0 === t && (t = new s.Point);
var e = 2 * Math.PI * Math.random()
, i = Math.random() + Math.random()
, n = i > 1 ? 2 - i : i
, o = n * Math.cos(e)
, r = n * Math.sin(e);
return t.x = this.x + o * this.radius,
t.y = this.y + r * this.radius,
t
},
getBounds: function() {
return new s.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 = s.Math.distance(this.x, this.y, t.x, t.y);
return e ? Math.round(i) : i
},
clone: function(t) {
return void 0 === t || null === t ? t = new
s.Circle(this.x,this.y,this.diameter) : t.setTo(this.x, this.y, this.diameter),
t
},
contains: function(t, e) {
return s.Circle.contains(this, t, e)
},
circumferencePoint: function(t, e, i) {
return s.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 + ")}]"
}
},
s.Circle.prototype.constructor = s.Circle,
Object.defineProperty(s.Circle.prototype, "diameter", {
get: function() {
return this._diameter
},
set: function(t) {
t > 0 && (this._diameter = t,
this._radius = .5 * t)
}
}),
Object.defineProperty(s.Circle.prototype, "radius", {
get: function() {
return this._radius
},
set: function(t) {
t > 0 && (this._radius = t,
this._diameter = 2 * t)
}
}),
Object.defineProperty(s.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(s.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(s.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(s.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(s.Circle.prototype, "area", {
get: function() {
return this._radius > 0 ? Math.PI * this._radius * this._radius : 0
}
}),
Object.defineProperty(s.Circle.prototype, "empty", {
get: function() {
return 0 === this._diameter
},
set: function(t) {
!0 === t && this.setTo(0, 0, 0)
}
}),
s.Circle.contains = function(t, e, i) {
if (t.radius > 0 && e >= t.left && e <= t.right && i >= t.top && i <=
t.bottom) {
return (t.x - e) * (t.x - e) + (t.y - i) * (t.y - i) <= t.radius *
t.radius
}
return !1
}
,
s.Circle.equals = function(t, e) {
return t.x === e.x && t.y === e.y && t.diameter === e.diameter
}
,
s.Circle.intersects = function(t, e) {
return s.Math.distance(t.x, t.y, e.x, e.y) <= t.radius + e.radius
}
,
s.Circle.circumferencePoint = function(t, e, i, n) {
return void 0 === i && (i = !1),
void 0 === n && (n = new s.Point),
!0 === i && (e = s.Math.degToRad(e)),
n.x = t.x + t.radius * Math.cos(e),
n.y = t.y + t.radius * Math.sin(e),
n
}
,
s.Circle.intersectsRectangle = function(t, e) {
var i = Math.abs(t.x - e.x - e.halfWidth);
if (i > e.halfWidth + t.radius)
return !1;
var n = Math.abs(t.y - e.y - e.halfHeight);
if (n > e.halfHeight + t.radius)
return !1;
if (i <= e.halfWidth || n <= e.halfHeight)
return !0;
var s = i - e.halfWidth
, o = n - e.halfHeight;
return s * s + o * o <= t.radius * t.radius
}
,
PIXI.Circle = s.Circle,
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Chad Engler <chad@pantherdev.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Ellipse = function(t, e, i, n) {
t = t || 0,
e = e || 0,
i = i || 0,
n = n || 0,
this.x = t,
this.y = e,
this.width = i,
this.height = n,
this.type = s.ELLIPSE
}
,
s.Ellipse.prototype = {
setTo: function(t, e, i, n) {
return this.x = t,
this.y = e,
this.width = i,
this.height = n,
this
},
getBounds: function() {
return new s.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 void 0 === t || null === t ? t = new
s.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 s.Ellipse.contains(this, t, e)
},
random: function(t) {
void 0 === t && (t = new s.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 + ")}]"
}
},
s.Ellipse.prototype.constructor = s.Ellipse,
Object.defineProperty(s.Ellipse.prototype, "left", {
get: function() {
return this.x
},
set: function(t) {
this.x = t
}
}),
Object.defineProperty(s.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(s.Ellipse.prototype, "top", {
get: function() {
return this.y
},
set: function(t) {
this.y = t
}
}),
Object.defineProperty(s.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(s.Ellipse.prototype, "empty", {
get: function() {
return 0 === this.width || 0 === this.height
},
set: function(t) {
!0 === t && this.setTo(0, 0, 0, 0)
}
}),
s.Ellipse.contains = function(t, e, i) {
if (t.width <= 0 || t.height <= 0)
return !1;
var n = (e - t.x) / t.width - .5
, s = (i - t.y) / t.height - .5;
return n *= n,
s *= s,
n + s < .25
}
,
PIXI.Ellipse = s.Ellipse,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Line = function(t, e, i, n) {
t = t || 0,
e = e || 0,
i = i || 0,
n = n || 0,
this.start = new s.Point(t,e),
this.end = new s.Point(i,n),
this.type = s.LINE
}
,
s.Line.prototype = {
setTo: function(t, e, i, n) {
return this.start.setTo(t, e),
this.end.setTo(i, n),
this
},
fromSprite: function(t, e, i) {
return void 0 === i && (i = !1),
i ? this.setTo(t.centerX, t.centerY, e.centerX, e.centerY) :
this.setTo(t.x, t.y, e.x, e.y)
},
fromAngle: function(t, e, i, n) {
return this.start.setTo(t, e),
this.end.setTo(t + Math.cos(i) * n, e + Math.sin(i) * n),
this
},
rotate: function(t, e) {
var i = (this.start.x + this.end.x) / 2
, n = (this.start.y + this.end.y) / 2;
return this.start.rotate(i, n, t, e),
this.end.rotate(i, n, t, e),
this
},
rotateAround: function(t, e, i, n) {
return this.start.rotate(t, e, i, n),
this.end.rotate(t, e, i, n),
this
},
intersects: function(t, e, i) {
return s.Line.intersectsPoints(this.start, this.end, t.start,
t.end, e, i)
},
reflect: function(t) {
return s.Line.reflect(this, t)
},
midPoint: function(t) {
return void 0 === t && (t = new s.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 = (this.start.x + this.end.x) / 2
, n = (this.start.y + this.end.y) / 2
, s = t - i
, o = e - n;
this.start.add(s, o),
this.end.add(s, o)
},
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)
, n = Math.max(this.start.x, this.end.x)
, s = Math.min(this.start.y, this.end.y)
, o = Math.max(this.start.y, this.end.y);
return this.pointOnLine(t, e) && t >= i && t <= n && e >= s && e <=
o
},
random: function(t) {
void 0 === t && (t = new s.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)
, n = Math.round(this.start.y)
, s = Math.round(this.end.x)
, o = Math.round(this.end.y)
, r = Math.abs(s - i)
, a = Math.abs(o - n)
, h = i < s ? 1 : -1
, l = n < o ? 1 : -1
, c = r - a;
e.push([i, n]);
for (var u = 1; i !== s || n !== o; ) {
var d = c << 1;
d > -a && (c -= a,
i += h),
d < r && (c += r,
n += l),
u % t == 0 && e.push([i, n]),
u++
}
return e
},
clone: function(t) {
return void 0 === t || null === t ? t = new
s.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(s.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(s.Line.prototype, "angle", {
get: function() {
return Math.atan2(this.end.y - this.start.y, this.end.x -
this.start.x)
}
}),
Object.defineProperty(s.Line.prototype, "slope", {
get: function() {
return (this.end.y - this.start.y) / (this.end.x - this.start.x)
}
}),
Object.defineProperty(s.Line.prototype, "perpSlope", {
get: function() {
return -(this.end.x - this.start.x) / (this.end.y - this.start.y)
}
}),
Object.defineProperty(s.Line.prototype, "x", {
get: function() {
return Math.min(this.start.x, this.end.x)
}
}),
Object.defineProperty(s.Line.prototype, "y", {
get: function() {
return Math.min(this.start.y, this.end.y)
}
}),
Object.defineProperty(s.Line.prototype, "left", {
get: function() {
return Math.min(this.start.x, this.end.x)
}
}),
Object.defineProperty(s.Line.prototype, "right", {
get: function() {
return Math.max(this.start.x, this.end.x)
}
}),
Object.defineProperty(s.Line.prototype, "top", {
get: function() {
return Math.min(this.start.y, this.end.y)
}
}),
Object.defineProperty(s.Line.prototype, "bottom", {
get: function() {
return Math.max(this.start.y, this.end.y)
}
}),
Object.defineProperty(s.Line.prototype, "width", {
get: function() {
return Math.abs(this.start.x - this.end.x)
}
}),
Object.defineProperty(s.Line.prototype, "height", {
get: function() {
return Math.abs(this.start.y - this.end.y)
}
}),
Object.defineProperty(s.Line.prototype, "normalX", {
get: function() {
return Math.cos(this.angle - 1.5707963267948966)
}
}),
Object.defineProperty(s.Line.prototype, "normalY", {
get: function() {
return Math.sin(this.angle - 1.5707963267948966)
}
}),
Object.defineProperty(s.Line.prototype, "normalAngle", {
get: function() {
return s.Math.wrap(this.angle - 1.5707963267948966, -Math.PI,
Math.PI)
}
}),
s.Line.intersectsPoints = function(t, e, i, n, o, r) {
void 0 === o && (o = !0),
void 0 === r && (r = new s.Point);
var a = e.y - t.y
, h = n.y - i.y
, l = t.x - e.x
, c = i.x - n.x
, u = e.x * t.y - t.x * e.y
, d = n.x * i.y - i.x * n.y
, p = a * c - h * l;
if (0 === p)
return null;
if (r.x = (l * d - c * u) / p,
r.y = (h * u - a * d) / p,
o) {
var f = (n.y - i.y) * (e.x - t.x) - (n.x - i.x) * (e.y - t.y)
, m = ((n.x - i.x) * (t.y - i.y) - (n.y - i.y) * (t.x - i.x)) / f
, g = ((e.x - t.x) * (t.y - i.y) - (e.y - t.y) * (t.x - i.x)) /
f;
return m >= 0 && m <= 1 && g >= 0 && g <= 1 ? r : null
}
return r
}
,
s.Line.intersects = function(t, e, i, n) {
return s.Line.intersectsPoints(t.start, t.end, e.start, e.end, i, n)
}
,
s.Line.intersectsRectangle = function(t, e) {
if (0 === t.length || e.empty)
return !1;
var i = t.start.x
, n = t.start.y
, s = t.end.x
, o = t.end.y
, r = e.x
, a = e.y
, h = e.right
, l = e.bottom
, c = 0;
if (i >= r && i <= h && n >= a && n <= l || s >= r && s <= h && o >= a
&& o <= l)
return !0;
if (i < r && s >= r) {
if ((c = n + (o - n) * (r - i) / (s - i)) > a && c <= l)
return !0
} else if (i > h && s <= h && (c = n + (o - n) * (h - i) / (s - i)) >=
a && c <= l)
return !0;
if (n < a && o >= a) {
if ((c = i + (s - i) * (a - n) / (o - n)) >= r && c <= h)
return !0
} else if (n > l && o <= l && (c = i + (s - i) * (l - n) / (o - n)) >=
r && c <= h)
return !0;
return !1
}
,
s.Line.reflect = function(t, e) {
return 2 * e.normalAngle - 3.141592653589793 - t.angle
}
,
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Matrix = function(t, e, i, n, o, r) {
void 0 !== t && null !== t || (t = 1),
void 0 !== e && null !== e || (e = 0),
void 0 !== i && null !== i || (i = 0),
void 0 !== n && null !== n || (n = 1),
void 0 !== o && null !== o || (o = 0),
void 0 !== r && null !== r || (r = 0),
this.a = t,
this.b = e,
this.c = i,
this.d = n,
this.tx = o,
this.ty = r,
this.type = s.MATRIX
}
,
s.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, n, s, o) {
return this.a = t,
this.b = e,
this.c = i,
this.d = n,
this.tx = s,
this.ty = o,
this
},
clone: function(t) {
return void 0 === t || null === t ? t = new
s.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 Float32Array(9)),
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,
e[7] = this.ty,
e[8] = 1) : (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,
e[7] = 0,
e[8] = 1),
e
},
apply: function(t, e) {
return void 0 === e && (e = new s.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 s.Point);
var i = 1 / (this.a * this.d + this.c * -this.b)
, n = t.x
, o = t.y;
return e.x = this.d * i * n + -this.c * i * o + (this.ty * this.c -
this.tx * this.d) * i,
e.y = this.a * i * o + -this.b * i * n + (-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)
, n = this.a
, s = this.c
, o = this.tx;
return this.a = n * e - this.b * i,
this.b = n * i + this.b * e,
this.c = s * e - this.d * i,
this.d = s * i + this.d * e,
this.tx = o * e - this.ty * i,
this.ty = o * i + this.ty * e,
this
},
append: function(t) {
var e = this.a
, i = this.b
, n = this.c
, s = this.d;
return this.a = t.a * e + t.b * n,
this.b = t.a * i + t.b * s,
this.c = t.c * e + t.d * n,
this.d = t.c * i + t.d * s,
this.tx = t.tx * e + t.ty * n + this.tx,
this.ty = t.tx * i + t.ty * s + this.ty,
this
},
identity: function() {
return this.setTo(1, 0, 0, 1, 0, 0)
}
},
s.identityMatrix = new s.Matrix,
PIXI.Matrix = s.Matrix,
PIXI.identityMatrix = s.identityMatrix,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Point = function(t, e) {
t = t || 0,
e = e || 0,
this.x = t,
this.y = e,
this.type = s.POINT
}
,
s.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 = s.Math.clamp(this.x, t, e),
this
},
clampY: function(t, e) {
return this.y = s.Math.clamp(this.y, t, e),
this
},
clamp: function(t, e) {
return this.x = s.Math.clamp(this.x, t, e),
this.y = s.Math.clamp(this.y, t, e),
this
},
clone: function(t) {
return void 0 === t || null === t ? t = new
s.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 s.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 ? s.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, n, o) {
return s.Point.rotate(this, t, e, i, n, 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
},
limit: function(t) {
return this.getMagnitudeSq() > t * t && this.setMagnitude(t),
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 + ")}]"
}
},
s.Point.prototype.constructor = s.Point,
s.Point.add = function(t, e, i) {
return void 0 === i && (i = new s.Point),
i.x = t.x + e.x,
i.y = t.y + e.y,
i
}
,
s.Point.subtract = function(t, e, i) {
return void 0 === i && (i = new s.Point),
i.x = t.x - e.x,
i.y = t.y - e.y,
i
}
,
s.Point.multiply = function(t, e, i) {
return void 0 === i && (i = new s.Point),
i.x = t.x * e.x,
i.y = t.y * e.y,
i
}
,
s.Point.divide = function(t, e, i) {
return void 0 === i && (i = new s.Point),
i.x = t.x / e.x,
i.y = t.y / e.y,
i
}
,
s.Point.equals = function(t, e) {
return t.x === e.x && t.y === e.y
}
,
s.Point.angle = function(t, e) {
return Math.atan2(t.y - e.y, t.x - e.x)
}
,
s.Point.negative = function(t, e) {
return void 0 === e && (e = new s.Point),
e.setTo(-t.x, -t.y)
}
,
s.Point.multiplyAdd = function(t, e, i, n) {
return void 0 === n && (n = new s.Point),
n.setTo(t.x + e.x * i, t.y + e.y * i)
}
,
s.Point.interpolate = function(t, e, i, n) {
return void 0 === n && (n = new s.Point),
n.setTo(t.x + (e.x - t.x) * i, t.y + (e.y - t.y) * i)
}
,
s.Point.perp = function(t, e) {
return void 0 === e && (e = new s.Point),
e.setTo(-t.y, t.x)
}
,
s.Point.rperp = function(t, e) {
return void 0 === e && (e = new s.Point),
e.setTo(t.y, -t.x)
}
,
s.Point.distance = function(t, e, i) {
var n = s.Math.distance(t.x, t.y, e.x, e.y);
return i ? Math.round(n) : n
}
,
s.Point.project = function(t, e, i) {
void 0 === i && (i = new s.Point);
var n = t.dot(e) / e.getMagnitudeSq();
return 0 !== n && i.setTo(n * e.x, n * e.y),
i
}
,
s.Point.projectUnit = function(t, e, i) {
void 0 === i && (i = new s.Point);
var n = t.dot(e);
return 0 !== n && i.setTo(n * e.x, n * e.y),
i
}
,
s.Point.normalRightHand = function(t, e) {
return void 0 === e && (e = new s.Point),
e.setTo(-1 * t.y, t.x)
}
,
s.Point.normalize = function(t, e) {
void 0 === e && (e = new s.Point);
var i = t.getMagnitude();
return 0 !== i && e.setTo(t.x / i, t.y / i),
e
}
,
s.Point.rotate = function(t, e, i, n, o, r) {
if (o && (n = s.Math.degToRad(n)),
void 0 === r) {
t.subtract(e, i);
var a = Math.sin(n)
, h = Math.cos(n)
, l = h * t.x - a * t.y
, c = a * t.x + h * t.y;
t.x = l + e,
t.y = c + i
} else {
var u = n + Math.atan2(t.y - i, t.x - e);
t.x = e + r * Math.cos(u),
t.y = i + r * Math.sin(u)
}
return t
}
,
s.Point.centroid = function(t, e) {
if (void 0 === e && (e = new s.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 n = 0; n < i; n++)
s.Point.add(e, t[n], e);
return e.divide(i, i),
e
}
,
s.Point.parse = function(t, e, i) {
e = e || "x",
i = i || "y";
var n = new s.Point;
return t[e] && (n.x = parseInt(t[e], 10)),
t[i] && (n.y = parseInt(t[i], 10)),
n
}
,
PIXI.Point = s.Point,
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Adrien Brault <adrien.brault@gmail.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Polygon = function() {
this.area = 0,
this._points = [],
arguments.length > 0 && this.setTo.apply(this, arguments),
this.closed = !0,
this.flattened = !1,
this.type = s.POLYGON
}
,
s.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 void 0 === t || null === t ? t = new s.Polygon(e) :
t.setTo(e),
t
},
contains: function(t, e) {
var i = !1;
if (this.flattened)
for (var n = -2, s = this._points.length - 2; (n += 2) <
this._points.length; s = n) {
var o = this._points[n]
, r = this._points[n + 1]
, a = this._points[s]
, h = this._points[s + 1];
(r <= e && e < h || h <= e && e < r) && t < (a - o) * (e -
r) / (h - r) + o && (i = !i)
}
else
for (var n = -1, s = this._points.length - 1; ++n <
this._points.length; s = n) {
var o = this._points[n].x
, r = this._points[n].y
, a = this._points[s].x
, h = this._points[s].y;
(r <= e && e < h || h <= e && e < r) && t < (a - o) * (e -
r) / (h - r) + o && (i = !i)
}
return i
},
setTo: function(t) {
if (this.area = 0,
this._points = [],
arguments.length > 0) {
Array.isArray(t) || (t =
Array.prototype.slice.call(arguments));
for (var e = Number.MAX_VALUE, i = 0, n = t.length; i < n; i++)
{
if ("number" == typeof t[i]) {
var s = new PIXI.Point(t[i],t[i + 1]);
i++
} else if (Array.isArray(t[i]))
var s = new PIXI.Point(t[i][0],t[i][1]);
else
var s = new PIXI.Point(t[i].x,t[i].y);
this._points.push(s),
s.y < e && (e = s.y)
}
this.calculateArea(e)
}
return this
},
calculateArea: function(t) {
for (var e, i, n, s, o = 0, r = this._points.length; o < r; o++)
e = this._points[o],
i = o === r - 1 ? this._points[0] : this._points[o + 1],
n = (e.y - t + (i.y - t)) / 2,
s = e.x - i.x,
this.area += n * s;
return this.area
}
},
s.Polygon.prototype.constructor = s.Polygon,
Object.defineProperty(s.Polygon.prototype, "points", {
get: function() {
return this._points
},
set: function(t) {
null != t ? this.setTo(t) : this.setTo()
}
}),
PIXI.Polygon = s.Polygon,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Rectangle = function(t, e, i, n) {
t = t || 0,
e = e || 0,
i = i || 0,
n = n || 0,
this.x = t,
this.y = e,
this.width = i,
this.height = n,
this.type = s.RECTANGLE
}
,
s.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, n) {
return this.x = t,
this.y = e,
this.width = i,
this.height = n,
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 s.Rectangle.inflate(this, t, e)
},
size: function(t) {
return s.Rectangle.size(this, t)
},
resize: function(t, e) {
return this.width = t,
this.height = e,
this
},
clone: function(t) {
return s.Rectangle.clone(this, t)
},
contains: function(t, e) {
return s.Rectangle.contains(this, t, e)
},
containsRect: function(t) {
return s.Rectangle.containsRect(t, this)
},
equals: function(t) {
return s.Rectangle.equals(this, t)
},
intersection: function(t, e) {
return s.Rectangle.intersection(this, t, e)
},
intersects: function(t) {
return s.Rectangle.intersects(this, t)
},
intersectsRaw: function(t, e, i, n, o) {
return s.Rectangle.intersectsRaw(this, t, e, i, n, o)
},
union: function(t, e) {
return s.Rectangle.union(this, t, e)
},
random: function(t) {
return void 0 === t && (t = new s.Point),
t.x = this.randomX,
t.y = this.randomY,
t
},
getPoint: function(t, e) {
switch (void 0 === e && (e = new s.Point),
t) {
default:
case s.TOP_LEFT:
return e.set(this.x, this.y);
case s.TOP_CENTER:
return e.set(this.centerX, this.y);
case s.TOP_RIGHT:
return e.set(this.right, this.y);
case s.LEFT_CENTER:
return e.set(this.x, this.centerY);
case s.CENTER:
return e.set(this.centerX, this.centerY);
case s.RIGHT_CENTER:
return e.set(this.right, this.centerY);
case s.BOTTOM_LEFT:
return e.set(this.x, this.bottom);
case s.BOTTOM_CENTER:
return e.set(this.centerX, this.bottom);
case s.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(s.Rectangle.prototype, "halfWidth", {
get: function() {
return Math.round(this.width / 2)
}
}),
Object.defineProperty(s.Rectangle.prototype, "halfHeight", {
get: function() {
return Math.round(this.height / 2)
}
}),
Object.defineProperty(s.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(s.Rectangle.prototype, "bottomLeft", {
get: function() {
return new s.Point(this.x,this.bottom)
},
set: function(t) {
this.x = t.x,
this.bottom = t.y
}
}),
Object.defineProperty(s.Rectangle.prototype, "bottomRight", {
get: function() {
return new s.Point(this.right,this.bottom)
},
set: function(t) {
this.right = t.x,
this.bottom = t.y
}
}),
Object.defineProperty(s.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(s.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(s.Rectangle.prototype, "volume", {
get: function() {
return this.width * this.height
}
}),
Object.defineProperty(s.Rectangle.prototype, "perimeter", {
get: function() {
return 2 * this.width + 2 * this.height
}
}),
Object.defineProperty(s.Rectangle.prototype, "centerX", {
get: function() {
return this.x + this.halfWidth
},
set: function(t) {
this.x = t - this.halfWidth
}
}),
Object.defineProperty(s.Rectangle.prototype, "centerY", {
get: function() {
return this.y + this.halfHeight
},
set: function(t) {
this.y = t - this.halfHeight
}
}),
Object.defineProperty(s.Rectangle.prototype, "randomX", {
get: function() {
return this.x + Math.random() * this.width
}
}),
Object.defineProperty(s.Rectangle.prototype, "randomY", {
get: function() {
return this.y + Math.random() * this.height
}
}),
Object.defineProperty(s.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(s.Rectangle.prototype, "topLeft", {
get: function() {
return new s.Point(this.x,this.y)
},
set: function(t) {
this.x = t.x,
this.y = t.y
}
}),
Object.defineProperty(s.Rectangle.prototype, "topRight", {
get: function() {
return new s.Point(this.x + this.width,this.y)
},
set: function(t) {
this.right = t.x,
this.y = t.y
}
}),
Object.defineProperty(s.Rectangle.prototype, "empty", {
get: function() {
return !this.width || !this.height
},
set: function(t) {
!0 === t && this.setTo(0, 0, 0, 0)
}
}),
s.Rectangle.prototype.constructor = s.Rectangle,
s.Rectangle.inflate = function(t, e, i) {
return t.x -= e,
t.width += 2 * e,
t.y -= i,
t.height += 2 * i,
t
}
,
s.Rectangle.inflatePoint = function(t, e) {
return s.Rectangle.inflate(t, e.x, e.y)
}
,
s.Rectangle.size = function(t, e) {
return void 0 === e || null === e ? e = new s.Point(t.width,t.height) :
e.setTo(t.width, t.height),
e
}
,
s.Rectangle.clone = function(t, e) {
return void 0 === e || null === e ? e = new
s.Rectangle(t.x,t.y,t.width,t.height) : e.setTo(t.x, t.y, t.width, t.height),
e
}
,
s.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)
}
,
s.Rectangle.containsRaw = function(t, e, i, n, s, o) {
return s >= t && s < t + i && o >= e && o < e + n
}
,
s.Rectangle.containsPoint = function(t, e) {
return s.Rectangle.contains(t, e.x, e.y)
}
,
s.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)
}
,
s.Rectangle.equals = function(t, e) {
return t.x === e.x && t.y === e.y && t.width === e.width && t.height
=== e.height
}
,
s.Rectangle.sameDimensions = function(t, e) {
return t.width === e.width && t.height === e.height
}
,
s.Rectangle.intersection = function(t, e, i) {
return void 0 === i && (i = new s.Rectangle),
s.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
}
,
s.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)
}
,
s.Rectangle.intersectsRaw = function(t, e, i, n, s, o) {
return void 0 === o && (o = 0),
!(e > t.right + o || i < t.left - o || n > t.bottom + o || s < t.top -
o)
}
,
s.Rectangle.union = function(t, e, i) {
return void 0 === i && (i = new s.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))
}
,
s.Rectangle.aabb = function(t, e) {
void 0 === e && (e = new s.Rectangle);
var i = Number.NEGATIVE_INFINITY
, n = Number.POSITIVE_INFINITY
, o = Number.NEGATIVE_INFINITY
, r = Number.POSITIVE_INFINITY;
return t.forEach(function(t) {
t.x > i && (i = t.x),
t.x < n && (n = t.x),
t.y > o && (o = t.y),
t.y < r && (r = t.y)
}),
e.setTo(n, r, i - n, o - r),
e
}
,
PIXI.Rectangle = s.Rectangle,
PIXI.EmptyRectangle = new s.Rectangle(0,0,0,0),
/**
* @author Mat Groves http://matgroves.com/
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.RoundedRectangle = function(t, e, i, n, o) {
void 0 === t && (t = 0),
void 0 === e && (e = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 0),
void 0 === o && (o = 20),
this.x = t,
this.y = e,
this.width = i,
this.height = n,
this.radius = o || 20,
this.type = s.ROUNDEDRECTANGLE
}
,
s.RoundedRectangle.prototype = {
clone: function() {
return new
s.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 (t >= i && t <= i + this.width) {
var n = this.y;
if (e >= n && e <= n + this.height)
return !0
}
return !1
}
},
s.RoundedRectangle.prototype.constructor = s.RoundedRectangle,
PIXI.RoundedRectangle = s.RoundedRectangle,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Camera = function(t, e, i, n, o, r) {
this.game = t,
this.world = t.world,
this.id = 0,
this.view = new s.Rectangle(i,n,o,r),
this.bounds = new s.Rectangle(i,n,o,r),
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 s.Point(1,1),
this.onShakeComplete = new s.Signal,
this.onFlashComplete = new s.Signal,
this.onFadeComplete = new s.Signal,
this.fx = null,
this._targetPosition = new s.Point,
this._edge = 0,
this._position = new s.Point,
this._shake = {
intensity: 0,
duration: 0,
horizontal: !1,
vertical: !1,
shakeBounds: !0,
x: 0,
y: 0
},
this._fxDuration = 0,
this._fxType = 0
}
,
s.Camera.FOLLOW_LOCKON = 0,
s.Camera.FOLLOW_PLATFORMER = 1,
s.Camera.FOLLOW_TOPDOWN = 2,
s.Camera.FOLLOW_TOPDOWN_TIGHT = 3,
s.Camera.SHAKE_BOTH = 4,
s.Camera.SHAKE_HORIZONTAL = 5,
s.Camera.SHAKE_VERTICAL = 6,
s.Camera.ENABLE_FX = !0,
s.Camera.prototype = {
boot: function() {
this.displayObject = this.game.world,
this.scale = this.game.world.scale,
this.game.camera = this,
s.Graphics && s.Camera.ENABLE_FX && (this.fx = new
s.Graphics(this.game),
this.game.stage.addChild(this.fx))
},
preUpdate: function() {
this.totalInView = 0
},
follow: function(t, e, i, n) {
void 0 === e && (e = s.Camera.FOLLOW_LOCKON),
void 0 === i && (i = 1),
void 0 === n && (n = 1),
this.target = t,
this.lerp.set(i, n);
var o;
switch (e) {
case s.Camera.FOLLOW_PLATFORMER:
var r = this.width / 8
, a = this.height / 3;
this.deadzone = new s.Rectangle((this.width - r) / 2,
(this.height - a) / 2 - .25 * a,r,a);
break;
case s.Camera.FOLLOW_TOPDOWN:
o = Math.max(this.width, this.height) / 4,
this.deadzone = new s.Rectangle((this.width - o) / 2,
(this.height - o) / 2,o,o);
break;
case s.Camera.FOLLOW_TOPDOWN_TIGHT:
o = Math.max(this.width, this.height) / 8,
this.deadzone = new s.Rectangle((this.width - o) / 2,
(this.height - o) / 2,o,o);
break;
case s.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, n, o) {
return void 0 === t && (t = .05),
void 0 === e && (e = 500),
void 0 === i && (i = !0),
void 0 === n && (n = s.Camera.SHAKE_BOTH),
void 0 === o && (o = !0),
!(!i && this._shake.duration > 0) && (this._shake.intensity = t,
this._shake.duration = e,
this._shake.shakeBounds = o,
this._shake.x = 0,
this._shake.y = 0,
this._shake.horizontal = n === s.Camera.SHAKE_BOTH || n ===
s.Camera.SHAKE_HORIZONTAL,
this._shake.vertical = n === s.Camera.SHAKE_BOTH || n ===
s.Camera.SHAKE_VERTICAL,
!0)
},
flash: function(t, e, i, n) {
return void 0 === t && (t = 16777215),
void 0 === e && (e = 500),
void 0 === i && (i = !1),
void 0 === n && (n = 1),
!(!this.fx || !i && this._fxDuration > 0) && (this.fx.clear(),
this.fx.beginFill(t, n),
this.fx.drawRect(0, 0, this.width, this.height),
this.fx.endFill(),
this.fx.alpha = 1,
this._fxDuration = e,
this._fxType = 0,
!0)
},
fade: function(t, e, i, n) {
return void 0 === t && (t = 0),
void 0 === e && (e = 500),
void 0 === i && (i = !1),
void 0 === n && (n = 1),
!(!this.fx || !i && this._fxDuration > 0) && (this.fx.clear(),
this.fx.beginFill(t, n),
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() {
this._fxDuration > 0 && this.updateFX(),
this._shake.duration > 0 && 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,
this.fx.alpha >= 1 && (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
, n = 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)),
n >= 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
}
},
s.Camera.prototype.constructor = s.Camera,
Object.defineProperty(s.Camera.prototype, "x", {
get: function() {
return this.view.x
},
set: function(t) {
this.view.x = t,
this.bounds && this.checkBounds()
}
}),
Object.defineProperty(s.Camera.prototype, "y", {
get: function() {
return this.view.y
},
set: function(t) {
this.view.y = t,
this.bounds && this.checkBounds()
}
}),
Object.defineProperty(s.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(s.Camera.prototype, "width", {
get: function() {
return this.view.width
},
set: function(t) {
this.view.width = t
}
}),
Object.defineProperty(s.Camera.prototype, "height", {
get: function() {
return this.view.height
},
set: function(t) {
this.view.height = t
}
}),
Object.defineProperty(s.Camera.prototype, "shakeIntensity", {
get: function() {
return this._shake.intensity
},
set: function(t) {
this._shake.intensity = t
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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
}
,
s.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() {}
},
s.State.prototype.constructor = s.State,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.StateManager = function(t, e) {
this.game = t,
this.states = {},
this._pendingState = null,
void 0 !== e && null !== e && (this._pendingState = e),
this._clearWorld = !1,
this._clearCache = !1,
this._created = !1,
this._args = [],
this.current = "",
this.onStateChange = new s.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
}
,
s.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) {
void 0 === i && (i = !1);
var n;
return e instanceof s.State ? n = e : "object" == typeof e ? (n =
e,
n.game = this.game) : "function" == typeof e && (n = new
e(this.game)),
this.states[t] = n,
i && (this.game.isBooted ? this.start(t) : this._pendingState = t),
n
},
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,
arguments.length > 3 && (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,
arguments.length > 2 && (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) ||
(console.warn("Invalid Phaser State object given. Must contain at least a one of
the required functions: preload, create, update or render"),
!1) : (console.warn("Phaser.StateManager - No state found with the
key: " + t),
!1)
},
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,
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 ===
s.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 = ""
}
},
s.StateManager.prototype.constructor = s.StateManager,
Object.defineProperty(s.StateManager.prototype, "created", {
get: function() {
return this._created
}
}),
/**
* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Signal = function() {}
,
s.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, n, o) {
var r, a = this._indexOfListener(t, i);
if (-1 !== a) {
if (r = this._bindings[a],
r.isOnce() !== e)
throw new Error("You cannot add" + (e ? "" : "Once") + "()
then add" + (e ? "Once" : "") + "() the same listener without removing the
relationship first.")
} else
r = new s.SignalBinding(this,t,e,i,n,o),
this._addBinding(r);
return this.memorize && this._prevParams &&
r.execute(this._prevParams),
r
},
_addBinding: function(t) {
this._bindings || (this._bindings = []);
var e = this._bindings.length;
do {
e--
} while (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, n = this._bindings.length; n--; )
if (i = this._bindings[n],
i._listener === t && i.context === e)
return n;
return -1
},
has: function(t, e) {
return -1 !== this._indexOfListener(t, e)
},
add: function(t, e, i) {
this.validateListener(t, "add");
var n = [];
if (arguments.length > 3)
for (var s = 3; s < arguments.length; s++)
n.push(arguments[s]);
return this._registerListener(t, !1, e, i, n)
},
addOnce: function(t, e, i) {
this.validateListener(t, "addOnce");
var n = [];
if (arguments.length > 3)
for (var s = 3; s < arguments.length; s++)
n.push(arguments[s]);
return this._registerListener(t, !0, e, i, n)
},
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) {
t = this._bindings.slice(),
this._shouldPropagate = !0;
do {
i--
} while (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(s.Signal.prototype, "boundDispatch", {
get: function() {
var t = this;
return this._boundDispatch || (this._boundDispatch = function() {
return t.dispatch.apply(t, arguments)
}
)
}
}),
s.Signal.prototype.constructor = s.Signal,
/**
* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.SignalBinding = function(t, e, i, n, s, o) {
this._listener = e,
i && (this._isOnce = !0),
null != n && (this.context = n),
this._signal = t,
s && (this._priority = s),
o && o.length && (this._args = o)
}
,
s.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 + "]"
}
},
s.SignalBinding.prototype.constructor = s.SignalBinding,
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Mat Groves (@Doormat23)
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Filter = function(t, e, i) {
this.game = t,
this.type = s.WEBGL_FILTER,
this.passes = [this],
this.shaders = [],
this.dirty = !0,
this.padding = 0,
this.prevPoint = new s.Point;
var n = 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: [n.getFullYear(), n.getMonth(), n.getDate(), 60 *
n.getHours() * 60 + 60 * n.getMinutes() + n.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];
"string" == typeof i && (i = i.split("\n")),
this.fragmentSrc = i || []
}
,
s.Filter.prototype = {
init: function() {},
setResolution: function(t, e) {
this.uniforms.resolution.value.x = t,
this.uniforms.resolution.value.y = e
},
update: function(t) {
if (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, n, s, o) {
void 0 === s && (s = 0),
void 0 === o && (o = 0),
void 0 !== i && null !== i ? this.width = i : i = this.width,
void 0 !== n && null !== n ? this.height = n : n = this.height;
var r = this.game.add.image(t, e, "__default");
return r.width = i,
r.height = n,
r.anchor.set(s, o),
r.filters = [this],
r
},
syncUniforms: function() {
for (var t = 0; t < this.shaders.length; t++)
this.shaders[t].dirty = !0
},
destroy: function() {
this.passes.length = 0,
this.shaders.length = 0,
this.fragmentSrc.length = 0,
this.game = null,
this.uniforms = null,
this.prevPoint = null
}
},
s.Filter.prototype.constructor = s.Filter,
Object.defineProperty(s.Filter.prototype, "width", {
get: function() {
return this.uniforms.resolution.value.x
},
set: function(t) {
this.uniforms.resolution.value.x = t
}
}),
Object.defineProperty(s.Filter.prototype, "height", {
get: function() {
return this.uniforms.resolution.value.y
},
set: function(t) {
this.uniforms.resolution.value.y = t
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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
}
,
s.Plugin.prototype = {
preUpdate: function() {},
update: function() {},
render: function() {},
postRender: function() {},
destroy: function() {
this.game = null,
this.parent = null,
this.active = !1,
this.visible = !1
}
},
s.Plugin.prototype.constructor = s.Plugin,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.PluginManager = function(t) {
this.game = t,
this.plugins = [],
this._len = 0,
this._i = 0
}
,
s.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 && (t.hasPreUpdate = !0,
i = !0),
"function" == typeof t.update && (t.hasUpdate = !0,
i = !0),
"function" == typeof t.postUpdate && (t.hasPostUpdate = !0,
i = !0),
"function" == typeof t.render && (t.hasRender = !0,
i = !0),
"function" == typeof t.postRender && (t.hasPostRender = !0,
i = !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
}
},
s.PluginManager.prototype.constructor = s.PluginManager,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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,
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)
}
,
s.Stage.prototype = Object.create(PIXI.DisplayObjectContainer.prototype),
s.Stage.prototype.constructor = s.Stage,
s.Stage.prototype.parseConfig = function(t) {
t.disableVisibilityChange && (this.disableVisibilityChange =
t.disableVisibilityChange),
t.backgroundColor && this.setBackgroundColor(t.backgroundColor)
}
,
s.Stage.prototype.boot = function() {
s.DOM.getOffset(this.game.canvas, this.offset),
s.Canvas.setUserSelect(this.game.canvas, "none"),
s.Canvas.setTouchAction(this.game.canvas, "none"),
this.checkVisibility()
}
,
s.Stage.prototype.preUpdate = function() {
this.currentRenderOrderID = 0;
for (var t = 0; t < this.children.length; t++)
this.children[t].preUpdate()
}
,
s.Stage.prototype.update = function() {
for (var t = this.children.length; t--; )
this.children[t].update()
}
,
s.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()
}
,
s.Stage.prototype.updateTransform = function() {
this.worldAlpha = 1;
for (var t = 0; t < this.children.length; t++)
this.children[t].updateTransform()
}
,
s.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 t = this;
this._onChange = function(e) {
return t.visibilityChange(e)
}
,
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() {
s.Stage.prototype.visibilityChange.call(t, {
type: "pause"
})
}),
CocoonJS.App.onActivated.addEventListener(function() {
s.Stage.prototype.visibilityChange.call(t, {
type: "resume"
})
}))
}
,
s.Stage.prototype.visibilityChange = function(t) {
if ("pagehide" === t.type || "blur" === t.type || "pageshow" === t.type
|| "focus" === t.type)
return void ("pagehide" === t.type || "blur" === t.type ?
this.game.focusLoss(t) : "pageshow" !== t.type && "focus" !== t.type ||
this.game.focusGain(t));
this.disableVisibilityChange || (document.hidden || document.mozHidden
|| document.msHidden || document.webkitHidden || "pause" === t.type ?
this.game.gamePaused(t) : this.game.gameResumed(t))
}
,
s.Stage.prototype.setBackgroundColor = function(t) {
this.game.transparent || (s.Color.valueToColor(t, this._bgColor),
s.Color.updateColor(this._bgColor),
this._bgColor.r /= 255,
this._bgColor.g /= 255,
this._bgColor.b /= 255,
this._bgColor.a = 1)
}
,
s.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(s.Stage.prototype, "backgroundColor", {
get: function() {
return this._bgColor.color
},
set: function(t) {
this.setBackgroundColor(t)
}
}),
Object.defineProperty(s.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
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Group = function(t, e, i, n, o, r) {
void 0 === n && (n = !1),
void 0 === o && (o = !1),
void 0 === r && (r = s.Physics.ARCADE),
this.game = t,
void 0 === e && (e = t.world),
this.name = i || "group",
this.z = 0,
PIXI.DisplayObjectContainer.call(this),
n ? (this.game.stage.addChild(this),
this.z = this.game.stage.children.length) : e && (e.addChild(this),
this.z = e.children.length),
this.type = s.GROUP,
this.physicsType = s.GROUP,
this.alive = !0,
this.exists = !0,
this.ignoreDestroy = !1,
this.pendingDestroy = !1,
this.classType = s.Sprite,
this.cursor = null,
this.inputEnableChildren = !1,
this.onChildInputDown = new s.Signal,
this.onChildInputUp = new s.Signal,
this.onChildInputOver = new s.Signal,
this.onChildInputOut = new s.Signal,
this.enableBody = o,
this.enableBodyDebug = !1,
this.physicsBodyType = r,
this.physicsSortDirection = null,
this.onDestroy = new s.Signal,
this.cursorIndex = 0,
this.fixedToCamera = !1,
this.cameraOffset = new s.Point,
this.hash = [],
this._sortProperty = "z"
}
,
s.Group.prototype = Object.create(PIXI.DisplayObjectContainer.prototype),
s.Group.prototype.constructor = s.Group,
s.Group.RETURN_NONE = 0,
s.Group.RETURN_TOTAL = 1,
s.Group.RETURN_CHILD = 2,
s.Group.RETURN_ALL = 3,
s.Group.SORT_ASCENDING = -1,
s.Group.SORT_DESCENDING = 1,
s.Group.prototype.add = function(t, e, i) {
return void 0 === e && (e = !1),
t.parent === this ? t : (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)
}
,
s.Group.prototype.addAt = function(t, e, i) {
return this.add(t, i, e)
}
,
s.Group.prototype.addToHash = function(t) {
if (t.parent === this) {
if (-1 === this.hash.indexOf(t))
return this.hash.push(t),
!0
}
return !1
}
,
s.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
}
,
s.Group.prototype.addMultiple = function(t, e) {
if (t instanceof s.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
}
,
s.Group.prototype.getAt = function(t) {
return t < 0 || t >= this.children.length ? -1 : this.getChildAt(t)
}
,
s.Group.prototype.create = function(t, e, i, n, s, o) {
void 0 === s && (s = !0);
var r = new this.classType(this.game,t,e,i,n);
return r.exists = s,
r.visible = s,
r.alive = s,
this.add(r, !1, o)
}
,
s.Group.prototype.createMultiple = function(t, e, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = !1),
Array.isArray(e) || (e = [e]),
Array.isArray(i) || (i = [i]);
var s = this
, o = [];
return e.forEach(function(e) {
i.forEach(function(i) {
for (var r = 0; r < t; r++)
o.push(s.create(0, 0, e, i, n))
})
}),
o
}
,
s.Group.prototype.updateZ = function() {
for (var t = this.children.length; t--; )
this.children[t].z = t
}
,
s.Group.prototype.align = function(t, e, i, n, o, r) {
if (void 0 === o && (o = s.TOP_LEFT),
void 0 === r && (r = 0),
0 === this.children.length || r > this.children.length || -1 === t &&
-1 === e)
return !1;
for (var a = new s.Rectangle(0,0,i,n), h = t * i, l = e * n, c = r; c <
this.children.length; c++) {
var u = this.children[c];
if (u.alignIn)
if (u.alignIn(a, o),
-1 === t)
a.y += n,
a.y === l && (a.x += i,
a.y = 0);
else if (-1 === e)
a.x += i,
a.x === h && (a.x = 0,
a.y += n);
else if (a.x += i,
a.x === h && (a.x = 0,
a.y += n,
a.y === l))
return !0
}
return !0
}
;
s.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
}
,
s.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
}
,
s.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
}
,
s.Group.prototype.swap = function(t, e) {
this.swapChildren(t, e),
this.updateZ()
}
,
s.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
}
,
s.Group.prototype.sendToBack = function(t) {
return t.parent === this && this.getIndex(t) > 0 && (this.remove(t, !1,
!0),
this.addAt(t, 0, !0)),
t
}
,
s.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
}
,
s.Group.prototype.moveDown = function(t) {
if (t.parent === this && this.getIndex(t) > 0) {
var e = this.getIndex(t)
, i = this.getAt(e - 1);
i && this.swap(t, i)
}
return t
}
,
s.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
}
,
s.Group.prototype.reverse = function() {
this.children.reverse(),
this.updateZ()
}
,
s.Group.prototype.getIndex = function(t) {
return this.children.indexOf(t)
}
,
s.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
}
,
s.Group.prototype.replace = function(t, e) {
var i = this.getIndex(t);
if (-1 !== i)
return e.parent && (e.parent instanceof s.Group ?
e.parent.remove(e) : e.parent.removeChild(e)),
this.remove(t),
this.addAt(e, i),
t
}
,
s.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]]))
}
,
s.Group.prototype.setProperty = function(t, e, i, n, s) {
if (void 0 === s && (s = !1),
n = n || 0,
!this.hasProperty(t, e) && (!s || n > 0))
return !1;
var o = e.length;
return 1 === o ? 0 === n ? t[e[0]] = i : 1 === n ? t[e[0]] += i : 2 ===
n ? t[e[0]] -= i : 3 === n ? t[e[0]] *= i : 4 === n && (t[e[0]] /= i) : 2 === o ? 0
=== n ? t[e[0]][e[1]] = i : 1 === n ? t[e[0]][e[1]] += i : 2 === n ? t[e[0]][e[1]]
-= i : 3 === n ? t[e[0]][e[1]] *= i : 4 === n && (t[e[0]][e[1]] /= i) : 3 === o ? 0
=== n ? t[e[0]][e[1]][e[2]] = i : 1 === n ? t[e[0]][e[1]][e[2]] += i : 2 === n ?
t[e[0]][e[1]][e[2]] -= i : 3 === n ? t[e[0]][e[1]][e[2]] *= i : 4 === n && (t[e[0]]
[e[1]][e[2]] /= i) : 4 === o && (0 === n ? t[e[0]][e[1]][e[2]][e[3]] = i : 1 ===
n ? t[e[0]][e[1]][e[2]][e[3]] += i : 2 === n ? t[e[0]][e[1]][e[2]][e[3]] -= i : 3
=== n ? t[e[0]][e[1]][e[2]][e[3]] *= i : 4 === n && (t[e[0]][e[1]][e[2]][e[3]] /=
i)),
!0
}
,
s.Group.prototype.checkProperty = function(t, e, i, n) {
return void 0 === n && (n = !1),
!(!s.Utils.getProperty(t, e) && n) && s.Utils.getProperty(t, e) === i
}
,
s.Group.prototype.set = function(t, e, i, n, s, o, r) {
if (void 0 === r && (r = !1),
e = e.split("."),
void 0 === n && (n = !1),
void 0 === s && (s = !1),
(!1 === n || n && t.alive) && (!1 === s || s && t.visible))
return this.setProperty(t, e, i, o, r)
}
,
s.Group.prototype.setAll = function(t, e, i, n, s, o) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === o && (o = !1),
t = t.split("."),
s = s || 0;
for (var r = 0; r < this.children.length; r++)
(!i || i && this.children[r].alive) && (!n || n &&
this.children[r].visible) && this.setProperty(this.children[r], t, e, s, o)
}
,
s.Group.prototype.setAllChildren = function(t, e, i, n, o, r) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === r && (r = !1),
o = o || 0;
for (var a = 0; a < this.children.length; a++)
(!i || i && this.children[a].alive) && (!n || n &&
this.children[a].visible) && (this.children[a]instanceof s.Group ?
this.children[a].setAllChildren(t, e, i, n, o, r) :
this.setProperty(this.children[a], t.split("."), e, o, r))
}
,
s.Group.prototype.checkAll = function(t, e, i, n, s) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
void 0 === s && (s = !1);
for (var o = 0; o < this.children.length; o++)
if ((!i || i && this.children[o].alive) && (!n || n &&
this.children[o].visible) && !this.checkProperty(this.children[o], t, e, s))
return !1;
return !0
}
,
s.Group.prototype.addAll = function(t, e, i, n) {
this.setAll(t, e, i, n, 1)
}
,
s.Group.prototype.subAll = function(t, e, i, n) {
this.setAll(t, e, i, n, 2)
}
,
s.Group.prototype.multiplyAll = function(t, e, i, n) {
this.setAll(t, e, i, n, 3)
}
,
s.Group.prototype.divideAll = function(t, e, i, n) {
this.setAll(t, e, i, n, 4)
}
,
s.Group.prototype.callAllExists = function(t, e) {
var i;
if (arguments.length > 2) {
i = [];
for (var n = 2; n < arguments.length; n++)
i.push(arguments[n])
}
for (var n = 0; n < this.children.length; n++)
this.children[n].exists === e && this.children[n][t] &&
this.children[n][t].apply(this.children[n], i)
}
,
s.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
}
,
s.Group.prototype.callAll = function(t, e) {
if (void 0 !== t) {
t = t.split(".");
var i = t.length;
if (void 0 === e || null === e || "" === e)
e = null;
else if ("string" == typeof e) {
e = e.split(".");
var n = e.length
}
var s;
if (arguments.length > 2) {
s = [];
for (var o = 2; o < arguments.length; o++)
s.push(arguments[o])
}
for (var r = null, a = null, o = 0; o < this.children.length; o++)
r = this.callbackFromArray(this.children[o], t, i),
e && r ? (a = this.callbackFromArray(this.children[o], e, n),
r && r.apply(a, s)) : r && r.apply(this.children[o], s)
}
}
,
s.Group.prototype.preUpdate = function() {
if (this.pendingDestroy)
return this.destroy(),
!1;
if (!this.exists || !this.parent.exists)
return this.renderOrderID = -1,
!1;
for (var t = 0; t < this.children.length; t++)
this.children[t].preUpdate();
return !0
}
,
s.Group.prototype.update = function() {
for (var t = this.children.length; t--; )
this.children[t].update()
}
,
s.Group.prototype.postUpdate = function() {
this.fixedToCamera && (this.x = (this.game.camera.view.x +
this.cameraOffset.x) / this.game.camera.scale.x,
this.y = (this.game.camera.view.y + this.cameraOffset.y) /
this.game.camera.scale.y);
for (var t = 0; t < this.children.length; t++)
this.children[t].postUpdate()
}
,
s.Group.prototype.filter = function(t, e) {
for (var i = -1, n = this.children.length, o = []; ++i < n; ) {
var r = this.children[i];
(!e || e && r.exists) && t(r, i, this.children) && o.push(r)
}
return new s.ArraySet(o)
}
,
s.Group.prototype.forEach = function(t, e, i) {
if (void 0 === i && (i = !1),
arguments.length <= 3)
for (var n = 0; n < this.children.length; n++)
(!i || i && this.children[n].exists) && t.call(e,
this.children[n]);
else {
for (var s = [null], n = 3; n < arguments.length; n++)
s.push(arguments[n]);
for (var n = 0; n < this.children.length; n++)
(!i || i && this.children[n].exists) && (s[0] =
this.children[n],
t.apply(e, s))
}
}
,
s.Group.prototype.forEachExists = function(t, e) {
var i;
if (arguments.length > 2) {
i = [null];
for (var n = 2; n < arguments.length; n++)
i.push(arguments[n])
}
this.iterate("exists", !0, s.Group.RETURN_TOTAL, t, e, i)
}
,
s.Group.prototype.forEachAlive = function(t, e) {
var i;
if (arguments.length > 2) {
i = [null];
for (var n = 2; n < arguments.length; n++)
i.push(arguments[n])
}
this.iterate("alive", !0, s.Group.RETURN_TOTAL, t, e, i)
}
,
s.Group.prototype.forEachDead = function(t, e) {
var i;
if (arguments.length > 2) {
i = [null];
for (var n = 2; n < arguments.length; n++)
i.push(arguments[n])
}
this.iterate("alive", !1, s.Group.RETURN_TOTAL, t, e, i)
}
,
s.Group.prototype.sort = function(t, e) {
this.children.length < 2 || (void 0 === t && (t = "z"),
void 0 === e && (e = s.Group.SORT_ASCENDING),
this._sortProperty = t,
e === s.Group.SORT_ASCENDING ?
this.children.sort(this.ascendingSortHandler.bind(this)) :
this.children.sort(this.descendingSortHandler.bind(this)),
this.updateZ())
}
,
s.Group.prototype.customSort = function(t, e) {
this.children.length < 2 || (this.children.sort(t.bind(e)),
this.updateZ())
}
,
s.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
}
,
s.Group.prototype.descendingSortHandler = function(t, e) {
return t[this._sortProperty] < e[this._sortProperty] ? 1 :
t[this._sortProperty] > e[this._sortProperty] ? -1 : 0
}
,
s.Group.prototype.iterate = function(t, e, i, n, o, r) {
if (0 === this.children.length) {
if (i === s.Group.RETURN_TOTAL)
return 0;
if (i === s.Group.RETURN_ALL)
return []
}
var a = 0;
if (i === s.Group.RETURN_ALL)
var h = [];
for (var l = 0; l < this.children.length; l++)
if (this.children[l][t] === e) {
if (a++,
n && (r ? (r[0] = this.children[l],
n.apply(o, r)) : n.call(o, this.children[l])),
i === s.Group.RETURN_CHILD)
return this.children[l];
i === s.Group.RETURN_ALL && h.push(this.children[l])
}
return i === s.Group.RETURN_TOTAL ? a : i === s.Group.RETURN_ALL ? h :
null
}
,
s.Group.prototype.getFirstExists = function(t, e, i, n, o, r) {
void 0 === e && (e = !1),
"boolean" != typeof t && (t = !0);
var a = this.iterate("exists", t, s.Group.RETURN_CHILD);
return null === a && e ? this.create(i, n, o, r) : this.resetChild(a,
i, n, o, r)
}
,
s.Group.prototype.getFirstAlive = function(t, e, i, n, o) {
void 0 === t && (t = !1);
var r = this.iterate("alive", !0, s.Group.RETURN_CHILD);
return null === r && t ? this.create(e, i, n, o) : this.resetChild(r,
e, i, n, o)
}
,
s.Group.prototype.getFirstDead = function(t, e, i, n, o) {
void 0 === t && (t = !1);
var r = this.iterate("alive", !1, s.Group.RETURN_CHILD);
return null === r && t ? this.create(e, i, n, o) : this.resetChild(r,
e, i, n, o)
}
,
s.Group.prototype.resetChild = function(t, e, i, n, s) {
return null === t ? null : (void 0 === e && (e = null),
void 0 === i && (i = null),
null !== e && null !== i && t.reset(e, i),
void 0 !== n && t.loadTexture(n, s),
t)
}
,
s.Group.prototype.getTop = function() {
if (this.children.length > 0)
return this.children[this.children.length - 1]
}
,
s.Group.prototype.getBottom = function() {
if (this.children.length > 0)
return this.children[0]
}
,
s.Group.prototype.getClosestTo = function(t, e, i) {
for (var n = Number.MAX_VALUE, o = 0, r = null, a = 0; a <
this.children.length; a++) {
var h = this.children[a];
h.exists && (o = Math.abs(s.Point.distance(t, h))) < n && (!e ||
e.call(i, h, o)) && (n = o,
r = h)
}
return r
}
,
s.Group.prototype.getFurthestFrom = function(t, e, i) {
for (var n = 0, o = 0, r = null, a = 0; a < this.children.length; a++)
{
var h = this.children[a];
h.exists && (o = Math.abs(s.Point.distance(t, h))) > n && (!e ||
e.call(i, h, o)) && (n = o,
r = h)
}
return r
}
,
s.Group.prototype.countLiving = function() {
return this.iterate("alive", !0, s.Group.RETURN_TOTAL)
}
,
s.Group.prototype.countDead = function() {
return this.iterate("alive", !1, s.Group.RETURN_TOTAL)
}
,
s.Group.prototype.getRandom = function(t, e) {
return void 0 === t && (t = 0),
void 0 === e && (e = this.children.length),
0 === e ? null : s.ArrayUtils.getRandomItem(this.children, t, e)
}
,
s.Group.prototype.getRandomExists = function(t, e) {
var i = this.getAll("exists", !0, t, e);
return this.game.rnd.pick(i)
}
,
s.Group.prototype.getAll = function(t, e, i, n) {
void 0 === i && (i = 0),
void 0 === n && (n = this.children.length);
for (var s = [], o = i; o < n; o++) {
var r = this.children[o];
t && r[t] === e && s.push(r)
}
return s
}
,
s.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 n = this.removeChild(t);
return this.removeFromHash(t),
this.updateZ(),
this.cursor === t && this.next(),
e && n && n.destroy(!0),
!0
}
,
s.Group.prototype.moveAll = function(t, e) {
if (void 0 === e && (e = !1),
this.children.length > 0 && t instanceof s.Group) {
do {
t.add(this.children[0], e)
} while (this.children.length > 0);this.hash = [],
this.cursor = null
}
return t
}
,
s.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 n = this.removeChild(this.children[0]);
this.removeFromHash(n),
t && n && n.destroy(!0, i)
} while (this.children.length > 0);this.hash = [],
this.cursor = null
}
}
,
s.Group.prototype.removeBetween = function(t, e, i, n) {
if (void 0 === e && (e = this.children.length - 1),
void 0 === i && (i = !1),
void 0 === n && (n = !1),
0 !== this.children.length) {
if (t > e || t < 0 || e > this.children.length)
return !1;
for (var s = e; s >= t; ) {
!n && this.children[s].events &&
this.children[s].events.onRemovedFromGroup$dispatch(this.children[s], this);
var o = this.removeChild(this.children[s]);
this.removeFromHash(o),
i && o && o.destroy(!0),
this.cursor === this.children[s] && (this.cursor = null),
s--
}
this.updateZ()
}
}
,
s.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(s.Group.prototype, "total", {
get: function() {
return this.iterate("exists", !0, s.Group.RETURN_TOTAL)
}
}),
Object.defineProperty(s.Group.prototype, "length", {
get: function() {
return this.children.length
}
}),
Object.defineProperty(s.Group.prototype, "angle", {
get: function() {
return s.Math.radToDeg(this.rotation)
},
set: function(t) {
this.rotation = s.Math.degToRad(t)
}
}),
Object.defineProperty(s.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(s.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(s.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(s.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(s.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(s.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
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.World = function(t) {
s.Group.call(this, t, null, "__world", !1),
this.bounds = new s.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)
}
,
s.World.prototype = Object.create(s.Group.prototype),
s.World.prototype.constructor = s.World,
s.World.prototype.boot = function() {
this.camera = new
s.Camera(this.game,0,0,0,this.game.width,this.game.height),
this.game.stage.addChild(this),
this.camera.boot()
}
,
s.World.prototype.stateChange = function() {
this.x = 0,
this.y = 0,
this.camera.reset()
}
,
s.World.prototype.setBounds = function(t, e, i, n) {
this._definedSize = !0,
this._width = i,
this._height = n,
this.bounds.setTo(t, e, i, n),
this.x = t,
this.y = e,
this.camera.bounds && this.camera.bounds.setTo(t, e, Math.max(i,
this.game.width), Math.max(n, this.game.height)),
this.game.physics.setBoundsToWorld()
}
,
s.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()
}
,
s.World.prototype.shutdown = function() {
this.destroy(!0, !0)
}
,
s.World.prototype.wrap = function(t, e, i, n, s) {
void 0 === e && (e = 0),
void 0 === i && (i = !1),
void 0 === n && (n = !0),
void 0 === s && (s = !0),
i ? (t.getBounds(),
n && (t.x + t._currentBounds.width < this.bounds.x ? t.x =
this.bounds.right : t.x > this.bounds.right && (t.x = this.bounds.left)),
s && (t.y + t._currentBounds.height < this.bounds.top ? t.y =
this.bounds.bottom : t.y > this.bounds.bottom && (t.y = this.bounds.top))) : (n &&
t.x + e < this.bounds.x ? t.x = this.bounds.right + e : n && t.x - e >
this.bounds.right && (t.x = this.bounds.left - e),
s && t.y + e < this.bounds.top ? t.y = this.bounds.bottom + e : s &&
t.y - e > this.bounds.bottom && (t.y = this.bounds.top - e))
}
,
Object.defineProperty(s.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(s.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(s.World.prototype, "centerX", {
get: function() {
return this.bounds.halfWidth + this.bounds.x
}
}),
Object.defineProperty(s.World.prototype, "centerY", {
get: function() {
return this.bounds.halfHeight + this.bounds.y
}
}),
Object.defineProperty(s.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(s.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)
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Game = function(t, e, i, n, o, r, a, h) {
return this.id = s.GAMES.push(this) - 1,
this.config = null,
this.physicsConfig = h,
this.parent = "",
this.width = 800,
this.height = 600,
this.resolution = 1,
this._width = 800,
this._height = 600,
this.transparent = !1,
this.antialias = !0,
this.multiTexture = !1,
this.preserveDrawingBuffer = !1,
this.clearBeforeRender = !0,
this.renderer = null,
this.renderType = s.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 = s.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 s.Signal,
this.forceSingleUpdate = !0,
this._nextFpsNotification = 0,
1 === arguments.length && "object" == typeof arguments[0] ?
this.parseConfig(arguments[0]) : (this.config = {
enableDebug: !0
},
void 0 !== t && (this._width = t),
void 0 !== e && (this._height = e),
void 0 !== i && (this.renderType = i),
void 0 !== n && (this.parent = n),
void 0 !== r && (this.transparent = r),
void 0 !== a && (this.antialias = a),
this.rnd = new s.RandomDataGenerator([(Date.now() *
Math.random()).toString()]),
this.state = new s.StateManager(this,o)),
this.device.whenReady(this.boot, this),
this
}
,
s.Game.prototype = {
parseConfig: function(t) {
this.config = t,
void 0 === 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),
void 0 !== t.multiTexture && (this.multiTexture = t.multiTexture),
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 s.RandomDataGenerator(e);
var i = null;
t.state && (i = t.state),
this.state = new s.StateManager(this,i)
},
boot: function() {
this.isBooted || (this.onPause = new s.Signal,
this.onResume = new s.Signal,
this.onBlur = new s.Signal,
this.onFocus = new s.Signal,
this.isBooted = !0,
PIXI.game = this,
this.math = s.Math,
this.scale = new s.ScaleManager(this,this._width,this._height),
this.stage = new s.Stage(this),
this.setUpRenderer(),
this.world = new s.World(this),
this.add = new s.GameObjectFactory(this),
this.make = new s.GameObjectCreator(this),
this.cache = new s.Cache(this),
this.load = new s.Loader(this),
this.time = new s.Time(this),
this.tweens = new s.TweenManager(this),
this.input = new s.Input(this),
this.sound = new s.SoundManager(this),
this.physics = new s.Physics(this,this.physicsConfig),
this.particles = new s.Particles(this),
this.create = new s.Create(this),
this.plugins = new s.PluginManager(this),
this.net = new s.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 s.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
s.RequestAnimationFrame(this,this.config.forceSetTimeOut) : this.raf = new
s.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 = s.VERSION
, e = "Canvas"
, i = "HTML Audio"
, n = 1;
if (this.renderType === s.WEBGL ? (e = "WebGL",
n++) : this.renderType === s.HEADLESS && (e = "Headless"),
this.device.webAudio && (i = "WebAudio",
n++),
this.device.chrome) {
for (var o = ["%c %c %c Phaser CE v" + t + " | Pixi.js | "
+ e + " | " + i + " %c %c %c http://phaser.io %c?%c?%c?", "background: #fb8cb3",
"background: #d44a52", "color: #ffffff; background: #871905;", "background:
#d44a52", "background: #fb8cb3", "background: #ffffff"], r = 0; r < 3; r++)
r < n ? o.push("color: #ff2424; background: #fff") :
o.push("color: #959595; background: #fff");
console.log.apply(console, o)
} else
window.console && console.log("Phaser v" + t + " | Pixi.js
| " + e + " | " + i + " | http://phaser.io")
}
},
setUpRenderer: function() {
if (this.config.canvas ? this.canvas = this.config.canvas :
this.canvas = s.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 === s.HEADLESS || this.renderType === s.CANVAS ||
this.renderType === s.AUTO && !this.device.webGL) {
if (!this.device.canvas)
throw new Error("Phaser.Game - Cannot create Canvas or
WebGL context, aborting.");
this.renderType = s.CANVAS,
this.renderer = new PIXI.CanvasRenderer(this),
this.context = this.renderer.context
} else
(this.multiTexture || this.renderType === s.WEBGL_MULTI) &&
PIXI.enableMultiTexture(),
this.renderType = s.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
=== s.CANVAS),
this.renderType !== s.HEADLESS && (this.stage.smoothed =
this.antialias,
s.Canvas.addToDOM(this.canvas, this.parent, !1),
s.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 (this._spiraling > 1 && !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 !== s.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),
s.Canvas.removeFromDOM(this.canvas),
PIXI.defaultRenderer = null,
s.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)
}
},
s.Game.prototype.constructor = s.Game,
Object.defineProperty(s.Game.prototype, "paused", {
get: function() {
return this._paused
},
set: function(t) {
!0 === t ? (!1 === this._paused && (this._paused = !0,
this.sound.setMute(),
this.time.gamePaused(),
this.onPause.dispatch(this)),
this._codePaused = !0) : (this._paused && (this._paused = !1,
this.input.reset(),
this.sound.unsetMute(),
this.time.gameResumed(),
this.onResume.dispatch(this)),
this._codePaused = !1)
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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 = s.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 s.ArraySet,
this._localPoint = new s.Point,
this._pollCounter = 0,
this._oldPosition = null,
this._x = 0,
this._y = 0
}
,
s.Input.MOUSE_OVERRIDES_TOUCH = 0,
s.Input.TOUCH_OVERRIDES_MOUSE = 1,
s.Input.MOUSE_TOUCH_COMBINE = 2,
s.Input.MAX_POINTERS = 10,
s.Input.prototype = {
boot: function() {
this.mousePointer = new
s.Pointer(this.game,0,s.PointerMode.CURSOR),
this.addPointer(),
this.addPointer(),
this.mouse = new s.Mouse(this.game),
this.touch = new s.Touch(this.game),
this.mspointer = new s.MSPointer(this.game),
s.Keyboard && (this.keyboard = new s.Keyboard(this.game)),
s.Gamepad && (this.gamepad = new s.Gamepad(this.game)),
this.onDown = new s.Signal,
this.onUp = new s.Signal,
this.onTap = new s.Signal,
this.onHold = new s.Signal,
this.scale = new s.Point(1,1),
this.speed = new s.Point,
this.position = new s.Point,
this._oldPosition = new s.Point,
this.circle = new s.Circle(0,0,44),
this.activePointer = this.mousePointer,
this.hitCanvas = s.CanvasPool.create(this, 1, 1),
this.hitContext = this.hitCanvas.getContext("2d"),
this.mouse.start(),
this.touch.start(),
this.mspointer.start(),
this.mousePointer.active = !0,
this.keyboard && this.keyboard.start();
var t = this;
this._onClickTrampoline = function(e) {
t.onClickTrampoline(e)
}
,
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 = [],
s.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 >= s.Input.MAX_POINTERS)
return console.warn("Phaser.Input.addPointer: Maximum limit of
" + s.Input.MAX_POINTERS + " pointers reached."),
null;
var t = this.pointers.length + 1
, e = new s.Pointer(this.game,t,s.PointerMode.TOUCH);
return this.pointers.push(e),
this["pointer" + t] = e,
e
},
update: function() {
if (this.keyboard && this.keyboard.update(),
this.pollRate > 0 && this._pollCounter < this.pollRate)
return void this._pollCounter++;
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 s.Signal,
this.onUp = new s.Signal,
this.onTap = new s.Signal,
this.onHold = new s.Signal,
this.moveCallbacks = []),
this._pollCounter = 0
}
},
resetSpeed: function(t, e) {
this._oldPosition.setTo(t, e),
this.speed.setTo(0, 0)
},
startPointer: function(t) {
if (this.maxPointers >= 0 &&
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 && e > 0; 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 s.Point);
var n = t.worldTransform
, o = 1 / (n.a * n.d + n.c * -n.b);
return i.setTo(n.d * o * e.x + -n.c * o * e.y + (n.ty * n.c - n.tx
* n.d) * o, n.a * o * e.y + -n.b * o * e.x + (-n.ty * n.a + n.tx * n.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 s.TileSprite) {
var n = t.width
, o = t.height
, r = -n * t.anchor.x;
if (this._localPoint.x >= r && this._localPoint.x < r + n) {
var a = -o * t.anchor.y;
if (this._localPoint.y >= a && this._localPoint.y < a + o)
return !0
}
} else if (t instanceof PIXI.Sprite) {
var n = t.texture.frame.width
, o = t.texture.frame.height
, r = -n * t.anchor.x;
if (this._localPoint.x >= r && this._localPoint.x < r + n) {
var a = -o * t.anchor.y;
if (this._localPoint.y >= a && this._localPoint.y < a + o)
return !0
}
} else if (t instanceof s.Graphics)
for (var h = 0; h < t.graphicsData.length; h++) {
var l = t.graphicsData[h];
if (l.fill && (l.shape &&
l.shape.contains(this._localPoint.x, this._localPoint.y)))
return !0
}
for (var h = 0; h < t.children.length; h++)
if (this.hitTest(t.children[h], e, i))
return !0;
return !1
},
onClickTrampoline: function() {
this.activePointer.processClickTrampolines()
}
},
s.Input.prototype.constructor = s.Input,
Object.defineProperty(s.Input.prototype, "x", {
get: function() {
return this._x
},
set: function(t) {
this._x = Math.floor(t)
}
}),
Object.defineProperty(s.Input.prototype, "y", {
get: function() {
return this._y
},
set: function(t) {
this._y = Math.floor(t)
}
}),
Object.defineProperty(s.Input.prototype, "pollLocked", {
get: function() {
return this.pollRate > 0 && this._pollCounter < this.pollRate
}
}),
Object.defineProperty(s.Input.prototype, "totalInactivePointers", {
get: function() {
return this.pointers.length - this.countActivePointers()
}
}),
Object.defineProperty(s.Input.prototype, "totalActivePointers", {
get: function() {
return this.countActivePointers()
}
}),
Object.defineProperty(s.Input.prototype, "worldX", {
get: function() {
return this.game.camera.view.x + this.x
}
}),
Object.defineProperty(s.Input.prototype, "worldY", {
get: function() {
return this.game.camera.view.y + this.y
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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 s.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
}
,
s.Mouse.NO_BUTTON = -1,
s.Mouse.LEFT_BUTTON = 0,
s.Mouse.MIDDLE_BUTTON = 1,
s.Mouse.RIGHT_BUTTON = 2,
s.Mouse.BACK_BUTTON = 3,
s.Mouse.FORWARD_BUTTON = 4,
s.Mouse.WHEEL_UP = 1,
s.Mouse.WHEEL_DOWN = -1,
s.Mouse.prototype = {
start: function() {
if ((!this.game.device.android || !1 !== this.game.device.chrome)
&& null === this._onMouseDown) {
var t = this;
this._onMouseDown = function(e) {
return t.onMouseDown(e)
}
,
this._onMouseMove = function(e) {
return t.onMouseMove(e)
}
,
this._onMouseUp = function(e) {
return t.onMouseUp(e)
}
,
this._onMouseUpGlobal = function(e) {
return t.onMouseUpGlobal(e)
}
,
this._onMouseOutGlobal = function(e) {
return t.onMouseOutGlobal(e)
}
,
this._onMouseOut = function(e) {
return t.onMouseOut(e)
}
,
this._onMouseOver = function(e) {
return t.onMouseOver(e)
}
,
this._onMouseWheel = function(e) {
return t.onMouseWheel(e)
}
;
var e = this.game.canvas;
e.addEventListener("mousedown", this._onMouseDown, !0),
e.addEventListener("mousemove", this._onMouseMove, !0),
e.addEventListener("mouseup", this._onMouseUp, !0),
this.game.device.cocoonJS ||
(window.addEventListener("mouseup", this._onMouseUpGlobal, !0),
window.addEventListener("mouseout", this._onMouseOutGlobal, !
0),
e.addEventListener("mouseover", this._onMouseOver, !0),
e.addEventListener("mouseout", this._onMouseOut, !0));
var n = this.game.device.wheelEvent;
n && (e.addEventListener(n, this._onMouseWheel, !0),
"mousewheel" === n ? this._wheelEvent = new i(-.025,1) :
"DOMMouseScroll" === n && (this._wheelEvent = new i(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 = s.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)
}
},
s.Mouse.prototype.constructor = s.Mouse,
i.prototype = {},
i.prototype.constructor = i,
i.prototype.bindEvent = function(t) {
if (!i._stubsGenerated && t) {
var e = function(t) {
return function() {
var e = this.originalEvent[t];
return "function" != typeof e ? e :
e.bind(this.originalEvent)
}
};
for (var n in t)
n in i.prototype || Object.defineProperty(i.prototype, n, {
get: e(n)
});
i._stubsGenerated = !0
}
return this.originalEvent = t,
this
}
,
Object.defineProperties(i.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
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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
}
,
s.MSPointer.prototype = {
start: function() {
if (null === this._onMSPointerDown) {
var t = this;
if (this.game.device.mspointer) {
this._onMSPointerDown = function(e) {
return t.onPointerDown(e)
}
,
this._onMSPointerMove = function(e) {
return t.onPointerMove(e)
}
,
this._onMSPointerUp = function(e) {
return t.onPointerUp(e)
}
,
this._onMSPointerUpGlobal = function(e) {
return t.onPointerUpGlobal(e)
}
,
this._onMSPointerOut = function(e) {
return t.onPointerOut(e)
}
,
this._onMSPointerOver = function(e) {
return t.onPointerOver(e)
}
;
var e = this.game.canvas;
e.addEventListener("MSPointerDown",
this._onMSPointerDown, !1),
e.addEventListener("MSPointerMove",
this._onMSPointerMove, !1),
e.addEventListener("MSPointerUp", this._onMSPointerUp, !1),
e.addEventListener("pointerdown", this._onMSPointerDown, !
1),
e.addEventListener("pointermove", this._onMSPointerMove, !
1),
e.addEventListener("pointerup", this._onMSPointerUp, !1),
e.style["-ms-content-zooming"] = "none",
e.style["-ms-touch-action"] = "none",
this.game.device.cocoonJS ||
(window.addEventListener("MSPointerUp", this._onMSPointerUpGlobal, !0),
e.addEventListener("MSPointerOver",
this._onMSPointerOver, !0),
e.addEventListener("MSPointerOut", this._onMSPointerOut, !
0),
window.addEventListener("pointerup",
this._onMSPointerUpGlobal, !0),
e.addEventListener("pointerover", this._onMSPointerOver, !
0),
e.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)
}
},
s.MSPointer.prototype.constructor = s.MSPointer,
/**
* @author Richard Davey <rich@photonstorm.com>
* @author @karlmacklin <tacklemcclean@gmail.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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 s.Signal,
this.onUp = new s.Signal,
this.onFloat = new s.Signal
}
,
s.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.isDown = !1,
this.isUp = !1,
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
}
},
s.DeviceButton.prototype.constructor = s.DeviceButton,
Object.defineProperty(s.DeviceButton.prototype, "duration", {
get: function() {
return this.isUp ? -1 : this.game.time.time - this.timeDown
}
}),
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Pointer = function(t, e, i) {
this.game = t,
this.id = e,
this.type = s.POINTER,
this.exists = !0,
this.identifier = 0,
this.pointerId = null,
this.pointerMode = i || s.PointerMode.CURSOR | s.PointerMode.CONTACT,
this.target = null,
this.button = null,
this.leftButton = new s.DeviceButton(this,s.Pointer.LEFT_BUTTON),
this.middleButton = new s.DeviceButton(this,s.Pointer.MIDDLE_BUTTON),
this.rightButton = new s.DeviceButton(this,s.Pointer.RIGHT_BUTTON),
this.backButton = new s.DeviceButton(this,s.Pointer.BACK_BUTTON),
this.forwardButton = new s.DeviceButton(this,s.Pointer.FORWARD_BUTTON),
this.eraserButton = new s.DeviceButton(this,s.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 s.Point,
this.positionDown = new s.Point,
this.positionUp = new s.Point,
this.circle = new s.Circle(0,0,44),
this._clickTrampolines = null,
this._trampolineTargetObject = null
}
,
s.Pointer.NO_BUTTON = 0,
s.Pointer.LEFT_BUTTON = 1,
s.Pointer.RIGHT_BUTTON = 2,
s.Pointer.MIDDLE_BUTTON = 4,
s.Pointer.BACK_BUTTON = 8,
s.Pointer.FORWARD_BUTTON = 16,
s.Pointer.ERASER_BUTTON = 32,
s.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) {
s.Pointer.LEFT_BUTTON & t && this.leftButton.start(e),
s.Pointer.RIGHT_BUTTON & t && this.rightButton.start(e),
s.Pointer.MIDDLE_BUTTON & t && this.middleButton.start(e),
s.Pointer.BACK_BUTTON & t && this.backButton.start(e),
s.Pointer.FORWARD_BUTTON & t && this.forwardButton.start(e),
s.Pointer.ERASER_BUTTON & t && this.eraserButton.start(e)
},
processButtonsUp: function(t, e) {
t === s.Mouse.LEFT_BUTTON && this.leftButton.stop(e),
t === s.Mouse.RIGHT_BUTTON && this.rightButton.stop(e),
t === s.Mouse.MIDDLE_BUTTON && this.middleButton.stop(e),
t === s.Mouse.BACK_BUTTON && this.backButton.stop(e),
t === s.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 === s.Input.MOUSE_OVERRIDES_TOUCH ||
e.multiInputOverride === s.Input.MOUSE_TOUCH_COMBINE || e.multiInputOverride ===
s.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 && (t.interactiveItems.total > 0 &&
this.processInteractiveObjects(!1),
this.dirty = !1),
!1 === this._holdSent && this.duration >= t.holdRate &&
((t.multiInputOverride === s.Input.MOUSE_OVERRIDES_TOUCH || t.multiInputOverride
=== s.Input.MOUSE_TOUCH_COMBINE || t.multiInputOverride ===
s.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) {
if (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 === s.Input.MOUSE_OVERRIDES_TOUCH ||
i.multiInputOverride === s.Input.MOUSE_TOUCH_COMBINE || i.multiInputOverride ===
s.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),
this.game.paused)
return this;
for (var n = i.moveCallbacks.length; n--; )

i.moveCallbacks[n].callback.call(i.moveCallbacks[n].context, this, this.x, this.y,


e);
return null !== this.targetObject && !0 ===
this.targetObject.isDragged ? !1 === this.targetObject.update(this) &&
(this.targetObject = null) : i.interactiveItems.total > 0 &&
this.processInteractiveObjects(e),
this
}
},
processInteractiveObjects: function(t) {
var e = 0
, i = -1
, n = null
, s = this.game.input.interactiveItems.first;
for (this.interactiveCandidates = []; s; )
s.checked = !1,
s.validForInput(i, e, !1) && (s.checked = !0,
(t && s.checkPointerDown(this, !0) || !t &&
s.checkPointerOver(this, !0)) && (e = s.sprite.renderOrderID,
i = s.priorityID,
n = s,
this.interactiveCandidates.push(s))),
s = this.game.input.interactiveItems.next;
for (s = this.game.input.interactiveItems.first; s; )
!s.checked && s.validForInput(i, e, !0) && (t &&
s.checkPointerDown(this, !1) || !t && s.checkPointerOver(this, !1)) && (e =
s.sprite.renderOrderID,
i = s.priorityID,
n = s,
this.interactiveCandidates.push(s)),
s = this.game.input.interactiveItems.next;
return this.game.input.customCandidateHandler && (n =
this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerC
ontext, this, this.interactiveCandidates, n)),
this.swapTarget(n, !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,
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;
return this._stateReset && this.withinGame ? void
t.preventDefault() : (this.timeUp = this.game.time.time,
(e.multiInputOverride === s.Input.MOUSE_OVERRIDES_TOUCH ||
e.multiInputOverride === s.Input.MOUSE_TOUCH_COMBINE || e.multiInputOverride ===
s.Input.TOUCH_OVERRIDES_MOUSE && 0 === e.totalActivePointers) &&
(e.onUp.dispatch(this, t),
this.duration >= 0 && 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),
this.id > 0 && (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)
},
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, n) {
if (this.isDown) {
for (var s = this._clickTrampolines = this._clickTrampolines ||
[], o = 0; o < s.length; o++)
if (s[o].name === t) {
s.splice(o, 1);
break
}
s.push({
name: t,
targetObject: this.targetObject,
callback: e,
callbackContext: i,
callbackArgs: n
})
}
},
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
}
},
s.Pointer.prototype.constructor = s.Pointer,
Object.defineProperty(s.Pointer.prototype, "duration", {
get: function() {
return this.isUp ? -1 : this.game.time.time - this.timeDown
}
}),
Object.defineProperty(s.Pointer.prototype, "worldX", {
get: function() {
return this.game.world.camera.x + this.x
}
}),
Object.defineProperty(s.Pointer.prototype, "worldY", {
get: function() {
return this.game.world.camera.y + this.y
}
}),
s.PointerMode = {
CURSOR: 1,
CONTACT: 2
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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
}
,
s.Touch.prototype = {
start: function() {
if (null === this._onTouchStart) {
var t = this;
this.game.device.touch && (this._onTouchStart = function(e) {
return t.onTouchStart(e)
}
,
this._onTouchMove = function(e) {
return t.onTouchMove(e)
}
,
this._onTouchEnd = function(e) {
return t.onTouchEnd(e)
}
,
this._onTouchEnter = function(e) {
return t.onTouchEnter(e)
}
,
this._onTouchLeave = function(e) {
return t.onTouchLeave(e)
}
,
this._onTouchCancel = function(e) {
return t.onTouchCancel(e)
}
,
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 (var 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 (var 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))
}
},
s.Touch.prototype.constructor = s.Touch,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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 s.Point,
this.dragFromCenter = !1,
this.dragStopBlocksInputUp = !1,
this.dragStartPoint = new s.Point,
this.dragDistanceThreshold = 0,
this.dragTimeThreshold = 0,
this.downPoint = new s.Point,
this.snapPoint = new s.Point,
this._dragPoint = new s.Point,
this._dragPhase = !1,
this._pendingDrag = !1,
this._dragTimePass = !1,
this._dragDistancePass = !1,
this._wasEnabled = !1,
this._tempPoint = new s.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
})
}
,
s.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 s.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) {
for (var e = 0; e < 10; e++)
if (this._pointerData[e].isOver)
return !0;
return !1
}
return this._pointerData[t].isOver
},
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);
var 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;
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);
if (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 = s.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 n = !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 && n && this.sprite && this.sprite.events &&
this.sprite.events.onInputOver$dispatch(this.sprite, t),
this.sprite.parent && this.sprite.parent.type === s.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
=== s.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 === s.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,
this.dragTimeThreshold > 0 ? (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 === s.GROUP &&
this.sprite.parent.onChildInputUp.dispatch(this.sprite, t, i),
i && (i = this.checkPointerOver(t))),
e.isOver = i,
!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
, n = 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 = n),
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 s = this.game.camera.x - this._pointerData[t.id].camX
, o = this.game.camera.y - this._pointerData[t.id].camY;
this.allowHorizontalDrag && (this.sprite.x = i + s),
this.allowVerticalDrag && (this.sprite.y = n + o),
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,
n, 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, n, o, r) {
void 0 === t && (t = !1),
void 0 === e && (e = !1),
void 0 === i && (i = !1),
void 0 === n && (n = 255),
void 0 === o && (o = null),
void 0 === r && (r = null),
this._dragPoint = new s.Point,
this.draggable = !0,
this.bringToTop = e,
this.dragOffset = new s.Point,
this.dragFromCenter = t,
this.pixelPerfectClick = i,
this.pixelPerfectAlpha = n,
o && (this.boundsRect = o),
r && (this.boundsSprite = r)
},
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 n = this.sprite.getBounds();
this.sprite.cameraOffset.x = this.globalToLocalX(t.x) +
(this.sprite.cameraOffset.x - n.centerX),
this.sprite.cameraOffset.y = this.globalToLocalY(t.y) +
(this.sprite.cameraOffset.y - n.centerY)
}
this._dragPoint.setTo(this.sprite.cameraOffset.x - t.x,
this.sprite.cameraOffset.y - t.y)
} else {
if (this.dragFromCenter) {
var n = this.sprite.getBounds();
this.sprite.x = this.globalToLocalX(t.x) + (this.sprite.x -
n.centerX),
this.sprite.y = this.globalToLocalY(t.y) + (this.sprite.y -
n.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, n, s, o) {
void 0 === i && (i = !0),
void 0 === n && (n = !1),
void 0 === s && (s = 0),
void 0 === o && (o = 0),
this.snapX = t,
this.snapY = e,
this.snapOffsetX = s,
this.snapOffsetY = o,
this.snapOnDrag = i,
this.snapOnRelease = n
},
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)))
}
},
s.InputHandler.prototype.constructor = s.InputHandler,
/**
* @author @karlmacklin <tacklemcclean@gmail.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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,
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 s.SinglePad(t,this), new s.SinglePad(t,this), new
s.SinglePad(t,this), new s.SinglePad(t,this)]
}
,
s.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 t = this;
this._onGamepadConnected = function(e) {
return t.onGamepadConnected(e)
}
,
this._onGamepadDisconnected = function(e) {
return t.onGamepadDisconnected(e)
}
,
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)
var t = navigator.webkitGetGamepads();
else if (navigator.webkitGamepads)
var t = navigator.webkitGamepads();
if (t) {
this._rawPads = [];
for (var e = !1, 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 n = 0; n < this._gamepads.length; n++)
this._gamepads[n]._rawPad = this._rawPads[n];
if (e) {
for (var s, o = {
rawIndices: {},
padIndices: {}
}, r = 0; r < this._gamepads.length; r++)
if (s = this._gamepads[r],
s.connected)
for (var a = 0; a < this._rawPads.length; a++)
this._rawPads[a].index === s.index &&
(o.rawIndices[s.index] = !0,
o.padIndices[r] = !0);
for (var h = 0; h < this._gamepads.length; h++)
if (s = this._gamepads[h],
!o.padIndices[h]) {
this._rawPads.length < 1 && s.disconnect();
for (var l = 0; l < this._rawPads.length && !
o.padIndices[h]; l++) {
var c = this._rawPads[l];
if (c) {
if (o.rawIndices[c.index]) {
s.disconnect();
continue
}
s.connect(c),
o.rawIndices[c.index] = !0,
o.padIndices[h] = !0
} else
s.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()
}
},
s.Gamepad.prototype.constructor = s.Gamepad,
Object.defineProperty(s.Gamepad.prototype, "active", {
get: function() {
return this._active
}
}),
Object.defineProperty(s.Gamepad.prototype, "supported", {
get: function() {
return this._gamepadSupportAvailable
}
}),
Object.defineProperty(s.Gamepad.prototype, "padsConnected", {
get: function() {
return this._rawPads.length
}
}),
Object.defineProperty(s.Gamepad.prototype, "pad1", {
get: function() {
return this._gamepads[0]
}
}),
Object.defineProperty(s.Gamepad.prototype, "pad2", {
get: function() {
return this._gamepads[1]
}
}),
Object.defineProperty(s.Gamepad.prototype, "pad3", {
get: function() {
return this._gamepads[2]
}
}),
Object.defineProperty(s.Gamepad.prototype, "pad4", {
get: function() {
return this._gamepads[3]
}
}),
s.Gamepad.BUTTON_0 = 0,
s.Gamepad.BUTTON_1 = 1,
s.Gamepad.BUTTON_2 = 2,
s.Gamepad.BUTTON_3 = 3,
s.Gamepad.BUTTON_4 = 4,
s.Gamepad.BUTTON_5 = 5,
s.Gamepad.BUTTON_6 = 6,
s.Gamepad.BUTTON_7 = 7,
s.Gamepad.BUTTON_8 = 8,
s.Gamepad.BUTTON_9 = 9,
s.Gamepad.BUTTON_10 = 10,
s.Gamepad.BUTTON_11 = 11,
s.Gamepad.BUTTON_12 = 12,
s.Gamepad.BUTTON_13 = 13,
s.Gamepad.BUTTON_14 = 14,
s.Gamepad.BUTTON_15 = 15,
s.Gamepad.AXIS_0 = 0,
s.Gamepad.AXIS_1 = 1,
s.Gamepad.AXIS_2 = 2,
s.Gamepad.AXIS_3 = 3,
s.Gamepad.AXIS_4 = 4,
s.Gamepad.AXIS_5 = 5,
s.Gamepad.AXIS_6 = 6,
s.Gamepad.AXIS_7 = 7,
s.Gamepad.AXIS_8 = 8,
s.Gamepad.AXIS_9 = 9,
s.Gamepad.XBOX360_A = 0,
s.Gamepad.XBOX360_B = 1,
s.Gamepad.XBOX360_X = 2,
s.Gamepad.XBOX360_Y = 3,
s.Gamepad.XBOX360_LEFT_BUMPER = 4,
s.Gamepad.XBOX360_RIGHT_BUMPER = 5,
s.Gamepad.XBOX360_LEFT_TRIGGER = 6,
s.Gamepad.XBOX360_RIGHT_TRIGGER = 7,
s.Gamepad.XBOX360_BACK = 8,
s.Gamepad.XBOX360_START = 9,
s.Gamepad.XBOX360_STICK_LEFT_BUTTON = 10,
s.Gamepad.XBOX360_STICK_RIGHT_BUTTON = 11,
s.Gamepad.XBOX360_DPAD_LEFT = 14,
s.Gamepad.XBOX360_DPAD_RIGHT = 15,
s.Gamepad.XBOX360_DPAD_UP = 12,
s.Gamepad.XBOX360_DPAD_DOWN = 13,
s.Gamepad.XBOX360_STICK_LEFT_X = 0,
s.Gamepad.XBOX360_STICK_LEFT_Y = 1,
s.Gamepad.XBOX360_STICK_RIGHT_X = 2,
s.Gamepad.XBOX360_STICK_RIGHT_Y = 3,
s.Gamepad.PS3XC_X = 0,
s.Gamepad.PS3XC_CIRCLE = 1;
s.Gamepad.PS3XC_SQUARE = 2,
s.Gamepad.PS3XC_TRIANGLE = 3,
s.Gamepad.PS3XC_L1 = 4,
s.Gamepad.PS3XC_R1 = 5,
s.Gamepad.PS3XC_L2 = 6,
s.Gamepad.PS3XC_R2 = 7,
s.Gamepad.PS3XC_SELECT = 8,
s.Gamepad.PS3XC_START = 9,
s.Gamepad.PS3XC_STICK_LEFT_BUTTON = 10,
s.Gamepad.PS3XC_STICK_RIGHT_BUTTON = 11,
s.Gamepad.PS3XC_DPAD_UP = 12,
s.Gamepad.PS3XC_DPAD_DOWN = 13,
s.Gamepad.PS3XC_DPAD_LEFT = 14,
s.Gamepad.PS3XC_DPAD_RIGHT = 15,
s.Gamepad.PS3XC_STICK_LEFT_X = 0,
s.Gamepad.PS3XC_STICK_LEFT_Y = 1,
s.Gamepad.PS3XC_STICK_RIGHT_X = 2,
s.Gamepad.PS3XC_STICK_RIGHT_Y = 3,
/**
* @author @karlmacklin <tacklemcclean@gmail.com>
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.SinglePad = function(t, e) {
this.game = t,
this.index = null,
this.connected = !1,
this.callbackContext = this,
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
}
,
s.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 n = this._rawPad.axes[i];
n > 0 && n > this.deadZone || n < 0 && n < -this.deadZone ?
this.processAxisChange(i, n) : 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 n in t.buttons)
n = parseInt(n, 10),
this._buttons[n] = new s.DeviceButton(this,n);
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
}
},
s.SinglePad.prototype.constructor = s.SinglePad,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.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.durationUp = -2500,
this.repeats = 0,
this.keyCode = e,
this.onDown = new s.Signal,
this.onHoldCallback = null,
this.onHoldContext = null,
this.onUp = new s.Signal,
this._justDown = !1,
this._justUp = !1
}
,
s.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)) : this.durationUp = this.game.time.time - this.timeUp)
},
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.durationUp = this.game.time.time - this.timeUp,
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.durationUp = 0,
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.durationUp = -2500,
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
},
justPressed: function() {
return this.isDown && 0 === this.duration
},
justReleased: function() {
return !this.isDown && 0 === this.durationUp
}
},
Object.defineProperty(s.Key.prototype, "justDown", {
get: function() {
var t = this._justDown;
return this._justDown = !1,
t
}
}),
Object.defineProperty(s.Key.prototype, "justUp", {
get: function() {
var t = this._justUp;
return this._justUp = !1,
t
}
}),
Object.defineProperty(s.Key.prototype, "enabled", {
get: function() {
return this._enabled
},
set: function(t) {
(t = !!t) !== this._enabled && (t || this.reset(!1),
this._enabled = t)
}
}),
s.Key.prototype.constructor = s.Key,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Keyboard = function(t) {
this.game = t,
this.enabled = !0,
this.event = null,
this.pressEvent = null,
this.callbackContext = this,
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
}
,
s.Keyboard.prototype = {
addCallbacks: function(t, e, i, n) {
this.callbackContext = t,
void 0 !== e && null !== e && (this.onDownCallback = e),
void 0 !== i && null !== i && (this.onUpCallback = i),
void 0 !== n && null !== n && (this.onPressCallback = n)
},
addKey: function(t) {
return this._keys[t] || (this._keys[t] = new s.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: s.KeyCode.UP,
down: s.KeyCode.DOWN,
left: s.KeyCode.LEFT,
right: s.KeyCode.RIGHT
})
},
start: function() {
if (!this.game.device.cocoonJS && null === this._onKeyDown) {
var t = this;
this._onKeyDown = function(e) {
return t.processKeyDown(e)
}
,
this._onKeyUp = function(e) {
return t.processKeyUp(e)
}
,
this._onKeyPress = function(e) {
return t.processKeyPress(e)
}
,
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 s.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 s.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
},
justPressed: function(t) {
return this._keys[t] ? this._keys[t].justPressed() : null
},
justReleased: function(t) {
return this._keys[t] ? this._keys[t].justReleased() : null
},
isDown: function(t) {
return this._keys[t] ? this._keys[t].isDown : null
}
},
Object.defineProperty(s.Keyboard.prototype, "lastChar", {
get: function() {
return 32 === this.event.charCode ? "" :
String.fromCharCode(this.pressEvent.charCode)
}
}),
Object.defineProperty(s.Keyboard.prototype, "lastKey", {
get: function() {
return this._keys[this._k]
}
}),
s.Keyboard.prototype.constructor = s.Keyboard,
s.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
};
for (var r in s.KeyCode)
s.KeyCode.hasOwnProperty(r) && !r.match(/[a-z]/) && (s.Keyboard[r] =
s.KeyCode[r]);
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component = function() {}
,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Angle = function() {}
,
s.Component.Angle.prototype = {
angle: {
get: function() {
return s.Math.wrapAngle(s.Math.radToDeg(this.rotation))
},
set: function(t) {
this.rotation = s.Math.degToRad(s.Math.wrapAngle(t))
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Animation = function() {}
,
s.Component.Animation.prototype = {
play: function(t, e, i, n) {
if (this.animations)
return this.animations.play(t, e, i, n)
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.AutoCull = function() {}
,
s.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)
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Bounds = function() {}
,
s.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, n) {
switch (void 0 === i && (i = 0),
void 0 === n && (n = 0),
e) {
default:
case s.TOP_LEFT:
this.left = t.left - i,
this.top = t.top - n;
break;
case s.TOP_CENTER:
this.centerX = t.centerX + i,
this.top = t.top - n;
break;
case s.TOP_RIGHT:
this.right = t.right + i,
this.top = t.top - n;
break;
case s.LEFT_CENTER:
this.left = t.left - i,
this.centerY = t.centerY + n;
break;
case s.CENTER:
this.centerX = t.centerX + i,
this.centerY = t.centerY + n;
break;
case s.RIGHT_CENTER:
this.right = t.right + i,
this.centerY = t.centerY + n;
break;
case s.BOTTOM_LEFT:
this.left = t.left - i,
this.bottom = t.bottom + n;
break;
case s.BOTTOM_CENTER:
this.centerX = t.centerX + i,
this.bottom = t.bottom + n;
break;
case s.BOTTOM_RIGHT:
this.right = t.right + i,
this.bottom = t.bottom + n
}
return this
},
alignTo: function(t, e, i, n) {
switch (void 0 === i && (i = 0),
void 0 === n && (n = 0),
e) {
default:
case s.TOP_LEFT:
this.left = t.left - i,
this.bottom = t.top - n;
break;
case s.TOP_CENTER:
this.centerX = t.centerX + i,
this.bottom = t.top - n;
break;
case s.TOP_RIGHT:
this.right = t.right + i,
this.bottom = t.top - n;
break;
case s.LEFT_TOP:
this.right = t.left - i,
this.top = t.top - n;
break;
case s.LEFT_CENTER:
this.right = t.left - i,
this.centerY = t.centerY + n;
break;
case s.LEFT_BOTTOM:
this.right = t.left - i,
this.bottom = t.bottom + n;
break;
case s.RIGHT_TOP:
this.left = t.right + i,
this.top = t.top - n;
break;
case s.RIGHT_CENTER:
this.left = t.right + i,
this.centerY = t.centerY + n;
break;
case s.RIGHT_BOTTOM:
this.left = t.right + i,
this.bottom = t.bottom + n;
break;
case s.BOTTOM_LEFT:
this.left = t.left - i,
this.top = t.bottom + n;
break;
case s.BOTTOM_CENTER:
this.centerX = t.centerX + i,
this.top = t.bottom + n;
break;
case s.BOTTOM_RIGHT:
this.right = t.right + i,
this.top = t.bottom + n
}
return this
}
},
s.Group.prototype.alignIn = s.Component.Bounds.prototype.alignIn,
s.Group.prototype.alignTo = s.Component.Bounds.prototype.alignTo,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.BringToTop = function() {}
,
s.Component.BringToTop.prototype.bringToTop = function() {
return this.parent && this.parent.bringToTop(this),
this
}
,
s.Component.BringToTop.prototype.sendToBack = function() {
return this.parent && this.parent.sendToBack(this),
this
}
,
s.Component.BringToTop.prototype.moveUp = function() {
return this.parent && this.parent.moveUp(this),
this
}
,
s.Component.BringToTop.prototype.moveDown = function() {
return this.parent && this.parent.moveDown(this),
this
}
,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Core = function() {}
,
s.Component.Core.install = function(t) {
s.Utils.mixinPrototype(this, s.Component.Core.prototype),
this.components = {};
for (var e = 0; e < t.length; e++) {
var i = t[e]
, n = !1;
"Destroy" === i && (n = !0),
s.Utils.mixinPrototype(this, s.Component[i].prototype, n),
this.components[i] = !0
}
}
,
s.Component.Core.init = function(t, e, i, n, o) {
this.game = t,
this.key = n,
this.data = {},
this.position.set(e, i),
this.world = new s.Point(e,i),
this.previousPosition = new s.Point(e,i),
this.events = new s.Events(this),
this._bounds = new s.Rectangle,
this.components.PhysicsBody && (this.body = this.body),
this.components.Animation && (this.animations = new
s.AnimationManager(this)),
this.components.LoadTexture && null !== n && this.loadTexture(n, o),
this.components.FixedToCamera && (this.cameraOffset = new s.Point(e,i))
}
,
s.Component.Core.preUpdate = function() {
if (this.pendingDestroy)
return void this.destroy();
if (this.previousPosition.set(this.world.x, this.world.y),
this.previousRotation = this.rotation,
!this.exists || !this.parent.exists)
return this.renderOrderID = -1,
!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
}
,
s.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) {
t ? (this._exists = !0,
this.body && this.body.type === s.Physics.P2JS &&
this.body.addToWorld(),
this.visible = !0) : (this._exists = !1,
this.body && this.body.type === s.Physics.P2JS &&
this.body.removeFromWorld(),
this.visible = !1)
}
},
update: function() {},
postUpdate: function() {
this.customRender && this.key.render(),
this.components.PhysicsBody &&
s.Component.PhysicsBody.postUpdate.call(this),
this.components.FixedToCamera &&
s.Component.FixedToCamera.postUpdate.call(this);
for (var t = 0; t < this.children.length; t++)
this.children[t].postUpdate()
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Crop = function() {}
,
s.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
s.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
, n = this.texture.crop.height;
this._crop = s.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)
, r = Math.max(this._frame.y, this._crop.y)
, a = Math.min(this._frame.right, this._crop.right) - o
, h = Math.min(this._frame.bottom, this._crop.bottom) - r;
this.texture.crop.x = o,
this.texture.crop.y = r,
this.texture.crop.width = a,
this.texture.crop.height = h,
this.texture.frame.width = Math.min(a, this.cropRect.width),
this.texture.frame.height = Math.min(h, 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 === r && i === a && n
=== h || (this.texture.requiresReTint = !0)
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Delta = function() {}
,
s.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
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Destroy = function() {}
,
s.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 s.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),
s.Video && this.key instanceof s.Video &&
this.key.onChangeSource.remove(this.resizeFrame, this),
s.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
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Events = function(t) {
this.parent = t
}
,
s.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
},
s.Events.prototype.constructor = s.Events;
for (var a in s.Events.prototype)
s.Events.prototype.hasOwnProperty(a) && 0 === a.indexOf("on") && null
=== s.Events.prototype[a] && function(t, e) {
"use strict";
Object.defineProperty(s.Events.prototype, t, {
get: function() {
return this[e] || (this[e] = new s.Signal)
}
}),
s.Events.prototype[t + "$dispatch"] = function() {
return this[e] ? this[e].dispatch.apply(this[e], arguments) :
null
}
}(a, "_" + a);
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.FixedToCamera = function() {}
,
s.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)
}
,
s.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 s.Point
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Health = function() {}
,
s.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
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.InCamera = function() {}
,
s.Component.InCamera.prototype = {
inCamera: {
get: function() {
return this.game.world.camera.view.intersects(this._bounds)
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.InputEnabled = function() {}
,
s.Component.InputEnabled.prototype = {
input: null,
inputEnabled: {
get: function() {
return this.input && this.input.enabled
},
set: function(t) {
t ? null === this.input ? (this.input = new
s.InputHandler(this),
this.input.start()) : this.input && !this.input.enabled &&
this.input.start() : this.input && this.input.enabled && this.input.stop()
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.InWorld = function() {}
,
s.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
}
,
s.Component.InWorld.prototype = {
checkWorldBounds: !1,
outOfBoundsKill: !1,
outOfCameraBoundsKill: !1,
_outOfBoundsFired: !1,
inWorld: {
get: function() {
return this.game.world.bounds.intersects(this.getBounds())
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.LifeSpan = function() {}
,
s.Component.LifeSpan.preUpdate = function() {
return !(this.lifespan > 0 && (this.lifespan -=
this.game.time.physicsElapsedMS,
this.lifespan <= 0)) || (this.kill(),
!1)
}
,
s.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
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.LoadTexture = function() {}
,
s.Component.LoadTexture.prototype = {
customRender: !1,
_frame: null,
loadTexture: function(t, e, i) {
t === s.PENDING_ATLAS ? (t = e,
e = 0) : e = e || 0,
(i || void 0 === i) && this.animations && this.animations.stop(),
this.key = t,
this.customRender = !1;
var n = this.game.cache
, o = !0
, r = !this.texture.baseTexture.scaleMode;
if (s.RenderTexture && t instanceof s.RenderTexture)
this.key = t.key,
this.setTexture(t);
else if (s.BitmapData && t instanceof s.BitmapData)
this.customRender = !0,
this.setTexture(t.texture),
o = n.hasFrameData(t.key, s.Cache.BITMAPDATA) ? !
this.animations.loadFrameData(n.getFrameData(t.key, s.Cache.BITMAPDATA), e) : !
this.animations.loadFrameData(t.frameData, 0);
else if (s.Video && t instanceof s.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 (s.Tilemap && t instanceof s.TilemapLayer)
this.setTexture(PIXI.Texture.fromCanvas(t.canvas));
else if (t instanceof PIXI.Texture)
this.setTexture(t);
else {
var h = n.getImage(t, !0);
this.key = h.key,
this.setTexture(new PIXI.Texture(h.base)),
this.texture.baseTexture.skipRender = "__default" === t,
o = !this.animations.loadFrameData(h.frameData, e)
}
o && (this._frame = s.Rectangle.clone(this.texture.frame)),
r || (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),
t.rotated && (this.texture.rotated = !0),
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
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Overlap = function() {}
,
s.Component.Overlap.prototype = {
overlap: function(t) {
return s.Rectangle.intersects(this.getBounds(), t.getBounds())
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.PhysicsBody = function() {}
,
s.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,
!1) : (this.previousPosition.set(this.world.x, this.world.y),
this.previousRotation = this.rotation,
!(!this._exists || !this.parent.exists) || (this.renderOrderID = -1,
!1))
}
,
s.Component.PhysicsBody.postUpdate = function() {
this.exists && this.body && this.body.postUpdate()
}
,
s.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)
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Reset = function() {}
,
s.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
}
,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.ScaleMinMax = function() {}
,
s.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, n) {
void 0 === e ? e = i = n = t : void 0 === i && (i = n = e,
e = t),
null === t ? this.scaleMin = null : this.scaleMin ?
this.scaleMin.set(t, e) : this.scaleMin = new s.Point(t,e),
null === i ? this.scaleMax = null : this.scaleMax ?
this.scaleMax.set(i, n) : this.scaleMax = new s.Point(i,n),
null === this.scaleMin ? this.transformCallback = null :
(this.transformCallback = this.checkTransform,
this.transformCallbackContext = this)
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Component.Smoothed = function() {}
,
s.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)
}
}
},
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.GameObjectFactory = function(t) {
this.game = t,
this.world = this.game.world
}
,
s.GameObjectFactory.prototype = {
existing: function(t) {
return this.world.add(t)
},
weapon: function(t, e, i, n) {
var o = this.game.plugins.add(s.Weapon);
return o.createBullets(t, e, i, n),
o
},
image: function(t, e, i, n, o) {
return void 0 === o && (o = this.world),
o.add(new s.Image(this.game,t,e,i,n))
},
sprite: function(t, e, i, n, s) {
return void 0 === s && (s = this.world),
s.create(t, e, i, n)
},
creature: function(t, e, i, n, o) {
void 0 === o && (o = this.world);
var r = new s.Creature(this.game,t,e,i,n);
return o.add(r),
r
},
tween: function(t) {
return this.game.tweens.create(t)
},
group: function(t, e, i, n, o) {
return new s.Group(this.game,t,e,i,n,o)
},
physicsGroup: function(t, e, i, n) {
return new s.Group(this.game,e,i,n,!0,t)
},
spriteBatch: function(t, e, i) {
return void 0 === t && (t = null),
void 0 === e && (e = "group"),
void 0 === i && (i = !1),
new s.SpriteBatch(this.game,t,e,i)
},
audio: function(t, e, i, n) {
return this.game.sound.add(t, e, i, n)
},
sound: function(t, e, i, n) {
return this.game.sound.add(t, e, i, n)
},
audioSprite: function(t) {
return this.game.sound.addSprite(t)
},
tileSprite: function(t, e, i, n, o, r, a) {
return void 0 === a && (a = this.world),
a.add(new s.TileSprite(this.game,t,e,i,n,o,r))
},
rope: function(t, e, i, n, o, r) {
return void 0 === r && (r = this.world),
r.add(new s.Rope(this.game,t,e,i,n,o))
},
text: function(t, e, i, n, o) {
return void 0 === o && (o = this.world),
o.add(new s.Text(this.game,t,e,i,n))
},
button: function(t, e, i, n, o, r, a, h, l, c) {
return void 0 === c && (c = this.world),
c.add(new s.Button(this.game,t,e,i,n,o,r,a,h,l))
},
graphics: function(t, e, i) {
return void 0 === i && (i = this.world),
i.add(new s.Graphics(this.game,t,e))
},
emitter: function(t, e, i) {
return this.game.particles.add(new
s.Particles.Arcade.Emitter(this.game,t,e,i))
},
retroFont: function(t, e, i, n, o, r, a, h, l) {
return new s.RetroFont(this.game,t,e,i,n,o,r,a,h,l)
},
bitmapText: function(t, e, i, n, o, r) {
return void 0 === r && (r = this.world),
r.add(new s.BitmapText(this.game,t,e,i,n,o))
},
tilemap: function(t, e, i, n, o) {
return new s.Tilemap(this.game,t,e,i,n,o)
},
renderTexture: function(t, e, i, n) {
void 0 !== i && "" !== i || (i = this.game.rnd.uuid()),
void 0 === n && (n = !1);
var o = new s.RenderTexture(this.game,t,e,i);
return n && this.game.cache.addRenderTexture(i, o),
o
},
video: function(t, e) {
return new s.Video(this.game,t,e)
},
bitmapData: function(t, e, i, n) {
void 0 === n && (n = !1),
void 0 !== i && "" !== i || (i = this.game.rnd.uuid());
var o = new s.BitmapData(this.game,i,t,e);
return n && this.game.cache.addBitmapData(i, o),
o
},
filter: function(t) {
var e = Array.prototype.slice.call(arguments, 1)
, t = new s.Filter[t](this.game);
return t.init.apply(t, e),
t
},
plugin: function(t) {
return this.game.plugins.add(t)
}
},
s.GameObjectFactory.prototype.constructor = s.GameObjectFactory,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.GameObjectCreator = function(t) {
this.game = t,
this.world = this.game.world
}
,
s.GameObjectCreator.prototype = {
image: function(t, e, i, n) {
return new s.Image(this.game,t,e,i,n)
},
sprite: function(t, e, i, n) {
return new s.Sprite(this.game,t,e,i,n)
},
tween: function(t) {
return new s.Tween(t,this.game,this.game.tweens)
},
group: function(t, e, i, n, o) {
return new s.Group(this.game,t,e,i,n,o)
},
spriteBatch: function(t, e, i) {
return void 0 === e && (e = "group"),
void 0 === i && (i = !1),
new s.SpriteBatch(this.game,t,e,i)
},
audio: function(t, e, i, n) {
return this.game.sound.add(t, e, i, n)
},
audioSprite: function(t) {
return this.game.sound.addSprite(t)
},
sound: function(t, e, i, n) {
return this.game.sound.add(t, e, i, n)
},
tileSprite: function(t, e, i, n, o, r) {
return new s.TileSprite(this.game,t,e,i,n,o,r)
},
rope: function(t, e, i, n, o) {
return new s.Rope(this.game,t,e,i,n,o)
},
text: function(t, e, i, n) {
return new s.Text(this.game,t,e,i,n)
},
button: function(t, e, i, n, o, r, a, h, l) {
return new s.Button(this.game,t,e,i,n,o,r,a,h,l)
},
graphics: function(t, e) {
return new s.Graphics(this.game,t,e)
},
emitter: function(t, e, i) {
return new s.Particles.Arcade.Emitter(this.game,t,e,i)
},
retroFont: function(t, e, i, n, o, r, a, h, l) {
return new s.RetroFont(this.game,t,e,i,n,o,r,a,h,l)
},
bitmapText: function(t, e, i, n, o, r) {
return new s.BitmapText(this.game,t,e,i,n,o,r)
},
tilemap: function(t, e, i, n, o) {
return new s.Tilemap(this.game,t,e,i,n,o)
},
renderTexture: function(t, e, i, n) {
void 0 !== i && "" !== i || (i = this.game.rnd.uuid()),
void 0 === n && (n = !1);
var o = new s.RenderTexture(this.game,t,e,i);
return n && this.game.cache.addRenderTexture(i, o),
o
},
bitmapData: function(t, e, i, n) {
void 0 === n && (n = !1),
void 0 !== i && "" !== i || (i = this.game.rnd.uuid());
var o = new s.BitmapData(this.game,i,t,e);
return n && this.game.cache.addBitmapData(i, o),
o
},
filter: function(t) {
var e = Array.prototype.slice.call(arguments, 1)
, t = new s.Filter[t](this.game);
return t.init.apply(t, e),
t
}
},
s.GameObjectCreator.prototype.constructor = s.GameObjectCreator,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Sprite = function(t, e, i, n, o) {
e = e || 0,
i = i || 0,
n = n || null,
o = o || null,
this.type = s.SPRITE,
this.physicsType = s.SPRITE,
PIXI.Sprite.call(this, s.Cache.DEFAULT),
s.Component.Core.init.call(this, t, e, i, n, o)
}
,
s.Sprite.prototype = Object.create(PIXI.Sprite.prototype),
s.Sprite.prototype.constructor = s.Sprite,
s.Component.Core.install.call(s.Sprite.prototype, ["Angle", "Animation",
"AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera",
"Health", "InCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture",
"Overlap", "PhysicsBody", "Reset", "ScaleMinMax", "Smoothed"]),
s.Sprite.prototype.preUpdatePhysics = s.Component.PhysicsBody.preUpdate,
s.Sprite.prototype.preUpdateLifeSpan = s.Component.LifeSpan.preUpdate,
s.Sprite.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.Sprite.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.Sprite.prototype.preUpdate = function() {
return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() &&
this.preUpdateInWorld()) && this.preUpdateCore()
}
,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Image = function(t, e, i, n, o) {
e = e || 0,
i = i || 0,
n = n || null,
o = o || null,
this.type = s.IMAGE,
PIXI.Sprite.call(this, s.Cache.DEFAULT),
s.Component.Core.init.call(this, t, e, i, n, o)
}
,
s.Image.prototype = Object.create(PIXI.Sprite.prototype),
s.Image.prototype.constructor = s.Image,
s.Component.Core.install.call(s.Image.prototype, ["Angle", "Animation",
"AutoCull", "Bounds", "BringToTop", "Crop", "Destroy", "FixedToCamera",
"InputEnabled", "LifeSpan", "LoadTexture", "Overlap", "Reset", "ScaleMinMax",
"Smoothed"]),
s.Image.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.Image.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.Image.prototype.preUpdate = function() {
return !!this.preUpdateInWorld() && this.preUpdateCore()
}
,
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
s.Button = function(t, e, i, n, o, r, a, h, l, c) {
e = e || 0,
i = i || 0,
n = n || null,
o = o || null,
r = r || this,
s.Image.call(this, t, e, i, n, h),
this.type = s.BUTTON,
this.physicsType = s.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 s.Signal,
this.onInputOut = new s.Signal,
this.onInputDown = new s.Signal,
this.onInputUp = new s.Signal,
this.onOverMouseOnly = !0,
this.justReleasedPreventsOver = s.PointerMode.TOUCH,
this.freezeFrames = !1,
this.forceOut = !1,
this.inputEnabled = !0,
this.input.start(0, !0),
this.input.useHandCursor = !0,
this.setFrames(a, h, l, c),
null !== o && this.onInputUp.add(o, r),
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)
}
,
s.Button.prototype = Object.create(s.Image.prototype),
s.Button.prototype.constructor = s.Button;
var h = "Over"
, l = "Out"
, c = "Down"
, u = "Up";
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Mat Groves (@Doormat23)
* @author Rovanion Luckey
* @copyright 2016 Photon Storm Ltd, Richard Davey
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Timo Hausmann
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Jeremy Dowell <jeremy@codevinsky.com>
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Georgios Kaleadis https://github.com/georgiee
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author George https://github.com/georgiee
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
return s.Button.prototype.clearFrames = function() {
this.setFrames(null, null, null, null)
}
,
s.Button.prototype.removedFromWorld = function() {
this.inputEnabled = !1
}
,
s.Button.prototype.setStateFrame = function(t, e, i) {
var n = "_on" + t + "Frame";
null !== e ? (this[n] = e,
i && this.changeStateFrame(t)) : this[n] = null
}
,
s.Button.prototype.changeStateFrame = function(t) {
if (this.freezeFrames)
return !1;
var e = "_on" + t + "Frame"
, i = this[e];
return "string" == typeof i ? (this.frameName = i,
!0) : "number" == typeof i && (this.frame = i,
!0)
}
,
s.Button.prototype.setFrames = function(t, e, i, n) {
this.setStateFrame(h, t, this.input.pointerOver()),
this.setStateFrame(l, e, !this.input.pointerOver()),
this.setStateFrame(c, i, this.input.pointerDown()),
this.setStateFrame(u, n, this.input.pointerUp())
}
,
s.Button.prototype.setStateSound = function(t, e, i) {
var n = "on" + t + "Sound"
, o = "on" + t + "SoundMarker";
e instanceof s.Sound || e instanceof s.AudioSprite ? (this[n] = e,
this[o] = "string" == typeof i ? i : "") : (this[n] = null,
this[o] = "")
}
,
s.Button.prototype.playStateSound = function(t) {
var e = "on" + t + "Sound"
, i = this[e];
if (i) {
var n = "on" + t + "SoundMarker"
, s = this[n];
return i.play(s),
!0
}
return !1
}
,
s.Button.prototype.setSounds = function(t, e, i, n, s, o, r, a) {
this.setStateSound(h, t, e),
this.setStateSound(l, s, o),
this.setStateSound(c, i, n),
this.setStateSound(u, r, a)
}
,
s.Button.prototype.setOverSound = function(t, e) {
this.setStateSound(h, t, e)
}
,
s.Button.prototype.setOutSound = function(t, e) {
this.setStateSound(l, t, e)
}
,
s.Button.prototype.setDownSound = function(t, e) {
this.setStateSound(c, t, e)
}
,
s.Button.prototype.setUpSound = function(t, e) {
this.setStateSound(u, t, e)
}
,
s.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)))
}
,
s.Button.prototype.onInputOutHandler = function(t, e) {
this.changeStateFrame(l),
this.playStateSound(l),
this.onInputOut && this.onInputOut.dispatch(this, e)
}
,
s.Button.prototype.onInputDownHandler = function(t, e) {
this.changeStateFrame(c),
this.playStateSound(c),
this.onInputDown && this.onInputDown.dispatch(this, e)
}
,
s.Button.prototype.onInputUpHandler = function(t, e, i) {
if (this.playStateSound(u),
this.onInputUp && this.onInputUp.dispatch(this, e, i),
!this.freezeFrames)
if (!0 === this.forceOut || (this.forceOut & e.pointerMode) ===
e.pointerMode)
this.changeStateFrame(l);
else {
var n = this.changeStateFrame(u);
n || (i ? this.changeStateFrame(h) : this.changeStateFrame(l))
}
}
,
s.SpriteBatch = function(t, e, i, n) {
void 0 !== e && null !== e || (e = t.world),
s.Group.call(this, t, e, i, n),
this.type = s.SPRITEBATCH,
this.fastSpriteBatch = null,
this.ready = !1
}
,
s.SpriteBatch.prototype = Object.create(s.Group.prototype),
s.SpriteBatch.prototype.constructor = s.SpriteBatch,
s.SpriteBatch.prototype._renderWebGL = function(t) {
!this.visible || this.alpha <= 0 || !this.children.length ||
(this.ready || (this.fastSpriteBatch = new PIXI.WebGLFastSpriteBatch(t.gl),
this.ready = !0),
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())
}
,
s.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, n = !0, s = 0; s <
this.children.length; s++) {
var o = this.children[s];
if (o.visible) {
var r = o.texture
, a = r.frame;
if (e.globalAlpha = this.worldAlpha * o.alpha,
o.rotation % (2 * Math.PI) == 0)
n && (e.setTransform(i.a, i.b, i.c, i.d, i.tx, i.ty),
n = !1),
e.drawImage(r.baseTexture.source, a.x, a.y, a.width,
a.height, o.anchor.x * (-a.width * o.scale.x) + o.position.x + .5 + t.shakeX | 0,
o.anchor.y * (-a.height * o.scale.y) + o.position.y + .5 + t.shakeY | 0, a.width *
o.scale.x, a.height * o.scale.y);
else {
n || (n = !0),
o.displayObjectUpdateTransform();
var h = o.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(r.baseTexture.source, a.x, a.y, a.width,
a.height, o.anchor.x * -a.width + .5 | 0, o.anchor.y * -a.height + .5 | 0, a.width,
a.height)
}
}
}
}
}
,
s.BitmapData = function(t, e, i, n, o) {
void 0 !== i && 0 !== i || (i = 256),
void 0 !== n && 0 !== n || (n = 256),
void 0 === o && (o = !1),
this.game = t,
this.key = e,
this.width = i,
this.height = n,
this.canvas = s.Canvas.create(this, i, n, null, o),
this.context = this.canvas.getContext("2d", {
alpha: !0
}),
this.ctx = this.context,
this.smoothProperty = t.renderType === s.CANVAS ?
t.renderer.renderSession.smoothProperty :
s.Canvas.getSmoothingPrefix(this.context),
this.imageData = this.context.getImageData(0, 0, i, n),
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,null,this.game.resolution),
this.texture = new PIXI.Texture(this.baseTexture),
this.frameData = new s.FrameData,
this.textureFrame = this.frameData.addFrame(new
s.Frame(0,0,0,i,n,"bitmapData")),
this.texture.frame = this.textureFrame,
this.type = s.BITMAPDATA,
this.disableTextureUpload = !1,
this.dirty = !1,
this.cls = this.clear,
this._image = null,
this._pos = new s.Point,
this._size = new s.Point,
this._scale = new s.Point,
this._rotate = 0,
this._alpha = {
prev: 1,
current: 1
},
this._anchor = new s.Point,
this._tempR = 0,
this._tempG = 0,
this._tempB = 0,
this._circle = new s.Circle,
this._swapCanvas = void 0
}
,
s.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 =
s.CanvasPool.create(this, this.width, this.height));
var i = this._swapCanvas
, n = i.getContext("2d")
, o = this.height
, r = this.canvas;
if (n.clearRect(0, 0, this.width, this.height),
t < 0) {
t = Math.abs(t);
var a = this.width - t;
e && n.drawImage(r, 0, 0, t, o, a, 0, t, o),
n.drawImage(r, t, 0, a, o, 0, 0, a, o)
} else {
var a = this.width - t;
e && n.drawImage(r, a, 0, t, o, 0, 0, t, o),
n.drawImage(r, 0, 0, a, o, t, 0, a, o)
}
return this.clear(),
this.copy(this._swapCanvas)
},
moveV: function(t, e) {
void 0 === e && (e = !0),
void 0 === this._swapCanvas && (this._swapCanvas =
s.CanvasPool.create(this, this.width, this.height));
var i = this._swapCanvas
, n = i.getContext("2d")
, o = this.width
, r = this.canvas;
if (n.clearRect(0, 0, this.width, this.height),
t < 0) {
t = Math.abs(t);
var a = this.height - t;
e && n.drawImage(r, 0, 0, o, t, 0, a, o, t),
n.drawImage(r, 0, t, o, a, 0, 0, o, a)
} else {
var a = this.height - t;
e && n.drawImage(r, 0, a, o, t, 0, 0, o, t),
n.drawImage(r, 0, 0, o, a, 0, t, o, a)
}
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, n) {
return void 0 === t && (t = 0),
void 0 === e && (e = 0),
void 0 === i && (i = this.width),
void 0 === n && (n = this.height),
this.context.clearRect(t, e, i, n),
this.dirty = !0,
this
},
fill: function(t, e, i, n) {
return void 0 === n && (n = 1),
this.context.fillStyle = "rgba(" + t + "," + e + "," + i + "," + n
+ ")",
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, n) {
return void 0 === t && (t = 0),
void 0 === e && (e = 0),
void 0 === i && (i = Math.max(1, this.width)),
void 0 === n && (n = Math.max(1, this.height)),
this.imageData = this.context.getImageData(t, e, i, n),
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, n, o, r) {
void 0 === i && (i = 0),
void 0 === n && (n = 0),
void 0 === o && (o = this.width),
void 0 === r && (r = this.height);
for (var a = i + o, h = n + r, l = s.Color.createColor(), c = {
r: 0,
g: 0,
b: 0,
a: 0
}, u = !1, d = n; d < h; d++)
for (var p = i; p < a; p++)
s.Color.unpackPixel(this.getPixel32(p, d), l),
!1 !== (c = t.call(e, l, p, d)) && null !== c && void 0 !==
c && (this.setPixel32(p, d, c.r, c.g, c.b, c.a, !1),
u = !0);
return u && (this.context.putImageData(this.imageData, 0, 0),
this.dirty = !0),
this
},
processPixel: function(t, e, i, n, s, o) {
void 0 === i && (i = 0),
void 0 === n && (n = 0),
void 0 === s && (s = this.width),
void 0 === o && (o = this.height);
for (var r = i + s, a = n + o, h = 0, l = 0, c = !1, u = n; u < a;
u++)
for (var d = i; d < r; d++)
h = this.getPixel32(d, u),
(l = t.call(e, h, d, u)) !== h && (this.pixels[u *
this.width + d] = l,
c = !0);
return c && (this.context.putImageData(this.imageData, 0, 0),
this.dirty = !0),
this
},
replaceRGB: function(t, e, i, n, o, r, a, h, l) {
var c = 0
, u = 0
, d = this.width
, p = this.height
, f = s.Color.packPixel(t, e, i, n);
void 0 !== l && l instanceof s.Rectangle && (c = l.x,
u = l.y,
d = l.width,
p = l.height);
for (var m = 0; m < p; m++)
for (var g = 0; g < d; g++)
this.getPixel32(c + g, u + m) === f && this.setPixel32(c +
g, u + m, o, r, a, h, !1);
return this.context.putImageData(this.imageData, 0, 0),
this.dirty = !0,
this
},
setHSL: function(t, e, i, n) {
var o = t || 0 === t
, r = e || 0 === e
, a = i || 0 === i;
if (o || r || a) {
void 0 === n && (n = new
s.Rectangle(0,0,this.width,this.height));
for (var h = s.Color.createColor(), l = n.y; l < n.bottom; l++)
for (var c = n.x; c < n.right; c++)
s.Color.unpackPixel(this.getPixel32(c, l), h, !0),
o && (h.h = t),
r && (h.s = e),
a && (h.l = i),
s.Color.HSLtoRGB(h.h, h.s, h.l, h),
this.setPixel32(c, l, h.r, h.g, h.b, h.a, !1);
return this.context.putImageData(this.imageData, 0, 0),
this.dirty = !0,
this
}
},
shiftHSL: function(t, e, i, n) {
if (void 0 !== t && null !== t || (t = !1),
void 0 !== e && null !== e || (e = !1),
void 0 !== i && null !== i || (i = !1),
t || e || i) {
void 0 === n && (n = new
s.Rectangle(0,0,this.width,this.height));
for (var o = s.Color.createColor(), r = n.y; r < n.bottom; r++)
for (var a = n.x; a < n.right; a++)
s.Color.unpackPixel(this.getPixel32(a, r), 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)),
s.Color.HSLtoRGB(o.h, o.s, o.l, o),
this.setPixel32(a, r, 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, n, o, r, a) {
return void 0 === a && (a = !0),
t >= 0 && t <= this.width && e >= 0 && e <= this.height &&
(s.Device.LITTLE_ENDIAN ? this.pixels[e * this.width + t] = r << 24 | o << 16 | n
<< 8 | i : this.pixels[e * this.width + t] = i << 24 | n << 16 | o << 8 | r,
a && (this.context.putImageData(this.imageData, 0, 0),
this.dirty = !0)),
this
},
setPixel: function(t, e, i, n, s, o) {
return this.setPixel32(t, e, i, n, s, 255, o)
},
getPixel: function(t, e, i) {
i || (i = s.Color.createColor());
var n = ~~(t + e * this.width);
return n *= 4,
i.r = this.data[n],
i.g = this.data[++n],
i.b = this.data[++n],
i.a = this.data[++n],
i
},
getPixel32: function(t, e) {
if (t >= 0 && t <= this.width && e >= 0 && e <= this.height)
return this.pixels[e * this.width + t]
},
getPixelRGB: function(t, e, i, n, o) {
return s.Color.unpackPixel(this.getPixel32(t, e), i, n, 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 = s.Color.createColor()
, i = 0
, n = 0
, o = 1
, r = !1;
1 === t ? (o = -1,
n = this.height) : 3 === t && (o = -1,
i = this.width);
do {
s.Color.unpackPixel(this.getPixel32(i, n), e),
0 === t || 1 === t ? ++i === this.width && (i = 0,
((n += o) >= this.height || n <= 0) && (r = !0)) : 2 !== t && 3
!== t || ++n === this.height && (n = 0,
((i += o) >= this.width || i <= 0) && (r = !0))
} while (0 === e.a && !r);return e.x = i,
e.y = n,
e
},
getBounds: function(t) {
return void 0 === t && (t = new s.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, n, s, o) {
s = s || 1,
o = o || 1;
var r = this.game.add.image(t, e, this);
return r.anchor.set(i, n),
r.scale.set(s, o),
r
},
copy: function(t, e, i, n, o, r, a, h, l, c, u, d, p, f, m, g, y) {
if (void 0 !== t && null !== t || (t = this),
t instanceof s.RenderTexture && (t = t.getCanvas()),
this._image = t,
t instanceof s.Sprite || t instanceof s.Image || t instanceof
s.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 s.RenderTexture ? this._image =
t.texture.getCanvas() : this._image = t.texture.baseTexture.source,
void 0 !== r && null !== r || (r = t.x),
void 0 !== a && null !== a || (a = t.y),
t.texture.trim && (r += 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 s.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 (void 0 !== e && null !== e || (e = 0),
void 0 !== i && null !== i || (i = 0),
n && (this._size.x = n),
o && (this._size.y = o),
void 0 !== r && null !== r || (r = e),
void 0 !== a && null !== a || (a = i),
void 0 !== h && null !== h || (h = this._size.x),
void 0 !== l && null !== l || (l = this._size.y),
"number" == typeof c && (this._rotate = c),
"number" == typeof u && (this._anchor.x = u),
"number" == typeof d && (this._anchor.y = d),
"number" == typeof p && (this._scale.x = p),
"number" == typeof f && (this._scale.y = f),
"number" == typeof m && (this._alpha.current = m),
void 0 === g && (g = null),
void 0 === y && (y = !1),
!(this._alpha.current <= 0 || 0 === this._scale.x || 0 ===
this._scale.y || 0 === this._size.x || 0 === this._size.y)) {
var v = this.context;
return this._alpha.prev = v.globalAlpha,
v.save(),
v.globalAlpha = this._alpha.current,
g && (this.op = g),
y && (r |= 0,
a |= 0),
v.translate(r, a),
v.scale(this._scale.x, this._scale.y),
v.rotate(this._rotate),
v.drawImage(this._image, this._pos.x + e, this._pos.y + i,
this._size.x, this._size.y, -h * this._anchor.x, -l * this._anchor.y, h, l),
v.restore(),
v.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 n = 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 === n.a || 0 === n.d || 0 === this._size.x || 0 === this._size.y)
return this;
t.texture instanceof s.RenderTexture ? this._image =
t.texture.getCanvas() : this._image = t.texture.baseTexture.source;
var o = n.tx
, r = n.ty;
t.texture.trim && (o += t.texture.trim.x - t.anchor.x *
t.texture.trim.width,
r += 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,
r |= 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(n.a, n.b, n.c, n.d, o, r),
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, n, s, o, r) {
return this.copy(t, e.x, e.y, e.width, e.height, i, n, e.width,
e.height, 0, 0, 0, 1, 1, s, o, r)
},
draw: function(t, e, i, n, s, o, r) {
return this.copy(t, null, null, null, null, e, i, n, s, null, null,
null, null, null, null, o, r)
},
drawGroup: function(t, e, i) {
return t.total > 0 && t.forEachExists(this.drawGroupProxy, this, e,
i),
this
},
drawGroupProxy: function(t, e, i) {
if (t.hasOwnProperty("texture") && this.copyTransform(t, e, i),
t.type === s.GROUP && t.exists)
this.drawGroup(t, e, i);
else if (t.hasOwnProperty("children") && t.children.length > 0)
for (var n = 0; n < t.children.length; n++)
t.children[n].exists && this.copyTransform(t.children[n],
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 !== s.GROUP && t.type !== s.EMITTER && t.type !==
s.BITMAPTEXT)
if (t.type === s.GRAPHICS) {
var n = t.getBounds();
this.ctx.save(),
this.ctx.translate(n.x, n.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, n) {
var s = this.context;
return void 0 === t || null === t ? s.shadowColor = "rgba(0,0,0,0)"
: (s.shadowColor = t,
s.shadowBlur = e || 5,
s.shadowOffsetX = i || 10,
s.shadowOffsetY = n || 10),
this
},
alphaMask: function(t, e, i, n) {
return void 0 === n || null === n ?
this.draw(e).blendSourceAtop() : this.draw(e, n.x, n.y, n.width,
n.height).blendSourceAtop(),
void 0 === i || null === i ? this.draw(t).blendReset() :
this.draw(t, i.x, i.y, i.width, i.height).blendReset(),
this
},
extract: function(t, e, i, n, s, o, r, a, h) {
return void 0 === s && (s = 255),
void 0 === o && (o = !1),
void 0 === r && (r = e),
void 0 === a && (a = i),
void 0 === h && (h = n),
o && t.resize(this.width, this.height),
this.processPixelRGB(function(o, l, c) {
return o.r === e && o.g === i && o.b === n && t.setPixel32(l,
c, r, a, h, s, !1),
!1
}, this),
t.context.putImageData(t.imageData, 0, 0),
t.dirty = !0,
t
},
rect: function(t, e, i, n, s) {
return void 0 !== s && (this.context.fillStyle = s),
this.context.fillRect(t, e, i, n),
this
},
text: function(t, e, i, n, s, o) {
void 0 === e && (e = 0),
void 0 === i && (i = 0),
void 0 === n && (n = "14px Courier"),
void 0 === s && (s = "rgb(255,255,255)"),
void 0 === o && (o = !0);
var r = this.context
, a = r.font;
return r.font = n,
o && (r.fillStyle = "rgb(0,0,0)",
r.fillText(t, e + 1, i + 1)),
r.fillStyle = s,
r.fillText(t, e, i),
r.font = a,
this
},
circle: function(t, e, i, n) {
var s = this.context;
return void 0 !== n && (s.fillStyle = n),
s.beginPath(),
s.arc(t, e, i, 0, 2 * Math.PI, !1),
s.closePath(),
s.fill(),
this
},
line: function(t, e, i, n, s, o) {
void 0 === s && (s = "#fff"),
void 0 === o && (o = 1);
var r = this.context;
return r.beginPath(),
r.moveTo(t, e),
r.lineTo(i, n),
r.lineWidth = o,
r.strokeStyle = s,
r.stroke(),
r.closePath(),
this
},
textureLine: function(t, e, i) {
if (void 0 === i && (i = "repeat-x"),
"string" != typeof e || (e = this.game.cache.getImage(e))) {
var n = t.length;
"no-repeat" === i && n > e.width && (n = e.width);
var o = this.context;
return o.fillStyle = o.createPattern(e, i),
this._circle = new s.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, n, 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),
s.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(s.BitmapData.prototype, "smoothed", {
get: function() {
s.Canvas.getSmoothingEnabled(this.context)
},
set: function(t) {
s.Canvas.setSmoothingEnabled(this.context, t)
}
}),
Object.defineProperty(s.BitmapData.prototype, "op", {
get: function() {
return this.context.globalCompositeOperation
},
set: function(t) {
this.context.globalCompositeOperation = t
}
}),
s.BitmapData.getTransform = function(t, e, i, n, s, o) {
return "number" != typeof t && (t = 0),
"number" != typeof e && (e = 0),
"number" != typeof i && (i = 1),
"number" != typeof n && (n = 1),
"number" != typeof s && (s = 0),
"number" != typeof o && (o = 0),
{
sx: i,
sy: n,
scaleX: i,
scaleY: n,
skewX: s,
skewY: o,
translateX: t,
translateY: e,
tx: t,
ty: e
}
}
,
s.BitmapData.prototype.constructor = s.BitmapData,
s.EarCut = {},
s.EarCut.Triangulate = function(t, e, i) {
i = i || 2;
var n = e && e.length
, o = n ? e[0] * i : t.length
, r = s.EarCut.linkedList(t, 0, o, i, !0)
, a = [];
if (!r)
return a;
var h, l, c, u, d, p, f;
if (n && (r = s.EarCut.eliminateHoles(t, e, r, i)),
t.length > 80 * i) {
h = c = t[0],
l = u = t[1];
for (var m = i; m < o; m += i)
d = t[m],
p = t[m + 1],
d < h && (h = d),
p < l && (l = p),
d > c && (c = d),
p > u && (u = p);
f = Math.max(c - h, u - l)
}
return s.EarCut.earcutLinked(r, a, i, h, l, f),
a
}
,
s.EarCut.linkedList = function(t, e, i, n, o) {
var r, a, h, l = 0;
for (r = e,
a = i - n; r < i; r += n)
l += (t[a] - t[r]) * (t[r + 1] + t[a + 1]),
a = r;
if (o === l > 0)
for (r = e; r < i; r += n)
h = s.EarCut.insertNode(r, t[r], t[r + 1], h);
else
for (r = i - n; r >= e; r -= n)
h = s.EarCut.insertNode(r, t[r], t[r + 1], h);
return h
}
,
s.EarCut.filterPoints = function(t, e) {
if (!t)
return t;
e || (e = t);
var i, n = t;
do {
if (i = !1,
n.steiner || !s.EarCut.equals(n, n.next) && 0 !==
s.EarCut.area(n.prev, n, n.next))
n = n.next;
else {
if (s.EarCut.removeNode(n),
(n = e = n.prev) === n.next)
return null;
i = !0
}
} while (i || n !== e);return e
}
,
s.EarCut.earcutLinked = function(t, e, i, n, o, r, a) {
if (t) {
!a && r && s.EarCut.indexCurve(t, n, o, r);
for (var h, l, c = t; t.prev !== t.next; )
if (h = t.prev,
l = t.next,
r ? s.EarCut.isEarHashed(t, n, o, r) : s.EarCut.isEar(t))
e.push(h.i / i),
e.push(t.i / i),
e.push(l.i / i),
s.EarCut.removeNode(t),
t = l.next,
c = l.next;
else if ((t = l) === c) {
a ? 1 === a ? (t = s.EarCut.cureLocalIntersections(t, e,
i),
s.EarCut.earcutLinked(t, e, i, n, o, r, 2)) : 2 === a &&
s.EarCut.splitEarcut(t, e, i, n, o, r) :
s.EarCut.earcutLinked(s.EarCut.filterPoints(t), e, i, n, o, r, 1);
break
}
}
}
,
s.EarCut.isEar = function(t) {
var e = t.prev
, i = t
, n = t.next;
if (s.EarCut.area(e, i, n) >= 0)
return !1;
for (var o = t.next.next; o !== t.prev; ) {
if (s.EarCut.pointInTriangle(e.x, e.y, i.x, i.y, n.x, n.y, o.x,
o.y) && s.EarCut.area(o.prev, o, o.next) >= 0)
return !1;
o = o.next
}
return !0
}
,
s.EarCut.isEarHashed = function(t, e, i, n) {
var o = t.prev
, r = t
, a = t.next;
if (s.EarCut.area(o, r, a) >= 0)
return !1;
for (var h = o.x < r.x ? o.x < a.x ? o.x : a.x : r.x < a.x ? r.x : a.x,
l = o.y < r.y ? o.y < a.y ? o.y : a.y : r.y < a.y ? r.y : a.y, c = o.x > r.x ? o.x
> a.x ? o.x : a.x : r.x > a.x ? r.x : a.x, u = o.y > r.y ? o.y > a.y ? o.y : a.y :
r.y > a.y ? r.y : a.y, d = s.EarCut.zOrder(h, l, e, i, n), p = s.EarCut.zOrder(c,
u, e, i, n), f = t.nextZ; f && f.z <= p; ) {
if (f !== t.prev && f !== t.next && s.EarCut.pointInTriangle(o.x,
o.y, r.x, r.y, a.x, a.y, f.x, f.y) && s.EarCut.area(f.prev, f, f.next) >= 0)
return !1;
f = f.nextZ
}
for (f = t.prevZ; f && f.z >= d; ) {
if (f !== t.prev && f !== t.next && s.EarCut.pointInTriangle(o.x,
o.y, r.x, r.y, a.x, a.y, f.x, f.y) && s.EarCut.area(f.prev, f, f.next) >= 0)
return !1;
f = f.prevZ
}
return !0
}
,
s.EarCut.cureLocalIntersections = function(t, e, i) {
var n = t;
do {
var o = n.prev
, r = n.next.next;
s.EarCut.intersects(o, n, n.next, r) && s.EarCut.locallyInside(o,
r) && s.EarCut.locallyInside(r, o) && (e.push(o.i / i),
e.push(n.i / i),
e.push(r.i / i),
s.EarCut.removeNode(n),
s.EarCut.removeNode(n.next),
n = t = r),
n = n.next
} while (n !== t);return n
}
,
s.EarCut.splitEarcut = function(t, e, i, n, o, r) {
var a = t;
do {
for (var h = a.next.next; h !== a.prev; ) {
if (a.i !== h.i && s.EarCut.isValidDiagonal(a, h)) {
var l = s.EarCut.splitPolygon(a, h);
return a = s.EarCut.filterPoints(a, a.next),
l = s.EarCut.filterPoints(l, l.next),
s.EarCut.earcutLinked(a, e, i, n, o, r),
void s.EarCut.earcutLinked(l, e, i, n, o, r)
}
h = h.next
}
a = a.next
} while (a !== t)
}
,
s.EarCut.eliminateHoles = function(t, e, i, n) {
var o, r, a, h, l, c = [];
for (o = 0,
r = e.length; o < r; o++)
a = e[o] * n,
h = o < r - 1 ? e[o + 1] * n : t.length,
l = s.EarCut.linkedList(t, a, h, n, !1),
l === l.next && (l.steiner = !0),
c.push(s.EarCut.getLeftmost(l));
for (c.sort(compareX),
o = 0; o < c.length; o++)
s.EarCut.eliminateHole(c[o], i),
i = s.EarCut.filterPoints(i, i.next);
return i
}
,
s.EarCut.compareX = function(t, e) {
return t.x - e.x
}
,
s.EarCut.eliminateHole = function(t, e) {
if (e = s.EarCut.findHoleBridge(t, e)) {
var i = s.EarCut.splitPolygon(e, t);
s.EarCut.filterPoints(i, i.next)
}
}
,
s.EarCut.findHoleBridge = function(t, e) {
var i, n = e, o = t.x, r = t.y, a = -1 / 0;
do {
if (r <= n.y && r >= n.next.y) {
var h = n.x + (r - n.y) * (n.next.x - n.x) / (n.next.y - n.y);
h <= o && h > a && (a = h,
i = n.x < n.next.x ? n : n.next)
}
n = n.next
} while (n !== e);if (!i)
return null;
if (t.x === i.x)
return i.prev;
var l, c = i, u = 1 / 0;
for (n = i.next; n !== c; )
o >= n.x && n.x >= i.x && s.EarCut.pointInTriangle(r < i.y ? o : a,
r, i.x, i.y, r < i.y ? a : o, r, n.x, n.y) && ((l = Math.abs(r - n.y) / (o - n.x))
< u || l === u && n.x > i.x) && s.EarCut.locallyInside(n, t) && (i = n,
u = l),
n = n.next;
return i
}
,
s.EarCut.indexCurve = function(t, e, i, n) {
var o = t;
do {
null === o.z && (o.z = s.EarCut.zOrder(o.x, o.y, e, i, n)),
o.prevZ = o.prev,
o.nextZ = o.next,
o = o.next
} while (o !== t);o.prevZ.nextZ = null,
o.prevZ = null,
s.EarCut.sortLinked(o)
}
,
s.EarCut.sortLinked = function(t) {
var e, i, n, s, o, r, a, h, l = 1;
do {
for (i = t,
t = null,
o = null,
r = 0; i; ) {
for (r++,
n = i,
a = 0,
e = 0; e < l && (a++,
n = n.nextZ); e++)
;
for (h = l; a > 0 || h > 0 && n; )
0 === a ? (s = n,
n = n.nextZ,
h--) : 0 !== h && n ? i.z <= n.z ? (s = i,
i = i.nextZ,
a--) : (s = n,
n = n.nextZ,
h--) : (s = i,
i = i.nextZ,
a--),
o ? o.nextZ = s : t = s,
s.prevZ = o,
o = s;
i = n
}
o.nextZ = null,
l *= 2
} while (r > 1);return t
}
,
s.EarCut.zOrder = function(t, e, i, n, s) {
return t = 32767 * (t - i) / s,
e = 32767 * (e - n) / s,
t = 16711935 & (t | t << 8),
t = 252645135 & (t | t << 4),
t = 858993459 & (t | t << 2),
t = 1431655765 & (t | t << 1),
e = 16711935 & (e | e << 8),
e = 252645135 & (e | e << 4),
e = 858993459 & (e | e << 2),
e = 1431655765 & (e | e << 1),
t | e << 1
}
,
s.EarCut.getLeftmost = function(t) {
var e = t
, i = t;
do {
e.x < i.x && (i = e),
e = e.next
} while (e !== t);return i
}
,
s.EarCut.pointInTriangle = function(t, e, i, n, s, o, r, a) {
return (s - r) * (e - a) - (t - r) * (o - a) >= 0 && (t - r) * (n - a)
- (i - r) * (e - a) >= 0 && (i - r) * (o - a) - (s - r) * (n - a) >= 0
}
,
s.EarCut.isValidDiagonal = function(t, e) {
return s.EarCut.equals(t, e) || t.next.i !== e.i && t.prev.i !== e.i &&
!s.EarCut.intersectsPolygon(t, e) && s.EarCut.locallyInside(t, e) &&
s.EarCut.locallyInside(e, t) && s.EarCut.middleInside(t, e)
}
,
s.EarCut.area = function(t, e, i) {
return (e.y - t.y) * (i.x - e.x) - (e.x - t.x) * (i.y - e.y)
}
,
s.EarCut.equals = function(t, e) {
return t.x === e.x && t.y === e.y
}
,
s.EarCut.intersects = function(t, e, i, n) {
return s.EarCut.area(t, e, i) > 0 != s.EarCut.area(t, e, n) > 0 &&
s.EarCut.area(i, n, t) > 0 != s.EarCut.area(i, n, e) > 0
}
,
s.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 && s.EarCut.intersects(i, i.next, t, e))
return !0;
i = i.next
} while (i !== t);return !1
}
,
s.EarCut.locallyInside = function(t, e) {
return s.EarCut.area(t.prev, t, t.next) < 0 ? s.EarCut.area(t, e,
t.next) >= 0 && s.EarCut.area(t, t.prev, e) >= 0 : s.EarCut.area(t, e, t.prev) < 0
|| s.EarCut.area(t, t.next, e) < 0
}
,
s.EarCut.middleInside = function(t, e) {
var i = t
, n = !1
, s = (t.x + e.x) / 2
, o = (t.y + e.y) / 2;
do {
i.y > o != i.next.y > o && s < (i.next.x - i.x) * (o - i.y) /
(i.next.y - i.y) + i.x && (n = !n),
i = i.next
} while (i !== t);return n
}
,
s.EarCut.splitPolygon = function(t, e) {
var i = new s.EarCut.Node(t.i,t.x,t.y)
, n = new s.EarCut.Node(e.i,e.x,e.y)
, o = t.next
, r = e.prev;
return t.next = e,
e.prev = t,
i.next = o,
o.prev = i,
n.next = i,
i.prev = n,
r.next = n,
n.prev = r,
n
}
,
s.EarCut.insertNode = function(t, e, i, n) {
var o = new s.EarCut.Node(t,e,i);
return n ? (o.next = n.next,
o.prev = n,
n.next.prev = o,
n.next = o) : (o.prev = o,
o.next = o),
o
}
,
s.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)
}
,
s.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, n = e.gl, o = e.projection, r = e.offset, a =
e.shaderManager.primitiveShader;
t.dirty && PIXI.WebGLGraphics.updateGraphics(t, n);
for (var h = t._webGL[n.id], l = 0; l < h.data.length; l++)
1 === h.data[l].mode ? (i = h.data[l],
e.stencilManager.pushStencil(t, i, e),
n.drawElements(n.TRIANGLE_FAN, 4, n.UNSIGNED_SHORT, 2 *
(i.indices.length - 4)),
e.stencilManager.popStencil(t, i, e)) : (i = h.data[l],
e.shaderManager.setShader(a),
a = e.shaderManager.primitiveShader,
n.uniformMatrix3fv(a.translationMatrix, !1,
t.worldTransform.toArray(!0)),
n.uniform1f(a.flipY, 1),
n.uniform2f(a.projectionVector, o.x, -o.y),
n.uniform2f(a.offsetVector, -r.x, -r.y),
n.uniform3fv(a.tintColor, s.Color.hexToRGBArray(t.tint)),
n.uniform1f(a.alpha, t.worldAlpha),
n.bindBuffer(n.ARRAY_BUFFER, i.buffer),
n.vertexAttribPointer(a.aVertexPosition, 2, n.FLOAT, !1, 24, 0),
n.vertexAttribPointer(a.colorAttribute, 4, n.FLOAT, !1, 24, 8),
n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, i.indexBuffer),
n.drawElements(n.TRIANGLE_STRIP, i.indices.length,
n.UNSIGNED_SHORT, 0))
}
,
PIXI.WebGLGraphics.updateGraphics = function(t, e) {
var i = t._webGL[e.id];
i || (i = t._webGL[e.id] = {
lastIndex: 0,
data: [],
gl: e
}),
t.dirty = !1;
var n;
if (t.clearDirty) {
for (t.clearDirty = !1,
n = 0; n < i.data.length; n++) {
var o = i.data[n];
o.reset(),
PIXI.WebGLGraphics.graphicsDataPool.push(o)
}
i.data = [],
i.lastIndex = 0
}
var r;
for (n = i.lastIndex; n < t.graphicsData.length; n++) {
var a = t.graphicsData[n];
if (a.type === s.POLYGON) {
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 && a.points.length >=
PIXI.WebGLGraphics.stencilBufferLimit)
if (a.points.length < 2 *
PIXI.WebGLGraphics.stencilBufferLimit) {
r = PIXI.WebGLGraphics.switchMode(i, 0);
var h = PIXI.WebGLGraphics.buildPoly(a, r);
h || (r = PIXI.WebGLGraphics.switchMode(i, 1),
PIXI.WebGLGraphics.buildComplexPoly(a, r))
} else
r = PIXI.WebGLGraphics.switchMode(i, 1),
PIXI.WebGLGraphics.buildComplexPoly(a, r);
a.lineWidth > 0 && (r = PIXI.WebGLGraphics.switchMode(i, 0),
PIXI.WebGLGraphics.buildLine(a, r))
} else
r = PIXI.WebGLGraphics.switchMode(i, 0),
a.type === s.RECTANGLE ? PIXI.WebGLGraphics.buildRectangle(a,
r) : a.type === s.CIRCLE || a.type === s.ELLIPSE ?
PIXI.WebGLGraphics.buildCircle(a, r) : a.type === s.ROUNDEDRECTANGLE &&
PIXI.WebGLGraphics.buildRoundedRectangle(a, r);
i.lastIndex++
}
for (n = 0; n < i.data.length; n++)
r = i.data[n],
r.dirty && r.upload()
}
,
PIXI.WebGLGraphics.switchMode = function(t, e) {
var i;
return t.data.length ? (i = t.data[t.data.length - 1],
i.mode === e && 1 !== e || (i =
PIXI.WebGLGraphics.graphicsDataPool.pop() || new PIXI.WebGLGraphicsData(t.gl),
i.mode = e,
t.data.push(i))) : (i = PIXI.WebGLGraphics.graphicsDataPool.pop() ||
new PIXI.WebGLGraphicsData(t.gl),
i.mode = e,
t.data.push(i)),
i.dirty = !0,
i
}
,
PIXI.WebGLGraphics.buildRectangle = function(t, e) {
var i = t.shape
, n = i.x
, o = i.y
, r = i.width
, a = i.height;
if (t.fill) {
var h = s.Color.hexToRGBArray(t.fillColor)
, l = t.fillAlpha
, c = h[0] * l
, u = h[1] * l
, d = h[2] * l
, p = e.points
, f = e.indices
, m = p.length / 6;
p.push(n, o),
p.push(c, u, d, l),
p.push(n + r, o),
p.push(c, u, d, l),
p.push(n, o + a),
p.push(c, u, d, l),
p.push(n + r, o + a),
p.push(c, u, d, l),
f.push(m, m, m + 1, m + 2, m + 3, m + 3)
}
if (t.lineWidth) {
var g = t.points;
t.points = [n, o, n + r, o, n + r, o + a, n, o + a, n, o],
PIXI.WebGLGraphics.buildLine(t, e),
t.points = g
}
}
,
PIXI.WebGLGraphics.buildRoundedRectangle = function(t, e) {
var i = t.shape
, n = i.x
, o = i.y
, r = i.width
, a = i.height
, h = i.radius
, l = [];
if (l.push(n, o + h),
l = l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n, o + a - h, n, o
+ a, n + h, o + a)),
l = l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n + r - h, o + a,
n + r, o + a, n + r, o + a - h)),
l = l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n + r, o + h, n +
r, o, n + r - h, o)),
l = l.concat(PIXI.WebGLGraphics.quadraticBezierCurve(n + h, o, n, o, n,
o + h)),
t.fill) {
var c = s.Color.hexToRGBArray(t.fillColor)
, u = t.fillAlpha
, d = c[0] * u
, p = c[1] * u
, f = c[2] * u
, m = e.points
, g = e.indices
, y = m.length / 6
, v = s.EarCut.Triangulate(l, null, 2)
, b = 0;
for (b = 0; b < v.length; b += 3)
g.push(v[b] + y),
g.push(v[b] + y),
g.push(v[b + 1] + y),
g.push(v[b + 2] + y),
g.push(v[b + 2] + y);
for (b = 0; b < l.length; b++)
m.push(l[b], l[++b], d, p, f, u)
}
if (t.lineWidth) {
var w = t.points;
t.points = l,
PIXI.WebGLGraphics.buildLine(t, e),
t.points = w
}
}
,
PIXI.WebGLGraphics.quadraticBezierCurve = function(t, e, i, n, s, o) {
function r(t, e, i) {
return t + (e - t) * i
}
for (var a, h, l, c, u, d, p = 20, f = [], m = 0, g = 0; g <= p; g++)
m = g / p,
a = r(t, i, m),
h = r(e, n, m),
l = r(i, s, m),
c = r(n, o, m),
u = r(a, l, m),
d = r(h, c, m),
f.push(u, d);
return f
}
,
PIXI.WebGLGraphics.buildCircle = function(t, e) {
var i, n, o = t.shape, r = o.x, a = o.y;
t.type === s.CIRCLE ? (i = o.radius,
n = o.radius) : (i = o.width,
n = o.height);
var h = 40
, l = 2 * Math.PI / h
, c = 0;
if (t.fill) {
var u = s.Color.hexToRGBArray(t.fillColor)
, d = t.fillAlpha
, p = u[0] * d
, f = u[1] * d
, m = u[2] * d
, g = e.points
, y = e.indices
, v = g.length / 6;
for (y.push(v),
c = 0; c < h + 1; c++)
g.push(r, a, p, f, m, d),
g.push(r + Math.sin(l * c) * i, a + Math.cos(l * c) * n, p, f,
m, d),
y.push(v++, v++);
y.push(v - 1)
}
if (t.lineWidth) {
var b = t.points;
for (t.points = [],
c = 0; c < h + 1; c++)
t.points.push(r + Math.sin(l * c) * i, a + Math.cos(l * c) *
n);
PIXI.WebGLGraphics.buildLine(t, e),
t.points = b
}
}
,
PIXI.WebGLGraphics.buildLine = function(t, e) {
var i = 0
, n = t.points;
if (0 !== n.length) {
if (t.lineWidth % 2)
for (i = 0; i < n.length; i++)
n[i] += .5;
var o = new PIXI.Point(n[0],n[1])
, r = new PIXI.Point(n[n.length - 2],n[n.length - 1]);
if (o.x === r.x && o.y === r.y) {
n = n.slice(),
n.pop(),
n.pop(),
r = new PIXI.Point(n[n.length - 2],n[n.length - 1]);
var a = r.x + .5 * (o.x - r.x)
, h = r.y + .5 * (o.y - r.y);
n.unshift(a, h),
n.push(a, h)
}
var l, c, u, d, p, f, m, g, y, v, b, w, x, _, P, T, C, S, A, k, E,
I, M, O = e.points, B = e.indices, R = n.length / 2, L = n.length, D = O.length /
6, F = t.lineWidth / 2, N = s.Color.hexToRGBArray(t.lineColor), G = t.lineAlpha, U
= N[0] * G, W = N[1] * G, j = N[2] * G;
for (u = n[0],
d = n[1],
p = n[2],
f = n[3],
y = -(d - f),
v = u - p,
M = Math.sqrt(y * y + v * v),
y /= M,
v /= M,
y *= F,
v *= F,
O.push(u - y, d - v, U, W, j, G),
O.push(u + y, d + v, U, W, j, G),
i = 1; i < R - 1; i++)
u = n[2 * (i - 1)],
d = n[2 * (i - 1) + 1],
p = n[2 * i],
f = n[2 * i + 1],
m = n[2 * (i + 1)],
g = n[2 * (i + 1) + 1],
y = -(d - f),
v = u - p,
M = Math.sqrt(y * y + v * v),
y /= M,
v /= M,
y *= F,
v *= F,
b = -(f - g),
w = p - m,
M = Math.sqrt(b * b + w * w),
b /= M,
w /= M,
b *= F,
w *= F,
P = -v + d - (-v + f),
T = -y + p - (-y + u),
C = (-y + u) * (-v + f) - (-y + p) * (-v + d),
S = -w + g - (-w + f),
A = -b + p - (-b + m),
k = (-b + m) * (-w + f) - (-b + p) * (-w + g),
E = P * A - S * T,
Math.abs(E) < .1 ? (E += 10.1,
O.push(p - y, f - v, U, W, j, G),
O.push(p + y, f + v, U, W, j, G)) : (l = (T * k - A * C) / E,
c = (S * C - P * k) / E,
I = (l - p) * (l - p) + (c - f) + (c - f),
I > 19600 ? (x = y - b,
_ = v - w,
M = Math.sqrt(x * x + _ * _),
x /= M,
_ /= M,
x *= F,
_ *= F,
O.push(p - x, f - _),
O.push(U, W, j, G),
O.push(p + x, f + _),
O.push(U, W, j, G),
O.push(p - x, f - _),
O.push(U, W, j, G),
L++) : (O.push(l, c),
O.push(U, W, j, G),
O.push(p - (l - p), f - (c - f)),
O.push(U, W, j, G)));
for (u = n[2 * (R - 2)],
d = n[2 * (R - 2) + 1],
p = n[2 * (R - 1)],
f = n[2 * (R - 1) + 1],
y = -(d - f),
v = u - p,
M = Math.sqrt(y * y + v * v),
y /= M,
v /= M,
y *= F,
v *= F,
O.push(p - y, f - v),
O.push(U, W, j, G),
O.push(p + y, f + v),
O.push(U, W, j, G),
B.push(D),
i = 0; i < L; i++)
B.push(D++);
B.push(D - 1)
}
}
,
PIXI.WebGLGraphics.buildComplexPoly = function(t, e) {
var i = t.points.slice();
if (!(i.length < 6)) {
var n = e.indices;
e.points = i,
e.alpha = t.fillAlpha,
e.color = s.Color.hexToRGBArray(t.fillColor);
for (var o, r, a = 1 / 0, h = -1 / 0, l = 1 / 0, c = -1 / 0, u = 0;
u < i.length; u += 2)
o = i[u],
r = i[u + 1],
a = o < a ? o : a,
h = o > h ? o : h,
l = r < l ? r : l,
c = r > c ? r : c;
i.push(a, l, h, l, h, c, a, c);
var d = i.length / 2;
for (u = 0; u < d; u++)
n.push(u)
}
}
,
PIXI.WebGLGraphics.buildPoly = function(t, e) {
var i = t.points;
if (!(i.length < 6)) {
var n = e.points
, o = e.indices
, r = i.length / 2
, a = s.Color.hexToRGBArray(t.fillColor)
, h = t.fillAlpha
, l = a[0] * h
, c = a[1] * h
, u = a[2] * h
, d = s.EarCut.Triangulate(i, null, 2);
if (!d)
return !1;
var p = n.length / 6
, f = 0;
for (f = 0; f < d.length; f += 3)
o.push(d[f] + p),
o.push(d[f] + p),
o.push(d[f + 1] + p),
o.push(d[f + 2] + p),
o.push(d[f + 2] + p);
for (f = 0; f < r; f++)
n.push(i[2 * f], i[2 * f + 1], l, c, u, h);
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 Float32Array(this.points),
t.bindBuffer(t.ARRAY_BUFFER, this.buffer),
t.bufferData(t.ARRAY_BUFFER, this.glPoints, t.STATIC_DRAW),
this.glIndicies = new 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 n = 0; n < t.graphicsData.length; n++) {
var o = t.graphicsData[n]
, r = o.shape
, a = o._fillTint
, h = o._lineTint;
if (e.lineWidth = o.lineWidth,
o.type === s.POLYGON) {
e.beginPath();
var l = r.points;
e.moveTo(l[0], l[1]);
for (var c = 1; c < l.length / 2; c++)
e.lineTo(l[2 * c], l[2 * c + 1]);
r.closed && e.lineTo(l[0], l[1]),
l[0] === l[l.length - 2] && l[1] === l[l.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 | h).toString(16)).substr(-
6),
e.stroke())
} else if (o.type === s.RECTANGLE)
(o.fillColor || 0 === o.fillColor) && (e.globalAlpha =
o.fillAlpha * i,
e.fillStyle = "#" + ("00000" + (0 | a).toString(16)).substr(-
6),
e.fillRect(r.x, r.y, r.width, r.height)),
o.lineWidth && (e.globalAlpha = o.lineAlpha * i,
e.strokeStyle = "#" + ("00000" + (0 | h).toString(16)).substr(-
6),
e.strokeRect(r.x, r.y, r.width, r.height));
else if (o.type === s.CIRCLE)
e.beginPath(),
e.arc(r.x, r.y, r.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 | h).toString(16)).substr(-
6),
e.stroke());
else if (o.type === s.ELLIPSE) {
var u = 2 * r.width
, d = 2 * r.height
, p = r.x - u / 2
, f = r.y - d / 2;
e.beginPath();
var m = .5522848
, g = u / 2 * m
, y = d / 2 * m
, v = p + u
, b = f + d
, w = p + u / 2
, x = f + d / 2;
e.moveTo(p, x),
e.bezierCurveTo(p, x - y, w - g, f, w, f),
e.bezierCurveTo(w + g, f, v, x - y, v, x),
e.bezierCurveTo(v, x + y, w + g, b, w, b),
e.bezierCurveTo(w - g, b, p, x + y, p, 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 | h).toString(16)).substr(-
6),
e.stroke())
} else if (o.type === s.ROUNDEDRECTANGLE) {
var _ = r.x
, P = r.y
, T = r.width
, C = r.height
, S = r.radius
, A = Math.min(T, C) / 2 | 0;
S = S > A ? A : S,
e.beginPath(),
e.moveTo(_, P + S),
e.lineTo(_, P + C - S),
e.quadraticCurveTo(_, P + C, _ + S, P + C),
e.lineTo(_ + T - S, P + C),
e.quadraticCurveTo(_ + T, P + C, _ + T, P + C - S),
e.lineTo(_ + T, P + S),
e.quadraticCurveTo(_ + T, P, _ + T - S, P),
e.lineTo(_ + S, P),
e.quadraticCurveTo(_, P, _, P + S),
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 | h).toString(16)).substr(-
6),
e.stroke())
}
}
}
,
PIXI.CanvasGraphics.renderGraphicsMask = function(t, e) {
var i = t.graphicsData.length;
if (0 !== i) {
e.beginPath();
for (var n = 0; n < i; n++) {
var o = t.graphicsData[n]
, r = o.shape;
if (o.type === s.POLYGON) {
var a = r.points;
e.moveTo(a[0], a[1]);
for (var h = 1; h < a.length / 2; h++)
e.lineTo(a[2 * h], a[2 * h + 1]);
a[0] === a[a.length - 2] && a[1] === a[a.length - 1] &&
e.closePath()
} else if (o.type === s.RECTANGLE)
e.rect(r.x, r.y, r.width, r.height),
e.closePath();
else if (o.type === s.CIRCLE)
e.arc(r.x, r.y, r.radius, 0, 2 * Math.PI),
e.closePath();
else if (o.type === s.ELLIPSE) {
var l = 2 * r.width
, c = 2 * r.height
, u = r.x - l / 2
, d = r.y - c / 2
, p = .5522848
, f = l / 2 * p
, m = c / 2 * p
, g = u + l
, y = d + c
, v = u + l / 2
, b = d + c / 2;
e.moveTo(u, b),
e.bezierCurveTo(u, b - m, v - f, d, v, d),
e.bezierCurveTo(v + f, d, g, b - m, g, b),
e.bezierCurveTo(g, b + m, v + f, y, v, y),
e.bezierCurveTo(v - f, y, u, b + m, u, b),
e.closePath()
} else if (o.type === s.ROUNDEDRECTANGLE) {
var w = r.x
, x = r.y
, _ = r.width
, P = r.height
, T = r.radius
, C = Math.min(_, P) / 2 | 0;
T = T > C ? C : T,
e.moveTo(w, x + T),
e.lineTo(w, x + P - T),
e.quadraticCurveTo(w, x + P, w + T, x + P),
e.lineTo(w + _ - T, x + P),
e.quadraticCurveTo(w + _, x + P, w + _, x + P - T),
e.lineTo(w + _, x + T),
e.quadraticCurveTo(w + _, x, w + _ - T, x),
e.lineTo(w + T, x),
e.quadraticCurveTo(w, x, w, x + T),
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, n = (255 & t.tint) / 255, s = 0; s < t.graphicsData.length; s++) {
var o = t.graphicsData[s]
, r = 0 | o.fillColor
, a = 0 | o.lineColor;
o._fillTint = ((r >> 16 & 255) / 255 * e * 255 << 16) + ((r >>
8 & 255) / 255 * i * 255 << 8) + (255 & r) / 255 * n * 255,
o._lineTint = ((a >> 16 & 255) / 255 * e * 255 << 16) + ((a >>
8 & 255) / 255 * i * 255 << 8) + (255 & a) / 255 * n * 255
}
}
,
s.GraphicsData = function(t, e, i, n, s, o, r) {
this.lineWidth = t,
this.lineColor = e,
this.lineAlpha = i,
this._lineTint = e,
this.fillColor = n,
this.fillAlpha = s,
this._fillTint = n,
this.fill = o,
this.shape = r,
this.type = r.type
}
,
s.GraphicsData.prototype.constructor = s.GraphicsData,
s.GraphicsData.prototype.clone = function() {
return new
s.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fil
lAlpha,this.fill,this.shape)
}
,
s.Graphics = function(t, e, i) {
void 0 === e && (e = 0),
void 0 === i && (i = 0),
this.type = s.GRAPHICS,
this.physicsType = s.SPRITE,
this.anchor = new s.Point,
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 s.Rectangle(0,0,1,1),
this.dirty = !0,
this._boundsDirty = !1,
this.webGLDirty = !1,
this.cachedSpriteDirty = !1,
s.Component.Core.init.call(this, t, e, i, "", null)
}
,
s.Graphics.prototype =
Object.create(PIXI.DisplayObjectContainer.prototype),
s.Graphics.prototype.constructor = s.Graphics,
s.Component.Core.install.call(s.Graphics.prototype, ["Angle", "AutoCull",
"Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan",
"PhysicsBody", "Reset"]),
s.Graphics.prototype.preUpdatePhysics = s.Component.PhysicsBody.preUpdate,
s.Graphics.prototype.preUpdateLifeSpan = s.Component.LifeSpan.preUpdate,
s.Graphics.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.Graphics.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.Graphics.prototype.preUpdate = function() {
return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() &&
this.preUpdateInWorld()) && this.preUpdateCore()
}
,
s.Graphics.prototype.postUpdate = function() {
s.Component.PhysicsBody.postUpdate.call(this),
s.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()
}
,
s.Graphics.prototype.destroy = function(t) {
this.clear(),
s.Component.Destroy.prototype.destroy.call(this, t)
}
,
s.Graphics.prototype.drawTriangle = function(t, e) {
void 0 === e && (e = !1);
var i = new s.Polygon(t);
if (e) {
var n = new s.Point(this.game.camera.x - t[0].x,this.game.camera.y
- t[0].y)
, o = new s.Point(t[1].x - t[0].x,t[1].y - t[0].y)
, r = new s.Point(t[1].x - t[2].x,t[1].y - t[2].y)
, a = r.cross(o);
n.dot(a) > 0 && this.drawPolygon(i)
} else
this.drawPolygon(i)
}
,
s.Graphics.prototype.drawTriangles = function(t, e, i) {
void 0 === i && (i = !1);
var n, o = new s.Point, r = new s.Point, a = new s.Point, h = [];
if (e)
if (t[0]instanceof s.Point)
for (n = 0; n < e.length / 3; n++)
h.push(t[e[3 * n]]),
h.push(t[e[3 * n + 1]]),
h.push(t[e[3 * n + 2]]),
3 === h.length && (this.drawTriangle(h, i),
h = []);
else
for (n = 0; n < e.length; n++)
o.x = t[2 * e[n]],
o.y = t[2 * e[n] + 1],
h.push(o.copyTo({})),
3 === h.length && (this.drawTriangle(h, i),
h = []);
else if (t[0]instanceof s.Point)
for (n = 0; n < t.length / 3; n++)
this.drawTriangle([t[3 * n], t[3 * n + 1], t[3 * n + 2]], i);
else
for (n = 0; n < t.length / 6; n++)
o.x = t[6 * n + 0],
o.y = t[6 * n + 1],
r.x = t[6 * n + 2],
r.y = t[6 * n + 3],
a.x = t[6 * n + 4],
a.y = t[6 * n + 5],
this.drawTriangle([o, r, a], i)
}
,
s.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 s.Polygon(this.currentPath.shape.points.slice(-2))) :
(this.currentPath.lineWidth = this.lineWidth,
this.currentPath.lineColor = this.lineColor,
this.currentPath.lineAlpha = this.lineAlpha)),
this
}
,
s.Graphics.prototype.moveTo = function(t, e) {
return this.drawShape(new s.Polygon([t, e])),
this
}
,
s.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
}
,
s.Graphics.prototype.quadraticCurveTo = function(t, e, i, n) {
this.currentPath ? 0 === this.currentPath.shape.points.length &&
(this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
var s, o, r = 20, a = this.currentPath.shape.points;
0 === a.length && this.moveTo(0, 0);
for (var h = a[a.length - 2], l = a[a.length - 1], c = 0, u = 1; u <=
r; ++u)
c = u / r,
s = h + (t - h) * c,
o = l + (e - l) * c,
a.push(s + (t + (i - t) * c - s) * c, o + (e + (n - e) * c - o) *
c);
return this.dirty = !0,
this._boundsDirty = !0,
this
}
,
s.Graphics.prototype.bezierCurveTo = function(t, e, i, n, s, o) {
this.currentPath ? 0 === this.currentPath.shape.points.length &&
(this.currentPath.shape.points = [0, 0]) : this.moveTo(0, 0);
for (var r, a, h, l, c, u = 20, d = this.currentPath.shape.points, p =
d[d.length - 2], f = d[d.length - 1], m = 0, g = 1; g <= u; ++g)
m = g / u,
r = 1 - m,
a = r * r,
h = a * r,
l = m * m,
c = l * m,
d.push(h * p + 3 * a * m * t + 3 * r * l * i + c * s, h * f + 3 * a
* m * e + 3 * r * l * n + c * o);
return this.dirty = !0,
this._boundsDirty = !0,
this
}
,
s.Graphics.prototype.arcTo = function(t, e, i, n, s) {
this.currentPath ? 0 === this.currentPath.shape.points.length &&
this.currentPath.shape.points.push(t, e) : this.moveTo(t, e);
var o = this.currentPath.shape.points
, r = o[o.length - 2]
, a = o[o.length - 1]
, h = a - e
, l = r - t
, c = n - e
, u = i - t
, d = Math.abs(h * u - l * c);
if (d < 1e-8 || 0 === s)
o[o.length - 2] === t && o[o.length - 1] === e || o.push(t, e);
else {
var p = h * h + l * l
, f = c * c + u * u
, m = h * c + l * u
, g = s * Math.sqrt(p) / d
, y = s * Math.sqrt(f) / d
, v = g * m / p
, b = y * m / f
, w = g * u + y * l
, x = g * c + y * h
, _ = l * (y + v)
, P = h * (y + v)
, T = u * (g + b)
, C = c * (g + b)
, S = Math.atan2(P - x, _ - w)
, A = Math.atan2(C - x, T - w);
this.arc(w + t, x + e, s, S, A, l * c > u * h)
}
return this.dirty = !0,
this._boundsDirty = !0,
this
}
,
s.Graphics.prototype.arc = function(t, e, i, n, s, o, r) {
if (n === s)
return this;
void 0 === o && (o = !1),
void 0 === r && (r = 40),
!o && s <= n ? s += 2 * Math.PI : o && n <= s && (n += 2 * Math.PI);
var a = o ? -1 * (n - s) : s - n
, h = Math.ceil(Math.abs(a) / (2 * Math.PI)) * r;
if (0 === a)
return this;
var l = t + Math.cos(n) * i
, c = e + Math.sin(n) * i;
o && this.filling ? this.moveTo(t, e) : this.moveTo(l, c);
for (var u = this.currentPath.shape.points, d = a / (2 * h), p = 2 * d,
f = Math.cos(d), m = Math.sin(d), g = h - 1, y = g % 1 / g, v = 0; v <= g; v++) {
var b = v + y * v
, w = d + n + p * b
, x = Math.cos(w)
, _ = -Math.sin(w);
u.push((f * x + m * _) * i + t, (f * -_ + m * x) * i + e)
}
return this.dirty = !0,
this._boundsDirty = !0,
this
}
,
s.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
}
,
s.Graphics.prototype.endFill = function() {
return this.filling = !1,
this.fillColor = null,
this.fillAlpha = 1,
this
}
,
s.Graphics.prototype.drawRect = function(t, e, i, n) {
return this.drawShape(new s.Rectangle(t,e,i,n)),
this
}
,
s.Graphics.prototype.drawRoundedRect = function(t, e, i, n, o) {
return this.drawShape(new s.RoundedRectangle(t,e,i,n,o)),
this
}
,
s.Graphics.prototype.drawCircle = function(t, e, i) {
return this.drawShape(new s.Circle(t,e,i)),
this
}
,
s.Graphics.prototype.drawEllipse = function(t, e, i, n) {
return this.drawShape(new s.Ellipse(t,e,i,n)),
this
}
,
s.Graphics.prototype.drawPolygon = function(t) {
t instanceof s.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 s.Polygon(e)),
this
}
,
s.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
}
,
s.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 n = this.getBounds();
n.width += i,
n.height += i;
var s = new PIXI.CanvasBuffer(n.width * t,n.height * t)
, o = PIXI.Texture.fromCanvas(s.canvas, e);
return o.baseTexture.resolution = t,
s.context.scale(t, t),
s.context.translate(-n.x, -n.y),
PIXI.CanvasGraphics.renderGraphics(this, s.context),
o
}
,
s.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()
}
}
,
s.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 n = t.resolution
, s = i.tx * t.resolution + t.shakeX
, o = i.ty * t.resolution + t.shakeY;
e.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, s, o),
PIXI.CanvasGraphics.renderGraphics(this, e);
for (var r = 0; r < this.children.length; r++)
this.children[r]._renderCanvas(t);
this._mask && t.maskManager.popMask(t)
}
}
,
s.Graphics.prototype.getBounds = function(t) {
if (this._currentBounds)
return this._currentBounds;
if (!this.renderable)
return s.EmptyRectangle;
this.dirty && (this.updateLocalBounds(),
this.webGLDirty = !0,
this.cachedSpriteDirty = !0,
this.dirty = !1);
var e = this._localBounds
, i = e.x
, n = e.width + e.x
, o = e.y
, r = e.height + e.y
, a = t || this.worldTransform
, h = a.a
, l = a.b
, c = a.c
, u = a.d
, d = a.tx
, p = a.ty
, f = h * n + c * r + d
, m = u * r + l * n + p
, g = h * i + c * r + d
, y = u * r + l * i + p
, v = h * i + c * o + d
, b = u * o + l * i + p
, w = h * n + c * o + d
, x = u * o + l * n + p
, _ = f
, P = m
, T = f
, C = m;
return T = g < T ? g : T,
T = v < T ? v : T,
T = w < T ? w : T,
C = y < C ? y : C,
C = b < C ? b : C,
C = x < C ? x : C,
_ = g > _ ? g : _,
_ = v > _ ? v : _,
_ = w > _ ? w : _,
P = y > P ? y : P,
P = b > P ? b : P,
P = x > P ? x : P,
this._bounds.x = T,
this._bounds.width = _ - T,
this._bounds.y = C,
this._bounds.height = P - C,
this._currentBounds = this._bounds,
this._currentBounds
}
,
s.Graphics.prototype.getLocalBounds = function() {
var t = this.worldTransform;
this.worldTransform = s.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
}
,
s.Graphics.prototype.containsPoint = function(t, e) {
void 0 === e && (e = new s.Point),
this.worldTransform.applyInverse(t, e);
for (var i = this.graphicsData, n = 0; n < i.length; n++) {
var o = i[n];
if (o.fill && (o.shape && o.shape.contains(e.x, e.y)))
return !0
}
return !1
}
,
s.Graphics.prototype.updateLocalBounds = function() {
var t = 1 / 0
, e = -1 / 0
, i = 1 / 0
, n = -1 / 0;
if (this.graphicsData.length)
for (var o, r, a, h, l, c, u = 0; u < this.graphicsData.length; u+
+) {
var d = this.graphicsData[u]
, p = d.type
, f = d.lineWidth;
if (o = d.shape,
p === s.RECTANGLE || p === s.ROUNDEDRECTANGLE)
a = o.x - f / 2,
h = o.y - f / 2,
l = o.width + f,
c = o.height + f,
t = a < t ? a : t,
e = a + l > e ? a + l : e,
i = h < i ? h : i,
n = h + c > n ? h + c : n;
else if (p === s.CIRCLE)
a = o.x,
h = o.y,
l = o.radius + f / 2,
c = o.radius + f / 2,
t = a - l < t ? a - l : t,
e = a + l > e ? a + l : e,
i = h - c < i ? h - c : i,
n = h + c > n ? h + c : n;
else if (p === s.ELLIPSE)
a = o.x,
h = o.y,
l = o.width + f / 2,
c = o.height + f / 2,
t = a - l < t ? a - l : t,
e = a + l > e ? a + l : e,
i = h - c < i ? h - c : i,
n = h + c > n ? h + c : n;
else {
r = o.points;
for (var m = 0; m < r.length; m++)
r[m]instanceof s.Point ? (a = r[m].x,
h = r[m].y) : (a = r[m],
h = r[m + 1],
m < r.length - 1 && m++),
t = a - f < t ? a - f : t,
e = a + f > e ? a + f : e,
i = h - f < i ? h - f : i,
n = h + f > n ? h + f : n
}
}
else
t = 0,
e = 0,
i = 0,
n = 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 = n - i + 2 * g
}
,
s.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
}
,
s.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()
}
,
s.Graphics.prototype.destroyCachedSprite = function() {
this._cachedSprite.texture.destroy(!0),
this._cachedSprite = null
}
,
s.Graphics.prototype.drawShape = function(t) {
this.currentPath && this.currentPath.shape.points.length <= 2 &&
this.graphicsData.pop(),
this.currentPath = null,
t instanceof s.Polygon && (t = t.clone(),
t.flatten());
var e = new
s.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fil
lAlpha,this.filling,t);
return this.graphicsData.push(e),
e.type === s.POLYGON && (e.shape.closed = this.filling,
this.currentPath = e),
this.dirty = !0,
this._boundsDirty = !0,
e
}
,
Object.defineProperty(s.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
}
}),
s.RenderTexture = function(t, e, i, n, o, r, a, h) {
if (void 0 === e && (e = 100),
void 0 === i && (i = 100),
void 0 === n && (n = ""),
void 0 === o && (o = s.scaleModes.DEFAULT),
void 0 === r && (r = 1),
void 0 === a && (a = PIXI.defaultRenderer),
void 0 === h && (h = 0),
this.game = t,
this.key = n,
this.type = s.RENDERTEXTURE,
this._tempMatrix = new s.Matrix,
this.width = e,
this.height = i,
this.resolution = r,
this.frame = new s.Rectangle(0,0,this.width *
this.resolution,this.height * this.resolution),
this.crop = this.frame.clone(),
this.baseTexture = new PIXI.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 = o,
this.baseTexture.hasLoaded = !0,
PIXI.Texture.call(this, this.baseTexture, this.frame.clone()),
this.renderer = a,
this.renderer.type === s.WEBGL) {
var l = this.renderer.gl;
this.baseTexture.textureIndex = h,
this.baseTexture._dirty[l.id] = !1,
this.textureBuffer = new
PIXI.FilterTexture(l,this.width,this.height,this.baseTexture.scaleMode,h),
this.baseTexture._glTextures[l.id] = this.textureBuffer.texture,
this.projection = new s.Point(.5 * this.width,.5 * -this.height)
} else
this.textureBuffer = new PIXI.CanvasBuffer(this.width *
this.resolution,this.height * this.resolution),
this.baseTexture.source = this.textureBuffer.canvas;
this.valid = !0,
this.tempMatrix = new s.Matrix,
this._updateUvs()
}
,
s.RenderTexture.prototype = Object.create(PIXI.Texture.prototype),
s.RenderTexture.prototype.constructor = s.RenderTexture,
s.RenderTexture.prototype.renderXY = function(t, e, i, n) {
t.updateTransform(),
this._tempMatrix.copyFrom(t.worldTransform),
this._tempMatrix.tx = e,
this._tempMatrix.ty = i,
this.renderer.type === s.WEBGL ? this._renderWebGL(t, this._tempMatrix,
n) : this._renderCanvas(t, this._tempMatrix, n)
}
,
s.RenderTexture.prototype.renderRawXY = function(t, e, i, n) {
this._tempMatrix.identity().translate(e, i),
this.renderer.type === s.WEBGL ? this._renderWebGL(t, this._tempMatrix,
n) : this._renderCanvas(t, this._tempMatrix, n)
}
,
s.RenderTexture.prototype.render = function(t, e, i) {
void 0 === e || null === e ?
this._tempMatrix.copyFrom(t.worldTransform) : this._tempMatrix.copyFrom(e),
this.renderer.type === s.WEBGL ? this._renderWebGL(t, this._tempMatrix,
i) : this._renderCanvas(t, this._tempMatrix, i)
}
,
s.RenderTexture.prototype.resize = function(t, e, i) {
t === this.width && e === this.height || (this.valid = t > 0 && e > 0,
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 === s.WEBGL && (this.projection.x = this.width / 2,
this.projection.y = -this.height / 2),
this.valid && this.textureBuffer.resize(this.width, this.height))
}
,
s.RenderTexture.prototype.clear = function() {
this.valid && (this.renderer.type === s.WEBGL &&
this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,
this.textureBuffer.frameBuffer),
this.textureBuffer.clear())
}
,
s.RenderTexture.prototype._renderWebGL = function(t, e, i) {
if (this.valid && 0 !== t.alpha) {
var n = t.worldTransform;
n.identity(),
n.translate(0, 2 * this.projection.y),
e && n.append(e),
n.scale(1, -1);
for (var s = 0; s < t.children.length; s++)
t.children[s].updateTransform();
var o = this.renderer.gl;
o.viewport(0, 0, this.width * this.resolution, this.height *
this.resolution),
o.bindFramebuffer(o.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,
o.bindFramebuffer(o.FRAMEBUFFER, null)
}
}
,
s.RenderTexture.prototype._renderCanvas = function(t, e, i) {
if (this.valid && 0 !== t.alpha) {
var n = t.worldTransform;
n.identity(),
e && n.append(e);
for (var s = 0; s < t.children.length; s++)
t.children[s].updateTransform();
i && this.textureBuffer.clear();
var o = this.renderer.resolution;
this.renderer.resolution = this.resolution,
this.renderer.renderDisplayObject(t, this.textureBuffer.context,
e),
this.renderer.resolution = o
}
}
,
s.RenderTexture.prototype.getImage = function() {
var t = new Image;
return t.src = this.getBase64(),
t
}
,
s.RenderTexture.prototype.getBase64 = function() {
return this.getCanvas().toDataURL()
}
,
s.RenderTexture.prototype.getCanvas = function() {
if (this.renderer.type === s.WEBGL) {
var t = this.renderer.gl
, e = this.textureBuffer.width
, i = this.textureBuffer.height
, n = new Uint8Array(4 * e * i);
t.bindFramebuffer(t.FRAMEBUFFER, this.textureBuffer.frameBuffer),
t.readPixels(0, 0, e, i, t.RGBA, t.UNSIGNED_BYTE, n),
t.bindFramebuffer(t.FRAMEBUFFER, null);
var o = new PIXI.CanvasBuffer(e,i)
, r = o.context.getImageData(0, 0, e, i);
return r.data.set(n),
o.context.putImageData(r, 0, 0),
o.canvas
}
return this.textureBuffer.canvas
}
,
s.Text = function(t, e, i, n, o) {
e = e || 0,
i = i || 0,
n = void 0 === n || null === n ? "" : n.toString(),
o = s.Utils.extend({}, o),
this.type = s.TEXT,
this.physicsType = s.SPRITE,
this.padding = new s.Point,
this.textBounds = null,
this.canvas = s.CanvasPool.create(this),
this.context = this.canvas.getContext("2d"),
this.colors = [],
this.strokeColors = [],
this.fontStyles = [],
this.fontWeights = [],
this.autoRound = !1,
this.useAdvancedWrap = !1,
this.splitRegExp = /(?:\r\n|\r|\n)/,
this.characterLimitSize = -1,
this.characterLimitSuffix = "",
this._res = t.renderer.resolution,
this._text = n,
this._fontComponents = null,
this._lineSpacing = 0,
this._charCount = 0,
this._width = 0,
this._height = 0,
s.Sprite.call(this, t, e, i, PIXI.Texture.fromCanvas(this.canvas)),
this.setStyle(o),
"" !== n && this.updateText()
}
,
s.Text.prototype = Object.create(s.Sprite.prototype),
s.Text.prototype.constructor = s.Text,
s.Text.prototype.preUpdate = function() {
return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() &&
this.preUpdateInWorld()) && this.preUpdateCore()
}
,
s.Text.prototype.update = function() {}
,
s.Text.prototype.destroy = function(t) {
this.texture.destroy(!0),
s.Component.Destroy.prototype.destroy.call(this, t)
}
,
s.Text.prototype.setShadow = function(t, e, i, n, s, o) {
return void 0 === t && (t = 0),
void 0 === e && (e = 0),
void 0 === i && (i = "rgba(0, 0, 0, 1)"),
void 0 === n && (n = 0),
void 0 === s && (s = !0),
void 0 === o && (o = !0),
this.style.shadowOffsetX = t,
this.style.shadowOffsetY = e,
this.style.shadowColor = i,
this.style.shadowBlur = n,
this.style.shadowStroke = s,
this.style.shadowFill = o,
this.dirty = !0,
this
}
,
s.Text.prototype.setStyle = function(t, e) {
void 0 === e && (e = !1),
t = 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
}
,
s.Text.prototype.updateText = function() {
this.texture.baseTexture.resolution = this._res,
this.context.font = this.style.font;
var t = this.text;
this.characterLimitSize > -1 && this.characterLimitSize < t.length &&
(t = this.text.substring(0, this.characterLimitSize) + this.characterLimitSuffix),
this.style.wordWrap && (t = this.runWordWrap(this.text));
var e = t.split(this.splitRegExp)
, i = this.style.tabs
, n = []
, s = 0
, o = this.determineFontProperties(this.style.font)
, r = e.length;
this.style.maxLines > 0 && this.style.maxLines < e.length && (r =
this.style.maxLines),
this._charCount = 0;
for (var a = 0; a < r; a++) {
if (0 === i) {
var h = this.style.strokeThickness + this.padding.x;
this.colors.length > 0 || this.strokeColors.length > 0 ||
this.fontWeights.length > 0 || this.fontStyles.length > 0 ? h +=
this.measureLine(e[a]) : h += this.context.measureText(e[a]).width,
this.style.wordWrap && (h -= this.context.measureText("
").width)
} else {
var l = e[a].split(/(?:\t)/)
, h = this.padding.x + this.style.strokeThickness;
if (Array.isArray(i))
for (var c = 0, u = 0; u < l.length; u++) {
var d = 0;
d = this.colors.length > 0 || this.strokeColors.length
> 0 || this.fontWeights.length > 0 || this.fontStyles.length > 0 ?
this.measureLine(l[u]) : Math.ceil(this.context.measureText(l[u]).width),
u > 0 && (c += i[u - 1]),
h = c + d
}
else
for (var u = 0; u < l.length; u++) {
this.colors.length > 0 || this.strokeColors.length > 0
|| this.fontWeights.length > 0 || this.fontStyles.length > 0 ? h +=
this.measureLine(l[u]) : h += Math.ceil(this.context.measureText(l[u]).width);
var p = this.game.math.snapToCeil(h, i) - h;
h += p
}
}
n[a] = Math.ceil(h),
s = Math.max(s, n[a])
}
this.canvas.width = s * this._res;
var f = o.fontSize + this.style.strokeThickness + this.padding.y
, m = f * r
, g = this._lineSpacing;
g < 0 && Math.abs(g) > f && (g = -f),
0 !== g && (m += g > 0 ? g * e.length : g * (e.length - 1)),
this.canvas.height = m * 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";
var y, v;
for (this._charCount = 0,
a = 0; a < r; a++)
y = this.style.strokeThickness / 2,
v = this.style.strokeThickness / 2 + a * f + o.ascent,
a > 0 && (v += g * a),
"right" === this.style.align ? y += s - n[a] : "center" ===
this.style.align && (y += (s - n[a]) / 2),
this.autoRound && (y = Math.round(y),
v = Math.round(v)),
this.colors.length > 0 || this.strokeColors.length > 0 ||
this.fontWeights.length > 0 || this.fontStyles.length > 0 ? this.updateLine(e[a],
y, v) : (this.style.stroke && this.style.strokeThickness &&
(this.updateShadow(this.style.shadowStroke),
0 === i ? this.context.strokeText(e[a], y, v) :
this.renderTabLine(e[a], y, v, !1)),
this.style.fill && (this.updateShadow(this.style.shadowFill),
0 === i ? this.context.fillText(e[a], y, v) :
this.renderTabLine(e[a], y, v, !0)));
this.updateTexture(),
this.dirty = !1
}
,
s.Text.prototype.renderTabLine = function(t, e, i, n) {
var s = t.split(/(?:\t)/)
, o = this.style.tabs
, r = 0;
if (Array.isArray(o))
for (var a = 0, h = 0; h < s.length; h++)
h > 0 && (a += o[h - 1]),
r = e + a,
n ? this.context.fillText(s[h], r, i) :
this.context.strokeText(s[h], r, i);
else
for (var h = 0; h < s.length; h++) {
var l = Math.ceil(this.context.measureText(s[h]).width);
r = this.game.math.snapToCeil(e, o),
n ? this.context.fillText(s[h], r, i) :
this.context.strokeText(s[h], r, i),
e = r + l
}
}
,
s.Text.prototype.updateShadow = function(t) {
t ? (this.context.shadowOffsetX = this.style.shadowOffsetX,
this.context.shadowOffsetY = this.style.shadowOffsetY,
this.context.shadowColor = this.style.shadowColor,
this.context.shadowBlur = this.style.shadowBlur) :
(this.context.shadowOffsetX = 0,
this.context.shadowOffsetY = 0,
this.context.shadowColor = 0,
this.context.shadowBlur = 0)
}
,
s.Text.prototype.measureLine = function(t) {
for (var e = 0, i = 0; i < t.length; i++) {
var n = t[i];
if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
var s = this.fontToComponents(this.context.font);
this.fontStyles[this._charCount] && (s.fontStyle =
this.fontStyles[this._charCount]),
this.fontWeights[this._charCount] && (s.fontWeight =
this.fontWeights[this._charCount]),
this.context.font = this.componentsToFont(s)
}
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(n).width,
this._charCount++
}
return Math.ceil(e)
}
,
s.Text.prototype.updateLine = function(t, e, i) {
for (var n = 0; n < t.length; n++) {
var s = t[n];
if (this.fontWeights.length > 0 || this.fontStyles.length > 0) {
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.context.strokeText(s, e, i)),
this.style.fill && (this.colors[this._charCount] &&
(this.context.fillStyle = this.colors[this._charCount]),
this.updateShadow(this.style.shadowFill),
this.context.fillText(s, e, i)),
e += this.context.measureText(s).width,
this._charCount++
}
}
,
s.Text.prototype.clearColors = function() {
return this.colors = [],
this.strokeColors = [],
this.dirty = !0,
this
}
,
s.Text.prototype.clearFontValues = function() {
return this.fontStyles = [],
this.fontWeights = [],
this.dirty = !0,
this
}
,
s.Text.prototype.addColor = function(t, e) {
return this.colors[e] = t,
this.dirty = !0,
this
}
,
s.Text.prototype.addStrokeColor = function(t, e) {
return this.strokeColors[e] = t,
this.dirty = !0,
this
}
,
s.Text.prototype.addFontStyle = function(t, e) {
return this.fontStyles[e] = t,
this.dirty = !0,
this
}
,
s.Text.prototype.addFontWeight = function(t, e) {
return this.fontWeights[e] = t,
this.dirty = !0,
this
}
,
s.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)/)
}
,
s.Text.prototype.runWordWrap = function(t) {
return this.useAdvancedWrap ? this.advancedWordWrap(t) :
this.basicWordWrap(t)
}
,
s.Text.prototype.advancedWordWrap = function(t) {
for (var e = this.context, i = this.style.wordWrapWidth, n = "", s =
t.replace(/ +/gi, " ").split(/\r?\n/gi), o = s.length, r = 0; r < o; r++) {
var a = s[r]
, h = "";
a = a.replace(/^ *|\s*$/gi, "");
if (e.measureText(a).width < i)
n += a + "\n";
else {
for (var l = i, c = a.split(" "), u = 0; u < c.length; u++) {
var d = c[u]
, p = d + " "
, f = e.measureText(p).width;
if (f > l) {
if (0 === u) {
for (var m = p; m.length && (m = m.slice(0, -1),
!((f = e.measureText(m).width) <= l)); )
;
if (!m.length)
throw new Error("This text's wordWrapWidth
setting is less than a single character!");
var g = d.substr(m.length);
c[u] = g,
h += m
}
var y = c[u].length ? u : u + 1
, v = c.slice(y).join(" ").replace(/[ \n]*$/gi, "");
s[r + 1] = v + " " + (s[r + 1] || ""),
o = s.length;
break
}
h += p,
l -= f
}
n += h.replace(/[ \n]*$/gi, "") + "\n"
}
}
return n = n.replace(/[\s|\n]*$/gi, "")
}
,
s.Text.prototype.basicWordWrap = function(t) {
for (var e = "", i = t.split("\n"), n = 0; n < i.length; n++) {
for (var s = this.style.wordWrapWidth, o = i[n].split(" "), r = 0;
r < o.length; r++) {
var a = this.context.measureText(o[r]).width
, h = a + this.context.measureText(" ").width;
h > s ? (r > 0 && (e += "\n"),
e += o[r] + " ",
s = this.style.wordWrapWidth - a) : (s -= h,
e += o[r] + " ")
}
n < i.length - 1 && (e += "\n")
}
return e
}
,
s.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())
}
,
s.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 console.warn("Phaser.Text - unparsable CSS font: " + t),
{
font: t
}
}
,
s.Text.prototype.componentsToFont = function(t) {
var e, i = [];
return e = t.fontStyle,
e && "normal" !== e && i.push(e),
e = t.fontVariant,
e && "normal" !== e && i.push(e),
e = t.fontWeight,
e && "normal" !== e && i.push(e),
e = t.fontSize,
e && "medium" !== e && i.push(e),
e = t.fontFamily,
e && i.push(e),
i.length || i.push(t.font),
i.join(" ")
}
,
s.Text.prototype.setText = function(t, e) {
return void 0 === e && (e = !1),
this.text = t.toString() || "",
e ? this.updateText() : this.dirty = !0,
this
}
,
s.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
}
,
s.Text.prototype.setTextBounds = function(t, e, i, n) {
return void 0 === t ? this.textBounds = null : (this.textBounds ?
this.textBounds.setTo(t, e, i, n) : this.textBounds = new s.Rectangle(t,e,i,n),
this.style.wordWrapWidth > i && (this.style.wordWrapWidth = i)),
this.updateTexture(),
this
}
,
s.Text.prototype.updateTexture = function() {
var t = this.texture.baseTexture
, e = this.texture.crop
, i = this.texture.frame
, n = this.canvas.width
, s = this.canvas.height;
if (t.width = n,
t.height = s,
e.width = n,
e.height = s,
i.width = n,
i.height = s,
this.texture.width = n,
this.texture.height = s,
this._width = n,
this._height = s,
this.textBounds) {
var o = this.textBounds.x
, r = this.textBounds.y;
"right" === this.style.boundsAlignH ? o += this.textBounds.width -
this.canvas.width / this.resolution : "center" === this.style.boundsAlignH && (o +=
this.textBounds.halfWidth - this.canvas.width / this.resolution / 2),
"bottom" === this.style.boundsAlignV ? r += this.textBounds.height
- this.canvas.height / this.resolution : "middle" === this.style.boundsAlignV && (r
+= this.textBounds.halfHeight - this.canvas.height / this.resolution / 2),
this.pivot.x = -o,
this.pivot.y = -r
}
this.renderable = 0 !== n && 0 !== s,
this.texture.requiresReTint = !0,
this.texture.baseTexture.dirty()
}
,
s.Text.prototype._renderWebGL = function(t) {
this.dirty && (this.updateText(),
this.dirty = !1),
PIXI.Sprite.prototype._renderWebGL.call(this, t)
}
,
s.Text.prototype._renderCanvas = function(t) {
this.dirty && (this.updateText(),
this.dirty = !1),
PIXI.Sprite.prototype._renderCanvas.call(this, t)
}
,
s.Text.prototype.determineFontProperties = function(t) {
var e = s.Text.fontPropertiesCache[t];
if (!e) {
e = {};
var i = s.Text.fontPropertiesCanvas
, n = s.Text.fontPropertiesContext;
n.font = t;
var o = Math.ceil(n.measureText("|MEq").width)
, r = Math.ceil(n.measureText("|MEq").width)
, a = 2 * r;
if (r = 1.4 * r | 0,
i.width = o,
i.height = a,
n.fillStyle = "#f00",
n.fillRect(0, 0, o, a),
n.font = t,
n.textBaseline = "alphabetic",
n.fillStyle = "#000",
n.fillText("|MEq", 0, r),
!n.getImageData(0, 0, o, a))
return e.ascent = r,
e.descent = r + 6,
e.fontSize = e.ascent + e.descent,
s.Text.fontPropertiesCache[t] = e,
e;
var h, l, c = n.getImageData(0, 0, o, a).data, u = c.length, d = 4
* o, p = 0, f = !1;
for (h = 0; h < r; h++) {
for (l = 0; l < d; l += 4)
if (255 !== c[p + l]) {
f = !0;
break
}
if (f)
break;
p += d
}
for (e.ascent = r - h,
p = u - d,
f = !1,
h = a; h > r; h--) {
for (l = 0; l < d; l += 4)
if (255 !== c[p + l]) {
f = !0;
break
}
if (f)
break;
p -= d
}
e.descent = h - r,
e.descent += 6,
e.fontSize = e.ascent + e.descent,
s.Text.fontPropertiesCache[t] = e
}
return e
}
,
s.Text.prototype.getBounds = function(t) {
return this.dirty && (this.updateText(),
this.dirty = !1),
PIXI.Sprite.prototype.getBounds.call(this, t)
}
,
s.Text.prototype.setCharacterLimit = function(t, e) {
this.characterLimitSuffix = void 0 === e ? "" : e,
this.characterLimitSize = t,
this.updateText()
}
,
Object.defineProperty(s.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(s.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(s.Text.prototype, "font", {
get: function() {
return this._fontComponents.fontFamily
},
set: function(t) {
t = t || "Arial",
t = t.trim(),
/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(t)
|| /['",]/.exec(t) || (t = "'" + t + "'"),
this._fontComponents.fontFamily = t,
this.updateFont(this._fontComponents)
}
}),
Object.defineProperty(s.Text.prototype, "fontSize", {
get: function() {
var t = this._fontComponents.fontSize;
return t && /(?:^0$|px$)/.exec(t) ? parseInt(t, 10) : t
},
set: function(t) {
t = t || "0",
"number" == typeof t && (t += "px"),
this._fontComponents.fontSize = t,
this.updateFont(this._fontComponents)
}
}),
Object.defineProperty(s.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(s.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(s.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(s.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(s.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(s.Text.prototype, "resolution", {
get: function() {
return this._res
},
set: function(t) {
t !== this._res && (this._res = t,
this.dirty = !0)
}
}),
Object.defineProperty(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.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(s.Text.prototype, "width", {
get: function() {
return this.dirty && (this.updateText(),
this.dirty = !1),
this.scale.x * (this.texture.frame.width / this.resolution)
},
set: function(t) {
this.scale.x = t / this.texture.frame.width,
this._width = t
}
}),
Object.defineProperty(s.Text.prototype, "height", {
get: function() {
return this.dirty && (this.updateText(),
this.dirty = !1),
this.scale.y * (this.texture.frame.height / this.resolution)
},
set: function(t) {
this.scale.y = t / this.texture.frame.height,
this._height = t
}
}),
s.Text.fontPropertiesCache = {},
s.Text.fontPropertiesCanvas = document.createElement("canvas"),
s.Text.fontPropertiesContext =
s.Text.fontPropertiesCanvas.getContext("2d"),
s.BitmapText = function(t, e, i, n, o, r, a) {
e = e || 0,
i = i || 0,
n = n || "",
o = o || "",
r = r || 32,
a = a || "left",
PIXI.DisplayObjectContainer.call(this),
this.type = s.BITMAPTEXT,
this.physicsType = s.SPRITE,
this.textWidth = 0,
this.textHeight = 0,
this.anchor = new s.Point,
this._prevAnchor = new s.Point,
this._glyphs = [],
this._maxWidth = 0,
this._text = o.toString() || "",
this._data = t.cache.getBitmapFont(n),
this._font = n,
this._fontSize = r,
this._align = a,
this._tint = 16777215,
this.updateText(),
this.dirty = !1,
s.Component.Core.init.call(this, t, e, i, "", null)
}
,
s.BitmapText.prototype =
Object.create(PIXI.DisplayObjectContainer.prototype),
s.BitmapText.prototype.constructor = s.BitmapText,
s.Component.Core.install.call(s.BitmapText.prototype, ["Angle", "AutoCull",
"Bounds", "Destroy", "FixedToCamera", "InputEnabled", "InWorld", "LifeSpan",
"PhysicsBody", "Reset"]),
s.BitmapText.prototype.preUpdatePhysics =
s.Component.PhysicsBody.preUpdate,
s.BitmapText.prototype.preUpdateLifeSpan = s.Component.LifeSpan.preUpdate,
s.BitmapText.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.BitmapText.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.BitmapText.prototype.preUpdate = function() {
return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() &&
this.preUpdateInWorld()) && this.preUpdateCore()
}
,
s.BitmapText.prototype.postUpdate = function() {
s.Component.PhysicsBody.postUpdate.call(this),
s.Component.FixedToCamera.postUpdate.call(this),
this.body && this.body.type === s.Physics.ARCADE && (this.textWidth ===
this.body.sourceWidth && this.textHeight === this.body.sourceHeight ||
this.body.setSize(this.textWidth, this.textHeight))
}
,
s.BitmapText.prototype.setText = function(t) {
this.text = t
}
,
s.BitmapText.prototype.scanLine = function(t, e, i) {
for (var n = 0, s = 0, o = -1, r = 0, a = null, h = this._maxWidth >
0 ? this._maxWidth : null, l = [], c = 0; c < i.length; c++) {
var u = c === i.length - 1;
if (/(?:\r\n|\r|\n)/.test(i.charAt(c)))
return {
width: s,
text: i.substr(0, c),
end: u,
chars: l
};
var d = i.charCodeAt(c)
, p = t.chars[d]
, f = 0;
void 0 === p && (d = 32,
p = t.chars[d]);
var m = a && p.kerning[a] ? p.kerning[a] : 0;
if (/(\s)/.test(i.charAt(c)) && (o = c,
r = s),
f = (m + p.texture.width + p.xOffset) * e,
h && s + f >= h && o > -1)
return {
width: r || s,
text: i.substr(0, c - (c - o)),
end: u,
chars: l
};
s += (p.xAdvance + m) * e,
l.push(n + (p.xOffset + m) * e),
n += (p.xAdvance + m) * e,
a = d
}
return {
width: s,
text: i,
end: u,
chars: l
}
}
,
s.BitmapText.prototype.cleanText = function(t, e) {
void 0 === e && (e = "");
var i = this._data.font;
if (!i)
return "";
for (var n = /\r\n|\n\r|\n|\r/g, s = t.replace(n, "\n").split("\n"), o
= 0; o < s.length; o++) {
for (var r = "", a = s[o], h = 0; h < a.length; h++)
r = i.chars[a.charCodeAt(h)] ? r.concat(a[h]) : r.concat(e);
s[o] = r
}
return s.join("\n")
}
,
s.BitmapText.prototype.updateText = function() {
var t = this._data.font;
if (t) {
var e = this.text
, i = this._fontSize / t.size
, n = []
, s = 0;
this.textWidth = 0;
do {
var o = this.scanLine(t, i, e);
o.y = s,
n.push(o),
o.width > this.textWidth && (this.textWidth = o.width),
s += t.lineHeight * i,
e = e.substr(o.text.length + 1)
} while (!1 === o.end);this.textHeight = s;
for (var r = 0, a = 0, h = this.textWidth * this.anchor.x, l =
this.textHeight * this.anchor.y, c = 0; c < n.length; c++) {
var o = n[c];
"right" === this._align ? a = this.textWidth - o.width :
"center" === this._align && (a = (this.textWidth - o.width) / 2);
for (var u = 0; u < o.text.length; u++) {
var d = o.text.charCodeAt(u)
, p = t.chars[d];
void 0 === p && (d = 32,
p = t.chars[d]);
var f = this._glyphs[r];
f ? f.texture = p.texture : (f = new
PIXI.Sprite(p.texture),
f.name = o.text[u],
this._glyphs.push(f)),
f.position.x = o.chars[u] + a - h,
f.position.y = o.y + p.yOffset * i - l,
f.scale.set(i),
f.tint = this.tint,
f.texture.requiresReTint = !0,
f.parent || this.addChild(f),
r++
}
}
for (c = r; c < this._glyphs.length; c++)
this.removeChild(this._glyphs[c])
}
}
,
s.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
}
,
s.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(s.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(s.BitmapText.prototype, "tint", {
get: function() {
return this._tint
},
set: function(t) {
t !== this._tint && (this._tint = t,
this.updateText())
}
}),
Object.defineProperty(s.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(s.BitmapText.prototype, "fontSize", {
get: function() {
return this._fontSize
},
set: function(t) {
(t = parseInt(t, 10)) !== this._fontSize && t > 0 &&
(this._fontSize = t,
this.updateText())
}
}),
Object.defineProperty(s.BitmapText.prototype, "text", {
get: function() {
return this._text
},
set: function(t) {
t !== this._text && (this._text = t.toString() || "",
this.updateText())
}
}),
Object.defineProperty(s.BitmapText.prototype, "maxWidth", {
get: function() {
return this._maxWidth
},
set: function(t) {
t !== this._maxWidth && (this._maxWidth = t,
this.updateText())
}
}),
Object.defineProperty(s.BitmapText.prototype, "smoothed", {
get: function() {
return !this._data.base.scaleMode
},
set: function(t) {
this._data.base.scaleMode = t ? 0 : 1
}
}),
s.RetroFont = function(t, e, i, n, o, r, a, h, l, c) {
if (!t.cache.checkImageKey(e))
return !1;
void 0 !== r && null !== r || (r = t.cache.getImage(e).width / i),
this.characterWidth = i,
this.characterHeight = n,
this.characterSpacingX = a || 0,
this.characterSpacingY = h || 0,
this.characterPerRow = r,
this.offsetX = l || 0,
this.offsetY = c || 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 s.FrameData;
for (var u = this.offsetX, d = this.offsetY, p = 0, f = 0; f <
o.length; f++) {
var m = this.frameData.addFrame(new
s.Frame(f,u,d,this.characterWidth,this.characterHeight));
this.grabData[o.charCodeAt(f)] = m.index,
p++,
p === this.characterPerRow ? (p = 0,
u = this.offsetX,
d += this.characterHeight + this.characterSpacingY) : u +=
this.characterWidth + this.characterSpacingX
}
t.cache.updateFrameData(e, this.frameData),
this.stamp = new s.Image(t,0,0,e,0),
s.RenderTexture.call(this, t, 100, 100, "", s.scaleModes.NEAREST),
this.type = s.RETROFONT
}
,
s.RetroFont.prototype = Object.create(s.RenderTexture.prototype),
s.RetroFont.prototype.constructor = s.RetroFont,
s.RetroFont.ALIGN_LEFT = "left",
s.RetroFont.ALIGN_RIGHT = "right",
s.RetroFont.ALIGN_CENTER = "center",
s.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",
s.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ",
s.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",
s.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",
s.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",
s.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.'
",
s.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,
(17EKQW\")28FLRX-'39",
s.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",
s.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",
s.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
s.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?
()':;0123456789",
s.RetroFont.prototype.setFixedWidth = function(t, e) {
void 0 === e && (e = "left"),
this.fixedWidth = t,
this.align = e
}
,
s.RetroFont.prototype.setText = function(t, e, i, n, s, o) {
this.multiLine = e || !1,
this.customSpacingX = i || 0,
this.customSpacingY = n || 0,
this.align = s || "left",
this.autoUpperCase = !o,
t.length > 0 && (this.text = t)
}
,
s.RetroFont.prototype.buildRetroFontText = function() {
var t = 0
, e = 0;
if (this.clear(),
this.multiLine) {
var i = this._text.split("\n");
this.fixedWidth > 0 ? 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 n = 0; n < i.length; n++)
t = 0,
this.align === s.RetroFont.ALIGN_RIGHT ? t = this.width -
i[n].length * (this.characterWidth + this.customSpacingX) : this.align ===
s.RetroFont.ALIGN_CENTER && (t = this.width / 2 - i[n].length *
(this.characterWidth + this.customSpacingX) / 2,
t += this.customSpacingX / 2),
t < 0 && (t = 0),
this.pasteLine(i[n], t, e, this.customSpacingX),
e += this.characterHeight + this.customSpacingY
} else
this.fixedWidth > 0 ? this.resize(this.fixedWidth,
this.characterHeight, !0) : this.resize(this._text.length * (this.characterWidth +
this.customSpacingX), this.characterHeight, !0),
t = 0,
this.align === s.RetroFont.ALIGN_RIGHT ? t = this.width -
this._text.length * (this.characterWidth + this.customSpacingX) : this.align ===
s.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
}
,
s.RetroFont.prototype.pasteLine = function(t, e, i, n) {
for (var s = 0; s < t.length; s++)
if (" " === t.charAt(s))
e += this.characterWidth + n;
else if (this.grabData[t.charCodeAt(s)] >= 0 && (this.stamp.frame =
this.grabData[t.charCodeAt(s)],
this.renderXY(this.stamp, e, i, !1),
(e += this.characterWidth + n) > this.width))
break
}
,
s.RetroFont.prototype.getLongestLine = function() {
var t = 0;
if (this._text.length > 0)
for (var e = this._text.split("\n"), i = 0; i < e.length; i++)
e[i].length > t && (t = e[i].length);
return t
}
,
s.RetroFont.prototype.removeUnsupportedCharacters = function(t) {
for (var e = "", i = 0; i < this._text.length; i++) {
var n = this._text[i]
, s = n.charCodeAt(0);
(this.grabData[s] >= 0 || !t && "\n" === n) && (e = e.concat(n))
}
return e
}
,
s.RetroFont.prototype.updateOffset = function(t, e) {
if (this.offsetX !== t || this.offsetY !== e) {
for (var i = t - this.offsetX, n = e - this.offsetY, s =
this.game.cache.getFrameData(this.stamp.key).getFrames(), o = s.length; o--; )
s[o].x += i,
s[o].y += n;
this.buildRetroFontText()
}
}
,
Object.defineProperty(s.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(s.RetroFont.prototype, "smoothed", {
get: function() {
return this.stamp.smoothed
},
set: function(t) {
this.stamp.smoothed = t,
this.buildRetroFontText()
}
}),
s.Rope = function(t, e, i, n, o, r) {
this.points = [],
this.points = r,
this._hasUpdateAnimation = !1,
this._updateAnimationCallback = null,
e = e || 0,
i = i || 0,
n = n || null,
o = o || null,
this.type = s.ROPE,
this.points = r,
PIXI.DisplayObjectContainer.call(this),
this.texture = s.Cache.DEFAULT,
this.uvs = new Float32Array([0, 1, 1, 1, 1, 0, 0, 1]),
this.vertices = new Float32Array([0, 0, 100, 0, 100, 100, 0, 100]),
this.colors = new Float32Array([1, 1, 1, 1]),
this.indices = new Uint16Array([0, 1, 2, 3]),
r && (this.vertices = new Float32Array(4 * r.length),
this.uvs = new Float32Array(4 * r.length),
this.colors = new Float32Array(2 * r.length),
this.indices = new Uint16Array(2 * r.length)),
this.dirty = !0,
this.canvasPadding = 0,
this.drawMode = s.Rope.TRIANGLE_STRIP,
s.Component.Core.init.call(this, t, e, i, n, o),
this.refresh()
}
,
s.Rope.prototype = Object.create(PIXI.DisplayObjectContainer.prototype),
s.Rope.prototype.constructor = s.Rope,
s.Component.Core.install.call(s.Rope.prototype, ["Angle", "Animation",
"AutoCull", "Bounds", "BringToTop", "Crop", "Delta", "Destroy", "FixedToCamera",
"InWorld", "LifeSpan", "LoadTexture", "Overlap", "PhysicsBody", "Reset",
"ScaleMinMax", "Smoothed"]),
s.Rope.prototype.preUpdatePhysics = s.Component.PhysicsBody.preUpdate,
s.Rope.prototype.preUpdateLifeSpan = s.Component.LifeSpan.preUpdate,
s.Rope.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.Rope.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.Rope.TRIANGLE_STRIP = 0,
s.Rope.TRIANGLES = 1,
s.Rope.prototype.preUpdate = function() {
return !!(this.preUpdatePhysics() && this.preUpdateLifeSpan() &&
this.preUpdateInWorld()) && this.preUpdateCore()
}
,
s.Rope.prototype.update = function() {
this._hasUpdateAnimation && this.updateAnimation.call(this)
}
,
s.Rope.prototype.reset = function(t, e) {
return s.Component.Reset.prototype.reset.call(this, t, e),
this
}
,
s.Rope.prototype.refresh = function() {
var t = this.points;
if (!(t.length < 1)) {
var e = this.uvs
, i = this.indices
, n = this.colors;
this.count -= .2,
e[0] = 0,
e[1] = 0,
e[2] = 0,
e[3] = 1,
n[0] = 1,
n[1] = 1,
i[0] = 0,
i[1] = 1;
for (var s, o, r = t.length, a = 1; a < r; a++)
s = 4 * a,
o = a / (r - 1),
e[s] = o,
e[s + 1] = 0,
e[s + 2] = o,
e[s + 3] = 1,
s = 2 * a,
n[s] = 1,
n[s + 1] = 1,
s = 2 * a,
i[s] = s,
i[s + 1] = s + 1
}
}
,
s.Rope.prototype.updateTransform = function() {
var t = this.points;
if (!(t.length < 1)) {
var e, i = t[0], n = {
x: 0,
y: 0
};
this.count -= .2;
for (var s, o, r, a, h, l = this.vertices, c = t.length, u = 0; u <
c; u++)
s = t[u],
o = 4 * u,
e = u < t.length - 1 ? t[u + 1] : s,
n.y = -(e.x - i.x),
n.x = e.y - i.y,
r = 10 * (1 - u / (c - 1)),
r > 1 && (r = 1),
a = Math.sqrt(n.x * n.x + n.y * n.y),
h = this.texture.height / 2,
n.x /= a,
n.y /= a,
n.x *= h,
n.y *= h,
l[o] = s.x + n.x,
l[o + 1] = s.y + n.y,
l[o + 2] = s.x - n.x,
l[o + 3] = s.y - n.y,
i = s;
PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)
}
}
,
s.Rope.prototype.setTexture = function(t) {
this.texture = t
}
,
s.Rope.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())
}
,
s.Rope.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)
}
,
s.Rope.prototype._renderStrip = function(t) {
var e = t.gl
, i = t.projection
, n = t.offset
, o = t.shaderManager.stripShader
, r = this.drawMode === s.Rope.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, -n.x, -n.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(r, this.indices.length, e.UNSIGNED_SHORT, 0)
}
,
s.Rope.prototype._renderCanvas = function(t) {
var e = t.context
, i = this.worldTransform
, n = 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 | n, 0 | o) :
e.setTransform(i.a, i.b, i.c, i.d, n, o),
this.drawMode === s.Rope.TRIANGLE_STRIP ?
this._renderCanvasTriangleStrip(e) : this._renderCanvasTriangles(e)
}
,
s.Rope.prototype._renderCanvasTriangleStrip = function(t) {
var e = this.vertices
, i = this.uvs
, n = e.length / 2;
this.count++;
for (var s = 0; s < n - 2; s++) {
var o = 2 * s;
this._renderCanvasDrawTriangle(t, e, i, o, o + 2, o + 4)
}
}
,
s.Rope.prototype._renderCanvasTriangles = function(t) {
var e = this.vertices
, i = this.uvs
, n = this.indices
, s = n.length;
this.count++;
for (var o = 0; o < s; o += 3) {
var r = 2 * n[o]
, a = 2 * n[o + 1]
, h = 2 * n[o + 2];
this._renderCanvasDrawTriangle(t, e, i, r, a, h)
}
}
,
s.Rope.prototype._renderCanvasDrawTriangle = function(t, e, i, n, s, o) {
var r = this.texture.baseTexture.source
, a = this.texture.width
, h = this.texture.height
, l = e[n]
, c = e[s]
, u = e[o]
, d = e[n + 1]
, p = e[s + 1]
, f = e[o + 1]
, m = i[n] * a
, g = i[s] * a
, y = i[o] * a
, v = i[n + 1] * h
, b = i[s + 1] * h
, w = i[o + 1] * h;
if (this.canvasPadding > 0) {
var x = this.canvasPadding / this.worldTransform.a
, _ = this.canvasPadding / this.worldTransform.d
, P = (l + c + u) / 3
, T = (d + p + f) / 3
, C = l - P
, S = d - T
, A = Math.sqrt(C * C + S * S);
l = P + C / A * (A + x),
d = T + S / A * (A + _),
C = c - P,
S = p - T,
A = Math.sqrt(C * C + S * S),
c = P + C / A * (A + x),
p = T + S / A * (A + _),
C = u - P,
S = f - T,
A = Math.sqrt(C * C + S * S),
u = P + C / A * (A + x),
f = T + S / A * (A + _)
}
t.save(),
t.beginPath(),
t.moveTo(l, d),
t.lineTo(c, p),
t.lineTo(u, f),
t.closePath(),
t.clip();
var k = m * b + v * y + g * w - b * y - v * g - m * w
, E = l * b + v * u + c * w - b * u - v * c - l * w
, I = m * c + l * y + g * u - c * y - l * g - m * u
, M = m * b * u + v * c * y + l * g * w - l * b * y - v * g * u - m *
c * w
, O = d * b + v * f + p * w - b * f - v * p - d * w
, B = m * p + d * y + g * f - p * y - d * g - m * f
, R = m * b * f + v * p * y + d * g * w - d * b * y - v * g * f - m *
p * w;
t.transform(E / k, O / k, I / k, B / k, M / k, R / k),
t.drawImage(r, 0, 0),
t.restore()
}
,
s.Rope.prototype.renderStripFlat = function(t) {
var e = this.context
, i = t.vertices
, n = i.length / 2;
this.count++,
e.beginPath();
for (var s = 1; s < n - 2; s++) {
var o = 2 * s
, r = i[o]
, a = i[o + 2]
, h = i[o + 4]
, l = i[o + 1]
, c = i[o + 3]
, u = i[o + 5];
e.moveTo(r, l),
e.lineTo(a, c),
e.lineTo(h, u)
}
e.fillStyle = "#FF0000",
e.fill(),
e.closePath()
}
,
s.Rope.prototype.getBounds = function(t) {
for (var e = t || this.worldTransform, i = e.a, n = e.b, s = e.c, o =
e.d, r = e.tx, a = e.ty, h = -1 / 0, l = -1 / 0, c = 1 / 0, u = 1 / 0, d =
this.vertices, p = 0; p < d.length; p += 2) {
var f = d[p]
, m = d[p + 1]
, g = i * f + s * m + r
, y = o * m + n * f + a;
c = g < c ? g : c,
u = y < u ? y : u,
h = g > h ? g : h,
l = y > l ? y : l
}
if (c === -1 / 0 || l === 1 / 0)
return PIXI.EmptyRectangle;
var v = this._bounds;
return v.x = c,
v.width = h - c,
v.y = u,
v.height = l - u,
this._currentBounds = v,
v
}
,
Object.defineProperty(s.Rope.prototype, "updateAnimation", {
get: function() {
return this._updateAnimation
},
set: function(t) {
t && "function" == typeof t ? (this._hasUpdateAnimation = !0,
this._updateAnimation = t) : (this._hasUpdateAnimation = !1,
this._updateAnimation = null)
}
}),
Object.defineProperty(s.Rope.prototype, "segments", {
get: function() {
for (var t, e, i, n, o, r, a, h, l = [], c = 0; c <
this.points.length; c++)
t = 4 * c,
e = this.vertices[t] * this.scale.x,
i = this.vertices[t + 1] * this.scale.y,
n = this.vertices[t + 4] * this.scale.x,
o = this.vertices[t + 3] * this.scale.y,
r = s.Math.difference(e, n),
a = s.Math.difference(i, o),
e += this.world.x,
i += this.world.y,
h = new s.Rectangle(e,i,r,a),
l.push(h);
return l
}
}),
s.TileSprite = function(t, e, i, n, o, r, a) {
e = e || 0,
i = i || 0,
n = n || 256,
o = o || 256,
r = r || null,
a = a || null;
var h = t.cache.getImage("__default", !0);
PIXI.Sprite.call(this, new PIXI.Texture(h.base), n, o),
this.type = s.TILESPRITE,
this.physicsType = s.SPRITE,
this._scroll = new s.Point,
this.tileScale = new s.Point(1,1),
this.tileScaleOffset = new s.Point(1,1),
this.tilePosition = new s.Point,
this.textureDebug = !1,
this.canvasBuffer = null,
this.tilingTexture = null,
this.tilePattern = null,
this.refreshTexture = !0,
this.frameWidth = 0,
this.frameHeight = 0,
this._width = n,
this._height = o,
s.Component.Core.init.call(this, t, e, i, r, a)
}
,
s.TileSprite.prototype = Object.create(PIXI.Sprite.prototype),
s.TileSprite.prototype.constructor = s.TileSprite,
s.Component.Core.install.call(s.TileSprite.prototype, ["Angle",
"Animation", "AutoCull", "Bounds", "BringToTop", "Destroy", "FixedToCamera",
"Health", "InCamera", "InputEnabled", "InWorld", "LifeSpan", "LoadTexture",
"Overlap", "PhysicsBody", "Reset", "Smoothed"]),
s.TileSprite.prototype.preUpdatePhysics =
s.Component.PhysicsBody.preUpdate,
s.TileSprite.prototype.preUpdateLifeSpan = s.Component.LifeSpan.preUpdate,
s.TileSprite.prototype.preUpdateInWorld = s.Component.InWorld.preUpdate,
s.TileSprite.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.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()
}
,
s.TileSprite.prototype.autoScroll = function(t, e) {
return this._scroll.set(t, e),
this
}
,
s.TileSprite.prototype.stopScroll = function() {
return this._scroll.set(0, 0),
this
}
,
s.TileSprite.prototype.destroy = function(t) {
s.Component.Destroy.prototype.destroy.call(this, t),
PIXI.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)
}
,
s.TileSprite.prototype.reset = function(t, e) {
return s.Component.Reset.prototype.reset.call(this, t, e),
this.tilePosition.x = 0,
this.tilePosition.y = 0,
this
}
,
s.TileSprite.prototype.setTexture = function(t) {
return this.texture !== t && (this.texture = t,
this.refreshTexture = !0,
this.cachedTint = 16777215),
this
}
,
s.TileSprite.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 &&
(this.tilingTexture.baseTexture.textureIndex =
this.texture.baseTexture.textureIndex,
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);
var i = !1;
this._filters && (i = !0,
t.spriteBatch.stop(),
t.filterManager.popFilter()),
this._mask && (i || t.spriteBatch.stop(),
t.maskManager.popMask(this._mask, t)),
i && t.spriteBatch.start()
}
}
,
s.TileSprite.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
, n = t.resolution
, s = i.tx * n + t.shakeX
, o = i.ty * n + t.shakeY;
if (e.setTransform(i.a * n, i.b * n, i.c * n, i.d * n, s, o),
this.refreshTexture) {
if (this.generateTilingTexture(!1, t),
!this.tilingTexture)
return;
this.tilePattern =
e.createPattern(this.tilingTexture.baseTexture.source, "repeat")
}
var r = t.currentBlendMode;
this.blendMode !== t.currentBlendMode && (t.currentBlendMode =
this.blendMode,
e.globalCompositeOperation =
PIXI.blendModesCanvas[t.currentBlendMode]);
var a = this.tilePosition
, h = this.tileScale;
a.x %= this.tilingTexture.baseTexture.width,
a.y %= this.tilingTexture.baseTexture.height,
e.scale(h.x, h.y),
e.translate(a.x + this.anchor.x * -this._width, a.y + this.anchor.y
* -this._height),
e.fillStyle = this.tilePattern,
s = -a.x,
o = -a.y;
var l = this._width / h.x
, c = this._height / h.y;
t.roundPixels && (s |= 0,
o |= 0,
l |= 0,
c |= 0),
e.fillRect(s, o, l, c),
e.scale(1 / h.x, 1 / h.y),
e.translate(-a.x + this.anchor.x * this._width, -a.y +
this.anchor.y * this._height),
this._mask && t.maskManager.popMask(t);
for (var u = 0; u < this.children.length; u++)
this.children[u]._renderCanvas(t);
r !== this.blendMode && (t.currentBlendMode = r,
e.globalCompositeOperation = PIXI.blendModesCanvas[r])
}
}
,
s.TileSprite.prototype.onTextureUpdate = function() {}
,
s.TileSprite.prototype.generateTilingTexture = function(t) {
if (this.texture.baseTexture.hasLoaded) {
var e = this.texture
, i = e.frame
, n = this._frame.sourceSizeW || this._frame.width
, o = this._frame.sourceSizeH || this._frame.height
, r = 0
, a = 0;
this._frame.trimmed && (r = this._frame.spriteSourceSizeX,
a = this._frame.spriteSourceSizeY),
t && (n = s.Math.getNextPowerOfTwo(n),
o = s.Math.getNextPowerOfTwo(o)),
this.canvasBuffer ? (this.canvasBuffer.resize(n, o),
this.tilingTexture.baseTexture.width = n,
this.tilingTexture.baseTexture.height = o,
this.tilingTexture.needsUpdate = !0) : (this.canvasBuffer = new
PIXI.CanvasBuffer(n,o),
this.tilingTexture =
PIXI.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, n, o));
var h = e.crop.width
, l = e.crop.height;
h === n && l === o || (h = n,
l = o),
this.canvasBuffer.context.drawImage(e.baseTexture.source, e.crop.x,
e.crop.y, e.crop.width, e.crop.height, r, a, h, l),
this.tileScaleOffset.x = i.width / n,
this.tileScaleOffset.y = i.height / o,
this.refreshTexture = !1,
this.tilingTexture.baseTexture._powerOf2 = !0
}
}
,
s.TileSprite.prototype.getBounds = function() {
var t = this._width
, e = this._height
, i = t * (1 - this.anchor.x)
, n = t * -this.anchor.x
, s = e * (1 - this.anchor.y)
, o = e * -this.anchor.y
, r = this.worldTransform
, a = r.a
, h = r.b
, l = r.c
, c = r.d
, u = r.tx
, d = r.ty
, p = a * n + l * o + u
, f = c * o + h * n + d
, m = a * i + l * o + u
, g = c * o + h * i + d
, y = a * i + l * s + u
, v = c * s + h * i + d
, b = a * n + l * s + u
, w = c * s + h * n + d
, x = -1 / 0
, _ = -1 / 0
, P = 1 / 0
, T = 1 / 0;
P = p < P ? p : P,
P = m < P ? m : P,
P = y < P ? y : P,
P = b < P ? b : P,
T = f < T ? f : T,
T = g < T ? g : T,
T = v < T ? v : T,
T = w < T ? w : T,
x = p > x ? p : x,
x = m > x ? m : x,
x = y > x ? y : x,
x = b > x ? b : x,
_ = f > _ ? f : _,
_ = g > _ ? g : _,
_ = v > _ ? v : _,
_ = w > _ ? w : _;
var C = this._bounds;
return C.x = P,
C.width = x - P,
C.y = T,
C.height = _ - T,
this._currentBounds = C,
C
}
,
Object.defineProperty(s.TileSprite.prototype, "width", {
get: function() {
return this._width
},
set: function(t) {
this._width = t
}
}),
Object.defineProperty(s.TileSprite.prototype, "height", {
get: function() {
return this._height
},
set: function(t) {
this._height = t
}
}),
s.CanvasPool = {
create: function(t, e, i) {
var n, o = s.CanvasPool.getFirst();
if (-1 === o) {
var r = {
parent: t,
canvas: document.createElement("canvas")
};
s.CanvasPool.pool.push(r),
n = r.canvas
} else
s.CanvasPool.pool[o].parent = t,
n = s.CanvasPool.pool[o].canvas;
return void 0 !== e && (n.width = e,
n.height = i),
n
},
getFirst: function() {
for (var t = s.CanvasPool.pool, e = 0; e < t.length; e++)
if (!t[e].parent)
return e;
return -1
},
remove: function(t) {
for (var e = s.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 = s.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 = s.CanvasPool.pool, e = 0, i = 0; i < t.length; i++)
t[i].parent && e++;
return e
},
getFree: function() {
for (var t = s.CanvasPool.pool, e = 0, i = 0; i < t.length; i++)
t[i].parent || e++;
return e
}
},
s.CanvasPool.pool = [],
s.Device = function() {
this.deviceReadyAt = 0,
this.initialized = !1,
this.desktop = !1,
this.iOS = !1,
this.iOSVersion = 0,
this.cocoonJS = !1,
this.cocoonJSApp = !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.canHandleAlpha = !1,
this.canUseMultiply = !1,
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
}
,
s.Device = new s.Device,
s.Device.onInitialized = new s.Signal,
s.Device.whenReady = function(t, e, i) {
var n = this._readyCheck;
if (this.deviceReadyAt || !n)
t.call(e, this);
else if (n._monitor || i)
n._queue = n._queue || [],
n._queue.push([t, e]);
else {
n._monitor = n.bind(this),
n._queue = n._queue || [],
n._queue.push([t, e]);
var s = void 0 !== window.cordova
, o = navigator.isCocoonJS;
"complete" === document.readyState || "interactive" ===
document.readyState ? window.setTimeout(n._monitor, 0) : s && !o ?
document.addEventListener("deviceready", n._monitor, !1) :
(document.addEventListener("DOMContentLoaded", n._monitor, !1),
window.addEventListener("load", n._monitor, !1))
}
}
,
s.Device._readyCheck = function() {
var t = this._readyCheck;
if (document.body) {
if (!this.deviceReadyAt) {
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);
for (var e; e = t._queue.shift(); ) {
var i = e[0]
, n = e[1];
i.call(n, this)
}
this._readyCheck = null,
this._initialize = null,
this.onInitialized = null
}
} else
window.setTimeout(t._monitor, 20)
}
,
s.Device._initialize = function() {
function t() {
var t = navigator.userAgent;
/Playstation Vita/.test(t) ? p.vita = !0 : /Kindle/.test(t) ||
/\bKF[A-Z][A-Z]+/.test(t) || /Silk.*Mobile Safari/.test(t) ? p.kindle = !0 :
/Android/.test(t) ? p.android = !0 : /CrOS/.test(t) ? p.chromeOS = !0 : /iP[ao]d|
iPhone/i.test(t) ? (p.iOS = !0,
navigator.appVersion.match(/OS (\d+)/),
p.iOSVersion = parseInt(RegExp.$1, 10)) : /Linux/.test(t) ? p.linux
= !0 : /Mac OS/.test(t) ? p.macOS = !0 : /Windows/.test(t) && (p.windows = !0),
(/Windows Phone/i.test(t) || /IEMobile/i.test(t)) && (p.android = !
1,
p.iOS = !1,
p.macOS = !1,
p.windows = !0,
p.windowsPhone = !0);
var e = /Silk/.test(t);
(p.windows || p.macOS || p.linux && !e || p.chromeOS) && (p.desktop
= !0),
(p.windowsPhone || /Windows NT/i.test(t) && /Touch/i.test(t)) &&
(p.desktop = !1)
}
function e() {
var t = s.CanvasPool.create(this, 6, 1)
, e = t.getContext("2d");
e.fillStyle = "rgba(10, 20, 30, 0.5)",
e.fillRect(0, 0, 1, 1);
var i = e.getImageData(0, 0, 1, 1);
if (i) {
e.putImageData(i, 1, 0);
var n = e.getImageData(1, 0, 1, 1);
p.canHandleAlpha = n.data[0] === i.data[0] && n.data[1] ===
i.data[1] && n.data[2] === i.data[2] && n.data[3] === i.data[3]
}
var o =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/"
, r = "AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=="
, a = new Image;
a.src = o + "AP804Oa6" + r;
var h = new Image;
if (h.src = o + "/wCKxvRF" + r,
e.clearRect(0, 0, 6, 1),
e.globalCompositeOperation = "multiply",
e.drawImage(a, 0, 0),
e.drawImage(h, 2, 0),
e.getImageData(2, 0, 1, 1)) {
var l = e.getImageData(2, 0, 1, 1).data;
p.canUseMultiply = 255 === l[0] && 0 === l[1] && 0 === l[2]
}
s.CanvasPool.removeByCanvas(t),
PIXI.CanvasTinter.tintMethod = p.canUseMultiply ?
PIXI.CanvasTinter.tintWithMultiply : PIXI.CanvasTinter.tintWithPerPixel
}
function i() {
p.canvas = !!window.CanvasRenderingContext2D || p.cocoonJS;
try {
p.localStorage = !!localStorage.getItem
} catch (t) {
p.localStorage = !1
}
p.file = !!(window.File && window.FileReader && window.FileList &&
window.Blob),
p.fileSystem = !!window.requestFileSystem,
p.webGL = function() {
try {
var t = document.createElement("canvas");
return t.screencanvas = !1,
!!window.WebGLRenderingContext && (t.getContext("webgl") ||
t.getContext("experimental-webgl"))
} catch (t) {
return !1
}
}(),
p.webGL = !!p.webGL,
p.worker = !!window.Worker,
p.pointerLock = "pointerLockElement"in document ||
"mozPointerLockElement"in document || "webkitPointerLockElement"in document,
p.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,
p.getUserMedia = p.getUserMedia && !!navigator.getUserMedia && !!
window.URL,
p.firefox && p.firefoxVersion < 21 && (p.getUserMedia = !1),
!p.iOS && (p.ie || p.firefox || p.chrome) && (p.canvasBitBltShift =
!0),
(p.safari || p.mobileSafari) && (p.canvasBitBltShift = !1)
}
function n() {
("ontouchstart"in document.documentElement ||
window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1) &&
(p.touch = !0),
(window.PointerEvent || window.MSPointerEvent ||
window.navigator.msPointerEnabled || window.navigator.pointerEnabled) &&
(p.mspointer = !0),
p.cocoonJS || ("onwheel"in window || p.ie && "WheelEvent"in
window ? p.wheelEvent = "wheel" : "onmousewheel"in window ? p.wheelEvent =
"mousewheel" : p.firefox && "MouseScrollEvent"in window && (p.wheelEvent =
"DOMMouseScroll"))
}
function o() {
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]]) {
p.fullscreen = !0,
p.requestFullscreen = t[i];
break
}
var n = ["cancelFullScreen", "exitFullscreen",
"webkitCancelFullScreen", "webkitExitFullscreen", "msCancelFullScreen",
"msExitFullscreen", "mozCancelFullScreen", "mozExitFullscreen"];
if (p.fullscreen)
for (var i = 0; i < n.length; i++)
if (document[n[i]]) {
p.cancelFullscreen = n[i];
break
}
window.Element && Element.ALLOW_KEYBOARD_INPUT &&
(p.fullscreenKeyboard = !0)
}
function r() {
var t = navigator.userAgent;
if (/Arora/.test(t) ? p.arora = !0 : /Edge\/\d+/.test(t) ? p.edge =
!0 : /Chrome\/(\d+)/.test(t) && !p.windowsPhone ? (p.chrome = !0,
p.chromeVersion = parseInt(RegExp.$1, 10)) : /Epiphany/.test(t) ?
p.epiphany = !0 : /Firefox\D+(\d+)/.test(t) ? (p.firefox = !0,
p.firefoxVersion = parseInt(RegExp.$1, 10)) : /AppleWebKit/.test(t)
&& p.iOS ? p.mobileSafari = !0 : /MSIE (\d+\.\d+);/.test(t) ? (p.ie = !0,
p.ieVersion = parseInt(RegExp.$1, 10)) : /Midori/.test(t) ?
p.midori = !0 : /Opera/.test(t) ? p.opera = !0 : /Safari\/(\d+)/.test(t) && !
p.windowsPhone ? (p.safari = !0,
/Version\/(\d+)\./.test(t) && (p.safariVersion = parseInt(RegExp.
$1, 10))) : /Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(t) && (p.ie = !0,
p.trident = !0,
p.tridentVersion = parseInt(RegExp.$1, 10),
p.ieVersion = parseInt(RegExp.$3, 10)),
/Silk/.test(t) && (p.silk = !0),
navigator.standalone && (p.webApp = !0),
void 0 !== window.cordova && (p.cordova = !0),
"undefined" != typeof process && "undefined" != typeof require &&
(p.node = !0),
p.node && "object" == typeof process.versions && (p.nodeWebkit = !!
process.versions["node-webkit"],
p.electron = !!process.versions.electron),
navigator.isCocoonJS && (p.cocoonJS = !0),
p.cocoonJS)
try {
p.cocoonJSApp = "undefined" != typeof CocoonJS
} catch (t) {
p.cocoonJSApp = !1
}
void 0 !== window.ejecta && (p.ejecta = !0),
/Crosswalk/.test(t) && (p.crosswalk = !0)
}
function a() {
var t = document.createElement("video");
try {
!!t.canPlayType && (t.canPlayType('video/ogg;
codecs="theora"').replace(/^no$/, "") && (p.oggVideo = !0),
t.canPlayType('video/mp4;
codecs="avc1.42E01E"').replace(/^no$/, "") && (p.h264Video = !0,
p.mp4Video = !0),
t.canPlayType('video/webm; codecs="vp8,
vorbis"').replace(/^no$/, "") && (p.webmVideo = !0),
t.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, "")
&& (p.vp9Video = !0),
t.canPlayType('application/x-mpegURL;
codecs="avc1.42E01E"').replace(/^no$/, "") && (p.hlsVideo = !0))
} catch (t) {}
}
function h() {
p.audioData = !!window.Audio,
p.webAudio = !(!window.AudioContext && !window.webkitAudioContext);
var t = document.createElement("audio");
try {
if (!!t.canPlayType && (t.canPlayType('audio/ogg;
codecs="vorbis"').replace(/^no$/, "") && (p.ogg = !0),
(t.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, "")
|| t.canPlayType("audio/opus;").replace(/^no$/, "")) && (p.opus = !0),
t.canPlayType("audio/mpeg;").replace(/^no$/, "") && (p.mp3 = !
0),
t.canPlayType('audio/wav; codecs="1"').replace(/^no$/, "") &&
(p.wav = !0),
(t.canPlayType("audio/x-m4a;") ||
t.canPlayType("audio/aac;").replace(/^no$/, "")) && (p.m4a = !0),
t.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,
"") && (p.webm = !0),
"" !== t.canPlayType('audio/mp4;codecs="ec-3"')))
if (p.edge)
p.dolby = !0;
else if (p.safari && p.safariVersion >= 9 && /Mac OS X
(\d+)_(\d+)/.test(navigator.userAgent)) {
var e = parseInt(RegExp.$1, 10)
, i = parseInt(RegExp.$2, 10);
(10 === e && i >= 11 || e > 10) && (p.dolby = !0)
}
} catch (t) {}
}
function l() {
var t = new ArrayBuffer(4)
, e = new Uint8Array(t)
, i = new Uint32Array(t);
return e[0] = 161,
e[1] = 178,
e[2] = 195,
e[3] = 212,
3569595041 === i[0] || 2712847316 !== i[0] && null
}
function c() {
if (void 0 === Uint8ClampedArray)
return !1;
var t = s.CanvasPool.create(this, 1, 1)
, e = t.getContext("2d");
if (!e)
return !1;
var i = e.createImageData(1, 1);
return s.CanvasPool.remove(this),
i.data instanceof Uint8ClampedArray
}
function u() {
p.pixelRatio = window.devicePixelRatio || 1,
p.iPhone = -1 !==
navigator.userAgent.toLowerCase().indexOf("iphone"),
p.iPhone4 = 2 === p.pixelRatio && p.iPhone,
p.iPad = -1 !== navigator.userAgent.toLowerCase().indexOf("ipad"),
"undefined" != typeof Int8Array ? p.typedArray = !0 : p.typedArray
= !1,
"undefined" != typeof ArrayBuffer && "undefined" != typeof
Uint8Array && "undefined" != typeof Uint32Array && (p.littleEndian = l(),
p.LITTLE_ENDIAN = p.littleEndian),
p.support32bit = "undefined" != typeof ArrayBuffer && "undefined" !
= typeof Uint8ClampedArray && "undefined" != typeof Int32Array && null !==
p.littleEndian && c(),
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate ||
navigator.mozVibrate || navigator.msVibrate,
navigator.vibrate && (p.vibration = !0)
}
function d() {
var t, e = document.createElement("p"), i = {
webkitTransform: "-webkit-transform",
OTransform: "-o-transform",
msTransform: "-ms-transform",
MozTransform: "-moz-transform",
transform: "transform"
};
document.body.insertBefore(e, null);
for (var n in i)
void 0 !== e.style[n] && (e.style[n] =
"translate3d(1px,1px,1px)",
t = window.getComputedStyle(e).getPropertyValue(i[n]));
document.body.removeChild(e),
p.css3D = void 0 !== t && t.length > 0 && "none" !== t
}
var p = this;
t(),
r(),
h(),
a(),
d(),
u(),
i(),
e(),
o(),
n()
}
,
s.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))))))
}
,
s.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)))
}
,
s.Device.isConsoleOpen = function() {
return !(!window.console || !window.console.firebug) || !(!
window.console || (console.profile(),
console.profileEnd(),
console.clear && console.clear(),
!console.profiles)) && console.profiles.length > 0
}
,
s.Device.isAndroidStockBrowser = function() {
var t = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]
+)/);
return t && t[1] < 537
}
,
s.Canvas = {
create: function(t, e, i, n, o) {
e = e || 256,
i = i || 256;
var r = o ? document.createElement("canvas") :
s.CanvasPool.create(t, e, i);
return "string" == typeof n && "" !== n && (r.id = n),
r.width = e,
r.height = i,
r.style.display = "block",
r
},
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 n;
return void 0 === i && (i = !0),
e && ("string" == typeof e ? n = document.getElementById(e) :
"object" == typeof e && 1 === e.nodeType && (n = e)),
n || (n = document.body),
i && n.style && (n.style.overflow = "hidden"),
n.appendChild(t),
t
},
removeFromDOM: function(t) {
t.parentNode && t.parentNode.removeChild(t)
},
setTransform: function(t, e, i, n, s, o, r) {
return t.setTransform(n, o, r, s, e, i),
t
},
setSmoothingEnabled: function(t, e) {
var i = s.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 n = e[i] + "mageSmoothingEnabled";
if (n in t)
return n
}
return null
},
getSmoothingEnabled: function(t) {
var e = s.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
}
},
s.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"], n = 0; n < i.length && !
window.requestAnimationFrame; n++)
window.requestAnimationFrame = window[i[n] +
"RequestAnimationFrame"],
window.cancelAnimationFrame = window[i[n] + "CancelAnimationFrame"]
|| window[i[n] + "CancelRequestAnimationFrame"];
this._isSetTimeOut = !1,
this._onLoop = null,
this._timeOutID = null
}
,
s.RequestAnimationFrame.prototype = {
start: function() {
this.isRunning = !0;
var t = this;
!window.requestAnimationFrame || this.forceSetTimeOut ?
(this._isSetTimeOut = !0,
this._onLoop = function() {
return t.updateSetTimeout()
}
,
this._timeOutID = window.setTimeout(this._onLoop, 0)) :
(this._isSetTimeOut = !1,
this._onLoop = function(e) {
return t.updateRAF(e)
}
,
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
}
},
s.RequestAnimationFrame.prototype.constructor = s.RequestAnimationFrame,
s.Math = {
PI2: 2 * Math.PI,
DEG_TO_RAD: Math.PI / 180,
RAD_TO_DEG: 180 / Math.PI,
degToRad: function(t) {
return t * s.Math.DEG_TO_RAD
},
radToDeg: function(t) {
return t * s.Math.RAD_TO_DEG
},
getNextPowerOfTwo: function(t) {
if (t > 0 && 0 == (t & t - 1))
return t;
for (var e = 1; e < t; )
e <<= 1;
return e
},
isPowerOfTwo: function(t, e) {
return t > 0 && 0 == (t & t - 1) && e > 0 && 0 == (e & e - 1)
},
random: function(t, e) {
if (void 0 === t && (t = 0),
void 0 === e && (e = 1),
t === e)
return t;
if (t < e) {
var i = t;
t = e,
e = i
}
return Math.random() * (e - t) + t
},
between: function(t, e) {
if (void 0 === t && (t = 0),
void 0 === e && (e = 1),
t === e)
return t;
if (t < e) {
var i = t;
t = e,
e = i
}
return t = Math.ceil(t),
e = Math.floor(e),
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),
t > e - i
},
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,
t = e * Math.round(t / e),
i + t)
},
snapToFloor: function(t, e, i) {
return void 0 === i && (i = 0),
0 === e ? t : (t -= i,
t = e * Math.floor(t / e),
i + t)
},
snapToCeil: function(t, e, i) {
return void 0 === i && (i = 0),
0 === e ? t : (t -= i,
t = e * Math.ceil(t / e),
i + t)
},
roundTo: function(t, e, i) {
void 0 === e && (e = 0),
void 0 === i && (i = 10);
var n = Math.pow(i, -e);
return Math.round(t * n) / n
},
floorTo: function(t, e, i) {
void 0 === e && (e = 0),
void 0 === i && (i = 10);
var n = Math.pow(i, -e);
return Math.floor(t * n) / n
},
ceilTo: function(t, e, i) {
void 0 === e && (e = 0),
void 0 === i && (i = 10);
var n = Math.pow(i, -e);
return Math.ceil(t * n) / n
},
rotateToAngle: function(t, e, i) {
return void 0 === i && (i = .05),
t === e ? t : (Math.abs(e - t) <= i || Math.abs(e - t) >=
s.Math.PI2 - i ? t = e : (Math.abs(e - t) > Math.PI && (e < t ? e += s.Math.PI2 : e
-= s.Math.PI2),
e > t ? 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, n) {
return Math.atan2(n - e, i - t)
},
angleBetweenY: function(t, e, i, n) {
return Math.atan2(i - t, n - 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 t %= 2 * Math.PI,
t >= 0 ? 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 n = i - e;
if (n <= 0)
return 0;
var s = (t - e) % n;
return s < 0 && (s += n),
s + e
},
wrapValue: function(t, e, i) {
return t = Math.abs(t),
e = Math.abs(e),
i = Math.abs(i),
(t + e) % 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
var t = arguments;
for (var e = 1, i = 0, n = t.length; e < n; 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
var t = arguments;
for (var e = 1, i = 0, n = t.length; e < n; 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
var e = arguments.slice(1);
for (var i = 1, n = 0, s = e.length; i < s; i++)
e[i][t] < e[n][t] && (n = i);
return e[n][t]
},
maxProperty: function(t) {
if (2 === arguments.length && "object" == typeof arguments[1])
var e = arguments[1];
else
var e = arguments.slice(1);
for (var i = 1, n = 0, s = e.length; i < s; i++)
e[i][t] > e[n][t] && (n = i);
return e[n][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
, n = i * e
, s = Math.floor(n);
return e < 0 ? this.linear(t[0], t[1], n) : e > 1 ?
this.linear(t[i], t[i - 1], i - n) : this.linear(t[s], t[s + 1 > i ? i : s + 1], n
- s)
},
bezierInterpolation: function(t, e) {
for (var i = 0, n = t.length - 1, s = 0; s <= n; s++)
i += Math.pow(1 - e, n - s) * Math.pow(e, s) * t[s] *
this.bernstein(n, s);
return i
},
catmullRomInterpolation: function(t, e) {
var i = t.length - 1
, n = i * e
, s = Math.floor(n);
return t[0] === t[i] ? (e < 0 && (s = Math.floor(n = i * (1 + e))),
this.catmullRom(t[(s - 1 + i) % i], t[s], t[(s + 1) % i], t[(s + 2)
% i], n - s)) : e < 0 ? t[0] - (this.catmullRom(t[0], t[0], t[1], t[1], -n) - t[0])
: e > 1 ? t[i] - (this.catmullRom(t[i], t[i], t[i - 1], t[i - 1], n - i) - t[i]) :
this.catmullRom(t[s ? s - 1 : 0], t[s], t[i < s + 1 ? i : s + 1], t[i < s + 2 ? i :
s + 2], n - s)
},
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, n, s) {
var o = .5 * (i - t)
, r = .5 * (n - e)
, a = s * s;
return (2 * e - 2 * i + o + r) * (s * a) + (-3 * e + 3 * i - 2 * o
- r) * a + o * s + e
},
difference: function(t, e) {
return Math.abs(t - e)
},
roundAwayFromZero: function(t) {
return t > 0 ? Math.ceil(t) : Math.floor(t)
},
sinCosGenerator: function(t, e, i, n) {
void 0 === e && (e = 1),
void 0 === i && (i = 1),
void 0 === n && (n = 1);
for (var s = e, o = i, r = n * Math.PI / t, a = [], h = [], l = 0;
l < t; l++)
o -= s * r,
s += o * r,
a[l] = o,
h[l] = s;
return {
sin: h,
cos: a,
length: t
}
},
distance: function(t, e, i, n) {
var s = t - i
, o = e - n;
return Math.sqrt(s * s + o * o)
},
distanceSq: function(t, e, i, n) {
var s = t - i
, o = e - n;
return s * s + o * o
},
distancePow: function(t, e, i, n, s) {
return void 0 === s && (s = 2),
Math.sqrt(Math.pow(i - t, s) + Math.pow(n - e, s))
},
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, n, s) {
return n + (t - e) * (s - n) / (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 : t > 0 ? 1 : 0
},
percent: function(t, e, i) {
return void 0 === i && (i = 0),
t > e || i > e ? 1 : t < i || i > t ? 0 : (t - i) / e
}
},
s.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)
}
,
s.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, n;
for (n = 4022871197,
t = t.toString(),
i = 0; i < t.length; i++)
n += t.charCodeAt(i),
e = .02519603282416938 * n,
n = e >>> 0,
e -= n,
e *= n,
n = e >>> 0,
e -= n,
n += 4294967296 * e;
return 2.3283064365386963e-10 * (n >>> 0)
},
integer: function() {
return 4294967296 * this.rnd.apply(this)
},
frac: function() {
return this.rnd.apply(this) + 1.1102230246251565e-16 * (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(",")
}
},
s.RandomDataGenerator.prototype.constructor = s.RandomDataGenerator,
s.QuadTree = function(t, e, i, n, s, o, r) {
this.maxObjects = 10,
this.maxLevels = 4,
this.level = 0,
this.bounds = {},
this.objects = [],
this.nodes = [],
this._empty = [],
this.reset(t, e, i, n, s, o, r)
}
,
s.QuadTree.prototype = {
reset: function(t, e, i, n, s, o, r) {
this.maxObjects = s || 10,
this.maxLevels = o || 4,
this.level = r || 0,
this.bounds = {
x: Math.round(t),
y: Math.round(e),
width: i,
height: n,
subWidth: Math.floor(i / 2),
subHeight: Math.floor(n / 2),
right: Math.round(t) + Math.floor(i / 2),
bottom: Math.round(e) + Math.floor(n / 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
s.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeig
ht,this.maxObjects,this.maxLevels,this.level + 1),
this.nodes[1] = new
s.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,t
his.maxObjects,this.maxLevels,this.level + 1),
this.nodes[2] = new
s.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHei
ght,this.maxObjects,this.maxLevels,this.level + 1),
this.nodes[3] = new
s.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.su
bHeight,this.maxObjects,this.maxLevels,this.level + 1)
},
insert: function(t) {
var e, i = 0;
if (null != this.nodes[0] && -1 !== (e = this.getIndex(t)))
return void this.nodes[e].insert(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; )
e = this.getIndex(this.objects[i]),
-1 !== e ? this.nodes[e].insert(this.objects.splice(i, 1)
[0]) : i++
},
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 s.Rectangle)
var e = this.objects
, i = this.getIndex(t);
else {
if (!t.body)
return this._empty;
var e = this.objects
, i = this.getIndex(t.body)
}
return this.nodes[0] && (-1 !== i ? e =
e.concat(this.nodes[i].retrieve(t)) : (e = e.concat(this.nodes[0].retrieve(t)),
e = e.concat(this.nodes[1].retrieve(t)),
e = e.concat(this.nodes[2].retrieve(t)),
e = e.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
}
},
s.QuadTree.prototype.constructor = s.QuadTree,
s.Net = function(t) {
this.game = t
}
,
s.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, n) {
void 0 === i && (i = !1),
void 0 !== n && "" !== n || (n = window.location.href);
var s = ""
, o = new RegExp("([?|&])" + t + "=.*?(&|#|$)(.*)","gi");
if (o.test(n))
s = void 0 !== e && null !== e ? n.replace(o, "$1" + t + "=" +
e + "$2$3") : n.replace(o, "$1$3").replace(/(&|\?)$/, "");
else if (void 0 !== e && null !== e) {
var r = -1 !== n.indexOf("?") ? "&" : "?"
, a = n.split("#");
n = a[0] + r + t + "=" + e,
a[1] && (n += "#" + a[1]),
s = n
} else
s = n;
if (!i)
return s;
window.location.href = s
},
getQueryString: function(t) {
void 0 === t && (t = "");
var e = {}
, i = location.search.substring(1).split("&");
for (var n in i) {
var s = i[n].split("=");
if (s.length > 1) {
if (t && t === this.decodeURI(s[0]))
return this.decodeURI(s[1]);
e[this.decodeURI(s[0])] = this.decodeURI(s[1])
}
}
return e
},
decodeURI: function(t) {
return decodeURIComponent(t.replace(/\+/g, " "))
}
},
s.Net.prototype.constructor = s.Net,
s.TweenManager = function(t) {
this.game = t,
this.frameBased = !1,
this._tweens = [],
this._add = [],
this.easeMap = {
Power0: s.Easing.Power0,
Power1: s.Easing.Power1,
Power2: s.Easing.Power2,
Power3: s.Easing.Power3,
Power4: s.Easing.Power4,
Linear: s.Easing.Linear.None,
Quad: s.Easing.Quadratic.Out,
Cubic: s.Easing.Cubic.Out,
Quart: s.Easing.Quartic.Out,
Quint: s.Easing.Quintic.Out,
Sine: s.Easing.Sinusoidal.Out,
Expo: s.Easing.Exponential.Out,
Circ: s.Easing.Circular.Out,
Elastic: s.Easing.Elastic.Out,
Back: s.Easing.Back.Out,
Bounce: s.Easing.Bounce.Out,
"Quad.easeIn": s.Easing.Quadratic.In,
"Cubic.easeIn": s.Easing.Cubic.In,
"Quart.easeIn": s.Easing.Quartic.In,
"Quint.easeIn": s.Easing.Quintic.In,
"Sine.easeIn": s.Easing.Sinusoidal.In,
"Expo.easeIn": s.Easing.Exponential.In,
"Circ.easeIn": s.Easing.Circular.In,
"Elastic.easeIn": s.Easing.Elastic.In,
"Back.easeIn": s.Easing.Back.In,
"Bounce.easeIn": s.Easing.Bounce.In,
"Quad.easeOut": s.Easing.Quadratic.Out,
"Cubic.easeOut": s.Easing.Cubic.Out,
"Quart.easeOut": s.Easing.Quartic.Out,
"Quint.easeOut": s.Easing.Quintic.Out,
"Sine.easeOut": s.Easing.Sinusoidal.Out,
"Expo.easeOut": s.Easing.Exponential.Out,
"Circ.easeOut": s.Easing.Circular.Out,
"Elastic.easeOut": s.Easing.Elastic.Out,
"Back.easeOut": s.Easing.Back.Out,
"Bounce.easeOut": s.Easing.Bounce.Out,
"Quad.easeInOut": s.Easing.Quadratic.InOut,
"Cubic.easeInOut": s.Easing.Cubic.InOut,
"Quart.easeInOut": s.Easing.Quartic.InOut,
"Quint.easeInOut": s.Easing.Quintic.InOut,
"Sine.easeInOut": s.Easing.Sinusoidal.InOut,
"Expo.easeInOut": s.Easing.Exponential.InOut,
"Circ.easeInOut": s.Easing.Circular.InOut,
"Elastic.easeInOut": s.Easing.Elastic.InOut,
"Back.easeInOut": s.Easing.Back.InOut,
"Bounce.easeInOut": s.Easing.Bounce.InOut
},
this.game.onPause.add(this._pauseAll, this),
this.game.onResume.add(this._resumeAll, this)
}
,
s.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) {
void 0 === e && (e = !0);
var i, n;
if (Array.isArray(t))
for (i = 0,
n = t.length; i < n; i++)
this.removeFrom(t[i]);
else if (t.type === s.GROUP && e)
for (var i = 0, n = t.children.length; i < n; i++)
this.removeFrom(t.children[i]);
else {
for (i = 0,
n = this._tweens.length; i < n; i++)
t === this._tweens[i].target &&
this.remove(this._tweens[i]);
for (i = 0,
n = this._add.length; i < n; i++)
t === this._add[i].target && this.remove(this._add[i])
}
},
add: function(t) {
t._manager = this,
this._add.push(t)
},
create: function(t) {
return new s.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 t > 0 && (this._tweens = this._tweens.concat(this._add),
this._add.length = 0),
!0
},
isTweening: function(t) {
return this._tweens.some(function(e) {
return e.target === t
})
},
_pauseAll: function() {
for (var t = this._tweens.length - 1; t >= 0; t--)
this._tweens[t]._pause()
},
_resumeAll: function() {
for (var t = this._tweens.length - 1; t >= 0; t--)
this._tweens[t]._resume()
},
pauseAll: function() {
for (var t = this._tweens.length - 1; t >= 0; t--)
this._tweens[t].pause()
},
resumeAll: function() {
for (var t = this._tweens.length - 1; t >= 0; t--)
this._tweens[t].resume(!0)
}
},
s.TweenManager.prototype.constructor = s.TweenManager,
s.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 s.Signal,
this.onLoop = new s.Signal,
this.onRepeat = new s.Signal,
this.onChildComplete = new s.Signal,
this.onComplete = new s.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
}
,
s.Tween.prototype = {
to: function(t, e, i, n, o, r, a) {
return (void 0 === e || e <= 0) && (e = 1e3),
void 0 !== i && null !== i || (i = s.Easing.Default),
void 0 === n && (n = !1),
void 0 === o && (o = 0),
void 0 === r && (r = 0),
void 0 === a && (a = !1),
"string" == typeof i && this.manager.easeMap[i] && (i =
this.manager.easeMap[i]),
this.isRunning ? (console.warn("Phaser.Tween.to cannot be called
after Tween.start"),
this) : (this.timeline.push(new s.TweenData(this).to(t, e, i, o, r,
a)),
n && this.start(),
this)
},
from: function(t, e, i, n, o, r, a) {
return void 0 === e && (e = 1e3),
void 0 !== i && null !== i || (i = s.Easing.Default),
void 0 === n && (n = !1),
void 0 === o && (o = 0),
void 0 === r && (r = 0),
void 0 === a && (a = !1),
"string" == typeof i && this.manager.easeMap[i] && (i =
this.manager.easeMap[i]),
this.isRunning ? (console.warn("Phaser.Tween.from cannot be called
after Tween.start"),
this) : (this.timeline.push(new s.TweenData(this).from(t, e, i, o,
r, a)),
n && 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 (var 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 n = 0; n < this.timeline.length; n++)
this.timeline[n][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 = s.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--; )
t > 0 ? 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 === s.TweenData.PENDING)
return !0;
if (e === s.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 === s.TweenData.LOOPED)
return -1 === this.timeline[this.current].repeatCounter ?
this.onLoop.dispatch(this.target, this) : this.onRepeat.dispatch(this.target,
this),
!0;
if (e === s.TweenData.COMPLETE) {
var i = !1;
return this.reverse ? --this.current < 0 && (this.current =
this.timeline.length - 1,
i = !0) : ++this.current === this.timeline.length &&
(this.current = 0,
i = !0),
i ? -1 === this.repeatCounter ?
(this.timeline[this.current].start(),
this.onLoop.dispatch(this.target, this),
!0) : this.repeatCounter > 0 ? (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 n in this.timeline[i].vEnd)
this.properties[n] = this.target[n] || 0,
Array.isArray(this.properties[n]) || (this.properties[n] *=
1);
for (var i = 0; i < this.timeline.length; i++)
this.timeline[i].loadValues();
for (var i = 0; i < this.timeline.length; i++)
e = e.concat(this.timeline[i].generateData(t));
return e
}
},
Object.defineProperty(s.Tween.prototype, "totalDuration", {
get: function() {
for (var t = 0, e = 0; e < this.timeline.length; e++)
t += this.timeline[e].duration;
return t
}
}),
s.Tween.prototype.constructor = s.Tween,
s.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 = s.Easing.Default,
this.interpolationFunction = s.Math.linearInterpolation,
this.interpolationContext = s.Math,
this.isRunning = !1,
this.isFrom = !1
}
,
s.TweenData.PENDING = 0,
s.TweenData.RUNNING = 1,
s.TweenData.LOOPED = 2,
s.TweenData.COMPLETE = 3,
s.TweenData.prototype = {
to: function(t, e, i, n, s, o) {
return this.vEnd = t,
this.duration = e,
this.easingFunction = i,
this.delay = n,
this.repeatTotal = s,
this.yoyo = o,
this.isFrom = !1,
this
},
from: function(t, e, i, n, s, o) {
return this.vEnd = t,
this.duration = e,
this.easingFunction = i,
this.delay = n,
this.repeatTotal = s,
this.yoyo = o,
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,
this.delay > 0 ? 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 s.TweenData.RUNNING
} else {
if (!(t >= this.startTime))
return s.TweenData.PENDING;
this.isRunning = !0
}
var e = this.parent.frameBased ? this.game.time.physicsElapsedMS :
this.game.time.elapsedMS;
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);
for (var i in this.vEnd) {
var n = 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] = n + (o - n) * this.value
}
return !this.parent.reverse && 1 === this.percent ||
this.parent.reverse && 0 === this.percent ? this.repeat() : s.TweenData.RUNNING
},
generateData: function(t) {
this.parent.reverse ? this.dt = this.duration : this.dt = 0;
var e = []
, i = !1
, n = 1 / t * 1e3;
do {
this.parent.reverse ? (this.dt -= n,
this.dt = Math.max(this.dt, 0)) : (this.dt += n,
this.dt = Math.min(this.dt, this.duration)),
this.percent = this.dt / this.duration,
this.value = this.easingFunction(this.percent);
var s = {};
for (var o in this.vEnd) {
var r = this.vStart[o]
, a = this.vEnd[o];
Array.isArray(a) ? s[o] = this.interpolationFunction(a,
this.value) : s[o] = r + (a - r) * this.value
}
e.push(s),
(!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,
s.TweenData.COMPLETE
}
this.inReverse = !this.inReverse
} else if (0 === this.repeatCounter)
return s.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];
this.repeatCounter > 0 && 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,
s.TweenData.LOOPED
}
},
s.TweenData.prototype.constructor = s.TweenData,
s.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, n = .4;
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1,
e = n / 4) : e = n * Math.asin(1 / i) / (2 * Math.PI),
-i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t - e) * (2 *
Math.PI) / n))
},
Out: function(t) {
var e, i = .1, n = .4;
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1,
e = n / 4) : e = n * Math.asin(1 / i) / (2 * Math.PI),
i * Math.pow(2, -10 * t) * Math.sin((t - e) * (2 * Math.PI) /
n) + 1)
},
InOut: function(t) {
var e, i = .1, n = .4;
return 0 === t ? 0 : 1 === t ? 1 : (!i || i < 1 ? (i = 1,
e = n / 4) : e = n * Math.asin(1 / i) / (2 * Math.PI),
(t *= 2) < 1 ? i * Math.pow(2, 10 * (t -= 1)) * Math.sin((t -
e) * (2 * Math.PI) / n) * -.5 : i * Math.pow(2, -10 * (t -= 1)) * Math.sin((t - e)
* (2 * Math.PI) / n) * .5 + 1)
}
},
Back: {
In: function(t) {
var e = 1.70158;
return t * t * ((e + 1) * t - e)
},
Out: function(t) {
var e = 1.70158;
return --t * t * ((e + 1) * t + e) + 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 - s.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 * s.Easing.Bounce.In(2 * t) : .5 *
s.Easing.Bounce.Out(2 * t - 1) + .5
}
}
},
s.Easing.Default = s.Easing.Linear.None,
s.Easing.Power0 = s.Easing.Linear.None,
s.Easing.Power1 = s.Easing.Quadratic.Out,
s.Easing.Power2 = s.Easing.Cubic.Out,
s.Easing.Power3 = s.Easing.Quartic.Out,
s.Easing.Power4 = s.Easing.Quintic.Out,
s.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 s.Timer(this.game,!1),
this._frameCount = 0,
this._elapsedAccumulator = 0,
this._started = 0,
this._timeLastSecond = 0,
this._pauseStarted = 0,
this._justResumed = !1,
this._timers = []
}
,
s.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 s.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(s.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
}
}),
s.Time.prototype.constructor = s.Time,
s.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 s.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
}
,
s.Timer.MINUTE = 6e4,
s.Timer.SECOND = 1e3,
s.Timer.HALF = 500,
s.Timer.QUARTER = 250,
s.Timer.prototype = {
create: function(t, e, i, n, o, r) {
t = Math.round(t);
var a = t;
0 === this._now ? a += this.game.time.time : a += this._now;
var h = new s.TimerEvent(this,t,a,i,e,n,o,r);
return this.events.push(h),
this.order(),
this.expired = !1,
h
},
add: function(t, e, i) {
return this.create(t, !1, 0, e, i,
Array.prototype.slice.call(arguments, 3))
},
repeat: function(t, e, i, n) {
return this.create(t, !1, e, i, n,
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,
!0;
return !1
},
order: function() {
this.events.length > 0 && (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 && this._len > 0) {
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,

this.events[this._i].callback.apply(this.events[this._i].callbackContext,
this.events[this._i].args)) : this.events[this._i].repeatCount > 0 ?
(this.events[this._i].repeatCount--,
this.events[this._i].tick = this._newTick,

this.events[this._i].callback.apply(this.events[this._i].callbackContext,
this.events[this._i].args)) : (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 n = this.nextTick - t;
this.nextTick = n < 0 ? this._now : this._now + n
},
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(s.Timer.prototype, "next", {
get: function() {
return this.nextTick
}
}),
Object.defineProperty(s.Timer.prototype, "duration", {
get: function() {
return this.running && this.nextTick > this._now ? this.nextTick -
this._now : 0
}
}),
Object.defineProperty(s.Timer.prototype, "length", {
get: function() {
return this.events.length
}
}),
Object.defineProperty(s.Timer.prototype, "ms", {
get: function() {
return this.running ? this._now - this._started -
this._pauseTotal : 0
}
}),
Object.defineProperty(s.Timer.prototype, "seconds", {
get: function() {
return this.running ? .001 * this.ms : 0
}
}),
s.Timer.prototype.constructor = s.Timer,
s.TimerEvent = function(t, e, i, n, s, o, r, a) {
this.timer = t,
this.delay = e,
this.tick = i,
this.repeatCount = n - 1,
this.loop = s,
this.callback = o,
this.callbackContext = r,
this.args = a,
this.pendingDelete = !1
}
,
s.TimerEvent.prototype.constructor = s.TimerEvent,
s.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 = []
}
,
s.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,
void 0 === e || null === e ? this.frame = 0 : "string" == typeof
e ? this.frameName = e : this.frame = e,
this.isLoaded = !0,
!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 void 0 === e || null === e ? this.frame = 0 : "string" ==
typeof e ? this.frameName = e : this.frame = e,
this.isLoaded = !0,
!0
},
add: function(t, e, i, n, o) {
return e = e || [],
i = i || 60,
void 0 === n && (n = !1),
void 0 === o && (o = !(!e || "number" != typeof e[0])),
this._outputFrames = [],
this._frameData.getFrameIndexes(e, o, this._outputFrames),
this._anims[t] = new
s.Animation(this.game,this.sprite,t,this._frameData,this._outputFrames,i,n),
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, n) {
if (this._anims[t])
return this.currentAnim === this._anims[t] ? !1 ===
this.currentAnim.isPlaying ? (this.currentAnim.paused = !1,
this.currentAnim.play(e, i, n)) : 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, n))
},
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
}
},
s.AnimationManager.prototype.constructor = s.AnimationManager,
Object.defineProperty(s.AnimationManager.prototype, "frameData", {
get: function() {
return this._frameData
}
}),
Object.defineProperty(s.AnimationManager.prototype, "frameTotal", {
get: function() {
return this._frameData.total
}
}),
Object.defineProperty(s.AnimationManager.prototype, "paused", {
get: function() {
return this.currentAnim.isPaused
},
set: function(t) {
this.currentAnim.paused = t
}
}),
Object.defineProperty(s.AnimationManager.prototype, "name", {
get: function() {
if (this.currentAnim)
return this.currentAnim.name
}
}),
Object.defineProperty(s.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(s.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))) : console.warn("Cannot
set frameName: " + t)
}
}),
s.Animation = function(t, e, i, n, o, r, a) {
void 0 === a && (a = !1),
this.game = t,
this._parent = e,
this._frameData = n,
this.name = i,
this._frames = [],
this._frames = this._frames.concat(o),
this.delay = 1e3 / r,
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 s.Signal,
this.onUpdate = null,
this.onComplete = new s.Signal,
this.onLoop = new s.Signal,
this.isReversed = !1,
this.game.onPause.add(this.onPause, this),
this.game.onResume.add(this.onResume, this)
}
,
s.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,
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,
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 n = 0; n < this._frames.length; n++)
this._frameData.getFrame(this._frames[n]).name === t && (i
= n);
else if ("number" == typeof t)
if (e)
i = t;
else
for (var n = 0; n < this._frames.length; n++)
this._frames[n] === t && (i = n);
if (i) {
var s = this.isReversed ? -1 : 1;
this._frameIndex = i - s,
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()
}
},
s.Animation.prototype.constructor = s.Animation,
Object.defineProperty(s.Animation.prototype, "paused", {
get: function() {
return this.isPaused
},
set: function(t) {
this.isPaused = t,
t ? this._pauseStartTime = this.game.time.time : this.isPlaying &&
(this._timeNextFrame = this.game.time.time + this.delay)
}
}),
Object.defineProperty(s.Animation.prototype, "reversed", {
get: function() {
return this.isReversed
},
set: function(t) {
this.isReversed = t
}
}),
Object.defineProperty(s.Animation.prototype, "frameTotal", {
get: function() {
return this._frames.length
}
}),
Object.defineProperty(s.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(s.Animation.prototype, "speed", {
get: function() {
return 1e3 / this.delay
},
set: function(t) {
t > 0 && (this.delay = 1e3 / t)
}
}),
Object.defineProperty(s.Animation.prototype, "enableUpdate", {
get: function() {
return null !== this.onUpdate
},
set: function(t) {
t && null === this.onUpdate ? this.onUpdate = new s.Signal : t ||
null === this.onUpdate || (this.onUpdate.dispose(),
this.onUpdate = null)
}
}),
s.Animation.generateFrameNames = function(t, e, i, n, o) {
void 0 === n && (n = "");
var r = []
, a = "";
if (e < i)
for (var h = e; h <= i; h++)
a = "number" == typeof o ? s.Utils.pad(h.toString(), o, "0", 1)
: h.toString(),
a = t + a + n,
r.push(a);
else
for (var h = e; h >= i; h--)
a = "number" == typeof o ? s.Utils.pad(h.toString(), o, "0", 1)
: h.toString(),
a = t + a + n,
r.push(a);
return r
}
,
s.Frame = function(t, e, i, n, o, r) {
this.index = t,
this.x = e,
this.y = i,
this.width = n,
this.height = o,
this.name = r,
this.centerX = Math.floor(n / 2),
this.centerY = Math.floor(o / 2),
this.distance = s.Math.distance(0, 0, n, o),
this.rotated = !1,
this.trimmed = !1,
this.sourceSizeW = n,
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
}
,
s.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 = s.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, n, s, o, r) {
this.trimmed = t,
t && (this.sourceSizeW = e,
this.sourceSizeH = i,
this.centerX = Math.floor(e / 2),
this.centerY = Math.floor(i / 2),
this.spriteSourceSizeX = n,
this.spriteSourceSizeY = s,
this.spriteSourceSizeW = o,
this.spriteSourceSizeH = r)
},
clone: function() {
var t = new
s.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
s.Rectangle(this.x,this.y,this.width,this.height) : t.setTo(this.x, this.y,
this.width, this.height),
t
}
},
s.Frame.prototype.constructor = s.Frame,
s.FrameData = function() {
this._frames = [],
this._frameNames = []
}
,
s.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 s.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 n = t; n <= e; n++)
i.push(this._frames[n]);
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 n = 0; n < this._frames.length; n++)
i.push(this._frames[n]);
else
for (var n = 0; n < t.length; n++)
e ? i.push(this.getFrame(t[n])) :
i.push(this.getFrameByName(t[n]));
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 n = 0; n < this._frames.length; n++)
i.push(this._frames[n].index);
else
for (var n = 0; n < t.length; n++)
e && this._frames[t[n]] ?
i.push(this._frames[t[n]].index) : this.getFrameByName(t[n]) &&
i.push(this.getFrameByName(t[n]).index);
return i
},
destroy: function() {
this._frames = null,
this._frameNames = null
}
},
s.FrameData.prototype.constructor = s.FrameData,
Object.defineProperty(s.FrameData.prototype, "total", {
get: function() {
return this._frames.length
}
}),
s.AnimationParser = {
spriteSheet: function(t, e, i, n, o, r, a, h) {
void 0 === o && (o = -1),
void 0 === r && (r = 0),
void 0 === a && (a = 0),
void 0 === h && (h = 0);
var l = e;
if ("string" == typeof e && (l = t.cache.getImage(e)),
null === l)
return null;
var c = l.width
, u = l.height;
i <= 0 && (i = Math.floor(-c / Math.min(-1, i))),
n <= 0 && (n = Math.floor(-u / Math.min(-1, n)));
var d = Math.floor((c - r) / (i + a))
, p = Math.floor((u - r) / (n + a))
, f = d * p;
if (h > f || h < -f)
return console.warn("Phaser.AnimationParser.spriteSheet:
skipFrames = " + h.toString() + " is larger than total sprite number " +
f.toString()),
null;
if (h < 0 && (h = f + h),
-1 !== o && (f = h + o),
0 === c || 0 === u || c < i || u < n || 0 === f)
return console.warn("Phaser.AnimationParser.spriteSheet: '" + e
+ "'s width/height zero or width/height < given frameWidth/frameHeight"),
null;
for (var m = new s.FrameData, g = r, y = r, v = 0; v < f; v++)
m.addFrame(new s.Frame(v,g,y,i,n,"")),
(g += i + a) + i > c && (g = r,
y += n + a);
return m
},
JSONData: function(t, e) {
if (!e.frames)
return console.warn("Phaser.AnimationParser.JSONData: Invalid
Texture Atlas JSON given, missing 'frames' array"),
void console.log(e);
for (var i, n = new s.FrameData, o = e.frames, r = 0; r < o.length;
r++)
i = n.addFrame(new
s.Frame(r,o[r].frame.x,o[r].frame.y,o[r].frame.w,o[r].frame.h,o[r].filename)),
o[r].trimmed && i.setTrim(o[r].trimmed, o[r].sourceSize.w,
o[r].sourceSize.h, o[r].spriteSourceSize.x, o[r].spriteSourceSize.y,
o[r].spriteSourceSize.w, o[r].spriteSourceSize.h),
o[r].rotated && (i.rotated = !0);
return n
},
JSONDataPyxel: function(t, e) {
if (["layers", "tilewidth", "tileheight", "tileswide",
"tileshigh"].forEach(function(t) {
if (!e[t])
return console.warn('Phaser.AnimationParser.JSONDataPyxel:
Invalid Pyxel Tilemap JSON given, missing "' + t + '" key.'),
void console.log(e)
}),
1 !== e.layers.length)
return console.warn("Phaser.AnimationParser.JSONDataPyxel: Too
many layers, this parser only supports flat Tilemaps."),
void console.log(e);
for (var i, n = new s.FrameData, o = e.tileheight, r = e.tilewidth,
a = e.layers[0].tiles, h = 0; h < a.length; h++)
i = n.addFrame(new s.Frame(h,a[h].x,a[h].y,r,o,"frame_" + h)),
i.setTrim(!1);
return n
},
JSONDataHash: function(t, e) {
if (!e.frames)
return console.warn("Phaser.AnimationParser.JSONDataHash:
Invalid Texture Atlas JSON given, missing 'frames' object"),
void console.log(e);
var i, n = new s.FrameData, o = e.frames, r = 0;
for (var a in o)
i = n.addFrame(new
s.Frame(r,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),
o[a].rotated && (i.rotated = !0),
r++;
return n
},
XMLData: function(t, e) {
if (!e.getElementsByTagName("TextureAtlas"))
return void console.warn("Phaser.AnimationParser.XMLData:
Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
for (var i, n, o, r, a, h, l, c, u, d, p, f = new s.FrameData, m =
e.getElementsByTagName("SubTexture"), g = 0; g < m.length; g++)
o = m[g].attributes,
n = o.name.value,
r = parseInt(o.x.value, 10),
a = parseInt(o.y.value, 10),
h = parseInt(o.width.value, 10),
l = parseInt(o.height.value, 10),
c = null,
u = null,
o.frameX && (c = Math.abs(parseInt(o.frameX.value, 10)),
u = Math.abs(parseInt(o.frameY.value, 10)),
d = parseInt(o.frameWidth.value, 10),
p = parseInt(o.frameHeight.value, 10)),
i = f.addFrame(new s.Frame(g,r,a,h,l,n)),
null === c && null === u || i.setTrim(!0, h, l, c, u, d, p);
return f
}
},
s.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: {},
compressedTexture: {}
},
this._urlMap = {},
this._urlResolver = new Image,
this._urlTemp = null,
this.onSoundUnlock = new s.Signal,
this._cacheMap = [],
this._cacheMap[s.Cache.CANVAS] = this._cache.canvas,
this._cacheMap[s.Cache.IMAGE] = this._cache.image,
this._cacheMap[s.Cache.TEXTURE] = this._cache.texture,
this._cacheMap[s.Cache.SOUND] = this._cache.sound,
this._cacheMap[s.Cache.TEXT] = this._cache.text,
this._cacheMap[s.Cache.PHYSICS] = this._cache.physics,
this._cacheMap[s.Cache.TILEMAP] = this._cache.tilemap,
this._cacheMap[s.Cache.BINARY] = this._cache.binary,
this._cacheMap[s.Cache.BITMAPDATA] = this._cache.bitmapData,
this._cacheMap[s.Cache.BITMAPFONT] = this._cache.bitmapFont,
this._cacheMap[s.Cache.JSON] = this._cache.json,
this._cacheMap[s.Cache.XML] = this._cache.xml,
this._cacheMap[s.Cache.VIDEO] = this._cache.video,
this._cacheMap[s.Cache.SHADER] = this._cache.shader,
this._cacheMap[s.Cache.RENDER_TEXTURE] = this._cache.renderTexture,
this.addDefaultImage(),
this.addMissingImage()
}
,
s.Cache.CANVAS = 1,
s.Cache.IMAGE = 2,
s.Cache.TEXTURE = 3,
s.Cache.SOUND = 4,
s.Cache.TEXT = 5,
s.Cache.PHYSICS = 6,
s.Cache.TILEMAP = 7,
s.Cache.BINARY = 8,
s.Cache.BITMAPDATA = 9,
s.Cache.BITMAPFONT = 10,
s.Cache.JSON = 11,
s.Cache.XML = 12,
s.Cache.VIDEO = 13,
s.Cache.SHADER = 14,
s.Cache.RENDER_TEXTURE = 15,
s.Cache.DEFAULT = null,
s.Cache.MISSING = null,
s.Cache.prototype = {
addCompressedTextureMetaData: function(t, e, i, n) {
this.checkImageKey(t) && this.removeImage(t);
var o = i in s.LoaderParser ? s.LoaderParser[i](n) : n
, r = {
key: t,
url: e,
data: o,
base: new PIXI.BaseTexture(o,null,this.game.resolution),
frame: new s.Frame(0,0,0,o.width,o.height,t),
frameData: new s.FrameData,
fileFormat: i
};
return r.frameData.addFrame(new s.Frame(0,0,0,o.width,o.height,e)),
this._cache.image[t] = r,
this._resolveURL(e, r),
r
},
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 n = {
key: t,
url: e,
data: i,
base: new PIXI.BaseTexture(i,null,this.game.resolution),
frame: new s.Frame(0,0,0,i.width,i.height,t),
frameData: new s.FrameData
};
return n.frameData.addFrame(new s.Frame(0,0,0,i.width,i.height,e)),
this._cache.image[t] = n,
this._resolveURL(e, n),
"__default" === t ? s.Cache.DEFAULT = new PIXI.Texture(n.base) :
"__missing" === t && (s.Cache.MISSING = new PIXI.Texture(n.base)),
n
},
addDefaultImage: function() {
var t = new Image;
t.src =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///
+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJgg
g==";
var e = this.addImage("__default", null, t);
e.base.skipRender = !0,
s.Cache.DEFAULT = new PIXI.Texture(e.base)
},
addMissingImage: function() {
var t = new Image;
t.src =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0
d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBA
RKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ
0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rw
ACp2yA/ttmvsQAAAABJRU5ErkJggg==";
var e = this.addImage("__missing", null, t);
s.Cache.MISSING = new PIXI.Texture(e.base)
},
addSound: function(t, e, i, n, s) {
void 0 === n && (n = !0,
s = !1),
void 0 === s && (n = !1,
s = !0);
var o = !1;
s && (o = !0),
this._cache.sound[t] = {
url: e,
data: i,
isDecoding: !1,
decoded: o,
webAudio: n,
audioTag: s,
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, n) {
this._cache.physics[t] = {
url: e,
data: i,
format: n
},
this._resolveURL(e, this._cache.physics[t])
},
addTilemap: function(t, e, i, n) {
this._cache.tilemap[t] = {
url: e,
data: i,
format: n
},
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 s.FrameData,
i.addFrame(e.textureFrame)),
this._cache.bitmapData[t] = {
data: e,
frameData: i
},
e
},
addBitmapFont: function(t, e, i, n, o, r, a) {
var h = {
url: e,
data: i,
font: null,
base: new PIXI.BaseTexture(i,null,this.game.resolution)
};
void 0 === r && (r = 0),
void 0 === a && (a = 0),
h.font = "json" === o ? s.LoaderParser.jsonBitmapFont(n, h.base, r,
a, !1, this.game.resolution) : s.LoaderParser.xmlBitmapFont(n, h.base, r, a, !1,
this.game.resolution),
this._cache.bitmapFont[t] = h,
this._resolveURL(e, h)
},
addBitmapFontFromAtlas: function(t, e, i, n, o, r, a) {
var h = this.getFrameByName(e, i);
if (h) {
var l = {
font: null,
base: this.getBaseTexture(e),
frame: h
};
void 0 === r && (r = 0),
void 0 === a && (a = 0);
var c;
"json" === o ? (c = this.getJSON(n),
l.font = s.LoaderParser.jsonBitmapFont(c, l.base, r, a, h,
this.game.resolution)) : (c = this.getXML(n),
l.font = s.LoaderParser.xmlBitmapFont(c, l.base, r, a, h,
this.game.resolution)),
this._cache.bitmapFont[t] = l
}
},
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, n) {
this._cache.video[t] = {
url: e,
data: i,
isBlob: n,
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 s.Frame(0,0,0,e.width,e.height,"","")
}
},
addSpriteSheet: function(t, e, i, n, o, r, a, h, l) {
void 0 === r && (r = -1),
void 0 === a && (a = 0),
void 0 === h && (h = 0);
var c = {
key: t,
url: e,
data: i,
frameWidth: n,
frameHeight: o,
margin: a,
spacing: h,
base: new PIXI.BaseTexture(i,null,this.game.resolution),
frameData: s.AnimationParser.spriteSheet(this.game, i, n, o, r,
a, h, l)
};
this._cache.image[t] = c,
this._resolveURL(e, c)
},
addTextureAtlas: function(t, e, i, n, o) {
var r = {
key: t,
url: e,
data: i,
base: new PIXI.BaseTexture(i,null,this.game.resolution)
};
o === s.Loader.TEXTURE_ATLAS_XML_STARLING ? r.frameData =
s.AnimationParser.XMLData(this.game, n, t) : o ===
s.Loader.TEXTURE_ATLAS_JSON_PYXEL ? r.frameData =
s.AnimationParser.JSONDataPyxel(this.game, n, t) : Array.isArray(n.frames) ?
r.frameData = s.AnimationParser.JSONData(this.game, n, t) : r.frameData =
s.AnimationParser.JSONDataHash(this.game, n, t),
this._cache.image[t] = r,
this._resolveURL(e, r)
},
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 n = this.getSound(t);
n && (n[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, s.Cache.SOUND, "isSoundDecoded");
if (e)
return e.decoded
},
isSoundReady: function(t) {
var e = this.getItem(t, s.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(s.Cache.CANVAS, t)
},
checkImageKey: function(t) {
return this.checkKey(s.Cache.IMAGE, t)
},
checkTextureKey: function(t) {
return this.checkKey(s.Cache.TEXTURE, t)
},
checkSoundKey: function(t) {
return this.checkKey(s.Cache.SOUND, t)
},
checkTextKey: function(t) {
return this.checkKey(s.Cache.TEXT, t)
},
checkPhysicsKey: function(t) {
return this.checkKey(s.Cache.PHYSICS, t)
},
checkTilemapKey: function(t) {
return this.checkKey(s.Cache.TILEMAP, t)
},
checkBinaryKey: function(t) {
return this.checkKey(s.Cache.BINARY, t)
},
checkBitmapDataKey: function(t) {
return this.checkKey(s.Cache.BITMAPDATA, t)
},
checkBitmapFontKey: function(t) {
return this.checkKey(s.Cache.BITMAPFONT, t)
},
checkJSONKey: function(t) {
return this.checkKey(s.Cache.JSON, t)
},
checkXMLKey: function(t) {
return this.checkKey(s.Cache.XML, t)
},
checkVideoKey: function(t) {
return this.checkKey(s.Cache.VIDEO, t)
},
checkShaderKey: function(t) {
return this.checkKey(s.Cache.SHADER, t)
},
checkRenderTextureKey: function(t) {
return this.checkKey(s.Cache.RENDER_TEXTURE, t)
},
getItem: function(t, e, i, n) {
return this.checkKey(e, t) ? void 0 === n ? this._cacheMap[e][t] :
this._cacheMap[e][t][n] : (i && console.warn("Phaser.Cache." + i + ': Key "' + t +
'" not found in Cache.'),
null)
},
getCanvas: function(t) {
return this.getItem(t, s.Cache.CANVAS, "getCanvas", "canvas")
},
getImage: function(t, e) {
void 0 !== t && null !== t || (t = "__default"),
void 0 === e && (e = !1);
var i = this.getItem(t, s.Cache.IMAGE, "getImage");
return null === i && (i = this.getItem("__missing", s.Cache.IMAGE,
"getImage")),
e ? i : i.data
},
getTextureFrame: function(t) {
return this.getItem(t, s.Cache.TEXTURE, "getTextureFrame", "frame")
},
getSound: function(t) {
return this.getItem(t, s.Cache.SOUND, "getSound")
},
getSoundData: function(t) {
return this.getItem(t, s.Cache.SOUND, "getSoundData", "data")
},
getText: function(t) {
return this.getItem(t, s.Cache.TEXT, "getText", "data")
},
getPhysicsData: function(t, e, i) {
var n = this.getItem(t, s.Cache.PHYSICS, "getPhysicsData", "data");
if (null === n || void 0 === e || null === e)
return n;
if (n[e]) {
var o = n[e];
if (!o || !i)
return o;
for (var r in o)
if (r = o[r],
r.fixtureKey === i)
return r;
console.warn('Phaser.Cache.getPhysicsData: Could not find given
fixtureKey: "' + i + " in " + t + '"')
} else
console.warn('Phaser.Cache.getPhysicsData: Invalid key/object:
"' + t + " / " + e + '"');
return null
},
getTilemapData: function(t) {
return this.getItem(t, s.Cache.TILEMAP, "getTilemapData")
},
getBinary: function(t) {
return this.getItem(t, s.Cache.BINARY, "getBinary")
},
getBitmapData: function(t) {
return this.getItem(t, s.Cache.BITMAPDATA, "getBitmapData", "data")
},
getBitmapFont: function(t) {
return this.getItem(t, s.Cache.BITMAPFONT, "getBitmapFont")
},
getJSON: function(t, e) {
var i = this.getItem(t, s.Cache.JSON, "getJSON", "data");
return i ? e ? s.Utils.extend(!0, Array.isArray(i) ? [] : {}, i) :
i : null
},
getXML: function(t) {
return this.getItem(t, s.Cache.XML, "getXML", "data")
},
getVideo: function(t) {
return this.getItem(t, s.Cache.VIDEO, "getVideo")
},
getShader: function(t) {
return this.getItem(t, s.Cache.SHADER, "getShader", "data")
},
getRenderTexture: function(t) {
return this.getItem(t, s.Cache.RENDER_TEXTURE, "getRenderTexture")
},
getBaseTexture: function(t, e) {
return void 0 === e && (e = s.Cache.IMAGE),
this.getItem(t, e, "getBaseTexture", "base")
},
getFrame: function(t, e) {
return void 0 === e && (e = s.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 = s.Cache.IMAGE),
this.getItem(t, e, "getFrameData", "frameData")
},
hasFrameData: function(t, e) {
return void 0 === e && (e = s.Cache.IMAGE),
null !== this.getItem(t, e, "", "frameData")
},
updateFrameData: function(t, e, i) {
void 0 === i && (i = s.Cache.IMAGE),
this._cacheMap[i][t] && (this._cacheMap[i][t].frameData = e)
},
getFrameByIndex: function(t, e, i) {
var n = this.getFrameData(t, i);
return n ? n.getFrame(e) : null
},
getFrameByName: function(t, e, i) {
var n = this.getFrameData(t, i);
return n ? n.getFrameByName(e) : null
},
getURL: function(t) {
var t = this._resolveURL(t);
return t ? this._urlMap[t] : (console.warn('Phaser.Cache.getUrl:
Invalid url: "' + t + '" or Cache.autoResolveURL was false'),
null)
},
getKeys: function(t) {
void 0 === t && (t = s.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.image[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
}
},
s.Cache.prototype.constructor = s.Cache,
s.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 s.Signal,
this.onLoadComplete = new s.Signal,
this.onPackComplete = new s.Signal,
this.onFileStart = new s.Signal,
this.onFileComplete = new s.Signal,
this.onFileError = new s.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
}
,
s.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0,
s.Loader.TEXTURE_ATLAS_JSON_HASH = 1,
s.Loader.TEXTURE_ATLAS_XML_STARLING = 2,
s.Loader.PHYSICS_LIME_CORONA_JSON = 3,
s.Loader.PHYSICS_PHASER_JSON = 4,
s.Loader.TEXTURE_ATLAS_JSON_PYXEL = 5,
s.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 s.Rectangle(0,0,1,t.height)
: new s.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 this.getAssetIndex(t, e) > -1
},
getAssetIndex: function(t, e) {
for (var i = -1, n = 0; n < this._fileList.length; n++) {
var s = this._fileList[n];
if (s.type === t && s.key === e && (i = n,
!s.loaded && !s.loading))
break
}
return i
},
getAsset: function(t, e) {
var i = this.getAssetIndex(t, e);
return i > -1 && {
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, n, s, o) {
if (void 0 === s && (s = !1),
void 0 === e || "" === e)
return console.warn("Phaser.Loader: Invalid or no key given of
type " + t),
this;
if (void 0 === i || null === i) {
if (!o)
return console.warn("Phaser.Loader: No URL given for file
type: " + t + " key: " + e),
this;
i = e + o
}
var r = {
type: t,
key: e,
path: this.path,
url: i,
syncPoint: this._withSyncPointDepth > 0,
data: null,
loading: !1,
loaded: !1,
error: !1
};
if (n)
for (var a in n)
r[a] = n[a];
var h = this.getAssetIndex(t, e);
if (s && h > -1) {
var l = this._fileList[h];
l.loading || l.loaded ? (this._fileList.push(r),
this._totalFileCount++) : this._fileList[h] = r
} else
-1 === h && (this._fileList.push(r),
this._totalFileCount++);
return this
},
replaceInFileList: function(t, e, i, n) {
return this.addToFileList(t, e, i, n, !0)
},
pack: function(t, e, i, n) {
if (void 0 === e && (e = null),
void 0 === i && (i = null),
void 0 === n && (n = null),
!e && !i)
return console.warn("Phaser.Loader.pack - Both url and data are
null. One must be set."),
this;
var s = {
type: "packfile",
key: t,
url: e,
path: this.path,
syncPoint: !0,
data: null,
loading: !1,
loaded: !1,
error: !1,
callbackContext: n
};
i && ("string" == typeof i && (i = JSON.parse(i)),
s.data = i || {},
s.loaded = !0);
for (var o = 0; o < this._fileList.length + 1; o++) {
var r = this._fileList[o];
if (!r || !r.loaded && !r.loading && "packfile" !== r.type) {
this._fileList.splice(o, 0, s),
this._totalPackCount++;
break
}
}
return this
},
image: function(t, e, i) {
return "object" == typeof e ? this.texture(t, e, i) :
this.addToFileList("image", t, e, void 0, i, ".png")
},
texture: function(t, e, i) {
if (this.game.renderType === s.WEBGL) {
var n, o = this.game.renderer.extensions.compression;
for (n in e)
if (n.toUpperCase()in o)
return this.addToFileList("texture", t, e[n], void 0,
i, ".pvr")
}
return e.truecolor && this.addToFileList("image", t, e.truecolor,
void 0, i, ".png"),
this
},
images: function(t, e) {
if (Array.isArray(e))
for (var i = 0; i < t.length; i++)
this.image(t[i], e[i]);
else
for (var 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, n) {
return void 0 === i && (i = !1),
!1 !== i && void 0 === n && (n = this),
this.addToFileList("script", t, e, {
syncPoint: !0,
callback: i,
callbackContext: n
}, !1, ".js")
},
binary: function(t, e, i, n) {
return void 0 === i && (i = !1),
!1 !== i && void 0 === n && (n = i),
this.addToFileList("binary", t, e, {
callback: i,
callbackContext: n
}, !1, ".bin")
},
spritesheet: function(t, e, i, n, s, o, r, a) {
return void 0 === s && (s = -1),
void 0 === o && (o = 0),
void 0 === r && (r = 0),
void 0 === a && (a = 0),
this.addToFileList("spritesheet", t, e, {
frameWidth: i,
frameHeight: n,
frameMax: s,
margin: o,
spacing: r,
skipFrames: 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, n, s) {
return this.game.sound.noAudio ? this : (void 0 === i && (i =
null),
void 0 === n && (n = null),
void 0 === s && (s = !0),
this.audio(t, e, s),
i ? this.json(t + "-audioatlas", i) : n ? ("string" == typeof n &&
(n = JSON.parse(n)),
this.cache.addJSON(t + "-audioatlas", "", n)) :
console.warn("Phaser.Loader.audiosprite - You must specify either a jsonURL or
provide a jsonData object"),
this)
},
audiosprite: function(t, e, i, n, s) {
return this.audioSprite(t, e, i, n, s)
},
video: function(t, e, i, n) {
return void 0 === i && (i = this.game.device.firefox ? "loadeddata"
: "canplaythrough"),
void 0 === n && (n = !1),
"string" == typeof e && (e = [e]),
this.addToFileList("video", t, e, {
buffer: null,
asBlob: n,
loadEvent: i
})
},
tilemap: function(t, e, i, n) {
if (void 0 === e && (e = null),
void 0 === i && (i = null),
void 0 === n && (n = s.Tilemap.CSV),
e || i || (e = n === s.Tilemap.CSV ? t + ".csv" : t + ".json"),
i) {
switch (n) {
case s.Tilemap.CSV:
break;
case s.Tilemap.TILED_JSON:
"string" == typeof i && (i = JSON.parse(i))
}
this.cache.addTilemap(t, null, i, n)
} else
this.addToFileList("tilemap", t, e, {
format: n
});
return this
},
physics: function(t, e, i, n) {
return void 0 === e && (e = null),
void 0 === i && (i = null),
void 0 === n && (n = s.Physics.LIME_CORONA_JSON),
e || i || (e = t + ".json"),
i ? ("string" == typeof i && (i = JSON.parse(i)),
this.cache.addPhysicsData(t, null, i, n)) :
this.addToFileList("physics", t, e, {
format: n
}),
this
},
bitmapFont: function(t, e, i, n, s, o) {
if (void 0 !== e && null !== e || (e = t + ".png"),
void 0 === i && (i = null),
void 0 === n && (n = null),
null === i && null === n && (i = t + ".xml"),
void 0 === s && (s = 0),
void 0 === o && (o = 0),
i)
this.addToFileList("bitmapfont", t, e, {
atlasURL: i,
xSpacing: s,
ySpacing: o
});
else if ("string" == typeof n) {
var r, a;
try {
r = JSON.parse(n)
} catch (t) {
a = this.parseXml(n)
}
if (!a && !r)
throw new Error("Phaser.Loader. Invalid Bitmap Font atlas
given");
this.addToFileList("bitmapfont", t, e, {
atlasURL: null,
atlasData: r || a,
atlasType: r ? "json" : "xml",
xSpacing: s,
ySpacing: o
})
}
return this
},
atlasJSONArray: function(t, e, i, n) {
return this.atlas(t, e, i, n, s.Loader.TEXTURE_ATLAS_JSON_ARRAY)
},
atlasJSONHash: function(t, e, i, n) {
return this.atlas(t, e, i, n, s.Loader.TEXTURE_ATLAS_JSON_HASH)
},
atlasXML: function(t, e, i, n) {
return void 0 === i && (i = null),
void 0 === n && (n = null),
i || n || (i = t + ".xml"),
this.atlas(t, e, i, n, s.Loader.TEXTURE_ATLAS_XML_STARLING)
},
atlas: function(t, e, i, n, o) {
if (void 0 !== e && null !== e || (e = t + ".png"),
void 0 === i && (i = null),
void 0 === n && (n = null),
void 0 === o && (o = s.Loader.TEXTURE_ATLAS_JSON_ARRAY),
i || n || (i = o === s.Loader.TEXTURE_ATLAS_XML_STARLING ? t +
".xml" : t + ".json"),
i)
this.addToFileList("textureatlas", t, e, {
atlasURL: i,
format: o
});
else {
switch (o) {
case s.Loader.TEXTURE_ATLAS_JSON_ARRAY:
"string" == typeof n && (n = JSON.parse(n));
break;
case s.Loader.TEXTURE_ATLAS_XML_STARLING:
if ("string" == typeof n) {
var r = this.parseXml(n);
if (!r)
throw new Error("Phaser.Loader. Invalid Texture
Atlas XML given");
n = r
}
}
this.addToFileList("textureatlas", t, e, {
atlasURL: null,
atlasData: n,
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)
return console.warn("Phaser.Loader - active loading canceled /
reset"),
void this.finishedLoading(!0);
for (var t = 0; t < this._flightQueue.length; t++) {
var e = this._flightQueue[t];
(e.loaded || e.error) && (this._flightQueue.splice(t, 1),
t--,
e.loading = !1,
e.requestUrl = null,
e.requestObject = null,
e.error && this.onFileError.dispatch(e.key, e),
"packfile" !== e.type ? (this._loadedFileCount++,
this.onFileComplete.dispatch(this.progress, e.key, !e.error,
this._loadedFileCount, this._totalFileCount)) : "packfile" === e.type && e.error &&
(this._loadedPackCount++,
this.onPackComplete.dispatch(e.key, !e.error,
this._loadedPackCount, this._totalPackCount)))
}
for (var i = !1, n = this.enableParallel ?
s.Math.clamp(this.maxParallelDownloads, 1, 12) : 1, t = this._processingHead; t <
this._fileList.length; t++) {
var e = this._fileList[t];
if ("packfile" === e.type && !e.error && e.loaded && t ===
this._processingHead && (this.processPack(e),
this._loadedPackCount++,
this.onPackComplete.dispatch(e.key, !e.error,
this._loadedPackCount, this._totalPackCount)),
e.loaded || e.error ? t === this._processingHead &&
(this._processingHead = t + 1) : !e.loading && this._flightQueue.length < n &&
("packfile" !== e.type || e.data ? i || (this._fileLoadStarted ||
(this._fileLoadStarted = !0,
this.onLoadStart.dispatch()),
this._flightQueue.push(e),
e.loading = !0,
this.onFileStart.dispatch(this.progress, e.key, e.url),
this.loadFile(e)) : (this._flightQueue.push(e),
e.loading = !0,
this.loadFile(e))),
!e.loaded && e.syncPoint && (i = !0),
this._flightQueue.length >= n || i && this._loadedPackCount ===
this._totalPackCount)
break
}
if (this.updateProgress(),
this._processingHead >= this._fileList.length)
this.finishedLoading();
else if (!this._flightQueue.length) {
console.warn("Phaser.Loader - aborting: processing queue empty,
loading may have stalled");
var o = this;
setTimeout(function() {
o.finishedLoading(!0)
}, 2e3)
}
},
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,
console.warn("Phaser.Loader - " + t.type + "[" + t.key + "]: " +
e)),
this.processLoadQueue()
},
processPack: function(t) {
var e = t.data[t.key];
if (!e)
return void console.warn("Phaser.Loader - " + t.key + ": pack
has data, but not for pack key");
for (var i = 0; i < e.length; i++) {
var n = e[i];
switch (n.type) {
case "image":
this.image(n.key, n.url, n.overwrite);
break;
case "text":
this.text(n.key, n.url, n.overwrite);
break;
case "json":
this.json(n.key, n.url, n.overwrite);
break;
case "xml":
this.xml(n.key, n.url, n.overwrite);
break;
case "script":
this.script(n.key, n.url, n.callback, t.callbackContext ||
this);
break;
case "binary":
this.binary(n.key, n.url, n.callback, t.callbackContext ||
this);
break;
case "spritesheet":
this.spritesheet(n.key, n.url, n.frameWidth, n.frameHeight,
n.frameMax, n.margin, n.spacing, n.skipFrames);
break;
case "video":
this.video(n.key, n.urls);
break;
case "audio":
this.audio(n.key, n.urls, n.autoDecode);
break;
case "audiosprite":
this.audiosprite(n.key, n.urls, n.jsonURL, n.jsonData,
n.autoDecode);
break;
case "tilemap":
this.tilemap(n.key, n.url, n.data, s.Tilemap[n.format]);
break;
case "physics":
this.physics(n.key, n.url, n.data, s.Loader[n.format]);
break;
case "bitmapFont":
this.bitmapFont(n.key, n.textureURL, n.atlasURL,
n.atlasData, n.xSpacing, n.ySpacing);
break;
case "atlasJSONArray":
this.atlasJSONArray(n.key, n.textureURL, n.atlasURL,
n.atlasData);
break;
case "atlasJSONHash":
this.atlasJSONHash(n.key, n.textureURL, n.atlasURL,
n.atlasData);
break;
case "atlasXML":
this.atlasXML(n.key, n.textureURL, n.atlasURL,
n.atlasData);
break;
case "atlas":
this.atlas(n.key, n.textureURL, n.atlasURL, n.atlasData,
s.Loader[n.format]);
break;
case "shader":
this.shader(n.key, n.url, n.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 === s.Tilemap.TILED_JSON ? this.xhrLoad(t,
this.transformUrl(t.url, t), "text", this.jsonLoadComplete) : t.format ===
s.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 "texture":
"truecolor" === t.key.split("_").pop() && this.loadImageTag(t);
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,
s.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(t, e, i, n, s) {
if (this.useXDomainRequest && window.XDomainRequest)
return void this.xhrLoadWithXDR(t, e, i, n, s);
var o = new XMLHttpRequest;
o.open("GET", e, !0),
o.responseType = i,
!1 !== this.headers.requestedWith && o.setRequestHeader("X-
Requested-With", this.headers.requestedWith),
this.headers[t.type] && o.setRequestHeader("Accept",
this.headers[t.type]),
s = s || this.fileError;
var r = this;
o.onload = function() {
try {
return 4 === o.readyState && o.status >= 400 && o.status <=
599 ? s.call(r, t, o) : n.call(r, t, o)
} catch (e) {
r.hasLoaded ? window.console && console.error(e) :
r.asyncComplete(t, e.message || "Exception")
}
}
,
o.onerror = function() {
try {
return s.call(r, t, o)
} catch (e) {
r.hasLoaded ? window.console && console.error(e) :
r.asyncComplete(t, e.message || "Exception")
}
}
,
t.requestObject = o,
t.requestUrl = e,
o.send()
},
xhrLoadWithXDR: function(t, e, i, n, s) {
this._warnedAboutXDomainRequest || this.game.device.ie && !
(this.game.device.ieVersion >= 10) || (this._warnedAboutXDomainRequest = !0,
console.warn("Phaser.Loader - using XDomainRequest outside of IE
9"));
var o = new window.XDomainRequest;
o.open("GET", e, !0),
o.responseType = i,
o.timeout = 3e3,
s = s || this.fileError;
var r = this;
o.onerror = function() {
try {
return s.call(r, t, o)
} catch (e) {
r.asyncComplete(t, e.message || "Exception")
}
}
,
o.ontimeout = function() {
try {
return s.call(r, t, o)
} catch (e) {
r.asyncComplete(t, e.message || "Exception")
}
}
,
o.onprogress = function() {}
,
o.onload = function() {
try {
return 4 === o.readyState && o.status >= 400 && o.status <=
599 ? s.call(r, t, o) : n.call(r, t, o)
} catch (e) {
r.asyncComplete(t, e.message || "Exception")
}
}
,
t.requestObject = o,
t.requestUrl = e,
setTimeout(function() {
o.send()
}, 0)
},
getVideoURL: function(t) {
for (var e = 0; e < t.length; e++) {
var i, n = t[e];
if (n.uri) {
if (i = n.type,
n = n.uri,
this.game.device.canPlayVideo(i))
return n
} else {
if (0 === n.indexOf("blob:") || 0 === n.indexOf("data:"))
return n;
n.indexOf("?") >= 0 && (n = n.substr(0, n.indexOf("?")));
if (i = n.substr((Math.max(0, n.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, n = t[e];
if (n.uri) {
if (i = n.type,
n = n.uri,
this.game.device.canPlayAudio(i))
return n
} else {
if (0 === n.indexOf("blob:") || 0 === n.indexOf("data:"))
return n;
n.indexOf("?") >= 0 && (n = n.substr(0, n.indexOf("?")));
if (i = n.substr((Math.max(0, n.lastIndexOf(".")) || 1 / 0)
+ 1).toLowerCase(),
this.game.device.canPlayAudio(i))
return t[e]
}
}
return null
},
fileError: function(t, e, i) {
var n = t.requestUrl || this.transformUrl(t.url, t)
, s = "error loading asset from URL " + n;
!i && e && (i = e.status),
i && (s = s + " (" + i + ")"),
this.asyncComplete(t, s)
},
fileComplete: function(t, e) {
var i = !0;
switch (t.type) {
case "packfile":
var n = JSON.parse(e.responseText);
t.data = n || {};
break;
case "texture":
null !== t.data ?
this.cache.addCompressedTextureMetaData(t.key, t.url,
t.url.split(".").pop().toLowerCase(), t.data) :
this.cache.addCompressedTextureMetaData(t.key, t.url,
t.url.split(".").pop().toLowerCase(), e.response);
break;
case "image":
this.cache.addImage(t.key, t.url, t.data);
break;
case "spritesheet":
this.cache.addSpriteSheet(t.key, t.url, t.data, t.frameWidth,
t.frameHeight, t.frameMax, t.margin, t.spacing, t.skipFrames);
break;
case "textureatlas":
if (null == t.atlasURL)
this.cache.addTextureAtlas(t.key, t.url, t.data,
t.atlasData, t.format);
else if (i = !1,
t.format === s.Loader.TEXTURE_ATLAS_JSON_ARRAY || t.format ===
s.Loader.TEXTURE_ATLAS_JSON_HASH || t.format === s.Loader.TEXTURE_ATLAS_JSON_PYXEL)
this.xhrLoad(t, this.transformUrl(t.atlasURL, t), "text",
this.jsonLoadComplete);
else {
if (t.format !== s.Loader.TEXTURE_ATLAS_XML_STARLING)
throw new Error("Phaser.Loader. Invalid Texture Atlas
format: " + t.format);
this.xhrLoad(t, this.transformUrl(t.atlasURL, t), "text",
this.xmlLoadComplete)
}
break;
case "bitmapfont":
t.atlasURL ? (i = !1,
this.xhrLoad(t, this.transformUrl(t.atlasURL, t), "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(t.key, t.url, t.data,
t.atlasData, t.atlasType, t.xSpacing, t.ySpacing);
break;
case "video":
if (t.asBlob)
try {
t.data = e.response
} catch (e) {
throw new Error("Phaser.Loader. Unable to parse video
file as Blob: " + t.key)
}
this.cache.addVideo(t.key, t.url, t.data, t.asBlob);
break;
case "audio":
this.game.sound.usingWebAudio ? (t.data = e.response,
this.cache.addSound(t.key, t.url, t.data, !0, !1),
t.autoDecode && this.game.sound.decode(t.key)) :
this.cache.addSound(t.key, t.url, t.data, !1, !0);
break;
case "text":
t.data = e.responseText,
this.cache.addText(t.key, t.url, t.data);
break;
case "shader":
t.data = e.responseText,
this.cache.addShader(t.key, t.url, t.data);
break;
case "physics":
var n = JSON.parse(e.responseText);
this.cache.addPhysicsData(t.key, t.url, n, t.format);
break;
case "script":
t.data = document.createElement("script"),
t.data.language = "javascript",
t.data.type = "text/javascript",
t.data.defer = !1,
t.data.text = e.responseText,
document.head.appendChild(t.data),
t.callback && (t.data = t.callback.call(t.callbackContext,
t.key, e.responseText));
break;
case "binary":
t.callback ? t.data = t.callback.call(t.callbackContext, t.key,
e.response) : t.data = e.response,
this.cache.addBinary(t.key, t.data)
}
i && this.asyncComplete(t)
},
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
, n = this.parseXml(i);
if (!n) {
var s = e.responseType || e.contentType;
return console.warn("Phaser.Loader - " + t.key + ": invalid XML
(" + s + ")"),
void this.asyncComplete(t, "invalid XML")
}
"bitmapfont" === t.type ? this.cache.addBitmapFont(t.key, t.url,
t.data, n, t.atlasType, t.xSpacing, t.ySpacing) : "textureatlas" === t.type ?
this.cache.addTextureAtlas(t.key, t.url, t.data, n, t.format) : "xml" === t.type &&
this.cache.addXML(t.key, t.url, n),
this.asyncComplete(t)
},
parseXml: function(t) {
var e;
try {
if (window.DOMParser) {
var i = new DOMParser;
e = i.parseFromString(t, "text/xml")
} else
e = new ActiveXObject("Microsoft.XMLDOM"),
e.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(s.Loader.prototype, "progressFloat", {
get: function() {
var t = this._loadedFileCount / this._totalFileCount * 100;
return s.Math.clamp(t || 0, 0, 100)
}
}),
Object.defineProperty(s.Loader.prototype, "progress", {
get: function() {
return Math.round(this.progressFloat)
}
}),
s.Loader.prototype.constructor = s.Loader,
s.LoaderParser = {
bitmapFont: function(t, e, i, n) {
return this.xmlBitmapFont(t, e, i, n)
},
xmlBitmapFont: function(t, e, i, n, s, o) {
var r = {}
, a = t.getElementsByTagName("info")[0]
, h = t.getElementsByTagName("common")[0];
r.font = a.getAttribute("face"),
r.size = parseInt(a.getAttribute("size"), 10),
r.lineHeight = parseInt(h.getAttribute("lineHeight"), 10) + n,
r.chars = {};
for (var l = t.getElementsByTagName("char"), c = s ? s.x : 0, u = s
? s.y : 0, d = 0; d < l.length; d++) {
var p = parseInt(l[d].getAttribute("id"), 10);
r.chars[p] = {
x: c + parseInt(l[d].getAttribute("x"), 10),
y: u + parseInt(l[d].getAttribute("y"), 10),
width: parseInt(l[d].getAttribute("width"), 10),
height: parseInt(l[d].getAttribute("height"), 10),
xOffset: parseInt(l[d].getAttribute("xoffset"), 10) / o,
yOffset: parseInt(l[d].getAttribute("yoffset"), 10) / o,
xAdvance: (parseInt(l[d].getAttribute("xadvance"), 10) + i)
/ o,
kerning: {}
}
}
var f = t.getElementsByTagName("kerning");
for (d = 0; d < f.length; d++) {
var m = parseInt(f[d].getAttribute("first"), 10)
, g = parseInt(f[d].getAttribute("second"), 10)
, y = parseInt(f[d].getAttribute("amount"), 10) / o;
r.chars[g].kerning[m] = y
}
return this.finalizeBitmapFont(e, r)
},
jsonBitmapFont: function(t, e, i, n, s, o) {
var r = {
font: t.font.info._face,
size: parseInt(t.font.info._size, 10),
lineHeight: parseInt(t.font.common._lineHeight, 10) + n,
chars: {}
}
, a = s ? s.x : 0
, h = s ? s.y : 0;
return t.font.chars.char.forEach(function(t) {
var e = parseInt(t._id, 10);
r.chars[e] = {
x: a + parseInt(t._x, 10),
y: h + parseInt(t._y, 10),
width: parseInt(t._width, 10),
height: parseInt(t._height, 10),
xOffset: parseInt(t._xoffset, 10) / o,
yOffset: parseInt(t._yoffset, 10) / o,
xAdvance: (parseInt(t._xadvance, 10) + i) / o,
kerning: {}
}
}),
t.font.kernings && t.font.kernings.kerning &&
t.font.kernings.kerning.forEach(function(t) {
r.chars[t._second].kerning[t._first] = parseInt(t._amount,
10) / o
}),
this.finalizeBitmapFont(e, r)
},
finalizeBitmapFont: function(t, e) {
return Object.keys(e.chars).forEach(function(i) {
var n = e.chars[i];
n.texture = new PIXI.Texture(t,new
s.Rectangle(n.x,n.y,n.width,n.height))
}),
e
},
pvr: function(t) {
var e, i = new Uint32Array(t.slice(0, 52)), n = new Uint8Array(t),
s = null, o = i[3] << 32 | i[2], r = 0;
if (55727696 === i[0] && [0, 1, 2, 3, 6, 7, 9, 11].indexOf(o) >= 0)
{
switch (o >= 0 && o <= 3 ? e = "PVRTC" : o >= 7 && o <= 11 ? e
= "S3TC" : 6 === o && (e = "ETC1"),
o) {
case 0:
r = 35841;
break;
case 1:
r = 35843;
break;
case 2:
r = 35840;
break;
case 3:
r = 35842;
break;
case 6:
r = 36196;
break;
case 7:
r = 33777;
break;
case 9:
r = 33778;
break;
case 11:
r = 33779;
break;
default:
r = -1
}
s = {
complete: !0,
fileFormat: "PVR",
compressionAlgorithm: e,
flags: i[1],
pixelFormat: o,
colorSpace: i[4],
channelType: i[5],
height: i[6],
width: i[7],
depth: i[8],
numberOfSurfaces: i[9],
numberOfFaces: i[10],
numberOfMipmaps: i[11],
metaDataSize: i[12],
textureData: n.subarray(52 + i[12], n.byteLength),
glExtensionFormat: r
}
}
return s
},
dds: function(t) {
var e = new Uint8Array(t)
, i = new Uint32Array(t)
, n = null;
return 68 === e[0] && 68 === e[1] && 83 === e[2] && 32 === e[3] &&
(n = {
complete: !0,
fileFormat: "DDS",
compressionAlgorithm: "S3TC",
size: i[1],
flags: i[2],
height: i[3],
width: i[4],
pitch: i[5],
depth: i[6],
mipmapCount: i[7],
formatSize: i[19],
formatFlag: i[19],
formatFourCC: [String.fromCharCode(e[84]),
String.fromCharCode(e[85]), String.fromCharCode(e[86]),
String.fromCharCode(e[87])].join(""),
formatBitCount: i[21],
formatRBitMask: i[22],
formatGBitMask: i[23],
formatBBitMask: i[24],
formatABitMask: i[25],
caps1: i[26],
caps2: i[27],
caps3: i[28],
caps4: i[29],
reserved2: i[30],
DXGIFormat: null,
resourceDimension: null,
miscFlag: null,
arraySize: null,
textureData: e.subarray(i[1] + 4, e.byteLength)
},
"DX10" === n.formatFourCC && (n.DXGIFormat = i[31],
n.resourceDimension = i[32],
n.miscFlag = i[33],
n.arraySize = i[34],
n.miscFlag = i[35])),
n
},
ktx: function(t) {
var e = new Uint8Array(t)
, i = new Uint32Array(t)
, n = null
, s = 16 + i[15] / 4 | 0
, o = i[s]
, r = i[7]
, a = 0;
if (171 === e[0] && 75 === e[1] && 84 === e[2] && 88 === e[3] && 32
=== e[4] && 49 === e[5] && 49 === e[6] && 187 === e[7] && 13 === e[8] && 10 ===
e[9] && 26 === e[10] && 10 === e[11] && [36196, 35840, 35841, 35842, 35843, 33776,
33777, 33778, 33779].indexOf(r) >= 0) {
switch (r) {
case 36196:
a = "ETC1";
break;
case 35840:
case 35841:
case 35842:
case 35843:
a = "PVRTC";
break;
case 33776:
case 33777:
case 33778:
case 33779:
a = "S3TC"
}
n = {
complete: !0,
fileFormat: "KTX",
compressionAlgorithm: a,
endianness: i[3],
glType: i[4],
glTypeSize: i[5],
glFormat: i[6],
glInternalFormat: i[7],
glBaseInternalFormat: i[8],
width: i[9],
height: i[10],
pixelDepth: i[11],
numberOfArrayElements: i[12],
numberOfFaces: i[13],
numberOfMipmapLevels: i[14],
bytesOfKeyValueData: i[15],
keyAndValueByteSize: i[16],
imageSize: o,
textureData: e.subarray(4 * (s + 1), o + 100)
}
}
return n
},
pkm: function(t) {
var e = new Uint8Array(t)
, i = null;
return 80 === e[0] && 75 === e[1] && 77 === e[2] && 32 === e[3] &&
(i = {
complete: !0,
fileFormat: "PKM",
compressionAlgorithm: "ETC1",
format: 65535 & (e[6] << 8 | e[7]),
width: 65535 & (e[8] << 8 | e[9]),
height: 65535 & (e[10] << 8 | e[11]),
originalWidth: 65535 & (e[12] << 8 | e[13]),
originalHeight: 65535 & (e[14] << 8 | e[15]),
textureData: e.subarray(16, e.length)
}),
i
}
},
s.AudioSprite = function(t, e) {
this.game = t,
this.key = e,
this.config = this.game.cache.getJSON(e + "-audioatlas"),
this.autoplayKey = null,
this.autoplay = !1,
this.sounds = {};
for (var i in this.config.spritemap) {
var n = this.config.spritemap[i]
, s = this.game.add.sound(this.key);
s.addMarker(i, n.start, n.end - n.start, null, n.loop),
this.sounds[i] = s
}
this.config.autoplay && (this.autoplayKey = this.config.autoplay,
this.play(this.autoplayKey),
this.autoplay = this.sounds[this.autoplayKey])
}
,
s.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]
}
},
s.AudioSprite.prototype.constructor = s.AudioSprite,
s.Sound = function(t, e, i, n, o) {
void 0 === i && (i = 1),
void 0 === n && (n = !1),
void 0 === o && (o = t.sound.connectToMaster),
this.game = t,
this.name = e,
this.key = e,
this.loop = n,
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 s.Signal,
this.onPlay = new s.Signal,
this.onPause = new s.Signal,
this.onResume = new s.Signal,
this.onLoop = new s.Signal,
this.onStop = new s.Signal,
this.onMute = new s.Signal,
this.onMarkerComplete = new s.Signal,
this.onFadeComplete = new s.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
}
,
s.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, n, s) {
void 0 !== i && null !== i || (i = 1),
void 0 !== n && null !== n || (n = 1),
void 0 === s && (s = !1),
this.markers[t] = {
name: t,
start: e,
stop: e + i,
volume: n,
duration: i,
durationMS: 1e3 * i,
loop: s
}
},
removeMarker: function(t) {
delete this.markers[t]
},
onEndedHandler: function() {
this._sound.onended = null,
this.isPlaying = !1,
this.currentTime = this.durationMS,
this.stop()
},
update: function() {
if (!this.game.cache.checkSoundKey(this.key))
return void this.destroy();
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()))
},
loopFull: function(t) {
return this.play(null, 0, t, !0)
},
play: function(t, e, i, n, s) {
if (void 0 !== t && !1 !== t && null !== t || (t = ""),
void 0 === s && (s = !0),
this.isPlaying && !this.allowMultiple && !s && !this.override)
return this;
if (this._sound && this.isPlaying && !this.allowMultiple &&
(this.override || s)) {
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
}
if ("" === t && Object.keys(this.markers).length > 0)
return this;
if ("" !== t) {
if (!this.markers[t])
return console.warn("Phaser.Sound.play: audio marker " + t
+ " doesn't exist"),
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 !== n && (this.loop = n),
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 === n && (n = this.loop),
this.position = Math.max(0, e),
this.volume = i,
this.loop = n,
this.duration = 0,
this.durationMS = 0,
this._tempMarker = t,
this._tempPosition = e,
this._tempVolume = i,
this._tempLoop = n;
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.cocoonJS || 4 === this._sound.readyState) ? (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, n) {
t = t || "",
e = e || 0,
i = i || 1,
void 0 === n && (n = !1),
this.play(t, e, i, n, !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) {
if (this.isPlaying && !this.paused && e !== this.volume) {
if (void 0 === t && (t = 1e3),
void 0 === e)
return void console.warn("Phaser.Sound.fadeTo: No Volume
Specified.");
this.fadeTween = this.game.add.tween(this).to({
volume: e
}, t, s.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())
}
},
s.Sound.prototype.constructor = s.Sound,
Object.defineProperty(s.Sound.prototype, "isDecoding", {
get: function() {
return this.game.cache.getSound(this.key).isDecoding
}
}),
Object.defineProperty(s.Sound.prototype, "isDecoded", {
get: function() {
return this.game.cache.isSoundDecoded(this.key)
}
}),
Object.defineProperty(s.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.usingWebAudio ? this.gainNode.gain.value = 0 :
this.usingAudioTag && this._sound && (this._sound.volume = 0)) : (this._muted = !1,
this.usingWebAudio ? this.gainNode.gain.value = this._muteVolume :
this.usingAudioTag && this._sound && (this._sound.volume = this._muteVolume)),
this.onMute.dispatch(this))
}
}),
Object.defineProperty(s.Sound.prototype, "volume", {
get: function() {
return this._volume
},
set: function(t) {
if (this.game.device.firefox && this.usingAudioTag && (t =
this.game.math.clamp(t, 0, 1)),
this._muted)
return void (this._muteVolume = t);
this._tempVolume = t,
this._volume = t,
this.usingWebAudio ? this.gainNode.gain.value = t :
this.usingAudioTag && this._sound && (this._sound.volume = t)
}
}),
s.SoundManager = function(t) {
this.game = t,
this.onSoundDecode = new s.Signal,
this.onVolumeChange = new s.Signal,
this.onMute = new s.Signal,
this.onUnMute = new s.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 s.ArraySet,
this._watching = !1,
this._watchCallback = null,
this._watchContext = null
}
,
s.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.iOS
|| window.PhaserGlobal && window.PhaserGlobal.fakeiOSTouchLock) &&
this.setTouchLock()
},
setTouchLock: function() {
this.noAudio || window.PhaserGlobal && !0 ===
window.PhaserGlobal.disableAudio || (this.game.device.iOSVersion > 8 ?
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)
}
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(t, e) {
e = e || null;
var i = this.game.cache.getSoundData(t);
if (i && !1 === this.game.cache.isSoundDecoded(t)) {
this.game.cache.updateSound(t, "isDecoding", !0);
var n = this;
try {
this.context.decodeAudioData(i, function(i) {
i && (n.game.cache.decodedSound(t, i),
n.onSoundDecode.dispatch(t, e))
})
} catch (t) {}
}
},
setDecodedCallback: function(t, e, i) {
"string" == typeof t && (t = [t]),
this._watchList.reset();
for (var n = 0; n < t.length; n++)
t[n]instanceof s.Sound ?
this.game.cache.isSoundDecoded(t[n].key) || this._watchList.add(t[n].key) :
this.game.cache.isSoundDecoded(t[n]) || this._watchList.add(t[n]);
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, n) {
void 0 === e && (e = 1),
void 0 === i && (i = !1),
void 0 === n && (n = this.connectToMaster);
var o = new s.Sound(this.game,t,e,i,n);
return this._sounds.push(o),
o
},
addSprite: function(t) {
return new s.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 n = this.add(t, e, i);
return n.play(),
n
}
},
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())
}
},
s.SoundManager.prototype.constructor = s.SoundManager,
Object.defineProperty(s.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(s.SoundManager.prototype, "volume", {
get: function() {
return this._volume
},
set: function(t) {
if (t < 0 ? t = 0 : t > 1 && (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)
}
}
}),
s.ScaleManager = function(t, e, i) {
this.game = t,
this.dom = s.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 s.Point,
this.forceLandscape = !1,
this.forcePortrait = !1,
this.incorrectOrientation = !1,
this._pageAlignHorizontally = !1,
this._pageAlignVertically = !1,
this.onOrientationChange = new s.Signal,
this.enterIncorrectOrientation = new s.Signal,
this.leaveIncorrectOrientation = new s.Signal,
this.hasPhaserSetFullScreen = !1,
this.fullScreenTarget = null,
this._createdFullScreenTarget = null,
this.onFullScreenInit = new s.Signal,
this.onFullScreenChange = new s.Signal,
this.onFullScreenError = new s.Signal,
this.screenOrientation = this.dom.getScreenOrientation(),
this.scaleFactor = new s.Point(1,1),
this.scaleFactorInversed = new s.Point(1,1),
this.margin = {
left: 0,
top: 0,
right: 0,
bottom: 0,
x: 0,
y: 0
},
this.bounds = new s.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 = s.ScaleManager.NO_SCALE,
this._fullScreenScaleMode = s.ScaleManager.NO_SCALE,
this.parentIsWindow = !1,
this.parentNode = null,
this.parentScaleFactor = new s.Point(1,1),
this.trackParentInterval = 2e3,
this.onSizeChange = new s.Signal,
this.onResize = null,
this.onResizeContext = null,
this._pendingScaleMode = null,
this._fullScreenRestore = null,
this._gameSize = new s.Rectangle,
this._userScaleFactor = new s.Point(1,1),
this._userScaleTrim = new s.Point(0,0),
this._lastUpdate = 0,
this._updateThrottle = 0,
this._updateThrottleReset = 100,
this._parentBounds = new s.Rectangle,
this._tempBounds = new s.Rectangle,
this._lastReportedCanvasSize = new s.Rectangle,
this._lastReportedGameSize = new s.Rectangle,
this._booted = !1,
t.config && this.parseConfig(t.config),
this.setupScale(e, i)
}
,
s.ScaleManager.EXACT_FIT = 0,
s.ScaleManager.NO_SCALE = 1,
s.ScaleManager.SHOW_ALL = 2,
s.ScaleManager.RESIZE = 3,
s.ScaleManager.USER_SCALE = 4,
s.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 s.Point(0,1) : t.scrollTo = new s.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),
s.FlexGrid && (this.grid = new
s.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, n = new s.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),
n.width = this._parentBounds.width,
n.height = this._parentBounds.height,
this.offset.set(this._parentBounds.x, this._parentBounds.y)) :
(this.parentNode = null,
this.parentIsWindow = !0,
n.width = this.dom.visualBounds.width,
n.height = this.dom.visualBounds.height,
this.offset.set(0, 0));
var o = 0
, r = 0;
"number" == typeof t ? o = t : (this.parentScaleFactor.x =
parseInt(t, 10) / 100,
o = n.width * this.parentScaleFactor.x),
"number" == typeof e ? r = e : (this.parentScaleFactor.y =
parseInt(e, 10) / 100,
r = n.height * this.parentScaleFactor.y),
o = Math.floor(o),
r = Math.floor(r),
this._gameSize.setTo(0, 0, o, r),
this.updateDimensions(o, r, !1)
},
_gameResumed: function() {
this.queueUpdate(!0)
},
setGameSize: function(t, e) {
this._gameSize.setTo(0, 0, t, e),
this.currentScaleMode !== s.ScaleManager.RESIZE &&
this.updateDimensions(t, e, !0),
this.queueUpdate(!0)
},
setUserScale: function(t, e, i, n) {
this._userScaleFactor.setTo(t, e),
this._userScaleTrim.setTo(0 | i, 0 | n),
this.queueUpdate(!0)
},
setResizeCallback: function(t, e) {
this.onResize = t,
this.onResizeContext = e
},
signalSizeChange: function() {
if (!s.Rectangle.sameDimensions(this, this._lastReportedCanvasSize)
|| !s.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 === s.ScaleManager.RESIZE &&
(this.game.state.resize(t, e),
this.game.load.resize(t, e))
}
},
setMinMax: function(t, e, i, n) {
this.minWidth = t,
this.minHeight = e,
void 0 !== i && (this.maxWidth = i),
void 0 !== n && (this.maxHeight = n)
},
preUpdate: function() {
if (!(this.game.time.time < this._lastUpdate +
this._updateThrottle)) {
var t = this._updateThrottle;
this._updateThrottleReset = t >= 400 ? 0 : 100,
this.dom.getOffset(this.game.canvas, this.offset);
var e = this._parentBounds.width
, i = this._parentBounds.height
, n = this.getParentBounds(this._parentBounds)
, o = n.width !== e || n.height !== i
, r = this.updateOrientationState();
(o || r) && (this.onResize &&
this.onResize.call(this.onResizeContext, this, n),
this.updateLayout(),
this.signalSizeChange());
var a = 2 * this._updateThrottle;
this._updateThrottle < t && (a = Math.min(t,
this._updateThrottleReset)),
this._updateThrottle = s.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
, n = e !== this.incorrectOrientation;
return n && (this.incorrectOrientation ?
this.enterIncorrectOrientation.dispatch() :
this.leaveIncorrectOrientation.dispatch()),
(i || n) && this.onOrientationChange.dispatch(this, t, e),
i || n
},
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 === s.ScaleManager.RESIZE)
return void this.reflowGame();
if (this.scrollTop(),
this.compatibility.forceMinimumDocumentHeight &&
(document.documentElement.style.minHeight = window.innerHeight + "px"),
this.incorrectOrientation ? this.setMaximum() : t ===
s.ScaleManager.EXACT_FIT ? this.setExactFit() : t === s.ScaleManager.SHOW_ALL ? !
this.isFullScreen && this.boundingParent && this.compatibility.canExpandParent ?
(this.setShowAll(!0),
this.resetCanvas(),
this.setShowAll()) : this.setShowAll() : t ===
s.ScaleManager.NO_SCALE ? (this.width = this.game.width,
this.height = this.game.height) : t === s.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 ===
s.ScaleManager.SHOW_ALL || t === s.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()
},
getParentBounds: function(t) {
var e = t || new s.Rectangle
, i = this.boundingParent
, n = this.dom.visualBounds
, o = this.dom.layoutBounds;
if (i) {
var r = i.getBoundingClientRect()
, a = i.offsetParent ? i.offsetParent.getBoundingClientRect()
: i.getBoundingClientRect();
e.setTo(r.left - a.left, r.top - a.top, r.width, r.height);
var h = this.windowConstraints;
if (h.right) {
var l = "layout" === h.right ? o : n;
e.right = Math.min(e.right, l.width)
}
if (h.bottom) {
var l = "layout" === h.bottom ? o : n;
e.bottom = Math.min(e.bottom, l.height)
}
} else
e.setTo(0, 0, n.width, n.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)
, n = this.game.canvas
, s = this.margin;
if (t) {
s.left = s.right = 0;
var o = n.getBoundingClientRect();
if (this.width < i.width && !this.incorrectOrientation) {
var r = o.left - i.x
, a = i.width / 2 - this.width / 2;
a = Math.max(a, 0);
var h = a - r;
s.left = Math.round(h)
}
n.style.marginLeft = s.left + "px",
0 !== s.left && (s.right = -(i.width - o.width - s.left),
n.style.marginRight = s.right + "px")
}
if (e) {
s.top = s.bottom = 0;
var o = n.getBoundingClientRect();
if (this.height < i.height && !this.incorrectOrientation) {
var r = o.top - i.y
, a = i.height / 2 - this.height / 2;
a = Math.max(a, 0);
var h = a - r;
s.top = Math.round(h)
}
n.style.marginTop = s.top + "px",
0 !== s.top && (s.bottom = -(i.height - o.height - s.top),
n.style.marginBottom = s.bottom + "px")
}
s.x = s.left,
s.y = s.top
},
reflowGame: function() {
this.resetCanvas("", "");
var t = this.getParentBounds(this._tempBounds);
this.updateDimensions(t.width, t.height, !0)
},
reflowCanvas: function() {
this.incorrectOrientation || (this.width = s.Math.clamp(this.width,
this.minWidth || 0, this.maxWidth || this.width),
this.height = s.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), n = i.width, s =
i.height;
e = t ? Math.max(s / this.game.height, n / this.game.width) :
Math.min(s / this.game.height, n / 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) {
var i = this;
return void setTimeout(function() {
i.fullScreenError()
}, 10)
}
if ("when-not-mouse" === this.compatibility.clickTrampoline) {
var n = this.game.input;
if (n.activePointer && n.activePointer !== n.mousePointer && (e
|| !1 !== e))
return void
n.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this,
[t, !1])
}
void 0 !== t && this.game.renderType === s.CANVAS &&
(this.game.stage.smoothed = t);
var o = this.fullScreenTarget;
o || (this.cleanupCreatedTarget(),
this._createdFullScreenTarget = this.createFullScreenTarget(),
o = this._createdFullScreenTarget);
var r = {
targetElement: o
};
if (this.hasPhaserSetFullScreen = !0,
this.onFullScreenInit.dispatch(this, r),
this._createdFullScreenTarget) {
var a = this.game.canvas;
a.parentNode.insertBefore(o, a),
o.appendChild(a)
}
return this.game.device.fullscreenKeyboard ?
o[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT) :
o[this.game.device.requestFullscreen](),
!0
},
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 === s.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.updateLayout(),
this.queueUpdate(!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(),
console.warn("Phaser.ScaleManager: requestFullscreen failed or
device does not support the Fullscreen API"),
this.onFullScreenError.dispatch(this)
},
scaleSprite: function(t, e, i, n) {
if (void 0 === e && (e = this.width),
void 0 === i && (i = this.height),
void 0 === n && (n = !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 s = e
, o = t.height * e / t.width
, r = t.width * i / t.height
, a = i
, h = r > e;
return h = h ? n : !n,
h ? (t.width = Math.floor(s),
t.height = Math.floor(o)) : (t.width = Math.floor(r),
t.height = Math.floor(a)),
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))
}
},
s.ScaleManager.prototype.constructor = s.ScaleManager,
Object.defineProperty(s.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(s.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(s.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(s.ScaleManager.prototype, "currentScaleMode", {
get: function() {
return this.isFullScreen ? this._fullScreenScaleMode :
this._scaleMode
}
}),
Object.defineProperty(s.ScaleManager.prototype, "pageAlignHorizontally", {
get: function() {
return this._pageAlignHorizontally
},
set: function(t) {
t !== this._pageAlignHorizontally && (this._pageAlignHorizontally =
t,
this.queueUpdate(!0))
}
}),
Object.defineProperty(s.ScaleManager.prototype, "pageAlignVertically", {
get: function() {
return this._pageAlignVertically
},
set: function(t) {
t !== this._pageAlignVertically && (this._pageAlignVertically = t,
this.queueUpdate(!0))
}
}),
Object.defineProperty(s.ScaleManager.prototype, "isFullScreen", {
get: function() {
return !!(document.fullscreenElement ||
document.webkitFullscreenElement || document.mozFullScreenElement ||
document.msFullscreenElement)
}
}),
Object.defineProperty(s.ScaleManager.prototype, "isPortrait", {
get: function() {
return "portrait" ===
this.classifyOrientation(this.screenOrientation)
}
}),
Object.defineProperty(s.ScaleManager.prototype, "isLandscape", {
get: function() {
return "landscape" ===
this.classifyOrientation(this.screenOrientation)
}
}),
Object.defineProperty(s.ScaleManager.prototype, "isGamePortrait", {
get: function() {
return this.height > this.width
}
}),
Object.defineProperty(s.ScaleManager.prototype, "isGameLandscape", {
get: function() {
return this.width > this.height
}
}),
s.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
}
,
s.Utils.Debug.prototype = {
boot: function() {
this.game.renderType === s.CANVAS ? this.context =
this.game.context : (this.bmd = new
s.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 = s.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, n) {
"number" != typeof t && (t = 0),
"number" != typeof e && (e = 0),
i = i || "rgb(255,255,255)",
void 0 === n && (n = 0),
this.currentX = t,
this.currentY = e,
this.currentColor = i,
this.columnWidth = n,
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, n) {
this.start(e, i, n),
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, n) {
this.start(e, i, n),
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, n) {
this.start(e, i, n),
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, n, s) {
null != t && (void 0 === e && (e = !1),
i = i || "rgba(0,255,0,0.5)",
n = n || "rgba(255,0,0,0.5)",
!0 === e && !0 === t.isUp || (this.start(t.x, t.y - 100, s),
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 = n,
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, n) {
this.start(e, i, n),
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, n) {
this.start(e, i, n, 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 n = t.getBounds();
n.x += this.game.camera.x,
n.y += this.game.camera.y,
this.rectangle(n, e, i)
},
ropeSegments: function(t, e, i) {
var n = this;
t.segments.forEach(function(t) {
n.rectangle(t, e, i)
}, this)
},
spriteInfo: function(t, e, i, n) {
this.start(e, i, n),
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, n) {
this.start(e, i, n, 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, n) {
this.start(e, i, n, 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, n) {
n = n || 2,
this.start(),
this.context.fillStyle = i,
this.context.fillRect(t, e, n, n),
this.stop()
},
geom: function(t, e, i, n) {
void 0 === i && (i = !0),
void 0 === n && (n = 0),
e = e || "rgba(0,255,0,0.4)",
this.start(),
this.context.fillStyle = e,
this.context.strokeStyle = e,
t instanceof s.Rectangle || 1 === n ? 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 s.Circle || 2 === n ? (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
s.Point || 3 === n ? this.context.fillRect(t.x - this.game.camera.x, t.y -
this.game.camera.y, 4, 4) : (t instanceof s.Line || 4 === n) &&
(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, n, s) {
n = n || "rgb(255,255,255)",
s = s || "16px Courier",
this.start(),
this.context.font = s,
this.renderShadow && (this.context.fillStyle = "rgb(0,0,0)",
this.context.fillText(t, e + 1, i + 1)),
this.context.fillStyle = n,
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 n = 0; n < t.objects.length; n++)
this.context.strokeRect(t.objects[n].x, t.objects[n].y,
t.objects[n].width, t.objects[n].height)
} else
for (var n = 0; n < t.nodes.length; n++)
this.quadTree(t.nodes[n]);
this.stop()
},
body: function(t, e, i) {
t.body && (this.start(),
t.body.type === s.Physics.ARCADE ?
s.Physics.Arcade.Body.render(this.context, t.body, e, i) : t.body.type ===
s.Physics.NINJA ? s.Physics.Ninja.Body.render(this.context, t.body, e, i) :
t.body.type === s.Physics.BOX2D && s.Physics.Box2D.renderBody(this.context, t.body,
e),
this.stop())
},
bodyInfo: function(t, e, i, n) {
t.body && (this.start(e, i, n, 210),
t.body.type === s.Physics.ARCADE ?
s.Physics.Arcade.Body.renderBodyInfo(this, t.body) : t.body.type ===
s.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(),
s.Physics.Box2D.renderBody(this.context, t, e),
this.stop()
},
displayList: function(t) {
if (void 0 === t && (t = this.game.world),
t.hasOwnProperty("renderOrderID") ? console.log("[" +
t.renderOrderID + "]", t) : console.log("[]", t),
t.children && t.children.length > 0)
for (var e = 0; e < t.children.length; e++)
this.game.debug.displayList(t.children[e])
},
destroy: function() {
s.CanvasPool.remove(this)
}
},
s.Utils.Debug.prototype.constructor = s.Utils.Debug,
s.DOM = {
getOffset: function(t, e) {
e = e || new s.Point;
var i = t.getBoundingClientRect()
, n = s.DOM.scrollY
, o = s.DOM.scrollX
, r = document.documentElement.clientTop
, a = document.documentElement.clientLeft;
return e.x = i.left + o - a,
e.y = i.top + n - r,
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) {
t = null == t ? this.visualBounds : 1 === t.nodeType ?
this.getBounds(t) : t;
var e = 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 && i.bottom >= 0 && i.right >= 0 && 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 n = "portrait-primary"
, s = "landscape-primary";
if ("screen" === t)
return e.height > e.width ? n : s;
if ("viewport" === t)
return this.visualBounds.height > this.visualBounds.width ? n :
s;
if ("window.orientation" === t && "number" == typeof
window.orientation)
return 0 === window.orientation || 180 === window.orientation ?
n : s;
if (window.matchMedia) {
if (window.matchMedia("(orientation: portrait)").matches)
return n;
if (window.matchMedia("(orientation: landscape)").matches)
return s
}
return this.visualBounds.height > this.visualBounds.width ? n : s
},
visualBounds: new s.Rectangle,
layoutBounds: new s.Rectangle,
documentBounds: new s.Rectangle
},
s.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(s.DOM, "scrollX", {
get: e
}),
Object.defineProperty(s.DOM, "scrollY", {
get: i
}),
Object.defineProperty(s.DOM.visualBounds, "x", {
get: e
}),
Object.defineProperty(s.DOM.visualBounds, "y", {
get: i
}),
Object.defineProperty(s.DOM.layoutBounds, "x", {
value: 0
}),
Object.defineProperty(s.DOM.layoutBounds, "y", {
value: 0
}),
t.desktop && document.documentElement.clientWidth <= window.innerWidth
&& document.documentElement.clientHeight <= window.innerHeight) {
var n = function() {
return Math.max(window.innerWidth,
document.documentElement.clientWidth)
}
, o = function() {
return Math.max(window.innerHeight,
document.documentElement.clientHeight)
};
Object.defineProperty(s.DOM.visualBounds, "width", {
get: n
}),
Object.defineProperty(s.DOM.visualBounds, "height", {
get: o
}),
Object.defineProperty(s.DOM.layoutBounds, "width", {
get: n
}),
Object.defineProperty(s.DOM.layoutBounds, "height", {
get: o
})
} else
Object.defineProperty(s.DOM.visualBounds, "width", {
get: function() {
return window.innerWidth
}
}),
Object.defineProperty(s.DOM.visualBounds, "height", {
get: function() {
return window.innerHeight
}
}),
Object.defineProperty(s.DOM.layoutBounds, "width", {
get: function() {
var t = document.documentElement.clientWidth
, e = window.innerWidth;
return t < e ? e : t
}
}),
Object.defineProperty(s.DOM.layoutBounds, "height", {
get: function() {
var t = document.documentElement.clientHeight
, e = window.innerHeight;
return t < e ? e : t
}
});
Object.defineProperty(s.DOM.documentBounds, "x", {
value: 0
}),
Object.defineProperty(s.DOM.documentBounds, "y", {
value: 0
}),
Object.defineProperty(s.DOM.documentBounds, "width", {
get: function() {
var t = document.documentElement;
return Math.max(t.clientWidth, t.offsetWidth, t.scrollWidth)
}
}),
Object.defineProperty(s.DOM.documentBounds, "height", {
get: function() {
var t = document.documentElement;
return Math.max(t.clientHeight, t.offsetHeight, t.scrollHeight)
}
})
}, null, !0),
s.ArraySet = function(t) {
this.position = 0,
this.list = t || []
}
,
s.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 this.list.indexOf(t) > -1
},
reset: function() {
this.list.length = 0
},
remove: function(t) {
var e = this.list.indexOf(t);
if (e > -1)
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(s.ArraySet.prototype, "total", {
get: function() {
return this.list.length
}
}),
Object.defineProperty(s.ArraySet.prototype, "first", {
get: function() {
return this.position = 0,
this.list.length > 0 ? this.list[0] : null
}
}),
Object.defineProperty(s.ArraySet.prototype, "next", {
get: function() {
return this.position < this.list.length ? (this.position++,
this.list[this.position]) : null
}
}),
s.ArraySet.prototype.constructor = s.ArraySet,
s.ArrayUtils = {
getRandomItem: function(t, e, i) {
if (null === t)
return null;
void 0 === e && (e = 0),
void 0 === i && (i = t.length);
var n = e + Math.floor(Math.random() * i);
return void 0 === t[n] ? null : t[n]
},
removeRandomItem: function(t, e, i) {
if (null == t)
return null;
void 0 === e && (e = 0),
void 0 === i && (i = t.length);
var n = e + Math.floor(Math.random() * i);
if (n < t.length) {
var s = t.splice(n, 1);
return void 0 === s[0] ? null : s[0]
}
return null
},
shuffle: function(t) {
for (var e = t.length - 1; e > 0; e--) {
var i = Math.floor(Math.random() * (e + 1))
, n = t[e];
t[e] = t[i],
t[i] = n
}
return t
},
transposeMatrix: function(t) {
for (var e = t.length, i = t[0].length, n = new Array(i), s = 0; s
< i; s++) {
n[s] = new Array(e);
for (var o = e - 1; o > -1; o--)
n[s][o] = t[o][s]
}
return n
},
rotateMatrix: function(t, e) {
if ("string" != typeof e && (e = (e % 360 + 360) % 360),
90 === e || -270 === e || "rotateLeft" === e)
t = s.ArrayUtils.transposeMatrix(t),
t = t.reverse();
else if (-90 === e || 270 === e || "rotateRight" === e)
t = t.reverse(),
t = s.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 n = e[i - 1]
, s = i < e.length ? e[i] : Number.POSITIVE_INFINITY;
return s - t <= t - n ? s : n
},
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 = [], n = t; n <= e; n++)
i.push(n);
return i
},
numberArrayStep: function(t, e, i) {
void 0 !== t && null !== t || (t = 0),
void 0 !== e && null !== e || (e = t,
t = 0),
void 0 === i && (i = 1);
for (var n = [], o = Math.max(s.Math.roundAwayFromZero((e - t) / (i
|| 1)), 0), r = 0; r < o; r++)
n.push(t),
t += i;
return n
}
},
s.LinkedList = function() {
this.next = null,
this.prev = null,
this.first = null,
this.last = null,
this.total = 0
}
,
s.LinkedList.prototype = {
add: function(t) {
return 0 === this.total && null === this.first && null ===
this.last ? (this.first = t,
this.last = t,
this.next = t,
t.prev = this,
this.total++,
t) : (this.last.next = t,
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) {
var e = this.first;
do {
e && e[t] && e[t].call(e),
e = e.next
} while (e !== this.last.next)
}
}
},
s.LinkedList.prototype.constructor = s.LinkedList,
s.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"
}]
}
,
s.Create.PALETTE_ARNE = 0,
s.Create.PALETTE_JMP = 1,
s.Create.PALETTE_CGA = 2,
s.Create.PALETTE_C64 = 3,
s.Create.PALETTE_JAPANESE_MACHINE = 4,
s.Create.prototype = {
texture: function(t, e, i, n, s) {
void 0 === i && (i = 8),
void 0 === n && (n = i),
void 0 === s && (s = 0);
var o = e[0].length * i
, r = e.length * n;
null === this.bmd && (this.bmd = this.game.make.bitmapData(),
this.canvas = this.bmd.canvas,
this.ctx = this.bmd.context),
this.bmd.resize(o, r),
this.bmd.clear();
for (var a = 0; a < e.length; a++)
for (var h = e[a], l = 0; l < h.length; l++) {
var c = h[l];
"." !== c && " " !== c && (this.ctx.fillStyle =
this.palettes[s][c],
this.ctx.fillRect(l * i, a * n, i, n))
}
return this.bmd.generateTexture(t)
},
grid: function(t, e, i, n, s, o) {
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 = o;
for (var r = 0; r < i; r += s)
this.ctx.fillRect(0, r, e, 1);
for (var a = 0; a < e; a += n)
this.ctx.fillRect(a, 0, 1, i);
return this.bmd.generateTexture(t)
}
},
s.Create.prototype.constructor = s.Create,
s.FlexGrid = function(t, e, i) {
this.game = t.game,
this.manager = t,
this.width = e,
this.height = i,
this.boundsCustom = new s.Rectangle(0,0,e,i),
this.boundsFluid = new s.Rectangle(0,0,e,i),
this.boundsFull = new s.Rectangle(0,0,e,i),
this.boundsNone = new s.Rectangle(0,0,e,i),
this.positionCustom = new s.Point(0,0),
this.positionFluid = new s.Point(0,0),
this.positionFull = new s.Point(0,0),
this.positionNone = new s.Point(0,0),
this.scaleCustom = new s.Point(1,1),
this.scaleFluid = new s.Point(1,1),
this.scaleFluidInversed = new s.Point(1,1),
this.scaleFull = new s.Point(1,1),
this.scaleNone = new s.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 = []
}
,
s.FlexGrid.prototype = {
setSize: function(t, e) {
this.width = t,
this.height = e,
this.ratioH = t / e,
this.ratioV = e / t,
this.scaleNone = new s.Point(1,1),
this.boundsNone.width = this.width,
this.boundsNone.height = this.height,
this.refresh()
},
createCustomLayer: function(t, e, i, n) {
void 0 === n && (n = !0),
this.customWidth = t,
this.customHeight = e,
this.boundsCustom.width = t,
this.boundsCustom.height = e;
var o = new
s.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);
return n && 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
s.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
s.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
s.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)
}
},
s.FlexGrid.prototype.constructor = s.FlexGrid,
s.FlexLayer = function(t, e, i, n) {
s.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 = n,
this.topLeft = i.topLeft,
this.topMiddle = new s.Point(i.halfWidth,0),
this.topRight = i.topRight,
this.bottomLeft = i.bottomLeft,
this.bottomMiddle = new s.Point(i.halfWidth,i.bottom),
this.bottomRight = i.bottomRight
}
,
s.FlexLayer.prototype = Object.create(s.Group.prototype),
s.FlexLayer.prototype.constructor = s.FlexLayer,
s.FlexLayer.prototype.resize = function() {}
,
s.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")
}
,
s.Color = {
packPixel: function(t, e, i, n) {
return s.Device.LITTLE_ENDIAN ? (n << 24 | i << 16 | e << 8 | t)
>>> 0 : (t << 24 | e << 16 | i << 8 | n) >>> 0
},
unpackPixel: function(t, e, i, n) {
return void 0 !== e && null !== e || (e = s.Color.createColor()),
void 0 !== i && null !== i || (i = !1),
void 0 !== n && null !== n || (n = !1),
s.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 && s.Color.RGBtoHSL(e.r, e.g, e.b, e),
n && s.Color.RGBtoHSV(e.r, e.g, e.b, e),
e
},
fromRGBA: function(t, e) {
return e || (e = s.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, n) {
return t << 24 | e << 16 | i << 8 | n
},
toABGR: function(t, e, i, n) {
return (n << 24 | i << 16 | e << 8 | t) >>> 0
},
hexToRGBArray: function(t) {
return [(t >> 16 & 255) / 255, (t >> 8 & 255) / 255, (255 & t) /
255]
},
RGBArrayToHex: function(t) {
return (255 * t[0] << 16) + (255 * t[1] << 8) + 255 * t[2]
},
RGBtoHSL: function(t, e, i, n) {
n || (n = s.Color.createColor(t, e, i, 1)),
t /= 255,
e /= 255,
i /= 255;
var o = Math.min(t, e, i)
, r = Math.max(t, e, i);
if (n.h = 0,
n.s = 0,
n.l = (r + o) / 2,
r !== o) {
var a = r - o;
n.s = n.l > .5 ? a / (2 - r - o) : a / (r + o),
r === t ? n.h = (e - i) / a + (e < i ? 6 : 0) : r === e ? n.h =
(i - t) / a + 2 : r === i && (n.h = (t - e) / a + 4),
n.h /= 6
}
return n
},
HSLtoRGB: function(t, e, i, n) {
if (n ? (n.r = i,
n.g = i,
n.b = i) : n = s.Color.createColor(i, i, i),
0 !== e) {
var o = i < .5 ? i * (1 + e) : i + e - i * e
, r = 2 * i - o;
n.r = s.Color.hueToColor(r, o, t + 1 / 3),
n.g = s.Color.hueToColor(r, o, t),
n.b = s.Color.hueToColor(r, o, t - 1 / 3)
}
return n.r = Math.floor(255 * n.r | 0),
n.g = Math.floor(255 * n.g | 0),
n.b = Math.floor(255 * n.b | 0),
s.Color.updateColor(n),
n
},
RGBtoHSV: function(t, e, i, n) {
n || (n = s.Color.createColor(t, e, i, 255)),
t /= 255,
e /= 255,
i /= 255;
var o = Math.min(t, e, i)
, r = Math.max(t, e, i)
, a = r - o;
return n.h = 0,
n.s = 0 === r ? 0 : a / r,
n.v = r,
r !== o && (r === t ? n.h = (e - i) / a + (e < i ? 6 : 0) : r === e
? n.h = (i - t) / a + 2 : r === i && (n.h = (t - e) / a + 4),
n.h /= 6),
n
},
HSVtoRGB: function(t, e, i, n) {
void 0 === n && (n = s.Color.createColor(0, 0, 0, 1, t, e, 0, i));
var o, r, a, h = Math.floor(6 * t), l = 6 * t - h, c = i * (1 - e),
u = i * (1 - l * e), d = i * (1 - (1 - l) * e);
switch (h % 6) {
case 0:
o = i,
r = d,
a = c;
break;
case 1:
o = u,
r = i,
a = c;
break;
case 2:
o = c,
r = i,
a = d;
break;
case 3:
o = c,
r = u,
a = i;
break;
case 4:
o = d,
r = c,
a = i;
break;
case 5:
o = i,
r = c,
a = u
}
return n.r = Math.floor(255 * o),
n.g = Math.floor(255 * r),
n.b = Math.floor(255 * a),
s.Color.updateColor(n),
n
},
hueToColor: function(t, e, i) {
return i < 0 && (i += 1),
i > 1 && (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, n, o, r, a, h) {
var l = {
r: t || 0,
g: e || 0,
b: i || 0,
a: n || 1,
h: o || 0,
s: r || 0,
l: a || 0,
v: h || 0,
color: 0,
color32: 0,
rgba: ""
};
return s.Color.updateColor(l)
},
updateColor: function(t) {
return t.rgba = "rgba(" + t.r.toString() + "," + t.g.toString() +
"," + t.b.toString() + "," + t.a.toString() + ")",
t.color = s.Color.getColor(t.r, t.g, t.b),
t.color32 = s.Color.getColor32(255 * t.a, t.r, t.g, t.b),
t
},
getColor32: function(t, e, i, n) {
return t << 24 | e << 16 | i << 8 | n
},
getColor: function(t, e, i) {
return t << 16 | e << 8 | i
},
RGBtoString: function(t, e, i, n, o) {
return void 0 === n && (n = 255),
void 0 === o && (o = "#"),
"#" === o ? "#" + ((1 << 24) + (t << 16) + (e << 8) +
i).toString(16).slice(1) : "0x" + s.Color.componentToHex(n) +
s.Color.componentToHex(t) + s.Color.componentToHex(e) + s.Color.componentToHex(i)
},
hexToRGB: function(t) {
var e = s.Color.hexToColor(t);
if (e)
return s.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, n) {
return e + e + i + i + n + n
});
var i = /^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);
if (i) {
var n = parseInt(i[1], 16)
, o = parseInt(i[2], 16)
, r = parseInt(i[3], 16);
e ? (e.r = n,
e.g = o,
e.b = r) : e = s.Color.createColor(n, o, r)
}
return e
},
webToColor: function(t, e) {
e || (e = s.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,
s.Color.updateColor(e)),
e
},
valueToColor: function(t, e) {
if (e || (e = s.Color.createColor()),
"string" == typeof t)
return 0 === t.indexOf("rgb") ? s.Color.webToColor(t, e) : (e.a
= 1,
s.Color.hexToColor(t, e));
if ("number" == typeof t) {
var i = s.Color.getRGB(t);
return e.r = i.r,
e.g = i.g,
e.b = i.b,
e.a = i.a / 255,
e
}
return 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 = [], n = 0; n <= 359; n++)
i.push(s.Color.HSVtoRGB(n / 359, t, e));
return i
},
HSLColorWheel: function(t, e) {
void 0 === t && (t = .5),
void 0 === e && (e = .5);
for (var i = [], n = 0; n <= 359; n++)
i.push(s.Color.HSLtoRGB(n / 359, t, e));
return i
},
interpolateColor: function(t, e, i, n, o) {
void 0 === o && (o = 255);
var r = s.Color.getRGB(t)
, a = s.Color.getRGB(e)
, h = (a.red - r.red) * n / i + r.red
, l = (a.green - r.green) * n / i + r.green
, c = (a.blue - r.blue) * n / i + r.blue;
return s.Color.getColor32(o, h, l, c)
},
interpolateColorWithRGB: function(t, e, i, n, o, r) {
var a = s.Color.getRGB(t)
, h = (e - a.red) * r / o + a.red
, l = (i - a.green) * r / o + a.green
, c = (n - a.blue) * r / o + a.blue;
return s.Color.getColor(h, l, c)
},
interpolateRGB: function(t, e, i, n, o, r, a, h) {
var l = (n - t) * h / a + t
, c = (o - e) * h / a + e
, u = (r - i) * h / a + i;
return s.Color.getColor(l, c, u)
},
getRandomColor: function(t, e, i) {
if (void 0 === t && (t = 0),
void 0 === e && (e = 255),
void 0 === i && (i = 255),
e > 255 || t > e)
return s.Color.getColor(255, 255, 255);
var n = t + Math.round(Math.random() * (e - t))
, o = t + Math.round(Math.random() * (e - t))
, r = t + Math.round(Math.random() * (e - t));
return s.Color.getColor32(i, n, o, r)
},
getRGB: function(t) {
return t > 16777215 ? {
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 = s.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 e > t ? e : t
},
blendDarken: function(t, e) {
return e > t ? 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 s.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 s.Color.blendAdd(t, e)
},
blendLinearBurn: function(t, e) {
return s.Color.blendSubtract(t, e)
},
blendLinearLight: function(t, e) {
return e < 128 ? s.Color.blendLinearBurn(t, 2 * e) :
s.Color.blendLinearDodge(t, 2 * (e - 128))
},
blendVividLight: function(t, e) {
return e < 128 ? s.Color.blendColorBurn(t, 2 * e) :
s.Color.blendColorDodge(t, 2 * (e - 128))
},
blendPinLight: function(t, e) {
return e < 128 ? s.Color.blendDarken(t, 2 * e) :
s.Color.blendLighten(t, 2 * (e - 128))
},
blendHardMix: function(t, e) {
return s.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 s.Color.blendReflect(e, t)
},
blendPhoenix: function(t, e) {
return Math.min(t, e) - Math.max(t, e) + 255
}
},
s.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()
}
,
s.Physics.ARCADE = 0,
s.Physics.P2JS = 1,
s.Physics.NINJA = 2,
s.Physics.BOX2D = 3,
s.Physics.CHIPMUNK = 4,
s.Physics.MATTERJS = 5,
s.Physics.prototype = {
parseConfig: function() {
this.config.hasOwnProperty("arcade") && !0 !== this.config.arcade
|| !s.Physics.hasOwnProperty("Arcade") || (this.arcade = new
s.Physics.Arcade(this.game)),
this.config.hasOwnProperty("ninja") && !0 === this.config.ninja &&
s.Physics.hasOwnProperty("Ninja") && (this.ninja = new s.Physics.Ninja(this.game)),
this.config.hasOwnProperty("p2") && !0 === this.config.p2 &&
s.Physics.hasOwnProperty("P2") && (this.p2 = new
s.Physics.P2(this.game,this.config)),
this.config.hasOwnProperty("box2d") && !0 === this.config.box2d &&
s.Physics.hasOwnProperty("BOX2D") && (this.box2d = new
s.Physics.BOX2D(this.game,this.config)),
this.config.hasOwnProperty("matter") && !0 === this.config.matter
&& s.Physics.hasOwnProperty("Matter") && (this.matter = new
s.Physics.Matter(this.game,this.config))
},
startSystem: function(t) {
t === s.Physics.ARCADE ? this.arcade = new
s.Physics.Arcade(this.game) : t === s.Physics.P2JS ? null === this.p2 ? this.p2 =
new s.Physics.P2(this.game,this.config) : this.p2.reset() : t === s.Physics.NINJA ?
this.ninja = new s.Physics.Ninja(this.game) : t === s.Physics.BOX2D ? null ===
this.box2d ? this.box2d = new s.Physics.Box2D(this.game,this.config) :
this.box2d.reset() : t === s.Physics.MATTERJS && (null === this.matter ?
this.matter = new s.Physics.Matter(this.game,this.config) : this.matter.reset())
},
enable: function(t, e, i) {
void 0 === e && (e = s.Physics.ARCADE),
void 0 === i && (i = !1),
e === s.Physics.ARCADE ? this.arcade.enable(t) : e ===
s.Physics.P2JS && this.p2 ? this.p2.enable(t, i) : e === s.Physics.NINJA &&
this.ninja ? this.ninja.enableAABB(t) : e === s.Physics.BOX2D && this.box2d ?
this.box2d.enable(t) : e === s.Physics.MATTERJS && this.matter ?
this.matter.enable(t) : console.warn(t.key + " is attempting to enable a physics
body using an unknown physics system.")
},
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
}
},
s.Physics.prototype.constructor = s.Physics,
s.Physics.Arcade = function(t) {
this.game = t,
this.gravity = new s.Point,
this.bounds = new s.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 = s.Physics.Arcade.LEFT_RIGHT,
this.skipQuadTree = !0,
this.isPaused = !1,
this.quadTree = new
s.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()
}
,
s.Physics.Arcade.prototype.constructor = s.Physics.Arcade,
s.Physics.Arcade.SORT_NONE = 0,
s.Physics.Arcade.LEFT_RIGHT = 1,
s.Physics.Arcade.RIGHT_LEFT = 2,
s.Physics.Arcade.TOP_BOTTOM = 3,
s.Physics.Arcade.BOTTOM_TOP = 4,
s.Physics.Arcade.prototype = {
setBounds: function(t, e, i, n) {
this.bounds.setTo(t, e, i, n)
},
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 s.Group ? this.enable(t[i].children, e) :
(this.enableBody(t[i]),
e && t[i].hasOwnProperty("children") &&
t[i].children.length > 0 && this.enable(t[i], !0));
else
t instanceof s.Group ? this.enable(t.children, e) :
(this.enableBody(t),
e && t.hasOwnProperty("children") && t.children.length > 0 &&
this.enable(t.children, !0))
},
enableBody: function(t) {
t.hasOwnProperty("body") && null === t.body && (t.body = new
s.Physics.Arcade.Body(t),
t.parent && t.parent instanceof s.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, n, s, o) {
return void 0 === o && (o = 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),
n ? i += n * this.game.time.physicsElapsed : s && (s *=
this.game.time.physicsElapsed,
i - s > 0 ? i -= s : i + s < 0 ? i += s : i = 0),
i > o ? i = o : i < -o && (i = -o),
i
},
overlap: function(t, e, i, n, s) {
if (i = i || null,
n = n || null,
s = s || i,
this._total = 0,
!Array.isArray(t) && Array.isArray(e))
for (var o = 0; o < e.length; o++)
this.collideHandler(t, e[o], i, n, s, !0);
else if (Array.isArray(t) && !Array.isArray(e))
for (var o = 0; o < t.length; o++)
this.collideHandler(t[o], e, i, n, s, !0);
else if (Array.isArray(t) && Array.isArray(e))
for (var o = 0; o < t.length; o++)
for (var r = 0; r < e.length; r++)
this.collideHandler(t[o], e[r], i, n, s, !0);
else
this.collideHandler(t, e, i, n, s, !0);
return this._total > 0
},
collide: function(t, e, i, n, s) {
if (i = i || null,
n = n || null,
s = s || i,
this._total = 0,
!Array.isArray(t) && Array.isArray(e))
for (var o = 0; o < e.length; o++)
this.collideHandler(t, e[o], i, n, s, !1);
else if (Array.isArray(t) && !Array.isArray(e))
for (var o = 0; o < t.length; o++)
this.collideHandler(t[o], e, i, n, s, !1);
else if (Array.isArray(t) && Array.isArray(e))
for (var o = 0; o < t.length; o++)
for (var r = 0; r < e.length; r++)
this.collideHandler(t[o], e[r], i, n, s, !1);
else
this.collideHandler(t, e, i, n, s, !1);
return this._total > 0
},
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 === s.Physics.Arcade.LEFT_RIGHT ? t.hash.sort(this.sortLeftRight)
: e === s.Physics.Arcade.RIGHT_LEFT ? t.hash.sort(this.sortRightLeft) : e ===
s.Physics.Arcade.TOP_BOTTOM ? t.hash.sort(this.sortTopBottom) : e ===
s.Physics.Arcade.BOTTOM_TOP && t.hash.sort(this.sortBottomTop)
},
collideHandler: function(t, e, i, n, o, r) {
if (void 0 === e && t.physicsType === s.GROUP)
return this.sort(t),
void this.collideGroupVsSelf(t, i, n, o, r);
t && e && t.exists && e.exists && (this.sortDirection !==
s.Physics.Arcade.SORT_NONE && (t.physicsType === s.GROUP && this.sort(t),
e.physicsType === s.GROUP && this.sort(e)),
t.physicsType === s.SPRITE ? e.physicsType === s.SPRITE ?
this.collideSpriteVsSprite(t, e, i, n, o, r) : e.physicsType === s.GROUP ?
this.collideSpriteVsGroup(t, e, i, n, o, r) : e.physicsType === s.TILEMAPLAYER &&
this.collideSpriteVsTilemapLayer(t, e, i, n, o, r) : t.physicsType === s.GROUP ?
e.physicsType === s.SPRITE ? this.collideSpriteVsGroup(e, t, i, n, o, r) :
e.physicsType === s.GROUP ? this.collideGroupVsGroup(t, e, i, n, o, r) :
e.physicsType === s.TILEMAPLAYER && this.collideGroupVsTilemapLayer(t, e, i, n, o,
r) : t.physicsType === s.TILEMAPLAYER && (e.physicsType === s.SPRITE ?
this.collideSpriteVsTilemapLayer(e, t, i, n, o, r) : e.physicsType === s.GROUP &&
this.collideGroupVsTilemapLayer(e, t, i, n, o, r)))
},
collideSpriteVsSprite: function(t, e, i, n, s, o) {
return !(!t.body || !e.body) && (this.separate(t.body, e.body, n,
s, o) && (i && i.call(s, t, e),
this._total++),
!0)
},
collideSpriteVsGroup: function(t, e, i, n, o, r) {
if (0 !== e.length && t.body)
if (this.skipQuadTree || t.body.skipQuadTree)
for (var a = {}, h = 0; h < e.hash.length; h++) {
var l = e.hash[h];
if (l && l.exists && l.body) {
if (a = l.body.getBounds(a),
this.sortDirection === s.Physics.Arcade.LEFT_RIGHT)
{
if (t.body.right < a.x)
break;
if (a.right < t.body.x)
continue
} else if (this.sortDirection ===
s.Physics.Arcade.RIGHT_LEFT) {
if (t.body.x > a.right)
break;
if (a.x > t.body.right)
continue
} else if (this.sortDirection ===
s.Physics.Arcade.TOP_BOTTOM) {
if (t.body.bottom < a.y)
break;
if (a.bottom < t.body.y)
continue
} else if (this.sortDirection ===
s.Physics.Arcade.BOTTOM_TOP) {
if (t.body.y > a.bottom)
break;
if (a.y > t.body.bottom)
continue
}
this.collideSpriteVsSprite(t, l, i, n, o, r)
}
}
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);
for (var c = this.quadTree.retrieve(t), h = 0; h <
c.length; h++)
this.separate(t.body, c[h], n, o, r) && (i && i.call(o,
t, c[h].sprite),
this._total++)
}
},
collideGroupVsSelf: function(t, e, i, n, o) {
if (0 !== t.length)
for (var r = 0; r < t.hash.length; r++) {
var a = {}
, h = t.hash[r];
if (h && h.exists && h.body) {
a = h.body.getBounds(a);
for (var l = r + 1; l < t.hash.length; l++) {
var c = {}
, u = t.hash[l];
if (u && u.exists && u.body) {
if (c = u.body.getBounds(c),
this.sortDirection ===
s.Physics.Arcade.LEFT_RIGHT) {
if (a.right < c.x)
break;
if (c.right < a.x)
continue
} else if (this.sortDirection ===
s.Physics.Arcade.RIGHT_LEFT) {
if (a.x > c.right)
continue;
if (c.x > a.right)
break
} else if (this.sortDirection ===
s.Physics.Arcade.TOP_BOTTOM) {
if (a.bottom < c.y)
continue;
if (c.bottom < a.y)
break
} else if (this.sortDirection ===
s.Physics.Arcade.BOTTOM_TOP) {
if (a.y > c.bottom)
continue;
if (c.y > h.body.bottom)
break
}
this.collideSpriteVsSprite(h, u, e, i, n, o)
}
}
}
}
},
collideGroupVsGroup: function(t, e, i, n, o, r) {
if (0 !== t.length && 0 !== e.length)
for (var a = 0; a < t.children.length; a++)
t.children[a].exists && (t.children[a].physicsType ===
s.GROUP ? this.collideGroupVsGroup(t.children[a], e, i, n, o, r) :
this.collideSpriteVsGroup(t.children[a], e, i, n, o, r))
},
separate: function(t, e, i, n, s) {
if (!t.enable || !e.enable || t.checkCollision.none ||
e.checkCollision.none || !this.intersects(t, e))
return !1;
if (i && !1 === i.call(n, t.sprite, e.sprite))
return !1;
if (t.isCircle && e.isCircle)
return this.separateCircle(t, e, s);
if (t.isCircle !== e.isCircle) {
var o = t.isCircle ? e : t
, r = t.isCircle ? t : e
, a = {
x: o.x,
y: o.y,
right: o.right,
bottom: o.bottom
}
, h = {
x: r.x + r.radius,
y: r.y + r.radius
};
if ((h.y < a.y || h.y > a.bottom) && (h.x < a.x || h.x >
a.right))
return this.separateCircle(t, e, s)
}
var l = !1
, c = !1;
this.forceX || Math.abs(this.gravity.y + t.gravity.y) <
Math.abs(this.gravity.x + t.gravity.x) ? (l = this.separateX(t, e, s),
this.intersects(t, e) && (c = this.separateY(t, e, s))) : (c =
this.separateY(t, e, s),
this.intersects(t, e) && (l = this.separateX(t, e, s)));
var u = l || c;
return u && (s ? (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))),
u
},
intersects: function(t, e) {
return t !== e && (t.isCircle ? e.isCircle ?
s.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 = s.Math.clamp(t.center.x, e.left, e.right)
, n = s.Math.clamp(t.center.y, e.top, e.bottom);
return (t.center.x - i) * (t.center.x - i) + (t.center.y - n) *
(t.center.y - n) <= t.radius * t.radius
},
separateCircle: function(t, e, i) {
this.getOverlapX(t, e),
this.getOverlapY(t, e);
var n = e.center.x - t.center.x
, o = e.center.y - t.center.y
, r = Math.atan2(o, n)
, a = 0;
if (t.isCircle !== e.isCircle) {
var h = {
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
}
, l = {
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
};
l.y < h.y ? l.x < h.x ? a = s.Math.distance(l.x, l.y, h.x, h.y)
- l.radius : l.x > h.right && (a = s.Math.distance(l.x, l.y, h.right, h.y) -
l.radius) : l.y > h.bottom && (l.x < h.x ? a = s.Math.distance(l.x, l.y, h.x,
h.bottom) - l.radius : l.x > h.right && (a = s.Math.distance(l.x, l.y, h.right,
h.bottom) - l.radius)),
a *= -1
} else
a = t.radius + e.radius - s.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 c = {
x: t.velocity.x * Math.cos(r) + t.velocity.y * Math.sin(r),
y: t.velocity.x * Math.sin(r) - t.velocity.y * Math.cos(r)
}
, u = {
x: e.velocity.x * Math.cos(r) + e.velocity.y * Math.sin(r),
y: e.velocity.x * Math.sin(r) - e.velocity.y * Math.cos(r)
}
, d = ((t.mass - e.mass) * c.x + 2 * e.mass * u.x) / (t.mass +
e.mass)
, p = (2 * t.mass * c.x + (e.mass - t.mass) * u.x) / (t.mass +
e.mass);
return t.immovable || (t.velocity.x = (d * Math.cos(r) - c.y *
Math.sin(r)) * t.bounce.x,
t.velocity.y = (c.y * Math.cos(r) + d * Math.sin(r)) * t.bounce.y),
e.immovable || (e.velocity.x = (p * Math.cos(r) - u.y *
Math.sin(r)) * e.bounce.x,
e.velocity.y = (u.y * Math.cos(r) + p * Math.sin(r)) * e.bounce.y),
Math.abs(r) < Math.PI / 2 ? t.velocity.x > 0 && !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 : t.velocity.y > 0 && !
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(r) > Math.PI / 2 && (t.velocity.x < 0 && !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 : t.velocity.y < 0 && !t.immovable
&& e.velocity.y < t.velocity.y ? t.velocity.y *= -1 : e.velocity.y > 0 && !
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(r),
t.y += t.velocity.y * this.game.time.physicsElapsed - a *
Math.sin(r)),
e.immovable || (e.x += e.velocity.x * this.game.time.physicsElapsed
+ a * Math.cos(r),
e.y += e.velocity.y * this.game.time.physicsElapsed + a *
Math.sin(r)),
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 n = 0
, s = t.deltaAbsX() + e.deltaAbsX() + this.OVERLAP_BIAS;
return 0 === t.deltaX() && 0 === e.deltaX() ? (t.embedded = !0,
e.embedded = !0) : t.deltaX() > e.deltaX() ? (n = t.right - e.x,
n > s && !i || !1 === t.checkCollision.right || !1 ===
e.checkCollision.left ? n = 0 : (t.touching.none = !1,
t.touching.right = !0,
e.touching.none = !1,
e.touching.left = !0)) : t.deltaX() < e.deltaX() && (n = t.x -
e.width - e.x,
-n > s && !i || !1 === t.checkCollision.left || !1 ===
e.checkCollision.right ? n = 0 : (t.touching.none = !1,
t.touching.left = !0,
e.touching.none = !1,
e.touching.right = !0)),
t.overlapX = n,
e.overlapX = n,
n
},
getOverlapY: function(t, e, i) {
var n = 0
, s = t.deltaAbsY() + e.deltaAbsY() + this.OVERLAP_BIAS;
return 0 === t.deltaY() && 0 === e.deltaY() ? (t.embedded = !0,
e.embedded = !0) : t.deltaY() > e.deltaY() ? (n = t.bottom - e.y,
n > s && !i || !1 === t.checkCollision.down || !1 ===
e.checkCollision.up ? n = 0 : (t.touching.none = !1,
t.touching.down = !0,
e.touching.none = !1,
e.touching.up = !0)) : t.deltaY() < e.deltaY() && (n = t.y -
e.bottom,
-n > s && !i || !1 === t.checkCollision.up || !1 ===
e.checkCollision.down ? n = 0 : (t.touching.none = !1,
t.touching.up = !0,
e.touching.none = !1,
e.touching.down = !0)),
t.overlapY = n,
e.overlapY = n,
n
},
separateX: function(t, e, i) {
var n = this.getOverlapX(t, e, i);
if (i || 0 === n || t.immovable && e.immovable || t.customSeparateX
|| e.customSeparateX)
return 0 !== n || t.embedded && e.embedded;
var s = t.velocity.x
, o = e.velocity.x;
if (t.immovable || e.immovable)
t.immovable ? (e.x += n,
e.velocity.x = s - o * e.bounce.x,
t.moves && (e.y += (t.y - t.prev.y) * t.friction.y)) : (t.x -=
n,
t.velocity.x = o - s * t.bounce.x,
e.moves && (t.y += (e.y - e.prev.y) * e.friction.y));
else {
n *= .5,
t.x -= n,
e.x += n;
var r = Math.sqrt(o * o * e.mass / t.mass) * (o > 0 ? 1 : -1)
, a = Math.sqrt(s * s * t.mass / e.mass) * (s > 0 ? 1 : -1)
, h = .5 * (r + a);
r -= h,
a -= h,
t.velocity.x = h + r * t.bounce.x,
e.velocity.x = h + a * e.bounce.x
}
return !0
},
separateY: function(t, e, i) {
var n = this.getOverlapY(t, e, i);
if (i || 0 === n || t.immovable && e.immovable || t.customSeparateY
|| e.customSeparateY)
return 0 !== n || t.embedded && e.embedded;
var s = t.velocity.y
, o = e.velocity.y;
if (t.immovable || e.immovable)
t.immovable ? (e.y += n,
e.velocity.y = s - o * e.bounce.y,
t.moves && (e.x += (t.x - t.prev.x) * t.friction.x)) : (t.y -=
n,
t.velocity.y = o - s * t.bounce.y,
e.moves && (t.x += (e.x - e.prev.x) * e.friction.x));
else {
n *= .5,
t.y -= n,
e.y += n;
var r = Math.sqrt(o * o * e.mass / t.mass) * (o > 0 ? 1 : -1)
, a = Math.sqrt(s * s * t.mass / e.mass) * (s > 0 ? 1 : -1)
, h = .5 * (r + a);
r -= h,
a -= h,
t.velocity.y = h + r * t.bounce.y,
e.velocity.y = h + a * e.bounce.y
}
return !0
},
getObjectsUnderPointer: function(t, e, i, n) {
if (0 !== e.length && t.exists)
return this.getObjectsAtLocation(t.x, t.y, e, i, n, t)
},
getObjectsAtLocation: function(t, e, i, n, o, r) {
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 s.Rectangle(t,e,1,1), h = [], l =
this.quadTree.retrieve(a), c = 0; c < l.length; c++)
l[c].hitTest(t, e) && (n && n.call(o, r, l[c].sprite),
h.push(l[c].sprite));
return h
},
moveToObject: function(t, e, i, n) {
void 0 === i && (i = 60),
void 0 === n && (n = 0);
var s = Math.atan2(e.y - t.y, e.x - t.x);
return n > 0 && (i = this.distanceBetween(t, e) / (n / 1e3)),
t.body.velocity.x = Math.cos(s) * i,
t.body.velocity.y = Math.sin(s) * i,
s
},
moveToPointer: function(t, e, i, n) {
void 0 === e && (e = 60),
i = i || this.game.input.activePointer,
void 0 === n && (n = 0);
var s = this.angleToPointer(t, i);
return n > 0 && (e = this.distanceToPointer(t, i) / (n / 1e3)),
t.body.velocity.x = Math.cos(s) * e,
t.body.velocity.y = Math.sin(s) * e,
s
},
moveToXY: function(t, e, i, n, s) {
void 0 === n && (n = 60),
void 0 === s && (s = 0);
var o = Math.atan2(i - t.y, e - t.x);
return s > 0 && (n = this.distanceToXY(t, e, i) / (s / 1e3)),
t.body.velocity.x = Math.cos(o) * n,
t.body.velocity.y = Math.sin(o) * n,
o
},
velocityFromAngle: function(t, e, i) {
return void 0 === e && (e = 60),
i = i || new s.Point,
i.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 s.Point,
i.setTo(Math.cos(t) * e, Math.sin(t) * e)
},
accelerationFromRotation: function(t, e, i) {
return void 0 === e && (e = 60),
i = i || new s.Point,
i.setTo(Math.cos(t) * e, Math.sin(t) * e)
},
accelerateToObject: function(t, e, i, n, s) {
void 0 === i && (i = 60),
void 0 === n && (n = 1e3),
void 0 === s && (s = 1e3);
var o = this.angleBetween(t, e);
return t.body.acceleration.setTo(Math.cos(o) * i, Math.sin(o) * i),
t.body.maxVelocity.setTo(n, s),
o
},
accelerateToPointer: function(t, e, i, n, s) {
void 0 === i && (i = 60),
void 0 === e && (e = this.game.input.activePointer),
void 0 === n && (n = 1e3),
void 0 === s && (s = 1e3);
var o = this.angleToPointer(t, e);
return t.body.acceleration.setTo(Math.cos(o) * i, Math.sin(o) * i),
t.body.maxVelocity.setTo(n, s),
o
},
accelerateToXY: function(t, e, i, n, s, o) {
void 0 === n && (n = 60),
void 0 === s && (s = 1e3),
void 0 === o && (o = 1e3);
var r = this.angleToXY(t, e, i);
return t.body.acceleration.setTo(Math.cos(r) * n, Math.sin(r) * n),
t.body.maxVelocity.setTo(s, o),
r
},
distanceBetween: function(t, e, i) {
void 0 === i && (i = !1);
var n = i ? t.world.x - e.world.x : t.x - e.x
, s = i ? t.world.y - e.world.y : t.y - e.y;
return Math.sqrt(n * n + s * s)
},
distanceToXY: function(t, e, i, n) {
void 0 === n && (n = !1);
var s = n ? t.world.x - e : t.x - e
, o = n ? t.world.y - i : t.y - i;
return Math.sqrt(s * s + o * o)
},
distanceToPointer: function(t, e, i) {
void 0 === e && (e = this.game.input.activePointer),
void 0 === i && (i = !1);
var n = i ? t.world.x - e.worldX : t.x - e.worldX
, s = i ? t.world.y - e.worldY : t.y - e.worldY;
return Math.sqrt(n * n + s * s)
},
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
, n = e.centerY - t.centerY;
return Math.atan2(n, i)
},
angleToXY: function(t, e, i, n) {
return void 0 === n && (n = !1),
n ? 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)
}
},
s.Physics.Arcade.Body = function(t) {
this.sprite = t,
this.game = t.game,
this.type = s.Physics.ARCADE,
this.enable = !0,
this.isCircle = !1,
this.radius = 0,
this.offset = new s.Point,
this.position = new s.Point(t.x,t.y),
this.prev = new s.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 s.Point(t.x + this.halfWidth,t.y + this.halfHeight),
this.velocity = new s.Point,
this.newVelocity = new s.Point,
this.deltaMax = new s.Point,
this.acceleration = new s.Point,
this.drag = new s.Point,
this.allowGravity = !0,
this.gravity = new s.Point,
this.bounce = new s.Point,
this.worldBounce = null,
this.onWorldBounds = null,
this.onCollide = null,
this.onOverlap = null,
this.maxVelocity = new s.Point(1e4,1e4),
this.friction = new s.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 = s.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 s.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 s.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
}
,
s.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 (this.moveDuration > 0 ? (this.moveTimer +=
this.game.time.elapsedMS,
t = this.moveTimer / this.moveDuration) :
(this.moveTarget.end.set(this.position.x, this.position.y),
t = this.moveTarget.length / this.moveDistance),
this.movementCallback)
var i =
this.movementCallback.call(this.movementCallbackContext, this, this.velocity, t);
return !(e || t >= 1 || void 0 !== i && !0 !== i) ||
(this.stopMovement(t >= 1 || 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 = s.LEFT : this.deltaX() > 0 &&
(this.facing = s.RIGHT),
this.deltaY() < 0 ? this.facing = s.UP : this.deltaY() > 0 &&
(this.facing = s.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 : this._dx > 0 &&
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 : this._dy > 0 &&
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
, n = this.worldBounce ? -this.worldBounce.x : -this.bounce.x
, s = this.worldBounce ? -this.worldBounce.y : -this.bounce.y;
if (this.isCircle) {
var o = {
x: this.center.x - this.radius,
y: this.center.y - this.radius,
right: this.center.x + this.radius,
bottom: this.center.y + this.radius
};
o.x < e.x && i.left ? (t.x = e.x - this.halfWidth +
this.radius,
this.velocity.x *= n,
this.blocked.left = !0) : o.right > e.right && i.right && (t.x
= e.right - this.halfWidth - this.radius,
this.velocity.x *= n,
this.blocked.right = !0),
o.y < e.y && i.up ? (t.y = e.y - this.halfHeight + this.radius,
this.velocity.y *= s,
this.blocked.up = !0) : o.bottom > e.bottom && i.down && (t.y =
e.bottom - this.halfHeight - this.radius,
this.velocity.y *= s,
this.blocked.down = !0)
} else
t.x < e.x && i.left ? (t.x = e.x,
this.velocity.x *= n,
this.blocked.left = !0) : this.right > e.right && i.right &&
(t.x = e.right - this.width,
this.velocity.x *= n,
this.blocked.right = !0),
t.y < e.y && i.up ? (t.y = e.y,
this.velocity.y *= s,
this.blocked.up = !0) : this.bottom > e.bottom && i.down &&
(t.y = e.bottom - this.height,
this.velocity.y *= s,
this.blocked.down = !0);
return this.blocked.up || this.blocked.down || this.blocked.left ||
this.blocked.right
},
moveFrom: function(t, e, i) {
if (void 0 === e && (e = this.speed),
0 === e)
return !1;
var n;
return void 0 === i ? (n = this.angle,
i = this.game.math.radToDeg(n)) : n = this.game.math.degToRad(i),
this.moveTimer = 0,
this.moveDuration = t,
0 === i || 180 === i ? this.velocity.set(Math.cos(n) * e, 0) : 90
=== i || 270 === i ? this.velocity.set(0, Math.sin(n) * e) :
this.velocity.set(Math.cos(n) * e, Math.sin(n) * e),
this.isMoving = !0,
!0
},
moveTo: function(t, e, i) {
var n = e / (t / 1e3);
if (0 === n)
return !1;
var o;
return void 0 === i ? (o = this.angle,
i = this.game.math.radToDeg(o)) : o = this.game.math.degToRad(i),
e = Math.abs(e),
this.moveDuration = 0,
this.moveDistance = e,
null === this.moveTarget && (this.moveTarget = new s.Line,
this.moveEnd = new s.Point),
this.moveTarget.fromAngle(this.x, this.y, o, 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(o) * n, 0) : 90
=== i || 270 === i ? this.velocity.set(0, Math.sin(o) * n) :
this.velocity.set(Math.cos(o) * n, Math.sin(o) * n),
this.isMoving = !0,
!0
},
setSize: function(t, e, i, n) {
void 0 === i && (i = this.offset.x),
void 0 === n && (n = 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, n),
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),
t > 0 ? (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 ? s.Circle.contains(this, t, e) :
s.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 this.deltaX() > 0 ? this.deltaX() : -this.deltaX()
},
deltaAbsY: function() {
return this.deltaY() > 0 ? 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 s.Group &&
this.sprite.parent.removeFromHash(this.sprite),
this.sprite.body = null,
this.sprite = null
}
},
Object.defineProperty(s.Physics.Arcade.Body.prototype, "left", {
get: function() {
return this.position.x
}
}),
Object.defineProperty(s.Physics.Arcade.Body.prototype, "right", {
get: function() {
return this.position.x + this.width
}
}),
Object.defineProperty(s.Physics.Arcade.Body.prototype, "top", {
get: function() {
return this.position.y
}
}),
Object.defineProperty(s.Physics.Arcade.Body.prototype, "bottom", {
get: function() {
return this.position.y + this.height
}
}),
Object.defineProperty(s.Physics.Arcade.Body.prototype, "x", {
get: function() {
return this.position.x
},
set: function(t) {
this.position.x = t
}
}),
Object.defineProperty(s.Physics.Arcade.Body.prototype, "y", {
get: function() {
return this.position.y
},
set: function(t) {
this.position.y = t
}
}),
s.Physics.Arcade.Body.render = function(t, e, i, n) {
void 0 === n && (n = !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),
n ? t.fill() : t.stroke()) : n ? 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)
}
,
s.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)
}
,
s.Physics.Arcade.Body.prototype.constructor = s.Physics.Arcade.Body,
s.Physics.Arcade.TilemapCollision = function() {}
,
s.Physics.Arcade.TilemapCollision.prototype = {
TILE_BIAS: 16,
collideSpriteVsTilemapLayer: function(t, e, i, n, s, o) {
if (t.body) {
var r = 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 !== r.length)
for (var a = 0; a < r.length; a++)
n ? n.call(s, t, r[a]) && this.separateTile(a, t.body,
r[a], e, o) && (this._total++,
i && i.call(s, t, r[a])) : this.separateTile(a, t.body,
r[a], e, o) && (this._total++,
i && i.call(s, t, r[a]))
}
},
collideGroupVsTilemapLayer: function(t, e, i, n, s, o) {
if (0 !== t.length)
for (var r = 0; r < t.children.length; r++)
t.children[r].exists &&
this.collideSpriteVsTilemapLayer(t.children[r], e, i, n, s, o)
},
separateTile: function(t, e, i, n, s) {
if (!e.enable)
return !1;
var o = n.fixedToCamera ? 0 : n.position.x
, r = n.fixedToCamera ? 0 : n.position.y;
if (!i.intersects(e.position.x - o, e.position.y - r, e.right - o,
e.bottom - r))
return !1;
if (s)
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 a = 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 - o -
i.right), Math.abs(e.right - o - i.left)),
c = Math.min(Math.abs(e.position.y - r - i.bottom),
Math.abs(e.bottom - r - i.top))),
l < c) {
if ((i.faceLeft || i.faceRight) && 0 !== (a =
this.tileCheckX(e, i, n)) && !i.intersects(e.position.x - o, e.position.y - r,
e.right - o, e.bottom - r))
return !0;
(i.faceTop || i.faceBottom) && (h = this.tileCheckY(e, i, n))
} else {
if ((i.faceTop || i.faceBottom) && 0 !== (h =
this.tileCheckY(e, i, n)) && !i.intersects(e.position.x - o, e.position.y - r,
e.right - o, e.bottom - r))
return !0;
(i.faceLeft || i.faceRight) && (a = this.tileCheckX(e, i, n))
}
return 0 !== a || 0 !== h
},
tileCheckX: function(t, e, i) {
var n = 0
, s = i.fixedToCamera ? 0 : i.position.x;
return t.deltaX() < 0 && !t.blocked.left && e.collideRight &&
t.checkCollision.left ? e.faceRight && t.x - s < e.right && (n = t.x - s - e.right)
< -this.TILE_BIAS && (n = 0) : t.deltaX() > 0 && !t.blocked.right && e.collideLeft
&& t.checkCollision.right && e.faceLeft && t.right - s > e.left && (n = t.right - s
- e.left) > this.TILE_BIAS && (n = 0),
0 !== n && (t.customSeparateX ? t.overlapX = n :
this.processTileSeparationX(t, n)),
n
},
tileCheckY: function(t, e, i) {
var n = 0
, s = i.fixedToCamera ? 0 : i.position.y;
return t.deltaY() < 0 && !t.blocked.up && e.collideDown &&
t.checkCollision.up ? e.faceBottom && t.y - s < e.bottom && (n = t.y - s -
e.bottom) < -this.TILE_BIAS && (n = 0) : t.deltaY() > 0 && !t.blocked.down &&
e.collideUp && t.checkCollision.down && e.faceTop && t.bottom - s > e.top && (n =
t.bottom - s - e.top) > this.TILE_BIAS && (n = 0),
0 !== n && (t.customSeparateY ? t.overlapY = n :
this.processTileSeparationY(t, n)),
n
},
processTileSeparationX: function(t, e) {
e < 0 ? t.blocked.left = !0 : e > 0 && (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 : e > 0 && (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
}
},
s.Utils.mixinPrototype(s.Physics.Arcade.prototype,
s.Physics.Arcade.TilemapCollision.prototype),
p2.Body.prototype.parent = null,
p2.Spring.prototype.parent = null,
s.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
s.Physics.P2.InversePointProxy(this,this.world.gravity),
this.walls = {
left: null,
right: null,
top: null,
bottom: null
},
this.onBodyAdded = new s.Signal,
this.onBodyRemoved = new s.Signal,
this.onSpringAdded = new s.Signal,
this.onSpringRemoved = new s.Signal,
this.onConstraintAdded = new s.Signal,
this.onConstraintRemoved = new s.Signal,
this.onContactMaterialAdded = new s.Signal,
this.onContactMaterialRemoved = new s.Signal,
this.postBroadphaseCallback = null,
this.callbackContext = null,
this.onBeginContact = new s.Signal,
this.onEndContact = new s.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 s.Physics.P2.CollisionGroup(1),
this.boundsCollisionGroup = new s.Physics.P2.CollisionGroup(2),
this.everythingCollisionGroup = new
s.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)
}
,
s.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 n = 1;
if (Array.isArray(t))
for (n = t.length; n--; )
t[n]instanceof s.Group ? this.enable(t[n].children, e, i) :
(this.enableBody(t[n], e),
i && t[n].hasOwnProperty("children") &&
t[n].children.length > 0 && this.enable(t[n], e, !0));
else
t instanceof s.Group ? this.enable(t.children, e, i) :
(this.enableBody(t, e),
i && t.hasOwnProperty("children") && t.children.length > 0 &&
this.enable(t.children, e, !0))
},
enableBody: function(t, e) {
t.hasOwnProperty("body") && null === t.body && (t.body = new
s.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; e >= 0; 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.co
llisionGroup], e, i, t.shapeA, t.shapeB),
i._groupCallbacks[t.shapeA.collisionGroup] &&
i._groupCallbacks[t.shapeA.collisionGroup].call(i._groupCallbackContext[t.shapeA.co
llisionGroup], 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, n, s) {
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, n, s)
},
setWorldMaterial: function(t, e, i, n, s) {
void 0 === e && (e = !0),
void 0 === i && (i = !0),
void 0 === n && (n = !0),
void 0 === s && (s = !0),
e && this.walls.left && (this.walls.left.shapes[0].material = t),
i && this.walls.right && (this.walls.right.shapes[0].material = t),
n && this.walls.top && (this.walls.top.shapes[0].material = t),
s && 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, n, s, o, r, a, h) {
void 0 === s && (s = this._boundsLeft),
void 0 === o && (o = this._boundsRight),
void 0 === r && (r = this._boundsTop),
void 0 === a && (a = this._boundsBottom),
void 0 === h && (h = this._boundsOwnGroup),
this.setupWall(s, "left", t, e, 1.5707963267948966, h),
this.setupWall(o, "right", t + i, e, -1.5707963267948966, h),
this.setupWall(r, "top", t, e, -3.141592653589793, h),
this.setupWall(a, "bottom", t, e + n, 0, h),
this._boundsLeft = s,
this._boundsRight = o,
this._boundsTop = r,
this._boundsBottom = a,
this._boundsOwnGroup = h
},
setupWall: function(t, e, i, n, s, o) {
t ? (this.walls[e] ? this.walls[e].position = [this.pxmi(i),
this.pxmi(n)] : (this.walls[e] = new p2.Body({
mass: 0,
position: [this.pxmi(i), this.pxmi(n)],
angle: s
}),
this.walls[e].addShape(new p2.Plane),
this.world.addBody(this.walls[e])),
o && (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 s.Physics.P2.CollisionGroup(1),
this.boundsCollisionGroup = new s.Physics.P2.CollisionGroup(2),
this.everythingCollisionGroup = new
s.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; e >= 0; e--)
this.world.removeConstraint(t[e]);
for (var i = this.world.bodies, e = i.length - 1; e >= 0; e--)
this.world.removeBody(i[e]);
for (var n = this.world.springs, e = n.length - 1; e >= 0; e--)
this.world.removeSpring(n[e]);
for (var s = this.world.contactMaterials, e = s.length - 1; e >= 0;
e--)
this.world.removeContactMaterial(s[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 s.Physics.P2.Spring || t instanceof
s.Physics.P2.RotationalSpring ? this.world.addSpring(t.data) :
this.world.addSpring(t),
this.onSpringAdded.dispatch(t),
t
},
removeSpring: function(t) {
return t instanceof s.Physics.P2.Spring || t instanceof
s.Physics.P2.RotationalSpring ? this.world.removeSpring(t.data) :
this.world.removeSpring(t),
this.onSpringRemoved.dispatch(t),
t
},
createDistanceConstraint: function(t, e, i, n, o, r) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addConstraint(new
s.Physics.P2.DistanceConstraint(this,t,e,i,n,o,r));
console.warn("Cannot create Constraint, invalid body objects
given")
},
createGearConstraint: function(t, e, i, n) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addConstraint(new
s.Physics.P2.GearConstraint(this,t,e,i,n));
console.warn("Cannot create Constraint, invalid body objects
given")
},
createRevoluteConstraint: function(t, e, i, n, o, r) {
if (t = this.getBody(t),
i = this.getBody(i),
t && i)
return this.addConstraint(new
s.Physics.P2.RevoluteConstraint(this,t,e,i,n,o,r));
console.warn("Cannot create Constraint, invalid body objects
given")
},
createLockConstraint: function(t, e, i, n, o) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addConstraint(new
s.Physics.P2.LockConstraint(this,t,e,i,n,o));
console.warn("Cannot create Constraint, invalid body objects
given")
},
createPrismaticConstraint: function(t, e, i, n, o, r, a) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addConstraint(new
s.Physics.P2.PrismaticConstraint(this,t,e,i,n,o,r,a));
console.warn("Cannot create Constraint, invalid body objects
given")
},
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 s.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 n = new s.Physics.P2.ContactMaterial(t,e,i);
return this.addContactMaterial(n)
},
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 s.Physics.P2.Body ?
t.data : t.body && t.body.type === s.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, n) {
void 0 === e && (e = this.world.bodies),
void 0 === i && (i = 5),
void 0 === n && (n = !1);
for (var o = [this.pxmi(t.x), this.pxmi(t.y)], r = [], a =
e.length; a--; )
e[a]instanceof s.Physics.P2.Body && (!n || e[a].data.type !==
p2.Body.STATIC) ? r.push(e[a].data) : e[a]instanceof p2.Body && e[a].parent && (!n
|| e[a].type !== p2.Body.STATIC) ? r.push(e[a]) : e[a]instanceof s.Sprite &&
e[a].hasOwnProperty("body") && (!n || e[a].body.data.type !== p2.Body.STATIC) &&
r.push(e[a].body.data);
return this.world.hitTest(o, r, 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 s.Physics.P2.CollisionGroup(e);
return this.collisionGroups.push(i),
t && this.setCollisionGroup(t, i),
i
},
setCollisionGroup: function(t, e) {
if (t instanceof s.Group)
for (var i = 0; i < t.total; i++)
t.children[i].body && t.children[i].body.type ===
s.Physics.P2JS && t.children[i].body.setCollisionGroup(e);
else
t.body.setCollisionGroup(e)
},
createSpring: function(t, e, i, n, o, r, a, h, l) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addSpring(new
s.Physics.P2.Spring(this,t,e,i,n,o,r,a,h,l));
console.warn("Cannot create Spring, invalid body objects given")
},
createRotationalSpring: function(t, e, i, n, o) {
if (t = this.getBody(t),
e = this.getBody(e),
t && e)
return this.addSpring(new
s.Physics.P2.RotationalSpring(this,t,e,i,n,o));
console.warn("Cannot create Rotational Spring, invalid body objects
given")
},
createBody: function(t, e, i, n, o, r) {
void 0 === n && (n = !1);
var a = new s.Physics.P2.Body(this.game,null,t,e,i);
if (r) {
if (!a.addPolygon(o, r))
return !1
}
return n && this.world.addBody(a.data),
a
},
createParticle: function(t, e, i, n, o, r) {
void 0 === n && (n = !1);
var a = new s.Physics.P2.Body(this.game,null,t,e,i);
if (r) {
if (!a.addPolygon(o, r))
return !1
}
return n && this.world.addBody(a.data),
a
},
convertCollisionObjects: function(t, e, i) {
void 0 === i && (i = !0);
for (var n = [], s = 0, o = t.collision[e].length; s < o; s++) {
var r = t.collision[e][s]
, a = this.createBody(r.x, r.y, 0, i, {}, r.polyline);
a && n.push(a)
}
return n
},
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, n) {
e = t.getLayer(e),
void 0 === i && (i = !0),
void 0 === n && (n = !0),
this.clearTilemapLayerBodies(t, e);
for (var s = 0, o = 0, r = 0, a = 0, h = t.layers[e].height; a < h;
a++) {
s = 0;
for (var l = 0, c = t.layers[e].width; l < c; l++) {
var u = t.layers[e].data[a][l];
if (u && u.index > -1 && u.collides)
if (n) {
var d = t.getTileRight(e, l, a);
if (0 === s && (o = u.x * u.width,
r = u.y * u.height,
s = u.width),
d && d.collides)
s += u.width;
else {
var p = this.createBody(o, r, 0, !1);
p.addRectangle(s, u.height, s / 2, u.height /
2, 0),
i && this.addBody(p),
t.layers[e].bodies.push(p),
s = 0
}
} else {
var p = this.createBody(u.x * u.width, u.y *
u.height, 0, !1);
p.addRectangle(u.width, u.height, u.width / 2,
u.height / 2, 0),
i && this.addBody(p),
t.layers[e].bodies.push(p)
}
}
}
return t.layers[e].bodies
},
mpx: function(t) {
return t *= 20
},
pxm: function(t) {
return .05 * t
},
mpxi: function(t) {
return t *= -20
},
pxmi: function(t) {
return -.05 * t
}
},
Object.defineProperty(s.Physics.P2.prototype, "friction", {
get: function() {
return this.world.defaultContactMaterial.friction
},
set: function(t) {
this.world.defaultContactMaterial.friction = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "restitution", {
get: function() {
return this.world.defaultContactMaterial.restitution
},
set: function(t) {
this.world.defaultContactMaterial.restitution = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "contactMaterial", {
get: function() {
return this.world.defaultContactMaterial
},
set: function(t) {
this.world.defaultContactMaterial = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "applySpringForces", {
get: function() {
return this.world.applySpringForces
},
set: function(t) {
this.world.applySpringForces = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "applyDamping", {
get: function() {
return this.world.applyDamping
},
set: function(t) {
this.world.applyDamping = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "applyGravity", {
get: function() {
return this.world.applyGravity
},
set: function(t) {
this.world.applyGravity = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "solveConstraints", {
get: function() {
return this.world.solveConstraints
},
set: function(t) {
this.world.solveConstraints = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "time", {
get: function() {
return this.world.time
}
}),
Object.defineProperty(s.Physics.P2.prototype, "emitImpactEvent", {
get: function() {
return this.world.emitImpactEvent
},
set: function(t) {
this.world.emitImpactEvent = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "sleepMode", {
get: function() {
return this.world.sleepMode
},
set: function(t) {
this.world.sleepMode = t
}
}),
Object.defineProperty(s.Physics.P2.prototype, "total", {
get: function() {
return this.world.bodies.length
}
}),
s.Physics.P2.FixtureList = function(t) {
Array.isArray(t) || (t = [t]),
this.rawList = t,
this.init(),
this.parse(this.rawList)
}
,
s.Physics.P2.FixtureList.prototype = {
init: function() {
this.namedFixtures = {},
this.groupedFixtures = [],
this.allFixtures = []
},
setCategory: function(t, e) {
var i = function(e) {
e.collisionGroup = t
};
this.getFixtures(e).forEach(i)
},
setMask: function(t, e) {
var i = function(e) {
e.collisionMask = t
};
this.getFixtures(e).forEach(i)
},
setSensor: function(t, e) {
var i = function(e) {
e.sensor = t
};
this.getFixtures(e).forEach(i)
},
setMaterial: function(t, e) {
var i = function(e) {
e.material = t
};
this.getFixtures(e).forEach(i)
},
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, n;
i = this.rawList,
n = [];
for (t in i)
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)),
n.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
}
},
s.Physics.P2.PointProxy = function(t, e) {
this.world = t,
this.destination = e
}
,
s.Physics.P2.PointProxy.prototype.constructor = s.Physics.P2.PointProxy,
Object.defineProperty(s.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(s.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(s.Physics.P2.PointProxy.prototype, "mx", {
get: function() {
return this.destination[0]
},
set: function(t) {
this.destination[0] = t
}
}),
Object.defineProperty(s.Physics.P2.PointProxy.prototype, "my", {
get: function() {
return this.destination[1]
},
set: function(t) {
this.destination[1] = t
}
}),
s.Physics.P2.InversePointProxy = function(t, e) {
this.world = t,
this.destination = e
}
,
s.Physics.P2.InversePointProxy.prototype.constructor =
s.Physics.P2.InversePointProxy,
Object.defineProperty(s.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(s.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(s.Physics.P2.InversePointProxy.prototype, "mx", {
get: function() {
return this.destination[0]
},
set: function(t) {
this.destination[0] = -t
}
}),
Object.defineProperty(s.Physics.P2.InversePointProxy.prototype, "my", {
get: function() {
return this.destination[1]
},
set: function(t) {
this.destination[1] = -t
}
}),
s.Physics.P2.Body = function(t, e, i, n, o) {
e = e || null,
i = i || 0,
n = n || 0,
void 0 === o && (o = 1),
this.game = t,
this.world = t.physics.p2,
this.sprite = e,
this.type = s.Physics.P2JS,
this.offset = new s.Point,
this.data = new p2.Body({
position: [this.world.pxmi(i), this.world.pxmi(n)],
mass: o
}),
this.data.parent = this,
this.velocity = new
s.Physics.P2.InversePointProxy(this.world,this.data.velocity),
this.force = new
s.Physics.P2.InversePointProxy(this.world,this.data.force),
this.gravity = new s.Point,
this.onBeginContact = new s.Signal,
this.onEndContact = new s.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))
}
,
s.Physics.P2.Body.prototype = {
createBodyCallback: function(t, e, i) {
var n = -1;
t.id ? n = t.id : t.body && (n = t.body.id),
n > -1 && (null === e ? (delete this._bodyCallbacks[n],
delete this._bodyCallbackContext[n]) : (this._bodyCallbacks[n] = e,
this._bodyCallbackContext[n] = 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; i >= 0; 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 n = this.data.shapes.length - 1; n >= 0; n--)
this.data.shapes[n].collisionGroup = t.mask,
this.data.shapes[n].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 n = this.data.shapes.length - 1; n >= 0; n--)
t && (this.data.shapes[n].collisionGroup = null),
e && (this.data.shapes[n].collisionMask = null);
else
t && (i.collisionGroup = null),
e && (i.collisionMask = null);
t && (this.collidesWith.length = 0)
},
removeCollisionGroup: function(t, e, i) {
void 0 === e && (e = !0);
var n;
if (Array.isArray(t))
for (var s = 0; s < t.length; s++)
(n = this.collidesWith.indexOf(t[s])) > -1 &&
(this.collidesWith.splice(n, 1),
e && (delete this._groupCallbacks[t.mask],
delete this._groupCallbackContext[t.mask]));
else
(n = this.collidesWith.indexOf(t)) > -1 &&
(this.collidesWith.splice(n, 1),
e && (delete this._groupCallbacks[t.mask],
delete this._groupCallbackContext[t.mask]));
var o = this.getCollisionMask();
if (void 0 === i)
for (var s = this.data.shapes.length - 1; s >= 0; s--)
this.data.shapes[s].collisionMask = o;
else
i.collisionMask = o
},
collides: function(t, e, i, n) {
if (Array.isArray(t))
for (var s = 0; s < t.length; s++)
-1 === this.collidesWith.indexOf(t[s]) &&
(this.collidesWith.push(t[s]),
e && this.createGroupCallback(t[s], e, i));
else
-1 === this.collidesWith.indexOf(t) &&
(this.collidesWith.push(t),
e && this.createGroupCallback(t, e, i));
var o = this.getCollisionMask();
if (void 0 === n)
for (var s = this.data.shapes.length - 1; s >= 0; s--)
this.data.shapes[s].collisionMask = o;
else
n.collisionMask = o
},
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, n) {
void 0 === i && (i = !1),
void 0 === n && (n = !1),
this.setZeroForce(),
this.setZeroVelocity(),
this.setZeroRotation(),
i && this.setZeroDamping(),
n && (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, n) {
return void 0 === e && (e = 0),
void 0 === i && (i = 0),
void 0 === n && (n = 0),
this.data.addShape(t, [this.world.pxmi(e), this.world.pxmi(i)], n),
this.shapeChanged(),
t
},
addCircle: function(t, e, i, n) {
var s = new p2.Circle({
radius: this.world.pxm(t)
});
return this.addShape(s, e, i, n)
},
addRectangle: function(t, e, i, n, s) {
var o = new p2.Box({
width: this.world.pxm(t),
height: this.world.pxm(e)
});
return this.addShape(o, i, n, s)
},
addPlane: function(t, e, i) {
var n = new p2.Plane;
return this.addShape(n, t, e, i)
},
addParticle: function(t, e, i) {
var n = new p2.Particle;
return this.addShape(n, t, e, i)
},
addLine: function(t, e, i, n) {
var s = new p2.Line({
length: this.world.pxm(t)
});
return this.addShape(s, e, i, n)
},
addCapsule: function(t, e, i, n, s) {
var o = new p2.Capsule({
length: this.world.pxm(t),
radius: this.world.pxm(e)
});
return this.addShape(o, i, n, s)
},
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 n = 0, s = e.length; n < s; n += 2)
i.push([e[n], e[n + 1]]);
var o = i.length - 1;
i[o][0] === i[0][0] && i[o][1] === i[0][1] && i.pop();
for (var r = 0; r < i.length; r++)
i[r][0] = this.world.pxmi(i[r][0]),
i[r][1] = this.world.pxmi(i[r][1]);
var a = this.data.fromPolygon(i, t);
return this.shapeChanged(),
a
},
removeShape: function(t) {
var e = this.data.removeShape(t);
return this.shapeChanged(),
e
},
setCircle: function(t, e, i, n) {
return this.clearShapes(),
this.addCircle(t, e, i, n)
},
setRectangle: function(t, e, i, n, s) {
return void 0 === t && (t = 16),
void 0 === e && (e = 16),
this.clearShapes(),
this.addRectangle(t, e, i, n, s)
},
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; i >= 0; 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), n = [], s = 0; s
< i.length; s++) {
var o = i[s]
, r = this.addFixture(o);
n[o.filter.group] = n[o.filter.group] || [],
n[o.filter.group] = n[o.filter.group].concat(r),
o.fixtureKey && (n[o.fixtureKey] = r)
}
return this.data.aabbNeedsUpdate = !0,
this.shapeChanged(),
n
},
addFixture: function(t) {
var e = [];
if (t.circle) {
var i = new p2.Circle({
radius: this.world.pxm(t.circle.radius)
});
i.collisionGroup = t.filter.categoryBits,
i.collisionMask = t.filter.maskBits,
i.sensor = t.isSensor;
var n = p2.vec2.create();
n[0] = this.world.pxmi(t.circle.position[0] - this.sprite.width
/ 2),
n[1] = this.world.pxmi(t.circle.position[1] -
this.sprite.height / 2),
this.data.addShape(i, n),
e.push(i)
} else
for (var s = t.polygons, o = p2.vec2.create(), r = 0; r <
s.length; r++) {
for (var a = s[r], h = [], l = 0; l < a.length; l += 2)
h.push([this.world.pxmi(a[l]), this.world.pxmi(a[l +
1])]);
for (var i = new p2.Convex({
vertices: h
}), c = 0; c !== i.vertices.length; c++) {
var u = i.vertices[c];
p2.vec2.sub(u, u, i.centerOfMass)
}
p2.vec2.scale(o, i.centerOfMass, 1),
o[0] -= this.world.pxmi(this.sprite.width / 2),
o[1] -= this.world.pxmi(this.sprite.height / 2),
i.updateTriangles(),
i.updateCenterOfMass(),
i.updateBoundingRadius(),
i.collisionGroup = t.filter.categoryBits,
i.collisionMask = t.filter.maskBits,
i.sensor = t.isSensor,
this.data.addShape(i, o),
e.push(i)
}
return e
},
loadPolygon: function(t, e) {
if (null === t)
var i = e;
else
var i = this.game.cache.getPhysicsData(t, e);
for (var n = p2.vec2.create(), s = 0; s < i.length; s++) {
for (var o = [], r = 0; r < i[s].shape.length; r += 2)
o.push([this.world.pxmi(i[s].shape[r]),
this.world.pxmi(i[s].shape[r + 1])]);
for (var a = new p2.Convex({
vertices: o
}), h = 0; h !== a.vertices.length; h++) {
var l = a.vertices[h];
p2.vec2.sub(l, l, a.centerOfMass)
}
p2.vec2.scale(n, a.centerOfMass, 1),
n[0] -= this.world.pxmi(this.sprite.width / 2),
n[1] -= this.world.pxmi(this.sprite.height / 2),
a.updateTriangles(),
a.updateCenterOfMass(),
a.updateBoundingRadius(),
this.data.addShape(a, n)
}
return this.data.aabbNeedsUpdate = !0,
this.shapeChanged(),
!0
}
},
s.Physics.P2.Body.prototype.constructor = s.Physics.P2.Body,
s.Physics.P2.Body.DYNAMIC = 1,
s.Physics.P2.Body.STATIC = 2,
s.Physics.P2.Body.KINEMATIC = 4,
Object.defineProperty(s.Physics.P2.Body.prototype, "static", {
get: function() {
return this.data.type === s.Physics.P2.Body.STATIC
},
set: function(t) {
t && this.data.type !== s.Physics.P2.Body.STATIC ? (this.data.type
= s.Physics.P2.Body.STATIC,
this.mass = 0) : t || this.data.type !== s.Physics.P2.Body.STATIC
|| (this.data.type = s.Physics.P2.Body.DYNAMIC,
this.mass = 1)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "dynamic", {
get: function() {
return this.data.type === s.Physics.P2.Body.DYNAMIC
},
set: function(t) {
t && this.data.type !== s.Physics.P2.Body.DYNAMIC ? (this.data.type
= s.Physics.P2.Body.DYNAMIC,
this.mass = 1) : t || this.data.type !== s.Physics.P2.Body.DYNAMIC
|| (this.data.type = s.Physics.P2.Body.STATIC,
this.mass = 0)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "kinematic", {
get: function() {
return this.data.type === s.Physics.P2.Body.KINEMATIC
},
set: function(t) {
t && this.data.type !== s.Physics.P2.Body.KINEMATIC ?
(this.data.type = s.Physics.P2.Body.KINEMATIC,
this.mass = 4) : t || this.data.type !==
s.Physics.P2.Body.KINEMATIC || (this.data.type = s.Physics.P2.Body.STATIC,
this.mass = 0)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "allowSleep", {
get: function() {
return this.data.allowSleep
},
set: function(t) {
t !== this.data.allowSleep && (this.data.allowSleep = t)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "angle", {
get: function() {
return s.Math.wrapAngle(s.Math.radToDeg(this.data.angle))
},
set: function(t) {
this.data.angle = s.Math.degToRad(s.Math.wrapAngle(t))
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "angularDamping", {
get: function() {
return this.data.angularDamping
},
set: function(t) {
this.data.angularDamping = t
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "angularForce", {
get: function() {
return this.data.angularForce
},
set: function(t) {
this.data.angularForce = t
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "angularVelocity", {
get: function() {
return this.data.angularVelocity
},
set: function(t) {
this.data.angularVelocity = t
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "damping", {
get: function() {
return this.data.damping
},
set: function(t) {
this.data.damping = t
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "fixedRotation", {
get: function() {
return this.data.fixedRotation
},
set: function(t) {
t !== this.data.fixedRotation && (this.data.fixedRotation = t)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "inertia", {
get: function() {
return this.data.inertia
},
set: function(t) {
this.data.inertia = t
}
}),
Object.defineProperty(s.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(s.Physics.P2.Body.prototype, "motionState", {
get: function() {
return this.data.type
},
set: function(t) {
t !== this.data.type && (this.data.type = t)
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "rotation", {
get: function() {
return this.data.angle
},
set: function(t) {
this.data.angle = t
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "sleepSpeedLimit", {
get: function() {
return this.data.sleepSpeedLimit
},
set: function(t) {
this.data.sleepSpeedLimit = t
}
}),
Object.defineProperty(s.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(s.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(s.Physics.P2.Body.prototype, "id", {
get: function() {
return this.data.id
}
}),
Object.defineProperty(s.Physics.P2.Body.prototype, "debug", {
get: function() {
return null !== this.debugBody
},
set: function(t) {
t && !this.debugBody ? this.debugBody = new
s.Physics.P2.BodyDebug(this.game,this.data) : !t && this.debugBody &&
(this.debugBody.destroy(),
this.debugBody = null)
}
}),
Object.defineProperty(s.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())
}
}),
s.Physics.P2.BodyDebug = function(t, e, i) {
s.Group.call(this, t);
var n = {
pixelsPerLengthUnit: t.physics.p2.mpx(1),
debugPolygons: !1,
lineWidth: 1,
alpha: .5
};
this.settings = s.Utils.extend(n, i),
this.ppu = this.settings.pixelsPerLengthUnit,
this.ppu = -1 * this.ppu,
this.body = e,
this.canvas = new s.Graphics(t),
this.canvas.alpha = this.settings.alpha,
this.add(this.canvas),
this.draw(),
this.updateSpriteTransform()
}
,
s.Physics.P2.BodyDebug.prototype = Object.create(s.Group.prototype),
s.Physics.P2.BodyDebug.prototype.constructor = s.Physics.P2.BodyDebug,
s.Utils.extend(s.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, n, s, o, r, a, h, l, c, u, d, p, f;
if (a = this.body,
l = this.canvas,
l.clear(),
i = parseInt(this.randomPastelHex(), 16),
o = 16711680,
r = this.lineWidth,
a instanceof p2.Body && a.shapes.length) {
var m = a.shapes.length;
for (n = 0; n !== m; ) {
if (e = a.shapes[n],
h = e.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, r);
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, o, i, r);
else if (e instanceof p2.Plane)
this.drawPlane(l, h[0] * this.ppu, -h[1] * this.ppu, i,
o, 5 * r, 10 * r, 10 * r, 100 * this.ppu, t);
else if (e instanceof p2.Line)
this.drawLine(l, e.length * this.ppu, o, r);
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, o, i, r);
else if (e instanceof p2.Convex) {
for (u = [],
d = p2.vec2.create(),
s = p = 0,
f = e.vertices.length; 0 <= f ? p < f : p > f; s = 0 <=
f ? ++p : --p)
c = e.vertices[s],
p2.vec2.rotate(d, c, t),
u.push([(d[0] + h[0]) * this.ppu, -(d[1] + h[1]) *
this.ppu]);
this.drawConvex(l, u, e.triangles, o, i, r,
this.settings.debugPolygons, [h[0] * this.ppu, -h[1] * this.ppu])
}
n++
}
}
},
drawRectangle: function(t, e, i, n, s, o, r, a, h) {
void 0 === h && (h = 1),
void 0 === r && (r = 0),
t.lineStyle(h, r, 1),
t.beginFill(a),
t.drawRect(e - s / 2, i - o / 2, s, o)
},
drawCircle: function(t, e, i, n, s, o, r) {
void 0 === r && (r = 1),
void 0 === o && (o = 16777215),
t.lineStyle(r, 0, 1),
t.beginFill(o, 1),
t.drawCircle(e, i, 2 * -s),
t.endFill(),
t.moveTo(e, i),
t.lineTo(e + s * Math.cos(-n), i + s * Math.sin(-n))
},
drawLine: function(t, e, i, n) {
void 0 === n && (n = 1),
void 0 === i && (i = 0),
t.lineStyle(5 * n, i, 1),
t.moveTo(-e / 2, 0),
t.lineTo(e / 2, 0)
},
drawConvex: function(t, e, i, n, s, o, r, a) {
var h, l, c, u, d, p, f, m, g, y, v;
if (void 0 === o && (o = 1),
void 0 === n && (n = 0),
r) {
for (h = [16711680, 65280, 255],
l = 0; l !== e.length + 1; )
u = e[l % e.length],
d = e[(l + 1) % e.length],
f = u[0],
y = u[1],
m = d[0],
v = d[1],
t.lineStyle(o, h[l % h.length], 1),
t.moveTo(f, -y),
t.lineTo(m, -v),
t.drawCircle(f, -y, 2 * o),
l++;
return t.lineStyle(o, 0, 1),
t.drawCircle(a[0], a[1], 2 * o)
}
for (t.lineStyle(o, n, 1),
t.beginFill(s),
l = 0; l !== e.length; )
c = e[l],
p = c[0],
g = c[1],
0 === l ? t.moveTo(p, -g) : t.lineTo(p, -g),
l++;
if (t.endFill(),
e.length > 2)
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, n, s) {
var o, r, a, h, l, c, u, d, p, f, m, g;
for (void 0 === s && (s = 1),
void 0 === i && (i = 0),
t.lineStyle(s, i, 1),
"number" == typeof n && t.beginFill(n),
r = null,
a = null,
o = 0; o < e.length; )
f = e[o],
m = f[0],
g = f[1],
m === r && g === a || (0 === o ? t.moveTo(m, g) : (h = r,
l = a,
c = m,
u = g,
d = e[(o + 1) % e.length][0],
p = e[(o + 1) % e.length][1],
0 !== (c - h) * (p - l) - (d - h) * (u - l) && t.lineTo(m, g)),
r = m,
a = g),
o++;
"number" == typeof n && t.endFill(),
e.length > 2 && "number" == typeof n && (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, n, s, o, r, a, h, l) {
var c, u;
void 0 === o && (o = 1),
void 0 === n && (n = 16777215),
t.lineStyle(o, s, 11),
t.beginFill(n),
t.moveTo(e, -i),
c = e + Math.cos(l) * this.game.width,
u = i + Math.sin(l) * this.game.height,
t.lineTo(c, -u),
t.moveTo(e, -i),
c = e + Math.cos(l) * -this.game.width,
u = i + Math.sin(l) * -this.game.height,
t.lineTo(c, -u)
},
drawCapsule: function(t, e, i, n, s, o, r, a, h) {
void 0 === h && (h = 1),
void 0 === r && (r = 0),
t.lineStyle(h, r, 1);
var l = Math.cos(n)
, c = Math.sin(n);
t.beginFill(a, 1),
t.drawCircle(-s / 2 * l + e, -s / 2 * c + i, 2 * -o),
t.drawCircle(s / 2 * l + e, s / 2 * c + i, 2 * -o),
t.endFill(),
t.lineStyle(h, r, 0),
t.beginFill(a, 1),
t.moveTo(-s / 2 * l + o * c + e, -s / 2 * c + o * l + i),
t.lineTo(s / 2 * l + o * c + e, s / 2 * c + o * l + i),
t.lineTo(s / 2 * l - o * c + e, s / 2 * c - o * l + i),
t.lineTo(-s / 2 * l - o * c + e, -s / 2 * c - o * l + i),
t.endFill(),
t.lineStyle(h, r, 1),
t.moveTo(-s / 2 * l + o * c + e, -s / 2 * c + o * l + i),
t.lineTo(s / 2 * l + o * c + e, s / 2 * c + o * l + i),
t.moveTo(-s / 2 * l - o * c + e, -s / 2 * c - o * l + i),
t.lineTo(s / 2 * l - o * c + e, s / 2 * c - o * l + i)
},
randomPastelHex: function() {
var t, e, i, n;
return i = [255, 255, 255],
n = Math.floor(256 * Math.random()),
e = Math.floor(256 * Math.random()),
t = Math.floor(256 * Math.random()),
n = Math.floor((n + 3 * i[0]) / 4),
e = Math.floor((e + 3 * i[1]) / 4),
t = Math.floor((t + 3 * i[2]) / 4),
this.rgbToHex(n, e, t)
},
rgbToHex: function(t, e, i) {
return this.componentToHex(t) + this.componentToHex(e) +
this.componentToHex(i)
},
componentToHex: function(t) {
var e;
return e = t.toString(16),
2 === e.length ? e : e + "0"
}
}),
s.Physics.P2.Spring = function(t, e, i, n, s, o, r, a, h, l) {
this.game = t.game,
this.world = t,
void 0 === n && (n = 1),
void 0 === s && (s = 100),
void 0 === o && (o = 1),
n = t.pxm(n);
var c = {
restLength: n,
stiffness: s,
damping: o
};
void 0 !== r && null !== r && (c.worldAnchorA = [t.pxm(r[0]),
t.pxm(r[1])]),
void 0 !== a && null !== a && (c.worldAnchorB = [t.pxm(a[0]),
t.pxm(a[1])]),
void 0 !== h && null !== h && (c.localAnchorA = [t.pxm(h[0]),
t.pxm(h[1])]),
void 0 !== l && null !== l && (c.localAnchorB = [t.pxm(l[0]),
t.pxm(l[1])]),
this.data = new p2.LinearSpring(e,i,c),
this.data.parent = this
}
,
s.Physics.P2.Spring.prototype.constructor = s.Physics.P2.Spring,
s.Physics.P2.RotationalSpring = function(t, e, i, n, s, o) {
this.game = t.game,
this.world = t,
void 0 === n && (n = null),
void 0 === s && (s = 100),
void 0 === o && (o = 1),
n && (n = t.pxm(n));
var r = {
restAngle: n,
stiffness: s,
damping: o
};
this.data = new p2.RotationalSpring(e,i,r),
this.data.parent = this
}
,
s.Physics.P2.Spring.prototype.constructor = s.Physics.P2.Spring,
s.Physics.P2.Material = function(t) {
this.name = t,
p2.Material.call(this)
}
,
s.Physics.P2.Material.prototype = Object.create(p2.Material.prototype),
s.Physics.P2.Material.prototype.constructor = s.Physics.P2.Material,
s.Physics.P2.ContactMaterial = function(t, e, i) {
p2.ContactMaterial.call(this, t, e, i)
}
,
s.Physics.P2.ContactMaterial.prototype =
Object.create(p2.ContactMaterial.prototype),
s.Physics.P2.ContactMaterial.prototype.constructor =
s.Physics.P2.ContactMaterial,
s.Physics.P2.CollisionGroup = function(t) {
this.mask = t
}
,
s.Physics.P2.DistanceConstraint = function(t, e, i, n, s, o, r) {
void 0 === n && (n = 100),
void 0 === s && (s = [0, 0]),
void 0 === o && (o = [0, 0]),
void 0 === r && (r = Number.MAX_VALUE),
this.game = t.game,
this.world = t,
n = t.pxm(n),
s = [t.pxmi(s[0]), t.pxmi(s[1])],
o = [t.pxmi(o[0]), t.pxmi(o[1])];
var a = {
distance: n,
localAnchorA: s,
localAnchorB: o,
maxForce: r
};
p2.DistanceConstraint.call(this, e, i, a)
}
,
s.Physics.P2.DistanceConstraint.prototype =
Object.create(p2.DistanceConstraint.prototype),
s.Physics.P2.DistanceConstraint.prototype.constructor =
s.Physics.P2.DistanceConstraint,
s.Physics.P2.GearConstraint = function(t, e, i, n, s) {
void 0 === n && (n = 0),
void 0 === s && (s = 1),
this.game = t.game,
this.world = t;
var o = {
angle: n,
ratio: s
};
p2.GearConstraint.call(this, e, i, o)
}
,
s.Physics.P2.GearConstraint.prototype =
Object.create(p2.GearConstraint.prototype),
s.Physics.P2.GearConstraint.prototype.constructor =
s.Physics.P2.GearConstraint,
s.Physics.P2.LockConstraint = function(t, e, i, n, s, o) {
void 0 === n && (n = [0, 0]),
void 0 === s && (s = 0),
void 0 === o && (o = Number.MAX_VALUE),
this.game = t.game,
this.world = t,
n = [t.pxm(n[0]), t.pxm(n[1])];
var r = {
localOffsetB: n,
localAngleB: s,
maxForce: o
};
p2.LockConstraint.call(this, e, i, r)
}
,
s.Physics.P2.LockConstraint.prototype =
Object.create(p2.LockConstraint.prototype),
s.Physics.P2.LockConstraint.prototype.constructor =
s.Physics.P2.LockConstraint,
s.Physics.P2.PrismaticConstraint = function(t, e, i, n, s, o, r, a) {
void 0 === n && (n = !0),
void 0 === s && (s = [0, 0]),
void 0 === o && (o = [0, 0]),
void 0 === r && (r = [0, 0]),
void 0 === a && (a = Number.MAX_VALUE),
this.game = t.game,
this.world = t,
s = [t.pxmi(s[0]), t.pxmi(s[1])],
o = [t.pxmi(o[0]), t.pxmi(o[1])];
var h = {
localAnchorA: s,
localAnchorB: o,
localAxisA: r,
maxForce: a,
disableRotationalLock: !n
};
p2.PrismaticConstraint.call(this, e, i, h)
}
,
s.Physics.P2.PrismaticConstraint.prototype =
Object.create(p2.PrismaticConstraint.prototype),
s.Physics.P2.PrismaticConstraint.prototype.constructor =
s.Physics.P2.PrismaticConstraint,
s.Physics.P2.RevoluteConstraint = function(t, e, i, n, s, o, r) {
void 0 === o && (o = Number.MAX_VALUE),
void 0 === r && (r = null),
this.game = t.game,
this.world = t,
i = [t.pxmi(i[0]), t.pxmi(i[1])],
s = [t.pxmi(s[0]), t.pxmi(s[1])],
r && (r = [t.pxmi(r[0]), t.pxmi(r[1])]);
var a = {
worldPivot: r,
localPivotA: i,
localPivotB: s,
maxForce: o
};
p2.RevoluteConstraint.call(this, e, n, a)
}
,
s.Physics.P2.RevoluteConstraint.prototype =
Object.create(p2.RevoluteConstraint.prototype),
s.Physics.P2.RevoluteConstraint.prototype.constructor =
s.Physics.P2.RevoluteConstraint,
s.ImageCollection = function(t, e, i, n, s, o, r) {
(void 0 === i || i <= 0) && (i = 32),
(void 0 === n || n <= 0) && (n = 32),
void 0 === s && (s = 0),
void 0 === o && (o = 0),
this.name = t,
this.firstgid = 0 | e,
this.imageWidth = 0 | i,
this.imageHeight = 0 | n,
this.imageMargin = 0 | s,
this.imageSpacing = 0 | o,
this.properties = r || {},
this.images = [],
this.total = 0
}
,
s.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++
}
},
s.ImageCollection.prototype.constructor = s.ImageCollection,
s.Tile = function(t, e, i, n, s, o) {
this.layer = t,
this.index = e,
this.x = i,
this.y = n,
this.rotation = 0,
this.flipped = !1,
this.worldX = i * s,
this.worldY = n * o,
this.width = s,
this.height = o,
this.centerX = Math.abs(s / 2),
this.centerY = Math.abs(o / 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
}
,
s.Tile.prototype = {
containsPoint: function(t, e) {
return !(t < this.worldX || e < this.worldY || t > this.right || e
> this.bottom)
},
intersects: function(t, e, i, n) {
return !(i <= this.worldX) && (!(n <= 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, n) {
this.collideLeft = t,
this.collideRight = e,
this.collideUp = i,
this.collideDown = n,
this.faceLeft = t,
this.faceRight = e,
this.faceTop = i,
this.faceBottom = n
},
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
}
},
s.Tile.prototype.constructor = s.Tile,
Object.defineProperty(s.Tile.prototype, "collides", {
get: function() {
return this.collideLeft || this.collideRight || this.collideUp ||
this.collideDown
}
}),
Object.defineProperty(s.Tile.prototype, "canCollide", {
get: function() {
return this.collideLeft || this.collideRight || this.collideUp ||
this.collideDown || this.collisionCallback
}
}),
Object.defineProperty(s.Tile.prototype, "left", {
get: function() {
return this.worldX
}
}),
Object.defineProperty(s.Tile.prototype, "right", {
get: function() {
return this.worldX + this.width
}
}),
Object.defineProperty(s.Tile.prototype, "top", {
get: function() {
return this.worldY
}
}),
Object.defineProperty(s.Tile.prototype, "bottom", {
get: function() {
return this.worldY + this.height
}
}),
s.Tilemap = function(t, e, i, n, o, r) {
this.game = t,
this.key = e;
var a = s.TilemapParser.parse(this.game, e, i, n, o, r);
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)
}
,
s.Tilemap.CSV = 0,
s.Tilemap.TILED_JSON = 1,
s.Tilemap.NORTH = 0,
s.Tilemap.EAST = 1,
s.Tilemap.SOUTH = 2,
s.Tilemap.WEST = 3,
s.Tilemap.prototype = {
create: function(t, e, i, n, s, o) {
return void 0 === o && (o = this.game.world),
this.width = e,
this.height = i,
this.setTileSize(n, s),
this.layers.length = 0,
this.createBlankLayer(t, e, i, n, s, o)
},
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, n, o, r, a) {
if (void 0 === t)
return null;
void 0 === i && (i = this.tileWidth),
void 0 === n && (n = this.tileHeight),
void 0 === o && (o = 0),
void 0 === r && (r = 0),
void 0 === a && (a = 0),
0 === i && (i = 32),
0 === n && (n = 32);
var h = null;
if (void 0 !== e && null !== e || (e = t),
e instanceof s.BitmapData)
h = e.canvas;
else {
if (!this.game.cache.checkImageKey(e))
return console.warn('Phaser.Tilemap.addTilesetImage:
Invalid image key given: "' + e + '"'),
null;
h = this.game.cache.getImage(e)
}
var l = this.getTilesetIndex(t);
if (null === l && this.format === s.Tilemap.TILED_JSON)
return console.warn('Phaser.Tilemap.addTilesetImage: No data
found in the JSON matching the tileset name: "' + t + '"'),
null;
if (this.tilesets[l])
return this.tilesets[l].setImage(h),
this.tilesets[l];
var c = new s.Tileset(t,a,i,n,o,r,{});
c.setImage(h),
this.tilesets.push(c);
for (var u = this.tilesets.length - 1, d = o, p = o, f = 0, m = 0,
g = 0, y = a; y < a + c.total && (this.tiles[y] = [d, p, u],
d += i + r,
++f !== c.total) && (++m !== c.columns || (d = o,
p += n + r,
m = 0,
++g !== c.rows)); y++)
;
return c
},
createFromObjects: function(t, e, i, n, o, r, a, h, l) {
if (void 0 === o && (o = !0),
void 0 === r && (r = !1),
void 0 === a && (a = this.game.world),
void 0 === h && (h = s.Sprite),
void 0 === l && (l = !0),
!this.objects[t])
return void console.warn("Tilemap.createFromObjects: Invalid
objectgroup name given: " + t);
for (var c = 0; c < this.objects[t].length; c++) {
var u = !1
, d = this.objects[t][c];
if (void 0 !== d.gid && "number" == typeof e && d.gid === e ? u
= !0 : void 0 !== d.id && "number" == typeof e && d.id === e ? u = !0 : void 0 !==
d.name && "string" == typeof e && d.name === e && (u = !0),
u) {
var p = new h(this.game,parseFloat(d.x, 10),parseFloat(d.y,
10),i,n);
p.name = d.name,
p.visible = d.visible,
p.autoCull = r,
p.exists = o,
d.width && (p.width = d.width),
d.height && (p.height = d.height),
d.rotation && (p.angle = d.rotation),
l && (p.y -= p.height),
a.add(p);
for (var f in d.properties)
a.set(p, f, d.properties[f], !1, !1, 0, !0)
}
}
},
createFromTiles: function(t, e, i, n, o, r) {
"number" == typeof t && (t = [t]),
void 0 === e || null === e ? e = [] : "number" == typeof e && (e =
[e]),
n = this.getLayer(n),
void 0 === o && (o = this.game.world),
void 0 === r && (r = {}),
void 0 === r.customClass && (r.customClass = s.Sprite),
void 0 === r.adjustY && (r.adjustY = !0);
var a = this.layers[n].width
, h = this.layers[n].height;
if (this.copy(0, 0, a, h, n),
this._results.length < 2)
return 0;
for (var l, c = 0, u = 1, d = this._results.length; u < d; u++)
if (-1 !== t.indexOf(this._results[u].index)) {
l = new
r.customClass(this.game,this._results[u].worldX,this._results[u].worldY,i);
for (var p in r)
l[p] = r[p];
o.add(l),
c++
}
if (1 === e.length)
for (u = 0; u < t.length; u++)
this.replace(t[u], e[0], 0, 0, a, h, n);
else if (e.length > 1)
for (u = 0; u < t.length; u++)
this.replace(t[u], e[u], 0, 0, a, h, n);
return c
},
createLayer: function(t, e, i, n) {
void 0 === e && (e = this.game.width),
void 0 === i && (i = this.game.height),
void 0 === n && (n = this.game.world);
var o = t;
if ("string" == typeof t && (o = this.getLayerIndex(t)),
null === o || o > this.layers.length)
return void console.warn("Tilemap.createLayer: Invalid layer ID
given: " + o);
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 && (console.group("Tilemap.createLayer"),
console.log("Name:", this.layers[o].name),
console.log("Size:", e, "x", i),
console.log("Tileset:", this.tilesets[0].name, "index:", o));
var r = n.add(new s.TilemapLayer(this.game,this,o,e,i));
return this.enableDebug && console.groupEnd(),
r
},
createBlankLayer: function(t, e, i, n, o, r) {
if (void 0 === r && (r = this.game.world),
null !== this.getLayerIndex(t))
return void console.warn("Tilemap.createBlankLayer: Layer with
matching name already exists: " + t);
for (var a, h = {
name: t,
x: 0,
y: 0,
width: e,
height: i,
widthInPixels: e * n,
heightInPixels: i * o,
alpha: 1,
visible: !0,
properties: {},
indexes: [],
callbacks: [],
bodies: [],
data: null
}, l = [], c = 0; c < i; c++) {
a = [];
for (var u = 0; u < e; u++)
a.push(new s.Tile(h,-1,u,c,n,o));
l.push(a)
}
h.data = l,
this.layers.push(h),
this.currentLayer = this.layers.length - 1;
var d = h.widthInPixels
, p = h.heightInPixels;
d > this.game.width && (d = this.game.width),
p > this.game.height && (p = this.game.height);
var l = new s.TilemapLayer(this.game,this,this.layers.length -
1,d,p);
return l.name = t,
r.add(l)
},
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, n) {
if (n = this.getLayer(n),
"number" == typeof t)
this.layers[n].callbacks[t] = {
callback: e,
callbackContext: i
};
else
for (var s = 0, o = t.length; s < o; s++)
this.layers[n].callbacks[t[s]] = {
callback: e,
callbackContext: i
}
},
setTileLocationCallback: function(t, e, i, n, s, o, r) {
if (r = this.getLayer(r),
this.copy(t, e, i, n, r),
!(this._results.length < 2))
for (var a = 1; a < this._results.length; a++)
this._results[a].setCollisionCallback(s, o)
},
setCollision: function(t, e, i, n) {
if (void 0 === e && (e = !0),
void 0 === n && (n = !0),
i = this.getLayer(i),
"number" == typeof t)
return this.setCollisionByIndex(t, e, i, !0);
if (Array.isArray(t)) {
for (var s = 0; s < t.length; s++)
this.setCollisionByIndex(t[s], e, i, !1);
n && this.calculateFaces(i)
}
},
setCollisionBetween: function(t, e, i, n, s) {
if (void 0 === i && (i = !0),
void 0 === s && (s = !0),
n = this.getLayer(n),
!(t > e)) {
for (var o = t; o <= e; o++)
this.setCollisionByIndex(o, i, n, !1);
s && this.calculateFaces(n)
}
},
setCollisionByExclusion: function(t, e, i, n) {
void 0 === e && (e = !0),
void 0 === n && (n = !0),
i = this.getLayer(i);
for (var s = 0, o = this.tiles.length; s < o; s++)
-1 === t.indexOf(s) && this.setCollisionByIndex(s, e, i, !1);
n && this.calculateFaces(i)
},
setCollisionByIndex: function(t, e, i, n) {
if (void 0 === e && (e = !0),
void 0 === i && (i = this.currentLayer),
void 0 === n && (n = !0),
e)
this.collideIndexes.push(t);
else {
var s = this.collideIndexes.indexOf(t);
s > -1 && this.collideIndexes.splice(s, 1)
}
for (var o = 0; o < this.layers[i].height; o++)
for (var r = 0; r < this.layers[i].width; r++) {
var a = this.layers[i].data[o][r];
a && a.index === t && (e ? a.setCollision(!0, !0, !0, !0) :
a.resetCollision(),
a.faceTop = e,
a.faceBottom = e,
a.faceLeft = e,
a.faceRight = e)
}
return n && this.calculateFaces(i),
i
},
getLayer: function(t) {
return void 0 === t ? t = this.currentLayer : "string" == typeof
t ? t = this.getLayerIndex(t) : t instanceof s.TilemapLayer && (t = t.index),
t
},
setPreventRecalculate: function(t) {
if (!0 === t && !0 !== this.preventingRecalculate &&
(this.preventingRecalculate = !0,
this.needToRecalculate = {}),
!1 === t && !0 === this.preventingRecalculate) {
this.preventingRecalculate = !1;
for (var e in this.needToRecalculate)
this.calculateFaces(e);
this.needToRecalculate = !1
}
},
calculateFaces: function(t) {
if (this.preventingRecalculate)
return void (this.needToRecalculate[t] = !0);
for (var e = null, i = null, n = null, s = null, o = 0, r =
this.layers[t].height; o < r; o++)
for (var a = 0, h = this.layers[t].width; a < h; a++) {
var l = this.layers[t].data[o][a];
l && (e = this.getTileAbove(t, a, o),
i = this.getTileBelow(t, a, o),
n = this.getTileLeft(t, a, o),
s = this.getTileRight(t, a, o),
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),
n && n.collides && (l.faceLeft = !1),
s && s.collides && (l.faceRight = !1))
}
},
getTileAbove: function(t, e, i) {
return i > 0 ? 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 e > 0 ? 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] && this.layers[i].data[e][t].index > -1
},
removeTile: function(t, e, i) {
if (i = this.getLayer(i),
t >= 0 && t < this.layers[i].width && e >= 0 && e <
this.layers[i].height && this.hasTile(t, e, i)) {
var n = this.layers[i].data[e][t];
return this.layers[i].data[e][t] = new s.Tile(this.layers[i],-
1,t,e,this.tileWidth,this.tileHeight),
this.layers[i].dirty = !0,
this.calculateFaces(i),
n
}
},
removeTileWorldXY: function(t, e, i, n, s) {
return s = this.getLayer(s),
t = this.game.math.snapToFloor(t, i) / i,
e = this.game.math.snapToFloor(e, n) / n,
this.removeTile(t, e, s)
},
putTile: function(t, e, i, n) {
if (null === t)
return this.removeTile(e, i, n);
if (n = this.getLayer(n),
e >= 0 && e < this.layers[n].width && i >= 0 && i <
this.layers[n].height) {
var o;
return t instanceof s.Tile ? (o = t.index,
this.hasTile(e, i, n) ? this.layers[n].data[i][e].copy(t) :
this.layers[n].data[i][e] = new s.Tile(n,o,e,i,t.width,t.height)) : (o = t,
this.hasTile(e, i, n) ? this.layers[n].data[i][e].index = o :
this.layers[n].data[i][e] = new
s.Tile(this.layers[n],o,e,i,this.tileWidth,this.tileHeight)),
this.collideIndexes.indexOf(o) > -1 ? this.layers[n].data[i]
[e].setCollision(!0, !0, !0, !0) : this.layers[n].data[i][e].resetCollision(),
this.layers[n].dirty = !0,
this.calculateFaces(n),
this.layers[n].data[i][e]
}
return null
},
putTileWorldXY: function(t, e, i, n, s, o) {
return o = this.getLayer(o),
e = this.game.math.snapToFloor(e, n) / n,
i = this.game.math.snapToFloor(i, s) / s,
this.putTile(t, e, i, o)
},
searchTileIndex: function(t, e, i, n) {
void 0 === e && (e = 0),
void 0 === i && (i = !1),
n = this.getLayer(n);
var s = 0;
if (i) {
for (var o = this.layers[n].height - 1; o >= 0; o--)
for (var r = this.layers[n].width - 1; r >= 0; r--)
if (this.layers[n].data[o][r].index === t) {
if (s === e)
return this.layers[n].data[o][r];
s++
}
} else
for (var o = 0; o < this.layers[n].height; o++)
for (var r = 0; r < this.layers[n].width; r++)
if (this.layers[n].data[o][r].index === t) {
if (s === e)
return this.layers[n].data[o][r];
s++
}
return null
},
getTile: function(t, e, i, n) {
return void 0 === n && (n = !1),
i = this.getLayer(i),
t >= 0 && t < this.layers[i].width && e >= 0 && e <
this.layers[i].height ? -1 === this.layers[i].data[e][t].index ? n ?
this.layers[i].data[e][t] : null : this.layers[i].data[e][t] : null
},
getTileWorldXY: function(t, e, i, n, s, o) {
return void 0 === i && (i = this.tileWidth),
void 0 === n && (n = this.tileHeight),
s = this.getLayer(s),
t = this.game.math.snapToFloor(t, i) / i,
e = this.game.math.snapToFloor(e, n) / n,
this.getTile(t, e, s, o)
},
copy: function(t, e, i, n, s) {
if (s = this.getLayer(s),
!this.layers[s])
return void (this._results.length = 0);
void 0 === t && (t = 0),
void 0 === e && (e = 0),
void 0 === i && (i = this.layers[s].width),
void 0 === n && (n = this.layers[s].height),
t < 0 && (t = 0),
e < 0 && (e = 0),
i > this.layers[s].width && (i = this.layers[s].width),
n > this.layers[s].height && (n = this.layers[s].height),
this._results.length = 0,
this._results.push({
x: t,
y: e,
width: i,
height: n,
layer: s
});
for (var o = e; o < e + n; o++)
for (var r = t; r < t + i; r++)
this._results.push(this.layers[s].data[o][r]);
return this._results
},
paste: function(t, e, i, n) {
if (void 0 === t && (t = 0),
void 0 === e && (e = 0),
n = this.getLayer(n),
i && !(i.length < 2)) {
for (var s = t - i[1].x, o = e - i[1].y, r = 1; r < i.length;
r++)
this.layers[n].data[o + i[r].y][s + i[r].x].copy(i[r]);
this.layers[n].dirty = !0,
this.calculateFaces(n)
}
},
swap: function(t, e, i, n, s, o, r) {
r = this.getLayer(r),
this.copy(i, n, s, o, r),
this._results.length < 2 || (this._tempA = t,
this._tempB = e,
this._results.forEach(this.swapHandler, this),
this.paste(i, n, this._results, r))
},
swapHandler: function(t) {
t.index === this._tempA ? t.index = this._tempB : t.index ===
this._tempB && (t.index = this._tempA)
},
forEach: function(t, e, i, n, s, o, r) {
r = this.getLayer(r),
this.copy(i, n, s, o, r),
this._results.length < 2 || (this._results.forEach(t, e),
this.paste(i, n, this._results, r))
},
replace: function(t, e, i, n, s, o, r) {
if (r = this.getLayer(r),
this.copy(i, n, s, o, r),
!(this._results.length < 2)) {
for (var a = 1; a < this._results.length; a++)
this._results[a].index === t && (this._results[a].index =
e);
this.paste(i, n, this._results, r)
}
},
random: function(t, e, i, n, s) {
if (s = this.getLayer(s),
this.copy(t, e, i, n, s),
!(this._results.length < 2)) {
for (var o = [], r = 1; r < this._results.length; r++)
if (this._results[r].index) {
var a = this._results[r].index;
-1 === o.indexOf(a) && o.push(a)
}
for (var h = 1; h < this._results.length; h++)
this._results[h].index = this.game.rnd.pick(o);
this.paste(t, e, this._results, s)
}
},
shuffle: function(t, e, i, n, o) {
if (o = this.getLayer(o),
this.copy(t, e, i, n, o),
!(this._results.length < 2)) {
for (var r = [], a = 1; a < this._results.length; a++)
this._results[a].index && r.push(this._results[a].index);
s.ArrayUtils.shuffle(r);
for (var h = 1; h < this._results.length; h++)
this._results[h].index = r[h - 1];
this.paste(t, e, this._results, o)
}
},
fill: function(t, e, i, n, s, o) {
if (o = this.getLayer(o),
this.copy(e, i, n, s, o),
!(this._results.length < 2)) {
for (var r = 1; r < this._results.length; r++)
this._results[r].index = t;
this.paste(e, i, this._results, o)
}
},
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 n = 0; n < this.layers[this.currentLayer].width; n++)
t += "%c ",
this.layers[this.currentLayer].data[i][n] > 1 ?
this.debugMap[this.layers[this.currentLayer].data[i][n]] ? e.push("background: " +
this.debugMap[this.layers[this.currentLayer].data[i][n]]) : e.push("background:
#ffffff") : e.push("background: rgb(0, 0, 0)");
t += "\n"
}
e[0] = t,
console.log.apply(console, e)
},
destroy: function() {
this.removeAllLayers(),
this.data = [],
this.game = null
}
},
s.Tilemap.prototype.constructor = s.Tilemap,
Object.defineProperty(s.Tilemap.prototype, "layer", {
get: function() {
return this.layers[this.currentLayer]
},
set: function(t) {
t !== this.currentLayer && this.setLayer(t)
}
}),
s.TilemapLayer = function(t, e, i, n, o) {
n |= 0,
o |= 0,
s.Sprite.call(this, t, 0, 0),
this.map = e,
this.index = i,
this.layer = e.layers[i],
this.canvas = s.CanvasPool.create(this, n, o),
this.context = this.canvas.getContext("2d"),
this.setTexture(new PIXI.Texture(new
PIXI.BaseTexture(this.canvas,null,this.game.resolution))),
this.type = s.TILEMAPLAYER,
this.physicsType = s.TILEMAPLAYER,
this.renderSettings = {
enableScrollDelta: !0,
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 =
s.TilemapLayer.ensureSharedCopyCanvas()),
this.fixedToCamera = !0
}
,
s.TilemapLayer.prototype = Object.create(s.Sprite.prototype),
s.TilemapLayer.prototype.constructor = s.TilemapLayer,
s.TilemapLayer.prototype.preUpdateCore = s.Component.Core.preUpdate,
s.TilemapLayer.sharedCopyCanvas = null,
s.TilemapLayer.ensureSharedCopyCanvas = function() {
return this.sharedCopyCanvas || (this.sharedCopyCanvas =
s.CanvasPool.create(this, 2, 2)),
this.sharedCopyCanvas
}
,
s.TilemapLayer.prototype.preUpdate = function() {
return this.preUpdateCore()
}
,
s.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
}
,
s.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)
}
,
s.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)
}
,
s.TilemapLayer.prototype.destroy = function() {
s.CanvasPool.remove(this),
s.Component.Destroy.prototype.destroy.call(this)
}
,
s.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
}
,
s.TilemapLayer.prototype.resizeWorld = function() {
this.game.world.setBounds(0, 0, this.layer.widthInPixels *
this.scale.x, this.layer.heightInPixels * this.scale.y)
}
,
s.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)
}
,
s.TilemapLayer.prototype._unfixX = function(t) {
return 1 === this.scrollFactorX ? t : this._scrollX /
this.scrollFactorX + (t - this._scrollX)
}
,
s.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)
}
,
s.TilemapLayer.prototype._unfixY = function(t) {
return 1 === this.scrollFactorY ? t : this._scrollY /
this.scrollFactorY + (t - this._scrollY)
}
,
s.TilemapLayer.prototype.getTileX = function(t) {
return Math.floor(this._fixX(t) / this._mc.tileWidth)
}
,
s.TilemapLayer.prototype.getTileY = function(t) {
return Math.floor(this._fixY(t) / this._mc.tileHeight)
}
,
s.TilemapLayer.prototype.getTileXY = function(t, e, i) {
return i.x = this.getTileX(t),
i.y = this.getTileY(e),
i
}
,
s.TilemapLayer.prototype.getRayCastTiles = function(t, e, i, n) {
e || (e = this.rayStepRate),
void 0 === i && (i = !1),
void 0 === n && (n = !1);
var s = this.getTiles(t.x, t.y, t.width, t.height, i, n);
if (0 === s.length)
return [];
for (var o = t.coordinatesOnLine(e), r = [], a = 0; a < s.length; a++)
for (var h = 0; h < o.length; h++) {
var l = s[a]
, c = o[h];
if (l.containsPoint(c[0], c[1])) {
r.push(l);
break
}
}
return r
}
,
s.TilemapLayer.prototype.getTiles = function(t, e, i, n, s, o) {
void 0 === s && (s = !1),
void 0 === o && (o = !1);
var r = !(s || o);
t = this._fixX(t),
e = this._fixY(e);
for (var a = 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)) - a, c = Math.ceil((e + n) / (this._mc.ch * this.scale.y)) - h;
this._results.length; )
this._results.pop();
for (var u = h; u < h + c; u++)
for (var d = a; d < a + l; d++) {
var p = this.layer.data[u];
p && p[d] && (r || p[d].isInteresting(s, o)) &&
this._results.push(p[d])
}
return this._results.slice()
}
,
s.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 n = this.map.tilesets[i];
if (n && n.containsTileIndex(t))
return e[t] = n
}
return e[t] = null
}
,
s.TilemapLayer.prototype.resetTilesetCache = function() {
for (var t = this._mc.tilesets; t.length; )
t.pop()
}
,
s.TilemapLayer.prototype.setScale = function(t, e) {
t = t || 1,
e = e || t;
for (var i = 0; i < this.layer.data.length; i++)
for (var n = this.layer.data[i], s = 0; s < n.length; s++) {
var o = n[s];
o.width = this.map.tileWidth * t,
o.height = this.map.tileHeight * e,
o.worldX = o.x * o.width,
o.worldY = o.y * o.height
}
this.scale.setTo(t, e)
}
,
s.TilemapLayer.prototype.shiftCanvas = function(t, e, i) {
var n = t.canvas
, s = n.width - Math.abs(e)
, o = n.height - Math.abs(i)
, r = 0
, a = 0
, h = e
, l = i;
e < 0 && (r = -e,
h = 0),
i < 0 && (a = -i,
l = 0);
var c = this.renderSettings.copyCanvas;
if (c) {
(c.width < s || c.height < o) && (c.width = s,
c.height = o);
var u = c.getContext("2d");
u.clearRect(0, 0, s, o),
u.drawImage(n, r, a, s, o, 0, 0, s, o),
t.clearRect(h, l, s, o),
t.drawImage(c, 0, 0, s, o, h, l, s, o)
} else
t.save(),
t.globalCompositeOperation = "copy",
t.drawImage(n, r, a, s, o, h, l, s, o),
t.restore()
}
,
s.TilemapLayer.prototype.renderRegion = function(t, e, i, n, s, o) {
var r = this.context
, a = this.layer.width
, h = this.layer.height
, l = this._mc.tileWidth
, c = this._mc.tileHeight
, u = this._mc.tilesets
, d = NaN;
this._wrap || (i <= s && (i = Math.max(0, i),
s = Math.min(a - 1, s)),
n <= o && (n = Math.max(0, n),
o = Math.min(h - 1, o)));
var p, f, m, g, y, v, b = i * l - t, w = n * c - e, x = (i + (1 << 20)
* a) % a, _ = (n + (1 << 20) * h) % h;
for (g = _,
v = o - n,
f = w; v >= 0; g++,
v--,
f += c) {
g >= h && (g -= h);
var P = this.layer.data[g];
for (m = x,
y = s - i,
p = b; y >= 0; m++,
y--,
p += l) {
m >= a && (m -= a);
var T = P[m];
if (T && !(T.index < 0)) {
var C = T.index
, S = u[C];
void 0 === S && (S = this.resolveTileset(C)),
T.alpha === d || this.debug || (r.globalAlpha = T.alpha,
d = T.alpha),
S ? T.rotation || T.flipped ? (r.save(),
r.translate(p + T.centerX, f + T.centerY),
r.rotate(T.rotation),
T.flipped && r.scale(-1, 1),
S.draw(r, -T.centerX, -T.centerY, C),
r.restore()) : S.draw(r, p, f, C) :
this.debugSettings.missingImageFill && (r.fillStyle =
this.debugSettings.missingImageFill,
r.fillRect(p, f, l, c)),
T.debug && this.debugSettings.debuggedTileOverfill &&
(r.fillStyle = this.debugSettings.debuggedTileOverfill,
r.fillRect(p, f, l, c))
}
}
}
}
,
s.TilemapLayer.prototype.renderDeltaScroll = function(t, e) {
var i = this._mc.scrollX
, n = this._mc.scrollY
, s = this.canvas.width
, o = this.canvas.height
, r = this._mc.tileWidth
, a = this._mc.tileHeight
, h = 0
, l = -r
, c = 0
, u = -a;
if (t < 0 ? (h = s + t,
l = s - 1) : t > 0 && (l = t),
e < 0 ? (c = o + e,
u = o - 1) : e > 0 && (u = e),
this.shiftCanvas(this.context, t, e),
h = Math.floor((h + i) / r),
l = Math.floor((l + i) / r),
c = Math.floor((c + n) / a),
u = Math.floor((u + n) / a),
h <= l) {
this.context.clearRect(h * r - i, 0, (l - h + 1) * r, o);
var d = Math.floor((0 + n) / a)
, p = Math.floor((o - 1 + n) / a);
this.renderRegion(i, n, h, d, l, p)
}
if (c <= u) {
this.context.clearRect(0, c * a - n, s, (u - c + 1) * a);
var f = Math.floor((0 + i) / r)
, m = Math.floor((s - 1 + i) / r);
this.renderRegion(i, n, f, c, m, u)
}
}
,
s.TilemapLayer.prototype.renderFull = function() {
var t = this._mc.scrollX
, e = this._mc.scrollY
, i = this.canvas.width
, n = this.canvas.height
, s = this._mc.tileWidth
, o = this._mc.tileHeight
, r = Math.floor(t / s)
, a = Math.floor((i - 1 + t) / s)
, h = Math.floor(e / o)
, l = Math.floor((n - 1 + e) / o);
this.context.clearRect(0, 0, i, n),
this.renderRegion(t, e, r, h, a, l)
}
,
s.TilemapLayer.prototype.render = function() {
var t = !1;
if (this.visible) {
(this.dirty || this.layer.dirty) && (this.layer.dirty = !1,
t = !0);
var e = this.canvas.width
, i = this.canvas.height
, n = 0 | this._scrollX
, s = 0 | this._scrollY
, o = this._mc
, r = o.scrollX - n
, a = o.scrollY - s;
if (t || 0 !== r || 0 !== a || o.renderWidth !== e ||
o.renderHeight !== i)
return this.context.save(),
o.scrollX = n,
o.scrollY = s,
o.renderWidth === e && o.renderHeight === i || (o.renderWidth =
e,
o.renderHeight = i),
this.debug && (this.context.globalAlpha =
this.debugSettings.debugAlpha,
this.debugSettings.forceFullRedraw && (t = !0)),
!t && this.renderSettings.enableScrollDelta && Math.abs(r) +
Math.abs(a) < Math.min(e, i) ? this.renderDeltaScroll(r, a) : this.renderFull(),
this.debug && (this.context.globalAlpha = 1,
this.renderDebug()),
this.texture.baseTexture.dirty(),
this.dirty = !1,
this.context.restore(),
!0
}
}
,
s.TilemapLayer.prototype.renderDebug = function() {
var t, e, i, n, s, o, r = this._mc.scrollX, a = this._mc.scrollY, h =
this.context, l = this.canvas.width, c = this.canvas.height, u = this.layer.width,
d = this.layer.height, p = this._mc.tileWidth, f = this._mc.tileHeight, m =
Math.floor(r / p), g = Math.floor((l - 1 + r) / p), y = Math.floor(a / f), v =
Math.floor((c - 1 + a) / f), b = m * p - r, w = y * f - a, x = (m + (1 << 20) * u)
% u, _ = (y + (1 << 20) * d) % d;
for (h.strokeStyle = this.debugSettings.facingEdgeStroke,
n = _,
o = v - y,
e = w; o >= 0; n++,
o--,
e += f) {
n >= d && (n -= d);
var P = this.layer.data[n];
for (i = x,
s = g - m,
t = b; s >= 0; i++,
s--,
t += p) {
i >= u && (i -= u);
var T = P[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(s.TilemapLayer.prototype, "wrap", {
get: function() {
return this._wrap
},
set: function(t) {
this._wrap = t,
this.dirty = !0
}
}),
Object.defineProperty(s.TilemapLayer.prototype, "scrollX", {
get: function() {
return this._scrollX
},
set: function(t) {
this._scrollX = t
}
}),
Object.defineProperty(s.TilemapLayer.prototype, "scrollY", {
get: function() {
return this._scrollY
},
set: function(t) {
this._scrollY = t
}
}),
Object.defineProperty(s.TilemapLayer.prototype, "collisionWidth", {
get: function() {
return this._mc.cw
},
set: function(t) {
this._mc.cw = 0 | t,
this.dirty = !0
}
}),
Object.defineProperty(s.TilemapLayer.prototype, "collisionHeight", {
get: function() {
return this._mc.ch
},
set: function(t) {
this._mc.ch = 0 | t,
this.dirty = !0
}
}),
s.TilemapParser = {
INSERT_NULL: !1,
parse: function(t, e, i, n, o, r) {
if (void 0 === i && (i = 32),
void 0 === n && (n = 32),
void 0 === o && (o = 10),
void 0 === r && (r = 10),
void 0 === e)
return this.getEmptyData();
if (null === e)
return this.getEmptyData(i, n, o, r);
var a = t.cache.getTilemapData(e);
if (a) {
if (a.format === s.Tilemap.CSV)
return this.parseCSV(e, a.data, i, n);
if (!a.format || a.format === s.Tilemap.TILED_JSON)
return this.parseTiledJSON(a.data)
} else
console.warn("Phaser.TilemapParser.parse - No map data found
for key " + e)
},
parseCSV: function(t, e, i, n) {
var o = this.getEmptyData();
e = e.trim();
for (var r = [], a = e.split("\n"), h = a.length, l = 0, c = 0; c <
a.length; c++) {
r[c] = [];
for (var u = a[c].split(","), d = 0; d < u.length; d++)
r[c][d] = new s.Tile(o.layers[0],parseInt(u[d],
10),d,c,i,n);
0 === l && (l = u.length)
}
return o.format = s.Tilemap.CSV,
o.name = t,
o.width = l,
o.height = h,
o.tileWidth = i,
o.tileHeight = n,
o.widthInPixels = l * i,
o.heightInPixels = h * n,
o.layers[0].width = l,
o.layers[0].height = h,
o.layers[0].widthInPixels = o.widthInPixels,
o.layers[0].heightInPixels = o.heightInPixels,
o.layers[0].data = r,
o
},
getEmptyData: function(t, e, i, n) {
return {
width: void 0 !== i && null !== i ? i : 0,
height: void 0 !== n && null !== n ? n : 0,
tileWidth: void 0 !== t && null !== t ? t : 0,
tileHeight: void 0 !== e && 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) {
function e(t, e) {
var i = {};
for (var n in e) {
var s = e[n];
void 0 !== t[s] && (i[s] = t[s])
}
return i
}
if ("orthogonal" !== t.orientation)
return console.warn("TilemapParser.parseTiledJSON - Only
orthogonal map types are supported in this version of Phaser"),
null;
for (var i = {
width: t.width,
height: t.height,
tileWidth: t.tilewidth,
tileHeight: t.tileheight,
orientation: t.orientation,
format: s.Tilemap.TILED_JSON,
version: t.version,
properties: t.properties,
widthInPixels: t.width * t.tilewidth,
heightInPixels: t.height * t.tileheight
}, n = [], o = 0; o < t.layers.length; o++)
if ("tilelayer" === t.layers[o].type) {
var r = t.layers[o];
if (!r.compression && r.encoding && "base64" ===
r.encoding) {
for (var a = window.atob(r.data), h = a.length, l = new
Array(h), c = 0; c < h; c += 4)
l[c / 4] = (a.charCodeAt(c) | a.charCodeAt(c + 1)
<< 8 | a.charCodeAt(c + 2) << 16 | a.charCodeAt(c + 3) << 24) >>> 0;
r.data = l,
delete r.encoding
} else if (r.compression) {
console.warn("TilemapParser.parseTiledJSON - Layer
compression is unsupported, skipping layer '" + r.name + "'");
continue
}
var u = {
name: r.name,
x: r.x,
y: r.y,
width: r.width,
height: r.height,
widthInPixels: r.width * t.tilewidth,
heightInPixels: r.height * t.tileheight,
alpha: r.opacity,
visible: r.visible,
properties: {},
indexes: [],
callbacks: [],
bodies: []
};
r.properties && (u.properties = r.properties);
for (var d, p, f, m, g = 0, y = [], v = [], b = 0, h =
r.data.length; b < h; b++) {
if (d = 0,
p = !1,
m = r.data[b],
f = 0,
m > 536870912)
switch (m > 2147483648 && (m -= 2147483648,
f += 4),
m > 1073741824 && (m -= 1073741824,
f += 2),
m > 536870912 && (m -= 536870912,
f += 1),
f) {
case 5:
d = Math.PI / 2;
break;
case 6:
d = Math.PI;
break;
case 3:
d = 3 * Math.PI / 2;
break;
case 4:
d = 0,
p = !0;
break;
case 7:
d = Math.PI / 2,
p = !0;
break;
case 2:
d = Math.PI,
p = !0;
break;
case 1:
d = 3 * Math.PI / 2,
p = !0
}
if (m > 0) {
var w = new
s.Tile(u,m,g,v.length,t.tilewidth,t.tileheight);
w.rotation = d,
w.flipped = p,
0 !== f && (w.flippedVal = f),
y.push(w)
} else
s.TilemapParser.INSERT_NULL ? y.push(null) :
y.push(new s.Tile(u,-1,g,v.length,t.tilewidth,t.tileheight));
g++,
g === r.width && (v.push(y),
g = 0,
y = [])
}
u.data = v,
n.push(u)
}
i.layers = n;
for (var x = [], o = 0; o < t.layers.length; o++)
if ("imagelayer" === t.layers[o].type) {
var _ = t.layers[o]
, P = {
name: _.name,
image: _.image,
x: _.x,
y: _.y,
alpha: _.opacity,
visible: _.visible,
properties: {}
};
_.properties && (P.properties = _.properties),
x.push(P)
}
i.images = x;
for (var T = [], C = [], S = null, o = 0; o < t.tilesets.length; o+
+) {
var A = t.tilesets[o];
if (A.image) {
var k = new
s.Tileset(A.name,A.firstgid,A.tilewidth,A.tileheight,A.margin,A.spacing,A.propertie
s);
A.tileproperties && (k.tileProperties = A.tileproperties),
k.updateTileData(A.imagewidth, A.imageheight),
T.push(k)
} else {
var E = new
s.ImageCollection(A.name,A.firstgid,A.tilewidth,A.tileheight,A.margin,A.spacing,A.p
roperties);
for (var I in A.tiles) {
var P = A.tiles[I].image
, m = A.firstgid + parseInt(I, 10);
E.addImage(m, P)
}
C.push(E)
}
S && (S.lastgid = A.firstgid - 1),
S = A
}
i.tilesets = T,
i.imagecollections = C;
for (var M = {}, O = {}, o = 0; o < t.layers.length; o++)
if ("objectgroup" === t.layers[o].type) {
var B = t.layers[o];
M[B.name] = [],
O[B.name] = [];
for (var R = 0, h = B.objects.length; R < h; R++)
if (B.objects[R].gid) {
var L = {
gid: B.objects[R].gid,
name: B.objects[R].name,
type: B.objects[R].hasOwnProperty("type") ?
B.objects[R].type : "",
x: B.objects[R].x,
y: B.objects[R].y,
visible: B.objects[R].visible,
properties: B.objects[R].properties
};
B.objects[R].rotation && (L.rotation =
B.objects[R].rotation),
M[B.name].push(L)
} else if (B.objects[R].polyline) {
var L = {
name: B.objects[R].name,
type: B.objects[R].type,
x: B.objects[R].x,
y: B.objects[R].y,
width: B.objects[R].width,
height: B.objects[R].height,
visible: B.objects[R].visible,
properties: B.objects[R].properties
};
B.objects[R].rotation && (L.rotation =
B.objects[R].rotation),
L.polyline = [];
for (var D = 0; D < B.objects[R].polyline.length;
D++)
L.polyline.push([B.objects[R].polyline[D].x,
B.objects[R].polyline[D].y]);
O[B.name].push(L),
M[B.name].push(L)
} else if (B.objects[R].polygon) {
var L = e(B.objects[R], ["name", "type", "x", "y",
"visible", "rotation", "properties"]);
L.polygon = [];
for (var D = 0; D < B.objects[R].polygon.length; D+
+)
L.polygon.push([B.objects[R].polygon[D].x,
B.objects[R].polygon[D].y]);
M[B.name].push(L)
} else if (B.objects[R].ellipse) {
var L = e(B.objects[R], ["name", "type", "ellipse",
"x", "y", "width", "height", "visible", "rotation", "properties"]);
M[B.name].push(L)
} else {
var L = e(B.objects[R], ["name", "type", "x", "y",
"width", "height", "visible", "rotation", "properties"]);
L.rectangle = !0,
M[B.name].push(L)
}
}
i.objects = M,
i.collision = O,
i.tiles = [];
for (var o = 0; o < i.tilesets.length; o++)
for (var A = i.tilesets[o], g = A.tileMargin, F = A.tileMargin,
N = 0, G = 0, U = 0, b = A.firstgid; b < A.firstgid + A.total && (i.tiles[b] = [g,
F, o],
g += A.tileWidth + A.tileSpacing,
++N !== A.total) && (++G !== A.columns || (g = A.tileMargin,
F += A.tileHeight + A.tileSpacing,
G = 0,
++U !== A.rows)); b++)
;
for (var u, w, W, A, o = 0; o < i.layers.length; o++) {
u = i.layers[o],
A = null;
for (var c = 0; c < u.data.length; c++) {
y = u.data[c];
for (var j = 0; j < y.length; j++)
null === (w = y[j]) || w.index < 0 || (W =
i.tiles[w.index][2],
A = i.tilesets[W],
A.tileProperties && A.tileProperties[w.index -
A.firstgid] && (w.properties = s.Utils.mixin(A.tileProperties[w.index -
A.firstgid], w.properties)))
}
}
return i
}
},
s.Tileset = function(t, e, i, n, s, o, r) {
(void 0 === i || i <= 0) && (i = 32),
(void 0 === n || n <= 0) && (n = 32),
void 0 === s && (s = 0),
void 0 === o && (o = 0),
this.name = t,
this.firstgid = 0 | e,
this.tileWidth = 0 | i,
this.tileHeight = 0 | n,
this.tileMargin = 0 | s,
this.tileSpacing = 0 | o,
this.properties = r || {},
this.image = null,
this.rows = 0,
this.columns = 0,
this.total = 0,
this.drawCoords = []
}
,
s.Tileset.prototype = {
draw: function(t, e, i, n) {
var s = n - this.firstgid << 1;
s >= 0 && s + 1 < this.drawCoords.length && t.drawImage(this.image,
this.drawCoords[s], this.drawCoords[s + 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)
, n = (t - 2 * this.tileMargin + this.tileSpacing) /
(this.tileWidth + this.tileSpacing);
i % 1 == 0 && n % 1 == 0 || console.warn("Phaser.Tileset - " +
this.name + " image tile area is not an even multiple of tile size"),
i = Math.floor(i),
n = Math.floor(n),
(this.rows && this.rows !== i || this.columns && this.columns !==
n) && console.warn("Phaser.Tileset - actual and expected number of tile rows and
columns differ"),
this.rows = i,
this.columns = n,
this.total = i * n,
this.drawCoords.length = 0;
for (var s = this.tileMargin, o = this.tileMargin, r = 0; r <
this.rows; r++) {
for (var a = 0; a < this.columns; a++)
this.drawCoords.push(s),
this.drawCoords.push(o),
s += this.tileWidth + this.tileSpacing;
s = this.tileMargin,
o += this.tileHeight + this.tileSpacing
}
}
},
s.Tileset.prototype.constructor = s.Tileset,
s.Particle = function(t, e, i, n, o) {
s.Sprite.call(this, t, e, i, n, o),
this.autoScale = !1,
this.scaleData = null,
this._s = 0,
this.autoAlpha = !1,
this.alphaData = null,
this._a = 0
}
,
s.Particle.prototype = Object.create(s.Sprite.prototype),
s.Particle.prototype.constructor = s.Particle,
s.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)
}
,
s.Particle.prototype.onEmit = function() {}
,
s.Particle.prototype.setAlphaData = function(t) {
this.alphaData = t,
this._a = t.length - 1,
this.alpha = this.alphaData[this._a].v,
this.autoAlpha = !0
}
,
s.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
}
,
s.Particle.prototype.reset = function(t, e, i) {
return s.Component.Reset.prototype.reset.call(this, t, e, i),
this.alpha = 1,
this.scale.set(1),
this.autoScale = !1,
this.autoAlpha = !1,
this
}
,
s.Particles = function(t) {
this.game = t,
this.emitters = {},
this.ID = 0
}
,
s.Particles.prototype = {
add: function(t) {
return this.emitters[t.id] = t,
t
},
remove: function(t) {
delete this.emitters[t.id]
},
update: function() {
for (var t in this.emitters)
this.emitters[t].exists && this.emitters[t].update()
}
},
s.Particles.prototype.constructor = s.Particles,
s.Particles.Arcade = {},
s.Particles.Arcade.Emitter = function(t, e, i, n) {
this.maxParticles = n || 50,
s.Group.call(this, t),
this._id = this.game.particles.ID++,
this.name = "emitter" + this.id,
this.type = s.EMITTER,
this.physicsType = s.GROUP,
this.area = new s.Rectangle(e,i,1,1),
this.minParticleSpeed = new s.Point(-100,-100),
this.maxParticleSpeed = new s.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 = new s.Point(0,100),
this.particleClass = s.Particle,
this.particleDrag = new s.Point,
this.angularDrag = 0,
this.frequency = 100,
this.lifespan = 2e3,
this.bounce = new s.Point,
this.on = !1,
this.particleAnchor = new s.Point(.5,.5),
this.blendMode = s.blendModes.NORMAL,
this.emitX = e,
this.emitY = i,
this.autoScale = !1,
this.autoAlpha = !1,
this.particleBringToTop = !1,
this.particleSendToBack = !1,
this._minParticleScale = new s.Point(1,1),
this._maxParticleScale = new s.Point(1,1),
this._quantity = 0,
this._timer = 0,
this._counter = 0,
this._flowQuantity = 0,
this._flowTotal = 0,
this._explode = !0,
this._frames = null
}
,
s.Particles.Arcade.Emitter.prototype = Object.create(s.Group.prototype),
s.Particles.Arcade.Emitter.prototype.constructor =
s.Particles.Arcade.Emitter,
s.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 (this._flowQuantity > 0) {
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++,
this._quantity > 0 && this._counter >= this._quantity &&
(this.on = !1));
for (var t = this.children.length; t--; )
this.children[t].exists && this.children[t].update()
}
,
s.Particles.Arcade.Emitter.prototype.makeParticles = function(t, e, i, n,
s) {
void 0 === e && (e = 0),
void 0 === i && (i = this.maxParticles),
void 0 === n && (n = !1),
void 0 === s && (s = !1);
var o, r = 0, a = t, h = e;
for (this._frames = e,
i > this.maxParticles && (this.maxParticles = i); r < i; )
Array.isArray(t) && (a = this.game.rnd.pick(t)),
Array.isArray(e) && (h = this.game.rnd.pick(e)),
o = new this.particleClass(this.game,0,0,a,h),
this.game.physics.arcade.enable(o, !1),
n ? (o.body.checkCollision.any = !0,
o.body.checkCollision.none = !1) : o.body.checkCollision.none = !0,
o.body.collideWorldBounds = s,
o.body.skipQuadTree = !0,
o.exists = !1,
o.visible = !1,
o.anchor.copyFrom(this.particleAnchor),
this.add(o),
r++;
return this
}
,
s.Particles.Arcade.Emitter.prototype.kill = function() {
return this.on = !1,
this.alive = !1,
this.exists = !1,
this
}
,
s.Particles.Arcade.Emitter.prototype.revive = function() {
return this.alive = !0,
this.exists = !0,
this
}
,
s.Particles.Arcade.Emitter.prototype.explode = function(t, e) {
return this._flowTotal = 0,
this.start(!0, t, 0, e, !1),
this
}
,
s.Particles.Arcade.Emitter.prototype.flow = function(t, e, i, n, s) {
return void 0 !== e && null !== e || (e = 250),
void 0 !== i && 0 !== i || (i = 1),
void 0 === n && (n = -1),
void 0 === s && (s = !0),
i > this.maxParticles && (i = this.maxParticles),
this._counter = 0,
this._flowQuantity = i,
this._flowTotal = n,
s ? (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
}
,
s.Particles.Arcade.Emitter.prototype.start = function(t, e, i, n, s) {
if (void 0 === t && (t = !0),
void 0 === e && (e = 0),
void 0 !== i && null !== i || (i = 250),
void 0 === n && (n = 0),
void 0 === s && (s = !1),
n > this.maxParticles && (n = this.maxParticles),
this.revive(),
this.visible = !0,
this.lifespan = e,
this.frequency = i,
t || s)
for (var o = 0; o < n; o++)
this.emitParticle();
else
this.on = !0,
this._quantity = n,
this._counter = 0,
this._timer = this.game.time.time + i * this.game.time.slowMotion;
return this
}
,
s.Particles.Arcade.Emitter.prototype.emitParticle = function(t, e, i, n) {
void 0 === t && (t = null),
void 0 === e && (e = null);
var s = this.getFirstExists(!1);
if (null === s)
return !1;
var o = this.game.rnd;
void 0 !== i && void 0 !== n ? s.loadTexture(i, n) : void 0 !== i &&
s.loadTexture(i);
var r = this.emitX
, a = this.emitY;
null !== t ? r = t : this.width > 1 && (r = o.between(this.left,
this.right)),
null !== e ? a = e : this.height > 1 && (a = o.between(this.top,
this.bottom)),
s.reset(r, a),
s.angle = 0,
s.lifespan = this.lifespan,
this.particleBringToTop ? this.bringToTop(s) : this.particleSendToBack
&& this.sendToBack(s),
this.autoScale ? s.setScaleData(this.scaleData) : 1 !==
this.minParticleScale || 1 !== this.maxParticleScale ?
s.scale.set(o.realInRange(this.minParticleScale, this.maxParticleScale)) :
this._minParticleScale.x === this._maxParticleScale.x && this._minParticleScale.y
=== this._maxParticleScale.y || s.scale.set(o.realInRange(this._minParticleScale.x,
this._maxParticleScale.x), o.realInRange(this._minParticleScale.y,
this._maxParticleScale.y)),
void 0 === n && (Array.isArray(this._frames) ? s.frame =
this.game.rnd.pick(this._frames) : s.frame = this._frames),
this.autoAlpha ? s.setAlphaData(this.alphaData) : s.alpha =
o.realInRange(this.minParticleAlpha, this.maxParticleAlpha),
s.blendMode = this.blendMode;
var h = s.body;
return h.updateBounds(),
h.bounce.copyFrom(this.bounce),
h.drag.copyFrom(this.particleDrag),
h.velocity.x = o.between(this.minParticleSpeed.x,
this.maxParticleSpeed.x),
h.velocity.y = o.between(this.minParticleSpeed.y,
this.maxParticleSpeed.y),
h.angularVelocity = o.between(this.minRotation, this.maxRotation),
h.gravity = this.gravity,
h.angularDrag = this.angularDrag,
s.onEmit(),
!0
}
,
s.Particles.Arcade.Emitter.prototype.destroy = function() {
this.game.particles.remove(this),
s.Group.prototype.destroy.call(this, !0, !1)
}
,
s.Particles.Arcade.Emitter.prototype.setSize = function(t, e) {
return this.area.width = t,
this.area.height = e,
this
}
,
s.Particles.Arcade.Emitter.prototype.setXSpeed = function(t, e) {
return t = t || 0,
e = e || 0,
this.minParticleSpeed.x = t,
this.maxParticleSpeed.x = e,
this
}
,
s.Particles.Arcade.Emitter.prototype.setYSpeed = function(t, e) {
return t = t || 0,
e = e || 0,
this.minParticleSpeed.y = t,
this.maxParticleSpeed.y = e,
this
}
,
s.Particles.Arcade.Emitter.prototype.setRotation = function(t, e) {
return t = t || 0,
e = e || 0,
this.minRotation = t,
this.maxRotation = e,
this
}
,
s.Particles.Arcade.Emitter.prototype.setAlpha = function(t, e, i, n, o) {
if (void 0 === t && (t = 1),
void 0 === e && (e = 1),
void 0 === i && (i = 0),
void 0 === n && (n = s.Easing.Linear.None),
void 0 === o && (o = !1),
this.minParticleAlpha = t,
this.maxParticleAlpha = e,
this.autoAlpha = !1,
i > 0 && t !== e) {
var r = {
v: t
}
, a = this.game.make.tween(r).to({
v: e
}, i, n);
a.yoyo(o),
this.alphaData = a.generateData(60),
this.alphaData.reverse(),
this.autoAlpha = !0
}
return this
}
,
s.Particles.Arcade.Emitter.prototype.setScale = function(t, e, i, n, o, r,
a) {
if (void 0 === t && (t = 1),
void 0 === e && (e = 1),
void 0 === i && (i = 1),
void 0 === n && (n = 1),
void 0 === o && (o = 0),
void 0 === r && (r = s.Easing.Linear.None),
void 0 === a && (a = !1),
this.minParticleScale = 1,
this.maxParticleScale = 1,
this._minParticleScale.set(t, i),
this._maxParticleScale.set(e, n),
this.autoScale = !1,
o > 0 && (t !== e || i !== n)) {
var h = {
x: t,
y: i
}
, l = this.game.make.tween(h).to({
x: e,
y: n
}, o, r);
l.yoyo(a),
this.scaleData = l.generateData(60),
this.scaleData.reverse(),
this.autoScale = !0
}
return this
}
,
s.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(s.Particles.Arcade.Emitter.prototype, "id", {
get: function() {
return this._id
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "width", {
get: function() {
return this.area.width
},
set: function(t) {
this.area.width = t
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "height", {
get: function() {
return this.area.height
},
set: function(t) {
this.area.height = t
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "x", {
get: function() {
return this.emitX
},
set: function(t) {
this.emitX = t
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "y", {
get: function() {
return this.emitY
},
set: function(t) {
this.emitY = t
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "left", {
get: function() {
return Math.floor(this.x - this.area.width / 2)
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "right", {
get: function() {
return Math.floor(this.x + this.area.width / 2)
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "top", {
get: function() {
return Math.floor(this.y - this.area.height / 2)
}
}),
Object.defineProperty(s.Particles.Arcade.Emitter.prototype, "bottom", {
get: function() {
return Math.floor(this.y + this.area.height / 2)
}
}),
s.Weapon = function(t, e) {
s.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 s.Rectangle(0,0,1,1),
this.fireAngle = s.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 s.Point(0,0),
this.bulletRotateToVelocity = !1,
this.bulletKey = "",
this.bulletFrame = "",
this._bulletClass = s.Bullet,
this._bulletCollideWorldBounds = !1,
this._bulletKillType = s.Weapon.KILL_WORLD_BOUNDS,
this._data = {
customBody: !1,
width: 0,
height: 0,
offsetX: 0,
offsetY: 0
},
this.bounds = new s.Rectangle,
this.bulletBounds = t.world.bounds,
this.bulletFrames = [],
this.bulletFrameIndex = 0,
this.anims = {},
this.onFire = new s.Signal,
this.onKill = new s.Signal,
this.onFireLimit = new s.Signal,
this.trackedSprite = null,
this.trackedPointer = null,
this.multiFire = !1,
this._hasFired = !1,
this.trackRotation = !1,
this.trackOffset = new s.Point,
this._nextFire = 0,
this._tempNextFire = 0,
this._rotatedPoint = new s.Point
}
,
s.Weapon.prototype = Object.create(s.Plugin.prototype),
s.Weapon.prototype.constructor = s.Weapon,
s.Weapon.KILL_NEVER = 0,
s.Weapon.KILL_LIFESPAN = 1,
s.Weapon.KILL_DISTANCE = 2,
s.Weapon.KILL_WEAPON_BOUNDS = 3,
s.Weapon.KILL_CAMERA_BOUNDS = 4,
s.Weapon.KILL_WORLD_BOUNDS = 5,
s.Weapon.KILL_STATIC_BOUNDS = 6,
s.Weapon.prototype.createBullets = function(t, e, i, n) {
return void 0 === t && (t = 1),
void 0 === n && (n = this.game.world),
this.bullets || (this.bullets =
this.game.add.physicsGroup(s.Physics.ARCADE, n),
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
}
,
s.Weapon.prototype.forEach = function(t, e) {
return this.bullets.forEachExists(t, e, arguments),
this
}
,
s.Weapon.prototype.pauseAll = function() {
return this.bullets.setAll("body.enable", !1),
this
}
,
s.Weapon.prototype.resumeAll = function() {
return this.bullets.setAll("body.enable", !0),
this
}
,
s.Weapon.prototype.killAll = function() {
return this.bullets.callAllExists("kill", !0),
this.bullets.setAll("body.enable", !0),
this
}
,
s.Weapon.prototype.resetShots = function(t) {
return this.shots = 0,
void 0 !== t && (this.fireLimit = t),
this
}
,
s.Weapon.prototype.destroy = function() {
this.parent.remove(this, !1),
this.bullets.destroy(),
this.game = null,
this.parent = null,
this.active = !1,
this.visible = !1
}
,
s.Weapon.prototype.update = function() {
this._bulletKillType === s.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()
}
,
s.Weapon.prototype.postRender = function() {
this.multiFire && this._hasFired && (this._hasFired = !1,
this._nextFire = this._tempNextFire)
}
,
s.Weapon.prototype.trackSprite = function(t, e, i, n) {
return void 0 === e && (e = 0),
void 0 === i && (i = 0),
void 0 === n && (n = !1),
this.trackedPointer = null,
this.trackedSprite = t,
this.trackRotation = n,
this.trackOffset.set(e, i),
this
}
,
s.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
}
,
s.Weapon.prototype.fireMany = function(t, e) {
this.multiFire = !0;
var i = []
, n = this;
return e || this.trackedSprite || this.trackedPointer ?
t.forEach(function(t) {
i.push(n.fire(e, null, null, t.x, t.y))
}) : t.forEach(function(t) {
i.push(n.fire(t))
}),
i
}
,
s.Weapon.prototype.fireOffset = function(t, e) {
return void 0 === t && (t = 0),
void 0 === e && (e = 0),
this.fire(null, null, null, t, e)
}
,
s.Weapon.prototype.fire = function(t, e, i, n, o) {
if (void 0 === e && (e = null),
void 0 === i && (i = null),
this.game.time.now < this._nextFire || this.fireLimit > 0 && this.shots
=== this.fireLimit)
return null;
var r = this.bulletSpeed;
0 !== this.bulletSpeedVariance && (r += s.Math.between(-
this.bulletSpeedVariance, this.bulletSpeedVariance)),
t ? this.fireFrom.width > 1 ? 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),
this.fireFrom.width > 1 ? this.fireFrom.centerOn(this._rotatedPoint.x,
this._rotatedPoint.y) : (this.fireFrom.x = this._rotatedPoint.x,
this.fireFrom.y = this._rotatedPoint.y)) : this.fireFrom.width > 1 ?
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 && (r +=
this.trackedSprite.body.speed)) : this.trackedPointer && (this.fireFrom.width > 1 ?
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)),
void 0 !== n && (this.fireFrom.x += n),
void 0 !== o && (this.fireFrom.y += o);
var a = this.fireFrom.width > 1 ? this.fireFrom.randomX :
this.fireFrom.x
, h = this.fireFrom.height > 1 ? this.fireFrom.randomY :
this.fireFrom.y
, l = this.trackRotation ? this.trackedSprite.angle : this.fireAngle;
null !== e && null !== i && (l = this.game.math.radToDeg(Math.atan2(i -
h, e - a))),
0 !== this.bulletAngleVariance && (l += s.Math.between(-
this.bulletAngleVariance, this.bulletAngleVariance));
var c = 0
, u = 0;
0 === l || 180 === l ? c = Math.cos(this.game.math.degToRad(l)) * r :
90 === l || 270 === l ? u = Math.sin(this.game.math.degToRad(l)) * r : (c =
Math.cos(this.game.math.degToRad(l)) * r,
u = Math.sin(this.game.math.degToRad(l)) * r);
var d = null;
if (this.autoExpandBulletsGroup ? (d = this.bullets.getFirstExists(!
1, !0, a, h, this.bulletKey, this.bulletFrame),
d.data.bulletManager = this) : d = this.bullets.getFirstExists(!1),
d) {
if (d.reset(a, h),
d.data.fromX = a,
d.data.fromY = h,
d.data.killType = this.bulletKillType,
d.data.killDistance = this.bulletKillDistance,
d.data.rotateToVelocity = this.bulletRotateToVelocity,
this.bulletKillType === s.Weapon.KILL_LIFESPAN && (d.lifespan =
this.bulletLifespan),
d.angle = l + this.bulletAngleOffset,
"" !== this.bulletAnimation) {
if (null === d.animations.getAnimation(this.bulletAnimation)) {
var p = this.anims[this.bulletAnimation];
d.animations.add(p.name, p.frames, p.frameRate, p.loop,
p.useNumericIndex)
}
d.animations.play(this.bulletAnimation)
} else
this.bulletFrameCycle ? (d.frame =
this.bulletFrames[this.bulletFrameIndex],
++this.bulletFrameIndex >= this.bulletFrames.length &&
(this.bulletFrameIndex = 0)) : this.bulletFrameRandom && (d.frame =
this.bulletFrames[Math.floor(Math.random() * this.bulletFrames.length)]);
d.data.bodyDirty && (this._data.customBody &&
d.body.setSize(this._data.width, this._data.height, this._data.offsetX,
this._data.offsetY),
d.body.collideWorldBounds = this.bulletCollideWorldBounds,
d.data.bodyDirty = !1),
d.body.velocity.set(c, u),
d.body.gravity.set(this.bulletGravity.x, this.bulletGravity.y);
var f = 0;
if (0 !== this.bulletSpeedVariance) {
var m = this.fireRate;
m += s.Math.between(-this.fireRateVariance,
this.fireRateVariance),
m < 0 && (m = 0),
f = this.game.time.now + m
} else
f = this.game.time.now + this.fireRate;
this.multiFire ? this._hasFired || (this._hasFired = !0,
this._tempNextFire = f,
this.shots++) : (this._nextFire = f,
this.shots++),
this.onFire.dispatch(d, this, r),
this.fireLimit > 0 && this.shots === this.fireLimit &&
this.onFireLimit.dispatch(this, this.fireLimit)
}
return d
}
,
s.Weapon.prototype.fireAtPointer = function(t) {
return void 0 === t && (t = this.game.input.activePointer),
this.fire(null, t.worldX, t.worldY)
}
,
s.Weapon.prototype.fireAtSprite = function(t) {
return this.fire(null, t.world.x, t.world.y)
}
,
s.Weapon.prototype.fireAtXY = function(t, e) {
return this.fire(null, t, e)
}
,
s.Weapon.prototype.setBulletBodyOffset = function(t, e, i, n) {
return void 0 === i && (i = 0),
void 0 === n && (n = 0),
this._data.customBody = !0,
this._data.width = t,
this._data.height = e,
this._data.offsetX = i,
this._data.offsetY = n,
this.bullets.callAll("body.setSize", "body", t, e, i, n),
this.bullets.setAll("data.bodyDirty", !1),
this
}
,
s.Weapon.prototype.setBulletFrames = function(t, e, i, n) {
return void 0 === i && (i = !0),
void 0 === n && (n = !1),
this.bulletFrames = s.ArrayUtils.numberArray(t, e),
this.bulletFrameIndex = 0,
this.bulletFrameCycle = i,
this.bulletFrameRandom = n,
this
}
,
s.Weapon.prototype.addBulletAnimation = function(t, e, i, n, s) {
return this.anims[t] = {
name: t,
frames: e,
frameRate: i,
loop: n,
useNumericIndex: s
},
this.bullets.callAll("animations.add", "animations", t, e, i, n, s),
this.bulletAnimation = t,
this
}
,
s.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(s.Weapon.prototype, "bulletClass", {
get: function() {
return this._bulletClass
},
set: function(t) {
this._bulletClass = t,
this.bullets && (this.bullets.classType = this._bulletClass)
}
}),
Object.defineProperty(s.Weapon.prototype, "bulletKillType", {
get: function() {
return this._bulletKillType
},
set: function(t) {
switch (t) {
case s.Weapon.KILL_STATIC_BOUNDS:
case s.Weapon.KILL_WEAPON_BOUNDS:
this.bulletBounds = this.bounds;
break;
case s.Weapon.KILL_CAMERA_BOUNDS:
this.bulletBounds = this.game.camera.view;
break;
case s.Weapon.KILL_WORLD_BOUNDS:
this.bulletBounds = this.game.world.bounds
}
this._bulletKillType = t
}
}),
Object.defineProperty(s.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(s.Weapon.prototype, "x", {
get: function() {
return this.fireFrom.x
},
set: function(t) {
this.fireFrom.x = t
}
}),
Object.defineProperty(s.Weapon.prototype, "y", {
get: function() {
return this.fireFrom.y
},
set: function(t) {
this.fireFrom.y = t
}
}),
s.Bullet = function(t, e, i, n, o) {
s.Sprite.call(this, t, e, i, n, o),
this.anchor.set(.5),
this.data = {
bulletManager: null,
fromX: 0,
fromY: 0,
bodyDirty: !0,
rotateToVelocity: !1,
killType: 0,
killDistance: 0
}
}
,
s.Bullet.prototype = Object.create(s.Sprite.prototype),
s.Bullet.prototype.constructor = s.Bullet,
s.Bullet.prototype.kill = function() {
return this.alive = !1,
this.exists = !1,
this.visible = !1,
this.data.bulletManager.onKill.dispatch(this),
this
}
,
s.Bullet.prototype.update = function() {
this.exists && (this.data.killType > s.Weapon.KILL_LIFESPAN &&
(this.data.killType === s.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))
}
,
s.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 = s.VIDEO,
this.disableTextureUpload = !1,
this.touchLocked = !1,
this.onPlay = new s.Signal,
this.onChangeSource = new s.Signal,
this.onComplete = new s.Signal,
this.onAccess = new s.Signal,
this.onError = new s.Signal,
this.onTimeout = new s.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._pendingChangeSource = !1,
this._autoplay = !1,
this._endCallback = null,
this._playCallback = null,
e && this.game.cache.checkVideoKey(e)) {
var n = this.game.cache.getVideo(e);
n.isBlob ? this.createVideoFromBlob(n.data) : this.video = n.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,null,this.game.resolution),
this.baseTexture.forceLoaded(this.width, this.height)) :
(this.baseTexture = new
PIXI.BaseTexture(s.Cache.DEFAULT.baseTexture.source,null,this.game.resolution),
this.baseTexture.forceLoaded(this.width, this.height)),
this.texture = new PIXI.Texture(this.baseTexture),
this.textureFrame = new s.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,
s.BitmapData && (this.snapshot = new
s.BitmapData(this.game,"",this.width,this.height)),
!this.game.device.cocoonJS && (this.game.device.iOS ||
this.game.device.android) || window.PhaserGlobal &&
window.PhaserGlobal.fakeiOSTouchLock ? this.setTouchLock() : n && (n.locked = !1)
}
,
s.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 e = this;
this.video.onloadeddata = function() {
function t() {
if (i > 0)
if (e.video.videoWidth > 0) {
var n = e.video.videoWidth
, s = e.video.videoHeight;
isNaN(e.video.videoHeight) && (s = n / (4 / 3)),
e.video.play(),
e.isStreaming = !0,
e.baseTexture.source = e.video,
e.updateTexture(null, n, s),
e.onAccess.dispatch(e)
} else
window.setTimeout(t, 500);
else
console.warn("Unable to connect to video stream. Webcam
error?");
i--
}
var i = 10;
t()
}
},
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 n = !1;
void 0 !== e && null !== e || (e = this.video.videoWidth,
n = !0),
void 0 !== i && 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),
n && 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 this._pendingChangeSource ? this : (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, n, s, o) {
s = s || 1,
o = o || 1;
var r = this.game.add.image(t, e, this);
return r.anchor.set(i, n),
r.scale.set(s, o),
r
},
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._pendingChangeSource = !0,
this.retry = this.retryLimit,
this._retryID =
window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval),
this.video.src = t,
this.video.load(),
this._autoplay = e,
e || (this.paused = !0),
this
},
checkVideoProgress: function() {
4 === this.video.readyState ? (this._pendingChangeSource = !1,
this.updateTexture()) : (this.retry--,
this.retry > 0 ? this._retryID =
window.setTimeout(this.checkVideoProgress.bind(this), this.retryInterval) :
console.warn("Phaser.Video: Unable to start downloading video in time",
this.isStreaming))
},
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) {
return void 0 === t && (t = !1),
void 0 === e && (e = 1),
void 0 === i && (i = null),
null === this.snapshot ? void console.warn("Video.grab cannot run
because Phaser.BitmapData is unavailable") : (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(s.Video.prototype, "currentTime", {
get: function() {
return this.video ? this.video.currentTime : 0
},
set: function(t) {
this.video.currentTime = t
}
}),
Object.defineProperty(s.Video.prototype, "duration", {
get: function() {
return this.video ? this.video.duration : 0
}
}),
Object.defineProperty(s.Video.prototype, "progress", {
get: function() {
return this.video ? this.video.currentTime / this.video.duration :
0
}
}),
Object.defineProperty(s.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(s.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(s.Video.prototype, "volume", {
get: function() {
return this.video ? this.video.volume : 1
},
set: function(t) {
t < 0 ? t = 0 : t > 1 && (t = 1),
this.video && (this.video.volume = t)
}
}),
Object.defineProperty(s.Video.prototype, "playbackRate", {
get: function() {
return this.video ? this.video.playbackRate : 1
},
set: function(t) {
this.video && (this.video.playbackRate = t)
}
}),
Object.defineProperty(s.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(s.Video.prototype, "playing", {
get: function() {
return !!this.video && !(this.video.paused && this.video.ended)
}
}),
s.Video.prototype.constructor = s.Video,
void 0 === PIXI.blendModes && (PIXI.blendModes = s.blendModes),
void 0 === PIXI.scaleModes && (PIXI.scaleModes = s.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),
PIXI.TextureSilentFail = !0,
void 0 !== e ? (void 0 !== t && t.exports && (e = t.exports = s),
e.Phaser = s) : "undefined" != typeof define && define.amd ?
define("Phaser", function() {
return n.Phaser = s
}()) : n.Phaser = s,
s
}
).call(this)
}
, function(t, e) {
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2016 Photon Storm Ltd.
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*
* @overview
*
* Phaser - http://phaser.io
*
* v2.7.3 "2017-01-09" - Built: Mon Jan 09 2017 13:26:34
*
* By Richard Davey http://www.photonstorm.com @photonstorm
*
* Phaser is a fun, free and fast 2D game framework for making HTML5 games
* for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
*
* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com
@Doormat23
* Phaser uses p2.js for full-body physics, created by Stefan Hedman
https://github.com/schteppe/p2.js @schteppe
* Phaser contains a port of N+ Physics, converted by Richard Davey, original by
http://www.metanetsoftware.com
*
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from which both
Phaser and my love of framework development originate.
*
* Follow development at http://phaser.io and on our forum
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
* -- Albert Einstein
*/
(function() {
function i(t, e, i, n) {
var s = t.createTexture();
return t.bindTexture(t.TEXTURE_2D, s),
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.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, n ===
o.scaleModes.LINEAR ? t.LINEAR : t.NEAREST),
t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, n ===
o.scaleModes.LINEAR ? t.LINEAR : t.NEAREST),
t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, e, i, 0, t.RGBA, t.UNSIGNED_BYTE,
null),
s
}
function n(t, e, n, s, o) {
var a = t.createFramebuffer()
, h = t.createRenderbuffer()
, l = null
, c = 0;
return t.activeTexture(t.TEXTURE0 + o),
t.bindFramebuffer(t.FRAMEBUFFER, a),
t.bindRenderbuffer(t.RENDERBUFFER, h),
t.framebufferRenderbuffer(t.FRAMEBUFFER, t.DEPTH_STENCIL_ATTACHMENT,
t.RENDERBUFFER, this.renderBuffer),
l = i(t, e, n, s),
t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0,
t.TEXTURE_2D, l, 0),
c = t.checkFramebufferStatus(t.FRAMEBUFFER),
c !== t.FRAMEBUFFER_COMPLETE && console.error("Incomplete GL
framebuffer. ", r[c]),
a.width = e,
a.height = n,
a.targetTexture = l,
a.renderBuffer = h,
a
}
var s = this
, o = o || {};
/**
* @author Mat Groves http://matgroves.com @Doormat23
* @author Richard Davey <rich@photonstorm.com>
* @license {@link
https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
o.DisplayObject = function() {
this.position = new o.Point(0,0),
this.scale = new o.Point(1,1),
this.pivot = new o.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 o.Matrix,
this.worldPosition = new o.Point(0,0),
this.worldScale = new o.Point(1,1),
this.worldRotation = 0,
this.filterArea = null,
this._sr = 0,
this._cr = 1,
this._bounds = new o.Rectangle(0,0,0,0),
this._currentBounds = null,
this._mask = null,
this._cacheAsBitmap = !1,
this._cacheIsDirty = !1
}
,
o.DisplayObject.prototype.constructor = o.DisplayObject,
o.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, n, s, o, r, a, h = e.worldTransform, l =
this.worldTransform;
return this.rotation % Phaser.Math.PI2 ? (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,
n = this._sr * this.scale.x,
s = -this._sr * this.scale.y,
o = this._cr * this.scale.y,
r = this.position.x,
a = this.position.y,
(this.pivot.x || this.pivot.y) && (r -= this.pivot.x * i +
this.pivot.y * s,
a -= this.pivot.x * n + this.pivot.y * o),
l.a = i * h.a + n * h.c,
l.b = i * h.b + n * h.d,
l.c = s * h.a + o * h.c,
l.d = s * h.b + o * h.d,
l.tx = r * h.a + a * h.c + h.tx,
l.ty = r * h.b + a * h.d + h.ty) : (i = this.scale.x,
o = this.scale.y,
r = this.position.x - this.pivot.x * i,
a = this.position.y - this.pivot.y * o,
l.a = i * h.a,
l.b = i * h.b,
l.c = o * h.c,
l.d = o * h.d,
l.tx = r * h.a + a * h.c + h.tx,
l.ty = r * h.b + a * 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 n = this.getLocalBounds()
, s = new Phaser.RenderTexture(this.game,0 | n.width,0 |
n.height,i,e,t);
return o.DisplayObject._tempMatrix.tx = -n.x,
o.DisplayObject._tempMatrix.ty = -n.y,
s.render(this, o.DisplayObject._tempMatrix),
s
},
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 ? o.Sprite.prototype._renderWebGL.call(this._cachedSprite,
t) : o.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 = 0;
this.texture && this.texture.baseTexture &&
o._enableMultiTextureToggle && (e = this.texture.baseTexture.textureIndex);
var i = new
Phaser.RenderTexture(t.width,t.height,null,null,null,e);
this._cachedSprite = new o.Sprite(i),
this._cachedSprite.worldTransform = this.worldTransform
}
var n = this._filters;
this._filters = null,
this._cachedSprite.filters = n,
o.DisplayObject._tempMatrix.tx = -t.x,
o.DisplayObject._tempMatrix.ty = -t.y,
this._cachedSprite.texture.render(this,
o.DisplayObject._tempMatrix, !0),
this._cachedSprite.anchor.x = -t.x / t.width,
this._cachedSprite.anchor.y = -t.y / t.height,
this._filters = n,
this._cacheAsBitmap = !0
},
_destroyCachedSprite: function() {
this._cachedSprite && (this._cachedSprite.texture.destroy(!0),
this._cachedSprite = null)
}
},
o.DisplayObject.prototype.displayObjectUpdateTransform =
o.DisplayObject.prototype.updateTransform,
Object.defineProperties(o.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,
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 n = t[i].passes, s = 0; s < n.length; s++)
e.push(n[s]);
this._filterBlock = {
target: this,
filterPasses: e
}
}
this._filters = t,
this.blendMode && this.blendMode === o.blendModes.MULTIPLY &&
(this.blendMode = o.blendModes.NORMAL)
}
},
cacheAsBitmap: {
get: function() {
return this._cacheAsBitmap
},
set: function(t) {
this._cacheAsBitmap !== t && (t ?
this._generateCachedSprite() : this._destroyCachedSprite(),
this._cacheAsBitmap = t)
}
}
}),
o.DisplayObjectContainer = function() {
o.DisplayObject.call(this),
this.children = [],
this.ignoreChildInput = !1
}
,
o.DisplayObjectContainer.prototype =
Object.create(o.DisplayObject.prototype),
o.DisplayObjectContainer.prototype.constructor = o.DisplayObjectContainer,
o.DisplayObjectContainer.prototype.addChild = function(t) {
return this.addChildAt(t, this.children.length)
}
,
o.DisplayObjectContainer.prototype.addChildAt = function(t, e) {
if (e >= 0 && e <= this.children.length)
return t.parent && t.parent.removeChild(t),
t.parent = this,
this.children.splice(e, 0, t),
t;
throw new Error(t + "addChildAt: The index " + e + " supplied is out of
bounds " + this.children.length)
}
,
o.DisplayObjectContainer.prototype.swapChildren = function(t, e) {
if (t !== e) {
var i = this.getChildIndex(t)
, n = this.getChildIndex(e);
if (i < 0 || n < 0)
throw new Error("swapChildren: Both the supplied DisplayObjects
must be a child of the caller.");
this.children[i] = e,
this.children[n] = t
}
}
,
o.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
}
,
o.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)
}
,
o.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]
}
,
o.DisplayObjectContainer.prototype.removeChild = function(t) {
var e = this.children.indexOf(t);
if (-1 !== e)
return this.removeChildAt(e)
}
,
o.DisplayObjectContainer.prototype.removeChildAt = function(t) {
var e = this.getChildAt(t);
return e && (e.parent = void 0,
this.children.splice(t, 1)),
e
}
,
o.DisplayObjectContainer.prototype.removeChildren = function(t, e) {
void 0 === t && (t = 0),
void 0 === e && (e = this.children.length);
var i = e - t;
if (i > 0 && i <= e) {
for (var n = this.children.splice(t, i), s = 0; s < n.length; s++)
{
n[s].parent = void 0
}
return n
}
if (0 === i && 0 === this.children.length)
return [];
throw new Error("removeChildren: Range Error, numeric values are
outside the acceptable range")
}
,
o.DisplayObjectContainer.prototype.updateTransform = function() {
if (this.visible && (this.displayObjectUpdateTransform(),
!this._cacheAsBitmap))
for (var t = 0; t < this.children.length; t++)
this.children[t].updateTransform()
}
,
o.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform =
o.DisplayObjectContainer.prototype.updateTransform,
o.DisplayObjectContainer.prototype.getBounds = function(t) {
var e = t && t instanceof o.DisplayObject
, i = !0;
e ? i = t instanceof o.DisplayObjectContainer && t.contains(this) : t =
this;
var n;
if (e) {
var s = t.worldTransform;
for (t.worldTransform = o.identityMatrix,
n = 0; n < t.children.length; n++)
t.children[n].updateTransform()
}
var r, a, h, l = 1 / 0, c = 1 / 0, u = -1 / 0, d = -1 / 0, p = !1;
for (n = 0; n < this.children.length; n++) {
this.children[n].visible && (p = !0,
r = this.children[n].getBounds(),
l = l < r.x ? l : r.x,
c = c < r.y ? c : r.y,
a = r.width + r.x,
h = r.height + r.y,
u = u > a ? u : a,
d = d > h ? d : h)
}
var f = this._bounds;
if (!p) {
f = new o.Rectangle;
var m = f.x
, g = f.width + f.x
, y = f.y
, v = f.height + f.y
, b = this.worldTransform
, w = b.a
, x = b.b
, _ = b.c
, P = b.d
, T = b.tx
, C = b.ty
, S = w * g + _ * v + T
, A = P * v + x * g + C
, k = w * m + _ * v + T
, E = P * v + x * m + C
, I = w * m + _ * y + T
, M = P * y + x * m + C
, O = w * g + _ * y + T
, B = P * y + x * g + C;
u = S,
d = A,
l = S,
c = A,
l = k < l ? k : l,
l = I < l ? I : l,
l = O < l ? O : l,
c = E < c ? E : c,
c = M < c ? M : c,
c = B < c ? B : c,
u = k > u ? k : u,
u = I > u ? I : u,
u = O > u ? O : u,
d = E > d ? E : d,
d = M > d ? M : d,
d = B > d ? B : d
}
if (f.x = l,
f.y = c,
f.width = u - l,
f.height = d - c,
e)
for (t.worldTransform = s,
n = 0; n < t.children.length; n++)
t.children[n].updateTransform();
if (!i) {
var R = t.getBounds();
f.x -= R.x,
f.y -= R.y
}
return f
}
,
o.DisplayObjectContainer.prototype.getLocalBounds = function() {
return this.getBounds(this)
}
,
o.DisplayObjectContainer.prototype.contains = function(t) {
return !!t && (t === this || this.contains(t.parent))
}
,
o.DisplayObjectContainer.prototype._renderWebGL = function(t) {
if (this.visible && !(this.alpha <= 0)) {
if (this._cacheAsBitmap)
return void this._renderCachedSprite(t);
var e;
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)
}
}
,
o.DisplayObjectContainer.prototype._renderCanvas = function(t) {
if (!1 !== this.visible && 0 !== this.alpha) {
if (this._cacheAsBitmap)
return void this._renderCachedSprite(t);
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(o.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(o.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
}
}),
o.Sprite = function(t) {
o.DisplayObjectContainer.call(this),
this.anchor = new o.Point,
this.texture = t || o.Texture.emptyTexture,
this._width = 0,
this._height = 0,
this.tint = 16777215,
this.cachedTint = -1,
this.tintedTexture = null,
this.blendMode = o.blendModes.NORMAL,
this.shader = null,
this.exists = !0,
this.texture.baseTexture.hasLoaded && this.onTextureUpdate(),
this.renderable = !0
}
,
o.Sprite.prototype = Object.create(o.DisplayObjectContainer.prototype),
o.Sprite.prototype.constructor = o.Sprite,
Object.defineProperty(o.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(o.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
}
}),
o.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
}
,
o.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)
}
,
o.Sprite.prototype.getBounds = function(t) {
var e = this.texture.frame.width
, i = this.texture.frame.height
, n = e * (1 - this.anchor.x)
, s = e * -this.anchor.x
, o = i * (1 - this.anchor.y)
, r = i * -this.anchor.y
, a = t || this.worldTransform
, h = a.a
, l = a.b
, c = a.c
, u = a.d
, d = a.tx
, p = a.ty
, f = -1 / 0
, m = -1 / 0
, g = 1 / 0
, y = 1 / 0;
if (0 === l && 0 === c) {
if (h < 0) {
h *= -1;
var v = n;
n = -s,
s = -v
}
if (u < 0) {
u *= -1;
var v = o;
o = -r,
r = -v
}
g = h * s + d,
f = h * n + d,
y = u * r + p,
m = u * o + p
} else {
var b = h * s + c * r + d
, w = u * r + l * s + p
, x = h * n + c * r + d
, _ = u * r + l * n + p
, P = h * n + c * o + d
, T = u * o + l * n + p
, C = h * s + c * o + d
, S = u * o + l * s + p;
g = b < g ? b : g,
g = x < g ? x : g,
g = P < g ? P : g,
g = C < g ? C : g,
y = w < y ? w : y,
y = _ < y ? _ : y,
y = T < y ? T : y,
y = S < y ? S : y,
f = b > f ? b : f,
f = x > f ? x : f,
f = P > f ? P : f,
f = C > f ? C : f,
m = w > m ? w : m,
m = _ > m ? _ : m,
m = T > m ? T : m,
m = S > m ? S : m
}
var A = this._bounds;
return A.x = g,
A.width = f - g,
A.y = y,
A.height = m - y,
this._currentBounds = A,
A
}
,
o.Sprite.prototype.getLocalBounds = function() {
var t = this.worldTransform;
this.worldTransform = o.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
}
,
o.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 n = t.spriteBatch;
this._filters && (n.flush(),
t.filterManager.pushFilter(this._filterBlock)),
this._mask && (n.stop(),
t.maskManager.pushMask(this.mask, t),
n.start()),
n.render(this);
for (var s = 0; s < this.children.length; s++)
this.children[s]._renderWebGL(t);
n.stop(),
this._mask && t.maskManager.popMask(this._mask, t),
this._filters && t.filterManager.popFilter(),
n.start()
} else {
t.spriteBatch.render(this);
for (var s = 0; s < this.children.length; s++)
this.children[s]._renderWebGL(t, i)
}
}
}
,
o.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 =
o.blendModesCanvas[t.currentBlendMode]),
this._mask && t.maskManager.pushMask(this._mask, t),
!this.texture.valid) {
for (var n = 0; n < this.children.length; n++)
this.children[n]._renderCanvas(t);
return void (this._mask && t.maskManager.popMask(t))
}
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 === o.scaleModes.LINEAR);
var r = this.texture.trim ? this.texture.trim.x - this.anchor.x *
this.texture.trim.width : this.anchor.x * -this.texture.frame.width
, a = this.texture.trim ? this.texture.trim.y - this.anchor.y *
this.texture.trim.height : this.anchor.y * -this.texture.frame.height
, h = i.tx * t.resolution + t.shakeX
, l = i.ty * t.resolution + t.shakeY
, c = this.texture.crop.width
, u = this.texture.crop.height;
if (this.texture.rotated) {
var d = i.a
, p = i.b
, f = i.c
, m = i.d
, g = c;
h = i.c * u + h,
l = i.d * u + l,
i.a = 6.123233995736766e-17 * d - f,
i.b = 6.123233995736766e-17 * p - m,
i.c = d + 6.123233995736766e-17 * f,
i.d = p + 6.123233995736766e-17 * m,
c = u,
u = g
}
if (t.roundPixels ? (t.context.setTransform(i.a, i.b, i.c, i.d, 0 |
h, 0 | l),
r |= 0,
a |= 0) : t.context.setTransform(i.a, i.b, i.c, i.d, h, l),
r /= s,
a /= s,
16777215 !== this.tint)
(this.texture.requiresReTint || this.cachedTint !== this.tint)
&& (this.tintedTexture = o.CanvasTinter.getTintedTexture(this, this.tint),
this.cachedTint = this.tint,
this.texture.requiresReTint = !1),
t.context.drawImage(this.tintedTexture, 0, 0, c, u, r, a, c /
s, u / s);
else {
var y = this.texture.crop.x
, v = this.texture.crop.y;
t.context.drawImage(this.texture.baseTexture.source, y, v, c,
u, r, a, c / s, u / s)
}
for (var n = 0; n < this.children.length; n++)
this.children[n]._renderCanvas(t);
this._mask && t.maskManager.popMask(t)
}
}
,
o.initDefaultShaders = function() {}
,
o.CompileVertexShader = function(t, e) {
return o._CompileShader(t, e, t.VERTEX_SHADER)
}
,
o.CompileFragmentShader = function(t, e) {
return o._CompileShader(t, e, t.FRAGMENT_SHADER)
}
,
o._CompileShader = function(t, e, i) {
var n = e;
Array.isArray(e) && (n = e.join("\n"));
var s = t.createShader(i);
return t.shaderSource(s, n),
t.compileShader(s),
t.getShaderParameter(s, t.COMPILE_STATUS) ? s :
(window.console.log(t.getShaderInfoLog(s)),
null)
}
,
o.compileProgram = function(t, e, i) {
var n = o.CompileFragmentShader(t, i)
, s = o.CompileVertexShader(t, e)
, r = t.createProgram();
return t.attachShader(r, s),
t.attachShader(r, n),
t.linkProgram(r),
t.getProgramParameter(r, t.LINK_STATUS) ||
(window.console.log(t.getProgramInfoLog(r)),
window.console.log("Could not initialise shaders")),
r
}
,
o.PixiShader = function(t) {
this._UID = Phaser._UID++,
this.gl = t,
this.program = null,
this.fragmentSrc = null,
this.textureCount = 0,
this.firstRun = !0,
this.dirty = !0,
this.attributes = [],
this.init()
}
,
o.PixiShader.prototype.constructor = o.PixiShader,
o.PixiShader.prototype.initMultitexShader = function() {
var t = this.gl;
this.MAX_TEXTURES = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
for (var e = "\tif (vTextureIndex == 0.0) gl_FragColor =
texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n", i = 1; i <
this.MAX_TEXTURES; ++i)
e += "\telse if (vTextureIndex == " + i + ".0) gl_FragColor =
texture2D(uSamplerArray[" + i + "], vTextureCoord) * vColor;\n";
this.fragmentSrc = ["// PixiShader Fragment Shader.", "precision lowp
float;", "bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val ==
0.0 ) ? false : true; }", "varying vec2 vTextureCoord;", "varying vec4 vColor;",
"varying float vTextureIndex;", "uniform sampler2D uSamplerArray[" +
this.MAX_TEXTURES + "];", "const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);", "const
vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);", "void main(void) {", e, " else
if(vTextureIndex >= " + this.MAX_TEXTURES + ".0) gl_FragColor = BLUE;", " else
if(isnan(vTextureIndex)) gl_FragColor = RED;", "}"];
var n = o.compileProgram(t, this.vertexSrc ||
o.PixiShader.defaultVertexSrc, this.fragmentSrc);
t.useProgram(n),
this.uSamplerArray = t.getUniformLocation(n, "uSamplerArray[0]"),
this.projectionVector = t.getUniformLocation(n, "projectionVector"),
this.offsetVector = t.getUniformLocation(n, "offsetVector"),
this.dimensions = t.getUniformLocation(n, "dimensions"),
this.aVertexPosition = t.getAttribLocation(n, "aVertexPosition"),
this.aTextureCoord = t.getAttribLocation(n, "aTextureCoord"),
this.colorAttribute = t.getAttribLocation(n, "aColor"),
this.aTextureIndex = t.getAttribLocation(n, "aTextureIndex");
var s = []
, r = t.createTexture();
t.activeTexture(t.TEXTURE0),
t.bindTexture(t.TEXTURE_2D, r),
t.texImage2D(t.TEXTURE_2D, 0, t.RGB, 1, 1, 0, t.RGB, t.UNSIGNED_BYTE,
null);
for (var a = 0; a < this.MAX_TEXTURES; ++a)
t.activeTexture(t.TEXTURE0 + a),
t.bindTexture(t.TEXTURE_2D, r),
s.push(a);
t.activeTexture(t.TEXTURE0),
t.uniform1iv(this.uSamplerArray, s),
-1 === this.colorAttribute && (this.colorAttribute = 2),
this.attributes = [this.aVertexPosition, this.aTextureCoord,
this.colorAttribute, this.aTextureIndex];
for (var h in this.uniforms)
this.uniforms[h].uniformLocation = t.getUniformLocation(n, h);
this.initUniforms(),
this.program = n
}
,
o.PixiShader.prototype.initDefaultShader = function() {
null === this.fragmentSrc && (this.fragmentSrc = ["precision lowp
float;", "varying vec2 vTextureCoord;", "varying vec4 vColor;", "varying float
vTextureIndex;", "uniform sampler2D uSampler;", "void main(void) {", "
gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;", "}"]);
var t = this.gl
, e = o.compileProgram(t, this.vertexSrc ||
o.PixiShader.defaultVertexSrc, 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.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"),
this.aTextureCoord = t.getAttribLocation(e, "aTextureCoord"),
this.colorAttribute = t.getAttribLocation(e, "aColor"),
this.aTextureIndex = t.getAttribLocation(e, "aTextureIndex"),
-1 === this.colorAttribute && (this.colorAttribute = 2),
this.attributes = [this.aVertexPosition, this.aTextureCoord,
this.colorAttribute, this.aTextureIndex];
for (var i in this.uniforms)
this.uniforms[i].uniformLocation = t.getUniformLocation(e, i);
this.initUniforms(),
this.program = e
}
,
o.PixiShader.prototype.init = function(t) {
o._enableMultiTextureToggle && !t ? this.initMultitexShader() :
this.initDefaultShader()
}
,
o.PixiShader.prototype.initUniforms = function() {
this.textureCount = 1;
var t, e = this.gl;
for (var i in this.uniforms) {
t = this.uniforms[i];
var n = t.type;
"sampler2D" === n ? (t._init = !1,
null !== t.value && this.initSampler2D(t)) : "mat2" === n || "mat3"
=== n || "mat4" === n ? (t.glMatrix = !0,
t.glValueLength = 1,
"mat2" === n ? t.glFunc = e.uniformMatrix2fv : "mat3" === n ?
t.glFunc = e.uniformMatrix3fv : "mat4" === n && (t.glFunc = e.uniformMatrix4fv)) :
(t.glFunc = e["uniform" + n],
t.glValueLength = "2f" === n || "2i" === n ? 2 : "3f" === n || "3i"
=== n ? 3 : "4f" === n || "4i" === n ? 4 : 1)
}
}
,
o.PixiShader.prototype.initSampler2D = function(t) {
if (t.value && t.value.baseTexture && t.value.baseTexture.hasLoaded) {
var e = this.gl;
if (e.activeTexture(e.TEXTURE0 + this.textureCount),
e.bindTexture(e.TEXTURE_2D, t.value.baseTexture._glTextures[e.id]),
t.textureData) {
var i = t.textureData
, n = i.magFilter ? i.magFilter : e.LINEAR
, s = i.minFilter ? i.minFilter : e.LINEAR
, o = i.wrapS ? i.wrapS : e.CLAMP_TO_EDGE
, r = i.wrapT ? i.wrapT : e.CLAMP_TO_EDGE
, a = i.luminance ? e.LUMINANCE : e.RGBA;
if (i.repeat && (o = e.REPEAT,
r = 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, a, h, l, c, a,
e.UNSIGNED_BYTE, null)
} else
e.texImage2D(e.TEXTURE_2D, 0, a, e.RGBA, e.UNSIGNED_BYTE,
t.value.baseTexture.source);
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, n),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, s),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, o),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, r)
}
e.uniform1i(t.uniformLocation, this.textureCount),
t._init = !0,
this.textureCount++
}
}
,
o.PixiShader.prototype.syncUniforms = function() {
this.textureCount = 1;
var t, e = this.gl;
for (var i in this.uniforms)
t = this.uniforms[i],
1 === t.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] ?
o.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))
}
,
o.PixiShader.prototype.destroy = function() {
this.gl.deleteProgram(this.program),
this.uniforms = null,
this.gl = null,
this.attributes = null
}
,
o.PixiShader.defaultVertexSrc = ["// PixiShader Vertex Shader", "// With
multi-texture rendering", "attribute vec2 aVertexPosition;", "attribute vec2
aTextureCoord;", "attribute vec4 aColor;", "attribute float aTextureIndex;",
"uniform vec2 projectionVector;", "uniform vec2 offsetVector;", "varying vec2
vTextureCoord;", "varying vec4 vColor;", "varying float vTextureIndex;", "const
vec2 center = vec2(-1.0, 1.0);", "void main(void) {", " if (aTextureIndex > 0.0)
gl_Position = vec4(0.0);", " gl_Position = vec4( ((aVertexPosition +
offsetVector) / projectionVector) + center , 0.0, 1.0);", " vTextureCoord =
aTextureCoord;", " vColor = vec4(aColor.rgb * aColor.a, aColor.a);", "
vTextureIndex = aTextureIndex;", "}"],
o.PixiFastShader = function(t) {
if (this._UID = Phaser._UID++,
this.gl = t,
this.program = null,
o._enableMultiTextureToggle) {
var t = this.gl;
this.MAX_TEXTURES = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
for (var e = "\tif (vTextureIndex == 0.0) gl_FragColor =
texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n", i = 1; i <
this.MAX_TEXTURES; ++i)
e += "\telse if (vTextureIndex == " + i + ".0) gl_FragColor =
texture2D(uSamplerArray[" + i + "], vTextureCoord) * vColor;\n";
this.fragmentSrc = ["// PixiFastShader Fragment Shader.",
"precision lowp float;", "bool isnan( float val ) { return ( val < 0.0 || 0.0 <
val || val == 0.0 ) ? false : true; }", "varying vec2 vTextureCoord;", "varying
float vColor;", "varying float vTextureIndex;", "uniform sampler2D uSamplerArray["
+ this.MAX_TEXTURES + "];", "const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);", "const
vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);", "void main(void) {", e, " else
if(vTextureIndex >= " + this.MAX_TEXTURES + ".0) gl_FragColor = BLUE;", " else
if(isnan(vTextureIndex)) gl_FragColor = RED;", "}"]
} else
this.fragmentSrc = ["// PixiFastShader Fragment Shader.",
"precision lowp float;", "varying vec2 vTextureCoord;", "varying float vColor;",
"varying float vTextureIndex;", "uniform sampler2D uSampler;", "void main(void) {",
" gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;", "}"];
this.vertexSrc = ["// PixiFastShader Vertex Shader.", "attribute vec2
aVertexPosition;", "attribute vec2 aPositionCoord;", "attribute vec2 aScale;",
"attribute float aRotation;", "attribute vec2 aTextureCoord;", "attribute float
aColor;", "attribute float aTextureIndex;", "uniform vec2 projectionVector;",
"uniform vec2 offsetVector;", "uniform mat3 uMatrix;", "varying vec2
vTextureCoord;", "varying float vColor;", "varying float vTextureIndex;", "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;", "
vTextureIndex = aTextureIndex;", " vColor = aColor;", "}"],
this.textureCount = 0,
this.init()
}
,
o.PixiFastShader.prototype.constructor = o.PixiFastShader,
o.PixiFastShader.prototype.init = function() {
var t = this.gl
, e = o.compileProgram(t, this.vertexSrc, this.fragmentSrc);
if (t.useProgram(e),
this.uSampler = o._enableMultiTextureToggle ? t.getUniformLocation(e,
"uSamplerArray[0]") : t.getUniformLocation(e, "uSampler"),
o._enableMultiTextureToggle) {
var i = []
, n = t.createTexture();
t.activeTexture(t.TEXTURE0),
t.bindTexture(t.TEXTURE_2D, n),
t.texImage2D(t.TEXTURE_2D, 0, t.RGB, 1, 1, 0, t.RGB,
t.UNSIGNED_BYTE, null);
for (var s = 0; s < this.MAX_TEXTURES; ++s)
t.activeTexture(t.TEXTURE0 + s),
t.bindTexture(t.TEXTURE_2D, n),
i.push(s);
t.activeTexture(t.TEXTURE0),
t.uniform1iv(this.uSampler, i)
}
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"),
this.aTextureIndex = t.getAttribLocation(e, "aTextureIndex"),
-1 === this.colorAttribute && (this.colorAttribute = 2),
this.attributes = [this.aVertexPosition, this.aPositionCoord,
this.aScale, this.aRotation, this.aTextureCoord, this.colorAttribute,
this.aTextureIndex],
this.program = e
}
,
o.PixiFastShader.prototype.destroy = function() {
this.gl.deleteProgram(this.program),
this.uniforms = null,
this.gl = null,
this.attributes = null
}
,
o.StripShader = function(t) {
if (this._UID = Phaser._UID++,
this.gl = t,
this.program = null,
o._enableMultiTextureToggle) {
var t = this.gl;
this.MAX_TEXTURES = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);
for (var e = "\tif (vTextureIndex == 0.0) gl_FragColor =
texture2D(uSamplerArray[0], vTextureCoord);\n", i = 1; i < this.MAX_TEXTURES; ++i)
e += "\telse if (vTextureIndex == " + i + ".0) gl_FragColor =
texture2D(uSamplerArray[" + i + "], vTextureCoord) ;\n";
this.fragmentSrc = ["//StripShader Fragment Shader.", "precision
mediump float;", "bool isnan( float val ) { return ( val < 0.0 || 0.0 < val || val
== 0.0 ) ? false : true; }", "varying vec2 vTextureCoord;", "varying float
vTextureIndex;", "uniform float alpha;", "uniform sampler2D uSamplerArray[" +
this.MAX_TEXTURES + "];", "const vec4 BLUE = vec4(1.0, 0.0, 1.0, 1.0);", "const
vec4 RED = vec4(1.0, 0.0, 0.0, 1.0);", "void main(void) {", e, " else
if(vTextureIndex >= " + this.MAX_TEXTURES + ".0) gl_FragColor = BLUE;", " else
if(isnan(vTextureIndex)) gl_FragColor = RED;", "}"]
} else
this.fragmentSrc = ["//StripShader Fragment Shader.", "precision
mediump float;", "varying vec2 vTextureCoord;", "varying float vTextureIndex;",
"uniform float alpha;", "uniform sampler2D uSampler;", "void main(void) {", "
gl_FragColor = texture2D(uSampler, vTextureCoord);", "}"];
this.vertexSrc = ["//StripShader Vertex Shader.", "attribute vec2
aVertexPosition;", "attribute vec2 aTextureCoord;", "attribute float
aTextureIndex;", "uniform mat3 translationMatrix;", "uniform vec2
projectionVector;", "uniform vec2 offsetVector;", "varying vec2 vTextureCoord;",
"varying float vTextureIndex;", "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;", " vTextureIndex = aTextureIndex;", "}"],
this.init()
}
,
o.StripShader.prototype.constructor = o.StripShader,
o.StripShader.prototype.init = function() {
var t = this.gl
, e = o.compileProgram(t, this.vertexSrc, this.fragmentSrc);
if (t.useProgram(e),
this.uSampler = o._enableMultiTextureToggle ? t.getUniformLocation(e,
"uSamplerArray[0]") : t.getUniformLocation(e, "uSampler"),
o._enableMultiTextureToggle) {
var i = []
, n = t.createTexture();
t.activeTexture(t.TEXTURE0),
t.bindTexture(t.TEXTURE_2D, n),
t.texImage2D(t.TEXTURE_2D, 0, t.RGB, 1, 1, 0, t.RGB,
t.UNSIGNED_BYTE, null);
for (var s = 0; s < this.MAX_TEXTURES; ++s)
t.activeTexture(t.TEXTURE0 + s),
t.bindTexture(t.TEXTURE_2D, n),
i.push(s);
t.activeTexture(t.TEXTURE0),
t.uniform1iv(this.uSampler, i)
}
this.projectionVector = t.getUniformLocation(e, "projectionVector"),
this.offsetVector = t.getUniformLocation(e, "offsetVector"),
this.colorAttribute = t.getAttribLocation(e, "aColor"),
this.aTextureIndex = t.getAttribLocation(e, "aTextureIndex"),
this.aVertexPosition = t.getAttribLocation(e, "aVertexPosition"),
this.aTextureCoord = t.getAttribLocation(e, "aTextureCoord"),
this.attributes = [this.aVertexPosition, this.aTextureCoord,
this.aTextureIndex],
this.translationMatrix = t.getUniformLocation(e, "translationMatrix"),
this.alpha = t.getUniformLocation(e, "alpha"),
this.program = e
}
,
o.StripShader.prototype.destroy = function() {
this.gl.deleteProgram(this.program),
this.uniforms = null,
this.gl = null,
this.attribute = null
}
,
o.PrimitiveShader = function(t) {
this._UID = Phaser._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()
}
,
o.PrimitiveShader.prototype.constructor = o.PrimitiveShader,
o.PrimitiveShader.prototype.init = function() {
var t = this.gl
, e = o.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
}
,
o.PrimitiveShader.prototype.destroy = function() {
this.gl.deleteProgram(this.program),
this.uniforms = null,
this.gl = null,
this.attributes = null
}
,
o.ComplexPrimitiveShader = function(t) {
this._UID = Phaser._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()
}
,
o.ComplexPrimitiveShader.prototype.constructor = o.ComplexPrimitiveShader,
o.ComplexPrimitiveShader.prototype.init = function() {
var t = this.gl
, e = o.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
}
,
o.ComplexPrimitiveShader.prototype.destroy = function() {
this.gl.deleteProgram(this.program),
this.uniforms = null,
this.gl = null,
this.attribute = null
}
,
o.glContexts = [],
o.instances = [],
o._enableMultiTextureToggle = !1,
o.WebGLRenderer = function(t) {
this.game = t,
o.defaultRenderer || (o.defaultRenderer = this),
this.extensions = {},
this.type = Phaser.WEBGL,
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 o.Point,
this.offset = new o.Point,
this.shaderManager = new o.WebGLShaderManager,
this.spriteBatch = new o.WebGLSpriteBatch(t),
this.maskManager = new o.WebGLMaskManager,
this.filterManager = new o.WebGLFilterManager,
this.stencilManager = new o.WebGLStencilManager,
this.blendModeManager = new o.WebGLBlendModeManager,
this.renderSession = {},
this.currentBatchedTextures = [],
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,
this.renderSession.resolution = this.resolution,
this.initContext(),
this.mapBlendModes()
}
,
o.WebGLRenderer.prototype.constructor = o.WebGLRenderer,
o.WebGLRenderer.prototype.initContext = function() {
var t = this.view.getContext("webgl", this._contextOptions) ||
this.view.getContext("experimental-webgl", this._contextOptions);
if (this.gl = t,
!t)
throw new Error("This browser does not support webGL. Try using the
canvas renderer");
this.maxTextures = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),
this.glContextId = t.id = o.WebGLRenderer.glContextId++,
o.glContexts[this.glContextId] = t,
o.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),
this.extensions.compression = {},
etc1 = t.getExtension("WEBGL_compressed_texture_etc1") ||
t.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
pvrtc = t.getExtension("WEBGL_compressed_texture_pvrtc") ||
t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
s3tc = t.getExtension("WEBGL_compressed_texture_s3tc") ||
t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
etc1 && (this.extensions.compression.ETC1 = etc1),
pvrtc && (this.extensions.compression.PVRTC = pvrtc),
s3tc && (this.extensions.compression.S3TC = s3tc)
}
,
o.WebGLRenderer.prototype.setTexturePriority = function(t) {
if (!o._enableMultiTextureToggle)
return void console.warn("setTexturePriority error: Multi Texture
support hasn't been enabled in the Phaser Game Config.");
for (var e = function(t) {
return --t,
t |= t >> 1,
t |= t >> 2,
t |= t >> 4,
t |= t >> 8,
t |= t >> 16,
++t
}, i = this.gl, n = i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS), s =
i.getParameter(i.MAX_TEXTURE_SIZE), r = this.game.cache._cache.image, a = null, h =
0; h < this.currentBatchedTextures.length; h++)
(a = t[c])in r && (r[a].base.textureIndex = 0);
var l = s - e(Math.max(this.width, this.height));
this.currentBatchedTextures.length = 0;
for (var c = 0; c < t.length; ++c)
if ((a = t[c])in r) {
var u = r[a].base;
l -= e(Math.max(u.width, u.height)),
u.textureIndex = l <= 0 ? 0 : 1 + c % (n - 1),
this.currentBatchedTextures.push(a)
}
return this.currentBatchedTextures
}
,
o.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)
}
}
,
o.WebGLRenderer.prototype.renderDisplayObject = function(t, e, i, n) {
this.renderSession.blendModeManager.setBlendMode(o.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, n),
this.spriteBatch.end()
}
,
o.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
}
,
o.WebGLRenderer.prototype.updateCompressedTexture = function(t) {
if (!t.hasLoaded)
return !1;
var e = this.gl
, i = t.source;
return t._glTextures[e.id] || (t._glTextures[e.id] =
e.createTexture()),
e.activeTexture(e.TEXTURE0 + t.textureIndex),
e.bindTexture(e.TEXTURE_2D, t._glTextures[e.id]),
e.compressedTexImage2D(e.TEXTURE_2D, 0, i.glExtensionFormat, i.width,
i.height, 0, i.textureData),
e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, t.scaleMode ===
o.scaleModes.LINEAR ? e.LINEAR : e.NEAREST),
t.mipmap && Phaser.Math.isPowerOfTwo(t.width, t.height) ?
(e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, t.scaleMode ===
o.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 === o.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,
!0
}
,
o.WebGLRenderer.prototype.updateTexture = function(t) {
if (!t.hasLoaded)
return !1;
if (t.source.compressionAlgorithm)
return this.updateCompressedTexture(t);
var e = this.gl;
return t._glTextures[e.id] || (t._glTextures[e.id] =
e.createTexture()),
e.activeTexture(e.TEXTURE0 + t.textureIndex),
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 ===
o.scaleModes.LINEAR ? e.LINEAR : e.NEAREST),
t.mipmap && Phaser.Math.isPowerOfTwo(t.width, t.height) ?
(e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, t.scaleMode ===
o.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 === o.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,
!0
}
,
o.WebGLRenderer.prototype.destroy = function() {
o.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,
Phaser.CanvasPool.remove(this),
o.instances[this.glContextId] = null,
o.WebGLRenderer.glContextId--
}
,
o.WebGLRenderer.prototype.mapBlendModes = function() {
var t = this.gl;
if (!o.blendModesWebGL) {
var e = []
, i = o.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],
o.blendModesWebGL = e
}
}
,
o.WebGLRenderer.prototype.getMaxTextureUnit = function() {
var t = this.gl;
return t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)
}
,
o.enableMultiTexture = function() {
o._enableMultiTextureToggle = !0
}
,
o.WebGLRenderer.glContextId = 0,
o.WebGLRenderer.textureArray = [],
o.WebGLBlendModeManager = function() {
this.currentBlendMode = 99999
}
,
o.WebGLBlendModeManager.prototype.constructor = o.WebGLBlendModeManager,
o.WebGLBlendModeManager.prototype.setContext = function(t) {
this.gl = t
}
,
o.WebGLBlendModeManager.prototype.setBlendMode = function(t) {
if (this.currentBlendMode === t)
return !1;
this.currentBlendMode = t;
var e = o.blendModesWebGL[this.currentBlendMode];
return e && this.gl.blendFunc(e[0], e[1]),
!0
}
,
o.WebGLBlendModeManager.prototype.destroy = function() {
this.gl = null
}
,
o.WebGLMaskManager = function() {}
,
o.WebGLMaskManager.prototype.constructor = o.WebGLMaskManager,
o.WebGLMaskManager.prototype.setContext = function(t) {
this.gl = t
}
,
o.WebGLMaskManager.prototype.pushMask = function(t, e) {
var i = e.gl;
t.dirty && o.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)
}
,
o.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)
}
,
o.WebGLMaskManager.prototype.destroy = function() {
this.gl = null
}
,
o.WebGLStencilManager = function() {
this.stencilStack = [],
this.reverse = !0,
this.count = 0
}
,
o.WebGLStencilManager.prototype.setContext = function(t) {
this.gl = t
}
,
o.WebGLStencilManager.prototype.pushStencil = function(t, e, i) {
var n = this.gl;
this.bindGraphics(t, e, i),
0 === this.stencilStack.length && (n.enable(n.STENCIL_TEST),
n.clear(n.STENCIL_BUFFER_BIT),
this.reverse = !0,
this.count = 0),
this.stencilStack.push(e);
var s = this.count;
n.colorMask(!1, !1, !1, !1),
n.stencilFunc(n.ALWAYS, 0, 255),
n.stencilOp(n.KEEP, n.KEEP, n.INVERT),
1 === e.mode ? (n.drawElements(n.TRIANGLE_FAN, e.indices.length - 4,
n.UNSIGNED_SHORT, 0),
this.reverse ? (n.stencilFunc(n.EQUAL, 255 - s, 255),
n.stencilOp(n.KEEP, n.KEEP, n.DECR)) : (n.stencilFunc(n.EQUAL, s, 255),
n.stencilOp(n.KEEP, n.KEEP, n.INCR)),
n.drawElements(n.TRIANGLE_FAN, 4, n.UNSIGNED_SHORT, 2 *
(e.indices.length - 4)),
this.reverse ? n.stencilFunc(n.EQUAL, 255 - (s + 1), 255) :
n.stencilFunc(n.EQUAL, s + 1, 255),
this.reverse = !this.reverse) : (this.reverse ? (n.stencilFunc(n.EQUAL,
s, 255),
n.stencilOp(n.KEEP, n.KEEP, n.INCR)) : (n.stencilFunc(n.EQUAL, 255 - s,
255),
n.stencilOp(n.KEEP, n.KEEP, n.DECR)),
n.drawElements(n.TRIANGLE_STRIP, e.indices.length, n.UNSIGNED_SHORT,
0),
this.reverse ? n.stencilFunc(n.EQUAL, s + 1, 255) :
n.stencilFunc(n.EQUAL, 255 - (s + 1), 255)),
n.colorMask(!0, !0, !0, !0),
n.stencilOp(n.KEEP, n.KEEP, n.KEEP),
this.count++
}
,
o.WebGLStencilManager.prototype.bindGraphics = function(t, e, i) {
this._currentGraphics = t;
var n, s = this.gl, o = i.projection, r = i.offset;
1 === e.mode ? (n = i.shaderManager.complexPrimitiveShader,
i.shaderManager.setShader(n),
s.uniform1f(n.flipY, i.flipY),
s.uniformMatrix3fv(n.translationMatrix, !1, t.worldTransform.toArray(!
0)),
s.uniform2f(n.projectionVector, o.x, -o.y),
s.uniform2f(n.offsetVector, -r.x, -r.y),
s.uniform3fv(n.tintColor, Phaser.Color.hexToRGBArray(t.tint)),
s.uniform3fv(n.color, e.color),
s.uniform1f(n.alpha, t.worldAlpha * e.alpha),
s.bindBuffer(s.ARRAY_BUFFER, e.buffer),
s.vertexAttribPointer(n.aVertexPosition, 2, s.FLOAT, !1, 8, 0),
s.bindBuffer(s.ELEMENT_ARRAY_BUFFER, e.indexBuffer)) : (n =
i.shaderManager.primitiveShader,
i.shaderManager.setShader(n),
s.uniformMatrix3fv(n.translationMatrix, !1, t.worldTransform.toArray(!
0)),
s.uniform1f(n.flipY, i.flipY),
s.uniform2f(n.projectionVector, o.x, -o.y),
s.uniform2f(n.offsetVector, -r.x, -r.y),
s.uniform3fv(n.tintColor, Phaser.Color.hexToRGBArray(t.tint)),
s.uniform1f(n.alpha, t.worldAlpha),
s.bindBuffer(s.ARRAY_BUFFER, e.buffer),
s.vertexAttribPointer(n.aVertexPosition, 2, s.FLOAT, !1, 24, 0),
s.vertexAttribPointer(n.colorAttribute, 4, s.FLOAT, !1, 24, 8),
s.bindBuffer(s.ELEMENT_ARRAY_BUFFER, e.indexBuffer))
}
,
o.WebGLStencilManager.prototype.popStencil = function(t, e, i) {
var n = this.gl;
if (this.stencilStack.pop(),
this.count--,
0 === this.stencilStack.length)
n.disable(n.STENCIL_TEST);
else {
var s = this.count;
this.bindGraphics(t, e, i),
n.colorMask(!1, !1, !1, !1),
1 === e.mode ? (this.reverse = !this.reverse,
this.reverse ? (n.stencilFunc(n.EQUAL, 255 - (s + 1), 255),
n.stencilOp(n.KEEP, n.KEEP, n.INCR)) : (n.stencilFunc(n.EQUAL, s +
1, 255),
n.stencilOp(n.KEEP, n.KEEP, n.DECR)),
n.drawElements(n.TRIANGLE_FAN, 4, n.UNSIGNED_SHORT, 2 *
(e.indices.length - 4)),
n.stencilFunc(n.ALWAYS, 0, 255),
n.stencilOp(n.KEEP, n.KEEP, n.INVERT),
n.drawElements(n.TRIANGLE_FAN, e.indices.length - 4,
n.UNSIGNED_SHORT, 0),
this.reverse ? n.stencilFunc(n.EQUAL, s, 255) :
n.stencilFunc(n.EQUAL, 255 - s, 255)) : (this.reverse ? (n.stencilFunc(n.EQUAL, s +
1, 255),
n.stencilOp(n.KEEP, n.KEEP, n.DECR)) : (n.stencilFunc(n.EQUAL, 255
- (s + 1), 255),
n.stencilOp(n.KEEP, n.KEEP, n.INCR)),
n.drawElements(n.TRIANGLE_STRIP, e.indices.length,
n.UNSIGNED_SHORT, 0),
this.reverse ? n.stencilFunc(n.EQUAL, s, 255) :
n.stencilFunc(n.EQUAL, 255 - s, 255)),
n.colorMask(!0, !0, !0, !0),
n.stencilOp(n.KEEP, n.KEEP, n.KEEP)
}
}
,
o.WebGLStencilManager.prototype.destroy = function() {
this.stencilStack = null,
this.gl = null
}
,
o.WebGLShaderManager = function() {
this.maxAttibs = 10,
this.attribState = [],
this.tempAttribState = [];
for (var t = 0; t < this.maxAttibs; t++)
this.attribState[t] = !1;
this.stack = []
}
,
o.WebGLShaderManager.prototype.constructor = o.WebGLShaderManager,
o.WebGLShaderManager.prototype.setContext = function(t) {
this.gl = t,
this.primitiveShader = new o.PrimitiveShader(t),
this.complexPrimitiveShader = new o.ComplexPrimitiveShader(t),
this.defaultShader = new o.PixiShader(t),
this.fastShader = new o.PixiFastShader(t),
this.stripShader = new o.StripShader(t),
this.setShader(this.defaultShader)
}
,
o.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 n = 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] ? n.enableVertexAttribArray(e) :
n.disableVertexAttribArray(e))
}
,
o.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)
}
,
o.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
}
,
o.WebGLSpriteBatch = function(t) {
this.game = t,
this.vertSize = 5,
this.size = 2e3,
this.vertexSize = 24;
var e = this.vertexSize * this.size * 4
, i = 6 * this.size;
this.vertices = new ArrayBuffer(e),
this.positions = new Float32Array(this.vertices),
this.colors = new Uint32Array(this.vertices),
this.indices = new Uint16Array(i),
this.lastIndexCount = 0;
for (var n = 0, s = 0; n < i; n += 6,
s += 4)
this.indices[n + 0] = s + 0,
this.indices[n + 1] = s + 1,
this.indices[n + 2] = s + 2,
this.indices[n + 3] = s + 0,
this.indices[n + 4] = s + 2,
this.indices[n + 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 = null
}
,
o.WebGLSpriteBatch.prototype.setContext = function(t) {
if (this.MAX_TEXTURES = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),
this.gl = t,
o._enableMultiTextureToggle) {
for (var e = "\tif (vTextureIndex == 0.0) gl_FragColor =
texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n", i = 1; i <
this.MAX_TEXTURES; ++i)
e += "\telse if (vTextureIndex == " + i + ".0) gl_FragColor =
texture2D(uSamplerArray[" + i + "], vTextureCoord) * vColor;\n";
this.defaultShader = new Phaser.Filter(this.game,void 0,
["//WebGLSpriteBatch Fragment Shader.", "precision lowp float;", "varying vec2
vTextureCoord;", "varying vec4 vColor;", "varying float vTextureIndex;", "uniform
sampler2D uSamplerArray[" + this.MAX_TEXTURES + "];", "void main(void) {", e,
"\telse gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;", "}"])
} else
this.defaultShader = new Phaser.Filter(this.game,void 0,
["//WebGLSpriteBatch Fragment Shader.", "precision lowp float;", "varying vec2
vTextureCoord;", "varying vec4 vColor;", "varying float vTextureIndex;", "uniform
sampler2D uSampler;", "void main(void) {", " gl_FragColor = texture2D(uSampler,
vTextureCoord) * vColor;", "}"]);
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 n = new o.PixiShader(t);
n.fragmentSrc = this.defaultShader.fragmentSrc,
n.uniforms = {},
n.init(),
this.defaultShader.shaders[t.id] = n
}
,
o.WebGLSpriteBatch.prototype.begin = function(t) {
this.renderSession = t,
this.shader = this.renderSession.shaderManager.defaultShader,
this.start()
}
,
o.WebGLSpriteBatch.prototype.end = function() {
this.flush()
}
,
o.WebGLSpriteBatch.prototype.render = function(t, e) {
var i = t.texture
, n = i.baseTexture
, s = this.gl;
o.WebGLRenderer.textureArray[n.textureIndex] != n && (this.flush(),
s.activeTexture(s.TEXTURE0 + n.textureIndex),
s.bindTexture(s.TEXTURE_2D, n._glTextures[s.id]),
o.WebGLRenderer.textureArray[n.textureIndex] = n);
var r = t.worldTransform;
e && (r = e),
this.currentBatchSize >= this.size && (this.flush(),
this.currentBaseTexture = i.baseTexture);
var a = i._uvs;
if (a) {
var h, l, c, u, d = t.anchor.x, p = t.anchor.y;
if (i.trim) {
var f = i.trim;
l = f.x - d * f.width,
h = l + i.crop.width,
u = f.y - p * f.height,
c = u + i.crop.height
} else
h = i.frame.width * (1 - d),
l = i.frame.width * -d,
c = i.frame.height * (1 - p),
u = i.frame.height * -p;
var m = this.currentBatchSize * this.vertexSize
, g = (this.currentBatchSize,
i.baseTexture.resolution)
, y = i.baseTexture.textureIndex
, v = r.a / g
, b = r.b / g
, w = r.c / g
, x = r.d / g
, _ = r.tx
, P = r.ty
, T = (i.crop.width,
i.crop.height);
if (i.rotated) {
var C = r.a
, S = r.b
, A = r.c
, k = r.d
, E = l
, I = h;
_ = r.c * T + _,
P = r.d * T + P,
v = 6.123233995736766e-17 * C - A,
b = 6.123233995736766e-17 * S - k,
w = C + 6.123233995736766e-17 * A,
x = S + 6.123233995736766e-17 * k,
i._updateUvsInverted(),
h = c,
l = u,
c = I,
u = E
}
var M = this.colors
, O = this.positions
, B = t.tint
, R = (B >> 16) + (65280 & B) + ((255 & B) << 16) + (255 *
t.worldAlpha << 24);
this.renderSession.roundPixels ? (O[m++] = v * l + w * u + _ | 0,
O[m++] = x * u + b * l + P | 0,
O[m++] = a.x0,
O[m++] = a.y0,
M[m++] = R,
O[m++] = y,
O[m++] = v * h + w * u + _ | 0,
O[m++] = x * u + b * h + P | 0,
O[m++] = a.x1,
O[m++] = a.y1,
M[m++] = R,
O[m++] = y,
O[m++] = v * h + w * c + _ | 0,
O[m++] = x * c + b * h + P | 0,
O[m++] = a.x2,
O[m++] = a.y2,
M[m++] = R,
O[m++] = y,
O[m++] = v * l + w * c + _ | 0,
O[m++] = x * c + b * l + P | 0,
O[m++] = a.x3,
O[m++] = a.y3,
M[m++] = R,
O[m++] = y) : (O[m++] = v * l + w * u + _,
O[m++] = x * u + b * l + P,
O[m++] = a.x0,
O[m++] = a.y0,
M[m++] = R,
O[m++] = y,
O[m++] = v * h + w * u + _,
O[m++] = x * u + b * h + P,
O[m++] = a.x1,
O[m++] = a.y1,
M[m++] = R,
O[m++] = y,
O[m++] = v * h + w * c + _,
O[m++] = x * c + b * h + P,
O[m++] = a.x2,
O[m++] = a.y2,
M[m++] = R,
O[m++] = y,
O[m++] = v * l + w * c + _,
O[m++] = x * c + b * l + P,
O[m++] = a.x3,
O[m++] = a.y3,
M[m++] = R,
O[m++] = y),
this.sprites[this.currentBatchSize++] = t
}
}
,
o.WebGLSpriteBatch.prototype.renderTilingSprite = function(t) {
var e = t.tilingTexture
, i = e.baseTexture
, n = this.gl
, s = t.texture.baseTexture.textureIndex;
o.WebGLRenderer.textureArray[s] != i && (this.flush(),
n.activeTexture(n.TEXTURE0 + s),
n.bindTexture(n.TEXTURE_2D, i._glTextures[n.id]),
o.WebGLRenderer.textureArray[s] = i),
this.currentBatchSize >= this.size && (this.flush(),
this.currentBaseTexture = e.baseTexture),
t._uvs || (t._uvs = new o.TextureUvs);
var r = t._uvs
, a = e.baseTexture.width
, h = e.baseTexture.height;
t.tilePosition.x %= a * t.tileScaleOffset.x,
t.tilePosition.y %= h * t.tileScaleOffset.y;
var l = t.tilePosition.x / (a * t.tileScaleOffset.x)
, c = t.tilePosition.y / (h * t.tileScaleOffset.y)
, u = t.width / a / (t.tileScale.x * t.tileScaleOffset.x)
, d = t.height / h / (t.tileScale.y * t.tileScaleOffset.y);
r.x0 = 0 - l,
r.y0 = 0 - c,
r.x1 = 1 * u - l,
r.y1 = 0 - c,
r.x2 = 1 * u - l,
r.y2 = 1 * d - c,
r.x3 = 0 - l,
r.y3 = 1 * d - c;
var p = t.tint
, f = (p >> 16) + (65280 & p) + ((255 & p) << 16) + (255 *
t.worldAlpha << 24)
, m = this.positions
, g = this.colors
, y = t.width
, v = t.height
, b = t.anchor.x
, w = t.anchor.y
, x = y * (1 - b)
, _ = y * -b
, P = v * (1 - w)
, T = v * -w
, C = this.currentBatchSize * this.vertexSize
, S = e.baseTexture.resolution
, A = t.worldTransform
, k = A.a / S
, E = A.b / S
, I = A.c / S
, M = A.d / S
, O = A.tx
, B = A.ty;
m[C++] = k * _ + I * T + O,
m[C++] = M * T + E * _ + B,
m[C++] = r.x0,
m[C++] = r.y0,
g[C++] = f,
m[C++] = s,
m[C++] = k * x + I * T + O,
m[C++] = M * T + E * x + B,
m[C++] = r.x1,
m[C++] = r.y1,
g[C++] = f,
m[C++] = s,
m[C++] = k * x + I * P + O,
m[C++] = M * P + E * x + B,
m[C++] = r.x2,
m[C++] = r.y2,
g[C++] = f,
m[C++] = s,
m[C++] = k * _ + I * P + O,
m[C++] = M * P + E * _ + B,
m[C++] = r.x3,
m[C++] = r.y3,
g[C++] = f,
m[C++] = s,
this.sprites[this.currentBatchSize++] = t
}
,
o.WebGLSpriteBatch.prototype.flush = function() {
if (0 !== this.currentBatchSize) {
var t, e = this.gl;
if (this.dirty) {
this.dirty = !1,
t = this.defaultShader.shaders[e.id],
e.activeTexture(e.TEXTURE0),
e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
var i = this.vertexSize;
e.vertexAttribPointer(t.aVertexPosition, 2, e.FLOAT, !1, i, 0),
e.vertexAttribPointer(t.aTextureCoord, 2, e.FLOAT, !1, i, 8),
e.vertexAttribPointer(t.colorAttribute, 4, e.UNSIGNED_BYTE, !0,
i, 16),
e.vertexAttribPointer(t.aTextureIndex, 1, e.FLOAT, !1, i, 20)
}
if (this.currentBatchSize > .5 * this.size)
e.bufferSubData(e.ARRAY_BUFFER, 0, this.vertices);
else {
e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer);
var n = this.positions.subarray(0, this.currentBatchSize *
this.vertexSize);
e.bufferSubData(e.ARRAY_BUFFER, 0, n)
}
for (var s, r, a, h, l = 0, c = 0, u = null, d =
this.renderSession.blendModeManager.currentBlendMode, p = null, f = !1, m = !1, g =
0, y = this.currentBatchSize; g < y; g++) {
h = this.sprites[g],
s = h.tilingTexture ? h.tilingTexture.baseTexture :
h.texture.baseTexture,
r = h.blendMode,
a = h.shader || this.defaultShader,
f = d !== r,
m = p !== a;
var v = s.skipRender;
if (v && h.children.length > 0 && (v = !1),
(f || m) && (this.renderBatch(u, l, c),
c = g,
l = 0,
u = s,
f && (d = r,
this.renderSession.blendModeManager.setBlendMode(d)),
m)) {
p = a,
t = p.shaders[e.id],
t || (t = new o.PixiShader(e),
t.fragmentSrc = p.fragmentSrc,
t.uniforms = p.uniforms,
t.init(),
p.shaders[e.id] = t),
this.renderSession.shaderManager.setShader(t),
t.dirty && t.syncUniforms();
var b = this.renderSession.projection;
e.uniform2f(t.projectionVector, b.x, b.y);
var w = this.renderSession.offset;
e.uniform2f(t.offsetVector, w.x, w.y)
}
l++
}
this.renderBatch(u, l, c),
this.currentBatchSize = 0
}
}
,
o.WebGLSpriteBatch.prototype.renderBatch = function(t, e, i) {
if (0 !== e) {
var n = this.gl;
t._dirty[n.id] && !this.renderSession.renderer.updateTexture(t) ||
(n.drawElements(n.TRIANGLES, 6 * e, n.UNSIGNED_SHORT, 6 * i * 2),
this.renderSession.drawCount++)
}
}
,
o.WebGLSpriteBatch.prototype.stop = function() {
this.flush(),
this.dirty = !0
}
,
o.WebGLSpriteBatch.prototype.start = function() {
this.dirty = !0
}
,
o.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
}
,
o.WebGLFastSpriteBatch = function(t) {
this.vertSize = 11,
this.maxSize = 6e3,
this.size = this.maxSize;
var e = 4 * this.size * this.vertSize
, i = 6 * this.maxSize;
this.vertices = new Float32Array(e),
this.indices = new Uint16Array(i),
this.vertexBuffer = null,
this.indexBuffer = null,
this.lastIndexCount = 0;
for (var n = 0, s = 0; n < i; n += 6,
s += 4)
this.indices[n + 0] = s + 0,
this.indices[n + 1] = s + 1,
this.indices[n + 2] = s + 2,
this.indices[n + 3] = s + 0,
this.indices[n + 4] = s + 2,
this.indices[n + 5] = s + 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)
}
,
o.WebGLFastSpriteBatch.prototype.constructor = o.WebGLFastSpriteBatch,
o.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)
}
,
o.WebGLFastSpriteBatch.prototype.begin = function(t, e) {
this.renderSession = e,
this.shader = this.renderSession.shaderManager.fastShader,
this.matrix = t.worldTransform.toArray(!0),
this.start()
}
,
o.WebGLFastSpriteBatch.prototype.end = function() {
this.flush()
}
,
o.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 n = 0, s = e.length; n < s; n++)
this.renderSprite(e[n]);
this.flush()
}
}
,
o.WebGLFastSpriteBatch.prototype.renderSprite = function(t) {
var e = t.texture
, i = e.baseTexture
, n = this.gl
, s = t.texture.baseTexture.textureIndex;
if ((o.WebGLRenderer.textureArray[s] == i || !i._glTextures[n.id] ||
t.texture.baseTexture.skipRender || (this.flush(),
n.activeTexture(n.TEXTURE0 + s),
n.bindTexture(n.TEXTURE_2D, i._glTextures[n.id]),
o.WebGLRenderer.textureArray[s] = i,
t.texture._uvs)) && t.visible) {
var r, a, h, l, c, u, d = this.vertices;
if (r = t.texture._uvs,
t.texture.frame.width,
t.texture.frame.height,
t.texture.trim) {
var p = t.texture.trim;
h = p.x - t.anchor.x * p.width,
a = h + t.texture.crop.width,
c = p.y - t.anchor.y * p.height,
l = c + t.texture.crop.height
} else
a = t.texture.frame.width * (1 - t.anchor.x),
h = t.texture.frame.width * -t.anchor.x,
l = t.texture.frame.height * (1 - t.anchor.y),
c = t.texture.frame.height * -t.anchor.y;
u = 4 * this.currentBatchSize * this.vertSize,
d[u++] = h,
d[u++] = c,
d[u++] = t.position.x,
d[u++] = t.position.y,
d[u++] = t.scale.x,
d[u++] = t.scale.y,
d[u++] = t.rotation,
d[u++] = r.x0,
d[u++] = r.y1,
d[u++] = t.alpha,
d[u++] = s,
d[u++] = a,
d[u++] = c,
d[u++] = t.position.x,
d[u++] = t.position.y,
d[u++] = t.scale.x,
d[u++] = t.scale.y,
d[u++] = t.rotation,
d[u++] = r.x1,
d[u++] = r.y1,
d[u++] = t.alpha,
d[u++] = s,
d[u++] = a,
d[u++] = l,
d[u++] = t.position.x,
d[u++] = t.position.y,
d[u++] = t.scale.x,
d[u++] = t.scale.y,
d[u++] = t.rotation,
d[u++] = r.x2,
d[u++] = r.y2,
d[u++] = t.alpha,
d[u++] = s,
d[u++] = h,
d[u++] = l,
d[u++] = t.position.x,
d[u++] = t.position.y,
d[u++] = t.scale.x,
d[u++] = t.scale.y,
d[u++] = t.rotation,
d[u++] = r.x3,
d[u++] = r.y3,
d[u++] = t.alpha,
d[u++] = s,
this.currentBatchSize++,
this.currentBatchSize >= this.size && this.flush()
}
}
,
o.WebGLFastSpriteBatch.prototype.flush = function() {
if (0 !== this.currentBatchSize) {
var t = this.gl;
if (!this.currentBaseTexture._glTextures[t.id])
return void
this.renderSession.renderer.updateTexture(this.currentBaseTexture, t);
if (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++
}
}
,
o.WebGLFastSpriteBatch.prototype.stop = function() {
this.flush()
}
,
o.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),
t.vertexAttribPointer(this.shader.aTextureIndex, 1, t.FLOAT, !1, i, 40)
}
,
o.WebGLFilterManager = function() {
this.filterStack = [],
this.offsetX = 0,
this.offsetY = 0
}
,
o.WebGLFilterManager.prototype.constructor = o.WebGLFilterManager,
o.WebGLFilterManager.prototype.setContext = function(t) {
this.gl = t,
this.texturePool = [],
this.initShaderBuffers()
}
,
o.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
}
,
o.WebGLFilterManager.prototype.pushFilter = function(t) {
var e = this.gl
, i = this.renderSession.projection
, n = this.renderSession.offset;
t._filterArea = t.target.filterArea || t.target.getBounds(),
t._previous_stencil_mgr = this.renderSession.stencilManager,
this.renderSession.stencilManager = new o.WebGLStencilManager,
this.renderSession.stencilManager.setContext(e),
e.disable(e.STENCIL_TEST),
this.filterStack.push(t);
var s = t.filterPasses[0];
this.offsetX += t._filterArea.x,
this.offsetY += t._filterArea.y;
var r = this.texturePool.pop();
r ? r.resize(this.width * this.renderSession.resolution, this.height *
this.renderSession.resolution) : r = new o.FilterTexture(this.gl,this.width *
this.renderSession.resolution,this.height * this.renderSession.resolution),
e.bindTexture(e.TEXTURE_2D, r.texture);
var a = t._filterArea
, h = s.padding;
a.x -= h,
a.y -= h,
a.width += 2 * h,
a.height += 2 * h,
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, r.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,
n.x = -a.x,
n.y = -a.y,
e.colorMask(!0, !0, !0, !0),
e.clearColor(0, 0, 0, 0),
e.clear(e.COLOR_BUFFER_BIT),
t._glFilterTexture = r
}
,
o.WebGLFilterManager.prototype.popFilter = function() {
var t = this.gl
, e = this.filterStack.pop()
, i = e._filterArea
, n = e._glFilterTexture
, s = this.renderSession.projection
, r = this.renderSession.offset;
if (e.filterPasses.length > 1) {
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 = n
, h = this.texturePool.pop();
h || (h = new o.FilterTexture(this.gl,this.width *
this.renderSession.resolution,this.height * this.renderSession.resolution)),
h.resize(this.width * this.renderSession.resolution, this.height *
this.renderSession.resolution),
t.bindFramebuffer(t.FRAMEBUFFER, h.frameBuffer),
t.clear(t.COLOR_BUFFER_BIT),
t.disable(t.BLEND);
for (var l = 0; l < e.filterPasses.length - 1; l++) {
var c = e.filterPasses[l];
t.bindFramebuffer(t.FRAMEBUFFER, h.frameBuffer),
t.activeTexture(t.TEXTURE0),
t.bindTexture(t.TEXTURE_2D, a.texture),
this.applyFilterPass(c, i, i.width, i.height);
var u = a;
a = h,
h = u
}
t.enable(t.BLEND),
n = a,
this.texturePool.push(h)
}
var d = e.filterPasses[e.filterPasses.length - 1];
this.offsetX -= i.x,
this.offsetY -= i.y;
var p = this.width
, f = this.height
, m = 0
, g = 0
, y = this.buffer;
if (0 === this.filterStack.length)
t.colorMask(!0, !0, !0, !0);
else {
var v = this.filterStack[this.filterStack.length - 1];
i = v._filterArea,
p = i.width,
f = i.height,
m = i.x,
g = i.y,
y = v._glFilterTexture.frameBuffer
}
s.x = p / 2,
s.y = -f / 2,
r.x = m,
r.y = g,
i = e._filterArea;
var b = i.x - m
, w = i.y - g;
t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer),
this.vertexArray[0] = b,
this.vertexArray[1] = w + i.height,
this.vertexArray[2] = b + i.width,
this.vertexArray[3] = w + i.height,
this.vertexArray[4] = b,
this.vertexArray[5] = w,
this.vertexArray[6] = b + i.width,
this.vertexArray[7] = w,
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, p * this.renderSession.resolution, f *
this.renderSession.resolution),
t.bindFramebuffer(t.FRAMEBUFFER, y),
t.activeTexture(t.TEXTURE0),
t.bindTexture(t.TEXTURE_2D, n.texture),
this.renderSession.stencilManager &&
this.renderSession.stencilManager.destroy(),
this.renderSession.stencilManager = e._previous_stencil_mgr,
e._previous_stencil_mgr = null,
this.renderSession.stencilManager.count > 0 ?
t.enable(t.STENCIL_TEST) : t.disable(t.STENCIL_TEST),
this.applyFilterPass(d, i, p, f),
this.texturePool.push(n),
e._glFilterTexture = null
}
,
o.WebGLFilterManager.prototype.applyFilterPass = function(t, e, i, n) {
var s = this.gl
, r = t.shaders[s.id];
r || (r = new o.PixiShader(s),
r.fragmentSrc = t.fragmentSrc,
r.uniforms = t.uniforms,
r.init(!0),
t.shaders[s.id] = r),
this.renderSession.shaderManager.setShader(r),
s.uniform2f(r.projectionVector, i / 2, -n / 2),
s.uniform2f(r.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]),
r.syncUniforms(),
s.bindBuffer(s.ARRAY_BUFFER, this.vertexBuffer),
s.vertexAttribPointer(r.aVertexPosition, 2, s.FLOAT, !1, 0, 0),
s.bindBuffer(s.ARRAY_BUFFER, this.uvBuffer),
s.vertexAttribPointer(r.aTextureCoord, 2, s.FLOAT, !1, 0, 0),
s.bindBuffer(s.ARRAY_BUFFER, this.colorBuffer),
s.vertexAttribPointer(r.colorAttribute, 2, s.FLOAT, !1, 0, 0),
s.bindBuffer(s.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
s.drawElements(s.TRIANGLES, 6, s.UNSIGNED_SHORT, 0),
this.renderSession.drawCount++
}
,
o.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 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 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 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)
}
,
o.WebGLFilterManager.prototype.destroy = function() {
var t = this.gl;
this.filterStack = null,
this.offsetX = 0,
this.offsetY = 0;
for (var e = 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)
}
;
var r = {
36054: "Incomplete attachment",
36055: "Missing attachment",
36057: "Incomplete dimensions",
36061: "Framebuffer unsupported"
};
return o.FilterTexture = function(t, e, i, s, r) {
r = "number" == typeof r ? r : 0,
this.gl = t,
this.frameBuffer = n(t, e, i, s || o.scaleModes.DEFAULT, r),
this.texture = this.frameBuffer.targetTexture,
this.width = e,
this.height = i,
this.renderBuffer = this.frameBuffer.renderBuffer
}
,
o.FilterTexture.prototype.constructor = o.FilterTexture,
o.FilterTexture.prototype.clear = function() {
var t = this.gl;
t.clearColor(0, 0, 0, 0),
t.clear(t.COLOR_BUFFER_BIT)
}
,
o.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)
}
}
,
o.FilterTexture.prototype.destroy = function() {
var t = this.gl;
t.deleteFramebuffer(this.frameBuffer),
t.deleteTexture(this.texture),
this.frameBuffer = null,
this.texture = null
}
,
o.CanvasBuffer = function(t, e) {
this.width = t,
this.height = e,
this.canvas = Phaser.CanvasPool.create(this, this.width, this.height),
this.context = this.canvas.getContext("2d"),
this.canvas.width = t,
this.canvas.height = e
}
,
o.CanvasBuffer.prototype.constructor = o.CanvasBuffer,
o.CanvasBuffer.prototype.clear = function() {
this.context.setTransform(1, 0, 0, 1, 0, 0),
this.context.clearRect(0, 0, this.width, this.height)
}
,
o.CanvasBuffer.prototype.resize = function(t, e) {
this.width = this.canvas.width = t,
this.height = this.canvas.height = e
}
,
o.CanvasBuffer.prototype.destroy = function() {
Phaser.CanvasPool.remove(this)
}
,
o.CanvasMaskManager = function() {}
,
o.CanvasMaskManager.prototype.constructor = o.CanvasMaskManager,
o.CanvasMaskManager.prototype.pushMask = function(t, e) {
var i = e.context;
i.save();
var n = t.alpha
, s = t.worldTransform
, r = e.resolution;
i.setTransform(s.a * r, s.b * r, s.c * r, s.d * r, s.tx * r, s.ty * r),
o.CanvasGraphics.renderGraphicsMask(t, i),
i.clip(),
t.worldAlpha = n
}
,
o.CanvasMaskManager.prototype.popMask = function(t) {
t.context.restore()
}
,
o.CanvasTinter = function() {}
,
o.CanvasTinter.getTintedTexture = function(t, e) {
var i = t.tintedTexture || Phaser.CanvasPool.create(this);
return o.CanvasTinter.tintMethod(t.texture, e, i),
i
}
,
o.CanvasTinter.tintWithMultiply = function(t, e, i) {
var n = i.getContext("2d")
, s = t.crop
, o = s.width
, r = s.height;
t.rotated && (o = r,
r = s.width),
i.width === o && i.height === r || (i.width = o,
i.height = r),
n.clearRect(0, 0, o, r),
n.fillStyle = "#" + ("00000" + (0 | e).toString(16)).substr(-6),
n.fillRect(0, 0, o, r),
n.globalCompositeOperation = "multiply",
n.drawImage(t.baseTexture.source, s.x, s.y, o, r, 0, 0, o, r),
n.globalCompositeOperation = "destination-atop",
n.drawImage(t.baseTexture.source, s.x, s.y, o, r, 0, 0, o, r)
}
,
o.CanvasTinter.tintWithPerPixel = function(t, e, i) {
var n = i.getContext("2d")
, s = t.crop
, r = s.width
, a = s.height;
t.rotated && (r = a,
a = s.width),
i.width === r && i.height === a || (i.width = r,
i.height = a),
n.globalCompositeOperation = "copy",
n.drawImage(t.baseTexture.source, s.x, s.y, r, a, 0, 0, r, a);
for (var h = Phaser.Color.hexToRGBArray(e), l = h[0], c = h[1], u =
h[2], d = n.getImageData(0, 0, r, a), p = d.data, f = 0; f < p.length; f += 4)
if (p[f + 0] *= l,
p[f + 1] *= c,
p[f + 2] *= u,
!o.CanvasTinter.canHandleAlpha) {
var m = p[f + 3];
p[f + 0] /= 255 / m,
p[f + 1] /= 255 / m,
p[f + 2] /= 255 / m
}
n.putImageData(d, 0, 0)
}
,
o.CanvasRenderer = function(t) {
this.game = t,
o.defaultRenderer || (o.defaultRenderer = this),
this.type = Phaser.CANVAS,
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 o.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)
}
,
o.CanvasRenderer.prototype.constructor = o.CanvasRenderer,
o.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)
}
,
o.CanvasRenderer.prototype.setTexturePriority = function(t) {}
,
o.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
}
,
o.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 ===
o.scaleModes.LINEAR)
}
,
o.CanvasRenderer.prototype.renderDisplayObject = function(t, e, i) {
this.renderSession.context = e || this.context,
this.renderSession.resolution = this.resolution,
t._renderCanvas(this.renderSession, i)
}
,
o.CanvasRenderer.prototype.mapBlendModes = function() {
if (!o.blendModesCanvas) {
var t = []
, e = o.blendModes
, i = this.game.device.canUseMultiply;
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",
o.blendModesCanvas = t
}
}
,
o.BaseTexture = function(t, e, i) {
this.resolution = i || 1,
this.width = 100,
this.height = 100,
this.scaleMode = e || o.scaleModes.DEFAULT,
this.hasLoaded = !1,
this.source = t,
this.premultipliedAlpha = !0,
this._glTextures = [],
this.mipmap = !1,
this.textureIndex = 0,
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)
}
,
o.BaseTexture.prototype.constructor = o.BaseTexture,
o.BaseTexture.prototype.forceLoaded = function(t, e) {
this.hasLoaded = !0,
this.width = t,
this.height = e,
this.dirty()
}
,
o.BaseTexture.prototype.destroy = function() {
this.source && Phaser.CanvasPool.removeByCanvas(this.source),
this.source = null,
this.unloadFromGPU()
}
,
o.BaseTexture.prototype.updateSourceImage = function(t) {
console.warn("PIXI.BaseTexture.updateSourceImage is deprecated. Use
Phaser.Sprite.loadTexture instead.")
}
,
o.BaseTexture.prototype.dirty = function() {
for (var t = 0; t < this._glTextures.length; t++)
this._dirty[t] = !0
}
,
o.BaseTexture.prototype.unloadFromGPU = function() {
this.dirty();
for (var t = this._glTextures.length - 1; t >= 0; t--) {
var e = this._glTextures[t]
, i = o.glContexts[t];
i && e && i.deleteTexture(e)
}
this._glTextures.length = 0,
this.dirty()
}
,
o.BaseTexture.fromCanvas = function(t, e, i) {
return 0 === t.width && (t.width = 1),
0 === t.height && (t.height = 1),
i = i || 1,
new o.BaseTexture(t,e,i)
}
,
o.TextureSilentFail = !1,
o.Texture = function(t, e, i, n) {
this.noFrame = !1,
e || (this.noFrame = !0,
e = new o.Rectangle(0,0,1,1)),
t instanceof o.Texture && (t = t.baseTexture),
this.baseTexture = t,
this.frame = e,
this.trim = n,
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 o.Rectangle(0,0,1,1),
this.rotated = !1,
t.hasLoaded && (this.noFrame && (e = new
o.Rectangle(0,0,t.width,t.height)),
this.setFrame(e))
}
,
o.Texture.prototype.constructor = o.Texture,
o.Texture.prototype.onBaseTextureLoaded = function() {
var t = this.baseTexture;
this.noFrame && (this.frame = new o.Rectangle(0,0,t.width,t.height)),
this.setFrame(this.frame)
}
,
o.Texture.prototype.destroy = function(t) {
t && this.baseTexture.destroy(),
this.valid = !1
}
,
o.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)) {
if (!o.TextureSilentFail)
throw new Error("Texture Error: frame does not fit inside the
base Texture dimensions " + this);
return void (this.valid = !1)
}
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()
}
,
o.Texture.prototype._updateUvs = function() {
this._uvs || (this._uvs = new o.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
}
,
o.Texture.prototype._updateUvsInverted = function() {
this._uvs || (this._uvs = new o.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.height) / e,
this._uvs.y1 = t.y / i,
this._uvs.x2 = (t.x + t.height) / e,
this._uvs.y2 = (t.y + t.width) / i,
this._uvs.x3 = t.x / e,
this._uvs.y3 = (t.y + t.width) / i
}
,
o.Texture.fromCanvas = function(t, e) {
var i = o.BaseTexture.fromCanvas(t, e);
return new o.Texture(i)
}
,
o.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
}
,
void 0 !== e ? (void 0 !== t && t.exports && (e = t.exports = o),
e.PIXI = o) : "undefined" != typeof define && define.amd ? define("PIXI",
function() {
return s.PIXI = o
}()) : s.PIXI = o,
o
}
).call(this)
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(19)
, s = function() {
function t(t) {
var e = this;
this.state = t,
this.window = document.getElementById("respawn-window"),
this.button = document.getElementById("respawn-button"),
this.ad = document.getElementById("respawn-ad"),
this.button.onclick = function() {
e.requestRespawn()
}
}
return t.prototype.requestRespawn = function() {
if (this.seconds < 1) {
this.stop();
var t = this;
n.default.play(function() {
t.state.request_respawn()
})
}
}
,
t.prototype.show = function() {
this.state.game.time.events.add(2 * Phaser.Timer.SECOND, function() {
this.reallyShow()
}, this),
this.state.game.time.events.add(3 * Phaser.Timer.SECOND, function() {
this.ad.style.display = "block"
}, this)
}
,
t.prototype.reallyShow = function() {
var t = this;
this.window.style.display = "block",
this.button.className = "inactive",
this.seconds = 5,
this.button.innerText = "Spawn in " + this.seconds + " seconds..",
this.interval = setInterval(function() {
t.update()
}, 1e3)
}
,
t.prototype.update = function() {
this.seconds -= 1,
this.seconds < 1 ? (clearInterval(this.interval),
this.button.innerText = "Spawn",
this.button.className = "active") : this.button.innerText = "Spawn in "
+ this.seconds + " seconds.."
}
,
t.prototype.stop = function() {
this.ad.style.display = "none",
this.window.style.display = "none"
}
,
t
}();
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(2)
, l = i(165)
, c = i(11)
, u = i(160)
, d = i(13)
, p = i(12)
, f = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,h.Atlases.AtlasesWhitewalker.getName(),new
Phaser.Point(.5,.55))),
s.addComponent(new p.default),
s.addComponent(new c.default(100)),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WhiteWalker = f;
var m = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesPig.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Pig = m;
var g = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesChicken.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Chicken = g;
var y = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesWolf.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new u.default),
s.addComponent(new c.default(50)),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Wolf = y;
var v = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesBear.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new u.default),
s.addComponent(new c.default(50)),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Bear = v;
var b = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesWhitebear.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new u.default),
s.addComponent(new c.default(50)),
s.addComponent(new d.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WhiteBear = b;
var w = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesCarpig.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.RideablePig = w;
var x = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesCarwolf.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.RideableWolf = x;
var _ = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesRideablebear.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.RideableBear = _
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(12)
, l = i(21)
, c = i(2)
, u = i(11)
, d = i(13)
, p = i(23)
, f = i(22)
, m = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,c.Atlases.AtlasesKnight.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new h.default),
s.addComponent(new l.default),
s.addComponent(new u.default(50)),
s.addComponent(new d.default),
s.addComponent(new p.default),
n === e.id && s.addComponent(new
f.default(50)).setPlayerName("Mercenary"),
s
}
return n(e, t),
e
}(s.Entity);
e.FollowerBot = m;
var g = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,c.Atlases.AtlasesGardener.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new h.default),
s.addComponent(new l.default),
s.addComponent(new u.default(50)),
s.addComponent(new d.default),
s.addComponent(new p.default),
n === e.id && s.addComponent(new
f.default(50)).setPlayerName("Peasant"),
s
}
return n(e, t),
e
}(s.Entity);
e.FarmerBot = g;
var y = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,c.Atlases.AtlasesGuard.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new h.default),
s.addComponent(new l.default),
s.addComponent(new u.default(50)),
s.addComponent(new d.default),
s.addComponent(new p.default),
n === e.id && s.addComponent(new f.default(50)).setPlayerName("Guard"),
s
}
return n(e, t),
e
}(s.Entity);
e.GuardBot = y;
var v = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,c.Atlases.AtlasesDarkguard.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new h.default),
s.addComponent(new l.default),
s.addComponent(new u.default(50)),
s.addComponent(new d.default),
s.addComponent(new p.default),
n === e.id && s.addComponent(new f.default(50)).setPlayerName("Guard"),
s
}
return n(e, t),
e
}(s.Entity);
e.DarkGuardBot = v;
var b = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,c.Atlases.AtlasesPickupbot.getName(),new
Phaser.Point(.485,.533))),
s.addComponent(new h.default),
s.addComponent(new l.default),
s.addComponent(new u.default(50)),
s.addComponent(new d.default),
s.addComponent(new p.default),
n === e.id && s.addComponent(new
f.default(50)).setPlayerName("Gardener"),
s
}
return n(e, t),
e
}(s.Entity);
e.GardenBot = b
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(2)
, l = i(20)
, c = i(164)
, u = i(161)
, d = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesWoodwall.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WoodBlock = d;
var p = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesDarkstonewall.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.DarkStoneBlock = p;
var f = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesStonewall.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.StoneBlock = f;
var m = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesDoor.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new c.default),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Door = m;
var g = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Atlases.AtlasesDarkdoor.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new c.default),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.DarkDoor = g;
var y = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesGarden.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Garden = y;
var v = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesWoodspikes.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WoodSpikes = v;
var b = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesPortal.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Portal = b;
var w = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesTower.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Tower = w;
var x = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesHeartstone.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Heartstone = x;
var _ = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,h.Images.ImagesFoodcrate.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.FoodCrate = _;
var P = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,h.Images.ImagesWoodcrate.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WoodCrate = P;
var T = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_1,h.Images.ImagesStonecrate.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.StoneCrate = T;
var C = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Images.ImagesMannequin.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.Mannequin = C;
var S = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default(!0,!1)),
s.addComponent(new
a.default(e.LAYER_MIDDLE_0,h.Images.ImagesSoccerball.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new u.default),
s
}
return n(e, t),
e
}(s.Entity);
e.SoccerBall = S
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(8)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.entity.on("senddamage", this.onSendDamage.bind(this)),
this.addAnimation("walk", Phaser.Animation.generateFrameNames("walk",
1, 8, ".png", 0), 15, !0),
this.addAnimation("punch", Phaser.Animation.generateFrameNames("hit",
1, 8, ".png", 0), 30, !1).onComplete.add(function() {
this.walk()
}
.bind(this)),
this.walk()
}
,
e.prototype.walk = function() {
this.play("walk")
}
,
e.prototype.onSendDamage = function(t) {
this.play("punch")
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
"punch" !== this.getCurrentName() && "pigpunch" !==
this.getCurrentName() && (this.cachedTransform.isMoving() ? this.walk() :
this.cachedSpriteComponent.sprite.animations.stop())
}
,
e.prototype.destroy = function() {}
,
e
}(s.default);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(8)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this)
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
this.cachedTransform.isMoving() ? this.cachedTransform.rotation += .
01 : this.cachedSpriteComponent.sprite.animations.stop()
}
,
e.prototype.destroy = function() {}
,
e
}(s.default);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = function() {
function t(t) {
this.container = document.createElement("div"),
this.container.innerText = t,
this.container.style.left = "0px",
this.container.style.top = "0px",
this.container.className = "speechbubble",
document.body.appendChild(this.container)
}
return t.prototype.setPosition = function(t, e) {
t = Math.round(t),
e = Math.round(e);
var i = this.container.offsetWidth
, n = this.container.offsetHeight;
t -= i / 2,
e -= n,
this.container.style.left = t + "px",
this.container.style.top = e + "px"
}
,
t.prototype.setText = function(t) {
this.container.innerText = t
}
,
t.prototype.destroy = function() {
this.container.parentElement.removeChild(this.container)
}
,
t
}()
, r = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.chatBubble = null,
i.chatBubbleTimer = null,
i.offset = e,
i
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.cachedTransform = this.entity.components.transform,
this.cachedSprite = this.entity.components.sprite,
this.entity.on("chatmessage", this.onChatMessage.bind(this))
}
,
e.prototype.onChatMessage = function(t) {
this.chatBubble ?
(this.world.game.time.events.remove(this.chatBubbleTimer),
this.chatBubble.setText(t)) : this.chatBubble = new o(t),
this.align(),
this.chatBubbleTimer = this.world.game.time.events.add(7 *
Phaser.Timer.SECOND, function() {
this.chatBubble && (this.chatBubble.destroy(),
this.chatBubble = null)
}, this)
}
,
e.prototype.align = function() {
if (this.chatBubble) {
var t = this.cachedTransform.position.y + this.offset;
if (this.cachedSprite && (t -= this.cachedSprite.sprite.height /
2),
this.world.game.scale.scaleMode === Phaser.ScaleManager.USER_SCALE)
{
var e = this.cachedTransform.position.x -
this.world.game.camera.x;
e = e / this.world.game.scale.scaleFactor.x -
this.world.game.screenOffsetWidth,
t -= this.world.game.camera.y,
t = t / this.world.game.scale.scaleFactor.y -
this.world.game.screenOffsetHeight,
this.chatBubble.setPosition(e, t)
} else
this.chatBubble.setPosition(this.cachedTransform.position.x -
this.world.game.camera.x, t - this.world.game.camera.y)
}
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
this.align()
}
,
e.prototype.destroy = function() {
this.chatBubble && (this.chatBubble.destroy(),
this.chatBubble = null)
}
,
e
}(s.Component);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(3)
, r = o.Protocol.MessageType
, a = function() {
function t(t, e) {
this.callback = t,
this.cancelcallback = e,
this.container = document.createElement("div"),
this.container.style.left = "0px",
this.container.style.top = "0px",
this.container.style.position = "absolute",
this.container.className = "speechbubble",
this.input = document.createElement("input"),
this.input.type = "text",
this.input.maxLength = 60,
this.container.appendChild(this.input);
var i = this;
this.input.addEventListener("keydown", function(t) {
13 === t.keyCode && (i.send(),
t.stopImmediatePropagation())
}),
this.input.addEventListener("keydown", function(t) {
27 === t.keyCode && i.cancel()
}),
document.body.appendChild(this.container),
this.input.focus()
}
return t.prototype.cancel = function() {
this.cancelcallback()
}
,
t.prototype.send = function() {
this.callback(this.input.value)
}
,
t.prototype.setposition = function(t, e) {
t = Math.round(t),
e = Math.round(e);
var i = this.container.offsetWidth
, n = this.container.offsetHeight;
t -= i / 2,
e -= n,
this.container.style.left = t + "px",
this.container.style.top = e + "px"
}
,
t.prototype.destroy = function() {
this.container.parentElement.removeChild(this.container)
}
,
t
}()
, h = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.id = "chatinput",
i.chatInput = null,
i.offset = e,
i
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.cachedTransform = this.entity.components.transform,
this.cachedSprite = this.entity.components.sprite,
this.returnKey =
this.world.game.input.keyboard.addKey(Phaser.Keyboard.ENTER),
this.returnKey.onDown.add(this.onReturnKey, this),
this.escapeKey =
this.world.game.input.keyboard.addKey(Phaser.Keyboard.ESC)
}
,
e.prototype.onReturnKey = function() {
this.chatInput || (this.chatInput = new
a(this.onChatRequest.bind(this),this.onChatCancel.bind(this)),
this.align(),
this.world.game.input.keyboard.enabled = !1)
}
,
e.prototype.onChatRequest = function(t) {
this.chatInput && (this.world.socket.sendMessage(r.PlayerChatRequest, {
message: t
}),
this.stopInput())
}
,
e.prototype.onChatCancel = function() {
this.stopInput()
}
,
e.prototype.stopInput = function() {
this.chatInput && (this.chatInput.destroy(),
this.world.game.input.keyboard.reset(!1),
this.world.game.input.keyboard.enabled = !0,
this.chatInput = null)
}
,
e.prototype.align = function() {
if (this.chatInput) {
var t = this.cachedTransform.position.y + this.offset;
if (this.cachedSprite && (t -= this.cachedSprite.sprite.height /
2),
this.world.game.scale.scaleMode === Phaser.ScaleManager.USER_SCALE)
{
var e = this.cachedTransform.position.x -
this.world.game.camera.x;
e = e / this.world.game.scale.scaleFactor.x -
this.world.game.screenOffsetWidth,
t -= this.world.game.camera.y,
t = t / this.world.game.scale.scaleFactor.y -
this.world.game.screenOffsetHeight,
this.chatInput.setposition(e, t)
} else
this.chatInput.setposition(this.cachedTransform.position.x -
this.world.game.camera.x, t - this.world.game.camera.y)
}
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
this.align(),
this.escapeKey.isDown && this.stopInput()
}
,
e.prototype.destroy = function() {
this.stopInput(),
this.returnKey.onDown.remove(this.onReturnKey, this)
}
,
e
}(s.Component);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(8)
, o = function(t) {
function e() {
var e = t.call(this) || this;
return e.isOpened = !1,
e
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.entity.on("networksync", this.onNetworkSync.bind(this))
}
,
e.prototype.set = function(t) {
this.cachedSpriteComponent.sprite.frameName = t
}
,
e.prototype.onNetworkSync = function(t) {
var e = !1;
t.hasOwnProperty("isOpened") && (this.isOpened = t.isOpened,
e = !0),
e && (this.isOpened ? this.set("door_open.png") :
this.set("door_close.png"))
}
,
e
}(s.default);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(8)
, o = function(t) {
function e() {
return t.call(this) || this
}
return n(e, t),
e.prototype.start = function() {
t.prototype.start.call(this),
this.addAnimation("walk", Phaser.Animation.generateFrameNames("walk",
1, 8, ".png", 0), 15, !0),
this.walk()
}
,
e.prototype.walk = function() {
this.play("walk")
}
,
e.prototype.update = function(e) {
t.prototype.update.call(this, e),
this.cachedTransform.isMoving() ? this.walk() :
this.cachedSpriteComponent.sprite.animations.stop()
}
,
e.prototype.destroy = function() {}
,
e
}(s.default);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(3)
, r = o.Protocol.HatType
, a = i(2)
, h = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.id = "hat",
i.hatId = -1,
i.currentTintColor = 16777215,
i.currentScale = 1,
i.layer = e,
i
}
return n(e, t),
e.prototype.start = function() {
this.cachedTransform = this.entity.components.transform,
this.entity.on("networksync", this.onNetworkSync.bind(this))
}
,
e.prototype.update = function(t) {
if (this.hatSprite &&
(this.hatSprite.position.copyFrom(this.cachedTransform.position),
this.hatSprite.rotation = this.cachedTransform.rotation,
this.hatId === r.ChessHat)) {
var e = this.hatSprite.getChildAt(0);
e && (e.rotation = e.rotation + .1,
e.rotation > 100 && (e.rotation = e.rotation % Math.PI))
}
}
,
e.prototype.onNetworkSync = function(t) {
t.hasOwnProperty("hatId") && this.hatId !== t.hatId &&
this.setHat(t.hatId)
}
,
e.prototype.setHat = function(t) {
if (this.hatId = t,
this.hatSprite && (this.hatSprite.destroy(),
this.hatSprite = null),
t > -1) {
if (this.hatSprite =
this.layer.create(this.cachedTransform.position.x, this.cachedTransform.position.y,
this.getHatSprite(t)),
this.hatSprite.anchor.set(.5, .5),
t === r.ChessHat) {
var e = this.world.game.make.image(0, 0,
a.Images.ImagesChesshatrot.getName());
e.anchor.set(.5, .5),
this.hatSprite.addChild(e),
e.position.set(0, 0)
}
this.setScale(this.currentScale),
this.setColor(this.currentTintColor)
}
}
,
e.prototype.getHatSprite = function(t) {
return t === r.WhiteBearHat ? a.Images.ImagesWhitebearhat.getName() : t
=== r.BrownBearHat ? a.Images.ImagesBrownbearhat.getName() : t === r.ChessHat ?
a.Images.ImagesChesshat.getName() : t === r.CowboyHat ?
a.Images.ImagesCowboyhat.getName() : t === r.ChickenHat ?
a.Images.ImagesChickenhat.getName() : t === r.FoxHat ?
a.Images.ImagesFoxhat.getName() : t === r.VikingHat ?
a.Images.ImagesVikinghat.getName() : t === r.BuilderHat ?
a.Images.ImagesBuilderhat.getName() : t === r.HockeyHat ?
a.Images.ImagesHockeyhat.getName() : t === r.TankHat ?
a.Images.ImagesTankhat.getName() : t === r.DruidHat ?
a.Images.ImagesDruidhat.getName() : t === r.IceHat ?
a.Images.ImagesIcehat.getName() : a.Images.ImagesWhitebearhat.getName()
}
,
e.prototype.setScale = function(t) {
this.currentScale = t,
this.hatSprite && this.hatSprite.scale.set(t, t)
}
,
e.prototype.setColor = function(t) {
this.currentTintColor = t,
this.hatSprite && (this.hatSprite.tint = t)
}
,
e.prototype.getHatId = function() {
return this.hatId
}
,
e.prototype.destroy = function() {
this.hatSprite && (this.hatSprite.destroy(),
this.hatSprite = null)
}
,
e
}(s.Component);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(4)
, r = function(t) {
function e() {
var e = t.call(this) || this;
return e.id = "localrotationinput",
e.lockTimeout = 0,
e
}
return n(e, t),
e.prototype.start = function() {
this.cachedTransform = this.entity.components.transform,
this.entity.on("senddamage", this.onSendDamage.bind(this))
}
,
e.prototype.onSendDamage = function(t) {
this.lockTimeout = .5,
this.latestPunchRotation = Phaser.Math.angleBetween(0, 0, t.directionX,
t.directionY) + Phaser.Math.degToRad(90)
}
,
e.prototype.update = function(t) {
if (this.lockTimeout > 0)
this.lockTimeout -= t,
this.cachedTransform.rotation = this.latestPunchRotation;
else {
var e = Phaser.Math.angleBetween(0, 0,
this.world.game.input.activePointer.worldX - this.cachedTransform.position.x,
this.world.game.input.activePointer.worldY - this.cachedTransform.position.y);
e += Phaser.Math.degToRad(90),
e = parseFloat(e.toPrecision(2)),
this.cachedTransform.rotation =
o.RotationInterpolator.interpolateAngle(this.cachedTransform.rotation, e, 12 * t)
}
}
,
e.prototype.destroy = function() {}
,
e
}(s.Component);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(3)
, r = o.Protocol.MessageType
, a = i(15)
, h = function(t) {
function e() {
var e = t.call(this) || this;
return e.id = "networkinput",
e.currentInput = new Phaser.Point,
e.currentRotation = 0,
e.previousInput = new Phaser.Point,
e.previousRotation = 0,
e.punchDirection = new Phaser.Point,
e.needSendPunch = !1,
e._lockPunchUntilMouseUp = !1,
e
}
return n(e, t),
e.prototype.lockPunchUntilMouseUp = function() {
this._lockPunchUntilMouseUp = !0
}
,
e.prototype.onNetworkSend = function() {
this.previousInput.equals(this.currentInput) && this.previousRotation
=== this.currentRotation || (this.world.socket.sendMessage(r.PlayerInput, {
x: this.currentInput.x,
y: this.currentInput.y,
rotation: this.currentRotation
}),
this.previousInput.copyFrom(this.currentInput),
this.previousRotation = this.currentRotation),
this.needSendPunch && (this.punchDirection.normalize(),
this.world.socket.sendMessage(r.PlayerAction, {
x: this.punchDirection.x,
y: this.punchDirection.y,
action: 0
}),
this.needSendPunch = !1)
}
,
e.prototype.start = function() {
this.cachedTransform = this.entity.components.transform,
this.entity.on("networksend", this.onNetworkSend.bind(this)),
this.cursors = this.world.game.input.keyboard.createCursorKeys(),
this.wasd = {
up: this.world.game.input.keyboard.addKey(Phaser.Keyboard.W),
down: this.world.game.input.keyboard.addKey(Phaser.Keyboard.S),
left: this.world.game.input.keyboard.addKey(Phaser.Keyboard.A),
right: this.world.game.input.keyboard.addKey(Phaser.Keyboard.D)
},
this.world.game.input.onDown.add(this.onMouseDown, this)
}
,
e.prototype.onMouseDown = function() {
this.world.services.getService(a.default).inProgress() ||
(this.punchDirection.set(this.world.game.input.activePointer.worldX -
this.cachedTransform.position.x, this.world.game.input.activePointer.worldY -
this.cachedTransform.position.y),
this.needSendPunch = !0,
this.entity.emit("sendpunch"))
}
,
e.prototype.update = function(t) {
var e = 0
, i = 0;
this.cursors.up.isDown || this.wasd.up.isDown ? i = -1 :
(this.cursors.down.isDown || this.wasd.down.isDown) && (i = 1),
this.cursors.left.isDown || this.wasd.left.isDown ? e = -1 :
(this.cursors.right.isDown || this.wasd.right.isDown) && (e = 1),
this.currentInput.set(e, i);
var n = Phaser.Math.angleBetween(0, 0,
this.world.game.input.activePointer.worldX - this.cachedTransform.position.x,
this.world.game.input.activePointer.worldY - this.cachedTransform.position.y);
n += Phaser.Math.degToRad(90),
n = parseFloat(n.toPrecision(2)),
this.currentRotation = n,
this.world.game.input.activePointer.isDown ?
this._lockPunchUntilMouseUp || this.onMouseDown() : this._lockPunchUntilMouseUp &&
(this._lockPunchUntilMouseUp = !1)
}
,
e.prototype.destroy = function() {
this.world.game.input.onDown.remove(this.onMouseDown, this)
}
,
e
}(s.Component);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(2)
, r = function(t) {
function e(e) {
var i = t.call(this) || this;
return i.id = "teamlabel",
i.labelColor = "#ffffff",
i.isAdmin = !1,
i.offset = e,
i
}
return n(e, t),
e.prototype.start = function() {
this.entity.on("networksync", this.onNetworkSync.bind(this)),
this.cachedTransform = this.entity.components.transform,
this.cachedSprite = this.entity.components.sprite,
this.label = this.world.game.add.text(this.cachedTransform.position.x,
this.cachedTransform.position.y + this.offset - this.cachedSprite.sprite.height /
2, "", {
fontSize: "18px",
font: "Roboto Mono"
}),
this.label.anchor.set(.5, 1),
this.label.stroke = "rgba(0,0,0,0.7)",
this.label.strokeThickness = 3,
this.label.fill = this.labelColor,
this.crownImage =
this.world.make.image(this.cachedTransform.position.x,
this.cachedTransform.position.y + this.offset - this.cachedSprite.sprite.height /
2, o.Images.ImagesCrown.getName()),
this.crownImage.anchor.set(.5, .5)
}
,
e.prototype.setTeamName = function(t) {
this.teamName = t,
this.label.setText(this.teamName)
}
,
e.prototype.setColor = function(t) {
this.labelColor = t,
this.label.fill = this.labelColor
}
,
e.prototype.align = function() {
var t = this.cachedTransform.position.x
, e = this.cachedTransform.position.y + this.offset -
this.cachedSprite.sprite.height / 2;
this.label.position.set(t, e),
this.crownImage.position.set(t, e - 45)
}
,
e.prototype.onNetworkSync = function(t) {
var e = !1;
t.hasOwnProperty("teamName") && (this.teamName = t.teamName,
e = !0),
t.hasOwnProperty("isTeamAdmin") && (this.isAdmin = t.isTeamAdmin,
e = !0),
e && (this.teamName ? this.label.setText("[" + this.teamName + "]") :
this.label.setText(""),
this.isAdmin ? this.crownImage.parent !== this.world.LAYER_UI &&
this.world.LAYER_UI.add(this.crownImage) : this.crownImage.parent ===
this.world.LAYER_UI && this.crownImage.parent.removeChild(this.crownImage))
}
,
e.prototype.update = function(t) {
this.align()
}
,
e.prototype.destroy = function() {
this.label.destroy(),
this.crownImage.destroy()
}
,
e
}(s.Component);
e.default = r
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(0)
, s = i(25)
, o = i(24)
, r = i(157)
, a = i(3)
, h = a.Protocol.EntityType
, l = i(172)
, c = i(171)
, u = i(159)
, d = i(158)
, p = i(173)
, f = function() {
function t() {}
return t.create = function(t, e, i, a) {
return void 0 === a && (a = -1),
t === h.Spectator ? new s.default(e,i,a) : t === h.Player ? new
o.default(e,i,a) : t === h.FollowerBot ? new d.FollowerBot(e,i,a) : t ===
h.FarmerBot ? new d.FarmerBot(e,i,a) : t === h.GuardBot ? new d.GuardBot(e,i,a) : t
=== h.WoodGenerator ? new c.WoodGenerator(e,i,a) : t === h.StoneGenerator ? new
c.StoneGenerator(e,i,a) : t === h.Pig ? new r.Pig(e,i,a) : t === h.Chicken ? new
r.Chicken(e,i,a) : t === h.Wolf ? new r.Wolf(e,i,a) : t === h.Bear ? new
r.Bear(e,i,a) : t === h.RideablePig ? new r.RideablePig(e,i,a) : t ===
h.PigMeatPickup ? new l.PigMeatPickup(e,i,a) : t === h.BearMeatPickup ? new
l.BearMeatPickup(e,i,a) : t === h.EggPickup ? new l.EggPickup(e,i,a) : t ===
h.CarrotPickup ? new l.CarrotPickup(e,i,a) : t === h.BoxPickup ? new
l.BoxPickup(e,i,a) : t === h.WoodBlock ? new u.WoodBlock(e,i,a) : t ===
h.StoneBlock ? new u.StoneBlock(e,i,a) : t === h.Door ? new u.Door(e,i,a) : t ===
h.Garden ? new u.Garden(e,i,a) : t === h.Tower ? new u.Tower(e,i,a) : t ===
h.Heartstone ? new u.Heartstone(e,i,a) : t === h.FoodCrate ? new u.FoodCrate(e,i,a)
: t === h.WoodCrate ? new u.WoodCrate(e,i,a) : t === h.StoneCrate ? new
u.StoneCrate(e,i,a) : t === h.RideableWolf ? new r.RideableWolf(e,i,a) : t ===
h.Mannequin ? new u.Mannequin(e,i,a) : t === h.GardenBot ? new d.GardenBot(e,i,a) :
t === h.WhiteBear ? new r.WhiteBear(e,i,a) : t === h.WinterStoneGenerator ? new
c.WinterStoneGenerator(e,i,a) : t === h.WinterWoodGenerator ? new
c.WinterWoodGenerator(e,i,a) : t === h.SoccerBall ? new u.SoccerBall(e,i,a) : t ===
h.FireballBullet ? new u.SoccerBall(e,i,a) : t === h.NightmareBoss ? new
d.GardenBot(e,i,a) : t === h.WhiteWalker ? new r.WhiteWalker(e,i,a) : t ===
h.WinterWall ? new p.WinterWall(e,i,a) : t === h.WinterFloor ? new
p.WinterFloor(e,i,a) : t === h.WinterTower ? new p.WinterTower(e,i,a) : t ===
h.WhiteBearHat ? new l.WhiteBearHat(e,i,a) : t === h.BrownBearHat ? new
l.BrownBearHat(e,i,a) : t === h.CowboyHat ? new l.CowboyHat(e,i,a) : t ===
h.ChessHat ? new l.ChessHat(e,i,a) : t === h.ChickenHat ? new l.ChickenHat(e,i,a) :
t === h.CoinPickup ? new l.CoinPickup(e,i,a) : t === h.WoodSpikes ? new
u.WoodSpikes(e,i,a) : t === h.Portal ? new u.Portal(e,i,a) : t === h.BuilderHat ?
new l.BuilderHat(e,i,a) : t === h.FoxHat ? new l.FoxHat(e,i,a) : t ===
h.VikingHat ? new l.VikingHat(e,i,a) : t === h.HockeyHat ? new l.HockeyHat(e,i,a) :
t === h.SoulPickup ? new l.SoulPickup(e,i,a) : t === h.RideableBear ? new
r.RideableBear(e,i,a) : t === h.DarkDoor ? new u.DarkDoor(e,i,a) : t ===
h.DarkGuardBot ? new d.DarkGuardBot(e,i,a) : t === h.DarkStoneBlock ? new
u.DarkStoneBlock(e,i,a) : t === h.TankHat ? new l.TankHat(e,i,a) : t === h.DruidHat
? new l.DruidHat(e,i,a) : t === h.IceHat ? new l.IceHat(e,i,a) : new
n.Entity(e,i,a)
}
,
t
}();
e.EntityFactory = f
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(2)
, l = i(20)
, c = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesWoodgenerator.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WoodGenerator = c;
var u = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesStonegenerator.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.StoneGenerator = u;
var d = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesWinterwoodgenerator.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WinterWoodGenerator = d;
var p = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesWinterstonegenerator.getName(),new
Phaser.Point(.5,.5))),
s.addComponent(new l.default),
s
}
return n(e, t),
e
}(s.Entity);
e.WinterStoneGenerator = p
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(2)
, l = function(t) {
function e(e, i, n, s, h) {
var l = t.call(this, e, i, -1) || this;
return l.addComponent(new o.default),
l.addComponent(new r.default),
l.addComponent(new a.default(n,s,h)),
l
}
return n(e, t),
e
}(s.Entity);
e.default = l;
var c = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesMeat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.PigMeatPickup = c;
var u = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesMeat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.BearMeatPickup = u;
var d = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesEgg.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.EggPickup = d;
var p = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesSoul.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.SoulPickup = p;
var f = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_1,
h.Images.ImagesCarrot.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.CarrotPickup = f;
var m = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesBox.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.BoxPickup = m;
var g = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesCoin.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.CoinPickup = g;
var y = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesWhitebearhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.WhiteBearHat = y;
var v = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesBrownbearhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.BrownBearHat = v;
var b = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesChesshat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.ChessHat = b;
var w = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesCowboyhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.CowboyHat = w;
var x = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesChickenhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.ChickenHat = x;
var _ = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesVikinghat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.VikingHat = _;
var P = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesFoxhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.FoxHat = P;
var T = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesBuilderhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.BuilderHat = T;
var C = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesHockeyhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.HockeyHat = C;
var S = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesTankhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.TankHat = S;
var A = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesDruidhat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.DruidHat = A;
var k = function(t) {
function e(e, i, n) {
return t.call(this, e, i, e.LAYER_BACKGROUND_0,
h.Images.ImagesIcehat.getName(), new Phaser.Point(.5,.5)) || this
}
return n(e, t),
e
}(l);
e.IceHat = k
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(0)
, o = i(5)
, r = i(4)
, a = i(6)
, h = i(2)
, l = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesWinterwall.getName(),new
Phaser.Point(.5,.5))),
s
}
return n(e, t),
e
}(s.Entity);
e.WinterWall = l;
var c = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_BACKGROUND_0,h.Images.ImagesWinterfloor.getName(),new
Phaser.Point(.5,.5))),
s
}
return n(e, t),
e
}(s.Entity);
e.WinterFloor = c;
var u = function(t) {
function e(e, i, n) {
var s = t.call(this, e, i, n) || this;
return s.addComponent(new o.default),
s.addComponent(new r.default),
s.addComponent(new
a.default(e.LAYER_FOREGROUND_0,h.Images.ImagesWintertower.getName(),new
Phaser.Point(.5,.5))),
s
}
return n(e, t),
e
}(s.Entity);
e.WinterTower = u
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(10)
, o = i(1)
, r = i(3)
, a = r.Protocol.MessageType
, h = i(2)
, l = i(17)
, c = i(16)
, u = function(t) {
function e() {
var e = t.call(this) || this;
return e.element = document.getElementById("top-panel"),
e
}
return n(e, t),
e
}(s.MenuContainer)
, d = function(t) {
function e(e, i, n, s, o) {
var r = t.call(this, n, s) || this;
return r.world = e,
r.element.className = "item",
r.element.innerHTML = '\n <img src="' + i + '" />\n
<div class="hotkey" id="' + n + ':hotkey">' + o + "</div>\n ",
r
}
return n(e, t),
e.prototype.onClick = function() {
t.prototype.onClick.call(this)
}
,
e.prototype.action = function() {
this.world.services.getService(p).requestWork(this.name)
}
,
e
}(s.MenuItem)
, p = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.actionMenu = new u,
i.actionMenu.appendChild(new
d(i.world,h.Images.ImagesBuild.getPNG(),"shop-show","B","B")),
i.actionMenu.appendChild(new
d(i.world,h.Images.ImagesUnmount.getPNG(),"unmount","U","U")),
i.actionMenu.appendChild(new
d(i.world,h.Images.ImagesTeam.getPNG(),"team","T","T")),
i.actionMenu.appendChild(new
d(i.world,h.Images.ImagesCowboyhaticon.getPNG(),"hat","H","H")),
i
}
return n(e, t),
e.prototype.requestWork = function(t) {
"shop-show" === t ?
this.world.services.getService(s.CraftMenuService).shopMenu.toggle() : "unmount"
=== t ? this.world.socket.sendMessage(a.PlayerUnmountRequest, {}) : "team" === t ?
this.world.services.getService(l.default).toggle() : "hat" === t &&
this.world.services.getService(c.default).toggle()
}
,
e
}(o.Service);
e.ActionService = p
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.ResourceType
, a = i(2)
, h = function(t) {
function e(e) {
return t.call(this, e) || this
}
return n(e, t),
e.prototype.float = function(t, e, i) {
for (var n = 0, s = function(s) {
var r = s
, a = i[s];
a > 0 && (o.world.game.time.events.add(.4 * Phaser.Timer.SECOND *
n, function() {
this._float(t, e, r, a)
}, o),
n++)
}, o = this, r = 0; r < i.length; r++)
s(r)
}
,
e.prototype._float = function(t, e, i, n) {
var s = this.world.game.add.text(t, e, "+" + n + " " + r[i], {
font: "20px " + a.GoogleWebFonts.RobotoMono
});
s.anchor.set(.5, 1),
s.stroke = "#000000",
s.strokeThickness = 3,
s.fill = "#00ff00";
var o = this.world.game.add.tween(s);
o.to({
y: s.y - 60
}),
o.onComplete.add(function() {
s.destroy()
}, this),
o.start()
}
,
e
}(s.Service);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = i(9)
, a = o.Protocol.EntityType
, h = i(2)
, l = Phaser.Rectangle
, c = i(27)
, u = i(26)
, d = o.Protocol.HatType
, p = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.x_ratio = 150 / 25600,
i.y_ratio = 150 / 25600,
i.minimapWinnerImage = i.world.game.make.image(0, 0,
h.Images.ImagesMinimapwinner.getName()),
i.minimapWalkerImage = i.world.game.make.image(0, 0,
h.Images.ImagesMinimapwalker.getName()),
i.bitmapData = i.world.game.add.bitmapData(150, 150),
i.image = i.bitmapData.addToWorld(),
i.image.fixedToCamera = !0,
i.image.cameraOffset.setTo(15, i.world.game.height - 170),
i.image.alpha = .7,
i.childService = e.services.getService(r.default),
i.preRenderBitmapData = i.world.game.add.bitmapData(150, 150),
i.initializePrerendered(),
i
}
return n(e, t),
e.prototype.initializePrerendered = function() {
this.preRenderBitmapData.clear(0, 0, this.preRenderBitmapData.width,
this.preRenderBitmapData.height);
for (var t = this.world.game.cache.getTilemapData("mapdata").data, e =
0, i = t.layers; e < i.length; e++) {
var n = i[e];
if ("objectgroup" === n.type)
for (var s = 0, o = n.objects; s < o.length; s++) {
var r = o[s]
, a = r.x
, h = r.y;
"woodgenerator" === r.type || "winterwoodgenerator" ===
r.type ? (this.preRenderBitmapData.ctx.beginPath(),
this.preRenderBitmapData.ctx.rect(a * this.x_ratio - 1, h *
this.y_ratio - 1, 2, 2),
this.preRenderBitmapData.ctx.fillStyle = "#00ff00",
this.preRenderBitmapData.ctx.fill()) : "stonegenerator" !==
r.type && "winterstonegenerator" !== r.type ||
(this.preRenderBitmapData.ctx.beginPath(),
this.preRenderBitmapData.ctx.rect(a * this.x_ratio - 1, h *
this.y_ratio - 1, 2, 2),
this.preRenderBitmapData.ctx.fillStyle = "#ffffff",
this.preRenderBitmapData.ctx.fill())
}
}
}
,
e.prototype.drawMinimapObject = function(t, e, i, n, s, o, r, a, h) {
this.bitmapData.ctx.beginPath(),
i >= -1 ? this.world.id === t ? t === r ?
this.bitmapData.draw(this.minimapWinnerImage, s - 5, o - 5, 10, 10) :
(this.bitmapData.ctx.rect(s - 4, o - 4, 10, 10),
this.bitmapData.ctx.fillStyle = n < 0 ? "#00aa00" : "#00ff00") :
this.world.networkId === e ? (this.bitmapData.ctx.rect(s - 2, o - 2, 5, 5),
this.bitmapData.ctx.fillStyle = "#00bb00") : this.world.teamId === i &&
i > -1 ? t === r ? this.bitmapData.draw(this.minimapWinnerImage, s - 5, o - 5, 10,
10) : (this.bitmapData.ctx.rect(s - 2, o - 2, 6, 6),
this.bitmapData.ctx.fillStyle = "#00bb00") : n > -1 && (!a || a || h)
&& (t === r ? this.bitmapData.draw(this.minimapWinnerImage, s - 5, o - 5, 10, 10) :
(this.bitmapData.ctx.rect(s - 1, o - 1, 4, 4),
this.bitmapData.ctx.fillStyle = "#ff0000")) : -2 === i && (a || !a) &&
this.drawWhiteWalker(s, o),
this.bitmapData.ctx.fill()
}
,
e.prototype.drawWhiteWalker = function(t, e) {
this.bitmapData.draw(this.minimapWalkerImage, t - 5, e - 5, 10, 10)
}
,
e.prototype.onMapMessage = function(t) {
var e = -1
, i = new Phaser.Point(0,0);
if (this.world.assignedObject) {
if (this.world.assignedObject.components.hat) {
e = this.world.assignedObject.components.hat.getHatId()
}
this.world.assignedObject.components.transform && (i =
this.world.assignedObject.components.transform.position)
}
var n = this.world.services.getService(c.default).topId
, s = this.world.services.getService(u.default).isNight();
this.bitmapData.clear(0, 0, this.bitmapData.width,
this.bitmapData.height),
this.bitmapData.ctx.beginPath(),
this.bitmapData.ctx.rect(0, 0, 150, 150),
this.bitmapData.ctx.fillStyle = "#222222",
this.bitmapData.ctx.fill(),
this.bitmapData.copyRect(this.preRenderBitmapData, new
l(0,0,this.bitmapData.width,this.bitmapData.height), 0, 0, .2);
for (var o = 0; o < this.childService.childs.length; o++) {
var r = this.childService.childs[o]
, h = r.position.x * this.x_ratio
, p = r.position.y * this.y_ratio
, f = r.objectType;
f === a.Tower ? (this.bitmapData.ctx.beginPath(),
this.bitmapData.ctx.rect(h - 3, p - 3, 6, 6),
this.bitmapData.ctx.fillStyle = "#aaaaaa",
this.bitmapData.ctx.fill()) : f !== a.StoneBlock && f !==
a.WoodBlock || (this.bitmapData.ctx.beginPath(),
this.bitmapData.ctx.rect(h - 1, p - 1, 2, 2),
this.bitmapData.ctx.fillStyle = "#aaaaaa",
this.bitmapData.ctx.fill())
}
for (var m = t.content.data, g = t.content.teamIdData, o = 0; o <
m.length; o += 5) {
var y = m[o]
, h = m[o + 1] * this.x_ratio
, p = m[o + 2] * this.y_ratio
, v = m[o + 3]
, b = m[o + 4]
, w = g[o / 5];
e === d.FoxHat && Phaser.Math.distance(m[o + 1], m[o + 2], i.x,
i.y) < 5e3 ? this.drawMinimapObject(y, b, w, v, h, p, n, s, !0) :
this.drawMinimapObject(y, b, w, v, h, p, n, s, !1)
}
}
,
e.prototype.update = function(t) {
this.world.game.scale.scaleMode === Phaser.ScaleManager.USER_SCALE ?
this.image.cameraOffset.setTo(20 + this.world.game.screenOffsetWidth *
this.world.game.scale.scaleFactor.x, this.world.game.height - 170 -
this.world.game.screenOffsetHeight * this.world.scale.scaleFactor.y) :
this.world.game.scale.scaleMode === Phaser.ScaleManager.RESIZE &&
this.image.cameraOffset.setTo(20, this.world.game.height - 170)
}
,
e.prototype.destroy = function() {
this.image.destroy(),
this.bitmapData.destroy()
}
,
e
}(s.Service);
e.default = p
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.updateTimeoutMax = .05,
i.updateTimeout = 0,
i
}
return n(e, t),
e.prototype.update = function(t) {
this.updateTimeout -= t,
this.updateTimeout <= 0 && (this.updateTimeout = this.updateTimeoutMax,
this.sendUpdate())
}
,
e.prototype.sendUpdate = function() {
this.world.assignedObject &&
this.world.assignedObject.emit("networksend")
}
,
e
}(s.Service);
e.default = o
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(3)
, r = o.Protocol.MessageType
, a = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.currentWidth = 0,
i.currentHeight = 0,
i.updateTimeout = .3,
i.updateTimeoutMax = .3,
i
}
return n(e, t),
e.prototype.update = function(t) {
this.updateTimeout -= t,
this.updateTimeout <= 0 && (this.updateTimeout = this.updateTimeoutMax,
this.performUpdate())
}
,
e.prototype.performUpdate = function() {
this.world.camera.width === this.currentWidth &&
this.world.camera.height === this.currentHeight || (this.currentWidth =
this.world.camera.width,
this.currentHeight = this.world.camera.height,
this.world.socket.sendMessage(r.PlayerSetViewportSize, {
width: this.currentWidth,
height: this.currentHeight
}))
}
,
e
}(s.Service);
e.default = a
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(14)
, r = function(t) {
function e(e, i) {
var n = t.call(this, e) || this;
n.container = document.getElementById("server-select");
for (var s = [], r = [], a = 0, h = 0, l = i; h < l.length; h++) {
var c = l[h];
if (c.status) {
var u = c.name.split("-")[0]
, d = c.name.split("-")[1];
u = u.charAt(0).toUpperCase() + u.slice(1),
r.indexOf(u) < 0 && (s.push("<option disabled>" + u +
"</option>"),
r.push(u)),
c.host === o.default.getHostAddressRaw().split(":")[0] ?
s.push('<option selected value="' + c.host + '">' + u + " #" + d + " [" + c.clients
+ "/100]</option>") : s.push('<option value="' + c.host + '">' + u + " #" + d + "
[" + c.clients + "/100]</option>"),
a += c.clients
}
}
return s.push("<option disabled>Total players: " + a + "</option>"),
n.container.innerHTML = s.join(""),
n.container.addEventListener("change", function() {
try {
window.location.href = "/?ip=" +
this.container.options[this.container.selectedIndex].value + ":5000"
} catch (t) {}
}
.bind(n)),
n
}
return n(e, t),
e
}(s.Service);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(1)
, o = i(2)
, r = function(t) {
function e(e) {
var i = t.call(this, e) || this;
return i.world.game.add.audio(o.Audio.SfxWhoosh1.getName(), 1, !1, !1),
i
}
return n(e, t),
e.prototype.play = function(t) {
this.world.game.sound.play(t)
}
,
e.prototype.toggle = function(t) {
this.world.game.sound.mute = !t
}
,
e.prototype.destroy = function() {}
,
e
}(s.Service);
e.default = r
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(3)
, o = i(7)
, r = s.Protocol.MessageType
, a = function(t) {
function e(e, i, n) {
var s = t.call(this) || this;
return s.websocket = new WebSocket(e),
s.websocket.binaryType = "arraybuffer",
s.websocket.onmessage = s.handleWebsocketMessage.bind(s),
s.websocket.onopen = function() {
i()
}
,
s.websocket.onclose = function() {
n()
}
,
s.websocket.onerror = function() {
n()
}
,
window.onbeforeunload = function() {
this.websocket.onclose = function() {}
,
this.websocket.close()
}
.bind(s),
s
}
return n(e, t),
e.prototype.handleWebsocketMessage = function(t) {
var e = new Uint8Array(t.data)
, i = s.Protocol.decode(e);
if (null != i)
if (i.type === r.PackedMessage)
for (var n = i.content.message, o = 0, a = 0, h =
i.content.sizes; a < h.length; a++) {
var l = h[a]
, c = new Uint8Array(n.buffer,o + n.byteOffset,l)
, u = s.Protocol.decode(c);
null != u && this.emit(u.type.toString(), u),
o += l
}
else
this.emit(i.type.toString(), i)
}
,
e.prototype.onMessage = function(t, e) {
this.on(t.toString(), e)
}
,
e.prototype.sendMessage = function(t, e) {
var i = s.Protocol.encode(t, e);
this.websocket.send(i)
}
,
e.prototype.destroy = function() {
this.websocket.close()
}
,
e
}(o.EventEmitter);
e.default = a
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = function(t) {
function e() {
var e = null !== t && t.apply(this, arguments) || this;
return e.nextState = "preloader",
e
}
return n(e, t),
e.prototype.preload = function() {
this.game.canvas.oncontextmenu = function(t) {
t.preventDefault()
}
}
,
e.prototype.create = function() {
this.input.maxPointers = 1,
this.game.scale.scaleMode = Phaser.ScaleManager.RESIZE,
this.game.scale.pageAlignHorizontally = !0,
this.game.scale.pageAlignVertically = !0,
this.game.device.desktop || this.game.scale.forceOrientation(!0, !1),
this.game.scale.scaleMode === Phaser.ScaleManager.RESIZE ?
(this.game.scale.parentIsWindow = !0,
window.addEventListener("resize", function() {
this.game.scale.setGameSize(window.innerWidth, window.innerHeight),
this.game.scale.refresh()
}
.bind(this)),
this.game.scale.setGameSize(window.innerWidth, window.innerHeight)) :
this.game.scale.scaleMode === Phaser.ScaleManager.USER_SCALE &&
(window.addEventListener("resize", function() {
this.onResizeUserScale()
}
.bind(this)),
this.onResizeUserScale()),
this.game.stage.disableVisibilityChange = !0,
this.game.state.start(this.nextState)
}
,
e.prototype.onResizeUserScale = function() {
var t = window.innerWidth / 1920
, e = window.innerHeight / 1080
, i = Math.max(t, e);
this.game.scale.setGameSize(1920, 1080),
this.game.scale.setUserScale(i, i, 0, 0);
var n = window.innerWidth
, s = Math.abs(n - 1920 * i) / 2
, o = window.innerHeight
, r = Math.abs(o - 1080 * i) / 2;
this.game.screenOffsetWidth = s,
this.game.screenOffsetHeight = r,
this.game.canvas.parentElement.style.left = (-s).toString() + "px",
this.game.canvas.parentElement.style.top = (-r).toString() + "px",
this.game.canvas.parentElement.style.position = "absolute",
this.game.canvas.parentElement.style.zIndex = "-1"
}
,
e
}(Phaser.State);
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(14)
, o = i(181)
, r = i(3)
, a = r.Protocol.MessageType
, h = function(t) {
function e() {
var e = null !== t && t.apply(this, arguments) || this;
return e.disconnectReason = -1,
e
}
return n(e, t),
e.prototype.onDisconnected = function() {
this.disconnectReason < 0 && this.game.state.start("crash", !0, !0)
}
,
e.prototype.onServerFullDisconnect = function(t) {
this.disconnectReason = t.content.reason,
0 === this.disconnectReason ? this.game.state.start("full", !0, !0) :
this.game.state.start("kicked", !0, !0)
}
,
e.prototype.onConnected = function() {
document.getElementById("preloader-screen").style.display = "none",
this.game.state.start("game", !0, !1, this.socket)
}
,
e.prototype.preload = function() {
s.default.init(function() {
var t = s.default.getHostAddress();
this.socket = new
o.default(t,this.onConnected.bind(this),this.onDisconnected.bind(this)),
this.socket.onMessage(a.ForceDisconnect,
this.onServerFullDisconnect.bind(this)),
console.log("Connecting to: " + t)
}
.bind(this))
}
,
e.prototype.create = function() {}
,
e.prototype.shutdown = function() {}
,
e
}(Phaser.State);
e.default = h
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = function(t) {
function e() {
return null !== t && t.apply(this, arguments) || this
}
return n(e, t),
e.prototype.preload = function() {}
,
e.prototype.create = function() {
document.getElementById("crashscreen").style.display = "block"
}
,
e
}(Phaser.State);
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = function(t) {
function e() {
return null !== t && t.apply(this, arguments) || this
}
return n(e, t),
e.prototype.preload = function() {}
,
e.prototype.create = function() {
document.getElementById("serverfullscreen").style.display = "block"
}
,
e
}(Phaser.State);
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s, o = i(3), r = o.Protocol.MessageType, a = i(170), h = i(1), l = i(177),
c = i(29), u = i(32), d = i(24), p = i(31), f = i(175), m = i(9), g = i(15), y =
i(27), v = i(176), b = i(28), w = i(33), x = i(35), _ =
x.UrlParse.getUrlParameterByName, P = i(19), T = i(156), C = i(25), S = i(178), A =
i(10), k = i(174), E = i(14), I = i(179), M = i(17), O = i(26), B = i(30), R =
i(180), L = i(16);
!function(t) {
t[t.LOBBY = 0] = "LOBBY",
t[t.GAME = 1] = "GAME",
t[t.RESPAWN = 2] = "RESPAWN"
}(s || (s = {}));
var D = function(t) {
function e() {
var e = null !== t && t.apply(this, arguments) || this;
return e.teamId = -1,
e.isAdmin = !1,
e.services = new h.ServiceManager,
e.entityHash = {},
e.gameState = s.LOBBY,
e
}
return n(e, t),
e.prototype.init = function(t) {
this.socket = t,
this.socket.onMessage(r.Assign, this.onAssignMessage.bind(this)),
this.socket.onMessage(r.SyncObject, this.onSyncMessage.bind(this)),
this.socket.onMessage(r.SyncObjectDelete,
this.onSyncMessageDelete.bind(this)),
this.socket.onMessage(r.ObjectSendDamage,
this.onSendDamage.bind(this)),
this.socket.onMessage(r.ObjectReceiveDamage,
this.onReceiveDamage.bind(this)),
this.socket.onMessage(r.SyncBackpack, this.onSyncBackpack.bind(this)),
this.socket.onMessage(r.Ping, this.onPingReply.bind(this)),
this.socket.onMessage(r.FloatResources,
this.onFloatResources.bind(this)),
this.socket.onMessage(r.SyncChild, this.onSyncChild.bind(this)),
this.socket.onMessage(r.SyncChildDelete,
this.onSyncChildDelete.bind(this)),
this.socket.onMessage(r.LeaderboardMessage,
this.onLeaderboardMessage.bind(this)),
this.socket.onMessage(r.LeaderboardMessagePlayer,
this.onLeaderboardMessagePlayer.bind(this)),
this.socket.onMessage(r.MapMessage, this.onMapMessage.bind(this)),
this.socket.onMessage(r.ChatMessage, this.onChatMessage.bind(this)),
this.socket.onMessage(r.PlayerBuildResponse,
this.onBuildResponse.bind(this)),
this.respawnWindow = new T.default(this),
this.initializeLoginButton(),
this.initializeGameState(s.LOBBY),
this.initializePartyLink(),
window.onbeforeunload = function(t) {
if (this.isNeedToPreventClose()) {
var e = "Are you really want to quit?";
return t.returnValue = e,
e
}
}
.bind(this)
}
,
e.prototype.isNeedToPreventClose = function() {
return !(!this.assignedObject || !this.assignedObject.components.level)
&& this.assignedObject.components.level.currentLevel > 1
}
,
e.prototype.initializeLoginButton = function() {
var t = document.getElementById("login-input");
t.focus(),
w.default.read("nickname") && (t.value = w.default.read("nickname")),
document.getElementById("login-button").onclick =
this.onLoginButtonClick.bind(this)
}
,
e.prototype.onLoginButtonClick = function() {
var t = document.getElementById("login-input")
, e = t.value;
w.default.write("nickname", e),
P.default.play(function() {
this.request_spawn(e)
}
.bind(this))
}
,
e.prototype.initializeGameState = function(t) {
t === s.LOBBY ? (document.getElementById("lobby-layout").style.display
= "block",
document.getElementById("game-layout").style.display = "none",
document.getElementById("respawn-layout").style.display = "none",
this.game.input.keyboard.enabled = !1) : t === s.GAME ?
(document.getElementById("lobby-layout").style.display = "none",
document.getElementById("game-layout").style.display = "block",
document.getElementById("respawn-layout").style.display = "none",
this.game.input.keyboard.enabled = !0) : t === s.RESPAWN &&
(document.getElementById("lobby-layout").style.display = "none",
document.getElementById("game-layout").style.display = "none",
document.getElementById("respawn-layout").style.display = "block",
this.game.input.keyboard.reset(!1),
this.game.input.keyboard.enabled = !1,
this.respawnWindow.show()),
this.gameState = t
}
,
e.prototype.onBuildResponse = function(t) {
this.services.getService(g.default).onBuildResponse(t.content)
}
,
e.prototype.onChatMessage = function(t) {
var e = t.content.id;
this.entityHash.hasOwnProperty(e.toString()) &&
this.entityHash[e].emit("chatmessage", t.content.message)
}
,
e.prototype.onMapMessage = function(t) {
this.services.getService(v.default).onMapMessage(t)
}
,
e.prototype.onLeaderboardMessage = function(t) {
this.services.getService(y.default).onScoreMessage(t)
}
,
e.prototype.onLeaderboardMessagePlayer = function(t) {
this.services.getService(y.default).onScoreMessagePlayer(t)
}
,
e.prototype.onSyncChild = function(t) {
this.services.getService(m.default).onCreateChild(t)
}
,
e.prototype.onSyncChildDelete = function(t) {
this.services.getService(m.default).onRemoveChild(t)
}
,
e.prototype.onFloatResources = function(t) {
var e = t.content.id;
if (this.entityHash.hasOwnProperty(e.toString())) {
var i = this.entityHash[e].components.transform.position;
this.services.getService(f.default).float(i.x, i.y,
t.content.counts)
}
}
,
e.prototype.onPingReply = function(t) {
this.services.getService(p.default).onPingReply(t)
}
,
e.prototype.onSyncBackpack = function(t) {
this.services.getService(u.default).sync(t.content.counts)
}
,
e.prototype.onReceiveDamage = function(t) {
var e = t.content.id;
this.entityHash.hasOwnProperty(e.toString()) &&
this.entityHash[e].emit("receivedamage")
}
,
e.prototype.onSendDamage = function(t) {
var e = t.content.id;
this.entityHash.hasOwnProperty(e.toString()) &&
this.entityHash[e].emit("senddamage", t.content)
}
,
e.prototype.onSyncMessageDelete = function(t) {
var e = t.content.id;
this.entityHash.hasOwnProperty(e.toString()) &&
(this.entityHash[e].destroy(),
delete this.entityHash[e])
}
,
e.prototype.initializePartyLink = function() {
var t = document.getElementById("partylink");
t.style.visibility = "visible",
t.onclick = function() {
history.pushState({
id: 0
}, "", "/?ip=" + E.default.getHostAddressRaw())
}
.bind(this)
}
,
e.prototype.onSyncMessage = function(t) {
var e = !1
, i = t.content.id
, n = !1;
this.entityHash[i] || (this.entityHash[i] =
a.EntityFactory.create(t.content.objectType, this, i, t.content.parentId),
n = !0),
i === this.id && (t.content.hasOwnProperty("networkId") &&
(this.networkId = t.content.networkId),
t.content.hasOwnProperty("teamId") && (this.teamId = t.content.teamId,
n || (e = !0)),
t.content.hasOwnProperty("isTeamAdmin") && (this.isAdmin =
t.content.isTeamAdmin,
e = !0)),
this.entityHash[i].emit("networksync", t.content),
i === this.id && n && (this.assignedObject = this.entityHash[i],
this.assignedObject instanceof d.default ? this.onGameStart() :
this.assignedObject instanceof C.default && this.gameState === s.GAME &&
this.initializeGameState(s.RESPAWN),
this.assignedObject.components.sprite ?
this.camera.follow(this.assignedObject.components.sprite.sprite,
Phaser.Camera.FOLLOW_LOCKON, .1, .1) : t.content.x && t.content.y &&
this.camera.focusOnXY(t.content.x, t.content.y),
this.broadcastEvent("hostspawn"),
this.services.getService(M.default).onTeamSwitch(this.teamId)),
e && (this.broadcastEvent("hostteamchanged"),
this.services.getService(M.default).onTeamSwitch(this.teamId))
}
,
e.prototype.broadcastEvent = function(t) {
for (var e in this.entityHash)
this.entityHash[e] && this.entityHash[e].emit(t)
}
,
e.prototype.onAssignMessage = function(t) {
this.id = t.content.id,
this.camera.unfollow(),
this.cleanup()
}
,
e.prototype.onGameStart = function() {
this.initializeGameState(s.GAME)
}
,
e.prototype.preload = function() {}
,
e.prototype.cleanup = function() {
for (var t in this.entityHash)
this.entityHash[t].destroy();
this.entityHash = {},
this.assignedObject = null,
this.services.cleanup()
}
,
e.prototype.getTeamId = function() {
return _("networkId") || ""
}
,
e.prototype.request_respawn = function() {
var t = document.getElementById("login-input")
, e = t.value;
this.request_spawn(e)
}
,
e.prototype.request_spawn = function(t) {
this.socket.sendMessage(r.PlayerSpawnRequest, {
name: t,
teamId: this.getTeamId()
})
}
,
e.prototype.createLayers = function() {
this.LAYER_BACKGROUND_0 = this.game.add.group(),
this.LAYER_BACKGROUND_1 = this.game.add.group(),
this.LAYER_MIDDLE_0 = this.game.add.group(),
this.LAYER_MIDDLE_1 = this.game.add.group(),
this.LAYER_FOREGROUND_0 = this.game.add.group(),
this.LAYER_UI = this.game.add.group()
}
,
e.prototype.create = function() {
this.createLayers(),
this.services.registerService(new R.default(this)),
this.services.registerService(new l.default(this)),
this.services.registerService(new S.default(this)),
this.services.registerService(new c.default(this)),
this.services.registerService(new u.default(this)),
this.services.registerService(new p.default(this)),
this.services.registerService(new f.default(this)),
this.services.registerService(new g.default(this)),
this.services.registerService(new m.default(this)),
this.services.registerService(new y.default(this)),
this.services.registerService(new v.default(this)),
this.services.registerService(new b.default(this)),
this.services.registerService(new A.CraftMenuService(this)),
this.services.registerService(new k.ActionService(this)),
this.services.registerService(new M.default(this)),
this.services.registerService(new O.default(this)),
this.services.registerService(new B.default(this)),
this.services.registerService(new L.default(this)),
$.ajax("http://status.glor.io").done(function(t) {
this.services.registerService(new I.default(this,t))
}
.bind(this))
}
,
e.prototype.update = function() {
var t = this.game.time.elapsed / 1e3;
for (var e in this.entityHash)
this.entityHash[e].update(t);
this.services.update(t)
}
,
e.prototype.shutdown = function() {
this.cleanup(),
this.services.destroy()
}
,
e
}(Phaser.State);
e.default = D
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = function(t) {
function e() {
return null !== t && t.apply(this, arguments) || this
}
return n(e, t),
e.prototype.preload = function() {}
,
e.prototype.create = function() {
document.getElementById("kickedscreen").style.display = "block"
}
,
e
}(Phaser.State);
e.default = s
}
, function(t, e, i) {
"use strict";
var n = this && this.__extends || function() {
var t = 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(e, i) {
function n() {
this.constructor = e
}
t(e, i),
e.prototype = null === i ? Object.create(i) : (n.prototype =
i.prototype,
new n)
}
}();
Object.defineProperty(e, "__esModule", {
value: !0
});
var s = i(2)
, o = i(34)
, r = i(190)
, a = function(t) {
function e() {
var e = null !== t && t.apply(this, arguments) || this;
return e.nextState = "connection",
e
}
return n(e, t),
e.prototype.preload = function() {
this.game.load.tilemap("mapdata", s.Atlases.MapMap.getJSONHash(), null,
Phaser.Tilemap.TILED_JSON),
this.game.load.image("mapimage", s.Atlases.MapMap.getPNG()),
this.game.load.image(s.Images.ImagesBox.getName(),
s.Images.ImagesBox.getPNG()),
this.game.load.image(s.Images.ImagesStonegenerator.getName(),
s.Images.ImagesStonegenerator.getPNG()),
this.game.load.image(s.Images.ImagesWoodgenerator.getName(),
s.Images.ImagesWoodgenerator.getPNG()),
this.game.load.image(s.Images.ImagesWinterstonegenerator.getName(),
s.Images.ImagesWinterstonegenerator.getPNG()),
this.game.load.image(s.Images.ImagesWinterwoodgenerator.getName(),
s.Images.ImagesWinterwoodgenerator.getPNG()),
this.game.load.image(s.Images.ImagesEgg.getName(),
s.Images.ImagesEgg.getPNG()),
this.game.load.image(s.Images.ImagesCarrot.getName(),
s.Images.ImagesCarrot.getPNG()),
this.game.load.image(s.Images.ImagesMeat.getName(),
s.Images.ImagesMeat.getPNG()),
this.game.load.image(s.Images.ImagesWoodwall.getName(),
s.Images.ImagesWoodwall.getPNG()),
this.game.load.image(s.Images.ImagesStonewall.getName(),
s.Images.ImagesStonewall.getPNG()),
this.game.load.image(s.Images.ImagesGarden.getName(),
s.Images.ImagesGarden.getPNG()),
this.game.load.image(s.Images.ImagesTower.getName(),
s.Images.ImagesTower.getPNG()),
this.game.load.image(s.Images.ImagesDoor.getName(),
s.Images.ImagesDoor.getPNG()),
this.game.load.image(s.Images.ImagesHeartstone.getName(),
s.Images.ImagesHeartstone.getPNG()),
this.game.load.image(s.Images.ImagesKnight.getName(),
s.Images.ImagesKnight.getPNG()),
this.game.load.image(s.Images.ImagesGardener.getName(),
s.Images.ImagesGardener.getPNG()),
this.game.load.image(s.Images.ImagesGuard.getName(),
s.Images.ImagesGuard.getPNG()),
this.game.load.image(s.Images.ImagesFollower.getName(),
s.Images.ImagesFollower.getPNG()),
this.game.load.image(s.Images.ImagesFoodcrate.getName(),
s.Images.ImagesFoodcrate.getPNG()),
this.game.load.image(s.Images.ImagesWoodcrate.getName(),
s.Images.ImagesWoodcrate.getPNG()),
this.game.load.image(s.Images.ImagesStonecrate.getName(),
s.Images.ImagesStonecrate.getPNG()),
this.game.load.image(s.Images.ImagesCarwolf.getName(),
s.Images.ImagesCarwolf.getPNG()),
this.game.load.image(s.Images.ImagesUnmount.getName(),
s.Images.ImagesUnmount.getPNG()),
this.game.load.image(s.Images.ImagesMannequin.getName(),
s.Images.ImagesMannequin.getPNG()),
this.game.load.image(s.Images.ImagesPickupbot.getName(),
s.Images.ImagesPickupbot.getPNG()),
this.game.load.image(s.Images.ImagesBuild.getName(),
s.Images.ImagesBuild.getPNG()),
this.game.load.image(s.Images.ImagesSoccerball.getName(),
s.Images.ImagesSoccerball.getPNG()),
this.game.load.image(s.Images.ImagesTeam.getName(),
s.Images.ImagesTeam.getPNG()),
this.game.load.image(s.Images.ImagesMinimapwinner.getName(),
s.Images.ImagesMinimapwinner.getPNG()),
this.game.load.image(s.Images.ImagesCrown.getName(),
s.Images.ImagesCrown.getPNG()),
this.game.load.image(s.Images.ImagesWinterwall.getName(),
s.Images.ImagesWinterwall.getPNG()),
this.game.load.image(s.Images.ImagesWinterfloor.getName(),
s.Images.ImagesWinterfloor.getPNG()),
this.game.load.image(s.Images.ImagesWintertower.getName(),
s.Images.ImagesWintertower.getPNG()),
this.game.load.image(s.Images.ImagesCoin.getName(),
s.Images.ImagesCoin.getPNG()),
this.game.load.image(s.Images.ImagesMinimapwalker.getName(),
s.Images.ImagesMinimapwalker.getPNG()),
this.game.load.image(s.Images.ImagesBannertopleft.getName(),
s.Images.ImagesBannertopleft.getPNG()),
this.game.load.image(s.Images.ImagesWoodspikes.getName(),
s.Images.ImagesWoodspikes.getPNG()),
this.game.load.image(s.Images.ImagesPortal.getName(),
s.Images.ImagesPortal.getPNG()),
this.game.load.image(s.Images.ImagesSoul.getName(),
s.Images.ImagesSoul.getPNG()),
this.game.load.image(s.Images.ImagesDarkdoor.getName(),
s.Images.ImagesDarkdoor.getPNG()),
this.game.load.image(s.Images.ImagesDarkguard.getName(),
s.Images.ImagesDarkguard.getPNG()),
this.game.load.image(s.Images.ImagesRideablebear.getName(),
s.Images.ImagesRideablebear.getPNG()),
this.game.load.image(s.Images.ImagesDarkstonewall.getName(),
s.Images.ImagesDarkstonewall.getPNG()),
this.game.load.image(s.Images.ImagesWhitebearhat.getName(),
s.Images.ImagesWhitebearhat.getPNG()),
this.game.load.image(s.Images.ImagesBrownbearhat.getName(),
s.Images.ImagesBrownbearhat.getPNG()),
this.game.load.image(s.Images.ImagesChesshat.getName(),
s.Images.ImagesChesshat.getPNG()),
this.game.load.image(s.Images.ImagesChesshatrot.getName(),
s.Images.ImagesChesshatrot.getPNG()),
this.game.load.image(s.Images.ImagesCowboyhat.getName(),
s.Images.ImagesCowboyhat.getPNG()),
this.game.load.image(s.Images.ImagesChickenhat.getName(),
s.Images.ImagesChickenhat.getPNG()),
this.game.load.image(s.Images.ImagesVikinghat.getName(),
s.Images.ImagesVikinghat.getPNG()),
this.game.load.image(s.Images.ImagesBuilderhat.getName(),
s.Images.ImagesBuilderhat.getPNG()),
this.game.load.image(s.Images.ImagesFoxhat.getName(),
s.Images.ImagesFoxhat.getPNG()),
this.game.load.image(s.Images.ImagesHockeyhat.getName(),
s.Images.ImagesHockeyhat.getPNG()),
this.game.load.image(s.Images.ImagesTankhat.getName(),
s.Images.ImagesTankhat.getPNG()),
this.game.load.image(s.Images.ImagesDruidhat.getName(),
s.Images.ImagesDruidhat.getPNG()),
this.game.load.image(s.Images.ImagesIcehat.getName(),
s.Images.ImagesIcehat.getPNG()),
this.game.load.image(s.Images.ImagesWhitebearhaticon.getName(),
s.Images.ImagesWhitebearhaticon.getPNG()),
this.game.load.image(s.Images.ImagesBrownbearhaticon.getName(),
s.Images.ImagesBrownbearhaticon.getPNG()),
this.game.load.image(s.Images.ImagesChesshaticon.getName(),
s.Images.ImagesChesshaticon.getPNG()),
this.game.load.image(s.Images.ImagesCowboyhaticon.getName(),
s.Images.ImagesCowboyhaticon.getPNG()),
this.game.load.image(s.Images.ImagesChickenhaticon.getName(),
s.Images.ImagesChickenhaticon.getPNG()),
this.game.load.image(s.Images.ImagesVikinghaticon.getName(),
s.Images.ImagesVikinghaticon.getPNG()),
this.game.load.image(s.Images.ImagesBuilderhaticon.getName(),
s.Images.ImagesBuilderhaticon.getPNG()),
this.game.load.image(s.Images.ImagesFoxhaticon.getName(),
s.Images.ImagesFoxhaticon.getPNG()),
this.game.load.image(s.Images.ImagesHockeyhaticon.getName(),
s.Images.ImagesHockeyhaticon.getPNG()),
this.game.load.image(s.Images.ImagesTankhaticon.getName(),
s.Images.ImagesTankhaticon.getPNG()),
this.game.load.image(s.Images.ImagesDruidhaticon.getName(),
s.Images.ImagesDruidhaticon.getPNG()),
this.game.load.image(s.Images.ImagesIcehaticon.getName(),
s.Images.ImagesIcehaticon.getPNG()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesChicken.getName(),
s.Atlases.AtlasesChicken.getPNG(), s.Atlases.AtlasesChicken.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesKnight.getName(),
s.Atlases.AtlasesKnight.getPNG(), s.Atlases.AtlasesKnight.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesGuard.getName(),
s.Atlases.AtlasesGuard.getPNG(), s.Atlases.AtlasesGuard.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesGardener.getName(),
s.Atlases.AtlasesGardener.getPNG(), s.Atlases.AtlasesGardener.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesFollower.getName(),
s.Atlases.AtlasesFollower.getPNG(), s.Atlases.AtlasesFollower.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesPig.getName(),
s.Atlases.AtlasesPig.getPNG(), s.Atlases.AtlasesPig.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesWolf.getName(),
s.Atlases.AtlasesWolf.getPNG(), s.Atlases.AtlasesWolf.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesBear.getName(),
s.Atlases.AtlasesBear.getPNG(), s.Atlases.AtlasesBear.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesWhitebear.getName(),
s.Atlases.AtlasesWhitebear.getPNG(), s.Atlases.AtlasesWhitebear.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesCarpig.getName(),
s.Atlases.AtlasesCarpig.getPNG(), s.Atlases.AtlasesCarpig.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesDoor.getName(),
s.Atlases.AtlasesDoor.getPNG(), s.Atlases.AtlasesDoor.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesCarwolf.getName(),
s.Atlases.AtlasesCarwolf.getPNG(), s.Atlases.AtlasesCarwolf.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesPickupbot.getName(),
s.Atlases.AtlasesPickupbot.getPNG(), s.Atlases.AtlasesPickupbot.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesWhitewalker.getName(),
s.Atlases.AtlasesWhitewalker.getPNG(), s.Atlases.AtlasesWhitewalker.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesRideablebear.getName(),
s.Atlases.AtlasesRideablebear.getPNG(),
s.Atlases.AtlasesRideablebear.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesDarkdoor.getName(),
s.Atlases.AtlasesDarkdoor.getPNG(), s.Atlases.AtlasesDarkdoor.getJSONHash()),
this.game.load.atlasJSONHash(s.Atlases.AtlasesDarkguard.getName(),
s.Atlases.AtlasesDarkguard.getPNG(), s.Atlases.AtlasesDarkguard.getJSONHash()),
this.game.load.audio(s.Audio.SfxWhoosh1.getName(),
s.Audio.SfxWhoosh1.getWAV(), !0),
this.loadLeaderboards()
}
,
e.prototype.create = function() {
r.Loader.waitForSoundDecoding(function() {
this.game.state.start(this.nextState)
}, this)
}
,
e.prototype.loadLeaderboards = function() {
$.ajax("http://leaderboard.glor.io").done(function(t) {
for (var e = t[1], i = [], n = 0; n < e.length; n += 2) {
var s = e[n]
, r = e[n + 1]
, a = r > 1e4 ? Math.floor(r / 1e3).toString() + "k" :
r.toString();
i.push(' \n <div class="ui-leaderboard-
player">\n <span class="player-rank">#' + (Math.floor(n / 2)
+ 1) + '</span>\n <span class="player-name">' +
o.escapeHtml(s) + '</span>\n <span class="player-score">' +
a + "</span>\n </div>")
}
$("#weekly-leaderboard").append(i.join(""))
}
.bind(this))
}
,
e
}(Phaser.State);
e.default = a
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = function() {
function t() {}
return t.call = function(t, e) {
var i;
i = new XMLHttpRequest,
i.onreadystatechange = function() {
4 === i.readyState && 200 === i.status &&
e(JSON.parse(i.responseText))
}
,
i.open("GET", t, !0),
i.send()
}
,
t
}();
e.default = n
}
, function(t, e, i) {
"use strict";
Object.defineProperty(e, "__esModule", {
value: !0
});
var n = i(2)
, s = function() {
function t() {}
return t.loadImages = function() {
for (var t in n.Images)
if (!this.game.cache.checkImageKey(n.Images[t].getName()))
for (var e in n.Images[t])
"getName" !== e &&
this.game.load.image(n.Images[t].getName(), n.Images[t][e]())
}
,
t.loadAtlases = function() {
for (var t in n.Atlases)
if (!this.game.cache.checkImageKey(n.Atlases[t].getName())) {
var e = null
, i = null;
for (var s in n.Atlases[t])
"getXML" === s || "getJSONArray" === s || "getJSONHash" ===
s ? i = s : "getName" !== s && "Frames" !== s && (e = s);
"getXML" === i ?
this.game.load.atlasXML(n.Atlases[t].getName(), n.Atlases[t][e](),
n.Atlases[t].getXML()) : "getJSONArray" === i ?
this.game.load.atlasJSONArray(n.Atlases[t].getName(), n.Atlases[t][e](),
n.Atlases[t].getJSONArray()) : "getJSONHash" === i &&
this.game.load.atlasJSONHash(n.Atlases[t].getName(), n.Atlases[t][e](),
n.Atlases[t].getJSONHash())
}
}
,
t.orderAudioSourceArrayBasedOnSoundExtensionPreference = function(t) {
var e = this
, i = [];
for (var n in this.soundExtensionsPreference) {
var s = t.filter(function(t) {
return t.substring(t.lastIndexOf(".") + 1, t.length) ===
e.soundExtensionsPreference[n]
});
i = i.concat(s)
}
return i
}
,
t.loadAudio = function() {
for (var t in n.Audio) {
var e = n.Audio[t].getName();
if (this.soundKeys.push(e),
!this.game.cache.checkSoundKey(e)) {
var i = [];
for (var s in n.Audio[t])
"getName" !== s && i.push(n.Audio[t][s]());
i =
this.orderAudioSourceArrayBasedOnSoundExtensionPreference(i),
this.game.load.audio(e, i, !0)
}
}
}
,
t.loadAudiosprites = function() {
for (var t in n.Audiosprites) {
var e = n.Audiosprites[t].getName();
if (this.soundKeys.push(e),
!this.game.cache.checkSoundKey(e)) {
var i = [];
for (var s in n.Audiosprites[t])
"getName" !== s && "getJSON" !== s && "Sprites" !== s &&
i.push(n.Audiosprites[t][s]());
i =
this.orderAudioSourceArrayBasedOnSoundExtensionPreference(i),
this.game.load.audiosprite(e, i, n.Audiosprites[t].getJSON(),
null, !0)
}
}
}
,
t.loadBitmapFonts = function() {
for (var t in n.BitmapFonts)
if (!
this.game.cache.checkBitmapFontKey(n.BitmapFonts[t].getName())) {
var e = null
, i = null;
for (var s in n.BitmapFonts[t])
"getXML" === s || "getFNT" === s ? i = s : "getName" !== s
&& (e = s);
this.game.load.bitmapFont(n.BitmapFonts[t].getName(),
n.BitmapFonts[t][e](), n.BitmapFonts[t][i]())
}
}
,
t.loadJSON = function() {
for (var t in n.JSON)
this.game.cache.checkJSONKey(n.JSON[t].getName()) ||
this.game.load.json(n.JSON[t].getName(), n.JSON[t].getJSON(), !0)
}
,
t.loadXML = function() {
for (var t in n.XML)
this.game.cache.checkXMLKey(n.XML[t].getName()) ||
this.game.load.xml(n.XML[t].getName(), n.XML[t].getXML(), !0)
}
,
t.loadText = function() {
for (var t in n.Text)
this.game.cache.checkTextKey(n.Text[t].getName()) ||
this.game.load.xml(n.Text[t].getName(), n.Text[t].getText(), !0)
}
,
t.loadScripts = function() {
for (var t in n.Scripts)
this.game.load.script(n.Scripts[t].getName(), n.Scripts[t].getJS())
}
,
t.loadShaders = function() {
for (var t in n.Shaders)
this.game.cache.checkShaderKey(n.Shaders[t].getName()) ||
this.game.load.shader(n.Shaders[t].getName(), n.Shaders[t].getFRAG(), !0)
}
,
t.loadAllAssets = function(t, e, i) {
this.game = t,
e && this.game.load.onLoadComplete.addOnce(e, i),
this.loadImages(),
this.loadAtlases(),
this.loadAudio(),
this.loadAudiosprites(),
this.loadBitmapFonts(),
this.loadJSON(),
this.loadXML(),
this.loadText(),
this.loadScripts(),
this.loadShaders()
}
,
t.waitForSoundDecoding = function(t, e) {
this.soundKeys.length > 0 ?
this.game.sound.setDecodedCallback(this.soundKeys, t, e) : t.call(e)
}
,
t
}();
s.game = null,
s.soundKeys = [],
s.soundExtensionsPreference = ["webm", "ogg", "m4a", "mp3", "aac", "ac3",
"caf", "flac", "mp4", "wav"],
e.Loader = s
}
, function(t, e, i) {
var n;
!function() {
function s(t, e, i) {
return t.call.apply(t.bind, arguments)
}
function o(t, e, i) {
if (!t)
throw Error();
if (2 < arguments.length) {
var n = Array.prototype.slice.call(arguments, 2);
return function() {
var i = Array.prototype.slice.call(arguments);
return Array.prototype.unshift.apply(i, n),
t.apply(e, i)
}
}
return function() {
return t.apply(e, arguments)
}
}
function r(t, e, i) {
return r = Function.prototype.bind && -1 !=
Function.prototype.bind.toString().indexOf("native code") ? s : o,
r.apply(null, arguments)
}
function a(t, e) {
this.a = t,
this.m = e || t,
this.c = this.m.document
}
function h(t, e, i, n) {
if (e = t.c.createElement(e),
i)
for (var s in i)
i.hasOwnProperty(s) && ("style" == s ? e.style.cssText = i[s] :
e.setAttribute(s, i[s]));
return n && e.appendChild(t.c.createTextNode(n)),
e
}
function l(t, e, i) {
t = t.c.getElementsByTagName(e)[0],
t || (t = document.documentElement),
t.insertBefore(i, t.lastChild)
}
function c(t) {
t.parentNode && t.parentNode.removeChild(t)
}
function u(t, e, i) {
e = e || [],
i = i || [];
for (var n = t.className.split(/\s+/), s = 0; s < e.length; s += 1) {
for (var o = !1, r = 0; r < n.length; r += 1)
if (e[s] === n[r]) {
o = !0;
break
}
o || n.push(e[s])
}
for (e = [],
s = 0; s < n.length; s += 1) {
for (o = !1,
r = 0; r < i.length; r += 1)
if (n[s] === i[r]) {
o = !0;
break
}
o || e.push(n[s])
}
t.className = e.join(" ").replace(/\s+/g, " ").replace(/^\s+|\s+$/, "")
}
function d(t, e) {
for (var i = t.className.split(/\s+/), n = 0, s = i.length; n < s; n++)
if (i[n] == e)
return !0;
return !1
}
function p(t) {
if ("string" == typeof t.f)
return t.f;
var e = t.m.location.protocol;
return "about:" == e && (e = t.a.location.protocol),
"https:" == e ? "https:" : "http:"
}
function f(t) {
return t.m.location.hostname || t.a.location.hostname
}
function m(t, e, i) {
function n() {
a && s && o && (a(r),
a = null)
}
e = h(t, "link", {
rel: "stylesheet",
href: e,
media: "all"
});
var s = !1
, o = !0
, r = null
, a = i || null;
at ? (e.onload = function() {
s = !0,
n()
}
,
e.onerror = function() {
s = !0,
r = Error("Stylesheet failed to load"),
n()
}
) : setTimeout(function() {
s = !0,
n()
}, 0),
l(t, "head", e)
}
function g(t, e, i, n) {
var s = t.c.getElementsByTagName("head")[0];
if (s) {
var o = h(t, "script", {
src: e
})
, r = !1;
return o.onload = o.onreadystatechange = function() {
r || this.readyState && "loaded" != this.readyState &&
"complete" != this.readyState || (r = !0,
i && i(null),
o.onload = o.onreadystatechange = null,
"HEAD" == o.parentNode.tagName && s.removeChild(o))
}
,
s.appendChild(o),
setTimeout(function() {
r || (r = !0,
i && i(Error("Script load timeout")))
}, n || 5e3),
o
}
return null
}
function y() {
this.a = 0,
this.c = null
}
function v(t) {
return t.a++,
function() {
t.a--,
w(t)
}
}
function b(t, e) {
t.c = e,
w(t)
}
function w(t) {
0 == t.a && t.c && (t.c(),
t.c = null)
}
function x(t) {
this.a = t || "-"
}
function _(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 P(t) {
return S(t) + " " + t.f + "00 300px " + T(t.c)
}
function T(t) {
var e = [];
t = t.split(/,\s*/);
for (var i = 0; i < t.length; i++) {
var n = t[i].replace(/['"]/g, "");
-1 != n.indexOf(" ") || /^\d/.test(n) ? e.push("'" + n + "'") :
e.push(n)
}
return e.join(",")
}
function C(t) {
return t.a + t.f
}
function S(t) {
var e = "normal";
return "o" === t.a ? e = "oblique" : "i" === t.a && (e = "italic"),
e
}
function A(t) {
var e = 4
, i = "n"
, n = null;
return t && ((n = t.match(/(normal|oblique|italic)/i)) && n[1] && (i =
n[1].substr(0, 1).toLowerCase()),
(n = t.match(/([1-9]00|normal|bold)/i)) && n[1] &&
(/bold/i.test(n[1]) ? e = 7 : /[1-9]00/.test(n[1]) && (e = parseInt(n[1].substr(0,
1), 10)))),
i + e
}
function k(t, e) {
this.c = t,
this.f = t.m.document.documentElement,
this.h = e,
this.a = new x("-"),
this.j = !1 !== e.events,
this.g = !1 !== e.classes
}
function E(t) {
t.g && u(t.f, [t.a.c("wf", "loading")]),
M(t, "loading")
}
function I(t) {
if (t.g) {
var e = d(t.f, t.a.c("wf", "active"))
, i = []
, n = [t.a.c("wf", "loading")];
e || i.push(t.a.c("wf", "inactive")),
u(t.f, i, n)
}
M(t, "inactive")
}
function M(t, e, i) {
t.j && t.h[e] && (i ? t.h[e](i.c, C(i)) : t.h[e]())
}
function O() {
this.c = {}
}
function B(t, e, i) {
var n, s = [];
for (n in e)
if (e.hasOwnProperty(n)) {
var o = t.c[n];
o && s.push(o(e[n], i))
}
return s
}
function R(t, e) {
this.c = t,
this.f = e,
this.a = h(this.c, "span", {
"aria-hidden": "true"
}, this.f)
}
function L(t) {
l(t.c, "body", t.a)
}
function D(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:" + T(t.c) + ";font-style:" + S(t) +
";font-weight:" + t.f + "00;"
}
function F(t, e, i, n, s, o) {
this.g = t,
this.j = e,
this.a = n,
this.c = i,
this.f = s || 3e3,
this.h = o || void 0
}
function N(t, e, i, n, s, o, r) {
this.v = t,
this.B = e,
this.c = i,
this.a = n,
this.s = r || "BESbswy",
this.f = {},
this.w = s || 3e3,
this.u = o || null,
this.o = this.j = this.h = this.g = null,
this.g = new R(this.c,this.s),
this.h = new R(this.c,this.s),
this.j = new R(this.c,this.s),
this.o = new R(this.c,this.s),
t = new _(this.a.c + ",serif",C(this.a)),
t = D(t),
this.g.a.style.cssText = t,
t = new _(this.a.c + ",sans-serif",C(this.a)),
t = D(t),
this.h.a.style.cssText = t,
t = new _("serif",C(this.a)),
t = D(t),
this.j.a.style.cssText = t,
t = new _("sans-serif",C(this.a)),
t = D(t),
this.o.a.style.cssText = t,
L(this.g),
L(this.h),
L(this.j),
L(this.o)
}
function G() {
if (null === lt) {
var t = /AppleWebKit\/([0-9]+)(?:\.([0-
9]+))/.exec(window.navigator.userAgent);
lt = !!t && (536 > parseInt(t[1], 10) || 536 === parseInt(t[1], 10)
&& 11 >= parseInt(t[2], 10))
}
return lt
}
function U(t, e, i) {
for (var n in ht)
if (ht.hasOwnProperty(n) && e === t.f[ht[n]] && i === t.f[ht[n]])
return !0;
return !1
}
function W(t) {
var e, i = t.g.a.offsetWidth, n = t.h.a.offsetWidth;
(e = i === t.f.serif && n === t.f["sans-serif"]) || (e = G() && U(t, i,
n)),
e ? rt() - t.A >= t.w ? G() && U(t, i, n) && (null === t.u ||
t.u.hasOwnProperty(t.a.c)) ? H(t, t.v) : H(t, t.B) : j(t) : H(t, t.v)
}
function j(t) {
setTimeout(r(function() {
W(this)
}, t), 50)
}
function H(t, e) {
setTimeout(r(function() {
c(this.g.a),
c(this.h.a),
c(this.j.a),
c(this.o.a),
e(this.a)
}, t), 0)
}
function X(t, e, i) {
this.c = t,
this.a = e,
this.f = 0,
this.o = this.j = !1,
this.s = i
}
function q(t) {
0 == --t.f && t.j && (t.o ? (t = t.a,
t.g && u(t.f, [t.a.c("wf", "active")], [t.a.c("wf", "loading"),
t.a.c("wf", "inactive")]),
M(t, "active")) : I(t.a))
}
function V(t) {
this.j = t,
this.a = new O,
this.h = 0,
this.f = this.g = !0
}
function Y(t, e, i, n, s) {
var o = 0 == --t.h;
(t.f || t.g) && setTimeout(function() {
var t = s || null
, a = n || null || {};
if (0 === i.length && o)
I(e.a);
else {
e.f += i.length,
o && (e.j = o);
var h, l = [];
for (h = 0; h < i.length; h++) {
var c = i[h]
, d = a[c.c]
, p = e.a
, f = c;
if (p.g && u(p.f, [p.a.c("wf", f.c, C(f).toString(),
"loading")]),
M(p, "fontloading", f),
p = null,
null === ct)
if (window.FontFace) {
var f = /Gecko.*Firefox\/
(\d+)/.exec(window.navigator.userAgent)
, m = /OS
X.*Version\/10\..*Safari/.exec(window.navigator.userAgent) &&
/Apple/.exec(window.navigator.vendor);
ct = f ? 42 < parseInt(f[1], 10) : !m
} else
ct = !1;
p = ct ? new F(r(e.g, e),r(e.h, e),e.c,c,e.s,d) : new
N(r(e.g, e),r(e.h, e),e.c,c,e.s,t,d),
l.push(p)
}
for (h = 0; h < l.length; h++)
l[h].start()
}
}, 0)
}
function z(t, e, i) {
var n = []
, s = i.timeout;
E(e);
var n = B(t.a, i, t.c)
, o = new X(t.c,e,s);
for (t.h = n.length,
e = 0,
i = n.length; e < i; e++)
n[e].load(function(e, i, n) {
Y(t, o, e, i, n)
})
}
function K(t, e) {
this.c = t,
this.a = e
}
function J(t, e, i) {
var n = p(t.c);
return t = (t.a.api || "fast.fonts.net/jsapi").replace(/^.*http(s?):
(\/\/)?/, ""),
n + "//" + t + "/" + e + ".js" + (i ? "?v=" + i : "")
}
function Z(t, e) {
this.c = t,
this.a = e
}
function Q(t, e, i) {
this.c = t || e + ut,
this.a = [],
this.f = [],
this.g = i || ""
}
function $(t, e) {
for (var i = e.length, n = 0; n < i; n++) {
var s = e[n].split(":");
3 == s.length && t.f.push(s.pop());
var o = "";
2 == s.length && "" != s[1] && (o = ":"),
t.a.push(s.join(o))
}
}
function tt(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 = [], n = 0; n < e; n++)
i.push(t.a[n].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
}
function et(t) {
this.f = t,
this.a = [],
this.c = {}
}
function it(t) {
for (var e = t.f.length, i = 0; i < e; i++) {
var n = t.f[i].split(":")
, s = n[0].replace(/\+/g, " ")
, o = ["n4"];
if (2 <= n.length) {
var r, a = n[1];
if (r = [],
a)
for (var a = a.split(","), h = a.length, l = 0; l < h; l++)
{
var c;
if (c = a[l],
c.match(/^[\w-]+$/)) {
var u = mt.exec(c.toLowerCase());
if (null == u)
c = "";
else {
if (c = u[2],
c = null == c || "" == c ? "n" : ft[c],
null == (u = u[1]) || "" == u)
u = "4";
else
var d = pt[u]
, u = d || (isNaN(u) ? "4" : u.substr(0,
1));
c = [c, u].join("")
}
} else
c = "";
c && r.push(c)
}
0 < r.length && (o = r),
3 == n.length && (n = n[2],
r = [],
n = n ? n.split(",") : r,
0 < n.length && (n = dt[n[0]]) && (t.c[s] = n))
}
for (t.c[s] || (n = dt[s]) && (t.c[s] = n),
n = 0; n < o.length; n += 1)
t.a.push(new _(s,o[n]))
}
}
function nt(t, e) {
this.c = t,
this.a = e
}
function st(t, e) {
this.c = t,
this.a = e
}
function ot(t, e) {
this.c = t,
this.f = e,
this.a = []
}
var rt = Date.now || function() {
return +new Date
}
, at = !!window.FontFace;
x.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)
}
,
F.prototype.start = function() {
var t = this.c.m.document
, e = this
, i = rt()
, n = new Promise(function(n, s) {
function o() {
rt() - i >= e.f ? s() : t.fonts.load(P(e.a),
e.h).then(function(t) {
1 <= t.length ? n() : setTimeout(o, 25)
}, function() {
s()
})
}
o()
}
)
, s = new Promise(function(t, i) {
setTimeout(i, e.f)
}
);
Promise.race([s, n]).then(function() {
e.g(e.a)
}, function() {
e.j(e.a)
})
}
;
var ht = {
D: "serif",
C: "sans-serif"
}
, lt = null;
N.prototype.start = function() {
this.f.serif = this.j.a.offsetWidth,
this.f["sans-serif"] = this.o.a.offsetWidth,
this.A = rt(),
W(this)
}
;
var ct = null;
X.prototype.g = function(t) {
var e = this.a;
e.g && u(e.f, [e.a.c("wf", t.c, C(t).toString(), "active")],
[e.a.c("wf", t.c, C(t).toString(), "loading"), e.a.c("wf", t.c, C(t).toString(),
"inactive")]),
M(e, "fontactive", t),
this.o = !0,
q(this)
}
,
X.prototype.h = function(t) {
var e = this.a;
if (e.g) {
var i = d(e.f, e.a.c("wf", t.c, C(t).toString(), "active"))
, n = []
, s = [e.a.c("wf", t.c, C(t).toString(), "loading")];
i || n.push(e.a.c("wf", t.c, C(t).toString(), "inactive")),
u(e.f, n, s)
}
M(e, "fontinactive", t),
q(this)
}
,
V.prototype.load = function(t) {
this.c = new a(this.j,t.context || this.j),
this.g = !1 !== t.events,
this.f = !1 !== t.classes,
z(this, new k(this.c,t), t)
}
,
K.prototype.load = function(t) {
function e() {
if (o["__mti_fntLst" + n]) {
var i, s = o["__mti_fntLst" + n](), r = [];
if (s)
for (var a = 0; a < s.length; a++) {
var h = s[a].fontfamily;
void 0 != s[a].fontStyle && void 0 != s[a].fontWeight ?
(i = s[a].fontStyle + s[a].fontWeight,
r.push(new _(h,i))) : r.push(new _(h))
}
t(r)
} else
setTimeout(function() {
e()
}, 50)
}
var i = this
, n = i.a.projectId
, s = i.a.version;
if (n) {
var o = i.c.m;
g(this.c, J(i, n, s), function(s) {
s ? t([]) : (o["__MonotypeConfiguration__" + n] = function() {
return i.a
}
,
e())
}).id = "__MonotypeAPIScript__" + n
} else
t([])
}
,
Z.prototype.load = function(t) {
var e, i, n = this.a.urls || [], s = this.a.families || [], o =
this.a.testStrings || {}, r = new y;
for (e = 0,
i = n.length; e < i; e++)
m(this.c, n[e], v(r));
var a = [];
for (e = 0,
i = s.length; e < i; e++)
if (n = s[e].split(":"),
n[1])
for (var h = n[1].split(","), l = 0; l < h.length; l += 1)
a.push(new _(n[0],h[l]));
else
a.push(new _(n[0]));
b(r, function() {
t(a, o)
})
}
;
var ut = "//fonts.googleapis.com/css"
, dt = {
latin: "BESbswy",
"latin-ext": "cougs",
cyrillic: "???",
greek: "???",
khmer: "???",
Hanuman: "???"
}
, pt = {
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"
}
, ft = {
i: "i",
italic: "i",
n: "n",
normal: "n"
}
, mt = /^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:
(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/
, gt = {
Arimo: !0,
Cousine: !0,
Tinos: !0
};
nt.prototype.load = function(t) {
var e = new y
, i = this.c
, n = new Q(this.a.api,p(i),this.a.text)
, s = this.a.families;
$(n, s);
var o = new et(s);
it(o),
m(i, tt(n), v(e)),
b(e, function() {
t(o.a, o.c, gt)
})
}
,
st.prototype.load = function(t) {
var e = this.a.id
, i = this.c.m;
e ? g(this.c, (this.a.api || "https://use.typekit.net") + "/" + e +
".js", function(e) {
if (e)
t([]);
else if (i.Typekit && i.Typekit.config && i.Typekit.config.fn) {
e = i.Typekit.config.fn;
for (var n = [], s = 0; s < e.length; s += 2)
for (var o = e[s], r = e[s + 1], a = 0; a < r.length; a++)
n.push(new _(o,r[a]));
try {
i.Typekit.load({
events: !1,
classes: !1,
async: !0
})
} catch (t) {}
t(n)
}
}, 2e3) : t([])
}
,
ot.prototype.load = function(t) {
var e = this.f.id
, i = this.c.m
, n = this;
e ? (i.__webfontfontdeckmodule__ || (i.__webfontfontdeckmodule__ = {}),
i.__webfontfontdeckmodule__[e] = function(e, i) {
for (var s = 0, o = i.fonts.length; s < o; ++s) {
var r = i.fonts[s];
n.a.push(new _(r.name,A("font-weight:" + r.weight + ";font-
style:" + r.style)))
}
t(n.a)
}
,
g(this.c, p(this.c) + (this.f.api || "//f.fontdeck.com/s/css/js/") +
f(this.c) + "/" + e + ".js", function(e) {
e && t([])
})) : t([])
}
;
var yt = new V(window);
yt.a.c.custom = function(t, e) {
return new Z(e,t)
}
,
yt.a.c.fontdeck = function(t, e) {
return new ot(e,t)
}
,
yt.a.c.monotype = function(t, e) {
return new K(e,t)
}
,
yt.a.c.typekit = function(t, e) {
return new st(e,t)
}
,
yt.a.c.google = function(t, e) {
return new nt(e,t)
}
;
var vt = {
load: r(yt.load, yt)
};
void 0 !== (n = function() {
return vt
}
.call(e, i, e, t)) && (t.exports = n)
}()
}
, function(t, e) {
(function(e) {
t.exports = e
}
).call(e, {})
}
, function(t, e) {
var i;
i = function() {
return this
}();
try {
i = i || Function("return this")() || (0,
eval)("this")
} catch (t) {
"object" == typeof window && (i = window)
}
t.exports = i
}
, function(t, e) {
t.exports = function(t) {
return t.webpackPolyfill || (t.deprecate = function() {}
,
t.paths = [],
t.children || (t.children = []),
Object.defineProperty(t, "loaded", {
enumerable: !0,
get: function() {
return t.l
}
}),
Object.defineProperty(t, "id", {
enumerable: !0,
get: function() {
return t.i
}
}),
t.webpackPolyfill = 1),
t
}
}
, function(t, e) {
t.exports = {
server: {
ws_port: 5e3,
port: 80,
host: "127.0.0.1",
connections_limit: 100,
daytime_speed: .01666667
},
bounds: {
x: 256,
y: 256,
width: 25088,
height: 25088
},
client: {
build_radius: 400
},
player: {
speed: 250,
health: 100,
damage: 30,
attack_distance: 60,
punch_timeout: .5,
punch_move_lock: .3,
radius: 30,
reward_for_punch: 1,
reward_for_building: 3,
reward_for_killing: 10
},
bosses: {
whitewalker: {
damage: 70,
attack_distance: 60,
search_radius: 800,
health: 700,
radius: 45,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Heartstone"],
building_damage_multiplier: 10,
chase_distance: 800,
speed: 230,
death_spawn: {
day: {
CowboyHat: .05,
HockeyHat: .01
},
night: {
VikingHat: .05
}
},
drop: {
gold: 500
},
drop_entity_type: "CoinPickup"
},
nightmare: {
attack_distance: 500,
search_radius: 1500,
health: 1e3,
radius: 70,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Mannequin"],
chase_distance: 1e3,
speed: 200,
drop: {
food: 300
},
drop_entity_type: "BearMeatPickup"
}
},
bullets: {
fireball: {
radius: 30,
lifetime: 5,
speed: 500,
damage: 5e3
}
},
pickups: {
egg: {
lifetime: 120,
radius: 15
},
box: {
lifetime: 120,
radius: 32
},
meat: {
lifetime: 120,
radius: 15
},
carrot: {
radius: 15
},
coin: {
radius: 15
},
soul: {
radius: 15
}
},
animals: {
pig: {
health: 100,
radius: 30,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
scare_timeout: 5,
walk_timeout: 7,
walk_speed: 150,
run_speed: 270,
death_spawn: {
day: {
ChessHat: .05,
BuilderHat: .01
},
night: {
BuilderHat: .05
}
},
drop: {
food: 5
},
drop_entity_type: "PigMeatPickup"
},
chicken: {
health: 50,
radius: 20,
walk_speed: 150,
run_speed: 270,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
scare_timeout: 5,
walk_timeout: 7,
death_spawn: {
day: {
ChickenHat: .05,
BuilderHat: .01
},
night: {
ChickenHat: .01,
FoxHat: .05
}
},
drop: {
food: 3
},
drop_entity_type: "EggPickup",
drop_timeout: 40
},
wolf: {
punch_move_lock: 1.5,
attack_distance: 80,
search_radius: 400,
punch_timeout: 2,
damage: 30,
health: 100,
radius: 30,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Pig", "Mannequin"],
chase_distance: 500,
walk_speed: 150,
run_speed: 260,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
scare_timeout: 5,
walk_timeout: 7,
death_spawn: {
day: {
CowboyHat: .01
},
night: {
VikingHat: .02
}
},
drop: {
food: 7
},
drop_entity_type: "PigMeatPickup"
},
bear: {
punch_move_lock: 1,
attack_distance: 80,
search_radius: 250,
punch_timeout: 1.5,
damage: 49,
health: 500,
radius: 70,
building_damage_multiplier: 10,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Pig", "Mannequin", "WoodSpikes"],
chase_distance: 600,
walk_speed: 150,
run_speed: 230,
walk_radius: 450,
idle_timeout_min: 5,
idle_timeout_max: 7,
scare_timeout: 5,
walk_timeout: 7,
death_spawn: {
day: {
BrownBearHat: .05,
HockeyHat: .01
},
night: {
HockeyHat: .02
}
},
drop: {
food: 150
},
drop_entity_type: "BearMeatPickup"
},
whitebear: {
punch_move_lock: 1,
attack_distance: 80,
search_radius: 250,
punch_timeout: 1.5,
damage: 80,
health: 1e3,
radius: 70,
building_damage_multiplier: 10,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Mannequin", "WoodSpikes"],
chase_distance: 600,
walk_speed: 150,
run_speed: 230,
walk_radius: 450,
idle_timeout_min: 5,
idle_timeout_max: 7,
scare_timeout: 5,
walk_timeout: 7,
drop: {
food: 300
},
death_spawn: {
day: {
WhiteBearHat: .05,
HockeyHat: .01
},
night: {
HockeyHat: .02
}
},
drop_entity_type: "BearMeatPickup"
},
rideable_pig: {
radius: 30,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
walk_timeout: 7,
walk_speed: 150,
run_speed: 270,
driver_speed: 300
}
},
hatpickups: {
whitebearhat: {
radius: 24,
lifetime: 60
},
brownbearhat: {
radius: 24,
lifetime: 60
},
chesshat: {
radius: 24,
lifetime: 60
},
cowboyhat: {
radius: 24,
lifetime: 60
},
hiddenhat: {
radius: 24,
lifetime: 60
},
cathat: {
radius: 24,
lifetime: 60
},
chickenhat: {
radius: 24,
lifetime: 60
},
foxhat: {
radius: 24,
lifetime: 60
},
builderhat: {
radius: 24,
lifetime: 60
},
vikinghat: {
radius: 24,
lifetime: 60
},
hockeyhat: {
radius: 24,
lifetime: 60
}
},
worldbuildings: {
winterwall: {
width: 64,
height: 64
},
winterfloor: {
width: 64,
height: 64
},
wintertower: {
radius: 64
}
},
buildings: {
woodgenerator: {
radius: 65
},
stonegenerator: {
radius: 45
},
woodblock: {
price: {
wood: 25
},
name: "Wooden Wall",
description: "Strong wooden wall.",
health: 1e3,
width: 64,
height: 64,
limit: 60,
drop: {
wood: 10
}
},
stoneblock: {
price: {
stone: 50
},
name: "Stone Wall",
description: "Very strong stone wall.",
health: 2e3,
width: 64,
height: 64,
limit: 60,
drop: {
stone: 10
}
},
darkstoneblock: {
price: {
stone: 150,
gold: 150
},
name: "Dark Wall",
description: "Very strong dark wall.",
health: 4e3,
width: 64,
height: 64,
limit: 60,
drop: {
stone: 75,
gold: 75
}
},
door: {
price: {
wood: 25,
stone: 50
},
name: "Door",
limit: 10,
description: "Opens only for you and your clan.",
health: 2e3,
width: 64,
height: 64,
drop: {
wood: 10,
stone: 20
}
},
darkdoor: {
price: {
wood: 150,
stone: 150,
gold: 300
},
name: "Dark Door",
limit: 10,
description: "Opens only for you and your clan.",
health: 4e3,
width: 64,
height: 64,
drop: {
wood: 75,
stone: 75,
gold: 75
}
},
farmerbot: {
attack_distance: 60,
punch_timeout: 2,
radius: 30,
search_radius: 600,
target_types: ["WoodGenerator", "StoneGenerator",
"WinterWoodGenerator", "WinterStoneGenerator"],
speed: 200,
price: {
food: 12
},
name: "Peasant",
limit: 2,
reward_for_punch: 2,
description: "Gather the nearest resource available.",
health: 80
},
gardenbot: {
radius: 30,
search_radius: 800,
target_types: ["CarrotPickup"],
speed: 200,
price: {
food: 50,
gold: 250
},
name: "Gardener",
limit: 2,
description: "Gather carrots from gardens.",
health: 80
},
woodspikes: {
price: {
wood: 100,
gold: 50
},
health: 1000,
name: "Wooden Spikes",
limit: 60,
width: 64,
height: 64,
damage: 10,
mirror_value: .3,
description: "Spikes damage your enemies!"
},
portal: {
price: {
stone: 300,
gold: 500
},
health: 500,
name: "Portal",
limit: 2,
width: 64,
height: 64,
description: "Teleport you!",
drop: {
stone: 100,
gold: 100
}
},
garden: {
price: {
food: 20
},
health: 300,
name: "Bed",
limit: 50,
width: 128,
height: 128,
subtile: !0,
description: "You can grow carrots on a bed!",
drop: {
food: 20
},
drop_entity_type: "CarrotPickup",
drop_timeout: 10
},
guardbot: {
punch_timeout: 1,
radius: 40,
search_radius: 600,
speed: 250,
price: {
food: 40
},
damage: 30,
name: "Guard",
limit: 3,
description: "Defends the area you place him on.",
reward_for_punch: 3,
health: 200,
target_types: ["Player", "GuardBot", "DarkGuardBot", "FollowerBot",
"Wolf", "Bear", "WhiteBear", "Mannequin", "WhiteWalker"]
},
darkguardbot: {
punch_timeout: 1,
radius: 30,
search_radius: 600,
speed: 210,
price: {
food: 300,
gold: 600
},
damage: 50,
name: "Dark Guard",
limit: 3,
description: "Defends the area you place him on.",
reward_for_punch: 3,
health: 500,
target_types: ["Player", "FarmerBot", "GuardBot", "DarkGuardBot",
"FollowerBot", "Wolf", "Bear", "WhiteBear", "Mannequin", "WhiteWalker"]
},
followerbot: {
punch_timeout: 1.5,
radius: 30,
search_radius: 400,
speed: 250,
price: {
food: 15
},
damage: 50,
name: "Mercenary",
reward_for_punch: 3,
limit: 5,
description: "Follows you wherever you go and helps in
everything!",
health: 200,
target_types: ["Player", "GuardBot", "DarkGuardBot", "FollowerBot",
"Wolf", "Bear", "WhiteBear", "WhiteWalker"]
},
mannequin: {
price: {
food: 100,
gold: 500
},
name: "Mannequin",
description: "Used for training",
limit: 1,
health: 80,
width: 64,
height: 64,
additional_punch_reward: 5
},
foodcrate: {
allow_reward: !1,
price: {
food: 100
},
name: "Food Container",
description: "Food container",
limit: 10,
health: 10,
width: 64,
height: 64,
drop: {
food: 100
},
disable_builder_hat: !0
},
woodcrate: {
allow_reward: !1,
price: {
wood: 100
},
name: "Wood Container",
description: "Wood container",
limit: 10,
health: 10,
width: 64,
height: 64,
drop: {
wood: 100
},
disable_builder_hat: !0
},
stonecrate: {
allow_reward: !1,
price: {
stone: 100
},
name: "Stone Container",
description: "Stone container",
limit: 10,
health: 10,
width: 64,
height: 64,
drop: {
stone: 100
},
disable_builder_hat: !0
},
soulcrate: {
allow_reward: !1,
price: {
soul: 100
},
name: "Souls Container",
description: "Souls container",
limit: 5,
health: 10,
width: 64,
height: 64,
drop: {
soul: 100
},
disable_builder_hat: !0
},
heartstone: {
price: {
food: 50,
gold: 100
},
name: "The Stone of Life",
limit: 1,
width: 64,
height: 64,
description: "Resurrects you after your death. Make sure it is not
destroyed!",
health: 500,
drop: {
food: 25,
gold: 100
}
},
tower: {
price: {
wood: 40,
stone: 40
},
name: "Tower",
limit: 5,
radius: 64,
description: "The tower produces gold, making you richer!",
health: 300,
resource_count: 5,
drop: {
wood: 20,
stone: 20
}
},
rideablewolf: {
price: {
food: 1e3,
gold: 1e4
},
radius: 32,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
walk_timeout: 7,
walk_speed: 150,
run_speed: 270,
driver_speed: 320,
driver_regeneration_speed: .5,
name: "Black Wolf",
description: "You can ride on it and regenerate faster!",
limit: 1
},
rideablebear: {
price: {
food: 5e3,
gold: 1e4
},
radius: 32,
walk_radius: 650,
idle_timeout_min: 3,
idle_timeout_max: 6,
walk_timeout: 7,
walk_speed: 150,
run_speed: 260,
driver_speed: 320,
driver_regeneration_speed: .5,
driver_buildings_damage_multiplier: 3,
driver_damage_multiplier: 1.1,
name: "Black Bear",
description: "You can ride on it and be more powerful!",
limit: 1
},
soccerball: {
price: {
gold: 500
},
radius: 28,
name: "Ball",
description: "For football fans",
limit: 1
}
}
}
}
, function(t, e) {
var i = function(t) {
return Array.from(t)
};
t.exports = i
}
, function(t, e, i) {
t.exports = i(37)
}
]);

Potrebbero piacerti anche