Created
December 20, 2016 19:54
-
-
Save thomasboyt/5ab294b47b015aa89112e7ce9f1cd5f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Polymer({ | |
is: "google-legacy-loader", | |
behaviors: [Polymer.IronJsonpLibraryBehavior], | |
properties: { | |
libraryUrl: { | |
type: String, | |
value: "https://www.google.com/jsapi?callback=%%callback%%" | |
}, | |
notifyEvent: { | |
type: String, | |
value: "api-load" | |
} | |
}, | |
get api() { | |
return google | |
} | |
}) | |
var scenes = scenes || {}; | |
scenes.wrapbattle = scenes.wrapbattle || {}, | |
function() { | |
function Gameover(t, e) { | |
this._hasPlayExtra = (this.game = t) && "playExtra"in this.game | |
} | |
function SharedGameOver() {} | |
function Scoreboard(t, e, o) { | |
this.game = t, | |
this.initialCountdown_ = isFinite(Constants.INITIAL_COUNTDOWN) ? Constants.INITIAL_COUNTDOWN : 60, | |
this.levels = o || 0, | |
this.score = this.level = 0, | |
this.countdown = this.initialCountdown_, | |
this.losing = !1, | |
this.lastSeconds = NaN, | |
this.announceTimeout_ = 0 | |
} | |
function SharedGame() {} | |
function LevelUp(t, e, o) { | |
this.bgElem = $(e), | |
this.numberElem = $(o), | |
this.onResizeBound_ = this.onResize_.bind(this), | |
$(window).on("resize", this.onResizeBound_), | |
this.onResize_() | |
} | |
function timeoutOneEvent(t, e, o, a) { | |
function n() { | |
s || (s = !0, | |
t.removeEventListener(e, n), | |
a && a()) | |
} | |
t = app.shared.utils.unwrapElement(t); | |
var s = !1; | |
t.addEventListener(e, n), | |
window.setTimeout(n, 1e3 * o) | |
} | |
var global = window | |
, $jscomp = { | |
scope: {} | |
}; | |
$jscomp.defineProperty = "function" == typeof Object.defineProperties ? Object.defineProperty : function(t, e, o) { | |
if (o.get || o.set) | |
throw new TypeError("ES3 does not support getters and setters."); | |
t != Array.prototype && t != Object.prototype && (t[e] = o.value) | |
} | |
, | |
$jscomp.getGlobal = function(t) { | |
return "undefined" != typeof window && window === t ? t : "undefined" != typeof global && null != global ? global : t | |
} | |
, | |
$jscomp.global = $jscomp.getGlobal(this), | |
$jscomp.SYMBOL_PREFIX = "jscomp_symbol_", | |
$jscomp.initSymbol = function() { | |
$jscomp.initSymbol = function() {} | |
, | |
$jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol) | |
} | |
, | |
$jscomp.symbolCounter_ = 0, | |
$jscomp.Symbol = function(t) { | |
return $jscomp.SYMBOL_PREFIX + (t || "") + $jscomp.symbolCounter_++ | |
} | |
, | |
$jscomp.initSymbolIterator = function() { | |
$jscomp.initSymbol(); | |
var t = $jscomp.global.Symbol.iterator; | |
t || (t = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator")), | |
"function" != typeof Array.prototype[t] && $jscomp.defineProperty(Array.prototype, t, { | |
configurable: !0, | |
writable: !0, | |
value: function() { | |
return $jscomp.arrayIterator(this) | |
} | |
}), | |
$jscomp.initSymbolIterator = function() {} | |
} | |
, | |
$jscomp.arrayIterator = function(t) { | |
var e = 0; | |
return $jscomp.iteratorPrototype(function() { | |
return e < t.length ? { | |
done: !1, | |
value: t[e++] | |
} : { | |
done: !0 | |
} | |
}) | |
} | |
, | |
$jscomp.iteratorPrototype = function(t) { | |
return $jscomp.initSymbolIterator(), | |
t = { | |
next: t | |
}, | |
t[$jscomp.global.Symbol.iterator] = function() { | |
return this | |
} | |
, | |
t | |
} | |
, | |
$jscomp.makeIterator = function(t) { | |
$jscomp.initSymbolIterator(); | |
var e = t[Symbol.iterator]; | |
return e ? e.call(t) : $jscomp.arrayIterator(t) | |
} | |
, | |
$jscomp.arrayFromIterator = function(t) { | |
for (var e, o = []; !(e = t.next()).done; ) | |
o.push(e.value); | |
return o | |
} | |
, | |
$jscomp.arrayFromIterable = function(t) { | |
return t instanceof Array ? t : $jscomp.arrayFromIterator($jscomp.makeIterator(t)) | |
} | |
; | |
var COMPILED = !0 | |
, goog = goog || {}; | |
goog.global = this, | |
goog.isDef = function(t) { | |
return void 0 !== t | |
} | |
, | |
goog.exportPath_ = function(t, e, o) { | |
t = t.split("."), | |
o = o || goog.global, | |
t[0]in o || !o.execScript || o.execScript("var " + t[0]); | |
for (var a; t.length && (a = t.shift()); ) | |
!t.length && goog.isDef(e) ? o[a] = e : o = o[a] ? o[a] : o[a] = {} | |
} | |
, | |
goog.define = function(t, e) { | |
COMPILED || (goog.global.CLOSURE_UNCOMPILED_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES, t) ? e = goog.global.CLOSURE_UNCOMPILED_DEFINES[t] : goog.global.CLOSURE_DEFINES && Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES, t) && (e = goog.global.CLOSURE_DEFINES[t])), | |
goog.exportPath_(t, e) | |
} | |
, | |
goog.DEBUG = !0, | |
goog.LOCALE = "en", | |
goog.TRUSTED_SITE = !0, | |
goog.STRICT_MODE_COMPATIBLE = !1, | |
goog.DISALLOW_TEST_ONLY_CODE = COMPILED && !goog.DEBUG, | |
goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING = !1, | |
goog.provide = function(t) { | |
if (goog.isInModuleLoader_()) | |
throw Error("goog.provide can not be used within a goog.module."); | |
if (!COMPILED && goog.isProvided_(t)) | |
throw Error('Namespace "' + t + '" already declared.'); | |
goog.constructNamespace_(t) | |
} | |
, | |
goog.constructNamespace_ = function(t, e) { | |
if (!COMPILED) { | |
delete goog.implicitNamespaces_[t]; | |
for (var o = t; (o = o.substring(0, o.lastIndexOf("."))) && !goog.getObjectByName(o); ) | |
goog.implicitNamespaces_[o] = !0 | |
} | |
goog.exportPath_(t, e) | |
} | |
, | |
goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/, | |
goog.module = function(t) { | |
if (!goog.isString(t) || !t || -1 == t.search(goog.VALID_MODULE_RE_)) | |
throw Error("Invalid module identifier"); | |
if (!goog.isInModuleLoader_()) | |
throw Error("Module " + t + " has been loaded incorrectly. Note, modules cannot be loaded as normal scripts. They require some kind of pre-processing step. You're likely trying to load a module via a script tag or as a part of a concatenated bundle without rewriting the module. For more info see: https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide."); | |
if (goog.moduleLoaderState_.moduleName) | |
throw Error("goog.module may only be called once per module."); | |
if (goog.moduleLoaderState_.moduleName = t, | |
!COMPILED) { | |
if (goog.isProvided_(t)) | |
throw Error('Namespace "' + t + '" already declared.'); | |
delete goog.implicitNamespaces_[t] | |
} | |
} | |
, | |
goog.module.get = function(t) { | |
return goog.module.getInternal_(t) | |
} | |
, | |
goog.module.getInternal_ = function(t) { | |
if (!COMPILED) | |
return goog.isProvided_(t) ? t in goog.loadedModules_ ? goog.loadedModules_[t] : goog.getObjectByName(t) : null | |
} | |
, | |
goog.moduleLoaderState_ = null, | |
goog.isInModuleLoader_ = function() { | |
return null != goog.moduleLoaderState_ | |
} | |
, | |
goog.module.declareLegacyNamespace = function() { | |
if (!COMPILED && !goog.isInModuleLoader_()) | |
throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module"); | |
if (!COMPILED && !goog.moduleLoaderState_.moduleName) | |
throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace."); | |
goog.moduleLoaderState_.declareLegacyNamespace = !0 | |
} | |
, | |
goog.setTestOnly = function(t) { | |
if (goog.DISALLOW_TEST_ONLY_CODE) | |
throw t = t || "", | |
Error("Importing test-only code into non-debug environment" + (t ? ": " + t : ".")) | |
} | |
, | |
goog.forwardDeclare = function(t) {} | |
, | |
COMPILED || (goog.isProvided_ = function(t) { | |
return t in goog.loadedModules_ || !goog.implicitNamespaces_[t] && goog.isDefAndNotNull(goog.getObjectByName(t)) | |
} | |
, | |
goog.implicitNamespaces_ = { | |
"goog.module": !0 | |
}), | |
goog.getObjectByName = function(t, e) { | |
t = t.split("."), | |
e = e || goog.global; | |
for (var o; o = t.shift(); ) { | |
if (!goog.isDefAndNotNull(e[o])) | |
return null; | |
e = e[o] | |
} | |
return e | |
} | |
, | |
goog.globalize = function(t, e) { | |
e = e || goog.global; | |
for (var o in t) | |
e[o] = t[o] | |
} | |
, | |
goog.addDependency = function(t, e, o, a) { | |
if (goog.DEPENDENCIES_ENABLED) { | |
var n; | |
t = t.replace(/\\/g, "/"); | |
var s = goog.dependencies_; | |
a && "boolean" != typeof a || (a = a ? { | |
module: "goog" | |
} : {}); | |
for (var i = 0; n = e[i]; i++) | |
s.nameToPath[n] = t, | |
s.loadFlags[t] = a; | |
for (a = 0; e = o[a]; a++) | |
t in s.requires || (s.requires[t] = {}), | |
s.requires[t][e] = !0 | |
} | |
} | |
, | |
goog.ENABLE_DEBUG_LOADER = !0, | |
goog.logToConsole_ = function(t) { | |
goog.global.console && goog.global.console.error(t) | |
} | |
, | |
goog.require = function(t) { | |
if (!COMPILED) { | |
if (goog.ENABLE_DEBUG_LOADER && goog.IS_OLD_IE_ && goog.maybeProcessDeferredDep_(t), | |
goog.isProvided_(t)) { | |
if (goog.isInModuleLoader_()) | |
return goog.module.getInternal_(t) | |
} else if (goog.ENABLE_DEBUG_LOADER) { | |
var e = goog.getPathFromDeps_(t); | |
if (!e) | |
throw t = "goog.require could not find: " + t, | |
goog.logToConsole_(t), | |
Error(t); | |
goog.writeScripts_(e) | |
} | |
return null | |
} | |
} | |
, | |
goog.basePath = "", | |
goog.nullFunction = function() {} | |
, | |
goog.abstractMethod = function() { | |
throw Error("unimplemented abstract method") | |
} | |
, | |
goog.addSingletonGetter = function(t) { | |
t.getInstance = function() { | |
return t.instance_ ? t.instance_ : (goog.DEBUG && (goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = t), | |
t.instance_ = new t) | |
} | |
} | |
, | |
goog.instantiatedSingletons_ = [], | |
goog.LOAD_MODULE_USING_EVAL = !0, | |
goog.SEAL_MODULE_EXPORTS = goog.DEBUG, | |
goog.loadedModules_ = {}, | |
goog.DEPENDENCIES_ENABLED = !COMPILED && goog.ENABLE_DEBUG_LOADER, | |
goog.TRANSPILE = "detect", | |
goog.TRANSPILER = "transpile.js", | |
goog.DEPENDENCIES_ENABLED && (goog.dependencies_ = { | |
loadFlags: {}, | |
nameToPath: {}, | |
requires: {}, | |
visited: {}, | |
written: {}, | |
deferred: {} | |
}, | |
goog.inHtmlDocument_ = function() { | |
var t = goog.global.document; | |
return null != t && "write"in t | |
} | |
, | |
goog.findBasePath_ = function() { | |
if (goog.isDef(goog.global.CLOSURE_BASE_PATH)) | |
goog.basePath = goog.global.CLOSURE_BASE_PATH; | |
else if (goog.inHtmlDocument_()) | |
for (var t = goog.global.document.getElementsByTagName("SCRIPT"), e = t.length - 1; 0 <= e; --e) { | |
var o = t[e].src | |
, a = o.lastIndexOf("?") | |
, a = -1 == a ? o.length : a; | |
if ("base.js" == o.substr(a - 7, 7)) { | |
goog.basePath = o.substr(0, a - 7); | |
break | |
} | |
} | |
} | |
, | |
goog.importScript_ = function(t, e) { | |
(goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_)(t, e) && (goog.dependencies_.written[t] = !0) | |
} | |
, | |
goog.IS_OLD_IE_ = !(goog.global.atob || !goog.global.document || !goog.global.document.all), | |
goog.importProcessedScript_ = function(t, e, o) { | |
goog.importScript_("", 'goog.retrieveAndExec_("' + t + '", ' + e + ", " + o + ");") | |
} | |
, | |
goog.queuedModules_ = [], | |
goog.wrapModule_ = function(t, e) { | |
return goog.LOAD_MODULE_USING_EVAL && goog.isDef(goog.global.JSON) ? "goog.loadModule(" + goog.global.JSON.stringify(e + "\n//# sourceURL=" + t + "\n") + ");" : 'goog.loadModule(function(exports) {"use strict";' + e + "\n;return exports});\n//# sourceURL=" + t + "\n" | |
} | |
, | |
goog.loadQueuedModules_ = function() { | |
var t = goog.queuedModules_.length; | |
if (0 < t) { | |
var e = goog.queuedModules_; | |
goog.queuedModules_ = []; | |
for (var o = 0; o < t; o++) | |
goog.maybeProcessDeferredPath_(e[o]) | |
} | |
} | |
, | |
goog.maybeProcessDeferredDep_ = function(t) { | |
goog.isDeferredModule_(t) && goog.allDepsAreAvailable_(t) && (t = goog.getPathFromDeps_(t), | |
goog.maybeProcessDeferredPath_(goog.basePath + t)) | |
} | |
, | |
goog.isDeferredModule_ = function(t) { | |
var e = (t = goog.getPathFromDeps_(t)) && goog.dependencies_.loadFlags[t] || {} | |
, o = e.lang || "es3"; | |
return !(!t || "goog" != e.module && !goog.needsTranspile_(o)) && goog.basePath + t in goog.dependencies_.deferred | |
} | |
, | |
goog.allDepsAreAvailable_ = function(t) { | |
if ((t = goog.getPathFromDeps_(t)) && t in goog.dependencies_.requires) | |
for (var e in goog.dependencies_.requires[t]) | |
if (!goog.isProvided_(e) && !goog.isDeferredModule_(e)) | |
return !1; | |
return !0 | |
} | |
, | |
goog.maybeProcessDeferredPath_ = function(t) { | |
if (t in goog.dependencies_.deferred) { | |
var e = goog.dependencies_.deferred[t]; | |
delete goog.dependencies_.deferred[t], | |
goog.globalEval(e) | |
} | |
} | |
, | |
goog.loadModuleFromUrl = function(t) { | |
goog.retrieveAndExec_(t, !0, !1) | |
} | |
, | |
goog.writeScriptSrcNode_ = function(t) { | |
goog.global.document.write('<script type="text/javascript" src="' + t + '"><\/script>') | |
} | |
, | |
goog.appendScriptSrcNode_ = function(t) { | |
var e = goog.global.document | |
, o = e.createElement("script"); | |
o.type = "text/javascript", | |
o.src = t, | |
o.defer = !1, | |
o.async = !1, | |
e.head.appendChild(o) | |
} | |
, | |
goog.writeScriptTag_ = function(t, e) { | |
if (goog.inHtmlDocument_()) { | |
var o = goog.global.document; | |
if (!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING && "complete" == o.readyState) { | |
if (/\bdeps.js$/.test(t)) | |
return !1; | |
throw Error('Cannot write "' + t + '" after document load') | |
} | |
return void 0 === e ? goog.IS_OLD_IE_ ? (e = " onreadystatechange='goog.onScriptLoad_(this, " + ++goog.lastNonModuleScriptIndex_ + ")' ", | |
o.write('<script type="text/javascript" src="' + t + '"' + e + "><\/script>")) : goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING ? goog.appendScriptSrcNode_(t) : goog.writeScriptSrcNode_(t) : o.write('<script type="text/javascript">' + goog.protectScriptTag_(e) + "<\/script>"), | |
!0 | |
} | |
return !1 | |
} | |
, | |
goog.protectScriptTag_ = function(t) { | |
return t.replace(/<\/(SCRIPT)>/gi, "\\x3c\\$1>") | |
} | |
, | |
goog.needsTranspile_ = function(t) { | |
if ("always" == goog.TRANSPILE) | |
return !0; | |
if ("never" == goog.TRANSPILE) | |
return !1; | |
if (goog.requiresTranspilation_ || (goog.requiresTranspilation_ = goog.createRequiresTranspilation_()), | |
t in goog.requiresTranspilation_) | |
return goog.requiresTranspilation_[t]; | |
throw Error("Unknown language mode: " + t) | |
} | |
, | |
goog.requiresTranspilation_ = null, | |
goog.lastNonModuleScriptIndex_ = 0, | |
goog.onScriptLoad_ = function(t, e) { | |
return "complete" == t.readyState && goog.lastNonModuleScriptIndex_ == e && goog.loadQueuedModules_(), | |
!0 | |
} | |
, | |
goog.writeScripts_ = function(t) { | |
function e(t) { | |
if (!(t in n.written || t in n.visited)) { | |
if (n.visited[t] = !0, | |
t in n.requires) | |
for (var s in n.requires[t]) | |
if (!goog.isProvided_(s)) { | |
if (!(s in n.nameToPath)) | |
throw Error("Undefined nameToPath for " + s); | |
e(n.nameToPath[s]) | |
} | |
t in a || (a[t] = !0, | |
o.push(t)) | |
} | |
} | |
var o = [] | |
, a = {} | |
, n = goog.dependencies_; | |
for (e(t), | |
t = 0; t < o.length; t++) { | |
var s = o[t]; | |
goog.dependencies_.written[s] = !0 | |
} | |
var i = goog.moduleLoaderState_; | |
for (goog.moduleLoaderState_ = null, | |
t = 0; t < o.length; t++) { | |
if (!(s = o[t])) | |
throw goog.moduleLoaderState_ = i, | |
Error("Undefined script input"); | |
var r = n.loadFlags[s] || {} | |
, p = goog.needsTranspile_(r.lang || "es3"); | |
"goog" == r.module || p ? goog.importProcessedScript_(goog.basePath + s, "goog" == r.module, p) : goog.importScript_(goog.basePath + s) | |
} | |
goog.moduleLoaderState_ = i | |
} | |
, | |
goog.getPathFromDeps_ = function(t) { | |
return t in goog.dependencies_.nameToPath ? goog.dependencies_.nameToPath[t] : null | |
} | |
, | |
goog.findBasePath_(), | |
goog.global.CLOSURE_NO_DEPS || goog.importScript_(goog.basePath + "deps.js")), | |
goog.loadModule = function(t) { | |
var e = goog.moduleLoaderState_; | |
try { | |
goog.moduleLoaderState_ = { | |
moduleName: void 0, | |
declareLegacyNamespace: !1 | |
}; | |
var o; | |
if (goog.isFunction(t)) | |
o = t.call(void 0, {}); | |
else { | |
if (!goog.isString(t)) | |
throw Error("Invalid module definition"); | |
o = goog.loadModuleFromSource_.call(void 0, t) | |
} | |
var a = goog.moduleLoaderState_.moduleName; | |
if (!goog.isString(a) || !a) | |
throw Error('Invalid module name "' + a + '"'); | |
goog.moduleLoaderState_.declareLegacyNamespace ? goog.constructNamespace_(a, o) : goog.SEAL_MODULE_EXPORTS && Object.seal && goog.isObject(o) && Object.seal(o), | |
goog.loadedModules_[a] = o | |
} finally { | |
goog.moduleLoaderState_ = e | |
} | |
} | |
, | |
goog.loadModuleFromSource_ = function(a) { | |
return eval(a), | |
{} | |
} | |
, | |
goog.normalizePath_ = function(t) { | |
t = t.split("/"); | |
for (var e = 0; e < t.length; ) | |
"." == t[e] ? t.splice(e, 1) : e && ".." == t[e] && t[e - 1] && ".." != t[e - 1] ? t.splice(--e, 2) : e++; | |
return t.join("/") | |
} | |
, | |
goog.loadFileSync_ = function(t) { | |
if (goog.global.CLOSURE_LOAD_FILE_SYNC) | |
return goog.global.CLOSURE_LOAD_FILE_SYNC(t); | |
try { | |
var e = new goog.global.XMLHttpRequest; | |
return e.open("get", t, !1), | |
e.send(), | |
0 == e.status || 200 == e.status ? e.responseText : null | |
} catch (t) { | |
return null | |
} | |
} | |
, | |
goog.retrieveAndExec_ = function(t, e, o) { | |
if (!COMPILED) { | |
var a = t; | |
t = goog.normalizePath_(t); | |
var n = goog.global.CLOSURE_IMPORT_SCRIPT || goog.writeScriptTag_ | |
, s = goog.loadFileSync_(t); | |
if (null == s) | |
throw Error('Load of "' + t + '" failed'); | |
o && (s = goog.transpile_.call(goog.global, s, t)), | |
s = e ? goog.wrapModule_(t, s) : s + ("\n//# sourceURL=" + t), | |
goog.IS_OLD_IE_ ? (goog.dependencies_.deferred[a] = s, | |
goog.queuedModules_.push(a)) : n(t, s) | |
} | |
} | |
, | |
goog.transpile_ = function(a, b) { | |
var c = goog.global.$jscomp; | |
c || (goog.global.$jscomp = c = {}); | |
var d = c.transpile; | |
if (!d) { | |
var f = goog.basePath + goog.TRANSPILER | |
, e = goog.loadFileSync_(f); | |
if (e) { | |
if (eval(e + "\n//# sourceURL=" + f), | |
goog.global.$gwtExport && goog.global.$gwtExport.$jscomp && !goog.global.$gwtExport.$jscomp.transpile) | |
throw Error('The transpiler did not properly export the "transpile" method. $gwtExport: ' + JSON.stringify(goog.global.$gwtExport)); | |
goog.global.$jscomp.transpile = goog.global.$gwtExport.$jscomp.transpile, | |
c = goog.global.$jscomp, | |
d = c.transpile | |
} | |
} | |
return d || (d = c.transpile = function(t, e) { | |
return goog.logToConsole_(e + " requires transpilation but no transpiler was found."), | |
t | |
} | |
), | |
d(a, b) | |
} | |
, | |
goog.typeOf = function(t) { | |
var e = typeof t; | |
if ("object" == e) { | |
if (!t) | |
return "null"; | |
if (t instanceof Array) | |
return "array"; | |
if (t instanceof Object) | |
return e; | |
var o = Object.prototype.toString.call(t); | |
if ("[object Window]" == o) | |
return "object"; | |
if ("[object Array]" == o || "number" == typeof t.length && "undefined" != typeof t.splice && "undefined" != typeof t.propertyIsEnumerable && !t.propertyIsEnumerable("splice")) | |
return "array"; | |
if ("[object Function]" == o || "undefined" != typeof t.call && "undefined" != typeof t.propertyIsEnumerable && !t.propertyIsEnumerable("call")) | |
return "function" | |
} else if ("function" == e && "undefined" == typeof t.call) | |
return "object"; | |
return e | |
} | |
, | |
goog.isNull = function(t) { | |
return null === t | |
} | |
, | |
goog.isDefAndNotNull = function(t) { | |
return null != t | |
} | |
, | |
goog.isArray = function(t) { | |
return "array" == goog.typeOf(t) | |
} | |
, | |
goog.isArrayLike = function(t) { | |
var e = goog.typeOf(t); | |
return "array" == e || "object" == e && "number" == typeof t.length | |
} | |
, | |
goog.isDateLike = function(t) { | |
return goog.isObject(t) && "function" == typeof t.getFullYear | |
} | |
, | |
goog.isString = function(t) { | |
return "string" == typeof t | |
} | |
, | |
goog.isBoolean = function(t) { | |
return "boolean" == typeof t | |
} | |
, | |
goog.isNumber = function(t) { | |
return "number" == typeof t | |
} | |
, | |
goog.isFunction = function(t) { | |
return "function" == goog.typeOf(t) | |
} | |
, | |
goog.isObject = function(t) { | |
var e = typeof t; | |
return "object" == e && null != t || "function" == e | |
} | |
, | |
goog.getUid = function(t) { | |
return t[goog.UID_PROPERTY_] || (t[goog.UID_PROPERTY_] = ++goog.uidCounter_) | |
} | |
, | |
goog.hasUid = function(t) { | |
return !!t[goog.UID_PROPERTY_] | |
} | |
, | |
goog.removeUid = function(t) { | |
null !== t && "removeAttribute"in t && t.removeAttribute(goog.UID_PROPERTY_); | |
try { | |
delete t[goog.UID_PROPERTY_] | |
} catch (t) {} | |
} | |
, | |
goog.UID_PROPERTY_ = "closure_uid_" + (1e9 * Math.random() >>> 0), | |
goog.uidCounter_ = 0, | |
goog.getHashCode = goog.getUid, | |
goog.removeHashCode = goog.removeUid, | |
goog.cloneObject = function(t) { | |
var e = goog.typeOf(t); | |
if ("object" == e || "array" == e) { | |
if (t.clone) | |
return t.clone(); | |
var o, e = "array" == e ? [] : {}; | |
for (o in t) | |
e[o] = goog.cloneObject(t[o]); | |
return e | |
} | |
return t | |
} | |
, | |
goog.bindNative_ = function(t, e, o) { | |
return t.call.apply(t.bind, arguments) | |
} | |
, | |
goog.bindJs_ = function(t, e, o) { | |
if (!t) | |
throw Error(); | |
if (2 < arguments.length) { | |
var a = Array.prototype.slice.call(arguments, 2); | |
return function() { | |
var o = Array.prototype.slice.call(arguments); | |
return Array.prototype.unshift.apply(o, a), | |
t.apply(e, o) | |
} | |
} | |
return function() { | |
return t.apply(e, arguments) | |
} | |
} | |
, | |
goog.bind = function(t, e, o) { | |
return Function.prototype.bind && -1 != Function.prototype.bind.toString().indexOf("native code") ? goog.bind = goog.bindNative_ : goog.bind = goog.bindJs_, | |
goog.bind.apply(null, arguments) | |
} | |
, | |
goog.partial = function(t, e) { | |
var o = Array.prototype.slice.call(arguments, 1); | |
return function() { | |
var e = o.slice(); | |
return e.push.apply(e, arguments), | |
t.apply(this, e) | |
} | |
} | |
, | |
goog.mixin = function(t, e) { | |
for (var o in e) | |
t[o] = e[o] | |
} | |
, | |
goog.now = goog.TRUSTED_SITE && Date.now || function() { | |
return +new Date | |
} | |
, | |
goog.globalEval = function(t) { | |
if (goog.global.execScript) | |
goog.global.execScript(t, "JavaScript"); | |
else { | |
if (!goog.global.eval) | |
throw Error("goog.globalEval not available"); | |
if (null == goog.evalWorksForGlobals_) | |
if (goog.global.eval("var _evalTest_ = 1;"), | |
"undefined" != typeof goog.global._evalTest_) { | |
try { | |
delete goog.global._evalTest_ | |
} catch (t) {} | |
goog.evalWorksForGlobals_ = !0 | |
} else | |
goog.evalWorksForGlobals_ = !1; | |
if (goog.evalWorksForGlobals_) | |
goog.global.eval(t); | |
else { | |
var e = goog.global.document | |
, o = e.createElement("SCRIPT"); | |
o.type = "text/javascript", | |
o.defer = !1, | |
o.appendChild(e.createTextNode(t)), | |
e.body.appendChild(o), | |
e.body.removeChild(o) | |
} | |
} | |
} | |
, | |
goog.evalWorksForGlobals_ = null, | |
goog.getCssName = function(t, e) { | |
if ("." == String(t).charAt(0)) | |
throw Error('className passed in goog.getCssName must not start with ".". You passed: ' + t); | |
var o = function(t) { | |
return goog.cssNameMapping_[t] || t | |
} | |
, a = function(t) { | |
t = t.split("-"); | |
for (var e = [], a = 0; a < t.length; a++) | |
e.push(o(t[a])); | |
return e.join("-") | |
} | |
, a = goog.cssNameMapping_ ? "BY_WHOLE" == goog.cssNameMappingStyle_ ? o : a : function(t) { | |
return t | |
} | |
; | |
return t = e ? t + "-" + a(e) : a(t), | |
goog.global.CLOSURE_CSS_NAME_MAP_FN ? goog.global.CLOSURE_CSS_NAME_MAP_FN(t) : t | |
} | |
, | |
goog.setCssNameMapping = function(t, e) { | |
goog.cssNameMapping_ = t, | |
goog.cssNameMappingStyle_ = e | |
} | |
, | |
!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING && (goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING), | |
goog.getMsg = function(t, e) { | |
return e && (t = t.replace(/\{\$([^}]+)}/g, function(t, o) { | |
return null != e && o in e ? e[o] : t | |
})), | |
t | |
} | |
, | |
goog.getMsgWithFallback = function(t, e) { | |
return t | |
} | |
, | |
goog.exportSymbol = function(t, e, o) { | |
goog.exportPath_(t, e, o) | |
} | |
, | |
goog.exportProperty = function(t, e, o) { | |
t[e] = o | |
} | |
, | |
goog.inherits = function(t, e) { | |
function o() {} | |
o.prototype = e.prototype, | |
t.superClass_ = e.prototype, | |
t.prototype = new o, | |
t.prototype.constructor = t, | |
t.base = function(t, o, a) { | |
for (var n = Array(arguments.length - 2), s = 2; s < arguments.length; s++) | |
n[s - 2] = arguments[s]; | |
return e.prototype[o].apply(t, n) | |
} | |
} | |
, | |
goog.base = function(t, e, o) { | |
var a = arguments.callee.caller; | |
if (goog.STRICT_MODE_COMPATIBLE || goog.DEBUG && !a) | |
throw Error("arguments.caller not defined. goog.base() cannot be used with strict mode code. See http://www.ecma-international.org/ecma-262/5.1/#sec-C"); | |
if (a.superClass_) { | |
for (var n = Array(arguments.length - 1), s = 1; s < arguments.length; s++) | |
n[s - 1] = arguments[s]; | |
return a.superClass_.constructor.apply(t, n) | |
} | |
for (n = Array(arguments.length - 2), | |
s = 2; s < arguments.length; s++) | |
n[s - 2] = arguments[s]; | |
for (var s = !1, i = t.constructor; i; i = i.superClass_ && i.superClass_.constructor) | |
if (i.prototype[e] === a) | |
s = !0; | |
else if (s) | |
return i.prototype[e].apply(t, n); | |
if (t[e] === a) | |
return t.constructor.prototype[e].apply(t, n); | |
throw Error("goog.base called from a method of one name to a method of a different name") | |
} | |
, | |
goog.scope = function(t) { | |
if (goog.isInModuleLoader_()) | |
throw Error("goog.scope is not supported within a goog.module."); | |
t.call(goog.global) | |
} | |
, | |
COMPILED || (goog.global.COMPILED = COMPILED), | |
goog.defineClass = function(t, e) { | |
var o = e.constructor | |
, a = e.statics; | |
return o && o != Object.prototype.constructor || (o = function() { | |
throw Error("cannot instantiate an interface (no constructor defined).") | |
} | |
), | |
o = goog.defineClass.createSealingConstructor_(o, t), | |
t && goog.inherits(o, t), | |
delete e.constructor, | |
delete e.statics, | |
goog.defineClass.applyProperties_(o.prototype, e), | |
null != a && (a instanceof Function ? a(o) : goog.defineClass.applyProperties_(o, a)), | |
o | |
} | |
, | |
goog.defineClass.SEAL_CLASS_INSTANCES = goog.DEBUG, | |
goog.defineClass.createSealingConstructor_ = function(t, e) { | |
if (!goog.defineClass.SEAL_CLASS_INSTANCES) | |
return t; | |
var o = !goog.defineClass.isUnsealable_(e) | |
, a = function() { | |
var e = t.apply(this, arguments) || this; | |
return e[goog.UID_PROPERTY_] = e[goog.UID_PROPERTY_], | |
this.constructor === a && o && Object.seal instanceof Function && Object.seal(e), | |
e | |
}; | |
return a | |
} | |
, | |
goog.defineClass.isUnsealable_ = function(t) { | |
return t && t.prototype && t.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_] | |
} | |
, | |
goog.defineClass.OBJECT_PROTOTYPE_FIELDS_ = "constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "), | |
goog.defineClass.applyProperties_ = function(t, e) { | |
for (var o in e) | |
Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]); | |
for (var a = 0; a < goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length; a++) | |
o = goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[a], | |
Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]) | |
} | |
, | |
goog.tagUnsealableClass = function(t) { | |
!COMPILED && goog.defineClass.SEAL_CLASS_INSTANCES && (t.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_] = !0) | |
} | |
, | |
goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_ = "goog_defineClass_legacy_unsealable", | |
goog.createRequiresTranspilation_ = function() { | |
function a(t, e) { | |
d ? c[t] = !0 : e() ? c[t] = !1 : d = c[t] = !0 | |
} | |
function b(a) { | |
try { | |
return !!eval(a) | |
} catch (t) { | |
return !1 | |
} | |
} | |
var c = { | |
es3: !1 | |
} | |
, d = !1; | |
return a("es5", function() { | |
return b("[1,].length==1") | |
}), | |
a("es6", function() { | |
return b('(()=>{"use strict";class X{constructor(){if(new.target!=String)throw 1;this.x=42}}let q=Reflect.construct(X,[],String);if(q.x!=42||!(q instanceof String))throw 1;for(const a of[2,3]){if(a==2)continue;function f(z={a}){let a=0;return z.a}{function f(){return 0;}}return f()==3}})()') | |
}), | |
a("es6-impl", function() { | |
return !0 | |
}), | |
a("es7", function() { | |
return b("2 ** 2 == 4") | |
}), | |
a("es8", function() { | |
return b("async () => 1, true") | |
}), | |
c | |
} | |
; | |
var app = { | |
Step: { | |
IDLE_1: { | |
key: "IDLE_1", | |
back: "idle_1" | |
}, | |
IDLE_2: { | |
key: "IDLE_2", | |
back: "idle_2" | |
}, | |
FAIL: { | |
key: "FAIL", | |
back: "fail" | |
}, | |
WRAP_BLUE: { | |
color: "blue", | |
key: "WRAP_BLUE", | |
back: "wrap_back_blue", | |
front: "wrap_front_blue" | |
}, | |
WRAP_GREEN: { | |
color: "green", | |
key: "WRAP_GREEN", | |
back: "wrap_back_green", | |
front: "wrap_front_green" | |
}, | |
WRAP_RED: { | |
color: "red", | |
key: "WRAP_RED", | |
back: "wrap_back_red", | |
front: "wrap_front_red" | |
} | |
} | |
} | |
, canvasWidth = 400 | |
, canvasHeight = 300 | |
, offsetX = 0 | |
, offsetY = 0 | |
, fps = 24 | |
, framesPerSprite = 24 | |
, spriteScaleFactor = .6 | |
, originalWidth = 1920 * spriteScaleFactor | |
, originalHeight = 1080 * spriteScaleFactor | |
, $jscomp$compprop0 = {} | |
, frameCounts = ($jscomp$compprop0[app.Step.IDLE_1.key] = 24, | |
$jscomp$compprop0[app.Step.IDLE_2.key] = 24, | |
$jscomp$compprop0[app.Step.FAIL.key] = 24, | |
$jscomp$compprop0[app.Step.WRAP_BLUE.key] = 24, | |
$jscomp$compprop0[app.Step.WRAP_GREEN.key] = 24, | |
$jscomp$compprop0[app.Step.WRAP_RED.key] = 24, | |
$jscomp$compprop0); | |
app.Animation = function(t, e) { | |
this.key = t.key, | |
this.backName = t.back, | |
this.frontName = t.front, | |
this.frame = 0, | |
this.frameCount = frameCounts[this.key], | |
this.frameDuration = 1e3 / fps * (60 / e) * 2, | |
this.elapsedTime = 0, | |
this.paused = !0 | |
} | |
, | |
app.Animation.prototype.play = function() { | |
this.frame = 0, | |
this.paused = !1 | |
} | |
, | |
goog.exportProperty(app.Animation.prototype, "play", app.Animation.prototype.play), | |
app.Animation.prototype.getFrame = function(t, e) { | |
if (t) | |
return { | |
x: e % framesPerSprite * canvasWidth, | |
y: 0, | |
width: canvasWidth, | |
height: canvasHeight, | |
offsetX: offsetX, | |
offsetY: offsetY, | |
sprite: t + "_" + Math.floor(e / framesPerSprite) | |
} | |
} | |
, | |
app.Animation.prototype.update = function(t) { | |
return this.paused ? { | |
back: this.getFrame(this.backName, this.frame), | |
front: this.getFrame(this.frontName, this.frame) | |
} : (this.elapsedTime += t, | |
this.elapsedTime > this.frameDuration && (t = Math.floor(this.elapsedTime / this.frameDuration), | |
this.frame += t, | |
this.frame = Math.min(this.frame, this.frameCount - 1), | |
this.elapsedTime -= t * this.frameDuration), | |
{ | |
back: this.getFrame(this.backName, this.frame), | |
front: this.getFrame(this.frontName, this.frame) | |
}) | |
} | |
, | |
goog.exportProperty(app.Animation.prototype, "update", app.Animation.prototype.update), | |
app.I18n = {}, | |
app.I18n.CACHE_ = {}, | |
app.I18n.getMsg = function(t) { | |
var e = app.I18n.getMsgOrNull(t); | |
return null === e ? "[Unknown message: " + t + "]" : e | |
} | |
, | |
app.I18n.getMsgOrNull = function(t) { | |
if (!(t in app.I18n.CACHE_)) { | |
var e = document.getElementById(t); | |
if (e) | |
return e = e.textContent, | |
e = e.replace(/\\n/g, "\n"), | |
app.I18n.CACHE_[t] = e | |
} | |
return app.I18n.CACHE_[t] | |
} | |
, | |
app.Constants = { | |
INITIAL_COUNTDOWN: 0, | |
COUNTDOWN_FLASH: 0, | |
CANVAS_MAX_HEIGHT: 8e3, | |
TRACK_PIXELS_PER_BEAT: 150, | |
ARROW_SIZE: { | |
desktop: 80, | |
mobile: 60 | |
}, | |
ARROW_MARGIN: 10, | |
TRACK_LINE_POSITION: { | |
desktop: 300, | |
mobile: 120 | |
}, | |
ARROW_IMG_WIDTH: 40, | |
ARROW_IMG_HEIGHT: 40, | |
ARROW_MULTI_MARGIN: 25, | |
COLORS: { | |
ARROW_FILL: "#333", | |
ARROW_PASSED_FILL: "#eee", | |
ARROW_MULTI_FILL: "#484848", | |
ARROW_MULTI_SHADOW: "rgba(0, 0, 0, 0.2)", | |
ARROW_MULTI_RAINBOW: "red orange yellow green blue indigo purple".split(" "), | |
TRACK_LINE: "#4d4d4d", | |
TRACK_LINE_MEGA: "#eeeeee", | |
POWERUP: "rgba(0, 0, 0, 0.5)", | |
POWERUP_SHADOW: "rgba(255, 255, 255, 0.2)", | |
POWERUP_SHINE: "rgba(255, 255, 255, 0.5)", | |
POWERUP_MARKER: "#d1febb", | |
GRADIENT_START: "#00ffb5", | |
GRADIENT_END: "#2ab4ff" | |
}, | |
HIT_SCORES: { | |
MISS: { | |
points: 0, | |
textKey: "WB_feedback_miss", | |
powerup: -.03 | |
}, | |
OK: { | |
points: 10, | |
textKey: "WB_feedback_okay", | |
accuracy: Number.MAX_VALUE, | |
powerup: 0 | |
}, | |
GOOD: { | |
points: 50, | |
textKey: "WB_feedback_good", | |
accuracy: 25, | |
powerup: .03 | |
}, | |
PERFECT: { | |
points: 100, | |
textKey: "WB_feedback_perfect", | |
accuracy: 10, | |
powerup: .1 | |
}, | |
HOLD: { | |
points: 1, | |
powerup: .001 | |
}, | |
COMBO: { | |
points: 50, | |
powerup: .05 | |
} | |
}, | |
ARROW_MULTI_HOLD_POINTS: 1, | |
ARROW_MULTI_HOLD_POWERUP: .001, | |
ARROW_MULTI_SHADOW_BLUR: 10, | |
ARROW_MULTI_SHADOW_OFFSET: 2, | |
COMBO_POINTS_BONUS: 50, | |
COMBO_POWERUP_BONUS: .05, | |
POWERUP_MARGIN: { | |
desktop: 20, | |
mobile: 10 | |
}, | |
POWERUP_INNER_MARGIN: { | |
desktop: 5, | |
mobile: 0 | |
}, | |
POWERUP_HEIGHT: { | |
desktop: 30, | |
mobile: 5 | |
}, | |
POWERUP_SHINE_POSITION: 17, | |
POWERUP_SHINE_HEIGHT: { | |
desktop: 4, | |
mobile: 0 | |
}, | |
POWERUP_MARKER_WIDTH: { | |
desktop: 3, | |
mobile: 1 | |
}, | |
POWERUP_DECAY: .0035, | |
ELF_LEFT_OFFSET: -120, | |
ELF_RIGHT_OFFSET: 130, | |
TOY_SIZE: 130, | |
TOY_VERTICAL_OFFSET: 140, | |
TOY_WRAP_OFFSET: 140, | |
PRESENT_HEIGHT: 110, | |
PRESENT_WIDTH: 150, | |
PRESENT_VERTICAL_OFFSET: 150 | |
}, | |
app.Constants.DIRECTIONS = { | |
LEFT: 37, | |
UP: 38, | |
RIGHT: 39, | |
DOWN: 40 | |
}; | |
var Constants = app.Constants; | |
app.Present = function(t) { | |
this.elf = t, | |
this.presentEl = $(".present", this.elf.frontEl), | |
this.toyEl = $(".present-toy", this.elf.frontEl), | |
this.boxEl = $(".present-box", this.elf.frontEl), | |
this.playing = !1, | |
this.toyClass = this.boxClass = null | |
} | |
, | |
app.Present.prototype.init = function(t, e) { | |
this.playing = !0, | |
this.toyClass = "present-toy--" + Math.ceil(8 * Math.random()), | |
this.boxClass = "present-box--" + t + "-" + e, | |
this.toyEl.addClass(this.toyClass), | |
this.boxEl.addClass(this.boxClass), | |
this.presentEl.css("left", this.elf.elfOffset + (this.elf.frontCanvas.width - this.presentEl.width()) / 2), | |
e || window.santaApp.fire("sound-trigger", "wrapbattle_wrap_present_fail") | |
} | |
, | |
app.Present.prototype.showToy = function() { | |
this.toyEl.addClass("is-active") | |
} | |
, | |
app.Present.prototype.hideToy = function() { | |
var t = this; | |
setTimeout(function() { | |
return t.toyEl.removeClass("is-active") | |
}, 200), | |
window.santaApp.fire("sound-trigger", "wrapbattle_wrap_present") | |
} | |
, | |
app.Present.prototype.showBox = function() { | |
this.boxEl.addClass("is-active"), | |
setTimeout(this.hideBox.bind(this), 500) | |
} | |
, | |
app.Present.prototype.hideBox = function() { | |
this.boxEl.removeClass("is-active"), | |
this.playing = !1 | |
} | |
, | |
app.Present.prototype.cleanUp = function() { | |
this.toyEl.removeClass("is-active " + this.toyClass), | |
this.boxEl.removeClass("is-active " + this.boxClass), | |
this.boxClass = this.toyClass = null, | |
this.playing = !1 | |
} | |
, | |
app.Character = function(t, e, o, a, n) { | |
this.currentState = this.animation = null, | |
this.backEl = t, | |
this.frontEl = e, | |
this.animations = "fail_0 idle_1_0 idle_2_0 wrap_back_blue_0 wrap_back_green_0 wrap_back_red_0 wrap_front_blue_0 wrap_front_green_0 wrap_front_red_0".split(" "), | |
this.lastFrame = null, | |
this.color = o, | |
this.dir = a, | |
this.elfOffset = n, | |
this.backCanvas = document.createElement("canvas"), | |
this.backCanvas.width = $(".dj--left canvas").width(), | |
this.backCanvas.height = canvasHeight, | |
t.appendChild(this.backCanvas), | |
this.backContext = this.backCanvas.getContext("2d"), | |
this.frontCanvas = document.createElement("canvas"), | |
this.frontCanvas.width = $(".dj--left canvas").width(), | |
this.frontCanvas.height = canvasHeight, | |
e.appendChild(this.frontCanvas), | |
this.frontContext = this.frontCanvas.getContext("2d"), | |
this.images = {}, | |
this.renderSprites_(o), | |
this.present = new app.Present(this), | |
this.offsetX = this.postAnimationCallback = this.nextAnimationBeat = this.animationQueue = null | |
} | |
, | |
app.Character.prototype.onResize = function() { | |
this.backCanvas.width = $(".dj--left canvas").width(), | |
this.frontCanvas.width = $(".dj--left canvas").width() | |
} | |
, | |
goog.exportProperty(app.Character.prototype, "onResize", app.Character.prototype.onResize), | |
app.Character.prototype.renderSprites_ = function(t) { | |
var e = this; | |
this.animations.forEach(function(o) { | |
e.loadImage(o, t) | |
}) | |
} | |
, | |
app.Character.prototype.loadImage = function(t, e) { | |
var o = this | |
, a = new Image; | |
a.onload = function() { | |
o.images[t] = a | |
} | |
, | |
a.onerror = function() { | |
a.onerror = null, | |
setTimeout(function() { | |
a.src += "?" + +new Date | |
}, 1e3) | |
} | |
, | |
a.src = this.dir + ("img/steps/" + e + "/" + t + ".png") | |
} | |
, | |
app.Character.prototype.update = function(t) { | |
this.animation && (t = this.animation.update(t), | |
t !== this.lastFrame && (this.renderFrame(t.back, this.backContext), | |
this.renderFrame(t.front, this.frontContext), | |
this.lastFrame = t)) | |
} | |
, | |
app.Character.prototype.renderFrame = function(t, e) { | |
if (t) { | |
var o = this.images[t.sprite]; | |
o ? (this.offsetX = (e.canvas.width - t.width) / 2 + this.elfOffset, | |
e.clearRect(0, 0, e.canvas.width, e.canvas.height), | |
e.drawImage(o, t.x, t.y, t.width, t.height, this.offsetX, t.offsetY, t.width, t.height)) : 0 === t.x && this.loadImage(t.sprite, this.color) | |
} else | |
e.clearRect(0, 0, e.canvas.width, e.canvas.height) | |
} | |
, | |
app.Character.prototype.play = function(t, e) { | |
this.animation = new app.Animation(t,e), | |
this.animation.play() | |
} | |
, | |
app.Character.prototype.cleanUp = function() { | |
this.animation = null, | |
this.present.cleanUp() | |
} | |
, | |
app.AnimationPlayer = function(t, e, o) { | |
this.leftElf = t, | |
this.rightElf = e, | |
this.sequencer = o, | |
this.beat = -1, | |
this.leftElf.animationQueue = [], | |
this.rightElf.animationQueue = [], | |
this.leftElf.nextAnimationBeat = 0, | |
this.rightElf.nextAnimationBeat = 0 | |
} | |
, | |
app.AnimationPlayer.prototype.update = function(t) { | |
t = Math.floor(t / (60 / this.sequencer.getBPM())), | |
this.beat !== t && (this.beat = t, | |
this.onBeat(this.leftElf), | |
this.onBeat(this.rightElf)) | |
} | |
, | |
goog.exportProperty(app.AnimationPlayer.prototype, "update", app.AnimationPlayer.prototype.update), | |
app.AnimationPlayer.prototype.onBeat = function(t) { | |
this.beat >= t.nextAnimationBeat && (t.postAnimationCallback && (t.postAnimationCallback(), | |
t.postAnimationCallback = null), | |
this.onAnimationBar(t)) | |
} | |
, | |
app.AnimationPlayer.prototype.onAnimationBar = function(t) { | |
var e = t.animationQueue.shift(); | |
e ? this.playGenericAnimation(e) : (.5 > Math.random() ? t.play(app.Step.IDLE_1, this.sequencer.getBPM()) : t.play(app.Step.IDLE_2, this.sequencer.getBPM()), | |
t.nextAnimationBeat = this.beat + 2) | |
} | |
, | |
app.AnimationPlayer.prototype.playGenericAnimation = function(t) { | |
var e = t.left ? this.leftElf : this.rightElf; | |
e.play(t.animationName, this.sequencer.getBPM()), | |
e.nextAnimationBeat = this.beat + 2, | |
t.startCallback && t.startCallback(), | |
t.endCallback && (e.postAnimationCallback = t.endCallback) | |
} | |
, | |
app.AnimationPlayer.prototype.queueAnimation = function(t, e) { | |
(e ? this.leftElf : this.rightElf).animationQueue.push({ | |
animationName: t, | |
left: e | |
}) | |
} | |
, | |
goog.exportProperty(app.AnimationPlayer.prototype, "queueAnimation", app.AnimationPlayer.prototype.queueAnimation), | |
app.AnimationPlayer.prototype.playWrapAnimation = function(t, e, o) { | |
var a = o ? this.leftElf : this.rightElf; | |
a.present.playing || (a.present.cleanUp(), | |
a.present.init(e.color, t), | |
a.present.showToy(), | |
a.animationQueue.push({ | |
animationName: e, | |
left: o, | |
startCallback: a.present.hideToy.bind(a.present), | |
endCallback: a.present.showBox.bind(a.present) | |
})) | |
} | |
, | |
goog.exportProperty(app.AnimationPlayer.prototype, "playWrapAnimation", app.AnimationPlayer.prototype.playWrapAnimation), | |
app.AnimationPlayer.prototype.cleanUp = function() { | |
this.leftElf.postAnimationCallback = null, | |
this.rightElf.postAnimationCallback = null, | |
this.beat = -1, | |
this.leftElf.animationQueue = [], | |
this.rightElf.animationQueue = [], | |
this.leftElf.nextAnimationBeat = 0, | |
this.rightElf.nextAnimationBeat = 0 | |
} | |
, | |
goog.exportProperty(app.AnimationPlayer.prototype, "cleanUp", app.AnimationPlayer.prototype.cleanUp), | |
app.Arrow = function(t, e) { | |
this.location = t.trackLocation, | |
this.directions = t.directions, | |
this.length = t.length, | |
this.data = t, | |
this.cacheCanvas = e[0] | |
} | |
, | |
app.Arrow.prototype.render = function(t, e, o, a) { | |
if (o && o[0]) { | |
var n = o[0].getContext("2d"); | |
o = o[0].width; | |
var s = app.Constants.ARROW_SIZE[e] | |
, i = app.Constants.ARROW_MARGIN | |
, r = 4 * s + 3 * i; | |
t = this.location + t; | |
var p = this.location - a; | |
a = app.Constants.ARROW_SIZE.desktop + app.Constants.ARROW_MARGIN; | |
var c = s + app.Constants.ARROW_MULTI_SHADOW_BLUR + app.Constants.ARROW_MULTI_SHADOW_OFFSET | |
, l = s + 5; | |
for (n.save(), | |
n.translate(0, p), | |
p = 0; p < this.directions.length; p++) { | |
var g = this.directions[p]; | |
n.save(); | |
var h = (o - r) / 2 + s / 2 | |
, d = void 0; | |
switch (g) { | |
case app.Constants.DIRECTIONS.UP: | |
h += s + i, | |
d = 0; | |
break; | |
case app.Constants.DIRECTIONS.DOWN: | |
h += 2 * (s + i), | |
d = a; | |
break; | |
case app.Constants.DIRECTIONS.LEFT: | |
d = 2 * a; | |
break; | |
case app.Constants.DIRECTIONS.RIGHT: | |
h += 3 * (s + i), | |
d = 3 * a | |
} | |
if (this.passed && !this.caught && (n.globalAlpha = .5), | |
n.translate(h, 0), | |
this.length) { | |
for (n.clearRect(-s / 2, p - s / 2, l, this.length + l + 5), | |
g = this.length, | |
h = 0; 0 < g; g -= app.Constants.ARROW_MULTI_MARGIN, | |
h++) | |
g + t < app.Constants.TRACK_LINE_POSITION[e] ? n.drawImage(this.cacheCanvas, a * (h % app.Constants.COLORS.ARROW_MULTI_RAINBOW.length + 1), 3 * a, l, c, -s / 2, g - s / 2, l, c) : n.drawImage(this.cacheCanvas, 0, 3 * a, l, c, -s / 2, g - s / 2, l, c); | |
this.caught ? n.drawImage(this.cacheCanvas, d, 2 * a, l, l, -s / 2, -s / 2, l, l) : n.drawImage(this.cacheCanvas, d, 0, l, l, -s / 2, -s / 2, l, l) | |
} else | |
this.caught ? this.clearAndDraw(n, this.cacheCanvas, d, 2 * a, l, l, -s / 2, -s / 2, l, l) : this.clearAndDraw(n, this.cacheCanvas, d, 0, l, l, -s / 2, -s / 2, l, l); | |
n.restore() | |
} | |
n.restore() | |
} | |
} | |
, | |
goog.exportProperty(app.Arrow.prototype, "render", app.Arrow.prototype.render), | |
app.Arrow.prototype.clearAndDraw = function(t, e) { | |
for (var o = [], a = 1; a < arguments.length; ++a) | |
o[a - 1] = arguments[a]; | |
t.clearRect(o[5], o[6], o[7], o[8]), | |
t.drawImage.apply(t, [].concat($jscomp.arrayFromIterable(o))) | |
} | |
, | |
app.shared = {}, | |
app.shared.utils = function() { | |
var t = { | |
animWithClass: function(t, e, o) { | |
var a = $(t); | |
a.one("animationend transitionend", function(t) { | |
a.removeClass(e), | |
o && o.apply(a[0]) | |
}), | |
a.addClass(e) | |
}, | |
updateLocalSVGRef: function(t) {}, | |
unwrapElement: function(t) { | |
if (t = $(t)[0], | |
!t) | |
throw new TypeError("Couldn't unwrap element, nothing matched"); | |
return t | |
}, | |
computedTransform: function(t) { | |
var e, o = window.getComputedStyle(t); | |
if (["", "-webkit-", "-moz-", "-ms-", "-o-"].some(function(t) { | |
return !!(t = o.getPropertyValue(t + "transform")) && (e = t, | |
!0) | |
}), | |
"none" === e) | |
return { | |
x: 0, | |
y: 0, | |
rotate: 0 | |
}; | |
var a; | |
try { | |
a = e.split("(")[1].split(")")[0].split(","), | |
a = a.map(function(t) { | |
return +t | |
}) | |
} catch (t) { | |
throw new TypeError("Couldn't split transform, expected matrix(...)") | |
} | |
return { | |
x: a[4], | |
y: a[5], | |
rotate: 180 / Math.PI * Math.atan2(a[1], a[0]) | |
} | |
}, | |
onWebAnimationFinished: function(t, e) { | |
t.addEventListener("finish", e, !1) | |
}, | |
playerFinished: function(t) { | |
return !t || "finished" === t.playState | |
}, | |
get touchEnabled() { | |
return !!window.matchMedia("(pointer: coarse)").matches || !window.matchMedia("(pointer: fine)").matches && ("ontouchstart"in window || window.DocumentTouch && document instanceof window.DocumentTouch) | |
}, | |
SmartValue: function(t) { | |
this.value = t | |
} | |
}; | |
return t.SmartValue.prototype.change = function(t) { | |
var e = this.value !== t; | |
return this.value = t, | |
e | |
} | |
, | |
t.SmartValue.prototype.moveToTarget = function(t, e) { | |
var o = this.value | |
, o = +o; | |
if (this.value !== o) | |
throw new TypeError("SmartValue does not contain a number"); | |
return o < t ? o = Math.min(t, o + e) : o > t && (o = Math.max(t, o - e)), | |
this.value = o, | |
this | |
} | |
, | |
t | |
}(); | |
var utils = app.shared.utils; | |
$jscomp.scope.getNormalizedEvent = function(t) { | |
return t = t.originalEvent ? t.originalEvent : t, | |
t = t.touches ? t.touches[0] : t | |
} | |
, | |
function() { | |
window.navigator.pointerEnabled ? ($jscomp.scope.eventStart = "pointerdown", | |
$jscomp.scope.eventMove = "pointermove", | |
$jscomp.scope.eventCancel = "pointerup pointerout pointermove", | |
$jscomp.scope.eventEnd = "pointerup") : ($jscomp.scope.eventStart = "mousedown", | |
$jscomp.scope.eventMove = "mousemove", | |
$jscomp.scope.eventCancel = "mouseup mouseout", | |
$jscomp.scope.eventEnd = "mouseup", | |
app.shared.utils.touchEnabled && ($jscomp.scope.eventStart += " touchstart", | |
$jscomp.scope.eventMove += " touchmove", | |
$jscomp.scope.eventCancel += " touchend touchleave touchcancel", | |
$jscomp.scope.eventEnd += " touchend")) | |
}(), | |
app.InputEvent = { | |
CANCEL: $jscomp.scope.eventCancel, | |
START: $jscomp.scope.eventStart, | |
MOVE: $jscomp.scope.eventMove, | |
END: $jscomp.scope.eventEnd, | |
normalize: $jscomp.scope.getNormalizedEvent | |
}, | |
app.Controls = function(t) { | |
this.game = t, | |
this.keysDown = [] | |
} | |
, | |
app.Controls.prototype.setup = function() { | |
$(document).on("keydown.wrapbattle", this.onKeyDown.bind(this)), | |
$(document).on("keyup.wrapbattle", this.onKeyUp.bind(this)), | |
$(".mobile-button", this.game.elem).on(app.InputEvent.START, this.onTouchEvent.bind(this, !0)), | |
$(".mobile-button", this.game.elem).on(app.InputEvent.END + " " + app.InputEvent.CANCEL, this.onTouchEvent.bind(this, !1)) | |
} | |
, | |
goog.exportProperty(app.Controls.prototype, "setup", app.Controls.prototype.setup), | |
app.Controls.prototype.onTouchEvent = function(t, e) { | |
e = e.originalEvent || e, | |
e = $(e.target), | |
t = t ? this.addKey.bind(this) : this.removeKey.bind(this), | |
e.hasClass("mobile-button--up") ? t(app.Constants.DIRECTIONS.UP) : e.hasClass("mobile-button--down") ? t(app.Constants.DIRECTIONS.DOWN) : e.hasClass("mobile-button--left") ? t(app.Constants.DIRECTIONS.LEFT) : e.hasClass("mobile-button--right") && t(app.Constants.DIRECTIONS.RIGHT) | |
} | |
, | |
app.Controls.prototype.onKeyDown = function(t) { | |
t.keyCode && (37 > t.keyCode || 40 < t.keyCode) || this.addKey(t.keyCode) | |
} | |
, | |
app.Controls.prototype.onKeyUp = function(t) { | |
this.removeKey(t.keyCode) | |
} | |
, | |
app.Controls.prototype.addKey = function(t) { | |
0 > this.keysDown.indexOf(t) && this.keysDown.push(t) | |
} | |
, | |
app.Controls.prototype.removeKey = function(t) { | |
for (var e = 0; e < this.keysDown.length; e++) | |
if (this.keysDown[e] == t) { | |
this.keysDown.splice(e, 1); | |
break | |
} | |
} | |
, | |
app.shared.Gameover = Gameover, | |
Gameover.prototype.show = function(t, e, o) { | |
window.santaApp.fire("game-stop", { | |
score: t || this.game && this.game.scoreboard && this.game.scoreboard.score || 0, | |
hasPlayExtra: this._hasPlayExtra && o | |
}) | |
} | |
, | |
app.shared.SharedGameOver = {}, | |
SharedGameOver.prototype.gameover = function() {} | |
, | |
app.shared.Scoreboard = Scoreboard, | |
Scoreboard.prototype.reset = function() { | |
this.restart(), | |
this.score = this.level = 0 | |
} | |
, | |
Scoreboard.prototype.restart = function() { | |
this.lastSeconds = NaN, | |
this.countdown = this.initialCountdown_, | |
this.losing = !1, | |
this.announce_() | |
} | |
, | |
Scoreboard.prototype.onFrame = function(t) { | |
this.countdown -= t; | |
var e = Math.ceil(this.countdown); | |
e !== this.lastSeconds && (this.lastSeconds = e, | |
0 < t && (0 > this.countdown && (this.countdown = 0, | |
this.game.gameover()), | |
t = e <= Constants.COUNTDOWN_FLASH && 0 !== e, | |
this.losing !== t && (this.losing = t, | |
0 < e && window.santaApp.fire("sound-trigger", t ? "game_hurry_up" : "game_hurry_up_end"))), | |
this.announce_()) | |
} | |
, | |
Scoreboard.prototype.addScore = function(t) { | |
t && (this.score += t, | |
this.announce_()) | |
} | |
, | |
Scoreboard.prototype.setLevel = function(t) { | |
this.level !== t && (this.level = t, | |
this.announce_()) | |
} | |
, | |
Scoreboard.prototype.addTime = function(t) { | |
t && (this.countdown += t, | |
this.announce_()) | |
} | |
, | |
Scoreboard.prototype.announce_ = function() { | |
var t = this; | |
window.clearTimeout(this.announceTimeout_), | |
this.announceTimeout_ = window.setTimeout(function() { | |
window.santaApp.fire("game-score", { | |
score: t.score, | |
level: t.level + 1, | |
levels: t.levels, | |
time: t.lastSeconds || t.countdown | |
}) | |
}, 1) | |
} | |
, | |
app.shared.SharedGame = SharedGame, | |
SharedGame.prototype.restart = function() {} | |
, | |
SharedGame.prototype.dispose = function() {} | |
, | |
app.shared.LevelUp = LevelUp, | |
LevelUp.prototype.dispose = function() { | |
$(window).off("resize", this.onResizeBound_) | |
} | |
, | |
LevelUp.prototype.onResize_ = function() { | |
var t = window.innerWidth | |
, e = window.innerHeight - window.santaApp.headerSize; | |
this.bgBorderWidth = t, | |
this.bgElem.css({ | |
width: 2 * t, | |
height: 2 * t, | |
left: -.5 * t, | |
top: -(t - e / 2) | |
}) | |
} | |
, | |
LevelUp.prototype.numberHidden_ = function() { | |
this.numberElem.removeClass("show hide"), | |
this.bgElem.removeClass("is-visible") | |
} | |
, | |
LevelUp.prototype.numberShown_ = function() { | |
timeoutOneEvent(this.numberElem, "transitionend", .5, this.numberHidden_.bind(this)), | |
this.numberElem.addClass("hide"), | |
this.bgElem.css("border-width", 0), | |
window.santaApp.fire("sound-trigger", "level_transition_open") | |
} | |
, | |
LevelUp.prototype.show = function(t, e) { | |
this.bgElem.addClass("is-visible"), | |
timeoutOneEvent(this.bgElem, "transitionend", 1, e), | |
this.bgElem.css("border-width", this.bgBorderWidth), | |
timeoutOneEvent(this.numberElem, "animationend", 1.5, this.numberShown_.bind(this)), | |
this.numberElem.text("" + t).addClass("show"), | |
window.santaApp.fire("sound-trigger", "level_transition_close") | |
} | |
, | |
app.Levels = { | |
combos: [{ | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: .75, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1.25, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 2.66, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 3, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 2.66, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 3, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 2.66, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 3, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: .75, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1.25, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .25, | |
length: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .25, | |
length: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .25, | |
length: .5, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: .75, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1.25, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 1.25, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 2, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: 0, | |
directions: [app.Constants.DIRECTIONS.DOWN, app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP, app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
arrows: [{ | |
beat: .25, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: .5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}] | |
}], | |
levels: [{ | |
length: 80, | |
startDelay: 1, | |
track: [{ | |
beat: 3, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 5, | |
comboIndex: 6 | |
}, { | |
beat: 7, | |
comboIndex: 3 | |
}, { | |
beat: 9.5, | |
comboIndex: 7 | |
}, { | |
beat: 15, | |
comboIndex: 3 | |
}, { | |
beat: 17.5, | |
comboIndex: 7 | |
}, { | |
beat: 19, | |
comboIndex: 3 | |
}, { | |
beat: 23, | |
comboIndex: 8 | |
}, { | |
beat: 25.5, | |
comboIndex: 7 | |
}, { | |
beat: 31, | |
comboIndex: 3 | |
}, { | |
beat: 35, | |
comboIndex: 3 | |
}, { | |
beat: 37, | |
comboIndex: 9 | |
}, { | |
beat: 43, | |
comboIndex: 3 | |
}, { | |
beat: 47, | |
comboIndex: 3 | |
}, { | |
beat: 49.5, | |
comboIndex: 4 | |
}, { | |
beat: 51.5, | |
comboIndex: 0 | |
}, { | |
beat: 55, | |
comboIndex: 8 | |
}, { | |
beat: 57.5, | |
comboIndex: 7 | |
}, { | |
beat: 63, | |
comboIndex: 3 | |
}, { | |
beat: 67, | |
comboIndex: 3 | |
}, { | |
beat: 69, | |
comboIndex: 9 | |
}, { | |
beat: 70, | |
comboIndex: 29 | |
}, { | |
beat: 71, | |
comboIndex: 9 | |
}, { | |
beat: 75, | |
comboIndex: 3 | |
}, { | |
beat: 79, | |
comboIndex: 3 | |
}] | |
}, { | |
length: 111, | |
startDelay: 3, | |
track: [{ | |
beat: 1, | |
comboIndex: 2 | |
}, { | |
beat: 3.5, | |
comboIndex: 9 | |
}, { | |
beat: 6, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 9, | |
comboIndex: 11 | |
}, { | |
beat: 14, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 17, | |
comboIndex: 12 | |
}, { | |
beat: 21, | |
comboIndex: 13 | |
}, { | |
beat: 25, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 29, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 31, | |
comboIndex: 15 | |
}, { | |
beat: 33, | |
comboIndex: 13 | |
}, { | |
beat: 37, | |
comboIndex: 11 | |
}, { | |
beat: 41, | |
comboIndex: 12 | |
}, { | |
beat: 45, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 47, | |
comboIndex: 15 | |
}, { | |
beat: 49, | |
comboIndex: 13 | |
}, { | |
beat: 53, | |
comboIndex: 13 | |
}, { | |
beat: 59, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 61, | |
comboIndex: 9 | |
}, { | |
beat: 63, | |
length: 1, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 65, | |
comboIndex: 12 | |
}, { | |
beat: 69, | |
comboIndex: 13 | |
}, { | |
beat: 73, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 77, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 79, | |
comboIndex: 15 | |
}, { | |
beat: 81, | |
comboIndex: 13 | |
}, { | |
beat: 85, | |
comboIndex: 11 | |
}, { | |
beat: 89, | |
comboIndex: 12 | |
}, { | |
beat: 93, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 95, | |
comboIndex: 15 | |
}, { | |
beat: 97, | |
comboIndex: 13 | |
}, { | |
beat: 101, | |
comboIndex: 13 | |
}, { | |
beat: 107, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 109, | |
comboIndex: 9 | |
}] | |
}, { | |
length: 98, | |
startDelay: 3, | |
track: [{ | |
beat: 1, | |
comboIndex: 17 | |
}, { | |
beat: 5, | |
comboIndex: 18 | |
}, { | |
beat: 9, | |
comboIndex: 16 | |
}, { | |
beat: 10.5, | |
comboIndex: 10 | |
}, { | |
beat: 13, | |
comboIndex: 21 | |
}, { | |
beat: 15.5, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 21, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 21.25, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 26.5, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 29, | |
comboIndex: 19 | |
}, { | |
beat: 31, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 33, | |
comboIndex: 21 | |
}, { | |
beat: 37, | |
comboIndex: 22 | |
}, { | |
beat: 41, | |
comboIndex: 20 | |
}, { | |
beat: 45, | |
comboIndex: 20 | |
}, { | |
beat: 50.5, | |
comboIndex: 10 | |
}, { | |
beat: 53, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 58, | |
comboIndex: 10 | |
}, { | |
beat: 62, | |
comboIndex: 19 | |
}, { | |
beat: 65, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 67, | |
comboIndex: 9 | |
}, { | |
beat: 71, | |
comboIndex: 23 | |
}, { | |
beat: 73, | |
comboIndex: 21 | |
}, { | |
beat: 77, | |
comboIndex: 22 | |
}, { | |
beat: 83, | |
comboIndex: 9 | |
}, { | |
beat: 85, | |
comboIndex: 21 | |
}, { | |
beat: 87, | |
comboIndex: 23 | |
}, { | |
beat: 89, | |
comboIndex: 22 | |
}, { | |
beat: 91, | |
comboIndex: 9 | |
}, { | |
beat: 94, | |
comboIndex: 19 | |
}, { | |
beat: 96, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}] | |
}, { | |
length: 155, | |
startDelay: 0, | |
track: [{ | |
beat: 3, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 7.5, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 9, | |
comboIndex: 24 | |
}, { | |
beat: 11.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 14.5, | |
comboIndex: 27 | |
}, { | |
beat: 19, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 24, | |
comboIndex: 25 | |
}, { | |
beat: 28, | |
length: 2, | |
directions: [app.Constants.DIRECTIONS.LEFT] | |
}, { | |
beat: 32, | |
comboIndex: 25 | |
}, { | |
beat: 36, | |
comboIndex: 26 | |
}, { | |
beat: 40, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 44, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 48, | |
comboIndex: 24 | |
}, { | |
beat: 52, | |
comboIndex: 25 | |
}, { | |
beat: 56, | |
comboIndex: 26 | |
}, { | |
beat: 60, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 62.5, | |
comboIndex: 28 | |
}, { | |
beat: 66, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 70.5, | |
comboIndex: 28 | |
}, { | |
beat: 74, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 80, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 82, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 86, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 88, | |
comboIndex: 1 | |
}, { | |
beat: 96, | |
comboIndex: 25 | |
}, { | |
beat: 100, | |
comboIndex: 26 | |
}, { | |
beat: 104, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 108, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 112, | |
comboIndex: 24 | |
}, { | |
beat: 116, | |
comboIndex: 25 | |
}, { | |
beat: 120, | |
comboIndex: 26 | |
}, { | |
beat: 124, | |
length: 1.5, | |
directions: [app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 126.5, | |
comboIndex: 28 | |
}, { | |
beat: 130, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 134.5, | |
comboIndex: 28 | |
}, { | |
beat: 138, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 144, | |
directions: [app.Constants.DIRECTIONS.LEFT, app.Constants.DIRECTIONS.RIGHT] | |
}, { | |
beat: 146, | |
directions: [app.Constants.DIRECTIONS.DOWN] | |
}, { | |
beat: 150, | |
directions: [app.Constants.DIRECTIONS.UP] | |
}, { | |
beat: 152, | |
comboIndex: 25 | |
}] | |
}] | |
}, | |
app.Track = function(t) { | |
this.game = t, | |
this.trackPosition = 0, | |
this.message = $(".message", t.elem), | |
this.comboMessage = $(".combo-message", t.elem), | |
this.canvasContainer = $(".arrow-track", t.elem), | |
this.track = $(".track", t.elem), | |
this.arrows = [], | |
this.misses = 0, | |
this.ready = !1, | |
this.level = this.isHoldingKey = this.messageText = this.combos = this.activeCombo = this.bpm = this.multipleArrows = this.lastInCombo = this.points = this.levelFailed = this.isNextComboElfLeft = this.levelEndTrackPosition = null | |
} | |
, | |
app.Track.prototype.initLevel = function(t, e) { | |
for (this.levelFailed = !1, | |
this.trackPosition = this.misses = 0, | |
this.arrows = [], | |
this.comboMessage.removeClass("is-active"), | |
this.message.removeClass("is-active"), | |
this.bpm = e, | |
this.level = app.Levels.levels[t], | |
this.combos = [], | |
t = app.Constants.TRACK_LINE_POSITION[this.game.responsiveKey], | |
e = 0; e < this.level.track.length; e++) { | |
var o = this.level.track[e]; | |
if (void 0 != o.comboIndex) | |
for (var a = app.Levels.combos[o.comboIndex], n = 0; n < a.arrows.length; n++) { | |
var s = a.arrows[n] | |
, s = { | |
combo: e, | |
directions: s.directions, | |
trackLocation: (o.beat + s.beat) * app.Constants.TRACK_PIXELS_PER_BEAT, | |
length: s.length * app.Constants.TRACK_PIXELS_PER_BEAT | |
}; | |
n == a.arrows.length - 1 && (s.lastInCombo = !0, | |
this.combos.push(!0)), | |
this.arrows.push(new app.Arrow(s,this.game.cacheCanvas)) | |
} | |
else | |
this.arrows.push(new app.Arrow({ | |
directions: o.directions, | |
trackLocation: o.beat * app.Constants.TRACK_PIXELS_PER_BEAT, | |
length: o.length * app.Constants.TRACK_PIXELS_PER_BEAT | |
},this.game.cacheCanvas)), | |
this.combos.push(!1) | |
} | |
this.resetComboElf(), | |
this.levelEndTrackPosition = -this.level.length * app.Constants.TRACK_PIXELS_PER_BEAT + t, | |
this.trackPosition = app.Constants.TRACK_PIXELS_PER_BEAT * this.level.startDelay + t, | |
this.renderTrack(), | |
this.ready = !0 | |
} | |
, | |
app.Track.prototype.renderTrack = function() { | |
if (this.level) { | |
var t = app.Constants.CANVAS_MAX_HEIGHT | |
, e = this.level.length * app.Constants.TRACK_PIXELS_PER_BEAT; | |
this.canvases = [], | |
this.canvasContainer.empty(); | |
for (var o = 0; o <= e / t + 1; o++) { | |
var a = $(document.createElement("canvas")); | |
a[0].height = t, | |
a[0].width = this.canvasContainer.width(), | |
this.canvases.push(a), | |
this.canvasContainer.append(a) | |
} | |
for (this.canvasContainer.css("transform", "translateY(" + this.trackPosition + "px)"), | |
t = this.arrows.length - 1; 0 <= t; t--) | |
this.renderArrow(this.arrows[t]) | |
} | |
} | |
, | |
app.Track.prototype.renderArrow = function(t) { | |
var e = app.Constants.ARROW_SIZE[this.game.responsiveKey] | |
, o = app.Constants.CANVAS_MAX_HEIGHT | |
, a = Math.floor((t.location - e / 2) / o) | |
, e = Math.floor((t.location + e / 2 + (t.length || 0)) / o); | |
t.render(this.trackPosition, this.game.responsiveKey, this.canvases[a], a * o), | |
a != e && t.render(this.trackPosition, this.game.responsiveKey, this.canvases[e], e * o) | |
} | |
, | |
app.Track.prototype.checkArrows = function(t) { | |
for (var e, o = [], a = 0; a < t.length; a++) | |
o.push(!1); | |
this.points = 0, | |
this.activeCombo = null; | |
for (var a = {}, n = 0; n < this.arrows.length; a = { | |
keyToPlay: a.keyToPlay | |
}, | |
n++) { | |
var s = this.arrows[n]; | |
if (!s.passed) { | |
var i = this.getArrowBoundaries(s); | |
if (i.arrowPosition > this.track.height() + app.Constants.ARROW_SIZE[this.game.responsiveKey] / 2) | |
break; | |
if (this.arrowInRange(s, i)) { | |
this.lightUpDirections(s), | |
void 0 != s.data.combo && (this.activeCombo = s.data.combo), | |
a.keyToPlay = void 0; | |
var r = !0; | |
s.directions.forEach(function(e) { | |
return function(a, n) { | |
n = t.indexOf(a), | |
0 <= n ? (o[n] = !0, | |
e.keyToPlay = a) : r = !1 | |
} | |
}(a)), | |
r && (s.length && s.caught ? (this.updateDisplayValues(app.Constants.HIT_SCORES.HOLD), | |
this.isHoldingKey || window.santaApp.fire("sound-trigger", { | |
name: "wrapbattle_long", | |
args: [this.bpm] | |
}), | |
this.isHoldingKey = !0) : s.caught || (1 < s.directions.length && (this.multipleArrows = !0), | |
e = this.checkAccuracy(s, i), | |
s.caught = !0, | |
this.renderArrow(s), | |
s.data.lastInCombo && this.combos[s.data.combo] && (this.updateDisplayValues(app.Constants.HIT_SCORES.COMBO), | |
this.registerCombo(!0), | |
this.lastInCombo = !0))), | |
s.length && this.renderArrow(s) | |
} else | |
i.arrowPosition < i.arrowEnd ? (s.passed || (s.passed = !0, | |
s.caught || this.renderArrow(s)), | |
s.caught || (e = app.Track.ACCURACY.MISS, | |
this.misses++, | |
5 < this.misses && !this.levelFailed && (this.levelFailed = !0, | |
this.game.gameover()))) : !r && this.isHoldingKey && (this.isHoldingKey = !1, | |
window.santaApp.fire("sound-trigger", { | |
name: "wrapbattle_stop_long", | |
args: [this.bpm] | |
})) | |
} | |
} | |
0 <= o.indexOf(!1) && (e = app.Track.ACCURACY.MISS), | |
this.registerAccuracy(e) | |
} | |
, | |
app.Track.prototype.getArrowBoundaries = function(t) { | |
var e = {} | |
, o = app.Constants.TRACK_LINE_POSITION[this.game.responsiveKey] - .75 * app.Constants.ARROW_SIZE[this.game.responsiveKey]; | |
return e.arrowBegin = app.Constants.TRACK_LINE_POSITION[this.game.responsiveKey] + .75 * app.Constants.ARROW_SIZE[this.game.responsiveKey], | |
e.arrowEnd = t.length ? o - t.length : o, | |
e.arrowPosition = t.location + this.trackPosition, | |
e | |
} | |
, | |
app.Track.prototype.arrowInRange = function(t, e) { | |
return e || (e = this.getArrowBoundaries(t)), | |
e.arrowPosition > e.arrowEnd && e.arrowPosition < e.arrowBegin | |
} | |
, | |
app.Track.prototype.lightUpDirections = function(t) { | |
t.directions.forEach(function(t) { | |
switch (t) { | |
case app.Constants.DIRECTIONS.UP: | |
this.game.litUpDirections[1] = !0; | |
break; | |
case app.Constants.DIRECTIONS.DOWN: | |
this.game.litUpDirections[2] = !0; | |
break; | |
case app.Constants.DIRECTIONS.LEFT: | |
this.game.litUpDirections[0] = !0; | |
break; | |
case app.Constants.DIRECTIONS.RIGHT: | |
this.game.litUpDirections[3] = !0 | |
} | |
}, this) | |
} | |
, | |
app.Track.prototype.checkAccuracy = function(t, e) { | |
return e || (e = this.getArrowBoundaries(t)), | |
t = Math.abs(e.arrowPosition - app.Constants.TRACK_LINE_POSITION[this.game.responsiveKey]), | |
t < app.Constants.HIT_SCORES.PERFECT.accuracy ? app.Track.ACCURACY.PERFECT : t < app.Constants.HIT_SCORES.GOOD.accuracy ? app.Track.ACCURACY.GOOD : app.Track.ACCURACY.OK | |
} | |
, | |
app.Track.prototype.updateDisplayValues = function(t) { | |
this.points += t.points, | |
this.game.powerUp += t.powerup, | |
this.game.powerUp = Math.max(0, Math.min(1, this.game.powerUp)), | |
t.textKey && (this.messageText = app.I18n.getMsg(t.textKey)) | |
} | |
, | |
app.Track.prototype.registerCombo = function(t) { | |
t && (this.comboMessage.addClass("is-active"), | |
setTimeout(function() { | |
this.comboMessage.removeClass("is-active") | |
} | |
.bind(this), 500)), | |
this.playWrapAnimation(t), | |
this.resetComboElf() | |
} | |
, | |
app.Track.prototype.showAccuracyMessage = function() { | |
this.messageText && (this.message.text(this.messageText), | |
this.message.addClass("is-active"), | |
setTimeout(function() { | |
this.message.removeClass("is-active") | |
} | |
.bind(this), 300)) | |
} | |
, | |
app.Track.prototype.registerAccuracy = function(t) { | |
if (this.messageText = "", | |
t) { | |
var e; | |
switch (t) { | |
case app.Track.ACCURACY.MISS: | |
this.updateDisplayValues(app.Constants.HIT_SCORES.MISS), | |
this.combos[this.activeCombo] && (this.game.animationPlayer.queueAnimation(app.Step.FAIL, this.isNextComboElfLeft), | |
this.combos[this.activeCombo] = !1, | |
e = "wrapbattle_miss", | |
this.registerCombo(!1)); | |
break; | |
case app.Track.ACCURACY.OK: | |
this.updateDisplayValues(app.Constants.HIT_SCORES.OK), | |
this.misses = 0, | |
e = "wrapbattle_correct"; | |
break; | |
case app.Track.ACCURACY.GOOD: | |
this.updateDisplayValues(app.Constants.HIT_SCORES.GOOD), | |
this.misses = 0, | |
e = "wrapbattle_correct"; | |
break; | |
case app.Track.ACCURACY.PERFECT: | |
this.updateDisplayValues(app.Constants.HIT_SCORES.PERFECT), | |
this.misses = 0, | |
e = "wrapbattle_correct" | |
} | |
this.multipleArrows ? (t !== app.Track.ACCURACY.MISS && window.santaApp.fire("sound-trigger", { | |
name: "wrapbattle_correct", | |
args: [this.bpm] | |
}), | |
this.multipleArrows = !1) : this.lastInCombo ? (this.lastInCombo = !1, | |
window.santaApp.fire("sound-trigger", "wrapbattle_correct")) : e && window.santaApp.fire("sound-trigger", e) | |
} | |
this.showAccuracyMessage() | |
} | |
, | |
app.Track.prototype.playWrapAnimation = function(t) { | |
var e = Math.random(); | |
this.game.animationPlayer.playWrapAnimation(t, .33 > e ? app.Step.WRAP_BLUE : .66 > e ? app.Step.WRAP_GREEN : app.Step.WRAP_RED, this.isNextComboElfLeft) | |
} | |
, | |
app.Track.prototype.resetComboElf = function() { | |
this.isNextComboElfLeft = !this.isNextComboElfLeft | |
} | |
, | |
app.Track.prototype.update = function(t) { | |
this.ready && (this.checkArrows(t), | |
this.game.points += this.points, | |
this.game.scoreboard.addScore(this.points), | |
this.game.powerUpActive && (this.game.points += this.points, | |
this.game.scoreboard.addScore(this.points))) | |
} | |
, | |
app.Track.prototype.render = function(t, e) { | |
this.ready && !this.levelFailed && (this.trackPosition -= t / 1e3 / (60 / e) * app.Constants.TRACK_PIXELS_PER_BEAT, | |
this.canvasContainer.css("transform", "translateY(" + this.trackPosition + "px)"), | |
this.trackPosition <= this.levelEndTrackPosition - app.Constants.TRACK_LINE_POSITION[this.game.responsiveKey] && (this.game.onLevelCompleted(), | |
this.ready = !1)) | |
} | |
, | |
app.Track.prototype.cleanUp = function() { | |
this.canvases = [], | |
this.canvasContainer.empty() | |
} | |
, | |
app.Track.ACCURACY = { | |
MISS: 1, | |
OK: 2, | |
GOOD: 3, | |
PERFECT: 4 | |
}, | |
app.Sequencer = function() { | |
this.bar = 0, | |
this.beat = -1, | |
this._variant = 0, | |
this._playScheduled = !1, | |
this._bpm = 120, | |
"audiotag" === Klang.engineVersion && (this._fallback = !0) | |
} | |
, | |
app.Sequencer.prototype.setTrack = function(t) { | |
this._nextTrack = t, | |
this._playScheduled = !0 | |
} | |
, | |
app.Sequencer.prototype.getVariants = function() { | |
return this.tracks.length | |
} | |
, | |
app.Sequencer.prototype.setVariant = function(t) { | |
this._variant = t, | |
this._playScheduled = !0 | |
} | |
, | |
app.Sequencer.prototype.setMaxIntensity = function() { | |
this._transitionToMega = !0, | |
window.santaApp.fire("sound-trigger", "wrapbattle_megamode_start"), | |
window.santaApp.fire("sound-trigger", "wrapbattle_megamode_transition_in") | |
} | |
, | |
app.Sequencer.prototype.setNormalIntensity = function(t) { | |
this._transitionFromMega = !0, | |
window.santaApp.fire("sound-trigger", "wrapbattle_megamode_end"), | |
t && window.santaApp.fire("sound-trigger", "wrapbattle_megamode_transition_out") | |
} | |
, | |
app.Sequencer.prototype.getPlayingLoops = function() { | |
var t = []; | |
if (!this.tracks) | |
return null; | |
for (var e = 0; e < this.tracks.length; e++) | |
this.tracks[e].playing && 0 <= this.tracks[e].position && t.push(this.tracks[e]); | |
if (0 === t.length && this.lastTracks) | |
for (e = 0; e < this.lastTracks.length; e++) | |
this.lastTracks[e].playing && 0 <= this.lastTracks[e].position && t.push(this.lastTracks[e]); | |
return t | |
} | |
, | |
app.Sequencer.prototype.pause = function() { | |
if (this.pausePositions = [], | |
this._fallback && this._currentTrack) { | |
var t = 0 | |
, e = Klang.$(this._currentTrack); | |
e && e._content && (t = e._content[0].position, | |
e._content[0].stop()), | |
this.pausePositions.push(t) | |
} else { | |
if (t = this.getPlayingLoops()) { | |
for (e = 0; e < t.length; e++) | |
this.pausePositions.push(t[e].position); | |
for (this.scheduledStopTime < Klang.Util.now() ? this.scheduledStopTime = 0 : this.scheduledStopTime -= Klang.Util.now(), | |
this.scheduledLoopTime < Klang.Util.now() ? this.scheduledLoopTime = 0 : this.scheduledLoopTime -= Klang.Util.now(), | |
this.pausedSounds = t, | |
e = 0; e < t.length; e++) | |
t[e].stop() | |
} else | |
this.tracks && this.tracks.length && (this.pausedSounds = this.tracks[0]), | |
this.pausePositions = [0, 0, 0], | |
this.scheduledLoopTime = this.scheduledStopTime = 0; | |
if (this.scheduledLoops) | |
for (t = 0; t < this.scheduledLoops.length; t++) | |
this.scheduledLoops[t].stop() | |
} | |
} | |
, | |
app.Sequencer.prototype.resume = function() { | |
if (this._fallback) | |
window.santaApp.fire("sound-trigger", { | |
name: "fallback_" + this._nextTrack, | |
args: [this.pausePositions[0]] | |
}); | |
else { | |
if (this.pausedSounds) | |
for (var t = 0; t < this.pausedSounds.length; t++) | |
this.pausedSounds[t].play(Klang.Util.now(), this.pausePositions[t]), | |
0 < this.scheduledStopTime && this.pausedSounds[t].stop(Klang.Util.now() + this.scheduledStopTime); | |
if (this.scheduledLoops && 0 < this.scheduledLoopTime) | |
for (t = 0; t < this.scheduledLoops.length; t++) | |
this.scheduledLoops[t].play(Klang.Util.now() + this.scheduledLoopTime) | |
} | |
} | |
, | |
app.Sequencer.prototype.play = function(t) { | |
var e = this; | |
if (this._playScheduled) { | |
var o, a = 0; | |
if (this._fallback) { | |
if (this._currentTrack && this._currentTrack !== this._nextTrack) { | |
var n = Klang.$(this._currentTrack); | |
n && n._content && n._content[0].fadeOutAndStop(.2) | |
} | |
this._currentTrack = this._nextTrack, | |
o = { | |
wrapbattle_track01: 80, | |
wrapbattle_track02: 87, | |
wrapbattle_track03: 110, | |
wrapbattle_track04: 140 | |
}[this._currentTrack], | |
window.santaApp.fire("sound-trigger", "fallback_" + this._currentTrack) | |
} else | |
a = this.getPlayingLoops(), | |
n = this._bpm, | |
this._nextTrack && (this.tracks && (this.lastTracks = this.tracks), | |
this.tracks = Klang.$(this._nextTrack)._content, | |
o = Klang.$(this._nextTrack).data.metaData.bpm, | |
a && a.length && (playTransition = !0)), | |
a = this.transition(a, this.tracks, n, 0, .2, 0) - Klang.Util.now(); | |
this._playScheduled = !1, | |
setTimeout(function() { | |
o && (e._bpm = o), | |
t && t() | |
}, 1e3 * a) | |
} | |
} | |
, | |
app.Sequencer.prototype.transition = function(t, e, o, a, n, s) { | |
if (o = o || 120, | |
!e || t === e) | |
return Klang.Util.now(); | |
if (!t) { | |
for (s = 0; s < e.length; s++) | |
e[s].play(Klang.Util.now(), 0, !1); | |
return Klang.Util.now() | |
} | |
for (o = Klang.Util.now() + this.getTimeToNextBar(t, o), | |
this.scheduledLoops = e, | |
this.scheduledLoopTime = o, | |
a = 0; a < t.length; a++) | |
t[a] && t[a].stop(Klang.Util.now()); | |
for (this.scheduledStopTime = o, | |
t = 0; t < e.length; t++) | |
e[t].play(o, s, !1); | |
return o | |
} | |
, | |
app.Sequencer.prototype.getTimeToNextBar = function(t, e) { | |
if (!t) | |
return 0; | |
var o = o || 4 | |
, a = o - e / 60 * ((t[0] ? t[0].position : 0) || 0) % o; | |
return .5 > a && (a += o), | |
e = 60 / e * a, | |
t[0] && !t[0].playing ? e = 0 : t.length || (e = 0), | |
e | |
} | |
, | |
app.Sequencer.prototype.onNextBar = function(t) { | |
var e = this.getPlayingLoops() | |
, o = this.getTimeToNextBar(e, this._bpm); | |
(e && e.length || this._fallback) && window.santaApp.fire("sound-trigger", { | |
name: "wrapbattle_next_level_transition", | |
args: [o] | |
}), | |
setTimeout(function() { | |
t && t() | |
}, 1e3 * o) | |
} | |
, | |
app.Sequencer.prototype.onGameOver = function() { | |
this.stop() | |
} | |
, | |
app.Sequencer.prototype.stop = function() { | |
var t = this.getPlayingLoops(); | |
if (t) | |
for (var e = 0; e < t.length; e++) | |
t[e].fadeOutAndStop(1) | |
} | |
, | |
app.Sequencer.prototype.getBPM = function() { | |
return this._bpm | |
} | |
, | |
app.Sequencer.prototype.update = function() { | |
var t; | |
t = "webaudio" === Klang.engineVersion ? (t = this.getPlayingLoops()) ? t.position : 0 : +new Date / 1e3, | |
t = Math.floor(t / (60 / this._bpm)), | |
this.beat !== t && (this.beat = t, | |
this.play()) | |
} | |
, | |
app.Game = function(t, e) { | |
this.elem = $(t), | |
this.componentDir = e, | |
this.gameStartTime = null, | |
this.isPlaying = this.paused = !1, | |
this.requestId = this.lastFrame = 0, | |
this.lastResponsiveKey = this.responsiveKey = null, | |
this.level = 0, | |
this.imagesLoaded = this.imageNames = this.images = this.powerUpActiveRendered = null, | |
this.scoreboard = new Scoreboard(this,this.elem.find(".board"),app.Levels.levels.length), | |
this.gameoverDialog = new Gameover(this,this.elem.find(".gameover")), | |
this.levelUp = new LevelUp(this,this.elem.find(".levelup"),this.elem.find(".levelup--number")), | |
this.cacheContext = this.cacheCanvas = this.pbContext = this.pbCanvas = this.fgContext = this.fgCanvas = this.bgContext = this.bgCanvas = this.canvases = null, | |
this.initCanvases(), | |
this.leftElf = new app.Character($(".djs--back .dj--left", t)[0],$(".djs--front .dj--left", t)[0],"boy",e,app.Constants.ELF_LEFT_OFFSET), | |
this.rightElf = new app.Character($(".djs--back .dj--right", t)[0],$(".djs--front .dj--right", t)[0],"girl",e,app.Constants.ELF_RIGHT_OFFSET), | |
this.track = new app.Track(this), | |
this.controls = new app.Controls(this), | |
this.powerUp = this.points = 0, | |
this.powerUpActive = !1, | |
this.litUpDirections = [], | |
this.circlePositions = [], | |
this.onFrame_ = this.onFrame_.bind(this), | |
this.audioTracks = ["wrapbattle_track01", "wrapbattle_track02", "wrapbattle_track03", "wrapbattle_track04"], | |
this.sequencer = new app.Sequencer, | |
this.animationPlayer = new app.AnimationPlayer(this.leftElf,this.rightElf,this.sequencer), | |
this.bpmBasedElements = $(".audience-row, .speaker-top, .speaker-bottom") | |
} | |
, | |
goog.exportSymbol("app.Game", app.Game), | |
app.Game.prototype.initCanvases = function() { | |
this.canvases = [], | |
this.bgCanvas = $(".background-canvas", this.elem), | |
this.bgContext = this.bgCanvas[0].getContext("2d"), | |
this.canvases.push(this.bgCanvas), | |
this.fgCanvas = $(".foreground-canvas", this.elem), | |
this.fgContext = this.fgCanvas[0].getContext("2d"), | |
this.canvases.push(this.fgCanvas), | |
this.pbCanvas = $(".power-bar", this.elem), | |
this.pbContext = this.pbCanvas[0].getContext("2d"), | |
this.canvases.push(this.pbCanvas); | |
for (var t = 0; t < this.canvases.length; t++) | |
this.canvases[t][0].width = this.canvases[t].width(), | |
0 != t && (this.canvases[t][0].height = this.canvases[t].height()); | |
this.cacheCanvas = $(document.createElement("canvas")), | |
this.cacheContext = this.cacheCanvas[0].getContext("2d"), | |
this.initCacheCanvas() | |
} | |
, | |
app.Game.prototype.start = function() { | |
window.santaApp.fire("sound-trigger", "wrapbattle_start_game"), | |
this.controls.setup(), | |
$(window).on("resize.wrapbattle", this.onResize_.bind(this)), | |
this.restart() | |
} | |
, | |
goog.exportProperty(app.Game.prototype, "start", app.Game.prototype.start), | |
app.Game.prototype.restart = function() { | |
var t = this; | |
this.onResize_(), | |
this.level = 0, | |
this.scoreboard.reset(), | |
this.points = 0, | |
this.deactivatePowerup(), | |
this.track.cleanUp(), | |
this.sequencer.setTrack(this.audioTracks[0]), | |
this.sequencer.play(function() { | |
t.paused = !1, | |
t.gameStartTime = +new Date, | |
t.track.initLevel(t.level, t.sequencer.getBPM()), | |
t.bpmBasedElements.css("animation-duration", 60 / t.sequencer.getBPM() * 2 + "s"), | |
t.animationPlayer.cleanUp(), | |
t.leftElf.cleanUp(), | |
t.rightElf.cleanUp(), | |
t.unfreezeGame() | |
}), | |
window.santaApp.fire("analytics-track-game-start", { | |
gameid: "wrapbattle" | |
}) | |
} | |
, | |
app.Game.prototype.update = function(t) { | |
this.litUpDirections = [!1, !1, !1, !1], | |
this.track.update(this.controls.keysDown), | |
this.render(t), | |
$(".points").text(this.points), | |
"desktop" === this.responsiveKey && (this.leftElf.update(t), | |
this.rightElf.update(t)), | |
this.powerUp = Math.max(0, Math.min(1, this.powerUp)), | |
1 != this.powerUp || this.powerUpActive || this.activatePowerup(), | |
this.powerUpActive && (this.powerUp -= app.Constants.POWERUP_DECAY, | |
0 >= this.powerUp && this.deactivatePowerup()) | |
} | |
, | |
app.Game.prototype.render = function(t) { | |
this.powerUpActive != this.powerUpActiveRendered && this.drawTrackLine(), | |
this.track.render(t, this.sequencer.getBPM()), | |
this.drawPowerBarFg(), | |
this.drawCircles() | |
} | |
, | |
app.Game.prototype.initCacheCanvas = function() { | |
this.imageNames = ["arrow-up", "arrow-down", "arrow-left", "arrow-right"], | |
this.images = {}, | |
this.imagesLoaded = 0, | |
setTimeout(this.setUpCacheCanvas.bind(this), 1e3), | |
this.imageNames.forEach(this.loadImage.bind(this)) | |
} | |
, | |
app.Game.prototype.loadImage = function(t) { | |
var e = this | |
, o = new Image; | |
o.onload = function() { | |
e.images[t] = o, | |
e.imagesLoaded++, | |
4 == e.imagesLoaded && e.setUpCacheCanvas() | |
} | |
, | |
o.onerror = function() { | |
o.onerror = null, | |
setTimeout(function() { | |
o.src += "?" + +new Date | |
}, 1e3) | |
} | |
, | |
o.src = this.componentDir + ("img/" + t + ".png") | |
} | |
, | |
app.Game.prototype.setUpCacheCanvas = function() { | |
var t = app.Constants.ARROW_SIZE[this.responsiveKey] | |
, e = app.Constants.ARROW_SIZE.desktop + app.Constants.ARROW_MARGIN; | |
this.cacheCanvas[0].height = 4 * e, | |
this.cacheCanvas[0].width = 8 * e, | |
this.cacheContext.fillStyle = app.Constants.COLORS.ARROW_FILL, | |
this.drawCachedArrowRow(0), | |
this.cacheContext.fillStyle = app.Constants.COLORS.ARROW_PASSED_FILL, | |
this.cacheContext.globalAlpha = 1, | |
this.drawCachedArrowRow(2 * e), | |
this.cacheContext.fillStyle = app.Constants.COLORS.ARROW_MULTI_FILL, | |
this.cacheContext.shadowColor = app.Constants.COLORS.ARROW_MULTI_SHADOW, | |
this.cacheContext.shadowBlur = app.Constants.ARROW_MULTI_SHADOW_BLUR, | |
this.cacheContext.shadowOffsetY = app.Constants.ARROW_MULTI_SHADOW_OFFSET, | |
this.cacheContext.save(), | |
this.cacheContext.translate(t / 2, 3 * e + t / 2), | |
this.cacheContext.beginPath(), | |
this.cacheContext.arc(0, 0, t / 2, 0, 2 * Math.PI), | |
this.cacheContext.fill(), | |
this.cacheContext.restore(); | |
for (var o = 0; o < app.Constants.COLORS.ARROW_MULTI_RAINBOW.length; o++) | |
this.cacheContext.fillStyle = app.Constants.COLORS.ARROW_MULTI_RAINBOW[o], | |
this.cacheContext.save(), | |
this.cacheContext.translate(e * (o + 1) + t / 2, 3 * e + t / 2), | |
this.cacheContext.beginPath(), | |
this.cacheContext.arc(0, o, t / 2, 0, 2 * Math.PI), | |
this.cacheContext.fill(), | |
this.cacheContext.restore() | |
} | |
, | |
app.Game.prototype.drawCachedArrowRow = function(t) { | |
for (var e = app.Constants.ARROW_SIZE[this.responsiveKey], o = app.Constants.ARROW_SIZE.desktop + app.Constants.ARROW_MARGIN, a = 0; a < this.imageNames.length; a++) { | |
var n = this.imageNames[a]; | |
this.cacheContext.save(), | |
this.cacheContext.translate(o * a + e / 2, t + e / 2), | |
this.cacheContext.beginPath(), | |
this.cacheContext.arc(0, a, e / 2, 0, 2 * Math.PI), | |
this.cacheContext.fill(), | |
this.cacheContext.drawImage(this.images[n], -app.Constants.ARROW_IMG_WIDTH / 2, -app.Constants.ARROW_IMG_HEIGHT / 2, app.Constants.ARROW_IMG_WIDTH, app.Constants.ARROW_IMG_HEIGHT), | |
this.cacheContext.restore() | |
} | |
} | |
, | |
app.Game.prototype.drawTrackLine = function() { | |
var t = app.Constants.TRACK_LINE_POSITION[this.responsiveKey]; | |
this.bgContext.clearRect(0, 0, this.bgCanvas.width(), this.bgCanvas.height()), | |
this.bgContext.fillStyle = this.powerUpActive ? app.Constants.COLORS.TRACK_LINE_MEGA : app.Constants.COLORS.TRACK_LINE, | |
this.bgContext.fillRect(0, t, this.bgCanvas.width(), 2), | |
this.powerUpActiveRendered = this.powerUpActive | |
} | |
, | |
app.Game.prototype.drawPowerBarBg = function() { | |
this.fgContext.clearRect(0, 0, this.fgCanvas.width(), this.fgCanvas.height()); | |
var t = app.Constants.POWERUP_MARGIN[this.responsiveKey] | |
, e = app.Constants.POWERUP_INNER_MARGIN[this.responsiveKey] | |
, o = app.Constants.POWERUP_HEIGHT[this.responsiveKey] | |
, a = this.fgCanvas.width() - 2 * t; | |
this.fgContext.fillStyle = app.Constants.COLORS.POWERUP_SHADOW, | |
this.fgContext.fillRect(t, t, a, o + 2 * e); | |
var n = t + e | |
, s = t + o / 2 | |
, i = a - 2 * e | |
, t = this.fgContext.createLinearGradient(n, s, t + a - e, s); | |
t.addColorStop(0, app.Constants.COLORS.GRADIENT_START), | |
t.addColorStop(1, app.Constants.COLORS.GRADIENT_END), | |
this.fgContext.fillStyle = t, | |
this.fgContext.fillRect(n, n, i, o) | |
} | |
, | |
app.Game.prototype.drawPowerBarFg = function() { | |
this.pbContext.clearRect(0, 0, this.pbCanvas.width(), this.pbCanvas.height()); | |
var t = app.Constants.POWERUP_MARGIN[this.responsiveKey] | |
, e = app.Constants.POWERUP_INNER_MARGIN[this.responsiveKey] | |
, o = app.Constants.POWERUP_HEIGHT[this.responsiveKey] | |
, a = this.pbCanvas.width() - 2 * t | |
, n = t + e | |
, s = a - 2 * e; | |
this.pbContext.fillStyle = app.Constants.COLORS.POWERUP, | |
this.pbContext.fillRect(t + a - e - s * (1 - this.powerUp), n, s * (1 - this.powerUp), o), | |
this.pbContext.fillStyle = app.Constants.COLORS.POWERUP_SHINE, | |
this.pbContext.fillRect(n, n + app.Constants.POWERUP_SHINE_POSITION, s * this.powerUp, app.Constants.POWERUP_SHINE_HEIGHT[this.responsiveKey]), | |
this.pbContext.fillStyle = app.Constants.COLORS.POWERUP_MARKER, | |
this.pbContext.fillRect(n + s * this.powerUp, n, app.Constants.POWERUP_MARKER_WIDTH[this.responsiveKey], o) | |
} | |
, | |
app.Game.prototype.drawCircles = function() { | |
for (var t = app.Constants.TRACK_LINE_POSITION[this.responsiveKey], e = this.pbContext.canvas.width, o = app.Constants.ARROW_SIZE[this.responsiveKey], a = app.Constants.ARROW_MARGIN, n = 4 * o + 3 * a, s = 0; 4 > s; s++) { | |
var i = (e - n) / 2 + s * (o + a) + o / 2; | |
if (this.pbContext.lineWidth = 2, | |
this.pbContext.strokeStyle = this.powerUpActive ? app.Constants.COLORS.TRACK_LINE_MEGA : app.Constants.COLORS.TRACK_LINE, | |
this.litUpDirections[s]) { | |
var r = this.pbContext.createLinearGradient(i - o / 2, t, i + o / 2, t); | |
r.addColorStop(0, app.Constants.COLORS.GRADIENT_START), | |
r.addColorStop(1, app.Constants.COLORS.GRADIENT_END), | |
this.pbContext.strokeStyle = r | |
} | |
this.circlePositions[s] = i, | |
this.pbContext.beginPath(), | |
this.pbContext.arc(i, t, o / 2, 0, 2 * Math.PI), | |
this.pbContext.stroke() | |
} | |
} | |
, | |
app.Game.prototype.activatePowerup = function() { | |
this.sequencer.setMaxIntensity(), | |
this.elem.addClass("megamode"), | |
this.powerUpActive = !0, | |
this.bpmBasedElements.css("animation-duration", 30 / this.sequencer.getBPM() * 2 + "s") | |
} | |
, | |
app.Game.prototype.deactivatePowerup = function() { | |
this.sequencer.setNormalIntensity(this.powerUpActive), | |
this.elem.removeClass("megamode"), | |
this.powerUpActive = !1, | |
this.powerUp = 0, | |
this.bpmBasedElements.css("animation-duration", 60 / this.sequencer.getBPM() * 2 + "s") | |
} | |
, | |
app.Game.prototype.onLevelCompleted = function() { | |
var t = this; | |
this.level + 1 === app.Levels.levels.length ? this.gameover() : this.sequencer.onNextBar(function() { | |
t.levelUp.show(t.level + 2, t.startNextLevel.bind(t, t.level + 1)) | |
}) | |
} | |
, | |
app.Game.prototype.startNextLevel = function(t) { | |
var e = this; | |
this.level = t, | |
this.points = 0, | |
this.deactivatePowerup(), | |
this.scoreboard.setLevel(this.level), | |
this.track.cleanUp(), | |
this.sequencer.setTrack(this.audioTracks[this.level % this.audioTracks.length]), | |
this.sequencer.play(function() { | |
e.animationPlayer.cleanUp(), | |
e.leftElf.cleanUp(), | |
e.rightElf.cleanUp(), | |
e.track.initLevel(e.level, e.sequencer.getBPM()), | |
e.bpmBasedElements.css("animation-duration", 60 / e.sequencer.getBPM() * 2 + "s") | |
}) | |
} | |
, | |
app.Game.prototype.freezeGame = function() { | |
cancelAnimationFrame(this.requestId), | |
this.isPlaying = !1, | |
this.sequencer.pause(), | |
this.elem.addClass("frozen") | |
} | |
, | |
app.Game.prototype.unfreezeGame = function() { | |
this.isPlaying || (this.elem.removeClass("frozen"), | |
this.isPlaying = !0, | |
this.lastFrame = +new Date, | |
this.requestId = window.requestAnimationFrame(this.onFrame_)) | |
} | |
, | |
app.Game.prototype.onFrame_ = function() { | |
if (this.isPlaying) { | |
var t = +new Date | |
, e = Math.min(1e3, t - this.lastFrame); | |
this.lastFrame = t, | |
this.update(e), | |
this.animationPlayer.update(t / 1e3), | |
this.sequencer.update(), | |
this.requestId = window.requestAnimationFrame(this.onFrame_) | |
} | |
} | |
, | |
app.Game.prototype.pause = function() { | |
this.paused = !0, | |
this.freezeGame() | |
} | |
, | |
app.Game.prototype.resume = function() { | |
this.gameStartTime && this.sequencer.resume(), | |
this.paused = !1, | |
this.unfreezeGame() | |
} | |
, | |
app.Game.prototype.togglePause = function() { | |
this.paused ? this.resume() : this.isPlaying && this.pause() | |
} | |
, | |
app.Game.prototype.onResize_ = function() { | |
var t = 800 > $(window).width() ? "mobile" : "desktop"; | |
for (this.lastResponsiveKey && this.lastResponsiveKey == t || (this.lastResponsiveKey = this.responsiveKey, | |
this.responsiveKey = t, | |
this.setUpCacheCanvas()), | |
t = 0; t < this.canvases.length; t++) | |
this.canvases[t][0].width = this.canvases[t].width(), | |
this.canvases[t][0].height = this.canvases[t].height(); | |
this.drawTrackLine(), | |
this.drawPowerBarBg(), | |
this.leftElf.onResize(), | |
this.rightElf.onResize(), | |
this.track.renderTrack() | |
} | |
, | |
app.Game.prototype.gameover = function() { | |
this.freezeGame(), | |
this.gameoverDialog.show(), | |
this.sequencer.onGameOver(), | |
this.leftElf.cleanUp(), | |
this.rightElf.cleanUp(), | |
this.animationPlayer.cleanUp(), | |
window.santaApp.fire("sound-trigger", "wrapbattle_gameover") | |
} | |
, | |
app.Game.prototype.dispose = function() { | |
this.isPlaying && window.santaApp.fire("analytics-track-game-quit", { | |
gameid: "wrapbattle", | |
timePlayed: new Date - this.gameStartTime, | |
level: 1 | |
}), | |
this.freezeGame(), | |
window.cancelAnimationFrame(this.requestId), | |
$(window).off(".wrapbattle"), | |
$(document).off(".wrapbattle"), | |
this.elem.off(".wrapbattle"), | |
this.levelUp.dispose() | |
} | |
, | |
goog.exportProperty(app.Game.prototype, "dispose", app.Game.prototype.dispose) | |
} | |
.call({ | |
app: scenes.wrapbattle | |
}); | |
!function() { | |
Polymer({ | |
is: "wrapbattle-scene", | |
behaviors: [window.SantaSceneBehavior, window.SantaSceneGameButtonsBehavior], | |
game: null, | |
onPreload: function() { | |
this.preloadSounds("wrapbattle_load_sounds", 30), | |
this.preloadImages(["img/arrow-down.png", "img/arrow-up.png", "img/arrow-left.png", "img/arrow-right.png", "img/scene/crowd-background.png", "img/scene/speaker-boom.svg", "img/scene/speaker-left-corner.svg", "img/scene/speaker-left-corner-foam.png", "img/scene/speaker-right-corner.svg", "img/scene/speaker-right-corner-foam.png", "img/scene/table.svg", "img/scene/turn-tables.svg", "img/scene/wrap-center.png", "img/scene/wrap-left.png", "img/scene/wrap-right.png", "img/steps/boy/fail_0.png", "img/steps/boy/idle_1_0.png", "img/steps/boy/idle_2_0.png", "img/steps/boy/wrap_back_blue_0.png", "img/steps/boy/wrap_back_green_0.png", "img/steps/boy/wrap_back_red_0.png", "img/steps/boy/wrap_front_blue_0.png", "img/steps/boy/wrap_front_green_0.png", "img/steps/boy/wrap_front_red_0.png", "img/steps/girl/fail_0.png", "img/steps/girl/idle_1_0.png", "img/steps/girl/idle_2_0.png", "img/steps/girl/wrap_back_blue_0.png", "img/steps/girl/wrap_back_green_0.png", "img/steps/girl/wrap_back_red_0.png", "img/steps/girl/wrap_front_blue_0.png", "img/steps/girl/wrap_front_green_0.png", "img/steps/girl/wrap_front_red_0.png", "img/presents/gift_blue_false.png", "img/presents/gift_blue_true.png", "img/presents/gift_green_false.png", "img/presents/gift_green_true.png", "img/presents/gift_red_false.png", "img/presents/gift_red_true.png", "img/toys/toys-01.svg", "img/toys/toys-02.svg", "img/toys/toys-03.svg", "img/toys/toys-04.svg", "img/toys/toys-05.svg", "img/toys/toys-06.svg", "img/toys/toys-07.svg", "img/toys/toys-08.svg"]), | |
window.innerWidth <= 800 && this.preloadImages(["img/wrap-battle-mobile.gif"]) | |
}, | |
onShow: function() { | |
var e = this.$["module-wrapbattle"]; | |
this.game = new scenes.wrapbattle.Game(e,this.resolveUrl(".")), | |
this.fire("sound-ambient", "wrapbattle_start") | |
}, | |
onHide: function() { | |
this.game.dispose(), | |
this.game = null, | |
this.fire("sound-ambient", "wrapbattle_end") | |
} | |
}) | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment