function ImagesPreloader() {
function e() {
var n = 0,
r = 0,
i;
for (i in t.loadedImages) t.loadedImages[i].complete && n++, r++;
n >= r ? t.endCallback && t.endCallback(t.loadedImages) : (t.processCallback && t.processCallback(Math.floor(n / r * 100)), setTimeout(e, 50))
}
var t = this;
this.curItem = -1;
this.loadedImages = {};
this.processCallback = this.endCallback = this.data = null;
this.load = function(t, n, r) {
this.data = t;
this.endCallback = n;
this.processCallback = r;
for (t = 0; t < this.data.length; t++) n = this.data[t], r = new Image, r.src = n.src, this.loadedImages[n.name] = r;
e()
}
}
function Sprite(e, t, n, r, i) {
this.uid = 0;
this.stage = null;
this.y = this.x = 0;
this.width = t;
this.height = n;
this.offset = {
left: 0,
top: 0
};
this.anchor = {
x: 0,
y: 0
};
this.scaleY = this.scaleX = 1;
this.zIndex = this.rotation = 0;
this.visible = !0;
this.opacity = 1;
this.ignoreViewport = this["static"] = !1;
this.animated = !0;
this.currentFrame = 0;
this.totalFrames = Math.max(1, ~~r);
1 >= this.totalFrames && (this.animated = !1);
this.currentLayer = 0;
this.totalLayers = Math.max(1, ~~i);
this.bitmap = e;
this.mask = null;
this.destroy = this.fillColor = !1;
this.animStep = 0;
this.animDelay = 1;
this.dragged = this.drawAlways = !1;
this.dragY = this.dragX = 0;
this.getX = function() {
return Math.round(this.x * Utils.globalScale)
};
this.getY = function() {
return Math.round(this.y * Utils.globalScale)
};
this.getWidth = function() {
return this.width * Math.abs(this.scaleX) * Utils.globalScale
};
this.getHeight = function() {
return this.height * Math.abs(this.scaleY) * Utils.globalScale
};
this.startDrag = function(e, t) {
this.dragged = !0;
this.dragX = e;
this.dragY = t
};
this.stopDrag = function() {
this.dragged = !1;
this.dragY = this.dragX = 0
};
this.play = function() {
this.animated = !0
};
this.stop = function() {
this.animated = !1
};
this.gotoAndStop = function(e) {
this.currentFrame = e;
this.stop()
};
this.gotoAndPlay = function(e) {
this.currentFrame = e;
this.play()
};
this.removeTweens = function() {
this.stage && this.stage.clearObjectTweens(this)
};
this.addTween = function(e, t, n, r, i, s) {
if (this.stage) {
var o = this[e];
if (!isNaN(o)) return e = stage.createTween(this, e, o, t, n, r), e.onchange = s, e.onfinish = i, e
}
};
this.moveTo = function(e, t, n, r, i, s) {
n = ~~n;
0 >= n ? this.setPosition(e, t) : ((e = this.addTween("x", e, n, r, i, s)) && e.play(), (t = this.addTween("y", t, n, r, e ? null : i, e ? null : s)) && t.play());
return this
};
this.moveBy = function(e, t, n, r, i, s) {
return this.moveTo(this.x + e, this.y + t, n, r, i, s)
};
this.fadeTo = function(e, t, n, r, i) {
t = ~~t;
0 >= t ? this.opacity = e : (e = this.addTween("opacity", e, t, n, r, i)) && e.play();
return this
};
this.fadeBy = function(e, t, n, r, i) {
e = Math.max(0, Math.min(1, this.opacity + e));
return this.fadeTo(e, t, n, r, i)
};
this.rotateTo = function(e, t, n, r, i) {
t = ~~t;
0 >= t ? this.rotation = e : (e = this.addTween("rotation", e, t, n, r, i)) && e.play();
return this
};
this.rotateBy = function(e, t, n, r, i) {
return this.rotateTo(this.rotation + e, t, n, r, i)
};
this.scaleTo = function(e, t, n, r, i) {
t = ~~t;
if (0 >= t) this.scaleX = this.scaleY = e;
else {
var s = this.addTween("scaleX", e, t, n, r, i);
s && s.play();
(e = this.addTween("scaleY", e, t, n, s ? null : r, s ? null : i)) && e.play()
}
return this
};
this.nextFrame = function() {
this.dispatchEvent("enterframe", {
target: this
});
this.animated && (this.animStep++, this.animStep >= this.animDelay && (this.currentFrame++, this.animStep = 0), this.currentFrame >= this.totalFrames && (this.currentFrame = 0))
};
this.eventsWhenInvisible = !1;
this.onbox2dsync = this.onremove = this.onadd = this.onrender = this.onprerender = this.onenterframe = this.onmousemove = this.oncontextmenu = this.onclick = this.onmouseup = this.onmousedown = this.onmouseout = this.onmouseover = null;
this.mouseOn = !1;
this.getPosition = function() {
return {
x: this.x,
y: this.y
}
};
this.setPosition = function(e, t) {
if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setPosition(e.x, e.y);
this.x = parseFloat(e);
this.y = parseFloat(t)
};
this.getAnchor = function() {
return this.anchor
};
this.setAnchor = function(e, t) {
if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setAnchor(e.x, e.y);
this.anchor.x = parseFloat(e);
this.anchor.y = parseFloat(t)
};
this.alignAnchor = function(e, t) {
e = parseInt(e);
isNaN(e) && (e = ANCHOR_ALIGN_CENTER);
0 > e && (e = ANCHOR_ALIGN_LEFT);
0 < e && (e = ANCHOR_ALIGN_RIGHT);
t = parseInt(t);
isNaN(t) && (t = ANCHOR_VALIGN_MIDDLE);
0 > t && (t = ANCHOR_VALIGN_TOP);
0 < t && (t = ANCHOR_VALIGN_BOTTOM);
this.anchor.x = this.width * e / 2;
this.anchor.y = this.height * t / 2;
return this.getAnchor()
};
this.getAbsoluteAnchor = function() {
return this.getPosition()
};
this.getRelativeCenter = function() {
var e = this.getAnchor();
if (0 == e.x && 0 == e.y) return e;
e = new Vector(-e.x * this.scaleX, -e.y * this.scaleY);
e.rotate(-this.rotation);
return e
};
this.getAbsoluteCenter = function() {
var e = this.getRelativeCenter(),
e = {
x: e.x,
y: e.y
};
e.x += this.x;
e.y += this.y;
return e
};
this.getCenter = function() {
return this.getAbsoluteCenter()
};
this.getDrawRectangle = function() {
var e = this.getCenter(),
t = new Rectangle(0, 0, this.width * Math.abs(this.scaleX), this.height * Math.abs(this.scaleY), this.rotation);
t.move(e.x, e.y);
return t
};
this.getAABBRectangle = function() {
var e = this.getDrawRectangle(),
t = e.AABB[1].x - e.AABB[0].x,
n = e.AABB[1].y - e.AABB[0].y;
return new Rectangle(e.AABB[0].x + t / 2, e.AABB[0].y + n / 2, t, n, 0)
};
this.localToGlobal = function(e, t) {
var n = "object" == typeof e && "undefined" != typeof e.x && "undefined" != typeof e.y ? new Vector(e.x + 0, e.y + 0) : new Vector(e, t);
n.rotate(this.rotation).add(this.getPosition());
return n
};
this.globalToLocal = function(e, t) {
var n = "object" == typeof e && "undefined" != typeof e.x && "undefined" != typeof e.y ? new Vector(e.x + 0, e.y + 0) : new Vector(e, t);
n.subtract(this.getPosition()).rotate(-this.rotation);
return n
};
this.allowDebugDrawing = !0;
this.debugDraw = function() {
if (this.visible && this.allowDebugDrawing) {
var e = this.getPosition(),
t = this.getCenter(),
n = this.getDrawRectangle(),
r = this.getAABBRectangle();
stage.drawCircle(e.x, e.y, 1, 1, "rgba(255,0,0,0.9)");
stage.drawCircle(t.x, t.y, 1, 1, "rgba(0,255,0,0.9)");
stage.drawLine(e.x, e.y, t.x, t.y, 1, "rgba(255,255,255,0.5)");
stage.drawPolygon(n.vertices, .5, "rgba(255,0,255,0.5)", 1);
stage.drawLine(r.vertices[0].x, r.vertices[0].y, r.vertices[2].x, r.vertices[2].y, .1, "rgba(255,255,255,0.5)");
stage.drawLine(r.vertices[2].x, r.vertices[0].y, r.vertices[0].x, r.vertices[2].y, .1, "rgba(255,255,255,0.5)");
stage.drawPolygon(r.vertices, .5, "rgba(255,255,255,0.5)")
}
};
this.setZIndex = function(e) {
this.zIndex = ~~e;
this.stage && this.stage.setZIndex(this, ~~e)
};
this.eventsListeners = [];
this.addEventListener = function(e, t) {
EventsManager.addEvent(this, e, t)
};
this.removeEventListener = function(e, t) {
EventsManager.removeEvent(this, e, t)
};
this.dispatchEvent = function(e, t) {
return EventsManager.dispatchEvent(this, e, t)
};
this.hitTestPoint = function(e, t, n, r, i) {
return this.stage ? this.stage.hitTestPointObject(this, e, t, n, r, i) : !1
}
}
function Tween(e, t, n, r, i, s) {
var o = this;
"object" != typeof e && (e = null);
if (e) {
if ("undefined" == typeof e[t]) throw Error('Trying to tween undefined property "' + t + '"');
if (isNaN(e[t])) throw Error("Tweened value can not be " + typeof e[t])
} else if (isNaN(t)) throw Error("Tweened value can not be " + typeof t);
"function" != typeof s && (s = Easing.linear.easeIn);
this.obj = e;
this.prop = t;
this.onfinish = this.onchange = null;
this.start = n;
this.end = r;
this.duration = ~~i;
this.callback = s;
this.playing = !1;
this._pos = -1;
this.play = function() {
o.playing = !0;
o.tick()
};
this.pause = function() {
o.playing = !1
};
this.rewind = function() {
o._pos = -1
};
this.forward = function() {
o._pos = this.duration
};
this.stop = function() {
o.rewind();
o.tick();
o.pause()
};
this.updateValue = function(e) {
o.obj ? o.obj[o.prop] = e : o.prop = e
};
this.tick = function() {
if (!o.playing) return !1;
o._pos++;
if (0 > o._pos) return !1;
if (o._pos > o.duration) return o.finish();
var e = o.callback,
e = e(o._pos, o.start, o.end - o.start, o.duration);
this.updateValue(e);
o.dispatchEvent("change", {
target: o,
value: e
});
return !1
};
this.finish = function() {
o.stop();
o.updateValue(o.end);
return o.dispatchEvent("finish", {
target: o,
value: o.end
})
};
this.eventsListeners = [];
this.addEventListener = function(e, t) {
EventsManager.addEvent(this, e, t)
};
this.removeEventListener = function(e, t) {
EventsManager.removeEvent(this, e, t)
};
this.dispatchEvent = function(e, t) {
return EventsManager.dispatchEvent(this, e, t)
}
}
function StageTimer(a, c, d) {
this.repeat = d;
this.timeout = this.initialTimeout = c;
this.callback = a;
this.paused = !1;
this.update = function() {
if (!this.paused) {
this.timeout--;
if (0 >= this.timeout)
if ("function" == typeof this.callback && this.callback(), "string" == typeof this.callback && eval(this.callback), this.repeat) this.timeout = this.initialTimeout;
else return !0;
return !1
}
};
this.resume = function() {
this.paused = !1
};
this.pause = function() {
this.paused = !0
}
}
function Stage(e, t, n) {
function r() {
s.lastFPS = s.fps;
s.fps = 0;
s.started && (s.tmFPS = setTimeout(r, 1e3))
}
function i() {
clearTimeout(s.tmMain);
var e = (new Date).getTime();
s.updateTweens();
s.updateTimers();
s.dispatchEvent("pretick");
s.drawScene(s.canvas, !1);
s.showFPS && (s.setTextStyle("sans-serif", 10, "bold", "#fff", "#000"), s.drawText("FPS: " + s.lastFPS, 2, 10, 1, !0));
s.dispatchEvent("posttick");
e = (new Date).getTime() - e;
e = s.delay - e - 1;
1 > e && (e = 1);
s.fps++;
s.started && (s.tmMain = setTimeout(i, e))
}
var s = this;
this.canvas = null;
e && (this.canvas = document.getElementById(e), this.canvas.ctx = this.canvas.getContext("2d"));
this.backBuffer = null;
this.screenWidth = t;
this.screenHeight = n;
this.viewport = {
x: 0,
y: 0
};
this.objects = [];
this.objectsCounter = 0;
try {
this.buffer = document.createElement("canvas"), this.buffer.width = t * Utils.globalScale, this.buffer.height = n * Utils.globalScale, this.buffer.ctx = this.buffer.getContext("2d")
} catch (o) {
this.buffer = this.canvas
}
this.delay = 40;
this.started = this.fillColor = !1;
this.lastFPS = this.fps = 0;
this.ceilSizes = this.pixelMouseMoveEvent = this.pixelMouseDownEvent = this.pixelMouseUpEvent = this.pixelClickEvent = this.showFPS = !1;
this.tmMain;
this.tmFPS;
this.clearLock = !1;
this.destroy = function() {
clearTimeout(this.tmMain);
clearTimeout(this.tmFPS);
this.stop();
this.clear();
this.clearScreen(this.canvas)
};
this.clearScreen = function(e) {
this.clearLock || e.ctx.clearRect(0, 0, this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.screenHeight * Utils.globalScale * Utils.globalPixelScale)
};
this.findMaxZIndex = function() {
for (var e = -1, t = !1, n = 0; n < this.objects.length; n++) this.objects[n].zIndex > e && (e = this.objects[n].zIndex, t = n);
return {
index: t,
zIndex: e
}
};
this.findMinZIndex = function() {
for (var e = -1, t = !1, n = 0; n < this.objects.length; n++) 0 == n && (e = this.objects[n].zIndex, t = 0), this.objects[n].zIndex < e && (e = this.objects[n].zIndex, t = n);
return {
index: t,
zIndex: e
}
};
this.addChild = function(e) {
var t = this.findMaxZIndex(),
n = e.zIndex;
e.zIndex = !1 !== t.index ? t.zIndex + 1 : 0;
this.objectsCounter++;
e.uid = this.objectsCounter;
e.stage = this;
this.objects.push(e);
0 != n && this.setZIndex(e, ~~n);
e.dispatchEvent("add", {
target: e
});
return e
};
this.removeChild = function(e) {
e && (this.clearObjectTweens(e), e.dispatchEvent("remove", {
target: e
}), e.stage = null, this.objects = Utils.removeFromArray(this.objects, e))
};
this.setZIndex = function(e, t) {
e.zIndex = t;
this.objects = this.objects.sort(function(e, t) {
return e.zIndex == t.zIndex ? e.uid > t.uid ? 1 : -1 : e.zIndex > t.zIndex ? 1 : -1
})
};
this.hitTestPointObject = function(e, t, n, r, i, s) {
var o, u, a, f, l, c;
a = e.width * Math.abs(e.scaleX);
f = e.height * Math.abs(e.scaleY);
o = e.x - a / 2;
u = e.y - f / 2;
l = t;
c = n;
e.ignoreViewport || (l += this.viewport.x, c += this.viewport.y);
s = !1;
0 == e.rotation ? o <= l && u <= c && o + a >= l && u + f >= c && (s = !0) : (o = e.getDrawRectangle(), o.hitTestPoint(new Vector(l, c)) && (s = !0));
s && r && (this.buffer.width = this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.buffer.height = this.screenHeight * Utils.globalScale * Utils.globalPixelScale, this.clearScreen(this.buffer), this.renderObject(this.buffer, e), t = this.buffer.ctx.getImageData(Math.floor(t * Utils.globalScale * Utils.globalPixelScale), Math.floor(n * Utils.globalScale * Utils.globalPixelScale), 1, 1), 0 == t.data[3] && (s = !1));
!s && i && e.dragged && (s = !0);
return s
};
this.getObjectsStackByCoord = function(e, t, n, r, i) {
for (var s, o = [], u = 0; u < this.objects.length; u++)
if (this.objects[u].visible || this.objects[u].eventsWhenInvisible) s = this.objects[u], this.hitTestPointObject(s, e, t, n, r, i) && o.push(s);
return o
};
this.getMaxZIndexInStack = function(e) {
for (var t = -1, n = 0, r = 0; r < e.length; r++) e[r].zIndex > t && (t = e[r].zIndex, n = r);
return n
};
this.sortStack = function(e, t) {
for (var n = !0, r, i; n;)
for (n = !1, i = 0; i < e.length - 1; i++) r = !1, e[i].zIndex < e[i + 1].zIndex && !t && (r = !0), e[i].zIndex > e[i + 1].zIndex && t && (r = !0), r && (n = e[i], e[i] = e[i + 1], e[i + 1] = n, n = !0);
return e
};
this.finalizeMouseCoords = function(e, t) {
if (!e) return t;
var n = this.prepareMouseCoord(t.x),
r = this.prepareMouseCoord(t.y);
e.ignoreViewport || (n += this.viewport.x, r += this.viewport.y);
n -= e.x;
r -= e.y;
return {
x: n,
y: r
}
};
this.prepareMouseCoord = function(e) {
return e / Utils.globalScale / Utils.globalPixelScale
};
this.checkClick = function(e) {
e = Utils.getMouseCoord(e, this.inputController);
var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent, !1, !0),
n;
if (0 < t.length)
for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("click", {
target: t[r],
x: n.x,
y: n.y
}), !1 !== n); r++);
};
this.checkContextMenu = function(e) {
e = Utils.getMouseCoord(e, this.inputController);
var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent),
n;
if (0 < t.length)
for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("contextmenu", {
target: t[r],
x: n.x,
y: n.y
}), !1 !== n); r++);
};
this.checkMouseMove = function(e) {
e = Utils.getMouseCoord(e, this.inputController);
for (r = 0; r < this.objects.length; r++)
if (this.objects[r].dragged) {
var t = e.x / Utils.globalScale / Utils.globalPixelScale,
n = e.y / Utils.globalScale / Utils.globalPixelScale;
this.objects[r].ignoreViewport || (t += this.viewport.x, n += this.viewport.y);
this.objects[r].x = t - this.objects[r].dragX;
this.objects[r].y = n - this.objects[r].dragY
}
var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseMoveEvent),
r, i, s, n = [];
if (0 < t.length) {
t = this.sortStack(t);
for (r = 0; r < t.length && (n.push(t[r]), s = this.finalizeMouseCoords(t[r], e), t[r].mouseOn || (i = t[r].dispatchEvent("mouseover", {
target: t[r],
x: s.x,
y: s.y
})), t[r].mouseOn = !0, !1 !== i); r++);
for (r = 0; r < t.length && (s = this.finalizeMouseCoords(t[r], e), i = t[r].dispatchEvent("mousemove", {
target: t[r],
x: s.x,
y: s.y
}), !1 !== i); r++);
}
for (r = 0; r < this.objects.length; r++)
if (this.objects[r].mouseOn) {
s = !1;
for (i = 0; i < n.length; i++) n[i] == this.objects[r] && (s = !0);
if (!s && (this.objects[r].mouseOn = !1, s = this.finalizeMouseCoords(t[r], e), i = this.objects[r].dispatchEvent("mouseout", {
target: this.objects[r],
x: s.x,
y: s.y
}), !1 === i)) break
}
};
this.checkMouseDown = function(e) {
e = Utils.getMouseCoord(e, this.inputController);
var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseDownEvent),
n;
if (0 < t.length)
for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mousedown", {
target: t[r],
x: n.x,
y: n.y
}), !1 !== n); r++);
};
this.checkMouseUp = function(e) {
e = Utils.getMouseCoord(e, this.inputController);
var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseUpEvent, !0),
n;
if (0 < t.length)
for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mouseup", {
target: t[r],
x: n.x,
y: n.y
}), !1 !== n); r++);
};
this.clear = function() {
for (var e = 0; e < this.objects.length; e++) this.objects[e].dispatchEvent("remove", {
target: this.objects[e]
});
this.objects = [];
this.tweens = [];
this.timers = [];
this.eventsListeners = [];
this.objectsCounter = 0
};
this.hitTest = function(e, t) {
if (0 == e.rotation && 0 == t.rotation) {
var n = e.getX() - e.getWidth() / 2,
r = e.getY() - e.getHeight() / 2,
i = t.getX() - t.getWidth() / 2,
s = t.getY() - t.getHeight() / 2,
o = Math.max(r, s),
u = Math.max(n, i),
n = Math.min(n + e.getWidth(), i + t.getWidth()),
r = Math.min(r + e.getHeight(), s + t.getHeight()) - o;
return 0 < n - u && 0 < r ? !0 : !1
}
u = e.getDrawRectangle();
r = t.getDrawRectangle();
return u.hitTestRectangle(r)
};
this.drawRectangle = function(e, t, n, r, i, s, o, u) {
var a = this.canvas;
a.ctx.globalAlpha = "undefined" != typeof o ? o : 1;
a.ctx.fillStyle = i;
a.ctx.strokeStyle = i;
u || (e -= this.viewport.x, t -= this.viewport.y);
e = e * Utils.globalScale * Utils.globalPixelScale;
t = t * Utils.globalScale * Utils.globalPixelScale;
n = n * Utils.globalScale * Utils.globalPixelScale;
r = r * Utils.globalScale * Utils.globalPixelScale;
s ? a.ctx.fillRect(e - n / 2, t - r / 2, n, r) : a.ctx.strokeRect(e - n / 2, t - r / 2, n, r)
};
this.drawCircle = function(e, t, n, r, i, s, o) {
this.drawArc(e, t, n, 0, 2 * Math.PI, !1, r, i, s, o)
};
this.drawArc = function(e, t, n, r, i, s, o, u, a, f) {
var l = this.canvas,
c = l.ctx.lineWidth;
"undefined" == typeof u && (u = "#000");
l.ctx.strokeStyle = u;
"undefined" == typeof o && (o = 1);
l.ctx.lineWidth = o * Utils.globalScale * Utils.globalPixelScale;
"undefined" == typeof a && (a = 1);
l.ctx.globalAlpha = a;
f || (e -= this.viewport.x, t -= this.viewport.y);
e = e * Utils.globalScale * Utils.globalPixelScale;
t = t * Utils.globalScale * Utils.globalPixelScale;
n = n * Utils.globalScale * Utils.globalPixelScale;
l.ctx.beginPath();
l.ctx.arc(e, t, n, r, i, s);
l.ctx.stroke();
l.ctx.lineWidth = c
};
this.drawPolygon = function(e, t, n, r, i) {
if ("object" == typeof e && e instanceof Array && !(2 > e.length)) {
for (var s = 0; s < e.length - 1; s++) this.drawLine(e[s].x, e[s].y, e[s + 1].x, e[s + 1].y, t, n, r, i);
this.drawLine(e[s].x, e[s].y, e[0].x, e[0].y, t, n, r, i)
}
};
this.drawLine = function(e, t, n, r, i, s, o, u) {
var a = this.canvas,
f = a.ctx.lineWidth;
a.ctx.strokeStyle = s ? s : "#000";
a.ctx.lineWidth = i ? i * Utils.globalScale * Utils.globalPixelScale : 1 * Utils.globalScale * Utils.globalPixelScale;
a.ctx.globalAlpha = o ? o : 1;
u || (e -= this.viewport.x, t -= this.viewport.y, n -= this.viewport.x, r -= this.viewport.y);
e = e * Utils.globalScale * Utils.globalPixelScale;
t = t * Utils.globalScale * Utils.globalPixelScale;
n = n * Utils.globalScale * Utils.globalPixelScale;
r = r * Utils.globalScale * Utils.globalPixelScale;
a.ctx.beginPath();
a.ctx.moveTo(e, t);
a.ctx.lineTo(n, r);
a.ctx.stroke();
a.ctx.lineWidth = f
};
this.start = function() {
this.started || (this.started = !0, r(), i())
};
this.forceRender = function() {
this.started && i()
};
this.stop = function() {
this.started = !1
};
this.setTextStyle = function(e, t, n, r, i, s) {
s = s ? s : this.canvas;
s.ctx.fillStyle = r;
s.ctx.strokeStyle = i;
r = "";
n && (r += n + " ");
t && (r += Math.floor(t * Utils.globalScale * Utils.globalPixelScale) + "px ");
e && (r += e);
s.ctx.font = r
};
this.drawText = function(e, t, n, r, i, s, o) {
o = o ? o : this.canvas;
o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
i || (t -= this.viewport.x, n -= this.viewport.y);
t = t * Utils.globalScale * Utils.globalPixelScale;
n = n * Utils.globalScale * Utils.globalPixelScale;
s && (t -= this.getTextWidth(e) / 2);
o.ctx.fillText(e, t, n)
};
this.strokeText = function(e, t, n, r, i, s, o) {
o = o ? o : this.canvas;
o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
i || (t -= this.viewport.x, n -= this.viewport.y);
t = t * Utils.globalScale * Utils.globalPixelScale;
n = n * Utils.globalScale * Utils.globalPixelScale;
s && (t -= this.getTextWidth(e) / 2);
o.ctx.strokeText(e, t, n)
};
this.getTextWidth = function(e, t) {
return (t ? t : this.canvas).ctx.measureText(e).width
};
this.allowStaticDebugDrawing = this.allowDebugDrawing = !1;
this.renderObject = function(e, t) {
if (!1 !== t.dispatchEvent("prerender", {
target: t,
canvas: e
})) {
var n = t.getAbsoluteCenter();
ow = t.width * Utils.globalScale;
oh = t.height * Utils.globalScale;
ox = n.x * Utils.globalPixelScale * Utils.globalScale - Math.floor(ow / 2);
oy = n.y * Utils.globalPixelScale * Utils.globalScale - Math.floor(oh / 2);
or = t.rotation;
scX = t.scaleX * Utils.globalPixelScale;
scY = t.scaleY * Utils.globalPixelScale;
canvasMod = Boolean(0 != or || 1 != scX || 1 != scY);
t.ignoreViewport || (ox -= this.viewport.x * Utils.globalPixelScale * Utils.globalScale, oy -= this.viewport.y * Utils.globalPixelScale * Utils.globalScale);
canvasMod && (e.ctx.save(), e.ctx.translate(ox + Math.floor(ow / 2), oy + Math.floor(oh / 2)), e.ctx.rotate(or), e.ctx.scale(scX, scY), ox = -Math.floor(ow / 2), oy = -Math.floor(oh / 2));
e.ctx.globalAlpha = t.opacity;
this.ceilSizes && (ow = Math.ceil(ow), oh = Math.ceil(oh));
t.fillColor && (e.ctx.fillStyle = t.fillColor, e.ctx.strokeStyle = t.fillColor, e.ctx.fillRect(ox, oy, ow, oh));
if (t.bitmap) {
var n = t.bitmap.width,
r = t.bitmap.height,
i = t.currentLayer * ow + t.offset.left * Utils.globalScale,
s = t.currentFrame * oh + t.offset.top * Utils.globalScale;
if (i < n && s < r) {
var o = ow,
u = oh,
a = !1;
i + o > n && (o = n - i);
s + u > r && (u = r - s);
t.mask && (this.buffer.ctx.save(), this.buffer.ctx.clearRect(0, 0, o, u), this.buffer.ctx.drawImage(t.bitmap, i, s, o, u, 0, 0, o, u), this.buffer.ctx.globalCompositeOperation = "destination-in", this.buffer.ctx.drawImage(t.mask, 0, 0), s = i = 0, a = !0);
try {
e.ctx.drawImage(a ? this.buffer : t.bitmap, ~~i, ~~s, ~~o, ~~u, ~~ox, ~~oy, ~~ow, ~~oh)
} catch (f) {}
a && this.buffer.ctx.restore()
}
}
canvasMod && e.ctx.restore();
this.allowDebugDrawing && t.allowDebugDrawing && (!this.allowStaticDebugDrawing && t.static || t.debugDraw());
t.dispatchEvent("render", {
target: t,
canvas: e
})
}
};
this.drawBackAlways = Utils.mobileCheckBrokenGalaxyPhones();
this.drawBackBuffer = function(e, t) {
!t && this.backBuffer && this.drawBackAlways && e.ctx.drawImage(this.backBuffer, 0, 0, e.width, e.height)
};
this.drawScene = function(e, t) {
var n, r;
e && !e.ctx && (e.ctx = e.getContext("2d"));
this.fillColor ? (e.ctx.fillStyle = this.fillColor, e.ctx.fillRect(0, 0, this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.screenHeight * Utils.globalScale * Utils.globalPixelScale), this.drawBackBuffer(e, t)) : this.clearLock || (this.clearScreen(e), this.drawBackBuffer(e, t));
for (var i = 0; i < this.objects.length; i++) n = this.objects[i], r = !1, t || n["static"] || (r = !0), t && n["static"] && (r = !0), r && (n.destroy ? (this.removeChild(n), i--) : (n.nextFrame(), n.visible && this.renderObject(e, n)));
t && (this.backBuffer = e)
};
this.tweens = [];
this.createTween = function(e, t, n, r, i, o) {
e = new Tween(e, t, n, r, i, o);
s.tweens.push(e);
return e
};
this.removeTween = function(e) {
var t = null;
if (isNaN(e))
for (var n = 0; n < s.tweens.length; n++) {
if (s.tweens[n] === e) {
t = n;
break
}
} else t = e;
s.tweens[t].pause();
s.tweens.splice(t, 1);
return t
};
this.clearObjectTweens = function(e) {
for (var t = 0; t < s.tweens.length; t++) s.tweens[t].obj === e && (t = s.removeTween(t), t--)
};
this.updateTweens = function() {
for (var e = 0; e < s.tweens.length; e++) s.tweens[e].tick() && (e = s.removeTween(e))
};
this.timers = [];
this.setTimeout = function(e, t) {
var n = new StageTimer(e, t);
this.timers.push(n);
return n
};
this.clearTimeout = function(e) {
this.timers = Utils.removeFromArray(this.timers, e)
};
this.setInterval = function(e, t) {
var n = new StageTimer(e, t, !0);
this.timers.push(n);
return n
};
this.clearInterval = function(e) {
this.clearTimeout(e)
};
this.updateTimers = function() {
for (var e = 0; e < this.timers.length; e++) this.timers[e].update() && (this.clearTimeout(this.timers[e]), e--)
};
this.box2dSync = function(e) {
for (b = e.m_bodyList; b; b = b.m_next) b.sprite && (b.sprite.rotation = b.GetRotation(), e = b.GetPosition(), b.sprite.x = e.x, b.sprite.y = e.y, b.sprite.dispatchEvent("box2dsync", {
target: b.sprite
}))
};
this.processTouchEvent = function(e, t) {
for (var n = 0; n < e.length; n++) s[t]({
clientX: e[n].clientX,
clientY: e[n].clientY
})
};
this.inputController = null;
this.addInputListeners = function(e) {
-1 != navigator.userAgent.toLowerCase().indexOf("firefox") && navigator.userAgent.toLowerCase().indexOf("mobile");
this.inputController = e;
"ontouchstart" in e ? (e.ontouchstart = function(e) {
s.processTouchEvent(e.touches, "checkMouseDown");
s.processTouchEvent(e.touches, "checkClick")
}, e.ontouchmove = function(e) {
s.processTouchEvent(e.touches, "checkMouseMove")
}, e.ontouchend = function(e) {
s.processTouchEvent(e.changedTouches, "checkMouseUp")
}) : (e.onclick = function(e) {
s.checkClick(e)
}, e.onmousemove = function(e) {
s.checkMouseMove(e)
}, e.onmousedown = function(e) {
0 == e.button && s.checkMouseDown(e)
}, e.onmouseup = function(e) {
0 == e.button && s.checkMouseUp(e)
}, e.oncontextmenu = function(e) {
s.checkContextMenu(e)
})
};
this.canvas && this.addInputListeners(this.canvas);
this.onposttick = this.onpretick = null;
this.eventsListeners = [];
this.addEventListener = function(e, t) {
EventsManager.addEvent(this, e, t)
};
this.removeEventListener = function(e, t) {
EventsManager.removeEvent(this, e, t)
};
this.dispatchEvent = function(e, t) {
return EventsManager.dispatchEvent(this, e, t)
}
}
function Vector(e, t) {
"undefined" == typeof e && (e = 0);
this.x = e;
"undefined" == typeof t && (t = 0);
this.y = t;
this.isZero = function() {
return 0 == this.x && 0 == this.y
};
this.clone = function() {
return new Vector(this.x, this.y)
};
this.add = function(e) {
this.x += e.x;
this.y += e.y;
return this
};
this.subtract = function(e) {
this.x -= e.x;
this.y -= e.y;
return this
};
this.mult = function(e) {
this.x *= e;
this.y *= e;
return this
};
this.invert = function() {
this.mult(-1);
return this
};
this.rotate = function(e, t) {
"undefined" == typeof t && (t = new Vector(0, 0));
var n = this.clone();
n.subtract(t);
n.x = this.x * Math.cos(e) + this.y * Math.sin(e);
n.y = this.x * -Math.sin(e) + this.y * Math.cos(e);
n.add(t);
this.x = n.x;
this.y = n.y;
return this
};
this.normalize = function(e, t) {
"undefined" == typeof t && (t = new Vector(0, 0));
this.subtract(t);
this.rotate(-e);
return this
};
this.getLength = function() {
return Math.sqrt(this.x * this.x + this.y * this.y)
};
this.distanceTo = function(e) {
p2 = this.clone();
p2.subtract(e);
return p2.getLength()
}
}
function ChainFinder(e, t, n, r) {
"undefined" == typeof e && (e = []);
t = Math.max(2, ~~t);
n = Math.max(1, ~~n);
"undefined" == typeof r && (r = !1);
this.items = e;
this.length = t;
this.cols = n;
this.rows = Math.floor(e.length / n);
this.diagonal = r;
this.chains = !1;
this.inField = function(e) {
return 0 > e || e >= this.items.length ? !1 : !0
};
this.idInChain = function(e) {
for (var t = 0; t < this.chains.length; t++)
if (0 <= this.chains[t].indexOf(e)) return t;
return -1
};
this.isNeighbour = function(e, t) {
if (!this.inField(t) || 0 <= this.idInChain(e)) return !1;
var n = Math.floor(e / this.cols),
r = Math.floor(t / this.cols),
i = Math.abs(e % this.cols - t % this.cols),
n = Math.abs(n - r);
return this.diagonal ? 0 < i + n && 2 > i && 2 > n : 1 == i + n
};
this.getNeighbours = function(e, t) {
"undefined" == typeof t && (t = !1);
var n = [e - 1, e + 1, e - this.cols, e + this.cols];
this.diagonal && (n.push(e - (this.cols - 1)), n.push(e - (this.cols + 1)), n.push(e + (this.cols - 1)), n.push(e + (this.cols + 1)));
for (var r = []; 0 < n.length;) {
var i = n.shift();
this.isNeighbour(e, i) && (t && 0 > this.ids.indexOf(i) || r.push(i))
}
return r
};
this.checkChainLength = function(e) {
return e ? e.length >= this.length : !1
};
this.ids = [];
this.prepare = function() {
this.ids = [];
this.chains = [];
for (var e = 0; e < this.items.length; e++) 0 <= this.idInChain(e) || this.ids.push(e)
};
this.findChains = function() {
this.prepare();
if (0 == this.items.length) return this.chains;
for (; 0 < this.ids.length;) {
var e = this.ids.shift(),
e = this.getChain(e);
this.checkChainLength(e) && this.chains.push(e)
}
return this.chains
};
this.getChain = function(e, t) {
"undefined" == typeof t && (t = []);
0 > t.indexOf(e) && t.push(e);
for (var n = this.getNeighbours(e, !0); 0 < n.length;) {
var r = n.shift();
this.empty(this.items[r]) || 0 <= t.indexOf(r) || !this.compare(this.items[r], this.items[e]) || (this.ids.splice(this.ids.indexOf(r), 1), t = this.getChain(r, t))
}
return t
};
this.findPossibleChains = function(e) {
this.prepare();
var t = this.items[e];
if (!this.inField(e)) return !1;
for (var n = {}, r = this.getNeighbours(e, !0); 0 < r.length;) {
this.prepare();
var i = r.shift(),
s = this.items[i];
this.empty(s) || (this.items[e] = s, n[s] || (n[s] = []), n[s] = this.getChain(i, n[s]))
}
this.items[e] = t;
return n
};
this.findMaxPossibleChain = function(e) {
e = this.findPossibleChains(e);
if (!e) return !1;
var t = !1,
n = -1,
r;
for (r in e) this.checkChainLength(e[r]) && ~~r > n && (t = e[r], n = ~~r);
return t
};
this.findMinPossibleChain = function(e) {
e = this.findPossibleChains(e);
if (!e) return !1;
var t = !1,
n = Number.MAX_VALUE,
r;
for (r in e) this.checkChainLength(e[r]) && r < n && (t = e[r], n = r);
return t
};
this.findLongestPossibleChain = function(e) {
e = this.findPossibleChains(e);
if (!e) return !1;
var t = !1,
n = -1,
r;
for (r in e) this.checkChainLength(e[r]) && e[r].length > n && (t = e[r], n = r);
return t
};
this.findShortestPossibleChain = function(e) {
e = this.findPossibleChains(e);
if (!e) return !1;
var t = !1,
n = Number.MAX_VALUE,
r;
for (r in e) this.checkChainLength(e[r]) && e[r].length < n && (t = e[r], n = r);
return t
};
this.getChainType = function(e) {
if (!1 === e) return 0;
for (var t = 0; t < e.length; t++)
if (!this.empty(e[t])) return this.items[e[t]];
return 0
};
this.compare_callback = null;
this.compare = function(e, t) {
return this.compare_callback ? this.compare_callback(e, t) : e == t
};
this.empty_callback = null;
this.empty = function(e) {
return this.empty_callback ? this.empty_callback(e) : 0 == ~~e
}
}
function AudioPlayer() {
var e = this;
this.disabled = !1;
this.basePath = "";
this.mp3Support = !0;
this.delayPlay = this.webAudioSupport = !1;
this.audioWrapper = null;
this.busy = this.locked = !1;
this.startPlayTime = 0;
this.onend = null;
this.createNewAudio = function() {
if (this.webAudioSupport) {
var e = AudioMixer.waContext.createBufferSource();
e.connect(AudioMixer.waContext.destination);
return e
}
return document.createElement("audio")
};
this.init = function(e, t) {
this.webAudioSupport = t;
this.basePath = e ? e : "";
this.delayPlay = "ontouchstart" in window;
this.audioWrapper = this.createNewAudio();
var n = document.createElement("audio");
n.canPlayType ? this.mp3Support = "" != n.canPlayType("audio/mpeg") : this.disabled = !0;
return !this.disabled
};
this.play = function(e, t) {
if (this.disabled) return !1;
var n = this.basePath + "/" + e + (this.mp3Support ? ".mp3" : ".ogg");
this.stop();
this.audioWrapper = this.createNewAudio();
this.audioWrapper.doLoop = t ? !0 : !1;
if (this.webAudioSupport) {
var r = this;
this.loadSound(n, function(e) {
r.audioWrapper.buffer = e;
r.audioWrapper.noteOn(0);
r.startPlayTime = (new Date).getTime();
r.audioWrapper.loop = t;
r.waCheckInterval = setInterval(function() {
r.audioWrapper ? r.audioWrapper.playbackState == r.audioWrapper.FINISHED_STATE && r.controlPlay() : clearInterval(r.waCheckInterval)
}, 100)
})
} else this.audioWrapper.src = n, this.audioWrapper.type = this.mp3Support ? "audio/mpeg" : "audio/ogg", this.audioWrapper.loop = !1, this.audioWrapper.preload = "auto", this.audioWrapper.load(), this.delayPlay ? this.audioWrapper.addEventListener("canplay", this.readyToPlay) : this.audioWrapper.play(), this.audioWrapper.addEventListener("ended", this.controlPlay, !1);
this.busy = !0;
this.startPlayTime = (new Date).getTime()
};
this.loadSound = function(e, t) {
if (AudioMixer.buffer[e]) t && t(AudioMixer.buffer[e]);
else {
var n = new XMLHttpRequest;
n.open("GET.html", e, !0);
n.responseType = "arraybuffer";
n.onload = function() {
AudioMixer.waContext.decodeAudioData(this.response, function(n) {
AudioMixer.buffer[e] = n;
t && t(n)
})
}
}
};
this.readyToPlay = function(e) {
e.currentTarget.play()
};
this.stop = function() {
this.busy = !1;
try {
this.webAudioSupport ? this.audioWrapper.noteOff(0) : (this.audioWrapper.removeEventListener("canplay", this.readyToPlay), this.audioWrapper.pause(), this.audioWrapper.currentTime = 0), this.audioWrapper = null
} catch (e) {}
};
this.pause = function() {
this.webAudioSupport ? e.audioWrapper && e.audioWrapper.disconnect() : this.audioWrapper.pause()
};
this.resume = function() {
this.webAudioSupport ? e.audioWrapper && e.audioWrapper.connect(AudioMixer.waContext.destination) : this.audioWrapper.play()
};
this.controlPlay = function() {
if (e.audioWrapper.doLoop) this.webAudioSupport || (e.audioWrapper.pause(), e.audioWrapper.currentTime = 0, e.audioWrapper.play());
else {
e.busy = !1;
if ("function" == typeof e.onend) e.onend();
this.waCheckInterval && clearInterval(this.waCheckInterval)
}
};
this.getPosition = function() {
if (this.webAudioSupport) {
if (!this.startPlayTime) return 0;
var e = this.getDuration();
if (!e) return 0;
var t = ((new Date).getTime() - this.startPlayTime) / 1e3;
return t <= e ? t : this.audioWrapper.doLoop ? t - Math.floor(t / e) * e : e
}
return this.audioWrapper.currentTime ? this.audioWrapper.currentTime : 0
};
this.getDuration = function() {
return this.webAudioSupport ? this.audioWrapper.buffer ? this.audioWrapper.buffer.duration : 0 : this.audioWrapper.duration ? this.audioWrapper.duration : 0
}
}
function AudioMixer(e, t) {
this.singleChannelMode = this.webAudioSupport = !1;
this.channels = [];
this.init = function(e, t) {
if (this.webAudioSupport = "webkitAudioContext" in window) {
AudioMixer.waContext = new webkitAudioContext;
var n = AudioMixer.waContext.createBuffer(1, 1, 22050);
sound = AudioMixer.waContext.createBufferSource();
sound.buffer = n;
sound.connect(AudioMixer.waContext.destination)
}
this.webAudioSupport || -1 == navigator.userAgent.toLowerCase().indexOf("mac") || (this.singleChannelMode = !0, t = 1);
this.path = e;
this.channels = [];
for (n = 0; n < t; n++) this.channels[n] = new AudioPlayer, this.channels[n].init(e, this.webAudioSupport);
var r, i;
"undefined" !== typeof document.hidden ? (r = "hidden", i = "visibilitychange") : "undefined" !== typeof document.mozHidden ? (r = "mozHidden", i = "mozvisibilitychange") : "undefined" !== typeof document.msHidden ? (r = "msHidden", i = "msvisibilitychange") : "undefined" !== typeof document.webkitHidden && (r = "webkitHidden", i = "webkitvisibilitychange");
var s = this;
document.addEventListener(i, function() {
if (document[r])
for (var e = 0; e < s.channels.length; e++) s.channels[e].pause();
else
for (e = 0; e < s.channels.length; e++) s.channels[e].resume()
}, !1)
};
this.play = function(e, t, n, r) {
var i = -1,
i = "number" == typeof r ? r : this.getFreeChannel(n);
0 <= i && i < this.channels.length && (this.channels[i].stop(), this.channels[i].play(e, t));
return this.channels[i]
};
this.stop = function(e) {
0 <= e && e < this.channels.length && this.channels[e].stop()
};
this.getFreeChannel = function(e) {
for (var t = -1, n = [], r = -1, i = 0, s = 0; s < this.channels.length; s++) this.channels[s].locked || (this.channels[s].busy ? (i = (new Date).getTime(), i -= this.channels[s].startPlayTime, i > r && (r = i)) : n.push(s));
0 == n.length ? !e && 0 <= r && (t = r) : t = n[0];
return t
};
this.init(e, t)
}
function gameButton(e, t, n) {
var r = library.getSprite(e);
r.x = t;
r.y = n;
r.gotoAndStop(1);
r.onmousedown = function() {
r.gotoAndStop(0)
};
r.onmouseout = function() {
r.gotoAndStop(1)
};
r.onmouseup = function() {
r.gotoAndStop(1);
0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("button_click", !1, !1, 0)
};
return r
}
function startLoad() {
var e = Utils.getMobileScreenResolution(landscape);
Utils.globalScale = e.scale;
Utils.createLayout(document.getElementById("main_container"), e, landscape);
Utils.addEventListener("fitlayout", function() {
stage && (stage.drawScene(document.getElementById("screen")), buildBackground());
setBackgroundScale()
});
Utils.addEventListener("lockscreen", function() {
stage && stage.started && stage.stop()
});
Utils.addEventListener("unlockscreen", function() {
stage && !stage.started && stage.start()
});
Utils.mobileHideAddressBar();
Utils.checkOrientation(landscape);
mixer = new AudioMixer("music", 1);
mixer2 = new AudioMixer("music", 1);
library = new AssetsLibrary("images", Utils.globalScale, assets);
TTLoader.create(loadImagesEnd, !0);
library.load(TTLoader.loadComplete, TTLoader.showLoadProgress)
}
function loadImagesEnd(e) {
document.getElementById("progress_container").style.display = "none";
document.getElementById("screen_container").style.display = "block";
document.getElementById("screen_background_container").style.display = "block";
FontManager.registerFont("baveuse", Charset.latin, 9, 14);
gameState = STATE_MENU;
iosMode = -1 != navigator.userAgent.toLowerCase().indexOf("mac");
android = -1 != navigator.userAgent.toLowerCase().indexOf("android");
createScene()
}
function showMenu() {
gameState = STATE_MENU;
createScene()
}
function createStage() {
stage && (stage.destroy(), stage.stop());
stage = new Stage("screen", 320, 480, !1);
stage.delay = 1e3 / fps;
stage.ceilSizes = !0;
stage.onpretick = preTick;
stage.onposttick = postTick;
stage.showFPS = !1
}
function createScene() {
createStage();
gameState == STATE_MENU && createMenu();
gameState == STATE_SELECT_DIFFICULTY && selectDifficulty();
gameState == STATE_MISSION_INFO && showMissionInfo();
gameState == STATE_GAME && createGame();
gameState == STATE_VICTORY && showVictoryScreen();
gameState == STATE_DEFEAT && showDefeatScreen();
gameState == STATE_HIGHSCORES ;
gameState == STATE_CREDITS && showEvolution();
gameState == STATE_TUTORIAL && showTutorialMenu();
setBackground("#FFFFFF url('images/" + Utils.globalScale + "/gme-bg.jpg')");
buildBackground();
stage.start()
}
function setBackground(e) {
e !== lastBackground && (document.getElementById("screen_background_container").style.background = e, document.getElementById("screen_background_container").style.backgroundRepeat = "no-repeat", document.getElementById("screen_background_container").style.backgroundPosition = "center top", lastBackground = e, setBackgroundScale())
}
function setBackgroundScale() {
var e = Utils.globalScale * Utils.globalPixelScale;
document.getElementById("screen_background_container").style.backgroundSize = 870 * e + "px " + 480 * e + "px"
}
function showDefeatScreen() {
stage.addChild(library.getSprite("null", {
x: 160,
y: 240,
"static": !0,
onmouseup: function() {
gameState = STATE_GAME;
createScene()
}
}));
stage.addChild(library.getSprite("popup_loose", {
x: 160,
y: 180
}));
var e = new gameButton("menu", 160, 455);
e.addEventListener("mouseup", function() {
showMenu();
return !1
});
stage.addChild(e);
checkAndSetHighscores()
}
function createMenu() {
stage.addChild(library.getSprite("field-main-logo", {
x: 160,
y: 80
}));
stage.addChild(library.getSprite("field-main-btn-bg", {
x: 160,
y: 280
}));
var e = new gameButton("play", 158, 201);
e.addEventListener("mouseup", function(e) {
gameState = STATE_SELECT_DIFFICULTY;
createScene();
return !1
});
stage.addChild(e);
e = new gameButton("highscores", 171, 302);
e.addEventListener("mouseup", function(e) {
gameState = STATE_HIGHSCORES;
createScene()
});
stage.addChild(e);
e = new gameButton("credits", 145, 375);
e.addEventListener("mouseup", function(e) {
gameState = STATE_CREDITS;
createScene()
});
stage.addChild(e);
e = new gameButton("qmark", 55, 450);
e.addEventListener("mouseup", function(e) {
gameState = STATE_TUTORIAL;
createScene()
});
stage.addChild(e);
1 == Utils.getCookie("soundOn") || ignoreMenuTheme || mixer2.play("main_theme", !0, !1, 0);
addSoundIcon()
}
function testChance() {
var e = rouletteProbability,
t = 0,
n;
for (n in e) t += e[n].n;
t = Math.floor(Math.random() * t);
for (n in e)
if (t -= e[n].n, 0 >= t) return e[n].v;
return 1
}
function playRoulette() {
for (var e = [], t = [], n = 0; 3 > n; n++) {
t.push(testChance());
var r = new GameElement(t[n]);
r.x = 102 + 58 * n;
r.y = 219;
r.isRoulette = !0;
e.push(r);
r = library.getSprite("coin_rotate");
r.x = 102 + 58 * n;
r.y = 219;
r.animDelay = 1;
r.isRoulette = !0;
r.gotoAndPlay(0);
tempRouletteArray.push(r);
stage.addChild(r)
}
setTimeout(function() {
tempRouletteArray[0].onenterframe = function(t) {
8 == t.target.currentFrame && (tempRouletteArray[0].destroy = !0, stage.addChild(e[0]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
}
}, 2e3);
setTimeout(function() {
tempRouletteArray[1].onenterframe = function(t) {
8 == t.target.currentFrame && (tempRouletteArray[1].destroy = !0, stage.addChild(e[1]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
}
}, 4e3);
setTimeout(function() {
tempRouletteArray[2].onenterframe = function(t) {
8 == t.target.currentFrame && (tempRouletteArray[2].destroy = !0, stage.addChild(e[2]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
};
setTimeout(function() {
checkIfRouletteWon(t)
}, 1e3)
}, 6e3)
}
function checkIfRouletteWon(e) {
if (e[0] == e[1] && e[0] != e[2] || e[0] == e[2] && e[0] != e[1] || e[1] == e[2] && e[0] != e[1]) 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_nice", !1, !1, 0);
e[0] == e[1] && e[0] == e[2] ? (coinsInc(), setUserCoins(), stage.addChild(library.getSprite("text2", {
x: 160,
y: 260
})), drawHighscores(1, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_super_nice", !1, !1, 0)) : (stage.addChild(library.getSprite("text3", {
x: 160,
y: 260
})), drawHighscores(0, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_not_nice", !1, !1, 0));
stage.addChild(library.getSprite("text1", {
x: 170,
y: 285
}))
}
function showVictoryScreen() {
0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
var e, t = "ultimate" == currentDifficulty ? !0 : !1,
n;
if (t && maxUnlockedItem.newUnlocked) maxUnlockedItem.newUnlocked && (e = 240, stage.addChild(library.getSprite("back_field_win_3", {
x: 160,
y: e - 40
})), e += 43, drawLevelScore(143), playRoulette());
else {
0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
n = LEVELS[current_game_mode].upgrades;
n = t ? maxUnlockedItem.t : n[n.length - 1];
e = 240;
stage.addChild(library.getSprite("back_field_win", {
x: 160,
y: e - 40
}));
var r = library.getSprite("light_win");
r.x = 160;
r.y = 200;
stage.addChild(r);
stage.setInterval(function() {
r.rotateBy(Math.PI / 160)
}, 2);
n = new GameElement(n, t);
n.setPosition(160, 205);
stage.addChild(n);
drawLevelScore(265)
}
n = new gameButton("win_next", 243, e + 18);
n.addEventListener("mouseup", function(e) {
gameState = STATE_SELECT_DIFFICULTY;
createScene()
});
stage.addChild(n);
e = new gameButton("win_replay", 76, e + 18);
e.addEventListener("mouseup", function(e) {
gameState = STATE_GAME;
createScene()
});
stage.addChild(e);
t || levelCompleted();
checkAndSetHighscores()
}
function addSoundIcon() {
ignoreMenuTheme = !0;
sound = library.getSprite("sound");
sound.x = 275;
sound.y = 455;
1 == Utils.getCookie("soundOn") ? (sound.gotoAndStop(0), soundOn = !1) : (sound.gotoAndStop(1), soundOn = !0);
sound.state = 1;
sound.onmouseup = soundIconOnChange;
stage.addChild(sound)
}
function showHighscores() {
stage.addChild(library.getSprite("field_highscore", {
x: 160,
y: 240,
"static": !0
}));
var e = new gameButton("menu", 160, 400);
e.addEventListener("mouseup", showMenu);
stage.addChild(e);
addSoundIcon();
for (var e = [], t = 1; 11 > t; t++) {
var n = Utils.getCookie("maxScore" + t),
n = null == n ? 0 : n,
n = parseInt(n);
e.push(n)
}
e.sort(function(e, t) {
return e > t ? -1 : e < t ? 1 : 0
});
t = 0;
for (n = e.length; t < n; t++) drawHighscores(t + 1, 60, 92 + 30 * t, "numbers"), drawHighscores(e[t], 265, 92 + 30 * t)
}
function drawHighscores(e, t, n, r) {
var i = library.getAsset("font1", !0).bitmap;
e += "";
if ("numbers" == r)
for (r = 0; r < e.length; r++) mc = new Sprite(i, 12, 20, 10), mc.gotoAndStop(e.substr(r, 1)), mc.x = t + 12 * r, mc.y = n, stage.addChild(mc);
else
for (r = e.length; 0 < r; r--) mc = new Sprite(i, 12, 20, 10), mc.gotoAndStop(e.substr(e.length - r, 1)), mc.x = t - 12 * r, mc.y = n, stage.addChild(mc)
}
function checkAndSetHighscores() { /*updateShare(current_game_mode,gameScore);Play68.setRankingScoreDesc(gameScore);*/
for (var e = [], t = 1; 11 > t; t++) {
var n = Utils.getCookie("maxScore" + t);
void 0 != n && e.push(n)
}
t = e.length;
if (10 > t) t++, Utils.setCookie("maxScore" + t, gameScore);
else
for (t = 0; 10 > t; t++)
if (e[t] < gameScore) {
t++;
Utils.setCookie("maxScore" + t, gameScore);
break
}
}
function moveIconsVert(e, t) {
for (var n, r = 0, i = stage.objects.length; r < i; r++) {
var s = stage.objects[r];
s.first && (n = s, 0 < e && 110 <= s.y + e && (e = 110 - s.y, t && (t[0].visible = !1)), 0 > e && -660 >= s.y + e && (e = -660 - s.y, t && (t[1].visible = !1)));
if (s.first && 110 <= s.y && 0 < e) return t && (t[0].visible = !1), !1;
if (s.first && -660 >= s.y && 0 > e) return t && (t[1].visible = !1), !1;
if (s.isMovable) {
s.y += e;
var o = s.y;
s.visible = 90 >= o || 390 <= o ? !1 : !0;
s.opacity = 90 < o && 110 >= o ? (o - 90) / 20 : 360 <= o && 390 > o ? Math.abs(390 - o) / 30 : 1
}
}
t && (t[0].visible = !0, t[1].visible = !0);
110 <= n.y && t && (t[0].visible = !1); - 660 >= n.y && t && (t[1].visible = !1)
}
function showEvolution() {
scrollLocked = !1;
var e = new Sprite(null, 320, 480);
e.x = 160;
e.y = 240;
e.static = !0;
e.onmousedown = function() {
startScrollPosition = window.event.pageY;
scrollLocked = !0
};
e.onmouseup = function() {
scrollLocked = !1
};
e.onmousemove = function() {
if (scrollLocked) {
var e = window.event.pageY;
moveIconsVert((e - startScrollPosition) / 1.85, [t, n]);
startScrollPosition = e
}
};
stage.addChild(e);
stage.addChild(library.getSprite("back", {
x: 160,
y: 235
}));
e = library.getSprite("evol_back", {
x: 160,
y: 230
});
stage.setZIndex(e, 100);
stage.addChild(e);
var t = new Sprite(library.getSprite("arrow_up").bitmap, 31, 12);
t.x = 160;
t.y = 70;
t.onclick = function() {
moveIconsVert(85, [t, n])
};
t.visible = !1;
stage.setZIndex(t, 150);
stage.addChild(t);
var n = new Sprite(library.getSprite("arrow_down").bitmap, 31, 12);
n.x = 160;
n.y = 405;
n.onclick = function() {
moveIconsVert(-85, [t, n])
};
stage.setZIndex(n, 150);
stage.addChild(n);
e = new gameButton("menu", 160, 450);
e.addEventListener("mousedown", function() {
clickForbidden = !1
});
e.addEventListener("mouseup", function() {
clickForbidden || (showMenu(), clickForbidden = !0)
});
stage.addChild(e);
addSoundIcon();
sound.addEventListener("mousedown", function() {
clickForbidden = !1
});
sound.onmouseup = function(e) {
clickForbidden || (clickForbidden = !0, soundIconOnChange())
};
stage.addChild(library.getSprite("Amoeba", {
x: 160,
y: 110,
isMovable: !0,
first: !0
}));
stage.addChild(library.getSprite("Jellyfish", {
x: 160,
y: 195,
isMovable: !0
}));
stage.addChild(library.getSprite("Fish", {
x: 160,
y: 280,
isMovable: !0
}));
e = Utils.getCookie("icon4ul") ? "lizard" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 365,
isMovable: !0
}));
e = Utils.getCookie("icon5ul") ? "wolf" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 450,
isMovable: !0
}));
e = Utils.getCookie("icon6ul") ? "ape" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 535,
isMovable: !0
}));
e = Utils.getCookie("icon7ul") ? "human" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 620,
isMovable: !0
}));
e = Utils.getCookie("icon11ul") ? "humanoid" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 705,
isMovable: !0
}));
e = Utils.getCookie("icon12ul") ? "superhuman" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 790,
isMovable: !0
}));
e = Utils.getCookie("icon13ul") ? "cyborg" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 875,
isMovable: !0
}));
e = Utils.getCookie("icon14ul") ? "geek" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 960,
isMovable: !0
}));
e = Utils.getCookie("icon15ul") ? "zombie" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 1045,
isMovable: !0
}));
e = Utils.getCookie("icon16ul") ? "superbrains" : "Unknown";
stage.addChild(library.getSprite(e, {
x: 160,
y: 1130,
isMovable: !0
}));
moveIconsVert(0)
}
function setDifficulty(e) {
e = ~~e.target.mode;
gameState = STATE_MISSION_INFO;
current_game_mode = e = Math.max(0, Math.min(LEVELS.length, ~~e));
createScene()
}
function selectDifficulty() {
stage.addChild(library.getSprite("field-select-level-bg", {
x: 161,
y: 240
}));
var e = new gameButton("menu", 160, 455);
e.addEventListener("mouseup", showMenu);
stage.addChild(e);
addLevelIcon("easy");
addLevelIcon("medium");
addLevelIcon("hard");
addLevelIcon("expert");
addLevelIcon("ultimate");
addSoundIcon();
showUnlockAnimation && (addUnlockAnimation(), showUnlockAnimation = !1)
}
function addUnlockAnimation() {
var e;
switch (currentDifficulty) {
case "easy":
e = 175;
break;
case "medium":
e = 245;
break;
case "hard":
e = 315;
break;
case "expert":
e = 385
}
var t = library.getSprite("lock");
t.x = 230;
t.y = e;
t.animDelay = 3;
t.onenterframe = function(e) {
10 == e.target.currentFrame && (e.target.destroy = !0)
};
stage.addChild(t)
}
function addLevelIcon(e) {
var t = library.getSprite(e);
t.x = 160;
switch (e) {
case "easy":
t.y = 105;
t.mode = D_SIMPLE;
t.gotoAndStop(0);
t.onmouseup = function(e) {
currentDifficulty = "easy";
setDifficulty(e)
};
break;
case "medium":
t.y = 175;
t.mode = D_NORMAL;
void 0 == Utils.getCookie("easy_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
currentDifficulty = "medium";
setDifficulty(e)
});
break;
case "hard":
t.y = 245;
t.mode = D_HARD;
void 0 == Utils.getCookie("medium_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
currentDifficulty = "hard";
setDifficulty(e)
});
break;
case "expert":
t.y = 315;
t.mode = D_EXPERT;
void 0 == Utils.getCookie("hard_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
currentDifficulty = "expert";
setDifficulty(e)
});
break;
case "ultimate":
t.y = 385, t.mode = D_ULTIMATE, void 0 == Utils.getCookie("expert_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
currentDifficulty = "ultimate";
setDifficulty(e)
})
}
stage.addChild(t)
}
function levelCompleted() {
Utils.getCookie(currentDifficulty + "_level_completed") || (Utils.setCookie(currentDifficulty + "_level_completed", !0), showUnlockAnimation = !0, "easy" == currentDifficulty && Utils.setCookie("icon4ul", !0), "medium" == currentDifficulty && Utils.setCookie("icon5ul", !0), "hard" == currentDifficulty && Utils.setCookie("icon6ul", !0), "expert" == currentDifficulty && Utils.setCookie("icon7ul", !0))
}
function createGame() {
if (gameState != STATE_GAME) return !1;
clearGame();
stage.addChild(library.getSprite("field-play-playingfield", {
x: 161,
y: 260,
tatic: !0
}));
stage.addChild(library.getSprite("field-play-score-bg", {
x: 145,
y: 111,
"static": !0
}));
var e = new gameButton("menu", 80, 30);
e.addEventListener("mouseup", showMenu);
stage.addChild(e);
e = new gameButton("replay", 240, 30);
e.addEventListener("mouseup", createScene);
stage.addChild(e);
addSoundIcon();
e = new gameButton("plus", 281, 106);
e.addEventListener("mouseup", function() {
tutorialActivated || showShop();
tutorialActivated && tut14completed && (showShop(), tutDone())
});
stage.addChild(e);
field = new GameField(LEVELS[current_game_mode]);
field.create()
}
function clearGame() {
score = field = null;
maxUnlockedItem = {
t: 3,
newUnlocked: !1
}
}
function showShop() {
field.locked = !0;
var e = new Sprite(null, 320, 480);
e.x = 160;
e.y = 240;
e.isShopElement = !0;
e.onmouseup = function() {
destroyShop();
return !1
};
stage.addChild(e);
e = library.getSprite("popup_bg");
e.x = 160;
e.y = 240;
e.isShopElement = !0;
e.onmouseup = function() {
return !1
};
stage.addChild(e);
drawText("coins", 200, 180);
e = library.getSprite("ether");
e.x = 125;
e.y = 217;
e.isShopElement = !0;
e.gametype = T_ETHER;
e.onmouseup = buyItem;
stage.addChild(e);
e = library.getSprite("fire");
e.x = 195;
e.y = 217;
e.gametype = T_FIRE;
e.isShopElement = !0;
e.onmouseup = buyItem;
stage.addChild(e);
e = new gameButton("buy", 160, 290);
e.onmouseup = buyCoins;
e.isShopElement = !0;
stage.addChild(e)
}
function buyCoins() {}
function coinsInc() {
coins++;
0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("coin_add", !1, !1, 0)
}
function addCoins() {
usedPoints -= 1e6;
coinsInc();
var e = library.getSprite("light_win");
e.x = 281;
e.y = 106;
stage.addChild(e);
var t = stage.setInterval(function() {
e.rotateBy(Math.PI / 160)
}, 3);
setTimeout(function() {
stage.clearInterval(t);
e.destroy = !0
}, 3500);
setUserCoins();
var n = library.getSprite("coin_rotate12");
n.x = 160;
n.y = 83;
n.animDelay = 2;
n.gotoAndPlay(0);
n.onenterframe = function(e) {
17 == e.target.currentFrame && (n.destroy = !0)
};
stage.addChild(n)
}
function buyItem(e) {
var t = e.target.gametype;
if (!(t == T_ETHER && 3 > coins || t == T_FIRE && 1 > coins)) {
var n = new GameElement(t);
n.setPosition(e.target.x, e.target.y);
var r = new GameElement(field.storedElement.gametype);
r.setPosition(field.storedElement.x, field.storedElement.y);
stage.addChild(n);
field.locked = !0;
n.moveTo(field.storedElement.x, field.storedElement.y, 6, Easing.cubic.easeIn, function(e) {
field.storedElement.setType(e.target.obj.gametype);
field.storedElement.visible = !0;
stage.removeChild(e.target.obj);
field.locked = !1
});
r.gametype > T_EMPTY && (field.storedElement.visible = !1, stage.removeChild(e.target.obj));
coins -= t == T_ETHER ? 3 : 1;
setUserCoins();
drawText("coins", 200, 180)
}
}
function destroyShop() {
for (var e = stage.objects.length, t = 0, e = stage.objects.length; t < e; t++) {
var n = stage.objects[t];
n.isShopElement && (n.destroy = !0)
}
field.locked = !1
}
function checkIfNeedPopup(e) {
if (3 >= field.upgradeType || 8 == field.upgradeType || Utils.getCookie("icon" + field.upgradeType + "ul")) return e(), !1;
if ("number" == typeof field.upgradeType) showEvolutionPopup(field.upgradeType, e);
else return e(), !0
}
function showEvolutionPopup(e, t) {
field.locked = !0;
var n = new Sprite(null, 320, 480);
n.setPosition(160, 240);
n.onmouseup = function() {
n.destroy = !0;
r.destroy = !0;
s.destroy = !0;
field.locked = !1;
t();
return !1
};
stage.addChild(n);
var r = new Sprite(library.getAsset("back_field-evolution-popup").bitmap, 411, 313);
r.setPosition(160, 240);
stage.addChild(r);
var i;
switch (e) {
case 4:
i = "lizard";
break;
case 5:
i = "wolf";
break;
case 6:
i = "ape";
break;
case 7:
i = "human";
break;
case 11:
i = "humanoid";
break;
case 12:
i = "superhuman";
break;
case 13:
i = "cyborg";
break;
case 14:
i = "geek";
break;
case 15:
i = "zombie";
break;
case 16:
i = "superbrains"
}
var s = new Sprite(library.getSprite(i).bitmap, 256, 80);
s.setPosition(r.x + 6, r.y + 8);
stage.addChild(s);
Utils.setCookie("icon" + field.upgradeType + "ul", !0)
}
function shuffle(e) {
for (var t, n, r = e.length; r; t = parseInt(Math.random() * r), n = e[--r], e[r] = e[t], e[t] = n);
}
function initializeUserScore() {
var e = Utils.getCookie("coins");
void 0 != e && (coins = parseInt(e));
gameScore = usedPoints = 0
}
function setUserCoins() {
Utils.setCookie("coins", coins)
}
function getScore() {
return score ? ~~score.getString() : 0
}
function setScore(e, t, n, r) {
gameScore += e;
usedPoints += e;
1e6 <= usedPoints && addCoins();
drawText("gameScore", 150, 110);
void 0 != t && (t = ~~t, r = ~~r, 0 != t && (e = new GUIString("baveuse", !1, {
align: STR_ALIGN_CENTER,
valign: STR_VALIGN_MIDDLE,
x: ~~n,
y: r
}), e.write((0 < t ? "+" : "") + t), t = stage.createTween(e, "y", r, r - 30, 12, Easing.linear.easeIn), r = stage.createTween(e, "opacity", 1, 0, 18, Easing.linear.easeIn), t.onchange = function(e) {
e.target.obj.setParams({
y: e.target.obj.y
})
}, r.onchange = function(e) {
e.target.obj.setParams({
opacity: e.target.obj.opacity
})
}, r.onfinish = function(e) {
e.target.obj.write("");
e.target.obj = null
}, t.play(), r.play()))
}
function buildBackground() {
stage.drawScene(document.getElementById("screen_background"), !0)
}
function submitScores() {
ExternalAPI.check() && ExternalAPI.checkUserLoggedIn() && insertScores()
}
function insertScores() {
ExternalAPI.check() && ExternalAPI.submitScores(gameScore, function() {})
}
function preTick() {}
function postTick() {}
function Text(e, t, n) {
this.ALIGN_LEFT = 0;
this.ALIGN_RIGHT = 1;
this.ALIGN_CENTER = 2;
this.font = e;
this.y = this.x = 0;
this.width = t;
this.height = n;
this.align = this.ALIGN_LEFT;
this.rotation = 0;
this.static = !1;
this.charMap = "0123456789:+".split("");
this.sprites = [];
this.text = "";
this.manageSprites = function(e) {
var t, n = e.length,
r = this.sprites.length;
if (r < n)
for (e = 0; e < n - r; e++) t = new Sprite(this.font, this.width, this.height, this.charMap.length), this.sprites.push(t), stage.addChild(t);
if (r > n) {
for (e = 0; e < r - n; e++) stage.removeChild(this.sprites[e]);
this.sprites.splice(0, r - n)
}
};
this.write = function(e) {
var t, n, r, i;
this.text = e += "";
this.manageSprites(e);
t = this.x;
this.align == this.ALIGN_CENTER && (t = this.x - (e.length - 1) / 2 * this.width);
this.align == this.ALIGN_RIGHT && (t = this.x - (e.length - 1) * this.width);
r = new Vector(t - this.x, 0);
r.rotate(-this.rotation);
t = r.x + this.x;
n = r.y + this.y;
r = new Vector(0, 0);
for (var s = 0; s < e.length; s++) this.sprites[s].visible = !0, i = this.charMap.indexOf(e.substr(s, 1)), 0 > i ? this.sprites[s].visible = !1 : (this.sprites[s].gotoAndStop(i), i = r.clone(), i.rotate(-this.rotation), this.sprites[s].x = i.x + t, this.sprites[s].y = i.y + n, this.sprites[s].rotation = this.rotation, this.sprites[s].static = this.static, r.x += this.width)
}
}
function clearText(e) {
for (var t = 0, n = stage.objects.length; t < n; t++) {
var r = stage.objects[t];
r[e] && (r.destroy = !0)
}
}
function drawLevelScore(e) {
var t = 160,
n = library.getAsset("font1", !0).bitmap;
gameScore += "";
for (var t = t - (gameScore.length - 1) / 2 * 12, r = 0; r < gameScore.length; r++) {
var i = new Sprite(n, 12, 20, 10);
i.gotoAndStop(gameScore.substr(r, 1));
i.x = t + 12 * r;
i.y = e;
stage.addChild(i)
}
}
function soundIconOnChange() {
1 == Utils.getCookie("soundOn") ? (soundOn = !1, sound.gotoAndStop(1), mixer2.play("main_theme", !0, !1, 0), Utils.setCookie("soundOn", 0)) : (soundOn = !0, sound.gotoAndStop(0), mixer2.stop(0), Utils.setCookie("soundOn", 1))
}
function drawText(e, t, n) {
clearText(e);
var r = library.getAsset("font1", !0).bitmap,
i = "coins" == e ? coins : gameScore,
i = i + "";
t -= (i.length - 1) / 2 * 12;
for (var s = 0; s < i.length; s++) mc = new Sprite(r, 12, 20, 10), mc[e] = !0, "coins" == e && (mc.isShopElement = !0), mc.gotoAndStop(i.substr(s, 1)), mc.x = t + 12 * s, mc.y = n, stage.addChild(mc)
}
function moveIconsHor(e) {
for (var t = 320 * (slidesNumber - 1) - 160, n = 0, r = stage.objects.length; n < r; n++) {
var i = stage.objects[n];
if (0 == i.id && i.x <= -t - 20 && 0 < e || 0 == i.id && 180 <= i.x && 0 > e) return !1;
i.isMovable && (i.x -= e)
}
}
function checkClosestFigure() {
for (var e = Number.POSITIVE_INFINITY, t = 0, n, r = 0, i = stage.objects.length; r < i; r++) {
var s = stage.objects[r],
o = Math.abs(s.x - 160);
s.isMovable && o <= e && (e = o, n = s.id, t = s.x - 160)
}
return {
l: t,
n: n
}
}
function moveSelector(e, t) {
e.x = 160 - 8 * slidesNumber / 2 + 8 * t
}
function showTutorialMenu() {
var e = new Sprite(library.getAsset("arrow_prev", !0).bitmap, 12, 31);
e.x = 10;
e.y = 285;
e.visible = !1;
e.onclick = function() {
if (e.visible) {
moveIconsHor(-320);
showArrows(e, t);
var n = checkClosestFigure();
moveSelector(i, n.n)
}
};
stage.addChild(e);
var t = new Sprite(library.getAsset("arrow_frwd", !0).bitmap, 12, 31);
t.x = 310;
t.y = 285;
t.onclick = function() {
if (t.visible) {
moveIconsHor(320);
showArrows(e, t);
var n = checkClosestFigure();
moveSelector(i, n.n)
}
};
stage.addChild(t);
var n = new Sprite(null, 300, 480);
n.x = 160;
n.y = 240;
n.static = !0;
n.onmousedown = function() {
startScrollPosition = window.event.pageX;
scrollLocked = !0
};
n.onmouseup = function() {
scrollLocked = !1;
var n = checkClosestFigure();
moveIconsHor(n.l);
moveSelector(i, n.n);
showArrows(e, t)
};
n.onmousemove = function() {
if (scrollLocked) {
var n = window.event.pageX;
moveIconsHor(.8 * (startScrollPosition - n));
startScrollPosition = n;
t.visible = e.visible = !1
}
};
n.onmouseout = function() {
scrollLocked = !1;
var n = checkClosestFigure();
moveIconsHor(n.l);
moveSelector(i, n.n);
showArrows(e, t)
};
stage.addChild(n);
n = new gameButton("menu", 160, 450);
n.addEventListener("mouseup", showMenu);
stage.addChild(n);
addSoundIcon();
slidesNumber = 4;
n = new Sprite(library.getAsset("Help1", !0).bitmap, 320, 480);
n.x = 160;
n.y = 240;
n.isMovable = !0;
n.id = 0;
showTutorialMenu.firstPage = n;
stage.addChild(n);
stage.addChild(library.getSprite("Help2", {
x: 480,
y: 240,
isMovable: !0,
id: 1
}));
stage.addChild(library.getSprite("Help3", {
x: 800,
y: 240,
isMovable: !0,
id: 2
}));
stage.addChild(library.getSprite("Help4", {
x: 1120,
y: 240,
isMovable: !0,
id: 3
}));
for (var n = 160 - 8 * slidesNumber / 2, r = 0; r < slidesNumber; r++) stage.addChild(library.getSprite("r1", {
x: n + 8 * r,
y: 473
}));
var i = new Sprite(library.getAsset("r2", !0).bitmap, 6, 6);
i.x = n;
i.y = 473;
stage.addChild(i)
}
function showArrows(e, t) {
var n = showTutorialMenu.firstPage.x;
e.visible = 150 > n ? !0 : !1;
t.visible = n <= 180 - 320 * (slidesNumber - 1) ? !1 : !0
}
function showTutorial(e, t) {
"easy" == currentDifficulty && (t[0].setType(22), t[1].setType(22), t[4].setType(22), t[21].setType(22), t[19].setType(1), t[5].setType(1), t[20].setType(1), t[15].setType(1), t[13].setType(2), t[16].setType(3), showTutorial_1());
"medium" == currentDifficulty && (t[2].setType(22), t[10].setType(22), t[23].setType(22), t[9].setType(22), t[0].setType(1), t[8].setType(1), t[22].setType(1), t[16].setType(2), t[17].setType(2), showTutorial_10());
"hard" == currentDifficulty && (t[23].setType(22), t[19].setType(22), t[5].setType(22), t[16].setType(1), t[17].setType(1), t[3].setType(1), t[6].setType(2), showTutorial_11());
"ultimate" == currentDifficulty && showTutorial_14()
}
function fadeOut(e) {
e.opacity = 1;
e = e.addTween("opacity", 0, 10, Easing.linear.out, null, null);
setTimeout(e.play, 100)
}
function clearTutorialSprites() {
for (var e = 0, t = tutArray.length; e < t; e++) fadeOut(tutArray[e]);
tutArray = []
}
function showTutorial_1() {
var e = library.getSprite("txt_17");
e.x = 170;
e.y = 380;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
setTimeout(function() {
fadeOut(e)
}, 2e3);
var n = library.getSprite("txt_18");
n.x = 120;
n.y = 170;
n.opacity = 0;
stage.addChild(n);
t = n.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 3e3);
setTimeout(function() {
fadeOut(n)
}, 5e3);
t = library.getSprite("txt_16");
t.x = 95;
t.y = 175;
t.opacity = 0;
stage.addChild(t);
var r = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(r.play, 6e3);
tutArray.push(t);
t = library.getSprite("txt_12");
t.x = 215;
t.y = 280;
t.opacity = 0;
stage.addChild(t);
tutArray.push(t);
fillGameElementArray();
var i = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
i.play();
gameElementArray[18].addEventListener("mouseup", tutDone)
}, 8e3)
}
function tutDone() {
clearTutorialSprites();
tut01completed ? tut02completed ? tut04completed ? tut05completed ? tut06completed ? tut07completed ? tut08completed ? checkTurorial() : showTutorial_8() : checkTurorial() : checkTurorial() : (tut05completed = !0, showTutorial_5_1()) : (tut04completed = !0, checkTurorial()) : (tut02completed = !0, checkTurorial()) : (tut01completed = !0, checkTurorial())
}
function fillGameElementArray() {
gameElementArray = [];
for (var e = 0, t = stage.objects.length; e < t; e++) "gameCell" == stage.objects[e].type && gameElementArray.push(stage.objects[e])
}
function showTutorial_2() {
var e = library.getSprite("txt_2");
e.x = 160;
e.y = 200;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_11");
e.x = 160;
e.y = 280;
e.opacity = 0;
stage.addChild(e);
tutArray.push(e);
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
n.play();
gameElementArray[17].addEventListener("mouseup", tutDone)
}, 3e3)
}
function showTutorial_3() {
var e = library.getSprite("txt_7");
e.x = 265;
e.y = 130;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
setTimeout(function() {
fadeOut(e)
}, 2500);
tut03completed = !0;
setTimeout(checkTurorial, 2500)
}
function showTutorial_4() {
var e = library.getSprite("txt_6");
e.x = 120;
e.y = 170;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_10");
e.x = 190;
e.y = 230;
e.opacity = 0;
stage.addChild(e);
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
tutArray.push(e);
setTimeout(function() {
n.play();
gameElementArray[4].addEventListener("mouseup", tutDone)
}, 3e3)
}
function showTutorial_5() {
var e = library.getSprite("txt_20");
e.x = 180;
e.y = 200;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e)
}
function showTutorial_5_1() {
var e = library.getSprite("txt_13");
e.x = 160;
e.y = 195;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
tutArray.push(e);
setTimeout(function() {
t.play();
gameElementArray[7].addEventListener("mouseup", tutDone)
}, 100)
}
function showTutorial_6() {
var e = library.getSprite("txt_13");
e.x = 210;
e.y = 200;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
t.play();
gameElementArray[8].addEventListener("mouseup", tutDone)
}, 100);
tutArray.push(e)
}
function showTutorial_7() {
var e = library.getSprite("txt_14");
e.x = 170;
e.y = 180;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e)
}
function showTutorial_8() {
var e = library.getSprite("txt_13");
e.x = 160;
e.y = 250;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
tutArray.push(e);
setTimeout(function() {
t.play();
gameElementArray[12].addEventListener("mouseup", checkTurorial)
}, 100)
}
function checkTurorial() {
if ("easy" == currentDifficulty) {
if (!tut01completed) {
showTutorial_1();
return
}
if (!tut02completed) {
gameElementArray[18].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[18].dispatchEvent("mouseup", {
target: gameElementArray[18]
});
blockForTutorial = !0;
showTutorial_2();
return
}
if (!tut03completed) {
gameElementArray[17].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[17].dispatchEvent("mouseup", {
target: gameElementArray[17]
});
blockForTutorial = !0;
setTimeout(showTutorial_3, 2500);
return
}
if (!tut04completed) {
showTutorial_4();
return
}
if (!tut05completed) {
gameElementArray[4].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[4].dispatchEvent("mouseup", {
target: gameElementArray[4]
});
blockForTutorial = !0;
showTutorial_5();
return
}
if (!tut06completed) {
gameElementArray[7].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[7].dispatchEvent("mouseup", {
target: gameElementArray[7]
});
tut06completed = blockForTutorial = !0;
showTutorial_6();
return
}
if (!tut07completed) {
gameElementArray[8].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[8].dispatchEvent("mouseup", {
target: gameElementArray[8]
});
tut07completed = blockForTutorial = !0;
showTutorial_7();
return
}
if (!tut08completed) {
clearTutorialSprites();
gameElementArray[12].removeEventListener("mouseup", checkTurorial);
blockForTutorial = !1;
gameElementArray[12].dispatchEvent("mouseup", {
target: gameElementArray[12]
});
tutorialActivated = !1;
tut08completed = !0;
levelTutorialCompleted();
return
}
}
if ("medium" != currentDifficulty || tut10completed) {
if ("hard" == currentDifficulty) {
if (!tut11completed) {
tut11completed = !0;
gameElementArray[18].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[18].dispatchEvent("mouseup", {
target: gameElementArray[18]
});
blockForTutorial = !0;
showTutorial_12();
return
}
if (!tut12completed) {
gameElementArray[13].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[13].dispatchEvent("mouseup", {
target: gameElementArray[13]
});
tut12completed = blockForTutorial = !0;
showTutorial_12_1();
return
}
if (!tut12_1completed) {
gameElementArray[18].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[18].dispatchEvent("mouseup", {
target: gameElementArray[18]
});
tut12_1completed = blockForTutorial = !0;
showTutorial_13();
return
}
if (!tut13completed) {
gameElementArray[24].removeEventListener("mouseup", tutDone);
blockForTutorial = !1;
gameElementArray[24].dispatchEvent("mouseup", {
target: gameElementArray[24]
});
tutorialActivated = !1;
tut13completed = !0;
levelTutorialCompleted();
return
}
}
"ultimate" != currentDifficulty || tut15completed || (tutorialActivated = blockForTutorial = !1, tut15completed = !0, showTutorial_15(), levelTutorialCompleted())
} else gameElementArray[18].removeEventListener("mouseup", tutDone), blockForTutorial = !1, gameElementArray[18].dispatchEvent("mouseup", {
target: gameElementArray[18]
}), tutorialActivated = !1, tut10completed = !0, showTutorial_9(), levelTutorialCompleted()
}
function levelTutorialCompleted() {
Utils.setCookie(currentDifficulty + "_tutorial_completed", !0)
}
function resetTutorialVariables() {
tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = tut14completed = tut15completed = blockForTutorial = !1
}
function checkDifficulty() {
resetTutorialVariables();
"easy" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? blockForTutorial = tutorialActivated = !0 : "medium" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = blockForTutorial = tutorialActivated = !0 : "hard" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = blockForTutorial = tutorialActivated = !0 : ("expert" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") && (tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = !0), "ultimate" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? (tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = tutorialActivated = !0, coins++) : tutorialActivated = !1)
}
function showTutorial_10() {
var e = library.getSprite("txt_5");
e.x = 95;
e.y = 192;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_13");
e.x = 210;
e.y = 295;
e.opacity = 0;
stage.addChild(e);
fillGameElementArray();
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
n.play();
gameElementArray[18].addEventListener("mouseup", tutDone)
}, 3e3);
tutArray.push(e)
}
function showTutorial_9() {
var e = library.getSprite("txt_3");
e.x = 160;
e.y = 220;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
setTimeout(function() {
fadeOut(e)
}, 5e3)
}
function showTutorial_11() {
var e = library.getSprite("txt_4");
e.x = 120;
e.y = 178;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_13");
e.x = 210;
e.y = 295;
e.opacity = 0;
stage.addChild(e);
fillGameElementArray();
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
n.play();
gameElementArray[18].addEventListener("mouseup", tutDone)
}, 3e3);
tutArray.push(e)
}
function showTutorial_12() {
var e = library.getSprite("txt_8");
e.x = 105;
e.y = 320;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_13");
e.x = 210;
e.y = 250;
e.opacity = 0;
stage.addChild(e);
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
n.play();
gameElementArray[13].addEventListener("mouseup", tutDone)
}, 3e3);
tutArray.push(e)
}
function showTutorial_12_1() {
var e = library.getSprite("txt_13");
e.x = 210;
e.y = 300;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
t.play();
gameElementArray[18].addEventListener("mouseup", tutDone)
}, 1e3);
tutArray.push(e)
}
function showTutorial_13() {
var e = library.getSprite("txt_1");
e.x = 155;
e.y = 192;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 100);
tutArray.push(e);
e = library.getSprite("txt_9");
e.x = 195;
e.y = 330;
e.opacity = 0;
stage.addChild(e);
var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(function() {
n.play();
gameElementArray[24].addEventListener("mouseup", tutDone)
}, 3e3);
tutArray.push(e)
}
function showTutorial_14() {
blockForTutorial = !0;
var e = library.getSprite("txt_19");
e.x = 165;
e.y = 175;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 1e3);
tutArray.push(e);
tut14completed = !0
}
function showTutorial_15() {
var e = library.getSprite("txt_9");
e.x = 130;
e.y = 150;
e.opacity = 0;
stage.addChild(e);
var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
setTimeout(t.play, 1e3);
setTimeout(clearTutorialSprites, 3e3);
tutArray.push(e)
}
function showMissionInfo() {
stage.stop();
var e = new Sprite(null, 320, 480);
e.x = 160;
e.y = 240;
e.isMissionElement = !0;
e.onmouseup = function() {
gameState = STATE_GAME;
createScene();
return !1
};
stage.addChild(e);
stage.addChild(library.getSprite("mission_bg", {
x: 160,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("unicellar", {
x: 55,
y: 240,
isMissionElement: !0,
first: !0
}));
stage.addChild(library.getSprite("meduze", {
x: 120,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("fish", {
x: 185,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 87,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 152,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 217,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 282,
y: 240,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 37,
y: 295,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 102,
y: 295,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 167,
y: 295,
isMissionElement: !0
}));
stage.addChild(library.getSprite("arrow", {
x: 232,
y: 295,
isMissionElement: !0
}));
"easy" == currentDifficulty ? (stage.addChild(library.getSprite("mission_untitled_b", {
x: 250,
y: 240,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 70,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 135,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 200,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_create_1", {
x: 160,
y: 335,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 265,
y: 295,
isMissionElement: !0
}))) : "medium" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
x: 250,
y: 240,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_b", {
x: 70,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 135,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 200,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_create_2", {
x: 160,
y: 335,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 265,
y: 295,
isMissionElement: !0
}))) : "hard" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
x: 250,
y: 240,
isMissionElement: !0
})), stage.addChild(library.getSprite("mammal", {
x: 70,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_b", {
x: 135,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 200,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_create_3", {
x: 160,
y: 335,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 265,
y: 295,
isMissionElement: !0
}))) : "expert" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
x: 250,
y: 240,
isMissionElement: !0
})), stage.addChild(library.getSprite("mammal", {
x: 70,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("people", {
x: 135,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_b", {
x: 200,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_create_4", {
x: 160,
y: 335,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_a", {
x: 265,
y: 295,
isMissionElement: !0
}))) : "ultimate" == currentDifficulty && (stage.addChild(library.getSprite("pangolin", {
x: 250,
y: 240,
isMissionElement: !0
})), stage.addChild(library.getSprite("mammal", {
x: 70,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("people", {
x: 135,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("uslon", {
x: 200,
y: 295,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_create_5", {
x: 160,
y: 335,
isMissionElement: !0
})), stage.addChild(library.getSprite("mission_untitled_b", {
x: 265,
y: 295,
isMissionElement: !0
})))
}
function checkIfNeedLaunchTutorial(e, t) {
if ("easy" == currentDifficulty && tutorialActivated || "medium" == currentDifficulty && tutorialActivated || "hard" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !0;
if ("ultimate" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !1
}
var CRENDER_DEBUG = !1;
var Utils = {
touchScreen: "ontouchstart" in window,
globalScale: 1,
setCookie: function(e, t) {
try {
window.localStorage.setItem(e, t)
} catch (n) {
var r = new Date;
r.setDate(r.getDate() + 3650);
document.cookie = e + "=" + t + "; expires=" + r.toUTCString()
}
},
getCookie: function(e) {
var t;
try {
t = window.localStorage.getItem(e)
} catch (n) {
e += "=";
t = document.cookie.indexOf(e);
if (-1 == t) return null;
var r = document.cookie.indexOf(";", t + e.length); - 1 == r && (r = document.cookie.length);
t = unescape(document.cookie.substring(t + e.length, r))
}
return t
},
bindEvent: function(e, t, n) {
e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n)
},
getObjectLeft: function(e) {
var t = e.offsetLeft;
e.offsetParent && (t += Utils.getObjectLeft(e.offsetParent));
return t
},
getObjectTop: function(e) {
var t = e.offsetTop;
e.offsetParent && (t += Utils.getObjectTop(e.offsetParent));
return t
},
parseGet: function() {
var e = {},
t = new String(window.location),
n = t.indexOf("?");
if (-1 != n)
for (var t = t.substr(n + 1, t.length), n = t.split("&"), r = 0; r < n.length; r++) t = n[r].split("="), e[t[0]] = t[1];
return e
},
globalPixelScale: 1,
getMouseCoord: function(e, t) {
var n = e || window.event;
n.touches && (n = n.touches[0]);
if (!n) return {
x: 0,
y: 0
};
var r = 0,
i = 0,
s = 0,
o = 0;
t && (r = Utils.getObjectLeft(t), i = Utils.getObjectTop(t));
if (n.pageX || n.pageY) s = n.pageX, o = n.pageY;
else if (n.clientX || n.clientY) s = n.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft, o = n.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
return {
x: s - r,
y: o - i
}
},
extend: function(e, t) {
var n = function() {};
n.prototype = t.prototype;
e.prototype = new n;
e.prototype.constructor = e;
e.superclass = t.prototype
},
removeFromArray: function(e, t) {
for (var n = [], r = 0; r < e.length; r++) e[r] != t && n.push(e[r]);
return n
},
showLoadProgress: function(e) {
var t = Utils.globalScale,
n;
n = "Loading: " + e + "%
";
n += '